From c296b7d0c412429d29ad24bd34aa9def65045085 Mon Sep 17 00:00:00 2001
From: chenrui <1187576398@qq.com>
Date: 星期四, 10 四月 2025 17:17:09 +0800
Subject: [PATCH] 成品下单检验新增字段

---
 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java |  116 ++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 68 insertions(+), 48 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 69d71dc..7008c60 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
@@ -30,6 +30,7 @@
 import com.ruoyi.basic.service.StandardTemplateService;
 import com.ruoyi.common.constant.DictDataConstants;
 import com.ruoyi.common.constant.InsOrderTypeConstants;
+import com.ruoyi.common.constant.MenuJumpPathConstants;
 import com.ruoyi.common.core.domain.entity.Custom;
 import com.ruoyi.common.core.domain.entity.InformationNotification;
 import com.ruoyi.common.core.domain.entity.User;
@@ -54,7 +55,9 @@
 import com.ruoyi.system.service.InformationNotificationService;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.xwpf.usermodel.*;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.ClassPathResource;
 import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Service;
@@ -97,14 +100,9 @@
     private InsOrderStateMapper insOrderStateMapper;
     @Resource
     private InsProductMapper insProductMapper;
-    @Resource
-    private ShiftTimeMapper shiftTimeMapper;
-    @Resource
-    private PerformanceShiftMapper performanceShiftMapper;
+
     @Value("${wordUrl}")
     private String wordUrl;
-    @Value("${twoCode}")
-    private String twoCode;
     @Resource
     private InsReportMapper insReportMapper;
     @Resource
@@ -141,8 +139,7 @@
     private InsOrderFactoryVerifyMapper insOrderFactoryVerifyMapper;
     @Resource
     private InsOrderFactoryVerifyItemService insOrderFactoryVerifyItemService;
-    @Value("${file.licenseUrl}")
-    private String licenseUrl;
+
     @Resource
     private SpotCheckQuarterItemMapper spotCheckQuarterItemMapper;
     @Resource
@@ -158,28 +155,20 @@
 
     @Override
     public IPage<InsOrderPlanVO> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) {
-        // todo: 浠呯湅鑷繁鎴栬�呭疄楠屽
-        //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id
-
-        String laboratory = null;
-
-        String userName = null;
-        Integer userId = null;
-        if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) {
-            userId = SecurityUtils.getUserId().intValue();
-            userName = userMapper.selectById(userId).getName();
+        // 妫�娴嬬鐞嗕汉鍛樺叏鏌ワ紝闈炴娴嬬鐞嗕汉鍛樺彧鏌ョ湅鑷繁鐨�
+        InsOrderPlanQueryDto insOrderPlanQueryDto = new InsOrderPlanQueryDto();
+        insOrderPlanQueryDto.setCheckUserFlag(SecurityUtils.hasRole("inspector"));
+        insOrderPlanQueryDto.setTestAdminFlag(SecurityUtils.hasRole("testadmin"));
+        // 鍒ゆ柇鏄惁瑙﹀彂鍙煡鐪嬭嚜宸�
+        if(null != insOrderPlanDTO.getUserId()){
+            insOrderPlanQueryDto.setViewMySelfFlag(true);
             insOrderPlanDTO.setUserId(null);
         }
-        Integer isCheck = insOrderPlanDTO.getIsCheck();
+        insOrderPlanQueryDto.setIsCheck(insOrderPlanDTO.getIsCheck());
         insOrderPlanDTO.setIsCheck(null);
-        String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//璇曢獙瀹�
+        insOrderPlanQueryDto.setUserId(SecurityUtils.getUserId().intValue());
         IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page,
-                QueryWrappers.queryWrappers(insOrderPlanDTO),
-                userName,
-                userId,
-                sonLaboratory,
-                laboratory,
-                isCheck);
+                QueryWrappers.queryWrappers(insOrderPlanDTO),insOrderPlanQueryDto);
         return insOrderPage;
     }
 
@@ -228,17 +217,19 @@
 
         // 鏌ヨ鍘傚瀵嗗害
         String supplierDensity = "";
