故障上报生成巡检工单
This commit is contained in:
parent
2b18099dc6
commit
a3fda60ae3
@ -10,7 +10,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.cdzy.user.model.entity.table.EbikeAttachmentFileTableDef.EBIKE_ATTACHMENT_FILE;
|
import static com.cdzy.user.model.entity.table.EbikeFaultFileTableDef.EBIKE_FAULT_FILE;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用车相关附件文件记录 服务实现类
|
* 用车相关附件文件记录 服务实现类
|
||||||
@ -24,16 +25,16 @@ public class EbikeFaultFileServiceImpl extends ServiceImpl<EbikeFaultFileMapper,
|
|||||||
@Override
|
@Override
|
||||||
public List<EbikeFaultFile> queryFiles(Long reportId) {
|
public List<EbikeFaultFile> queryFiles(Long reportId) {
|
||||||
QueryWrapper query = QueryWrapper.create()
|
QueryWrapper query = QueryWrapper.create()
|
||||||
.select(EBIKE_ATTACHMENT_FILE.ALL_COLUMNS)
|
.select(EBIKE_FAULT_FILE.ALL_COLUMNS)
|
||||||
.where(EBIKE_ATTACHMENT_FILE.REPORT_ID.eq(reportId));
|
.where(EBIKE_FAULT_FILE.REPORT_ID.eq(reportId));
|
||||||
return this.mapper.selectListByQuery(query);
|
return this.mapper.selectListByQuery(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteFileByReportId(Long reportId) {
|
public void deleteFileByReportId(Long reportId) {
|
||||||
QueryWrapper query = QueryWrapper.create()
|
QueryWrapper query = QueryWrapper.create()
|
||||||
.select(EBIKE_ATTACHMENT_FILE.ALL_COLUMNS)
|
.select(EBIKE_FAULT_FILE.ALL_COLUMNS)
|
||||||
.where(EBIKE_ATTACHMENT_FILE.REPORT_ID.eq(reportId));
|
.where(EBIKE_FAULT_FILE.REPORT_ID.eq(reportId));
|
||||||
this.mapper.deleteByQuery(query);
|
this.mapper.deleteByQuery(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ public class EbikeFaultFileServiceImpl extends ServiceImpl<EbikeFaultFileMapper,
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
QueryWrapper query = QueryWrapper.create()
|
QueryWrapper query = QueryWrapper.create()
|
||||||
.and(EBIKE_ATTACHMENT_FILE.REPORT_ID.in(reportIds));
|
.and(EBIKE_FAULT_FILE.REPORT_ID.in(reportIds));
|
||||||
return this.list(query);
|
return this.list(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,7 @@ import java.io.InputStream;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.cdzy.user.model.entity.table.EbikeAttachmentFileTableDef.EBIKE_ATTACHMENT_FILE;
|
import static com.cdzy.user.model.entity.table.EbikeFaultFileTableDef.EBIKE_FAULT_FILE;
|
||||||
import static com.cdzy.user.model.entity.table.EbikeFaultPartTableDef.EBIKE_FAULT_PART;
|
import static com.cdzy.user.model.entity.table.EbikeFaultPartTableDef.EBIKE_FAULT_PART;
|
||||||
import static com.cdzy.user.model.entity.table.EbikeFaultReportTableDef.EBIKE_FAULT_REPORT;
|
import static com.cdzy.user.model.entity.table.EbikeFaultReportTableDef.EBIKE_FAULT_REPORT;
|
||||||
import static com.cdzy.user.model.entity.table.EbikeUserTableDef.EBIKE_USER;
|
import static com.cdzy.user.model.entity.table.EbikeUserTableDef.EBIKE_USER;
|
||||||
@ -96,23 +96,28 @@ public class EbikeFaultReportServiceImpl extends ServiceImpl<EbikeFaultReportMap
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
ebikeAttachmentFileService.saveBatch(fileEntities);
|
ebikeAttachmentFileService.saveBatch(fileEntities);
|
||||||
}
|
}
|
||||||
// 保存故障上报部位
|
|
||||||
List<Integer> faultPart = ebikeFaultReportDto.getFaultPart();
|
List<Integer> faultPart = Optional.ofNullable(ebikeFaultReportDto.getFaultPart())
|
||||||
List<EbikeFaultPart> fileEntities = faultPart.stream().map(e -> EbikeFaultPart.builder()
|
.orElse(Collections.emptyList());
|
||||||
.reportId(reportId)
|
|
||||||
.faultPart(e)
|
if (!faultPart.isEmpty()) {
|
||||||
.createBy(ebikeFaultReportDto.getUserId())
|
List<EbikeFaultPart> partEntities = faultPart.stream()
|
||||||
.build())
|
.map(part -> EbikeFaultPart.builder()
|
||||||
.toList();
|
.reportId(reportId)
|
||||||
ebikeFaultPartService.saveBatch(fileEntities);
|
.faultPart(part)
|
||||||
// 根据bikeCode生成巡检工单
|
.createBy(ebikeFaultReportDto.getUserId())
|
||||||
List<String> fileUrls = null;
|
.build())
|
||||||
if (Objects.nonNull(attachmentFiles)) {
|
|
||||||
fileUrls = attachmentFiles.stream()
|
|
||||||
.map(EbikeFaultFileDto::getFileUrl)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.toList();
|
.toList();
|
||||||
|
ebikeFaultPartService.saveBatch(partEntities);
|
||||||
}
|
}
|
||||||
|
// 获取附件 URL 列表
|
||||||
|
List<String> fileUrls = Optional.ofNullable(ebikeFaultReportDto.getAttachmentFiles())
|
||||||
|
.orElse(Collections.emptyList())
|
||||||
|
.stream()
|
||||||
|
.map(EbikeFaultFileDto::getFileUrl)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.toList();
|
||||||
|
// 生成巡检工单
|
||||||
FeignInspectionSwapOrderVo feignInspectionSwapOrderVo = FeignInspectionSwapOrderVo.builder()
|
FeignInspectionSwapOrderVo feignInspectionSwapOrderVo = FeignInspectionSwapOrderVo.builder()
|
||||||
.bikeCode(ebikeFaultReportDto.getBikeCode())
|
.bikeCode(ebikeFaultReportDto.getBikeCode())
|
||||||
.parts(faultPart)
|
.parts(faultPart)
|
||||||
@ -122,6 +127,7 @@ public class EbikeFaultReportServiceImpl extends ServiceImpl<EbikeFaultReportMap
|
|||||||
if (jsonResult.getCode() != Code.SUCCESS) {
|
if (jsonResult.getCode() != Code.SUCCESS) {
|
||||||
throw new EbikeException("故障上报生成巡检工单失败!");
|
throw new EbikeException("故障上报生成巡检工单失败!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return reportId;
|
return reportId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,8 +395,8 @@ public class EbikeFaultReportServiceImpl extends ServiceImpl<EbikeFaultReportMap
|
|||||||
|
|
||||||
// 获取上传图片 按照reportId分组
|
// 获取上传图片 按照reportId分组
|
||||||
QueryWrapper attachmentQuery = QueryWrapper.create()
|
QueryWrapper attachmentQuery = QueryWrapper.create()
|
||||||
.select(EBIKE_ATTACHMENT_FILE.ALL_COLUMNS)
|
.select(EBIKE_FAULT_FILE.ALL_COLUMNS)
|
||||||
.where(EBIKE_ATTACHMENT_FILE.REPORT_ID.in(reportIds));
|
.where(EBIKE_FAULT_FILE.REPORT_ID.in(reportIds));
|
||||||
List<EbikeFaultFile> allAttachments = ebikeAttachmentFileService.list(attachmentQuery);
|
List<EbikeFaultFile> allAttachments = ebikeAttachmentFileService.list(attachmentQuery);
|
||||||
Map<Long, List<EbikeFaultFile>> attachmentsByReportId = allAttachments.stream()
|
Map<Long, List<EbikeFaultFile>> attachmentsByReportId = allAttachments.stream()
|
||||||
.collect(Collectors.groupingBy(EbikeFaultFile::getReportId));
|
.collect(Collectors.groupingBy(EbikeFaultFile::getReportId));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user