diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java index b7a3936f..0523ed15 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java @@ -1830,16 +1830,13 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { // 第1步:从协议中获取总领料数量(原listL5逻辑) Map totalLeaseNums = new HashMap<>(); if (!CollectionUtils.isEmpty(agreementList)) { - for (AgreementVo agreementVo : agreementList) { - BackApplyInfo backApplyInfo = new BackApplyInfo(); - backApplyInfo.setAgreementId(Long.valueOf(agreementVo.getAgreementId())); - List listL4 = mapper.getUseTypeTreeL4(backApplyInfo); - - if (!CollectionUtils.isEmpty(listL4)) { - for (TypeTreeNode node : listL4) { - if (node.getTypeId() != 0L && node.getNum() != null) { - totalLeaseNums.merge(node.getTypeId(), node.getNum(), BigDecimal::add); - } + // 获取agreementList中的协议id集合 + List agreementIds = agreementList.stream().map(agreementVo -> Long.valueOf(agreementVo.getAgreementId())).collect(Collectors.toList()); + List listL4 = mapper.getTeamClzTree(agreementIds); + if (!CollectionUtils.isEmpty(listL4)) { + for (TypeTreeNode node : listL4) { + if (node.getTypeId() != 0L && node.getNum() != null) { + totalLeaseNums.merge(node.getTypeId(), node.getNum(), BigDecimal::add); } } } @@ -1852,15 +1849,11 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { List listAgreement = materialLeaseInfoMapper.getAgreementIdByProId(bean); if (!CollectionUtils.isEmpty(listAgreement)) { - for (BmAgreementInfo agreementInfo : listAgreement) { - bean.setAgreementId(agreementInfo.getAgreementId()); - List list6 = materialLeaseInfoMapper.getUseTypeTree(bean); - - if (!CollectionUtils.isEmpty(list6)) { - for (TypeTreeNode node : list6) { - if (node.getTypeId() != 0L && node.getNum() != null) { - usedNums.merge(node.getTypeId(), node.getNum(), BigDecimal::add); - } + List list6 = materialLeaseInfoMapper.getPlUseTypeTree(listAgreement); + if (!CollectionUtils.isEmpty(list6)) { + for (TypeTreeNode node : list6) { + if (node.getTypeId() != 0L && node.getNum() != null) { + usedNums.merge(node.getTypeId(), node.getNum(), BigDecimal::add); } } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java index bf0ac728..3e87c89b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java @@ -793,7 +793,6 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { //查询目前还有库存的设备 List recordList = materialMachineMapper.getRetainInfoList(bean); - List infos = new ArrayList<>(); if (CollectionUtils.isNotEmpty(recordList)) { inCountNum = recordList.stream() .filter(item -> "0".equals(item.getUnitValue())) @@ -811,17 +810,6 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { .filter(Objects::nonNull) .distinct() .count()); - // 获取集合中departName不为空,且去重的数据存放在新集合中 - List distinctDepartNames = recordList.stream() - // 过滤出departName不为空的元素 - .filter(entity -> StringUtils.isNotBlank(entity.getDepartName())) - // 根据departName进行去重 - .distinct() - // 收集到新的List集合中 - .collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(distinctDepartNames)) { - infos.addAll(distinctDepartNames); - } } else { info.setProNum(0); } @@ -834,26 +822,12 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { .filter(Objects::nonNull) .distinct() .count()); - // 获取集合中departName不为空,且去重的数据存放在新集合中 - List userInfoList = usList.stream() - // 过滤出departName不为空的元素 - .filter(entity -> StringUtils.isNotBlank(entity.getDepartName())) - // 根据departName进行去重 - .distinct() - // 收集到新的List集合中 - .collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(userInfoList)) { - infos.addAll(userInfoList); - } } else { info.setTeamNum(0); } - if (CollectionUtils.isNotEmpty(infos)) { - info.setDepartNum((int) infos.stream() - .map(MaterialRetainedEquipmentInfo::getDepartName) - .filter(Objects::nonNull) - .distinct() - .count()); + List departNameList = materialMachineMapper.getDepartNameList(bean); + if (CollectionUtils.isNotEmpty(departNameList)) { + info.setDepartNum(departNameList.size()); } else { info.setDepartNum(0); } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml index 97cb6206..305aec59 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml @@ -770,8 +770,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit WHERE sai.`status` = '0' + AND mm.ma_status = 2 AND mt.jiju_type = 2 AND sai.ma_id IS NOT NULL + AND mt2.type_id not in (6032,6008,6270,6012,6761) and sd.dept_name LIKE CONCAT('%', #{impUnitName}, '%') @@ -1597,14 +1599,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"