|
|
@ -10,6 +10,7 @@ import com.xydl.cac.repository.*;
|
|
|
|
import com.xydl.cac.service.DataService;
|
|
|
|
import com.xydl.cac.service.DataService;
|
|
|
|
import com.xydl.cac.service.IedDlRecordService;
|
|
|
|
import com.xydl.cac.service.IedDlRecordService;
|
|
|
|
import com.xydl.cac.socket.WebSocketServer;
|
|
|
|
import com.xydl.cac.socket.WebSocketServer;
|
|
|
|
|
|
|
|
import com.xydl.cac.util.DateUtil;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
@ -33,6 +34,7 @@ public class IEDCollectService {
|
|
|
|
BizConfig _bizConfig;
|
|
|
|
BizConfig _bizConfig;
|
|
|
|
|
|
|
|
|
|
|
|
String folder = "/record";
|
|
|
|
String folder = "/record";
|
|
|
|
|
|
|
|
HashMap<Integer, String> eqmidTimeMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
public IEDCollectService(IcdConfigTypeRepository configRepository, IcdConfigTypeAttRepository attRepository,
|
|
|
|
public IEDCollectService(IcdConfigTypeRepository configRepository, IcdConfigTypeAttRepository attRepository,
|
|
|
|
IcdConfigTypeInstRepository instRepository, RptparamindexRepository rptparamindexRepository,
|
|
|
|
IcdConfigTypeInstRepository instRepository, RptparamindexRepository rptparamindexRepository,
|
|
|
@ -69,6 +71,7 @@ public class IEDCollectService {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
log.info("61850开始采集数据, ied=" + ied.getName() + ", ip=" + ied.getIp() + ", port=" + ied.getPort());
|
|
|
|
log.info("61850开始采集数据, ied=" + ied.getName() + ", ip=" + ied.getIp() + ", port=" + ied.getPort());
|
|
|
|
this.connect();
|
|
|
|
this.connect();
|
|
|
|
|
|
|
|
eqmidTimeMap.clear();
|
|
|
|
if (!CollectionUtils.isEmpty(rptList)) {
|
|
|
|
if (!CollectionUtils.isEmpty(rptList)) {
|
|
|
|
this.doCollectAndSave(configTypeList, rptList);
|
|
|
|
this.doCollectAndSave(configTypeList, rptList);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -116,7 +119,8 @@ public class IEDCollectService {
|
|
|
|
String value = iecClient.getValue(paramindexNew, fc);
|
|
|
|
String value = iecClient.getValue(paramindexNew, fc);
|
|
|
|
String time = iecClient.getValue(paramindexT, fc);
|
|
|
|
String time = iecClient.getValue(paramindexT, fc);
|
|
|
|
log.info("采集到" + fc + " " + paramindexNew + "=" + value + ", t=" + time);
|
|
|
|
log.info("采集到" + fc + " " + paramindexNew + "=" + value + ", t=" + time);
|
|
|
|
time = time.replace("T", " ").replace("Z", "").replace("z", "");
|
|
|
|
time = DateUtil.fromZoneUTCToLocal(time);
|
|
|
|
|
|
|
|
time = this.makeSameTime(rpt.getEqmid(), time);
|
|
|
|
_dataService.insertData(rpt.getTablename(), rpt.getEqmid(), time, rpt.getColname(), value);
|
|
|
|
_dataService.insertData(rpt.getTablename(), rpt.getEqmid(), time, rpt.getColname(), value);
|
|
|
|
|
|
|
|
|
|
|
|
// 更新最新数据缓存
|
|
|
|
// 更新最新数据缓存
|
|
|
@ -131,6 +135,15 @@ public class IEDCollectService {
|
|
|
|
StaticVariable.paramRelationMap.put(key, value);
|
|
|
|
StaticVariable.paramRelationMap.put(key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String makeSameTime(Integer eqmid, String time) {
|
|
|
|
|
|
|
|
String sameTime = eqmidTimeMap.get(eqmid);
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(sameTime)) {
|
|
|
|
|
|
|
|
sameTime = time;
|
|
|
|
|
|
|
|
eqmidTimeMap.put(eqmid, sameTime);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return sameTime;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Rptparamindex findRpt(List<Rptparamindex> rptList, String paramindex) {
|
|
|
|
private Rptparamindex findRpt(List<Rptparamindex> rptList, String paramindex) {
|
|
|
|
for (Rptparamindex rpt : rptList) {
|
|
|
|
for (Rptparamindex rpt : rptList) {
|
|
|
|
if (rpt.getParamindex().equals(paramindex)) {
|
|
|
|
if (rpt.getParamindex().equals(paramindex)) {
|
|
|
@ -153,6 +166,9 @@ public class IEDCollectService {
|
|
|
|
if (StringUtils.isBlank(config.getPath())) {
|
|
|
|
if (StringUtils.isBlank(config.getPath())) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!config.getPath().endsWith("/")) {
|
|
|
|
|
|
|
|
config.setPath(config.getPath() + "/");
|
|
|
|
|
|
|
|
}
|
|
|
|
if (config.getDevId() == null) {
|
|
|
|
if (config.getDevId() == null) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -162,18 +178,20 @@ public class IEDCollectService {
|
|
|
|
for (FileInformation file : fileList) {
|
|
|
|
for (FileInformation file : fileList) {
|
|
|
|
String filename = file.getFilename();
|
|
|
|
String filename = file.getFilename();
|
|
|
|
if (!filename.endsWith("/")) {
|
|
|
|
if (!filename.endsWith("/")) {
|
|
|
|
if (StringUtils.isBlank(config.getSuffix()) ||
|
|
|
|
if (matchSuffix(filename, config.getSuffix())
|
|
|
|
filename.toLowerCase().endsWith(config.getSuffix().toLowerCase())) {
|
|
|
|
&& matchContain(filename, config.getContain())) {
|
|
|
|
IedDlRecord record = new IedDlRecord();
|
|
|
|
IedDlRecord record = new IedDlRecord();
|
|
|
|
record.setConfigId(config.getId());
|
|
|
|
record.setConfigId(config.getId());
|
|
|
|
record.setFilename(filename);
|
|
|
|
record.setFilename(filename);
|
|
|
|
|
|
|
|
record.setRemotePath(config.getPath() + filename);
|
|
|
|
boolean exist = _dlRecordService.exist(record);
|
|
|
|
boolean exist = _dlRecordService.exist(record);
|
|
|
|
if (!exist) {
|
|
|
|
if (!exist) {
|
|
|
|
String localFilePath = localPath + "/" + filename;
|
|
|
|
String localFilePath = localPath + "/" + filename;
|
|
|
|
iecClient.getFile(config.getPath(), filename, _bizConfig.getDatapath() + localFilePath, config.getTodel());
|
|
|
|
iecClient.getFile(record.getRemotePath(), _bizConfig.getDatapath() + localFilePath, config.getTodel());
|
|
|
|
record.setPath(_bizConfig.getDataNginxPath() + localFilePath);
|
|
|
|
record.setPath(_bizConfig.getDataNginxPath() + localFilePath);
|
|
|
|
record.setCreateTime(new Date());
|
|
|
|
record.setCreateTime(new Date());
|
|
|
|
_dlRecordService.add(record);
|
|
|
|
_dlRecordService.add(record);
|
|
|
|
|
|
|
|
log.info("采集到" + record.getRemotePath());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -189,6 +207,28 @@ public class IEDCollectService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean matchSuffix(String filename, String suffix) {
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(suffix)) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (filename.toLowerCase().endsWith(suffix.toLowerCase())) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean matchContain(String filename, String contain) {
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(contain)) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (filename.toLowerCase().contains(contain.toLowerCase())) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void updateLastData(Integer eqmid, String colname, String value, String time) {
|
|
|
|
public static void updateLastData(Integer eqmid, String colname, String value, String time) {
|
|
|
|
HashMap<String, String> map = StaticVariable.sensorLastDataMap.get(eqmid);
|
|
|
|
HashMap<String, String> map = StaticVariable.sensorLastDataMap.get(eqmid);
|
|
|
|
if (map == null) {
|
|
|
|
if (map == null) {
|
|
|
@ -212,7 +252,7 @@ public class IEDCollectService {
|
|
|
|
String colname = str[1];
|
|
|
|
String colname = str[1];
|
|
|
|
value = bda.getValueString();
|
|
|
|
value = bda.getValueString();
|
|
|
|
if ("acquisitionTime".equals(colname)) {
|
|
|
|
if ("acquisitionTime".equals(colname)) {
|
|
|
|
value = value.replace("T", " ").replace("Z", "").replace("z", "");
|
|
|
|
value = DateUtil.fromZoneUTCToLocal(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateLastData(eqmid, colname, value, null);
|
|
|
|
updateLastData(eqmid, colname, value, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|