From 5524a0820112c4057899d214b3e3065deee8ad8e Mon Sep 17 00:00:00 2001 From: xiaofajia <1665375861@qq.com> Date: Wed, 11 Dec 2024 11:46:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=80=E5=A7=8B=E6=A3=80?= =?UTF-8?q?=E6=B5=8B->=E9=80=89=E6=8B=A9=E9=A1=B9=E7=9B=AE=EF=BC=8C?= =?UTF-8?q?=E6=9C=89=E9=97=AE=E9=A2=98=E5=BE=85=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/InspectionInfoController.java | 14 ++++++ .../service/IInspectionInfoService.java | 10 ++++ .../impl/InspectionInfoServiceImpl.java | 50 +++++++++++++++++-- 3 files changed, 70 insertions(+), 4 deletions(-) diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionInfoController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionInfoController.java index b89e8e07..4206cbc5 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionInfoController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionInfoController.java @@ -267,4 +267,18 @@ public class InspectionInfoController extends BaseController { public CommonResult isExamine(){ return success(inspectionInfoService.isExamine()); } + + /** + * 获取某个工单针对当前操作用户,某个状态的项目们 + * + * @author 小李 + * @date 10:48 2024/12/11 + * @param id 工单ID + * @param status 状态 + **/ + @GetMapping("/getWorkNodeByIdAndNow") + public CommonResult getWorkNodeByIdAndNow(Long id, String status){ + return success(inspectionInfoService.getWorkNodeByIdAndNow(id, status)); + } + } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java index c71c609d..64f922eb 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java @@ -109,4 +109,14 @@ public interface IInspectionInfoService extends IService * @return */ Boolean isExamine(); + + /** + * 获取某个工单针对当前操作用户,某个状态的项目们 + * + * @author 小李 + * @date 10:48 2024/12/11 + * @param id 工单ID + * @param status 状态 + **/ + Map getWorkNodeByIdAndNow(Long id, String status); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java index 0d99bf6a..c848ddac 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java @@ -3,10 +3,7 @@ package cn.iocoder.yudao.module.inspection.service.impl; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import cn.hutool.core.collection.CollUtil; @@ -57,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_CUS; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; /** * 【请填写功能名称】Service业务层处理 @@ -99,6 +97,9 @@ public class InspectionInfoServiceImpl extends ServiceImpl getWorkNodeByIdAndNow(Long id, String status){ + Long userId = SecurityFrameworkUtils.getLoginUserId(); + List roles = roleService.getByUserId(userId); + if (CollUtil.isEmpty(roles)){ + throw exception0(500, "查询角色为空"); + } + List roleIds = roles.stream().map(UserRoleDO::getRoleId).collect(Collectors.toList()); + List workNodes = workNodeService.list(new LambdaQueryWrapper() + .and(i -> + i.eq(InspectionWorkNode::getInspectionInfoId, id) + .in(InspectionWorkNode::getRoleId, roleIds) + .eq(InspectionWorkNode::getStatus, status) + )); + if (CollUtil.isEmpty(workNodes)){ + throw exception0(500, "查询节点为空"); + } + List projectIds = workNodes.stream().map(InspectionWorkNode::getProjectId).collect(Collectors.toList()); + if (CollUtil.isEmpty(projectIds)){ + throw exception0(500, "查询项目时为空"); + } + List projects = projectService.listByIds(projectIds); + if (CollUtil.isEmpty(projects)){ + throw exception0(500, "查询项目时为空"); + } + Map map = projects.stream().collect(Collectors.toMap(DlInspectionProject::getId, DlInspectionProject::getProjectName)); + Map result = new HashMap<>(); + workNodes.forEach(item -> { + result.put(item.getId(), map.get(item.getProjectId())); + }); + return result; + } }