diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java index 855c7753..c5ba5d52 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java @@ -1264,8 +1264,9 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { // 消耗性物资直接计算购置价 result.setConsumeCost(result.getNum().multiply(Optional.ofNullable(result.getBuyPrice()).orElse(BigDecimal.ZERO))); } - if (result.getNum() != null && result.getLeasePrice() != null && leaseDays > 0) { + if (result.getNum() != null && result.getLeasePrice() != null && leaseDays >= 1) { // 非消耗性物资按照租赁单价计算租赁费用 + // 修复:改为 >= 1,确保当天领当天退(1天)也能正常计算费用 leaseCost = result.getNum().multiply(result.getLeasePrice()).multiply(new BigDecimal(leaseDays)).setScale(2, RoundingMode.HALF_UP); } @@ -1380,7 +1381,8 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { /** * 计算两个日期之间的天数(包含起始和结束日期) * 只计算日期,不考虑具体时间 - * 例如:8月15日~8月16日 = 2天 + * 例如:8月15日~8月16日 = 2天,当天领当天退 = 1天 + * 修复说明:确保当领料日期和退料日期相同时,无论时间如何,都算作1天 * * @param startDate 开始日期 * @param endDate 结束日期 @@ -1395,9 +1397,10 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { return 0; } - // 使用Calendar来确保只计算日期部分,忽略时间 + // 使用Calendar来确保只计算日期部分,完全忽略时间 Calendar startCal = Calendar.getInstance(); startCal.setTime(startDate); + // 将开始时间设为当天00:00:00.000 startCal.set(Calendar.HOUR_OF_DAY, 0); startCal.set(Calendar.MINUTE, 0); startCal.set(Calendar.SECOND, 0); @@ -1405,16 +1408,18 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { Calendar endCal = Calendar.getInstance(); endCal.setTime(endDate); + // 将结束时间设为当天00:00:00.000 endCal.set(Calendar.HOUR_OF_DAY, 0); endCal.set(Calendar.MINUTE, 0); endCal.set(Calendar.SECOND, 0); endCal.set(Calendar.MILLISECOND, 0); - // 计算天数差异 + // 计算天数差异(现在比较的是日期,不包含时间) long diffInMillies = endCal.getTimeInMillis() - startCal.getTimeInMillis(); long diffInDays = diffInMillies / (24 * 60 * 60 * 1000); // 包含起始和结束日期,所以要加1 + // 即使是同一天(diffInDays=0),加1后也是1天,符合需求 return diffInDays + 1; } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml index fd6eeb20..a856918f 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/settlement/SltAgreementInfoMapper.xml @@ -1180,9 +1180,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND bai.is_slt = #{settlementStatus} - - AND bai.agreement_code LIKE CONCAT('%', #{agreementCode}, '%') - AND bu.unit_name LIKE CONCAT('%', #{unitName}, '%') @@ -1202,7 +1199,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" )) OR - (bai.is_slt = 0 AND ( + ((bai.is_slt = 0 or bai.is_slt IS NULL) AND ( (sai.start_time IS NOT NULL AND sai.start_time BETWEEN #{startDate} AND #{endDate}) OR (sai.end_time IS NOT NULL AND sai.end_time BETWEEN #{startDate} AND #{endDate}) OR (sai.status = '0')