From ee5f64ff15c79240681fc46b0201a293ccaf54ad Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期三, 26 七月 2023 18:02:56 +0800
Subject: [PATCH] 检验模块

---
 inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionServiceImpl.java |   64 +++++++++++++++++++++++---------
 1 files changed, 46 insertions(+), 18 deletions(-)

diff --git a/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionServiceImpl.java b/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionServiceImpl.java
index 0f49d8c..040aa26 100644
--- a/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionServiceImpl.java
+++ b/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionServiceImpl.java
@@ -1,23 +1,28 @@
 package com.yuanchu.limslaboratory.service.impl;
 
+
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.yuanchu.limslaboratory.mapper.InspectionMaterialListMapper;
+import com.yuanchu.limslaboratory.mapper.InspectionProductListMapper;
+import com.yuanchu.limslaboratory.mapper.PlanMapper;
 import com.yuanchu.limslaboratory.pojo.Inspection;
 import com.yuanchu.limslaboratory.mapper.InspectionMapper;
 import com.yuanchu.limslaboratory.pojo.InspectionMaterialList;
 import com.yuanchu.limslaboratory.pojo.InspectionProductList;
+import com.yuanchu.limslaboratory.pojo.Plan;
 import com.yuanchu.limslaboratory.pojo.dto.InspectionDto;
+import com.yuanchu.limslaboratory.service.InspectionProductListService;
 import com.yuanchu.limslaboratory.service.InspectionService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
-
 import javax.annotation.Resource;
-import java.time.LocalDateTime;
+import java.util.Date;
 import java.util.List;
-import java.util.Map;
+
 
 /**
  * <p>
- *  鏈嶅姟瀹炵幇绫�
+ * 鏈嶅姟瀹炵幇绫�
  * </p>
  *
  * @author 姹熻嫃榈烽洀缃戠粶绉戞妧鏈夐檺鍏徃
@@ -29,37 +34,60 @@
     @Resource
     private InspectionMapper inspectionMapper;
 
+    @Resource
+    private PlanMapper planMapper;
+
+    @Resource
+    InspectionMaterialListMapper inspectionMaterialListMapper;
+
+    @Resource
+    InspectionProductListMapper inspectionProductListMapper;
+
+    //娣诲姞妫�楠岀敵璇峰崟
     @Override
-    public Inspection addInspection(String userName,int type) {
-        Inspection inspection = new Inspection(type, 0,1,1, userName);
-        System.out.println(inspection);
+    public Inspection addInspection(String userName, int type) {
+        Inspection inspection = new Inspection(type, 0, 1, 1, userName);
         int judge = inspectionMapper.insert(inspection);
-        System.out.println(judge);
-        return judge>0?inspection:null;
+        return judge > 0 ? inspection : null;
     }
 
+    //鏌ヨ鎵�鏈夋楠屽崟鍒楄〃
     @Override
     public List<InspectionDto> selectAllInspection(int pageSize, int countSize, Integer state) {
-        return inspectionMapper.selectAllInspection((pageSize - 1) * countSize,pageSize * countSize, state);
+        return inspectionMapper.selectAllInspection((pageSize - 1) * countSize, pageSize * countSize, state);
     }
 
+    //浣滃簾鐢宠妫�楠屽崟
     @Override
     public boolean delInspectionByInsId(String inspectionId) {
-        Inspection inspection = new Inspection();
+        //妫�楠屽崟浣滃簾
+        Inspection inspection = inspectionMapper.selectById(inspectionId);
         inspection.setState(0);
-        inspection.setId(inspectionId);
-        int judge = inspectionMapper.updateById(inspection);
-        return judge>0;
+        int judge1 = inspectionMapper.updateById(inspection);
+        //妫�楠岃鍒掍綔搴�
+        UpdateWrapper<Plan> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.eq("inspection_id", inspectionId).set("state", 0);
+        planMapper.update(new Plan(),updateWrapper );
+        //妫�楠屾牱鍝佷綔搴�(鏍规嵁鎶ユ鍗昳d鍒犻櫎鏍峰搧淇℃伅)
+        UpdateWrapper<InspectionMaterialList> wrapper1 = new UpdateWrapper<>();
+        wrapper1.eq("inspection_id", inspectionId).set("state", 0);
+        int judge2 = inspectionMaterialListMapper.update(new InspectionMaterialList(), wrapper1);
+        return judge1 > 0 && judge2 > 0;
+        //妫�楠屾牱鍝佷腑鐨勬楠岄」鐩綔搴�
+        //鏌ュ嚭妫�楠屾牱鍝乮d
 
     }
 
+    //鎻愪氦鐢宠妫�楠屽崟
     @Override
     public boolean subInspectionByInsId(String inspectionId) {
-        Inspection inspection = new Inspection();
+        Inspection inspection = inspectionMapper.selectById(inspectionId);
+        //鐘舵�佹敼涓哄凡鎻愪氦2
         inspection.setState(2);
-        inspection.setId(inspectionId);
-        inspection.setInspectStartTime(LocalDateTime.now());
         int judge = inspectionMapper.updateById(inspection);
-        return judge>0;
+        //璁″垝琛ㄦ柊澧�
+        Plan plan = Plan.builder().inspectionId(inspectionId).state(1).userId(inspection.getInspectUserId()).createTime(new Date()).build();
+        planMapper.insert(plan);
+        return judge > 0;
     }
 }

--
Gitblit v1.9.3