调整
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m15s

This commit is contained in:
tiger_zhou 2024-10-24 14:24:51 +08:00
parent 69eed1fc96
commit fa1a3c9f51
2 changed files with 28 additions and 8 deletions

View File

@ -10,7 +10,11 @@ import club.joylink.xiannccda.event.Listener;
import club.joylink.xiannccda.repository.IAlertRecordRepository; import club.joylink.xiannccda.repository.IAlertRecordRepository;
import club.joylink.xiannccda.ws.NccAlertMessageServer; import club.joylink.xiannccda.ws.NccAlertMessageServer;
import club.joylink.xiannccda.ws.WsMessageServerManager; import club.joylink.xiannccda.ws.WsMessageServerManager;
import io.netty.util.internal.ObjectUtil;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
@ -61,14 +65,14 @@ public class AlertListenerJob implements ApplicationRunner {
OccClientMessage clientMessage = serverProto.getClientMessage(alertInfo.getLineId()); OccClientMessage clientMessage = serverProto.getClientMessage(alertInfo.getLineId());
for (LineTypeEnum lineType : clientMessage.getLineTypes()) { for (LineTypeEnum lineType : clientMessage.getLineTypes()) {
NccAlertInfo cloned = alertInfo.clone2();
NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getInstance(lineType); // NccAlertInfo cloneNcc = ObjectUtils.clone(alertInfo);
alertInfo.setLineType(lineType); cloned.setLineType(lineType);
AlertRecord record = convertToRecord(alertInfo); AlertRecord record = convertToRecord(cloned);
alertRecordRepository.save(record); alertRecordRepository.save(record);
alertInfo.setId(record.getId()); cloned.setId(record.getId());
nccAlertMessageServer.addMsg(alertInfo); NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getInstance(lineType);
nccAlertMessageServer.addMsg(cloned);
} }
} }
}); });

View File

@ -11,8 +11,11 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@Getter @Getter
public class NccAlertInfo implements AlertInfo { public class NccAlertInfo implements AlertInfo, Cloneable {
public NccAlertInfo() {
}
@Setter @Setter
private Integer id; private Integer id;
@ -53,6 +56,19 @@ public class NccAlertInfo implements AlertInfo {
this.alertDeviceType = alertDeviceType; this.alertDeviceType = alertDeviceType;
} }
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
public NccAlertInfo clone2() {
try {
return (NccAlertInfo) this.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType, Integer alertTipId, public NccAlertInfo(LocalDateTime alertTime, AlertType alertType, Integer alertTipId,
Integer lineId, String alertObject, String locatorDeviceId, Integer lineId, String alertObject, String locatorDeviceId,
Long alertLocationId, AlertDeviceType alertDeviceType) { Long alertLocationId, AlertDeviceType alertDeviceType) {