From 6cf49d88b1acc3031da00f963ce354e58457376d Mon Sep 17 00:00:00 2001 From: furongxin <419481438@qq.com> Date: Thu, 22 May 2025 09:06:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(smartfactory):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=B7=A5=E5=8E=82=E4=B8=BB=E7=AE=A1=E6=9D=83=E9=99=90=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=97=B6=E7=9A=84=E7=A9=BA=E6=8C=87=E9=92=88=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 HandlingGroupAmountSpecificationsServiceImpl 类中,增加了对 factoryId 不为空的过滤 - 修复了在 getHandlingGroupAmountSpecificationsPage 和 getTotalNum 方法中可能发生的空指针异常 - 优化了代码逻辑,提高了系统稳定性 --- .../HandlingGroupAmountSpecificationsServiceImpl.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsServiceImpl.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsServiceImpl.java index 6802424e..972881f8 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsServiceImpl.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsServiceImpl.java @@ -15,7 +15,6 @@ import cn.iocoder.yudao.module.smartfactory.service.handlingspecifications.Handl import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.springframework.stereotype.Service; @@ -69,8 +68,9 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro public PageResult getHandlingGroupAmountSpecificationsPage(HandlingGroupAmountSpecificationsPageReqVO pageReqVO) { // 判断当前登录人是否属于工厂主管 List deptRespDTOS = deptApi.getDeptByLeaderId(getLoginUserId()).getCheckedData(); - if (CollUtil.isNotEmpty(deptRespDTOS)) { - pageReqVO.setFactoryIds(deptRespDTOS.stream().map(DeptRespDTO::getFactoryId).distinct().collect(Collectors.toList())); + List factoryDeptVOs = deptRespDTOS.stream().filter(item -> item.getFactoryId() != null).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(factoryDeptVOs)) { + pageReqVO.setFactoryIds(factoryDeptVOs.stream().map(DeptRespDTO::getFactoryId).distinct().collect(Collectors.toList())); } IPage pageResult = handlingGroupAmountSpecificationsMapper.getHandlingGroupAmountSpecificationsPage(MyBatisUtils.buildPage(pageReqVO), pageReqVO); return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); @@ -170,8 +170,9 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro public HandlingGroupAmountSpecificationsTotalNumVO getTotalNum(HandlingGroupAmountSpecificationsTotalNumDTO dto) { // 判断当前登录人是否属于工厂主管 List deptRespDTOS = deptApi.getDeptByLeaderId(getLoginUserId()).getCheckedData(); - if (CollUtil.isNotEmpty(deptRespDTOS)) { - dto.setFactoryIds(deptRespDTOS.stream().map(DeptRespDTO::getFactoryId).distinct().collect(Collectors.toList())); + List factoryDeptVOs = deptRespDTOS.stream().filter(item -> item.getFactoryId() != null).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(factoryDeptVOs)) { + dto.setFactoryIds(factoryDeptVOs.stream().map(DeptRespDTO::getFactoryId).distinct().collect(Collectors.toList())); } return handlingGroupAmountSpecificationsMapper.getTotalNum(dto); }