| | |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.DeviceDataLog; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.DeviceDataLogService; |
| | | import com.zy.common.utils.News; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | |
| | | private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>(); |
| | | private short heartBeatVal = 1; |
| | | |
| | | /** |
| | | * 日志采集时间 |
| | | */ |
| | | private Long deviceDataLogTime = System.currentTimeMillis(); |
| | | |
| | | public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{ |
| | | add(1008);add(1009);add(1010);add(1011);add(1012);add(1013);add(1014);add(1015); |
| | | add(1016);add(1017);add(1018);add(1019);add(1020);add(1021);add(1022);add(1023); |
| | | add(1024);add(1025);add(1026);add(1027);add(1028);add(1029);add(1030);add(1031); |
| | | add(1032);add(1033);add(1034);add(1035);add(1036);add(1037);add(1038);add(1039); |
| | | add(1040);add(1041);add(1042);add(1043);add(1044);add(1045);add(1046);add(1047); |
| | | add(1048);add(1049);add(1050);add(1051);add(1052);add(1053);add(1054);add(1055); |
| | | add(1056);add(1057);add(1058);add(1059);add(1060);add(1061);add(1062);add(1063); |
| | | add(1064);add(1065);add(1066);add(1067);add(1068);add(1069);add(1070);add(1071); |
| | | add(1072);add(1073);add(1074);add(1075);add(1076);add(1077);add(1078);add(1079); |
| | | add(1080);add(1081);add(1082);add(1083);add(1084);add(1085);add(1086);add(1087); |
| | | add(1088);add(1089);add(1090);add(2003); |
| | | add(401);add(402); |
| | | }}; |
| | | |
| | | public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{ |
| | | add(2000);add(2001);add(2002);add(1001);add(1002); |
| | | // add(2000);add(2001);add(2002);add(1001);add(1002);add(1003);add(1004);add(1005);add(1006);add(1007); |
| | | }}; |
| | | |
| | | |
| | |
| | | }}; |
| | | |
| | | public static final ArrayList<Integer> barcode2 = new ArrayList<Integer>() {{ |
| | | add(3); |
| | | add(4); |
| | | // add(3); |
| | | // add(4); |
| | | }}; |
| | | |
| | | /** |
| | |
| | | |
| | | } |
| | | |
| | | if (System.currentTimeMillis() - deviceDataLogTime > 1000 * 1) { |
| | | //采集时间超过5s,保存一次数据记录 |
| | | //保存数据记录 |
| | | DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class); |
| | | DeviceDataLog deviceDataLog = new DeviceDataLog(); |
| | | deviceDataLog.setOriginData(Base64.getEncoder().encodeToString(result.Content)); |
| | | deviceDataLog.setWcsData(JSON.toJSONString(station)); |
| | | deviceDataLog.setType("devp"); |
| | | deviceDataLog.setDeviceNo(slave.getId()); |
| | | deviceDataLog.setCreateTime(new Date()); |
| | | deviceDataLogService.insert(deviceDataLog); |
| | | |
| | | //更新采集时间 |
| | | deviceDataLogTime = System.currentTimeMillis(); |
| | | } |
| | | |
| | | if (result.IsSuccess && result2.IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId())); |
| | | |