whycxzp
2022-07-28 8fe657f1d00f27307b51bc609554fe4a996a15ae
src/main/java/com/whyc/service/ProductBomHistoryService.java
@@ -1,8 +1,10 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.dto.Response;
import com.whyc.mapper.ProductBomHistoryMapper;
import com.whyc.pojo.ProductBomHistory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -13,12 +15,27 @@
    @Autowired(required = false)
    private ProductBomHistoryMapper mapper;
    //根据子件名称和母料型号查询历史版本记录
    public Response getBomByPModelAndSName(String pmodel, int sname) {
    public Response getBomHistoryByPModelAndSName(String pmodel, String sname) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("parent_model",pmodel);
        wrapper.eq("sub_code",sname);
        wrapper.eq("sub_name",sname);
        wrapper.orderByAsc("s_version");
        List list=mapper.selectList(wrapper);
        return new Response().setII(1,list.size()>0?true:false,list,"返回数据");
    }
    /**指定版本的产品bom*/
    public List<ProductBomHistory> getListByParentModel(String parentModel, Integer version) {
        QueryWrapper<ProductBomHistory> query = Wrappers.query();
        query.eq("parent_model",parentModel).le("e_version",version).ge("s_version",version);
        return mapper.selectList(query);
    }
    public void addBatch(List<ProductBomHistory> newHistoryList) {
        mapper.insertBatchSomeColumn(newHistoryList);
    }
    public void updateVersionBatch(List<ProductBomHistory> newVersionCurrentHistoryList) {
        mapper.updateVersionBatch(newVersionCurrentHistoryList);
    }
}