未结算协议查询修正
This commit is contained in:
parent
40c7c19aa8
commit
8d79e7c931
|
|
@ -1492,12 +1492,12 @@ public class SltAgreementInfoController extends BaseController {
|
||||||
@GetMapping("/getSltReportList")
|
@GetMapping("/getSltReportList")
|
||||||
public TableDataInfo getSltReportList(SltAgreementInfo query) {
|
public TableDataInfo getSltReportList(SltAgreementInfo query) {
|
||||||
try {
|
try {
|
||||||
// ----------- 查询列表 ---------------
|
startPage();
|
||||||
|
// ----------- 查询未结算的全部协议 ---------------
|
||||||
List<SltAgreementInfo> list = sltAgreementInfoService.getSltReportList(query);
|
List<SltAgreementInfo> list = sltAgreementInfoService.getSltReportList(query);
|
||||||
|
|
||||||
// ----------- 遍历列表,设置默认值 ---------------
|
// ----------- 给查询出来的协议设置权限控制(例如只查询工器具) ---------------
|
||||||
Byte settlementType = sltAgreementInfoService.checkLoginUserHasSettlementPermission();
|
Byte settlementType = sltAgreementInfoService.checkLoginUserHasSettlementPermission();
|
||||||
// 设置结算权限,控制展示
|
|
||||||
list.forEach(info -> info.setSettlementType(settlementType));
|
list.forEach(info -> info.setSettlementType(settlementType));
|
||||||
|
|
||||||
// --------- 定义返回集合 ------------------
|
// --------- 定义返回集合 ------------------
|
||||||
|
|
@ -1508,6 +1508,7 @@ public class SltAgreementInfoController extends BaseController {
|
||||||
// 把每个对象的agreementId设置成集合,避免重复查询
|
// 把每个对象的agreementId设置成集合,避免重复查询
|
||||||
list.forEach(info -> {
|
list.forEach(info -> {
|
||||||
info.setAgreementIds(AgreementIdsArray);
|
info.setAgreementIds(AgreementIdsArray);
|
||||||
|
// 查询每个协议的各项费用明细📉
|
||||||
SltInfoVo vo = sltAgreementInfoService.getSltInfoReportBatch(info);
|
SltInfoVo vo = sltAgreementInfoService.getSltInfoReportBatch(info);
|
||||||
if (vo != null && !ObjectUtil.isEmpty(vo)) {
|
if (vo != null && !ObjectUtil.isEmpty(vo)) {
|
||||||
vo.setAgreementId(info.getAgreementId());
|
vo.setAgreementId(info.getAgreementId());
|
||||||
|
|
|
||||||
|
|
@ -253,6 +253,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||||
//费用减免列表
|
//费用减免列表
|
||||||
List<SltAgreementReduce> reductionList = getReductionListBatch(info);
|
List<SltAgreementReduce> reductionList = getReductionListBatch(info);
|
||||||
|
|
||||||
|
// 删除掉各项费用都为空的数据
|
||||||
if (CollectionUtils.isEmpty(leaseList) && CollectionUtils.isEmpty(repairList)
|
if (CollectionUtils.isEmpty(leaseList) && CollectionUtils.isEmpty(repairList)
|
||||||
&& CollectionUtils.isEmpty(scrapList) && CollectionUtils.isEmpty(loseList)
|
&& CollectionUtils.isEmpty(scrapList) && CollectionUtils.isEmpty(loseList)
|
||||||
&& CollectionUtils.isEmpty(reductionList))
|
&& CollectionUtils.isEmpty(reductionList))
|
||||||
|
|
@ -1138,6 +1139,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||||
Date leaseStartTime = result.getStartTime(); // 领料时间
|
Date leaseStartTime = result.getStartTime(); // 领料时间
|
||||||
Date returnTime = result.getEndTime(); // 退料时间
|
Date returnTime = result.getEndTime(); // 退料时间
|
||||||
Date settlementTime = result.getSettlementTime(); // 结算时间
|
Date settlementTime = result.getSettlementTime(); // 结算时间
|
||||||
|
String status = result.getStatus(); // 状态
|
||||||
|
|
||||||
// 如果是已结算协议
|
// 如果是已结算协议
|
||||||
boolean leaseInRange = isDateInRange(leaseStartTime, inputStartDate, inputEndDate);
|
boolean leaseInRange = isDateInRange(leaseStartTime, inputStartDate, inputEndDate);
|
||||||
|
|
@ -1148,8 +1150,8 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
||||||
return leaseInRange || returnInRange || settlementInRange;
|
return leaseInRange || returnInRange || settlementInRange;
|
||||||
} else {
|
} else {
|
||||||
// 如果是未结算协议
|
// 如果是未结算协议
|
||||||
// 检查领料时间、退料时间是否有任何一个在查询范围内
|
// 检查领料时间、退料时间是否有任何一个在查询范围内、或者是在用状态的设备(未退还)
|
||||||
return leaseInRange || returnInRange;
|
return leaseInRange || returnInRange || ("0").equals(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -856,46 +856,53 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<choose>
|
<if test="sltStatus != null">
|
||||||
<when test="sltStatus == '1'.toString()">
|
<choose>
|
||||||
and saa.status = '1'
|
<when test="sltStatus == '1'.toString()">
|
||||||
</when>
|
and saa.status = '1'
|
||||||
<when test="sltStatus == '2'.toString()">
|
</when>
|
||||||
and saa.status = '2'
|
<when test="sltStatus == '2'.toString()">
|
||||||
</when>
|
and saa.status = '2'
|
||||||
<when test="sltStatus == '3'.toString()">
|
</when>
|
||||||
and saa.status = '3'
|
<when test="sltStatus == '3'.toString()">
|
||||||
</when>
|
and saa.status = '3'
|
||||||
</choose>
|
</when>
|
||||||
GROUP BY bai.agreement_id
|
</choose>
|
||||||
|
</if>
|
||||||
|
GROUP BY bai.agreement_id, saa.settlement_type
|
||||||
ORDER BY saa.create_time desc
|
ORDER BY saa.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getSltReportList" resultMap="SltAgreementInfoResult">
|
<select id="getSltReportList" resultMap="SltAgreementInfoResult">
|
||||||
SELECT bai.agreement_id, bai.agreement_code as agreementCode, bai.is_slt as isSlt,
|
SELECT
|
||||||
bui.unit_id as unitId,bui.unit_name as unitName, bp.pro_id as projectId , bp.pro_name as projectName,
|
bai.agreement_id, bai.agreement_code as agreementCode, bai.is_slt as isSlt,
|
||||||
saa.remark,bai.protocol,saa.cost as costs,
|
bui.unit_id as unitId,bui.unit_name as unitName, bp.pro_id as projectId , bp.pro_name as projectName,
|
||||||
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
|
saa.remark,bai.protocol,saa.cost as costs,
|
||||||
FROM bm_agreement_info bai
|
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
|
||||||
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
|
FROM
|
||||||
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
bm_agreement_info bai
|
||||||
LEFT JOIN slt_agreement_apply saa on saa.agreement_id = bai.agreement_id
|
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
|
||||||
where bai.status = '1' AND bui.type_id != '1731' AND (bai.is_slt = '0' OR bai.is_slt is null)
|
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
|
||||||
<if test="unitIds != null">
|
LEFT JOIN slt_agreement_apply saa on saa.agreement_id = bai.agreement_id
|
||||||
and bui.unit_id in
|
WHERE
|
||||||
<foreach item="item" index="index" collection="unitIds" open="(" separator="," close=")">
|
bai.status = '1' AND bui.type_id != '1731'
|
||||||
#{item}
|
AND (bai.is_slt = '0' OR bai.is_slt is null)
|
||||||
</foreach>
|
AND (saa.status is null or saa.status != '2')
|
||||||
</if>
|
<if test="unitIds != null">
|
||||||
<if test="projectId != null and projectId != ''">
|
and bui.unit_id in
|
||||||
and bp.pro_id = #{projectId}
|
<foreach item="item" index="index" collection="unitIds" open="(" separator="," close=")">
|
||||||
</if>
|
#{item}
|
||||||
<if test="sltStatus != null">
|
</foreach>
|
||||||
and bai.is_slt = #{sltStatus}
|
</if>
|
||||||
</if>
|
<if test="projectId != null and projectId != ''">
|
||||||
<if test="agreementCode != null and agreementCode != ''">
|
and bp.pro_id = #{projectId}
|
||||||
and bai.agreement_code = #{agreementCode}
|
</if>
|
||||||
</if>
|
<if test="sltStatus != null">
|
||||||
|
and bai.is_slt = #{sltStatus}
|
||||||
|
</if>
|
||||||
|
<if test="agreementCode != null and agreementCode != ''">
|
||||||
|
and bai.agreement_code = #{agreementCode}
|
||||||
|
</if>
|
||||||
GROUP BY bai.agreement_id
|
GROUP BY bai.agreement_id
|
||||||
ORDER BY bai.create_time desc
|
ORDER BY bai.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
@ -955,19 +962,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
<select id="getLoseListBatch" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
<select id="getLoseListBatch" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||||
SELECT
|
SELECT
|
||||||
res.agreementId,
|
res.agreementId, res.unitName, res.projectName, res.companyId, res.typeId,
|
||||||
res.unitName,
|
res.typeName, res.modelName, res.mtUnitName, res.buyPrice, res.startTime, res.endTime, res.leaseDays,
|
||||||
res.projectName,
|
SUM(res.num) as num
|
||||||
res.companyId,
|
|
||||||
res.typeId,
|
|
||||||
res.typeName,
|
|
||||||
res.modelName,
|
|
||||||
res.mtUnitName,
|
|
||||||
res.buyPrice,
|
|
||||||
SUM(res.num) as num,
|
|
||||||
res.startTime,
|
|
||||||
res.endTime,
|
|
||||||
res.leaseDays
|
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
select sai.id,
|
select sai.id,
|
||||||
|
|
@ -1002,7 +999,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
and mt.jiju_type = #{settlementType}
|
and mt.jiju_type = #{settlementType}
|
||||||
</if>
|
</if>
|
||||||
) res
|
) res
|
||||||
GROUP BY res.typeId
|
GROUP BY res.typeId, res.agreementId
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getRepairDetailsListBatch" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
<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 (sai.slt_time IS NOT NULL AND sai.slt_time BETWEEN #{startDate} AND #{endDate})
|
||||||
))
|
))
|
||||||
OR
|
OR
|
||||||
<!-- 未结算协议:领料时间、退料时间中至少有一个在查询范围内 -->
|
<!-- 未结算协议:领料时间、退料时间中至少有一个在查询范围内 或者设备状态为在用-->
|
||||||
(bai.is_slt = 0 AND (
|
(bai.is_slt = 0 AND (
|
||||||
(sai.start_time IS NOT NULL AND sai.start_time BETWEEN #{startDate} AND #{endDate})
|
(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.end_time IS NOT NULL AND sai.end_time BETWEEN #{startDate} AND #{endDate})
|
||||||
|
OR (sai.status = '0')
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
</where>
|
</where>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue