1
zhang
5 天以前 b10ed4245c671edbf3a0ef346d5b08ec854a277d
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
package com.zy.asrs.controller;
 
import com.core.common.Cools;
import com.core.common.R;
import com.zy.asrs.controller.requestParam.StationRequestParam;
import com.zy.asrs.controller.responseParam.StationResponseParam;
import com.zy.common.web.BaseController;
import com.zy.core.DevpThread;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.properties.SlaveProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
/**
 * 对ctu系统的接口
 */
@Slf4j
@RestController
public class CtuController extends BaseController {
 
 
    @Autowired
    private SlaveProperties slaveProperties;
 
    /**
     * 站点查询
     */
    @ResponseBody
    @PostMapping("/station/query")
    public R query(@RequestBody StationRequestParam param) {
        log.info("站点查询:{}", param);
        List<String> staNos = param.getStaNos();
        DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, param.getDevpId());
        List<StationResponseParam> list = new ArrayList<>();
        Map<Integer, StaProtocol> station = devpThread.getStation();
        if (Cools.isEmpty(staNos)) {
            for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) {
                staNos.add(entry.getKey() + "");
            }
        }
        StationResponseParam stationResponseParam;
        for (String staNo : staNos) {
            StaProtocol staProtocol = station.get(Integer.parseInt(staNo));
            stationResponseParam = new StationResponseParam();
            stationResponseParam.setStaNo(staNo);
            stationResponseParam.setOccupied(staProtocol.isLoading());
            stationResponseParam.setInEnable(staProtocol.isInEnable());
            stationResponseParam.setOutEnable(staProtocol.isOutEnable());
            stationResponseParam.setOnline(staProtocol.isAutoing());
            list.add(stationResponseParam);
        }
        return R.ok(list);
    }
 
 
}