问题调整,"故障测试"环境区分

This commit is contained in:
tiger_zhou 2023-10-08 10:55:26 +08:00
parent e649ac2084
commit a289854910
12 changed files with 43 additions and 42 deletions

View File

@ -4,6 +4,7 @@ import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.alert.core.AlertMonitoringTask;
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
import club.joylink.xiannccda.constants.SystemContext;
import club.joylink.xiannccda.mock.message.MockLoadData;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Map;
@ -12,10 +13,12 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Order(1)
@Order(2)
@Component
@Slf4j
public class AlertEmitJob implements ApplicationRunner {

View File

@ -4,12 +4,9 @@ import club.joylink.xiannccda.alert.NccAlertInfo;
import club.joylink.xiannccda.alert.core.AlertDeviceType;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
import club.joylink.xiannccda.ats.warn.AxleSwitchTrackLedMostAlertListener.SwitchAndTrackLedMostAlertEvent;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section.SectionType;
import club.joylink.xiannccda.service.AlertInfoService;
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
import club.joylink.xiannccda.vo.AreaConfigVO;
@ -20,7 +17,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
//@Deprecated
@Component
@Slf4j
public class AxleSwitchTrackLedMostAlertListener implements AlertSourceEventListener<SwitchAndTrackLedMostAlertEvent> {

View File

@ -30,7 +30,7 @@ public class SwitchAndLedInterlockTask implements AlertMonitoringTask {
@Override
public String getName() {
return AlertType.INTERLOCK_LEVEL_ONE.name() + AlertDeviceType.DEVICE_TYPE_TRACK.name();
return AlertType.INTERLOCK_LEVEL_ONE.name();
}
private String getDefaultName(AlertType alertType, Integer lineId, Integer rtuId) {
@ -66,15 +66,6 @@ public class SwitchAndLedInterlockTask implements AlertMonitoringTask {
}
private void validateAlert(InterLockDetail detail, int total, AlertType alertType, AlertDeviceType deviceType, Integer lineId) {
/* if (alertType == AlertType.AXLE_LED_RED_INTERLOCK_AREA) {
List<String> deList = Lists.newArrayList();
for (String device : detail.getDevices()) {
MessageOrBuilder builder = LineGraphicDataRepository.getDeviceByCode(lineId, device);
String code = DeviceStatusDataOperate.findFieldVal(builder, "code", String.class);
deList.add(code);
}
System.out.println(deList);
}*/
String customName = String.format("%s-%s", alertType.name(), detail.getAreaConfigId());
if (total >= detail.getDevices().size()) {
if (alertManager.putAlterDevice(lineId, customName, alertType.name())) {
@ -90,9 +81,6 @@ public class SwitchAndLedInterlockTask implements AlertMonitoringTask {
private int handle2(AlertType alertType, Integer lineId, Integer rtuId) {
String name = this.getDefaultName(alertType, lineId, rtuId);
List<String> tmpList = alertManager.findAllWarnDeviceForList(lineId, name);
/* if (alertType == AlertType.AXLE_LED_RED) {
System.out.println(tmpList);
}*/
return tmpList.size();
}

View File

@ -22,7 +22,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
//@Deprecated
@Component
@Slf4j
public class SwitchLostMostAlertListener implements AlertSourceEventListener<SwitchLostMostEvent> {

View File

@ -10,8 +10,6 @@ import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.TrainMode;
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.CommonInfo;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.LogicSection;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo.Builder;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;

View File

@ -19,9 +19,13 @@ import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@ConditionalOnProperty(name = "mock-alert-test", havingValue = "true")
@Component
@Order(1)
@RequiredArgsConstructor
public class MockLoadData implements ApplicationRunner {

View File

@ -27,28 +27,29 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ConditionalOnProperty(name = "mock-alert-test", havingValue = "true")
@Component
//@RestController()
//@RequestMapping("/mock/server")
public class MockOccServer {
@PostMapping("send")
/*@PostMapping("send")
public String sendTestData(@RequestBody OccMockData md) {
if (!this.connectioned) {
return "未与测试server连接 ";
}
MessageData data = this.convertor(md);
if (Objects.nonNull(data)) {
// this.connection.writeAndFlush(List.of(data));
this.outHandle.write(List.of(data));
return "ok";
}
return String.format("错误的messageId [%s]", md.getMessageId().name());
}
}*/
public String writeData(NewAlertMockDTO mockDTO) {
if (!this.connectioned) {

View File

@ -6,6 +6,7 @@ import club.joylink.xiannccda.alert.core.AlertDeviceType;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
import club.joylink.xiannccda.constants.SystemContext;
import club.joylink.xiannccda.dto.mock.show.BlueAlertMockDTO;
import club.joylink.xiannccda.dto.mock.test.AlertMockDTO;
import club.joylink.xiannccda.dto.mock.show.NewAlertMockDTO;
@ -38,22 +39,24 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class AlertMockService {
@Autowired
private AlertDetailFactory alertDetailFactory;
private final AlertDetailFactory alertDetailFactory;
@Autowired
private AlertInfoService alertInfoService;
@Autowired
private MockOccServer occServer;
private final AlertInfoService alertInfoService;
public AlertMockService(AlertDetailFactory alertDetailFactory, AlertInfoService alertInfoService) {
this.alertDetailFactory = alertDetailFactory;
this.alertInfoService = alertInfoService;
}
public void setAlert(AlertMockDTO alertMockDTO) {
int lineId = alertMockDTO.getLineId();
@ -69,13 +72,19 @@ public class AlertMockService {
alertManager.emit(alertInfo);
}
@Value("${mock-alert-test}")
private boolean mockTest;
public void alertDemoTest(String json, AlertType alertType) {
Class<? extends NewAlertMockDTO> clazz = this.findMockDataObj(alertType);
NewAlertMockDTO mockDTO = JSONObject.parseObject(json, clazz);
mockDTO.setAlertType(alertType);
System.out.println(mockDTO.parseMessageId());
System.out.println(mockDTO);
this.occServer.writeData(mockDTO);
if (this.mockTest) {
MockOccServer occServer = SystemContext.getBean(MockOccServer.class);
Class<? extends NewAlertMockDTO> clazz = this.findMockDataObj(alertType);
NewAlertMockDTO mockDTO = JSONObject.parseObject(json, clazz);
mockDTO.setAlertType(alertType);
occServer.writeData(mockDTO);
} else {
log.error("非本,地测试调试环境");
}
}
private Class<? extends NewAlertMockDTO> findMockDataObj(AlertType alertType) {

View File

@ -101,8 +101,8 @@ public class DeviceAreaConfigService {
public void saveOrUpdate(DeviceAreaConfigDto dto) {
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(CollectionUtils.isNotEmpty(dto.getAlertTypes()), "绑定数据类型不能为空");
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(dto.getAlertTypes().contains(AlertType.INTERLOCK_LEVEL_ONE.name()) && dto.getAlertTypes().size() == 1, "联锁区只能选择一个类型");
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(dto.getAlertTypes().contains(AlertType.INTERLOCK_LEVEL_ONE.name()) && dto.getData().size() == 1, "联锁区只能添加一个设备");
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(dto.getAlertTypes().contains(AlertType.INTERLOCK_LEVEL_ONE.name()) && dto.getAlertTypes().size() != 1, "联锁区只能选择一个类型");
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotTrue(dto.getAlertTypes().contains(AlertType.INTERLOCK_LEVEL_ONE.name()) && dto.getData().size() > 1, "联锁区只能添加一个设备");
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(CollectionUtils.isNotEmpty(dto.getData()), "绑定数据不能为空");
boolean isUpdate = false;

View File

@ -16,4 +16,5 @@ occ:
realPort: 2603
unRealPort: 123
lineId: 3
collectorData: false
collectorData: false
mock-alert-test: true

View File

@ -21,4 +21,5 @@ occ:
realPort: 5603
unRealPort: 5703
lineId: 3
collectorData: false
collectorData: false
mock-alert-test: false

View File

@ -21,4 +21,5 @@ occ:
realPort: 5603
unRealPort: 5703
lineId: 3
collectorData: false
collectorData: false
mock-alert-test: false