From 76c185e8b6af9a700f8812369d0001e90dee0d17 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期四, 04 六月 2026 17:55:33 +0800
Subject: [PATCH] 下载检测报告,查询关联销售台账的客户
---
src/main/java/com/ruoyi/quality/service/impl/QualityInspectServiceImpl.java | 61 +++++++++++++++++++++++++++++-
1 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/ruoyi/quality/service/impl/QualityInspectServiceImpl.java b/src/main/java/com/ruoyi/quality/service/impl/QualityInspectServiceImpl.java
index a1bdb1d..cad0da6 100644
--- a/src/main/java/com/ruoyi/quality/service/impl/QualityInspectServiceImpl.java
+++ b/src/main/java/com/ruoyi/quality/service/impl/QualityInspectServiceImpl.java
@@ -22,6 +22,14 @@
import com.ruoyi.quality.pojo.QualityUnqualified;
import com.ruoyi.quality.service.IQualityInspectParamService;
import com.ruoyi.quality.service.IQualityInspectService;
+import com.ruoyi.sales.pojo.SalesLedger;
+import com.ruoyi.sales.mapper.SalesLedgerMapper;
+import com.ruoyi.production.pojo.ProductOrder;
+import com.ruoyi.production.pojo.ProductWorkOrder;
+import com.ruoyi.production.pojo.ProductionProductMain;
+import com.ruoyi.production.mapper.ProductOrderMapper;
+import com.ruoyi.production.mapper.ProductWorkOrderMapper;
+import com.ruoyi.production.mapper.ProductionProductMainMapper;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@@ -32,6 +40,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
@@ -49,6 +58,14 @@
private QualityUnqualifiedMapper qualityUnqualifiedMapper;
private QualityInspectExportHandle qualityInspectExportHandle;
+
+ private ProductionProductMainMapper productionProductMainMapper;
+
+ private ProductWorkOrderMapper productWorkOrderMapper;
+
+ private ProductOrderMapper productOrderMapper;
+
+ private SalesLedgerMapper salesLedgerMapper;
@Override
public int add(QualityInspectDto qualityInspectDto) {
@@ -90,7 +107,9 @@
qualityUnqualifiedMapper.insert(qualityUnqualified);
} else {
//鍚堟牸鐩存帴鍏ュ簱
- stockUtils.addStock(qualityInspect.getProductModelId(), qualityInspect.getQuantity(), StockInQualifiedRecordTypeEnum.QUALITYINSPECT_STOCK_IN.getCode(), qualityInspect.getId(), "-", "-", "-");
+ if (qualityInspect.getInspectType() == 2 || qualityInspect.getInspectType() == 0) {
+ stockUtils.addStock(qualityInspect.getProductModelId(), qualityInspect.getQuantity(), StockInQualifiedRecordTypeEnum.QUALITYINSPECT_STOCK_IN.getCode(), qualityInspect.getId(), "-", "-", "-");
+ }
}
qualityInspect.setInspectState(1);//宸叉彁浜�
return qualityInspectMapper.updateById(qualityInspect);
@@ -117,6 +136,16 @@
detail.setIndex(index);
index++;
}
+
+ // 鏍煎紡鍖栨楠屾棩鏈�
+ String checkTimeStr;
+ if (inspect.getCheckTime() != null) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ checkTimeStr = sdf.format(inspect.getCheckTime());
+ } else {
+ checkTimeStr = "";
+ }
+
InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx");
Configure configure = Configure.builder()
.bind("paramList", new HackLoopTableRenderPolicy())
@@ -125,8 +154,36 @@
XWPFTemplate template = XWPFTemplate.compile(inputStream, configure).render(
new HashMap<String, Object>() {{
put("inspect", inspect);
+ put("customerLabel", inspect.getInspectType() == 0 ? "渚涘簲鍟�" : "瀹㈡埛");
+ // 鏍规嵁妫�楠岀被鍨嬬‘瀹氬鎴�/渚涘簲鍟�
+ String customerValue;
+ if (inspect.getInspectType() == 0) {
+ // 鍘熸潗鏂欐楠岋細鐩存帴浣跨敤渚涘簲鍟�
+ customerValue = inspect.getSupplier();
+ } else {
+ // 杩囩▼妫�楠�/鍑哄巶妫�楠岋細閫氳繃鍏宠仈鍏崇郴鏌ヨ閿�鍞彴璐︾殑瀹㈡埛
+ customerValue = inspect.getCustomer(); // 榛樿浣跨敤鐩存帴瀛樺偍鐨勫鎴�
+ if (inspect.getProductMainId() != null) {
+ // 閫氳繃鎶ュ伐ID鏌ヨ宸ュ崟
+ ProductionProductMain productMain = productionProductMainMapper.selectById(inspect.getProductMainId());
+ if (productMain != null && productMain.getWorkOrderId() != null) {
+ ProductWorkOrder workOrder = productWorkOrderMapper.selectById(productMain.getWorkOrderId());
+ if (workOrder != null && workOrder.getProductOrderId() != null) {
+ ProductOrder productOrder = productOrderMapper.selectById(workOrder.getProductOrderId());
+ if (productOrder != null && productOrder.getSalesLedgerId() != null) {
+ SalesLedger salesLedger = salesLedgerMapper.selectById(productOrder.getSalesLedgerId());
+ if (salesLedger != null && salesLedger.getCustomerName() != null) {
+ customerValue = salesLedger.getCustomerName();
+ }
+ }
+ }
+ }
+ }
+ }
+ put("customer", customerValue);
put("inspectType", finalInspectType);
put("paramList", paramList);
+ put("checkTime", checkTimeStr);
}});
try {
@@ -200,4 +257,4 @@
qualityInspectExportHandle.exportExcel(response, exportList, exportDTO.getInspectType());
}
-}
+}
\ No newline at end of file
--
Gitblit v1.9.3