| | |
| | | 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.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | 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.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog; |
| | | import org.jeecg.modules.system.entity.BaseFactory; |
| | | import org.jeecg.modules.system.entity.BaseFactoryUser; |
| | | import org.jeecg.modules.system.service.IBaseFactoryService; |
| | | import org.jeecg.modules.system.service.IBaseFactoryUserService; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.constant.EquipmentOperationTagEnum; |
| | | import org.jeecg.modules.eam.constant.InspectionItemCategroyEnum; |
| | | import org.jeecg.modules.eam.constant.InspectionStatus; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.entity.EamInspectionOrder; |
| | | import org.jeecg.modules.eam.entity.EamInspectionOrderDetail; |
| | | import org.jeecg.modules.eam.entity.*; |
| | | import org.jeecg.modules.eam.mapper.EamInspectionOrderMapper; |
| | | import org.jeecg.modules.eam.request.EamInspectionOrderQuery; |
| | | import org.jeecg.modules.eam.request.EamInspectionOrderRequest; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamInspectionOrderDetailService; |
| | | import org.jeecg.modules.eam.service.IEamInspectionOrderService; |
| | | import org.jeecg.modules.eam.service.IEamReportRepairService; |
| | | import org.jeecg.modules.eam.service.*; |
| | | import org.jeecg.modules.eam.util.DateUtils; |
| | | import org.jeecg.modules.eam.vo.InspectionVo; |
| | | import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; |
| | | import org.jeecg.modules.flowable.apithird.business.service.impl.FlowMyBusinessServiceImpl; |
| | |
| | | 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.IMdcUserProductionService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: 点检工单 |
| | |
| | | |
| | | @Resource |
| | | private EamInspectionOrderMapper eamInspectionOrderMapper; |
| | | @Autowired |
| | | @Resource |
| | | private IEamInspectionOrderDetailService eamInspectionOrderDetailService; |
| | | @Resource |
| | | private IEamWeekInspectionDetailService eamWeekInspectionDetailService; |
| | | @Resource |
| | | private IBaseFactoryUserService baseFactoryUserService; |
| | | @Resource |
| | | private IBaseFactoryService baseFactoryService; |
| | | @Resource |
| | | private FlowCommonService flowCommonService; |
| | | @Resource |
| | | private IFlowDefinitionService flowDefinitionService; |
| | | @Autowired |
| | | @Resource |
| | | private IFlowTaskService flowTaskService; |
| | | @Autowired |
| | | @Resource |
| | | private IEamEquipmentService eamEquipmentService; |
| | | @Autowired |
| | | @Resource |
| | | private FlowMyBusinessServiceImpl flowMyBusinessService; |
| | | @Autowired |
| | | @Resource |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private IEamEquipmentService iEamEquipmentService; |
| | | @Autowired |
| | | private IMdcUserProductionService mdcUserProductionService; |
| | | @Autowired |
| | | @Resource |
| | | private IEamReportRepairService eamReportRepairService; |
| | | @Resource |
| | | private IEamMaintenanceStandardDetailService eamMaintenanceStandardDetailService; |
| | | |
| | | @Override |
| | | public IPage<EamInspectionOrder> queryPageList(Page<EamInspectionOrder> page, EamInspectionOrderQuery query) { |
| | |
| | | List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | queryWrapper.in("e.equipment_code", equipArr); |
| | | } else { |
| | | //没有选择设备,根据车间过滤设备 |
| | | queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id ", sysUser.getId()); |
| | | //没有选择设备,根据中心过滤设备 |
| | | List<BaseFactoryUser> baseFactoryUserList = baseFactoryUserService. |
| | | list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId, sysUser.getId())); |
| | | if (!CollectionUtils.isEmpty(baseFactoryUserList)) { |
| | | 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 { |
| | | return page; |
| | | } |
| | | } |
| | | //查询条件过滤 |
| | | if (query != null) { |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean addInspectionOrder(EamInspectionOrderRequest eamInspectionOrderRequest) { |
| | | public Result<String> addInspectionOrder(EamInspectionOrderRequest eamInspectionOrderRequest) { |
| | | List<EamInspectionOrder> eamInspectionOrders = eamInspectionOrderMapper.selectList(new LambdaQueryWrapper<EamInspectionOrder>().eq(EamInspectionOrder::getStandardId, eamInspectionOrderRequest.getStandardId()).eq(EamInspectionOrder::getInspectionDate, eamInspectionOrderRequest.getInspectionDate()).ne(EamInspectionOrder::getInspectionStatus, InspectionStatus.ABOLISH.name())); |
| | | if (CollectionUtils.isNotEmpty(eamInspectionOrders)) { |
| | | return Result.error("添加失败,系统已存在当前日期工单!"); |
| | | } |
| | | EamInspectionOrder eamInspectionOrder = new EamInspectionOrder(); |
| | | BeanUtils.copyProperties(eamInspectionOrderRequest, eamInspectionOrder); |
| | | //修改状态 |
| | | if (StrUtil.isNotBlank(eamInspectionOrderRequest.getOperator())) { |
| | | eamInspectionOrder.setInspectionStatus(InspectionStatus.UNDER_INSPECTION.name()); |
| | | } else { |
| | | eamInspectionOrder.setInspectionStatus(InspectionStatus.WAIT_INSPECTION.name()); |
| | | } |
| | | eamInspectionOrder.setInspectionStatus(InspectionStatus.WAIT_INSPECTION.name()); |
| | | eamInspectionOrder.setDelFlag(CommonConstant.DEL_FLAG_0); |
| | | save(eamInspectionOrder); |
| | | //处理明细数据 |
| | | if (CollectionUtil.isNotEmpty(eamInspectionOrderRequest.getTableDetailList())) { |
| | | eamInspectionOrderRequest.getTableDetailList().forEach(tableDetail -> { |
| | | tableDetail.setOrderId(eamInspectionOrder.getId()); |
| | | tableDetail.setId(null); |
| | | }); |
| | | eamInspectionOrderDetailService.saveBatch(eamInspectionOrderRequest.getTableDetailList()); |
| | | } |
| | | //处理附件 |
| | | if (CollectionUtil.isNotEmpty(eamInspectionOrderRequest.getFileList())) { |
| | | FileUploadResult fileUploadResult = eamInspectionOrderRequest.getFileList().get(0); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | | String referenceFile = mapper.writeValueAsString(fileUploadResult); |
| | | eamInspectionOrder.setImageFiles(referenceFile); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("JSON转换失败:" + e.getMessage(), e); |
| | | //处理日点检明细数据 |
| | | if (StrUtil.isNotBlank(eamInspectionOrderRequest.getStandardId())) { |
| | | List<EamMaintenanceStandardDetail> maintenanceStandardDetailList = eamMaintenanceStandardDetailService.list(new LambdaQueryWrapper<EamMaintenanceStandardDetail>().eq(EamMaintenanceStandardDetail::getStandardId, eamInspectionOrderRequest.getStandardId()).eq(EamMaintenanceStandardDetail::getItemCategory, InspectionItemCategroyEnum.DAY_INSPECTION.name())); |
| | | if (CollectionUtils.isNotEmpty(maintenanceStandardDetailList)) { |
| | | List<EamInspectionOrderDetail> inspectionOrderList = maintenanceStandardDetailList.stream().map(EamInspectionOrderDetail::new).collect(Collectors.toList()); |
| | | inspectionOrderList.forEach(tableDetail -> { |
| | | tableDetail.setOrderId(eamInspectionOrder.getId()); |
| | | tableDetail.setId(null); |
| | | }); |
| | | eamInspectionOrderDetailService.saveBatch(inspectionOrderList); |
| | | } |
| | | } |
| | | if (StrUtil.isNotBlank(eamInspectionOrderRequest.getOperator())) { |
| | | triggerProcess(eamInspectionOrder); |
| | | //处理周点检明细数据 |
| | | if (StrUtil.isNotBlank(eamInspectionOrderRequest.getStandardId()) && eamInspectionOrderRequest.getInspectionDate() != null) { |
| | | LambdaQueryWrapper<EamWeekInspectionDetail> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(EamWeekInspectionDetail::getStandardId, eamInspectionOrderRequest.getStandardId()); |
| | | queryWrapper.between(EamWeekInspectionDetail::getPlanInspectionDate, DateUtils.getFirstDayOfWeek(eamInspectionOrderRequest.getInspectionDate()), DateUtils.getLastDayOfWeek(eamInspectionOrderRequest.getInspectionDate())); |
| | | queryWrapper.orderByAsc(EamWeekInspectionDetail::getItemCode); |
| | | List<EamWeekInspectionDetail> eamWeekInspectionDetailList = eamWeekInspectionDetailService.list(queryWrapper); |
| | | if (CollectionUtil.isEmpty(eamWeekInspectionDetailList)) { |
| | | List<EamMaintenanceStandardDetail> maintenanceStandardDetailList = eamMaintenanceStandardDetailService.list(new LambdaQueryWrapper<EamMaintenanceStandardDetail>().eq(EamMaintenanceStandardDetail::getStandardId, eamInspectionOrderRequest.getStandardId()).eq(EamMaintenanceStandardDetail::getItemCategory, InspectionItemCategroyEnum.WEEK_INSPECTION.name())); |
| | | if (CollectionUtils.isNotEmpty(maintenanceStandardDetailList)) { |
| | | List<EamWeekInspectionDetail> weekInspectionDetailList = maintenanceStandardDetailList.stream().map(EamWeekInspectionDetail::new).collect(Collectors.toList()); |
| | | weekInspectionDetailList.forEach(weekInspectionDetail -> { |
| | | weekInspectionDetail.setStandardId(eamInspectionOrderRequest.getStandardId()); |
| | | // TODO 周点检日期 |
| | | weekInspectionDetail.setPlanInspectionDate(eamInspectionOrderRequest.getInspectionDate()); |
| | | }); |
| | | eamWeekInspectionDetailService.saveBatch(weekInspectionDetailList); |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (equipment == null) { |
| | | return false; |
| | | } else { |
| | | eamInspectionOrder.setEquipmentCode(equipment.getEquipmentCode()); |
| | | eamInspectionOrder.setEquipmentId(equipment.getId()); |
| | | } |
| | | flowCommonService.initActBusiness("工单号: " + eamInspectionOrder.getOrderNum() + ";设备编号: " + eamInspectionOrder.getEquipmentCode() + ";安装位置: " + equipment.getInstallationPosition(), |
| | | flowCommonService.initActBusiness("工单号: " + eamInspectionOrder.getOrderNum() + ";设备编号: " + equipment.getEquipmentCode() + (equipment.getInstallationPosition() == null ? "" : ";安装位置: " + equipment.getInstallationPosition()), |
| | | eamInspectionOrder.getId(), "IEamInspectionOrderService", "eam_inspection", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", eamInspectionOrder.getId()); |
| | |
| | | eamInspectionOrder.setInspectionStatus(InspectionStatus.UNDER_INSPECTION.name()); |
| | | } |
| | | super.updateById(eamInspectionOrder); |
| | | //处理明细数据 |
| | | if (CollectionUtil.isNotEmpty(eamInspectionOrderRequest.getTableDetailList())) { |
| | | eamInspectionOrderRequest.getTableDetailList().forEach(tableDetail -> { |
| | | tableDetail.setOrderId(eamInspectionOrder.getId()); |
| | | tableDetail.setCreateTime(new Date()); |
| | | }); |
| | | //删除明细 |
| | | eamInspectionOrderDetailService.remove(new QueryWrapper<EamInspectionOrderDetail>().eq("order_id", eamInspectionOrder.getId())); |
| | | eamInspectionOrderDetailService.saveBatch(eamInspectionOrderRequest.getTableDetailList()); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean takeInspectionOrder(String id) { |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if(user == null || !BusinessCodeConst.PCR0001.equals(user.getPost())) { |
| | | if (user == null || !BusinessCodeConst.PCR0001.equals(user.getPost())) { |
| | | throw new JeecgBootException("不是操作工,无法领取此工单!"); |
| | | } |
| | | EamInspectionOrder eamInspectionOrder = this.getById(id); |
| | |
| | | Map<String, Object> values = new HashMap<>(); |
| | | if (InspectionStatus.UNDER_INSPECTION.name().equals(order.getInspectionStatus()) && user.getUsername().equals(order.getOperator())) { |
| | | // 点检人点检结束 |
| | | String manager = Optional.ofNullable(iEamEquipmentService.getById(order.getEquipmentId())) |
| | | .map(EamEquipment::getEquipmentManager) |
| | | .orElse(null); |
| | | if (manager == null) { |
| | | throw new IllegalArgumentException("设备管理员未配置"); |
| | | } |
| | | List<String> usernameList = Collections.singletonList(manager); |
| | | values.put("dataId", order.getId()); |
| | | values.put("organization", "点检人点检结束"); |
| | | values.put("comment", "点检人点检结束"); |
| | | values.put("NextAssignee", usernameList); |
| | | request.setComment("点检人点检结束"); |
| | | } else { |
| | | // 班组长确认 |
| | | // 维修工确认 |
| | | values.put("dataId", order.getId()); |
| | | values.put("organization", request.getConfirmComment()); |
| | | values.put("comment", request.getConfirmComment()); |
| | | values.put("confirmation", request.getConfirmDealType()); |
| | | request.setComment(request.getConfirmComment()); |
| | | if ("2".equals(request.getConfirmDealType())) { |
| | | // 班组长驳回 |
| | | // 维修工驳回 |
| | | List<String> usernames = new ArrayList<>(); |
| | | usernames.add(order.getOperator()); |
| | | order.setInspectionStatus(InspectionStatus.UNDER_INSPECTION.name()); |
| | |
| | | // 点检完成 |
| | | order.setInspectionStatus(InspectionStatus.WAIT_CONFIRM.name()); |
| | | order.setOperateTime(new Date()); |
| | | if (CollectionUtil.isNotEmpty(request.getFileList())) { |
| | | List<FileUploadResult> fileUploadResultList = request.getFileList(); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | | String referenceFile = mapper.writeValueAsString(fileUploadResultList); |
| | | order.setImageFiles(referenceFile); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("JSON转换失败:" + e.getMessage(), e); |
| | | } |
| | | } |
| | | eamInspectionOrderDetailService.remove(new QueryWrapper<EamInspectionOrderDetail>().eq("order_id", order.getId())); |
| | | eamInspectionOrderDetailService.saveBatch(request.getTableDetailList()); |
| | | |
| | | if (request.getTableWeekDetailList() != null && !request.getTableWeekDetailList().isEmpty()) { |
| | | // 设置周点检 |
| | | // eamWeekInspectionDetailService.remove(new QueryWrapper<EamWeekInspectionDetail>().eq("order_id", order.getId())); |
| | | eamWeekInspectionDetailService.saveOrUpdateBatch(request.getTableWeekDetailList()); |
| | | } |
| | | } else if (InspectionStatus.WAIT_CONFIRM.name().equals(order.getInspectionStatus()) && StrUtil.isNotEmpty(request.getConfirmDealType())) { |
| | | // 班组长确认任务 |
| | | order.setInspectionStatus(InspectionStatus.COMPLETE.name()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<InspectionVo> findInspectionResult(String equipmentId,String itemDemand,String yearMonth) { |
| | | return this.baseMapper.findInspectionResult(equipmentId,itemDemand,yearMonth); |
| | | public List<InspectionVo> findInspectionResult(String equipmentId, String itemDemand, String yearMonth) { |
| | | return this.baseMapper.findInspectionResult(equipmentId, itemDemand, yearMonth); |
| | | } |
| | | |
| | | @Override |
| | | public List<InspectionVo> findInspectionUser(String equipmentId,String yearMonth) { |
| | | return this.baseMapper.findInspectionUser(equipmentId,yearMonth); |
| | | public List<InspectionVo> findInspectionUser(String equipmentId, String yearMonth) { |
| | | return this.baseMapper.findInspectionUser(equipmentId, yearMonth); |
| | | } |
| | | |
| | | @Override |