| | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import liquibase.pro.packaged.Q; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.flowable.engine.TaskService; |
| | | import org.flowable.task.api.Task; |
| | | import org.jeecg.common.api.vo.FileUploadResult; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.constant.DataBaseConstant; |
| | |
| | | import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog; |
| | | import org.jeecg.modules.eam.constant.*; |
| | | import org.jeecg.modules.eam.entity.*; |
| | | import org.jeecg.modules.eam.mapper.EamEquipmentMapper; |
| | | import org.jeecg.modules.eam.mapper.EamMaintenanceStandardMapper; |
| | | import org.jeecg.modules.eam.mapper.EamSecondMaintenanceOrderMapper; |
| | | import org.jeecg.modules.eam.request.EamSecondMaintenanceQuery; |
| | | import org.jeecg.modules.eam.request.EamSecondMaintenanceRequest; |
| | | import org.jeecg.modules.eam.service.*; |
| | | import org.jeecg.modules.eam.tree.FindsEquipmentEamCenterUtil; |
| | | import org.jeecg.modules.eam.vo.EamEquipmentTree; |
| | | import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; |
| | | import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; |
| | |
| | | import org.jeecg.modules.flowable.service.IFlowTaskService; |
| | | import org.jeecg.modules.system.entity.BaseFactory; |
| | | import org.jeecg.modules.system.entity.BaseFactoryUser; |
| | | import org.jeecg.modules.system.mapper.BaseFactoryMapper; |
| | | import org.jeecg.modules.system.service.IBaseFactoryService; |
| | | import org.jeecg.modules.system.service.IBaseFactoryUserService; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private IEamEquipmentService eamEquipmentService; |
| | | @Autowired |
| | | private IEamReportRepairService eamReportRepairService; |
| | | @Autowired |
| | | private IEamEquipmentExtendService eamEquipmentExtendService; |
| | | @Autowired |
| | | private IEamBaseHFCodeService hfCodeService; |
| | | @Autowired |
| | | private IEamMaintenanceStandardDetailService eamMaintenanceStandardDetailService; |
| | | @Autowired |
| | | private EamMaintenanceStandardMapper eamMaintenanceStandardMapper; |
| | | @Resource |
| | | private BaseFactoryMapper baseFactoryMapper; |
| | | |
| | | @Override |
| | | public IPage<EamSecondMaintenanceOrder> queryPageList(Page<EamSecondMaintenanceOrder> page, EamSecondMaintenanceQuery query) { |
| | | QueryWrapper<EamSecondMaintenanceOrder> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("wmo.del_flag",CommonConstant.DEL_FLAG_0.toString()); |
| | | //用户数据权限 |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null) { |
| | |
| | | } |
| | | //查询条件过滤 |
| | | if (query != null) { |
| | | if (StringUtils.isNotBlank(query.getId())){ |
| | | queryWrapper.eq("wmo.id", query.getId()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getEquipmentId())) { |
| | | queryWrapper.eq("wmo.equipment_id", query.getEquipmentId()); |
| | | } |
| | |
| | | } |
| | | |
| | | return eamSecondMaintenanceOrderMapper.queryPageList(page, queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 批量新增树结构 |
| | | */ |
| | | @Override |
| | | public List<EamEquipmentTree> getTree(){ |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null) return Collections.emptyList(); |
| | | |
| | | // 构建通用查询条件 |
| | | QueryWrapper<EamMaintenanceStandard> baseQuery = new QueryWrapper<EamMaintenanceStandard>() |
| | | .eq("ems.maintenance_category", "SECOND_MAINTENANCE") |
| | | .eq("ems.standard_status", MaintenanceStandardStatusEnum.START.name()) |
| | | .eq("ems.del_flag", CommonConstant.DEL_FLAG_0.toString()); |
| | | |
| | | // 应用数据权限过滤 |
| | | applyDataPermissionFilter(sysUser, baseQuery); |
| | | |
| | | // 单次查询设备列表 |
| | | List<EamEquipment> equipmentList = eamMaintenanceStandardMapper.queryList(baseQuery); |
| | | if (CollectionUtils.isEmpty(equipmentList)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | // 获取关联的工厂代码 |
| | | Set<String> factoryOrgCodes = equipmentList.stream() |
| | | .map(EamEquipment::getFactoryOrgCode) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | // 单次查询所有工厂数据(包含完整树结构) |
| | | List<BaseFactory> allFactories = baseFactoryService.list( |
| | | new LambdaQueryWrapper<BaseFactory>() |
| | | .eq(BaseFactory::getDelFlag, CommonConstant.DEL_FLAG_0.toString()) |
| | | .orderByAsc(BaseFactory::getSorter)); |
| | | |
| | | // 提取权限关联的工厂节点ID(包含所有父节点) |
| | | Set<String> authorizedFactoryIds = extractAuthorizedFactoryIds( |
| | | allFactories, factoryOrgCodes); |
| | | |
| | | // 过滤出有效工厂结构 |
| | | List<BaseFactory> validFactories = allFactories.stream() |
| | | .filter(f -> authorizedFactoryIds.contains(f.getId())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // ===构建设备树 === |
| | | Map<String, List<EamEquipment>> equipmentMap = equipmentList.stream() |
| | | .collect(Collectors.groupingBy(EamEquipment::getFactoryOrgCode)); |
| | | |
| | | // 构建基础树 |
| | | List<EamEquipmentTree> treeList = FindsEquipmentEamCenterUtil.wrapEquipmentBaseFactoryTreeList(validFactories); |
| | | |
| | | // 填充设备数据 |
| | | populateEquipmentNodes(treeList, equipmentMap); |
| | | return treeList; |
| | | } |
| | | |
| | | // 应用数据权限条件(共用方法) |
| | | private void applyDataPermissionFilter(LoginUser user, QueryWrapper<EamMaintenanceStandard> query) { |
| | | if (StringUtils.isNotBlank(user.getEamEquipmentIds())) { |
| | | List<String> equipmentIds = Arrays.asList(user.getEamEquipmentIds().split(",")); |
| | | query.in("e.equipment_code", equipmentIds); |
| | | } else { |
| | | List<BaseFactoryUser> factoryUsers = baseFactoryUserService.list( |
| | | new LambdaQueryWrapper<BaseFactoryUser>() |
| | | .eq(BaseFactoryUser::getUserId, user.getId())); |
| | | |
| | | if (CollectionUtils.isNotEmpty(factoryUsers)) { |
| | | Set<String> factoryIds = factoryUsers.stream() |
| | | .map(BaseFactoryUser::getFactoryId) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | Set<String> factoryCodes = baseFactoryService.listByIds(factoryIds).stream() |
| | | .map(BaseFactory::getOrgCode) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | query.in("e.factory_org_code", factoryCodes); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 提取授权工厂ID |
| | | private Set<String> extractAuthorizedFactoryIds(List<BaseFactory> allFactories, Set<String> authOrgCodes) { |
| | | Set<String> result = new HashSet<>(); |
| | | // 构建ID->工厂的映射 |
| | | Map<String, BaseFactory> factoryMap = allFactories.stream() |
| | | .collect(Collectors.toMap(BaseFactory::getId, Function.identity())); |
| | | |
| | | // 逆向查找父节点链 |
| | | for (BaseFactory factory : allFactories) { |
| | | if (authOrgCodes.contains(factory.getOrgCode())) { |
| | | collectParentIds(factoryMap, factory.getId(), result); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | // 递归收集父节点ID |
| | | private void collectParentIds(Map<String, BaseFactory> factoryMap, String currentId, Set<String> idSet) { |
| | | if (StringUtils.isEmpty(currentId) || idSet.contains(currentId)) return; |
| | | |
| | | idSet.add(currentId); |
| | | BaseFactory factory = factoryMap.get(currentId); |
| | | if (factory != null && StringUtils.isNotBlank(factory.getParentId())) { |
| | | collectParentIds(factoryMap, factory.getParentId(), idSet); |
| | | } |
| | | } |
| | | |
| | | // 填充设备节点(非递归) |
| | | private void populateEquipmentNodes(List<EamEquipmentTree> treeList, |
| | | Map<String, List<EamEquipment>> equipmentMap) { |
| | | for (EamEquipmentTree node : treeList) { |
| | | |
| | | String orgCode = resolveOrgCodeFromTree(node); // 需实现该逻辑 |
| | | |
| | | // 关联设备数据 |
| | | List<EamEquipment> devices = equipmentMap.getOrDefault(orgCode, Collections.emptyList()); |
| | | if (!CollectionUtils.isEmpty(devices)) { |
| | | for (EamEquipment device : devices) { |
| | | EamEquipmentTree deviceNode = new EamEquipmentTree().convert(device); |
| | | deviceNode.setParentId(node.getKey()); |
| | | deviceNode.setType(2); |
| | | deviceNode.setLeaf(true); // 明确标记为叶子节点 |
| | | node.getChildren().add(deviceNode); |
| | | } |
| | | // 只有当存在设备时才标记为非叶子 |
| | | node.setLeaf(false); |
| | | } |
| | | |
| | | // 继续处理子节点(工厂层级) |
| | | if (!CollectionUtils.isEmpty(node.getChildren())) { |
| | | populateEquipmentNodes(node.getChildren(), equipmentMap); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 解析方法 |
| | | private String resolveOrgCodeFromTree(EamEquipmentTree node) { |
| | | BaseFactory factory =baseFactoryMapper.selectById(node.getKey()); |
| | | return factory != null ? factory.getOrgCode() : null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | eamMaintenanceStandardDetailList.forEach(item -> { |
| | | EamSecondMaintenanceOrderDetail detail = new EamSecondMaintenanceOrderDetail(); |
| | | BeanUtils.copyProperties(item, detail); |
| | | detail.setId(null); |
| | | detail.setOrderId(order.getId()); |
| | | requestTableDetailList.add(detail); |
| | | }); |
| | |
| | | throw new JeecgBootException("设备不存在,添加失败!"); |
| | | } |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if(sysUser == null || !BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { |
| | | throw new JeecgBootException("不是操作工,无法领取此工单!"); |
| | | if(sysUser != null) { |
| | | if (!BusinessCodeConst.PCR0001.equals(sysUser.getPost()) && !BusinessCodeConst.PCR0002.equals(sysUser.getPost())){ |
| | | throw new JeecgBootException("不是操作工,无法领取此工单!"); |
| | | } |
| | | } |
| | | entity.setOperator(sysUser.getUsername()); |
| | | List<String> usernames = new ArrayList<>(); |
| | | if (sysUser != null) { |
| | | if (BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { |
| | | entity.setOperator(sysUser.getUsername()); |
| | | usernames.add(entity.getOperator()); |
| | | } |
| | | if (BusinessCodeConst.PCR0002.equals(sysUser.getPost())) { |
| | | entity.setRepairman(sysUser.getUsername()); |
| | | usernames.add(entity.getRepairman()); |
| | | } |
| | | } |
| | | entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | entity.setActualStartTime(new Date()); |
| | | eamSecondMaintenanceOrderMapper.updateById(entity); |
| | | |
| | | //启动流程 |
| | | flowCommonService.initActBusiness("工单号: " + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";安装位置" + equipment.getInstallationPosition(), |
| | | entity.getId(), "IEamSecondMaintenanceOrderService", "second_maintenance_process", null); |
| | | flowCommonService.initActBusiness("工单号: " + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + "进行设备二级保养", |
| | | entity.getId(), "IEamSecondMaintenanceOrderService", "SecondMaintenance_Process", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", entity.getId()); |
| | | if (StrUtil.isEmpty(entity.getRemark())) { |
| | |
| | | variables.put("comment", entity.getRemark()); |
| | | } |
| | | variables.put("proofreading", true); |
| | | List<String> usernames = new ArrayList<>(); |
| | | usernames.add(entity.getOperator()); |
| | | variables.put("NextAssignee", usernames); |
| | | Result result = flowDefinitionService.startProcessInstanceByKey("second_maintenance_process", variables); |
| | | if (sysUser != null) { |
| | | if (BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { |
| | | variables.put("operator_task", usernames); |
| | | List<UserSelector> userSelectorList = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0002); |
| | | if (!CollectionUtils.isEmpty(userSelectorList)) { |
| | | List<String> usernameList = userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | variables.put("maintenance_task",usernameList); |
| | | } |
| | | }else if (BusinessCodeConst.PCR0002.equals(sysUser.getPost())) { |
| | | variables.put("maintenance_task", usernames); |
| | | List<UserSelector> userSelectorList = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0001); |
| | | if (!CollectionUtils.isEmpty(userSelectorList)) { |
| | | List<String> usernameList = userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | variables.put("operator_task",usernameList); |
| | | } |
| | | } |
| | | } |
| | | Result result = flowDefinitionService.startProcessInstanceByKey("SecondMaintenance_Process", variables); |
| | | if (result != null) { |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_SECOND_MAINTENANCE.name()); |
| | |
| | | } |
| | | request.setAssignee(user.getUsername()); |
| | | // 获取流程业务记录 |
| | | FlowMyBusiness flowMyBusiness = flowMyBusinessService.getFlowMyBusiness(request.getInstanceId()); |
| | | FlowMyBusiness flowMyBusiness = flowMyBusinessService.getFlowMyBusiness(request.getInstanceId(), request.getTaskId()); |
| | | if (flowMyBusiness == null) { |
| | | throw new JeecgBootException("流程实例不存在,请刷新后重试!"); |
| | | } |
| | |
| | | List<UserSelector> userSelectors; |
| | | switch (status) { |
| | | case UNDER_MAINTENANCE: |
| | | //保养中 |
| | | boolean parallelCompletion = flowTaskService.checkParallelCompletion(flowMyBusiness.getTaskId()); |
| | | //执行完成 |
| | | //设备管理员确认 |
| | | // String equipmentManager = equipment.getEquipmentManager(); |
| | | // if(StringUtils.isBlank(equipmentManager)) { |
| | | // throw new JeecgBootException("设备未分配设备管理员,无法进入下级审批!"); |
| | | // } |
| | | // userApprovalList = Collections.singletonList(equipmentManager); |
| | | values.put("dataId", entity.getId()); |
| | | values.put("organization", "二保执行结束"); |
| | | values.put("comment", "二保执行结束"); |
| | | // values.put("NextAssignee", userApprovalList); |
| | | request.setComment("二保执行结束"); |
| | | //设置entity |
| | | entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.WAIT_CONFIRM.name()); |
| | | entity.setActualEndTime(new Date()); |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.SECOND_MAINTENANCE_WAIT_CONFIRM.name()); |
| | | break; |
| | | case WAIT_CONFIRM: |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(),null, BusinessCodeConst.PCR0003); |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0004); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未分配给车间班组长,无法进入下级审批!"); |
| | | throw new JeecgBootException("设备未存在管理员,无法进入下级审批!"); |
| | | }else{ |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | if (parallelCompletion) { |
| | | values.put("NextAssignee", userApprovalList); |
| | | entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.WAIT_ADMIN_CONFIRM.name()); |
| | | entity.setActualEndTime(new Date()); |
| | | } |
| | | } |
| | | //班组长确认 |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | //设置entity |
| | | entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.WAIT_LEADER_CONFIRM.name()); |
| | | entity.setConfirmTime(new Date()); |
| | | break; |
| | | case WAIT_LEADER_CONFIRM: |
| | | if (BusinessCodeConst.PCR0001.equals(user.getPost())) { |
| | | entity.setOperator(user.getUsername()); |
| | | values.put("organization", "二保操作工执行结束"); |
| | | values.put("comment", "二保操作工执行结束"); |
| | | request.setComment("二保操作工执行结束"); |
| | | //处理对应详情 |
| | | if (CollectionUtils.isNotEmpty(request.getTableDetailList())){ |
| | | //删除原有数据 |
| | | List<EamSecondMaintenanceOrderDetail> addList = new ArrayList<>(); |
| | | //先删除原有 |
| | | LambdaQueryWrapper<EamSecondMaintenanceOrderDetail> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(EamSecondMaintenanceOrderDetail::getOrderId, entity.getId()); |
| | | queryWrapper.eq(EamSecondMaintenanceOrderDetail::getItemCategory,EamMaintenanceStandardDetailCategory.OPERATOR_MAINTENANCE.name()); |
| | | secondMaintenanceOrderDetailService.remove(queryWrapper); |
| | | request.getTableDetailList().forEach(tableDetail -> { |
| | | EamSecondMaintenanceOrderDetail eamMaintenanceStandardDetail=new EamSecondMaintenanceOrderDetail(); |
| | | BeanUtils.copyProperties(tableDetail, eamMaintenanceStandardDetail); |
| | | eamMaintenanceStandardDetail.setOrderId(entity.getId()); |
| | | eamMaintenanceStandardDetail.setCreateBy(user.getUsername()); |
| | | addList.add(eamMaintenanceStandardDetail); |
| | | }); |
| | | secondMaintenanceOrderDetailService.saveBatch(addList); |
| | | } |
| | | }else if (BusinessCodeConst.PCR0002.equals(user.getPost())) { |
| | | entity.setRepairman(user.getUsername()); |
| | | values.put("organization", "二保维修工执行结束"); |
| | | values.put("comment", "二保维修工执行结束"); |
| | | request.setComment("二保维修工执行结束"); |
| | | //处理对应详情 |
| | | if (CollectionUtils.isNotEmpty(request.getTableDetailList())){ |
| | | //删除原有数据 |
| | | List<EamSecondMaintenanceOrderDetail> addList = new ArrayList<>(); |
| | | //先删除原有 |
| | | LambdaQueryWrapper<EamSecondMaintenanceOrderDetail> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(EamSecondMaintenanceOrderDetail::getOrderId, entity.getId()); |
| | | queryWrapper.eq(EamSecondMaintenanceOrderDetail::getItemCategory,EamMaintenanceStandardDetailCategory.REPAIRER_MAINTENANCE.name()); |
| | | secondMaintenanceOrderDetailService.remove(queryWrapper); |
| | | request.getTableDetailList().forEach(tableDetail -> { |
| | | EamSecondMaintenanceOrderDetail eamMaintenanceStandardDetail=new EamSecondMaintenanceOrderDetail(); |
| | | BeanUtils.copyProperties(tableDetail, eamMaintenanceStandardDetail); |
| | | eamMaintenanceStandardDetail.setOrderId(entity.getId()); |
| | | eamMaintenanceStandardDetail.setCreateBy(user.getUsername()); |
| | | addList.add(eamMaintenanceStandardDetail); |
| | | }); |
| | | secondMaintenanceOrderDetailService.saveBatch(addList); |
| | | } |
| | | } |
| | | values.put("dataId", entity.getId()); |
| | | //设置entity |
| | | entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.COMPLETE.name()); |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name()); |
| | | break; |
| | | case WAIT_ADMIN_CONFIRM: |
| | | //管理员确认 |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0006); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未存在检查人,无法进入下级审批!"); |
| | | }else{ |
| | | userApprovalList= userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("dataId", entity.getId()); |
| | | if (StrUtil.isEmpty(request.getDealDescription())){ |
| | | request.setDealDescription(""); |
| | | } |
| | | values.put("organization",request.getDealDescription()); |
| | | values.put("comment", request.getDealDescription()); |
| | | values.put("manageUserResult",request.getManageUserResult()); |
| | | request.setComment(request.getDealDescription()); |
| | | if (request.getManageUserResult().equals("2")){ |
| | | entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | }else { |
| | | values.put("NextAssignee", userApprovalList); |
| | | entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.WAIT_INSPECTOR_CONFIRM.name()); |
| | | entity.setConfirmTime(new Date()); |
| | | entity.setManageUser(user.getUsername()); |
| | | entity.setProblemDescription(request.getProblemDescription()); |
| | | entity.setManageUserResult(request.getManageUserResult()); |
| | | entity.setDealDescription(request.getDealDescription()); |
| | | } |
| | | } |
| | | break; |
| | | case WAIT_INSPECTOR_CONFIRM: |
| | | //检查人确认 |
| | | if (StrUtil.isEmpty(request.getInspectConfirmComment())){ |
| | | request.setInspectConfirmComment(""); |
| | | } |
| | | values.put("dataId", entity.getId()); |
| | | values.put("organization",request.getInspectConfirmComment()); |
| | | values.put("comment", request.getInspectConfirmComment()); |
| | | values.put("inspectorResult",request.getInspectorResult()); |
| | | request.setComment(request.getInspectConfirmComment()); |
| | | if (request.getInspectorResult().equals("2")){ |
| | | entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.WAIT_ADMIN_CONFIRM.name()); |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0004); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未存在车间设备管理员,无法进入驳回审批!"); |
| | | }else{ |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | } |
| | | }else { |
| | | entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.COMPLETE.name()); |
| | | entity.setInspector(user.getUsername()); |
| | | entity.setInspectorResult(request.getInspectorResult()); |
| | | entity.setInspectConfirmComment(request.getInspectConfirmComment()); |
| | | entity.setInspectConfirmTime(new Date()); |
| | | } |
| | | break; |
| | | default: |
| | | throw new JeecgBootException("审批失败"); |
| | | } |
| | | request.setValues(values); |
| | | |
| | | // 完成流程任务 |
| | | Result result = flowTaskService.complete(request); |
| | | if (!result.isSuccess()) { |
| | | throw new JeecgBootException("审批失败,请刷新查看!"); |
| | | } |
| | | if (user.getPost().equals(BusinessCodeConst.PCR0004)&&request.getManageUserResult().equals("2")){ |
| | | //管理员拒绝,会签节点修改对应关系 |
| | | List<FlowMyBusiness> list = flowMyBusinessService.list(new LambdaQueryWrapper<FlowMyBusiness>().eq(FlowMyBusiness::getProcessInstanceId, request.getInstanceId())); |
| | | if (CollectionUtils.isNotEmpty(list)) { |
| | | list.forEach(item -> { |
| | | if (item.getTaskNameId().equals("maintenance_task")) { |
| | | //获取维修工岗位用户 |
| | | List<UserSelector> userSelectorList = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0002); |
| | | if (!CollectionUtils.isEmpty(userSelectorList)) { |
| | | List<String> usernameList = userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | item.setTodoUsers(JSON.toJSONString(usernameList)); |
| | | } |
| | | } |
| | | if (item.getTaskNameId().equals("operator_task")) { |
| | | //获取操作人岗位用户 |
| | | List<UserSelector> userSelectorList = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0001); |
| | | if (!CollectionUtils.isEmpty(userSelectorList)) { |
| | | List<String> usernameList = userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | item.setTodoUsers(JSON.toJSONString(usernameList)); |
| | | } |
| | | } |
| | | }); |
| | | flowMyBusinessService.updateBatchById(list); |
| | | } |
| | | } |
| | | //保存工单 |
| | | eamSecondMaintenanceOrderMapper.updateById(entity); |
| | | return entity; |