XiaoRuby
2023-07-26 30f6da8bf0143906b42fa600f6a604cea6c81f71
inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionMaterialListServiceImpl.java
@@ -1,15 +1,13 @@
package com.yuanchu.limslaboratory.service.impl;
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.pojo.InspectionMaterialList;
import com.yuanchu.limslaboratory.pojo.InspectionProductList;
import com.yuanchu.limslaboratory.pojo.Plan;
import com.yuanchu.limslaboratory.pojo.Product;
import com.yuanchu.limslaboratory.pojo.*;
import com.yuanchu.limslaboratory.service.InspectionMaterialListService;
import com.yuanchu.limslaboratory.service.InspectionProductListService;
import com.yuanchu.limslaboratory.service.PlanService;
@@ -39,13 +37,18 @@
    ProductMapper productMapper;
    @Resource
    InspectionProductListService inspectionProductListService;
    @Resource
    InspectionProductListMapper inspectionProductListMapper;
    //查询检验单里面的物料信息
    @Override
    public List<InspectionMaterialList> selectInspectionMaterialListByInsId(String insId) {
        return inspectionMaterialListMapper.selectInspectionMaterialListByInsId(insId);
    }
    //添加检验单中的检验样品
    @Override
    @Transactional(rollbackFor = Exception.class)
    public InspectionMaterialList addInspectionMaterialList(InspectionMaterialList inspectionMaterialList,String userId) {
@@ -55,7 +58,6 @@
        list.forEach(a-> {
            InspectionProductList inspectionProductList = new InspectionProductList();
            inspectionProductList.setName(a.getName())
                    .setMethod(a.getMethod())
                    .setUnit(a.getUnit())
                    .setRequired(a.getRequired())
                    .setInternal(a.getInternal())
@@ -64,20 +66,32 @@
                    .setUserId(Integer.parseInt(userId));
            list1.add(inspectionProductList);
        });
        //添加检验项目
        int judge2 = inspectionProductListMapper.addInspectionProductList(list1);
        return judge>0&&judge2>0?inspectionMaterialList:null;
    }
    //根据样品id删除检验样品
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delInspectionMaterialListByInsId(int inspectionMaterialListId) {
        //删除检验样品
        InspectionMaterialList list = new InspectionMaterialList();
        list.setState(0);
        list.setId(inspectionMaterialListId);
        int judge1 = inspectionMaterialListMapper.updateById(list);
        UpdateWrapper<InspectionProductList> wrapper = new UpdateWrapper<>();
        wrapper.eq("inspection_material_list_id", inspectionMaterialListId).set("state", 0);
        int judge2 = inspectionProductListMapper.update(new InspectionProductList(), wrapper);
        //根据样品id删除检验样品中的检验项目
        int judge2 = inspectionProductListService.delInspectionProductList(inspectionMaterialListId);
        return judge1>0&&judge2>0;
    }
    //根据样品id修改样品信息
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateInspectionMaterialList( Integer inspectionMaterialListId,InspectionMaterialList inspectionMaterialList) {
        LambdaUpdateWrapper<InspectionMaterialList> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(InspectionMaterialList::getId,inspectionMaterialListId);
        int judge = inspectionMaterialListMapper.update(inspectionMaterialList, updateWrapper);
        return judge>0;
    }
}