材料站优化
This commit is contained in:
parent
9f6e4af5e3
commit
66730c0a78
|
|
@ -42,7 +42,7 @@ public class MaterialProvideNumInfo {
|
|||
private String departName;
|
||||
|
||||
@ApiModelProperty(value = "工程名称")
|
||||
@Excel(name = "工程名称", width = 65)
|
||||
@Excel(name = "工程名称", width = 60)
|
||||
private String proName;
|
||||
|
||||
@ApiModelProperty(value = "施工类型")
|
||||
|
|
|
|||
|
|
@ -47,11 +47,10 @@ public class MaterialRetainedEquipmentInfo {
|
|||
private String departName;
|
||||
|
||||
@ApiModelProperty(value = "项目部id")
|
||||
@Excel(name = "项目部id", width = 40)
|
||||
private String departId;
|
||||
|
||||
@ApiModelProperty(value = "工程名称")
|
||||
@Excel(name = "工程名称", width = 100)
|
||||
@Excel(name = "工程名称", width = 60)
|
||||
private String proName;
|
||||
|
||||
@ApiModelProperty(value = "分包单位")
|
||||
|
|
|
|||
|
|
@ -3,11 +3,9 @@ package com.bonus.material.clz.service.impl;
|
|||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.basic.domain.BmProject;
|
||||
import com.bonus.material.basic.domain.RetainedEquipmentInfo;
|
||||
import com.bonus.material.clz.domain.TeamVo;
|
||||
import com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo;
|
||||
import com.bonus.material.clz.domain.machine.MaterialUseStorageInfo;
|
||||
|
|
@ -21,8 +19,6 @@ import com.bonus.material.clz.domain.BmTeam;
|
|||
import com.bonus.material.clz.domain.machine.MaterialStorageInfo;
|
||||
import com.bonus.material.clz.mapper.MaterialMachineMapper;
|
||||
import com.bonus.material.clz.service.MaterialMachineService;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hibernate.validator.internal.util.StringHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -843,8 +839,12 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
|
|||
}
|
||||
// 计件类在用数量
|
||||
BigDecimal useCountNum = BigDecimal.ZERO;
|
||||
// 分包计件类在用数量
|
||||
BigDecimal useCountNumSub = BigDecimal.ZERO;
|
||||
// 绳索类在用数量
|
||||
BigDecimal useRopeNum = BigDecimal.ZERO;
|
||||
// 分包绳索类在用数量
|
||||
BigDecimal useRopeNumSub = BigDecimal.ZERO;
|
||||
// 计件类站内数量
|
||||
BigDecimal inCountNum = BigDecimal.ZERO;
|
||||
// 绳索类站内数量
|
||||
|
|
@ -901,13 +901,13 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
|
|||
.orElse(BigDecimal.ZERO);
|
||||
|
||||
|
||||
useCountNum = recordList.stream()
|
||||
useCountNumSub = recordList.stream()
|
||||
.filter(item -> "0".equals(item.getUnitValue()) && "32".equals(item.getUnitType()))
|
||||
.map(MaterialRetainedEquipmentInfo::getAllNum)
|
||||
.reduce(BigDecimal::add)
|
||||
.orElse(BigDecimal.ZERO);
|
||||
|
||||
useRopeNum = recordList.stream()
|
||||
useRopeNumSub = recordList.stream()
|
||||
.filter(item -> "1".equals(item.getUnitValue()) && "32".equals(item.getUnitType()))
|
||||
.map(MaterialRetainedEquipmentInfo::getAllNum)
|
||||
.reduce(BigDecimal::add)
|
||||
|
|
@ -951,13 +951,18 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
|
|||
} else {
|
||||
info.setDepartNum(0);
|
||||
}
|
||||
// 设置结果
|
||||
// 获取在库数量
|
||||
info.setInCountNum(inCountNum);
|
||||
// 获取在用数量
|
||||
info.setInRopeNum(inRopeNum);
|
||||
info.setUseCountNum(useCountNum);
|
||||
info.setUseRopeNum(useRopeNum);
|
||||
info.setCountNum(inCountNum.add(useCountNum));
|
||||
info.setRopeNum(inRopeNum.add(useRopeNum));
|
||||
// 获取计件类在用数量
|
||||
info.setUseCountNum(useCountNum.add(useCountNumSub));
|
||||
// 获取绳索类在用数量
|
||||
info.setUseRopeNum(useRopeNum.add(useRopeNumSub));
|
||||
// 计件类保有量
|
||||
info.setCountNum(inCountNum.add(useCountNum).add(useCountNumSub));
|
||||
// 绳索类保有量
|
||||
info.setRopeNum(inRopeNum.add(useRopeNum).add(useRopeNumSub));
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
@ -1369,12 +1374,14 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
|
|||
|
||||
// 分批查询
|
||||
List<MaterialProvideNumInfo> batchResult = materialMachineMapper.batchQueryLeaseDemand(subParams);
|
||||
List<MaterialProvideNumInfo> useDemandList = materialMachineMapper.batchQueryUseDemand(subParams);
|
||||
// 合并两个集合(顺序:先使用需求,再租赁需求,与原逻辑保持一致)
|
||||
List<MaterialProvideNumInfo> mergedList = new ArrayList<>(batchResult);
|
||||
mergedList.addAll(useDemandList);
|
||||
|
||||
// 将当前批次结果合并到总Map中
|
||||
batchResult.stream()
|
||||
.forEach(info -> {
|
||||
// 统一处理合并后的集合,按原逻辑存入Map(保留第一个出现的key)
|
||||
mergedList.forEach(info -> {
|
||||
String key = getCompositeKey(info.getProId(), info.getTypeId());
|
||||
// 若有重复key,保留第一个(与原逻辑一致)
|
||||
leaseBusinessMap.putIfAbsent(key, info.getBusinessNum());
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -279,7 +279,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
mt2.type_id AS typeId,
|
||||
bp.imp_unit AS impUnit,
|
||||
bt.bzz_idcard AS idCard,
|
||||
bp.external_id as externalId
|
||||
bp.external_id AS externalId,
|
||||
bp.pro_id AS proId
|
||||
FROM
|
||||
clz_slt_agreement_info sai
|
||||
LEFT JOIN clz_bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
|
||||
|
|
@ -2260,15 +2261,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN bm_project bp ON bp.pro_id = bagi.project_id
|
||||
AND bp.del_flag = '0'
|
||||
WHERE
|
||||
lad.type_id IS NOT NULL -- 基础条件:type_id不为空
|
||||
-- 批量条件:遍历list中的每个item,用OR连接多个条件组
|
||||
tt.task_type = 2
|
||||
AND lad.type_id IS NOT NULL
|
||||
<foreach collection="list" item="item" separator="OR" open="AND (" close=")">
|
||||
-- 单个item的条件:typeId匹配 + agreementIds在集合中
|
||||
(
|
||||
lad.type_id = #{item.typeId}
|
||||
AND tta.agreement_id IN (
|
||||
<foreach collection="item.agreementIds" item="aid" separator=",">
|
||||
#{aid} -- 遍历agreementIds集合,生成IN条件
|
||||
#{aid}
|
||||
</foreach>
|
||||
)
|
||||
)
|
||||
|
|
@ -2280,19 +2280,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="batchQueryUseDemand" resultType="com.bonus.material.clz.domain.vo.MaterialProvideNumInfo">
|
||||
select
|
||||
project_id AS proId,
|
||||
type_id AS typeId,
|
||||
IFNULL(sum(num),0) as businessNum
|
||||
lpd.project_id AS proId,
|
||||
lpd.type_id AS typeId,
|
||||
IFNULL(sum(lpd.num),0) AS businessNum
|
||||
from
|
||||
lease_publish_details
|
||||
<where>
|
||||
AND (project_id, type_id) IN
|
||||
<foreach collection="list" item="item" separator="," open="(" close=")">
|
||||
(#{item.proId}, #{item.typeId})
|
||||
lease_publish_details lpd
|
||||
LEFT JOIN bm_agreement_info bai ON lpd.project_id = bai.project_id
|
||||
AND lpd.unit_id = bai.unit_id
|
||||
WHERE
|
||||
lpd.type_id IS NOT NULL
|
||||
<foreach collection="list" item="item" separator="OR" open="AND (" close=")">
|
||||
(
|
||||
lpd.type_id = #{item.typeId}
|
||||
AND bai.agreement_id IN (
|
||||
<foreach collection="item.agreementIds" item="aid" separator=",">
|
||||
#{aid}
|
||||
</foreach>
|
||||
)
|
||||
)
|
||||
</foreach>
|
||||
</where>
|
||||
GROUP BY
|
||||
project_id,
|
||||
type_id
|
||||
lpd.project_id,
|
||||
lpd.type_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue