|
|
|
|
@ -17,7 +17,7 @@ public class MakeScarInfo {
|
|
|
|
|
private static String[] g_strDB = new String[4];
|
|
|
|
|
|
|
|
|
|
public static final Logger logger = Logger.getLogger(MakeScarInfo .class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
try {
|
|
|
|
|
@ -39,7 +39,7 @@ public class MakeScarInfo {
|
|
|
|
|
g_strDB[1] = props.getProperty("db_connect");
|
|
|
|
|
g_strDB[2] = props.getProperty("db_id");
|
|
|
|
|
g_strDB[3] = props.getProperty("db_pw");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 콘솔 출력
|
|
|
|
|
MakeScarInfo.logger.info(String.format("=== DB접속정보 : %s, %s, %s", g_strDB[1], g_strDB[2], g_strDB[3]));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
@ -48,29 +48,29 @@ public class MakeScarInfo {
|
|
|
|
|
|
|
|
|
|
MakeScarInfo obj = new MakeScarInfo();
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(args.length != 2) {
|
|
|
|
|
System.err.println("총 2개의 args를 입력하지 않았습니다.");
|
|
|
|
|
System.err.println("sFileDir, sFileName");
|
|
|
|
|
System.exit(0);
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double d = 0.0;
|
|
|
|
|
d = obj.runMakeScarMstBin(Long.parseLong(args[0]), Long.parseLong(args[1]));
|
|
|
|
|
MakeScarInfo.logger.info("=== 파일 생성 소요시간 : " + d);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
private Connection getOrclConn( ) throws Exception{
|
|
|
|
|
Class.forName(g_strDB[0]);
|
|
|
|
|
return DriverManager.getConnection(g_strDB[1], g_strDB[2], g_strDB[3]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private double runMakeScarMstBin(long nStart, long nEnd) throws Exception {
|
|
|
|
|
long start = System.currentTimeMillis(); // 작동 시간 측정용
|
|
|
|
|
|
|
|
|
|
@ -80,37 +80,40 @@ public class MakeScarInfo {
|
|
|
|
|
ResultSet rs = null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
conn = (Connection) getOrclConn(); // Connection 생성 시 Connection으로 형변환
|
|
|
|
|
|
|
|
|
|
// prepareStatement를 PreparedStatement으로 형변환
|
|
|
|
|
conn = getOrclConn(); // Connection 생성 시 Connection으로 형변환
|
|
|
|
|
|
|
|
|
|
// prepareStatement를 PreparedStatement으로 형변환
|
|
|
|
|
StringBuffer strSQL = new StringBuffer();
|
|
|
|
|
strSQL.append(" SELECT LPAD(SCAR_SEQ, 10, '0') AS SEQ, '00' AS REG, DECODE(REDU_CD, '00', '01', '02') AS DIV, LPAD(DECODE(FUN_CAR_CODE(NVL(CAR_NO,'0')),'없음','0', '숫자오류2', '0', '숫자오류3', '0', FUN_CAR_CODE(NVL(CAR_NO,'0'))), 10, '0') AS CARCODE") ;
|
|
|
|
|
strSQL.append(" FROM TB_CFS_SCAR_PL_MST A") ;
|
|
|
|
|
strSQL.append(" WHERE REDU_CD IN ('00')") ;
|
|
|
|
|
strSQL.append(" AND MODI_YN = 'N'") ;
|
|
|
|
|
strSQL.append(" ORDER BY SCAR_SEQ") ;
|
|
|
|
|
|
|
|
|
|
strSQL.append(" SELECT ");
|
|
|
|
|
strSQL.append(" LPAD(SCAR_SEQ, 10, '0') AS SEQ");
|
|
|
|
|
strSQL.append(" , '00' AS REG"); //
|
|
|
|
|
strSQL.append(" , DECODE(REDU_CD, '00', '01', '02') AS DIV"); //
|
|
|
|
|
strSQL.append(" , LPAD(DECODE(FUN_CAR_CODE(NVL(CAR_NO,'0')),'없음','0', '숫자오류2', '0', '숫자오류3', '0', FUN_CAR_CODE(NVL(CAR_NO,'0'))), 10, '0') AS CARCODE");
|
|
|
|
|
strSQL.append(" FROM TB_CFS_SCAR_PL_MST A") ;
|
|
|
|
|
strSQL.append(" WHERE REDU_CD IN ('00','01')") ; //
|
|
|
|
|
strSQL.append(" AND (END_DATE > SYSDATE OR END_DATE IS NULL)");
|
|
|
|
|
strSQL.append(" ORDER BY SCAR_SEQ") ;
|
|
|
|
|
|
|
|
|
|
logger.info(strSQL.toString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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( strSQL.toString() );
|
|
|
|
|
|
|
|
|
|
String str = "";
|
|
|
|
|
int n = 0;
|
|
|
|
|
File file = new File("/gpta/source-app/cfs/relay_jar/data/REDCARNO");
|
|
|
|
|
FileOutputStream fos = new FileOutputStream(file);
|
|
|
|
|
FileOutputStream fos = new FileOutputStream(file);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
n++;
|
|
|
|
|
if(n % 10000 == 0) {
|
|
|
|
|
logger.info("===== : " + n);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//red_carno_info.h(10자리+2자리+2자리+10자리)
|
|
|
|
|
str = String.format("%s%s%s%s", rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4));
|
|
|
|
|
fos.write(str.getBytes());
|
|
|
|
|
} // end while
|
|
|
|
|
|
|
|
|
|
} // end while
|
|
|
|
|
|
|
|
|
|
fos.close();
|
|
|
|
|
|
|
|
|
|
logger.info(strSQL.toString());
|
|
|
|
|
@ -121,12 +124,12 @@ public class MakeScarInfo {
|
|
|
|
|
|
|
|
|
|
return (end - start) / 1000.0; // insertBatchFileToDB 실행에 걸린 시간
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String sql = "update TB_CFS_MST_FLAG set RED_FLAG = '1', RED_SENDTIME = SYSDATE ";
|
|
|
|
|
ps = (PreparedStatement) conn.prepareStatement(sql);
|
|
|
|
|
ps = conn.prepareStatement(sql);
|
|
|
|
|
ps.executeUpdate();
|
|
|
|
|
conn.commit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}finally{
|
|
|
|
|
@ -134,7 +137,7 @@ public class MakeScarInfo {
|
|
|
|
|
rs.close();
|
|
|
|
|
if(ps != null)
|
|
|
|
|
ps.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -144,13 +147,13 @@ public class MakeScarInfo {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int setFtpData(File file, String fileNm) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FTPUtil sftp = new FTPUtil();
|
|
|
|
|
|
|
|
|
|
logger.debug("======== 업로드 시작 : " + fileNm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sftp.init("175.193.201.56", "tmax","tmax1234");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> map = new HashMap<String, String>();
|
|
|
|
|
map.put("return", "0");
|
|
|
|
|
|
|
|
|
|
@ -159,18 +162,18 @@ public class MakeScarInfo {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.debug("======== : " + map.get("return"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int nReturn = Integer.parseInt(map.get("return"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sftp.disconnect();
|
|
|
|
|
|
|
|
|
|
logger.debug("======== 업로드 끝 : " + nReturn);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|