i皖送推送修改
This commit is contained in:
parent
c124f9f4fb
commit
ae8560feb7
|
|
@ -538,14 +538,14 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
||||||
details.setStatus(PurchaseTaskStatusEnum.TO_STORE.getStatus());
|
details.setStatus(PurchaseTaskStatusEnum.TO_STORE.getStatus());
|
||||||
}
|
}
|
||||||
details.setCheckUser(SecurityUtils.getUserId());
|
details.setCheckUser(SecurityUtils.getUserId());
|
||||||
result = purchaseCheckDetailsMapper.updatePurchaseDetails4Check(details) > 0 ? AjaxResult.success("detail验证成功") : AjaxResult.error("details无验证信息");
|
result = 0 < purchaseCheckDetailsMapper.updatePurchaseDetails4Check(details) ? AjaxResult.success("验收成功") : AjaxResult.error("details无验证信息");
|
||||||
extractedFile(details);
|
extractedFile(details);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 验收驳回处理流程
|
// 验收驳回处理流程
|
||||||
for (PurchaseCheckDetails details : purchaseVerifyVo.getPurchaseCheckDetailsList()) {
|
for (PurchaseCheckDetails details : purchaseVerifyVo.getPurchaseCheckDetailsList()) {
|
||||||
details.setStatus(PurchaseTaskStatusEnum.TO_CHECK_AFTER_REJECT.getStatus());
|
details.setStatus(PurchaseTaskStatusEnum.TO_CHECK_AFTER_REJECT.getStatus());
|
||||||
result = 0 < purchaseCheckDetailsMapper.updatePurchaseDetails4Check(details) ? AjaxResult.success("detail验证驳回成功") : AjaxResult.error("details无验证信息");
|
result = 0 < purchaseCheckDetailsMapper.updatePurchaseDetails4Check(details) ? AjaxResult.success("驳回成功") : AjaxResult.error("details无验证信息");
|
||||||
extractedFile(details);
|
extractedFile(details);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.bonus.material.push.controller;
|
||||||
|
|
||||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||||
import com.bonus.common.core.web.controller.BaseController;
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.common.core.web.page.TableDataInfo;
|
import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
import com.bonus.material.push.domain.IwsCostPushBean;
|
import com.bonus.material.push.domain.IwsCostPushBean;
|
||||||
import com.bonus.material.push.service.IwsCostPushService;
|
import com.bonus.material.push.service.IwsCostPushService;
|
||||||
|
|
@ -13,7 +14,9 @@ import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : 阮世耀
|
* @author : 阮世耀
|
||||||
|
|
@ -54,7 +57,6 @@ public class IwsCostPushController extends BaseController {
|
||||||
util.exportExcel(response, list, "协议推送匹配");
|
util.exportExcel(response, list, "协议推送匹配");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询费用推送审核列表
|
* 查询费用推送审核列表
|
||||||
* @param obj 查询条件
|
* @param obj 查询条件
|
||||||
|
|
@ -67,4 +69,27 @@ public class IwsCostPushController extends BaseController {
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据协议ID及月份查询当月租赁费用明细
|
||||||
|
* @param obj 查询条件
|
||||||
|
* @return 分页数据
|
||||||
|
*/
|
||||||
|
@GetMapping("/getLeaseCostsByAgreementIdAndMonth")
|
||||||
|
@ApiOperation("根据协议ID及月份查询当月租赁费用明细--分页")
|
||||||
|
public TableDataInfo getLeaseCostsByAgreementIdAndMonth(IwsCostPushBean obj) {
|
||||||
|
if (Objects.isNull(obj) || Objects.isNull(obj.getAgreementId()) || Objects.isNull(obj.getMonth())) {
|
||||||
|
System.err.println("查询信息为空 = " + obj);
|
||||||
|
return getDataTable(Collections.emptyList());
|
||||||
|
}
|
||||||
|
//startPage(); 取消分页
|
||||||
|
List<IwsCostPushBean> list = iwsCostPushService.getLeaseCostsByAgreementIdAndMonth(obj);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/computeTheMonthCost")
|
||||||
|
@ApiOperation("计算当月费用")
|
||||||
|
public AjaxResult computeTheMonthCost(@Valid @RequestBody IwsCostPushBean obj) {
|
||||||
|
return iwsCostPushService.computeTheMonthCost(obj);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import lombok.Data;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -45,18 +46,33 @@ public class IwsCostPushBean implements Serializable {
|
||||||
@Excel(name = "单位名称", sort = 2)
|
@Excel(name = "单位名称", sort = 2)
|
||||||
private String unitName;
|
private String unitName;
|
||||||
|
|
||||||
|
// 物资类型
|
||||||
private String typeName;
|
private String typeName;
|
||||||
|
|
||||||
|
// 规格型号
|
||||||
private String modelName;
|
private String modelName;
|
||||||
|
|
||||||
|
// 物资类型id
|
||||||
|
private Integer typeId;
|
||||||
|
|
||||||
|
// 数量
|
||||||
private String num;
|
private String num;
|
||||||
|
|
||||||
|
// 领用数量
|
||||||
|
private BigDecimal leaseNum;
|
||||||
|
|
||||||
// 领料日期
|
// 领料日期
|
||||||
private String leaseDate;
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private LocalDateTime leaseDate;
|
||||||
|
|
||||||
private String backDate;
|
// 领用天数
|
||||||
|
private Integer leaseDays;
|
||||||
|
|
||||||
private String leaseMoney;
|
// 退料日期
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private LocalDateTime backDate;
|
||||||
|
|
||||||
|
private BigDecimal leaseMoney;
|
||||||
|
|
||||||
private String lostMoney;
|
private String lostMoney;
|
||||||
|
|
||||||
|
|
@ -74,6 +90,7 @@ public class IwsCostPushBean implements Serializable {
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
// 原值
|
||||||
private String buyPrice;
|
private String buyPrice;
|
||||||
|
|
||||||
// 是否推送
|
// 是否推送
|
||||||
|
|
@ -90,7 +107,7 @@ public class IwsCostPushBean implements Serializable {
|
||||||
|
|
||||||
// 结算时间
|
// 结算时间
|
||||||
@Excel(name = "结算时间", dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 7)
|
@Excel(name = "结算时间", dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 7)
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private LocalDateTime settlementTime;
|
private LocalDateTime settlementTime;
|
||||||
|
|
||||||
// 是否匹配
|
// 是否匹配
|
||||||
|
|
@ -99,8 +116,6 @@ public class IwsCostPushBean implements Serializable {
|
||||||
|
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
private List<String> ids;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "审核状态")
|
@ApiModelProperty(value = "审核状态")
|
||||||
private Byte checkStatus;
|
private Byte checkStatus;
|
||||||
|
|
||||||
|
|
@ -108,4 +123,13 @@ public class IwsCostPushBean implements Serializable {
|
||||||
private String pushRemark;
|
private String pushRemark;
|
||||||
|
|
||||||
private String companyId;
|
private String companyId;
|
||||||
|
|
||||||
|
// 开始时间
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
// 结束时间
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
|
// 是否删除 false未删除 true已删除
|
||||||
|
private boolean delFlag = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ public interface IwsCostPushMapper {
|
||||||
List<IwsCostPushBean> findAgreement(IwsCostPushBean o);
|
List<IwsCostPushBean> findAgreement(IwsCostPushBean o);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新协议push状态
|
* 更新协议信息表的push状态
|
||||||
*/
|
*/
|
||||||
int updateAgreementIsPush(IwsCostPushBean o);
|
int updateAgreementIsPush(IwsCostPushBean o);
|
||||||
|
|
||||||
|
|
@ -29,4 +29,15 @@ public interface IwsCostPushMapper {
|
||||||
* 查询费用推送审核数据列表
|
* 查询费用推送审核数据列表
|
||||||
*/
|
*/
|
||||||
List<IwsCostPushBean> getCostPushCheckList(IwsCostPushBean o);
|
List<IwsCostPushBean> getCostPushCheckList(IwsCostPushBean o);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入Calc表当前月份
|
||||||
|
*/
|
||||||
|
int insertCalcMonthRecord(IwsCostPushBean record);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据协议ID查询领用物资数据
|
||||||
|
* @param record 协议信息及条件
|
||||||
|
*/
|
||||||
|
List<IwsCostPushBean> getPaidSltBaseInfo(IwsCostPushBean record);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.bonus.material.push.service;
|
package com.bonus.material.push.service;
|
||||||
|
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.material.push.domain.IwsCostPushBean;
|
import com.bonus.material.push.domain.IwsCostPushBean;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -23,4 +24,14 @@ public interface IwsCostPushService {
|
||||||
* 查询费用推送审核数据列表
|
* 查询费用推送审核数据列表
|
||||||
*/
|
*/
|
||||||
List<IwsCostPushBean> getCostPushCheckList(IwsCostPushBean o);
|
List<IwsCostPushBean> getCostPushCheckList(IwsCostPushBean o);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算月结费用
|
||||||
|
*/
|
||||||
|
AjaxResult computeTheMonthCost(IwsCostPushBean costDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据协议ID及月份查询当月租赁费用明细
|
||||||
|
*/
|
||||||
|
List<IwsCostPushBean> getLeaseCostsByAgreementIdAndMonth(IwsCostPushBean record);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,25 @@
|
||||||
package com.bonus.material.push.service.impl;
|
package com.bonus.material.push.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||||
|
import com.bonus.common.biz.config.DateTimeHelper;
|
||||||
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.material.push.domain.IwsCostPushBean;
|
import com.bonus.material.push.domain.IwsCostPushBean;
|
||||||
import com.bonus.material.push.mapper.IwsCostPushMapper;
|
import com.bonus.material.push.mapper.IwsCostPushMapper;
|
||||||
import com.bonus.material.push.service.IwsCostPushService;
|
import com.bonus.material.push.service.IwsCostPushService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.time.temporal.TemporalAdjusters;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : 阮世耀
|
* @author : 阮世耀
|
||||||
|
|
@ -41,4 +53,208 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
|
||||||
public List<IwsCostPushBean> getCostPushCheckList(IwsCostPushBean o) {
|
public List<IwsCostPushBean> getCostPushCheckList(IwsCostPushBean o) {
|
||||||
return iwsCostPushMapper.getCostPushCheckList(o);
|
return iwsCostPushMapper.getCostPushCheckList(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算月结费用
|
||||||
|
*
|
||||||
|
* @param costDto IwsCostPushBean对象,包含月结费用计算的所需信息
|
||||||
|
* @return 返回一个AjaxResult对象,包含月结费用计算的结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult computeTheMonthCost(IwsCostPushBean costDto) {
|
||||||
|
|
||||||
|
// 获取当月第一天的日期和最后一天日期
|
||||||
|
String firstDay = DateTimeHelper.getFirstDay();
|
||||||
|
String lastDay = DateTimeHelper.getLastDay();
|
||||||
|
// 获取当前年月 2025-01
|
||||||
|
String month = DateTimeHelper.getNowMonth();
|
||||||
|
|
||||||
|
costDto.setMonth(month);
|
||||||
|
costDto.setStartTime(firstDay);
|
||||||
|
costDto.setEndTime(lastDay);
|
||||||
|
|
||||||
|
// 清除旧的费用计算数据
|
||||||
|
// cleanSameMonthOldRecords(record);
|
||||||
|
|
||||||
|
// 插入新的当前月份记录,并生成
|
||||||
|
iwsCostPushMapper.insertCalcMonthRecord(costDto);
|
||||||
|
|
||||||
|
String taskId = costDto.getId();
|
||||||
|
|
||||||
|
// 查询协议信息列表
|
||||||
|
List<IwsCostPushBean> agreementList = iwsCostPushMapper.findAgreement(costDto);
|
||||||
|
|
||||||
|
// 处理数据
|
||||||
|
computeMonthInfoDetail(agreementList, costDto, taskId, month);
|
||||||
|
|
||||||
|
// TODO 未完成费用结算 待完善
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据协议ID及月份查询当月租赁费用明细
|
||||||
|
*
|
||||||
|
* @param record 查询信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<IwsCostPushBean> getLeaseCostsByAgreementIdAndMonth(IwsCostPushBean record) {
|
||||||
|
if (Objects.isNull(record) || Objects.isNull(record.getMonth()) || Objects.isNull(record.getAgreementId())) {
|
||||||
|
System.err.println("查询信息为空 = " + record);
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取前端传入对应年月的第一天与最后一天的LocalDateTime对象
|
||||||
|
LocalDateTime queryStartTime = getFirstDayOfMonth(record.getMonth());
|
||||||
|
LocalDateTime queryEndTime = getLastDayOfMonthZ(record.getMonth());
|
||||||
|
|
||||||
|
List<IwsCostPushBean> theMonthAgreementLeaseList = iwsCostPushMapper.getPaidSltBaseInfo(record);
|
||||||
|
if (CollectionUtils.isEmpty(theMonthAgreementLeaseList)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
} else {
|
||||||
|
// 过滤异常数据
|
||||||
|
theMonthAgreementLeaseList.removeIf(item ->
|
||||||
|
Objects.isNull(item) ||
|
||||||
|
Objects.isNull(item.getTypeId()) ||
|
||||||
|
Objects.isNull(item.getLeaseNum()) ||
|
||||||
|
Objects.isNull(item.getLeasePrice())
|
||||||
|
);
|
||||||
|
for (IwsCostPushBean leaseCostInfo : theMonthAgreementLeaseList) {
|
||||||
|
if (null == leaseCostInfo.getLeaseDate()) { continue; }
|
||||||
|
if (null == leaseCostInfo.getBackDate()) { leaseCostInfo.setBackDate(queryEndTime); }
|
||||||
|
|
||||||
|
// 校准计算后的日期
|
||||||
|
if (leaseCostInfo.getLeaseDate().isBefore(queryStartTime)) {
|
||||||
|
leaseCostInfo.setLeaseDate(queryStartTime);
|
||||||
|
} else if (leaseCostInfo.getLeaseDate().isAfter(queryEndTime)) {
|
||||||
|
leaseCostInfo.setLeaseDays(0);
|
||||||
|
leaseCostInfo.setDelFlag(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (leaseCostInfo.getBackDate().isAfter(queryEndTime)) {
|
||||||
|
leaseCostInfo.setBackDate(queryEndTime);
|
||||||
|
} else if (leaseCostInfo.getBackDate().isBefore(queryStartTime)) {
|
||||||
|
leaseCostInfo.setLeaseDays(0);
|
||||||
|
leaseCostInfo.setDelFlag(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算天数
|
||||||
|
leaseCostInfo.setLeaseDays(Math.toIntExact(calculateDaysInclusive(leaseCostInfo.getLeaseDate(), leaseCostInfo.getBackDate())));
|
||||||
|
// 计算费用
|
||||||
|
leaseCostInfo.setLeaseMoney(new BigDecimal(leaseCostInfo.getLeaseDays())
|
||||||
|
.multiply(new BigDecimal(leaseCostInfo.getLeasePrice()))
|
||||||
|
.multiply(leaseCostInfo.getLeaseNum())
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
return theMonthAgreementLeaseList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算月结费用详情
|
||||||
|
* @param agreementList 协议集合
|
||||||
|
* @param costDto 要进行结算的信息
|
||||||
|
* @param taskId 任务id
|
||||||
|
* @param month 月份
|
||||||
|
*/
|
||||||
|
private void computeMonthInfoDetail(List<IwsCostPushBean> agreementList, IwsCostPushBean costDto, String taskId, String month) {
|
||||||
|
if (null == agreementList || agreementList.isEmpty()) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
System.out.println("agreementList = " + agreementList);
|
||||||
|
for (IwsCostPushBean agreement : agreementList) {
|
||||||
|
updatePushStatus(agreement);
|
||||||
|
BigDecimal changeMoney = BigDecimal.ZERO;
|
||||||
|
IwsCostPushBean bean = new IwsCostPushBean();
|
||||||
|
bean.setAgreementId(agreement.getAgreementId());
|
||||||
|
|
||||||
|
// 查询领料费用
|
||||||
|
List<IwsCostPushBean> baseInfo = iwsCostPushMapper.getPaidSltBaseInfo(bean);
|
||||||
|
List<IwsCostPushBean> l = new ArrayList<>();
|
||||||
|
|
||||||
|
if (null != baseInfo && !baseInfo.isEmpty()) {
|
||||||
|
l = baseInfo;
|
||||||
|
} else {
|
||||||
|
System.err.println("baseInfo为空 = " + baseInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!l.isEmpty()) {
|
||||||
|
// TODO 待完善
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新协议推送状态
|
||||||
|
*
|
||||||
|
* @param bean IwsCostPushBean对象,包含推送状态更新的信息
|
||||||
|
*/
|
||||||
|
private void updatePushStatus(IwsCostPushBean bean) {
|
||||||
|
String isPush = checkPush(bean) ? "0" : "1";
|
||||||
|
bean.setIsPush(isPush);
|
||||||
|
iwsCostPushMapper.updateAgreementIsPush(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查是否需要推送,包含大件及机械化的不需要进行push
|
||||||
|
* return true 需要推送, false 不需要推送
|
||||||
|
*/
|
||||||
|
private boolean checkPush(IwsCostPushBean o) {
|
||||||
|
return o.getUnitName().contains("大件") || o.getUnitName().contains("机械化") || StringUtils.isEmpty(o.getProjectId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字符串形式的年月获取当月的第一天
|
||||||
|
*
|
||||||
|
* @param yearMonth 字符串形式的年月,格式为 "yyyy-MM" 例如 2024-09
|
||||||
|
* @return 当月的第一天的 LocalDateTime 对象,时间部分为 00:00:00
|
||||||
|
*/
|
||||||
|
public static LocalDateTime getFirstDayOfMonth(String yearMonth) {
|
||||||
|
// 解析字符串为 LocalDate
|
||||||
|
LocalDate date = LocalDate.parse(yearMonth + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
|
// 获取当月的第一天
|
||||||
|
LocalDate firstDay = date.with(TemporalAdjusters.firstDayOfMonth());
|
||||||
|
// 转换为 LocalDateTime,时间部分为 00:00:00
|
||||||
|
return firstDay.atStartOfDay();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字符串形式的年月获取当月的最后一天
|
||||||
|
*
|
||||||
|
* @param yearMonth 字符串形式的年月,格式为 "yyyy-MM" 例如 2024-09
|
||||||
|
* @return 当月的最后一天的 LocalDateTime 对象,时间部分为 23:59:59
|
||||||
|
*/
|
||||||
|
public static LocalDateTime getLastDayOfMonthZ(String yearMonth) {
|
||||||
|
// 解析字符串为 LocalDate
|
||||||
|
LocalDate date = LocalDate.parse(yearMonth + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
|
// 获取当月的最后一天
|
||||||
|
LocalDate lastDay = date.with(TemporalAdjusters.lastDayOfMonth());
|
||||||
|
// 转换为 LocalDateTime,时间部分为 23:59:59
|
||||||
|
return lastDay.atTime(23, 59, 59);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算两个 LocalDateTime 之间的天数(当天开始和当天结束的情况也算1天)
|
||||||
|
*
|
||||||
|
* @param start 开始时间
|
||||||
|
* @param end 结束时间
|
||||||
|
* @return 天数差(包括当天)
|
||||||
|
*/
|
||||||
|
public static long calculateDaysInclusive(LocalDateTime start, LocalDateTime end) {
|
||||||
|
// 如果结束时间早于开始时间,交换两者
|
||||||
|
if (end.isBefore(start)) {
|
||||||
|
LocalDateTime temp = start;
|
||||||
|
start = end;
|
||||||
|
end = temp;
|
||||||
|
}
|
||||||
|
// 计算完整天数差
|
||||||
|
long daysBetween = ChronoUnit.DAYS.between(start.toLocalDate(), end.toLocalDate());
|
||||||
|
// 如果结束时间的时间部分晚于或等于开始时间的时间部分,则加 1 天
|
||||||
|
if (!end.toLocalTime().isBefore(start.toLocalTime())) {daysBetween += 1;}
|
||||||
|
|
||||||
|
return daysBetween;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
<select id="findAgreement" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
<select id="findAgreement" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
||||||
SELECT
|
SELECT
|
||||||
bp.pro_id AS projectId,
|
bp.pro_id AS projectId, bp.pro_name AS projectName, bp.pro_code AS projectCode,
|
||||||
bp.pro_name AS projectName,
|
|
||||||
bp.pro_code AS projectCode,
|
|
||||||
bu.unit_name AS unitName,
|
bu.unit_name AS unitName,
|
||||||
bma.`agreement_code` AS agreementCode,
|
bma.agreement_id AS agreementId,bma.`agreement_code` AS agreementCode, bma.is_slt AS isSettlement,
|
||||||
bma.is_slt AS isSettlement,
|
bma.sign_time AS settlementTime, bma.is_push AS isPush
|
||||||
bma.sign_time AS settlementTime,
|
|
||||||
bma.is_push AS isPush
|
|
||||||
FROM bm_agreement_info bma
|
FROM bm_agreement_info bma
|
||||||
LEFT JOIN bm_project bp ON bp.pro_id = bma.project_id
|
LEFT JOIN bm_project bp ON bp.pro_id = bma.project_id
|
||||||
LEFT JOIN bm_unit bu ON bu.unit_id = bma.unit_id
|
LEFT JOIN bm_unit bu ON bu.unit_id = bma.unit_id
|
||||||
|
|
@ -34,15 +30,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
AND bma.is_slt = #{isSettlement}
|
AND bma.is_slt = #{isSettlement}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
GROUP BY bma.agreement_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="updateAgreementIsPush">
|
<update id="updateAgreementIsPush">
|
||||||
UPDATE bm_agreement_info
|
UPDATE bm_agreement_info SET is_push = #{isPush} WHERE agreement_id = #{agreementId}
|
||||||
SET is_push = #{isPush}
|
|
||||||
WHERE agreement_id IN
|
|
||||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="getCostPushCheckList" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
<select id="getCostPushCheckList" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
||||||
|
|
@ -81,4 +73,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
GROUP BY
|
GROUP BY
|
||||||
pmc.AGREEMENT_ID
|
pmc.AGREEMENT_ID
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertCalcMonthRecord" parameterType="com.bonus.material.push.domain.IwsCostPushBean" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
INSERT INTO calc_project_month (MONTH)
|
||||||
|
VALUES (#{month})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="getPaidSltBaseInfo" resultType="com.bonus.material.push.domain.IwsCostPushBean">
|
||||||
|
SELECT
|
||||||
|
mt1.type_name as typeName,
|
||||||
|
mt.type_name as modelName,
|
||||||
|
mt.unit_name AS unitName,
|
||||||
|
sai.lease_price as leasePrice,
|
||||||
|
bma.agreement_id AS agreementId,sai.type_id as typeId,
|
||||||
|
IFNULL(mt.lease_price ,0) as nowLeasePrice,
|
||||||
|
sai.buy_price as buyPrice,sai.num AS leaseNum,sai.start_time AS leaseDate,sai.end_time AS backDate,
|
||||||
|
IF(sai.`status` = 0,sai.num,0) as returnNum,
|
||||||
|
(datediff(sai.end_time,sai.start_time)+1) * (sai.num) * (sai.lease_price) AS leaseMoney,
|
||||||
|
bma.`agreement_code` AS agreementCode,bma.project_id as projectId,
|
||||||
|
bma.is_slt AS isSettlement,
|
||||||
|
bma.sign_time AS settlementTime,
|
||||||
|
bma.is_push AS isPush
|
||||||
|
FROM bm_agreement_info bma
|
||||||
|
LEFT JOIN slt_agreement_info sai ON bma.agreement_id = sai.agreement_id
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
|
||||||
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||||
|
where bma.agreement_id = #{agreementId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue