From bf2026a38d4d36371060673d4651b6e05ca90632 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期二, 01 九月 2026 17:07:30 +0800
Subject: [PATCH] feat(device): 1.更新设备导入验证逻辑和检验任务功能 2.报告编制

---
 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 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..161afd1 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)
@@ -887,7 +902,7 @@
 
         // 11.鎴愬搧鎶芥牱娣诲姞鍚堟牸鐘舵��
         // 鍒ゆ柇鏄惁鏈夋娊鏍蜂俊鎭�
-        if (order.getQuarterItemId() != null) {
+        if (isInspectionReport && order.getQuarterItemId() != null) {
             // 鍒ゆ柇鏄惁鏈変笉鍚堟牸
             this.addProductSpotCheck(insSamples, order);
         }
@@ -942,7 +957,7 @@
         });
 
         // 14.ifs绉诲簱(鍘熸潗鏂欓渶瑕佽繘琛岀Щ搴撴搷浣�) --> 鏈�鍚庢墽琛�,鍥犱负澶辫触鏃犳硶鍥炴粴
-        if (ifsInventoryQuantity != null) {
+        if (ifsInventoryQuantity != null && isInspectionReport) {
             // 鐧昏妫�楠岀粨鏋�
             // 鍒ゆ柇鏄惁鏈変笉鍚堟牸, 鏈変笉鍚堟牸涓嶈兘绉诲簱
             // todo: ifs绉诲簱
@@ -956,7 +971,7 @@
             });
 
 
-        } else {
+        } else if (isInspectionReport) {
             // 淇敼鎴愬搧鐘舵��
             // 鍒ゆ柇鏄惁鏈変笉鍚堟牸
             Long unqualifiedCount = insReportService.getUnqualifiedCount(order);
@@ -983,7 +998,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)) {

--
Gitblit v1.9.3