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;
import com.yeejoin.amos.iec104.business.service.intfc.IPointConfigService;
import com.yeejoin.amos.iec104.context.FireAutoIntfContext;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.util.LinkedList;
......@@ -30,13 +28,13 @@ public class GeneralDataQueue {
IConfService confService;
private volatile static GeneralDataQueue instance = null;
@Autowired
private RedisTemplate<String, String> redisTemplate;
private GeneralDataQueue() {
clientListenService = (IClientListenService) FireAutoIntfContext.getInstance().getBean(IClientListenService.class);
confService = (IConfService) FireAutoIntfContext.getInstance().getBean(IConfService.class);
pointConfigService = (IPointConfigService) FireAutoIntfContext.getInstance().getBean(IPointConfigService.class);
redisTemplate = (RedisTemplate<String, String>) FireAutoIntfContext.getInstance().getBean(RedisTemplate.class);
}
public static GeneralDataQueue getInstance() {
......@@ -89,43 +87,15 @@ public class GeneralDataQueue {
while (true) {
try {
AlarmParam param1 = blockingQueue.take();
if (!alarmParamIsChange(param1)) {
return;
}
LinkedList<AlarmParam> datas = new LinkedList<>();
PointConfigVo vo = pointConfigService.findByServicesIdAndInfoAddress(param1.getServiceId(), Integer.valueOf(param1.getInformationAddress()));
param1.setPointCode(vo.getPointCode());
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);
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) {
if (alarmParamIsChange(param1)) {
datas.add(param1);
clientListenService.sendDatas(IEC104Constant.GENERAL_MESSAGE, datas);
}
} catch (Exception e) {
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