| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.platform.domain.dto.ReportImportDTO; |
| | | import com.ycl.platform.domain.entity.*; |
| | |
| | | if (Objects.isNull(form.getPointId())) { |
| | | throw new RuntimeException("点位不能为空"); |
| | | } |
| | | Long userId = SecurityUtils.getUserId(); |
| | | YwPeople people = new LambdaQueryChainWrapper<>(peopleMapper).eq(YwPeople::getUserId, userId).one(); |
| | | form.setPeopleId(people.getId()); |
| | | form.setUnitId(people.getBelongUnit()); |
| | | Integer unitId = SecurityUtils.getUnitId(); |
| | | if (Objects.isNull(unitId)) { |
| | | throw new RuntimeException("非运维单位暂时无法报备"); |
| | | } |
| | | form.setUnitId(unitId); |
| | | Long userId = SecurityUtils.getLoginUser().getUserId(); |
| | | form.setPeopleId(Integer.parseInt(userId+"")); |
| | | if ("事前报备".equals(form.getReportType())) { |
| | | // 如果是事前报备需要检验是否已经生成下发工单 |
| | | YwPointVO point = ywpointMapper.countNotFinishedWorkOrderByGb(form.getPointId()); |
| | |
| | | Report entity = ReportForm.getEntityByForm(form, null); |
| | | entity.setSerialNumber(point.getSerialNumber()); |
| | | entity.setStatus(0); |
| | | entity.setIdentify(IdUtils.randomNO()); |
| | | Date now = new Date(); |
| | | entity.setCreateTime(now); |
| | | entity.setUpdateTime(now); |
| | | entity.setIdentify(IdUtils.randomNO(now)); |
| | | baseMapper.insert(entity); |
| | | List<ReportErrorType> errorTypeList = form.getErrorTypeList().stream().map(item -> { |
| | | ReportErrorType reportErrorType = new ReportErrorType(); |
| | |
| | | @SneakyThrows |
| | | @Transactional |
| | | public Result importData(ReportForm form) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | YwPeople people = new LambdaQueryChainWrapper<>(peopleMapper).eq(YwPeople::getUserId, userId).one(); |
| | | form.setPeopleId(people.getId()); |
| | | form.setUnitId(people.getBelongUnit()); |
| | | Integer unitId = SecurityUtils.getUnitId(); |
| | | if (Objects.isNull(unitId)) { |
| | | throw new RuntimeException("非运维单位暂时无法报备"); |
| | | } |
| | | form.setUnitId(unitId); |
| | | form.setBeginCreateTime(DateUtils.parseDate(form.getBeginCreateTimeStr())); |
| | | form.setEndCreateTime(DateUtils.parseDate(form.getEndCreateTime())); |
| | | form.setEndCreateTime(DateUtils.parseDate(form.getEndCreateTimeStr())); |
| | | // 读取excel数据 |
| | | ExcelUtil<ReportImportDTO> excelUtil = new ExcelUtil<>(ReportImportDTO.class); |
| | | List<ReportImportDTO> list = excelUtil.importExcel(form.getImportPointId().getInputStream()); |
| | | Date now = DateUtils.getNowDate(); |
| | | // 批量插入 |
| | | String pid = IdUtils.randomNO(); |
| | | String pid = IdUtils.randomNO(now); |
| | | Integer success = 0; |
| | | for (ReportImportDTO item : list) { |
| | | if ("事前报备".equals(form.getReportType())) { |
| | |
| | | entity.setImportBatchNumber(pid); |
| | | entity.setSerialNumber(item.getSerialNumber()); |
| | | entity.setStatus(0); |
| | | entity.setIdentify(IdUtils.randomNO()); |
| | | Date now = DateUtils.getNowDate(); |
| | | entity.setIdentify(IdUtils.randomNO(now)); |
| | | entity.setCreateTime(now); |
| | | entity.setUpdateTime(now); |
| | | baseMapper.insert(entity); |
| | |
| | | @Override |
| | | public Result page(ReportQuery query) { |
| | | IPage<ReportVO> page = PageUtil.getPage(query, ReportVO.class); |
| | | query.setUnitId(SecurityUtils.getUnitId()); |
| | | baseMapper.page(page, query); |
| | | List<SysDictData> errorTypeList = dictTypeService.selectDictDataByType("report_error_type"); |
| | | Map<String, String> dictMap = errorTypeList.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel)); |
| | |
| | | public List<ReportVO> export(ReportQuery query) { |
| | | IPage<ReportVO> page = PageUtil.getPage(query, ReportVO.class); |
| | | page.setSize(-1); |
| | | query.setUnitId(SecurityUtils.getUnitId()); |
| | | baseMapper.page(page, query); |
| | | List<SysDictData> errorTypeList = dictTypeService.selectDictDataByType("report_error_type"); |
| | | Map<String, String> dictMap = errorTypeList.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel)); |
| | | page.getRecords().forEach(item -> { |
| | | if (StringUtils.hasText(item.getErrorType())) { |
| | | item.setErrorTypeList(List.of(item.getErrorType().split(","))); |
| | | StringBuilder sb = new StringBuilder(); |
| | | item.getErrorTypeList().stream().forEach(err -> { |
| | | String s = dictMap.get(err); |
| | | if (org.springframework.util.StringUtils.hasText(s)) { |
| | | sb.append(s).append("、"); |
| | | } |
| | | }); |
| | | item.setErrorType(sb.substring(0, sb.length() - 1)); |
| | | } |
| | | // 审核结果 |
| | | List<ReportAuditingRecord> records = new LambdaQueryChainWrapper<>(reportAuditingRecordService.getBaseMapper()) |
| | | .eq(ReportAuditingRecord::getReportId, item.getId()) |
| | | .orderByDesc(ReportAuditingRecord::getCreateTime) |
| | | .last("limit 1") |
| | | .list(); |
| | | if (! CollectionUtils.isEmpty(records)) { |
| | | item.setResultStr(records.get(0).getResult() ? "通过" : "未通过"); |
| | | item.setResultRemark(records.get(0).getResultRemark()); |
| | | item.setAuditingTime(records.get(0).getCreateTime()); |
| | | |
| | | } else { |
| | | item.setResultStr("审核中"); |
| | | } |
| | | item.setReportContent(EscapeUtil.clean(item.getReportContent())); |
| | | }); |
| | | return page.getRecords(); |
| | |
| | | |
| | | // 添加一条审核记录 |
| | | ReportAuditingRecord reportAuditingRecord = new ReportAuditingRecord(); |
| | | reportAuditingRecord.setReportId(form.getId()); |
| | | reportAuditingRecord.setReportId(id); |
| | | reportAuditingRecord.setDeleted(0); |
| | | reportAuditingRecord.setCreateTime(now); |
| | | reportAuditingRecord.setResultRemark(form.getAuditOpinion()); |
| | |
| | | } |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result getListByGb(String gb) { |
| | | List<ReportVO> list = baseMapper.getListByGb(gb); |
| | | for (ReportVO report : list) { |
| | | List<ReportErrorType> errors = new LambdaQueryChainWrapper<>(reportErrorTypeService.getBaseMapper()) |
| | | .eq(ReportErrorType::getReportId, report.getId()) |
| | | .orderByDesc(ReportErrorType::getCreateTime) |
| | | .list(); |
| | | String err = errors.stream().map(ReportErrorType::getErrorType).collect(Collectors.joining(",")); |
| | | report.setErrorType(err); |
| | | } |
| | | return Result.ok().data(list); |
| | | } |
| | | } |