From bb9499352faae20bb2c898f3f6078f7a4e9ceef2 Mon Sep 17 00:00:00 2001
From: value <z1292839451@163.com>
Date: 星期五, 19 四月 2024 10:17:19 +0800
Subject: [PATCH] 检验项目数据导入;检验模板调整

---
 inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java |   63 ++++++++++++++++++-------------
 1 files changed, 36 insertions(+), 27 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 12d2730..b3eda3a 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
@@ -91,6 +91,9 @@
     @Resource
     private InsProductResultMapper insProductResultMapper;
 
+    @Resource
+    private InsProductUserMapper insProductUserMapper;
+
     @Override
     public Map<String, Object> selectInsOrderPlanList(Page page, InsOrderPlanDTO insOrderPlanDTO) {
         Map<String, Object> map = new HashMap<>();
@@ -144,7 +147,6 @@
     public void saveInsContext(Map<String, Object> insContext) {
         Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId");
         CompletableFuture.supplyAsync(() -> {
-            AtomicInteger count = new AtomicInteger();
             insContext.forEach((k, v) -> {
                 JSONObject jo = JSON.parseObject(JSON.toJSONString(v));
                 InsProduct insProduct = new InsProduct();
@@ -154,7 +156,7 @@
                     result = new InsProductResult();
                 }
                 result.setInsProductId(Integer.parseInt(k));
-                if(jo.get("insValue") != null){
+                if (jo.get("insValue") != null) {
                     JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(jo.get("insValue")));
                     List<Map<String, Object>> iv = new ArrayList<>();
                     for (Object o : jsonArray) {
@@ -168,11 +170,12 @@
                                 map.put("u", insValue.get("u"));
                             }
                             iv.add(map);
-                        }catch (Exception e){}
+                        } catch (Exception e) {
+                        }
                     }
                     result.setInsValue(JSON.toJSONString(iv));
                 }
-                if(jo.get("comValue") != null){
+                if (jo.get("comValue") != null) {
                     JSONArray jsonArray2 = JSON.parseArray(JSON.toJSONString(jo.get("comValue")));
                     List<Map<String, Object>> cv = new ArrayList<>();
                     for (Object o : jsonArray2) {
@@ -184,7 +187,7 @@
                     result.setComValue(JSON.toJSONString(cv));
                 }
                 JSONObject resValue = JSON.parseObject(JSON.toJSONString(jo.get("resValue")));
-                if(resValue.get("v")!=null){
+                if (resValue.get("v") != null) {
                     insProduct.setLastValue(JSON.parseObject(JSON.toJSONString(resValue.get("v"))).get("v") + "");
                 }
                 JSONObject equipValue = JSON.parseObject(JSON.toJSONString(jo.get("equipValue")));
@@ -206,11 +209,17 @@
                 }
                 insProduct.setUpdateUser(userId);
                 insProductMapper.updateById(insProduct);
-                if (count.get() == 0) {
-                    InsSample insSample = insSampleMapper.selectById(insProductMapper.selectById(insProduct.getId()).getInsSampleId());
-                    insSample.setInsState(1);
-                    count.addAndGet(1);
+                insProductUserMapper.insert(new InsProductUser(null, userId, LocalDateTime.now(), insProduct.getId()));
+                InsSample insSample = insSampleMapper.selectById(insProductMapper.selectById(insProduct.getId()).getInsSampleId());
+                insSample.setInsState(1);
+                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));
+                if (l == l1) {
+                    insSample.setInsState(2);
                 }
+                insSampleMapper.updateById(insSample);
             });
             return null;
         }).thenAccept(res -> {
@@ -251,11 +260,11 @@
             samples.forEach(a -> {
                 Set<String> templateSet = new HashSet<>();
                 getTemplateThing(set, map2, a);
-                a.getInsProduct().forEach(b->{
-                    String[] split = b.getMethod().replaceAll("]", "").replaceAll("\\[","").replaceAll("\"","").split(",");
+                a.getInsProduct().forEach(b -> {
+                    String[] split = b.getMethod().replaceAll("]", "").replaceAll("\\[", "").replaceAll("\"", "").split(",");
                     standardMethod.addAll(Arrays.asList(split));
-                    if(b.getInsProductResult()!=null){
-                        if(b.getInsProductResult().getEquipValue()!=null&& !Objects.equals(b.getInsProductResult().getEquipValue(), "")){
+                    if (b.getInsProductResult() != null) {
+                        if (b.getInsProductResult().getEquipValue() != null && !Objects.equals(b.getInsProductResult().getEquipValue(), "")) {
                             deviceSet.add(b.getInsProductResult().getEquipValue());
                         }
                     }
@@ -265,7 +274,7 @@
                     templateSet.add(JSON.toJSONString(b.getTemplate()));
                 });
                 AtomicInteger index = new AtomicInteger();
-                templateSet.forEach(tem->{
+                templateSet.forEach(tem -> {
                     Set<Integer> set2 = new HashSet<>();
                     List<RowRenderData> rows = new ArrayList<>();
                     List<TextRenderData> text = new ArrayList<>();
@@ -283,15 +292,15 @@
                             if ("妫�楠屽瓙椤�".equals(JSON.parseObject(JSON.toJSONString(v.get("ps"))).get("value") + "")) {
                                 int count2 = 0;
                                 for (InsProduct p : a.getInsProduct()) {
-                                    if(v.get("v").equals(p.getInspectionItemSubclass())){
-                                        pMap.put(jo1.get("r")+"", p);
+                                    if (v.get("v").equals(p.getInspectionItemSubclass())) {
+                                        pMap.put(jo1.get("r") + "", p);
                                         break;
-                                    }else{
+                                    } else {
                                         count2++;
                                     }
                                 }
-                                if(count2 == a.getInsProduct().size()){
-                                    delRSet.add(jo1.get("r")+"");
+                                if (count2 == a.getInsProduct().size()) {
+                                    delRSet.add(jo1.get("r") + "");
                                 }
                             }
                         }
@@ -315,7 +324,7 @@
                         }
                         JSONObject v = JSON.parseObject(JSON.toJSONString(jo1.get("v")));
                         InsProduct p = pMap.get(jo1.get("r") + "");
-                        if (p!=null && v.get("ps") != null) {
+                        if (p != null && v.get("ps") != null) {
                             String value = JSON.parseObject(JSON.toJSONString(v.get("ps"))).get("value") + "";
                             if (value.equals("瑕佹眰鍊�")) {
                                 textRenderData.setText(p.getAsk());
@@ -350,7 +359,7 @@
                             } else {
                                 textRenderData.setText(v.get("v") == null ? "" : v.get("v") + "");
                             }
-                        } else if (p==null && v.get("ps") != null) {
+                        } else if (p == null && v.get("ps") != null) {
                             String value = JSON.parseObject(JSON.toJSONString(v.get("ps"))).get("value") + "";
                             p = pMap.get(pMap.keySet().iterator().next());
                             if (value.equals("鏈�缁堝��")) {
@@ -427,8 +436,8 @@
             for (String s : standardMethod) {
                 standardMethod2.append("銆�").append(s);
             }
-            standardMethod2.replace(0, 1,"");
-            tables.forEach(table->{
+            standardMethod2.replace(0, 1, "");
+            tables.forEach(table -> {
                 table.put("tableSize", tables.size() + 1);
             });
             List<Map<String, String>> deviceList = insOrderMapper.selectDeviceList(deviceSet);
@@ -439,8 +448,8 @@
             codeStr.put("鍙戞斁鏃ユ湡", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
             String codePath;
             try {
-                codePath = new MatrixToImageWriter().code(JackSonUtil.marshal(codeStr).replaceAll("\\{","")
-                        .replaceAll("}","").replaceAll(",","").replaceAll("\"",""), twoCode);
+                codePath = new MatrixToImageWriter().code(JackSonUtil.marshal(codeStr).replaceAll("\\{", "")
+                        .replaceAll("}", "").replaceAll(",", "").replaceAll("\"", ""), twoCode);
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }
@@ -491,8 +500,8 @@
                 Map<String, Object> style = new HashMap<>();
                 style.put("rowlen", config.get("rowlen"));
                 style.put("columnlen", config.get("columnlen"));
-//                int r = -1;
-                /*if (BeanUtil.isNotEmpty(cellData)) {
+                /*int r = -1;
+                if (BeanUtil.isNotEmpty(cellData)) {
                     for (JSONObject o : cellData) {
                         JSONObject v = JSON.parseObject(JSON.toJSONString(o.get("v")));
                         tableData.add(o);

--
Gitblit v1.9.3