From e07e8d4ccd220af0cb6d51cde68bff6434a6e623 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 08 八月 2024 20:57:07 +0800
Subject: [PATCH] 光纤配置在光纤试验室显示

---
 inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java |  399 +++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 292 insertions(+), 107 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 f5e2efb..217085a 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
@@ -135,18 +135,35 @@
 
     @Resource
     private InsOrderFileMapper insOrderFileMapper;
+
     @Override
     public Map<String, Object> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) {
         Map<String, Object> map = new HashMap<>();
         map.put("head", PrintChina.printChina(InsOrderPlanVO.class));
+        Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null);
+        User user = userMapper.selectById(map1.get("userId"));//褰撳墠鐧诲綍鐨勪汉
+
+        //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id
+        String departLimsId = user.getDepartLimsId();
+        String laboratory = null;
+        if (ObjectUtils.isNotEmpty(departLimsId) && !departLimsId.equals("")) {
+            String[] split = departLimsId.split(",");
+            //鏌ヨ瀵瑰簲鏋舵瀯鍚嶇О(閫氫俊瀹為獙瀹�,鐢靛姏瀹為獙瀹�,妫�娴嬪姙)
+            String departLims = baseMapper.seldepLimsId(Integer.parseInt(split[split.length - 1]));
+            if (departLims.contains("瀹為獙瀹�")) {
+                laboratory = departLims;
+            }
+        }
+        String userName = null;
         Integer userId = null;
-        if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId()) ) {
-            Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null);
-             userId = map1.get("userId");
-            insOrderPlanDTO.setUserId(userId.longValue());
+        if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) {
+            userId = map1.get("userId");
+            userName = userMapper.selectById(map1.get("userId")).getName();
+            insOrderPlanDTO.setUserId(null);
         }
         String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//璇曢獙瀹�
-        IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory);
+        insOrderPlanDTO.setSonLaboratory(null);
+        IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userName, sonLaboratory, laboratory);
         map.put("body", insOrderPage);
         return map;
     }
@@ -157,11 +174,24 @@
         map.put("head", PrintChina.printChina(InsOrderPlanTaskSwitchVo.class));
         Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null);
         Integer userId = map1.get("userId");
+        User user = userMapper.selectById(map1.get("userId"));//褰撳墠鐧诲綍鐨勪汉
+
+        //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id
+        String departLimsId = user.getDepartLimsId();
+        String laboratory = null;
+        if (ObjectUtils.isNotEmpty(departLimsId) && !departLimsId.equals("")) {
+            String[] split = departLimsId.split(",");
+            //鏌ヨ瀵瑰簲鏋舵瀯鍚嶇О(閫氫俊瀹為獙瀹�,鐢靛姏瀹為獙瀹�,妫�娴嬪姙)
+            String departLims = baseMapper.seldepLimsId(Integer.parseInt(split[split.length - 1]));
+            if (departLims.contains("瀹為獙瀹�")) {
+                laboratory = departLims;
+            }
+        }
         if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) {
             insOrderPlanDTO.setUserId(userId.longValue());
         }
         String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//璇曢獙瀹�
-        IPage<InsOrderPlanTaskSwitchVo> insOrderPage = insSampleMapper.inspectionOrderDetailsTaskSwitching(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory);
+        IPage<InsOrderPlanTaskSwitchVo> insOrderPage = insSampleMapper.inspectionOrderDetailsTaskSwitching(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId, sonLaboratory, laboratory);
         map.put("body", insOrderPage);
         return map;
     }
@@ -174,7 +204,7 @@
         }
         Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null);
         Integer userId = map1.get("userId");
-        InsSampleUser insSampleUser = new InsSampleUser(entity.getInsSampleId().intValue(), userId, 1,entity.getSonLaboratory());
+        InsSampleUser insSampleUser = new InsSampleUser(entity.getInsSampleId().intValue(), userId, 0, entity.getSonLaboratory());
         return insSampleUserMapper.insert(insSampleUser) > 0;
     }
 
@@ -203,18 +233,29 @@
         List<InsProduct> insProducts = new ArrayList<>();
         switch (type) {
             case 0:
+                //鏍峰搧
                 insProducts = insSampleMapper.getInsProduct1(id, laboratory);
                 break;
             case 1:
+                //鍏夌氦甯�
                 insProducts = insSampleMapper.getInsProduct2(id);
                 break;
             case 2:
+                //鍏夌氦
                 insProducts = insSampleMapper.getInsProduct3(id);
                 break;
+            case 3:
+                //濂楃
+                insProducts = insSampleMapper.getInsProduct4(id);
+                break;
         }
-        // 鏁伴噰鏂板
-        getDeviceMessage(insProducts, request);
 
+        //濡傛灉鏄ぇ鏍峰搧涓嬬殑椤圭洰涓虹┖,閭d箞鏌ヨ绗竴涓厜绾ょ殑椤圭洰
+        if (ObjectUtils.isEmpty(insProducts) && type==0){
+            //鏌ヨ绗竴涓厜绾ょ殑id
+            List<InsFiber> insFibers = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsBushingId, insBushingMapper.selectList(Wrappers.<InsBushing>lambdaQuery().eq(InsBushing::getInsSampleId, id)).get(0).getId()));
+            insProducts = insSampleMapper.getInsProduct3(insFibers.get(0).getId());
+        }
         Set<Integer> set = new HashSet<>();
         Map<Integer, String> map2 = new HashMap<>();
         if (BeanUtil.isEmpty(insProducts)) return null;
@@ -222,33 +263,6 @@
         return insProducts;
     }
 
