| | |
| | | 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(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(1088);add(1089);add(1090);add(2003); |
| | | }}; |
| | | |
| | | public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{ |
| | | add(1001);add(1002);add(1003);add(1004);add(1005);add(1006);add(1007); |
| | | add(2000);add(2001);add(2002);add(1001);add(1002);add(1003);add(1004);add(1005);add(1006);add(1007); |
| | | }}; |
| | | |
| | | |
| | |
| | | staProtocol.setWeightError(statusError[5]); // 超重报警 |
| | | staProtocol.setBarcodeError(statusError[6]); // 扫码报警 |
| | | |
| | | short emptyInType = siemensS7Net.getByteTransform().TransInt16(result.Content, (i * 18) + 14);//预留1-空托入库类型,1:立库方向 2:产线方向 |
| | | staProtocol.setEmptyInType(emptyInType); |
| | | |
| | | if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { |
| | | staProtocol.setPakMk(true); |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | 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())); |
| | | |