|
|
|
@ -15,6 +15,7 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PreDestroy;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -38,6 +39,13 @@ public class I2syncTask {
|
|
|
|
|
@Resource
|
|
|
|
|
WebSocketServer webSocketServer;
|
|
|
|
|
|
|
|
|
|
int shutdown = 0;
|
|
|
|
|
|
|
|
|
|
@PreDestroy
|
|
|
|
|
private void preDestroy() {
|
|
|
|
|
shutdown = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Scheduled(initialDelay = 60 * 1000, fixedDelay = 30 * 60 * 1000)
|
|
|
|
|
public void syncAll() {
|
|
|
|
|
List<I2syncConfig> configList = i2syncService.listConfig();
|
|
|
|
@ -55,7 +63,7 @@ public class I2syncTask {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("I2syncTask.syncAll error.", e);
|
|
|
|
|
String str = "i2同步导出数据异常: " + e.getMessage();
|
|
|
|
|
webSocketServer.sendMessage(str , null);
|
|
|
|
|
webSocketServer.sendMessage(str, null);
|
|
|
|
|
dingTalkPushUtil.pushText(str);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -63,7 +71,10 @@ public class I2syncTask {
|
|
|
|
|
|
|
|
|
|
// 同步一个类型
|
|
|
|
|
private void syncOneConfig(I2syncConfig config) throws Exception {
|
|
|
|
|
log.info("I2syncTask.syncOneConfig " + config.getTypeName());
|
|
|
|
|
if (shutdown == 1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
log.info("I2syncTask 同步一个类型 " + config.getTypeName());
|
|
|
|
|
List<I2syncField> fieldList = i2syncService.listFieldConfig(config.getTableName());
|
|
|
|
|
if (CollectionUtils.isEmpty(fieldList)) {
|
|
|
|
|
log.info("该类型未配置同步字段.");
|
|
|
|
@ -89,6 +100,9 @@ public class I2syncTask {
|
|
|
|
|
// 同步一个装置
|
|
|
|
|
private void syncOneSensor(NSensor sensor, I2syncConfig config,
|
|
|
|
|
List<I2syncField> fieldList, List<ModevTypePoint> points) throws Exception {
|
|
|
|
|
if (shutdown == 1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
I2syncRecord record;
|
|
|
|
|
List<I2syncRecord> recordList = recordRepository.findByEqmid(sensor.getDevId());
|
|
|
|
|
if (CollectionUtils.isEmpty(recordList)) {
|
|
|
|
|