| | |
| | | package com.zy.core.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.common.R; |
| | | import com.zy.core.News; |
| | | import com.zy.core.ThreadHandler; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.param.AddFakeDeviceParam; |
| | |
| | | import com.zy.core.utils.DeviceMsgUtils; |
| | | import com.zy.core.utils.FakeDeviceUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @RequestMapping("/open") |
| | | public class OpenController { |
| | | |
| | | @Value("${deviceMsgConfig.gatewayId}") |
| | | private Integer gatewayId; |
| | | @Value("${deviceMsgConfig.gatewayPort}") |
| | | private Integer gatewayPort; |
| | | |
| | | @Autowired |
| | | private DeviceMsgUtils deviceMsgUtils; |
| | | @Autowired |
| | | private FakeDeviceUtils fakeDeviceUtils; |
| | | |
| | | @GetMapping("/getSystemInfo") |
| | | public R getSystemInfo() { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("gatewayId", gatewayId); |
| | | map.put("gatewayPort", gatewayPort); |
| | | return R.ok().add(map); |
| | | } |
| | | |
| | | @GetMapping("/getDeviceList") |
| | | public R getDeviceList() { |
| | | List<DeviceConfig> deviceList = new ArrayList<>(); |
| | | |
| | | List<DeviceConfig> configList = new ArrayList<>(); |
| | | String deviceConfig = deviceMsgUtils.getDeviceConfig(); |
| | | if(null != deviceConfig){ |
| | | List<DeviceConfig> deviceConfigs = JSON.parseArray(deviceConfig, DeviceConfig.class); |
| | | configList.addAll(deviceConfigs); |
| | | } |
| | | |
| | | String fakeDeviceConfig = fakeDeviceUtils.getFakeDeviceConfig(); |
| | | if(null != fakeDeviceConfig){ |
| | | List<DeviceConfig> deviceConfigs = JSON.parseArray(fakeDeviceConfig, DeviceConfig.class); |
| | | configList.addAll(deviceConfigs); |
| | | } |
| | | List<DeviceConfig> deviceConfigs = deviceMsgUtils.getDeviceConfig(); |
| | | configList.addAll(deviceConfigs); |
| | | |
| | | List<DeviceConfig> fakeDeviceConfig = fakeDeviceUtils.getFakeDeviceConfig(); |
| | | configList.addAll(fakeDeviceConfig); |
| | | |
| | | for (DeviceConfig config : configList) { |
| | | SlaveType slaveType = SlaveType.findInstance(config.getDeviceType()); |
| | |
| | | continue; |
| | | } |
| | | deviceList.add(shuttleThread.getDeviceConfig()); |
| | | } else if (slaveType.equals(SlaveType.ForkLift)) { |
| | | ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(slaveType, config.getDeviceNo()); |
| | | if(forkLiftThread == null){ |
| | | continue; |
| | | } |
| | | deviceList.add(forkLiftThread.getDeviceConfig()); |
| | | } |
| | | } |
| | | |