|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONArray; |
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
|
|
import com.hxhq.business.domain.StudyFormFill; |
|
|
import com.hxhq.business.domain.StudyFormFillJcgj; |
|
|
import com.hxhq.business.domain.StudyFormFillJcgj; |
|
|
import com.hxhq.business.domain.StudyFormFillQmxx; |
|
|
import com.hxhq.business.domain.StudyFormFillQmxx; |
|
|
import com.hxhq.business.utils.lang.TemplateUtil; |
|
|
import com.hxhq.business.utils.lang.TemplateUtil; |
|
|
@ -30,6 +31,28 @@ public class TemplateBaseUtil { |
|
|
private static final Logger logger = LoggerFactory.getLogger(TemplateBaseUtil.class.getName()); |
|
|
private static final Logger logger = LoggerFactory.getLogger(TemplateBaseUtil.class.getName()); |
|
|
public static String language = "zh"; |
|
|
public static String language = "zh"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 试验信息 |
|
|
|
|
|
* 试验名称,试验编号,方法编号,版本号 |
|
|
|
|
|
* @param document |
|
|
|
|
|
* @param studyFormFill |
|
|
|
|
|
* @param bdnr |
|
|
|
|
|
* @param lang |
|
|
|
|
|
* @throws IOException |
|
|
|
|
|
* @throws DocumentException |
|
|
|
|
|
*/ |
|
|
|
|
|
public static void addStudyInfo(Document document, StudyFormFill studyFormFill, JSONObject bdnr, String lang) throws IOException, DocumentException { |
|
|
|
|
|
language = lang; |
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("试验基本信息"), 10, true); |
|
|
|
|
|
Map<String, String> formData1 = new LinkedHashMap<>(); |
|
|
|
|
|
formData1.put(getName("试验名称"), studyFormFill.getStudyMc()); |
|
|
|
|
|
formData1.put(getName("试验编号"), studyFormFill.getStudySn()); |
|
|
|
|
|
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); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 试验试剂信息 |
|
|
* 试验试剂信息 |
|
|
* |
|
|
* |
|
|
@ -41,6 +64,7 @@ public class TemplateBaseUtil { |
|
|
public static void addResource(Document document, String resource, String lang) throws IOException, DocumentException { |
|
|
public static void addResource(Document document, String resource, String lang) 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"}] |
|
|
// [{"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"}] |
|
|
language = lang; |
|
|
language = lang; |
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("试验试剂信息"), 10, true); |
|
|
// 9. 表头 |
|
|
// 9. 表头 |
|
|
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
|
|
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
|
|
Font headerFont = new Font(bfChinese, 10, Font.NORMAL); |
|
|
Font headerFont = new Font(bfChinese, 10, Font.NORMAL); |
|
|
@ -88,6 +112,7 @@ public class TemplateBaseUtil { |
|
|
*/ |
|
|
*/ |
|
|
public static void addInstrument(Document document, String instrument, String lang) throws IOException, DocumentException { |
|
|
public static void addInstrument(Document document, String instrument, String lang) throws IOException, DocumentException { |
|
|
language = lang; |
|
|
language = lang; |
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("仪器使用信息"), 10, true); |
|
|
// 9. 表头 |
|
|
// 9. 表头 |
|
|
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
|
|
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
|
|
Font headerFont = new Font(bfChinese, 10, Font.NORMAL); |
|
|
Font headerFont = new Font(bfChinese, 10, Font.NORMAL); |
|
|
@ -136,6 +161,7 @@ public class TemplateBaseUtil { |
|
|
*/ |
|
|
*/ |
|
|
public static void addQmxx(Document document, List<StudyFormFillQmxx> studyFormFillQmxxList, String lang) throws IOException, DocumentException { |
|
|
public static void addQmxx(Document document, List<StudyFormFillQmxx> studyFormFillQmxxList, String lang) throws IOException, DocumentException { |
|
|
language = lang; |
|
|
language = lang; |
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("签名信息"), 10, true); |
|
|
// 9. 表头 |
|
|
// 9. 表头 |
|
|
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
|
|
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
|
|
Font headerFont = new Font(bfChinese, 10, Font.NORMAL); |
|
|
Font headerFont = new Font(bfChinese, 10, Font.NORMAL); |
|
|
@ -150,7 +176,7 @@ public class TemplateBaseUtil { |
|
|
cell.setPadding(8); |
|
|
cell.setPadding(8); |
|
|
table.addCell(cell); |
|
|
table.addCell(cell); |
|
|
} |
|
|
} |
|
|
if(studyFormFillQmxxList.size()>0){ |
|
|
|
|
|
|
|
|
if (studyFormFillQmxxList.size() > 0) { |
|
|
int rowNum = 0; |
|
|
int rowNum = 0; |
|
|
for (StudyFormFillQmxx studyFormFillQmxx : studyFormFillQmxxList) { |
|
|
for (StudyFormFillQmxx studyFormFillQmxx : studyFormFillQmxxList) { |
|
|
// 交替行颜色 |
|
|
// 交替行颜色 |
|
|
@ -160,7 +186,7 @@ public class TemplateBaseUtil { |
|
|
table.getDefaultCell().setBackgroundColor(BaseColor.WHITE); |
|
|
table.getDefaultCell().setBackgroundColor(BaseColor.WHITE); |
|
|
} |
|
|
} |
|
|
table.addCell(PdfBaseUtil.createCell(studyFormFillQmxx.getQmrMc(), contentFont)); |
|
|
table.addCell(PdfBaseUtil.createCell(studyFormFillQmxx.getQmrMc(), contentFont)); |
|
|
table.addCell(PdfBaseUtil.createCell("en".equals(language)?studyFormFillQmxx.getQmyyEn():studyFormFillQmxx.getQmyy(), contentFont)); |
|
|
|
|
|
|
|
|
table.addCell(PdfBaseUtil.createCell("en".equals(language) ? studyFormFillQmxx.getQmyyEn() : studyFormFillQmxx.getQmyy(), contentFont)); |
|
|
table.addCell(PdfBaseUtil.createCell(PdfExportUtil.parseDateToStr(studyFormFillQmxx.getCreateTime()), contentFont)); |
|
|
table.addCell(PdfBaseUtil.createCell(PdfExportUtil.parseDateToStr(studyFormFillQmxx.getCreateTime()), contentFont)); |
|
|
table.addCell(PdfBaseUtil.createCell(studyFormFillQmxx.getRemark(), contentFont)); |
|
|
table.addCell(PdfBaseUtil.createCell(studyFormFillQmxx.getRemark(), contentFont)); |
|
|
rowNum++; |
|
|
rowNum++; |
|
|
@ -177,45 +203,50 @@ public class TemplateBaseUtil { |
|
|
* @throws IOException |
|
|
* @throws IOException |
|
|
* @throws DocumentException |
|
|
* @throws DocumentException |
|
|
*/ |
|
|
*/ |
|
|
public static void addJcgj(Document document, List<StudyFormFillJcgj> studyFormFillJcgjList, String lang) throws IOException, DocumentException { |
|
|
|
|
|
|
|
|
public static void addJcgj(Document document, List<StudyFormFillJcgj> studyFormFillJcgjList, Integer jcgjlx, String lang) throws IOException, DocumentException { |
|
|
language = lang; |
|
|
language = lang; |
|
|
for (StudyFormFillJcgj jcgj : studyFormFillJcgjList) { |
|
|
|
|
|
StringJoiner result = new StringJoiner(", "); |
|
|
|
|
|
if ("en".equals(lang)) { |
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, PdfExportUtil.parseDateToStr(jcgj.getCreateTime()) + " " + jcgj.getJcmcEn(), 10, false); |
|
|
|
|
|
if (StringUtils.isNoneBlank(jcgj.getJcnrEn())) { |
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
|
JsonNode jsonArray = mapper.readTree(jcgj.getJcnrEn()); |
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
Integer jcgjlxMark = 999; |
|
|
|
|
|
if (!jcgjlx.equals(jcgjlxMark)) { |
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, getName("稽查轨迹"), 10, true); |
|
|
|
|
|
TemplateBaseUtil.addJcgj(document, studyFormFillJcgjList, jcgjlxMark, language); |
|
|
|
|
|
for (StudyFormFillJcgj jcgj : studyFormFillJcgjList) { |
|
|
|
|
|
StringJoiner result = new StringJoiner(", "); |
|
|
|
|
|
if ("en".equals(lang)) { |
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, PdfExportUtil.parseDateToStr(jcgj.getCreateTime()) + " " + jcgj.getJcmcEn(), 10, false); |
|
|
|
|
|
if (StringUtils.isNoneBlank(jcgj.getJcnrEn())) { |
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
|
JsonNode jsonArray = mapper.readTree(jcgj.getJcnrEn()); |
|
|
|
|
|
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); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, PdfExportUtil.parseDateToStr(jcgj.getCreateTime()) + " " + jcgj.getJcmc(), 10, false); |
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, PdfExportUtil.parseDateToStr(jcgj.getCreateTime()) + " " + jcgj.getJcmc(), 10, false); |
|
|
|
|
|
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.getQmrMc())) { |
|
|
|
|
|
result.add(getName("签名人") + ":" + jcgj.getQmrMc()); |
|
|
|
|
|
|
|
|
if (StringUtils.isNoneBlank(jcgj.getRemark())) { |
|
|
|
|
|
result.add(getName("备注") + ":" + jcgj.getRemark()); |
|
|
|
|
|
} |
|
|
|
|
|
if (StringUtils.isNoneBlank(jcgj.getQmrMc())) { |
|
|
|
|
|
result.add(getName("签名人") + ":" + jcgj.getQmrMc()); |
|
|
|
|
|
} |
|
|
|
|
|
PdfBaseUtil.addUnderlinedTitle(document, result.toString(), 10, false); |
|
|
} |
|
|
} |
|
|
PdfBaseUtil.addUnderlinedTitle(document, result.toString(), 10, false); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|