| | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.ss.usermodel.Sheet; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.ss.usermodel.WorkbookFactory; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.flowable.engine.TaskService; |
| | | import org.flowable.task.api.Task; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | .or() |
| | | .like("e.equipment_code", eamMaintenanceStandard.getKeyword())); |
| | | } |
| | | //id |
| | | if(StringUtils.isNotBlank(eamMaintenanceStandard.getId())) { |
| | | queryWrapper.eq("ems.id", eamMaintenanceStandard.getId()); |
| | | } |
| | | } |
| | | queryWrapper.orderByDesc("ems.create_time"); |
| | | return eamMaintenanceStandardMapper.queryPageList(page, queryWrapper); |
| | |
| | | BeanUtils.copyProperties(standardRequest, entity); |
| | | entity.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); |
| | | //版本递增 |
| | | entity.setStandardVersion(CommonConstant.OPERATE_TYPE_1); |
| | | entity.setStandardVersion("v"+CommonConstant.OPERATE_TYPE_1); |
| | | //设备处理 |
| | | entity.setEquipmentId(standardRequest.getEquipmentId()); |
| | | //删除标记 |
| | |
| | | if(entity == null){ |
| | | throw new JeecgBootException("编辑的数据已删除,请刷新重试!"); |
| | | } |
| | | entity.setStandardStatus(MaintenanceStandardStatusEnum.ABOLISH.name()); |
| | | //原来的作废 |
| | | eamMaintenanceStandardMapper.updateById(entity); |
| | | |
| | | //新增一个版本 |
| | | EamMaintenanceStandard newEntity = new EamMaintenanceStandard(); |
| | |
| | | newEntity.setInitialDate(standardRequest.getInitialDate()); |
| | | newEntity.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); |
| | | //版本递增 |
| | | newEntity.setStandardVersion(entity.getStandardVersion() + 1); |
| | | //获取数字 |
| | | Pattern pattern = Pattern.compile("(\\d+)(?:\\.\\d+)*$"); |
| | | Matcher matcher = pattern.matcher(entity.getStandardVersion()); |
| | | if (matcher.find()) { |
| | | try { |
| | | int mainVersion = Integer.parseInt(matcher.group(1)); |
| | | newEntity.setStandardVersion("v"+(mainVersion+1)); |
| | | } catch (NumberFormatException ignored) { |
| | | } |
| | | } |
| | | //设备处理 |
| | | newEntity.setEquipmentId(standardRequest.getEquipmentId()); |
| | | //删除标记 |
| | |
| | | // 设置流程变量 |
| | | Map<String, Object> values = setProcessVariables(eamMaintenanceStandard, userId, eamMaintenanceStandardVo); |
| | | eamMaintenanceStandardVo.setValues(values); |
| | | |
| | | eamMaintenanceStandardVo.setComment(values.get("comment").toString()); |
| | | // 完成流程任务 |
| | | Result result = flowTaskService.complete(eamMaintenanceStandardVo); |
| | | if (result.isSuccess()) { |
| | | if (eamMaintenanceStandardVo.getRepairManagerApproveResult() != null) { |
| | | if (eamMaintenanceStandardVo.getRepairManagerApproveResult().equals("1")){ |
| | | eamMaintenanceStandard.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_TECHNICAL_DIRECTOR.name()); |
| | | //获取flow的流程实例id,设置下一步的处理人员 |
| | | EamMaintenanceStandard maintenanceStandard=this.getById(eamMaintenanceStandardVo.getDataId()); |
| | | EamEquipment eamEquipment=eamEquipmentService.getById(maintenanceStandard.getEquipmentId()); |
| | | BaseFactory baseFactory=baseFactoryService.getOne(new QueryWrapper<BaseFactory>().eq("org_code", eamEquipment.getFactoryOrgCode())); |
| | | List<UserSelector> userSelectorList=sysUserService.selectOperatorFactoryList(eamEquipment.getEquipmentCode(),baseFactory.getId(), BusinessCodeConst.PCR0008); |
| | | if (!CollectionUtils.isEmpty(userSelectorList)) { |
| | | List<String> usernameList=userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | flowMyBusiness.setTodoUsers(JSON.toJSONString(usernameList)); |
| | | flowMyBusinessService.updateById(flowMyBusiness); |
| | | } |
| | | }else { |
| | | eamMaintenanceStandard.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); |
| | | } |
| | |
| | | if (eamMaintenanceStandardVo.getTechnicalManagerApproveResult() != null) { |
| | | if (eamMaintenanceStandardVo.getTechnicalManagerApproveResult().equals("1")){ |
| | | eamMaintenanceStandard.setStandardStatus(MaintenanceStandardStatusEnum.START.name()); |
| | | //判断是否进行升版,通过设备编号、保养分类、状态进行筛选 |
| | | EamMaintenanceStandard maintenanceStandard=this.getById(eamMaintenanceStandardVo.getDataId()); |
| | | QueryWrapper<EamMaintenanceStandard> queryWrapper=new QueryWrapper<>(); |
| | | queryWrapper.eq("equipment_id", maintenanceStandard.getEquipmentId()); |
| | | queryWrapper.eq("maintenance_category", maintenanceStandard.getMaintenanceCategory()); |
| | | queryWrapper.eq("standard_status", MaintenanceStandardStatusEnum.START.name()); |
| | | List<EamMaintenanceStandard> list=eamMaintenanceStandardMapper.selectList(queryWrapper); |
| | | if (!CollectionUtils.isEmpty(list)) { |
| | | //作废原有 |
| | | for (EamMaintenanceStandard eamMaintenanceStandard1 : list) { |
| | | eamMaintenanceStandard1.setStandardStatus(MaintenanceStandardStatusEnum.ABOLISH.name()); |
| | | this.updateById(eamMaintenanceStandard1); |
| | | } |
| | | } |
| | | }else { |
| | | eamMaintenanceStandard.setStandardStatus(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name()); |
| | | } |
| | |
| | | } else { |
| | | return result; |
| | | } |
| | | |
| | | return Result.OK("操作成功"); |
| | | } catch (Exception e) { |
| | | return Result.error("操作失败:" + e.getMessage()); |
| | |
| | | Map<String, Object> values = new HashMap<>(); |
| | | values.put("dataId", eamMaintenanceStandard.getId()); |
| | | values.put("assignee", userId); |
| | | values.put("organization", eamMaintenanceStandardVo.getComment()); |
| | | values.put("comment", eamMaintenanceStandardVo.getComment()); |
| | | if (eamMaintenanceStandardVo.getRepairManagerApproveResult() != null) { |
| | | values.put("repairManagerApproveResult", eamMaintenanceStandardVo.getRepairManagerApproveResult()); |
| | | values.put("organization", eamMaintenanceStandardVo.getRepairManagerApproveComment()); |
| | | values.put("comment", eamMaintenanceStandardVo.getRepairManagerApproveComment()); |
| | | } |
| | | if (eamMaintenanceStandardVo.getTechnicalManagerApproveResult() != null) { |
| | | values.put("technicalManagerApproveResult", eamMaintenanceStandardVo.getTechnicalManagerApproveResult()); |
| | | values.put("organization", eamMaintenanceStandardVo.getTechnicalManagerApproveComment()); |
| | | values.put("comment", eamMaintenanceStandardVo.getTechnicalManagerApproveComment()); |
| | | } |
| | | return values; |
| | | } |
| | |
| | | } |
| | | |
| | | /*流程业务代码--------------------------结束*/ |
| | | |
| | | } |