| | |
| | | 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.eam.base.entity.BaseFactory; |
| | | import org.jeecg.modules.eam.base.entity.BaseFactoryUser; |
| | | import org.jeecg.modules.eam.base.service.IBaseFactoryService; |
| | | import org.jeecg.modules.eam.base.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)){ |
| | | List<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toList()); |
| | | List<String> factoryCode= baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getFactoryCode).collect(Collectors.toList()); |
| | | queryWrapper.in("e.factory_code", factoryCode); |
| | | } |
| | | } |
| | | //查询条件过滤 |
| | | if (query != null) { |
| | |
| | | } else { |
| | | eamInspectionOrder.setInspectionStatus(InspectionStatus.WAIT_INSPECTION.name()); |
| | | } |
| | | eamInspectionOrder.setDelFlag(CommonConstant.DEL_FLAG_0); |
| | | save(eamInspectionOrder); |
| | | //处理明细数据 |
| | | if (CollectionUtil.isNotEmpty(eamInspectionOrderRequest.getTableDetailList())) { |
| | |
| | | }); |
| | | 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 (CollectionUtil.isNotEmpty(eamInspectionOrderRequest.getTableWeekDetailList())) { |
| | | eamWeekInspectionDetailService.saveOrUpdateBatch(eamInspectionOrderRequest.getTableWeekDetailList()); |
| | | } |
| | | if (StrUtil.isNotBlank(eamInspectionOrderRequest.getOperator())) { |
| | | triggerProcess(eamInspectionOrder); |
| | |
| | | if (equipment == null) { |
| | | return false; |
| | | } else { |
| | | eamInspectionOrder.setEquipmentCode(equipment.getEquipmentCode()); |
| | | eamInspectionOrder.setEquipmentId(equipment.getEquipmentCode()); |
| | | } |
| | | flowCommonService.initActBusiness("工单号: " + eamInspectionOrder.getOrderNum() + ";设备编号: " + eamInspectionOrder.getEquipmentCode() + ";安装位置: " + equipment.getInstallationPosition(), |
| | | flowCommonService.initActBusiness("工单号: " + eamInspectionOrder.getOrderNum() + ";设备编号: " + eamInspectionOrder.getEquipmentId() + ";安装位置: " + 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()); |
| | | } |
| | | // //处理明细数据 |
| | | // 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; |
| | | } |
| | | |
| | |
| | | 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); |
| | | // 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); |
| | | // values.put("NextAssignee", usernameList); |
| | | request.setComment("点检人点检结束"); |
| | | } else { |
| | | // 班组长确认 |
| | |
| | | // 点检完成 |
| | | 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); |
| | | } |
| | | } |
| | | // 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()); |
| | | } else if (InspectionStatus.WAIT_CONFIRM.name().equals(order.getInspectionStatus()) && StrUtil.isNotEmpty(request.getConfirmDealType())) { |