|
|
|
|
@ -24,23 +24,23 @@ public class BasicInfoDB2File {
|
|
|
|
|
private static String[] g_strDB = new String[4];
|
|
|
|
|
|
|
|
|
|
private final Logger logger = Logger.getLogger(BasicInfoDB2File .class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 프로퍼티 파일 위치
|
|
|
|
|
String propFile = "/gpta/source-app/cfs/relay_jar/config.properties";
|
|
|
|
|
//String propFile = "./config.properties";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 프로퍼티 객체 생성
|
|
|
|
|
Properties props = new Properties();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 프로퍼티 파일 스트림에 담기
|
|
|
|
|
FileInputStream fis = new FileInputStream(propFile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 프로퍼티 파일 로딩
|
|
|
|
|
props.load(new java.io.BufferedInputStream(fis));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 항목 읽기
|
|
|
|
|
g_strDB[0] = props.getProperty("db_driver") ;
|
|
|
|
|
g_strDB[1] = props.getProperty("db_connect") ;
|
|
|
|
|
@ -52,13 +52,13 @@ public class BasicInfoDB2File {
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < strParam.length; i++)
|
|
|
|
|
System.out.println(String.format("=== 실행 구분 : [%d] - %s", i, strParam[i]));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String runGubun = args[0];
|
|
|
|
|
System.out.println("=== 실행 구분 : " + runGubun);
|
|
|
|
|
try {
|
|
|
|
|
try {
|
|
|
|
|
BasicInfoDB2File obj = new BasicInfoDB2File();
|
|
|
|
|
if(runGubun.equals("0") == true)
|
|
|
|
|
obj.runInsertTbRfid();
|
|
|
|
|
@ -68,55 +68,55 @@ public class BasicInfoDB2File {
|
|
|
|
|
}
|
|
|
|
|
else if(runGubun.equals("2") == true)
|
|
|
|
|
obj.runMakeExemptCsv();
|
|
|
|
|
else
|
|
|
|
|
else
|
|
|
|
|
System.out.println("=== 잘못된 파라미터 입력 ");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.exit(0);
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BasicInfoDB2File() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int getFtpData(String fileNm) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FTPUtil sftp = new FTPUtil();
|
|
|
|
|
|
|
|
|
|
this.logger.debug("======== 다운로드 시작 : " + fileNm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sftp.init("175.193.201.56", "tmax","tmax1234");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> map = new HashMap<String, String>();
|
|
|
|
|
map.put("return", "0");
|
|
|
|
|
sftp.download2("/gpta/source-web/cfs/relay/data/", fileNm, "/gpta/source-app/cfs/relay_jar/" + fileNm, map);
|
|
|
|
|
this.logger.debug("======== : " + map.get("return"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int nReturn = Integer.parseInt(map.get("return"));
|
|
|
|
|
if(nReturn > 0) {
|
|
|
|
|
sftp.fileDelete("/gpta/source-web/cfs/relay/data/" + fileNm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sftp.disconnect();
|
|
|
|
|
|
|
|
|
|
this.logger.debug("======== 다운로드 끝 : " + nReturn);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private Connection getOrclConn( ) throws Exception{
|
|
|
|
|
Class.forName(g_strDB[0]);
|
|
|
|
|
return DriverManager.getConnection(g_strDB[1], g_strDB[2], g_strDB[3]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("resource")
|
|
|
|
|
public double runInsertTbRfid() {
|
|
|
|
|
long start = System.currentTimeMillis(); // 작동 시간 측정용
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date time = new Date();
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMMdd");
|
|
|
|
|
|
|
|
|
|
@ -128,7 +128,7 @@ public class BasicInfoDB2File {
|
|
|
|
|
|
|
|
|
|
return (end - start) / 1000.0; // insertBatchFileToDB 실행에 걸린 시간
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String sql = "";
|
|
|
|
|
BufferedReader br = null;
|
|
|
|
|
|
|
|
|
|
@ -136,7 +136,7 @@ public class BasicInfoDB2File {
|
|
|
|
|
PreparedStatement ps = null; // 통상 PreparedStatement로 선언
|
|
|
|
|
try {
|
|
|
|
|
this.logger.debug("======== runInsertTbRfid start");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn = getOrclConn();
|
|
|
|
|
conn.setAutoCommit(false); // 자동 commit 끔
|
|
|
|
|
|
|
|
|
|
@ -146,7 +146,7 @@ public class BasicInfoDB2File {
|
|
|
|
|
|
|
|
|
|
this.logger.debug("======== runInsertTbRfid 2");
|
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sql = "Insert into RFID_INFO (RFID_TAG, CAR_NO, CAR_TYPE_KBN, DAMAGE_NO, WEEK_WRONG_NO, CAR_NO_HEX) ";
|
|
|
|
|
sql = sql + " values (?, ?, ?, ?,?, ?) ";
|
|
|
|
|
|
|
|
|
|
@ -181,7 +181,7 @@ public class BasicInfoDB2File {
|
|
|
|
|
str4 = array[3].replaceAll("\"", "");
|
|
|
|
|
str5 = array[4].replaceAll("\"", "");
|
|
|
|
|
str6 = PLUploader.runCarNo2Code(str2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ps.setString(1, str1);
|
|
|
|
|
ps.setString(2, str2);
|
|
|
|
|
ps.setString(3, str3);
|
|
|
|
|
@ -209,12 +209,12 @@ public class BasicInfoDB2File {
|
|
|
|
|
ps.executeBatch();
|
|
|
|
|
ps.clearBatch();
|
|
|
|
|
conn.commit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File file = new File(strFile);
|
|
|
|
|
File file2 = new File(String.format("/gpta/source-app/cfs/relay_jar/data/RFID_CARS_INFO_%s.CSV", sdf.format(time)));
|
|
|
|
|
if (file.exists()) {
|
|
|
|
|
file.renameTo(file2);
|
|
|
|
|
file.renameTo(file2);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
@ -228,7 +228,7 @@ public class BasicInfoDB2File {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.logger.debug("===== insert ok");
|
|
|
|
|
long end = System.currentTimeMillis(); // 작동시간 측정용
|
|
|
|
|
|
|
|
|
|
@ -238,7 +238,7 @@ public class BasicInfoDB2File {
|
|
|
|
|
|
|
|
|
|
public double runInsertTbIssue(String strFileName) {
|
|
|
|
|
long start = System.currentTimeMillis(); // 작동 시간 측정용
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date time = new Date();
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMMdd");
|
|
|
|
|
|
|
|
|
|
@ -250,27 +250,27 @@ public class BasicInfoDB2File {
|
|
|
|
|
|
|
|
|
|
return (end - start) / 1000.0; // insertBatchFileToDB 실행에 걸린 시간
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BufferedReader br = null;
|
|
|
|
|
|
|
|
|
|
Connection conn = null; // 통상 Connection으로 선언
|
|
|
|
|
PreparedStatement ps = null; // 통상 PreparedStatement로 선언
|
|
|
|
|
try {
|
|
|
|
|
this.logger.debug("======== runInsertTbIssue start");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn = getOrclConn();
|
|
|
|
|
conn.setAutoCommit(false); // 자동 commit 끔
|
|
|
|
|
|
|
|
|
|
this.logger.debug("======== runInsertTbRfid 2");
|
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuffer strSQL = new StringBuffer();
|
|
|
|
|
strSQL.append(" insert INTO T_PREFIX_INFO (CARD_COMP, COMP_CODE, BIN_CODE, ISS_CODE) ") ;
|
|
|
|
|
strSQL.append(" VALUES (?, ?, ?, ?)") ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.logger.debug("======== runInsertTbRfid 3");
|
|
|
|
|
|
|
|
|
|
this.logger.debug("======== runInsertTbRfid " + sdf.format(time));
|
|
|
|
|
@ -295,12 +295,12 @@ public class BasicInfoDB2File {
|
|
|
|
|
str2 = array[1].replaceAll("\"", "");
|
|
|
|
|
str3 = array[2].replaceAll("\"", "");
|
|
|
|
|
str4 = array[3].replaceAll("\"", "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ps.setString(1, str1);
|
|
|
|
|
ps.setString(2, str2);
|
|
|
|
|
ps.setString(3, str3);
|
|
|
|
|
ps.setString(4, str4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
this.logger.debug("======== runInsertTbRfid 5");
|
|
|
|
|
ps.executeUpdate();
|
|
|
|
|
@ -328,15 +328,16 @@ public class BasicInfoDB2File {
|
|
|
|
|
ps.executeBatch();
|
|
|
|
|
ps.clearBatch();
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
conn.commit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File file = new File(strFile);
|
|
|
|
|
File file2 = new File(String.format("/gpta/source-app/cfs/relay_jar/data/%s.CSV", strFileName));
|
|
|
|
|
if (file.exists()) {
|
|
|
|
|
file.renameTo(file2);
|
|
|
|
|
file.renameTo(file2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strSQL = new StringBuffer();
|
|
|
|
|
strSQL.append(" UPDATE TB_CFS_TABLENOM ") ;
|
|
|
|
|
strSQL.append(" set TCRD_BIN_RVS_NO = DECODE(TCRD_BIN_RVS_NO, '99', '0', TCRD_BIN_RVS_NO)+ 1, ") ;
|
|
|
|
|
@ -360,14 +361,14 @@ public class BasicInfoDB2File {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.logger.debug("===== insert ok");
|
|
|
|
|
long end = System.currentTimeMillis(); // 작동시간 측정용
|
|
|
|
|
|
|
|
|
|
this.logger.debug("======== runInsertTbUssue end");
|
|
|
|
|
return (end - start) / 1000.0; // insertBatchFileToDB 실행에 걸린 시간
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("resource")
|
|
|
|
|
@ -382,7 +383,7 @@ public class BasicInfoDB2File {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
conn = (Connection) getOrclConn(); // Connection 생성 시 Connection으로 형변환
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// prepareStatement를 PreparedStatement으로 형변환
|
|
|
|
|
|
|
|
|
|
sql= "select to_char(ENFORCE_DATE, 'YYYYMMDDHH24MISS'), CAR_NO, CARS_TYPE_ID, FILE_KIND_ID, DATA_SEQNO, YEAR, MONTH, DAY, DOCUMENT_NO, CAR_TYPE_NAME, OWNER";
|
|
|
|
|
@ -390,23 +391,22 @@ public class BasicInfoDB2File {
|
|
|
|
|
sql+= " , REPLACE_KBN, REPLACE_CAR_NO, END_KBN, REMARKS, TRANS_FILE_CREATE_YN, to_char(CREATE_DATE, 'YYYYMMDDHH24MISS')";
|
|
|
|
|
sql+= ", CREATER, to_char(UPDATE_DATE, 'YYYYMMDDHH24MISS'), UPDATER, EXEMPT_KBN, COMPANY_KBN, USE_REMARK";
|
|
|
|
|
sql+= " from exempt_cars_info";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ps = (PreparedStatement) conn.prepareStatement(sql);
|
|
|
|
|
|
|
|
|
|
rs = ps.executeQuery( sql );
|
|
|
|
|
rs.setFetchSize(10000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Statement stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,java.sql.ResultSet.CONCUR_READ_ONLY);
|
|
|
|
|
stmt.setFetchSize(10000);
|
|
|
|
|
stmt.setFetchSize(10000);
|
|
|
|
|
rs = stmt.executeQuery( sql );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String str = "";
|
|
|
|
|
int n = 0;
|
|
|
|
|
File file = new File("./vo co9n .csv");
|
|
|
|
|
FileOutputStream fos = new FileOutputStream(file);
|
|
|
|
|
FileOutputStream fos = new FileOutputStream(file);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
n++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
str = String.format("%s,%s,%s,%s,%s,", rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5));
|
|
|
|
|
str += String.format("%s,%s,%s,%s,%s,", rs.getString(6), rs.getString(7), rs.getString(8), rs.getString(9), rs.getString(10));
|
|
|
|
|
str += String.format("%s,%s,%s,%s,%s,", rs.getString(11), rs.getString(12), rs.getString(13), rs.getString(14), rs.getString(15));
|
|
|
|
|
@ -414,14 +414,14 @@ public class BasicInfoDB2File {
|
|
|
|
|
str += String.format("%s,%s,%s,%s,%s,", rs.getString(21), rs.getString(22), rs.getString(23), rs.getString(24), rs.getString(25));
|
|
|
|
|
str += String.format("%s,%s\r\n", rs.getString(26), rs.getString(27));
|
|
|
|
|
fos.write(str.getBytes());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(n % 100 == 0) {
|
|
|
|
|
System.out.println("===== : " + str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // end while
|
|
|
|
|
|
|
|
|
|
} // end while
|
|
|
|
|
|
|
|
|
|
fos.close();
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
@ -430,14 +430,14 @@ public class BasicInfoDB2File {
|
|
|
|
|
rs.close();
|
|
|
|
|
if(ps != null)
|
|
|
|
|
ps.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("===== insert ok");
|
|
|
|
|
long end = System.currentTimeMillis(); // 작동시간 측정용
|
|
|
|
|
return (end - start) / 1000.0; // insertBatchFileToDB 실행에 걸린 시간
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|