功能优化
This commit is contained in:
parent
9c1a1379f2
commit
989f1efc3d
|
|
@ -153,10 +153,12 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
|
||||||
if (teamData == null) {
|
if (teamData == null) {
|
||||||
// 根据用户名查询项目部信息
|
// 根据用户名查询项目部信息
|
||||||
List<String> departId = mapper.getDepartId(username);
|
List<String> departId = mapper.getDepartId(username);
|
||||||
// 根据项目部id查询工程信息
|
if (CollectionUtils.isNotEmpty(departId)) {
|
||||||
List<String> projectIdList = mapper.getProjectId(departId);
|
// 根据项目部id查询工程信息
|
||||||
if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) {
|
List<String> projectIdList = mapper.getProjectId(departId);
|
||||||
bean.setProjectIdList(projectIdList);
|
if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) {
|
||||||
|
bean.setProjectIdList(projectIdList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
||||||
|
|
@ -814,23 +816,25 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
|
||||||
BigDecimal useNum = (useInfo != null && useInfo.getUsNum() != null) ?
|
BigDecimal useNum = (useInfo != null && useInfo.getUsNum() != null) ?
|
||||||
useInfo.getUsNum() : BigDecimal.ZERO;
|
useInfo.getUsNum() : BigDecimal.ZERO;
|
||||||
|
|
||||||
// 库存量
|
//查询目前还有库存的设备
|
||||||
MaterialRetainedEquipmentInfo storeInfo = materialMachineMapper.getRetainStoreInfo(bean);
|
List<MaterialRetainedEquipmentInfo> recordList = materialMachineMapper.getRetainInfoList(bean);
|
||||||
BigDecimal storeNum = (storeInfo != null && storeInfo.getStoreNum() != null) ?
|
BigDecimal storeNum = BigDecimal.ZERO;
|
||||||
storeInfo.getStoreNum() : BigDecimal.ZERO;
|
if (CollectionUtils.isNotEmpty(recordList)) {
|
||||||
|
// 将recordList中storeNum大于0的数据过滤出来,并对总数求和
|
||||||
// 站内库存量 = 库存量 - 库存中已使用量,不能为负数
|
storeNum = recordList.stream()
|
||||||
BigDecimal inNum = storeNum.subtract(useNum);
|
.map(MaterialRetainedEquipmentInfo::getStoreNum)
|
||||||
if (inNum.compareTo(BigDecimal.ZERO) < 0) {
|
.filter(num -> num.compareTo(BigDecimal.ZERO) > 0)
|
||||||
inNum = BigDecimal.ZERO;
|
.reduce(BigDecimal::add)
|
||||||
|
.orElse(BigDecimal.ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置结果
|
// 设置结果
|
||||||
info.setInNum(inNum);
|
info.setInNum(storeNum);
|
||||||
info.setUseNum(useNum);
|
info.setUseNum(useNum);
|
||||||
info.setDepartNum(departNum);
|
info.setDepartNum(departNum);
|
||||||
info.setProNum(projectNum);
|
info.setProNum(projectNum);
|
||||||
info.setTeamNum(teamNum);
|
info.setTeamNum(teamNum);
|
||||||
info.setAllNum(inNum.add(useNum));
|
info.setAllNum(storeNum.add(useNum));
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -265,6 +265,9 @@ public class SelectServiceImpl implements SelectService {
|
||||||
// 根据用户名查询项目部信息
|
// 根据用户名查询项目部信息
|
||||||
List<String> departId = mapper.getDepartId(username);
|
List<String> departId = mapper.getDepartId(username);
|
||||||
// 根据项目部id查询工程信息
|
// 根据项目部id查询工程信息
|
||||||
|
if (CollectionUtils.isEmpty(departId)) {
|
||||||
|
return AjaxResult.success(Collections.emptyList());
|
||||||
|
}
|
||||||
List<String> projectIdList = mapper.getProjectId(departId);
|
List<String> projectIdList = mapper.getProjectId(departId);
|
||||||
if (CollectionUtils.isNotEmpty(projectIdList)) {
|
if (CollectionUtils.isNotEmpty(projectIdList)) {
|
||||||
// 找出list中projectId与projectIdList中相同的数据
|
// 找出list中projectId与projectIdList中相同的数据
|
||||||
|
|
@ -273,6 +276,9 @@ public class SelectServiceImpl implements SelectService {
|
||||||
} else {
|
} else {
|
||||||
// 根据班组用户查询工程信息
|
// 根据班组用户查询工程信息
|
||||||
List<String> teamList = mapper.getProjectIdByUseName(username);
|
List<String> teamList = mapper.getProjectIdByUseName(username);
|
||||||
|
if (CollectionUtils.isEmpty(teamList)) {
|
||||||
|
return AjaxResult.success(Collections.emptyList());
|
||||||
|
}
|
||||||
if (CollectionUtils.isNotEmpty(teamList)) {
|
if (CollectionUtils.isNotEmpty(teamList)) {
|
||||||
// 找出list中projectId与projectIdList中相同的数据
|
// 找出list中projectId与projectIdList中相同的数据
|
||||||
list = list.stream().filter(info -> teamList.contains(info.getProjectId())).collect(Collectors.toList());
|
list = list.stream().filter(info -> teamList.contains(info.getProjectId())).collect(Collectors.toList());
|
||||||
|
|
|
||||||
|
|
@ -1305,7 +1305,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
AND sai.is_slt = '0'
|
AND sai.is_slt = '0'
|
||||||
AND sai.end_time IS NULL
|
AND sai.end_time IS NULL
|
||||||
AND sai.back_id 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
|
) AS subquery1 ON mt.type_id = subquery1.type_id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
|
|
@ -1340,23 +1364,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
sai.`status` = '0'
|
sai.`status` = '0'
|
||||||
AND sai.end_time IS NULL
|
AND sai.end_time IS NULL
|
||||||
AND sai.back_id 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 != ''">
|
<if test="impUnitName != null and impUnitName != ''">
|
||||||
AND subquery1.departName like concat('%',#{impUnitName},'%')
|
AND sd.dept_name like concat('%',#{impUnitName},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="proName != null and proName != ''">
|
<if test="proName != null and proName != ''">
|
||||||
AND subquery1.proName like concat('%',#{proName},'%')
|
AND bp.pro_name like concat('%',#{proName},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="departName != null and departName != ''">
|
<if test="departName != null and departName != ''">
|
||||||
AND subquery1.proCenter like concat('%',#{departName},'%')
|
AND bp.pro_center like concat('%',#{departName},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="typeName != null and typeName != ''">
|
<if test="typeName != null and typeName != ''">
|
||||||
AND mt2.type_name like concat('%',#{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},'%')
|
AND mt.type_name like concat('%',#{typeModelName},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="projectIdList != null and projectIdList.size() > 0">
|
<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=")">
|
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="impUnit != null and impUnit != ''">
|
<if test="impUnit != null and impUnit != ''">
|
||||||
and subquery1.impUnit = #{impUnit}
|
and bp.imp_unit = #{impUnit}
|
||||||
</if>
|
</if>
|
||||||
GROUP BY mt.type_id
|
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>
|
||||||
|
|
||||||
<select id="getUsInfoList" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
|
<select id="getUsInfoList" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue