|
@@ -1,20 +1,29 @@
|
|
|
package com.its.rota.server.dto;
|
|
|
|
|
|
-import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
|
|
|
-import com.beanit.asn1bean.ber.types.*;
|
|
|
+import com.beanit.asn1bean.ber.types.BerBitString;
|
|
|
+import com.beanit.asn1bean.ber.types.BerEnum;
|
|
|
+import com.beanit.asn1bean.ber.types.BerInteger;
|
|
|
import com.beanit.asn1bean.ber.types.string.BerUTF8String;
|
|
|
-import com.beanit.enums.eAuthInfo;
|
|
|
import com.beanit.its.*;
|
|
|
import com.beanit.utils.ItsAsn;
|
|
|
import com.beanit.utils.ItsAsnSequence;
|
|
|
+import com.its.app.common.utils.SysUtils;
|
|
|
+import com.its.rota.server.common.SpringUtils;
|
|
|
import com.its.rota.server.entity.TbSndIncident;
|
|
|
+import com.its.rota.server.entity.TbSndLog;
|
|
|
+import com.its.rota.server.entity.TbTrafficCenter;
|
|
|
+import com.its.rota.server.process.dbms.DbmsData;
|
|
|
+import com.its.rota.server.process.dbms.DbmsDataProcess;
|
|
|
import com.its.rota.server.repository.ApplicationRepository;
|
|
|
+import com.its.rota.server.xnet.server.process.request.AiPublicationIncidentCondition;
|
|
|
+import com.its.rota.server.xnet.server.process.request.AiPublicationTraffic;
|
|
|
import io.netty.channel.ChannelFuture;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.Builder;
|
|
|
import lombok.Data;
|
|
|
import lombok.NoArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
|
import java.io.Serializable;
|
|
@@ -87,118 +96,131 @@ public class CenterDto implements Serializable {
|
|
|
|
|
|
@Async("jobDataExecutor")
|
|
|
public void executeSendIncident() {
|
|
|
- sendIncident();
|
|
|
+ AiPublicationIncidentCondition.run(this);
|
|
|
}
|
|
|
|
|
|
- public void sendIncident() {
|
|
|
- try {
|
|
|
- if (!channelOpened()) {
|
|
|
- return;
|
|
|
+ public IncidentConditionsList getIncidentConditionsList() {
|
|
|
+ IncidentConditionsList lists = new IncidentConditionsList();
|
|
|
+ if (!channelOpened()) {
|
|
|
+ return lists;
|
|
|
+ }
|
|
|
+ if (this.incident.getSendIdx() > 0 && this.incident.getSendIdx() >= this.incident.getIncidents().size()) {
|
|
|
+ // 모든 돌발 정보를 전송하였다.
|
|
|
+ DbmsDataProcess dbmsDataProcess = SpringUtils.getBean(DbmsDataProcess.class);
|
|
|
+ TbSndLog log = TbSndLog.builder()
|
|
|
+ .logDate(SysUtils.getSysTime())
|
|
|
+ .infoKind(DbmsData.D_KIND_INC)
|
|
|
+ .fromCenterId(ApplicationRepository.center.getCenterId())
|
|
|
+ .toCenterId(this.getCenterId())
|
|
|
+ .dataCnt(this.incident.getIncidents().size())
|
|
|
+ .build();
|
|
|
+ dbmsDataProcess.add(new DbmsData(this, DbmsData.DBMS_DATA_LOG_INCIDENT, log));
|
|
|
+ return lists;
|
|
|
+ }
|
|
|
+
|
|
|
+ int start = this.incident.getSendIdx();
|
|
|
+ int end = Math.min(start + ItsAsn.DATEX_MAX_INCIDENT_CONDITION_COUNT, this.incident.getIncidents().size());
|
|
|
+
|
|
|
+ for (int ii = start; ii < end; ii++) {
|
|
|
+ TbSndIncident data = this.incident.getIncidents().get(ii);
|
|
|
+ if (data.getNodeId() == null || data.getNodeId().isEmpty()) {
|
|
|
+ data.setNodeId(ItsAsn.DATEX_NODE_TEXT);
|
|
|
}
|
|
|
- if (this.incident.getSendIdx() > 0 && this.incident.getSendIdx() == this.incident.getIncidents().size()) {
|
|
|
- // 모든 돌발 정보를 전송하였다.
|
|
|
- return;
|
|
|
+ if (data.getLinkId() == null || data.getLinkId().isEmpty()) {
|
|
|
+ data.setLinkId(ItsAsn.DATEX_LINK_TEXT);
|
|
|
}
|
|
|
-
|
|
|
- int start = this.incident.getSendIdx();
|
|
|
- int end = Math.min(start + ItsAsn.DATEX_MAX_INC_COUNT, this.incident.getIncidents().size());
|
|
|
- if (start == end) {
|
|
|
- return;
|
|
|
+ if (data.getContactOrganizationNameText() == null || data.getContactOrganizationNameText().isEmpty()) {
|
|
|
+ data.setContactOrganizationNameText(ItsAsn.DATEX_DEFAULT_TEXT);
|
|
|
}
|
|
|
-
|
|
|
- IncidentConditionsList lists = new IncidentConditionsList();
|
|
|
- for (int ii = start; ii < end; ii++) {
|
|
|
- TbSndIncident data = this.incident.getIncidents().get(ii);
|
|
|
- if (data.getNodeId() == null || data.getNodeId().isEmpty()) {
|
|
|
- data.setNodeId(ItsAsn.DATEX_NODE_TEXT);
|
|
|
- }
|
|
|
- if (data.getLinkId() == null || data.getLinkId().isEmpty()) {
|
|
|
- data.setLinkId(ItsAsn.DATEX_LINK_TEXT);
|
|
|
- }
|
|
|
- if (data.getContactOrganizationNameText() == null || data.getContactOrganizationNameText().isEmpty()) {
|
|
|
- data.setContactOrganizationNameText(ItsAsn.DATEX_DEFAULT_TEXT);
|
|
|
- }
|
|
|
- if (data.getDescriptionTypeIncidentOther() == null || data.getDescriptionTypeIncidentOther().isEmpty()) {
|
|
|
- data.setDescriptionTypeIncidentOther(ItsAsn.DATEX_DEFAULT_TEXT);
|
|
|
- }
|
|
|
- if (data.getIncidentVehiclesInvolvedOther() == null || data.getIncidentVehiclesInvolvedOther().isEmpty()) {
|
|
|
- data.setIncidentVehiclesInvolvedOther(ItsAsn.DATEX_DEFAULT_TEXT);
|
|
|
- }
|
|
|
- if (data.getIncidentStatusOther() == null || data.getIncidentStatusOther().isEmpty()) {
|
|
|
- data.setIncidentStatusOther(ItsAsn.DATEX_DEFAULT_TEXT);
|
|
|
- }
|
|
|
- if (data.getUpdateTypeOther() == null || data.getUpdateTypeOther().isEmpty()) {
|
|
|
- data.setUpdateTypeOther(ItsAsn.DATEX_DEFAULT_TEXT);
|
|
|
- }
|
|
|
-
|
|
|
- IncidentConditions cond = new IncidentConditions();
|
|
|
-
|
|
|
- cond.setNodeNodeIdNumber(new BerUTF8String(data.getNodeId()));
|
|
|
- cond.setLinkLinkIdNumber(new BerUTF8String(data.getLinkId()));
|
|
|
- cond.setOrgnContactOrganizationNameText(new BerUTF8String(data.getContactOrganizationNameText()));
|
|
|
- cond.setEvntDescriptionTypeIncidentCode(new BerEnum(data.getDescriptionTypeIncidentCode()));
|
|
|
- cond.setEvntDescriptionTypeIncidentOther(new BerUTF8String(data.getDescriptionTypeIncidentOther()));
|
|
|
-
|
|
|
- byte[] bitData = new byte[1];
|
|
|
- bitData[0] = (byte) (data.getIncidentVehiclesInvolvedCode() & 0xFF);
|
|
|
- cond.setEvntIncidentVehiclesInvolvedCode(new BerBitString(bitData, 8));
|
|
|
-
|
|
|
- cond.setEvntIncidentVehiclesInvolvedOther(new BerUTF8String(data.getIncidentVehiclesInvolvedOther()));
|
|
|
- cond.setEvntIncidentStatusCode(new BerEnum(data.getIncidentStatusCode()));
|
|
|
- cond.setEvntIncidentStatusOther(new BerUTF8String(data.getIncidentStatusOther()));
|
|
|
- cond.setEvntUpdateTypeCode(new BerEnum(data.getUpdateTypeCode()));
|
|
|
- cond.setEvntUpdateTypeOther(new BerUTF8String(data.getUpdateTypeOther()));
|
|
|
-
|
|
|
- lists.getIncidentConditions().add(cond);
|
|
|
+ if (data.getDescriptionTypeIncidentOther() == null || data.getDescriptionTypeIncidentOther().isEmpty()) {
|
|
|
+ data.setDescriptionTypeIncidentOther(ItsAsn.DATEX_DEFAULT_TEXT);
|
|
|
}
|
|
|
-
|
|
|
- if (lists.getIncidentConditions().isEmpty()) {
|
|
|
- return;
|
|
|
+ if (data.getIncidentVehiclesInvolvedOther() == null || data.getIncidentVehiclesInvolvedOther().isEmpty()) {
|
|
|
+ data.setIncidentVehiclesInvolvedOther(ItsAsn.DATEX_DEFAULT_TEXT);
|
|
|
}
|
|
|
- EndApplicationMessage endMsg = new EndApplicationMessage();
|
|
|
- int[] messageId = {1, 0, 14827, 1, 1, 4};
|
|
|
- ReverseByteArrayOutputStream msgBuff = new ReverseByteArrayOutputStream(ItsAsn.ITS_ASN_PACKET_MAX_SIZE);
|
|
|
- lists.encode(msgBuff);
|
|
|
- endMsg.setEndApplicationMessageId(new BerObjectIdentifier(messageId));
|
|
|
- endMsg.setEndApplicationMessageMsg(new BerAny(msgBuff.getArray()));
|
|
|
-
|
|
|
- byte[] auth = { eAuthInfo.AI_IncidentConditions.getValue() };
|
|
|
- int packetNmbr = this.seq.nextValue();
|
|
|
-
|
|
|
- PublicationType publicationType = new PublicationType();
|
|
|
- publicationType.setDatexPublishData(endMsg);
|
|
|
-
|
|
|
- PublicationData publicationData = new PublicationData();
|
|
|
- publicationData.setDatexPublishSubscribeSerialNbr(new BerInteger(packetNmbr)); // 요청 serial nmbr
|
|
|
- publicationData.setDatexPublishSerialNbr(new BerInteger(packetNmbr)); // 생성 serial nmbr
|
|
|
- publicationData.setDatexPublishLatePublicationFlag(new BerBoolean(true));
|
|
|
- publicationData.setDatexPublishType(publicationType);
|
|
|
-
|
|
|
- PublishFormat.DatexPublishData publishData = new PublishFormat.DatexPublishData();
|
|
|
- publishData.getPublicationData().add(publicationData);
|
|
|
-
|
|
|
- PublishFormat publishFormat = new PublishFormat();
|
|
|
- publishFormat.setDatexPublishData(publishData);
|
|
|
-
|
|
|
- Publication publication = new Publication();
|
|
|
- publication.setDatexPublishFormat(publishFormat);
|
|
|
- publication.setDatexPublishGuaranteedBool(new BerBoolean(true));
|
|
|
-
|
|
|
- C2CAuthenticatedMessage c2c = new C2CAuthenticatedMessage();
|
|
|
- PDUs pdus = new PDUs();
|
|
|
- pdus.setPublication(publication);
|
|
|
- c2c.setDatexDataPacketNumber(new BerInteger(packetNmbr));
|
|
|
- c2c.setDatexDataPacketPriorityNumber(new BerInteger(1));
|
|
|
- c2c.setDatexAuthenticationInfoText(new BerOctetString(auth));
|
|
|
- c2c.setOptions(ApplicationRepository.getHeaderOptions(this));
|
|
|
- c2c.setPdu(pdus);
|
|
|
-
|
|
|
- sendData(c2c, "AI_IncidentConditions");
|
|
|
- this.incident.setSendIdx(end);
|
|
|
+ if (data.getIncidentStatusOther() == null || data.getIncidentStatusOther().isEmpty()) {
|
|
|
+ data.setIncidentStatusOther(ItsAsn.DATEX_DEFAULT_TEXT);
|
|
|
+ }
|
|
|
+ if (data.getUpdateTypeOther() == null || data.getUpdateTypeOther().isEmpty()) {
|
|
|
+ data.setUpdateTypeOther(ItsAsn.DATEX_DEFAULT_TEXT);
|
|
|
+ }
|
|
|
+
|
|
|
+ IncidentConditions cond = new IncidentConditions();
|
|
|
+
|
|
|
+ cond.setNodeNodeIdNumber(new BerUTF8String(data.getNodeId()));
|
|
|
+ cond.setLinkLinkIdNumber(new BerUTF8String(data.getLinkId()));
|
|
|
+ cond.setOrgnContactOrganizationNameText(new BerUTF8String(data.getContactOrganizationNameText()));
|
|
|
+ cond.setEvntDescriptionTypeIncidentCode(new BerEnum(data.getDescriptionTypeIncidentCode()));
|
|
|
+ cond.setEvntDescriptionTypeIncidentOther(new BerUTF8String(data.getDescriptionTypeIncidentOther()));
|
|
|
+
|
|
|
+ byte[] bitData = new byte[1];
|
|
|
+ bitData[0] = (byte) (data.getIncidentVehiclesInvolvedCode() & 0xFF);
|
|
|
+ cond.setEvntIncidentVehiclesInvolvedCode(new BerBitString(bitData, 8));
|
|
|
+
|
|
|
+ cond.setEvntIncidentVehiclesInvolvedOther(new BerUTF8String(data.getIncidentVehiclesInvolvedOther()));
|
|
|
+ cond.setEvntIncidentStatusCode(new BerEnum(data.getIncidentStatusCode()));
|
|
|
+ cond.setEvntIncidentStatusOther(new BerUTF8String(data.getIncidentStatusOther()));
|
|
|
+ cond.setEvntUpdateTypeCode(new BerEnum(data.getUpdateTypeCode()));
|
|
|
+ cond.setEvntUpdateTypeOther(new BerUTF8String(data.getUpdateTypeOther()));
|
|
|
+
|
|
|
+ lists.getIncidentConditions().add(cond);
|
|
|
+ }
|
|
|
+ this.incident.setSendIdx(end);
|
|
|
+ return lists;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Async("jobDataExecutor")
|
|
|
+ public void executeSendTraffic() {
|
|
|
+ AiPublicationTraffic.run(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ public CurrentLinkStateList getCurrentLinkStateList() {
|
|
|
+ CurrentLinkStateList lists = new CurrentLinkStateList();
|
|
|
+ if (!channelOpened()) {
|
|
|
+ return lists;
|
|
|
}
|
|
|
- catch (Exception e) {
|
|
|
- log.error("INCIDENT: [{}, {}]. Incident Data Send Exception. {}", this.centerId, this.ipAddress, e.getMessage());
|
|
|
+ if (this.traffic.getSendIdx() > 0 && this.traffic.getSendIdx() >= ApplicationRepository.traffics.size()) {
|
|
|
+ // 모든 교통 정보를 전송하였다.
|
|
|
+ DbmsDataProcess dbmsDataProcess = SpringUtils.getBean(DbmsDataProcess.class);
|
|
|
+ TbSndLog log = TbSndLog.builder()
|
|
|
+ .logDate(SysUtils.getSysTime())
|
|
|
+ .infoKind(DbmsData.D_KIND_TRAF)
|
|
|
+ .fromCenterId(ApplicationRepository.center.getCenterId())
|
|
|
+ .toCenterId(this.getCenterId())
|
|
|
+ .dataCnt(ApplicationRepository.traffics.size())
|
|
|
+ .build();
|
|
|
+ dbmsDataProcess.add(new DbmsData(this, DbmsData.DBMS_DATA_LOG_TRAFFIC, log));
|
|
|
+ return lists;
|
|
|
}
|
|
|
+
|
|
|
+ int start = this.traffic.getSendIdx();
|
|
|
+ int end = Math.min(start + ItsAsn.DATEX_MAX_TRAFFIC_COUNT, ApplicationRepository.traffics.size());
|
|
|
+
|
|
|
+ for (int ii = start; ii < end; ii++) {
|
|
|
+ CurrentLinkState traf = getCurrentLinkState(ii);
|
|
|
+ lists.getCurrentLinkState().add(traf);
|
|
|
+ }
|
|
|
+ this.traffic.setSendIdx(end);
|
|
|
+ return lists;
|
|
|
}
|
|
|
|
|
|
+ @NotNull
|
|
|
+ private static CurrentLinkState getCurrentLinkState(int ii) {
|
|
|
+ TbTrafficCenter data = ApplicationRepository.traffics.get(ii);
|
|
|
+ if (data.getLinkId() == null || data.getLinkId().isEmpty()) {
|
|
|
+ data.setLinkId(ItsAsn.DATEX_LINK_TEXT);
|
|
|
+ }
|
|
|
+
|
|
|
+ CurrentLinkState traf = new CurrentLinkState();
|
|
|
+
|
|
|
+ traf.setLinkLinkIdNumber(new BerUTF8String(data.getLinkId()));
|
|
|
+ traf.setLinkSpeedRate(new BerInteger(data.getSpeed()));
|
|
|
+ traf.setLinkVolumeRate(new BerInteger(0));
|
|
|
+ traf.setLinkDensityRate(new BerInteger(data.getTrafficGrade()));
|
|
|
+ traf.setLinkTravelTimeQuantity(new BerInteger(data.getTravelTime()));
|
|
|
+ traf.setLinkDelayQuanity(new BerInteger(data.getDataResType()));
|
|
|
+ traf.setTfdtVehicleQueueLengthQuantity(new BerInteger(0));
|
|
|
+ traf.setTfdtOccupancyPercent(new BerInteger(0));
|
|
|
+ return traf;
|
|
|
+ }
|
|
|
}
|