| | |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.constant.OrderCreationMethodEnum; |
| | | import org.jeecg.modules.eam.constant.WeekMaintenanceStatusEnum; |
| | | import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog; |
| | | import org.jeecg.modules.eam.constant.*; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrder; |
| | | import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrderDetail; |
| | | import org.jeecg.modules.eam.mapper.EamWeekMaintenanceOrderMapper; |
| | | import org.jeecg.modules.eam.request.EamWeekMaintenanceQuery; |
| | | import org.jeecg.modules.eam.request.EamWeekMaintenanceRequest; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamReportRepairService; |
| | | import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderDetailService; |
| | | import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderService; |
| | | import org.jeecg.modules.eam.service.*; |
| | | import org.jeecg.modules.eam.vo.EquipmentInspectionStatistics; |
| | | import org.jeecg.modules.eam.vo.EquipmentMaintenanceStatistics; |
| | | 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.apithird.service.FlowCommonService; |
| | | import org.jeecg.modules.flowable.service.IFlowDefinitionService; |
| | | import org.jeecg.modules.flowable.service.IFlowTaskService; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.jeecg.modules.system.vo.UserSelector; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private IEamEquipmentService eamEquipmentService; |
| | | @Autowired |
| | | private IEamReportRepairService eamReportRepairService; |
| | | @Autowired |
| | | private IEamEquipmentExtendService eamEquipmentExtendService; |
| | | @Autowired |
| | | private IMdcProductionService mdcProductionService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean addWeekMaintenance(EamWeekMaintenanceRequest request) { |
| | | EamEquipment equipment = eamEquipmentService.getById(request.getEquipmentId()); |
| | | if (equipment == null) { |
| | | throw new JeecgBootException("设备不存在,添加失败!"); |
| | | } |
| | | EamWeekMaintenanceOrder order = new EamWeekMaintenanceOrder(); |
| | | order.setOrderNum(request.getOrderNum()); |
| | | order.setEquipmentId(request.getEquipmentId()); |
| | |
| | | //判断是否存在保养人 如果存在则启动流程 |
| | | if (StringUtils.isNotBlank(order.getOperator())) { |
| | | //启动流程 |
| | | flowCommonService.initActBusiness("工单号:" + order.getOrderNum() + ";开始进行设备周保", |
| | | flowCommonService.initActBusiness("工单号:" + order.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";进行设备周保", |
| | | order.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", order.getId()); |
| | |
| | | order.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | order.setActualStartTime(new Date()); |
| | | eamWeekMaintenanceOrderMapper.updateById(order); |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name()); |
| | | return result.isSuccess(); |
| | | } |
| | | } |
| | |
| | | if (query.getMaintenanceDateBegin() != null && query.getMaintenanceDateEnd() != null) { |
| | | queryWrapper.between("wmo.maintenance_date", query.getMaintenanceDateBegin(), query.getMaintenanceDateEnd()); |
| | | } |
| | | if(StringUtils.isNotBlank(query.getRandomInspectionFlag())) { |
| | | if(CommonConstant.DEFAULT_1.equals(query.getRandomInspectionFlag())) { |
| | | queryWrapper.eq("wmo.random_inspection_flag", CommonConstant.DEFAULT_1); |
| | | }else { |
| | | queryWrapper.and(q -> q.eq("wmo.random_inspection_flag", CommonConstant.DEFAULT_0).or().isNull("wmo.random_inspection_flag")); |
| | | } |
| | | } |
| | | if(StringUtils.isNotBlank(query.getFinalRandomInspectionFlag())) { |
| | | if(CommonConstant.DEFAULT_1.equals(query.getFinalRandomInspectionFlag())) { |
| | | queryWrapper.eq("wmo.final_random_inspection_flag", CommonConstant.DEFAULT_1); |
| | | }else { |
| | | queryWrapper.and(q -> q.eq("wmo.final_random_inspection_flag", CommonConstant.DEFAULT_0).or().isNull("wmo.final_random_inspection_flag")); |
| | | } |
| | | } |
| | | //排序 |
| | | if (StringUtils.isNotBlank(query.getColumn()) && StringUtils.isNotBlank(query.getOrder())) { |
| | | String column = query.getColumn(); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean editWeekMaintenance(EamWeekMaintenanceRequest request) { |
| | | EamEquipment equipment = eamEquipmentService.getById(request.getEquipmentId()); |
| | | if (equipment == null) { |
| | | throw new JeecgBootException("设备不存在,添加失败!"); |
| | | } |
| | | EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderMapper.selectById(request.getId()); |
| | | if (entity == null) { |
| | | throw new JeecgBootException("编辑的数据已删除,请刷新重试!"); |
| | |
| | | //判断是否存在保养人 如果存在则启动流程 |
| | | if (StringUtils.isNotBlank(entity.getOperator())) { |
| | | //启动流程 |
| | | flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";开始进行设备周保", |
| | | flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";进行设备周保", |
| | | entity.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", entity.getId()); |
| | |
| | | entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | entity.setActualStartTime(new Date()); |
| | | eamWeekMaintenanceOrderMapper.updateById(entity); |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name()); |
| | | return result.isSuccess(); |
| | | } |
| | | |
| | | } |
| | | return true; |
| | | } |
| | |
| | | if (!WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | throw new JeecgBootException("该工单已进行过领取!"); |
| | | } |
| | | EamEquipment equipment = eamEquipmentService.getById(entity.getEquipmentId()); |
| | | if (equipment == null) { |
| | | throw new JeecgBootException("设备不存在,添加失败!"); |
| | | } |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if(sysUser == null || !BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { |
| | | throw new JeecgBootException("不是操作工,无法领取此工单!"); |
| | | } |
| | | entity.setOperator(sysUser.getUsername()); |
| | | entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | entity.setActualStartTime(new Date()); |
| | | eamWeekMaintenanceOrderMapper.updateById(entity); |
| | | |
| | | //启动流程 |
| | | flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";开始进行设备周保", |
| | | flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";进行设备周保", |
| | | entity.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", entity.getId()); |
| | |
| | | variables.put("NextAssignee", usernames); |
| | | Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables); |
| | | if (result != null) { |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name()); |
| | | return result.isSuccess(); |
| | | } |
| | | return true; |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean approval(EamWeekMaintenanceRequest request) { |
| | | @EquipmentHistoryLog(operationTag = EquipmentOperationTagEnum.WEEK_MAINTENANCE, businessTable = "eam_week_maintenance_order") |
| | | public EamWeekMaintenanceOrder approval(EamWeekMaintenanceRequest request) { |
| | | EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderMapper.selectById(request.getId()); |
| | | if (entity == null) { |
| | | throw new JeecgBootException("审批的数据已删除,请刷新重试!"); |
| | |
| | | |
| | | WeekMaintenanceStatusEnum status = WeekMaintenanceStatusEnum.getInstance(entity.getMaintenanceStatus()); |
| | | if (status == null) { |
| | | return false; |
| | | return null; |
| | | } |
| | | //流程变量 |
| | | Map<String, Object> values = new HashMap<>(); |
| | |
| | | if (CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | eamWeekMaintenanceOrderDetailService.updateBatchById(request.getTableDetailList()); |
| | | } |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.WAIT_CONFIRM.name()); |
| | | break; |
| | | case WAIT_CONFIRM: |
| | | if(StringUtils.isBlank(equipment.getEquipmentManager())) { |
| | | if (StringUtils.isBlank(equipment.getEquipmentManager())) { |
| | | throw new JeecgBootException("设备未分配设备管理员,无法进入下级审批!"); |
| | | } |
| | | //班组长确认 |
| | |
| | | entity.setInitialAcceptanceUser(user.getUsername()); |
| | | entity.setInitialAcceptanceComment(request.getInitialAcceptanceComment()); |
| | | entity.setInitialAcceptanceTime(new Date()); |
| | | entity.setRandomInspectionFlag(request.getRandomInspectionFlag()); |
| | | //处理附件 |
| | | if (CollectionUtil.isNotEmpty(request.getInitialAcceptanceFilesResult())) { |
| | | List<FileUploadResult> fileUploadResultList = request.getInitialAcceptanceFilesResult(); |
| | |
| | | break; |
| | | case WAIT_FINAL_ACCEPTANCE: |
| | | values.put("dataId", entity.getId()); |
| | | values.put("organization", request.getInitialAcceptanceComment()); |
| | | values.put("comment", request.getInitialAcceptanceComment()); |
| | | request.setComment(request.getInitialAcceptanceComment()); |
| | | values.put("organization", request.getFinalAcceptanceComment()); |
| | | values.put("comment", request.getFinalAcceptanceComment()); |
| | | request.setComment(request.getFinalAcceptanceComment()); |
| | | //设置entity |
| | | entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.COMPLETE.name()); |
| | | entity.setFinalAcceptanceUser(user.getUsername()); |
| | | entity.setFinalAcceptanceComment(request.getFinalAcceptanceComment()); |
| | | entity.setFinalAcceptanceTime(new Date()); |
| | | entity.setFinalRandomInspectionFlag(request.getFinalRandomInspectionFlag()); |
| | | //处理附件 |
| | | if (CollectionUtil.isNotEmpty(request.getFinalAcceptanceFilesResult())) { |
| | | List<FileUploadResult> fileUploadResultList = request.getFinalAcceptanceFilesResult(); |
| | |
| | | log.error("JSON转换失败:" + e.getMessage(), e); |
| | | } |
| | | } |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name()); |
| | | break; |
| | | } |
| | | request.setValues(values); |
| | |
| | | } |
| | | //保存工单 |
| | | eamWeekMaintenanceOrderMapper.updateById(entity); |
| | | return true; |
| | | return entity; |
| | | } |
| | | |
| | | @Override |
| | |
| | | return eamWeekMaintenanceOrderMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<EquipmentMaintenanceStatistics> equipmentMaintenanceStatistics(String productionId, LocalDate firstOfMonth, LocalDate today) { |
| | | if (StringUtils.isNotBlank(productionId)) { |
| | | //车间编码不为空 |
| | | List<String> productIds = mdcProductionService.recursionChildren(productionId); |
| | | if (CollectionUtil.isEmpty(productIds)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | List<EquipmentMaintenanceStatistics> list = this.baseMapper.equipmentMaintenanceStatistics(productIds, firstOfMonth.toString(), today.plusDays(1).toString()); |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return list; |
| | | } |
| | | List<EquipmentMaintenanceStatistics> list = this.baseMapper.equipmentMaintenanceStatistics(null, firstOfMonth.toString(), today.plusDays(1).toString()); |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private boolean isUserAuthorized(FlowMyBusiness flowMyBusiness, LoginUser user) { |
| | | List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); |
| | | return todoUsers != null && todoUsers.contains(user.getUsername()); |