|
@@ -2,9 +2,9 @@ package com.sig.comm.server.xnet.server.process.response;
|
|
|
|
|
|
import com.sig.comm.server.dto.IntDto;
|
|
|
import com.sig.comm.server.dto.IntStatusDto;
|
|
|
-import com.sig.comm.server.kafka.KafkaProducerService;
|
|
|
import com.sig.comm.server.process.dbms.DbmsData;
|
|
|
import com.sig.comm.server.process.dbms.DbmsDataProcess;
|
|
|
+import com.sig.comm.server.process.kafka.KafkaDataProcess;
|
|
|
import com.sig.comm.server.xnet.server.process.protocol.SigProtocolConst;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.slf4j.MDC;
|
|
@@ -16,11 +16,11 @@ import java.util.List;
|
|
|
@Slf4j
|
|
|
public class SigPhaseChange implements SigCommResponse {
|
|
|
private final DbmsDataProcess dbmsDataProcess;
|
|
|
- private final KafkaProducerService kafkaProducer;
|
|
|
+ private final KafkaDataProcess kafkaDataProcess;
|
|
|
|
|
|
- public SigPhaseChange(DbmsDataProcess dbmsDataProcess, KafkaProducerService kafkaProducer) {
|
|
|
+ public SigPhaseChange(DbmsDataProcess dbmsDataProcess, KafkaDataProcess kafkaDataProcess) {
|
|
|
this.dbmsDataProcess = dbmsDataProcess;
|
|
|
- this.kafkaProducer = kafkaProducer;
|
|
|
+ this.kafkaDataProcess = kafkaDataProcess;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -55,8 +55,11 @@ public class SigPhaseChange implements SigCommResponse {
|
|
|
// } pkt_phase_change, *pkt_phase_changep;
|
|
|
|
|
|
long unixTimestamp = System.currentTimeMillis() / 1000L; // 초 단위로 변환
|
|
|
+ int phaseIdx;
|
|
|
+
|
|
|
+ List<IntStatusDto> statusLists = new ArrayList<>();
|
|
|
+// List<HashMap<String, Object>> lists = new ArrayList<>();
|
|
|
|
|
|
- List<HashMap<String, Object>> lists = new ArrayList<>();
|
|
|
String regionCd = packet.getCenter().getRegionCd();
|
|
|
String commDt = packet.getPacket().getCommDate();
|
|
|
int idx = SigProtocolConst.SIG_HEAD_SIZE;
|
|
@@ -71,6 +74,7 @@ public class SigPhaseChange implements SigCommResponse {
|
|
|
int status = (buffer[idx++] & 0xFF);
|
|
|
int count = (buffer[idx++] & 0xFF);
|
|
|
int cycle = (buffer[idx++] & 0xFF);
|
|
|
+ phaseIdx = idx;
|
|
|
int phaseA1 = (buffer[idx++] & 0xFF);
|
|
|
int phaseA2 = (buffer[idx++] & 0xFF);
|
|
|
int phaseA3 = (buffer[idx++] & 0xFF);
|
|
@@ -109,60 +113,84 @@ public class SigPhaseChange implements SigCommResponse {
|
|
|
int turnOffFlag = ((status&0x04)>0) ? 0x01 : 0x00; /* 소등 상태, 1: 소등, 0: 정상 */
|
|
|
int manualFlag = ((status&0xF0)>0) ? 0x01 : 0x00;
|
|
|
|
|
|
- param.put("REGION_CD", regionCd);
|
|
|
- param.put("INT_NO", intNo);
|
|
|
- param.put("COLLCT_DTIME", commDt);
|
|
|
- param.put("COMM_ON_OFF_FLAG", commStts);
|
|
|
- param.put("CONTRLR_OPER_MODE_CD", operMode);
|
|
|
- param.put("A_RING_PHASE_VAL", ringPhaseA);
|
|
|
- param.put("B_RING_PHASE_VAL", ringPhaseB);
|
|
|
- param.put("SIGLIGHT_TURNOFF_FLAG", turnOffFlag);
|
|
|
- param.put("SIGLIGHT_BLINK_FLAG", blinking);
|
|
|
- param.put("CONTRLR_MANUAL_FLAG", manualFlag);
|
|
|
- param.put("MAP_NO", mapNo);
|
|
|
- param.put("CONTRLR_TMDIFF_CONTRL_FLAG", tmDiffFlag);
|
|
|
- param.put("INT_SIG_CYCLE_CNT", count);
|
|
|
- param.put("INT_SIG_CYCLE_LEN", cycle);
|
|
|
- param.put("A_RING_1_PHASE_VAL", phaseA1);
|
|
|
- param.put("A_RING_2_PHASE_VAL", phaseA2);
|
|
|
- param.put("A_RING_3_PHASE_VAL", phaseA3);
|
|
|
- param.put("A_RING_4_PHASE_VAL", phaseA4);
|
|
|
- param.put("A_RING_5_PHASE_VAL", phaseA5);
|
|
|
- param.put("A_RING_6_PHASE_VAL", phaseA6);
|
|
|
- param.put("A_RING_7_PHASE_VAL", phaseA7);
|
|
|
- param.put("A_RING_8_PHASE_VAL", phaseA8);
|
|
|
- param.put("B_RING_1_PHASE_VAL", phaseB1);
|
|
|
- param.put("B_RING_2_PHASE_VAL", phaseB2);
|
|
|
- param.put("B_RING_3_PHASE_VAL", phaseB3);
|
|
|
- param.put("B_RING_4_PHASE_VAL", phaseB4);
|
|
|
- param.put("B_RING_5_PHASE_VAL", phaseB5);
|
|
|
- param.put("B_RING_6_PHASE_VAL", phaseB6);
|
|
|
- param.put("B_RING_7_PHASE_VAL", phaseB7);
|
|
|
- param.put("B_RING_8_PHASE_VAL", phaseB8);
|
|
|
- param.put("PPC_CONTRL_FLAG", ppcControl);
|
|
|
- param.put("GROUP_NO", groupNo);
|
|
|
-
|
|
|
- lists.add(param);
|
|
|
-
|
|
|
IntDto intDto = packet.getCenter().getIntMap().get(intNo);
|
|
|
- if (intDto != null && intDto.getNodeId() > 1000000000) {
|
|
|
- IntStatusDto intStatus = intDto.getStatus();
|
|
|
- if (intStatus != null) {
|
|
|
- intStatus.initStatus(unixTimestamp);
|
|
|
- intStatus.setOperStatus(mode);
|
|
|
- intStatus.setPhase(ringA, ringB);
|
|
|
- intStatus.setStatus(status);
|
|
|
- intStatus.setCycle(count, cycle);
|
|
|
- intStatus.setPhaseVal(phaseA1, phaseA2, phaseA3, phaseA4, phaseA5, phaseA6, phaseA7, phaseA8,
|
|
|
- phaseB1, phaseB2, phaseB3, phaseB4, phaseB5, phaseB6, phaseB7, phaseB8);
|
|
|
-
|
|
|
- this.kafkaProducer.sendNode(Long.toString(intDto.getNodeId()), intStatus.getKafkaData());
|
|
|
- this.kafkaProducer.sendSig(Long.toString(intDto.getNodeId()), intStatus.getKafkaData());
|
|
|
- }
|
|
|
+ if (intDto == null) {
|
|
|
+ log.warn("[{}], SigPhaseChange.response: Not Found IntNo: {}", packet.getCenter().getLogKey(), intNo);
|
|
|
+ intDto = IntDto.builder()
|
|
|
+ .isDeleted(false)
|
|
|
+ .regionCd(packet.getCenter().getRegionCd())
|
|
|
+ .intNo(intNo)
|
|
|
+ .intType(0)
|
|
|
+ .intLcType(1)
|
|
|
+ .intLampType(3)
|
|
|
+ .mainIntNo(0)
|
|
|
+ .groupNo(0)
|
|
|
+ .nodeId(0L)
|
|
|
+ .debug(false)
|
|
|
+ .status(new IntStatusDto(packet.getCenter().getRegionCd(), intNo, 0))
|
|
|
+ .build();
|
|
|
+ packet.getCenter().getIntMap().put(intNo, intDto);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- this.dbmsDataProcess.add(new DbmsData(DbmsData.DBMS_DATA_INT_PHASE_CHANGE, packet.getCenter(), false, lists));
|
|
|
+ IntStatusDto intStatus = intDto.getStatus();
|
|
|
+ intStatus.initStatus(unixTimestamp);
|
|
|
+
|
|
|
+// param.put("REGION_CD", regionCd);
|
|
|
+// param.put("INT_NO", intNo);
|
|
|
+// param.put("COLLCT_DTIME", commDt);
|
|
|
+// param.put("COMM_ON_OFF_FLAG", commStts);
|
|
|
+// param.put("CONTRLR_OPER_MODE_CD", operMode);
|
|
|
+// param.put("A_RING_PHASE_VAL", ringPhaseA);
|
|
|
+// param.put("B_RING_PHASE_VAL", ringPhaseB);
|
|
|
+// param.put("SIGLIGHT_TURNOFF_FLAG", turnOffFlag);
|
|
|
+// param.put("SIGLIGHT_BLINK_FLAG", blinking);
|
|
|
+// param.put("CONTRLR_MANUAL_FLAG", manualFlag);
|
|
|
+// param.put("MAP_NO", mapNo);
|
|
|
+// param.put("CONTRLR_TMDIFF_CONTRL_FLAG", tmDiffFlag);
|
|
|
+// param.put("INT_SIG_CYCLE_CNT", count);
|
|
|
+// param.put("INT_SIG_CYCLE_LEN", cycle);
|
|
|
+// param.put("A_RING_1_PHASE_VAL", phaseA1);
|
|
|
+// param.put("A_RING_2_PHASE_VAL", phaseA2);
|
|
|
+// param.put("A_RING_3_PHASE_VAL", phaseA3);
|
|
|
+// param.put("A_RING_4_PHASE_VAL", phaseA4);
|
|
|
+// param.put("A_RING_5_PHASE_VAL", phaseA5);
|
|
|
+// param.put("A_RING_6_PHASE_VAL", phaseA6);
|
|
|
+// param.put("A_RING_7_PHASE_VAL", phaseA7);
|
|
|
+// param.put("A_RING_8_PHASE_VAL", phaseA8);
|
|
|
+// param.put("B_RING_1_PHASE_VAL", phaseB1);
|
|
|
+// param.put("B_RING_2_PHASE_VAL", phaseB2);
|
|
|
+// param.put("B_RING_3_PHASE_VAL", phaseB3);
|
|
|
+// param.put("B_RING_4_PHASE_VAL", phaseB4);
|
|
|
+// param.put("B_RING_5_PHASE_VAL", phaseB5);
|
|
|
+// param.put("B_RING_6_PHASE_VAL", phaseB6);
|
|
|
+// param.put("B_RING_7_PHASE_VAL", phaseB7);
|
|
|
+// param.put("B_RING_8_PHASE_VAL", phaseB8);
|
|
|
+// param.put("PPC_CONTRL_FLAG", ppcControl);
|
|
|
+// param.put("GROUP_NO", groupNo);
|
|
|
+//
|
|
|
+// lists.add(param);
|
|
|
+
|
|
|
+ if (intDto.getNodeId() > 1000000000) {
|
|
|
+ intStatus.initStatus(unixTimestamp);
|
|
|
+ intStatus.setOperStatus(mode);
|
|
|
+ intStatus.setPhase(ringA, ringB);
|
|
|
+ intStatus.setStatus(status);
|
|
|
+ intStatus.setCycle(count, cycle);
|
|
|
+ intStatus.setPhaseVal(buffer, phaseIdx);
|
|
|
+
|
|
|
+// intStatus.setPhaseVal(phaseA1, phaseA2, phaseA3, phaseA4, phaseA5, phaseA6, phaseA7, phaseA8,
|
|
|
+// phaseB1, phaseB2, phaseB3, phaseB4, phaseB5, phaseB6, phaseB7, phaseB8);
|
|
|
+//
|
|
|
+// this.kafkaProducer.sendNode(Long.toString(intDto.getNodeId()), intStatus.getKafkaData());
|
|
|
+// this.kafkaProducer.sendSig(Long.toString(intDto.getNodeId()), intStatus.getKafkaData());
|
|
|
+ }
|
|
|
+
|
|
|
+ statusLists.add(intStatus);
|
|
|
+ }
|
|
|
+ if (!statusLists.isEmpty()) {
|
|
|
+ this.kafkaDataProcess.add(new DbmsData(DbmsData.DBMS_DATA_INT_PHASE_CHANGE, packet.getCenter(), false, statusLists));
|
|
|
+ this.dbmsDataProcess.add(new DbmsData(DbmsData.DBMS_DATA_INT_PHASE_CHANGE, packet.getCenter(), false, statusLists));
|
|
|
+ }
|
|
|
}
|
|
|
catch (Exception e) {
|
|
|
log.error("[{}], SigPhaseChange.response: Exception. will be closed. {}", packet.getCenter().getLogKey(), e.getMessage());
|