| | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | 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.metadata.IPage; |
| | | 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.DateUtils; |
| | | 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.constant.*; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.entity.EamMaintenanceStandard; |
| | | import org.jeecg.modules.eam.entity.EamThirdMaintenanceOrder; |
| | | import org.jeecg.modules.eam.entity.EamThirdMaintenanceOrderDetail; |
| | | import org.jeecg.modules.eam.mapper.EamThirdMaintenanceOrderMapper; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private IEamEquipmentExtendService eamEquipmentExtendService; |
| | | @Autowired |
| | | private IEamPrecisionCheckDetailService precisionCheckDetailService; |
| | | @Autowired |
| | | private IEamMaintenanceStandardService eamMaintenanceStandardService; |
| | | |
| | | @Override |
| | | public IPage<EamThirdMaintenanceOrder> queryPageList(Page<EamThirdMaintenanceOrder> page, EamThirdMaintenanceQuery query) { |
| | |
| | | } |
| | | //判断是否存在保养人 如果存在则启动流程 |
| | | if (StringUtils.isNotBlank(order.getOperator())) { |
| | | //启动流程 TODO |
| | | // flowCommonService.initActBusiness("工单号:" + order.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";进行设备二保", |
| | | // order.getId(), "IEamWeekMaintenanceOrderService", "week_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); |
| | | // List<String> usernames = new ArrayList<>(); |
| | | // usernames.add(order.getOperator()); |
| | | // variables.put("NextAssignee", usernames); |
| | | // Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables); |
| | | // if (result != null) { |
| | | // //更新周保状态 |
| | | // order.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | // order.setActualStartTime(new Date()); |
| | | // eamWeekMaintenanceOrderMapper.updateById(order); |
| | | // //更新设备保养状态 |
| | | // eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name()); |
| | | // return result.isSuccess(); |
| | | // } |
| | | //启动流程 |
| | | 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(), null, null); |
| | | return result.isSuccess(); |
| | | } |
| | | } |
| | | |
| | | return true; |
| | |
| | | } |
| | | //判断是否存在保养人 如果存在则启动流程 |
| | | if (StringUtils.isNotBlank(entity.getOperator())) { |
| | | //启动流程 TODO |
| | | // flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";进行设备周保", |
| | | // entity.getId(), "IEamWeekMaintenanceOrderService", "week_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); |
| | | // List<String> usernames = new ArrayList<>(); |
| | | // usernames.add(entity.getOperator()); |
| | | // variables.put("NextAssignee", usernames); |
| | | // Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables); |
| | | // if (result != null) { |
| | | // //更新周保状态 |
| | | // entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); |
| | | // entity.setActualStartTime(new Date()); |
| | | // eamWeekMaintenanceOrderMapper.updateById(entity); |
| | | // //更新设备保养状态 |
| | | // eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name()); |
| | | // return result.isSuccess(); |
| | | // } |
| | | //启动流程 |
| | | 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(), null, null); |
| | | return result.isSuccess(); |
| | | } |
| | | |
| | | } |
| | | return true; |
| | |
| | | if (equipment == null) { |
| | | throw new JeecgBootException("设备不存在,添加失败!"); |
| | | } |
| | | if (StringUtils.isBlank(equipment.getEquipmentManager())) { |
| | | throw new JeecgBootException("设备未分配设备管理员,无法进入下级审批!"); |
| | | List<UserSelector> userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0002); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未分配给维修工,无法进入下级审批!"); |
| | | } |
| | | List<String> userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null || !BusinessCodeConst.PCR0001.equals(sysUser.getPost())) { |
| | | throw new JeecgBootException("不是操作工,无法领取此工单!"); |
| | |
| | | eamThirdMaintenanceOrderMapper.updateById(entity); |
| | | |
| | | //启动流程 |
| | | flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";进行设备三保", |
| | | flowCommonService.initActBusiness("工单号:" + entity.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + ";安装位置" + equipment.getInstallationPosition(), |
| | | entity.getId(), "IEamThirdMaintenanceOrderService", "third_maintenance_process", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | boolean equipmentPrecisionFlag = precisionCheckDetailService.hasPrecisionCheckDetail(entity.getId()); |
| | |
| | | } |
| | | variables.put("proofreading", true); |
| | | //并行任务会签 |
| | | //操作工执行保养 |
| | | variables.put("maintenance_execution", Collections.singletonList(sysUser.getUsername())); |
| | | variables.put("precision_check", Collections.singletonList(equipment.getEquipmentManager())); |
| | | //维修工精度检验 |
| | | variables.put("precision_check", userApprovalList); |
| | | Result result = flowDefinitionService.startProcessInstanceByKey("third_maintenance_process", variables); |
| | | if (result != null) { |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_THIRD_MAINTENANCE.name()); |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_THIRD_MAINTENANCE.name(), null, null); |
| | | return result.isSuccess(); |
| | | } |
| | | return true; |
| | |
| | | //执行完成 |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0006); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未分配给车间班组长,无法进入下级审批!"); |
| | | throw new JeecgBootException("设备未分配给机动办,无法进入下级审批!"); |
| | | } |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | | values.put("dataId", entity.getId()); |
| | |
| | | } |
| | | if (parallelCompletion) { |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.THIRD_MAINTENANCE_WAIT_CONFIRM.name()); |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.THIRD_MAINTENANCE_WAIT_CONFIRM.name(), null, null); |
| | | } |
| | | break; |
| | | case WAIT_CONFIRM: |
| | | userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getOrgId(), BusinessCodeConst.PCR0003); |
| | | if (CollectionUtil.isEmpty(userSelectors)) { |
| | | throw new JeecgBootException("设备未分配给车间班组长,无法进入下级审批!"); |
| | | throw new JeecgBootException("设备未分配给维修主任,无法进入下级审批!"); |
| | | } |
| | | //班组长确认 |
| | | userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList()); |
| | |
| | | entity.setConfirmLeader(user.getUsername()); |
| | | entity.setLeaderConfirmComment(request.getLeaderConfirmComment()); |
| | | entity.setLeaderConfirmTime(new Date()); |
| | | |
| | | //查询保养标准 |
| | | EamMaintenanceStandard standard = eamMaintenanceStandardService.getOne(new LambdaQueryWrapper<EamMaintenanceStandard>() |
| | | .eq(EamMaintenanceStandard::getEquipmentId, entity.getEquipmentId()) |
| | | .eq(EamMaintenanceStandard::getMaintenanceCategory, MaintenanceCategoryEnum.THIRD_MAINTENANCE.name())); |
| | | LocalDate nextThirdMaintenanceDate = DateUtils.dateToLocalDate(standard.getInitialDate()).plusDays(standard.getMaintenancePeriod()); |
| | | |
| | | //更新设备保养状态 |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name()); |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name(), standard.getMaintenanceCategory(), DateUtils.localDateToDate(nextThirdMaintenanceDate)); |
| | | break; |
| | | } |
| | | request.setValues(values); |