-        SampleProductDto sampleProductDto = list.get(0);
+        if (CollectionUtils.isNotEmpty(list)) {
+            SampleProductDto sampleProductDto = list.get(0);
 
-        // 鍒ゆ柇鏈夋病鏈夌粦瀹氬瀷鍙�
-        String modelValue = insSampleMapper.selectSupplierDensityModel(sampleProductDto.getSample(),
-                order.getProduction(),
-                sampleProductDto.getModel());
-        if (StringUtils.isNotBlank(modelValue)) {
-            supplierDensity = modelValue;
-        } else {
-            supplierDensity = insSampleMapper.selectSupplierDensity(sampleProductDto.getSample(),
-                    order.getProduction());
+            // 鍒ゆ柇鏈夋病鏈夌粦瀹氬瀷鍙�
+            String modelValue = insSampleMapper.selectSupplierDensityModel(sampleProductDto.getSample(),
+                    order.getProduction(),
+                    sampleProductDto.getModel());
+            if (StringUtils.isNotBlank(modelValue)) {
+                supplierDensity = modelValue;
+            } else {
+                supplierDensity = insSampleMapper.selectSupplierDensity(sampleProductDto.getSample(),
+                        order.getProduction());
+            }
         }
         map.put("supplierDensity", supplierDensity);
         return map;
@@ -361,7 +352,7 @@
         insContext.forEach((k, v) -> {
             JSONObject jo = JSON.parseObject(JSON.toJSONString(v));
             InsProduct insProduct = new InsProduct();
-            insProduct.setId(Integer.parseInt(k));
+            insProduct.setId(Long.valueOf(Integer.parseInt(k)));
             InsProduct product = insProductMapper.selectById(insProduct.getId());
             if (currentTable.equals(product.getTemplateId()) && currentSampleId.equals(product.getInsSampleId())) {
                 List<InsProductResult> oldResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery()
@@ -448,6 +439,30 @@
                     }
                     newResult.setEquipName(JSON.toJSONString(ev));
                 }
+                //娴嬭瘯寮�濮嬫椂闂�
+                if (jo.get("testStartTime") != null) {
+                    JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("testStartTime")));
+                    List<Map<String, Object>> ev = new ArrayList<>();
+                    for (Object o : jsonArray2) {
+                        JSONObject testStartTimeValue = JSON.parseObject(JSON.toJSONString(o));
+                        Map<String, Object> map = new HashMap<>();
+                        map.put("v", JSON.parseObject(JSON.toJSONString(testStartTimeValue.get("v"))).get("v"));
+                        ev.add(map);
+                    }
+                    newResult.setTestStartTime(JSON.toJSONString(ev));
+                }
+                //娴嬭瘯缁撴潫鏃堕棿
+                if (jo.get("testEndTime") != null) {
+                    JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("testEndTime")));
+                    List<Map<String, Object>> ev = new ArrayList<>();
+                    for (Object o : jsonArray2) {
+                        JSONObject testEndTimeValue = JSON.parseObject(JSON.toJSONString(o));
+                        Map<String, Object> map = new HashMap<>();
+                        map.put("v", JSON.parseObject(JSON.toJSONString(testEndTimeValue.get("v"))).get("v"));
+                        ev.add(map);
+                    }
+                    newResult.setTestEndTime(JSON.toJSONString(ev));
+                }
                 //缁撹
                 try {
                     JSONObject insResult = JSON.parseObject(JSON.toJSONString(jo.get("insResult")));
@@ -468,7 +483,7 @@
 
                 insProduct.setUpdateUser(userId);
                 insProductMapper.updateById(insProduct);
-                insProductUserMapper.insert(new InsProductUser(null, userId, LocalDateTime.now(), insProduct.getId()));
+                insProductUserMapper.insert(new InsProductUser(null, userId, LocalDateTime.now(), Math.toIntExact(insProduct.getId())));
 
                 insSample.setInsState(1);
                 Long l = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
@@ -780,11 +795,13 @@
             int count = 0;
             for (InsProduct product : insProducts) {
                 count++;
-                str += "<br/>" + count + "锛�" + product.getInspectionItem() + " " + product.getInspectionItemSubclass() + "<br/>";
-
+                str +=  (count != 0 ? "\n" : "") + count + "锛�" +
+                        product.getInspectionItemClass() + " " +
+                        product.getInspectionItem() + " " +
+                        product.getInspectionItemSubclass();
             }
             if (ObjectUtils.isNotEmpty(str)) {
-                throw new ErrorException("<strong>瀛樺湪寰呮楠岀殑椤圭洰锛�</strong><br/>" + str);
+                throw new ErrorException("瀛樺湪寰呮楠岀殑椤圭洰锛�" + str);
             }
         }
 
