From 09d162f650213d4d48c611d0d8ce4aa7628daf76 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期二, 18 六月 2024 16:35:59 +0800
Subject: [PATCH] 报告生成添加附件
---
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java | 39 +++++++++++++++++++++++++++------------
1 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
index 3a6a744..7493e30 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -10,6 +10,7 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -20,6 +21,7 @@
import com.deepoove.poi.data.*;
import com.deepoove.poi.data.style.*;
import com.deepoove.poi.util.TableTools;
+import com.deepoove.poi.xwpf.WidthScalePattern;
import com.yuanchu.mom.common.GetLook;
import com.yuanchu.mom.common.PrintChina;
import com.yuanchu.mom.dto.ExcelDto;
@@ -34,7 +36,6 @@
import com.yuanchu.mom.utils.QueryWrappers;
import com.yuanchu.mom.vo.InsOrderPlanTaskSwitchVo;
import com.yuanchu.mom.vo.InsOrderPlanVO;
-import com.yuanchu.mom.vo.Result;
import org.apache.commons.io.IOUtils;
import org.apache.poi.xwpf.usermodel.*;
import org.springframework.beans.factory.annotation.Value;
@@ -454,6 +455,7 @@
for (InsProduct insProduct : insProducts) {
if (insProduct.getInsResult() == 0) {
InsUnPass insUnPass = new InsUnPass();
+ insUnPass.setId(null);
insUnPass.setModel(insSample.getModel());
insUnPass.setSample(insSample.getSample());
insUnPass.setInspectionItem(insProduct.getInspectionItem());
@@ -466,16 +468,14 @@
insUnPasses.add(insUnPass);
}
}
- insUnPassService.saveBatch(insUnPasses);
}
+ insUnPassService.saveBatch(insUnPasses);
InsOrder insOrder = insOrderMapper.selectById(orderId);
Map<String, String> user = insProductMapper.selectUserById(insOrder.getUserId());
List<SampleProductDto> samples = insSampleMapper.selectSampleProductListByOrderId(orderId);
InsReport insReport = new InsReport();
insReport.setCode(insOrder.getEntrustCode());
insReport.setInsOrderId(orderId);
- Set<Integer> set = new HashSet<>();
- Map<Integer, String> map2 = new HashMap<>();
List<Map<String, Object>> tables = new ArrayList<>();
Set<String> standardMethod = new HashSet<>();
Set<String> deviceSet = new HashSet<>();
@@ -485,6 +485,8 @@
AtomicReference<String> resultCh = new AtomicReference<>("");
AtomicReference<String> resultEn = new AtomicReference<>("");
samples.forEach(a -> {
+ Set<Integer> set = new HashSet<>();
+ Map<Integer, String> map2 = new HashMap<>();
Long productCount = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsSampleId, a.getId()));
productSize.set(productSize.get() + Integer.parseInt(productCount + ""));
models.add(a.getModel());
@@ -705,10 +707,10 @@
tableRenderData.setRows(rows);
int countSize = tableRenderData.getRows().get(0).getCells().size();
for (RowRenderData row : tableRenderData.getRows()) {
- for (CellRenderData cell : row.getCells()) {
+ /*for (CellRenderData cell : row.getCells()) {
System.out.print(cell.getParagraphs().get(0).getContents());
}
- System.out.println("");
+ System.out.println("");*/
if (row.getCells().size() != countSize) {
throw new ErrorException("姣忚鍗曞厓鏍间笉鐩哥瓑");
}
@@ -779,7 +781,7 @@
ConfigureBuilder builder = Configure.builder();
builder.useSpringEL(true);
List<Map<String, String>> finalDeviceList = deviceList;
- Integer userId = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery().eq(InsSampleUser::getInsSampleId, orderId).orderByDesc(InsSampleUser::getCreateTime).last("limit 1")).getUserId();
+ Integer userId = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery().eq(InsSampleUser::getInsSampleId, orderId).last("limit 1")).getUserId();
String signatureUrl;
try {
signatureUrl = userMapper.selectById(userId).getSignatureUrl();
@@ -864,7 +866,7 @@
cells.add(cellRenderData);
} else {
//椤圭洰淇℃伅
- textRenderData.setText(insProducts1.get((int) (j - 2)).getInspectionItem() + "\n" + insProducts1.get((int) (j - 2)).getInspectionItemEn()+"鈭�"+(j+101));
+ textRenderData.setText(insProducts1.get((int) (j - 2)).getInspectionItem() + "\n" + insProducts1.get((int) (j - 2)).getInspectionItemEn() + "鈭�" + (j + 101));
renderData.add(textRenderData);
paragraphRenderData.setContents(renderData);
paragraphRenderDataList.add(paragraphRenderData);
@@ -893,7 +895,7 @@
//椤圭洰淇℃伅
//鍒ゆ柇鏄惁鏈夐」鐩瓙绫�
if (insProducts1.get((int) (j - 2)).getInspectionItemSubclass().equals("") || insProducts1.get((int) (j - 2)).getInspectionItemSubclass() == null) {
- textRenderData.setText(insProducts1.get((int) (j - 2)).getInspectionItem() + "\n" + insProducts1.get((int) (j - 2)).getInspectionItemEn()+"鈭�"+(j+101));
+ textRenderData.setText(insProducts1.get((int) (j - 2)).getInspectionItem() + "\n" + insProducts1.get((int) (j - 2)).getInspectionItemEn() + "鈭�" + (j + 101));
} else {
textRenderData.setText(insProducts1.get((int) (j - 2)).getInspectionItemSubclass() + "\n" + insProducts1.get((int) (j - 2)).getInspectionItemSubclassEn());
}
@@ -946,10 +948,10 @@
tableRenderData.setRows(rows);
int countSize = tableRenderData.getRows().get(0).getCells().size();
for (RowRenderData row : tableRenderData.getRows()) {
- for (CellRenderData cell : row.getCells()) {
+ /*for (CellRenderData cell : row.getCells()) {
System.out.print(cell.getParagraphs().get(0).getContents());
}
- System.out.println("");
+ System.out.println("");*/
if (row.getCells().size() != countSize) {
throw new ErrorException("姣忚鍗曞厓鏍间笉鐩哥瓑");
}
@@ -969,12 +971,24 @@
Map<String, Object> table = new HashMap<>();
table.put("table2", tableRenderData);
table.put("report", insReport);
- table.put("sample_number",sample.getSampleCode() );
+ table.put("sample_number", sample.getSampleCode());
table.put("type", sample.getModel());
tables2.add(table);
});
}
+ /*鑾峰彇闄勪欢鍥剧墖绫诲瀷*/
+ List<Map<String, Object>> images = new ArrayList<>();
+ List<InsOrderFile> insOrderFiles = insOrderFileMapper.selectList(Wrappers.<InsOrderFile>lambdaQuery().eq(InsOrderFile::getType, 1).eq(InsOrderFile::getInsOrderId, orderId));
+ if (CollectionUtils.isNotEmpty(insOrderFiles)) {
+ insOrderFiles.forEach(insOrderFile -> {
+ Map<String, Object> image = new HashMap<>();
+ PictureRenderData pictureRenderData = Pictures.ofLocal(imgUrl + "/" + insOrderFile.getFileUrl()).sizeInCm(17,20).create();
+ image.put("url", pictureRenderData);
+ image.put("report", insReport);
+ images.add(image);
+ });
+ }
XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render(
new HashMap<String, Object>() {{
@@ -997,6 +1011,7 @@
put("insTimeEn", monthNames[insOrder.getInsTime().getMonthValue() - 1] + " " + now.getDayOfMonth() + ", " + now.getYear());
put("writeUrl", null);
put("insUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create());
+ put("images", images);
put("examineUrl", null);
put("ratifyUrl", null);
put("sampleEn", sampleEn);
--
Gitblit v1.9.3