材料站结算查看接口修改

This commit is contained in:
bonus 2025-10-22 16:32:39 +08:00
parent 9e4dada563
commit a26d40d9ea
3 changed files with 238 additions and 102 deletions

View File

@ -125,4 +125,13 @@ public interface ClzSltAgreementInfoMapper {
String getTeamOutTime(MaterialSltAgreementInfo materialSltAgreementInfo); String getTeamOutTime(MaterialSltAgreementInfo materialSltAgreementInfo);
String getTeamSjOutTime(MaterialSltAgreementInfo materialSltAgreementInfo); String getTeamSjOutTime(MaterialSltAgreementInfo materialSltAgreementInfo);
List<MaterialSltAgreementInfo> getSltLeaseList(MaterialSltAgreementInfo info);
List<MaterialSltAgreementInfo> getSltRepairList(MaterialSltAgreementInfo info);
List<MaterialSltAgreementInfo> getSltScrapList(MaterialSltAgreementInfo info);
List<MaterialSltAgreementInfo> getSltLoseList(MaterialSltAgreementInfo info);
} }

View File

@ -181,30 +181,30 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
List<SltAgreementInfo> resultVo = new ArrayList<>(); List<SltAgreementInfo> resultVo = new ArrayList<>();
// 查询数据库 // 查询数据库
List<SltAgreementInfo> list = clzSltAgreementInfoMapper.getSltList(bean); List<SltAgreementInfo> list = clzSltAgreementInfoMapper.getSltList(bean);
if (CollectionUtils.isNotEmpty(list)) { // if (CollectionUtils.isNotEmpty(list)) {
// 按照结算单号分组 // // 按照结算单号分组
Map<String, List<SltAgreementInfo>> sltListByCodeMap = list.stream().collect(Collectors.groupingBy(SltAgreementInfo::getSltApplyCode)); // Map<String, List<SltAgreementInfo>> sltListByCodeMap = list.stream().collect(Collectors.groupingBy(SltAgreementInfo::getSltApplyCode));
// 遍历Map // // 遍历Map
sltListByCodeMap.forEach((s, sltAgreementInfoList) -> { // sltListByCodeMap.forEach((s, sltAgreementInfoList) -> {
if (CollectionUtils.isNotEmpty(sltAgreementInfoList)) { // if (CollectionUtils.isNotEmpty(sltAgreementInfoList)) {
// 定义初始化对象 // // 定义初始化对象
SltAgreementInfo obj = new SltAgreementInfo(); // SltAgreementInfo obj = new SltAgreementInfo();
BeanUtil.copyProperties(sltAgreementInfoList.get(0), obj, true); // BeanUtil.copyProperties(sltAgreementInfoList.get(0), obj, true);
//
// // 合并结算单中的多个单位名称及费用
// String unitNames = sltAgreementInfoList.stream().map(SltAgreementInfo::getUnitName).collect(Collectors.joining(","));
// BigDecimal costsSum = sltAgreementInfoList.stream().map(SltAgreementInfo::getCosts).reduce(BigDecimal.ZERO, BigDecimal::add);
// obj.setUnitName(unitNames);
// obj.setCosts(costsSum);
//
// resultVo.add(obj);
// }
// });
// } else {
// throw new ServiceException("数据库未查询到结算信息!");
// }
// 合并结算单中的多个单位名称及费用 return list;
String unitNames = sltAgreementInfoList.stream().map(SltAgreementInfo::getUnitName).collect(Collectors.joining(","));
BigDecimal costsSum = sltAgreementInfoList.stream().map(SltAgreementInfo::getCosts).reduce(BigDecimal.ZERO, BigDecimal::add);
obj.setUnitName(unitNames);
obj.setCosts(costsSum);
resultVo.add(obj);
}
});
} else {
throw new ServiceException("数据库未查询到结算信息!");
}
return resultVo;
} }
/** /**
@ -267,83 +267,104 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
* 获取已结算清单 * 获取已结算清单
*/ */
private List<MaterialSltInfoVo> getSettledInfo(MaterialSltAgreementInfo info) { private List<MaterialSltInfoVo> getSettledInfo(MaterialSltAgreementInfo info) {
// 查询各项费用列表
List<MaterialSltAgreementInfo> sltedList = clzSltAgreementInfoMapper.getSltedList(info);
if (CollectionUtils.isEmpty(sltedList)) {
throw new ServiceException("未查询到已结算信息!");
}
// 定义遍历集合
Map<Long, List<MaterialSltAgreementInfo>> materialSltInfoResultMap = sltedList.stream().collect(Collectors.groupingBy(MaterialSltAgreementInfo::getAgreementId));
// 定义返回对象 // 定义返回对象
List<MaterialSltInfoVo> resultVoList = new ArrayList<>(); List<MaterialSltInfoVo> resultVoList = new ArrayList<>();
for (List<MaterialSltAgreementInfo> key : materialSltInfoResultMap.values()) { //租赁费用列表
if (CollectionUtils.isEmpty(key)) { List<MaterialSltAgreementInfo> leaseList = clzSltAgreementInfoMapper.getSltLeaseList(info);
throw new ServiceException("已结算信息异常,请联系管理员!"); //维修费用列表
} List<MaterialSltAgreementInfo> repairList = clzSltAgreementInfoMapper.getSltRepairList(info);
//报废费用列表
List<MaterialSltAgreementInfo> scrapList = clzSltAgreementInfoMapper.getSltScrapList(info);
//丢失费用列表
List<MaterialSltAgreementInfo>loseList =clzSltAgreementInfoMapper.getSltLoseList(info);
key.forEach((item) -> {
MaterialSltInfoVo sltInfoVo = new MaterialSltInfoVo();
BigDecimal leaseCost = BigDecimal.ZERO, repairCost = BigDecimal.ZERO, scrapCost = BigDecimal.ZERO;
BigDecimal loseCost = BigDecimal.ZERO, reducCost = BigDecimal.ZERO;
//租赁费用列表 MaterialSltInfoVo sltInfoVo = new MaterialSltInfoVo();
List<MaterialSltAgreementInfo> leaseList = key.stream().filter(slt -> slt.getSltType() == 1).collect(Collectors.toList());
//维修费用列表
List<MaterialSltAgreementInfo> repairList = key.stream().filter(slt -> slt.getSltType() == 3).collect(Collectors.toList());
//报废费用列表
List<MaterialSltAgreementInfo> scrapList = key.stream().filter(slt -> slt.getSltType() == 4).collect(Collectors.toList());
//丢失费用列表
List<MaterialSltAgreementInfo> loseList = key.stream().filter(slt -> slt.getSltType() == 2).collect(Collectors.toList());
sltInfoVo.setLeaseList(leaseList); sltInfoVo.setLeaseList(leaseList);
sltInfoVo.setRepairList(repairList); sltInfoVo.setRepairList(repairList);
sltInfoVo.setScrapList(scrapList); sltInfoVo.setScrapList(scrapList);
sltInfoVo.setLoseList(loseList); sltInfoVo.setLoseList(loseList);
sltInfoVo.setReductionList(Collections.emptyList()); resultVoList.add(sltInfoVo);
for (MaterialSltAgreementInfo lease : leaseList) { // 查询各项费用列表
if (lease.getCosts() != null) { // List<MaterialSltAgreementInfo> sltedList = clzSltAgreementInfoMapper.getSltedList(info);
leaseCost = leaseCost.add(lease.getCosts());
}
}
for (MaterialSltAgreementInfo lose : loseList) {
if (lose.getCosts() != null) {
loseCost = loseCost.add(lose.getCosts());
}
}
sltInfoVo.setLeaseCost(leaseCost); // if (CollectionUtils.isEmpty(sltedList)) {
sltInfoVo.setRepairCost(repairCost); // throw new ServiceException("未查询到已结算信息!");
sltInfoVo.setScrapCost(scrapCost); // }
sltInfoVo.setLoseCost(loseCost); //
sltInfoVo.setReductionCost(reducCost); // // 定义遍历集合
List<SltAgreementRelation> relations = getRelations(leaseList, repairList, scrapList, loseList, info); // Map<Long, List<MaterialSltAgreementInfo>> materialSltInfoResultMap = sltedList.stream().collect(Collectors.groupingBy(MaterialSltAgreementInfo::getAgreementId));
sltInfoVo.setRelations(relations); //
// // 定义返回对象
resultVoList.add(sltInfoVo); // List<MaterialSltInfoVo> resultVoList = new ArrayList<>();
//
// 给外层的单位名称/工程名称赋值 // for (List<MaterialSltAgreementInfo> key : materialSltInfoResultMap.values()) {
extractInnerNameToOuter(resultVoList, sltInfoVo); // if (CollectionUtils.isEmpty(key)) {
// throw new ServiceException("已结算信息异常,请联系管理员!");
}); // }
} //
// key.forEach((item) -> {
// 返回之前对集合做去重处理根据外层的单位名称去重,保留每个单位名称的第一个 // MaterialSltInfoVo sltInfoVo = new MaterialSltInfoVo();
Set<String> seen = new HashSet<>(); // BigDecimal leaseCost = BigDecimal.ZERO, repairCost = BigDecimal.ZERO, scrapCost = BigDecimal.ZERO;
List<MaterialSltInfoVo> dedup = new ArrayList<>(resultVoList.size()); // BigDecimal loseCost = BigDecimal.ZERO, reducCost = BigDecimal.ZERO;
for (MaterialSltInfoVo it : resultVoList) { //
if (it == null) continue; // //租赁费用列表
String key = normalize(it.getUnitName()); // List<MaterialSltAgreementInfo> leaseList = key.stream().filter(slt -> slt.getSltType() == 1).collect(Collectors.toList());
if (key == null) continue; // //维修费用列表
if (seen.add(key)) { // List<MaterialSltAgreementInfo> repairList = key.stream().filter(slt -> slt.getSltType() == 3).collect(Collectors.toList());
dedup.add(it); // 第一次见到该单位名 -> 保留 // //报废费用列表
} // List<MaterialSltAgreementInfo> scrapList = key.stream().filter(slt -> slt.getSltType() == 4).collect(Collectors.toList());
} // //丢失费用列表
// List<MaterialSltAgreementInfo> loseList = key.stream().filter(slt -> slt.getSltType() == 2).collect(Collectors.toList());
return dedup; //
// sltInfoVo.setLeaseList(leaseList);
// sltInfoVo.setRepairList(repairList);
// sltInfoVo.setScrapList(scrapList);
// sltInfoVo.setLoseList(loseList);
// sltInfoVo.setReductionList(Collections.emptyList());
// for (MaterialSltAgreementInfo lease : leaseList) {
// if (lease.getCosts() != null) {
// leaseCost = leaseCost.add(lease.getCosts());
// }
// }
// for (MaterialSltAgreementInfo lose : loseList) {
// if (lose.getCosts() != null) {
// loseCost = loseCost.add(lose.getCosts());
// }
// }
//
// sltInfoVo.setLeaseCost(leaseCost);
// sltInfoVo.setRepairCost(repairCost);
// sltInfoVo.setScrapCost(scrapCost);
// sltInfoVo.setLoseCost(loseCost);
// sltInfoVo.setReductionCost(reducCost);
// List<SltAgreementRelation> relations = getRelations(leaseList, repairList, scrapList, loseList, info);
// sltInfoVo.setRelations(relations);
//
// resultVoList.add(sltInfoVo);
//
// // 给外层的单位名称/工程名称赋值
// extractInnerNameToOuter(resultVoList, sltInfoVo);
//
// });
// }
//
// // 返回之前对集合做去重处理根据外层的单位名称去重,保留每个单位名称的第一个
// Set<String> seen = new HashSet<>();
// List<MaterialSltInfoVo> dedup = new ArrayList<>(resultVoList.size());
// for (MaterialSltInfoVo it : resultVoList) {
// if (it == null) continue;
// String key = normalize(it.getUnitName());
// if (key == null) continue;
// if (seen.add(key)) {
// dedup.add(it); // 第一次见到该单位名 -> 保留
// }
// }
//
// return dedup;
return resultVoList;
} }
/** /**

View File

@ -345,24 +345,53 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="getSltList" resultType="com.bonus.material.settlement.domain.SltAgreementInfo"> <select id="getSltList" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
SELECT SELECT
saa.id as id, bai.agreement_id as agreementId, bai.agreement_code as agreementCode, saa.code as sltApplyCode, saa.id AS id,
bui.unit_id as unitId, bui.unit_name as unitName, bp.pro_id as projectId, bp.pro_name as projectName, bai.agreement_id AS agreementId,
saa.remark, saa.cost as costs, su.nick_name as auditor, saa.audit_time as auditTime, bai.agreement_code AS agreementCode,
case when saa.status = '1' then '1' when saa.status = '2' then '2' when saa.status = '3' then '3' end as sltStatus saa.CODE AS sltApplyCode,
FROM clz_bm_agreement_info bai bui.unit_id AS unitId,
GROUP_CONCAT(DISTINCT bui.unit_name) AS unitName,
bp.pro_id AS projectId,
bp.pro_name AS projectName,
saa.remark,
saa.cost AS costs,
su.nick_name AS auditor,
saa.audit_time AS auditTime,
CASE
WHEN saa.STATUS = '1' THEN
'1'
WHEN saa.STATUS = '2' THEN
'2'
WHEN saa.STATUS = '3' THEN
'3'
END AS sltStatus
FROM
clz_slt_agreement_apply saa
LEFT JOIN clz_bm_agreement_info bai ON saa.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id 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 bm_unit bui ON bui.unit_id = bai.unit_id
LEFT JOIN clz_slt_agreement_apply saa on saa.agreement_id = bai.agreement_id LEFT JOIN sys_user su ON saa.auditor = su.user_id
LEFT JOIN sys_user su ON saa.auditor = su.user_id and su.del_flag = 0 AND su.del_flag = 0
where bai.status = '1' and saa.status in ('1','2','3') WHERE
bai.STATUS = '1'
AND saa.STATUS IN ( '1', '2', '3' )
<if test="unitId != null and unitId != ''"> <if test="unitId != null and unitId != ''">
and bui.unit_id = #{unitId} and bui.unit_id = #{unitId}
</if> </if>
<if test="projectId != null and projectId != ''"> <if test="projectId != null and projectId != ''">
and bp.pro_id = #{projectId} and bp.pro_id = #{projectId}
</if> </if>
ORDER BY saa.create_time desc GROUP BY saa.CODE
ORDER BY
saa.create_time DESC
</select> </select>
<select id="getSltedList" resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo"> <select id="getSltedList" resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
@ -438,6 +467,83 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LIMIT 1 LIMIT 1
</select> </select>
<select id="getSltRepairList"
resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
SELECT
saa.id as id, bai.agreement_id as agreementId, bai.agreement_code as agreementCode, saa.`code` as sltApplyCode,
bui.unit_id as unitId, bui.unit_name as unitName, bp.pro_id as projectId, bp.pro_name as projectName,
saa.remark, sad.money as costs, saa.audit_time as auditTime, sad.start_time as startTime, sad.end_time as endTime,
saa.`status` as sltStatus, sad.slt_type as sltType, sad.num, sad.price as leasePrice,
mt1.type_name as typeName, mt.type_name as modelName, mt.unit_name as mtUnitName
FROM
clz_slt_agreement_apply saa
LEFT JOIN clz_bm_agreement_info bai ON saa.agreement_id = bai.agreement_id
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 clz_slt_agreement_details sad ON saa.id = sad.apply_id
left join ma_type mt on sad.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where
saa.`code` = #{sltApplyCode} and sad.slt_type =3
</select>
<select id="getSltScrapList"
resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
SELECT
saa.id as id, bai.agreement_id as agreementId, bai.agreement_code as agreementCode, saa.`code` as sltApplyCode,
bui.unit_id as unitId, bui.unit_name as unitName, bp.pro_id as projectId, bp.pro_name as projectName,
saa.remark, sad.money as costs, saa.audit_time as auditTime, sad.start_time as startTime, sad.end_time as endTime,
saa.`status` as sltStatus, sad.slt_type as sltType, sad.num, sad.price as leasePrice,
mt1.type_name as typeName, mt.type_name as modelName, mt.unit_name as mtUnitName
FROM
clz_slt_agreement_apply saa
LEFT JOIN clz_bm_agreement_info bai ON saa.agreement_id = bai.agreement_id
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 clz_slt_agreement_details sad ON saa.id = sad.apply_id
left join ma_type mt on sad.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where
saa.`code` = #{sltApplyCode} and sad.slt_type =4
</select>
<select id="getSltLoseList"
resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
SELECT
saa.id as id, bai.agreement_id as agreementId, bai.agreement_code as agreementCode, saa.`code` as sltApplyCode,
bui.unit_id as unitId, bui.unit_name as unitName, bp.pro_id as projectId, bp.pro_name as projectName,
saa.remark, sad.money as costs, saa.audit_time as auditTime, sad.start_time as startTime, sad.end_time as endTime,
saa.`status` as sltStatus, sad.slt_type as sltType, sad.num, sad.price as leasePrice,
mt1.type_name as typeName, mt.type_name as modelName, mt.unit_name as mtUnitName
FROM
clz_slt_agreement_apply saa
LEFT JOIN clz_bm_agreement_info bai ON saa.agreement_id = bai.agreement_id
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 clz_slt_agreement_details sad ON saa.id = sad.apply_id
left join ma_type mt on sad.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where
saa.`code` = #{sltApplyCode} and sad.slt_type =2
</select>
<select id="getSltLeaseList" resultType="com.bonus.material.clz.domain.vo.MaterialSltAgreementInfo">
SELECT
saa.id as id, bai.agreement_id as agreementId, bai.agreement_code as agreementCode, saa.`code` as sltApplyCode,
bui.unit_id as unitId, bui.unit_name as unitName, bp.pro_id as projectId, bp.pro_name as projectName,
saa.remark, sad.money as costs, saa.audit_time as auditTime, sad.start_time as startTime, sad.end_time as endTime,
saa.`status` as sltStatus, sad.slt_type as sltType, sad.num, sad.price as leasePrice,
mt1.type_name as typeName, mt.type_name as modelName, mt.unit_name as mtUnitName
FROM
clz_slt_agreement_apply saa
LEFT JOIN clz_bm_agreement_info bai ON saa.agreement_id = bai.agreement_id
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 clz_slt_agreement_details sad ON saa.id = sad.apply_id
left join ma_type mt on sad.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where
saa.`code` = #{sltApplyCode} and sad.slt_type =1
</select>
<update id="updateClzAgreementInfoByIds"> <update id="updateClzAgreementInfoByIds">
update clz_bm_agreement_info update clz_bm_agreement_info
set is_slt = 1, update_time = now() set is_slt = 1, update_time = now()