自动化立体仓库 - WCS系统
#
taisheng
2025-02-25 a2bf670143f51ce7fc9ae77ba0c4f113fca5f0e4
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
package com.zy.asrs.controller;
 
import com.alibaba.fastjson.JSON;
import com.core.annotations.ManagerAuth;
import com.core.common.Cools;
import com.core.common.R;
import com.zy.asrs.domain.param.SystemSwitchParam;
import com.zy.asrs.entity.BasMap;
import com.zy.asrs.service.BasMapService;
import com.zy.common.model.MapNode;
import com.zy.common.model.enums.NavigationMapType;
import com.zy.common.utils.NavigateMapData;
import com.zy.common.utils.RedisUtil;
import com.zy.core.enums.RedisKeyType;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.properties.SystemProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.util.*;
 
/**
 * 主控图接口
 * Created by vincent on 2020-06-01
 */
@Slf4j
@RestController
@RequestMapping("/console")
public class ConsoleController {
 
    @Autowired
    private SlaveProperties slaveProperties;
    @Autowired
    private BasMapService basMapService;
    @Autowired
    private RedisUtil redisUtil;
    @Value("${super.pwd}")
    private String superPwd;
    @Autowired
    private NavigateMapData navigateMapData;
 
    @PostMapping("/system/running/status")
    @ManagerAuth(memo = "系统运行状态")
    public R systemRunningStatus(){
        return R.ok().add(Cools.add("status", SystemProperties.WCS_RUNNING_STATUS.get()));
    }
 
    @PostMapping("/system/switch")
    @ManagerAuth(memo = "系统运行开关操作")
    public R systemSwitch(SystemSwitchParam param) throws InterruptedException {
        if (Cools.isEmpty(param.getOperatorType())){
            return R.error();
        }
        if (param.getOperatorType() == 0) {
            if (Cools.isEmpty(param.getPassword())){
                return R.error("请输入口令");
            }
            if (!param.getPassword().equals(SystemProperties.WCS_PASSWORD)){
                return R.error("口令错误");
            }
        }
        Thread.sleep(200L);
        SystemProperties.WCS_RUNNING_STATUS.set(param.getOperatorType()==1?Boolean.TRUE:Boolean.FALSE);
        return R.ok().add(Cools.add("status", SystemProperties.WCS_RUNNING_STATUS.get()));
    }
 
    /**
     * 获取地图数据
     */
    @GetMapping("/map/{lev}/auth")
    @ManagerAuth
    public R getMapFromRedis(@PathVariable Integer lev) {
        Object data = redisUtil.get(RedisKeyType.MAP.key + lev);
        if (data == null) {
            return R.error();
        }
 
        BasMap basMap = JSON.parseObject(data.toString(), BasMap.class);
        //解析json地图数据
        ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class);
        List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.NONE.id, arrayList, lev, null, null);//过滤地图数据
        return R.ok().add(lists);
    }
 
    /**
     * 重置redis中的地图,将占用的库位全部解除
     */
    @GetMapping("/map/resetMap/auth")
    @ManagerAuth
    public R resetMapToRedis() {
        for (int i = 1; i <= 10; i++) {//总共10层楼
            redisUtil.del(RedisKeyType.MAP.key + i);
        }
        return R.ok();
    }
 
    /**
     * 重置redis中的地图,将占用的库位全部解除
     */
    @GetMapping("/map/resetMap/{lev}")
    @ManagerAuth(memo = "重置Redis地图")
    public R resetMapToRedisByLev(@PathVariable Integer lev, HttpServletRequest request) {
        redisUtil.del(RedisKeyType.MAP.key + lev);
        return R.ok();
    }
 
}