-    private List<InsProduct> getDeviceMessage(List<InsProduct> insProducts, HttpServletRequest request) {
-        String ipAddress = request.getRemoteAddr();
-        // 闃叉鍥炵幆鍦板潃鍙樹负IPv6
-        String ip =  ipAddress.equals("0:0:0:0:0:0:0:1") ? "127.0.0.1" : ipAddress;
-        insProducts.forEach(i -> {
-            Map<String, Object> devices = baseMapper.getDeviceMessage(ip, i.getInspectionItem(), i.getInspectionItemSubclass(), i.getSampleType());
-            if (ObjectUtils.isNotEmpty(devices) && ObjectUtils.isNotEmpty(devices.get("file_type")) && ObjectUtils.isNotEmpty(devices.get("collect_url"))) {
-                InsProductResult insProductResult = i.getInsProductResult();
-                if (ObjectUtils.isEmpty(insProductResult)) {
-                    insProductResult = new InsProductResult();
-                }
-                List<Object> list = new ArrayList<>();
-                Map<Object, Object> hashMap = new HashMap<>();
-                hashMap.put("v", devices.get("device_name"));
-                list.add(hashMap);
-                insProductResult.setEquipName(JSON.toJSON(list).toString());
-                List<Object> listValue = new ArrayList<>();
-                Map<Object, Object> hashMapValue = new HashMap<>();
-                hashMapValue.put("v", devices.get("management_number"));
-                listValue.add(hashMapValue);
-                insProductResult.setEquipName(JSON.toJSON(list).toString());
-                insProductResult.setEquipValue(JSON.toJSON(listValue).toString());
-                i.setInsProductResult(insProductResult);
-            }
-        });
-        return insProducts;
-    }
     @Override
     public List<String> checkSubmitPlan(Integer orderId, String laboratory) {
         List<String> collect = new ArrayList<>();
@@ -320,16 +334,19 @@
         List<InsBushing> insBushings = insBushingMapper.selectList(Wrappers.<InsBushing>lambdaQuery().eq(InsBushing::getInsSampleId, sampleId));
         List<InsFibers> fibers = new ArrayList<>();
         List<InsFiber> fiber = new ArrayList<>();
+        List<InsBushing> bush = new ArrayList<>();
         for (InsBushing insBushing : insBushings) {
             //鍐嶆煡璇㈠嚭鎵�鏈夌殑鍏夌氦甯�
             List<InsFibers> insFibers = insFibersMapper.selectList(Wrappers.<InsFibers>lambdaQuery().eq(InsFibers::getInsBushingId, insBushing.getId()));
+            List<InsFiber> insFiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsBushingId, insBushing.getId()));
             if (CollectionUtils.isNotEmpty(insFibers)) {
                 for (InsFibers insFiber : insFibers) {
                     List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsFibersId, insFiber.getId()));
-                    List<Integer> collect = insProducts.stream().map(InsProduct::getInsResult).filter(sm -> ObjectUtils.isNotEmpty(sm)).collect(Collectors.toList());
-                    if (insProducts.size()==collect.size()) {
+                    List<Integer> collect = insProducts.stream().map(InsProduct::getInsResult)
+                            .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList());
+                    if (insProducts.size() == collect.size()) {
                         insFiber.setState(1);//宸叉楠�
-                    }else {
+                    } else {
                         insFiber.setState(0);//鏈楠�
                     }
                 }
@@ -338,31 +355,48 @@
                 List<InsFiber> fiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().in(InsFiber::getInsFibersId, insFibers.stream().map(InsFibers::getId).collect(Collectors.toList())));
                 for (InsFiber insFiber : fiberList) {
                     List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsFiberId, insFiber.getId()));
-                    List<Integer> collect = insProducts.stream().map(InsProduct::getInsResult).filter(sm -> ObjectUtils.isNotEmpty(sm)).collect(Collectors.toList());
-                    if (insProducts.size()==collect.size()) {
+                    List<Integer> collect = insProducts.stream().map(InsProduct::getInsResult)
+                            .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList());
+                    if (insProducts.size() == collect.size()) {
                         insFiber.setState(1);//宸叉楠�
-                    }else {
+                    } else {
                         insFiber.setState(0);//鏈楠�
                     }
                 }
                 fiber.addAll(fiberList);
-            } else {
-                //濡傛灉濂楃涓嬫病鏈夊厜绾ゅ甫灏卞彧鏈夊厜绾や簡
-                List<InsFiber> insFiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsBushingId, insBushing.getId()));
+            }
+            //濡傛灉濂楃涓嬫病鏈夊厜绾ゅ甫灏卞彧鏈夊厜绾や簡
+            else if (CollectionUtils.isNotEmpty(insFiberList)) {
                 for (InsFiber insFiber : insFiberList) {
                     List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsFiberId, insFiber.getId()));
-                    List<Integer> collect = insProducts.stream().map(InsProduct::getInsResult).filter(sm -> ObjectUtils.isNotEmpty(sm)).collect(Collectors.toList());
-                    if (insProducts.size()==collect.size()) {
+                    List<Integer> collect = insProducts.stream().map(InsProduct::getInsResult)
+                            .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList());
+                    if (insProducts.size() == collect.size()) {
                         insFiber.setState(1);//宸叉楠�
-                    }else {
+                    } else {
                         insFiber.setState(0);//鏈楠�
                     }
                 }
                 fiber.addAll(insFiberList);
             }
+            //濡傛灉鍏夌氦甯﹀拰鍏夌氦閮芥病鏈夊氨鍙湁濂楃(鏉惧绠�)
+            else {
+                List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
+                        .eq(InsProduct::getInsBushId, insBushing.getId()));
+                List<Integer> collect = insProducts.stream()
+                        .map(InsProduct::getInsResult)
+                        .filter(sm -> ObjectUtils.isNotEmpty(sm) && sm != 2).collect(Collectors.toList());
+                if (insProducts.size() == collect.size()) {
+                    insBushing.setState(1);//宸叉楠�
+                } else {
+                    insBushing.setState(0);//鏈楠�
+                }
+                bush.add(insBushing);
+            }
         }
         map.put("鍏夌氦甯�", fibers);
         map.put("鍏夌氦", fiber);
