| | |
| | | import com.ycl.platform.wvp.WVPResult; |
| | | import com.ycl.system.Result; |
| | | import com.ycl.system.domain.SysConfig; |
| | | import com.ycl.system.entity.SysDept; |
| | | import com.ycl.system.entity.SysDictData; |
| | | import com.ycl.system.mapper.SysConfigMapper; |
| | | import com.ycl.system.model.LoginUser; |
| | | import com.ycl.system.page.PageUtil; |
| | | import com.ycl.system.service.ISysDeptService; |
| | | import com.ycl.task.DeleteWorkOrderImgTask; |
| | | import com.ycl.utils.DateUtils; |
| | | import com.ycl.utils.SecurityUtils; |
| | |
| | | WorkOrderServiceImpl self = applicationContext.getBean(WorkOrderServiceImpl.class); |
| | | return self.batchAddWorkOrder(workOrderList); |
| | | } |
| | | |
| | | private boolean isSameDay(Date date1, Date date2) { |
| | | if (date1 == null || date2 == null) { |
| | | return false; |
| | | } |
| | | LocalDate localDate1 = date1.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | LocalDate localDate2 = date2.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | return localDate1.isEqual(localDate2); |
| | | } |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean batchAddWorkOrder(List<WorkOrder> workOrderList) { |
| | | int total = workOrderList.size(); |
| | |
| | | for (WorkOrder workOrder : workOrderList) { |
| | | WorkOrder databaseWorkOrder = mapping.get(workOrder.getSerialNumber()); |
| | | if (Objects.nonNull(databaseWorkOrder)) { |
| | | //判断是否是今天的工单 |
| | | if (!isSameDay(databaseWorkOrder.getCreateTime(), now)) { |
| | | // 若为前一天的工单,不更新,直接当作新工单新增 |
| | | workOrder.setCreateTime(now); |
| | | workOrder.setUpdateTime(now); |
| | | waitAddList.add(workOrder); |
| | | continue; // 跳过后续的更新逻辑 |
| | | } |
| | | |
| | | List<String> errorNameList = databaseWorkOrder.getErrorTypeList(); |
| | | List<String> errorTypes = workOrder.getErrorTypeList(); |
| | | if (errorNameList.containsAll(errorTypes)) { |
| | |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result ywConditionList(WorkOrderYWConditionsForm form) { |
| | | List<WorkOrder> workOrderList = new LambdaQueryChainWrapper<>(baseMapper) |
| | | .in(WorkOrder::getWorkOrderNo,form.getWorkOrderNumbers()) |
| | | .list(); |
| | | System.out.println("--------------"); |
| | | System.out.println(workOrderList); |
| | | if (CollectionUtils.isEmpty(workOrderList)) { |
| | | throw new ServiceException("工单不存在"); |
| | | } |
| | | // 工单状态 |
| | | for (WorkOrder workOrder : workOrderList) { |
| | | workOrder.setStatus(WorkOrderStatusEnum.YW_HANDLE); |
| | | workOrder.setYwHandleTime(LocalDateTime.now()); |
| | | } |
| | | baseMapper.updateMany(workOrderList); |
| | | // 添加一条运维情况记录 |
| | | for (WorkOrder workOrder : workOrderList) { |
| | | WorkOrderYwConditionRecord workOrderYwConditionRecord = new WorkOrderYwConditionRecord(); |
| | | workOrderYwConditionRecord.setWorkOrderNo(workOrder.getWorkOrderNo()); |
| | | workOrderYwConditionRecord.setCommitUser(SecurityUtils.getLoginUser().getUserId().intValue()); |
| | | workOrderYwConditionRecord.setYwCondition(form.getYwCondition()); |
| | | workOrderYwConditionRecord.setYwProofMaterials(form.getYwProofMaterials()); |
| | | workOrderYwConditionRecord.setSysMsg(Boolean.FALSE); |
| | | workOrderYwConditionRecordMapper.insert(workOrderYwConditionRecord); |
| | | WorkOrderServiceImpl self = applicationContext.getBean(WorkOrderServiceImpl.class); |
| | | self.getImage(workOrder); |
| | | } |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |
| | | @Async("threadPoolTaskExecutor") |
| | | public void getImage(WorkOrder workOrder) { |
| | | List<DeviceInfo> gbDevices = new LambdaQueryChainWrapper<>(deviceInfoMapper) |
| | |
| | | |
| | | |
| | | |
| | | |
| | | private final ISysDeptService deptService; |
| | | /** |
| | | * 分页查询 |
| | | * |
| | |
| | | */ |
| | | @Override |
| | | public Result page(WorkOrderQuery query) { |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | SysDept sysDept = null; |
| | | Long deptId =null; |
| | | if (loginUser.getDeptId() != null){ |
| | | deptId = loginUser.getDeptId(); |
| | | sysDept = deptService.selectDeptById(deptId); |
| | | } |
| | | //查询指定区数据 |
| | | // 登录账号的存在部门 不在部门内就不传值,默认查询全部 |
| | | if (sysDept !=null){ |
| | | //更具部门id获得对应枚举 部门code |
| | | AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromDept(Math.toIntExact(sysDept.getDeptId())); |
| | | if (areaDeptEnum != null){ |
| | | query.setDept(areaDeptEnum.getCode()); |
| | | } |
| | | } |
| | | |
| | | |
| | | IPage<WorkOrderVO> page = PageUtil.getPage(query, WorkOrderVO.class); |
| | | if (query.getUnitId() == null) { |
| | | query.setUnitId(SecurityUtils.getUnitId()); |
| | |
| | | } |
| | | }); |
| | | } |
| | | //加上报备信息 |
| | | if (!CollectionUtils.isEmpty(page.getRecords())) { |
| | | List<String> serialNumberList = page.getRecords().stream() |
| | | .map(WorkOrderVO::getSerialNumber).collect(Collectors.toList()); |
| | | List<Report> reports = new LambdaQueryChainWrapper<>(reportMapper) |
| | | .in(Report::getSerialNumber, serialNumberList) |
| | | .eq(Report::getStatus,1) |
| | | .eq(Report::getDeleted,Boolean.FALSE).list(); |
| | | Map<String, List<Report>> reportMap = reports.stream() |
| | | .collect(Collectors.groupingBy(Report::getSerialNumber)); |
| | | |
| | | for (WorkOrderVO workOrder : page.getRecords()) { |
| | | workOrder.setHasReport(false); |
| | | List<Report> reportsByWorkOrder = reportMap.get(workOrder.getSerialNumber()); |
| | | if (CollectionUtils.isEmpty(reportsByWorkOrder)) { |
| | | continue; // 无报告,直接跳过 |
| | | } |
| | | Date distributeTime = workOrder.getDistributeTime(); |
| | | for (Report report : reportsByWorkOrder) { |
| | | Date beginTime = report.getBeginCreateTime(); |
| | | Date endTime = report.getEndCreateTime(); |
| | | // 空指针防护 |
| | | if (distributeTime == null || beginTime == null || endTime == null) { |
| | | continue; |
| | | } |
| | | // 时间区间判断:distributeTime 在 [beginTime, endTime] 内 |
| | | boolean isInRange = distributeTime.compareTo(beginTime) >= 0 |
| | | && distributeTime.compareTo(endTime) <= 0; |
| | | if (isInRange) { |
| | | workOrder.setHasReport(true); |
| | | break; // 找到一个即退出循环 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public WorkOrderTotalVO workOrderTotal(DashboardQuery dashboardQuery) { |
| | | //todo大屏工单未处理工单数量有点问题 |
| | | return baseMapper.workOrderTotal(dashboardQuery); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<WorkOrderRegionVO> workOrderRegion(DashboardQuery dashboardQuery) { |
| | |
| | | } |
| | | |
| | | // 是否报备 |
| | | boolean hasReport = new LambdaQueryChainWrapper<>(reportMapper) |
| | | .eq(Report::getSerialNumber, workOrder.getSerialNumber()) |
| | | .exists(); |
| | | workOrder.setHasReport(hasReport); |
| | | |
| | | List<Report> reports = new LambdaQueryChainWrapper<>(reportMapper) |
| | | .eq(Report::getSerialNumber,workOrder.getSerialNumber()) |
| | | .eq(Report::getStatus,1) |
| | | .orderByDesc(Report::getCreateTime) |
| | | .list(); |
| | | log.info("报备记录:{}",reports); |
| | | Date distributeTime = workOrder.getDistributeTime(); |
| | | workOrder.setHasReport(false); |
| | | for (Report report : reports) { |
| | | Date beginTime = report.getBeginCreateTime(); |
| | | Date endTime = report.getEndCreateTime(); |
| | | // 空指针防护 |
| | | if (distributeTime == null || beginTime == null || endTime == null) { |
| | | continue; |
| | | } |
| | | // 时间区间判断:distributeTime 在 [beginTime, endTime] 内 |
| | | boolean isInRange = distributeTime.compareTo(beginTime) >= 0 |
| | | && distributeTime.compareTo(endTime) <= 0; |
| | | if (isInRange) { |
| | | workOrder.setHasReport(true); |
| | | break; // 找到一个即退出循环 |
| | | } |
| | | } |
| | | // 故障类型 |
| | | List<SysDictData> errorList = workOrderErrorTypeService.getBaseMapper().getErrorList(workOrder.getWorkOrderNo()); |
| | | List<String> errList = errorList.stream().map(SysDictData::getDictLabel).collect(Collectors.toList()); |