自动化立体仓库 - WCS系统
#
Junjie
2025-01-08 1ff4b70e59b8c9ceb80d0a695d26b4419ed349f1
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
package com.zy.asrs.controller;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.annotations.ManagerAuth;
import com.core.common.R;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.MapNode;
import com.zy.common.utils.NavigateMapData;
import com.zy.core.enums.LocStsType;
import com.zy.core.enums.MapNodeType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
 
@Slf4j
@RestController
@RequestMapping("/locMast")
public class LocMastController {
 
    @Autowired
    private NavigateMapData navigateMapData;
    @Autowired
    private LocMastService locMastService;
 
    @PostMapping("/init")
    @ManagerAuth(memo = "初始化库位")
    @Transactional
    public R shuttleStateTable(){
        locMastService.delete(new EntityWrapper<>(new LocMast()));
 
        for (int i = 1; i <= 4; i++) {//总共四层楼
            List<List<MapNode>> lists = navigateMapData.getJsonData(i, -1, null, null);//获取完整地图(包括入库出库)
 
            for (int row = 0; row < lists.size(); row++) {
                List<MapNode> nodeList = lists.get(row);
                for (int bay = 0; bay < nodeList.size(); bay++) {
                    MapNode mapNode = nodeList.get(bay);
 
                    if (mapNode.getValue() == MapNodeType.DISABLE.id) {
                        continue;
                    }
 
                    String locNo = Utils.getLocNo(row, bay, i);
                    LocMast locMast = new LocMast();
                    locMast.setLocNo(locNo);
                    locMast.setRow1(row);
                    locMast.setBay1(bay);
                    locMast.setLev1(i);
 
                    if (mapNode.getValue() == MapNodeType.NORMAL_PATH.id) {
                        locMast.setLocSts(LocStsType.O.toString());
                    }else if (mapNode.getValue() == MapNodeType.MAIN_PATH.id){
                        locMast.setLocSts(LocStsType.W.toString());
                    }
 
                    locMastService.insert(locMast);
                }
            }
        }
 
        return R.ok();
    }
 
}