Commit ddf91dea authored by wdy's avatar wdy

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

parents 524adab0 7cf48bec
......@@ -131,7 +131,7 @@ public class InspectionReportPdfVO {
private String taskNumber;
/**
*
* 样品数量
*/
private String sampleSum;
......@@ -140,6 +140,11 @@ public class InspectionReportPdfVO {
*/
private String vehicleType;
/**
* 车辆型号
*/
private String vehicleModel;
/**
* 车辆识别码
*/
......
package com.ruoyi.domain.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
......@@ -12,7 +15,14 @@ import java.util.List;
@NoArgsConstructor
@Data
public class SampleTaskVo {
@TableId(type = IdType.ASSIGN_ID)
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long taskId;
@TableId(type = IdType.ASSIGN_ID)
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long SampleId;
private String taskNo;
}
......@@ -5,7 +5,7 @@ import com.itextpdf.text.pdf.*;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.PdfBaseWriter;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.vo.PhotoStorageVO;
import com.ruoyi.domain.vo.InspectionReportPdfVO;
import com.ruoyi.domain.vo.ReviewEnterpriseArchiveViewVO;
import com.ruoyi.service.PdfTemplateManagementService;
import com.ruoyi.service.ReviewEnterpriseArchiveService;
......@@ -76,23 +76,15 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
BaseFont bf = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
fields.addSubstitutionFont(bf);
// 渲染
// fillData(fields, map, ps);
renderData(fields);
// 测试数据
InspectionReportPdfVO inspectionReportPdfVO = requireData();
PhotoStorageVO photoStorageVO = new PhotoStorageVO();
Class<? extends PhotoStorageVO> aClass = photoStorageVO.getClass();
Field[] declaredFields = aClass.getDeclaredFields();
for (Field field : declaredFields) {
String name = field.getName();
System.out.println(name);
}
// 渲染数据
renderData(fields, inspectionReportPdfVO);
//必须要调用这个,否则文档不会生成的
ps.setFormFlattening(true);
if(ps != null){
ps.close();
}
ps.close();
//生成pdf路径存放的路径
fos = response.getOutputStream();
fos.write(bos.toByteArray());
......@@ -113,6 +105,40 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
}
}
private InspectionReportPdfVO requireData() {
InspectionReportPdfVO inspectionReportPdfVO = InspectionReportPdfVO.builder()
.reportNumber("报告编号")
.productName("产品名称")
.productModel("产品型号")
.entrustedUnit("委托单位")
.inspectionCenterName("检验中心名称")
.inspectionCenterAddress("检验中心地址")
.inspectionCenterTelephone("检验中心电话")
.inspectionCenterPostcode("检验中心邮编")
.clientAddress("委托单位地址")
.entrustedUnitTelephone("委托单位电话")
.clientPostalCode("委托单位邮编")
.sampleName("样品名称")
.typeSpecification("型号规格")
.productionEnterprise("生产企业")
.sampleSender("送养着")
.sampleDeliveryDate("送样日期")
.sampleQuantity("样品数量")
.productionDate("生产日期")
.inspectionItem("检验项目")
.testConclusion("检验结论")
.issueDate("签发日期")
.remark("备注")
.taskNumber("任务编号")
.sampleSum("样品数量")
.vehicleType("车俩类型")
.vehicleModel("车辆型号")
.vehicleIdentificationNumber("车辆识别码")
.sampleNumberSummary("样品编号汇总")
.build();
return inspectionReportPdfVO;
}
/**
* 企业留档文件PDF下载
* @param taskId
......@@ -213,8 +239,20 @@ public class PdfTemplateManagementServiceImpl implements PdfTemplateManagementSe
* 渲染数据
* @param fields
*/
private void renderData(AcroFields fields) {
private void renderData(AcroFields fields, InspectionReportPdfVO inspectionReportPdfVO) throws Exception {
// 取出当前对象所有属性,并赋值到模板里
Class<? extends InspectionReportPdfVO> aClass = inspectionReportPdfVO.getClass();
Field[] declaredFields = aClass.getDeclaredFields();
for (Field field : declaredFields) {
String name = field.getName();
String key = name.replaceAll("([a-z])([A-Z])", "$1_$2").toLowerCase();
field.setAccessible(true);
Object o = field.get(inspectionReportPdfVO);
if (o != null) {
String value = o.toString();
fields.setField(key, value);
}
}
}
......
......@@ -172,8 +172,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="sampleName" column="sample_name" />
<result property="enterpriseId" column="enterprise_id" />
</resultMap>
<select id="findByIdList" resultMap="SampleListResponse">
select id,identification_code,sample_number,sample_name,enterprise_id from t_sample
<select id="findByIdList" resultMap="SampleManagementResult">
select id,identification_code,sample_number,sample_name,enterprise_id,trademark,sample_photos,number_of_samples,delivery_date,sample_sender,manufacturing_enterprise,manufacture_date from t_sample
WHERE id IN
<foreach collection="relationList" item="relation" open="(" separator="," close=")">
#{relation.sampleId}
......
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