|
@@ -0,0 +1,68 @@
|
|
|
+package com.its.api.scheduler.job;
|
|
|
+
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.its.api.bis.service.BisProcessService;
|
|
|
+import com.its.api.its.model.dto.unit.TbUnitSystSttsDto;
|
|
|
+import com.its.api.its.service.unit.TbUnitSystService;
|
|
|
+import com.its.api.websocket.ItsWebSocketMessage;
|
|
|
+import com.its.api.websocket.ItsWebSocketSessionManager;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StopWatch;
|
|
|
+import org.springframework.web.socket.TextMessage;
|
|
|
+
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@AllArgsConstructor
|
|
|
+@Service
|
|
|
+public class UnitSttsJobThread {
|
|
|
+
|
|
|
+ private final TbUnitSystService unitSystService;
|
|
|
+ private final BisProcessService bisService;
|
|
|
+ private ObjectMapper mapper;
|
|
|
+
|
|
|
+ @PostConstruct
|
|
|
+ private void init() {
|
|
|
+ this.mapper = new ObjectMapper();
|
|
|
+ log.info("{}", this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Async("schJobExecutor")
|
|
|
+ public void run() {
|
|
|
+
|
|
|
+ log.info("START: UnitSttsJobThread.run: {}", Thread.currentThread().getName());
|
|
|
+
|
|
|
+ StopWatch stopWatch = new StopWatch();
|
|
|
+ stopWatch.start();
|
|
|
+
|
|
|
+ // ITS Unit Stts
|
|
|
+ List<TbUnitSystSttsDto> itsUnitStts = this.unitSystService.findAllStts();
|
|
|
+ ItsWebSocketMessage itsMessage = new ItsWebSocketMessage("itsUnitStts", itsUnitStts);
|
|
|
+ try {
|
|
|
+ String itsSttsJsonData = this.mapper.writeValueAsString(itsMessage);
|
|
|
+ ItsWebSocketSessionManager.getInstance().sendBroadcastMessage(itsMessage.getCommand(), new TextMessage(itsSttsJsonData));
|
|
|
+ }
|
|
|
+ catch(JsonProcessingException e){
|
|
|
+ log.error("UnitSttsJobThread ItsFcltSttsDto Json parsing Exception: {}, {}", itsUnitStts, e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // BIS Unit Stts
|
|
|
+ List<TbUnitSystSttsDto> bitUnitDto = this.bisService.findAllStts();
|
|
|
+ ItsWebSocketMessage bisMessage = new ItsWebSocketMessage("itsUnitStts", bitUnitDto);
|
|
|
+ try {
|
|
|
+ String bitSttsJsonData = this.mapper.writeValueAsString(bisMessage);
|
|
|
+ ItsWebSocketSessionManager.getInstance().sendBroadcastMessage(bisMessage.getCommand(), new TextMessage(bitSttsJsonData));
|
|
|
+ }
|
|
|
+ catch(JsonProcessingException e){
|
|
|
+ log.error("UnitSttsJobThread BisFcltSttsDto Json parsing Exception: {}, {}", bitUnitDto, e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ stopWatch.stop();
|
|
|
+ log.info("--END: UnitSttsJobThread.run: {}, {} ms.", Thread.currentThread().getName(), stopWatch.getTotalTimeMillis());
|
|
|
+ }
|
|
|
+}
|