自动化立体仓库 - WMS系统
zyx
2023-07-14 f1223c78a7b93d89017c26770390ef446cc57ac6
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
package com.zy.asrs.service.impl;
 
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zy.asrs.entity.AgvLocMast;
import com.zy.asrs.entity.AgvLocRule;
import com.zy.asrs.mapper.AgvLocMastMapper;
import com.zy.asrs.service.AgvLocMastService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
@Service
@Transactional
public class AgvLocMastServiceImpl extends ServiceImpl<AgvLocMastMapper, AgvLocMast> implements AgvLocMastService {
 
    @Autowired
    AgvLocMastMapper agvLockMastMapper;
 
    public void clearLoc(){
        agvLockMastMapper.deleteAll();
    }
 
    public void initLocFloor1() {
        //1楼 13排 86列 12层
        List<AgvLocMast> agvLocMastList = getLocMastList(1,13,1,86,1,12,1);
        this.insertBatch(agvLocMastList);
    }
 
 
    public void initLocFloor3() {
        //3楼 1-33排 1-14列 8层
        this.insertBatch(getLocMastList(1, 33, 1, 14, 1, 8, 3));
 
        //3楼 1-27排 15-34列 8层
        this.insertBatch(getLocMastList(1, 27, 15, 34, 1, 8, 3));
 
        //3楼 1-25排 35-46列 8层
        this.insertBatch(getLocMastList(1, 25, 35, 46, 1, 8, 3));
 
        //3楼 3-25排 47-60列 8层
        this.insertBatch(getLocMastList(3, 25, 47, 60, 1, 8, 3));
 
        //3楼 4-25排 61-70列 8层
        this.insertBatch(getLocMastList(4, 25, 61, 70, 1, 8, 3));
 
    }
 
    //根据排列层获取AGV库位列表
    private List<AgvLocMast> getLocMastList(int rowIndex, int rowMax, int bayIndex, int bayMax, int levIndex, int levMax, int floor){
        List<AgvLocMast> agvLocMastList = new ArrayList<>();
        Date now = new Date();
        for(int row=rowIndex; row<=rowMax; row++) {
            for (int bay = bayIndex; bay <= bayMax; bay++) {
                for (int lev = levIndex; lev <= levMax; lev++) {
                    AgvLocMast loc = new AgvLocMast();
                    String locRow = row < 10 ? "-00" + row : "-0" + row;
                    String locBay = bay < 10 ? "-00" + bay : "-0" + bay;
                    String locLev = lev < 10 ? "-0" + lev : "-" + lev;
                    String locNo = "SK" + locRow + locBay + locLev + "@" + floor;
                    loc.setLocNo(locNo);
                    loc.setLocSts("O");
                    loc.setRow1(row);
                    loc.setBay1(bay);
                    loc.setLev1(lev);
                    loc.setFloor(floor);
                    loc.setModiTime(now);
                    loc.setFirstTime(now);
                    loc.setAppeTime(now);
                    agvLocMastList.add(loc);
                }
            }
        }
 
        return  agvLocMastList;
    }
 
    @Override
    public List<AgvLocMast> queryFreeLocMast2(Short locType1, Integer rowBeg, Integer rowEnd, Integer bayBeg, Integer bayEnd, Integer levBeg, Integer levEnd) {
        return this.baseMapper.queryFreeLocMast2(locType1, rowBeg, rowEnd, bayBeg, bayEnd, levBeg, levEnd);
    }
 
    @Override
    public void updateLocType2ByRBL(Integer locType2, AgvLocRule locRule) {
        this.baseMapper.updateLocType2(locType2,locRule.getRowBeg(),locRule.getRowEnd(),locRule.getBayBeg(),locRule.getBayEnd(),locRule.getLevBeg(),locRule.getLevEnd(),locRule.getFloor());
    }
 
}