+        map.put("濂楃", bush);
         return map;
     }
 
@@ -377,7 +411,7 @@
         //鍏堟煡鍑鸿繖涓牱鍝佷笅鏈夊摢浜涚鑹叉爣,鍏夌氦甯�,鍏夌氦鑹叉爣
         //鍏堟煡鍑哄绠�
         List<InsBushing> insBushings = insBushingMapper.selectList(Wrappers.<InsBushing>lambdaQuery().eq(InsBushing::getInsSampleId, sampleId));
-        if (insBushings.size()>0) {
+        if (insBushings.size() > 0) {
             //閫氫俊--娓╁害寰幆
             for (InsBushing insBushing : insBushings) {
                 //鍐嶆煡璇㈠嚭鎵�鏈夌殑鍏夌氦甯�
@@ -399,18 +433,18 @@
                                 ProductVo productVo = new ProductVo();
                                 productVo.setCode(insFiber.getCode());
                                 productVo.setColor(fiber.getColor());
-                                productVo.setBushColor(fiber.getBushColor());
+                                productVo.setBushColor(insBushing.getColor());
                                 if (ObjectUtils.isNotEmpty(insProductResult)) {
                                     insProduct.setInsProductResult(insProductResult);
                                 }
                                 //姹傚悓绛夋潯浠朵笅1娆″惊鐜�20搴﹀父娓╃殑璁$畻鍊�
-                                InsProductResult insProductResult1 = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId,insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
-                                        .eq(InsProduct::getInsSampleId,sampleId)
+                                InsProductResult insProductResult1 = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
+                                        .eq(InsProduct::getInsSampleId, sampleId)
                                         .eq(InsProduct::getInspectionItem, "1")
                                         .eq(InsProduct::getInspectionItemSubclass, "20鈩�(甯告俯)")
                                         .eq(InsProduct::getInspectionItemClass, insProduct.getInspectionItemClass())
-                                        .eq(InsProduct::getInsFiberId, fiber.getId())).getId() ));
-                                if (ObjectUtils.isNotEmpty(insProductResult1) &&!insProductResult1.getComValue().equals("[]")) {
+                                        .eq(InsProduct::getInsFiberId, fiber.getId())).getId()));
+                                if (ObjectUtils.isNotEmpty(insProductResult1) && !insProductResult1.getComValue().equals("[]")) {
                                     insProduct.setComplue(insProductResult1.getComValue().split(":")[1].split("\"")[1]);
                                 }
                                 productVo.setInsProduct(insProduct);
@@ -418,8 +452,7 @@
                             }
                         }
                     }
-                }
-                else {
+                } else {
                     //濡傛灉濂楃涓嬫病鏈夊厜绾ゅ甫灏卞彧鏈夊厜绾や簡
                     List<InsFiber> insFiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsBushingId, insBushing.getId()));
                     for (InsFiber fiber : insFiberList) {
@@ -432,17 +465,17 @@
                         for (InsProduct insProduct : insProducts) {
                             InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId()));
                             ProductVo productVo = new ProductVo();
-                            productVo.setCode("/");
+                            productVo.setCode("-");
                             productVo.setColor(fiber.getColor());
                             productVo.setBushColor(fiber.getBushColor());
                             insProduct.setInsProductResult(insProductResult);
                             //姹傚悓绛夋潯浠朵笅1娆″惊鐜�20搴﹀父娓╃殑璁$畻鍊�
-                            InsProductResult insProductResult1 = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId,insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
-                                    .eq(InsProduct::getInsSampleId,sampleId)
+                            InsProductResult insProductResult1 = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
+                                    .eq(InsProduct::getInsSampleId, sampleId)
                                     .eq(InsProduct::getInspectionItem, "1")
                                     .eq(InsProduct::getInspectionItemSubclass, "20鈩�(甯告俯)")
                                     .eq(InsProduct::getInspectionItemClass, insProduct.getInspectionItemClass())
-                                    .eq(InsProduct::getInsFiberId, fiber.getId())).getId() ));
+                                    .eq(InsProduct::getInsFiberId, fiber.getId())).getId()));
                             if (ObjectUtils.isNotEmpty(insProductResult1) && !insProductResult1.getComValue().equals("[]")) {
                                 insProduct.setComplue(insProductResult1.getComValue().split(":")[1].split("\"")[1]);
                             }
@@ -453,8 +486,7 @@
                 }
             }
             productVos = productVos.stream().sorted(Comparator.comparing(productVo -> productVo.getInsProduct().getInspectionItemClass())).collect(Collectors.toList());
-        }
-        else {
+        } else {
             //鐢靛姏--鐑惊鐜拰娓╁崌璇曢獙
             List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                     .eq(InsProduct::getInsSampleId, sampleId)
@@ -489,7 +521,9 @@
                 JSONObject jo = JSON.parseObject(JSON.toJSONString(v));
                 InsProduct insProduct = new InsProduct();
                 insProduct.setId(Integer.parseInt(k));
-                List<InsProductResult> results = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId()));
+                List<InsProductResult> results = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery()
+                        .eq(InsProductResult::getInsProductId, insProduct.getId()));
+                InsProduct product = insProductMapper.selectById(insProduct.getId());
                 InsProductResult result;
                 if (CollectionUtils.isEmpty(results)) {
                     result = new InsProductResult();
@@ -497,7 +531,16 @@
                     result = results.get(0);
                 }
                 result.setInsProductId(Integer.parseInt(k));
