From 12ecef99059f411e802c6fbc6f9a641c422b1747 Mon Sep 17 00:00:00 2001
From: Crunchy <3114200645@qq.com>
Date: 星期六, 03 八月 2024 22:34:20 +0800
Subject: [PATCH] 数采bug修复

---
 inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java |  110 +++++++++++++++++++++++++++++--------------------------
 1 files changed, 58 insertions(+), 52 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 692c498..ed89e30 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
@@ -139,14 +139,27 @@
     public Map<String, Object> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) {
         Map<String, Object> map = new HashMap<>();
         map.put("head", PrintChina.printChina(InsOrderPlanVO.class));
-        Integer userId = null;
+        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;
+            }
+        }
+        Integer userId =null;
         if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId()) ) {
-            Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null);
-             userId = map1.get("userId");
+            userId = map1.get("userId");
             insOrderPlanDTO.setUserId(userId.longValue());
         }
         String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//璇曢獙瀹�
-        IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory);
+        IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory,laboratory);
         map.put("body", insOrderPage);
         return map;
     }
@@ -157,11 +170,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;
     }
@@ -212,8 +238,6 @@
                 insProducts = insSampleMapper.getInsProduct3(id);
                 break;
         }
-        // 鏁伴噰鏂板
-        getDeviceMessage(insProducts, request);
 
         Set<Integer> set = new HashSet<>();
         Map<Integer, String> map2 = new HashMap<>();
@@ -222,33 +246,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());
-            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<>();
@@ -399,7 +396,7 @@
                                 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);
                                 }
@@ -432,7 +429,7 @@
                         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);
@@ -497,6 +494,7 @@
                     result = results.get(0);
                 }
                 result.setInsProductId(Integer.parseInt(k));
+                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<>();
@@ -597,7 +595,14 @@
                         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()
                                 .eq(AuxiliaryOutputWorkingHours::getCheck, userId)
@@ -610,15 +615,9 @@
                                 .eq(AuxiliaryOutputWorkingHours::getInspectionItem, insProduct.getInspectionItem())
                                 .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, insProduct.getInspectionItemSubclass())
                                 .eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode()));
-                        AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours();
-                        if (ObjectUtils.isNotEmpty(count1) ){
-                             auxiliaryOutputWorkingHours = count1;
-                        }
-                        else if (ObjectUtils.isNotEmpty(count2) ){
-                             auxiliaryOutputWorkingHours = count2;
-                        }
-                        if (ObjectUtils.isNotEmpty(insProduct.getManHour())) {
-                            if (isWithinRange && ObjectUtils.isEmpty(count2)) {
+                        if (ObjectUtils.isNotEmpty(insProduct.getManHour())&& ObjectUtils.isEmpty(count2) && ObjectUtils.isEmpty(count1)) {
+                            AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours();
+                            if (isWithinRange) {
                                 //鍦ㄦ椂闂村唴灏辨槸姝e父涓婄彮
                                 auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//妫�娴嬬埗椤�
                                 auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//妫�娴嬪瓙椤�
@@ -636,7 +635,7 @@
                                 auxiliaryOutputWorkingHours.setWeekDay(getWeek(localDateTime.format(formatters)));//鏄熸湡
                                 auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//鍛ㄦ
                                 auxiliaryOutputWorkingHours.setCheck(userId);//妫�娴嬩汉
-                            } else if(ObjectUtils.isEmpty(count1)) {
+                            } else {
                                 //鍔犵彮
                                 auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//妫�娴嬬埗椤�
                                 auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//妫�娴嬪瓙椤�
@@ -655,7 +654,9 @@
                                 auxiliaryOutputWorkingHours.setWeek(String.valueOf(DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1))));//鍛ㄦ
                                 auxiliaryOutputWorkingHours.setCheck(userId);//妫�娴嬩汉
                             }
-                            auxiliaryOutputWorkingHoursService.saveOrUpdate(auxiliaryOutputWorkingHours);
+                            if (ObjectUtils.isEmpty(insProductResult) && !result.getInsValue().equals("[]") || (ObjectUtils.isNotEmpty(insProductResult) && !insProductResult.getInsValue().equals(result.getInsValue()) && !insProductResult.getInsValue().equals("[]"))) {
+                                auxiliaryOutputWorkingHoursMapper.insert(auxiliaryOutputWorkingHours);
+                            }
                         }
                     }
                 }
@@ -1759,7 +1760,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"));
@@ -3450,6 +3451,11 @@
                 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;
     }
 
@@ -3480,7 +3486,7 @@
     }
 
     @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()
@@ -3570,8 +3576,8 @@
             return null;
         });
         // 鍒犻櫎鏁伴噰閲囬泦娆℃暟
-        String key = "frequency" + ":" + entrustCode + ":" + sampleCode;
-        RedisUtil.del(key);
+        String key = "frequency" + ":" + entrustCode + ":*";
+        RedisUtil.delsLike(key);
         return 1;
     }
 

--
Gitblit v1.9.3