@@ -810,7 +827,7 @@
         info.setSenderId(userId);
         info.setConsigneeId(verifyUser);
         info.setViewStatus(false);
-        info.setJumpPath("b1-inspect-orderPlan-review");
+        info.setJumpPath(MenuJumpPathConstants.INSPECTION_REVIEW);
         informationNotificationService.addInformationNotification(info);
 
         // 6.澶嶆牳浜�--鏂板妫�楠屽崟鐩稿叧璐熻矗浜�
@@ -823,8 +840,8 @@
 
         // 7.鏍¢獙涓�涓媟esult琛�(閬垮厤鍑虹幇澶氫釜妫�楠岄」缁撴灉)
         threadPoolTaskExecutor.execute(() -> {
-            List<Integer> ips = insProducts.stream().map(InsProduct::getId).distinct().collect(Collectors.toList());
-            for (Integer ip : ips) {
+            List<Long> ips = insProducts.stream().map(InsProduct::getId).distinct().collect(Collectors.toList());
+            for (Long ip : ips) {
                 List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery()
                         .eq(InsProductResult::getInsProductId, ip));
                 if (insProductResults.size() > 1) {
@@ -879,7 +896,7 @@
             InsOrderRates insOrderRates = new InsOrderRates();
             insOrderRates.setInsOrderId(orderId);
             insOrderRates.setInsSampleId(insProduct.getInsSampleId());
-            insOrderRates.setInsProductId(insProduct.getId());
+            insOrderRates.setInsProductId(Math.toIntExact(insProduct.getId()));
             insOrderRates.setSampleCode(insProduct.getSampleCode());
             insOrderRates.setEntrustCode(order.getEntrustCode());
             insOrderRates.setInspectionItemClass(insProduct.getInspectionItemClass());
@@ -1541,7 +1558,8 @@
         // 妫�娴嬩緷鎹�
         Set<String> standardMethod = new HashSet<>();
         StringBuilder standardMethod2 = new StringBuilder();
-        standardMethod.add(baseMapper.getStandardMethodCode(insSample.getStandardMethodListId()));
+        // TODO 妫�楠岀殑瀵硅薄鐨勬楠屾爣鍑嗙敱涓�涓涓� 鏁版嵁绫诲瀷鐢眎nt鍙樺瓧绗︿覆 闇�瑕侀噸鍐欏啓杩欏潡閫昏緫
+//        standardMethod.add(baseMapper.getStandardMethodCode(insSample.getStandardMethodListId()));
         for (String s : standardMethod) {
             standardMethod2.append("銆�").append(s);
         }
@@ -2085,7 +2103,9 @@
         samples.forEach(a -> {
             Map<Integer, String> map2 = new HashMap<>();
             models.add(a.getModel());
-            String standardMethodCode = baseMapper.getStandardMethodCode(a.getStandardMethodListId());
+            // TODO 妫�楠岀殑瀵硅薄鐨勬楠屾爣鍑嗙敱涓�涓涓� 鏁版嵁绫诲瀷鐢眎nt鍙樺瓧绗︿覆 闇�瑕侀噸鍐欏啓杩欏潡閫昏緫
+//            String standardMethodCode = baseMapper.getStandardMethodCode(a.getStandardMethodListId());
+            String standardMethodCode = "";
             if (StrUtil.isNotBlank(a.getSpecialStandardMethod())) {
                 standardMethodCode = standardMethodCode + "+" + a.getSpecialStandardMethod();
             }
@@ -4227,7 +4247,7 @@
         FileOutputStream os = null;
         try {
             //鍑瘉 涓嶇劧鍒囨崲鍚庢湁姘村嵃
-            InputStream is = Files.newInputStream(new File(licenseUrl).toPath());
+            InputStream is = new ClassPathResource("/lib/license.xml").getInputStream();
             License license = new License();
             license.setLicense(is);
             if (!license.getIsLicensed()) {

--
Gitblit v1.9.3