修复结算协议查询和费用计算相关问题- 移除了 SltAgreementInfoMapper.xml 中的协议编码模糊查询条件
- 修改了未结算协议的查询逻辑,增加了对 is_slt 字段为空的处理- 修正了租赁费用计算条件,将 > 0 改为 >= 1,确保当天领当天退也能正常计算费用 - 更新了日期计算方法,确保领料日期和退料日期相同时算作 1 天
This commit is contained in:
parent
8d4fc5ce0b
commit
635cabdc90
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1180,9 +1180,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="settlementStatus != null and settlementStatus != ''">
|
||||
AND bai.is_slt = #{settlementStatus}
|
||||
</if>
|
||||
<if test="agreementCode != null and agreementCode != ''">
|
||||
AND bai.agreement_code LIKE CONCAT('%', #{agreementCode}, '%')
|
||||
</if>
|
||||
<if test="unitName != null and unitName != ''">
|
||||
AND bu.unit_name LIKE CONCAT('%', #{unitName}, '%')
|
||||
</if>
|
||||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in New Issue