whycxzp
2022-07-28 8fe657f1d00f27307b51bc609554fe4a996a15ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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;
 
import java.util.List;
 
@Service
public class ProductBomHistoryService {
    @Autowired(required = false)
    private ProductBomHistoryMapper mapper;
    //根据子件名称和母料型号查询历史版本记录
    public Response getBomHistoryByPModelAndSName(String pmodel, String sname) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("parent_model",pmodel);
        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);
    }
}