|
|
@@ -19,6 +19,7 @@ import com.deepoove.poi.data.PictureType;
|
|
|
import com.deepoove.poi.data.Pictures;
|
|
|
import com.deepoove.poi.plugin.table.LoopColumnTableRenderPolicy;
|
|
|
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
|
|
+import com.deepoove.poi.policy.ListRenderPolicy;
|
|
|
import com.deepoove.poi.util.ByteUtils;
|
|
|
import com.deepoove.poi.util.PoitlIOUtils;
|
|
|
import com.deepoove.poi.xwpf.NiceXWPFDocument;
|
|
|
@@ -1272,17 +1273,24 @@ public class WordTest extends BaseMockitoUnitTest {
|
|
|
.anaType("全麻")
|
|
|
.surgeryName("股骨骨折切开复位钢板内固定术")
|
|
|
.build();
|
|
|
- Map<String, Object> exampleData = JsonUtils.parseMap(JsonUtils.toJsonString(clinic));
|
|
|
- NiceXWPFDocument document=XWPFTemplate.compile(new FileInputStream(file))
|
|
|
+// Map<String, Object> exampleData = JsonUtils.parseMap(JsonUtils.toJsonString(clinic));
|
|
|
+ Map<String, Object> exampleData = new HashMap<>();
|
|
|
+ Configure config = Configure.builder()
|
|
|
+ .bind("modifies", new LoopRowTableRenderPolicy())
|
|
|
+ .bind("evaluations",new LoopColumnTableRenderPolicy())
|
|
|
+ .build();
|
|
|
+ String base64= FileUtil.readString("E:\\Project\\tr-footstone\\tr-plugins\\tr-spring-boot-starter-plugin-biz-excel\\src\\main\\resources\\base64", Charset.defaultCharset());
|
|
|
+ exampleData.put("clinic",clinic);
|
|
|
+ exampleData.put("infusionRecords",JSONUtil.parseArray(str));
|
|
|
+ exampleData.put("evaluations",JSONUtil.parseArray(evalStr));
|
|
|
+ exampleData.put("image",Pictures.ofBase64(base64,PictureType.PNG)
|
|
|
+ .size(687, 500).create());
|
|
|
+ NiceXWPFDocument document=XWPFTemplate.compile(new FileInputStream(file),config)
|
|
|
.render(exampleData)
|
|
|
.getXWPFDocument();
|
|
|
-
|
|
|
- BufferedInputStream inputStream = FileUtil.getInputStream(FileUtil.file(pathPrefix + "EXXT.jpg"));
|
|
|
- byte[] bytes = IoUtil.readBytes(inputStream);
|
|
|
- String encode = cn.hutool.core.codec.Base64.encode(bytes);
|
|
|
- document=infusionInfo(document);
|
|
|
- document=eval(document);
|
|
|
- document=image(document,encode);
|
|
|
+// document=infusionInfo(document);
|
|
|
+// document=eval(document);
|
|
|
+// document=image(document,encode);
|
|
|
//文件输出流
|
|
|
FileOutputStream out = new FileOutputStream(pathPrefix+"patient.docx");
|
|
|
BufferedOutputStream bos = new BufferedOutputStream(out);
|
|
|
@@ -1332,15 +1340,17 @@ public class WordTest extends BaseMockitoUnitTest {
|
|
|
@Test
|
|
|
public NiceXWPFDocument infusionInfo(NiceXWPFDocument xwpfDocument) throws Exception {
|
|
|
xwpfDocument.createParagraph().createRun().addBreak(BreakType.PAGE);
|
|
|
- LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
|
|
+ LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
|
|
File file= FileUtil.touch(pathPrefix+"infusionHistoryTmp.docx");
|
|
|
JSONArray jsonArray = JSONUtil.parseArray(str);
|
|
|
Configure config = Configure.builder()
|
|
|
.bind("modifies", policy)
|
|
|
.build();
|
|
|
- for (Object o : jsonArray) {
|
|
|
- xwpfDocument=xwpfDocument.merge(XWPFTemplate.compile(new FileInputStream(file), config).render(o).getXWPFDocument());
|
|
|
- }
|
|
|
+ HashMap<String, JSONArray> infusions = MapUtil.of("infusions", jsonArray);
|
|
|
+ XWPFTemplate compile = XWPFTemplate.compile(new FileInputStream(file), config);
|
|
|
+// for (Object o : jsonArray) {
|
|
|
+ xwpfDocument=xwpfDocument.merge(compile.render(infusions).getXWPFDocument());
|
|
|
+// }
|
|
|
return xwpfDocument;
|
|
|
}
|
|
|
@Data
|