zss
2023-07-27 0e1722e96e5483d560eda8f1cf96282955d4f224
inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/PlanServiceImpl.java
@@ -1,16 +1,15 @@
package com.yuanchu.limslaboratory.service.impl;
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.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.dto.PlanDto;
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;
@@ -42,10 +41,7 @@
    InspectionMaterialListMapper inspectionMaterialListMapper;
    @Resource
    UserMapper userMapper;
    @Resource
    InstrumentMapper instrumentMapper;
    InspectionProductListService inspectionProductListService;
    //查询所有检验计划分配
    @Override
@@ -58,20 +54,37 @@
    //作废检验计划
    @Override
    public boolean delPlan(Integer id) {
    public void delPlan(Integer id) {
        Plan plan = planMapper.selectById(id);
        /*检验计划作废*/
        //状态改为作废0
        plan.setState(0);
        int judge = planMapper.updateById(plan);
        return judge > 0;
        planMapper.updateById(plan);
        /*检验样品作废(根据报检单id删除样品信息)*/
        UpdateWrapper<InspectionMaterialList> wrapper1 = new UpdateWrapper<>();
        wrapper1.eq("inspection_id", plan.getInspectionId()).set("state", 0);
        inspectionMaterialListMapper.update(new InspectionMaterialList(), wrapper1);
        /*检验样品中的检验项目作废*/
        //查出检验样品id
        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(InspectionProductListDto inspectionProductListDto) {
    public void upPlan(Integer id, InspectionProductListDto inspectionProductListDto) {
        /*更新计划表中的状态(3:已分配),更新时间*/
        //查询报检单id
        InspectionMaterialList inspectionMaterialList = inspectionMaterialListMapper.selectById(inspectionProductListDto.getInspectionMaterialListId());
        InspectionMaterialList inspectionMaterialList = inspectionMaterialListMapper.selectById(id);
        LambdaQueryWrapper<Plan> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Plan::getInspectionId, inspectionMaterialList.getInspectionId());
        Plan plan = planMapper.selectOne(queryWrapper);
@@ -83,17 +96,8 @@
        /*更新检验项目表中的项目检验开始日期,项目检验结束日期,项目试验员,试验要求,更新时间,设备id*/
        InspectionProductList inspectionProductList = new InspectionProductList();
        //复制之后,inspectionProductList里面有项目检验开始、结束日期,项目名称,试验方法,试验要求,单位,
        BeanUtils.copyProperties(inspectionProductListDto, inspectionProductList);
        //根据设备名获取设备id
        LambdaQueryWrapper<Instrument> wrapper1 = new LambdaQueryWrapper<>();
        wrapper1.eq(Instrument::getEquipmentName, inspectionProductListDto.getInstrumentName());
        Instrument instrument = instrumentMapper.selectOne(wrapper1);
        //根据用户名获取用户id
        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());
        inspectionProductList.setInspectionMaterialListId(id);
        //根据报检样品id和项目名称进行更新检验项目表
        LambdaUpdateWrapper<InspectionProductList> updateWrapper2 = new LambdaUpdateWrapper<>();
        updateWrapper2.eq(InspectionProductList::getInspectionMaterialListId, inspectionProductList.getInspectionMaterialListId())
@@ -103,7 +107,7 @@
    //查询成品检验
    @Override
    public List<PlanDto> selectInspection(int pageSize, int countSize, Integer state) {
    public List<FinPlanVo> selectInspection(int pageSize, int countSize, Integer state) {
        return planMapper.selectInspection((pageSize - 1) * countSize, pageSize * countSize, state);
    }
}