SELECT AVI_CTLR_MNGM_NMBR,   
       AVI_ID,               
       LINK_ID,              
       AVI_LCTN_NM,          
       AVI_VALD_YN,          
       AVI_CTLR_IP,          
       AVI_CTLR_CMNC_PORT,   
       AVI_MAIN_CTLR_YN,     
       AVI_MNGM_LANE_NUM,    
       AVI_CMRA_NUM,         
       AVI_DTCT_NUM,         
       AVI_DTCT_NM,          
       AVI_CLCT_CYCL,        
       AVI_LAMP_AUTO_YN,     
       AVI_LAMP_ON_HMS,      
       AVI_LAMP_OFF_HMS,     
       AVI_LAMP_ON_YN,       
       X_CRDN,               
       Y_CRDN,               
       RMRK,                 
       DEL_YN,               
       FRST_REGR_NMBR,       
       FRST_RGST_DT,         
       LAST_CRPR_NMBR,       
       LAST_CRCT_DT          
  FROM TB_AVI_CTLR           


-- 등록 시설물
SELECT 'AVI' AS FAC_TYPE, AVI_ID AS FAC_ID, AVI_LCTN_NM AS FAC_NM, DEL_YN
  FROM TB_AVI_CTLR  
 WHERE DEL_YN = 'N'

--시설물 상태
SELECT 'AVI' AS FAC_TYPE, AVI_CTLR_MNGM_NMBR AS FAC_ID, 
       DECODE(CMNC_STTS_CD, 'CMS0', '1', 'CMS1', '0', '2') AS COMM,       
       DECODE(CBOX_DOOR_STTS_CD, 'CDS0', '0', 'CDS1', '1', '2') AS DOOR
  FROM TB_AVI_CTLR_STTS 
 WHERE UPDT_DT >= TO_CHAR(SYSDATE-2/1440, 'YYYYMMDDHH24MISS')
