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