+                /*鏍¢獙涓�涓媟esult琛�*/
+                List<InsProductResult> insProductResultss = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery()
+                        .eq(InsProductResult::getInsProductId, insProduct.getId()));
+                if (insProductResultss.size() > 1) {
+                    for (int i = 1; i < insProductResultss.size(); i++) {
+                        insProductResultMapper.deleteById(insProductResultss.get(i));
+                    }
+                }
                 InsProductResult insProductResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, Integer.parseInt(k)));
+                //妫�楠屽��
                 if (jo.get("insValue") != null) {
                     JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(jo.get("insValue")));
                     List<Map<String, Object>> iv = new ArrayList<>();
@@ -520,6 +563,7 @@
                     }
                     result.setInsValue(JSON.toJSONString(iv));
                 }
+                //璁$畻鍊�
                 if (jo.get("comValue") != null && !Objects.equals(jo.get("comValue"), "")) {
                     JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("comValue")));
                     List<Map<String, Object>> cv = new ArrayList<>();
@@ -531,6 +575,7 @@
                     }
                     result.setComValue(JSON.toJSONString(cv));
                 }
+                //鏈�缁堝��
                 try {
                     JSONObject resValue = JSON.parseObject(JSON.toJSONString(jo.get("resValue")));
                     if (resValue.get("v") != null) {
@@ -538,7 +583,9 @@
                         insProduct.setLastValue(o.equals("") ? null : (o.toString()));
                     }
                 } catch (Exception e) {
+                    insProduct.setLastValue("");//''
                 }
+                //璁惧缂栧彿
                 if (jo.get("equipValue") != null) {
                     JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("equipValue")));
                     List<Map<String, Object>> ev = new ArrayList<>();
@@ -550,6 +597,7 @@
                     }
                     result.setEquipValue(JSON.toJSONString(ev));
                 }
+                //璁惧鍚嶇О
                 if (jo.get("equipName") != null) {
                     JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("equipName")));
                     List<Map<String, Object>> ev = new ArrayList<>();
@@ -561,11 +609,13 @@
                     }
                     result.setEquipName(JSON.toJSONString(ev));
                 }
+                //缁撹
                 try {
                     JSONObject insResult = JSON.parseObject(JSON.toJSONString(jo.get("insResult")));
                     String ir = JSON.parseObject(JSON.toJSONString(insResult.get("v"))).get("v") + "";
                     insProduct.setInsResult(Integer.parseInt(ir));
                 } catch (Exception e) {
+                    insProduct.setInsResult(2);//寰呭畾
                 }
                 if (BeanUtil.isEmpty(result.getId())) {
                     result.setCreateUser(userId);
@@ -576,6 +626,55 @@
                     result.setUpdateTime(LocalDateTime.now());
                     insProductResultMapper.updateById(result);
                 }
+
+                /*濡傛灉鏄涓�娆¢�夋嫨璁惧淇℃伅,涓旇繕鏈夊叾浣欐牱鍝佷篃鏈夊悓涓�涓粡楠岄」鐩�,閭d箞鎵�鏈夋牱鍝佺殑璇ラ」鐩兘鐢ㄨ繖涓澶囦俊鎭�*/
+                //鍏堟煡璇㈡槸鍚﹁繕鏈夊叾浣欐牱鍝�
+
+                Integer insSampleId = product.getInsSampleId();
+                List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, insSampleMapper.selectById(insSampleId).getInsOrderId()));
+                if (insSamples.size() > 1 && !product.getInspectionItemType().equals("1")) {
+                    //瀛樺湪鍏朵綑鏍峰搧,鏌ヨ鏄惁鏈夊悓涓�绉嶆楠岄」鐩�
+                    for (InsSample sample : insSamples.stream().filter(insSample -> !insSample.getId().equals(insSampleId)).collect(Collectors.toList())) {
+                        InsProduct product1 = insProductMapper.selectOne(Wrappers.<InsProduct>lambdaQuery()
+                                .eq(InsProduct::getState, 1)
+                                .eq(InsProduct::getInsSampleId, sample.getId())
+                                .eq(InsProduct::getInspectionItem, product.getInspectionItem())
+                                .eq(InsProduct::getInspectionItemEn, product.getInspectionItemEn())
+                                .eq(InsProduct::getInspectionItemSubclass, product.getInspectionItemSubclass())
+                                .eq(InsProduct::getInspectionItemSubclassEn, product.getInspectionItemSubclassEn())
+                                .eq(InsProduct::getTemplateId, product.getTemplateId())
+                                .eq(InsProduct::getStandardMethodListId, product.getStandardMethodListId())
+                                .eq(InsProduct::getInsBushId, product.getInsBushId())
+                                .eq(InsProduct::getInsFibersId, product.getInsFibersId())
+                                .eq(InsProduct::getInsFiberId, product.getInsFiberId())
+                        );
+                        if (ObjectUtils.isNotEmpty(product1)) {
+                            //濡傛灉瀛樺湪椤圭洰,鏌ヨ鏄惁鏈夎〃
+                            InsProductResult productResult = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery()
+                                    .eq(InsProductResult::getInsProductId, product1.getId()));
+                            if (ObjectUtils.isEmpty(productResult)) {
+                                //娌℃湁琛ㄦ柊寤鸿〃
+                                productResult = new InsProductResult();
+                                productResult.setInsProductId(product1.getId());
+                                productResult.setEquipValue(result.getEquipValue());
+                                productResult.setEquipName(result.getEquipValue());
+                                productResult.setCreateUser(userId);
+                                productResult.setUpdateUser(userId);
+                                insProductResultMapper.insert(productResult);
+                            } else if (ObjectUtils.isEmpty(productResult.getEquipValue())) {
+                                //鏈夎〃鍒ゆ柇鏄惁鏈夎澶�
+                                productResult.setEquipValue(result.getEquipValue());
+                                productResult.setEquipName(result.getEquipValue());
+                                productResult.setUpdateUser(userId);
+                                productResult.setUpdateTime(LocalDateTime.now());
+                                insProductResultMapper.updateById(productResult);
+                            }
+                        }
+                    }
+
+                }
+
+
                 insProduct.setUpdateUser(userId);
                 insProductMapper.updateById(insProduct);
                 insProductUserMapper.insert(new InsProductUser(null, userId, LocalDateTime.now(), insProduct.getId()));
