自动化立体仓库 - WCS系统
#
luxiaotao1123
2020-08-19 d3be642a803be434990679926e6e206416a634bd
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
package com.zy.asrs.controller;
 
import com.core.annotations.ManagerAuth;
import com.core.common.R;
import com.zy.asrs.domain.vo.PlcErrorTableVo;
import com.zy.asrs.domain.vo.SiteTableVo;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.DevpSlave;
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.DevpThread;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.*;
 
/**
 * 输送设备接口
 * Created by vincent on 2020-06-01
 */
@RestController
@RequestMapping("/site")
public class SiteController {
 
    @Autowired
    private SlaveProperties slaveProperties;
 
    @PostMapping("/table/site")
    @ManagerAuth(memo = "站点信息表")
    public R siteTable(){
        List<SiteTableVo> list = new ArrayList<>();
 
        for (DevpSlave devp : slaveProperties.getDevp()) {
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
            Map<Integer, StaProtocol> station = devpThread.getStation();
            for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) {
                StaProtocol staProtocol = entry.getValue();
                SiteTableVo vo = new SiteTableVo();
 
                vo.setDevNo(entry.getKey());    // 站点编号
                vo.setWorkNo(staProtocol.getWorkNo());   //  工作号
                vo.setAutoing(staProtocol.isAutoing()?"Y":"N");     //  自动
                vo.setLoading(staProtocol.isLoading()?"Y":"N");     // 有物
                vo.setInEnable(staProtocol.isInEnable()?"Y":"N");   // 可入
                vo.setOutEnable(staProtocol.isOutEnable()?"Y":"N"); // 可出
                vo.setInreq1(staProtocol.isInreq1()?"Y":"N");       // 需求1
                vo.setEmptyMk(staProtocol.isEmptyMk()?"Y":"N");     // 空板信号
                vo.setStaNo(staProtocol.getStaNo());                // 目标站
 
                list.add(vo);
            }
        }
        return R.ok().add(list);
    }
 
    @PostMapping("/table/plc/errors")
    @ManagerAuth(memo = "输送设备plc异常信息表")
    public R plcErrorTable(){
        List<PlcErrorTableVo> list = new ArrayList<>();
        for (int i = 0; i<new Random().nextInt(13); i++){
            PlcErrorTableVo table = new PlcErrorTableVo();
            table.setNo(String.valueOf(i));
            table.setError("异常信息");
            table.setPlcDesc("plc异常描述");
            list.add(table);
        }
        list.sort((o1, o2) -> {
            if (o1.getNo().compareTo(o2.getNo()) > 0){
                return 1;
            }else if (o1.getNo().compareTo(o2.getNo()) < 0){
                return 0;
            }else{
                return -1;
            }
 
        });
        return R.ok().add(list);
    }
 
    @PostMapping("/output/site")
    @ManagerAuth(memo = "站点设备报文日志输出")
    public R siteOutput(){
        String str = "\n" +new Date().toLocaleString() + "【2020-5-29 13:14:22】扫描plcA 目标站--27328372372832763643234323432342";
        return R.ok().add(str);
    }
 
}