|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.domain.param.*; | 
|---|
|  |  |  | import com.zy.asrs.utils.NotifyUtils; | 
|---|
|  |  |  | import com.zy.common.service.CommonService; | 
|---|
|  |  |  | import com.zy.core.cache.SlaveConnection; | 
|---|
|  |  |  | import com.zy.core.dispatcher.ShuttleDispatchUtils; | 
|---|
|  |  |  | import com.zy.core.enums.SlaveType; | 
|---|
|  |  |  | import com.zy.core.model.ForkLiftSlave; | 
|---|
|  |  |  | import com.zy.core.model.ShuttleSlave; | 
|---|
|  |  |  | import com.zy.core.model.protocol.ForkLiftProtocol; | 
|---|
|  |  |  | import com.zy.core.model.protocol.ShuttleProtocol; | 
|---|
|  |  |  | import com.zy.core.properties.SlaveProperties; | 
|---|
|  |  |  | import com.zy.core.thread.ForkLiftThread; | 
|---|
|  |  |  | import com.zy.core.thread.ShuttleThread; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | 
|---|
|  |  |  | private ShuttleDispatchUtils shuttleDispatchUtils; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NotifyUtils notifyUtils; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SlaveProperties slaveProperties; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/createMoveTask") | 
|---|
|  |  |  | public R createMoveTask(@RequestBody CreateMoveTaskParam param) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.error("任务取消失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/deviceStatus") | 
|---|
|  |  |  | public R getDeviceStatus() { | 
|---|
|  |  |  | HashMap<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | //获取小车数据 | 
|---|
|  |  |  | ArrayList<ShuttleProtocol> shuttleProtocols = new ArrayList<>(); | 
|---|
|  |  |  | for (ShuttleSlave slave : slaveProperties.getShuttle()) { | 
|---|
|  |  |  | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); | 
|---|
|  |  |  | if (shuttleThread == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); | 
|---|
|  |  |  | if (shuttleProtocol == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | shuttleProtocols.add(shuttleProtocol); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取货叉提升机数据 | 
|---|
|  |  |  | ArrayList<ForkLiftProtocol> forkLiftProtocols = new ArrayList<>(); | 
|---|
|  |  |  | for (ForkLiftSlave slave : slaveProperties.getForkLift()) { | 
|---|
|  |  |  | ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, slave.getId()); | 
|---|
|  |  |  | if (forkLiftThread == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); | 
|---|
|  |  |  | if (forkLiftProtocol == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | forkLiftProtocols.add(forkLiftProtocol); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | map.put("shuttle", shuttleProtocols); | 
|---|
|  |  |  | map.put("forkLift", forkLiftProtocols); | 
|---|
|  |  |  | return R.ok().add(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("/test") | 
|---|
|  |  |  | public R test() { | 
|---|
|  |  |  | notifyUtils.notify("task", 1, "9999", NotifyMsgType.SHUTTLE_MOVING, "data"); | 
|---|