Commit 3099c0c8 authored by wdy's avatar wdy

Merge branch 'dev' of http://gitlab.91isoft.com:90/wangfei/vehicle-quality-review into wangdingyi

parents e238c94d c3174724
......@@ -10,10 +10,12 @@ public interface PdfTemplateManagementService {
/**
* 检验报告PDF下载
* @param response
*
* @param taskId
* @return
* @throws Exception
*/
void generateInspectionReport(HttpServletResponse response) throws Exception;
String generateInspectionReport(Long taskId) throws Exception;
/**
* 企业留档文件PDF下载
......
......@@ -51,17 +51,19 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
/**
* 检验报告PDF下载
* @param response
*
* @param taskId
* @return
*/
@Override
public void generateInspectionReport(HttpServletResponse response) throws Exception {
public String generateInspectionReport(Long taskId) throws Exception {
PdfReader reader = null;
PdfStamper ps = null;
OutputStream fos = null;
ByteArrayOutputStream bos = null;
try {
// 模板绝对路径--服务器
String fileName = "/template/receipt_template_02_27.pdf";
// String fileName = "/template/receipt_template_02_27.pdf";
String fileName = "E:/文件/PDF模板/receipt_template_02_27.pdf";
// 读取现有模板内容
reader = new PdfReader(fileName);
// 创建输出流
......@@ -85,17 +87,10 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
//必须要调用这个,否则文档不会生成的
ps.setFormFlattening(true);
ps.close();
//生成pdf路径存放的路径
fos = response.getOutputStream();
fos.write(bos.toByteArray());
}catch (Exception e){
e.printStackTrace();
}finally {
if(fos!=null){
fos.flush();
fos.close();
}
if (bos != null){
bos.close();
}
......@@ -103,6 +98,8 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
reader.close();
}
}
assert bos != null;
return uploadMinio(bos, "检验报告_" + taskId);
}
private InspectionReportPdfVO requireData() {
......@@ -131,7 +128,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
.remark("备注")
.taskNumber("任务编号")
.sampleSum("样品数量")
.vehicleType("车类型")
.vehicleType("车类型")
.vehicleModel("车辆型号")
.vehicleIdentificationNumber("车辆识别码")
.sampleNumberSummary("样品编号汇总")
......@@ -198,7 +195,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
document.close();
// 上传到Minio
return uploadMinio(outputStream, "企业留档文件" + "_" + taskId);
return uploadMinio(outputStream, "企业留档文件_" + taskId);
}
/**
......
......@@ -15,8 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
/**
* @author gxk
*/
......@@ -33,18 +31,19 @@ public class PdfTemplateManagementController {
/**
* 检验报告PDF下载
* @param response
* @param request
*/
@Anonymous
@ApiOperation("检验报告PDF下载")
@GetMapping(value = "/inspectionReport", produces = "application/json")
public void download(HttpServletResponse response) {
response.setHeader("content-disposition","attachment;fileName="+"ReceiptPrinter.pdf");
@PostMapping("/inspectionReport")
public R<String> download(@Validated @RequestBody PdfFileRequest request) {
try {
// demo-模板
pdfTemplateManagementService.generateInspectionReport(response);
String url = pdfTemplateManagementService.generateInspectionReport(request.getTaskId());
return R.ok(url);
} catch (Exception e) {
e.printStackTrace();
return R.fail();
}
}
......@@ -83,7 +82,9 @@ public class PdfTemplateManagementController {
case 0:
url = task.getVehicleInformationUrl();
if (StrUtil.isBlank(url)) {
// TODO 生成整车
// 生成整车信息安全检验报告
url = pdfTemplateManagementService.generateInspectionReport(request.getTaskId());
taskService.update(new UpdateWrapper<Task>().lambda().eq(Task::getId, request.getTaskId()).set(Task::getVehicleInformationUrl, url));
}
break;
case 1:
......@@ -123,7 +124,9 @@ public class PdfTemplateManagementController {
try {
switch (request.getType()) {
case 0:
// TODO 更新整车
// 更新整车PDF文件
url = pdfTemplateManagementService.generateInspectionReport(request.getTaskId());
taskService.update(new UpdateWrapper<Task>().lambda().eq(Task::getId, request.getTaskId()).set(Task::getVehicleInformationUrl, url));
break;
case 1:
// 根据任务ID新生成
......
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