/*     */ import java.io.BufferedInputStream;
/*     */ import java.io.BufferedOutputStream;
/*     */ import java.io.BufferedReader;
/*     */ import java.io.FileInputStream;
/*     */ import java.io.InputStream;
/*     */ import java.io.InputStreamReader;
/*     */ import java.net.HttpURLConnection;
/*     */ import java.net.URL;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.Properties;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.json.simple.JSONObject;
/*     */ 
/*     */ public class AnprStateSend
/*     */   extends Thread
/*     */ {
/*  22 */   private String[] g_strDB = new String[4];
/*  23 */   private String[] g_strFTP = new String[6];
/*  24 */   private String[] g_strFTPColl = new String[4];
/*     */   
/*  26 */   private String g_strTenel = "";
/*  27 */   private String g_strLane = "";
/*     */   
/*  29 */   private String g_strApiUrAnprStatusl = "";
/*     */   
/*  31 */   private final Logger logger = Logger.getLogger(AnprStateSend.class);
/*     */ 
/*     */   
/*     */   public AnprStateSend(String str) {
/*     */     try {
/*  36 */       String propFile = "./config.properties";
/*     */ 
/*     */       
/*  39 */       Properties props = new Properties();
/*     */ 
/*     */       
/*  42 */       FileInputStream fis = new FileInputStream(propFile);
/*     */ 
/*     */       
/*  45 */       props.load(new BufferedInputStream(fis));
/*     */ 
/*     */       
/*  48 */       this.g_strDB[0] = props.getProperty("db_driver");
/*  49 */       this.g_strDB[1] = props.getProperty("db_connect");
/*  50 */       this.g_strDB[2] = props.getProperty("db_id");
/*  51 */       this.g_strDB[3] = props.getProperty("db_pw");
/*     */ 
/*     */       
/*  54 */       this.g_strFTP[0] = props.getProperty("path_org");
/*  55 */       this.g_strFTP[1] = props.getProperty("ftp_ip");
/*  56 */       this.g_strFTP[2] = props.getProperty("ftp_id");
/*  57 */       this.g_strFTP[3] = props.getProperty("ftp_pw");
/*  58 */       this.g_strFTP[4] = props.getProperty("api_url");
/*  59 */       this.g_strFTP[5] = props.getProperty("path_desc");
/*     */       
/*  61 */       this.g_strFTPColl[0] = props.getProperty("coll_ftp_ip");
/*  62 */       this.g_strFTPColl[1] = props.getProperty("coll_ftp_id");
/*  63 */       this.g_strFTPColl[2] = props.getProperty("coll_ftp_pw");
/*  64 */       this.g_strFTPColl[3] = props.getProperty("center_ftp_ip");
/*     */       
/*  66 */       this.g_strTenel = props.getProperty("tennel_no");
/*  67 */       this.g_strLane = str;
/*     */       
/*  69 */       this.g_strApiUrAnprStatusl = props.getProperty("api_url_status");
/*     */       
/*  71 */       props.clear();
/*  72 */       props = null;
/*     */     }
/*  74 */     catch (Exception e) {
/*  75 */       e.printStackTrace();
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public void run() {
/*  84 */     runCarNoImageSend();
/*  85 */     this.logger.debug(String.format("=======================================================", new Object[0]));
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public void runCarNoImageSend() {
/*  92 */     Map<String, String> cctvID = new HashMap<>();
/*     */     
/*  94 */     cctvID.put("101", "A10401001");
/*  95 */     cctvID.put("102", "A10301002");
/*  96 */     cctvID.put("103", "A10201003");
/*  97 */     cctvID.put("104", "A10101004");
/*  98 */     cctvID.put("105", "A10111005");
/*  99 */     cctvID.put("106", "A10211006");
/* 100 */     cctvID.put("107", "A10311007");
/* 101 */     cctvID.put("108", "A10411008");
/* 102 */     cctvID.put("301", "A10503001");
/* 103 */     cctvID.put("302", "A10403002");
/* 104 */     cctvID.put("303", "A10303003");
/* 105 */     cctvID.put("304", "A10203004");
/* 106 */     cctvID.put("307", "A10213005");
/* 107 */     cctvID.put("308", "A10313006");
/* 108 */     cctvID.put("309", "A10413007");
/* 109 */     cctvID.put("310", "A10513008");
/*     */     
/* 111 */     Date date_now = new Date(System.currentTimeMillis());
/* 112 */     SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
/* 113 */     String strDate = sdf.format(date_now);
/* 114 */     this.logger.debug("===========" + strDate);
/*     */ 
/*     */     
/* 117 */     List<String> temp = new ArrayList<>();
/* 118 */     temp.add("13");
/* 119 */     temp.add("11");
/* 120 */     temp.add("12");
/*     */     
/* 122 */     int n = (int)(Math.random() * 1000.0D) % 3;
/*     */     
/* 124 */     JSONObject jsonParam = new JSONObject();
/* 125 */     jsonParam.put("camId", cctvID.get(String.valueOf(this.g_strTenel) + this.g_strLane));
/* 126 */     jsonParam.put("colctTime", strDate);
/* 127 */     jsonParam.put("camConectSttus", "0");
/* 128 */     jsonParam.put("rtuTp", temp.get(n % 3));
/* 129 */     jsonParam.put("bxDoorSttus", "0");
/* 130 */     jsonParam.put("camSdCardSttus", "0");
/* 131 */     this.logger.debug("============== : " + jsonParam.toJSONString());
/* 132 */     callAnprCarnoSend(jsonParam.toJSONString());
/* 133 */     jsonParam.clear();
/*     */   }
/*     */ 
/*     */   
/*     */   private void callAnprCarnoSend(String strJson) {
/* 138 */     HttpURLConnection connection = null;
/* 139 */     InputStream is = null;
/* 140 */     InputStreamReader isr = null;
/* 141 */     BufferedReader br = null;
/*     */     
/*     */     try {
/* 144 */       URL url = new URL(this.g_strApiUrAnprStatusl);
/* 145 */       this.logger.debug("==== 수집서버 주소  : " + this.g_strApiUrAnprStatusl);
/*     */       
/* 147 */       connection = (HttpURLConnection)url.openConnection();
/*     */       
/* 149 */       connection.setDoInput(true);
/* 150 */       connection.setDoOutput(true);
/* 151 */       connection.setUseCaches(false);
/* 152 */       connection.setRequestMethod("POST");
/*     */       
/* 154 */       connection.setConnectTimeout(30000);
/*     */       
/* 156 */       connection.setReadTimeout(30000);
/*     */ 
/*     */ 
/*     */       
/* 160 */       connection.setRequestProperty("Accept", "application/json");
/* 161 */       connection.setRequestProperty("Content-Type", "application/json");
/*     */ 
/*     */       
/* 164 */       BufferedOutputStream bos = new BufferedOutputStream(connection.getOutputStream());
/* 165 */       bos.write(strJson.getBytes("UTF-8"));
/* 166 */       bos.flush();
/* 167 */       bos.close();
/*     */       
/* 169 */       int resCode = connection.getResponseCode();
/* 170 */       StringBuffer sb = new StringBuffer();
/* 171 */       String inputLine = null;
/*     */       
/* 173 */       this.logger.debug("====  : " + resCode);
/* 174 */       if (resCode == 200) {
/* 175 */         is = connection.getInputStream();
/* 176 */         isr = new InputStreamReader(is, "UTF-8");
/* 177 */         br = new BufferedReader(isr);
/*     */         
/* 179 */         while ((inputLine = br.readLine()) != null) {
/* 180 */           sb.append(inputLine);
/*     */         }
/*     */         
/* 183 */         this.logger.debug("==== " + sb.toString());
/*     */       }
/* 185 */       else if (connection.getErrorStream() != null) {
/* 186 */         br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
/*     */         
/* 188 */         while ((inputLine = br.readLine()) != null) {
/* 189 */           sb.append(inputLine);
/*     */         }
/* 191 */         this.logger.debug("==== Http Error Resopnse : " + sb.toString());
/*     */       } else {
/* 193 */         this.logger.debug("==== Http Error Resopnse : " + sb.toString());
/*     */       }
/*     */     
/* 196 */     } catch (Exception e) {
/* 197 */       e.printStackTrace();
/* 198 */       this.logger.debug("==== Http Error Resopnse : ");
/*     */     } finally {
/*     */       try {
/* 201 */         if (is != null)
/* 202 */           is.close(); 
/* 203 */         if (isr != null)
/* 204 */           isr.close(); 
/* 205 */         if (br != null)
/* 206 */           br.close(); 
/* 207 */       } catch (Exception exception) {}
/*     */     } 
/*     */   }
/*     */ }


/* Location:              C:\Users\XIT_LBJ\Desktop\남산 혼잡통행료\운영환경 실 파일\3호 연계서버\car이미지자르\anpr스테이터스센드\anpr_status_send.jar!\AnprStateSend.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */