|
@@ -12,10 +12,7 @@ import com.om.exception.BizException;
|
|
import com.om.mapper.RepairMapper;
|
|
import com.om.mapper.RepairMapper;
|
|
import com.om.service.*;
|
|
import com.om.service.*;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import com.om.utils.HuaweiObsUtil;
|
|
|
|
-import com.om.utils.ITextPdfUtil;
|
|
|
|
-import com.om.utils.Result;
|
|
|
|
-import com.om.utils.UserContext;
|
|
|
|
|
|
+import com.om.utils.*;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -30,6 +27,7 @@ import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -414,11 +412,100 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
|
|
try {
|
|
try {
|
|
huaweiObsUtil.upload(file, "report");
|
|
huaweiObsUtil.upload(file, "report");
|
|
String uploadUrl1 = huaweiObsUtil.getUploadUrl(file.getName(), "report");
|
|
String uploadUrl1 = huaweiObsUtil.getUploadUrl(file.getName(), "report");
|
|
|
|
+ file.delete();
|
|
|
|
+ return Result.ok(uploadUrl1);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result<String> reportH5(Integer id) {
|
|
|
|
+ //根据id查询报告是否存在
|
|
|
|
+ Repair repair = this.getById(id);
|
|
|
|
+
|
|
|
|
+ if (BeanUtil.isEmpty(repair)){
|
|
|
|
+ throw new BadReqException("该诊断报告不存在");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String,String> baseMap = new HashMap<>();
|
|
|
|
+ baseMap.put("车架号",repair.getVin());
|
|
|
|
+ baseMap.put("年款",repair.getMileage());
|
|
|
|
+ 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());
|
|
|
|
+
|
|
|
|
+ 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<FaultCode> FaultList = faultCodeService.lambdaQuery()
|
|
|
|
+ .eq(FaultCode::getElectronicControlId, eleId)
|
|
|
|
+ .eq(FaultCode::getStatus,1)
|
|
|
|
+ .list();
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ File file = HtmlGenerator.generateHtmlByMap(repair.getId(), controlListMap, baseMap, companyMap);
|
|
|
|
+
|
|
|
|
+ if (file==null){
|
|
|
|
+ throw new BizException("该h5文件不存在");
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ huaweiObsUtil.upload(file,"h5");
|
|
|
|
+
|
|
|
|
+ String uploadUrl1 = huaweiObsUtil.getUploadUrl(file.getName(), "h5");
|
|
|
|
+ file.delete();
|
|
return Result.ok(uploadUrl1);
|
|
return Result.ok(uploadUrl1);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|