From 87794ed4e7b7cf7b13f7deef5da3e3ff03255d81 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期日, 04 八月 2024 23:01:09 +0800
Subject: [PATCH] 检验任务负责人展示修改

---
 inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java |  192 +++++++++++++++++++++++++-----------------------
 1 files changed, 100 insertions(+), 92 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 64661c5..97e187c 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,34 @@
 
     @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);
+        IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userName, sonLaboratory, laboratory);
         map.put("body", insOrderPage);
         return map;
     }
@@ -157,11 +173,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 +203,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;
     }
 
@@ -212,8 +241,6 @@
                 insProducts = insSampleMapper.getInsProduct3(id);
                 break;
         }
-        // 鏁伴噰鏂板
-        getDeviceMessage(insProducts, request);
 
         Set<Integer> set = new HashSet<>();
         Map<Integer, String> map2 = new HashMap<>();
@@ -222,32 +249,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());
-            }
-        });
-        return insProducts;
-    }
     @Override
     public List<String> checkSubmitPlan(Integer orderId, String laboratory) {
         List<String> collect = new ArrayList<>();
@@ -326,9 +327,9 @@
                 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()) {
+                    if (insProducts.size() == collect.size()) {
                         insFiber.setState(1);//宸叉楠�
-                    }else {
+                    } else {
                         insFiber.setState(0);//鏈楠�
                     }
                 }
@@ -338,9 +339,9 @@
                 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()) {
+                    if (insProducts.size() == collect.size()) {
                         insFiber.setState(1);//宸叉楠�
-                    }else {
+                    } else {
                         insFiber.setState(0);//鏈楠�
                     }
                 }
@@ -351,9 +352,9 @@
                 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()) {
+                    if (insProducts.size() == collect.size()) {
                         insFiber.setState(1);//宸叉楠�
-                    }else {
+                    } else {
                         insFiber.setState(0);//鏈楠�
                     }
                 }
@@ -376,7 +377,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) {
                 //鍐嶆煡璇㈠嚭鎵�鏈夌殑鍏夌氦甯�
@@ -398,18 +399,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);
@@ -417,8 +418,7 @@
                             }
                         }
                     }
-                }
-                else {
+                } else {
                     //濡傛灉濂楃涓嬫病鏈夊厜绾ゅ甫灏卞彧鏈夊厜绾や簡
                     List<InsFiber> insFiberList = insFiberMapper.selectList(Wrappers.<InsFiber>lambdaQuery().eq(InsFiber::getInsBushingId, insBushing.getId()));
                     for (InsFiber fiber : insFiberList) {
@@ -431,17 +431,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]);
                             }
@@ -452,8 +452,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)
@@ -496,6 +495,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<>();
@@ -536,6 +536,7 @@
                         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")));
@@ -564,6 +565,7 @@
                     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);
@@ -588,15 +590,22 @@
                 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()
                                 .eq(AuxiliaryOutputWorkingHours::getCheck, userId)
@@ -609,15 +618,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());//妫�娴嬪瓙椤�
@@ -625,7 +628,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");
@@ -635,7 +638,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());//妫�娴嬪瓙椤�
@@ -643,7 +646,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");
@@ -654,7 +657,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);
+                            }
                         }
                     }
                 }
@@ -703,7 +708,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);
@@ -1087,8 +1092,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);
@@ -1130,8 +1135,7 @@
                                         cellRenderData.setParagraphs(paragraphRenderDataList);
                                         cells.add(cellRenderData);
                                     }
-                                }
-                                else if (j == 1) {
+                                } else if (j == 1) {
                                     //绗簩琛�
                                     if (k == 0) {
                                         //绗竴鍒�
@@ -1174,8 +1178,7 @@
                                         cellRenderData.setParagraphs(paragraphRenderDataList);
                                         cells.add(cellRenderData);
                                     }
-                                }
-                                else if (j == count1-1) {
+                                } else if (j == count1 - 1) {
                                     //鏈�鍚庝竴琛�
                                     if (k == 0 || k == 1) {
                                         //鍓嶄袱鍒�
@@ -1193,8 +1196,7 @@
                                         cellRenderData.setParagraphs(paragraphRenderDataList);
                                         cells.add(cellRenderData);
                                     }
-                                }
-                                else {
+                                } else {
                                     if (k == 0) {
                                         //绗竴鍒�
                                         textRenderData.setText((j - 1) + "");
@@ -1562,7 +1564,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();
@@ -1618,8 +1620,7 @@
                                         cellRenderData.setParagraphs(paragraphRenderDataList);
                                         cells.add(cellRenderData);
                                     }
-                                }
-                                else {
+                                } else {
                                     if (k == 0) {
                                         //绗竴鍒�
                                         textRenderData.setText(sampleList.get(0).getModel() + "鈭�44");
@@ -1758,7 +1759,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"));
@@ -3448,6 +3449,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;
     }
@@ -3479,14 +3484,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));
@@ -3512,7 +3521,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())
@@ -3528,8 +3537,7 @@
                         product.setInsResult(1);
                     }
                     insProductMapper.updateById(product);
-                }
-                else {
+                } else {
                     count++;
                     str += "<br/>" + count + "锛�" + product.getInspectionItem() + " " + product.getInspectionItemSubclass() + "<br/>";
                 }
@@ -3554,7 +3562,7 @@
         InsSampleUser insSampleUser = new InsSampleUser();
         insSampleUser.setUserId(verifyUser);
         insSampleUser.setInsSampleId(orderId);
-        insSampleUser.setState(0);
+        insSampleUser.setState(1);
         insSampleUser.setSonLaboratory(laboratory);
         insSampleUserMapper.insert(insSampleUser);
         /*鏍¢獙涓�涓媟esult琛�*/
@@ -3569,8 +3577,8 @@
             return null;
         });
         // 鍒犻櫎鏁伴噰閲囬泦娆℃暟
-        String key = "frequency" + ":" + entrustCode + ":" + sampleCode;
-        RedisUtil.del(key);
+        String key = "frequency" + ":" + entrustCode + ":*";
+        RedisUtil.delsLike(key);
         return 1;
     }
 

--
Gitblit v1.9.3