@@ -590,28 +689,47 @@
                 PerformanceShift performanceShift = performanceShiftMapper.selectOne(Wrappers.<PerformanceShift>lambdaQuery()
                         .eq(PerformanceShift::getUserId, userId)
                         .eq(PerformanceShift::getWorkTime, today));
-                if (ObjectUtils.isNotEmpty(performanceShift)){
+                if (ObjectUtils.isNotEmpty(performanceShift)) {
                     ShiftTime shiftTime = shiftTimeMapper.selectOne(Wrappers.<ShiftTime>lambdaQuery().eq(ShiftTime::getShift, performanceShift.getShift()));
-                    if (ObjectUtils.isNotEmpty(shiftTime)){
+                    if (ObjectUtils.isNotEmpty(shiftTime)) {
                         DateTimeFormatter forma = DateTimeFormatter.ofPattern("HH:mm");
                         LocalTime now = LocalTime.now();
                         LocalTime startTime = LocalTime.parse(shiftTime.getStartTime(), forma);
                         LocalTime endTime = LocalTime.parse(shiftTime.getEndTime(), forma);
                         // 妫�鏌ュ綋鍓嶆椂闂存槸鍚﹀湪鑼冨洿鍐咃紙鍖呮嫭杈圭晫锛�
-                        boolean isWithinRange = !now.isBefore(startTime) && !now.isAfter(endTime);
+                        boolean isWithinRange;
+                        if (endTime.isAfter(startTime)) {
+                            // 涓嶈法澶╃殑鎯呭喌
+                            isWithinRange = !now.isBefore(startTime) && !now.isAfter(endTime);
+                        } else {
+                            // 璺ㄥぉ鐨勬儏鍐�
+                            isWithinRange = !now.isBefore(startTime) || !now.isAfter(endTime);
+                        }
                         //鍔犵彮
-                        AuxiliaryOutputWorkingHours count1 = auxiliaryOutputWorkingHoursMapper.selectOne(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
+                        List<AuxiliaryOutputWorkingHours> count1s = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
                                 .eq(AuxiliaryOutputWorkingHours::getCheck, userId)
                                 .eq(AuxiliaryOutputWorkingHours::getInspectionItem, insProduct.getInspectionItem())
                                 .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, insProduct.getInspectionItemSubclass())
-                                .eq(AuxiliaryOutputWorkingHours::getOvertimeOrderNo, insOrder.getEntrustCode()));
+                                .eq(AuxiliaryOutputWorkingHours::getOvertimeOrderNo, insOrder.getEntrustCode())
+                                .eq(AuxiliaryOutputWorkingHours::getSample, insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode()));
+                        if (count1s.size() > 1) {
+                            for (int i = 1; i < count1s.size(); i++) {
+                                auxiliaryOutputWorkingHoursMapper.deleteById(count1s.get(i));
+                            }
+                        }
                         //闈炲姞鐝�
-                        AuxiliaryOutputWorkingHours count2 = auxiliaryOutputWorkingHoursMapper.selectOne(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
+                        List<AuxiliaryOutputWorkingHours> count2s = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery()
                                 .eq(AuxiliaryOutputWorkingHours::getCheck, userId)
                                 .eq(AuxiliaryOutputWorkingHours::getInspectionItem, insProduct.getInspectionItem())
                                 .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, insProduct.getInspectionItemSubclass())
-                                .eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode()));
-                        if (ObjectUtils.isNotEmpty(insProduct.getManHour())&& ObjectUtils.isEmpty(count2) && ObjectUtils.isEmpty(count1)) {
+                                .eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode())
+                                .eq(AuxiliaryOutputWorkingHours::getSample, insSampleMapper.selectById(insProduct.getInsSampleId()).getSampleCode()));
+                        if (count2s.size() > 1) {
+                            for (int i = 1; i < count2s.size(); i++) {
+                                auxiliaryOutputWorkingHoursMapper.deleteById(count2s.get(i));
+                            }
+                        }
+                        if (ObjectUtils.isNotEmpty(insProduct.getManHour()) && CollectionUtils.isEmpty(count2s) && CollectionUtils.isEmpty(count1s)) {
                             AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours();
                             if (isWithinRange) {
                                 //鍦ㄦ椂闂村唴灏辨槸姝e父涓婄彮
@@ -621,7 +739,7 @@
                                 auxiliaryOutputWorkingHours.setOrderNo(insOrder.getEntrustCode());//闈炲姞鐝鎵樺崟鍙�
                                 auxiliaryOutputWorkingHours.setWorkTime(insProduct.getManHour());//闈炲姞鐝伐鏃�
                                 auxiliaryOutputWorkingHours.setAmount(1);//闈炲姞鐝暟閲�
-                                auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime())?auxiliaryOutputWorkingHours.getOvertimeWorkTime():0)+(ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime())?auxiliaryOutputWorkingHours.getWorkTime():0));//浜ч噺宸ユ椂
+                                auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : 0) + (ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : 0));//浜ч噺宸ユ椂
                                 auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//宸ユ椂鍒嗙粍
                                 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                                 DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@@ -639,7 +757,7 @@
                                 auxiliaryOutputWorkingHours.setOvertimeOrderNo(insOrder.getEntrustCode());//鍔犵彮濮旀墭鍗曞彿
                                 auxiliaryOutputWorkingHours.setOvertimeWorkTime(insProduct.getManHour());//鍔犵彮宸ユ椂
                                 auxiliaryOutputWorkingHours.setOvertimeAmount(1);//鍔犵彮鏁伴噺
