|  |  |  | 
|---|
|  |  |  | 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 SiemensS7Net siemensS7Net; | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | 
|---|
|  |  |  | }}; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | }}; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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())); | 
|---|
|  |  |  |  | 
|---|