zss
2023-07-27 0e1722e96e5483d560eda8f1cf96282955d4f224
inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/PlanServiceImpl.java
@@ -1,22 +1,28 @@
package com.yuanchu.limslaboratory.service.impl;
import com.yuanchu.limslaboratory.mapper.InspectionMaterialListMapper;
import com.yuanchu.limslaboratory.mapper.InspectionProductListMapper;
import com.yuanchu.limslaboratory.pojo.InspectionMaterialList;
import com.yuanchu.limslaboratory.pojo.InspectionProductList;
import com.yuanchu.limslaboratory.pojo.Plan;
import com.yuanchu.limslaboratory.mapper.PlanMapper;
import com.yuanchu.limslaboratory.pojo.dto.PlanDto;
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 江苏鵷雏网络科技有限公司
@@ -29,30 +35,79 @@
    PlanMapper planMapper;
    @Resource
    InspectionProductListMapper inspectionProductListMapper;
    @Resource
    InspectionMaterialListMapper inspectionMaterialListMapper;
    @Resource
    InspectionProductListMapper inspectionProductListMapper;
    InspectionProductListService inspectionProductListService;
    //查询所有检验计划
    //查询所有检验计划分配
    @Override
    public List<PlanDto> selectAllPlan(int pageSize, int countSize, Integer state) {
        return planMapper.selectAllPlan((pageSize - 1) * countSize,pageSize * countSize, state);
    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) {
    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 List<InspectionProductList> selectById(Integer id) {
       return inspectionProductListMapper.selectByMaterId(id);
    public void upPlan(Integer id, InspectionProductListDto inspectionProductListDto) {
        /*更新计划表中的状态(3:已分配),更新时间*/
        //查询报检单id
        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());
        //根据报检单id进行更新计划表
        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);
    }
}