功能优化

This commit is contained in:
mashuai 2025-09-14 23:24:15 +08:00
parent 9c1a1379f2
commit 989f1efc3d
3 changed files with 63 additions and 30 deletions

View File

@ -153,10 +153,12 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
if (teamData == null) {
// 根据用户名查询项目部信息
List<String> departId = mapper.getDepartId(username);
// 根据项目部id查询工程信息
List<String> projectIdList = mapper.getProjectId(departId);
if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) {
bean.setProjectIdList(projectIdList);
if (CollectionUtils.isNotEmpty(departId)) {
// 根据项目部id查询工程信息
List<String> projectIdList = mapper.getProjectId(departId);
if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) {
bean.setProjectIdList(projectIdList);
}
}
}
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
@ -814,23 +816,25 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
BigDecimal useNum = (useInfo != null && useInfo.getUsNum() != null) ?
useInfo.getUsNum() : BigDecimal.ZERO;
// 库存量
MaterialRetainedEquipmentInfo storeInfo = materialMachineMapper.getRetainStoreInfo(bean);
BigDecimal storeNum = (storeInfo != null && storeInfo.getStoreNum() != null) ?
storeInfo.getStoreNum() : BigDecimal.ZERO;
// 站内库存量 = 库存量 - 库存中已使用量不能为负数
BigDecimal inNum = storeNum.subtract(useNum);
if (inNum.compareTo(BigDecimal.ZERO) < 0) {
inNum = BigDecimal.ZERO;
//查询目前还有库存的设备
List<MaterialRetainedEquipmentInfo> recordList = materialMachineMapper.getRetainInfoList(bean);
BigDecimal storeNum = BigDecimal.ZERO;
if (CollectionUtils.isNotEmpty(recordList)) {
// 将recordList中storeNum大于0的数据过滤出来并对总数求和
storeNum = recordList.stream()
.map(MaterialRetainedEquipmentInfo::getStoreNum)
.filter(num -> num.compareTo(BigDecimal.ZERO) > 0)
.reduce(BigDecimal::add)
.orElse(BigDecimal.ZERO);
}
// 设置结果
info.setInNum(inNum);
info.setInNum(storeNum);
info.setUseNum(useNum);
info.setDepartNum(departNum);
info.setProNum(projectNum);
info.setTeamNum(teamNum);
info.setAllNum(inNum.add(useNum));
info.setAllNum(storeNum.add(useNum));
return info;
}

View File

@ -265,6 +265,9 @@ public class SelectServiceImpl implements SelectService {
// 根据用户名查询项目部信息
List<String> departId = mapper.getDepartId(username);
// 根据项目部id查询工程信息
if (CollectionUtils.isEmpty(departId)) {
return AjaxResult.success(Collections.emptyList());
}
List<String> projectIdList = mapper.getProjectId(departId);
if (CollectionUtils.isNotEmpty(projectIdList)) {
// 找出list中projectId与projectIdList中相同的数据
@ -273,6 +276,9 @@ public class SelectServiceImpl implements SelectService {
} else {
// 根据班组用户查询工程信息
List<String> teamList = mapper.getProjectIdByUseName(username);
if (CollectionUtils.isEmpty(teamList)) {
return AjaxResult.success(Collections.emptyList());
}
if (CollectionUtils.isNotEmpty(teamList)) {
// 找出list中projectId与projectIdList中相同的数据
list = list.stream().filter(info -> teamList.contains(info.getProjectId())).collect(Collectors.toList());

View File

@ -1305,7 +1305,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND sai.is_slt = '0'
AND sai.end_time IS NULL
AND sai.back_id IS NULL
GROUP BY mt.type_id, bp.pro_id
<if test="impUnitName != null and impUnitName != ''">
AND sd.dept_name like concat('%',#{impUnitName},'%')
</if>
<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="typeName != null and typeName != ''">
AND mt2.type_name like concat('%',#{typeName},'%')
</if>
<if test="typeModelName != null and typeModelName != ''">
AND mt.type_name like concat('%',#{typeModelName},'%')
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
and bp.external_id in
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="impUnit != null and impUnit != ''">
and bp.imp_unit = #{impUnit}
</if>
GROUP BY mt.type_id
) AS subquery1 ON mt.type_id = subquery1.type_id
LEFT JOIN (
SELECT
@ -1340,23 +1364,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sai.`status` = '0'
AND sai.end_time IS NULL
AND sai.back_id IS NULL
GROUP BY mt.type_id, bp.pro_id
) AS subquery3
ON mt.type_id = subquery3.type_id
AND subquery1.proId = subquery3.proId
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
WHERE mt.`level` = 4 and mt.del_flag = '0'
AND IFNULL(subquery1.usNum, 0) - IFNULL(subquery3.usNum, 0) > 0
<if test="impUnitName != null and impUnitName != ''">
AND subquery1.departName like concat('%',#{impUnitName},'%')
AND sd.dept_name like concat('%',#{impUnitName},'%')
</if>
<if test="proName != null and proName != ''">
AND subquery1.proName like concat('%',#{proName},'%')
AND bp.pro_name like concat('%',#{proName},'%')
</if>
<if test="departName != null and departName != ''">
AND subquery1.proCenter like concat('%',#{departName},'%')
AND bp.pro_center like concat('%',#{departName},'%')
</if>
<if test="typeName != null and typeName != ''">
AND mt2.type_name like concat('%',#{typeName},'%')
@ -1365,15 +1380,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND mt.type_name like concat('%',#{typeModelName},'%')
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
and subquery1.externalId in
and bp.external_id in
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="impUnit != null and impUnit != ''">
and subquery1.impUnit = #{impUnit}
and bp.imp_unit = #{impUnit}
</if>
GROUP BY mt.type_id
) AS subquery3
ON mt.type_id = subquery3.type_id
LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
WHERE mt.`level` = 4 and mt.del_flag = '0'
AND IFNULL(subquery1.usNum, 0) - IFNULL(subquery3.usNum, 0) > 0
GROUP BY mt.type_id
</select>
<select id="getUsInfoList" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">