Commit bb5ff01f authored by xukaiqiang's avatar xukaiqiang

Update GeneralDataQueue.java

parent 9adb7d40
...@@ -10,9 +10,7 @@ import com.yeejoin.amos.iec104.business.service.intfc.IConfService; ...@@ -10,9 +10,7 @@ import com.yeejoin.amos.iec104.business.service.intfc.IConfService;
import com.yeejoin.amos.iec104.business.service.intfc.IPointConfigService; import com.yeejoin.amos.iec104.business.service.intfc.IPointConfigService;
import com.yeejoin.amos.iec104.context.FireAutoIntfContext; import com.yeejoin.amos.iec104.context.FireAutoIntfContext;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -30,13 +28,13 @@ public class GeneralDataQueue { ...@@ -30,13 +28,13 @@ public class GeneralDataQueue {
IConfService confService; IConfService confService;
private volatile static GeneralDataQueue instance = null; private volatile static GeneralDataQueue instance = null;
@Autowired
private RedisTemplate<String, String> redisTemplate; private RedisTemplate<String, String> redisTemplate;
private GeneralDataQueue() { private GeneralDataQueue() {
clientListenService = (IClientListenService) FireAutoIntfContext.getInstance().getBean(IClientListenService.class); clientListenService = (IClientListenService) FireAutoIntfContext.getInstance().getBean(IClientListenService.class);
confService = (IConfService) FireAutoIntfContext.getInstance().getBean(IConfService.class); confService = (IConfService) FireAutoIntfContext.getInstance().getBean(IConfService.class);
pointConfigService = (IPointConfigService) FireAutoIntfContext.getInstance().getBean(IPointConfigService.class); pointConfigService = (IPointConfigService) FireAutoIntfContext.getInstance().getBean(IPointConfigService.class);
redisTemplate = (RedisTemplate<String, String>) FireAutoIntfContext.getInstance().getBean(RedisTemplate.class);
} }
public static GeneralDataQueue getInstance() { public static GeneralDataQueue getInstance() {
...@@ -89,43 +87,15 @@ public class GeneralDataQueue { ...@@ -89,43 +87,15 @@ public class GeneralDataQueue {
while (true) { while (true) {
try { try {
AlarmParam param1 = blockingQueue.take(); AlarmParam param1 = blockingQueue.take();
if (!alarmParamIsChange(param1)) {
return;
}
LinkedList<AlarmParam> datas = new LinkedList<>(); LinkedList<AlarmParam> datas = new LinkedList<>();
PointConfigVo vo = pointConfigService.findByServicesIdAndInfoAddress(param1.getServiceId(), Integer.valueOf(param1.getInformationAddress())); PointConfigVo vo = pointConfigService.findByServicesIdAndInfoAddress(param1.getServiceId(), Integer.valueOf(param1.getInformationAddress()));
param1.setPointCode(vo.getPointCode()); param1.setPointCode(vo.getPointCode());
if (alarmParamIsChange(param1)) {
datas.add(param1); datas.add(param1);
boolean isEmpty = false;
do {
AlarmParam param = blockingQueue.poll(1, TimeUnit.SECONDS);
if (!ObjectUtils.isEmpty(param)) {
PointConfigVo vo1 = pointConfigService.findByServicesIdAndInfoAddress(param.getServiceId(), Integer.valueOf(param.getInformationAddress()));
if (!ObjectUtils.isEmpty(vo1)) {
param.setPointCode(vo1.getPointCode());
datas.add(param);
if (datas.size() > 10000) {
clientListenService.sendDatas(IEC104Constant.GENERAL_MESSAGE, datas); clientListenService.sendDatas(IEC104Constant.GENERAL_MESSAGE, datas);
datas.clear();
}
} else {
Logger.getLogger(this.getClass()).error(param.getServiceId() + " have not " + param.getInformationAddress());
}
} else {
isEmpty = true;
}
} while (!isEmpty);
try {
if (!ObjectUtils.isEmpty(datas)) {
clientListenService.sendDatas(IEC104Constant.GENERAL_MESSAGE, datas);
}
datas.clear();
} catch (Exception e) {
} }
} catch (Exception e) { } catch (Exception e) {
Logger.getLogger(this.getClass()).error(e.getMessage()); Logger.getLogger(this.getClass()).error(e.getMessage());
e.printStackTrace();
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment