whyclxw
3 天以前 29aed8c1fde9c1fc6d248ba8028914e038442306
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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.MaterialProductHistoryMapper;
import com.whyc.pojo.MaterialProductApproving;
import com.whyc.pojo.MaterialProductHistory;
import com.whyc.pojo.ProductBom;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service
public class MaterialProductHistoryService {
    @Autowired(required = false)
    private MaterialProductHistoryMapper mapper;
    //增加散装件和产品之间替换关系
    public Response addMaterialConnectBom(List<MaterialProductHistory> list) {
        int bl=mapper.insertBatchSomeColumn(list);
        return new Response().setII(1,true,bl,bl>0?"添加关联成功":"添加关联失败");
    }
 
    public List<MaterialProductHistory> getListByParentModel(String parentModel, int currentVersion) {
        QueryWrapper<MaterialProductHistory> query = Wrappers.query();
        query.eq("parent_model",parentModel).le("s_version",currentVersion).ge("e_version",currentVersion);
        return mapper.selectList(query);
    }
 
    public void updateVersionBatch(List<MaterialProductHistory> cphList) {
        mapper.updateVersionBatch(cphList);
    }
 
    public void insertBatch(List<MaterialProductHistory> newHistoryList) {
        mapper.insertBatchSomeColumn(newHistoryList);
    }
 
    public List<MaterialProductHistory> getLatestExistListByMaterialId(Integer materialId) {
        return mapper.getLatestExistListByMaterialId(materialId);
    }
 
    /**
     *  解除关联:
     *  终止版本-1即可
     * @param removedList 解除关联列表
     */
    public void updateVersionSubtractBatch(List<MaterialProductApproving> removedList) {
        mapper.updateVersionSubtractBatch(removedList);
    }
 
    public List<MaterialProductHistory> getListByParentCodeAndCustomCodeAndVersion(String parentCode, String customCode, Integer version) {
        QueryWrapper<MaterialProductHistory> query = Wrappers.query();
        query.eq("parent_code",parentCode).eq("custom_code",customCode)
                .le("s_version",version)
                .ge("e_version",version);
        return mapper.selectList(query);
    }
 
    public List<MaterialProductHistory> getListWithMaterialInfo(List<MaterialProductHistory> mpList) {
        return mapper.getListWithMaterialInfo(mpList);
    }
 
    public List<MaterialProductHistory> getListByParentCodeAndCustomCodeAndSubMaterialIdAndVersion(String parentCode, String customCode, List<ProductBom> bomList, int currentVersion) {
        return mapper.getListByParentCodeAndCustomCodeAndSubMaterialIdAndVersion(parentCode,customCode,bomList,currentVersion);
    }
}