| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | | @Component |
| | |
| | | |
| | | //上报堆垛机DB110状态数据 |
| | | reportDb110(); |
| | | //跨区入库任务下发,修改站点任务号为入库任务号 |
| | | taskToNewAreaInTaskStationSend(); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | //跨区入库任务下发,修改站点任务号为入库任务号 |
| | | public synchronized void taskToNewAreaInTaskStationSend() { |
| | | Set<String> list = redisUtil.searchKeys(RedisKeyType.RECEIVE_IN_TASK_CHANGE_STATION_TASK.key); |
| | | for (String key : list) { |
| | | Object dataStr = redisUtil.get(key); |
| | | if (dataStr == null) { |
| | | continue; |
| | | } |
| | | |
| | | JSONObject data = JSON.parseObject(dataStr.toString()); |
| | | Integer oldTaskNo = data.getInteger("oldTaskNo"); |
| | | Integer newTaskNo = data.getInteger("newTaskNo"); |
| | | StationCommand command = data.getObject("command", StationCommand.class); |
| | | Integer stationId = data.getInteger("stationId"); |
| | | Integer deviceNo = data.getInteger("deviceNo"); |
| | | |
| | | Object lock = redisUtil.get(RedisKeyType.RECEIVE_IN_TASK_CHANGE_STATION_TASK_SEND_LIMIT.key + stationId); |
| | | if(lock != null){ |
| | | continue; |
| | | } |
| | | |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, deviceNo); |
| | | if(stationThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap(); |
| | | StationProtocol stationProtocol = statusMap.get(stationId); |
| | | if(stationProtocol == null){ |
| | | continue; |
| | | } |
| | | |
| | | if (!stationProtocol.isAutoing()) { |
| | | continue; |
| | | } |
| | | |
| | | if (!stationProtocol.isLoading()) { |
| | | continue; |
| | | } |
| | | |
| | | if (stationProtocol.getTaskNo() == 0) { |
| | | continue; |
| | | } |
| | | |
| | | if (!stationProtocol.getTaskNo().equals(oldTaskNo)) { |
| | | //和缓存命令不相同删除 |
| | | redisUtil.del(key); |
| | | continue; |
| | | } |
| | | |
| | | //缓存命令相同,下发命令改变入库任务号信息 |
| | | MessageQueue.offer(SlaveType.Devp, deviceNo, new Task(2, command)); |
| | | redisUtil.set(RedisKeyType.RECEIVE_IN_TASK_CHANGE_STATION_TASK_SEND_LIMIT.key + stationId, "lock", 5); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |