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 735d8c3c..da9583d2 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 @@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.inspection.entity.InspectionInfo; import cn.iocoder.yudao.module.inspection.service.IInspectionInfoService; +import cn.iocoder.yudao.module.inspection.service.IInspectionWorkNodeService; import cn.iocoder.yudao.util.ExcelUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -27,6 +28,9 @@ public class InspectionInfoController extends BaseController @Autowired private IInspectionInfoService inspectionInfoService; + @Autowired + private IInspectionWorkNodeService inspectionWorkNodeService; + /** * 查询【请填写功能名称】列表 */ @@ -102,7 +106,32 @@ public class InspectionInfoController extends BaseController * @return */ @GetMapping("geStelectInspection") - public CommonResult geStelectInspection(){ - return success(inspectionInfoService.geStelectInspection()); + public CommonResult geStelectInspection(@RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize){ + Page page = new Page<>(pageNum, pageSize); + return success(inspectionInfoService.geStelectInspection(page)); + } + + /** + * 获取工单详情 + * @param inspectionId 工单id + * @param workNodeId 节点id (geStelectInspection这个方法中返回了) + * @return + */ + @GetMapping("getInspectionInfo") + public CommonResult getInspectionInfo(Integer inspectionId, Integer workNodeId){ + return success(inspectionInfoService.getWorkNode(inspectionId,workNodeId)); + } + + /** + * 员工接单 + * @param inspectionId 工单id + * @param workNodeId 节点id (geStelectInspection这个方法中返回了) + * @return + */ + @PostMapping("orderTaking") + public CommonResult orderTaking(Integer inspectionId, Integer workNodeId){ + inspectionWorkNodeService.updateInspectionWorkNode(inspectionId,workNodeId); + return success("接单成功"); } } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionInfo.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionInfo.java index 2805635b..0d0a4dea 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionInfo.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionInfo.java @@ -148,6 +148,9 @@ public class InspectionInfo extends TenantBaseDO private Integer nowOrderNum; /** 开始检测时需要 传入 选择项目的id、角色id、排序 */ + @TableField(exist = false) private List inspectionWorkNodes; + /** 流程节点id*/ + @TableField(exist = false) private String workNodeId; } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionWorkNode.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionWorkNode.java index 3245b5d0..7b81c558 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionWorkNode.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionWorkNode.java @@ -75,7 +75,18 @@ public class InspectionWorkNode extends TenantBaseDO { /** * 处理人员工表id */ - private Integer dealUserId; + private Long dealUserId; + + /** + * 状态(0-待开始 1-进行中 2-已完成) + */ + private String status; + + + /** + * 1-退办理 2-选择重审 3-项目完成 + */ + private Integer selectType; } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionInfoMapper.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionInfoMapper.java index 4bf9c11b..401eaef0 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionInfoMapper.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionInfoMapper.java @@ -87,4 +87,10 @@ public interface InspectionInfoMapper extends BaseMapper , @Param("roleId") Long roleId, @Param("endTime")String endTime); + /** + * 查询当前用户符合条件的工单 + * @param page + * @return + */ + IPage selectByUser(@Param("page") IPage page, @Param("roleIds") List roleIds); } 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 5fc966d1..e760d14f 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 @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.inspection.service; +import cn.iocoder.yudao.module.inspection.vo.DlInspectionWorkNodeVo; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; @@ -79,5 +80,12 @@ public interface IInspectionInfoService extends IService * 根据当前登陆人获取可以选择的工单 * @return */ - List geStelectInspection(); + IPage geStelectInspection(IPage page); + + /** + * 获取工单详情 + * @param id + * @return + */ + DlInspectionWorkNodeVo getWorkNode(Integer inspectionId, Integer workNodeId); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionWorkNodeService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionWorkNodeService.java index b9697e6e..009b09af 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionWorkNodeService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionWorkNodeService.java @@ -12,5 +12,17 @@ import com.baomidou.mybatisplus.extension.service.IService; * @since 2024-10-31 */ public interface IInspectionWorkNodeService extends IService { + /** + * 员工接单 + * @param inspectionId + * @param workNodeId + */ + void updateInspectionWorkNode(Integer inspectionId, Integer workNodeId); + + /** + * 更新流程图片 步骤信息 + * @param inspectionWorkNode + */ + void updateImageAndStep(InspectionWorkNode inspectionWorkNode); } 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 604c05f0..ae8e7656 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 @@ -15,6 +15,7 @@ import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.custom.entity.CustomerMain; import cn.iocoder.yudao.module.custom.service.CustomerMainService; +import cn.iocoder.yudao.module.inspection.vo.DlInspectionWorkNodeVo; import cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo; import cn.iocoder.yudao.module.partner.service.IPartnerCustomerInfoService; import cn.iocoder.yudao.module.partner.service.IPartnerWorkerService; @@ -234,7 +235,13 @@ public class InspectionInfoServiceImpl extends ServiceImpl inspectionWorkNodes = inspectionInfo.getInspectionWorkNodes(); //将检测工单流程补充检测工单id - inspectionWorkNodes.stream().forEach(inspectionWorkNode -> inspectionWorkNode.setInspectionInfoId(inspectionInfo.getId())); + inspectionWorkNodes.stream().forEach(inspectionWorkNode -> { + //检测工单id + inspectionWorkNode.setInspectionInfoId(inspectionInfo.getId()); + //将节点状态设置为未开始 + inspectionWorkNode.setStatus("0"); + }); + workNodeService.saveBatch(inspectionWorkNodes); //检测步骤表插入检测开始 @@ -368,47 +375,40 @@ public class InspectionInfoServiceImpl extends ServiceImpl geStelectInspection() { + public IPage geStelectInspection(IPage page) { //获取当前登录人 LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); //获取当前登陆人的角色 List byUserId = roleService.getByUserId(loginUser.getId()); List roleIds = byUserId.stream().map(UserRoleDO::getRoleId).collect(Collectors.toList()); - //查询所有工单为进行中的 - List inspectionInfos = baseMapper.selectList(new LambdaQueryWrapper() - .eq(InspectionInfo::getStatus, 0)); - //根据工单id查询工单流程节点 - List infoIds = inspectionInfos.stream().map(inspectionInfo -> inspectionInfo.getId()).collect(Collectors.toList()); - if (ObjectUtils.isNotEmpty(infoIds)) { - List inspectionWorkNodes = workNodeService.list(new LambdaQueryWrapper() - .in(InspectionWorkNode::getInspectionInfoId, infoIds) - .eq(InspectionWorkNode::getDealUserId, null)); + return baseMapper.selectByUser(page,roleIds); + } - //工单集合 - List inspectionInfoList = new ArrayList<>(); + /** + * 获取工单详情 + * + * @param id + * @return + */ + @Override + public DlInspectionWorkNodeVo getWorkNode(Integer inspectionId, Integer workNodeId) { + //查询工单 + InspectionInfo inspectionInfo = this.getById(inspectionId); + //根据工单id查询流程节点 + InspectionWorkNode inspectionWorkNode = workNodeService.getById(new LambdaQueryWrapper() + .eq(InspectionWorkNode::getInspectionInfoId, workNodeId)); + //根据工单id查询步骤 + List inspectionStepInfos = inspectionStepInfoService.list(new LambdaQueryWrapper() + .eq(InspectionStepInfo::getInspectionInfoId, inspectionId)); - //根据工单id查询工单流程节点 - Map> inspectionWorkNodeMap = inspectionWorkNodes.stream().collect(Collectors.groupingBy(InspectionWorkNode::getInspectionInfoId)); - for (InspectionInfo inspectionInfo : inspectionInfos) { - List inspectionWorkNodeList = inspectionWorkNodeMap.get(inspectionInfo.getId()); - //遍历工单流程节点 流程为key - if (CollectionUtil.isNotEmpty(inspectionWorkNodeList)) { - Map inspectionWorkMap = inspectionWorkNodeList.stream().collect(Collectors.toMap(InspectionWorkNode::getOrderNum, item -> item)); - InspectionWorkNode inspectionWorkNode = inspectionWorkMap.get(inspectionInfo.getNowOrderNum()); - if (inspectionWorkNode != null){ - //判断当前项目 当前登录人员 是否可以处理 - if (roleIds.contains(inspectionWorkNode.getRoleId())){ - inspectionInfo.setWorkNodeId(inspectionWorkNode.getId()); - inspectionInfoList.add(inspectionInfo); - } - } - } - } - return inspectionInfoList; - } - return null; + DlInspectionWorkNodeVo dlInspectionWorkNodeVo = new DlInspectionWorkNodeVo(); + dlInspectionWorkNodeVo.setInspectionInfo(inspectionInfo); + dlInspectionWorkNodeVo.setNode(inspectionWorkNode); + dlInspectionWorkNodeVo.setSteps(inspectionStepInfos); + return dlInspectionWorkNodeVo; } } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionWorkNodeServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionWorkNodeServiceImpl.java index 69c91b68..22b6d7cb 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionWorkNodeServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionWorkNodeServiceImpl.java @@ -1,11 +1,27 @@ package cn.iocoder.yudao.module.inspection.service.impl; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject; +import cn.iocoder.yudao.module.inspection.entity.InspectionInfo; +import cn.iocoder.yudao.module.inspection.entity.InspectionStepInfo; import cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode; import cn.iocoder.yudao.module.inspection.mapper.InspectionWorkNodeMapper; +import cn.iocoder.yudao.module.inspection.service.DlInspectionProjectService; +import cn.iocoder.yudao.module.inspection.service.IInspectionInfoService; import cn.iocoder.yudao.module.inspection.service.IInspectionWorkNodeService; +import cn.iocoder.yudao.module.inspection.service.InspectionStepInfoService; +import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import cn.iocoder.yudao.module.system.service.user.AdminUserService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** *

