From e07e0f836e64c5795a4819894a8c515f689ad535 Mon Sep 17 00:00:00 2001
From: Crunchy <3114200645@qq.com>
Date: 星期二, 23 七月 2024 17:23:59 +0800
Subject: [PATCH] 数采调整

---
 inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java |   76 ++++++++++++++++++++++++++++----------
 1 files changed, 56 insertions(+), 20 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 192afae..fd75c1a 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
@@ -3,7 +3,6 @@
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.lang.Console;
 import cn.hutool.core.lang.UUID;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
@@ -22,10 +21,11 @@
 import com.deepoove.poi.data.*;
 import com.deepoove.poi.data.style.*;
 import com.deepoove.poi.util.TableTools;
-import com.deepoove.poi.xwpf.WidthScalePattern;
 import com.yuanchu.mom.common.GetLook;
 import com.yuanchu.mom.common.PrintChina;
-import com.yuanchu.mom.dto.*;
+import com.yuanchu.mom.dto.ExcelDto;
+import com.yuanchu.mom.dto.InsOrderPlanDTO;
+import com.yuanchu.mom.dto.SampleProductDto;
 import com.yuanchu.mom.exception.ErrorException;
 import com.yuanchu.mom.mapper.*;
 import com.yuanchu.mom.pojo.*;
@@ -33,22 +33,18 @@
 import com.yuanchu.mom.utils.JackSonUtil;
 import com.yuanchu.mom.utils.MatrixToImageWriter;
 import com.yuanchu.mom.utils.QueryWrappers;
-import com.yuanchu.mom.vo.InsOrderPlanTaskSwitchVo;
-import com.yuanchu.mom.vo.InsOrderPlanVO;
-import com.yuanchu.mom.vo.ProductVo;
-import com.yuanchu.mom.vo.SampleVo;
+import com.yuanchu.mom.utils.RedisUtil;
+import com.yuanchu.mom.vo.*;
 import org.apache.commons.io.IOUtils;
 import org.apache.poi.xwpf.usermodel.*;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
-import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import java.io.*;
-import java.math.BigInteger;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.text.SimpleDateFormat;
@@ -131,7 +127,6 @@
 
     @Resource
     private InsOrderFileMapper insOrderFileMapper;
-
     @Override
     public Map<String, Object> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) {
         Map<String, Object> map = new HashMap<>();
@@ -142,7 +137,8 @@
              userId = map1.get("userId");
             insOrderPlanDTO.setUserId(userId.longValue());
         }
-        IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId);
+        String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//璇曢獙瀹�
+        IPage<InsOrderPlanVO> insOrderPage = insSampleMapper.findInsSampleAndOrder(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory);
         map.put("body", insOrderPage);
         return map;
     }
@@ -156,11 +152,13 @@
         if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) {
             insOrderPlanDTO.setUserId(userId.longValue());
         }
-        IPage<InsOrderPlanTaskSwitchVo> insOrderPage = insSampleMapper.inspectionOrderDetailsTaskSwitching(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId);
+        String sonLaboratory = insOrderPlanDTO.getSonLaboratory();//璇曢獙瀹�
+        IPage<InsOrderPlanTaskSwitchVo> insOrderPage = insSampleMapper.inspectionOrderDetailsTaskSwitching(page, QueryWrappers.queryWrappers(insOrderPlanDTO), userId,sonLaboratory);
         map.put("body", insOrderPage);
         return map;
     }
 
+    //璁ら浠诲姟
     @Override
     public boolean claimInsOrderPlan(InsOrderPlanDTO entity) {
         if (Objects.isNull(entity)) {
@@ -168,7 +166,7 @@
         }
         Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null);
         Integer userId = map1.get("userId");
-        InsSampleUser insSampleUser = new InsSampleUser(entity.getInsSampleId().intValue(), userId, 1);
+        InsSampleUser insSampleUser = new InsSampleUser(entity.getInsSampleId().intValue(), userId, 1,entity.getSonLaboratory());
         return insSampleUserMapper.insert(insSampleUser) > 0;
     }
 
@@ -193,7 +191,7 @@
     }
 
     @Override
