This commit is contained in:
hongchao 2025-09-17 18:27:01 +08:00
commit e7cecc89f3
10 changed files with 115 additions and 130 deletions

View File

@ -35,7 +35,7 @@ public class MaterialStorageInfo {
private BigDecimal storeNum;
@ApiModelProperty(value = "购置单价")
@Excel(name = "租赁价(元)")
//@Excel(name = "租赁价(元)")
private BigDecimal buyPrice;
@ApiModelProperty(value = "设备编码")
@ -46,13 +46,13 @@ public class MaterialStorageInfo {
private String maKeeper;
@ApiModelProperty(value = "操作人")
@Excel(name = "操作人")
//@Excel(name = "操作人")
private String inputUser;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "入库时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
//@Excel(name = "入库时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date inputTime;
@ApiModelProperty(value = "入库方式")

View File

@ -1,6 +1,7 @@
package com.bonus.material.clz.domain.vo;
import com.bonus.material.clz.domain.IwsUserBean;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -98,4 +99,7 @@ public class IwsTeamUserVo extends IwsUserBean {
private List<IwsTeamUserVo> teamList;
@ApiModelProperty(value = "分包单位")
private String subUnitName;
}

View File

@ -69,6 +69,10 @@ public class MaterialRetainedEquipmentInfo {
@Excel(name = "规格型号")
private String typeModelName;
@ApiModelProperty(value = "机具类型")
@Excel(name = "机具类型")
private String jiJuType;
@ApiModelProperty(value = "计量单位")
@Excel(name = "计量单位")
private String unit;
@ -212,9 +216,6 @@ public class MaterialRetainedEquipmentInfo {
*/
private List<String> projectIdList;
@ApiModelProperty("机具类型1机具2安全工器具")
private int jiJuType;
@ApiModelProperty(value = "协议id集合")
private List<Integer> agreementIdList;

View File

@ -52,11 +52,35 @@ public class MaterialTotalMentInfo {
@Excel(name = "总保有量")
private BigDecimal allNum;
@ApiModelProperty(value = "计件类总保有量")
@Excel(name = "计件类总保有量")
private BigDecimal countNum;
@ApiModelProperty(value = "绳索类总保有量")
@Excel(name = "绳索类总保有量")
private BigDecimal ropeNum;
@ApiModelProperty(value = "站内数量")
@Excel(name = "站内数量")
private BigDecimal inNum;
@ApiModelProperty(value = "计件类站内数量")
@Excel(name = "计件类站内数量")
private BigDecimal inCountNum;
@ApiModelProperty(value = "绳索类站内数量")
@Excel(name = "绳索类站内数量")
private BigDecimal inRopeNum;
@ApiModelProperty(value = "在用数量")
@Excel(name = "在用数量")
private BigDecimal useNum;
@ApiModelProperty(value = "计件类在用数量")
@Excel(name = "计件类在用数量")
private BigDecimal useCountNum;
@ApiModelProperty(value = "绳索类在用数量")
@Excel(name = "绳索类在用数量")
private BigDecimal useRopeNum;
}

View File

@ -192,7 +192,7 @@ public interface MaterialMachineMapper {
* @param bean
* @return
*/
MaterialRetainedEquipmentInfo getRetainTotalInfo(MaterialRetainedEquipmentInfo bean);
List<MaterialRetainedEquipmentInfo> getRetainTotalInfo(MaterialRetainedEquipmentInfo bean);
/**
* 库存量

View File

@ -460,98 +460,6 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
BigDecimal storageNum = storageNumMap.getOrDefault(detail.getTypeId(), BigDecimal.ZERO);
detail.setStorageNum(storageNum);
/* 原来的复杂类型树计算逻辑已被优化移除 - 节省600+ms
这里原来有大量复杂的嵌套循环和数据库查询现在用预计算替代
List<AgreementVo> list = agreementList;
List<TypeTreeNode> listL4 = new ArrayList<>();
List<TypeTreeNode> listL5 = new ArrayList<>();
List<TypeTreeNode> list7 = new ArrayList<>();
BackApplyInfo backApplyInfo = new BackApplyInfo();
if (!CollectionUtils.isEmpty(list)) {
for (AgreementVo agreementVo : list) {
backApplyInfo.setAgreementId(Long.valueOf(agreementVo.getAgreementId()));
listL4 = mapper.getUseTypeTreeL4(backApplyInfo);
if (!CollectionUtils.isEmpty(listL4)) {
listL4 = listL4.stream()
.filter(item -> StringUtils.isNotBlank(item.getMaterialName()) && StringUtils.isNotBlank(item.getTypeName()))
.collect(Collectors.toList());
// 将listL5中typeId相同的数据进行num相加
for (TypeTreeNode node : listL4) {
// 根据node中的typeId查询listL5中相同数据,如果在listL5中存在则将num相加,反之将node添加到list5中
TypeTreeNode node1 = listL5.stream()
.filter(item -> item.getTypeId() == (node.getTypeId()))
.findFirst()
.orElse(null);
if (node1 != null) {
node1.setNum(node1.getNum().add(node.getNum()));
}
if (node1 == null) {
listL5.add(node);
}
}
}
}
// 根据工程id去协议表中查询协议id
MaterialLeaseApplyInfo bean = new MaterialLeaseApplyInfo();
bean.setProId(info.getProId());
List<BmAgreementInfo> listAgreement = materialLeaseInfoMapper.getAgreementIdByProId(bean);
if (!CollectionUtils.isEmpty(listAgreement)) {
for (BmAgreementInfo agreementInfo : listAgreement) {
bean.setAgreementId(agreementInfo.getAgreementId());
List<TypeTreeNode> list6 = materialLeaseInfoMapper.getUseTypeTree(bean);
if (!CollectionUtils.isEmpty(list6)) {
for (TypeTreeNode node : list6) {
// 根据node中的typeId查询listL7中相同数据,如果在listL7中存在则将num相加,反之将node添加到list7中
TypeTreeNode node1 = list7.stream()
.filter(item -> item.getTypeId() == (node.getTypeId()))
.findFirst()
.orElse(null);
if (node1 != null) {
node1.setNum(node1.getNum().add(node.getNum()));
}
if (node1 == null) {
list7.add(node);
}
}
}
}
}
// 根据协议id去clz_slt_agreement_info材料站协议表中查询在用设备进行数据筛选去除
if (!CollectionUtils.isEmpty(listL5)) {
if (!CollectionUtils.isEmpty(list7)) {
// 将list5中typeId和list7中相同数据进行num相减并剔除相减后为0的数据
Map<Long, BigDecimal> typeIdToNum = list7.stream()
.collect(Collectors.toMap(
TypeTreeNode::getTypeId,
TypeTreeNode::getNum,
BigDecimal::add
));
Iterator<TypeTreeNode> iterator = listL5.iterator();
while (iterator.hasNext()) {
TypeTreeNode node = iterator.next();
Long typeId = node.getTypeId();
// 获取要减去的值默认值为BigDecimal.ZERO
BigDecimal subtractNum = typeIdToNum.getOrDefault(typeId, BigDecimal.ZERO);
// 计算新值处理num为null的情况若业务允许
BigDecimal currentNum = Optional.ofNullable(node.getNum())
.orElse(BigDecimal.ZERO);
BigDecimal newNum = currentNum.subtract(subtractNum);
if (newNum.compareTo(BigDecimal.ZERO) == 0) {
iterator.remove();
} else {
node.setNum(newNum);
}
}
}
// 根据details中的typeId去list5中获取库存
listL5.stream()
.filter(node -> detail.getTypeId().equals(node.getTypeId()))
.findFirst()
.ifPresent(node -> detail.setStorageNum(node.getNum()));
}
}
优化结束 - 以上复杂逻辑已被预计算替代 */
long treeCalcTime = System.currentTimeMillis() - treeCalcStart;
if (treeCalcTime > 200) {
log.warn("🐌 类型树计算慢typeId {} 耗时 {}ms", detail.getTypeId(), treeCalcTime);

View File

@ -766,20 +766,43 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
// 部门查询赋值
extractedDept(bean);
}
// 计件类在用数量
BigDecimal useCountNum = BigDecimal.ZERO;
// 绳索类在用数量
BigDecimal useRopeNum = BigDecimal.ZERO;
// 计件类站内数量
BigDecimal inCountNum = BigDecimal.ZERO;
// 绳索类站内数量
BigDecimal inRopeNum = BigDecimal.ZERO;
// 获取在用量
MaterialRetainedEquipmentInfo useInfo = materialMachineMapper.getRetainTotalInfo(bean);
BigDecimal useNum = (useInfo != null && useInfo.getUsNum() != null) ?
useInfo.getUsNum() : BigDecimal.ZERO;
List<MaterialRetainedEquipmentInfo> useInfoList = materialMachineMapper.getRetainTotalInfo(bean);
// 分别获取useInfoList中以unitValue分组的usNum数量,展示出来
if (!CollectionUtils.isEmpty(useInfoList)) {
useCountNum = useInfoList.stream()
.filter(item -> "0".equals(item.getUnitValue()))
.map(MaterialRetainedEquipmentInfo::getUsNum)
.reduce(BigDecimal::add)
.orElse(BigDecimal.ZERO);
useRopeNum = useInfoList.stream()
.filter(item -> "1".equals(item.getUnitValue()))
.map(MaterialRetainedEquipmentInfo::getUsNum)
.reduce(BigDecimal::add)
.orElse(BigDecimal.ZERO);
}
//查询目前还有库存的设备
List<MaterialRetainedEquipmentInfo> recordList = materialMachineMapper.getRetainInfoList(bean);
List<MaterialRetainedEquipmentInfo> infos = new ArrayList<>();
BigDecimal storeNum = BigDecimal.ZERO;
if (CollectionUtils.isNotEmpty(recordList)) {
// 将recordList中storeNum大于0的数据过滤出来并对总数求和
storeNum = recordList.stream()
inCountNum = recordList.stream()
.filter(item -> "0".equals(item.getUnitValue()))
.map(MaterialRetainedEquipmentInfo::getAllNum)
.reduce(BigDecimal::add)
.orElse(BigDecimal.ZERO);
inRopeNum = recordList.stream()
.filter(item -> "1".equals(item.getUnitValue()))
.map(MaterialRetainedEquipmentInfo::getAllNum)
.filter(num -> num.compareTo(BigDecimal.ZERO) > 0)
.reduce(BigDecimal::add)
.orElse(BigDecimal.ZERO);
// 获取到recordList中externalId不为null且去重的总数转换为Integer类型
@ -835,9 +858,12 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
info.setDepartNum(0);
}
// 设置结果
info.setInNum(storeNum);
info.setUseNum(useNum);
info.setAllNum(storeNum.add(useNum));
info.setInCountNum(inCountNum);
info.setInRopeNum(inRopeNum);
info.setUseCountNum(useCountNum);
info.setUseRopeNum(useRopeNum);
info.setCountNum(inCountNum.add(useCountNum));
info.setRopeNum(inRopeNum.add(useRopeNum));
return info;
}

View File

@ -21,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
DISTINCT
bzgl_bz.id, bzgl_bz.bzmc as teamName, bzgl_bz.bzz_name as relName, bzgl_bz.bzz_idcard as teamLeaderIdCard,
bzgl_bz.bz as remark, bzgl_bz.bz_status as teamStatus, bzgl_bz.project_id as projectId,
bzgl_bz.project_name as projectName, org_user.mobile as relPhone
bzgl_bz.project_name as projectName, org_user.mobile as relPhone, bzgl_bz.ssfbdw as subUnitName
from
`micro-tool`.bzgl_bz bzgl_bz
left join `uni_org`.org_user org_user on bzgl_bz.bzz_idcard = org_user.id_card
@ -37,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
DISTINCT
bzgl_bz.id, bzgl_bz.bzmc as teamName, bzgl_bz.bzz_name as relName, bzgl_bz.bzz_idcard as teamLeaderIdCard,
bzgl_bz.bz as remark, bzgl_bz.bz_status as teamStatus, bzgl_bz.project_id as projectId, bzgl_bz.project_name as projectName,
bzgl_bz.bzz_idcard as teamLeaderIdCard, org_user.mobile as relPhone
bzgl_bz.bzz_idcard as teamLeaderIdCard, org_user.mobile as relPhone, bzgl_bz.ssfbdw as subUnitName
from
`micro-tool`.bzgl_bz bzgl_bz
left join `uni_org`.org_user org_user on bzgl_bz.bzz_idcard = org_user.id_card

View File

@ -91,7 +91,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
CASE WHEN lai.lease_sign_url IS NOT NULL
THEN 0
ELSE 1
END as isElectronicSign
END as isElectronicSign,
lai.sub_unit_name as subUnitName
from
clz_lease_apply_info lai
left join tm_task tt on lai.task_id = tt.task_id
@ -159,6 +160,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="teamId != null">team_id,</if>
<if test="proId != null">project_id,</if>
<if test="leaseStyle != null">lease_style,</if>
<if test="subUnitName != null and subUnitName != ''">sub_unit_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="code != null">#{code},</if>
@ -188,6 +190,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="teamId != null">#{teamId},</if>
<if test="proId != null">#{proId},</if>
<if test="leaseStyle != null">#{leaseStyle},</if>
<if test="subUnitName != null and subUnitName != ''">#{subUnitName},</if>
</trim>
</insert>
<insert id="insertLeaseOutDetails" useGeneratedKeys="true" keyProperty="id">

View File

@ -1166,7 +1166,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bp.external_id as externalId,
bp.imp_unit AS impUnit,
bu.bzz_idcard AS idCard,
bp.pro_center AS proCenter
bp.pro_center AS proCenter,
mt.unit_value AS unitValue
FROM
clz_slt_agreement_info sai
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
@ -1208,6 +1209,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="impUnit != null and impUnit != ''">
AND bp.imp_unit = #{impUnit}
</if>
GROUP BY mt.unit_value
</select>
<select id="getRetainStoreInfo" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
@ -1296,7 +1298,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
END manageType,
'站内库存' AS teamName,
'/' AS subUnitName,
mt.unit_value AS unitValue
mt.unit_value AS unitValue,
CASE mt.jiju_type
WHEN 2 THEN
'安全工器具'
ELSE
'施工机具'
END jiJuType
FROM ma_type mt
LEFT JOIN (
SELECT
@ -1314,7 +1322,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bp.external_id as externalId,
bp.imp_unit AS impUnit,
bu.bzz_idcard AS idCard,
bp.pro_center AS proCenter,
df.project_dept AS proCenter,
sd.dept_name AS departName,
'站内库存' AS teamName
FROM
@ -1328,6 +1336,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id
AND bu.del_flag = '0'
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
WHERE
sai.`status` = '0'
AND sai.is_slt = '0'
@ -1380,7 +1389,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bp.external_id as externalId,
bp.imp_unit AS impUnit,
bu.bzz_idcard AS idCard,
bp.pro_center AS proCenter,
df.project_dept AS proCenter,
sd.dept_name AS departName,
'站内库存' AS teamName
FROM
@ -1393,7 +1402,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id
AND bu.del_flag = '0'
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
WHERE
sai.`status` = '0'
AND sai.end_time IS NULL
@ -1457,7 +1467,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bp.external_id as externalId,
bp.imp_unit AS impUnit,
bu.bzz_idcard AS idCard,
bp.pro_center AS departName,
df.project_dept AS departName,
mt.unit_name AS unit,
sd.dept_name AS impUnitName,
CASE mt.manage_type
@ -1467,7 +1477,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
'数量'
END manageType,
mt.unit_value AS unitValue,
bz.ssfbdw AS subUnitName
bz.ssfbdw AS subUnitName,
CASE mt.jiju_type
WHEN 2 THEN
'安全工器具'
ELSE
'施工机具'
END jiJuType
FROM
clz_slt_agreement_info sai
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
@ -1478,7 +1494,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id AND bu.del_flag = '0'
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN `micro-tool`.bzgl_bz bz ON bz.bzmc = bu.unit_name
LEFT JOIN `micro-tool`.bzgl_bz bz ON bp.external_id = bz.project_id
AND bz.bzmc = bu.unit_name
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
WHERE
sai.`status` = '0'
AND sai.end_time IS NULL
@ -1566,9 +1584,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="proName != null and proName != ''">
AND bp.pro_name LIKE CONCAT('%', #{proName}, '%')
</if>
<if test="departName != null and departName != ''">
AND bp.pro_center LIKE CONCAT('%', #{departName}, '%')
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
AND bp.external_id in
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
@ -1583,12 +1598,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getDepartNameList" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
SELECT
DISTINCT bp.pro_center AS departName
DISTINCT df.project_dept AS departName
FROM
bm_project bp
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
WHERE
bp.pro_center IS NOT NULL
df.project_dept IS NOT NULL
<if test="impUnitName != null and impUnitName != ''">
AND sd.dept_name LIKE CONCAT('%', #{impUnitName}, '%')
</if>
@ -1596,7 +1612,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND bp.pro_name LIKE CONCAT('%', #{proName}, '%')
</if>
<if test="departName != null and departName != ''">
AND bp.pro_center LIKE CONCAT('%', #{departName}, '%')
AND df.project_dept LIKE CONCAT('%', #{departName}, '%')
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
AND bp.external_id in
@ -1616,6 +1632,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM
bm_project bp
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
WHERE
bp.pro_center IS NOT NULL
AND bp.external_id IS NOT NULL
@ -1626,7 +1643,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND bp.pro_name LIKE CONCAT('%', #{proName}, '%')
</if>
<if test="departName != null and departName != ''">
AND bp.pro_center LIKE CONCAT('%', #{departName}, '%')
AND df.project_dept LIKE CONCAT('%', #{departName}, '%')
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
AND bp.external_id in
@ -1637,7 +1654,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="impUnit != null and impUnit != ''">
AND bp.imp_unit = #{impUnit}
</if>
GROUP BY bp.pro_center
GROUP BY bp.pro_name
</select>
<select id="getTeamList" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
@ -1648,6 +1665,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
`micro-tool`.bzgl_bz bz
LEFT JOIN bm_project bp ON bz.project_id = bp.external_id
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
WHERE
bz.bzmc IS NOT NULL
AND bp.external_id IS NOT NULL
@ -1658,7 +1676,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND bp.pro_name LIKE CONCAT('%', #{proName}, '%')
</if>
<if test="departName != null and departName != ''">
AND bp.pro_center LIKE CONCAT('%', #{departName}, '%')
AND df.project_dept LIKE CONCAT('%', #{departName}, '%')
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
AND bp.external_id in
@ -1683,6 +1701,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
`micro-tool`.bzgl_bz bz
LEFT JOIN bm_project bp ON bz.project_id = bp.external_id
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
WHERE
bz.bzmc IS NOT NULL
AND bp.external_id IS NOT NULL
@ -1693,7 +1712,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND bp.pro_name LIKE CONCAT('%', #{proName}, '%')
</if>
<if test="departName != null and departName != ''">
AND bp.pro_center LIKE CONCAT('%', #{departName}, '%')
AND df.project_dept LIKE CONCAT('%', #{departName}, '%')
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
AND bp.external_id in