#
Junjie
2024-05-24 4dcdd93603aad2ab27ee4976a6dd7b5d47dd5da4
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
package com.zy.asrs.common.wms.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.common.wms.mapper.LocDirectionMapper;
import com.zy.asrs.common.wms.entity.LocDirection;
import com.zy.asrs.common.wms.service.LocDirectionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
@Service("locDirectionService")
public class LocDirectionServiceImpl extends ServiceImpl<LocDirectionMapper, LocDirection> implements LocDirectionService {
 
    @Override
    public List<ArrayList<Integer>> getInnerList(Long hostId) {
        List<LocDirection> inner = this.list(new LambdaQueryWrapper<LocDirection>()
                .eq(LocDirection::getHostId, hostId)
                .eq(LocDirection::getType, "inner"));
        return this.parseData(inner);
    }
 
    @Override
    public List<ArrayList<Integer>> getOuterList(Long hostId) {
        List<LocDirection> outer = this.list(new LambdaQueryWrapper<LocDirection>()
                .eq(LocDirection::getHostId, hostId)
                .eq(LocDirection::getType, "outer"));
        return this.parseData(outer);
    }
 
    @Override
    public List<ArrayList<Integer>> getNaturalList(Long hostId) {
        List<LocDirection> natural = this.list(new LambdaQueryWrapper<LocDirection>()
                .eq(LocDirection::getHostId, hostId)
                .eq(LocDirection::getType, "natural"));
        return this.parseData(natural);
    }
 
    @Override
    public List<ArrayList<Integer>> parseData(List<LocDirection> origin) {
        ArrayList<ArrayList<Integer>> data = new ArrayList<>();
        for (LocDirection direction : origin) {
            ArrayList<Integer> list = new ArrayList<>();
            String[] split = direction.getData().split(",");
            for (String row : split) {
                list.add(Integer.parseInt(row));
            }
            data.add(list);
        }
        return data;
    }
 
    @Override
    public boolean isAsc(Integer row, String direction, Long hostId) {
        List<ArrayList<Integer>> list = null;
        if(direction.equals("inner")){
            list = this.getInnerList(hostId);
        } else if (direction.equals("outer")) {
            list = this.getOuterList(hostId);
        }else {
            list = this.getNaturalList(hostId);
        }
 
        ArrayList<Integer> obj = null;
        for (ArrayList<Integer> arrayList : list) {
            if(arrayList.contains(row)){
                obj = arrayList;
                break;
            }
        }
 
        if (obj != null && obj.size() >= 2) {
            Integer i0 = obj.get(0);
            Integer i1 = obj.get(1);
            return i0 - i1 < 0;
        }
 
        return false;
    }
}