| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import org.jeecg.common.constant.DataBaseConstant; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.StrUtils; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.constant.EquipmentMaintenanceStatus; |
| | | import org.jeecg.modules.eam.constant.EquipmentOperationTagEnum; |
| | | import org.jeecg.modules.eam.constant.ThirdMaintenanceStatusEnum; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.entity.EamThirdMaintenanceOrder; |
| | | import org.jeecg.modules.eam.entity.EamThirdMaintenanceOrderDetail; |
| | | import org.jeecg.modules.eam.constant.*; |
| | | import org.jeecg.modules.eam.entity.*; |
| | | import org.jeecg.modules.eam.mapper.EamThirdMaintenanceOrderMapper; |
| | | import org.jeecg.modules.eam.request.EamThirdMaintenanceQuery; |
| | | import org.jeecg.modules.eam.request.EamThirdMaintenanceRequest; |
| | |
| | | import org.jeecg.modules.system.service.IBaseFactoryService; |
| | | import org.jeecg.modules.system.service.IBaseFactoryUserService; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.jeecg.modules.system.vo.UserSelector; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | @Autowired |
| | | private IEamEquipmentService eamEquipmentService; |
| | | @Autowired |
| | | private IEamReportRepairService eamReportRepairService; |
| | | @Autowired |
| | | private IEamEquipmentExtendService eamEquipmentExtendService; |
| | | |
| | | @Resource |
| | | private IBaseFactoryUserService baseFactoryUserService; |
| | | @Resource |
| | | private IBaseFactoryService baseFactoryService; |
| | | |
| | | @Resource |
| | | private IEamBaseHFCodeService eamBaseHFCodeService; |
| | | @Resource |
| | | private IEamThirdMaintenanceOrderDetailService eamThirdMaintenanceOrderDetailService; |
| | | |
| | | @Override |
| | | public IPage<EamThirdMaintenanceOrder> queryPageList(Page<EamThirdMaintenanceOrder> page, EamThirdMaintenanceQuery query) { |
| | |
| | | Set<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toSet()); |
| | | Set<String> factoryCode = baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getOrgCode).collect(Collectors.toSet()); |
| | | queryWrapper.in("e.factory_org_code", factoryCode); |
| | | }else { |
| | | } else { |
| | | return page; |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean addMaintenance(EamThirdMaintenanceRequest request) { |
| | | public Result<String> addMaintenance(EamThirdMaintenanceRequest request) { |
| | | if (request == null) { |
| | | return Result.error("添加的对象不能为空!"); |
| | | } |
| | | if (CollectionUtil.isEmpty(request.getTableDetailList())) { |
| | | return Result.error("保养项不能为空!"); |
| | | } |
| | | EamEquipment equipment = eamEquipmentService.getById(request.getEquipmentId()); |
| | | if (equipment == null) { |
| | | throw new JeecgBootException("设备不存在,添加失败!"); |
| | | return Result.error("设备不存在,添加失败!"); |
| | | } |
| | | EamThirdMaintenanceOrder order = new EamThirdMaintenanceOrder(); |
| | | order.setOrderNum(request.getOrderNum()); |
| | | order.setEquipmentId(request.getEquipmentId()); |
| | | order.setStandardId(request.getStandardId()); |
| | | order.setMaintenanceDate(request.getMaintenanceDate()); |
| | | order.setOperator(request.getOperator()); |
| | | order.setRemark(request.getRemark()); |
| | | //状态初始化 |
| | | order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.WAIT_MAINTENANCE.name()); |
| | | order.setCreationMethod(request.getCreationMethod()); |
| | | //删除标记 |
| | | order.setDelFlag(CommonConstant.DEL_FLAG_0); |
| | | //HF码处理 三保移交单HF编码 |
| | | EamBaseHFCode hFCodeA = eamBaseHFCodeService.selectByCategory(HfTemplateCategoryEnum.THIRD_MAINTENANCE_HANDOVER.name()); |
| | | if (hFCodeA == null) { |
| | | return Result.error("添加失败,未配置三保移交单HF编码!"); |
| | | } |
| | | order.setHfCodeA(hFCodeA.getHfCode()); |
| | | // 三保验收单HF编码 |
| | | EamBaseHFCode hFCodeB = eamBaseHFCodeService.selectByCategory(HfTemplateCategoryEnum.THIRD_MAINTENANCE_ACCEPTANCE.name()); |
| | | if (hFCodeB == null) { |
| | | return Result.error("添加失败,未配置三保验收单HF编码!"); |
| | | } |
| | | order.setHfCodeB(hFCodeB.getHfCode()); |
| | | eamThirdMaintenanceOrderMapper.insert(order); |
| | | //处理明细数据 |
| | | if (CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | request.getTableDetailList().forEach(tableDetail -> { |
| | | // tableDetail.setId(null); |
| | | tableDetail.setId(null); |
| | | tableDetail.setOrderId(order.getId()); |
| | | }); |
| | | thirdMaintenanceOrderDetailService.saveBatch(request.getTableDetailList()); |
| | | } |
| | | |
| | | //判断是否存在保养人 如果存在则启动流程 |
| | | // if (StringUtils.isNotBlank(order.getOperator())) { |
| | | // //启动流程 |
| | | // flowCommonService.initActBusiness("工单号:" + order.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";安装位置" + equipment.getInstallationPosition(), |
| | | // order.getId(), "IEamThirdMaintenanceOrderService", "third_maintenance_process", null); |
| | | // Map<String, Object> variables = new HashMap<>(); |
| | | // variables.put("dataId", order.getId()); |
| | | // if (StrUtil.isEmpty(order.getRemark())) { |
| | | // variables.put("organization", "新增三保工单默认启动流程"); |
| | | // variables.put("comment", "新增三保工单默认启动流程"); |
| | | // } else { |
| | | // variables.put("organization", order.getRemark()); |
| | | // variables.put("comment", order.getRemark()); |
| | | // } |
| | | // variables.put("proofreading", true); |
| | | // //并行任务会签 |
| | | // variables.put("maintenance_execution", Collections.singletonList(request.getOperator())); |
| | | //// variables.put("precision_check", Collections.singletonList(equipment.getEquipmentManager())); |
| | | // Result result = flowDefinitionService.startProcessInstanceByKey("third_maintenance_process", variables); |
| | | // if (result != null) { |
| | | // //更新设备保养状态 |
| | | // eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_THIRD_MAINTENANCE.name()); |
| | | // return result.isSuccess(); |
| | | // } |
| | | // } |
| | | |
| | | return true; |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | throw new JeecgBootException("只有待保养状态的数据才可编辑!"); |
| | | } |
| | | entity.setMaintenanceDate(request.getMaintenanceDate()); |
| | | entity.setOperator(request.getOperator()); |
| | | entity.setRemark(request.getRemark()); |
| | | |
| | | eamThirdMaintenanceOrderMapper.updateById(entity); |
| | |
| | | List<String> ids = request.getRemoveDetailList().stream().map(EamThirdMaintenanceOrderDetail::getId).collect(Collectors.toList()); |
| | | thirdMaintenanceOrderDetailService.removeBatchByIds(ids); |
| | | } |
| | | //判断是否存在保养人 如果存在则启动流程 |
| | | if (StringUtils.isNotBlank(entity.getOperator())) { |
| | | //启动流程 |
| | | flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";安装位置" + equipment.getInstallationPosition(), |
| | | entity.getId(), "IEamThirdMaintenanceOrderService", "third_maintenance_process", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", entity.getId()); |
| | | if (StrUtil.isEmpty(entity.getRemark())) { |
| | | variables.put("organization", "新增三保工单默认启动流程"); |
| | | variables.put("comment", "新增三保工单默认启动流程"); |
| | | } else { |
| | | variables.put("organization", entity.getRemark()); |
| | | variables.put("comment", entity.getRemark()); |
| | | } |
| | | variables.put("proofreading", true); |
| | | //并行任务会签 |
| | | variables.put("maintenance_execution", Collections.singletonList(request.getOperator())); |
| | | // variables.put("precision_check", Collections.singletonList(equipment.getEquipmentManager())); |
| | | Result result = flowDefinitionService.startProcessInstanceByKey("third_maintenance_process", variables); |
| | | if (result != null) { |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_THIRD_MAINTENANCE.name()); |
| | | return result.isSuccess(); |
| | | } |
| | | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | |
| | | if (equipment == null) { |
| | | throw new JeecgBootException("设备不存在,添加失败!"); |
| | | } |
| | | // if (StringUtils.isBlank(equipment.getEquipmentManager())) { |
| | | // throw new JeecgBootException("设备未分配设备管理员,无法进入下级审批!"); |
| | | // } |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null || !BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { |
| | | throw new JeecgBootException("不是操作工,无法领取此工单!"); |
| | | if (sysUser == null || !BusinessCodeConst.PCR0002.equals(sysUser.getPost())) { |
| | | throw new JeecgBootException("不是维修工,无法领取此工单!"); |
| | | } |
| | | entity.setOperator(sysUser.getUsername()); |
| | | entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | entity.setRepairman(sysUser.getUsername()); |
| | | entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.WAIT_CHECK.name()); |
| | | entity.setActualStartTime(new Date()); |
| | | eamThirdMaintenanceOrderMapper.updateById(entity); |
| | | |
| | | //启动流程 |
| | | flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";安装位置" + equipment.getInstallationPosition(), |
| | | flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode(), |
| | | entity.getId(), "IEamThirdMaintenanceOrderService", "third_maintenance_process", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | // boolean equipmentPrecisionFlag = precisionCheckDetailService.hasPrecisionCheckDetail(entity.getId()); |
| | | // variables.put("equipmentPrecisionFlag", equipmentPrecisionFlag); |
| | | variables.put("dataId", entity.getId()); |
| | | if (StrUtil.isEmpty(entity.getRemark())) { |
| | | variables.put("organization", "新增三保工单默认启动流程"); |
| | |
| | | variables.put("comment", entity.getRemark()); |
| | | } |
| | | variables.put("proofreading", true); |
| | | //并行任务会签 |
| | | variables.put("maintenance_execution", Collections.singletonList(sysUser.getUsername())); |
| | | // variables.put("precision_check", Collections.singletonList(equipment.getEquipmentManager())); |
| | | // 设置下一步处理人 |
| | | List<String> usernames = new ArrayList<>(); |
| | | usernames.add(entity.getRepairman()); |
| | | variables.put("NextAssignee", usernames); |
| | | Result result = flowDefinitionService.startProcessInstanceByKey("third_maintenance_process", variables); |
| | | if (result != null) { |
| | | //更新设备保养状态 |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @EquipmentHistoryLog(operationTag = EquipmentOperationTagEnum.THIRD_MAINTENANCE, businessTable = "eam_third_maintenance_order") |
| | | public EamThirdMaintenanceOrder approval(EamThirdMaintenanceRequest request) { |
| | | EamThirdMaintenanceOrder entity = eamThirdMaintenanceOrderMapper.selectById(request.getId()); |
| | | if (entity == null) { |
| | | throw new JeecgBootException("审批的数据已删除,请刷新重试!"); |
| | | public EamThirdMaintenanceOrder approval(EamThirdMaintenanceRequest eamThirdMaintenanceRequest) { |
| | | EamThirdMaintenanceOrder eamThirdMaintenanceOrder = eamThirdMaintenanceOrderMapper.selectById(eamThirdMaintenanceRequest.getId()); |
| | | if (eamThirdMaintenanceOrder == null) { |
| | | throw new JeecgBootException("待处理的数据已删除,请刷新重试!"); |
| | | } |
| | | // // 获取当前登录用户 |
| | | // LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | // if (user == null || StrUtil.isBlank(user.getId())) { |
| | | // throw new JeecgBootException("未获取到登录用户,请重新登录后再试!"); |
| | | // } |
| | | // request.setAssignee(user.getUsername()); |
| | | // // 获取流程业务记录 |
| | | // FlowMyBusiness flowMyBusiness = flowMyBusinessService.getFlowMyBusiness(request.getInstanceId(), request.getTaskId()); |
| | | // if (flowMyBusiness == null) { |
| | | // throw new JeecgBootException("流程实例不存在,请刷新后重试!"); |
| | | // } |
| | | // |
| | | // boolean userAuthorized = isUserAuthorized(flowMyBusiness, user); |
| | | // if (!userAuthorized) { |
| | | // throw new JeecgBootException("用户无权操作此任务,请刷新后重试!"); |
| | | // } |
| | | // // 认领任务 |
| | | // if (!claimTask(flowMyBusiness.getTaskId(), user)) { |
| | | // throw new JeecgBootException("任务不存在、已完成或已被他人认领!"); |
| | | // } |
| | | // |
| | | // EamEquipment equipment = eamEquipmentService.getById(entity.getEquipmentId()); |
| | | // if (equipment == null) { |
| | | // throw new JeecgBootException("设备不存在,请检查!"); |
| | | // } |
| | | // |
| | | // ThirdMaintenanceStatusEnum status = ThirdMaintenanceStatusEnum.getInstance(entity.getMaintenanceStatus()); |
| | | // if (status == null) { |
| | | // return null; |
| | | // } |
| | | // //流程变量 |
| | | // Map<String, Object> values = new HashMap<>(); |
| | | // List<String> userApprovalList; |
| | | // List<UserSelector> userSelectors; |
| | | // switch (status) { |
| | | // case UNDER_MAINTENANCE: |
| | | // boolean parallelCompletion = flowTaskService.checkParallelCompletion(flowMyBusiness.getTaskId()); |
| | | // //执行完成 |
| | | // userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), null, BusinessCodeConst.PCR0006); |
| | | // if (CollectionUtil.isEmpty(userSelectors)) { |
| | | // throw new JeecgBootException("设备未分配给车间班组长,无法进入下级审批!"); |
| | | // } |
| | | // userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | // values.put("dataId", entity.getId()); |
| | | // values.put("organization", "三保执行结束"); |
| | | // values.put("comment", "三保执行结束"); |
| | | // if (parallelCompletion) { |
| | | // values.put("NextAssignee", userApprovalList); |
| | | // } |
| | | // request.setComment("三保执行结束"); |
| | | // //设置entity |
| | | // if (parallelCompletion) { |
| | | // entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.WAIT_CONFIRM.name()); |
| | | // entity.setActualEndTime(new Date()); |
| | | // } |
| | | // if ("maintenance_execution".equals(flowMyBusiness.getTaskNameId())) { |
| | | // //执行保养 |
| | | // //处理附件 |
| | | // if (CollectionUtil.isNotEmpty(request.getImageFilesResult())) { |
| | | // List<FileUploadResult> fileUploadResultList = request.getImageFilesResult(); |
| | | // ObjectMapper mapper = new ObjectMapper(); |
| | | // try { |
| | | // String referenceFile = mapper.writeValueAsString(fileUploadResultList); |
| | | // entity.setImageFiles(referenceFile); |
| | | // } catch (JsonProcessingException e) { |
| | | // log.error("JSON转换失败:" + e.getMessage(), e); |
| | | // } |
| | | // } |
| | | // //处理详情 |
| | | // if (CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | // thirdMaintenanceOrderDetailService.updateBatchById(request.getTableDetailList()); |
| | | // } |
| | | // } else if ("precision_check".equals(flowMyBusiness.getTaskNameId())) { |
| | | // entity.setPrecisionChecker(user.getUsername()); |
| | | // entity.setPrecisionCheckTime(new Date()); |
| | | // //处理精度检验 |
| | | // if (CollectionUtil.isNotEmpty(request.getPrecisionDetailList())) { |
| | | // precisionCheckDetailService.updateBatchById(request.getPrecisionDetailList()); |
| | | // } |
| | | // } |
| | | // if (parallelCompletion) { |
| | | // //更新设备保养状态 |
| | | // eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.THIRD_MAINTENANCE_WAIT_CONFIRM.name()); |
| | | // } |
| | | // break; |
| | | // case WAIT_CONFIRM: |
| | | // userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(),null, BusinessCodeConst.PCR0003); |
| | | // if (CollectionUtil.isEmpty(userSelectors)) { |
| | | // throw new JeecgBootException("设备未分配给车间班组长,无法进入下级审批!"); |
| | | // } |
| | | // //班组长确认 |
| | | // userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | // values.put("dataId", entity.getId()); |
| | | // values.put("organization", request.getConfirmComment()); |
| | | // values.put("comment", request.getConfirmComment()); |
| | | // values.put("NextAssignee", userApprovalList); |
| | | // values.put("confirmation", request.getConfirmDealType()); |
| | | // request.setComment(request.getConfirmComment()); |
| | | // //设置entity |
| | | // entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.WAIT_LEADER_CONFIRM.name()); |
| | | // entity.setConfirmUser(user.getUsername()); |
| | | // entity.setConfirmComment(request.getConfirmComment()); |
| | | // entity.setConfirmTime(new Date()); |
| | | // //处理报修 |
| | | // List<EamThirdMaintenanceOrderDetail> collect = request.getTableDetailList().stream().filter((detail) -> CommonConstant.DEFAULT_1.equals(detail.getReportFlag())).collect(Collectors.toList()); |
| | | // if (CollectionUtil.isNotEmpty(collect)) { |
| | | // eamReportRepairService.reportRepairFromThirdMaintenance(equipment.getId(), entity.getOperator(), collect); |
| | | // } |
| | | // break; |
| | | // case WAIT_LEADER_CONFIRM: |
| | | // values.put("dataId", entity.getId()); |
| | | // values.put("organization", request.getLeaderConfirmComment()); |
| | | // values.put("comment", request.getLeaderConfirmComment()); |
| | | // request.setComment(request.getLeaderConfirmComment()); |
| | | // //设置entity |
| | | // entity.setMaintenanceStatus(ThirdMaintenanceStatusEnum.COMPLETE.name()); |
| | | // entity.setConfirmLeader(user.getUsername()); |
| | | // entity.setLeaderConfirmComment(request.getLeaderConfirmComment()); |
| | | // entity.setLeaderConfirmTime(new Date()); |
| | | // //更新设备保养状态 |
| | | // eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name()); |
| | | // break; |
| | | // } |
| | | // request.setValues(values); |
| | | // |
| | | // // 完成流程任务 |
| | | // Result result = flowTaskService.complete(request); |
| | | // if (!result.isSuccess()) { |
| | | // throw new JeecgBootException("审批失败,请刷新查看!"); |
| | | // } |
| | | // //保存工单 |
| | | // eamThirdMaintenanceOrderMapper.updateById(entity); |
| | | return entity; |
| | | // 获取当前登录用户 |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (user == null || StrUtil.isBlank(user.getId())) { |
| | | throw new JeecgBootException("未获取到登录用户,请重新登录后再试!"); |
| | | } |
| | | eamThirdMaintenanceRequest.setAssignee(user.getUsername()); |
| | | // 获取流程业务记录 |
| | | FlowMyBusiness flowMyBusiness = flowMyBusinessService.getFlowMyBusiness(eamThirdMaintenanceRequest.getInstanceId(), eamThirdMaintenanceRequest.getTaskId()); |
| | | if (flowMyBusiness == null) { |
| | | throw new JeecgBootException("流程实例不存在,请刷新后重试!"); |
| | | } |
| | | |
| | | if (!isUserAuthorized(flowMyBusiness, user)) { |
| | | throw new JeecgBootException("用户无权操作此任务,请刷新后重试!"); |
| | | } |
| | | // 认领任务 |
| | | if (!claimTask(flowMyBusiness.getTaskId(), user)) { |
| | | throw new JeecgBootException("任务不存在、已完成或已被他人认领!"); |
| | | } |
| | | |
| | | EamEquipment equipment = eamEquipmentService.getById(eamThirdMaintenanceOrder.getEquipmentId()); |
| | | if (equipment == null) { |
| | | throw new JeecgBootException("设备不存在,请检查!"); |
| | | } |
| | | |
| | | // 设置流程变量 |
| | | setupProcessVariables(eamThirdMaintenanceRequest, eamThirdMaintenanceOrder, user, equipment); |
| | | |
| | | // 完成流程任务 |
| | | Result result = flowTaskService.complete(eamThirdMaintenanceRequest); |
| | | |
| | | // 根据任务完成结果更新工单状态 |
| | | updateOrderStatus(result, eamThirdMaintenanceRequest, eamThirdMaintenanceOrder, user); |
| | | |
| | | //更新工单信息 |
| | | eamThirdMaintenanceOrderMapper.updateById(eamThirdMaintenanceOrder); |
| | | return eamThirdMaintenanceOrder; |
| | | } |
| | | |
| | | /** |
| | | * 查询三保工单基本信息 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result<?> selectVoById(String id) { |
| | | List<EamThirdMaintenanceOrder> eamThirdMaintenanceOrders = this.list(new QueryWrapper<EamThirdMaintenanceOrder>().eq("id", id)); |
| | | List<EamThirdMaintenanceRequest> eamThirdMaintenanceRequestList = new ArrayList<>(); |
| | | eamThirdMaintenanceOrders.forEach(eamThirdMaintenanceOrder -> { |
| | | EamThirdMaintenanceRequest eamThirdMaintenanceRequest = new EamThirdMaintenanceRequest(); |
| | | BeanUtils.copyProperties(eamThirdMaintenanceOrder, eamThirdMaintenanceRequest); |
| | | List<EamThirdMaintenanceOrderDetail> eamThirdMaintenanceOrderDetails = eamThirdMaintenanceOrderDetailService |
| | | .list(new QueryWrapper<EamThirdMaintenanceOrderDetail>().eq("order_id", eamThirdMaintenanceOrder.getId())); |
| | | eamThirdMaintenanceRequest.setTableDetailList(eamThirdMaintenanceOrderDetails); |
| | | eamThirdMaintenanceRequestList.add(eamThirdMaintenanceRequest); |
| | | }); |
| | | return Result.ok(eamThirdMaintenanceRequestList); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateMaintenanceStatus(String orderId, String maintenanceStatus) { |
| | | LambdaUpdateWrapper<EamThirdMaintenanceOrder> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(EamThirdMaintenanceOrder::getId, orderId); |
| | | updateWrapper.set(EamThirdMaintenanceOrder::getMaintenanceStatus, maintenanceStatus); |
| | | updateWrapper.eq(EamThirdMaintenanceOrder::getDelFlag, CommonConstant.DEL_FLAG_0); |
| | | updateWrapper.in(EamThirdMaintenanceOrder::getMaintenanceStatus, Arrays.asList(ThirdMaintenanceStatusEnum.WAIT_MAINTENANCE.name(), ThirdMaintenanceStatusEnum.FREEZE.name())); |
| | | int update = this.getBaseMapper().update(null, updateWrapper); |
| | | return update > 0; |
| | | } |
| | | |
| | | /** |
| | | * 设置流程变量 |
| | | */ |
| | | private void setupProcessVariables(EamThirdMaintenanceRequest request, EamThirdMaintenanceOrder order, LoginUser user, EamEquipment equipment) { |
| | | //流程变量 |
| | | Map<String, Object> values = new HashMap<>(); |
| | | List<String> userApprovalList; |
| | | List<UserSelector> userSelectors; |
| | | ThirdMaintenanceStatusEnum status = ThirdMaintenanceStatusEnum.getInstance(order.getMaintenanceStatus()); |
| | | switch (status) { |
| | | case WAIT_CHECK: |
| | | // 技术状态鉴定结束 |
| | | values.put("dataId", order.getId()); |
| | | values.put("organization", "技术状态鉴定结束"); |
| | | values.put("comment", "技术状态鉴定结束"); |
| | | if (CommonConstant.YN_1.equals(request.getFullyFunctional()) && CommonConstant.YN_1.equals(request.getRunningNormally())) { |
| | | values.put("confirmation", "1"); |
| | | // 获取下一步执行人 |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0002); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未分配给维修工,无法进入下级审批!"); |
| | | } |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_THIRD_MAINTENANCE.name()); |
| | | } else { |
| | | values.put("confirmation", "2"); |
| | | } |
| | | request.setComment("检查人检查结束"); |
| | | break; |
| | | case UNDER_MAINTENANCE: |
| | | // 保养结束 |
| | | values.put("dataId", order.getId()); |
| | | values.put("organization", "保养人保养结束"); |
| | | values.put("comment", "保养人保养结束"); |
| | | // 获取下一步执行人 |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0003); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未分配给设备检验员,无法进入下级审批!"); |
| | | } |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | request.setComment("保养人保养结束"); |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.THIRD_MAINTENANCE_WAIT_CONFIRM.name()); |
| | | break; |
| | | case UNDER_FIRST_ACCEPTANCE: |
| | | // 第一次验收结束 |
| | | values.put("dataId", order.getId()); |
| | | values.put("organization", "第一次验收结束"); |
| | | values.put("comment", "第一次验收结束"); |
| | | boolean flag = false; |
| | | if (!CollectionUtil.isEmpty(request.getTableDetailList())) { |
| | | for (EamThirdMaintenanceOrderDetail eamThirdMaintenanceOrderDetail : request.getTableDetailList()) { |
| | | if ("2".equals(eamThirdMaintenanceOrderDetail.getFirstInspectResult())) { |
| | | flag = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (flag) { |
| | | // 开启第二次验收 |
| | | values.put("confirmation", "2"); |
| | | List<String> usernames = new ArrayList<>(); |
| | | usernames.add(user.getUsername()); |
| | | values.put("NextAssignee", usernames); |
| | | } else { |
| | | // 流程流转到操作人签字 |
| | | values.put("confirmation", "1"); |
| | | // 获取下一步执行人 |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0001); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未分配给操作工,无法进入下级审批!"); |
| | | } |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | } |
| | | request.setComment("第一次验收结束"); |
| | | break; |
| | | case UNDER_SECOND_ACCEPTANCE: |
| | | // 第二次验收结束 |
| | | values.put("dataId", order.getId()); |
| | | values.put("organization", "第二次验收结束"); |
| | | values.put("comment", "第二次验收结束"); |
| | | // 获取下一步执行人 |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0001); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未分配给操作工,无法进入下级审批!"); |
| | | } |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | request.setComment("第二次验收结束"); |
| | | break; |
| | | case OPERATOR_SIGNATURE: |
| | | // 操作人签字结束 |
| | | values.put("dataId", order.getId()); |
| | | values.put("organization", "操作人签字结束"); |
| | | values.put("comment", "操作人签字结束"); |
| | | // 获取下一步执行人 |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0002); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未分配给维修工,无法进入下级审批!"); |
| | | } |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | request.setComment("操作人签字结束"); |
| | | break; |
| | | case REPAIRMAN_SIGNATURE: |
| | | // 维修人签字结束 |
| | | values.put("dataId", order.getId()); |
| | | values.put("organization", "维修人签字结束"); |
| | | values.put("comment", "维修人签字结束"); |
| | | // 获取下一步执行人 |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0008); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未分配给维修室主任,无法进入下级审批!"); |
| | | } |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | request.setComment("维修人签字结束"); |
| | | break; |
| | | case REPAIR_MANAGER_SIGNATURE: |
| | | // 维修室主任签字结束 |
| | | values.put("dataId", order.getId()); |
| | | values.put("organization", "维修室主任签字结束"); |
| | | values.put("comment", "维修室主任签字结束"); |
| | | // 获取下一步执行人 |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0003); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未分配给设备检验员,无法进入下级审批!"); |
| | | } |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("NextAssignee", userApprovalList); |
| | | request.setComment("维修室主任签字结束"); |
| | | break; |
| | | case INSPECTOR_SIGNATURE: |
| | | // 设备检查人签字结束 |
| | | values.put("dataId", order.getId()); |
| | | values.put("organization", "维修室主任签字结束"); |
| | | values.put("comment", "维修室主任签字结束"); |
| | | request.setComment("维修室主任签字结束"); |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name()); |
| | | break; |
| | | } |
| | | request.setValues(values); |
| | | } |
| | | |
| | | /** |
| | | * 更新工单状态 |
| | | */ |
| | | private void updateOrderStatus(Result result, EamThirdMaintenanceRequest request, EamThirdMaintenanceOrder order, LoginUser user) { |
| | | if (result.isSuccess()) { |
| | | ThirdMaintenanceStatusEnum status = ThirdMaintenanceStatusEnum.getInstance(order.getMaintenanceStatus()); |
| | | switch (status) { |
| | | case WAIT_CHECK: |
| | | // 技术状态鉴定结束 |
| | | order.setInspector(user.getUsername()); |
| | | order.setFullyFunctional(request.getFullyFunctional()); |
| | | order.setRunningNormally(request.getRunningNormally()); |
| | | order.setInspectTime(new Date()); |
| | | if (CommonConstant.YN_1.equals(request.getFullyFunctional()) && CommonConstant.YN_1.equals(request.getRunningNormally())) { |
| | | // 鉴定通过 |
| | | order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | } else { |
| | | // 鉴定未通过 |
| | | order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.CANCEL.name()); |
| | | order.setProblemDescription(request.getProblemDescription()); |
| | | order.setActualEndTime(new Date()); |
| | | } |
| | | break; |
| | | case UNDER_MAINTENANCE: |
| | | // 保养结束 |
| | | order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.UNDER_FIRST_ACCEPTANCE.name()); |
| | | order.setRepairman(user.getUsername()); |
| | | order.setActualEndTime(new Date()); |
| | | // 三保明细处理 |
| | | eamThirdMaintenanceOrderDetailService.remove(new LambdaQueryWrapper<EamThirdMaintenanceOrderDetail>().eq(EamThirdMaintenanceOrderDetail::getOrderId, order.getId())); |
| | | eamThirdMaintenanceOrderDetailService.saveBatch(request.getTableDetailList()); |
| | | break; |
| | | case UNDER_FIRST_ACCEPTANCE: |
| | | // 第一次验收结束 |
| | | boolean flag = false; |
| | | if (!CollectionUtil.isEmpty(request.getTableDetailList())) { |
| | | for (EamThirdMaintenanceOrderDetail eamThirdMaintenanceOrderDetail : request.getTableDetailList()) { |
| | | if ("2".equals(eamThirdMaintenanceOrderDetail.getFirstInspectResult())) { |
| | | flag = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (flag) { |
| | | order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.UNDER_SECOND_ACCEPTANCE.name()); |
| | | } else { |
| | | order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.OPERATOR_SIGNATURE.name()); |
| | | } |
| | | // 三保明细处理 |
| | | eamThirdMaintenanceOrderDetailService.remove(new LambdaQueryWrapper<EamThirdMaintenanceOrderDetail>().eq(EamThirdMaintenanceOrderDetail::getOrderId, order.getId())); |
| | | eamThirdMaintenanceOrderDetailService.saveBatch(request.getTableDetailList()); |
| | | break; |
| | | case UNDER_SECOND_ACCEPTANCE: |
| | | // 第二次验收结束 |
| | | order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.OPERATOR_SIGNATURE.name()); |
| | | // 三保明细处理 |
| | | eamThirdMaintenanceOrderDetailService.remove(new LambdaQueryWrapper<EamThirdMaintenanceOrderDetail>().eq(EamThirdMaintenanceOrderDetail::getOrderId, order.getId())); |
| | | eamThirdMaintenanceOrderDetailService.saveBatch(request.getTableDetailList()); |
| | | break; |
| | | case OPERATOR_SIGNATURE: |
| | | // 操作人签字结束 |
| | | if (!StrUtils.isEmpty(request.getAssistantOperator())) { |
| | | order.setAssistantOperator(request.getAssistantOperator()); |
| | | } |
| | | order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.REPAIRMAN_SIGNATURE.name()); |
| | | order.setOperatorSignature(user.getUsername()); |
| | | order.setOperatorSignatureTime(new Date()); |
| | | break; |
| | | case REPAIRMAN_SIGNATURE: |
| | | // 维修人签字结束 |
| | | if (!StrUtils.isEmpty(request.getAssistantRepairman())) { |
| | | order.setAssistantRepairman(request.getAssistantRepairman()); |
| | | } |
| | | order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.REPAIR_MANAGER_SIGNATURE.name()); |
| | | order.setRepairmanSignature(user.getUsername()); |
| | | order.setRepairmanSignatureTime(new Date()); |
| | | break; |
| | | case REPAIR_MANAGER_SIGNATURE: |
| | | // 维修室主任签字结束 |
| | | order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.INSPECTOR_SIGNATURE.name()); |
| | | order.setRepairManagerSignature(user.getUsername()); |
| | | order.setRepairManagerSignatureTime(new Date()); |
| | | break; |
| | | case INSPECTOR_SIGNATURE: |
| | | // 设备检查人签字结束 |
| | | order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.COMPLETE.name()); |
| | | order.setInspectorSignature(user.getUsername()); |
| | | order.setInspectorSignatureTime(new Date()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private boolean isUserAuthorized(FlowMyBusiness flowMyBusiness, LoginUser user) { |