/*     */ import com.jcraft.jsch.SftpException;
/*     */ import java.io.BufferedInputStream;
/*     */ import java.io.File;
/*     */ import java.io.FileInputStream;
/*     */ import java.io.IOException;
/*     */ import java.sql.Connection;
/*     */ import java.sql.DriverManager;
/*     */ import java.sql.ResultSet;
/*     */ import java.util.Properties;
/*     */ import oracle.jdbc.OracleConnection;
/*     */ import oracle.jdbc.OraclePreparedStatement;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.apache.log4j.PropertyConfigurator;
/*     */ 
/*     */ 
/*     */ 
/*     */ public class LossDefaultCarImageSend
/*     */ {
/*  19 */   private String[] g_strDB = new String[4];
/*  20 */   private String[] g_strFTP = new String[6];
/*  21 */   private String[] g_strFTPColl = new String[4];
/*     */   
/*  23 */   private String g_strTenel = "";
/*     */   
/*  25 */   private final Logger logger = Logger.getLogger(LossDefaultCarImageSend.class);
/*     */   
/*     */   public static void main(String[] args) {
/*  28 */     LossDefaultCarImageSend obj = new LossDefaultCarImageSend();
/*     */     
/*     */     try {
/*  31 */       obj.sendDefaultCarImage();
/*  32 */     } catch (Exception e) {
/*  33 */       e.printStackTrace();
/*     */     } 
/*     */   }
/*     */   
/*     */   public LossDefaultCarImageSend() {
/*  38 */     PropertyConfigurator.configure("./log4j.properties");
/*     */ 
/*     */     
/*     */     try {
/*  42 */       String propFile = "./config.properties";
/*     */ 
/*     */       
/*  45 */       Properties props = new Properties();
/*     */ 
/*     */       
/*  48 */       FileInputStream fis = new FileInputStream(propFile);
/*     */ 
/*     */       
/*  51 */       props.load(new BufferedInputStream(fis));
/*     */ 
/*     */       
/*  54 */       this.g_strDB[0] = props.getProperty("db_driver");
/*  55 */       this.g_strDB[1] = props.getProperty("db_connect");
/*  56 */       this.g_strDB[2] = props.getProperty("db_id");
/*  57 */       this.g_strDB[3] = props.getProperty("db_pw");
/*     */ 
/*     */       
/*  60 */       this.g_strFTP[0] = props.getProperty("path_org");
/*  61 */       this.g_strFTP[1] = props.getProperty("ftp_ip");
/*  62 */       this.g_strFTP[2] = props.getProperty("ftp_id");
/*  63 */       this.g_strFTP[3] = props.getProperty("ftp_pw");
/*  64 */       this.g_strFTP[4] = props.getProperty("api_url");
/*  65 */       this.g_strFTP[5] = props.getProperty("path_desc");
/*     */       
/*  67 */       this.g_strFTPColl[0] = props.getProperty("coll_ftp_ip");
/*  68 */       this.g_strFTPColl[1] = props.getProperty("coll_ftp_id");
/*  69 */       this.g_strFTPColl[2] = props.getProperty("coll_ftp_pw");
/*  70 */       this.g_strFTPColl[3] = props.getProperty("center_ftp_ip");
/*     */       
/*  72 */       this.g_strTenel = props.getProperty("tennel_no");
/*     */       
/*  74 */       props.clear();
/*  75 */       props = null;
/*     */     }
/*  77 */     catch (Exception e) {
/*  78 */       this.logger.info("Exception : " + e);
/*     */     } 
/*     */   }
/*     */ 
/*     */   
/*     */   public String findFileList(String source, String prefix, String suffix) {
/*  84 */     File dir = new File(source);
/*  85 */     File[] fileList = dir.listFiles();
/*  86 */     if (fileList == null) {
/*  87 */       this.logger.debug("======== 12.5 :::" + source);
/*  88 */       return "";
/*     */     } 
/*     */     
/*  91 */     for (int i = 0; i < fileList.length; i++) {
/*  92 */       File file = fileList[i];
/*  93 */       if (file.isFile()) {
/*  94 */         String tempFileName = file.getName();
/*  95 */         if (tempFileName.startsWith(prefix)) {
/*  96 */           this.logger.info("=== = " + tempFileName);
/*     */           
/*  98 */           if (tempFileName.endsWith(suffix)) {
/*  99 */             return tempFileName;
/*     */           }
/*     */         } 
/*     */       } 
/*     */     } 
/* 104 */     return null;
/*     */   }
/*     */   
/*     */   private void sendDefaultCarImage() throws Exception {
/* 108 */     String sql = "";
/*     */ 
/*     */     
/* 111 */     OracleConnection conn = null;
/* 112 */     OraclePreparedStatement ps = null;
/* 113 */     OraclePreparedStatement ps2 = null;
/* 114 */     ResultSet rs = null;
/*     */     
/*     */     try {
/* 117 */       conn = (OracleConnection)getOrclConn();
/*     */       
/* 119 */       sql = "select FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, WORK_TIMES,  ";
/* 120 */       sql = String.valueOf(sql) + "  substr(CAR_NO, -4) || '_' ||    ";
/* 121 */       sql = String.valueOf(sql) + "  decode(BOOTH_ID, '01', '0.JPG', '02', '0.JPG', '03', '0.JPG', '04', '0.JPG'   ";
/* 122 */       sql = String.valueOf(sql) + "                  , '07', '1.JPG', '08', '1.JPG', '09', '1.JPG', '10', '1.JPG'  ";
/* 123 */       sql = String.valueOf(sql) + "  )  as car_no_4,   ";
/* 124 */       sql = String.valueOf(sql) + "  worker_id, seqno   ";
/* 125 */       sql = String.valueOf(sql) + " from  DEFAULT_FARE_READ_INFO where updater = 'PROCADD'";
/*     */       
/* 127 */       ps = (OraclePreparedStatement)conn.prepareStatement(sql);
/* 128 */       rs = ps.executeQuery(sql);
/*     */       
/* 130 */       String strPath = "";
/* 131 */       String pathDest = "";
/* 132 */       String strFindFileName = "";
/* 133 */       String strFileNameOld = "";
/* 134 */       String strFileNameNeo = "";
/* 135 */       while (rs.next()) {
/* 136 */         strPath = String.format("%s/%s/%s/send/", new Object[] { this.g_strFTP[0], rs.getString(4), rs.getString(2) });
/* 137 */         strFindFileName = String.format("%s%s%s_%s", new Object[] { rs.getString(3), rs.getString(4), rs.getString(5), rs.getString(6).substring(0, 4) });
/*     */         
/* 139 */         strFileNameOld = findFileList(strPath, strFindFileName, rs.getString(7));
/*     */         
/* 141 */         if (strFileNameOld == null || strFileNameOld == "") {
/*     */           continue;
/*     */         }
/* 144 */         strFileNameNeo = String.format("%s%s%s%s%s%sS.JPG", new Object[] { rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5), rs.getString(6) });
/*     */         
/* 146 */         pathDest = String.format("/DOTR/%s%s%s/0%s/IMAGE/", new Object[] { rs.getString(3), rs.getString(4), rs.getString(5), this.g_strTenel });
/*     */         
/* 148 */         callSendImage(strPath, pathDest, strFileNameOld, strFileNameNeo);
/* 149 */         callSendImageCenter(strPath, pathDest, strFileNameOld, strFileNameNeo);
/*     */ 
/*     */         
/* 152 */         sql = "update DEFAULT_FARE_READ_INFO set updater = 'PROCMOD' ";
/* 153 */         sql = String.valueOf(sql) + " where FARE_OFFICE_ID = ? and BOOTH_ID = ? and YEAR = ? and MONTH = ? and DAY = ? and WORK_TIMES = ? ";
/* 154 */         sql = String.valueOf(sql) + " and worker_id = ? and seqno = ? ";
/*     */         
/* 156 */         this.logger.info("=== = " + sql);
/*     */         
/* 158 */         ps2 = (OraclePreparedStatement)conn.prepareStatement(sql);
/* 159 */         ps2.setString(1, rs.getString(1));
/* 160 */         ps2.setString(2, rs.getString(2));
/* 161 */         ps2.setString(3, rs.getString(3));
/* 162 */         ps2.setString(4, rs.getString(4));
/* 163 */         ps2.setString(5, rs.getString(5));
/* 164 */         ps2.setString(6, rs.getString(6));
/*     */         
/* 166 */         ps2.setString(7, rs.getString(8));
/* 167 */         ps2.setString(8, rs.getString(9));
/*     */         
/* 169 */         ps2.execute();
/* 170 */         ps2.close();
/*     */       } 
/* 172 */       ps.close();
/* 173 */     } catch (Exception e) {
/* 174 */       this.logger.info("Exception : " + e);
/*     */     } finally {
/* 176 */       if (rs != null)
/* 177 */         rs.close(); 
/* 178 */       if (ps != null) {
/* 179 */         ps.close();
/*     */       }
/* 181 */       conn.close();
/*     */     } 
/* 183 */     this.logger.info(String.format("============= : DefaultCarDB 업데이트 2 후 ", new Object[0]));
/*     */   }
/*     */   
/*     */   public void callSendImage(String pathOrg, String pathDest, String old, String neo) {
/* 187 */     File file = new File(String.valueOf(pathOrg) + old);
/*     */     
/* 189 */     FTPUtil sftp = new FTPUtil();
/* 190 */     sftp.init(this.g_strFTP[1], this.g_strFTP[2], this.g_strFTP[3]);
/*     */     
/*     */     try {
/* 193 */       sftp.upload("/data2" + pathDest, file, old, neo);
/*     */       
/* 195 */       sftp.disconnect();
/* 196 */     } catch (SftpException e) {
/* 197 */       this.logger.info("Exception : " + e);
/* 198 */     } catch (IOException e) {
/* 199 */       this.logger.info("Exception : " + e);
/*     */     } 
/*     */   }
/*     */   
/*     */   public void callSendImageCenter(String pathOrg, String pathDest, String old, String neo) {
/* 204 */     File file = new File(String.valueOf(pathOrg) + old);
/*     */     
/* 206 */     FTPUtil sftp = new FTPUtil();
/* 207 */     sftp.init(this.g_strFTP[3], this.g_strFTP[2], this.g_strFTP[3]);
/*     */     
/*     */     try {
/* 210 */       sftp.upload(pathDest, file, old, neo);
/*     */       
/* 212 */       sftp.disconnect();
/* 213 */     } catch (SftpException e) {
/* 214 */       this.logger.info("Exception : " + e);
/* 215 */     } catch (IOException e) {
/* 216 */       this.logger.info("Exception : " + e);
/*     */     } 
/*     */ 
/*     */     
/* 220 */     OracleConnection conn = null;
/* 221 */     OraclePreparedStatement ps = null;
/*     */     try {
/* 223 */       conn = (OracleConnection)getOrclConnCenter();
/*     */       
/* 225 */       String sql = "update DEFAULT_FARE_READ_INFO set updater = 'PROCMOD' where updater = 'PROCADD'";
/* 226 */       ps = (OraclePreparedStatement)conn.prepareStatement(sql);
/* 227 */       ps.executeUpdate();
/* 228 */       ps.close();
/*     */       
/* 230 */       conn.close();
/* 231 */     } catch (Exception e) {
/* 232 */       e.printStackTrace();
/*     */     } 
/*     */   }
/*     */ 
/*     */   
/*     */   private Connection getOrclConn() throws Exception {
/* 238 */     Class.forName(this.g_strDB[0]);
/* 239 */     return DriverManager.getConnection(this.g_strDB[1], this.g_strDB[2], this.g_strDB[3]);
/*     */   }
/*     */ 
/*     */   
/*     */   private Connection getOrclConnCenter() throws Exception {
/* 244 */     Class.forName(this.g_strDB[0]);
/* 245 */     return DriverManager.getConnection("jdbc:oracle:thin:@150.50.46.11:1521:Ora91", "NAMSAN", "namsan");
/*     */   }
/*     */ }


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