自动化立体仓库 - WMS系统
#
luxiaotao1123
2022-09-20 0fc40840534f1010147982db2c3df6908f19aa00
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package com.zy.asrs.service.impl;
 
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.core.common.Cools;
import com.zy.asrs.entity.LocDetl;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.mapper.LocMastMapper;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.RowLastnoService;
import com.zy.asrs.service.WorkService;
import com.zy.asrs.utils.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
 
@Service("locMastService")
public class LocMastServiceImpl extends ServiceImpl<LocMastMapper, LocMast> implements LocMastService {
 
    @Autowired
    private RowLastnoService rowLastnoService;
    @Autowired
    private WorkService workService;
 
    @Override
    public List<LocMast> queryFreeLocMast(List<Integer> rows, Integer rowsLen, Short locType1) {
        return this.baseMapper.queryFreeLocMast(rows, rowsLen, locType1);
    }
 
    @Override
    public List<String> queryGroupEmptyStock(String sourceLocNo) {
        if (Cools.isEmpty(sourceLocNo)) {
            return null;
        }
        LocMast sourceStock = this.selectById(sourceLocNo);
        if (Cools.isEmpty(sourceStock)) {
            return null;
        }
        return this.baseMapper.queryGroupEmptyStock(sourceStock.getCrnNo());
    }
 
    @Override
    public Boolean checkEmptyCount(LocMast locMast) {
        if (locMast == null) {
            return false;
        }
        return this.baseMapper.selectEmptyLocCount(locMast.getLocType1(), locMast.getCrnNo()) > 1;
    }
 
    @Override
    public Boolean checkWhole(List<LocDetl> locDetls) {
        return null;
    }
 
    @Override
    public Boolean isOutMost(String locNo, Boolean pakin) {
        return Integer.parseInt(locNo.substring(0, 2)) == Utils.getOutermostRow(locNo, true);
    }
 
    @Override
    public LocMast findOutMost(List<String> locNos) {
        List<Integer> rows = locNos.stream().map(item -> Integer.parseInt(item.substring(0, 2))).distinct().collect(Collectors.toList());
        if (!rows.retainAll(new ArrayList<Integer>() {{ add(1);add(2);add(3);}})) {
            locNos.sort(Comparator.comparingInt(o -> Integer.parseInt(o.substring(0, 2))));
        } else {
            rows = locNos.stream().map(item -> Integer.parseInt(item.substring(0, 2))).distinct().collect(Collectors.toList());
        }
 
        if (!rows.retainAll(new ArrayList<Integer>() {{ add(8);add(9);add(10);add(11);}})) {
            locNos.sort(Comparator.comparingInt(o -> Integer.parseInt(o.substring(0, 2))));
        } else {
            rows = locNos.stream().map(item -> Integer.parseInt(item.substring(0, 2))).distinct().collect(Collectors.toList());
        }
 
        if (!rows.retainAll(new ArrayList<Integer>() {{ add(15);add(16);add(17);add(18);}})) {
            locNos.sort(Comparator.comparingInt(o -> Integer.parseInt(o.substring(0, 2))));
        } else {
            rows = locNos.stream().map(item -> Integer.parseInt(item.substring(0, 2))).distinct().collect(Collectors.toList());
        }
 
        if (!rows.retainAll(new ArrayList<Integer>() {{ add(4);add(5);add(6);add(7);}})) {
            locNos.sort((o1, o2) -> Integer.parseInt(o2.substring(0, 2)) - Integer.parseInt(o1.substring(0, 2)));
        } else {
            rows = locNos.stream().map(item -> Integer.parseInt(item.substring(0, 2))).distinct().collect(Collectors.toList());
        }
 
        if (!rows.retainAll(new ArrayList<Integer>() {{ add(12);add(13);add(14);}})) {
            locNos.sort((o1, o2) -> Integer.parseInt(o2.substring(0, 2)) - Integer.parseInt(o1.substring(0, 2)));
        } else {
            rows = locNos.stream().map(item -> Integer.parseInt(item.substring(0, 2))).distinct().collect(Collectors.toList());
        }
 
        if (!rows.retainAll(new ArrayList<Integer>() {{ add(19);add(20);add(21);}})) {
            locNos.sort((o1, o2) -> Integer.parseInt(o2.substring(0, 2)) - Integer.parseInt(o1.substring(0, 2)));
        } else {
            rows = locNos.stream().map(item -> Integer.parseInt(item.substring(0, 2))).distinct().collect(Collectors.toList());
        }
 
//        if (!rows.retainAll(new ArrayList<Integer>() {{ add(1);add(2);add(3);}})
//                || !rows.retainAll(new ArrayList<Integer>() {{ add(8);add(9);add(10);add(11);}})
//                || !rows.retainAll(new ArrayList<Integer>() {{ add(15);add(16);add(17);add(18);}})
//        ) {
//            locNos.sort(Comparator.comparingInt(o -> Integer.parseInt(o.substring(0, 2))));
//        } else if (!rows.retainAll(new ArrayList<Integer>() {{ add(4);add(5);add(6);add(7);}})
//                || !rows.retainAll(new ArrayList<Integer>() {{ add(12);add(13);add(14);}})
//                || !rows.retainAll(new ArrayList<Integer>() {{ add(19);add(20);add(21);}})
//        ) {
//            locNos.sort((o1, o2) -> Integer.parseInt(o2.substring(0, 2)) - Integer.parseInt(o1.substring(0, 2)));
//        }
        for (String locNo : locNos) {
            LocMast locMast = this.selectById(locNo);
            if (locMast.getLocSts().equals("O")) {
                return locMast;
            }
        }
        return null;
    }
 
    @Override
    public synchronized void breakUp(String locNo, List<String> excludeLocNos) {
        List<String> groupLoc = Utils.getGroupOuterLoc(locNo);
        Iterator<String> iterator = groupLoc.iterator();
        while (iterator.hasNext()) {
            String next = iterator.next();
            LocMast locMast = this.selectById(next);
            if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D") || excludeLocNos.contains(locMast.getLocNo())) {
                continue;
            }
            iterator.remove();
        }
        workService.shuttleTransfer(groupLoc);
    }
 
}