From a33396e17dd847f31b62f416f7d9c5a58b79126b Mon Sep 17 00:00:00 2001
From: XiaoRuby <3114200645@qq.com>
Date: 星期五, 28 七月 2023 09:02:29 +0800
Subject: [PATCH] LIMS管理系统框架-开发7-28早上
---
inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionMaterialListServiceImpl.java | 71 ++++++++++++++++++-----------------
1 files changed, 36 insertions(+), 35 deletions(-)
diff --git a/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionMaterialListServiceImpl.java b/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionMaterialListServiceImpl.java
index c7ed1f0..52ddc13 100644
--- a/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionMaterialListServiceImpl.java
+++ b/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionMaterialListServiceImpl.java
@@ -3,14 +3,14 @@
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.yuanchu.limslaboratory.mapper.InspectionMaterialListMapper;
-import com.yuanchu.limslaboratory.mapper.InspectionProductListMapper;
-import com.yuanchu.limslaboratory.mapper.PlanMapper;
-import com.yuanchu.limslaboratory.mapper.ProductMapper;
+import com.yuanchu.limslaboratory.mapper.*;
import com.yuanchu.limslaboratory.pojo.*;
+import com.yuanchu.limslaboratory.pojo.dto.InspectionMaterialListDto;
import com.yuanchu.limslaboratory.service.InspectionMaterialListService;
import com.yuanchu.limslaboratory.service.InspectionProductListService;
import com.yuanchu.limslaboratory.service.PlanService;
+import com.yuanchu.limslaboratory.vo.Result;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -21,7 +21,7 @@
/**
* <p>
- * 鏈嶅姟瀹炵幇绫�
+ * 鏈嶅姟瀹炵幇绫�
* </p>
*
* @author 姹熻嫃榈烽洀缃戠粶绉戞妧鏈夐檺鍏徃
@@ -37,59 +37,60 @@
ProductMapper productMapper;
@Resource
- InspectionProductListMapper inspectionProductListMapper;
+ InspectionProductListService inspectionProductListService;
+
+ //鏌ヨ妫�楠屽崟閲岄潰鐨勬牱鍝佷俊鎭�
@Override
public List<InspectionMaterialList> selectInspectionMaterialListByInsId(String insId) {
return inspectionMaterialListMapper.selectInspectionMaterialListByInsId(insId);
}
+ //娣诲姞妫�楠屽崟涓殑妫�楠屾牱鍝�
@Override
@Transactional(rollbackFor = Exception.class)
- public InspectionMaterialList addInspectionMaterialList(InspectionMaterialList inspectionMaterialList,String userId) {
- int judge = inspectionMaterialListMapper.insert(inspectionMaterialList);
- List<Product> list = productMapper.selectProductByMaterialId(inspectionMaterialList.getMaterialId());
- List<InspectionProductList> list1 = new ArrayList<>();
- list.forEach(a-> {
- InspectionProductList inspectionProductList = new InspectionProductList();
- inspectionProductList.setName(a.getName())
- .setMethod(a.getMethod())
- .setUnit(a.getUnit())
- .setRequired(a.getRequired())
- .setInternal(a.getInternal())
- .setState(1)
- .setInspectionMaterialListId(inspectionMaterialList.getId())
- .setUserId(Integer.parseInt(userId));
- list1.add(inspectionProductList);
- });
- int judge2 = inspectionProductListMapper.addInspectionProductList(list1);
- return judge>0&&judge2>0?inspectionMaterialList:null;
+ public void addInspectionMaterialList(InspectionMaterialList inspectionMaterialList, String userId) {
+ inspectionMaterialListMapper.insert(inspectionMaterialList);
+ List<Product> list = productMapper.selectProductByMaterialId(inspectionMaterialList.getMaterialId());
+ List<InspectionProductList> list1 = new ArrayList<>();
+ list.forEach(a -> {
+ InspectionProductList inspectionProductList = new InspectionProductList();
+ inspectionProductList.setName(a.getName())
+ .setUnit(a.getUnit())
+ .setRequired(a.getRequired())
+ .setInternal(a.getInternal())
+ .setState(1)
+ .setInspectionMaterialListId(inspectionMaterialList.getId())
+ .setUserId(Integer.parseInt(userId));
+ list1.add(inspectionProductList);
+ });
+ //娣诲姞妫�楠岄」鐩�
+ inspectionProductListService.saveBatch(list1);
}
//鏍规嵁鏍峰搧id鍒犻櫎妫�楠屾牱鍝�
@Override
@Transactional(rollbackFor = Exception.class)
- public boolean delInspectionMaterialListByInsId(int inspectionMaterialListId) {
+ public void delInspectionMaterialListByInsId(int inspectionMaterialListId) {
//鍒犻櫎妫�楠屾牱鍝�
InspectionMaterialList list = new InspectionMaterialList();
list.setState(0);
list.setId(inspectionMaterialListId);
- int judge1 = inspectionMaterialListMapper.updateById(list);
- //鍒犻櫎鏍峰搧妫�楠岄」鐩�
+ inspectionMaterialListMapper.updateById(list);
+ //鏍规嵁鏍峰搧id鍒犻櫎妫�楠屾牱鍝佷腑鐨勬楠岄」鐩�
UpdateWrapper<InspectionProductList> wrapper = new UpdateWrapper<>();
wrapper.eq("inspection_material_list_id", inspectionMaterialListId).set("state", 0);
- int judge2 = inspectionProductListMapper.update(new InspectionProductList(), wrapper);
- return judge1>0&&judge2>0;
+ inspectionProductListService.update(new InspectionProductList(), wrapper);
}
- //淇敼鏍峰搧淇℃伅
+ //鏍规嵁鏍峰搧id淇敼鏍峰搧淇℃伅
@Override
@Transactional(rollbackFor = Exception.class)
- public boolean updateInspectionMaterialList( Integer inspectionMaterialListId,InspectionMaterialList inspectionMaterialList) {
+ public void updateInspectionMaterialList(Integer inspectionMaterialListId, InspectionMaterialListDto inspectionMaterialListDto) {
+ InspectionMaterialList inspectionMaterialList = new InspectionMaterialList();
+ BeanUtils.copyProperties(inspectionMaterialListDto,inspectionMaterialList);
LambdaUpdateWrapper<InspectionMaterialList> updateWrapper = new LambdaUpdateWrapper<>();
- //鏍规嵁鏍峰搧id鏌ヨ
- updateWrapper.eq(InspectionMaterialList::getId,inspectionMaterialListId);
- int judge = inspectionMaterialListMapper.update(inspectionMaterialList, updateWrapper);
- return judge>0;
+ updateWrapper.eq(InspectionMaterialList::getId, inspectionMaterialListId);
+ inspectionMaterialListMapper.update(inspectionMaterialList, updateWrapper);
}
}
--
Gitblit v1.9.3