20250318 更新

1.常规毒品检验记录
master
陈江保 2 weeks ago
parent 83405e778d
commit 22d513759f
  1. 51
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/InspectRecordServiceImpl.java

@ -81,7 +81,7 @@ public class InspectRecordServiceImpl implements InspectRecordService {
// Map<String, Object> map = this.invivoRecord(entrustInfo);
return R.ok(this.createInVivoFile(entrustInfo, materialType), "生成成功!");
}
return null;
return R.ok(this.generateCommonDrugInpectRecord(entrustId));
}
/**
@ -188,36 +188,36 @@ public class InspectRecordServiceImpl implements InspectRecordService {
// 获取文件数据map
Map<String, Object> data = this.invivoRecord(entrustInfo, materialType);
// 调用模板生成检验记录
ByteArrayOutputStream bos = new ByteArrayOutputStream();
String templatePath = "";
if (materialType.equals("毛发")) {
templatePath = "/template" + "/贵阳生物样本毛发检验记录模板.docx";
} else {
templatePath = "/template" + "/贵阳生物样本尿液检验记录模板.docx";
}
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
Configure config = Configure.builder().
bind("dataDtos", policy).build();
return buildDocFileAndUploadToOss(entrustInfo.getId(), templatePath, config, data);
}
/**
* 根据委托信息模板路径配置和数据构建文档文件并上传到OSS
*
* @param entrustId 委托id
* @param templatePath 模板文件路径
* @param config 配置信息
* @param data 要填充到模板中的数据
* @return 上传后的文件路径
* @throws Exception 可能抛出的异常
*/
private String buildDocFileAndUploadToOss(String entrustId, String templatePath, Configure config, Map<String, Object> data) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ossFile.fileGet(templatePath, bos);
byte[] templateArray = bos.toByteArray();
ByteArrayInputStream bis = new ByteArrayInputStream(templateArray);
bos.close();
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
Configure config = Configure.builder().
bind("dataDtos", policy).build();
XWPFTemplate template = XWPFTemplate.compile(bis, config).render(
new HashMap<String, Object>() {{
put("entrustDepartment", data.get("entrustDepartment"));
put("deliver1Name", data.get("deliver1Name"));
put("deliver2Name", data.get("deliver2Name"));
put("year", data.get("year"));
put("month", data.get("month"));
put("day", data.get("day"));
put("instrumentName", data.get("instrumentName"));
put("referenceMaterialName", data.get("referenceMaterialName"));
put("reagentConsumableName", data.get("reagentConsumableName"));
put("dataDtos", data.get("dataDtos"));
}}
);
XWPFTemplate template = XWPFTemplate.compile(bis, config).render(data);
NiceXWPFDocument document = template.getXWPFDocument();
// XWPFTable table = document.getTables().get(3);
@ -233,7 +233,7 @@ public class InspectRecordServiceImpl implements InspectRecordService {
ByteArrayInputStream fisWord = new ByteArrayInputStream(fosWord.toByteArray());
fosWord.close();
document.close();
String path = TestRecordFileUrl.TEST_RECORD_CATALOGUE.getFileUrl() + "/" + entrustInfo.getId() + "/" + "贵阳生物样本检验记录.docx";
String path = TestRecordFileUrl.TEST_RECORD_CATALOGUE.getFileUrl() + "/" + entrustId + "/" + "贵阳生物样本检验记录.docx";
ossFile.fileSave(path, fisWord);
return path;
}
@ -280,8 +280,13 @@ public class InspectRecordServiceImpl implements InspectRecordService {
/**
* 生成常规毒品的检验记录贵阳禁毒
*/
public void generateCommonDrugInpectRecord(String entrustId) {
public String generateCommonDrugInpectRecord(String entrustId) throws Exception {
Map<String, Object> docMap = buildCommonDrugDocMap(entrustId);
String templatePath = "/template" + "/贵阳禁毒常规毒品检验记录模板.docx";
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
Configure config = Configure.builder().
bind("dataDtos", policy).build();
return buildDocFileAndUploadToOss(entrustId, templatePath, config, docMap);
}
/**
@ -343,7 +348,7 @@ public class InspectRecordServiceImpl implements InspectRecordService {
.stream()
.collect(Collectors.joining("、")); // 拼接筛查物名称
data.put("materialCharacterDesc", materialCharacterDesc);
data.put("ingredient", targetObjectStr);
data.put("materialIngredient", targetObjectStr);
// 设置使用的标准物质和试剂
List<TestRecordReagent> references = testRecordReagentService.list(Wrappers.<TestRecordReagent>lambdaQuery()

Loading…
Cancel
Save