1
zhang
2025-08-16 3688a0c6f14ab36966fa36866eeab7b812f37b70
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
package com.zy.asrs.controller;
 
import com.core.common.R;
import com.zy.asrs.domain.param.AskStaParam;
import com.zy.asrs.domain.param.TaskReportParam;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.impl.CtuMainServiceImpl;
import com.zy.common.web.BaseController;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.thread.SiemensDevpThread;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
 
/**
 * Created by vincent on 2022/4/8
 */
@Slf4j
@RestController
@RequestMapping("open/asrs")
public class OpenController extends BaseController {
 
 
    @Autowired
    private LocMastService locMastService;
 
 
    @Autowired
    private CtuMainServiceImpl ctuMainService;
 
 
    @Value("${ctu.url}")
    private String ctuUrl;
 
    @Value("${ctu.locSync}")
    private String locSync;
 
    private static final boolean auth = true;
 
    public static final ArrayList<String> APP_KEY_LIST = new ArrayList<String>() {{
        add("ea1f0459efc02a79f046f982767939ae");
    }};
 
 
    private String getLocSts(Long sts) {
        //15    IDLE    空闲
        //16    STOCK    在库
        //17    PAKIN    入库预约
        //18    PAKOUT    出库预约
        //19    DISABLED    禁用
        switch (sts.intValue()) {
            case 15:
                return "O";
            case 16:
                return "F";
            case 17:
                return "S";
            case 18:
                return "R";
            case 19:
                return "X";
            default:
                return "W";
        }
    }
 
    /**
     * 任务状态上报接收
     */
    @RequestMapping("/task/sync/v1")
    public R taskSync(@RequestBody TaskReportParam param) {
        if (param == null || param.getSeqNum() == null || param.getQrCode() == null) {
            return R.error("参数为空");
        }
        if (param.getQrCode().equals("00001547") && param.getTaskSts() == 10) {
            log.info("1001任务状态上报接收:{}", param);
            ctuMainService.setFlag1001(true);
        } else if (param.getQrCode().equals("00001612") && param.getTaskSts() == 5) {
            log.info("1007任务状态上报接收:{}", param);
            ctuMainService.setFlag1007(true);
        }
        return R.ok();
    }
 
    /**
     * 任务状态上报接收
     */
    @RequestMapping("/sta/ask/v1")
    public R taskSync(@RequestBody AskStaParam param) {
        if (param == null || param.getAskSta() == null || param.getAskType() == null) {
            return R.error("参数为空");
        }
        SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1);
        StaProtocol staProtocol = devpThread.getStation().get(param.getAskSta());
        if (staProtocol != null) {
            if (param.getAskType() == 1) {
                if (staProtocol.isLoading() && staProtocol.isAutoing() && staProtocol.isOutEnable()) {
                    return R.ok();
                }
            } else if (param.getAskType() == 2) {
                if (!staProtocol.isLoading() && staProtocol.isAutoing() && staProtocol.isInEnable()) {
                    return R.ok();
                }
            }
        }
        return R.error("状态不对");
    }
 
 
}