20250318 更新
1.常规毒品检验记录
This commit is contained in:
+28
-23
@@ -81,7 +81,7 @@ public class InspectRecordServiceImpl implements InspectRecordService {
|
|||||||
// Map<String, Object> map = this.invivoRecord(entrustInfo);
|
// Map<String, Object> map = this.invivoRecord(entrustInfo);
|
||||||
return R.ok(this.createInVivoFile(entrustInfo, materialType), "生成成功!");
|
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
|
||||||
Map<String, Object> data = this.invivoRecord(entrustInfo, materialType);
|
Map<String, Object> data = this.invivoRecord(entrustInfo, materialType);
|
||||||
// 调用模板生成检验记录
|
// 调用模板生成检验记录
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
||||||
String templatePath = "";
|
String templatePath = "";
|
||||||
if (materialType.equals("毛发")) {
|
if (materialType.equals("毛发")) {
|
||||||
templatePath = "/template" + "/贵阳生物样本毛发检验记录模板.docx";
|
templatePath = "/template" + "/贵阳生物样本毛发检验记录模板.docx";
|
||||||
} else {
|
} else {
|
||||||
templatePath = "/template" + "/贵阳生物样本尿液检验记录模板.docx";
|
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);
|
ossFile.fileGet(templatePath, bos);
|
||||||
byte[] templateArray = bos.toByteArray();
|
byte[] templateArray = bos.toByteArray();
|
||||||
ByteArrayInputStream bis = new ByteArrayInputStream(templateArray);
|
ByteArrayInputStream bis = new ByteArrayInputStream(templateArray);
|
||||||
bos.close();
|
bos.close();
|
||||||
|
|
||||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
XWPFTemplate template = XWPFTemplate.compile(bis, config).render(data);
|
||||||
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"));
|
|
||||||
}}
|
|
||||||
);
|
|
||||||
NiceXWPFDocument document = template.getXWPFDocument();
|
NiceXWPFDocument document = template.getXWPFDocument();
|
||||||
|
|
||||||
// XWPFTable table = document.getTables().get(3);
|
// XWPFTable table = document.getTables().get(3);
|
||||||
@@ -233,7 +233,7 @@ public class InspectRecordServiceImpl implements InspectRecordService {
|
|||||||
ByteArrayInputStream fisWord = new ByteArrayInputStream(fosWord.toByteArray());
|
ByteArrayInputStream fisWord = new ByteArrayInputStream(fosWord.toByteArray());
|
||||||
fosWord.close();
|
fosWord.close();
|
||||||
document.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);
|
ossFile.fileSave(path, fisWord);
|
||||||
return path;
|
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);
|
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()
|
.stream()
|
||||||
.collect(Collectors.joining("、")); // 拼接筛查物名称
|
.collect(Collectors.joining("、")); // 拼接筛查物名称
|
||||||
data.put("materialCharacterDesc", materialCharacterDesc);
|
data.put("materialCharacterDesc", materialCharacterDesc);
|
||||||
data.put("ingredient", targetObjectStr);
|
data.put("materialIngredient", targetObjectStr);
|
||||||
|
|
||||||
// 设置使用的标准物质和试剂
|
// 设置使用的标准物质和试剂
|
||||||
List<TestRecordReagent> references = testRecordReagentService.list(Wrappers.<TestRecordReagent>lambdaQuery()
|
List<TestRecordReagent> references = testRecordReagentService.list(Wrappers.<TestRecordReagent>lambdaQuery()
|
||||||
|
|||||||
Reference in New Issue
Block a user