Pārlūkot izejas kodu

诊断报告重新修改

bmmx 1 gadu atpakaļ
vecāks
revīzija
650d90a17a

+ 0 - 1
src/main/java/com/om/controller/admin/AppUserController.java

@@ -92,7 +92,6 @@ public class AppUserController {
     @GetMapping("/relieve(未写)")
     @ApiOperation("(未写)")
     public Result relieve(){
-
         //这里未写,未知要求
         return userService.relieve();
     }

+ 1 - 1
src/main/java/com/om/controller/admin/DiagnosisVersionInfoController.java

@@ -72,7 +72,7 @@ public class DiagnosisVersionInfoController {
     @ApiOperation("分页查询诊断程序")
     public Result getPageList(@RequestParam Integer pageIndex,
                               @RequestParam Integer pageSize,
-                              @RequestParam String username){
+                              @RequestParam(required = false) String username){
 
         return dvIoService.getPageList(pageIndex,pageSize,username);
     }

+ 1 - 1
src/main/java/com/om/controller/user/APPRepairController.java

@@ -45,7 +45,7 @@ public class APPRepairController {
 
 
     @PostMapping("/delete")
-    @ApiOperation("获取诊断报告列表")
+    @ApiOperation("删除诊断报告列表")
     public Result delete(@RequestBody AppBaseDTO dto){
         return repairService.delete(dto);
     }

+ 24 - 2
src/main/java/com/om/entity/dto/APPReportCreateDTO.java

@@ -1,7 +1,6 @@
 package com.om.entity.dto;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
+
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -25,6 +24,15 @@ public class APPReportCreateDTO extends AppBaseDTO {
     @ApiModelProperty(value = "里程")
     private String mileage;
 
+    @ApiModelProperty(value = "地址")
+    private String address;
+
+    @ApiModelProperty(value = "公司")
+    private String company;
+
+    @ApiModelProperty(value = "电话")
+    private String telephone;
+
     @ApiModelProperty(value = "SN号")
     private String sn;
 
@@ -37,6 +45,20 @@ public class APPReportCreateDTO extends AppBaseDTO {
     @ApiModelProperty(value = "报告编号")
     private String repairNum;
 
+    @ApiModelProperty(value = "小标题,如:诊断详情")
+    private String diagnosticDetailsTitle;
+
+    @ApiModelProperty(value = "故障码标题")
+    private String faultCodeTitle;
+
+    @ApiModelProperty(value = "版本信息标题")
+    private String versionInfoTitle;
+
+    @ApiModelProperty(value = "异常系统标题")
+    private String abnormalSystemTitle;
+
+    @ApiModelProperty(value = "正常系统标题")
+    private String normalSystemTitle;
 
     @ApiModelProperty(value = "激活的系统集合")
     private List<AppElectronicDTO> electronicControls;

+ 0 - 18
src/main/java/com/om/entity/dto/AppElectronicDTO.java

@@ -10,27 +10,9 @@ import java.util.List;
 @Data
 public class AppElectronicDTO {
 
-    @ApiModelProperty(value = "electronic_controlID")
-    private Integer id;
-
     @ApiModelProperty(value = "系统名称")
     private String electronicControlName;
 
-    @ApiModelProperty(value = "小标题,如:诊断详情")
-    private String diagnosticDetailsTitle;
-
-    @ApiModelProperty(value = "故障码标题")
-    private String faultCodeTitle;
-
-    @ApiModelProperty(value = "版本信息标题")
-    private String versionInfoTitle;
-
-    @ApiModelProperty(value = "异常系统标题")
-    private String abnormalSystemTitle;
-
-    @ApiModelProperty(value = "正常系统标题")
-    private String normalSystem;
-
     @ApiModelProperty(value = "版本信息集合")
     private List<AppEcuInfoDTO> ecuInfors;
 

+ 3 - 0
src/main/java/com/om/entity/po/DiagClients.java

@@ -40,5 +40,8 @@ public class DiagClients implements Serializable {
     @ApiModelProperty(value = "客户端编号")
     private String clientNum;
 
+    @ApiModelProperty(value = "客户端名称")
+    private String clientName;
+
 
 }

+ 0 - 1
src/main/java/com/om/entity/po/DiagnosisVersionInfo.java

@@ -41,7 +41,6 @@ public class DiagnosisVersionInfo implements Serializable {
     @ApiModelProperty(value = "客户端编号")
     private String clientNumber;
 
-
     @ApiModelProperty(value = "密码代码")
     private String cipherCode;
 

+ 2 - 15
src/main/java/com/om/entity/po/ElectronicControl.java

@@ -34,20 +34,7 @@ public class ElectronicControl implements Serializable {
     @ApiModelProperty(value = "系统名称")
     private String electronicControlName;
 
-    @ApiModelProperty(value = "小标题,如:诊断详情")
-    private String diagnosticDetailsTitle;
-
-    @ApiModelProperty(value = "故障码标题")
-    private String faultCodeTitle;
-
-    @ApiModelProperty(value = "版本信息标题")
-    private String versionInfoTitle;
-
-    @ApiModelProperty(value = "异常系统标题")
-    private String abnormalSystemTitle;
-
-    @ApiModelProperty(value = "正常系统标题")
-    private String normalSystemTitle;
-
+    @ApiModelProperty(value = "诊断报告id")
+    private Integer repairId;
 
 }

+ 1 - 1
src/main/java/com/om/entity/po/FaultCode.java

@@ -41,7 +41,7 @@ public class FaultCode implements Serializable {
     private String description;
 
     @ApiModelProperty(value = "故障码状态")
-    private String status;
+    private Integer status;
 
 
 }

+ 26 - 3
src/main/java/com/om/entity/po/Repair.java

@@ -52,9 +52,6 @@ public class Repair implements Serializable {
     @ApiModelProperty(value = "诊断路径")
     private String diagnosticPath;
 
-    @ApiModelProperty(value = "关联的ElectronicControlDetails IDs")
-    private String electronicControlIds;
-
     @ApiModelProperty(value = "更新时间")
     private LocalDateTime updateTime;
 
@@ -67,6 +64,16 @@ public class Repair implements Serializable {
     @ApiModelProperty(value = "维修厂名称")
     private String departmentName;
 
+
+    @ApiModelProperty(value = "地址")
+    private String address;
+
+    @ApiModelProperty(value = "公司")
+    private String company;
+
+    @ApiModelProperty(value = "电话")
+    private String telephone;
+
     @ApiModelProperty(value = "报告编号")
     private String repairNum;
 
@@ -82,5 +89,21 @@ public class Repair implements Serializable {
     @ApiModelProperty(value = "状态")
     private Integer status;
 
+    @ApiModelProperty(value = "小标题,如:诊断详情")
+    private String diagnosticDetailsTitle;
+
+    @ApiModelProperty(value = "故障码标题")
+    private String faultCodeTitle;
+
+    @ApiModelProperty(value = "版本信息标题")
+    private String versionInfoTitle;
+
+    @ApiModelProperty(value = "异常系统标题")
+    private String abnormalSystemTitle;
+
+    @ApiModelProperty(value = "正常系统标题")
+    private String normalSystemTitle;
+
+
 
 }

+ 0 - 3
src/main/java/com/om/entity/vo/APpDistributorVO.java

@@ -15,9 +15,6 @@ import java.io.Serializable;
 @NoArgsConstructor
 public class APpDistributorVO extends AppBaseDTO implements Serializable {
 
-    @ApiModelProperty(value = "标识符")
-    private Integer id;
-
     @ApiModelProperty(value = "公司名称")
     private String company;
 

+ 35 - 0
src/main/java/com/om/entity/vo/DiagnosisVersionSearchVO.java

@@ -0,0 +1,35 @@
+package com.om.entity.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class DiagnosisVersionSearchVO implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private Integer id;
+    private String mark;
+    private String diagnosisName;
+    private String brandName;
+    private String[] clientNames;
+    private String[] language;
+    private String[] descriptionList;
+    private String fileUrl;
+    private String fileName;
+    private long diagnosisFileSize;
+    private Integer status;
+    private String username;
+    private String version;
+    private String savePath;
+    @ApiModelProperty(value = "创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+}

+ 18 - 6
src/main/java/com/om/service/impl/DiagnosisVersionInfoServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.obs.services.model.TemporarySignatureRequest;
 import com.om.entity.dto.*;
 import com.om.entity.po.*;
+import com.om.entity.vo.DiagnosisVersionSearchVO;
 import com.om.entity.vo.DiagnosisVersionVO;
 import com.om.entity.vo.DignosisPageVO;
 import com.om.exception.BadReqException;
@@ -218,25 +219,28 @@ public class DiagnosisVersionInfoServiceImpl extends ServiceImpl<DiagnosisVersio
                 .page(new Page<>(pageIndex, pageSize));
         //获取总的数据
         List<DiagnosisVersionInfo> diagLists = page.getRecords();
-        List<DiagnosisVersionVO> diagVOLists = new ArrayList<>();
+        List<DiagnosisVersionSearchVO> diagVOLists = new ArrayList<>();
+
+
         for (int i = 0; i < diagLists.size(); i++) {
             //然后取得客户端编号
             DiagnosisVersionInfo info = diagLists.get(i);
             //创建前端传输数据
-            DiagnosisVersionVO versionVO = new DiagnosisVersionVO();
+            DiagnosisVersionSearchVO versionVO = new DiagnosisVersionSearchVO();
             BeanUtil.copyProperties(info, versionVO);
             Integer diagId = info.getId();
             LambdaQueryWrapper<DiagClients> queryWrapper = new LambdaQueryWrapper<>();
             queryWrapper.eq(DiagClients::getDiagId, diagId);
             List<DiagClients> diagClients = diagClientsService.list(queryWrapper);
             log.info("====diagClients={}", diagClients);
+
             String[] s = new String[diagClients.size()];
 
             for (int j = 0; j < diagClients.size(); j++) {
-                s[j] = diagClients.get(j).getClientNum();
+                s[j] = diagClients.get(j).getClientName();
             }
             //传入客户端num
-            versionVO.setClientNums(s);
+            versionVO.setClientNames(s);
 
             //传输描述和语言集合
             LambdaQueryWrapper<DiagnosisVersionDescribe> describeQueryWrapper = new LambdaQueryWrapper<>();
@@ -250,15 +254,23 @@ public class DiagnosisVersionInfoServiceImpl extends ServiceImpl<DiagnosisVersio
                 language[i1] = describe.getLanguage();
                 description[i1] = describe.getDescription();
             }
+
+            //根据品牌编号查询名称
+            Brand brand = brandService.lambdaQuery()
+                    .eq(Brand::getBrandCode, info.getBrandCode())
+                    .one();
+            if (BeanUtil.isEmpty(brand)){
+                throw new BadReqException(info.getDiagnosisName()+"此诊断程序中品牌编号有误");
+            }
             //传入客户端
             versionVO.setLanguage(language);
             versionVO.setDescriptionList(description);
-
+            versionVO.setBrandName(brand.getBrandCn());
             diagVOLists.add(versionVO);
 
 
         }
-        Page<DiagnosisVersionVO> pageVO = new Page<>();
+        Page<DiagnosisVersionSearchVO> pageVO = new Page<>();
         BeanUtil.copyProperties(page, pageVO);
         pageVO.setRecords(diagVOLists);
 

+ 0 - 1
src/main/java/com/om/service/impl/DistributorServiceImpl.java

@@ -195,7 +195,6 @@ public class DistributorServiceImpl extends ServiceImpl<DistributorMapper, Distr
         }
         BeanUtil.copyProperties(distributorVO,distributor);
         distributor.setUpdateTime(LocalDateTime.now());
-
         //修改操作
         this.updateById(distributor);
         return Result.ok();

+ 205 - 205
src/main/java/com/om/service/impl/RepairServiceImpl.java

@@ -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);
         }
 

+ 1 - 1
src/main/java/com/om/service/impl/UserServiceImpl.java

@@ -101,7 +101,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
             throw new BizException("密码加密出错", ResultCode.PASSWORD_ENCRYPT_ERROR);
         }
         //判断密码是否正确
-        if (StringUtils.equals(password, user.getPassword())) {
+        if (!StringUtils.equals(password, user.getPassword())) {
             return Result.fail("密码错误").result(ResultCode.PASSWORD_ERROR);
         }
         if (user.getState() == 0) {

+ 62 - 55
src/main/java/com/om/service/impl/VciInfoServiceImpl.java

@@ -13,10 +13,7 @@ import com.om.mapper.UserMapper;
 import com.om.mapper.VciInfoMapper;
 import com.om.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.om.utils.AesUtil;
-import com.om.utils.JwtUtils;
-import com.om.utils.Result;
-import com.om.utils.ResultCode;
+import com.om.utils.*;
 import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Service;
 
@@ -68,6 +65,9 @@ public class VciInfoServiceImpl extends ServiceImpl<VciInfoMapper, VciInfo> impl
     @Resource
     private IAppsClientsService appsClientsService;
 
+    @Resource
+    private HuaweiObsUtil obsUtil;
+
 
     @Override
     public Result addVci(VciInfo vciInfo) {
@@ -204,68 +204,75 @@ public class VciInfoServiceImpl extends ServiceImpl<VciInfoMapper, VciInfo> impl
         List<Integer> sdkIds = sdkClientsService.lambdaQuery()
                 .eq(SdkClients::getClientNum, clientNum)
                 .list().stream().map(c -> c.getSdkId()).collect(Collectors.toList());
-
-        List<SdkVersionInfo> sdkVersionInfos = sdkVersionInfoService.listByIds(sdkIds);
-        for (SdkVersionInfo sdkVersionInfo : sdkVersionInfos) {
-            SDKData sdk = BeanUtil.copyProperties(sdkVersionInfo, SDKData.class);
-            sdk.setVersion(sdkVersionInfo.getVersionNum());
-            sdk.setUrl(sdkVersionInfo.getSavePath());
-
-            //根据pcbId查询pcb
-            PcbVersionInfo pcbVersionInfo = pcbVersionInfoService.getById(sdkVersionInfo.getId());
-            if(BeanUtil.isEmpty(pcbVersionInfo)){
-                throw new BadReqException("该PCB版本不存在!!!");
+        if (!sdkIds.isEmpty()){
+            List<SdkVersionInfo> sdkVersionInfos = sdkVersionInfoService.listByIds(sdkIds);
+            for (SdkVersionInfo sdkVersionInfo : sdkVersionInfos) {
+                SDKData sdk = BeanUtil.copyProperties(sdkVersionInfo, SDKData.class);
+                sdk.setVersion(sdkVersionInfo.getVersionNum());
+                String uploadUrl = obsUtil.getUploadUrl(sdkVersionInfo.getFileName(), "appv");
+                sdk.setUrl(uploadUrl);
+
+                //根据pcbId查询pcb
+                PcbVersionInfo pcbVersionInfo = pcbVersionInfoService.getById(sdkVersionInfo.getId());
+                if(BeanUtil.isEmpty(pcbVersionInfo)){
+                    throw new BadReqException("该PCB版本不存在!!!");
+                }
+
+                SdkVersionDescribe sdkVersionDescribe = sdkVersionDescribeService.lambdaQuery()
+                        .eq(SdkVersionDescribe::getSdkId, sdkVersionInfo.getId())
+                        .eq(SdkVersionDescribe::getLanguage, language)
+                        .one();
+
+                if (BeanUtil.isEmpty(sdkVersionDescribe)){
+                    throw new BadReqException("SDK版本描述不存在");
+                }
+
+                sdk.setDescription(sdkVersionDescribe.getDescription());
+                sdk.setPcbVersion(pcbVersionInfo.getVersionNum());
+                sdkData.add(sdk);
             }
-
-            SdkVersionDescribe sdkVersionDescribe = sdkVersionDescribeService.lambdaQuery()
-                    .eq(SdkVersionDescribe::getSdkId, sdkVersionInfo.getId())
-                    .eq(SdkVersionDescribe::getLanguage, language)
-                    .one();
-
-            if (BeanUtil.isEmpty(sdkVersionDescribe)){
-                throw new BadReqException("SDK版本描述不存在");
-            }
-
-            sdk.setDescription(sdkVersionDescribe.getDescription());
-            sdk.setPcbVersion(pcbVersionInfo.getVersionNum());
-            sdkData.add(sdk);
         }
 
+
         List<Integer> appIds = appsClientsService.lambdaQuery()
                 .eq(AppsClients::getClientNum, clientNum)
                 .list().stream().map(c -> c.getAppId()).collect(Collectors.toList());
-        List<App> apps = appService.listByIds(appIds);
-        if (apps.isEmpty()){
-            return Result.error().result(ResultCode.SERVICE_HANDLE_ERROR);
-        }
-        for (App app : apps) {
-            appData appData1 = BeanUtil.copyProperties(app, appData.class);
-            appData1.setVersion(app.getVersionNum());
-            appData1.setUrl(app.getSavePath());
-
-            AppVersionDescribe appVersionDescribe = appVersionDescribeService.lambdaQuery()
-                    .eq(AppVersionDescribe::getAppId, app.getId())
-                    .eq(AppVersionDescribe::getLanguage, language)
-                    .one();
-            if (BeanUtil.isEmpty(appVersionDescribe)){
-                throw new BadReqException("app版本描述不存在");
-            }
-
 
-            appData1.setDescription(appVersionDescribe.getDescription());
-            Integer sdkId = app.getSdkId();
-            //根据sdkid查询sdk版本
-            SdkVersionInfo sdkVersionInfo = sdkVersionInfoService.getById(sdkId);
-            if (BeanUtil.isEmpty(sdkVersionInfo)){
-                throw new BadReqException("该sdk版本不存在");
+        if (!appIds.isEmpty()){
+            List<App> apps = appService.listByIds(appIds);
+            if (apps.isEmpty()){
+                return Result.error().result(ResultCode.SERVICE_HANDLE_ERROR);
+            }
+            for (App app : apps) {
+                appData appData1 = BeanUtil.copyProperties(app, appData.class);
+                appData1.setVersion(app.getVersionNum());
+                appData1.setUrl(app.getSavePath());
+
+                AppVersionDescribe appVersionDescribe = appVersionDescribeService.lambdaQuery()
+                        .eq(AppVersionDescribe::getAppId, app.getId())
+                        .eq(AppVersionDescribe::getLanguage, language)
+                        .one();
+                if (BeanUtil.isEmpty(appVersionDescribe)){
+                    throw new BadReqException("app版本描述不存在");
+                }
+
+
+                appData1.setDescription(appVersionDescribe.getDescription());
+                Integer sdkId = app.getSdkId();
+                //根据sdkid查询sdk版本
+                SdkVersionInfo sdkVersionInfo = sdkVersionInfoService.getById(sdkId);
+                if (BeanUtil.isEmpty(sdkVersionInfo)){
+                    throw new BadReqException("该sdk版本不存在");
+                }
+
+                appData1.setMinSdkVersion(sdkVersionInfo.getVersionNum());
+
+                appData.add(appData1);
             }
-
-            appData1.setMinSdkVersion(sdkVersionInfo.getVersionNum());
-
-            appData.add(appData1);
         }
 
 
+
         appSDKVO.setAppData(appData);
         appSDKVO.setSdkData(sdkData);
         return Result.ok(appSDKVO);

+ 9 - 3
src/main/java/com/om/utils/AesUtil.java

@@ -121,7 +121,7 @@ public class AesUtil {
          * 此处使用AES-128-ECB加密模式,key需要为16位。
          */
         // 加密
-        Map<String,Object> claims = new HashMap<>();
+      /*  Map<String,Object> claims = new HashMap<>();
         claims.put("u_id", 1);
         claims.put("deviceSn", "123456");
         claims.put("appVersion", "v3.0");
@@ -131,11 +131,17 @@ public class AesUtil {
 
         // 解密
         GuidDTO guidDTOFromGuid = getGuidDTOFromGuid(guid);
-        System.out.println("解密后的字串是:" + guidDTOFromGuid);
+        System.out.println("解密后的字串是:" + guidDTOFromGuid);*/
 
         //加密密码
-        String password = Encrypt("123456");
+        String password = Encrypt("1234");
         System.out.println("加密的密码是:"+password);
+
+        //密码解密
+        String decrypt = Decrypt(password);
+        System.out.println(decrypt);
     }
+
+
 }