* 检测流程表 服务实现类 @@ -16,5 +32,122 @@ import org.springframework.stereotype.Service; */ @Service public class InspectionWorkNodeServiceImpl extends ServiceImpl implements IInspectionWorkNodeService { + @Autowired + private IInspectionInfoService inspectionInfoService; + @Autowired + private AdminUserService userService; + @Autowired + private DlInspectionProjectService inspectionProjectService; + @Autowired + private InspectionStepInfoService inspectionStepService; -} + /** + * 员工接单 + * @param inspectionId + * @param workNodeId + */ + @Override + public void updateInspectionWorkNode(Integer inspectionId, Integer workNodeId) { + //获取当前登录人 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + //当前登陆人 就是检测人 + AdminUserDO workerUser = userService.getUser(loginUser.getId()); + //根据工单id获取工单 + InspectionInfo inspectionInfo = inspectionInfoService.getById(inspectionId); + if (ObjectUtil.isNull(inspectionInfo)) { + throw new RuntimeException("工单不存在"); + } + //根据流程id获取流程 + InspectionWorkNode workNode = this.getById(workNodeId); + if (ObjectUtil.isNull(workNode)) { + throw new RuntimeException("流程不存在"); + } + //判断当前流程是否已被接单 + if (ObjectUtil.isNotNull(workNode.getDealUserId())) { + throw new RuntimeException("当前流程已被接单"); + } + //修改流程相关信息 + workNode.setDealUserId(workerUser.getId()); + workNode.setDealUserName(workerUser.getNickname()); + workNode.setStatus("1"); + //更新 + this.updateById(workNode); + } + + /** + * 更新流程图片 步骤信息 + * + * @param inspectionWorkNode + */ + @Override + public void updateImageAndStep(InspectionWorkNode inspectionWorkNode) { + //根据流程id获取流程 + InspectionWorkNode workNode = this.getById(inspectionWorkNode.getId()); + + //根据工单id查询工单 + InspectionInfo inspectionInfo = inspectionInfoService.selectInspectionInfoById(inspectionWorkNode.getInspectionInfoId()); + + //判断是否是最后一个项目 根据工单id查询 + //根据工单id查询流程列表 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(InspectionWorkNode::getInspectionInfoId, inspectionWorkNode.getInspectionInfoId()); + List inspectionWorkNodes = this.list(queryWrapper); + //判断当前是否是最后一个项目 根据顺序号判断 + boolean flag = hasNextNode(inspectionWorkNodes, workNode); + + // 插入步骤信息 + InspectionStepInfo inspectionStepInfo = new InspectionStepInfo(); + inspectionStepInfo.setInspectionInfoId(Integer.parseInt(String.valueOf(inspectionWorkNode.getInspectionInfoId()))); + + //根据projectId查询项目名称 + DlInspectionProject project = inspectionProjectService.getOne(new LambdaQueryWrapper() + .eq(DlInspectionProject::getId, inspectionWorkNode.getProjectId())); + String stepTitle = project.getProjectName() + "项目检测完成"; + inspectionStepInfo.setTitle(stepTitle); + inspectionStepInfo.setContent(inspectionWorkNode.getDealImages()); + inspectionStepService.save(inspectionStepInfo); + if (!flag) { + stepTitle = "检测结束"; + //设置工单状态为已完成 + inspectionInfo.setStatus("1"); + //设置工单通过 + inspectionInfo.setIsPass("1"); + //设置工单结束时间 + inspectionInfo.setEndTime(DateUtil.date()); + + //步骤结束 + inspectionStepInfo = new InspectionStepInfo(); + inspectionStepInfo.setTitle(stepTitle); + inspectionStepService.save(inspectionStepInfo); + } else { + //修改工单表当前流程 + inspectionInfo.setNowOrderNum(workNode.getOrderNum() + 1); + } + + //将节点状态改为已完成 + inspectionWorkNode.setStatus("2"); + //更新流程节点表 + baseMapper.updateById(inspectionWorkNode); + //更细工单状态 + inspectionInfoService.updateById(inspectionInfo); + } + + /** + * 判断传入的 InspectionWorkNode 对象是否在集合中有后续项目 + * + * @param nodes InspectionWorkNode 对象的集合 + * @param currentNode 当前需要判断的 InspectionWorkNode 对象 + * @return 如果存在后续项目返回 true,否则返回 false + */ + public boolean hasNextNode(List nodes, InspectionWorkNode currentNode) { + int currentOrderNum = currentNode.getOrderNum(); + + // 遍历集合中的所有节点,检查是否有 orderNum 大于当前节点的 + for (InspectionWorkNode node : nodes) { + if (node.getOrderNum() > currentOrderNum) { + return true; + } + } + return false; + } +} \ No newline at end of file diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/DlInspectionWorkNodeVo.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/DlInspectionWorkNodeVo.java new file mode 100644 index 00000000..b79bd971 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/DlInspectionWorkNodeVo.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.inspection.vo; + +import cn.iocoder.yudao.module.inspection.entity.InspectionInfo; +import cn.iocoder.yudao.module.inspection.entity.InspectionStepInfo; +import cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode; +import lombok.Data; + +import java.util.List; + +@Data +public class DlInspectionWorkNodeVo { + /** + * 检测单 + */ + private InspectionInfo inspectionInfo; + /** + * 流程节点 + */ + private InspectionWorkNode node; + /** + * 步骤 + */ + private List steps; +} diff --git a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml index 85d4c0a5..1c91523f 100644 --- a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml @@ -266,4 +266,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by ins.start_time desc +