Commit 508c8ae5 authored by 盖献康's avatar 盖献康

Merge branch 'gaixiankang' into 'dev'

检验报告

See merge request !228
parents bae52bdd e9c342ac
......@@ -160,4 +160,9 @@ public class InspectionReportPdfVO {
*/
private String sampleNumberSummary;
/**
* 品牌图片
*/
private String brandImage;
}
package com.ruoyi.service.impl;
import cn.hutool.core.util.StrUtil;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.*;
import com.ruoyi.common.core.domain.entity.SysDictData;
......@@ -89,7 +90,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
InspectionReportPdfVO inspectionReportPdfVO = requireData(taskId);
// 渲染数据
renderData(fields, inspectionReportPdfVO);
renderData(fields, inspectionReportPdfVO, ps);
//必须要调用这个,否则文档不会生成的
ps.setFormFlattening(true);
......@@ -106,7 +107,12 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
}
}
assert bos != null;
return uploadMinio(bos, "检验报告_" + taskId);
// 名字
return uploadMinio(bos, "整车信息安全检验报告-" + getReportName());
}
private String getReportName() {
return DateUtils.parseDateToStr("yyyyMMddHHmm", new Date());
}
/**
......@@ -252,8 +258,9 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
* 渲染数据
* @param fields
*/
private void renderData(AcroFields fields, InspectionReportPdfVO inspectionReportPdfVO) throws Exception {
private void renderData(AcroFields fields, InspectionReportPdfVO inspectionReportPdfVO, PdfStamper ps) throws Exception {
// 取出当前对象所有属性,并赋值到模板里
// 文本域
Class<? extends InspectionReportPdfVO> aClass = inspectionReportPdfVO.getClass();
Field[] declaredFields = aClass.getDeclaredFields();
for (Field field : declaredFields) {
......@@ -266,6 +273,15 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
fields.setField(key, value);
}
}
// 图片域
// 样品
String url = inspectionReportPdfVO.getBrandImage();
if (StrUtil.isNotBlank(url)) {
if (url.startsWith(",")) {
url = inspectionReportPdfVO.getBrandImage().substring(1);
}
addImageToPdf("brand", fields, ps, "http://49.232.167.247:22038" + url.split(",")[0]);
}
}
......@@ -314,7 +330,7 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
// 获取操作的页面
PdfContentByte under = stamper.getOverContent(pageNo);
// 根据域的大小缩放图片
image.scaleToFit(signRect.getWidth() * 2, signRect.getHeight());
image.scaleToFit(signRect.getWidth(), signRect.getHeight());
// 添加图片并设置位置(个人通过此设置使得图片垂直水平居中,可参考,具体情况已实际为准)
image.setAbsolutePosition(x, y);
under.addImage(image);
......
......@@ -311,14 +311,15 @@
GROUP_CONCAT(distinct s.sample_sender) AS sampleSender,
GROUP_CONCAT(distinct DATE_FORMAT(s.delivery_date, '%Y-%m-%d')) AS sampleDeliveryDate,
count(s.id) AS sampleQuantity,
sum(s.number_of_samples) AS sampleSum,
CONVERT(sum(s.number_of_samples), UNSIGNED) AS sampleSum,
GROUP_CONCAT(distinct DATE_FORMAT(s.manufacture_date, '%Y-%m-%d')) AS sampleDeliveryDate,
t.product_model AS vehicleType,
t.product_model AS vehicleModel,
t.id AS taskNumber,
GROUP_CONCAT(distinct s.sample_number) AS sampleNumberSummary,
GROUP_CONCAT(distinct s.identification_code) AS vehicleIdentificationNumber,
t.task_list AS inspectionItem,
DATE_FORMAT(t.create_time, '%Y-%m-%d') AS productionDate
DATE_FORMAT(t.create_time, '%Y-%m-%d') AS productionDate,
GROUP_CONCAT(distinct s.trademark) AS brandImage
from
t_task t
left join t_task_sample_relation tsr on t.id = tsr.task_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