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/PlanServiceImpl.java |   95 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 92 insertions(+), 3 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 ba9c8cf..285a465 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,14 +1,29 @@
 package com.yuanchu.limslaboratory.service.impl;
 
-import com.yuanchu.limslaboratory.pojo.Plan;
-import com.yuanchu.limslaboratory.mapper.PlanMapper;
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.yuanchu.limslaboratory.mapper.*;
+import com.yuanchu.limslaboratory.pojo.*;
+import com.yuanchu.limslaboratory.pojo.dto.InspectionProductListDto;
+import com.yuanchu.limslaboratory.pojo.dto.PlanDto;
+import com.yuanchu.limslaboratory.pojo.vo.PlanVo;
 import com.yuanchu.limslaboratory.service.PlanService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+
 
 /**
  * <p>
- *  鏈嶅姟瀹炵幇绫�
+ * 鏈嶅姟瀹炵幇绫�
  * </p>
  *
  * @author 姹熻嫃榈烽洀缃戠粶绉戞妧鏈夐檺鍏徃
@@ -17,4 +32,78 @@
 @Service
 public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements PlanService {
 
+    @Resource
+    PlanMapper planMapper;
+
+    @Resource
+    InspectionProductListMapper inspectionProductListMapper;
+
+    @Resource
+    InspectionMaterialListMapper inspectionMaterialListMapper;
+
+    @Resource
+    UserMapper userMapper;
+
+    @Resource
+    InstrumentMapper instrumentMapper;
+
+    //鏌ヨ鎵�鏈夋楠岃鍒掑垎閰�
+    @Override
+    public List<PlanVo> selectAllPlan(int pageSize, int countSize, Integer state) {
+        if (state == null) {
+            state = 2;
+        }
+        return planMapper.selectAllPlan((pageSize - 1) * countSize, pageSize * countSize, state);
+    }
+
+    //浣滃簾妫�楠岃鍒�
+    @Override
+    public boolean delPlan(Integer id) {
+        Plan plan = planMapper.selectById(id);
+        //鐘舵�佹敼涓轰綔搴�0
+        plan.setState(0);
+        int judge = planMapper.updateById(plan);
+        return judge > 0;
+    }
+
+    //淇敼(鍒嗛厤)妫�楠岃鍒掗噷鍒嗛厤璁″垝鐨勪俊鎭�
+    @Override
+    public void upPlan(InspectionProductListDto inspectionProductListDto) {
+        /*鏇存柊璁″垝琛ㄤ腑鐨勭姸鎬�(3:宸插垎閰�),鏇存柊鏃堕棿*/
+        //鏌ヨ鎶ユ鍗昳d
+        InspectionMaterialList inspectionMaterialList = inspectionMaterialListMapper.selectById(inspectionProductListDto.getInspectionMaterialListId());
+        LambdaQueryWrapper<Plan> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Plan::getInspectionId, inspectionMaterialList.getInspectionId());
+        Plan plan = planMapper.selectOne(queryWrapper);
+        plan.setState(3).setUpdateTime(new Date());
+        //鏍规嵁鎶ユ鍗昳d杩涜鏇存柊璁″垝琛�
+        LambdaUpdateWrapper<Plan> updateWrapper1 = new LambdaUpdateWrapper<>();
+        updateWrapper1.eq(Plan::getInspectionId, plan.getInspectionId());
+        planMapper.update(plan, updateWrapper1);
+
+        /*鏇存柊妫�楠岄」鐩〃涓殑椤圭洰妫�楠屽紑濮嬫棩鏈�,椤圭洰妫�楠岀粨鏉熸棩鏈�,椤圭洰璇曢獙鍛�,璇曢獙瑕佹眰,鏇存柊鏃堕棿,璁惧id*/
+        InspectionProductList inspectionProductList = new InspectionProductList();
+        //澶嶅埗涔嬪悗,inspectionProductList閲岄潰鏈夐」鐩楠屽紑濮嬨�佺粨鏉熸棩鏈�,椤圭洰鍚嶇О,璇曢獙鏂规硶,璇曢獙瑕佹眰,鍗曚綅,
+        BeanUtils.copyProperties(inspectionProductListDto, inspectionProductList);
+        //鏍规嵁璁惧鍚嶈幏鍙栬澶噄d
+        LambdaQueryWrapper<Instrument> wrapper1 = new LambdaQueryWrapper<>();
+        wrapper1.eq(Instrument::getEquipmentName, inspectionProductListDto.getInstrumentName());
+        Instrument instrument = instrumentMapper.selectOne(wrapper1);
+        //鏍规嵁鐢ㄦ埛鍚嶈幏鍙栫敤鎴穒d
+        LambdaQueryWrapper<User> wrapper2 = new LambdaQueryWrapper<>();
+        wrapper2.eq(User::getName, inspectionProductListDto.getUserName());
+        User user = userMapper.selectOne(wrapper2);
+        inspectionProductList.setUpdateTime(new Date()).setUserId(user.getId()).setInstrumentId(instrument.getId());
+        //鏍规嵁鎶ユ鏍峰搧id鍜岄」鐩悕绉拌繘琛屾洿鏂版楠岄」鐩〃
+        LambdaUpdateWrapper<InspectionProductList> updateWrapper2 = new LambdaUpdateWrapper<>();
+        updateWrapper2.eq(InspectionProductList::getInspectionMaterialListId, inspectionProductList.getInspectionMaterialListId())
+                .eq(InspectionProductList::getName, inspectionProductList.getName());
+        inspectionProductListMapper.update(inspectionProductList, updateWrapper2);
+    }
+
+    //鏌ヨ鎴愬搧妫�楠�
+    @Override
+    public List<PlanDto> selectInspection(int pageSize, int countSize, Integer state) {
+        return planMapper.selectInspection((pageSize - 1) * countSize, pageSize * countSize, state);
+    }
 }

--
Gitblit v1.9.3