未结算协议查询修正

This commit is contained in:
syruan 2025-09-01 22:17:27 +08:00
parent 40c7c19aa8
commit 8d79e7c931
3 changed files with 57 additions and 56 deletions

View File

@ -1492,12 +1492,12 @@ public class SltAgreementInfoController extends BaseController {
@GetMapping("/getSltReportList")
public TableDataInfo getSltReportList(SltAgreementInfo query) {
try {
// ----------- 查询列表 ---------------
startPage();
// ----------- 查询未结算的全部协议 ---------------
List<SltAgreementInfo> list = sltAgreementInfoService.getSltReportList(query);
// ----------- 遍历列表设置默认值 ---------------
// ----------- 给查询出来的协议设置权限控制例如只查询工器具 ---------------
Byte settlementType = sltAgreementInfoService.checkLoginUserHasSettlementPermission();
// 设置结算权限,控制展示
list.forEach(info -> info.setSettlementType(settlementType));
// --------- 定义返回集合 ------------------
@ -1508,6 +1508,7 @@ public class SltAgreementInfoController extends BaseController {
// 把每个对象的agreementId设置成集合避免重复查询
list.forEach(info -> {
info.setAgreementIds(AgreementIdsArray);
// 查询每个协议的各项费用明细📉
SltInfoVo vo = sltAgreementInfoService.getSltInfoReportBatch(info);
if (vo != null && !ObjectUtil.isEmpty(vo)) {
vo.setAgreementId(info.getAgreementId());

View File

@ -253,6 +253,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
//费用减免列表
List<SltAgreementReduce> reductionList = getReductionListBatch(info);
// 删除掉各项费用都为空的数据
if (CollectionUtils.isEmpty(leaseList) && CollectionUtils.isEmpty(repairList)
&& CollectionUtils.isEmpty(scrapList) && CollectionUtils.isEmpty(loseList)
&& CollectionUtils.isEmpty(reductionList))
@ -1138,6 +1139,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
Date leaseStartTime = result.getStartTime(); // 领料时间
Date returnTime = result.getEndTime(); // 退料时间
Date settlementTime = result.getSettlementTime(); // 结算时间
String status = result.getStatus(); // 状态
// 如果是已结算协议
boolean leaseInRange = isDateInRange(leaseStartTime, inputStartDate, inputEndDate);
@ -1148,8 +1150,8 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
return leaseInRange || returnInRange || settlementInRange;
} else {
// 如果是未结算协议
// 检查领料时间退料时间是否有任何一个在查询范围内
return leaseInRange || returnInRange;
// 检查领料时间退料时间是否有任何一个在查询范围内或者是在用状态的设备未退还
return leaseInRange || returnInRange || ("0").equals(status);
}
}

View File

@ -856,6 +856,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</if>
<if test="sltStatus != null">
<choose>
<when test="sltStatus == '1'.toString()">
and saa.status = '1'
@ -867,20 +868,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and saa.status = '3'
</when>
</choose>
GROUP BY bai.agreement_id
</if>
GROUP BY bai.agreement_id, saa.settlement_type
ORDER BY saa.create_time desc
</select>
<select id="getSltReportList" resultMap="SltAgreementInfoResult">
SELECT bai.agreement_id, bai.agreement_code as agreementCode, bai.is_slt as isSlt,
SELECT
bai.agreement_id, bai.agreement_code as agreementCode, bai.is_slt as isSlt,
bui.unit_id as unitId,bui.unit_name as unitName, bp.pro_id as projectId , bp.pro_name as projectName,
saa.remark,bai.protocol,saa.cost as costs,
case when (saa.id is null or saa.status = '0') then '0' when saa.status = '1' then '1' when saa.status = '2' then '2' when saa.status = '3' then '3' end as sltStatus
FROM bm_agreement_info bai
FROM
bm_agreement_info bai
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
LEFT JOIN slt_agreement_apply saa on saa.agreement_id = bai.agreement_id
where bai.status = '1' AND bui.type_id != '1731' AND (bai.is_slt = '0' OR bai.is_slt is null)
WHERE
bai.status = '1' AND bui.type_id != '1731'
AND (bai.is_slt = '0' OR bai.is_slt is null)
AND (saa.status is null or saa.status != '2')
<if test="unitIds != null">
and bui.unit_id in
<foreach item="item" index="index" collection="unitIds" open="(" separator="," close=")">
@ -955,19 +962,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getLoseListBatch" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
SELECT
res.agreementId,
res.unitName,
res.projectName,
res.companyId,
res.typeId,
res.typeName,
res.modelName,
res.mtUnitName,
res.buyPrice,
SUM(res.num) as num,
res.startTime,
res.endTime,
res.leaseDays
res.agreementId, res.unitName, res.projectName, res.companyId, res.typeId,
res.typeName, res.modelName, res.mtUnitName, res.buyPrice, res.startTime, res.endTime, res.leaseDays,
SUM(res.num) as num
FROM
(
select sai.id,
@ -1002,7 +999,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and mt.jiju_type = #{settlementType}
</if>
) res
GROUP BY res.typeId
GROUP BY res.typeId, res.agreementId
</select>
<select id="getRepairDetailsListBatch" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
@ -1203,10 +1200,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
OR (sai.slt_time IS NOT NULL AND sai.slt_time BETWEEN #{startDate} AND #{endDate})
))
OR
<!-- 未结算协议:领料时间、退料时间中至少有一个在查询范围内 -->
<!-- 未结算协议:领料时间、退料时间中至少有一个在查询范围内 或者设备状态为在用-->
(bai.is_slt = 0 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')
))
)
</where>