cuijian
2023-08-19 bdd0875d4b13a3f1ef472f64d4b6a95e0ef64b22
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package org.jeecg.modules.base.service.impl;
 
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.base.entity.ProductionLineWarehouse;
import org.jeecg.modules.base.entity.Warehouse;
import org.jeecg.modules.base.mapper.ProductionLineWarehouseClientMapper;
import org.jeecg.modules.base.mapper.ProductionLineWarehouseMapper;
import org.jeecg.modules.base.service.IProductionLineWarehouseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.*;
 
/**
 * @Description: 线边库管理
 * @Author: jeecg-boot
 * @Date:   2023-01-28
 * @Version: V1.0
 */
@Service
public class ProductionLineWarehouseServiceImpl extends ServiceImpl<ProductionLineWarehouseMapper, ProductionLineWarehouse> implements IProductionLineWarehouseService {
 
    @Autowired
    private ProductionLineWarehouseMapper productionLineWarehouseMapper;
    @Autowired
    private ProductionLineWarehouseClientMapper productionLineWarehouseClientMapper;
 
    @Override
    public Integer getInitVersion() {
        List<ProductionLineWarehouse> usableVersionList = productionLineWarehouseMapper.getUsableList();
        Set<Integer> allVersionList = getVersionList();
        if(CollectionUtils.isNotEmpty(usableVersionList)){
            return usableVersionList.get(0).getVersion();
        }else if(CollectionUtils.isNotEmpty(allVersionList)){
            return allVersionList.stream().findFirst().get();
        }
        return null;
    }
 
    @Override
    public Page<Map<String, Object>> getWarehouseList(Page<Map<String, Object>> page, Integer version, String workshopId) {
        return page.setRecords(productionLineWarehouseMapper.getWarehouseList(page,version,workshopId));
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delMain(String id) {
        productionLineWarehouseClientMapper.deleteByMainId(id);
        productionLineWarehouseMapper.deleteById(id);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delBatchMain(Collection<? extends Serializable> idList) {
        for(Serializable id:idList) {
            productionLineWarehouseClientMapper.deleteByMainId(id.toString());
            productionLineWarehouseMapper.deleteById(id);
        }
    }
 
    @Override
    public Set<Integer> getVersionList() {
        Set<Integer> set = new TreeSet<Integer>(Comparator.reverseOrder());
        set.addAll(productionLineWarehouseMapper.getAllVersion());
        return set;
    }
 
    @Override
    public List<ProductionLineWarehouse> getLastUsableList() {
        return productionLineWarehouseMapper.getLastUsableList();
    }
 
    @Override
    public List<ProductionLineWarehouse> getUsableList() {
        return productionLineWarehouseMapper.getUsableList();
    }
 
    @Override
    public Map<String, Object> getNowAndLastUsableVersion() {
        List<ProductionLineWarehouse> usableList = productionLineWarehouseMapper.getUsableList();
        List<ProductionLineWarehouse> lastUsableList = productionLineWarehouseMapper.getLastUsableList();
        Map<String,Object> map = new HashMap<>(2);
        if(CollectionUtils.isNotEmpty(usableList)){
            map.put("usableVersion",usableList.get(0).getVersion());
        }
        if(CollectionUtils.isNotEmpty(lastUsableList)){
            map.put("lastUsableVersion",lastUsableList.get(0).getVersion());
        }
        return map;
    }
 
    @Override
    public List<String> getVersionStatusByVersion(Integer version) {
        return productionLineWarehouseMapper.getVersionStatusByVersion(version);
    }
 
}