-    public List<InsProduct> getInsProduct(Integer id, Integer type, String laboratory) {
+    public List<InsProduct> getInsProduct(Integer id, Integer type, String laboratory, HttpServletRequest request) {
         List<InsProduct> insProducts = new ArrayList<>();
         switch (type) {
             case 0:
@@ -206,10 +204,37 @@
                 insProducts = insSampleMapper.getInsProduct3(id);
                 break;
         }
+        // 鏁伴噰鏂板
+        getDeviceMessage(insProducts, request);
+
         Set<Integer> set = new HashSet<>();
         Map<Integer, String> map2 = new HashMap<>();
         if (BeanUtil.isEmpty(insProducts)) return null;
         getTemplateThing(set, map2, insProducts);
+        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());
+            if (ObjectUtils.isNotEmpty(devices)) {
+                InsProductResult insProductResult = i.getInsProductResult();
+                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;
     }
 
@@ -417,7 +442,7 @@
             productVos = productVos.stream().sorted(Comparator.comparing(productVo -> productVo.getInsProduct().getInspectionItemClass())).collect(Collectors.toList());
         }
         else {
-            //鐢靛姏--鐑惊鐜�
+            //鐢靛姏--鐑惊鐜拰娓╁崌璇曢獙
             List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery()
                     .eq(InsProduct::getInsSampleId, sampleId)
                     .eq(InsProduct::getInspectionItem, inspectionItem));
@@ -544,7 +569,7 @@
                         .eq(AuxiliaryOutputWorkingHours::getInspectionItemSubclass, insProduct.getInspectionItemSubclass())
                         .eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode()));
                 if (count == 0 && ObjectUtils.isNotEmpty(insProduct.getManHour())) {
-                    //娣诲姞姣忎釜浜虹殑浜ч噺宸ユ椂
+                    //娣诲姞姣忎釜浜虹殑浜ч噺宸ユ椂,瑕佸垽鏂綋鍓嶆椂闂存槸鍚︽槸杩欎釜浜虹殑鎺掔彮鏃堕棿,濡傛灉涓嶆槸鍒欐槸鍔犵彮
                     AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours();
                     auxiliaryOutputWorkingHours.setInspectionItem(insProduct.getInspectionItem());//妫�娴嬬埗椤�
                     auxiliaryOutputWorkingHours.setInspectionItemSubclass(insProduct.getInspectionItemSubclass());//妫�娴嬪瓙椤�
@@ -607,12 +632,14 @@
         });
     }
 
+    //浜ゆ帴
     @Override
-    public int upPlanUser(Integer userId, Integer orderId) {
+    public int upPlanUser(Integer userId, Integer orderId,String sonLaboratory) {
         InsSampleUser insSampleUser = new InsSampleUser();
         insSampleUser.setUserId(userId);
         insSampleUser.setInsSampleId(orderId);
         insSampleUser.setState(0);
+        insSampleUser.setSonLaboratory(sonLaboratory);
         return insSampleUserMapper.insert(insSampleUser);
     }
 
@@ -3383,7 +3410,7 @@
     }
 
     @Override
-    public int submitPlan(Integer orderId, String laboratory, Integer verifyUser) {
+    public int submitPlan(Integer orderId, String laboratory, Integer verifyUser, String entrustCode, String sampleCode) {
         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()
@@ -3454,7 +3481,13 @@
         info.setViewStatus(false);
         info.setJumpPath("b1-inspect-order-plan");
         informationNotificationService.addInformationNotification(info);
-        upPlanUser(verifyUser, orderId);
+        //澶嶆牳浜�--妫�楠屽崟鐩稿叧璐熻矗浜�
+        InsSampleUser insSampleUser = new InsSampleUser();
+        insSampleUser.setUserId(verifyUser);
+        insSampleUser.setInsSampleId(orderId);
+        insSampleUser.setState(0);
+        insSampleUser.setSonLaboratory(laboratory);
+         insSampleUserMapper.insert(insSampleUser);
         /*鏍¢獙涓�涓媟esult琛�*/
         CompletableFuture.supplyAsync(() -> {
             List<Integer> ips = insProducts.stream().map(InsProduct::getId).distinct().collect(Collectors.toList());
@@ -3466,6 +3499,9 @@
             }
             return null;
         });
+        // 鍒犻櫎鏁伴噰閲囬泦娆℃暟
+        String key = "frequency" + ":" + entrustCode + ":" + sampleCode;
+        RedisUtil.del(key);
         return 1;
     }
 

--
Gitblit v1.9.3