|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.xydl.cac.iec;
|
|
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.IcdFile;
|
|
|
|
|
import com.xydl.cac.entity.constants.Constants;
|
|
|
|
|
import com.xydl.cac.exception.BusinessException;
|
|
|
|
|
import com.xydl.cac.repository.IcdFileRepository;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -25,7 +26,7 @@ public class IecServerService {
|
|
|
|
|
|
|
|
|
|
@PostConstruct
|
|
|
|
|
private void init() {
|
|
|
|
|
List<IcdFile> list = fileRepository.findBySrvAndStart(1, 1);
|
|
|
|
|
List<IcdFile> list = fileRepository.findBySrvAndStart(Constants.Server, Constants.TRUE);
|
|
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
IcdFile icdFile = list.get(0);
|
|
|
|
|
try {
|
|
|
|
@ -41,7 +42,7 @@ public class IecServerService {
|
|
|
|
|
throw new BusinessException("未找到该文件");
|
|
|
|
|
}
|
|
|
|
|
IcdFile icdFile = optional.get();
|
|
|
|
|
if (icdFile.getSrv() != 1) {
|
|
|
|
|
if (icdFile.getSrv() != Constants.Server) {
|
|
|
|
|
throw new BusinessException("该文件不是服务端文件");
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
@ -49,7 +50,7 @@ public class IecServerService {
|
|
|
|
|
iecServer.filename = icdFile.getFilename();
|
|
|
|
|
iecServer.fileId = icdFile.getId();
|
|
|
|
|
RealTimeDataService.iecServer = iecServer;
|
|
|
|
|
icdFile.setStart(1);
|
|
|
|
|
icdFile.setStart(Constants.TRUE);
|
|
|
|
|
fileRepository.save(icdFile);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("启动IEC61850服务端异常.", e);
|
|
|
|
@ -62,7 +63,7 @@ public class IecServerService {
|
|
|
|
|
Optional<IcdFile> optional = fileRepository.findById(iecServer.fileId);
|
|
|
|
|
if (optional.isPresent()) {
|
|
|
|
|
IcdFile icdFile = optional.get();
|
|
|
|
|
icdFile.setStart(0);
|
|
|
|
|
icdFile.setStart(Constants.FALSE);
|
|
|
|
|
fileRepository.save(icdFile);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|