zss
2023-07-26 ee5f64ff15c79240681fc46b0201a293ccaf54ad
inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionServiceImpl.java
@@ -3,22 +3,26 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yuanchu.limslaboratory.mapper.InspectionMaterialListMapper;
import com.yuanchu.limslaboratory.mapper.InspectionProductListMapper;
import com.yuanchu.limslaboratory.mapper.PlanMapper;
import com.yuanchu.limslaboratory.pojo.Inspection;
import com.yuanchu.limslaboratory.mapper.InspectionMapper;
import com.yuanchu.limslaboratory.pojo.InspectionMaterialList;
import com.yuanchu.limslaboratory.pojo.InspectionProductList;
import com.yuanchu.limslaboratory.pojo.Plan;
import com.yuanchu.limslaboratory.pojo.dto.InspectionDto;
import com.yuanchu.limslaboratory.service.InspectionProductListService;
import com.yuanchu.limslaboratory.service.InspectionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
 * <p>
 *  服务实现类
 * 服务实现类
 * </p>
 *
 * @author 江苏鵷雏网络科技有限公司
@@ -36,18 +40,21 @@
    @Resource
    InspectionMaterialListMapper inspectionMaterialListMapper;
    @Resource
    InspectionProductListMapper inspectionProductListMapper;
    //添加检验申请单
    @Override
    public Inspection addInspection(String userName,int type) {
        Inspection inspection = new Inspection(type, 0,1,1, userName);
    public Inspection addInspection(String userName, int type) {
        Inspection inspection = new Inspection(type, 0, 1, 1, userName);
        int judge = inspectionMapper.insert(inspection);
        return judge>0?inspection:null;
        return judge > 0 ? inspection : null;
    }
    //查询所有检验单列表
    @Override
    public List<InspectionDto> selectAllInspection(int pageSize, int countSize, Integer state) {
        return inspectionMapper.selectAllInspection((pageSize - 1) * countSize,pageSize * countSize, state);
        return inspectionMapper.selectAllInspection((pageSize - 1) * countSize, pageSize * countSize, state);
    }
    //作废申请检验单
@@ -57,11 +64,18 @@
        Inspection inspection = inspectionMapper.selectById(inspectionId);
        inspection.setState(0);
        int judge1 = inspectionMapper.updateById(inspection);
        //检验计划作废
        UpdateWrapper<Plan> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("inspection_id", inspectionId).set("state", 0);
        planMapper.update(new Plan(),updateWrapper );
        //检验样品作废(根据报检单id删除样品信息)
        UpdateWrapper<InspectionMaterialList> wrapper = new UpdateWrapper<>();
        wrapper.eq("inspection_id", inspectionId).set("state", 0);
        int judge2 = inspectionMaterialListMapper.update(new InspectionMaterialList(),wrapper);
        return judge1>0&&judge2>0;
        UpdateWrapper<InspectionMaterialList> wrapper1 = new UpdateWrapper<>();
        wrapper1.eq("inspection_id", inspectionId).set("state", 0);
        int judge2 = inspectionMaterialListMapper.update(new InspectionMaterialList(), wrapper1);
        return judge1 > 0 && judge2 > 0;
        //检验样品中的检验项目作废
        //查出检验样品id
    }
    //提交申请检验单
@@ -72,8 +86,8 @@
        inspection.setState(2);
        int judge = inspectionMapper.updateById(inspection);
        //计划表新增
        Plan plan = Plan.builder().inspectionId(inspectionId).state(1).build();
        Plan plan = Plan.builder().inspectionId(inspectionId).state(1).userId(inspection.getInspectUserId()).createTime(new Date()).build();
        planMapper.insert(plan);
        return judge>0;
        return judge > 0;
    }
}