From 8ce578f52d2dc071beb043560baded7803787f07 Mon Sep 17 00:00:00 2001
From: value <z1292839451@163.com>
Date: 星期三, 06 九月 2023 17:36:22 +0800
Subject: [PATCH] 删除鹓雏管理端的时间限制

---
 inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/PlanServiceImpl.java |   59 ++++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/PlanServiceImpl.java b/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/PlanServiceImpl.java
index 94334c3..706aff9 100644
--- a/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/PlanServiceImpl.java
+++ b/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/PlanServiceImpl.java
@@ -1,17 +1,23 @@
 package com.yuanchu.limslaboratory.service.impl;
 
 
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import cn.hutool.core.date.DateUtil;
 import com.yuanchu.limslaboratory.mapper.*;
-import com.yuanchu.limslaboratory.pojo.*;
+import com.yuanchu.limslaboratory.pojo.Inspection;
+import com.yuanchu.limslaboratory.pojo.InspectionProduct;
+import com.yuanchu.limslaboratory.pojo.NonConformanceReview;
+import com.yuanchu.limslaboratory.pojo.Report;
 import com.yuanchu.limslaboratory.service.PlanService;
 import com.yuanchu.limslaboratory.utils.MyUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -41,6 +47,15 @@
 
     @Resource
     InspectionMapper inspectionMapper;
+
+    @Resource
+    InspectionMaterialMapper inspectionMaterialMapper;
+
+    @Resource
+    LinkDetectionMapper linkDetectionMapper;
+
+    @Resource
+    private NonConformanceReviewMapper nonConformanceReviewMapper;
 
     //鏌ヨ妫�楠岃鍒�
     @Override
@@ -75,21 +90,24 @@
     //妫�楠�
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public String check(Integer id, String value) {
-        //濡傛灉妫�楠屽�间笉涓虹┖
-        if (StringUtils.isNotBlank(value)) {
-            InspectionProduct inspectionProduct = inspectionProductMapper.selectById(id);
-            //鍒ゆ柇妫�娴嬪�兼槸鍚︽弧瓒虫爣鍑嗗�煎拰鍐呮帶鍊肩殑瑕佹眰,濡傛灉涓嶆弧瓒冲垯妫�楠岀粨璁轰负涓嶅悎鏍�0
-            String required = inspectionProduct.getRequired();//鏍囧噯鍊�
-            String internal = inspectionProduct.getInternal();//鍐呮帶鍊�
-            inspectionProduct.setTestValue(value);
-            inspectionProduct.setTestState(checkValues(required, internal, value));
-            inspectionProductMapper.updateById(inspectionProduct);
-        } else {
-            //濡傛灉妫�楠屽�间负绌�,灏嗗師鏈夌殑妫�楠岀粨璁鸿鐩栦负null
-            inspectionProductMapper.upda(id);
+    public Integer check(Integer id, String value) {
+        InspectionProduct inspectionProduct = inspectionProductMapper.selectById(id);
+        //鍒ゆ柇妫�娴嬪�兼槸鍚︽弧瓒虫爣鍑嗗�煎拰鍐呮帶鍊肩殑瑕佹眰,濡傛灉涓嶆弧瓒冲垯妫�楠岀粨璁轰负涓嶅悎鏍�0
+        String required = inspectionProduct.getRequired();//鏍囧噯鍊�
+        String internal = inspectionProduct.getInternal();//鍐呮帶鍊�
+        inspectionProduct.setTestValue(value);
+        List<Integer> list = Arrays.stream(value.split(",")).map(s -> {
+            int values = checkValues(required, internal, s);
+            return values;
+        }).collect(Collectors.toList());
+        if (list.contains(0)) {
+            //濡傛灉鍏朵腑涓�涓楠屽�间笉鍚堟牸鍒欒椤圭洰妫�楠屼笉鍚堟牸
+            inspectionProduct.setTestState(0);
+        }else {
+            inspectionProduct.setTestState(1);
         }
-        return "鎻愪氦鎴愬姛!";
+        inspectionProductMapper.updateById(inspectionProduct);
+        return inspectionProduct.getTestState();
     }
 
     //涓婃姤
@@ -101,7 +119,7 @@
         List<Integer> results = inspectionProductMapper.getresult(id);
         int count = 0;
         for (Integer result : results) {
-            if (result != null && result==1) {
+            if (result != null && result == 1) {
                 count++;
             }
         }
@@ -110,7 +128,13 @@
             Inspection inspection = new Inspection();
             inspection.setId(id);
             inspection.setInspectionStatus(0);
+            //鏇存柊妫�楠屽崟
             inspectionMapper.updateById(inspection);
+            //娣诲姞涓嶅悎鏍间俊鎭埌璇勫
+            NonConformanceReview nonConformanceReview = new NonConformanceReview();
+            LocalDateTime localDateTime = DateUtil.toLocalDateTime(DateUtil.date());
+            nonConformanceReview.setCreatedTime(localDateTime);
+            nonConformanceReview.setUpdatedTime(localDateTime);
         } else if (count == results.size()) {
             Inspection inspection = new Inspection();
             inspection.setId(id);
@@ -133,6 +157,7 @@
         report.setStatus(0);
         report.setConclusion(conclusion);
         report.setInspectionId(id);
+        //鏂板妫�楠屾姤鍛�
         reportMapper.insert(report);
         return "涓婃姤鎴愬姛!";
     }

--
Gitblit v1.9.3