Commit 944ce84a by 梁辉

新增自行上传检测报告(未完成)

parent c277b7f4
......@@ -53,6 +53,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
*/
static Map<String, JwtUserDto> userDtoCache = new ConcurrentHashMap<>();
@Override
public JwtUserDto loadUserByUsername(String username) {
boolean searchDb = true;
......
package me.zhengjie.modules.system.domain.vo.report;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ReportDownloadRespVo {
@ApiModelProperty("检测报告base64文件流")
private String reportBase64;
@ApiModelProperty("检测报告编号")
private String reportNum;
}
package me.zhengjie.modules.system.domain.vo.report;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
@Data
public class ReportFileUploadVo {
@ApiModelProperty("检测报告")
private MultipartFile reportFile;
@ApiModelProperty("行驶证1")
private MultipartFile drivingLicensePic1;
@ApiModelProperty("行驶证2")
private MultipartFile drivingLicensePic2;
@ApiModelProperty("身份证")
private MultipartFile idCardPic;
}
......@@ -11,6 +11,7 @@ import me.zhengjie.modules.system.domain.vo.signature.SignatureVo;
import me.zhengjie.modules.system.service.ReportService;
import me.zhengjie.utils.AssertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
......@@ -35,6 +36,25 @@ public class ReportController {
this.reportService = reportService;
}
@ApiOperation("上传车检文件")
@PostMapping(value = "/uploadReportFiles",produces = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResultVo uploadReportFiles(@RequestParam(name = "reportFile")MultipartFile reportFile,
@RequestParam(name = "drivingLicensePic1")MultipartFile drivingLicensePic1,
@RequestParam(name = "drivingLicensePic2")MultipartFile drivingLicensePic2,
@RequestParam(name = "idCardPic")MultipartFile idCardPic,
@RequestParam(name="reportPdfId")Integer reportPdfId){
return ResultVo.success();
}
@ApiOperation("下载检测报告Base64文件")
@GetMapping("/download/{reportPdfId}")
public ResultVo<ReportDownloadRespVo> downloadReport(@PathVariable Integer reportPdfId){
AssertUtil.isNotNull(reportPdfId,"缺少参数reportPdfId");
return ResultVo.success(reportService.getReportBase64FileByReportPdfId(reportPdfId));
}
@ApiOperation("获取当前用户部门下所有启用的签章")
@GetMapping("/signatureList")
public ResultVo<List<SignatureVo>> signatureList(){
......
package me.zhengjie.modules.system.service;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
......@@ -32,7 +33,9 @@ import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -72,6 +75,7 @@ public class ReportService {
this.restTemplate = restTemplate;
}
//调试用
static {
reportVoList = Arrays.asList(
TestReportVo.builder().InspectionNum("450107690120200529155024739")
......@@ -87,6 +91,27 @@ public class ReportService {
}
/**
* 根据检测报告id查询pdf并进行Base64转换
* @param reportPdfId
* @return
*/
public ReportDownloadRespVo getReportBase64FileByReportPdfId(Integer reportPdfId){
ReportPdfVo reportPdfVo = reportPdfMapper.selectById(reportPdfId);
AssertUtil.isTrue(reportPdfVo!=null && StrUtil.isNotBlank(reportPdfVo.getPath()),"不存在该检测报告,请刷新后重试");
boolean notEmpty = FileUtil.isNotEmpty(FileUtil.file(reportPdfVo.getPath()));
AssertUtil.isTrue(notEmpty,"检测报告丢失,请刷新后重试");
//将pdf检测报告转Base64
BASE64Encoder encoder = new BASE64Encoder();
String reportBase64 = encoder.encode(FileUtil.readBytes(reportPdfVo.getPath()));
ReportDownloadRespVo reportDownloadRespVo = new ReportDownloadRespVo();
reportDownloadRespVo.setReportBase64(reportBase64);
reportDownloadRespVo.setReportNum(reportPdfVo.getReportNum());
System.out.println(reportBase64);
return reportDownloadRespVo;
}
/**
* 获取当前用户部门下所有签章
* @return
*/
......@@ -189,8 +214,13 @@ public class ReportService {
.lambda().eq(ReportPdfVo::getReportNum, detailsReqVo.getReportNum()));
//如果已经下载保存过PDF了则删除旧的pdf 再去抓取新的pdf
if(reportPdfVo != null && StrUtil.isNotBlank(reportPdfVo.getPath())){
/*if(reportPdfVo != null && StrUtil.isNotBlank(reportPdfVo.getPath())){
FileUtil.del(reportPdfVo.getPath());
}*/
//测试用
if(reportPdfVo != null && StrUtil.isNotBlank(reportPdfVo.getPath())){
return reportPdfVo;
}
//获取当前用户的部门
......@@ -233,12 +263,14 @@ public class ReportService {
AssertUtil.isNotNull(deptVo,"列表获取失败,未找到当前账号所属部门");
IPage<TestReportVo> page = new Page<>(pageQueryVo.getCurrNo(),pageQueryVo.getSize());
try {
/*try {
page = carReportUtil.reportPageList(deptVo.getEpAccount(),deptVo.getEpPassword(),pageQueryVo);
} catch (InterruptedException e) {
e.printStackTrace();
}
/*page.setTotal(1).setRecords(reportVoList);*/
}*/
//测试用
page.setTotal(1).setRecords(reportVoList);
return page;
}
......
......@@ -5,7 +5,7 @@ spring:
freemarker:
check-template-location: false
profiles:
active: prod
active: dev
jackson:
time-zone: GMT+8
data:
......@@ -30,6 +30,10 @@ spring:
password: ${REDIS_PWD:}
#连接超时时间
timeout: 5000
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB #最大请求文件的大小
task:
pool:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment