From 0e1722e96e5483d560eda8f1cf96282955d4f224 Mon Sep 17 00:00:00 2001 From: zss <zss@example.com> Date: 星期四, 27 七月 2023 15:04:40 +0800 Subject: [PATCH] 检验模块 --- inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/PlanServiceImpl.java | 99 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 96 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..ef612f3 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,28 @@ package com.yuanchu.limslaboratory.service.impl; -import com.yuanchu.limslaboratory.pojo.Plan; -import com.yuanchu.limslaboratory.mapper.PlanMapper; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.yuanchu.limslaboratory.mapper.*; +import com.yuanchu.limslaboratory.pojo.*; +import com.yuanchu.limslaboratory.pojo.dto.InspectionProductListDto; +import com.yuanchu.limslaboratory.pojo.vo.FinPlanVo; +import com.yuanchu.limslaboratory.pojo.vo.PlanVo; +import com.yuanchu.limslaboratory.service.InspectionProductListService; 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 +31,83 @@ @Service public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements PlanService { + @Resource + PlanMapper planMapper; + + @Resource + InspectionProductListMapper inspectionProductListMapper; + + @Resource + InspectionMaterialListMapper inspectionMaterialListMapper; + + @Resource + InspectionProductListService inspectionProductListService; + + //鏌ヨ鎵�鏈夋楠岃鍒掑垎閰� + @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 void delPlan(Integer id) { + Plan plan = planMapper.selectById(id); + + /*妫�楠岃鍒掍綔搴�*/ + //鐘舵�佹敼涓轰綔搴�0 + plan.setState(0); + planMapper.updateById(plan); + + /*妫�楠屾牱鍝佷綔搴�(鏍规嵁鎶ユ鍗昳d鍒犻櫎鏍峰搧淇℃伅)*/ + UpdateWrapper<InspectionMaterialList> wrapper1 = new UpdateWrapper<>(); + wrapper1.eq("inspection_id", plan.getInspectionId()).set("state", 0); + inspectionMaterialListMapper.update(new InspectionMaterialList(), wrapper1); + + /*妫�楠屾牱鍝佷腑鐨勬楠岄」鐩綔搴�*/ + //鏌ュ嚭妫�楠屾牱鍝乮d + LambdaQueryWrapper<InspectionMaterialList> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(InspectionMaterialList::getInspectionId, plan.getInspectionId()); + List<InspectionMaterialList> inspectionMaterialLists = inspectionMaterialListMapper.selectList(queryWrapper); + for (InspectionMaterialList inspectionMaterialList : inspectionMaterialLists) { + UpdateWrapper<InspectionProductList> wrapper = new UpdateWrapper<>(); + wrapper.eq("inspection_material_list_id", inspectionMaterialList.getId()).set("state", 0); + inspectionProductListService.update(new InspectionProductList(), wrapper); + } + } + + //淇敼(鍒嗛厤)妫�楠岃鍒掗噷鍒嗛厤璁″垝鐨勪俊鎭� + @Override + public void upPlan(Integer id, InspectionProductListDto inspectionProductListDto) { + /*鏇存柊璁″垝琛ㄤ腑鐨勭姸鎬�(3:宸插垎閰�),鏇存柊鏃堕棿*/ + //鏌ヨ鎶ユ鍗昳d + InspectionMaterialList inspectionMaterialList = inspectionMaterialListMapper.selectById(id); + 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(); + BeanUtils.copyProperties(inspectionProductListDto, inspectionProductList); + inspectionProductList.setInspectionMaterialListId(id); + //鏍规嵁鎶ユ鏍峰搧id鍜岄」鐩悕绉拌繘琛屾洿鏂版楠岄」鐩〃 + LambdaUpdateWrapper<InspectionProductList> updateWrapper2 = new LambdaUpdateWrapper<>(); + updateWrapper2.eq(InspectionProductList::getInspectionMaterialListId, inspectionProductList.getInspectionMaterialListId()) + .eq(InspectionProductList::getName, inspectionProductList.getName()); + inspectionProductListMapper.update(inspectionProductList, updateWrapper2); + } + + //鏌ヨ鎴愬搧妫�楠� + @Override + public List<FinPlanVo> selectInspection(int pageSize, int countSize, Integer state) { + return planMapper.selectInspection((pageSize - 1) * countSize, pageSize * countSize, state); + } } -- Gitblit v1.9.3