From 80b9620794286b61718a84ec1c2447893189646a Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 03 九月 2026 17:04:02 +0800
Subject: [PATCH] fix(report): 修复检测报告生成和数据同步问题 - 调整样品发送时间排序为降序显示最新数据 - 完善检验项目同步逻辑支持多层级节点配置管理
---
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java | 41 ++++++++++++++++++++++++++++++++---------
1 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
index 31c71a6..f41d3d0 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
@@ -277,9 +277,14 @@
}
@Override
- public Map<String,Object> checkSubmitPlan(Integer orderId, String laboratory) {
+ public Map<String,Object> checkSubmitPlan(Integer orderId, String laboratory, Integer reportType) {
Map<String, Object> map = new HashMap<>();
List<String> collect = new ArrayList<>();
+ if (Objects.equals(DETECTION_REPORT, reportType)) {
+ map.put("errorMsg", collect);
+ map.put("unInsOrderCount", 0L);
+ return map;
+ }
List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId));
List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList());
List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
@@ -773,7 +778,17 @@
if (!Objects.equals(DETECTION_REPORT, reportType) && !Objects.equals(INSPECTION_REPORT, reportType)) {
throw new ErrorException("璇烽�夋嫨鎶ュ憡绫诲瀷");
}
- InsOrder order = insOrderMapper.selectById(orderId);
+ InsOrder order = insOrderMapper.selectOne(Wrappers.<InsOrder>lambdaQuery()
+ .eq(InsOrder::getId, orderId)
+ .last("FOR UPDATE"));
+ InsReport existingReport = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery()
+ .eq(InsReport::getInsOrderId, orderId));
+ if (existingReport != null && existingReport.getReportType() != null
+ && !Objects.equals(existingReport.getReportType(), reportType)) {
+ throw new ErrorException("鍚屼竴妫�楠岃鍗曞彧鑳戒娇鐢ㄤ竴绉嶆姤鍛婄被鍨�");
+ }
+ boolean isInspectionReport = Objects.equals(INSPECTION_REPORT, reportType);
+ registerInsResults = isInspectionReport && Boolean.TRUE.equals(registerInsResults);
// 1. 鍒ゆ柇鏄惁鏈夐噸澶嶇紪鍙�, 鏈夐噸澶嶇紪鍙峰仛鎻愰啋
Long codeCount = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery()
.ne(InsOrder::getState, -1)
@@ -808,7 +823,8 @@
})
.ne(InsProduct::getIsBinding, 1));
if (Objects.equals(reportType, INSPECTION_REPORT)) {
- insProducts.addAll(insProductMapper.selectFiberInsProduct(InsSampleIds, laboratory));
+ List<InsProduct> insProducts1 = insProductMapper.selectFiberInsProduct(InsSampleIds, laboratory);
+ insProducts.addAll(insProducts1);
}
if (insProducts.size() > 0) {
String str = "";
@@ -887,7 +903,7 @@
// 11.鎴愬搧鎶芥牱娣诲姞鍚堟牸鐘舵��
// 鍒ゆ柇鏄惁鏈夋娊鏍蜂俊鎭�
- if (order.getQuarterItemId() != null) {
+ if (isInspectionReport && order.getQuarterItemId() != null) {
// 鍒ゆ柇鏄惁鏈変笉鍚堟牸
this.addProductSpotCheck(insSamples, order);
}
@@ -942,7 +958,7 @@
});
// 14.ifs绉诲簱(鍘熸潗鏂欓渶瑕佽繘琛岀Щ搴撴搷浣�) --> 鏈�鍚庢墽琛�,鍥犱负澶辫触鏃犳硶鍥炴粴
- if (ifsInventoryQuantity != null) {
+ if (ifsInventoryQuantity != null && isInspectionReport) {
// 鐧昏妫�楠岀粨鏋�
// 鍒ゆ柇鏄惁鏈変笉鍚堟牸, 鏈変笉鍚堟牸涓嶈兘绉诲簱
// todo: ifs绉诲簱
@@ -956,7 +972,7 @@
});
- } else {
+ } else if (isInspectionReport) {
// 淇敼鎴愬搧鐘舵��
// 鍒ゆ柇鏄惁鏈変笉鍚堟牸
Long unqualifiedCount = insReportService.getUnqualifiedCount(order);
@@ -983,7 +999,7 @@
private void addAnalysis(List<InsProduct> productList, IfsInventoryQuantity ifsInventoryQuantity, InsOrder order, String sendUserAccount) {
for (InsProduct insProduct : productList) {
// 鍒ゆ柇鏄惁鏄暟鍊肩被鍨�
- if (insProduct.getInspectionValueType().equals("1") && insProduct.getInsResult().equals(1)) {
+ if ("1".equals(insProduct.getInspectionValueType()) && Objects.equals(insProduct.getInsResult(), 1)) {
List<InsProductDeviationWarningDetail> insProductAnalysisDtoList = insProductMapper.selectAnalysis(insProduct, ifsInventoryQuantity.getSupplierName());
if (CollectionUtils.isEmpty(insProductAnalysisDtoList)) {
@@ -1939,7 +1955,8 @@
// 淇敼鎹㈣鍜屽悎骞堕棶棰�
updaeMerge(template.getXWPFDocument(), true);
String name = insReport.getCode().replace("/", "") + (showResult ? "-J.docx" : "-C.docx");
- template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + name)));
+ Files.createDirectories(Paths.get(wordUrl));
+ template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl, name)));
insReport.setUrl("/word/" + name);
insReport.setIsPass(0);
insReport.setWriteUserId(SecurityUtils.getUserId().intValue());//鎻愪氦浜�
@@ -2851,7 +2868,8 @@
// 淇敼鎹㈣鍜屽悎骞堕棶棰�
updaeMerge(template.getXWPFDocument(), false);
String name = insReport.getCode().replace("/", "") + (showResult ? ".docx" : "-C.docx");
- template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + name)));
+ Files.createDirectories(Paths.get(wordUrl));
+ template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl, name)));
insReport.setUrl("/word/" + name);
insReport.setWriteUserId(SecurityUtils.getUserId().intValue());//鎻愪氦浜�
insReport.setWriteTime(LocalDateTime.now());//鎻愪氦鏃堕棿
@@ -3231,6 +3249,11 @@
}
}
+ // 妫�娴嬫姤鍛婁笉灞曠ず鈥滅粨璁衡�濆垪锛岄琛屼篃瑕佸悓姝ュ噺灏戜竴涓崟鍏冩牸锛�
+ // 鍚﹀垯棣栬涓� max + 6 鍒椼�佸叾浣欒涓� max + 5 鍒楋紝poi-tl 鏃犳硶娓叉煋琛ㄦ牸銆�
+ if (!showResult && !text.isEmpty()) {
+ text.remove(text.size() - 1);
+ }
TextRenderData[] text2 = text.toArray(new TextRenderData[0]);
rowRenderData = Rows.of(text2).center().rowAtleastHeight(1).create();
rows.add(rowRenderData);
--
Gitblit v1.9.3