|
|
@ -49,7 +49,7 @@ public class SP001 { |
|
|
if (loginUser != null) { |
|
|
if (loginUser != null) { |
|
|
sign = loginUser.getSysUser().getNickName(); |
|
|
sign = loginUser.getSysUser().getNickName(); |
|
|
} |
|
|
} |
|
|
document = PdfBaseUtil.init(document, fos, filePath, sign +PdfExportUtil.parseDateToStr(new Date()), "en".equals(language)?template.getShowSn():template.getName()); |
|
|
|
|
|
|
|
|
document = PdfBaseUtil.init(document, fos, filePath, sign +PdfExportUtil.parseDateToStr(new Date()), "en".equals(language)?template.getShowSn():template.getName(),false); |
|
|
// 基本信息 |
|
|
// 基本信息 |
|
|
|
|
|
|
|
|
JSONObject bdnr = JSONObject.parseObject(studyFormFill.getBdnr()); |
|
|
JSONObject bdnr = JSONObject.parseObject(studyFormFill.getBdnr()); |
|
|
@ -57,14 +57,14 @@ public class SP001 { |
|
|
Map<String, String> formData1 = new LinkedHashMap<>(); |
|
|
Map<String, String> formData1 = new LinkedHashMap<>(); |
|
|
formData1.put(getName("试验名称"), studyFormFill.getStudyMc()); |
|
|
formData1.put(getName("试验名称"), studyFormFill.getStudyMc()); |
|
|
formData1.put(getName("试验编号"), studyFormFill.getStudySn()); |
|
|
formData1.put(getName("试验编号"), studyFormFill.getStudySn()); |
|
|
formData1.put(getName("方法编号"), bdnr.getString("methodCode")); |
|
|
|
|
|
formData1.put(getName("版本号"), bdnr.getString("methodCode")); |
|
|
|
|
|
|
|
|
formData1.put(getName("方法编号"), (StringUtils.isNoneBlank(bdnr.getString("methodCode"))? bdnr.getString("methodCode"):"")); |
|
|
|
|
|
formData1.put(getName("版本号"), (StringUtils.isNoneBlank(bdnr.getString("methodCode"))? bdnr.getString("methodCode"):"")); |
|
|
PdfBaseUtil.addFormTableColumns(document, formData1, 2); |
|
|
PdfBaseUtil.addFormTableColumns(document, formData1, 2); |
|
|
|
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("试验配置条件"), 10, true); |
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("试验配置条件"), 10, true); |
|
|
Map<String, String> formData2 = new LinkedHashMap<>(); |
|
|
Map<String, String> formData2 = new LinkedHashMap<>(); |
|
|
formData2.put(getName("预填"), bdnr.getString("pre") + (StringUtils.isNoneBlank(bdnr.getString("preOther")) ? bdnr.getString("preOther") : "")); |
|
|
|
|
|
formData2.put(getName("实际"), bdnr.getString("act") + (StringUtils.isNoneBlank(bdnr.getString("actOther")) ? bdnr.getString("actOther") : "")); |
|
|
|
|
|
|
|
|
formData2.put(getName("预填"),(StringUtils.isNoneBlank(bdnr.getString("pre"))? bdnr.getString("pre"):"") + (StringUtils.isNoneBlank(bdnr.getString("preOther")) ? bdnr.getString("preOther") : "")); |
|
|
|
|
|
formData2.put(getName("实际"),(StringUtils.isNoneBlank(bdnr.getString("act"))? bdnr.getString("act"):"") + (StringUtils.isNoneBlank(bdnr.getString("actOther")) ? bdnr.getString("actOther") : "")); |
|
|
PdfBaseUtil.addFormTableColumns(document, formData2, 2); |
|
|
PdfBaseUtil.addFormTableColumns(document, formData2, 2); |
|
|
|
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("配置时间"), 10, true); |
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("配置时间"), 10, true); |
|
|
@ -75,10 +75,13 @@ public class SP001 { |
|
|
|
|
|
|
|
|
// 签名信息 |
|
|
// 签名信息 |
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("试验试剂信息"), 10, true); |
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("试验试剂信息"), 10, true); |
|
|
addResource(document, studyFormFill.getResource()); |
|
|
|
|
|
|
|
|
TemplateBaseUtil.addResource(document, studyFormFill.getResource(),language); |
|
|
|
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("仪器使用信息"), 10, true); |
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("仪器使用信息"), 10, true); |
|
|
|
|
|
TemplateBaseUtil.addInstrument(document, "",language); |
|
|
|
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("存储条件"), 10, true); |
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("存储条件"), 10, true); |
|
|
|
|
|
|
|
|
Map<String, String> formData4 = new LinkedHashMap<>(); |
|
|
Map<String, String> formData4 = new LinkedHashMap<>(); |
|
|
formData4.put(getName("存储条件"), bdnr.getString("storageCondition") + (StringUtils.isNoneBlank(bdnr.getString("storageConditionOther")) ? bdnr.getString("storageConditionOther") : "")); |
|
|
formData4.put(getName("存储条件"), bdnr.getString("storageCondition") + (StringUtils.isNoneBlank(bdnr.getString("storageConditionOther")) ? bdnr.getString("storageConditionOther") : "")); |
|
|
PdfBaseUtil.addFormTableColumns(document, formData4, 1); |
|
|
PdfBaseUtil.addFormTableColumns(document, formData4, 1); |
|
|
@ -98,10 +101,10 @@ public class SP001 { |
|
|
|
|
|
|
|
|
// 签名信息 |
|
|
// 签名信息 |
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("签名信息"), 10, true); |
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("签名信息"), 10, true); |
|
|
addQmxx(document, studyFormFillQmxxList); |
|
|
|
|
|
|
|
|
TemplateBaseUtil.addQmxx(document, studyFormFillQmxxList,language); |
|
|
//稽查轨迹 |
|
|
//稽查轨迹 |
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("稽查轨迹"), 10, true); |
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("稽查轨迹"), 10, true); |
|
|
addJcgj(document, studyFormFillJcgjList); |
|
|
|
|
|
|
|
|
TemplateBaseUtil.addJcgj(document, studyFormFillJcgjList,language); |
|
|
logger.info("生成成功:{}", filePath); |
|
|
logger.info("生成成功:{}", filePath); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
logger.error("生成失败", e); |
|
|
logger.error("生成失败", e); |
|
|
@ -121,129 +124,6 @@ public class SP001 { |
|
|
return filePath; |
|
|
return filePath; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 仪器使用信息 |
|
|
|
|
|
* |
|
|
|
|
|
* @param document |
|
|
|
|
|
* @param resource |
|
|
|
|
|
* @throws IOException |
|
|
|
|
|
* @throws DocumentException |
|
|
|
|
|
*/ |
|
|
|
|
|
public void addResource(Document document, String resource) throws IOException, DocumentException { |
|
|
|
|
|
// [{"mc":"布洛芬","bh":"BLF260115-0014","ph":"","nd":"18ng/mL","source":"ELN配制","ndz":18,"nddw":"ng/mL","kc":1190,"kcdw":"3","syl":"4","syldw":"3","yxzq":360,"yxzqdw":"days"}] |
|
|
|
|
|
if (StringUtils.isNoneBlank(resource)) { |
|
|
|
|
|
JSONArray jsonArray = JSONArray.parseArray(resource); |
|
|
|
|
|
// 9. 表头 |
|
|
|
|
|
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
|
|
|
|
|
Font headerFont = new Font(bfChinese, 10, Font.NORMAL); |
|
|
|
|
|
Font contentFont = new Font(bfChinese, 10, Font.NORMAL); |
|
|
|
|
|
// 8. 创建表格 |
|
|
|
|
|
PdfPTable table = new PdfPTable(6); |
|
|
|
|
|
table.setWidthPercentage(100); |
|
|
|
|
|
String[] headers = {getName("试剂名称"), getName("编号"), getName("批号"), getName("浓度/含量/纯度"), getName("来源"), getName("失效日")}; |
|
|
|
|
|
for (String header : headers) { |
|
|
|
|
|
PdfPCell cell = new PdfPCell(new Phrase(header, headerFont)); |
|
|
|
|
|
cell.setHorizontalAlignment(Element.ALIGN_CENTER); |
|
|
|
|
|
cell.setPadding(8); |
|
|
|
|
|
cell.setBorderWidth(1); |
|
|
|
|
|
table.addCell(cell); |
|
|
|
|
|
} |
|
|
|
|
|
int rowNum = 0; |
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
|
|
JSONObject obj = jsonArray.getJSONObject(i); |
|
|
|
|
|
// 交替行颜色 |
|
|
|
|
|
if (rowNum % 2 == 0) { |
|
|
|
|
|
table.getDefaultCell().setBackgroundColor(BaseColor.WHITE); |
|
|
|
|
|
} else { |
|
|
|
|
|
table.getDefaultCell().setBackgroundColor(BaseColor.WHITE); |
|
|
|
|
|
} |
|
|
|
|
|
table.addCell(PdfBaseUtil.createCell(obj.getString("mc"), contentFont)); |
|
|
|
|
|
table.addCell(PdfBaseUtil.createCell(obj.getString("bh"), contentFont)); |
|
|
|
|
|
table.addCell(PdfBaseUtil.createCell(obj.getString("ph"), contentFont)); |
|
|
|
|
|
table.addCell(PdfBaseUtil.createCell(obj.getString("nd"), contentFont)); |
|
|
|
|
|
table.addCell(PdfBaseUtil.createCell(obj.getString("source"), contentFont)); |
|
|
|
|
|
table.addCell(PdfBaseUtil.createCell(StringUtils.isNoneBlank(obj.getString("sxrq")) ? obj.getString("sxrq") : "", contentFont)); |
|
|
|
|
|
rowNum++; |
|
|
|
|
|
} |
|
|
|
|
|
document.add(table); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 签名信息 |
|
|
|
|
|
* |
|
|
|
|
|
* @param document |
|
|
|
|
|
* @param studyFormFillQmxxList |
|
|
|
|
|
* @throws IOException |
|
|
|
|
|
* @throws DocumentException |
|
|
|
|
|
*/ |
|
|
|
|
|
public void addQmxx(Document document, List<StudyFormFillQmxx> studyFormFillQmxxList) throws IOException, DocumentException { |
|
|
|
|
|
// 9. 表头 |
|
|
|
|
|
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
|
|
|
|
|
Font headerFont = new Font(bfChinese, 10, Font.NORMAL); |
|
|
|
|
|
Font contentFont = new Font(bfChinese, 10, Font.NORMAL); |
|
|
|
|
|
// 8. 创建表格 |
|
|
|
|
|
PdfPTable table = new PdfPTable(4); |
|
|
|
|
|
table.setWidthPercentage(100); |
|
|
|
|
|
String[] headers = {getName("签名人"), getName("签名意义"), getName("签名时间"), getName("备注原因")}; |
|
|
|
|
|
for (String header : headers) { |
|
|
|
|
|
PdfPCell cell = new PdfPCell(new Phrase(header, headerFont)); |
|
|
|
|
|
cell.setHorizontalAlignment(Element.ALIGN_CENTER); |
|
|
|
|
|
cell.setPadding(8); |
|
|
|
|
|
cell.setBorderWidth(1); |
|
|
|
|
|
table.addCell(cell); |
|
|
|
|
|
} |
|
|
|
|
|
int rowNum = 0; |
|
|
|
|
|
for (StudyFormFillQmxx studyFormFillQmxx : studyFormFillQmxxList) { |
|
|
|
|
|
// 交替行颜色 |
|
|
|
|
|
if (rowNum % 2 == 0) { |
|
|
|
|
|
table.getDefaultCell().setBackgroundColor(BaseColor.WHITE); |
|
|
|
|
|
} else { |
|
|
|
|
|
table.getDefaultCell().setBackgroundColor(BaseColor.WHITE); |
|
|
|
|
|
} |
|
|
|
|
|
table.addCell(PdfBaseUtil.createCell(studyFormFillQmxx.getQmrMc(), contentFont)); |
|
|
|
|
|
table.addCell(PdfBaseUtil.createCell(studyFormFillQmxx.getQmyy(), contentFont)); |
|
|
|
|
|
table.addCell(PdfBaseUtil.createCell(PdfExportUtil.parseDateToStr(studyFormFillQmxx.getCreateTime()), contentFont)); |
|
|
|
|
|
table.addCell(PdfBaseUtil.createCell(studyFormFillQmxx.getRemark(), contentFont)); |
|
|
|
|
|
rowNum++; |
|
|
|
|
|
} |
|
|
|
|
|
document.add(table); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 稽查轨迹 |
|
|
|
|
|
* |
|
|
|
|
|
* @param document |
|
|
|
|
|
* @param studyFormFillJcgjList |
|
|
|
|
|
* @throws IOException |
|
|
|
|
|
* @throws DocumentException |
|
|
|
|
|
*/ |
|
|
|
|
|
public void addJcgj(Document document, List<StudyFormFillJcgj> studyFormFillJcgjList) throws IOException, DocumentException { |
|
|
|
|
|
for (StudyFormFillJcgj jcgj : studyFormFillJcgjList) { |
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, PdfExportUtil.parseDateToStr(jcgj.getCreateTime()) + " " + jcgj.getJcmc(), 10, false); |
|
|
|
|
|
StringJoiner result = new StringJoiner(", "); |
|
|
|
|
|
if (StringUtils.isNoneBlank(jcgj.getJcnr())) { |
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
|
JsonNode jsonArray = mapper.readTree(jcgj.getJcnr()); |
|
|
|
|
|
for (JsonNode node : jsonArray) { |
|
|
|
|
|
if (node.get("name") != null) { |
|
|
|
|
|
String name = node.get("name").asText(); |
|
|
|
|
|
String value = node.get("value") != null ? node.get("value").asText() : ""; |
|
|
|
|
|
result.add(name + ":" + value); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (StringUtils.isNoneBlank(jcgj.getRemark())) { |
|
|
|
|
|
result.add(getName("备注") + ":" + jcgj.getRemark()); |
|
|
|
|
|
} |
|
|
|
|
|
if (StringUtils.isNoneBlank(jcgj.getRemark())) { |
|
|
|
|
|
result.add(getName("签名人") + ":" + jcgj.getQmrMc()); |
|
|
|
|
|
} |
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, result.toString(), 10, false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取名称 |
|
|
* 获取名称 |
|
|
@ -252,7 +132,7 @@ public class SP001 { |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
public String getName(String name) { |
|
|
public String getName(String name) { |
|
|
return "en".equals(language) ? TemplateUtil.getEn(name) : name; |
|
|
|
|
|
|
|
|
return TemplateBaseUtil.getNameByLanguage(name,language); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |