| 
					
				 | 
			
			
				@@ -2,33 +2,43 @@ package com.its.op.scheduler.job; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fasterxml.jackson.core.JsonProcessingException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fasterxml.jackson.databind.ObjectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.its.op.service.bis.BisProcessService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.its.op.config.AppUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.its.op.dto.its.unit.TbUnitSystSttsDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.its.op.service.bis.BisProcessService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.its.op.service.its.unit.TbUnitSystService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.its.op.websocket.ItsWebSocketMessage; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.its.op.websocket.ItsWebSocketSessionManager; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import lombok.AllArgsConstructor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import lombok.RequiredArgsConstructor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.core.env.Environment; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 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.Arrays; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Slf4j 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-@AllArgsConstructor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@RequiredArgsConstructor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class UnitSttsJobThread { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private final Environment environment; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private final TbUnitSystService unitSystService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private final BisProcessService bisService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ObjectMapper mapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private boolean isRunBis = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private BisProcessService bisService = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PostConstruct 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private void init() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.mapper = new ObjectMapper(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.isRunBis = Arrays.asList(environment.getActiveProfiles()).contains("bis"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (this.isRunBis) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("SUPPORT BIS INTERFACE....."); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.bisService = (BisProcessService) AppUtils.getBean(BisProcessService.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         log.info("{}", this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -52,14 +62,15 @@ public class UnitSttsJobThread { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // BIS Unit Stts 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<TbUnitSystSttsDto> bitUnitDto = this.bisService.findAllStts(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ItsWebSocketMessage bisMessage = new ItsWebSocketMessage("bisUnitStts", 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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (this.isRunBis && this.bisService != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<TbUnitSystSttsDto> bitUnitDto = this.bisService.findAllStts(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ItsWebSocketMessage bisMessage = new ItsWebSocketMessage("bisUnitStts", 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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         stopWatch.stop(); 
			 |