Compare commits
2 Commits
58609211ee
...
fda0e3ff79
Author | SHA1 | Date | |
---|---|---|---|
|
fda0e3ff79 | ||
|
046e765a1d |
@ -65,6 +65,7 @@ public class AlertListenerJob implements ApplicationRunner {
|
||||
//不论是否mock 都保存数据库
|
||||
|
||||
OccClientMessage clientMessage = serverProto.getClientMessage(alertInfo.getLineId());
|
||||
/*
|
||||
if (alertInfo.getAlertType() == AlertType.PLATFORM_EMERG_STOP) {
|
||||
NccAlertInfo cloned = alertInfo.clone2();
|
||||
cloned.setLineType(LineTypeEnum.OCC);
|
||||
@ -84,6 +85,17 @@ public class AlertListenerJob implements ApplicationRunner {
|
||||
nccAlertMessageServer.addMsg(cloned);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
for (LineTypeEnum lineType : clientMessage.getLineTypes()) {
|
||||
NccAlertInfo cloned = alertInfo.clone2();
|
||||
cloned.setLineType(lineType);
|
||||
AlertRecord record = convertToRecord(cloned);
|
||||
alertRecordRepository.save(record);
|
||||
cloned.setId(record.getId());
|
||||
NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getInstance(lineType);
|
||||
nccAlertMessageServer.addMsg(cloned);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -88,6 +88,9 @@ public class BuleDisplayMonitoringTask implements AlertMonitoringTask {
|
||||
List<RtuWarnVO> collectRtuList = this.findRtuBuild(lineId, builderMap);
|
||||
Map<Long, List<RtuWarnVO>> rtuVOMapList = collectRtuList.stream().collect(Collectors.groupingBy(d -> d.areaConfigVO.getId()));
|
||||
int interLockCount = rtuVOMapList.keySet().size();
|
||||
if (interLockCount == 0) {
|
||||
continue;
|
||||
}
|
||||
List<Boolean> allShutdownList = rtuVOMapList.values().stream().map(Collection::stream).map(ls -> ls.anyMatch(r -> Objects.nonNull(r.rtu) && r.rtu.getIpRtuStusDown())).toList();
|
||||
if (allShutdownList.size() == interLockCount && allShutdownList.stream().allMatch(d -> d)) {
|
||||
if (alertDataSource.putAlterDevice(lineId, ALL_BULE_DISPLAY_NAME, "All")) {
|
||||
|
@ -25,12 +25,12 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SwitchLostTask implements AlertMonitoringTask {
|
||||
public class SwitchLostAndJammedTask implements AlertMonitoringTask {
|
||||
|
||||
private DeviceGuardConfigService configService;
|
||||
private AlertInfoService alertInfoService;
|
||||
|
||||
public SwitchLostTask(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
|
||||
public SwitchLostAndJammedTask(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
|
||||
this.configService = configService;
|
||||
this.alertInfoService = alertInfoService;
|
||||
}
|
||||
@ -63,23 +63,41 @@ public class SwitchLostTask implements AlertMonitoringTask {
|
||||
|
||||
private void handle(Builder deviceBuild) {
|
||||
if (deviceBuild instanceof Switch.Builder switchBuild) {
|
||||
GuardConfig guardConfig = this.configService.getGuardConfig(switchBuild.getLineId());
|
||||
boolean isLost = switchBuild.getIpSingleSwitchStusLostIndication();
|
||||
if (isLost && this.timeOver(switchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) {
|
||||
Optional<Turnout> turnoutOpt = LineGraphicDataRepository.getDeviceOptByCode(switchBuild.getLineId(), switchBuild.getId(), Turnout.class);
|
||||
String layoutId = turnoutOpt.map(d -> String.valueOf(d.getCommon().getId())).orElse("");
|
||||
if (alertDataSource.putAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId())) {
|
||||
log.info("道岔失表超时,准备报警 线路[{}] 设备[{}] 接受时间[{}] 发送时间[{}] 对应地图设备id[{}]"
|
||||
, switchBuild.getLineId(), switchBuild.getId(), switchBuild.getReceiveTime(), switchBuild.getTimestamp(), layoutId);
|
||||
String alertMsg = String.format("设备[%s]失表", switchBuild.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.SWITCH_LOST, switchBuild, alertMsg, layoutId,
|
||||
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
alertDataSource.removeAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId());
|
||||
}
|
||||
Optional<Turnout> turnoutOpt = LineGraphicDataRepository.getDeviceOptByCode(switchBuild.getLineId(), switchBuild.getId(), Turnout.class);
|
||||
String layoutId = turnoutOpt.map(d -> String.valueOf(d.getCommon().getId())).orElse("");
|
||||
this.checkLost(switchBuild, layoutId);
|
||||
this.checkJammed(switchBuild, layoutId);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkLost(Switch.Builder switchBuild, String layoutId) {
|
||||
GuardConfig guardConfig = this.configService.getGuardConfig(switchBuild.getLineId());
|
||||
boolean isLost = switchBuild.getIpSingleSwitchStusLostIndication();
|
||||
if (isLost && this.timeOver(switchBuild.getReceiveTime(), guardConfig.getSwitchLostTimes())) {
|
||||
if (alertDataSource.putAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId())) {
|
||||
log.info("道岔失表超时,准备报警 线路[{}] 设备[{}] 接受时间[{}] 发送时间[{}] 对应地图设备id[{}]"
|
||||
, switchBuild.getLineId(), switchBuild.getId(), switchBuild.getReceiveTime(), switchBuild.getTimestamp(), layoutId);
|
||||
String alertMsg = String.format("设备[%s]失表", switchBuild.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.SWITCH_LOST, switchBuild, alertMsg, layoutId,
|
||||
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
} else {
|
||||
alertDataSource.removeAlterDevice(switchBuild.getLineId(), this.getName(), switchBuild.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final static String JAMMED_NAME = "JAMMED";
|
||||
|
||||
private void checkJammed(Switch.Builder switchBuild, String layoutId) {
|
||||
if (switchBuild.getIpSingleSwitchStusJammed()) {
|
||||
String alertMsg = String.format("设备[%s]挤岔", switchBuild.getId());
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.SWITCH_JAMMED, switchBuild, alertMsg, layoutId,
|
||||
AlertDeviceType.DEVICE_TYPE_SWITCH, false);
|
||||
alertManager.emit(alertInfo);
|
||||
} else {
|
||||
alertDataSource.removeAlterDevice(switchBuild.getLineId(), JAMMED_NAME, switchBuild.getId());
|
||||
}
|
||||
}
|
||||
}
|
@ -57,9 +57,10 @@ public class PlatformEmergStopTask implements AlertMonitoringTask {
|
||||
if (alertDataSource.putAlterDevice(lineIdInt, this.getName(), platformBuild.getId())) {
|
||||
Integer layOutId = giPlatform.getCommon().getId();
|
||||
Station station = LineGraphicDataRepository.getDeviceByCode(lineIdInt, giPlatform.getRefStation() + "", Station.class);
|
||||
|
||||
Optional<AreaConfigVO> optional = alertInfoService.findAreaDevice(AlertType.PLATFORM_EMERG_STOP, AlertDeviceType.DEVICE_TYPE_PLATFORM, layOutId, lineIdInt);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(optional, AlertType.PLATFORM_EMERG_STOP, platformBuild, "aaaaa", layOutId.toString(),
|
||||
String upWay = giPlatform.getUp() ? "上行" : "下行";
|
||||
String msg = String.format("%s-%s站台 应急触发", station.getName(), upWay);
|
||||
// Optional<AreaConfigVO> optional = alertInfoService.findAreaDevice(AlertType.PLATFORM_EMERG_STOP, AlertDeviceType.DEVICE_TYPE_PLATFORM, layOutId, lineIdInt);
|
||||
NccAlertInfo alertInfo = this.alertInfoService.createAlert2(Optional.empty(), AlertType.PLATFORM_EMERG_STOP, platformBuild, msg, layOutId.toString(),
|
||||
AlertDeviceType.DEVICE_TYPE_PLATFORM, false);
|
||||
alertManager.emit(alertInfo);
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package club.joylink.xiannccda.constants.common;
|
||||
|
||||
public enum FaultQueryType {
|
||||
// FAULT_EMERGENCY_GUIDE 开头是应急故障,FAULT_EXIT_SERVICE 开头是故障退出服务
|
||||
// T 代表车辆,T后面代表车辆型号
|
||||
FAULT_EMERGENCY_GUIDE,
|
||||
FAULT_EXIT_SERVICE,
|
||||
FAULT_EMERGENCY_GUIDE_T_DK37,
|
||||
FAULT_EXIT_SERVICE_T_DK37,
|
||||
|
||||
FAULT_EMERGENCY_GUIDE_T_CCD_5037,
|
||||
FAULT_EXIT_SERVICE_T_CCD_5037,
|
||||
;
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package club.joylink.xiannccda.controller;
|
||||
|
||||
import club.joylink.xiannccda.constants.common.CommonLogAnno;
|
||||
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum;
|
||||
import club.joylink.xiannccda.constants.common.CommonLogTypeEnum.SubEventType;
|
||||
import club.joylink.xiannccda.constants.common.FaultQueryType;
|
||||
import club.joylink.xiannccda.dto.alertTip.AlertTipInfoDto;
|
||||
import club.joylink.xiannccda.dto.alertTip.AlertTipQueryDTO;
|
||||
import club.joylink.xiannccda.dto.alertTip.AlertTipSaveDTO;
|
||||
import club.joylink.xiannccda.dto.fq.FaultQueryReqDTO;
|
||||
import club.joylink.xiannccda.dto.fq.FaultType;
|
||||
import club.joylink.xiannccda.entity.AlertTip;
|
||||
import club.joylink.xiannccda.entity.FaultQuery;
|
||||
import club.joylink.xiannccda.repository.IFaultQueryRepository;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author walker-sheng
|
||||
* @since 2024-11-06
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/fault/query")
|
||||
@Tag(name = "故障查询管理")
|
||||
public class FaultQueryController {
|
||||
|
||||
|
||||
private IFaultQueryRepository faultQueryRepository;
|
||||
|
||||
public FaultQueryController(IFaultQueryRepository faultQueryRepository) {
|
||||
this.faultQueryRepository = faultQueryRepository;
|
||||
}
|
||||
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "查询故障类型")
|
||||
@GetMapping("/type/{lineId}")
|
||||
// @CommonLogAnno(name = "决策信息-查看", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public List<FaultType> faultType(@PathVariable("lineId") Integer lineId) {
|
||||
if (lineId == 3) {
|
||||
return List.of(new FaultType(FaultQueryType.FAULT_EMERGENCY_GUIDE, "车辆故障应急处置指导关键点"), new FaultType(FaultQueryType.FAULT_EXIT_SERVICE, "车辆故障退出服务地点"));
|
||||
} else if (lineId == 4) {
|
||||
return List.of(new FaultType(FaultQueryType.FAULT_EMERGENCY_GUIDE_T_DK37, "车辆故障应急处置指导关键点-DK37车型"),
|
||||
new FaultType(FaultQueryType.FAULT_EXIT_SERVICE_T_DK37, "车辆故障退出服务地点-DK37车型")
|
||||
, new FaultType(FaultQueryType.FAULT_EMERGENCY_GUIDE_T_CCD_5037, "车辆故障应急处置指导关键点CCD-5037车型"),
|
||||
new FaultType(FaultQueryType.FAULT_EXIT_SERVICE_T_CCD_5037, "车辆故障退出服务地点CCD-5037车型")
|
||||
);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "保存故障查询")
|
||||
@PostMapping()
|
||||
// @CommonLogAnno(name = "决策信息-保存修改", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.SAVE_OR_UPDATE)
|
||||
public void save(@RequestBody @Validated FaultQuery fq) {
|
||||
this.faultQueryRepository.newSaveOrUpdate(fq);
|
||||
}
|
||||
|
||||
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "根据id查询数据")
|
||||
@GetMapping("/{id}")
|
||||
// @CommonLogAnno(name = "决策信息-查看", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public FaultQuery getById(@PathVariable int id) {
|
||||
return faultQueryRepository.getById(id);
|
||||
|
||||
}
|
||||
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "分页查询故障信息")
|
||||
@ApiResponse(description = "分页查询故障信息")
|
||||
@GetMapping("/page")
|
||||
// @CommonLogAnno(name = "决策信息-分页列表", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||
public IPage<FaultQuery> pageAlertTips(FaultQueryReqDTO req) {
|
||||
return this.faultQueryRepository.page(req);
|
||||
}
|
||||
|
||||
|
||||
@SecurityRequirement(name = "jwt")
|
||||
@Operation(summary = "根据id删除数据")
|
||||
@ApiResponse(description = "是否确实删除掉了一条数据")
|
||||
@DeleteMapping("/id/{id}")
|
||||
// @CommonLogAnno(name = "决策信息-删除", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.DELETE)
|
||||
public boolean deleteById(@PathVariable int id) {
|
||||
return this.faultQueryRepository.removeById(id);
|
||||
}
|
||||
|
||||
}
|
@ -9,8 +9,6 @@ import club.joylink.xiannccda.dto.user.UserEditDTO;
|
||||
import club.joylink.xiannccda.dto.user.UserInfoAuthDTO;
|
||||
import club.joylink.xiannccda.dto.user.UserQueryDTO;
|
||||
import club.joylink.xiannccda.dto.user.UserTokenDTO;
|
||||
import club.joylink.xiannccda.entity.User;
|
||||
import club.joylink.xiannccda.entity.User.Register;
|
||||
import club.joylink.xiannccda.repository.IUserRepository;
|
||||
import club.joylink.xiannccda.service.UserService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -20,7 +18,6 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.security.Principal;
|
||||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
@ -0,0 +1,12 @@
|
||||
package club.joylink.xiannccda.dto.fq;
|
||||
|
||||
import club.joylink.xiannccda.constants.common.FaultQueryType;
|
||||
import club.joylink.xiannccda.dto.CommonPage;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FaultQueryReqDTO extends CommonPage {
|
||||
|
||||
private Integer lineId;
|
||||
private FaultQueryType queryType;
|
||||
}
|
16
src/main/java/club/joylink/xiannccda/dto/fq/FaultType.java
Normal file
16
src/main/java/club/joylink/xiannccda/dto/fq/FaultType.java
Normal file
@ -0,0 +1,16 @@
|
||||
package club.joylink.xiannccda.dto.fq;
|
||||
|
||||
import club.joylink.xiannccda.constants.common.FaultQueryType;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FaultType {
|
||||
|
||||
private String faultType;
|
||||
private String typeName;
|
||||
|
||||
public FaultType(FaultQueryType qt, String name) {
|
||||
this.faultType = qt.name();
|
||||
this.typeName = name;
|
||||
}
|
||||
}
|
@ -383,6 +383,14 @@ public final class AlertConstProto {
|
||||
* <code>PLATFORM_EMERG_STOP = 24;</code>
|
||||
*/
|
||||
PLATFORM_EMERG_STOP(24),
|
||||
/**
|
||||
* <pre>
|
||||
* 道岔挤岔
|
||||
* </pre>
|
||||
*
|
||||
* <code>SWITCH_JAMMED = 25;</code>
|
||||
*/
|
||||
SWITCH_JAMMED(25),
|
||||
UNRECOGNIZED(-1),
|
||||
;
|
||||
|
||||
@ -566,6 +574,14 @@ public final class AlertConstProto {
|
||||
* <code>PLATFORM_EMERG_STOP = 24;</code>
|
||||
*/
|
||||
public static final int PLATFORM_EMERG_STOP_VALUE = 24;
|
||||
/**
|
||||
* <pre>
|
||||
* 道岔挤岔
|
||||
* </pre>
|
||||
*
|
||||
* <code>SWITCH_JAMMED = 25;</code>
|
||||
*/
|
||||
public static final int SWITCH_JAMMED_VALUE = 25;
|
||||
|
||||
|
||||
public final int getNumber() {
|
||||
@ -615,6 +631,7 @@ public final class AlertConstProto {
|
||||
case 22: return SWITCH_LOST_INTERLOCK_AREA;
|
||||
case 23: return INTERLOCK_LEVEL_ONE;
|
||||
case 24: return PLATFORM_EMERG_STOP;
|
||||
case 25: return SWITCH_JAMMED;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
@ -858,7 +875,7 @@ public final class AlertConstProto {
|
||||
"\n\020alertConst.proto\022\005alert*g\n\rAlertLocati" +
|
||||
"on\022\032\n\026ALERT_LOCATION_UNKNOWN\020\000\022\006\n\002QX\020\001\022\013" +
|
||||
"\n\007YHZ_LSQ\020\002\022\013\n\007HJM_LSQ\020\003\022\013\n\007BCT_LSQ\020\004\022\013\n" +
|
||||
"\007BSQ_LSQ\020\005*\304\004\n\tAlertType\022\026\n\022ALERT_TYPE_U" +
|
||||
"\007BSQ_LSQ\020\005*\327\004\n\tAlertType\022\026\n\022ALERT_TYPE_U" +
|
||||
"NKNOWN\020\000\022\020\n\014BLUE_DISPLAY\020\001\022\021\n\rTRAIN_DELA" +
|
||||
"Y_2\020\002\022\022\n\016TRAIN_DELAY_10\020\003\022\'\n#PLATFORM_DO" +
|
||||
"OR_WITHOUT_LOCKED_SIGNAL\020\004\022\035\n\031PLATFORM_D" +
|
||||
@ -872,12 +889,12 @@ public final class AlertConstProto {
|
||||
"\020\023\022\037\n\033AXLE_LED_RED_INTERLOCK_AREA\020\024\022\"\n\036A" +
|
||||
"XLE_LED_ORANGE_INTERLOCK_AREA\020\025\022\036\n\032SWITC" +
|
||||
"H_LOST_INTERLOCK_AREA\020\026\022\027\n\023INTERLOCK_LEV" +
|
||||
"EL_ONE\020\027\022\027\n\023PLATFORM_EMERG_STOP\020\030*x\n\rTip" +
|
||||
"TimeConfig\022\026\n\022HOLIDAYS_MORN_PEAK\020\000\022\031\n\025HO" +
|
||||
"LIDAYS_EVENING_PEAK\020\001\022\r\n\tMORN_PEAK\020\002\022\021\n\r" +
|
||||
"EVENING_PEARK\020\003\022\022\n\016NORMAL_UNPEARK\020\004B4\n!c" +
|
||||
"lub.joylink.xiannccda.dto.protosB\017AlertC" +
|
||||
"onstProtob\006proto3"
|
||||
"EL_ONE\020\027\022\027\n\023PLATFORM_EMERG_STOP\020\030\022\021\n\rSWI" +
|
||||
"TCH_JAMMED\020\031*x\n\rTipTimeConfig\022\026\n\022HOLIDAY" +
|
||||
"S_MORN_PEAK\020\000\022\031\n\025HOLIDAYS_EVENING_PEAK\020\001" +
|
||||
"\022\r\n\tMORN_PEAK\020\002\022\021\n\rEVENING_PEARK\020\003\022\022\n\016NO" +
|
||||
"RMAL_UNPEARK\020\004B4\n!club.joylink.xiannccda" +
|
||||
".dto.protosB\017AlertConstProtob\006proto3"
|
||||
};
|
||||
descriptor = com.google.protobuf.Descriptors.FileDescriptor
|
||||
.internalBuildGeneratedFileFrom(descriptorData,
|
||||
|
@ -0,0 +1,18 @@
|
||||
package club.joylink.xiannccda.mapper;
|
||||
|
||||
import club.joylink.xiannccda.entity.FaultQuery;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author walker-sheng
|
||||
* @since 2024-11-06
|
||||
*/
|
||||
@Mapper
|
||||
public interface FaultQueryMapper extends BaseMapper<FaultQuery> {
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package club.joylink.xiannccda.repository;
|
||||
|
||||
import club.joylink.xiannccda.dto.fq.FaultQueryReqDTO;
|
||||
import club.joylink.xiannccda.entity.FaultQuery;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author walker-sheng
|
||||
* @since 2024-11-06
|
||||
*/
|
||||
public interface IFaultQueryRepository extends IService<FaultQuery> {
|
||||
|
||||
void newSaveOrUpdate(FaultQuery fq);
|
||||
|
||||
IPage<FaultQuery> page(FaultQueryReqDTO reqDTO);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package club.joylink.xiannccda.repository.impl;
|
||||
|
||||
import club.joylink.xiannccda.dto.CommonPageRequest;
|
||||
import club.joylink.xiannccda.dto.fq.FaultQueryReqDTO;
|
||||
import club.joylink.xiannccda.entity.FaultQuery;
|
||||
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.xiannccda.mapper.FaultQueryMapper;
|
||||
import club.joylink.xiannccda.repository.IFaultQueryRepository;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.util.Objects;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author walker-sheng
|
||||
* @since 2024-11-06
|
||||
*/
|
||||
@Service
|
||||
public class FaultQueryRepository extends ServiceImpl<FaultQueryMapper, FaultQuery> implements IFaultQueryRepository {
|
||||
|
||||
@Override
|
||||
public void newSaveOrUpdate(FaultQuery fq) {
|
||||
if (fq.getId() == null) {
|
||||
this.save(fq);
|
||||
} else {
|
||||
FaultQuery nfq = this.getById(fq.getId());
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(nfq));
|
||||
this.updateById(fq);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<FaultQuery> page(FaultQueryReqDTO reqDTO) {
|
||||
QueryWrapper<FaultQuery> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(Objects.nonNull(reqDTO.getLineId()), FaultQuery::getLineId, reqDTO.getLineId())
|
||||
.eq(Objects.nonNull(reqDTO.getQueryType()), FaultQuery::getFaultType, reqDTO.getQueryType());
|
||||
return this.page(CommonPageRequest.defaultPage(), qw);
|
||||
}
|
||||
}
|
@ -18,6 +18,8 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
@ -85,9 +87,14 @@ public class AlertTipService {
|
||||
entity.setLineId(saveDTO.getLineId());
|
||||
entity.setLineType(saveDTO.getLineType());
|
||||
if (CollectionUtils.isNotEmpty(saveDTO.getTipTimeIds())) {
|
||||
String selectIds = this.timeConfigService.getCache().stream().filter(d -> saveDTO.getTipTimeIds().contains(d.getTimeType())).map(d -> d.getId().toString())
|
||||
.collect(Collectors.joining(StringPool.COMMA));
|
||||
entity.setTipTimeRef(selectIds);
|
||||
Collection<AlertTipTimeConfig> obj = this.timeConfigService.getCache();
|
||||
List<String> refTimeIdList = Lists.newArrayList();
|
||||
for (AlertTipTimeConfig timeConfig : obj) {
|
||||
if (saveDTO.getTipTimeIds().contains(timeConfig.getTimeType())) {
|
||||
refTimeIdList.add(timeConfig.getId().toString());
|
||||
}
|
||||
}
|
||||
entity.setTipTimeRef(Joiner.on(",").join(refTimeIdList));
|
||||
} else {
|
||||
entity.setTipTimeRef("");
|
||||
}
|
||||
|
@ -78,8 +78,10 @@ public class DeviceAreaConfigService {
|
||||
|
||||
private void checkDataForSql(DeviceAreaConfigDto dto, boolean isUpdate) {
|
||||
LambdaQueryWrapper<DeviceAreaConfig> queryWrapper = Wrappers.lambdaQuery(DeviceAreaConfig.class);
|
||||
queryWrapper.eq(DeviceAreaConfig::getLineId, dto.getLineId());
|
||||
queryWrapper.eq(DeviceAreaConfig::getDeviceType, dto.getDeviceType());
|
||||
queryWrapper.ne(isUpdate, DeviceAreaConfig::getId, dto.getId());
|
||||
|
||||
List<String> lastSqlList = Lists.newArrayList();
|
||||
for (String alertType : dto.getAlertTypes()) {
|
||||
lastSqlList.add(String.format(" find_in_set('%s',%s) > 0 ", alertType, DeviceAreaConfig.ALERT_TYPES));
|
||||
@ -93,11 +95,14 @@ public class DeviceAreaConfigService {
|
||||
List<DeviceAreaConfig> areaConfigList = this.deviceAreaConfigRepository.list(queryWrapper);
|
||||
|
||||
for (DeviceAreaConfig areaConfig : areaConfigList) {
|
||||
List<String> dbDatas = Splitter.on(StringPool.COMMA).splitToList(areaConfig.getData());
|
||||
List<String> saveDatas = Lists.newArrayList(dto.getData());
|
||||
saveDatas.retainAll(dbDatas);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(CollectionUtils.isEmpty(saveDatas),
|
||||
String.format("添加重复的设备区域[%s] 设备:%s", areaConfig.getAreaName(), this.findDevice(areaConfig.getLineId(), saveDatas)));
|
||||
if (StringUtils.isNotEmpty(areaConfig.getData())) {
|
||||
List<String> dbDatas = Splitter.on(StringPool.COMMA).splitToList(areaConfig.getData());
|
||||
List<String> saveDatas = Lists.newArrayList(dto.getData());
|
||||
saveDatas.retainAll(dbDatas);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(CollectionUtils.isEmpty(saveDatas),
|
||||
String.format("添加重复的设备区域[%s] 设备:%s", areaConfig.getAreaName(), this.findDevice(areaConfig.getLineId(), saveDatas)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,9 +144,11 @@ public class DeviceAreaConfigService {
|
||||
DeviceAreaConfigDto deviceAreaConfig = new DeviceAreaConfigDto();
|
||||
deviceAreaConfig.setLineId(dto.getLineId());
|
||||
deviceAreaConfig.setAreaName(dto.getAreaName());
|
||||
List<String> datas = Splitter.on(StringPool.COMMA).splitToList(dto.getData());
|
||||
if (StringUtils.isNotEmpty(dto.getData())) {
|
||||
List<String> datas = Splitter.on(StringPool.COMMA).splitToList(dto.getData());
|
||||
deviceAreaConfig.setData(datas);
|
||||
}
|
||||
|
||||
deviceAreaConfig.setData(datas);
|
||||
deviceAreaConfig.setDeviceType(dto.getDeviceType());
|
||||
if (StringUtils.isNotEmpty(dto.getAlertTypes())) {
|
||||
List<String> ll = Splitter.on(StringPool.COMMA).splitToList(dto.getAlertTypes());
|
||||
|
@ -29,8 +29,8 @@ public class MybatisPlusGenerator {
|
||||
private static final List<String> includeTableList = new ArrayList<>();
|
||||
|
||||
static {
|
||||
includeTableList.add("relieve_device_shere");
|
||||
includeTableList.add("relieve_time_shere");
|
||||
includeTableList.add("fault_query");
|
||||
// includeTableList.add("relieve_time_shere");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -71,7 +71,7 @@ public class DeviceStatusCheckTest {
|
||||
DeviceStatusProto.Switch.Builder s1 = DeviceStatusConvertor.convert(DeviceStatus.SWITCH.class, 40);
|
||||
System.out.println(s1);
|
||||
System.out.println("-----------------");
|
||||
DeviceStatusProto.Switch.Builder s2 = DeviceStatusConvertor.convert(DeviceStatus.SWITCH.class, 134217992);
|
||||
DeviceStatusProto.Switch.Builder s2 = DeviceStatusConvertor.convert(DeviceStatus.SWITCH.class, 134217728);
|
||||
System.out.println(s2);
|
||||
System.out.println("-----------------");
|
||||
DeviceStatusProto.Switch.Builder s3 = DeviceStatusConvertor.convert(DeviceStatus.SWITCH.class, 2);
|
||||
|
@ -12,7 +12,6 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.google.common.collect.HashBasedTable;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -33,6 +32,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@ -60,8 +60,11 @@ public class CollectorData {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String s : v) {
|
||||
String[] ssss = s.split("\u0000");
|
||||
String trackName = ssss[0];
|
||||
if (StringUtils.startsWith(trackName, "DG")) {
|
||||
newList.add(ssss[0]);
|
||||
|
||||
newList.add(ssss[0]);
|
||||
}
|
||||
}
|
||||
writer.write("\t\t" + newList.stream().sorted().collect(Collectors.joining(",")) + "\n");
|
||||
|
||||
|
@ -1,15 +1,20 @@
|
||||
package club.joylink.xiannccda.util.impo;
|
||||
|
||||
import club.joylink.xiannccda.alert.core.AlertDeviceType;
|
||||
import club.joylink.xiannccda.constants.common.LineTypeEnum;
|
||||
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto;
|
||||
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Turnout;
|
||||
import club.joylink.xiannccda.entity.AlertTip;
|
||||
import club.joylink.xiannccda.entity.DeviceAreaConfig;
|
||||
import club.joylink.xiannccda.entity.PublishedGi;
|
||||
import club.joylink.xiannccda.repository.IPublishedGiRepository;
|
||||
import club.joylink.xiannccda.repository.impl.AlertTipRepository;
|
||||
import club.joylink.xiannccda.repository.impl.DeviceAreaConfigRepository;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -19,7 +24,6 @@ import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -33,6 +37,12 @@ public class SwitchImportTest {
|
||||
@Autowired
|
||||
private AlertTipRepository tipRepository;
|
||||
|
||||
@Autowired
|
||||
private IPublishedGiRepository iPublishedGiRepository;
|
||||
|
||||
private static final Integer lineId = 4;
|
||||
private static final LineTypeEnum lineType = LineTypeEnum.OCC;
|
||||
|
||||
private List<DeviceAreaConfig> findAreaConfig() {
|
||||
QueryWrapper<DeviceAreaConfig> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(DeviceAreaConfig::getLineId, lineId).eq(DeviceAreaConfig::getDeviceType, "DEVICE_TYPE_SWITCH");
|
||||
@ -40,23 +50,87 @@ public class SwitchImportTest {
|
||||
return list;
|
||||
}
|
||||
|
||||
private static final Integer lineId = 3;
|
||||
private static final LineTypeEnum lineType = LineTypeEnum.OCC;
|
||||
private PublishedGi findGi() {
|
||||
return this.iPublishedGiRepository.lambdaQuery().eq(PublishedGi::getLineId, lineId).one();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private List<SwitcVO> findAllSwitchFromGI() {
|
||||
PublishedGi gi = this.findGi();
|
||||
LayoutGraphicsProto.RtssGraphicStorage storage =
|
||||
LayoutGraphicsProto.RtssGraphicStorage.parseFrom(gi.getProto());
|
||||
List<SwitcVO> switcVOS = new ArrayList<>();
|
||||
for (Turnout turnout : storage.getTurnoutsList()) {
|
||||
SwitcVO switcVO = new SwitcVO((long) turnout.getCommon().getId(), turnout.getCode());
|
||||
switcVOS.add(switcVO);
|
||||
}
|
||||
|
||||
String filePath = "g:\\2.xlsx";
|
||||
|
||||
try (FileInputStream file = new FileInputStream(new File(filePath));
|
||||
Workbook workbook = new XSSFWorkbook(file)) {
|
||||
Sheet sheet = workbook.getSheetAt(2);
|
||||
String station = "";
|
||||
String deviceCode = "";
|
||||
for (int i = 2; i < sheet.getPhysicalNumberOfRows(); i++) {
|
||||
Row row = sheet.getRow(i);
|
||||
Cell cell3 = row.getCell(2);
|
||||
Cell cell4 = row.getCell(3);
|
||||
String ts = cell3.getStringCellValue();
|
||||
String c = cell4.getStringCellValue();
|
||||
if (StringUtils.isNotEmpty(ts)) {
|
||||
station = ts;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(c)) {
|
||||
deviceCode = c;
|
||||
}
|
||||
String finalDeviceCode = deviceCode;
|
||||
List<SwitcVO> sw = switcVOS.stream().filter(d -> StringUtils.equals(d.code, finalDeviceCode)).toList();
|
||||
|
||||
if (CollectionUtils.isEmpty(sw)) {
|
||||
continue;
|
||||
// throw new RuntimeException(String.format("%s-%s", station, deviceCode));
|
||||
}
|
||||
sw.get(0).station = station;
|
||||
System.out.println(String.format("%s-%s", station, deviceCode));
|
||||
}
|
||||
}
|
||||
|
||||
return switcVOS;
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
public void importAreaConfig() {
|
||||
|
||||
List<SwitcVO> switcVOS = findAllSwitchFromGI();
|
||||
for (SwitcVO sw : switcVOS) {
|
||||
if (StringUtils.isEmpty(sw.station)) {
|
||||
continue;
|
||||
}
|
||||
DeviceAreaConfig ac = new DeviceAreaConfig();
|
||||
ac.setAreaName(String.format("%s-%s", sw.station, sw.code));
|
||||
ac.setLineId(lineId);
|
||||
ac.setDeviceType(AlertDeviceType.DEVICE_TYPE_SWITCH);
|
||||
ac.setAlertTypes(String.format("%s,%s,%s", AlertType.SWITCH_All_LOST.name(), AlertType.SWITCH_DW_LOST.name(), AlertType.SWITCH_FW_LOST.name()));
|
||||
ac.setData(sw.layoutId.toString());
|
||||
this.configRepository.save(ac);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
public void testRead() {
|
||||
String filePath = "g:\\1.xlsx";
|
||||
String filePath = "g:\\3.xlsx";
|
||||
|
||||
List<DeviceAreaConfig> areaConfigList = this.findAreaConfig();
|
||||
List<AlertTip> saveList = new ArrayList<>();
|
||||
|
||||
try (FileInputStream file = new FileInputStream(new File(filePath));
|
||||
Workbook workbook = new XSSFWorkbook(file)) {
|
||||
/* for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
|
||||
Sheet sheet = workbook.getSheetAt(i);
|
||||
System.out.println(sheet.getSheetName());
|
||||
}*/
|
||||
|
||||
Sheet sheet = workbook.getSheetAt(2);
|
||||
String newDeviceName = "";
|
||||
for (int i = 2; i < sheet.getPhysicalNumberOfRows(); i++) {
|
||||
@ -89,14 +163,28 @@ public class SwitchImportTest {
|
||||
msg2 = "\"" + msg2 + "\"";
|
||||
saveList.add(TestObj.create(lineId, lineType, funType, msg, msg2, config.getId()));
|
||||
} else {
|
||||
throw new RuntimeException("");
|
||||
System.out.println(finalNewDeviceName);
|
||||
// throw new RuntimeException(finalNewDeviceName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
System.out.println(saveList);
|
||||
this.tipRepository.saveBatch(saveList);
|
||||
}
|
||||
|
||||
|
||||
private static class SwitcVO {
|
||||
|
||||
public SwitcVO(Long layoutId, String code) {
|
||||
this.layoutId = layoutId;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
private Long layoutId;
|
||||
private String code;
|
||||
|
||||
private String station;
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit c8ca17875615e4fd3483a7b15c11a1bc2f2f9cd5
|
||||
Subproject commit a7b726826b89520f047c268415702df8116d225f
|
Loading…
Reference in New Issue
Block a user