|
@@ -2,6 +2,7 @@ package com.om.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.om.entity.dto.*;
|
|
@@ -86,12 +87,29 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
}
|
|
|
|
|
|
Repair repair = BeanUtil.copyProperties(dto, Repair.class);
|
|
|
+ repair.setUsername(user.getUsername());
|
|
|
+ repair.setStatus(1);
|
|
|
+ repair.setCreateTime(LocalDateTime.now());
|
|
|
+ repair.setUpdateTime(LocalDateTime.now());
|
|
|
+ //报告编号
|
|
|
+
|
|
|
+ this.save(repair);
|
|
|
+ String yyMMdd = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMdd"));
|
|
|
+ String repairNum = yyMMdd + repair.getId() + RandomUtil.randomNumbers(5);
|
|
|
+ repair.setRepairNum(repairNum);
|
|
|
+ this.updateById(repair);
|
|
|
List<AppElectronicDTO> electronicControls = dto.getElectronicControls();
|
|
|
|
|
|
List<Integer> eleIds = new ArrayList<>();
|
|
|
List<ElectronicControl> electronicControlList = new ArrayList<>();
|
|
|
for (AppElectronicDTO electronicControlDTO : electronicControls) {
|
|
|
- ElectronicControl electronicControl = BeanUtil.copyProperties(electronicControlDTO, ElectronicControl.class);
|
|
|
+
|
|
|
+ ElectronicControl electronicControl = new ElectronicControl();
|
|
|
+ electronicControl.setElectronicControlName(electronicControlDTO.getElectronicControlName());
|
|
|
+ electronicControl.setRepairId(repair.getId());
|
|
|
+
|
|
|
+ electronicControlService.save(electronicControl);
|
|
|
+
|
|
|
electronicControlList.add(electronicControl);
|
|
|
List<AppEcuInfoDTO> ecuInfors = electronicControlDTO.getEcuInfors();
|
|
|
List<AppFaultCodeDTO> faultCodes = electronicControlDTO.getFaultCodes();
|
|
@@ -105,25 +123,16 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
|
|
|
for (FaultCode faultCode : faultCodes1) {
|
|
|
faultCode.setElectronicControlId(electronicControl.getId());
|
|
|
+ faultCode.setStatus(1);
|
|
|
}
|
|
|
|
|
|
eleIds.add(electronicControl.getId());
|
|
|
|
|
|
ecuInfoService.saveBatch(ecuInfos);
|
|
|
faultCodeService.saveBatch(faultCodes1);
|
|
|
-
|
|
|
- }
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- for (int i = 0; i < eleIds.size(); i++) {
|
|
|
- sb.append(eleIds);
|
|
|
- if (i != eleIds.size() - 1) {
|
|
|
- sb.append(",");
|
|
|
- }
|
|
|
}
|
|
|
- repair.setElectronicControlIds(sb.toString());
|
|
|
- electronicControlService.saveBatch(electronicControlList);
|
|
|
- repair.setUsername(user.getUsername());
|
|
|
- this.save(repair);
|
|
|
+
|
|
|
+
|
|
|
return Result.ok();
|
|
|
}
|
|
|
|
|
@@ -137,28 +146,35 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
if (BeanUtil.isEmpty(user)) {
|
|
|
return Result.fail("用户不存在").result(ResultCode.NO_DATA);
|
|
|
}
|
|
|
+ AppRepairQueryPageVO vo = new AppRepairQueryPageVO();
|
|
|
//获取数据
|
|
|
Integer pageIndex = dto.getPageIndex();
|
|
|
Integer pageSize = dto.getPageSize();
|
|
|
+ List<Repair> records = new ArrayList<>();
|
|
|
+ if (pageIndex == 0 && pageSize == 0) {
|
|
|
+ records = this.lambdaQuery()
|
|
|
+ .orderByDesc(Repair::getCreateTime)
|
|
|
+ .list();
|
|
|
+ if (records.isEmpty()) {
|
|
|
+ return Result.ok(vo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //分页查询
|
|
|
+ Page<Repair> page = this.lambdaQuery()
|
|
|
+ .orderByDesc(Repair::getCreateTime)
|
|
|
+ .page(new Page<>(pageIndex, pageSize));
|
|
|
+
|
|
|
+ if (page.getRecords().isEmpty()) {
|
|
|
+ return Result.ok(vo);
|
|
|
+ }
|
|
|
|
|
|
- //分页查询
|
|
|
- Page<Repair> page = this.lambdaQuery()
|
|
|
- .orderByDesc(Repair::getCreateTime)
|
|
|
- .eq(Repair::getUsername, user.getUsername())
|
|
|
- .page(new Page<>(pageIndex, pageSize));
|
|
|
+ vo.setSize(pageSize);
|
|
|
+ vo.setCurrent(pageIndex);
|
|
|
+ vo.setPages((int) page.getPages());
|
|
|
+ vo.setTotal((int) page.getTotal());
|
|
|
|
|
|
- if (BeanUtil.isEmpty(page)) {
|
|
|
- return Result.fail("未获取到数据").result(ResultCode.NO_DATA);
|
|
|
+ records = page.getRecords();
|
|
|
}
|
|
|
-
|
|
|
- AppRepairQueryPageVO vo = new AppRepairQueryPageVO();
|
|
|
-
|
|
|
- vo.setSize(pageSize);
|
|
|
- vo.setCurrent(pageIndex);
|
|
|
- vo.setPages((int) page.getPages());
|
|
|
- vo.setTotal((int) page.getTotal());
|
|
|
-
|
|
|
- List<Repair> records = page.getRecords();
|
|
|
if (CollectionUtil.isEmpty(records)) {
|
|
|
records = Collections.emptyList();
|
|
|
}
|
|
@@ -170,19 +186,21 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
diagnosticReportVO.setDiagnosticReportId(record.getId());
|
|
|
diagnosticReportVO.setDiagnosticReportName(record.getMainTitle());
|
|
|
diagnosticReportVO.setFileName(record.getFileName());
|
|
|
- String electronicControlIds = record.getElectronicControlIds();
|
|
|
|
|
|
- List<Integer> eleIds = Arrays.stream(electronicControlIds.split(","))
|
|
|
- .map(Integer::parseInt)
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<Integer> eleIds = electronicControlService.lambdaQuery()
|
|
|
+ .eq(ElectronicControl::getRepairId, record.getId())
|
|
|
+ .list().stream().map(c -> c.getId()).collect(Collectors.toList());
|
|
|
|
|
|
- for (Integer eleId : eleIds) {
|
|
|
- List<FaultCode> faultCodeList = faultCodeService.lambdaQuery()
|
|
|
- .eq(FaultCode::getElectronicControlId, eleId)
|
|
|
- .list();
|
|
|
- diagnosticReportVO.setFaultCodesNumber(String.valueOf(faultCodeList.size()));
|
|
|
+ if (!eleIds.isEmpty()) {
|
|
|
+ for (Integer eleId : eleIds) {
|
|
|
+ List<FaultCode> faultCodeList = faultCodeService.lambdaQuery()
|
|
|
+ .eq(FaultCode::getElectronicControlId, eleId)
|
|
|
+ .list();
|
|
|
+ if (!faultCodeList.isEmpty()) {
|
|
|
+ diagnosticReportVO.setFaultCodesNumber(String.valueOf(faultCodeList.size()));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
list.add(diagnosticReportVO);
|
|
|
}
|
|
|
|
|
@@ -191,12 +209,11 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Result create(RepairDTO repairDTO) {
|
|
|
Repair repair = new Repair();
|
|
|
- BeanUtil.copyProperties(repairDTO,repair);
|
|
|
+ BeanUtil.copyProperties(repairDTO, repair);
|
|
|
return Result.ok();
|
|
|
}
|
|
|
|
|
@@ -209,27 +226,26 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
throw new BadReqException("该诊断报告不存在");
|
|
|
}
|
|
|
|
|
|
- String electronicControlIds = repair.getElectronicControlIds();
|
|
|
- List<Integer> eleIds = Arrays.stream(electronicControlIds.split(","))
|
|
|
- .map(Integer::parseInt)
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- for (Integer eleId : eleIds) {
|
|
|
- List<Integer> faultIds = faultCodeService.lambdaQuery()
|
|
|
- .eq(FaultCode::getElectronicControlId, eleId)
|
|
|
- .list().stream().map(c -> c.getId()).collect(Collectors.toList());
|
|
|
+ List<Integer> eleIds = electronicControlService.lambdaQuery()
|
|
|
+ .eq(ElectronicControl::getRepairId, repair.getId())
|
|
|
+ .list().stream().map(c -> c.getId()).collect(Collectors.toList());
|
|
|
+ if (!eleIds.isEmpty()) {
|
|
|
+ for (Integer eleId : eleIds) {
|
|
|
+ List<Integer> faultIds = faultCodeService.lambdaQuery()
|
|
|
+ .eq(FaultCode::getElectronicControlId, eleId)
|
|
|
+ .list().stream().map(c -> c.getId()).collect(Collectors.toList());
|
|
|
|
|
|
- List<Integer> ecuIds = ecuInfoService.lambdaQuery()
|
|
|
- .eq(EcuInfo::getElectronicControlId, eleId)
|
|
|
- .list().stream().map(c -> c.getId()).collect(Collectors.toList());
|
|
|
+ List<Integer> ecuIds = ecuInfoService.lambdaQuery()
|
|
|
+ .eq(EcuInfo::getElectronicControlId, eleId)
|
|
|
+ .list().stream().map(c -> c.getId()).collect(Collectors.toList());
|
|
|
|
|
|
- faultCodeService.removeByIds(faultIds);
|
|
|
- ecuInfoService.removeByIds(ecuIds);
|
|
|
+ faultCodeService.removeByIds(faultIds);
|
|
|
+ ecuInfoService.removeByIds(ecuIds);
|
|
|
+ }
|
|
|
+ electronicControlService.removeByIds(eleIds);
|
|
|
}
|
|
|
- electronicControlService.removeByIds(eleIds);
|
|
|
- this.removeById(id);
|
|
|
-
|
|
|
|
|
|
+ this.removeById(id);
|
|
|
return Result.ok();
|
|
|
}
|
|
|
|
|
@@ -240,46 +256,47 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
throw new BadReqException("该诊断报告不存在");
|
|
|
}
|
|
|
|
|
|
- String electronicControlIds = repair.getElectronicControlIds();
|
|
|
RepairVO vo = new RepairVO();
|
|
|
- List<Integer> eleIds = Arrays.stream(electronicControlIds.split(","))
|
|
|
- .map(Integer::parseInt)
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<Integer> eleIds = electronicControlService.lambdaQuery()
|
|
|
+ .eq(ElectronicControl::getRepairId, repair.getId())
|
|
|
+ .list().stream().map(c -> c.getId()).collect(Collectors.toList());
|
|
|
|
|
|
BeanUtil.copyProperties(repair, vo);
|
|
|
ReportTitleDto reportTitleDto = new ReportTitleDto();
|
|
|
- BeanUtil.copyProperties(repair,reportTitleDto);
|
|
|
+ BeanUtil.copyProperties(repair, reportTitleDto);
|
|
|
|
|
|
List<ElectronicControls> electronicControlsList = new ArrayList<>();
|
|
|
int eleCount = 0;
|
|
|
int faultCount = 0;
|
|
|
- for (Integer eleId : eleIds) {
|
|
|
- ElectronicControls electronicControls = new ElectronicControls();
|
|
|
- ElectronicControl electronicControl = electronicControlService.getById(eleId);
|
|
|
+ if (!eleIds.isEmpty()) {
|
|
|
+ for (Integer eleId : eleIds) {
|
|
|
+ ElectronicControls electronicControls = new ElectronicControls();
|
|
|
+ ElectronicControl electronicControl = electronicControlService.getById(eleId);
|
|
|
|
|
|
- BeanUtil.copyProperties(electronicControl,reportTitleDto);
|
|
|
- electronicControls.setElectronicControlName(electronicControl.getElectronicControlName());
|
|
|
+ BeanUtil.copyProperties(electronicControl, reportTitleDto);
|
|
|
+ electronicControls.setElectronicControlName(electronicControl.getElectronicControlName());
|
|
|
|
|
|
- List<EcuInfo> list = ecuInfoService.lambdaQuery()
|
|
|
- .eq(EcuInfo::getElectronicControlId, eleId)
|
|
|
- .list();
|
|
|
- electronicControls.setEcuInfo(list);
|
|
|
+ List<EcuInfo> list = ecuInfoService.lambdaQuery()
|
|
|
+ .eq(EcuInfo::getElectronicControlId, eleId)
|
|
|
+ .list();
|
|
|
+ electronicControls.setEcuInfo(list);
|
|
|
|
|
|
- List<FaultCode> faultCodeList = faultCodeService.lambdaQuery()
|
|
|
- .eq(FaultCode::getElectronicControlId, eleId)
|
|
|
- .list();
|
|
|
- electronicControls.setFaultCode(faultCodeList);
|
|
|
+ List<FaultCode> faultCodeList = faultCodeService.lambdaQuery()
|
|
|
+ .eq(FaultCode::getElectronicControlId, eleId)
|
|
|
+ .list();
|
|
|
+ electronicControls.setFaultCode(faultCodeList);
|
|
|
|
|
|
- electronicControlsList.add(electronicControls);
|
|
|
- eleCount++;
|
|
|
- faultCount += faultCodeList.size();
|
|
|
+ electronicControlsList.add(electronicControls);
|
|
|
+ eleCount++;
|
|
|
+ faultCount += faultCodeList.size();
|
|
|
+ }
|
|
|
}
|
|
|
vo.setElectronicControls(electronicControlsList);
|
|
|
vo.setElectronicControlCount(eleCount);
|
|
|
vo.setFaultCodeCount(faultCount);
|
|
|
vo.setReportTitleDto(reportTitleDto);
|
|
|
|
|
|
- return Result.ok(vo);
|
|
|
+ return Result.ok();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -297,7 +314,7 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
//分页查询
|
|
|
Page<Repair> page = this.lambdaQuery()
|
|
|
.like(StringUtils.isNotBlank(searchNum), Repair::getSn, searchNum)
|
|
|
- .like(StringUtils.isNotBlank(searchVIN),Repair::getVin,searchVIN)
|
|
|
+ .like(StringUtils.isNotBlank(searchVIN), Repair::getVin, searchVIN)
|
|
|
.like(StringUtils.isNotBlank(searchDistributor), Repair::getDepartmentName, searchDistributor)
|
|
|
.ge(beginTime != null, Repair::getCreateTime, beginTime)
|
|
|
.le(endTime != null, Repair::getCreateTime, endTime)
|
|
@@ -315,22 +332,24 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
}
|
|
|
|
|
|
List<Repair> records = page.getRecords();
|
|
|
+ if (records.isEmpty()) {
|
|
|
+ return Result.ok(vo);
|
|
|
+ }
|
|
|
+
|
|
|
List<QueryRepairVO> queryRepairVOList = new ArrayList<>();
|
|
|
for (Repair record : records) {
|
|
|
QueryRepairVO queryRepairVO = BeanUtil.copyProperties(record, QueryRepairVO.class);
|
|
|
-
|
|
|
- String electronicControlIds = record.getElectronicControlIds();
|
|
|
- List<Integer> eleIds = Arrays.stream(electronicControlIds.split(","))
|
|
|
- .map(Integer::parseInt)
|
|
|
- .collect(Collectors.toList());
|
|
|
- List<ElectronicControl> electronicControlList = electronicControlService.listByIds(eleIds);
|
|
|
-
|
|
|
- //查询系统数量
|
|
|
- queryRepairVO.setSystemCount(electronicControlList.size());
|
|
|
-
|
|
|
+ //根据Repair id 查询
|
|
|
+ List<ElectronicControl> electronicControls = electronicControlService.lambdaQuery()
|
|
|
+ .eq(ElectronicControl::getRepairId, record.getId())
|
|
|
+ .list();
|
|
|
+ if (!electronicControls.isEmpty()) {
|
|
|
+ //查询系统数量
|
|
|
+ queryRepairVO.setSystemCount(electronicControls.size());
|
|
|
+ }
|
|
|
|
|
|
int faultCount = 0;
|
|
|
- for (ElectronicControl electronicControl : electronicControlList) {
|
|
|
+ for (ElectronicControl electronicControl : electronicControls) {
|
|
|
List<FaultCode> faultCodeList = faultCodeService.lambdaQuery()
|
|
|
.eq(electronicControl != null, FaultCode::getElectronicControlId, electronicControl.getId())
|
|
|
.list();
|
|
@@ -353,75 +372,66 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
//根据id查询报告是否存在
|
|
|
Repair repair = this.getById(id);
|
|
|
|
|
|
- if (BeanUtil.isEmpty(repair)){
|
|
|
+ if (BeanUtil.isEmpty(repair)) {
|
|
|
throw new BadReqException("该诊断报告不存在");
|
|
|
}
|
|
|
|
|
|
- Map<String,String> baseMap = new HashMap<>();
|
|
|
- baseMap.put("车架号",repair.getVin());
|
|
|
- baseMap.put("年款",repair.getModelYear());
|
|
|
- baseMap.put("里程",repair.getMileage());
|
|
|
- baseMap.put("诊断路径",repair.getDiagnosticPath());
|
|
|
- baseMap.put("报告编号",repair.getRepairNum());
|
|
|
- baseMap.put("SN",repair.getSn());
|
|
|
+ Map<String, String> baseMap = new HashMap<>();
|
|
|
+ baseMap.put("车架号", repair.getVin());
|
|
|
+ baseMap.put("年款", repair.getModelYear());
|
|
|
+ baseMap.put("里程", repair.getMileage());
|
|
|
+ baseMap.put("诊断路径", repair.getDiagnosticPath());
|
|
|
+ baseMap.put("报告编号", repair.getRepairNum());
|
|
|
+ baseMap.put("SN", repair.getSn());
|
|
|
|
|
|
- String username = repair.getUsername();
|
|
|
- //根据用户名查询用户
|
|
|
- User user = userService.lambdaQuery()
|
|
|
- .eq(User::getUsername, username)
|
|
|
- .one();
|
|
|
- if (BeanUtil.isEmpty(user)){
|
|
|
- throw new BadReqException("该用户不存在");
|
|
|
- }
|
|
|
|
|
|
- Map<String,String> companyMap = new HashMap<>();
|
|
|
- companyMap.put("公司",user.getCompany());
|
|
|
- companyMap.put("电话",user.getTel());
|
|
|
- companyMap.put("地址",user.getAddress());
|
|
|
+ Map<String, String> companyMap = new HashMap<>();
|
|
|
+ companyMap.put("公司", repair.getCompany());
|
|
|
+ companyMap.put("电话", repair.getTelephone());
|
|
|
+ companyMap.put("地址", repair.getAddress());
|
|
|
|
|
|
List<ControlListMap> controlListMap = new ArrayList<>();
|
|
|
|
|
|
- String electronicControlIds = repair.getElectronicControlIds();
|
|
|
- List<Integer> eleIds = Arrays.stream(electronicControlIds.split(","))
|
|
|
- .map(Integer::parseInt)
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- List<ElectronicControl> electronicControlList = electronicControlService.listByIds(eleIds);
|
|
|
- for (Integer eleId : eleIds) {
|
|
|
- ElectronicControl electronicControl = electronicControlService.getById(eleId);
|
|
|
-
|
|
|
- List<EcuInfo> EcuList = ecuInfoService.lambdaQuery()
|
|
|
- .eq(EcuInfo::getElectronicControlId, eleId)
|
|
|
- .list();
|
|
|
+ List<Integer> eleIds = electronicControlService.lambdaQuery()
|
|
|
+ .eq(ElectronicControl::getRepairId, repair.getId())
|
|
|
+ .list().stream().map(c -> c.getId()).collect(Collectors.toList());
|
|
|
+ if (!eleIds.isEmpty()) {
|
|
|
+ List<ElectronicControl> electronicControlList = electronicControlService.listByIds(eleIds);
|
|
|
+ for (Integer eleId : eleIds) {
|
|
|
+ ElectronicControl electronicControl = electronicControlService.getById(eleId);
|
|
|
|
|
|
- List<FaultCode> FaultList = faultCodeService.lambdaQuery()
|
|
|
- .eq(FaultCode::getElectronicControlId, eleId)
|
|
|
- .eq(FaultCode::getStatus,1)
|
|
|
- .list();
|
|
|
+ List<EcuInfo> EcuList = ecuInfoService.lambdaQuery()
|
|
|
+ .eq(EcuInfo::getElectronicControlId, eleId)
|
|
|
+ .list();
|
|
|
|
|
|
- Map<String,String> faultCodeMap = new HashMap<>();
|
|
|
- Map<String,String> versionMap = new HashMap<>();
|
|
|
- for (EcuInfo ecuInfo : EcuList) {
|
|
|
- versionMap.put(ecuInfo.getStrCaption(),ecuInfo.getStrInformation());
|
|
|
- }
|
|
|
+ List<FaultCode> FaultList = faultCodeService.lambdaQuery()
|
|
|
+ .eq(FaultCode::getElectronicControlId, eleId)
|
|
|
+ .eq(FaultCode::getStatus, 1)
|
|
|
+ .list();
|
|
|
|
|
|
- for (FaultCode faultCode : FaultList) {
|
|
|
- faultCodeMap.put(faultCode.getFaultCode(),faultCode.getDescription());
|
|
|
+ Map<String, String> faultCodeMap = new HashMap<>();
|
|
|
+ Map<String, String> versionMap = new HashMap<>();
|
|
|
+ for (EcuInfo ecuInfo : EcuList) {
|
|
|
+ versionMap.put(ecuInfo.getStrCaption(), ecuInfo.getStrInformation());
|
|
|
+ }
|
|
|
+
|
|
|
+ for (FaultCode faultCode : FaultList) {
|
|
|
+ faultCodeMap.put(faultCode.getFaultCode(), faultCode.getDescription());
|
|
|
+ }
|
|
|
+ ControlListMap controlListMap1 = new ControlListMap();
|
|
|
+ controlListMap1.setName(electronicControl.getElectronicControlName());
|
|
|
+ controlListMap1.setVersionMap(versionMap);
|
|
|
+ controlListMap1.setFaultCodeMap(faultCodeMap);
|
|
|
+ controlListMap.add(controlListMap1);
|
|
|
}
|
|
|
- ControlListMap controlListMap1 = new ControlListMap();
|
|
|
- controlListMap1.setName(electronicControl.getElectronicControlName());
|
|
|
- controlListMap1.setVersionMap(versionMap);
|
|
|
- controlListMap1.setFaultCodeMap(faultCodeMap);
|
|
|
- controlListMap.add(controlListMap1);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
File file = pdfUtil.MapToPDF(repair.getId(), controlListMap, baseMap, companyMap);
|
|
|
- if (file==null){
|
|
|
+ if (file == null) {
|
|
|
throw new BizException("该pdf文件不存在");
|
|
|
}
|
|
|
try {
|
|
|
- huaweiObsUtil.upload(file, "report");
|
|
|
+ huaweiObsUtil.upload(file, "report");
|
|
|
String uploadUrl1 = huaweiObsUtil.getUploadUrl(file.getName(), "report");
|
|
|
file.delete();
|
|
|
return Result.ok(uploadUrl1);
|
|
@@ -435,75 +445,67 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
//根据id查询报告是否存在
|
|
|
Repair repair = this.getById(id);
|
|
|
|
|
|
- if (BeanUtil.isEmpty(repair)){
|
|
|
+ if (BeanUtil.isEmpty(repair)) {
|
|
|
throw new BadReqException("该诊断报告不存在");
|
|
|
}
|
|
|
|
|
|
- Map<String,String> baseMap = new HashMap<>();
|
|
|
- baseMap.put("车架号",repair.getVin());
|
|
|
- baseMap.put("年款",repair.getModelYear());
|
|
|
- baseMap.put("里程",repair.getMileage());
|
|
|
- baseMap.put("诊断路径",repair.getDiagnosticPath());
|
|
|
- baseMap.put("报告编号",repair.getRepairNum());
|
|
|
- baseMap.put("SN",repair.getSn());
|
|
|
+ Map<String, String> baseMap = new HashMap<>();
|
|
|
+ baseMap.put("车架号", repair.getVin());
|
|
|
+ baseMap.put("年款", repair.getModelYear());
|
|
|
+ baseMap.put("里程", repair.getMileage());
|
|
|
+ baseMap.put("诊断路径", repair.getDiagnosticPath());
|
|
|
+ baseMap.put("报告编号", repair.getRepairNum());
|
|
|
+ baseMap.put("SN", repair.getSn());
|
|
|
|
|
|
- String username = repair.getUsername();
|
|
|
- //根据用户名查询用户
|
|
|
- User user = userService.lambdaQuery()
|
|
|
- .eq(User::getUsername, username)
|
|
|
- .one();
|
|
|
- if (BeanUtil.isEmpty(user)){
|
|
|
- return Result.fail("用户不存在").result(ResultCode.USER_NO_EXIST);
|
|
|
- }
|
|
|
-
|
|
|
- Map<String,String> companyMap = new HashMap<>();
|
|
|
- companyMap.put("公司",user.getCompany());
|
|
|
- companyMap.put("电话",user.getTel());
|
|
|
- companyMap.put("地址",user.getAddress());
|
|
|
+ Map<String, String> companyMap = new HashMap<>();
|
|
|
+ companyMap.put("公司", repair.getCompany());
|
|
|
+ companyMap.put("电话", repair.getTelephone());
|
|
|
+ companyMap.put("地址", repair.getAddress());
|
|
|
|
|
|
List<ControlListMap> controlListMap = new ArrayList<>();
|
|
|
|
|
|
- String electronicControlIds = repair.getElectronicControlIds();
|
|
|
- List<Integer> eleIds = Arrays.stream(electronicControlIds.split(","))
|
|
|
- .map(Integer::parseInt)
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- List<ElectronicControl> electronicControlList = electronicControlService.listByIds(eleIds);
|
|
|
- for (Integer eleId : eleIds) {
|
|
|
- ElectronicControl electronicControl = electronicControlService.getById(eleId);
|
|
|
-
|
|
|
- List<EcuInfo> EcuList = ecuInfoService.lambdaQuery()
|
|
|
- .eq(EcuInfo::getElectronicControlId, eleId)
|
|
|
- .list();
|
|
|
+ List<Integer> eleIds = electronicControlService.lambdaQuery()
|
|
|
+ .eq(ElectronicControl::getRepairId, repair.getId())
|
|
|
+ .list().stream().map(c -> c.getId()).collect(Collectors.toList());
|
|
|
+ if (!eleIds.isEmpty()) {
|
|
|
+ List<ElectronicControl> electronicControlList = electronicControlService.listByIds(eleIds);
|
|
|
+ for (Integer eleId : eleIds) {
|
|
|
+ ElectronicControl electronicControl = electronicControlService.getById(eleId);
|
|
|
|
|
|
- List<FaultCode> FaultList = faultCodeService.lambdaQuery()
|
|
|
- .eq(FaultCode::getElectronicControlId, eleId)
|
|
|
- .eq(FaultCode::getStatus,1)
|
|
|
- .list();
|
|
|
+ List<EcuInfo> EcuList = ecuInfoService.lambdaQuery()
|
|
|
+ .eq(EcuInfo::getElectronicControlId, eleId)
|
|
|
+ .list();
|
|
|
|
|
|
- Map<String,String> faultCodeMap = new HashMap<>();
|
|
|
- Map<String,String> versionMap = new HashMap<>();
|
|
|
- for (EcuInfo ecuInfo : EcuList) {
|
|
|
- versionMap.put(ecuInfo.getStrCaption(),ecuInfo.getStrInformation());
|
|
|
- }
|
|
|
+ List<FaultCode> FaultList = faultCodeService.lambdaQuery()
|
|
|
+ .eq(FaultCode::getElectronicControlId, eleId)
|
|
|
+ .eq(FaultCode::getStatus, 1)
|
|
|
+ .list();
|
|
|
|
|
|
- for (FaultCode faultCode : FaultList) {
|
|
|
- faultCodeMap.put(faultCode.getFaultCode(),faultCode.getDescription());
|
|
|
+ Map<String, String> faultCodeMap = new HashMap<>();
|
|
|
+ Map<String, String> versionMap = new HashMap<>();
|
|
|
+ for (EcuInfo ecuInfo : EcuList) {
|
|
|
+ versionMap.put(ecuInfo.getStrCaption(), ecuInfo.getStrInformation());
|
|
|
+ }
|
|
|
+
|
|
|
+ for (FaultCode faultCode : FaultList) {
|
|
|
+ faultCodeMap.put(faultCode.getFaultCode(), faultCode.getDescription());
|
|
|
+ }
|
|
|
+ ControlListMap controlListMap1 = new ControlListMap();
|
|
|
+ controlListMap1.setName(electronicControl.getElectronicControlName());
|
|
|
+ controlListMap1.setVersionMap(versionMap);
|
|
|
+ controlListMap1.setFaultCodeMap(faultCodeMap);
|
|
|
+ controlListMap.add(controlListMap1);
|
|
|
}
|
|
|
- ControlListMap controlListMap1 = new ControlListMap();
|
|
|
- controlListMap1.setName(electronicControl.getElectronicControlName());
|
|
|
- controlListMap1.setVersionMap(versionMap);
|
|
|
- controlListMap1.setFaultCodeMap(faultCodeMap);
|
|
|
- controlListMap.add(controlListMap1);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
File file = htmlGenerator.generateHtmlByMap(repair.getId(), controlListMap, baseMap, companyMap);
|
|
|
|
|
|
- if (file==null){
|
|
|
+ if (file == null) {
|
|
|
throw new BizException("该h5文件不存在");
|
|
|
}
|
|
|
try {
|
|
|
- huaweiObsUtil.upload(file,"h5");
|
|
|
+ huaweiObsUtil.upload(file, "h5");
|
|
|
|
|
|
String uploadUrl1 = huaweiObsUtil.getUploadUrl(file.getName(), "h5");
|
|
|
file.delete();
|
|
@@ -521,16 +523,15 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
|
|
|
//根据id进行查询
|
|
|
Repair repair = this.getById(id);
|
|
|
- if (BeanUtil.isEmpty(repair)){
|
|
|
+ if (BeanUtil.isEmpty(repair)) {
|
|
|
throw new BadReqException("该诊断报告不存在");
|
|
|
}
|
|
|
|
|
|
- if (type.equals("vin")){
|
|
|
+ if (type.equals("vin")) {
|
|
|
repair.setVin(value);
|
|
|
- }else if (type.equals("year")){
|
|
|
+ } else if (type.equals("year")) {
|
|
|
repair.setModelYear(value);
|
|
|
- }
|
|
|
- else if (type.equals("mileage")){
|
|
|
+ } else if (type.equals("mileage")) {
|
|
|
repair.setMileage(value);
|
|
|
}
|
|
|
|
|
@@ -546,7 +547,7 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
|
|
|
//根据id进行查询
|
|
|
Repair repair = this.getById(id);
|
|
|
- if (BeanUtil.isEmpty(repair)){
|
|
|
+ if (BeanUtil.isEmpty(repair)) {
|
|
|
throw new BadReqException("该诊断报告不存在");
|
|
|
}
|
|
|
String username = repair.getUsername();
|
|
@@ -555,16 +556,15 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
|
User user = userService.lambdaQuery()
|
|
|
.eq(User::getUsername, username)
|
|
|
.one();
|
|
|
- if (BeanUtil.isEmpty(user)){
|
|
|
+ if (BeanUtil.isEmpty(user)) {
|
|
|
return Result.fail("用户不存在").result(ResultCode.USER_NO_EXIST);
|
|
|
}
|
|
|
|
|
|
- if (type.equals("company")){
|
|
|
+ if (type.equals("company")) {
|
|
|
user.setCompany(value);
|
|
|
- }else if (type.equals("address")){
|
|
|
+ } else if (type.equals("address")) {
|
|
|
user.setAddress(value);
|
|
|
- }
|
|
|
- else if (type.equals("phone")){
|
|
|
+ } else if (type.equals("phone")) {
|
|
|
user.setTel(value);
|
|
|
}
|
|
|
|