| | |
| | | import com.zy.core.network.ZyStationConnectDriver; |
| | | import com.zy.core.network.entity.ZyStationStatusEntity; |
| | | import com.zy.core.thread.support.RecentStationArrivalTracker; |
| | | import com.zy.core.thread.support.StationErrLogSupport; |
| | | import com.zy.core.utils.DeviceLogRedisKeyBuilder; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | public class ZyStationV3Thread implements Runnable, com.zy.core.thread.StationThread { |
| | | |
| | | private List<StationProtocol> statusList = new ArrayList<>(); |
| | | private volatile List<Integer> taskNoList = new ArrayList<>(); |
| | | private DeviceConfig deviceConfig; |
| | | private RedisUtil redisUtil; |
| | | private ZyStationConnectDriver zyStationConnectDriver; |
| | |
| | | } |
| | | |
| | | List<ZyStationStatusEntity> zyStationStatusEntities = zyStationConnectDriver.getStatus(); |
| | | LinkedHashSet<Integer> taskNoSet = new LinkedHashSet<>(); |
| | | for (ZyStationStatusEntity statusEntity : zyStationStatusEntities) { |
| | | for (StationProtocol stationProtocol : statusList) { |
| | | if (stationProtocol.getStationId().equals(statusEntity.getStationId())) { |
| | |
| | | stationProtocol.setRunBlock(statusEntity.isRunBlock()); |
| | | stationProtocol.setEnableIn(statusEntity.isEnableIn()); |
| | | stationProtocol.setWeight(statusEntity.getWeight()); |
| | | if (statusEntity.getTaskNo() != null && statusEntity.getTaskNo() > 0) { |
| | | taskNoSet.add(statusEntity.getTaskNo()); |
| | | } |
| | | recentArrivalTracker.observe(statusEntity.getStationId(), statusEntity.getTaskNo(), statusEntity.isLoading()); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | taskNoList = new ArrayList<>(taskNoSet); |
| | | |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功", DateUtils.convert(new Date()), deviceConfig.getDeviceNo())); |
| | | StationErrLogSupport.sync(deviceConfig, redisUtil, statusList); |
| | | |
| | | if (System.currentTimeMillis() - deviceDataLogTime > deviceLogCollectTime) { |
| | | DeviceDataLog deviceDataLog = new DeviceDataLog(); |
| | |
| | | map.put(stationProtocol.getStationId(), stationProtocol); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> getAllTaskNoList() { |
| | | return taskNoList; |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (navigateUtils == null) { |
| | | return new ArrayList<>(); |
| | | } |
| | | List<NavigateNode> nodes = navigateUtils.calcByStationId(startStationId, targetStationId, taskNo, pathLenFactor); |
| | | List<NavigateNode> nodes = navigateUtils.calcOptimalPathByStationId(startStationId, targetStationId, taskNo, pathLenFactor); |
| | | List<Integer> ids = new ArrayList<>(); |
| | | for (NavigateNode n : nodes) { |
| | | JSONObject v = JSONObject.parseObject(n.getNodeValue()); |