-                                auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime())?auxiliaryOutputWorkingHours.getOvertimeWorkTime():0)+(ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime())?auxiliaryOutputWorkingHours.getWorkTime():0));//浜ч噺宸ユ椂
+                                auxiliaryOutputWorkingHours.setOutputWorkTime((ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getOvertimeWorkTime()) ? auxiliaryOutputWorkingHours.getOvertimeWorkTime() : 0) + (ObjectUtils.isNotEmpty(auxiliaryOutputWorkingHours.getWorkTime()) ? auxiliaryOutputWorkingHours.getWorkTime() : 0));//浜ч噺宸ユ椂
                                 auxiliaryOutputWorkingHours.setManHourGroup(insProduct.getManHourGroup());//宸ユ椂鍒嗙粍
                                 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                                 DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@@ -650,8 +768,12 @@
                                 auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//鍛ㄦ
                                 auxiliaryOutputWorkingHours.setCheck(userId);//妫�娴嬩汉
                             }
-                            if (ObjectUtils.isEmpty(insProductResult) && !result.getInsValue().equals("[]") || (ObjectUtils.isNotEmpty(insProductResult) && !insProductResult.getInsValue().equals(result.getInsValue()) && !insProductResult.getInsValue().equals("[]"))) {
-                                auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours);
+                            try {
+                                if (ObjectUtils.isEmpty(insProductResult) && !result.getInsValue().equals("[]") || (ObjectUtils.isNotEmpty(insProductResult) && !insProductResult.getInsValue().equals(result.getInsValue()) && !insProductResult.getInsValue().equals("[]"))) {
+                                    auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours);
+                                }
+                            }catch (Exception e){
+                                System.out.println("宸ユ椂鏂板涓嶆垚鍔�!!!");
                             }
                         }
                     }
@@ -662,15 +784,23 @@
                 Long l = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
                         .eq(InsProduct::getInsSampleId, insSample.getId()));
                 Long l1 = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
-                        .eq(InsProduct::getInsSampleId, insSample.getId()).isNotNull(InsProduct::getInsResult));
+                        .eq(InsProduct::getInsSampleId, insSample.getId())
+                        .and(wrapper -> wrapper
+                                .isNull(InsProduct::getInsResult)
+                                .or()
+                                .eq(InsProduct::getInsResult, 2)
+                        ));
                 if (l == l1) {
                     insSample.setInsState(2);
                 }
                 insSampleMapper.updateById(insSample);
                 /*鏍¢獙涓�涓媟esult琛�*/
-                List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId()).orderByDesc(InsProductResult::getId));
+                List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery()
+                        .eq(InsProductResult::getInsProductId, insProduct.getId()));
                 if (insProductResults.size() > 1) {
-                    insProductResultMapper.deleteById(insProductResults.get(0));
+                    for (int i = 1; i < insProductResults.size(); i++) {
+                        insProductResultMapper.deleteById(insProductResults.get(i));
+                    }
                 }
             });
             return insContext.keySet().stream().findFirst().orElse(null);
@@ -684,8 +814,17 @@
                 int orderId = insSampleMapper.selectById(sampleId).getInsOrderId();
                 // 閫氳繃璁㈠崟id鏌ユ壘鎵�鏈夋牱鏈琲d
                 List<Integer> sampleIds = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId)).stream().map(InsSample::getId).collect(Collectors.toList());
-                // 閫氳繃妫�鏌ユ瘡涓�涓牱鏈琲d鏌ュ埌灞炰簬妫�楠岄」缁撹 is null鐨勬暟閲�
-                Long count = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().in(InsProduct::getInsSampleId, sampleIds).isNull(InsProduct::getInsResult).eq(InsProduct::getSonLaboratory, insProduct.getSonLaboratory()).eq(InsProduct::getState, 1));
+                // 閫氳繃妫�鏌ユ瘡涓�涓牱鏈琲d鏌ュ埌灞炰簬妫�楠岄」缁撹 is null 鎴栬�� =2 鐨勬暟閲�
+                Long count = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery()
+                        .in(InsProduct::getInsSampleId, sampleIds)
+                        .and(wrapper -> wrapper
+                                .isNull(InsProduct::getInsResult)
+                                .or()
+                                .eq(InsProduct::getInsResult, 2)
+                        )
+                        //.isNull(InsProduct::getInsResult)
+                        .eq(InsProduct::getSonLaboratory, insProduct.getSonLaboratory())
+                        .eq(InsProduct::getState, 1));
                 if (count == 0) {
                     insOrderStateMapper.update(new InsOrderState(), Wrappers.<InsOrderState>lambdaUpdate()
                             .eq(InsOrderState::getInsOrderId, orderId)
@@ -701,7 +840,7 @@
 
     //浜ゆ帴
     @Override
-    public int upPlanUser(Integer userId, Integer orderId,String sonLaboratory) {
+    public int upPlanUser(Integer userId, Integer orderId, String sonLaboratory) {
         InsSampleUser insSampleUser = new InsSampleUser();
         insSampleUser.setUserId(userId);
         insSampleUser.setInsSampleId(orderId);
@@ -908,8 +1047,48 @@
                                         textRenderData.setText("鈭�");
                                         break;
                                     case 0:
-                                        resultCh.set(resultCh.get() + "銆�" + p.getInspectionItem() + (Objects.equals(p.getInspectionItemSubclass(), "") ? "" : " " + p.getInspectionItemSubclass()));
-                                        resultEn.set(resultEn.get() + "銆�" + p.getInspectionItemEn() + ((Objects.equals(p.getInspectionItemSubclassEn(), "") || Objects.equals(p.getInspectionItemSubclassEn(), null)) ? "" : " " + p.getInspectionItemSubclassEn()));
+                                        String current = resultCh.get();
+                                        // 浣跨敤 Set 鏉ヤ繚鎸佸敮涓�椤�
+                                        Set<String> uniqueItems = new HashSet<>();
+                                        if (!current.isEmpty()) {
+                                            // 鍒嗗壊褰撳墠瀛楃涓插苟鍔犲叆鍒� Set 涓�
+                                            String[] items = current.split("銆�");
+                                            for (String item : items) {
+                                                if (!item.isEmpty()) {
+                                                    uniqueItems.add(item);
+                                                }
+                                            }
+                                        }
+                                        // 澶勭悊鏂版暟鎹�
+                                        String newItem = p.getInspectionItem() +
+                                                (Objects.equals(p.getInspectionItemSubclass(), "") ? "" : " " + p.getInspectionItemSubclass());
+                                        uniqueItems.add(newItem);
+
+                                        // 杩炴帴鍞竴椤瑰苟鏇存柊 AtomicReference
+                                        String result = String.join("銆�", uniqueItems);
+                                        resultCh.set(result);
+                                        //resultCh.set(resultCh.get() + "銆�" + p.getInspectionItem() + (Objects.equals(p.getInspectionItemSubclass(), "") ? "" : " " + p.getInspectionItemSubclass()));
+
+                                        String current1 = resultEn.get();
+                                        // 浣跨敤 Set 鏉ヤ繚鎸佸敮涓�椤�
+                                        Set<String> uniqueItems1 = new HashSet<>();
+                                        if (!current1.isEmpty()) {
+                                            // 鍒嗗壊褰撳墠瀛楃涓插苟鍔犲叆鍒� Set 涓�
+                                            String[] items = current1.split("銆�");
+                                            for (String item : items) {
+                                                if (!item.isEmpty()) {
+                                                    uniqueItems1.add(item);
+                                                }
+                                            }
+                                        }
+                                        // 澶勭悊鏂版暟鎹�
+                                        String newItem1 = p.getInspectionItemEn() +
+                                                ((Objects.equals(p.getInspectionItemSubclassEn(), "") || Objects.equals(p.getInspectionItemSubclassEn(), null)) ? "" : " " + p.getInspectionItemSubclassEn());
+                                        uniqueItems1.add(newItem1);
+                                        // 杩炴帴鍞竴椤瑰苟鏇存柊 AtomicReference
+                                        String result1 = String.join("銆�", uniqueItems1);
+                                        resultEn.set(result1);
+                                        //resultEn.set(resultEn.get() + "銆�" + p.getInspectionItemEn() + ((Objects.equals(p.getInspectionItemSubclassEn(), "") || Objects.equals(p.getInspectionItemSubclassEn(), null)) ? "" : " " + p.getInspectionItemSubclassEn()));
                                         textRenderData.setText("脳");
                                         break;
                                     default:
@@ -978,7 +1157,7 @@
                                 textRenderData.setText(v.get("v") == null ? "" : v.get("v") + "");
                             }
                         } else {
-                            textRenderData.setText(v.get("v") == null ? "" : v.get("v") + "");
+                            textRenderData.setText(v.get("v") == null ? "" : v.get("v") + "鈭�" + jo1.get("mc"));
                         }
                         if (jo1.get("mc") != null) {
                             textRenderData.setText(textRenderData.getText() + "鈭�" + jo1.get("mc"));
@@ -1085,8 +1264,8 @@
                     if (i % number == 0) {
                         List<RowRenderData> rows = new ArrayList<>();
                         //琛ㄦ牸鐨勮鏁� 脳 鈭� 鉁� 鉁�
-                        long count1 = size-(index-1)*number < number ? size-(index-1)*number + 3 : number + 3;
-                        for (int j = 0; j <count1 ; j++) {
+                        long count1 = size - (index - 1) * number < number ? size - (index - 1) * number + 3 : number + 3;
+                        for (int j = 0; j < count1; j++) {
                             RowRenderData rowRenderData = new RowRenderData();
                             RowStyle rowStyle = new RowStyle();
                             rowStyle.setHeight(40);
@@ -1128,8 +1307,7 @@
                                         cellRenderData.setParagraphs(paragraphRenderDataList);
                                         cells.add(cellRenderData);
                                     }
-                                }
-                                else if (j == 1) {
+                                } else if (j == 1) {
                                     //绗簩琛�
                                     if (k == 0) {
                                         //绗竴鍒�
@@ -1172,8 +1350,7 @@
                                         cellRenderData.setParagraphs(paragraphRenderDataList);
                                         cells.add(cellRenderData);
                                     }
-                                }
-                                else if (j == count1-1) {
+                                } else if (j == count1 - 1) {
                                     //鏈�鍚庝竴琛�
                                     if (k == 0 || k == 1) {
                                         //鍓嶄袱鍒�
@@ -1191,8 +1368,7 @@
                                         cellRenderData.setParagraphs(paragraphRenderDataList);
                                         cells.add(cellRenderData);
                                     }
-                                }
-                                else {
+                                } else {
                                     if (k == 0) {
                                         //绗竴鍒�
                                         textRenderData.setText((j - 1) + "");
@@ -1560,7 +1736,7 @@
                     if (i % 16 == 0) {
                         //鏍峰搧鏁伴噺瓒呰繃16闇�瑕佹柊澧炶〃鏍�
                         List<RowRenderData> rows = new ArrayList<>();
-                        int count2 = sampleList.size()-(index41-1)*16 < 16 ? (int) (sampleList.size() - (index41 - 1) * 16 + 1) : 17;
+                        int count2 = sampleList.size() - (index41 - 1) * 16 < 16 ? (int) (sampleList.size() - (index41 - 1) * 16 + 1) : 17;
                         //琛ㄦ牸鐨勮鏁�
                         for (int j = 0; j < count2; j++) {
                             RowRenderData rowRenderData = new RowRenderData();
@@ -1616,8 +1792,7 @@
                                         cellRenderData.setParagraphs(paragraphRenderDataList);
                                         cells.add(cellRenderData);
                                     }
-                                }
-                                else {
+                                } else {
                                     if (k == 0) {
                                         //绗竴鍒�
                                         textRenderData.setText(sampleList.get(0).getModel() + "鈭�44");
@@ -1756,7 +1931,7 @@
             } catch (Exception e) {
                 throw new ErrorException("鎵句笉鍒版楠屼汉鐨勭鍚�");
             }
-            if (signatureUrl.equals("")) {
+            if (ObjectUtils.isEmpty(signatureUrl) || signatureUrl.equals("")) {
                 throw new ErrorException("鎵句笉鍒版楠屼汉鐨勭鍚�");
             }
             //Custom custom = customMapper.selectById(user.get("company"));
@@ -3321,7 +3496,7 @@
                         put("createTime", now.format(DateTimeFormatter.ofPattern("yyyy骞碝M鏈坉d鏃�")));
                         put("createTimeEn", monthNames[now.getMonthValue() - 1] + " " + now.getDayOfMonth() + ", " + now.getYear());
                         put("insTime", insOrder.getInsTime().format(DateTimeFormatter.ofPattern("yyyy骞碝M鏈坉d鏃�")));
-                        put("insTimeEn", monthNames[insOrder.getInsTime().getMonthValue() - 1] + " " + now.getDayOfMonth() + ", " + now.getYear());
+                        put("insTimeEn", monthNames[insOrder.getInsTime().getMonthValue() - 1] + " " + insOrder.getInsTime().getDayOfMonth() + ", " + insOrder.getInsTime().getYear());
                         put("writeUrl", null);
                         put("insUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create());
                         put("images", images);
@@ -3446,6 +3621,10 @@
             } catch (IOException e) {
                 throw new RuntimeException(e);
             }
+        } else {
+            //澶嶆牳涓嶉�氳繃灏嗘妸澶嶆牳鐨勮礋璐d汉鍘绘帀
+            Integer id = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery().eq(InsSampleUser::getInsSampleId, orderId).orderByDesc(InsSampleUser::getId).last("limit 1")).getId();
+            insSampleUserMapper.deleteById(id);
         }
         return 1;
     }
@@ -3477,14 +3656,18 @@
     }
 
     @Override
-    public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode, String sampleCode) {
+    public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode) {
         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()
                 .in(InsProduct::getInsSampleId, ids)
                 .eq(InsProduct::getSonLaboratory, laboratory)
                 .eq(InsProduct::getState, 1)
-                .isNull(InsProduct::getInsResult)
+                .and(wrapper -> wrapper
+                        .isNull(InsProduct::getInsResult)
+                        .or()
+                        .eq(InsProduct::getInsResult, 2)
+                )
                 .isNull(InsProduct::getInsFiberId)
                 .isNull(InsProduct::getInsFibersId));
         insProducts.addAll(insProductMapper.selectFiberInsProduct(ids, laboratory));
@@ -3510,7 +3693,7 @@
                     insProductMapper.updateById(product);
                 }
                 //濡傛灉鏄儹寰幆鎴栬�呮槸娓╁崌璇曢獙
-                else if (product.getInspectionItem().equals("鐑惊鐜�") || product.getInspectionItem().equals("娓╁崌璇曢獙")){
+                else if (product.getInspectionItem().equals("鐑惊鐜�") || product.getInspectionItem().equals("娓╁崌璇曢獙")) {
                     //鏌ヨ杩欎簺椤圭洰涓嬬殑鍏朵粬妫�楠岄」鐩槸鍚﹀叏閮ㄦ楠�
                     List<InsProduct> insProductList = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                             .eq(InsProduct::getInsSampleId, product.getInsSampleId())
@@ -3526,8 +3709,7 @@
                         product.setInsResult(1);
                     }
                     insProductMapper.updateById(product);
-                }
-                else {
+                } else {
                     count++;
                     str += "<br/>" + count + "锛�" + product.getInspectionItem() + " " + product.getInspectionItemSubclass() + "<br/>";
                 }
@@ -3552,23 +3734,26 @@
         InsSampleUser insSampleUser = new InsSampleUser();
         insSampleUser.setUserId(verifyUser);
         insSampleUser.setInsSampleId(orderId);
-        insSampleUser.setState(0);
+        insSampleUser.setState(1);
         insSampleUser.setSonLaboratory(laboratory);
         insSampleUserMapper.insert(insSampleUser);
         /*鏍¢獙涓�涓媟esult琛�*/
         CompletableFuture.supplyAsync(() -> {
             List<Integer> ips = insProducts.stream().map(InsProduct::getId).distinct().collect(Collectors.toList());
             for (Integer ip : ips) {
-                List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, ip).orderByDesc(InsProductResult::getId));
+                List<InsProductResult> insProductResults = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery()
+                        .eq(InsProductResult::getInsProductId, ip));
                 if (insProductResults.size() > 1) {
-                    insProductResultMapper.deleteById(insProductResults.get(0));
+                    for (int i = 1; i < insProductResults.size(); i++) {
+                        insProductResultMapper.deleteById(insProductResults.get(i));
+                    }
                 }
             }
             return null;
         });
         // 鍒犻櫎鏁伴噰閲囬泦娆℃暟
-        String key = "frequency" + ":" + entrustCode + ":" + sampleCode;
-        RedisUtil.del(key);
+        String key = "frequency" + ":" + entrustCode + ":*";
+        RedisUtil.delsLike(key);
         return 1;
     }
 

--
Gitblit v1.9.3