材料站结算查看接口修改

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 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> list = clzSltAgreementInfoMapper.getSltList(bean);
if (CollectionUtils.isNotEmpty(list)) {
// 按照结算单号分组
Map<String, List<SltAgreementInfo>> sltListByCodeMap = list.stream().collect(Collectors.groupingBy(SltAgreementInfo::getSltApplyCode));
// 遍历Map
sltListByCodeMap.forEach((s, sltAgreementInfoList) -> {
if (CollectionUtils.isNotEmpty(sltAgreementInfoList)) {
// 定义初始化对象
SltAgreementInfo obj = new SltAgreementInfo();
BeanUtil.copyProperties(sltAgreementInfoList.get(0), obj, true);
// if (CollectionUtils.isNotEmpty(list)) {
// // 按照结算单号分组
// Map<String, List<SltAgreementInfo>> sltListByCodeMap = list.stream().collect(Collectors.groupingBy(SltAgreementInfo::getSltApplyCode));
// // 遍历Map
// sltListByCodeMap.forEach((s, sltAgreementInfoList) -> {
// if (CollectionUtils.isNotEmpty(sltAgreementInfoList)) {
// // 定义初始化对象
// SltAgreementInfo obj = new SltAgreementInfo();
// 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("数据库未查询到结算信息!");
// }
// 合并结算单中的多个单位名称及费用
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;
return list;
}
/**
@ -267,83 +267,104 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
* 获取已结算清单
*/
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<>();
for (List<MaterialSltAgreementInfo> key : materialSltInfoResultMap.values()) {
if (CollectionUtils.isEmpty(key)) {
throw new ServiceException("已结算信息异常,请联系管理员!");
}
//租赁费用列表
List<MaterialSltAgreementInfo> leaseList = clzSltAgreementInfoMapper.getSltLeaseList(info);
//维修费用列表
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;
//租赁费用列表
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());
MaterialSltInfoVo sltInfoVo = new MaterialSltInfoVo();
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.setLeaseList(leaseList);
sltInfoVo.setRepairList(repairList);
sltInfoVo.setScrapList(scrapList);
sltInfoVo.setLoseList(loseList);
resultVoList.add(sltInfoVo);
// 查询各项费用列表
// List<MaterialSltAgreementInfo> sltedList = clzSltAgreementInfoMapper.getSltedList(info);
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;
// if (CollectionUtils.isEmpty(sltedList)) {
// throw new ServiceException("未查询到已结算信息!");
// }
//
// // 定义遍历集合
// Map<Long, List<MaterialSltAgreementInfo>> materialSltInfoResultMap = sltedList.stream().collect(Collectors.groupingBy(MaterialSltAgreementInfo::getAgreementId));
//
// // 定义返回对象
// List<MaterialSltInfoVo> resultVoList = new ArrayList<>();
//
// for (List<MaterialSltAgreementInfo> key : materialSltInfoResultMap.values()) {
// if (CollectionUtils.isEmpty(key)) {
// throw new ServiceException("已结算信息异常,请联系管理员!");
// }
//
// key.forEach((item) -> {
// MaterialSltInfoVo sltInfoVo = new MaterialSltInfoVo();
// BigDecimal leaseCost = BigDecimal.ZERO, repairCost = BigDecimal.ZERO, scrapCost = BigDecimal.ZERO;
// BigDecimal loseCost = BigDecimal.ZERO, reducCost = BigDecimal.ZERO;
//
// //租赁费用列表
// 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.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 id="getSltList" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
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, 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_bm_agreement_info bai
saa.id AS id,
bai.agreement_id AS agreementId,
bai.agreement_code AS agreementCode,
saa.CODE AS sltApplyCode,
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_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 and su.del_flag = 0
where bai.status = '1' and saa.status in ('1','2','3')
LEFT JOIN sys_user su ON saa.auditor = su.user_id
AND su.del_flag = 0
WHERE
bai.STATUS = '1'
AND saa.STATUS IN ( '1', '2', '3' )
<if test="unitId != null and unitId != ''">
and bui.unit_id = #{unitId}
</if>
<if test="projectId != null and projectId != ''">
and bp.pro_id = #{projectId}
</if>
ORDER BY saa.create_time desc
GROUP BY saa.CODE
ORDER BY
saa.create_time DESC
</select>
<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
</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 clz_bm_agreement_info
set is_slt = 1, update_time = now()