소스 정리
parent
4f15a3b31c
commit
a69e8200ef
@ -1,3 +1,11 @@
|
||||
# DayCloseAPI
|
||||
|
||||
혼잡통행료 웹서버 jar (티머니 관련)
|
||||
혼잡통행료 웹서버 jar (티머니 관련)
|
||||
|
||||
|
||||
SW = 삼원
|
||||
<br/>
|
||||
TM = 티머니
|
||||
<br/>
|
||||
TN = 터널
|
||||
<br/>
|
||||
@ -1,562 +0,0 @@
|
||||
package center.dao;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
import com.resources.data.*;
|
||||
/**
|
||||
* 파일 송수신 관련 테이블 처리 메소드<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2006-12-20 초기 작성
|
||||
*/
|
||||
public class CenterTransDAO {
|
||||
private Connection conn;
|
||||
/**
|
||||
* Constructor
|
||||
* @param conn
|
||||
* @throws SQLException
|
||||
*/
|
||||
public CenterTransDAO(Connection conn){
|
||||
this.conn = conn;
|
||||
}
|
||||
/**
|
||||
* 파일 송수신 상태 반영
|
||||
*/
|
||||
public Info getSendFileInfo( String sOrganCode,
|
||||
String sTransType,
|
||||
String sStatus) throws SQLException , Exception {
|
||||
Info data = null;
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
// 송수신 파일 정보 조회
|
||||
sbBuffer.append(" select his.SEQ, ")
|
||||
.append(" his.file_kind_id FILE_CODE, ")
|
||||
.append(" his.FILE_NAME, ")
|
||||
.append(" his.DIR_NAME, ")
|
||||
.append(" info.RECORD_LEN REC_LEN, ")
|
||||
.append(" info.RECORD_CNT REC_CNT, ")
|
||||
.append(" info.SEQ_CNT ")
|
||||
.append(" from FILE_KIND_CODE_INFO info, ")
|
||||
.append(" FILE_TRANS_HISTORY his ")
|
||||
.append(" where info.file_kind_id = his.file_kind_id ")
|
||||
.append(" and his.FARE_OFFICE_ID = ? ")
|
||||
.append(" and his.file_trans_kbn = ? ")
|
||||
.append(" and his.FILE_TRANS_YN = ? ")
|
||||
.append(" order by seq ")
|
||||
;
|
||||
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
ps.setString(idx++ , sOrganCode);
|
||||
ps.setString(idx++ , sTransType);
|
||||
ps.setString(idx++ , sStatus);
|
||||
|
||||
rs = ps.executeQuery();
|
||||
if ( rs.next() ){
|
||||
data = new Info();
|
||||
data.setLong ("SEQ" , rs.getLong ("SEQ") );
|
||||
data.setString("FILE_CODE" , rs.getString("FILE_CODE") );
|
||||
data.setString("FILE_NAME" , rs.getString("FILE_NAME") );
|
||||
data.setString("DIR_NAME" , rs.getString("DIR_NAME") );
|
||||
data.setInt ("REC_LEN" , rs.getInt ("REC_LEN") );
|
||||
data.setInt ("REC_CNT" , rs.getInt ("REC_CNT") );
|
||||
data.setInt ("SEQ_CNT" , rs.getInt ("SEQ_CNT") );
|
||||
}
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
if(rs != null){ try{ rs.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* 파일 송수신 상태 반영
|
||||
*/
|
||||
public Info getFileInfo( String sFileCode) throws SQLException , Exception {
|
||||
Info data = null;
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
// 송수신 파일 정보 조회
|
||||
sbBuffer.append(" select file_kind_id FILE_CODE, ")
|
||||
.append(" RECORD_LEN REC_LEN, ")
|
||||
.append(" RECORD_CNT REC_CNT, ")
|
||||
.append(" SEQ_CNT, ")
|
||||
.append(" FILE_DIR ")
|
||||
.append(" from FILE_KIND_CODE_INFO ")
|
||||
.append(" where TRIM(file_kind_id) = ? ");
|
||||
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
ps.setString(idx++ , sFileCode);
|
||||
|
||||
rs = ps.executeQuery();
|
||||
if ( rs.next() ){
|
||||
data = new Info();
|
||||
data.setString("FILE_CODE" , rs.getString("FILE_CODE") );
|
||||
data.setInt ("REC_LEN" , rs.getInt("REC_LEN") );
|
||||
data.setInt ("REC_CNT" , rs.getInt("REC_CNT") );
|
||||
data.setInt ("SEQ_CNT" , rs.getInt("SEQ_CNT") );
|
||||
data.setString("FILE_DIR" , rs.getString("FILE_DIR") );
|
||||
}
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
if(rs != null){ try{ rs.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* 파일 송수신 상태 수정
|
||||
*/
|
||||
public void updTransFileInfo(long nSeq ,
|
||||
String sStatus,
|
||||
String sUpdater) throws SQLException , Exception {
|
||||
PreparedStatement ps = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
sbBuffer.append(" update FILE_TRANS_HISTORY ")
|
||||
.append(" set FILE_TRANS_YN = ?, ")
|
||||
.append(" SEND_DATE = SYSDATE, ")
|
||||
.append(" UPDATE_DATE = SYSDATE, ")
|
||||
.append(" UPDATER = ? ")
|
||||
.append(" WHERE SEQ = ? ")
|
||||
.append(" and file_trans_kbn = ? ")
|
||||
.append(" and FILE_TRANS_YN = ? ");
|
||||
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
ps.setString(idx++ , sStatus );
|
||||
ps.setString(idx++ , sUpdater);
|
||||
ps.setLong (idx++ , nSeq);
|
||||
ps.setString(idx++ , "S" );
|
||||
ps.setString(idx++ , "N" );
|
||||
|
||||
if( ps.executeUpdate() != 1){
|
||||
throw new SQLException ("FILE_TRANS_HISTORY 반영 실패");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 송수신파일 정보 INSERT
|
||||
*/
|
||||
public void insertRecvFileInfo(Info data) throws SQLException , Exception {
|
||||
PreparedStatement ps = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
sbBuffer.append(" INSERT INTO FILE_TRANS_HISTORY ( ")
|
||||
.append(" SEQ, ")
|
||||
.append(" FILE_KIND_ID, ")
|
||||
.append(" PASS_DATE, ")
|
||||
.append(" FORMAT_DATE, ")
|
||||
.append(" FARE_OFFICE_ID, ")
|
||||
.append(" FILE_TRANS_KBN, ")
|
||||
.append(" FILE_TRANS_YN, ")
|
||||
.append(" DATA_PROCESS_KBN, ")
|
||||
.append(" DIR_NAME, ")
|
||||
.append(" FILE_NAME, ")
|
||||
.append(" CREATE_DATE, ")
|
||||
.append(" CREATER , ")
|
||||
.append(" UPDATE_DATE, ")
|
||||
.append(" UPDATER ) ")
|
||||
.append(" VALUES ( FILE_TRANS_SEQ.NEXTVAL, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE, ? , SYSDATE, ? ) ");
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
|
||||
ps.setString(idx++ , data.getString("FILE_KIND_ID"));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE"));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE"));
|
||||
ps.setString(idx++ , data.getString("FARE_OFFICE_ID"));
|
||||
ps.setString(idx++ , data.getString("FILE_TRANS_KBN"));
|
||||
ps.setString(idx++ , data.getString("FILE_TRANS_YN"));
|
||||
ps.setString(idx++ , data.getString("DATA_PROCESS_KBN"));
|
||||
ps.setString(idx++ , data.getString("DIR_NAME"));
|
||||
ps.setString(idx++ , data.getString("FILE_NAME"));
|
||||
ps.setString(idx++ , data.getString("CREATER"));
|
||||
ps.setString(idx++ , data.getString("CREATER"));
|
||||
|
||||
if( ps.executeUpdate() != 1){
|
||||
throw new SQLException ("FILE_TRANS_HISTORY 반영 실패");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 송수신파일 정보 INSERT
|
||||
*/
|
||||
public long getNextSeq(String sFileKindID) throws Exception{
|
||||
long nSeqNo = 0;
|
||||
PreparedStatement ps = null;
|
||||
PreparedStatement psUpd = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
ResultSet rs = null;
|
||||
try{
|
||||
sbBuffer.append(" select Last_data_no+1 from file_kind_code_info ")
|
||||
.append(" where file_kind_id = ? ");
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
ps.setString(idx++ , sFileKindID);
|
||||
rs = ps.executeQuery();
|
||||
if(rs.next()){
|
||||
nSeqNo = rs.getLong(1);
|
||||
psUpd = conn.prepareStatement(" update file_kind_code_info set Last_data_no = ? where file_kind_id = ? ");
|
||||
idx = 1 ;
|
||||
psUpd.setLong (idx++ , nSeqNo);
|
||||
psUpd.setString(idx++ , sFileKindID);
|
||||
psUpd.executeUpdate();
|
||||
if( psUpd.executeUpdate() != 1){
|
||||
throw new SQLException ("file_kind_code_info 반영 실패");
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(rs != null){ try{ rs.close(); }catch(Exception ignore){} }
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
if(psUpd != null){ try{ psUpd.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
return nSeqNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 송수신파일 정보 INSERT
|
||||
*/
|
||||
public void insertFileTransInfo(Info data) throws SQLException , Exception {
|
||||
PreparedStatement ps = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
sbBuffer.append(" INSERT INTO FILE_TRANS_INFO ( ")
|
||||
.append(" FILE_KIND_ID, ")
|
||||
.append(" YEAR, ")
|
||||
.append(" MONTH, ")
|
||||
.append(" DAY, ")
|
||||
.append(" DATA_SEQNO, ")
|
||||
.append(" FILE_TRANS_YN, ")
|
||||
.append(" FORMAT_DATE, ")
|
||||
.append(" DIR_NAME , ")
|
||||
.append(" FILE_NAME, ")
|
||||
.append(" DATA_PROCESS_KBN, ")
|
||||
.append(" CREATE_DATE, ")
|
||||
.append(" CREATER, ")
|
||||
.append(" UPDATE_DATE, ")
|
||||
.append(" UPDATER) ")
|
||||
.append(" VALUES ( ?, ?, ?, ?, ?, '1', SYSDATE, ?, ?, ?, SYSDATE, ? , SYSDATE, ? ) ");
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
|
||||
ps.setString(idx++ , data.getString("FILE_KIND_ID"));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE").substring(0,4));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE").substring(4,6));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE").substring(6,8));
|
||||
ps.setLong (idx++ , data.getLong ("DATA_SEQNO"));
|
||||
ps.setString(idx++ , data.getString("DIR_NAME"));
|
||||
ps.setString(idx++ , data.getString("FILE_NAME"));
|
||||
ps.setString(idx++ , "R");
|
||||
ps.setString(idx++ , data.getString("CREATER"));
|
||||
ps.setString(idx++ , data.getString("CREATER"));
|
||||
|
||||
if( ps.executeUpdate() != 1){
|
||||
throw new SQLException ("FILE_TRANS_INFO 반영 실패");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 송수신파일 정보 INSERT
|
||||
*/
|
||||
public void insertOfficeTransInfo(Info data) throws SQLException , Exception {
|
||||
PreparedStatement ps = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
sbBuffer.append(" INSERT INTO office_trans_info ( ")
|
||||
.append(" FILE_KIND_ID, ")
|
||||
.append(" YEAR, ")
|
||||
.append(" MONTH, ")
|
||||
.append(" DAY, ")
|
||||
.append(" DATA_SEQNO, ")
|
||||
.append(" FARE_OFFICE_ID, ")
|
||||
.append(" DATA_PROCESS_KBN, ")
|
||||
.append(" CREATE_DATE, ")
|
||||
.append(" CREATER ) ")
|
||||
.append(" VALUES ( ?, ?, ?, ?, ?, ?, ?, SYSDATE, ? ) ");
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
|
||||
ps.setString(idx++ , data.getString("FILE_KIND_ID"));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE").substring(0,4));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE").substring(4,6));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE").substring(6,8));
|
||||
ps.setLong (idx++ , data.getLong ("DATA_SEQNO"));
|
||||
ps.setString(idx++ , data.getString("FARE_OFFICE_ID"));
|
||||
ps.setString(idx++ , "R");
|
||||
ps.setString(idx++ , data.getString("CREATER"));
|
||||
|
||||
if( ps.executeUpdate() != 1){
|
||||
throw new SQLException ("office_trans_info 반영 실패");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 파일 송수신 상태 반영
|
||||
*/
|
||||
public Info getTunnelSendInfo( String sOrganCode) throws SQLException , Exception {
|
||||
Info data = null;
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
// 송수신 파일 정보 조회
|
||||
sbBuffer.append(" select file_.file_name FILE_NAME, ")
|
||||
.append(" file_.dir_name DIR_NAME, ")
|
||||
.append(" office.file_kind_id FILE_CODE, ")
|
||||
.append(" file_.data_seqno SEQ, ")
|
||||
.append(" info.record_len REC_LEN, ")
|
||||
.append(" info.record_cnt REC_CNT, ")
|
||||
.append(" info.seq_cnt SEQ_CNT ")
|
||||
.append(" from file_kind_code_info info, ")
|
||||
.append(" file_trans_info file_, ")
|
||||
.append(" office_trans_info office ")
|
||||
.append(" where file_.data_seqno = office.data_seqno ")
|
||||
.append(" and file_.file_kind_id = office.file_kind_id ")
|
||||
.append(" and info.file_kind_id = file_.file_kind_id ")
|
||||
.append(" and office.fare_office_id = ? ")
|
||||
.append(" and office.data_process_kbn='R' ")
|
||||
.append(" order by file_.create_date asc ");
|
||||
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
ps.setString(idx++ , sOrganCode);
|
||||
|
||||
rs = ps.executeQuery();
|
||||
if ( rs.next() ){
|
||||
data = new Info();
|
||||
data.setString("SEQ" , rs.getString("SEQ") );
|
||||
data.setString("FILE_CODE" , rs.getString("FILE_CODE") );
|
||||
data.setString("FILE_NAME" , rs.getString("FILE_NAME") );
|
||||
data.setString("DIR_NAME" , rs.getString("DIR_NAME") );
|
||||
data.setInt ("REC_LEN" , rs.getInt ("REC_LEN") );
|
||||
data.setInt ("REC_CNT" , rs.getInt ("REC_CNT") );
|
||||
data.setInt ("SEQ_CNT" , rs.getInt ("SEQ_CNT") );
|
||||
}
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
if(rs != null){ try{ rs.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* 파일 송수신 상태 수정
|
||||
*/
|
||||
public void updTunnelSendInfo(String sDataSeq, String sOfficeID, String sFileKindID) throws SQLException , Exception {
|
||||
PreparedStatement ps = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
sbBuffer.append(" update office_trans_info ")
|
||||
.append(" set data_process_kbn = 'S', ")
|
||||
.append(" update_date = sysdate, ")
|
||||
.append(" updater = 'communicat' ")
|
||||
.append(" WHERE data_seqno = ? ")
|
||||
.append(" and fare_office_id = ? ")
|
||||
.append(" and file_kind_id = ? ");
|
||||
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
ps.setString(idx++ , sDataSeq );
|
||||
ps.setString(idx++ , sOfficeID );
|
||||
ps.setString(idx++ , sFileKindID );
|
||||
|
||||
if( ps.executeUpdate() != 1){
|
||||
throw new SQLException ("office_trans_info 반영 실패");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 파일 송수신 상태 수정
|
||||
*/
|
||||
public void insertCardTransLog(String sFileName, String sOfficeID, String sKBN, String sLog) throws SQLException , Exception {
|
||||
PreparedStatement ps = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
sbBuffer.append(" INSERT INTO Card_Trans_Log_INFO ( ")
|
||||
.append(" D_ST_DATE, ")
|
||||
.append(" D_ST_TIME, ")
|
||||
.append(" D_ED_DATE, ")
|
||||
.append(" D_ED_TIME, ")
|
||||
.append(" T_FILE_NAME, ")
|
||||
.append(" C_CARD_KBN, ")
|
||||
.append(" FARE_OFFICE_ID, ")
|
||||
.append(" C_STATUS, ")
|
||||
.append(" T_MESSAGE, ")
|
||||
.append(" ISSUE_OFFICE_ID ) ")
|
||||
.append(" VALUES (")
|
||||
.append(" to_char(sysdate,'YYYYMMDD'), ")
|
||||
.append(" to_char(sysdate,'HH24MISS'), ")
|
||||
.append(" to_char(sysdate,'YYYYMMDD'), ")
|
||||
.append(" to_char(sysdate,'HH24MISS'), ")
|
||||
.append(" ?, ?, ?, ")
|
||||
.append(" 'C', ")
|
||||
.append(" ?, ")
|
||||
.append(" '99' ) ");
|
||||
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
|
||||
ps.setString(idx++ , sFileName);
|
||||
ps.setString(idx++ , sKBN);
|
||||
ps.setString(idx++ , sOfficeID);
|
||||
ps.setString(idx++ , sLog);
|
||||
|
||||
if( ps.executeUpdate() != 1){
|
||||
throw new SQLException ("Card_Trans_Log_INFO 반영 실패");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 파일 송수신 상태 반영
|
||||
*/
|
||||
public MultiInfo getRecvFile() throws SQLException , Exception {
|
||||
MultiInfo mData = new MultiInfo();
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try{
|
||||
String sQuery
|
||||
= " SELECT HIS.SEQ, "
|
||||
+ " HIS.FILE_KIND_ID, "
|
||||
+ " HIS.DIR_NAME, "
|
||||
+ " HIS.FILE_NAME, "
|
||||
+ " HIS.FORMAT_DATE, "
|
||||
+ " INFO.RECORD_LEN, "
|
||||
+ " INFO.RECORD_CNT, "
|
||||
+ " INFO.SEQ_CNT "
|
||||
+ " FROM FILE_TRANS_HISTORY HIS, "
|
||||
+ " FILE_KIND_CODE_INFO INFO "
|
||||
+ " WHERE HIS.FILE_TRANS_KBN = 'R' "
|
||||
+ " AND HIS.FILE_TRANS_YN = 'Y' "
|
||||
+ " AND HIS.DATA_PROCESS_KBN = '0' "
|
||||
+ " AND INFO.FILE_KIND_ID = HIS.FILE_KIND_ID "
|
||||
+ " ORDER BY SEQ ";
|
||||
|
||||
ps = conn.prepareStatement(sQuery);
|
||||
rs = ps.executeQuery();
|
||||
while ( rs.next() ){
|
||||
Info data = new Info();
|
||||
data.putInt ("SEQ" , rs.getInt("SEQ") );
|
||||
data.putString("FILE_KIND_ID" , rs.getString("FILE_KIND_ID") );
|
||||
data.putString("DIR_NAME" , rs.getString("DIR_NAME") );
|
||||
data.putString("FILE_NAME" , rs.getString("FILE_NAME") );
|
||||
data.putString("FORMAT_DATE" , rs.getString("FORMAT_DATE") );
|
||||
|
||||
mData.addData(data);
|
||||
}
|
||||
}finally{
|
||||
if(rs != null){ try{ rs.close(); }catch(Exception ignore){} }
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
return mData;
|
||||
}
|
||||
/**
|
||||
* 파일 송수신 상태 수정
|
||||
*/
|
||||
public void updateFileTransHistory(long nSeq, String sStatus, String sUpdater) throws SQLException , Exception {
|
||||
PreparedStatement psUpdate = null;
|
||||
try{
|
||||
String sQuery = " UPDATE FILE_TRANS_HISTORY "
|
||||
+ " SET DATA_PROCESS_KBN = ?, "
|
||||
+ " UPDATER = ?, "
|
||||
+ " UPDATE_DATE = SYSDATE "
|
||||
+ " WHERE SEQ = ? ";
|
||||
int idx = 1 ;
|
||||
psUpdate = conn.prepareStatement(sQuery);
|
||||
psUpdate.setString(idx++ , sStatus);
|
||||
psUpdate.setString(idx++ , sUpdater);
|
||||
psUpdate.setLong (idx++ , nSeq);
|
||||
|
||||
if( psUpdate.executeUpdate() != 1){
|
||||
throw new SQLException ("FILE_TRANS_HISTORY 반영 실패");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(psUpdate != null){ try{ psUpdate.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 송수신파일 정보 INSERT
|
||||
*/
|
||||
public void insertFileTransHistory(Info data) throws SQLException , Exception {
|
||||
PreparedStatement ps = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
sbBuffer.append(" INSERT INTO FILE_TRANS_HISTORY ( ")
|
||||
.append(" SEQ, ")
|
||||
.append(" FILE_KIND_ID, ")
|
||||
.append(" PASS_DATE, ")
|
||||
.append(" FORMAT_DATE, ")
|
||||
.append(" FARE_OFFICE_ID, ")
|
||||
.append(" FILE_TRANS_KBN, ")
|
||||
.append(" FILE_TRANS_YN, ")
|
||||
.append(" DATA_PROCESS_KBN, ")
|
||||
.append(" DIR_NAME, ")
|
||||
.append(" FILE_NAME, ")
|
||||
.append(" CREATE_DATE, ")
|
||||
.append(" CREATER , ")
|
||||
.append(" UPDATE_DATE, ")
|
||||
.append(" UPDATER ) ")
|
||||
.append(" VALUES ( FILE_TRANS_SEQ.NEXTVAL, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE, ? , SYSDATE, ? ) ");
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
|
||||
ps.setString(idx++ , data.getString("FILE_KIND_ID"));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE"));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE"));
|
||||
ps.setString(idx++ , data.getString("FARE_OFFICE_ID"));
|
||||
ps.setString(idx++ , data.getString("FILE_TRANS_KBN"));
|
||||
ps.setString(idx++ , data.getString("FILE_TRANS_YN"));
|
||||
ps.setString(idx++ , data.getString("DATA_PROCESS_KBN"));
|
||||
ps.setString(idx++ , data.getString("DIR_NAME"));
|
||||
ps.setString(idx++ , data.getString("FILE_NAME"));
|
||||
ps.setString(idx++ , data.getString("CREATER"));
|
||||
ps.setString(idx++ , data.getString("CREATER"));
|
||||
|
||||
if( ps.executeUpdate() != 1){
|
||||
throw new SQLException ("FILE_TRANS_HISTORY 반영 실패");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,328 +0,0 @@
|
||||
package center.dao;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.resources.data.Info;
|
||||
/**
|
||||
* 파일 송수신 관련 테이블 처리 메소드<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class VanTransDAO {
|
||||
private Connection conn;
|
||||
public VanTransDAO(Connection conn){
|
||||
this.conn = conn;
|
||||
}
|
||||
/**
|
||||
* 파일 송수신 상태 반영
|
||||
*/
|
||||
public Info getSendFileInfo( String sOrganCode,
|
||||
String sTransType,
|
||||
String sStatus) throws SQLException , Exception {
|
||||
Info data = null;
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
// 송수신 파일 정보 조회
|
||||
sbBuffer.append(" select his.SEQ, ")
|
||||
.append(" his.file_kind_id FILE_CODE, ")
|
||||
.append(" his.FILE_NAME, ")
|
||||
.append(" his.DIR_NAME, ")
|
||||
.append(" info.RECORD_LEN REC_LEN, ")
|
||||
.append(" info.RECORD_CNT REC_CNT, ")
|
||||
.append(" info.SEQ_CNT ")
|
||||
.append(" from FILE_KIND_CODE_INFO info, ")
|
||||
.append(" FILE_TRANS_HISTORY his ")
|
||||
.append(" where info.file_kind_id = his.file_kind_id ")
|
||||
.append(" and his.FARE_OFFICE_ID = ?")
|
||||
.append(" and his.file_trans_kbn = ? ")
|
||||
.append(" and his.FILE_TRANS_YN = ? ")
|
||||
.append(" order by SEQ ")
|
||||
;
|
||||
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
ps.setString(idx++ , sOrganCode);
|
||||
ps.setString(idx++ , sTransType);
|
||||
ps.setString(idx++ , sStatus);
|
||||
|
||||
rs = ps.executeQuery();
|
||||
if ( rs.next() ){
|
||||
data = new Info();
|
||||
data.setLong ("SEQ" , rs.getLong ("SEQ") );
|
||||
data.setString("FILE_CODE" , rs.getString("FILE_CODE") );
|
||||
data.setString("FILE_NAME" , rs.getString("FILE_NAME") );
|
||||
data.setString("DIR_NAME" , rs.getString("DIR_NAME") );
|
||||
data.setInt ("REC_LEN" , rs.getInt ("REC_LEN") );
|
||||
data.setInt ("REC_CNT" , rs.getInt ("REC_CNT") );
|
||||
data.setInt ("SEQ_CNT" , rs.getInt ("SEQ_CNT") );
|
||||
}
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
if(rs != null){ try{ rs.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* 파일 송수신 상태 반영
|
||||
*/
|
||||
public Info getFileInfo( String sFileCode) throws SQLException , Exception {
|
||||
Info data = null;
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
// 송수신 파일 정보 조회
|
||||
sbBuffer.append(" select file_kind_id FILE_CODE, ")
|
||||
.append(" RECORD_LEN REC_LEN, ")
|
||||
.append(" RECORD_CNT REC_CNT, ")
|
||||
.append(" SEQ_CNT, ")
|
||||
.append(" FILE_DIR ")
|
||||
.append(" from FILE_KIND_CODE_INFO ")
|
||||
.append(" where TRIM(file_kind_id) = ? ");
|
||||
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
ps.setString(idx++ , sFileCode);
|
||||
|
||||
rs = ps.executeQuery();
|
||||
if ( rs.next() ){
|
||||
data = new Info();
|
||||
data.setString("FILE_CODE" , rs.getString("FILE_CODE") );
|
||||
data.setInt ("REC_LEN" , rs.getInt("REC_LEN") );
|
||||
data.setInt ("REC_CNT" , rs.getInt("REC_CNT") );
|
||||
data.setInt ("SEQ_CNT" , rs.getInt("SEQ_CNT") );
|
||||
data.setString("FILE_DIR" , rs.getString("FILE_DIR") );
|
||||
}
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
if(rs != null){ try{ rs.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* 파일 송수신 상태 수정
|
||||
*/
|
||||
public void updTransFileInfo(long nSeq ,
|
||||
String sTransType,
|
||||
String sFlag,
|
||||
String sStatus,
|
||||
String sUpdater) throws SQLException , Exception {
|
||||
PreparedStatement ps = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
sbBuffer.append(" update FILE_TRANS_HISTORY ")
|
||||
.append(" set FILE_TRANS_YN = ?, ");
|
||||
if(sStatus.equals("9")){
|
||||
sbBuffer.append(" SEND_DATE = SYSDATE, ");
|
||||
}
|
||||
sbBuffer.append(" DATA_PROCESS_KBN = ?,")
|
||||
.append(" UPDATE_DATE = SYSDATE, ")
|
||||
.append(" UPDATER = ? ")
|
||||
.append(" WHERE SEQ = ? ")
|
||||
.append(" and file_trans_kbn = ? ")
|
||||
.append(" and FILE_TRANS_YN = ? ");
|
||||
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
ps.setString(idx++ , sFlag );
|
||||
ps.setString(idx++ , sStatus );
|
||||
ps.setString(idx++ , sUpdater);
|
||||
ps.setLong (idx++ , nSeq);
|
||||
ps.setString(idx++ , "S" );
|
||||
ps.setString(idx++ , "N" );
|
||||
|
||||
if( ps.executeUpdate() != 1){
|
||||
throw new SQLException ("FILE_TRANS_HISTORY 반영 실패");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 송수신파일 정보 INSERT
|
||||
*/
|
||||
public void insertRecvFileInfo(Info data) throws SQLException , Exception {
|
||||
PreparedStatement ps = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
sbBuffer.append(" INSERT INTO FILE_TRANS_HISTORY ( ")
|
||||
.append(" SEQ, ")
|
||||
.append(" FILE_KIND_ID, ")
|
||||
.append(" PASS_DATE, ")
|
||||
.append(" FORMAT_DATE, ")
|
||||
.append(" FARE_OFFICE_ID, ")
|
||||
.append(" FILE_TRANS_KBN, ")
|
||||
.append(" FILE_TRANS_YN, ")
|
||||
.append(" DATA_PROCESS_KBN, ")
|
||||
.append(" DIR_NAME, ")
|
||||
.append(" FILE_NAME, ")
|
||||
.append(" CREATE_DATE, ")
|
||||
.append(" CREATER , ")
|
||||
.append(" UPDATE_DATE, ")
|
||||
.append(" UPDATER ) ")
|
||||
.append(" VALUES ( FILE_TRANS_SEQ.NEXTVAL, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE, ?, SYSDATE, ? ) ");
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
|
||||
ps.setString(idx++ , data.getString("FILE_KIND_ID"));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE"));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE"));
|
||||
ps.setString(idx++ , data.getString("FARE_OFFICE_ID"));
|
||||
ps.setString(idx++ , data.getString("FILE_TRANS_KBN"));
|
||||
ps.setString(idx++ , data.getString("FILE_TRANS_YN"));
|
||||
ps.setString(idx++ , data.getString("DATA_PROCESS_KBN"));
|
||||
ps.setString(idx++ , data.getString("DIR_NAME"));
|
||||
ps.setString(idx++ , data.getString("FILE_NAME"));
|
||||
ps.setString(idx++ , data.getString("CREATER"));
|
||||
ps.setString(idx++ , data.getString("CREATER"));
|
||||
|
||||
if( ps.executeUpdate() != 1){
|
||||
throw new SQLException ("FILE_TRANS_HISTORY 반영 실패");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일 전송 횟수 조회 및 증가
|
||||
* @param sFileKindID
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public long getNextSeq(String sFileKindID) throws Exception{
|
||||
long nSeqNo = 0;
|
||||
PreparedStatement ps = null;
|
||||
PreparedStatement psUpd = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
ResultSet rs = null;
|
||||
try{
|
||||
sbBuffer.append(" select Last_data_no+1 from file_kind_code_info ")
|
||||
.append(" where file_kind_id = ? ");
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
ps.setString(idx++ , sFileKindID);
|
||||
rs = ps.executeQuery();
|
||||
if(rs.next()){
|
||||
nSeqNo = rs.getLong(1);
|
||||
psUpd = conn.prepareStatement(" update file_kind_code_info set Last_data_no = ? where file_kind_id = ? ");
|
||||
idx = 1 ;
|
||||
psUpd.setLong (idx++ , nSeqNo);
|
||||
psUpd.setString(idx++ , sFileKindID);
|
||||
psUpd.executeUpdate();
|
||||
if( psUpd.executeUpdate() != 1){
|
||||
throw new SQLException ("file_kind_code_info 반영 실패");
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(rs != null){ try{ rs.close(); }catch(Exception ignore){} }
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
if(psUpd != null){ try{ psUpd.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
return nSeqNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 송수신파일 정보 INSERT
|
||||
*/
|
||||
public void insertFileTransInfo(Info data) throws SQLException , Exception {
|
||||
PreparedStatement ps = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
sbBuffer.append(" INSERT INTO FILE_TRANS_INFO ( ")
|
||||
.append(" FILE_KIND_ID, ")
|
||||
.append(" YEAR, ")
|
||||
.append(" MONTH, ")
|
||||
.append(" DAY, ")
|
||||
.append(" DATA_SEQNO, ")
|
||||
.append(" FILE_TRANS_YN, ")
|
||||
.append(" FORMAT_DATE, ")
|
||||
.append(" DIR_NAME , ")
|
||||
.append(" FILE_NAME, ")
|
||||
.append(" DATA_PROCESS_KBN, ")
|
||||
.append(" CREATE_DATE, ")
|
||||
.append(" CREATER, ")
|
||||
.append(" UPDATE_DATE, ")
|
||||
.append(" UPDATER) ")
|
||||
.append(" VALUES ( ?, ?, ?, ?, ?, '1', SYSDATE, ?, ?, ?, SYSDATE, ? , SYSDATE, ? ) ");
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
|
||||
ps.setString(idx++ , data.getString("FILE_KIND_ID"));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE").substring(0,4));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE").substring(4,6));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE").substring(6,8));
|
||||
ps.setLong (idx++ , data.getLong ("DATA_SEQNO"));
|
||||
ps.setString(idx++ , data.getString("DIR_NAME"));
|
||||
ps.setString(idx++ , data.getString("FILE_NAME"));
|
||||
ps.setString(idx++ , "R");
|
||||
ps.setString(idx++ , data.getString("CREATER"));
|
||||
ps.setString(idx++ , data.getString("CREATER"));
|
||||
|
||||
if( ps.executeUpdate() != 1){
|
||||
throw new SQLException ("FILE_TRANS_INFO 반영 실패");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 송수신파일 정보 INSERT
|
||||
*/
|
||||
public void insertOfficeTransInfo(Info data) throws SQLException , Exception {
|
||||
PreparedStatement ps = null;
|
||||
StringBuffer sbBuffer = new StringBuffer();
|
||||
try{
|
||||
sbBuffer.append(" INSERT INTO office_trans_info ( ")
|
||||
.append(" FILE_KIND_ID, ")
|
||||
.append(" YEAR, ")
|
||||
.append(" MONTH, ")
|
||||
.append(" DAY, ")
|
||||
.append(" DATA_SEQNO, ")
|
||||
.append(" FARE_OFFICE_ID, ")
|
||||
.append(" DATA_PROCESS_KBN, ")
|
||||
.append(" CREATE_DATE, ")
|
||||
.append(" CREATER ) ")
|
||||
.append(" VALUES ( ?, ?, ?, ?, ?, ?, ?, SYSDATE, ? ) ");
|
||||
int idx = 1 ;
|
||||
ps = conn.prepareStatement(sbBuffer.toString());
|
||||
|
||||
ps.setString(idx++ , data.getString("FILE_KIND_ID"));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE").substring(0,4));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE").substring(4,6));
|
||||
ps.setString(idx++ , data.getString("FORMAT_DATE").substring(6,8));
|
||||
ps.setLong (idx++ , data.getLong ("DATA_SEQNO"));
|
||||
ps.setString(idx++ , data.getString("FARE_OFFICE_ID"));
|
||||
ps.setString(idx++ , "R");
|
||||
ps.setString(idx++ , data.getString("CREATER"));
|
||||
|
||||
if( ps.executeUpdate() != 1){
|
||||
throw new SQLException ("office_trans_info 반영 실패");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}finally{
|
||||
if(ps != null){ try{ ps.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,169 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.BoothInfoDataRecord;
|
||||
|
||||
/**
|
||||
* 차로구분정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyBoothInfo extends FileWorker
|
||||
{
|
||||
|
||||
private String sPrcsName = "ApplyBoothInfo";
|
||||
public static final int REC_LEN = 150; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private PreparedStatement psIns = null;
|
||||
private PreparedStatement psUpd = null;
|
||||
private PreparedStatement psDel = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
if( sTemp.charAt(10) == 'D'){
|
||||
// 데이터 반영
|
||||
processRecord(new BoothInfoDataRecord(sTemp));
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(".... DB Update Count : "+ nUpdateCount);
|
||||
logger.logInfo(".... DB Delete Count : "+ nDeleteCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
nDeleteCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
|
||||
query = "INSERT INTO BOOTH_CODE_INFO( "
|
||||
+ " FARE_OFFICE_ID, BOOTH_ID, BOOTH_FULL_NAME, BOOTH_ABB_NAME, "
|
||||
+ " IN_OUT_KBN, USE_YN, CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ "VALUES (?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE BOOTH_CODE_INFO "
|
||||
+ " SET BOOTH_FULL_NAME = ? "
|
||||
+ " , BOOTH_ABB_NAME = ? "
|
||||
+ " , IN_OUT_KBN = ? "
|
||||
+ " , USE_YN = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE "
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? ";
|
||||
|
||||
psUpd = conn.prepareStatement(query);
|
||||
|
||||
query = "DELETE FROM BOOTH_CODE_INFO "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? ";
|
||||
|
||||
psDel = conn.prepareStatement(query);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psIns != null) psIns.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd != null) psUpd.close(); }catch(Exception ignore){}
|
||||
try{ if(psDel != null) psDel.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(BoothInfoDataRecord record) throws SQLException , Exception {
|
||||
int iParam = 1;
|
||||
try{
|
||||
String sPrcsKbn = record.getItem(BoothInfoDataRecord.IUD_KBN); // 입력수정삭제구분
|
||||
if( sPrcsKbn.equals("I")){
|
||||
psIns.setString(iParam++, record.getItem( BoothInfoDataRecord.FARE_OFFICE_ID ).trim());
|
||||
psIns.setString(iParam++, record.getItem( BoothInfoDataRecord.BOOTH_ID ).trim());
|
||||
psIns.setString(iParam++, record.getItem( BoothInfoDataRecord.BOOTH_FULL_NAME ).trim());
|
||||
psIns.setString(iParam++, record.getItem( BoothInfoDataRecord.BOOTH_ABB_NAME ).trim());
|
||||
psIns.setString(iParam++, record.getItem( BoothInfoDataRecord.IN_OUT_KBN ).trim());
|
||||
psIns.setString(iParam++, record.getItem( BoothInfoDataRecord.USE_YN ).trim());
|
||||
|
||||
psIns.executeUpdate();
|
||||
nInsertCount++;
|
||||
}else if( sPrcsKbn.equals("U")){
|
||||
psUpd.setString(iParam++, record.getItem( BoothInfoDataRecord.BOOTH_FULL_NAME ).trim());
|
||||
psUpd.setString(iParam++, record.getItem( BoothInfoDataRecord.BOOTH_ABB_NAME ).trim());
|
||||
psUpd.setString(iParam++, record.getItem( BoothInfoDataRecord.IN_OUT_KBN ).trim());
|
||||
psUpd.setString(iParam++, record.getItem( BoothInfoDataRecord.USE_YN ).trim());
|
||||
psUpd.setString(iParam++, record.getItem( BoothInfoDataRecord.FARE_OFFICE_ID ).trim());
|
||||
psUpd.setString(iParam++, record.getItem( BoothInfoDataRecord.BOOTH_ID ).trim());
|
||||
|
||||
psUpd.executeUpdate();
|
||||
nUpdateCount++;
|
||||
}else if( sPrcsKbn.equals("D")){
|
||||
psDel.setString(iParam++, record.getItem( BoothInfoDataRecord.FARE_OFFICE_ID ).trim());
|
||||
psDel.setString(iParam++, record.getItem( BoothInfoDataRecord.BOOTH_ID ).trim());
|
||||
|
||||
psDel.executeUpdate();
|
||||
nDeleteCount++;
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,185 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.CardJoinDataRecord;
|
||||
|
||||
/**
|
||||
* 가맹점정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyCardJoin extends FileWorker
|
||||
{
|
||||
|
||||
private String sPrcsName = "ApplyCardJoin";
|
||||
public static final int REC_LEN = 150; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private ResultSet rs = null;
|
||||
private PreparedStatement psSls = null;
|
||||
private PreparedStatement psIns = null;
|
||||
private PreparedStatement psUpd = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
if( sTemp.charAt(10) == 'D'){
|
||||
// 데이터 반영
|
||||
processRecord(new CardJoinDataRecord(sTemp));
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(".... DB Update Count : "+ nUpdateCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
|
||||
query = " SELECT COUNT(*) "
|
||||
+ " FROM JOIN_CARD_INFO "
|
||||
+ " WHERE FARE_OFFICE_ID = ?"
|
||||
+ " AND JOIN_CARD_NUMBER = ?";
|
||||
|
||||
psSls = conn.prepareStatement(query);
|
||||
|
||||
query = " INSERT INTO JOIN_CARD_INFO( "
|
||||
+ " FARE_OFFICE_ID, JOIN_CARD_NUMBER, STT_DATE, END_DATE, COLLECT_ID, "
|
||||
+ " CARD_ISSUE_ID, JOIN_CARD_NAME, CHARGE_RATE, CHARGE_AMOUNT, USE_YN, "
|
||||
+ " CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ " VALUES (?,?,?,?,?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns = conn.prepareStatement(query);
|
||||
|
||||
query = " UPDATE JOIN_CARD_INFO "
|
||||
+ " SET STT_DATE = ? "
|
||||
+ " , END_DATE = ? "
|
||||
+ " , COLLECT_ID = ? "
|
||||
+ " , CARD_ISSUE_ID = ? "
|
||||
+ " , JOIN_CARD_NAME = ? "
|
||||
+ " , CHARGE_RATE = ? "
|
||||
+ " , CHARGE_AMOUNT = ? "
|
||||
+ " , USE_YN = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE"
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND JOIN_CARD_NUMBER = ? ";
|
||||
|
||||
psUpd = conn.prepareStatement(query);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psSls != null) psSls.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns != null) psIns.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd != null) psUpd.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(CardJoinDataRecord record) throws SQLException , Exception {
|
||||
int iParam = 1;
|
||||
|
||||
try{
|
||||
psSls.setString(iParam++, record.getItem( CardJoinDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psSls.setString(iParam++, record.getItem( CardJoinDataRecord.JOIN_CHAIN_NO ).trim()); // '가맹점번호'
|
||||
rs = psSls.executeQuery();
|
||||
rs.next();
|
||||
|
||||
iParam = 1;
|
||||
if (rs.getInt(1) == 0) {
|
||||
psIns.setString(iParam++, record.getItem( CardJoinDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psIns.setString(iParam++, record.getItem( CardJoinDataRecord.JOIN_CHAIN_NO ).trim()); // '가맹점번호'
|
||||
psIns.setString(iParam++, record.getItem( CardJoinDataRecord.STT_DATE ).trim()); // '시작일자'
|
||||
psIns.setString(iParam++, record.getItem( CardJoinDataRecord.END_DATE ).trim()); // '종료일자'
|
||||
psIns.setString(iParam++, record.getItem( CardJoinDataRecord.COLLECT_ID ).trim()); // '징수유형'
|
||||
psIns.setString(iParam++, record.getItem( CardJoinDataRecord.ISSUER_ID ).trim()); // '카드발행사'
|
||||
psIns.setString(iParam++, record.getItem( CardJoinDataRecord.JOIN_CHAIN_NAME).trim()); // '가맹점명'
|
||||
psIns.setString(iParam++, record.getItem( CardJoinDataRecord.CARD_RATE ).trim()); // '수수료율'
|
||||
psIns.setString(iParam++, record.getItem( CardJoinDataRecord.REATE_AMOUNT ).trim()); // '수수료금액'
|
||||
psIns.setString(iParam++, record.getItem( CardJoinDataRecord.USE_KBN ).trim()); // '사용구분'
|
||||
psIns.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
} else if (rs.getInt(1) > 0) {
|
||||
psUpd.setString(iParam++, record.getItem( CardJoinDataRecord.STT_DATE ).trim()); // '시작일자'
|
||||
psUpd.setString(iParam++, record.getItem( CardJoinDataRecord.END_DATE ).trim()); // '종료일자'
|
||||
psUpd.setString(iParam++, record.getItem( CardJoinDataRecord.COLLECT_ID ).trim()); // '징수유형'
|
||||
psUpd.setString(iParam++, record.getItem( CardJoinDataRecord.ISSUER_ID ).trim()); // '카드발행사'
|
||||
psUpd.setString(iParam++, record.getItem( CardJoinDataRecord.JOIN_CHAIN_NAME).trim()); // '가맹점명'
|
||||
psUpd.setString(iParam++, record.getItem( CardJoinDataRecord.CARD_RATE ).trim()); // '수수료율'
|
||||
psUpd.setString(iParam++, record.getItem( CardJoinDataRecord.REATE_AMOUNT ).trim()); // '수수료금액'
|
||||
psUpd.setString(iParam++, record.getItem( CardJoinDataRecord.USE_KBN ).trim()); // '사용구분'
|
||||
psUpd.setString(iParam++, record.getItem( CardJoinDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd.setString(iParam++, record.getItem( CardJoinDataRecord.JOIN_CHAIN_NO ).trim()); // '가맹점번호'
|
||||
psUpd.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}finally{
|
||||
try{ if(rs != null) rs.close(); }catch(Exception ignore){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,330 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.CollectSettleDataRecord;
|
||||
|
||||
/**
|
||||
* 요금정산정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyCollectSettle extends FileWorker
|
||||
{
|
||||
private String sPrcsName = "ApplyCollectSettle";
|
||||
public static final int REC_LEN = 330; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private ResultSet rs = null;
|
||||
private PreparedStatement psSls = null;
|
||||
private PreparedStatement psIns = null;
|
||||
private PreparedStatement psUpd = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
if( sTemp.charAt(10) == 'D'){
|
||||
// 데이터 반영
|
||||
processRecord(new CollectSettleDataRecord(sTemp));
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(".... DB Update Count : "+ nUpdateCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
query = "SELECT COUNT(*) COUNT "
|
||||
+ " FROM FARE_ADJUST_INFO "
|
||||
+ " WHERE WORKER_ID = ?"
|
||||
+ " AND FARE_OFFICE_ID = ?"
|
||||
+ " AND BOOTH_ID = ?"
|
||||
+ " AND YEAR = ?"
|
||||
+ " AND MONTH = ?"
|
||||
+ " AND DAY = ?"
|
||||
+ " AND WORK_STT_TIME = ?"
|
||||
+ " AND WORK_END_TIME = ?";
|
||||
|
||||
psSls = conn.prepareStatement(query);
|
||||
|
||||
query = "INSERT INTO FARE_ADJUST_INFO ( "
|
||||
+ " WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, "
|
||||
+ " WORK_STT_TIME, WORK_END_TIME, EXEMPTION_QUANTITY, CASH_QUANTITY, "
|
||||
+ " COUPON_QUANTITY, NONPAYMENT_QUANTITY, CARD_BEFORE_QUANTITY, "
|
||||
+ " CARD_AFTER_QUANTITY, COUPON_SALE_QUANTITY, TOTAL_INCOME, CASH_INCOME, "
|
||||
+ " CARD_BEFORE_INCOME, CARD_AFTER_INCME, COUPON_INCOME, COUPON_SALE, "
|
||||
+ " DEPOSIT_PAY, CREDIT_PAY, OVERFARE_IN_AMOUNT, OVERFARE_OUT_AMOUNT, "
|
||||
+ " OVERCOUPON_COUNT, COUPON_RETURN_COUNT, NOTE_QUANTITY, NOTE_INCOME, "
|
||||
+ " FARE_ADJUST_YN, K_CASH_Q, K_COUPON_Q, K_CARD_SUN_Q, K_CARD_WHO_Q, "
|
||||
+ " K_COUPON_SALE_Q, K_CASH_INCOME, K_CARD_SUN_INCOME, K_CARD_WHO_INCOME, "
|
||||
+ " K_COUPON_SALE_INCOME, K_OVERCOUPON_CNT, K_COUPON_RET_CNT, K_NOTE_Q, "
|
||||
+ " K_NOTE_INCOME, REPAY_CNT, REPAY_AMOUNT, C_AMPM, OTHER_SEQNO, "
|
||||
+ " SALE_CARD_Q, SALE_CARD_M, K_SALE_CARD_Q, K_SALE_CARD_M, "
|
||||
+ " CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, "
|
||||
+ " ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, SYSDATE,'COMM', SYSDATE,'COMM') ";
|
||||
|
||||
psIns = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE FARE_ADJUST_INFO "
|
||||
+ " SET EXEMPTION_QUANTITY = ? "
|
||||
+ " , CASH_QUANTITY = ? "
|
||||
+ " , COUPON_QUANTITY = ? "
|
||||
+ " , NONPAYMENT_QUANTITY = ? "
|
||||
+ " , CARD_BEFORE_QUANTITY = ? "
|
||||
+ " , CARD_AFTER_QUANTITY = ? "
|
||||
+ " , COUPON_SALE_QUANTITY = ? "
|
||||
+ " , TOTAL_INCOME = ? "
|
||||
+ " , CASH_INCOME = ? "
|
||||
+ " , CARD_BEFORE_INCOME = ? "
|
||||
+ " , CARD_AFTER_INCME = ? "
|
||||
+ " , COUPON_INCOME = ? "
|
||||
+ " , COUPON_SALE = ? "
|
||||
+ " , DEPOSIT_PAY = ? "
|
||||
+ " , CREDIT_PAY = ? "
|
||||
+ " , OVERFARE_IN_AMOUNT = ? "
|
||||
+ " , OVERFARE_OUT_AMOUNT = ? "
|
||||
+ " , OVERCOUPON_COUNT = ? "
|
||||
+ " , COUPON_RETURN_COUNT = ? "
|
||||
+ " , NOTE_QUANTITY = ? "
|
||||
+ " , NOTE_INCOME = ? "
|
||||
+ " , FARE_ADJUST_YN = ? "
|
||||
+ " , K_CASH_Q = ? "
|
||||
+ " , K_COUPON_Q = ? "
|
||||
+ " , K_CARD_SUN_Q = ? "
|
||||
+ " , K_CARD_WHO_Q = ? "
|
||||
+ " , K_COUPON_SALE_Q = ? "
|
||||
+ " , K_CASH_INCOME = ? "
|
||||
+ " , K_CARD_SUN_INCOME = ? "
|
||||
+ " , K_CARD_WHO_INCOME = ? "
|
||||
+ " , K_COUPON_SALE_INCOME = ? "
|
||||
+ " , K_OVERCOUPON_CNT = ? "
|
||||
+ " , K_COUPON_RET_CNT = ? "
|
||||
+ " , K_NOTE_Q = ? "
|
||||
+ " , K_NOTE_INCOME = ? "
|
||||
+ " , REPAY_CNT = ? "
|
||||
+ " , REPAY_AMOUNT = ? "
|
||||
+ " , C_AMPM = ? "
|
||||
+ " , OTHER_SEQNO = ? "
|
||||
+ " , SALE_CARD_Q = ? "
|
||||
+ " , SALE_CARD_M = ? "
|
||||
+ " , K_SALE_CARD_Q = ? "
|
||||
+ " , K_SALE_CARD_M = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE"
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_STT_TIME = ? "
|
||||
+ " AND WORK_END_TIME = ? ";
|
||||
|
||||
psUpd = conn.prepareStatement(query);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psSls != null) psSls.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns != null) psIns.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd != null) psUpd.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(CollectSettleDataRecord record) throws SQLException , Exception {
|
||||
int iParam;
|
||||
|
||||
try{
|
||||
iParam = 1;
|
||||
psSls.setString(iParam++, record.getItem( CollectSettleDataRecord.WORKER_ID ).trim()); //'징수원ID'
|
||||
psSls.setString(iParam++, record.getItem( CollectSettleDataRecord.FARE_OFFICE_ID ).trim()); //'요금소ID'
|
||||
psSls.setString(iParam++, record.getItem( CollectSettleDataRecord.BOOTH_ID ).trim()); //'차로ID'
|
||||
psSls.setString(iParam++, record.getItem( CollectSettleDataRecord.YEAR ).trim()); //'년도'
|
||||
psSls.setString(iParam++, record.getItem( CollectSettleDataRecord.MONTH ).trim()); //'월'
|
||||
psSls.setString(iParam++, record.getItem( CollectSettleDataRecord.DAY ).trim()); //'일'
|
||||
psSls.setString(iParam++, record.getItem( CollectSettleDataRecord.WORK_STT_TIME ).trim()); //'근무시작시간'
|
||||
psSls.setString(iParam++, record.getItem( CollectSettleDataRecord.WORK_END_TIME ).trim()); //'근무종료시간'
|
||||
rs = psSls.executeQuery();
|
||||
|
||||
rs.next();
|
||||
if (rs.getInt(1) == 0) {
|
||||
iParam = 1;
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.FARE_OFFICE_ID ).trim()); // '요금소ID'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.BOOTH_ID ).trim()); // '차로ID'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.YEAR ).trim()); // '년도'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.MONTH ).trim()); // '월'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.DAY ).trim()); // '일'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.EXEMPTION_QUANTITY ).trim()); // '면제통행량'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.CASH_QUANTITY ).trim()); // '현금통행량'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_QUANTITY ).trim()); // '쿠폰회수통행량'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.NONPAYMENT_QUANTITY ).trim()); // '미납통행량'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_BEFORE_QUANTITY ).trim()); // '선불통행량'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_AFTER_QUANTITY ).trim()); // '후불통행량'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_SALE_QUANTITY ).trim()); // '정액권판매권수'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.TOTAL_INCOME ).trim()); // '총수입금'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.CASH_INCOME ).trim()); // '현금수입금'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_BEFORE_INCOME ).trim()); // '선불수입금'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_AFTER_INCOME ).trim()); // '후불수입금'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_INCOME ).trim()); // '쿠폰수입금'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_SALE ).trim()); // '정액권판매수입금'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.DEPOSIT_PAY ).trim()); // '입금액'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.CREDIT_PAY ).trim()); // '출금액'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.OVERFARE_IN_AMOUNT ).trim()); // '과오납입금액'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.OVERFARE_OUT_AMOUNT ).trim()); // '과오납출금액'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.OVERCOUPON_COUNT ).trim()); // '과잉쿠폰매수'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_RETURN_COUNT ).trim()); // '반납쿠폰매수'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.NOTE_QUANTITY ).trim()); // '수기통행량'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.NOTE_INCOME ).trim()); // '수기수입금'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.FARE_ADJUST_YN ) ); // '정산완료'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.CASH_Q ).trim()); // '경차현금통행량'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_Q ).trim()); // '경차쿠폰회수량'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_SUN_Q ).trim()); // '경차선불통행량'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_WHO_Q ).trim()); // '경차후불통행량'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_SALE_Q ).trim()); // '경차정액권판매권수'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.K_CASH_INCOME ).trim()); // '경차현금수입금'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_SUN_INCOME ).trim()); // '경차선불수입금'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_WHO_INCOME ).trim()); // '경차후불수입금'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_SALE_INCOME ).trim()); // '경차정액권판매금'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.OVERCOUPON_CNT ).trim()); // '경차과잉쿠폰매수'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_RET_CNT ).trim()); // '경차과잉쿠폰반납매수'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.NOTE_Q ).trim()); // '경차수기통행량'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.K_NOTE_INCOME ).trim()); // '경차수기수입금'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.REPAY_CNT ).trim()); // '카드환불건수'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.REPAY_AMOUNT ).trim()); // '카드환불금액'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.C_AMPM ).trim()); // '오전/오후구분'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.OTHER_SEQNO ).trim()); // '중복방지번호'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.SALE_CARD_Q ).trim()); // '일반정액권카드판매권수'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.SALE_CARD_M ).trim()); // '일반정액권카드판매금액'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.K_SALE_CARD_Q ).trim()); // '경차정액권카드판매권수'
|
||||
psIns.setString(iParam++, record.getItem( CollectSettleDataRecord.K_SALE_CARD_M ).trim()); // '경차정액권카드판매금액'
|
||||
psIns.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
} else if (rs.getInt(1) > 0) {
|
||||
iParam = 1;
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.EXEMPTION_QUANTITY ).trim()); // '면제통행량'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.CASH_QUANTITY ).trim()); // '현금통행량'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_QUANTITY ).trim()); // '쿠폰회수통행량'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.NONPAYMENT_QUANTITY ).trim()); // '미납통행량'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_BEFORE_QUANTITY ).trim()); // '선불통행량'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_AFTER_QUANTITY ).trim()); // '후불통행량'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_SALE_QUANTITY ).trim()); // '정액권판매권수'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.TOTAL_INCOME ).trim()); // '총수입금'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.CASH_INCOME ).trim()); // '현금수입금'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_BEFORE_INCOME ).trim()); // '선불수입금'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_AFTER_INCOME ).trim()); // '후불수입금'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_INCOME ).trim()); // '쿠폰수입금'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_SALE ).trim()); // '정액권판매수입금'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.DEPOSIT_PAY ).trim()); // '입금액'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.CREDIT_PAY ).trim()); // '출금액'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.OVERFARE_IN_AMOUNT ).trim()); // '과오납입금액'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.OVERFARE_OUT_AMOUNT ).trim()); // '과오납출금액'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.OVERCOUPON_COUNT ).trim()); // '과잉쿠폰매수'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_RETURN_COUNT ).trim()); // '반납쿠폰매수'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.NOTE_QUANTITY ).trim()); // '수기통행량'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.NOTE_INCOME ).trim()); // '수기수입금'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.FARE_ADJUST_YN ) ); // '정산완료'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.CASH_Q ).trim()); // '경차현금통행량'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_Q ).trim()); // '경차쿠폰회수량'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_SUN_Q ).trim()); // '경차선불통행량'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_WHO_Q ).trim()); // '경차후불통행량'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_SALE_Q ).trim()); // '경차정액권판매권수'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.K_CASH_INCOME ).trim()); // '경차현금수입금'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_SUN_INCOME ).trim()); // '경차선불수입금'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.CARD_WHO_INCOME ).trim()); // '경차후불수입금'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_SALE_INCOME ).trim()); // '경차정액권판매금'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.OVERCOUPON_CNT ).trim()); // '경차과잉쿠폰매수'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.COUPON_RET_CNT ).trim()); // '경차과잉쿠폰반납매수'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.NOTE_Q ).trim()); // '경차수기통행량'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.K_NOTE_INCOME ).trim()); // '경차수기수입금'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.REPAY_CNT ).trim()); // '카드환불건수'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.REPAY_AMOUNT ).trim()); // '카드환불금액'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.C_AMPM ).trim()); // '오전/오후구분'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.OTHER_SEQNO ).trim()); // '중복방지번호'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.SALE_CARD_Q ).trim()); // '일반정액권카드판매권수'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.SALE_CARD_M ).trim()); // '일반정액권카드판매금액'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.K_SALE_CARD_Q ).trim()); // '경차정액권카드판매권수'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.K_SALE_CARD_M ).trim()); // '경차정액권카드판매금액'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.FARE_OFFICE_ID ).trim()); // '요금소ID'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.BOOTH_ID ).trim()); // '차로ID'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.YEAR ).trim()); // '년도'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.MONTH ).trim()); // '월'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.DAY ).trim()); // '일'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psUpd.setString(iParam++, record.getItem( CollectSettleDataRecord.WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psUpd.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}finally{
|
||||
try{ if(rs != null) rs.close(); }catch(Exception ignore){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,179 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.CollectorDataRecord;
|
||||
|
||||
/**
|
||||
* 징수원정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyCollector extends FileWorker
|
||||
{
|
||||
|
||||
public static final int REC_LEN = 250; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private PreparedStatement psIns = null;
|
||||
private PreparedStatement psUpd = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
String sPrcsName = "ApplyCollector";
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
if( sTemp.charAt(10) == 'D'){
|
||||
// 데이터 반영
|
||||
processRecord(new CollectorDataRecord(sTemp));
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(".... DB Update Count : "+ nUpdateCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( "CollectorDataRecord apply fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
nDeleteCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
query = "INSERT INTO WORKER_INFO ( "
|
||||
+ " WORKER_ID , WORKER_SEQNO , PASSWORD , WORKER_NAME , SHIFT , RESIDENT_NO , "
|
||||
+ " TEL_NO , PCS_NO , POST_NO1 , POST_NO2 , ADDRESS_NAME , ADDRESS_NUMBER , "
|
||||
+ " OFFICE_NAME , WORK_END_YN , CREATE_DATE , CREATER , UPDATE_DATE , UPDATER "
|
||||
+ " ) "
|
||||
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE WORKER_INFO "
|
||||
+ " SET WORKER_SEQNO = ? "
|
||||
+ " , PASSWORD = ? "
|
||||
+ " , WORKER_NAME = ? "
|
||||
+ " , SHIFT = ? "
|
||||
+ " , RESIDENT_NO = ? "
|
||||
+ " , TEL_NO = ? "
|
||||
+ " , PCS_NO = ? "
|
||||
+ " , POST_NO1 = ? "
|
||||
+ " , POST_NO2 = ? "
|
||||
+ " , ADDRESS_NAME = ? "
|
||||
+ " , ADDRESS_NUMBER = ? "
|
||||
+ " , OFFICE_NAME = ? "
|
||||
+ " , WORK_END_YN = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE "
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE WORKER_ID = ? ";
|
||||
|
||||
psUpd = conn.prepareStatement(query);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( "CollectorDataRecord initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psIns != null) psIns.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd != null) psUpd.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(CollectorDataRecord record) throws SQLException , Exception {
|
||||
int iParam = 1;
|
||||
try{
|
||||
String sPrcsKbn = record.getItem(CollectorDataRecord.IUD_KBN); // 입력수정삭제구분
|
||||
|
||||
if ( sPrcsKbn.equals("I")) {
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.WORKER_SEQNO ).trim()); // '징수원번호'
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.PASSWORD ).trim()); // '패스워드'
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.WORKER_NAME ).trim()); // '징수원명'
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.SHIFT ).trim()); // '조구분'
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.RESIDENT_NO ).trim()); // '주민번호'
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.TEL_NO ).trim()); // '전화번호'
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.PCS_NO ).trim()); // '휴대폰번호'
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.POST_NO1 ).trim()); // '우편번호1'
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.POST_NO2 ).trim()); // '우편번호2'
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.ADDRESS_NAME ).trim()); // '주소'
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.ADDRESS_NUMBER ).trim()); // '주소번지'
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.OFFICE_NAME ).trim()); // '근무회사명'
|
||||
psIns.setString(iParam++, record.getItem( CollectorDataRecord.WORK_END_YN ).trim()); // '근무완료여부'
|
||||
psIns.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
} else if ( sPrcsKbn.equals("U")) {
|
||||
iParam = 1;
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.WORKER_SEQNO ).trim()); // '징수원번호'
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.PASSWORD ).trim()); // '패스워드'
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.WORKER_NAME ).trim()); // '징수원명'
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.SHIFT ).trim()); // '조구분'
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.RESIDENT_NO ).trim()); // '주민번호'
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.TEL_NO ).trim()); // '전화번호'
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.PCS_NO ).trim()); // '휴대폰번호'
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.POST_NO1 ).trim()); // '우편번호1'
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.POST_NO2 ).trim()); // '우편번호2'
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.ADDRESS_NAME ).trim()); // '주소'
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.ADDRESS_NUMBER ).trim()); // '주소번지'
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.OFFICE_NAME ).trim()); // '근무회사명'
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.WORK_END_YN ).trim()); // '근무완료여부'
|
||||
psUpd.setString(iParam++, record.getItem( CollectorDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psUpd.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,309 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.CpnDisuseDataRecord;
|
||||
import center.data.format.FixTicketDataRecord;
|
||||
|
||||
/**
|
||||
* 쿠폰폐기정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyCpnDisuse extends FileWorker
|
||||
{
|
||||
|
||||
private String sPrcsName = "ApplyCpnDisuse";
|
||||
public static final int REC_LEN = 200; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private ResultSet rs = null;
|
||||
private PreparedStatement psSls = null;
|
||||
private PreparedStatement psIns1 = null;
|
||||
private PreparedStatement psIns2 = null;
|
||||
private PreparedStatement psUpd1 = null;
|
||||
private PreparedStatement psUpd2 = null;
|
||||
private PreparedStatement psUpd3 = null;
|
||||
private PreparedStatement psUpd4 = null;
|
||||
private PreparedStatement psUpd5 = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
if( sTemp.charAt(10) == 'D'){
|
||||
// 데이터 반영
|
||||
processRecord(new CpnDisuseDataRecord(sTemp));
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(".... DB Update Count : "+ nUpdateCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
nDeleteCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
|
||||
query = "SELECT COUNT(*) "
|
||||
+ " FROM DAY_FIX_STOCK_INFO "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? ";
|
||||
|
||||
psSls = conn.prepareStatement(query);
|
||||
|
||||
query = "INSERT INTO DAY_FIX_STOCK_INFO( "
|
||||
+ " FARE_OFFICE_ID, YEAR, MONTH, DAY, RETURN_COUPON_COUNT, "
|
||||
+ " K_RET_COUPON_CNT, CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ "VALUES (?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns1 = conn.prepareStatement(query);
|
||||
|
||||
query = "INSERT INTO COUPON_DISUSE_INFO( "
|
||||
+ " FARE_OFFICE_ID, DISUSE_DATE, DISUSE_SEQNO, COUPON_KBN, FARE_YEAR, "
|
||||
+ " FARE_MONTH, FARE_DAY, COUPON_COUNT, DISUSE_PERSON, DISUSE_COUNT, "
|
||||
+ " K_COUPON_CNT, K_DISUSE_CNT, CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns2 = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE FARE_ADJUST_INFO "
|
||||
+ " SET COUPON_DISUSE_YN = '1' "
|
||||
+ " , UPDATE_DATE = SYSDATE "
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? ";
|
||||
|
||||
psUpd1 = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE DAY_FIX_STOCK_INFO "
|
||||
+ " SET RETURN_COUPON_COUNT = RETURN_COUPON_COUNT + ?"
|
||||
+ " , K_RET_COUPON_CNT = K_RET_COUPON_CNT + ? "
|
||||
+ " , UPDATE_DATE = SYSDATE "
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? ";
|
||||
|
||||
psUpd2 = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE FARE_ADJUST_INFO "
|
||||
+ " SET COUPON_DISUSE_YN = '1' "
|
||||
+ " , UPDATE_DATE = SYSDATE "
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? ";
|
||||
|
||||
psUpd3 = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE OVERCOUPON_HEAD_INFO "
|
||||
+ " SET COUPON_DISUSE_COUNT = OVERCOUPON_COUNT - COUPON_RETURN_COUNT "
|
||||
+ " , K_COUPON_DISUSE_CNT = K_OVERCOUPON_CNT - K_COUPON_RET_CNT "
|
||||
+ " , UPDATE_DATE = SYSDATE "
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? ";
|
||||
|
||||
psUpd4 = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE OVERCOUPON_DETAIL_INFO "
|
||||
+ " SET OVER_KBN = '3' "
|
||||
+ " , RETURN_DATE = ? "
|
||||
+ " , RETURN_PERSON = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE "
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND OVERFARE_KBN = '1' "
|
||||
+ " AND DELETE_YN = '0' ";
|
||||
|
||||
psUpd5 = conn.prepareStatement(query);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psSls != null) psSls.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns1 != null) psIns1.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns2 != null) psIns2.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd1 != null) psUpd1.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd2 != null) psUpd2.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd3 != null) psUpd3.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd4 != null) psUpd4.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd5 != null) psUpd5.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(CpnDisuseDataRecord record) throws SQLException , Exception {
|
||||
int iParam;
|
||||
try{
|
||||
char sPrcsKbn = record.getItem(FixTicketDataRecord.D_DATA_TYPE).charAt(0); // 쿠폰구분
|
||||
|
||||
switch (sPrcsKbn) {
|
||||
case '1': // 쿠폰회수폐기
|
||||
|
||||
iParam = 1;
|
||||
psUpd1.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd1.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_YEAR ).trim()); // '년도'
|
||||
psUpd1.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_MONTH ).trim()); // '월'
|
||||
psUpd1.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_DAY ).trim()); // '일'
|
||||
psUpd1.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
|
||||
iParam = 1;
|
||||
psSls.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psSls.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_YEAR ).trim()); // '년도'
|
||||
psSls.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_MONTH ).trim()); // '월'
|
||||
psSls.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_DAY ).trim()); // '일'
|
||||
rs = psSls.executeQuery();
|
||||
rs.next();
|
||||
|
||||
if (rs.getInt(1) == 0) {
|
||||
iParam = 1;
|
||||
psIns1.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psIns1.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_YEAR ).trim()); // '년도'
|
||||
psIns1.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_MONTH ).trim()); // '월'
|
||||
psIns1.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_DAY ).trim()); // '일'
|
||||
psIns1.setString(iParam++, record.getItem( CpnDisuseDataRecord.DISUSE_COUNT ).trim()); // '일반쿠폰폐기매수'
|
||||
psIns1.setString(iParam++, record.getItem( CpnDisuseDataRecord.K_DISUSE_CNT ).trim()); // '경차쿠폰폐기매수'
|
||||
psIns1.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
} else if (rs.getInt(1) > 0) {
|
||||
iParam = 1;
|
||||
psUpd2.setString(iParam++, record.getItem( CpnDisuseDataRecord.COUPON_COUNT ).trim()); // '일반쿠폰폐기매수'
|
||||
psUpd2.setString(iParam++, record.getItem( CpnDisuseDataRecord.K_COUPON_CNT ).trim()); // '경차쿠폰폐기매수'
|
||||
psUpd2.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd2.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_YEAR ).trim()); // '년도'
|
||||
psUpd2.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_MONTH ).trim()); // '월'
|
||||
psUpd2.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_DAY ).trim()); // '일'
|
||||
psUpd2.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case '2': // 과잉쿠폰폐기
|
||||
|
||||
iParam = 1;
|
||||
psUpd3.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd3.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_YEAR ).trim()); // '년도'
|
||||
psUpd3.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_MONTH ).trim()); // '월'
|
||||
psUpd3.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
|
||||
iParam = 1;
|
||||
psUpd4.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd4.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_YEAR ).trim()); // '년도'
|
||||
psUpd4.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_MONTH ).trim()); // '월'
|
||||
psUpd4.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
|
||||
iParam = 1;
|
||||
psUpd5.setString(iParam++, record.getItem( CpnDisuseDataRecord.DISUSE_DATE ).trim()); // '폐기일자'
|
||||
psUpd5.setString(iParam++, record.getItem( CpnDisuseDataRecord.DISUSE_PERSON ).trim()); // '폐기담당자'
|
||||
psUpd5.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd5.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_YEAR ).trim()); // '년도'
|
||||
psUpd5.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_MONTH ).trim()); // '월'
|
||||
psUpd5.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
iParam = 1;
|
||||
psIns2.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psIns2.setString(iParam++, record.getItem( CpnDisuseDataRecord.DISUSE_DATE ).trim()); // '폐기일자'
|
||||
psIns2.setString(iParam++, record.getItem( CpnDisuseDataRecord.DISUSE_SEQNO ).trim()); // '일련번호'
|
||||
psIns2.setString(iParam++, record.getItem( CpnDisuseDataRecord.COUPON_KBN ).trim()); // '쿠폰구분'
|
||||
psIns2.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_YEAR ).trim()); // '년도'
|
||||
psIns2.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_MONTH ).trim()); // '월'
|
||||
psIns2.setString(iParam++, record.getItem( CpnDisuseDataRecord.FARE_DAY ).trim()); // '일'
|
||||
psIns2.setString(iParam++, record.getItem( CpnDisuseDataRecord.COUPON_COUNT ).trim()); // '쿠폰매수'
|
||||
psIns2.setString(iParam++, record.getItem( CpnDisuseDataRecord.DISUSE_PERSON ).trim()); // '폐기자'
|
||||
psIns2.setString(iParam++, record.getItem( CpnDisuseDataRecord.DISUSE_COUNT ).trim()); // '폐기매수'
|
||||
psIns2.setString(iParam++, record.getItem( CpnDisuseDataRecord.K_COUPON_CNT ).trim()); // '경차쿠폰매수'
|
||||
psIns2.setString(iParam++, record.getItem( CpnDisuseDataRecord.K_DISUSE_CNT ).trim()); // '경차폐기매수'
|
||||
psIns2.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}finally{
|
||||
try{ if(rs != null) rs.close(); }catch(Exception ignore){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,190 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.io.*;
|
||||
import java.sql.*;
|
||||
|
||||
import center.dao.CenterTransDAO;
|
||||
|
||||
import com.base.FileWorker;
|
||||
import com.exception.*;
|
||||
import com.resources.data.*;
|
||||
import com.util.*;
|
||||
/**
|
||||
* 데이터 반영 메인
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyDataMain {
|
||||
private Connection con;
|
||||
private Log4JLogger logger;
|
||||
private Properties config;
|
||||
|
||||
CenterTransDAO commonDAO = null;
|
||||
/**
|
||||
* Constructor
|
||||
* @param config
|
||||
*/
|
||||
public ApplyDataMain(Properties config){
|
||||
this.config = config;
|
||||
initialize();
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
*/
|
||||
public void initialize(){
|
||||
// log file setting
|
||||
String fileDir = config.getProperty( "file.dir" );
|
||||
if(fileDir == null){
|
||||
logger.logFail("Can not find Configuration data : file.dir");
|
||||
System.exit(0);
|
||||
}
|
||||
try{
|
||||
logger = new Log4JLogger(fileDir + "ApplyData.log");
|
||||
}catch(Exception e){
|
||||
logger.logFail("Creating logger is failed.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// jdbc driver load
|
||||
String driver = config.getProperty("db.driver");
|
||||
if(driver == null){
|
||||
logger.logFail("Can not find Configuration data : db.driver");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
try{
|
||||
Class.forName(driver);
|
||||
}catch(ClassNotFoundException cnfe){
|
||||
System.err.println("Cannot find driver : " + driver);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Main process logic
|
||||
*/
|
||||
public void startup()
|
||||
{
|
||||
try{
|
||||
con = getConnection();
|
||||
con.setAutoCommit(false);
|
||||
commonDAO = new CenterTransDAO(con);
|
||||
|
||||
while(true)
|
||||
{
|
||||
Info data = null;
|
||||
MultiInfo mData = commonDAO.getRecvFile();
|
||||
|
||||
String sPrcsID = null;
|
||||
for ( int idx = 0 ; idx < mData.fieldSize(); idx++){
|
||||
try{
|
||||
data = mData.getData(idx);
|
||||
String sFileKindID = data.getString("FILE_KIND_ID");
|
||||
String sDirectory = data.getString("DIR_NAME");
|
||||
String sFileName = data.getString("FILE_NAME");
|
||||
|
||||
logger.logInfo("File Code : ["+sFileKindID + "]" );
|
||||
logger.logInfo("File Dir : ["+sDirectory + "]" );
|
||||
logger.logInfo("File Name : ["+sFileName + "]" );
|
||||
String sPrcsName = config.getProperty(sFileKindID + ".prcs");
|
||||
if( sPrcsName == null || sPrcsName.equals("")){
|
||||
throw new Exception ("Unregistered File Code : "+sFileKindID);
|
||||
}
|
||||
|
||||
FileWorker applyClass = (FileWorker) Class.forName("center.data." + sPrcsName ).newInstance();
|
||||
applyClass.initialize(config, logger, con, new File(sDirectory, sFileName));
|
||||
applyClass.execute();
|
||||
|
||||
if( sPrcsName.length() <= 10 ) sPrcsID = sPrcsName;
|
||||
else sPrcsID = sPrcsName.substring(0,10);
|
||||
|
||||
commonDAO.updateFileTransHistory(data.getLong("SEQ"), "9", "ApplyMain"); // 상태 변경
|
||||
con.commit();
|
||||
logger.logInfo("File Code : "+sFileKindID + " is normally ended");
|
||||
}catch(Exception ex){
|
||||
commonDAO.updateFileTransHistory(data.getLong("SEQ"), "2", "ApplyMain"); // 상태 변경
|
||||
con.commit();
|
||||
if( logger != null ) logger.logFail(StringUtil.getDate("yyMMdd") +" : "+ "Apply Data is Failed" + "["+ ex.getMessage() +"]");
|
||||
if( logger != null ) logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
// 1분 후에 다시 디렉토리를 읽기 위해서
|
||||
try { Thread.sleep( 1 * 60 * 1000); } catch (InterruptedException ie) {}
|
||||
}
|
||||
}catch(Exception se){
|
||||
System.err.println(se.getMessage());
|
||||
se.printStackTrace();
|
||||
}finally{
|
||||
closeDBResource(con, null, null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws AppException
|
||||
*/
|
||||
protected final Connection getConnection() throws AppException {
|
||||
String url = config.getProperty("db.url");
|
||||
String user = config.getProperty("db.user");
|
||||
String password = config.getProperty("db.password");
|
||||
try{
|
||||
return DriverManager.getConnection(url, user, password);
|
||||
}catch(SQLException se){
|
||||
se.printStackTrace();
|
||||
throw new AppException("Cannot get connection : " + url);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param con
|
||||
* @param st
|
||||
* @param rs
|
||||
*/
|
||||
protected final void closeDBResource(
|
||||
Connection con, Statement st, ResultSet rs){
|
||||
if(rs != null){ try{ rs.close(); }catch(Exception ignore){} }
|
||||
if(st != null){ try{ st.close(); }catch(Exception ignore){} }
|
||||
if(con != null){ try{ con.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
/**
|
||||
* Help 메시지 출력
|
||||
*/
|
||||
public static void showHelp(String sClass) {
|
||||
System.err.println("Command :");
|
||||
System.err.println("\tjava " + sClass + " -Dbatch.conf=CONFIG_FILE");
|
||||
System.err.println("");
|
||||
}
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main (String args[]){
|
||||
try {
|
||||
if(args.length != 0){
|
||||
showHelp("center.data.ApplyDataMain");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
String sConfFile = System.getProperty("batch.conf");
|
||||
if (sConfFile == null || sConfFile.equals("")) {
|
||||
showHelp("center.data.ApplyDataMain");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Properties config = new Properties();
|
||||
try {
|
||||
config.load(sConfFile);
|
||||
}
|
||||
catch (IOException ie) {
|
||||
System.err.println("Can not find Configuration data.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
ApplyDataMain client = new ApplyDataMain(config);
|
||||
client.startup();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println("Starting Demon is failed.");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,465 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.FareTermDataRecord;
|
||||
|
||||
/**
|
||||
* 요금단말정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyFareTerm extends FileWorker
|
||||
{
|
||||
|
||||
private String sPrcsName = "ApplyFareTerm";
|
||||
public static final int REC_LEN = 380; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private ResultSet rs1 = null;
|
||||
private ResultSet rs2 = null;
|
||||
private PreparedStatement psSls1 = null;
|
||||
private PreparedStatement psSls2 = null;
|
||||
private PreparedStatement psIns1 = null;
|
||||
private PreparedStatement psIns2 = null;
|
||||
private PreparedStatement psUpd = null;
|
||||
private PreparedStatement psUpd1 = null;
|
||||
private PreparedStatement psUpd2 = null;
|
||||
private PreparedStatement psDel = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
if( sTemp.charAt(10) == 'D'){
|
||||
// 데이터 반영
|
||||
processRecord(new FareTermDataRecord(sTemp));
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(".... DB Update Count : "+ nUpdateCount);
|
||||
logger.logInfo(".... DB Delete Count : "+ nDeleteCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
nDeleteCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
query = "SELECT COUNT(*) "
|
||||
+ " FROM FARE_TERMINAL_INFO"
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_TIMES = ? "
|
||||
+ " AND SEQNO = ? ";
|
||||
|
||||
psSls1 = conn.prepareStatement(query);
|
||||
|
||||
query = "SELECT COUNT(*) "
|
||||
+ " FROM DEFAULT_FARE_READ_INFO"
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_TIMES = ? "
|
||||
+ " AND SEQNO = ? ";
|
||||
|
||||
psSls2 = conn.prepareStatement(query);
|
||||
|
||||
query = "INSERT INTO FARE_TERMINAL_INFO ( "
|
||||
+ " WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, WORK_TIMES, "
|
||||
+ " SEQNO, CAR_TYPE_ID, COLLECT_ID, IN_OUT_KBN, LEVY_AMOUNT, READING_ID, "
|
||||
+ " FOREIGN_CARS_KBN, ARMY_CARS_KBN, CARS_MOVE_PICTURE_FILE, "
|
||||
+ " CARS_STOP_PICTURE_FILE, CAR_NO, READER, READING_DATE, REMARKS, X_POSITION, Y_POSITION, "
|
||||
+ " GARO_LEN, SERO_LEN, NOTE_TRANS_YN, NEW_DATA_YN, "
|
||||
+ " NOTE_INPUT_REMARKS, OTHER_SEQNO, URGENT_KBN, CREATE_DATE, CREATER, UPDATE_DATE, "
|
||||
+ " UPDATER "
|
||||
+ " ) "
|
||||
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,TO_DATE(?,'yyyymmdd'),?,?,?,?,?,?,?,?,?,?,SYSDATE,'COMM', SYSDATE,'COMM') ";
|
||||
|
||||
psIns1 = conn.prepareStatement(query);
|
||||
|
||||
query = "INSERT INTO DEFAULT_FARE_READ_INFO( "
|
||||
+ " WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, WORK_TIMES, "
|
||||
+ " SEQNO, COLLECT_ID, READING_ID, CARS_MOVE_PICTURE_FILE, "
|
||||
+ " CARS_STOP_PICTURE_FILE, CAR_NO, READING_DATE, X_POSITION, Y_POSITION,"
|
||||
+ " GARO_LEN, SERO_LEN, CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,TO_DATE(?,'yyyymmdd'),?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns2 = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE FARE_TERMINAL_INFO "
|
||||
+ " SET CAR_TYPE_ID = ? "
|
||||
+ " , COLLECT_ID = ? "
|
||||
+ " , IN_OUT_KBN = ? "
|
||||
+ " , LEVY_AMOUNT = ? "
|
||||
+ " , READING_ID = ? "
|
||||
+ " , FOREIGN_CARS_KBN = ? "
|
||||
+ " , ARMY_CARS_KBN = ? "
|
||||
+ " , CAR_NO = ? "
|
||||
+ " , READER = ? "
|
||||
+ " , READING_DATE = TO_DATE(?,'yyyymmdd') "
|
||||
+ " , REMARKS = ? "
|
||||
+ " , NOTE_TRANS_YN = ? "
|
||||
+ " , NEW_DATA_YN = ? "
|
||||
+ " , NOTE_INPUT_REMARKS = ? "
|
||||
+ " , OTHER_SEQNO = ? "
|
||||
+ " , DELETE_YN = ? "
|
||||
+ " , URGENT_KBN = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE"
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_TIMES = ? "
|
||||
+ " AND SEQNO = ? ";
|
||||
|
||||
psUpd = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE FARE_TERMINAL_INFO "
|
||||
+ " SET CAR_TYPE_ID = ? "
|
||||
+ " , COLLECT_ID = ? "
|
||||
+ " , LEVY_AMOUNT = ? "
|
||||
+ " , CAR_NO = ? "
|
||||
+ " , REMARKS = ? "
|
||||
+ " , DELETE_YN = ? "
|
||||
+ " , URGENT_KBN = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE"
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_TIMES = ? "
|
||||
+ " AND SEQNO = ? ";
|
||||
|
||||
psUpd1 = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE DEFAULT_FARE_READ_INFO "
|
||||
+ " SET CAR_NO = ? "
|
||||
+ " , COLLECT_ID = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE"
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_TIMES = ? "
|
||||
+ " AND SEQNO = ? ";
|
||||
|
||||
psUpd2 = conn.prepareStatement(query);
|
||||
|
||||
query = "DELETE FROM DEFAULT_FARE_READ_INFO"
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_TIMES = ? "
|
||||
+ " AND SEQNO = ? ";
|
||||
|
||||
psDel = conn.prepareStatement(query);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psSls1 != null) psSls1.close(); }catch(Exception ignore){}
|
||||
try{ if(psSls2 != null) psSls2.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns1 != null) psIns1.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns2 != null) psIns2.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd != null) psUpd.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd1 != null) psUpd1.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd2 != null) psUpd2.close(); }catch(Exception ignore){}
|
||||
try{ if(psDel != null) psDel.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(FareTermDataRecord record) throws SQLException , Exception {
|
||||
int iParam;
|
||||
try{
|
||||
String sPrcsKbn1 = record.getItem(FareTermDataRecord.NEW_DATA_YN); // 입력여부
|
||||
String sPrcsKbn2 = record.getItem(FareTermDataRecord.COLLECT_ID); // 징수유형
|
||||
String sPrcsKbn3 = record.getItem(FareTermDataRecord.DELETE_YN); // 삭제여부
|
||||
|
||||
if (sPrcsKbn1.equals("1")) { // 수기통행여부
|
||||
iParam = 1;
|
||||
psSls1.setString(iParam++, record.getItem( FareTermDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psSls1.setString(iParam++, record.getItem( FareTermDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psSls1.setString(iParam++, record.getItem( FareTermDataRecord.BOOTH_ID ).trim()); // '차로'
|
||||
psSls1.setString(iParam++, record.getItem( FareTermDataRecord.YEAR ).trim()); // '년'
|
||||
psSls1.setString(iParam++, record.getItem( FareTermDataRecord.MONTH ).trim()); // '월'
|
||||
psSls1.setString(iParam++, record.getItem( FareTermDataRecord.DAY ).trim()); // '일'
|
||||
psSls1.setString(iParam++, record.getItem( FareTermDataRecord.WORK_TIMES ).trim()); // '통행시간'
|
||||
psSls1.setString(iParam++, record.getItem( FareTermDataRecord.SEQNO ).trim()); // '일련번호'
|
||||
rs1 = psSls1.executeQuery();
|
||||
|
||||
rs1.next();
|
||||
if (rs1.getInt(1) == 0) { // Data 미존재시
|
||||
iParam = 1;
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.FARE_OFFICE_ID ).trim()); // '요금소코드'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.BOOTH_ID ).trim()); // '차로코드'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.YEAR ).trim()); // '년도'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.MONTH ).trim()); // '월'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.DAY ).trim()); // '일'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.WORK_TIMES ).trim()); // '통행시간'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.SEQNO ).trim()); // '일련번호'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.CAR_TYPE_ID ).trim()); // '차종코드'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.COLLECT_ID ).trim()); // '징수유형코드'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.IN_OUT_KBN ).trim()); // '유출입구분'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.LEVY_AMOUNT ).trim()); // '징수금액'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.READING_ID ).trim()); // '판독구분코드'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.FOREIGN_CARS_KBN ).trim()); // '외국인차량구분'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.ARMY_CARS_KBN ).trim()); // '미군용차량구분'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.CARS_MOVE_PICTURE_FILE ).trim()); // '동영상파일명'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.CARS_STOP_PICTURE_FILE ).trim()); // '정지영상파일명'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.CAR_NO ).trim()); // '차량번호'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.READER ).trim()); // '판독자 ID'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.READING_DATE ).trim()); // '판독일자'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.REMARKS ).trim()); // '비고'
|
||||
psIns1.setInt(iParam++, Integer.parseInt(record.getItem( FareTermDataRecord.X_POSITION ).trim())); // '번호판 X좌표'
|
||||
psIns1.setInt(iParam++, Integer.parseInt(record.getItem( FareTermDataRecord.Y_POSITION ).trim())); // '번호판 Y좌표'
|
||||
psIns1.setInt(iParam++, Integer.parseInt(record.getItem( FareTermDataRecord.GARO_LEN ).trim())); // '번호판 가로길이'
|
||||
psIns1.setInt(iParam++, Integer.parseInt(record.getItem( FareTermDataRecord.SERO_LEN ).trim())); // '번호판 세로길이'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.NOTE_TRANS_YN ).trim()); // '수기통행여부'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.NEW_DATA_YN ).trim()); // '입력여부'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.NOTE_INPUT_REMARKS ).trim()); // '수기입력사유'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.OTHER_SEQNO ).trim()); // '중복방지번호'
|
||||
psIns1.setString(iParam++, record.getItem( FareTermDataRecord.URGENT_KBN ).trim()); // '비상데이터구분'
|
||||
psIns1.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
}else{
|
||||
iParam = 1;
|
||||
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.CAR_TYPE_ID ).trim()); // '차종코드'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.COLLECT_ID ).trim()); // '징수유형코드'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.IN_OUT_KBN ).trim()); // '유출입구분'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.LEVY_AMOUNT ).trim()); // '징수금액'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.READING_ID ).trim()); // '판독구분코드'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.FOREIGN_CARS_KBN ).trim()); // '외국인차량구분'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.ARMY_CARS_KBN ).trim()); // '미군용차량구분'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.CAR_NO ).trim()); // '차량번호'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.READER ).trim()); // '판독자 ID'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.READING_DATE ).trim()); // '판독일자'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.REMARKS ).trim()); // '비고'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.NOTE_TRANS_YN ).trim()); // '수기통행여부'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.NEW_DATA_YN ).trim()); // '입력여부'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.NOTE_INPUT_REMARKS ).trim()); // '수기입력사유'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.OTHER_SEQNO ).trim()); // '중복방지번호'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.DELETE_YN ).trim()); // '삭제여부'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.URGENT_KBN ).trim()); // '비상데이터구분'
|
||||
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.FARE_OFFICE_ID ).trim()); // '요금소코드'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.BOOTH_ID ).trim()); // '차로코드'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.YEAR ).trim()); // '년도'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.MONTH ).trim()); // '월'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.DAY ).trim()); // '일'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.WORK_TIMES ).trim()); // '통행시간'
|
||||
psUpd.setString(iParam++, record.getItem( FareTermDataRecord.SEQNO ).trim()); // '일련번호'
|
||||
psUpd.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (sPrcsKbn2.equals("40")) { // 징수유형
|
||||
iParam = 1;
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.FARE_OFFICE_ID ).trim()); // '요금소코드'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.BOOTH_ID ).trim()); // '차로코드'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.YEAR ).trim()); // '년도'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.MONTH ).trim()); // '월'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.DAY ).trim()); // '일'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.WORK_TIMES ).trim()); // '통행시간'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.SEQNO ).trim()); // '일련번호'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.COLLECT_ID ).trim()); // '징수유형코드'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.READING_ID ).trim()); // '판독구분코드'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.CARS_MOVE_PICTURE_FILE ).trim()); // '동영상파일명'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.CARS_STOP_PICTURE_FILE ).trim()); // '정지영상파일명'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.CAR_NO ).trim()); // '차량번호'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.READING_DATE ).trim()); // '판독일자'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.X_POSITION ).trim()); // '번호판 X좌표'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.Y_POSITION ).trim()); // '번호판 Y좌표'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.GARO_LEN ).trim()); // '번호판 가로길이'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.SERO_LEN ).trim()); // '번호판 세로길이'
|
||||
psIns2.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
}
|
||||
} else {
|
||||
|
||||
iParam = 1;
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.CAR_TYPE_ID ).trim()); // '차종코드'
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.COLLECT_ID ).trim()); // '징수유형'
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.LEVY_AMOUNT ).trim()); // '징수금액'
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.CAR_NO ).trim()); // '차량번호'
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.REMARKS ).trim()); // '비고'
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.DELETE_YN ).trim()); // '삭제여부'
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.URGENT_KBN ).trim()); // '비상데이터구분'
|
||||
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.BOOTH_ID ).trim()); // '차로'
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.YEAR ).trim()); // '년'
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.MONTH ).trim()); // '월'
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.DAY ).trim()); // '일'
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.WORK_TIMES ).trim()); // '통행시간'
|
||||
psUpd1.setString(iParam++, record.getItem( FareTermDataRecord.SEQNO ).trim()); // '일련번호'
|
||||
psUpd1.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
|
||||
iParam = 1;
|
||||
psSls2.setString(iParam++, record.getItem( FareTermDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psSls2.setString(iParam++, record.getItem( FareTermDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psSls2.setString(iParam++, record.getItem( FareTermDataRecord.BOOTH_ID ).trim()); // '차로'
|
||||
psSls2.setString(iParam++, record.getItem( FareTermDataRecord.YEAR ).trim()); // '년'
|
||||
psSls2.setString(iParam++, record.getItem( FareTermDataRecord.MONTH ).trim()); // '월'
|
||||
psSls2.setString(iParam++, record.getItem( FareTermDataRecord.DAY ).trim()); // '일'
|
||||
psSls2.setString(iParam++, record.getItem( FareTermDataRecord.WORK_TIMES ).trim()); // '통행시간'
|
||||
psSls2.setString(iParam++, record.getItem( FareTermDataRecord.SEQNO ).trim()); // '일련번호'
|
||||
rs2 = psSls2.executeQuery();
|
||||
|
||||
rs2.next();
|
||||
|
||||
if (rs2.getInt(1) == 0) { // 미납정보 건수
|
||||
if (sPrcsKbn2.equals("40")) { // 징수유형
|
||||
iParam = 1;
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.FARE_OFFICE_ID ).trim()); // '요금소코드'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.BOOTH_ID ).trim()); // '차로코드'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.YEAR ).trim()); // '년도'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.MONTH ).trim()); // '월'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.DAY ).trim()); // '일'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.WORK_TIMES ).trim()); // '통행시간'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.SEQNO ).trim()); // '일련번호'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.COLLECT_ID ).trim()); // '징수유형코드'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.READING_ID ).trim()); // '판독구분코드'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.CARS_MOVE_PICTURE_FILE ).trim()); // '동영상파일명'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.CARS_STOP_PICTURE_FILE ).trim()); // '정지영상파일명'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.CAR_NO ).trim()); // '차량번호'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.READING_DATE ).trim()); // '판독일자'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.X_POSITION ).trim()); // '번호판 X좌표'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.Y_POSITION ).trim()); // '번호판 Y좌표'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.GARO_LEN ).trim()); // '번호판 가로길이'
|
||||
psIns2.setString(iParam++, record.getItem( FareTermDataRecord.SERO_LEN ).trim()); // '번호판 세로길이'
|
||||
psIns2.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
}
|
||||
} else if (rs2.getInt(1) > 0) { // 미납정보 건수
|
||||
if (sPrcsKbn3.equals("1")) { // 삭제여부
|
||||
iParam = 1;
|
||||
psDel.setString(iParam++, record.getItem( FareTermDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psDel.setString(iParam++, record.getItem( FareTermDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psDel.setString(iParam++, record.getItem( FareTermDataRecord.BOOTH_ID ).trim()); // '차로'
|
||||
psDel.setString(iParam++, record.getItem( FareTermDataRecord.YEAR ).trim()); // '년'
|
||||
psDel.setString(iParam++, record.getItem( FareTermDataRecord.MONTH ).trim()); // '월'
|
||||
psDel.setString(iParam++, record.getItem( FareTermDataRecord.DAY ).trim()); // '일'
|
||||
psDel.setString(iParam++, record.getItem( FareTermDataRecord.WORK_TIMES ).trim()); // '통행시간'
|
||||
psDel.setString(iParam++, record.getItem( FareTermDataRecord.SEQNO ).trim()); // '일련번호'
|
||||
psDel.executeUpdate();
|
||||
|
||||
nDeleteCount++;
|
||||
} else if (sPrcsKbn3.equals("0")) { // 삭제여부
|
||||
iParam = 1;
|
||||
psUpd2.setString(iParam++, record.getItem( FareTermDataRecord.CAR_NO ).trim()); // '차량번호'
|
||||
psUpd2.setString(iParam++, record.getItem( FareTermDataRecord.COLLECT_ID ).trim()); // '징수유형'
|
||||
psUpd2.setString(iParam++, record.getItem( FareTermDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psUpd2.setString(iParam++, record.getItem( FareTermDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd2.setString(iParam++, record.getItem( FareTermDataRecord.BOOTH_ID ).trim()); // '차로'
|
||||
psUpd2.setString(iParam++, record.getItem( FareTermDataRecord.YEAR ).trim()); // '년'
|
||||
psUpd2.setString(iParam++, record.getItem( FareTermDataRecord.MONTH ).trim()); // '월'
|
||||
psUpd2.setString(iParam++, record.getItem( FareTermDataRecord.DAY ).trim()); // '일'
|
||||
psUpd2.setString(iParam++, record.getItem( FareTermDataRecord.WORK_TIMES ).trim()); // '통행시간'
|
||||
psUpd2.setString(iParam++, record.getItem( FareTermDataRecord.SEQNO ).trim()); // '일련번호'
|
||||
psUpd2.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}finally{
|
||||
try{ if(rs1 != null) rs1.close(); }catch(Exception ignore){}
|
||||
try{ if(rs2 != null) rs2.close(); }catch(Exception ignore){}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,136 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.FareTermUpdDataRecord;
|
||||
|
||||
/**
|
||||
* 요금단말변경정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyFareTermupd extends FileWorker
|
||||
{
|
||||
|
||||
private String sPrcsName = "ApplyFareTermupd";
|
||||
public static final int REC_LEN = 200; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private PreparedStatement psIns = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
if( sTemp.charAt(10) == 'D'){
|
||||
// 데이터 반영
|
||||
processRecord(new FareTermUpdDataRecord(sTemp));
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
nDeleteCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
|
||||
query = "INSERT INTO FARE_TERMINAL_UPDATE_INFO ( "
|
||||
+ " WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, WORK_TIMES, "
|
||||
+ " SEQNO, UPDATE_SEQNO, HISTORY_UPDATE_DATE, UPDATE_REASON, DECISION_YN, "
|
||||
+ " CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ "VALUES (?,?,?,?,?,?,?,?,?,to_date(?,'yyyymmdd'),?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns = conn.prepareStatement(query);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psIns != null) psIns.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(FareTermUpdDataRecord record) throws SQLException , Exception {
|
||||
int iParam;
|
||||
|
||||
try{
|
||||
iParam = 1;
|
||||
psIns.setString(iParam++, record.getItem( FareTermUpdDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psIns.setString(iParam++, record.getItem( FareTermUpdDataRecord.FARE_OFFICE_ID ).trim()); // '요금소코드'
|
||||
psIns.setString(iParam++, record.getItem( FareTermUpdDataRecord.BOOTH_ID ).trim()); // '차로코드'
|
||||
psIns.setString(iParam++, record.getItem( FareTermUpdDataRecord.YEAR ).trim()); // '년도'
|
||||
psIns.setString(iParam++, record.getItem( FareTermUpdDataRecord.MONTH ).trim()); // '월'
|
||||
psIns.setString(iParam++, record.getItem( FareTermUpdDataRecord.DAY ).trim()); // '일'
|
||||
psIns.setString(iParam++, record.getItem( FareTermUpdDataRecord.WORK_TIMES ).trim()); // '통행시간'
|
||||
psIns.setString(iParam++, record.getItem( FareTermUpdDataRecord.SEQNO ).trim()); // '일련번호'
|
||||
psIns.setString(iParam++, record.getItem( FareTermUpdDataRecord.UPDATE_SEQNO ).trim()); // '이력일련번호'
|
||||
psIns.setString(iParam++, record.getItem( FareTermUpdDataRecord.UPDATE_HISTORY_DATE ).trim()); // '변경일자'
|
||||
psIns.setString(iParam++, record.getItem( FareTermUpdDataRecord.UPDATE_REASON ).trim()); // '변경사유'
|
||||
psIns.setString(iParam++, record.getItem( FareTermUpdDataRecord.COLLECT_ID ).trim()); // '수정 징수유형'
|
||||
psIns.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,277 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.FixTicketDataRecord;
|
||||
|
||||
/**
|
||||
* 정액권수불정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyFixTicket extends FileWorker
|
||||
{
|
||||
|
||||
private String sPrcsName = "ApplyFixTicket";
|
||||
public static final int REC_LEN = 210; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private ResultSet rs = null;
|
||||
private PreparedStatement psSls1 = null;
|
||||
private PreparedStatement psSls2 = null;
|
||||
private PreparedStatement psIns1 = null;
|
||||
private PreparedStatement psIns2 = null;
|
||||
private PreparedStatement psUpd1 = null;
|
||||
private PreparedStatement psUpd2 = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
// 데이터 반영
|
||||
processRecord(new FixTicketDataRecord(sTemp));
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(".... DB Update Count : "+ nUpdateCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
|
||||
query = "SELECT COUNT(*) "
|
||||
+ " FROM FIX_AMOUNT_HEAD_INFO "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND IN_OUT_KBN = ? ";
|
||||
|
||||
psSls1 = conn.prepareStatement(query);
|
||||
|
||||
query = "SELECT COUNT(*) "
|
||||
+ " FROM FIX_AMOUNT_DETAIL_INFO "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND IN_OUT_KBN = ? "
|
||||
+ " AND SEQNO = ? ";
|
||||
|
||||
psSls2 = conn.prepareStatement(query);
|
||||
|
||||
query = "INSERT INTO FIX_AMOUNT_HEAD_INFO( "
|
||||
+ " FARE_OFFICE_ID, YEAR, MONTH, DAY, IN_OUT_KBN, IN_OUT_COUNT, "
|
||||
+ " CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ "VALUES (?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns1 = conn.prepareStatement(query);
|
||||
|
||||
query = "INSERT INTO FIX_AMOUNT_DETAIL_INFO( "
|
||||
+ " FARE_OFFICE_ID, YEAR, MONTH, DAY, IN_OUT_KBN, SEQNO, BOOTH_ID, STT_SEQNO, "
|
||||
+ " END_SEQNO, IN_OUT_COUNT, REMARKS, DAY_END_PROCESS_FLAG, "
|
||||
+ " CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns2 = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE FIX_AMOUNT_HEAD_INFO "
|
||||
+ " SET IN_OUT_COUNT = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE "
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND IN_OUT_KBN = ? ";
|
||||
|
||||
psUpd1 = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE FIX_AMOUNT_DETAIL_INFO "
|
||||
+ " SET BOOTH_ID = ? "
|
||||
+ " , STT_SEQNO = ? "
|
||||
+ " , END_SEQNO = ? "
|
||||
+ " , IN_OUT_COUNT = ? "
|
||||
+ " , REMARKS = ? "
|
||||
+ " , DAY_END_PROCESS_FLAG = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE"
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND IN_OUT_KBN = ? "
|
||||
+ " AND SEQNO = ? ";
|
||||
|
||||
psUpd2 = conn.prepareStatement(query);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psSls1 != null) psSls1.close(); }catch(Exception ignore){}
|
||||
try{ if(psSls2 != null) psSls2.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns1 != null) psIns1.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns2 != null) psIns2.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd1 != null) psUpd1.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd2 != null) psUpd2.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(FixTicketDataRecord record) throws SQLException , Exception {
|
||||
int iParam;
|
||||
try{
|
||||
char sPrcsKbn = record.getItem(FixTicketDataRecord.D_DATA_TYPE).charAt(0); // 자료구분
|
||||
|
||||
switch (sPrcsKbn) {
|
||||
case 'H':
|
||||
iParam = 1;
|
||||
psSls1.setString(iParam++, record.getItem( FixTicketDataRecord.H_FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psSls1.setString(iParam++, record.getItem( FixTicketDataRecord.H_YEAR ).trim()); // '년도'
|
||||
psSls1.setString(iParam++, record.getItem( FixTicketDataRecord.H_MONTH ).trim()); // '월'
|
||||
psSls1.setString(iParam++, record.getItem( FixTicketDataRecord.H_DAY ).trim()); // '일'
|
||||
psSls1.setString(iParam++, record.getItem( FixTicketDataRecord.H_IN_OUT_KBN ).trim()); // '수불구분'
|
||||
rs = psSls1.executeQuery();
|
||||
rs.next();
|
||||
|
||||
if (rs.getInt(1) == 0) {
|
||||
iParam = 1;
|
||||
psIns1.setString(iParam++, record.getItem( FixTicketDataRecord.H_FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psIns1.setString(iParam++, record.getItem( FixTicketDataRecord.H_YEAR ).trim()); // '년도'
|
||||
psIns1.setString(iParam++, record.getItem( FixTicketDataRecord.H_MONTH ).trim()); // '월'
|
||||
psIns1.setString(iParam++, record.getItem( FixTicketDataRecord.H_DAY ).trim()); // '일'
|
||||
psIns1.setString(iParam++, record.getItem( FixTicketDataRecord.H_IN_OUT_KBN ).trim()); // '수불구분'
|
||||
psIns1.setString(iParam++, record.getItem( FixTicketDataRecord.H_IN_OUT_COUNT ).trim()); // '정액권권수'
|
||||
psIns1.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
} else if (rs.getInt(1) > 0) {
|
||||
iParam = 1;
|
||||
psUpd1.setString(iParam++, record.getItem( FixTicketDataRecord.H_IN_OUT_COUNT ).trim()); // '정액권권수'
|
||||
psUpd1.setString(iParam++, record.getItem( FixTicketDataRecord.H_FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd1.setString(iParam++, record.getItem( FixTicketDataRecord.H_YEAR ).trim()); // '년도'
|
||||
psUpd1.setString(iParam++, record.getItem( FixTicketDataRecord.H_MONTH ).trim()); // '월'
|
||||
psUpd1.setString(iParam++, record.getItem( FixTicketDataRecord.H_DAY ).trim()); // '일'
|
||||
psUpd1.setString(iParam++, record.getItem( FixTicketDataRecord.H_IN_OUT_KBN ).trim()); // '수불구분'
|
||||
psUpd1.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
|
||||
iParam = 1;
|
||||
psSls2.setString(iParam++, record.getItem( FixTicketDataRecord.D_FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psSls2.setString(iParam++, record.getItem( FixTicketDataRecord.D_YEAR ).trim()); // '년도'
|
||||
psSls2.setString(iParam++, record.getItem( FixTicketDataRecord.D_MONTH ).trim()); // '월'
|
||||
psSls2.setString(iParam++, record.getItem( FixTicketDataRecord.D_DAY ).trim()); // '일'
|
||||
psSls2.setString(iParam++, record.getItem( FixTicketDataRecord.D_IN_OUT_KBN ).trim()); // '수불구분'
|
||||
psSls2.setString(iParam++, record.getItem( FixTicketDataRecord.D_SEQNO ).trim()); // '일련번호'
|
||||
rs = psSls2.executeQuery();
|
||||
rs.next();
|
||||
|
||||
if (rs.getInt(1) == 0) {
|
||||
iParam = 1;
|
||||
psIns2.setString(iParam++, record.getItem( FixTicketDataRecord.D_FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psIns2.setString(iParam++, record.getItem( FixTicketDataRecord.D_YEAR ).trim()); // '년도'
|
||||
psIns2.setString(iParam++, record.getItem( FixTicketDataRecord.D_MONTH ).trim()); // '월'
|
||||
psIns2.setString(iParam++, record.getItem( FixTicketDataRecord.D_DAY ).trim()); // '일'
|
||||
psIns2.setString(iParam++, record.getItem( FixTicketDataRecord.D_IN_OUT_KBN ).trim()); // '수불구분'
|
||||
psIns2.setString(iParam++, record.getItem( FixTicketDataRecord.D_SEQNO ).trim()); // '일련번호'
|
||||
psIns2.setString(iParam++, record.getItem( FixTicketDataRecord.D_BOOTH_ID ).trim()); // '차로'
|
||||
psIns2.setString(iParam++, record.getItem( FixTicketDataRecord.D_STT_SEQNO ).trim()); // '시작일련번호'
|
||||
psIns2.setString(iParam++, record.getItem( FixTicketDataRecord.D_END_SEQNO ).trim()); // '종료일련번호'
|
||||
psIns2.setString(iParam++, record.getItem( FixTicketDataRecord.D_IN_OUT_COUNT ).trim()); // '정액권권수'
|
||||
psIns2.setString(iParam++, record.getItem( FixTicketDataRecord.D_REMARKS ).trim()); // '비고'
|
||||
psIns2.setString(iParam++, record.getItem( FixTicketDataRecord.D_DAY_END_PROCESS_FLAG ).trim()); // '일마감'
|
||||
psIns2.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
} else if (rs.getInt(1) > 0) {
|
||||
iParam = 1;
|
||||
psUpd2.setString(iParam++, record.getItem( FixTicketDataRecord.D_BOOTH_ID ).trim()); // '차로'
|
||||
psUpd2.setString(iParam++, record.getItem( FixTicketDataRecord.D_STT_SEQNO ).trim()); // '시작일련번호'
|
||||
psUpd2.setString(iParam++, record.getItem( FixTicketDataRecord.D_END_SEQNO ).trim()); // '종료일련번호'
|
||||
psUpd2.setString(iParam++, record.getItem( FixTicketDataRecord.D_IN_OUT_COUNT ).trim()); // '정액권권수'
|
||||
psUpd2.setString(iParam++, record.getItem( FixTicketDataRecord.D_REMARKS ).trim()); // '비고'
|
||||
psUpd2.setString(iParam++, record.getItem( FixTicketDataRecord.D_DAY_END_PROCESS_FLAG ).trim()); // '일마감'
|
||||
psUpd2.setString(iParam++, record.getItem( FixTicketDataRecord.D_FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd2.setString(iParam++, record.getItem( FixTicketDataRecord.D_YEAR ).trim()); // '년도'
|
||||
psUpd2.setString(iParam++, record.getItem( FixTicketDataRecord.D_MONTH ).trim()); // '월'
|
||||
psUpd2.setString(iParam++, record.getItem( FixTicketDataRecord.D_DAY ).trim()); // '일'
|
||||
psUpd2.setString(iParam++, record.getItem( FixTicketDataRecord.D_IN_OUT_KBN ).trim()); // '수불구분'
|
||||
psUpd2.setString(iParam++, record.getItem( FixTicketDataRecord.D_SEQNO ).trim()); // '일련번호'
|
||||
psUpd2.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}finally{
|
||||
try{ if(rs != null) rs.close(); }catch(Exception ignore){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,213 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.InOutAmtDataRecord;
|
||||
|
||||
/**
|
||||
* 입출금정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyInOutAmt extends FileWorker
|
||||
{
|
||||
|
||||
private String sPrcsName = "ApplyInOutAmt";
|
||||
public static final int REC_LEN = 250; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private ResultSet rs = null;
|
||||
private PreparedStatement psSls = null;
|
||||
private PreparedStatement psIns = null;
|
||||
private PreparedStatement psUpd = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
if( sTemp.charAt(10) == 'D'){
|
||||
// 데이터 반영
|
||||
processRecord(new InOutAmtDataRecord(sTemp));
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(".... DB Update Count : "+ nUpdateCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
|
||||
query = " SELECT COUNT(*) "
|
||||
+ " FROM IN_OUT_INFO "
|
||||
+ " WHERE WORKER_ID = ?"
|
||||
+ " AND FARE_OFFICE_ID = ?"
|
||||
+ " AND BOOTH_ID = ?"
|
||||
+ " AND YEAR = ?"
|
||||
+ " AND MONTH = ?"
|
||||
+ " AND DAY = ?"
|
||||
+ " AND WORK_STT_TIME = ?"
|
||||
+ " AND WORK_END_TIME = ?"
|
||||
+ " AND IO_SEQNO = ?";
|
||||
|
||||
psSls = conn.prepareStatement(query);
|
||||
|
||||
query = " INSERT INTO IN_OUT_INFO( "
|
||||
+ " WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, "
|
||||
+ " WORK_STT_TIME, WORK_END_TIME, IO_SEQNO, IN_OUT_KBN, IN_OUT_CONTENTS, "
|
||||
+ " IN_OUT_AMOUNT, DELETE_YN, REMARKS, CREATE_DATE, CREATER, UPDATE_DATE, "
|
||||
+ " UPDATER "
|
||||
+ " ) "
|
||||
+ " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns = conn.prepareStatement(query);
|
||||
|
||||
query = " UPDATE IN_OUT_INFO "
|
||||
+ " SET IN_OUT_KBN = ? "
|
||||
+ " , IN_OUT_CONTENTS = ? "
|
||||
+ " , IN_OUT_AMOUNT = ? "
|
||||
+ " , DELETE_YN = ? "
|
||||
+ " , REMARKS = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE"
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_STT_TIME = ? "
|
||||
+ " AND WORK_END_TIME = ? "
|
||||
+ " AND IO_SEQNO = ? ";
|
||||
|
||||
psUpd = conn.prepareStatement(query);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psSls != null) psSls.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns != null) psIns.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd != null) psUpd.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(InOutAmtDataRecord record) throws SQLException , Exception {
|
||||
int iParam = 1;
|
||||
|
||||
try{
|
||||
psSls.setString(iParam++, record.getItem( InOutAmtDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psSls.setString(iParam++, record.getItem( InOutAmtDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psSls.setString(iParam++, record.getItem( InOutAmtDataRecord.BOOTH_ID ).trim()); // '차로'
|
||||
psSls.setString(iParam++, record.getItem( InOutAmtDataRecord.YEAR ).trim()); // '년도'
|
||||
psSls.setString(iParam++, record.getItem( InOutAmtDataRecord.MONTH ).trim()); // '월'
|
||||
psSls.setString(iParam++, record.getItem( InOutAmtDataRecord.DAY ).trim()); // '일'
|
||||
psSls.setString(iParam++, record.getItem( InOutAmtDataRecord.WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psSls.setString(iParam++, record.getItem( InOutAmtDataRecord.WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psSls.setString(iParam++, record.getItem( InOutAmtDataRecord.IO_SEQNO ).trim()); // '일련번호'
|
||||
rs = psSls.executeQuery();
|
||||
rs.next();
|
||||
|
||||
if (rs.getInt(1) == 0) {
|
||||
iParam = 1;
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.BOOTH_ID ).trim()); // '차로'
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.YEAR ).trim()); // '년도'
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.MONTH ).trim()); // '월'
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.DAY ).trim()); // '일'
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.IO_SEQNO ).trim()); // '일련번호'
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.IN_OUT_KBN ).trim()); // '입출금구분'
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.IN_OUT_CONTENTS ).trim()); // '입출금내역'
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.IN_OUT_AMOUNT ).trim()); // '입출금액'
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.DELETE_YN ).trim()); // '삭제구분'
|
||||
psIns.setString(iParam++, record.getItem( InOutAmtDataRecord.REMARKS ).trim()); // '비고'
|
||||
psIns.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
} else if (rs.getInt(1) > 0) {
|
||||
iParam = 1;
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.IN_OUT_KBN ).trim()); // '입출금구분'
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.IN_OUT_CONTENTS ).trim()); // '입출금내역'
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.IN_OUT_AMOUNT ).trim()); // '입출금액'
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.DELETE_YN ).trim()); // '삭제구분'
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.REMARKS ).trim()); // '비고'
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.BOOTH_ID ).trim()); // '차로'
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.YEAR ).trim()); // '년도'
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.MONTH ).trim()); // '월'
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.DAY ).trim()); // '일'
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psUpd.setString(iParam++, record.getItem( InOutAmtDataRecord.IO_SEQNO ).trim()); // '일련번호'
|
||||
psUpd.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}finally{
|
||||
try{ if(rs != null) rs.close(); }catch(Exception ignore){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,267 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.IncomeInfoDataRecord;
|
||||
|
||||
/**
|
||||
* 수입금정산정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyIncomeInfo extends FileWorker
|
||||
{
|
||||
|
||||
private String sPrcsName = "ApplyIncomeInfo";
|
||||
public static final int REC_LEN = 260; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private ResultSet rs = null;
|
||||
private PreparedStatement psSls = null;
|
||||
private PreparedStatement psIns = null;
|
||||
private PreparedStatement psUpd1 = null;
|
||||
private PreparedStatement psUpd2 = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
if( sTemp.charAt(10) == 'D'){
|
||||
// 데이터 반영
|
||||
processRecord(new IncomeInfoDataRecord(sTemp));
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(".... DB Update Count : "+ nUpdateCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
|
||||
query = "SELECT COUNT(*) "
|
||||
+ " FROM INCOME_ADJUST_INFO "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND INCOME_DATE = ? "
|
||||
+ " AND INCOME_PART = ? ";
|
||||
|
||||
psSls = conn.prepareStatement(query);
|
||||
|
||||
query = "INSERT INTO INCOME_ADJUST_INFO( "
|
||||
+ " FARE_OFFICE_ID, INCOME_DATE, INCOME_PART, CASH_QUANTITY, "
|
||||
+ " CARD_BEFORE_QUANTITY, CARD_AFTER_QUANTITY, COUPON_QUANTITY, "
|
||||
+ " EXEMPTION_QUANTITY, NONPAYMENT_QUANTITY, COUPON_SALE_QUANTITY, "
|
||||
+ " CASH_INCOME, COUPON_SALE_INCOME, CUSTOM_NAME, CUSTOM_PERSON, K_CASH_Q, "
|
||||
+ " K_SUN_Q, K_WHO_Q, K_COUPON_Q, K_COUPON_SALE_Q, K_CASH_INCOME, "
|
||||
+ " K_COUPON_SALE_INCOME, "
|
||||
+ " REPAY_Q, REPAY_M,SALE_CARD_Q, SALE_CARD_M, K_SALE_CARD_Q, K_SALE_CARD_M, "
|
||||
+ " CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ "VALUES (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE FARE_ADJUST_INFO "
|
||||
+ " SET INCOME_ADJUST_YN = '1' "
|
||||
+ " , INCOME_DATE = ? "
|
||||
+ " , INCOME_PART = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE "
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND YEAR||MONTH||DAY = ? "
|
||||
+ " AND C_AMPM = ? "
|
||||
+ " AND FARE_ADJUST_YN = '1' ";
|
||||
|
||||
psUpd1 = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE INCOME_ADJUST_INFO "
|
||||
+ " SET CASH_QUANTITY = ? "
|
||||
+ " , CARD_BEFORE_QUANTITY = ? "
|
||||
+ " , CARD_AFTER_QUANTITY = ? "
|
||||
+ " , COUPON_QUANTITY = ? "
|
||||
+ " , EXEMPTION_QUANTITY = ? "
|
||||
+ " , NONPAYMENT_QUANTITY = ? "
|
||||
+ " , COUPON_SALE_QUANTITY = ? "
|
||||
+ " , CASH_INCOME = ? "
|
||||
+ " , COUPON_SALE_INCOME = ? "
|
||||
+ " , CUSTOM_NAME = ? "
|
||||
+ " , CUSTOM_PERSON = ? "
|
||||
+ " , K_CASH_Q = ? "
|
||||
+ " , K_SUN_Q = ? "
|
||||
+ " , K_WHO_Q = ? "
|
||||
+ " , K_COUPON_Q = ? "
|
||||
+ " , K_COUPON_SALE_Q = ? "
|
||||
+ " , K_CASH_INCOME = ? "
|
||||
+ " , K_COUPON_SALE_INCOME = ? "
|
||||
+ " , REPAY_Q = ? "
|
||||
+ " , REPAY_M = ? "
|
||||
+ " , SALE_CARD_Q = ? "
|
||||
+ " , SALE_CARD_M = ? "
|
||||
+ " , K_SALE_CARD_Q = ? "
|
||||
+ " , K_SALE_CARD_M = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE "
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE FARE_OFFICE_ID = ? "
|
||||
+ " AND INCOME_DATE = ? "
|
||||
+ " AND INCOME_PART = ? ";
|
||||
|
||||
psUpd2 = conn.prepareStatement(query);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psSls != null) psSls.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns != null) psIns.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd1 != null) psUpd1.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd2 != null) psUpd2.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(IncomeInfoDataRecord record) throws SQLException , Exception {
|
||||
int iParam = 1;
|
||||
|
||||
try{
|
||||
psUpd1.setString(iParam++, record.getItem( IncomeInfoDataRecord.INCOME_DATE ).trim()); // '정산일자'
|
||||
psUpd1.setString(iParam++, record.getItem( IncomeInfoDataRecord.INCOME_PART ).trim()); // '오전/오후'
|
||||
psUpd1.setString(iParam++, record.getItem( IncomeInfoDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd1.setString(iParam++, record.getItem( IncomeInfoDataRecord.INCOME_DATE ).trim()); // '정산일자'
|
||||
psUpd1.setString(iParam++, record.getItem( IncomeInfoDataRecord.INCOME_PART ).trim()); // '정산그룹(오전/오후)'
|
||||
psUpd1.addBatch();
|
||||
|
||||
iParam = 1;
|
||||
psSls.setString(iParam++, record.getItem( IncomeInfoDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psSls.setString(iParam++, record.getItem( IncomeInfoDataRecord.INCOME_DATE ).trim()); // '정산일자'
|
||||
psSls.setString(iParam++, record.getItem( IncomeInfoDataRecord.INCOME_PART ).trim()); // '정산그룹(오전/오후)'
|
||||
rs = psSls.executeQuery();
|
||||
rs.next();
|
||||
|
||||
if (rs.getInt(1) == 0) {
|
||||
iParam = 1;
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.INCOME_DATE ).trim()); // '정산일자'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.INCOME_PART ).trim()); // '정산그룹'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.CASH_QUANTITY ).trim()); // '현금통행량'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.CARD_BEFORE_QUANTITY ).trim()); // '선불통행량'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.CARD_AFTER_QUANTITY ).trim()); // '후불통행량'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.COUPON_QUANTITY ).trim()); // '쿠폰통행량'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.EXEMPTION_QUANTITY ).trim()); // '면제통행량'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.NONPAYMENT_QUANTITY ).trim()); // '미납통행량'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.COUPON_SALE_QUANTITY ).trim()); // '정액권판매권수'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.CASH_INCOME ).trim()); // '현금수입금'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.COUPON_SALE_INCOME ).trim()); // '정액권판매금액'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.CUSTOM_NAME ).trim()); // '징수사명'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.CUSTOM_PERSON ).trim()); // '담당자명'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_CASH_Q ).trim()); // '경차현금통행량'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_SUN_Q ).trim()); // '경차선불통행량'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_WHO_Q ).trim()); // '경차후불통행량'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_COUPON_Q ).trim()); // '경차쿠폰통행량'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_COUPON_SALE_Q ).trim()); // '경차정액권판매권수'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_CASH_INCOME ).trim()); // '경차현금수입금'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_COUPON_SALE_INCOME ).trim()); // '경차정액권판매금액'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.REPAY_Q ).trim()); // '카드환불건수'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.REPAY_M ).trim()); // '카드환불금액'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.SALE_CARD_Q ).trim()); // '정액권카드판매권수'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.SALE_CARD_M ).trim()); // '정액권카드판매금액'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_SALE_CARD_Q ).trim()); // '경차정액권카드판매권수'
|
||||
psIns.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_SALE_CARD_M ).trim()); // '경차정액권카드판매금액'
|
||||
psIns.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
} else if (rs.getInt(1) > 0) {
|
||||
iParam = 1;
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.CASH_QUANTITY ).trim()); // '현금통행량'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.CARD_BEFORE_QUANTITY ).trim()); // '선불통행량'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.CARD_AFTER_QUANTITY ).trim()); // '후불통행량'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.COUPON_QUANTITY ).trim()); // '쿠폰통행량'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.EXEMPTION_QUANTITY ).trim()); // '면제통행량'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.NONPAYMENT_QUANTITY ).trim()); // '미납통행량'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.COUPON_SALE_QUANTITY ).trim()); // '정액권판매권수'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.CASH_INCOME ).trim()); // '현금수입금'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.COUPON_SALE_INCOME ).trim()); // '정액권판매금액'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.CUSTOM_NAME ).trim()); // '징수사명'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.CUSTOM_PERSON ).trim()); // '담당자명'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_CASH_Q ).trim()); // '경차현금통행량'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_SUN_Q ).trim()); // '경차선불통행량'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_WHO_Q ).trim()); // '경차후불통행량'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_COUPON_Q ).trim()); // '경차쿠폰통행량'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_COUPON_SALE_Q ).trim()); // '경차정액권판매권수'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_CASH_INCOME ).trim()); // '경차현금수입금'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_COUPON_SALE_INCOME ).trim()); // '경차정액권판매금액'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.REPAY_Q ).trim()); // '카드환불건수'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.REPAY_M ).trim()); // '카드환불금액'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.SALE_CARD_Q ).trim()); // '정액권카드판매권수'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.SALE_CARD_M ).trim()); // '정액권카드판매금액'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_SALE_CARD_Q ).trim()); // '경차정액권카드판매권수'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.K_SALE_CARD_M ).trim()); // '경차정액권카드판매금액'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.INCOME_DATE ).trim()); // '정산일자'
|
||||
psUpd2.setString(iParam++, record.getItem( IncomeInfoDataRecord.INCOME_PART ).trim()); // '정산그룹'
|
||||
psUpd2.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}finally{
|
||||
try{ if(rs != null) rs.close(); }catch(Exception ignore){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,333 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.OverCouponDataRecord;
|
||||
|
||||
/**
|
||||
* 과잉쿠폰정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyOverCoupon extends FileWorker
|
||||
{
|
||||
|
||||
private String sPrcsName = "ApplyOverCoupon";
|
||||
public static final int REC_LEN = 280; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private ResultSet rs = null;
|
||||
private PreparedStatement psSls = null;
|
||||
private PreparedStatement psIns1 = null;
|
||||
private PreparedStatement psIns2 = null;
|
||||
private PreparedStatement psIns3 = null;
|
||||
private PreparedStatement psDel1 = null;
|
||||
private PreparedStatement psDel2 = null;
|
||||
private PreparedStatement psDel3 = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
// 데이터 반영
|
||||
processRecord(new OverCouponDataRecord(sTemp));
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(".... DB Delete Count : "+ nDeleteCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
nDeleteCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
|
||||
query = "SELECT COUNT(*) "
|
||||
+ " FROM OVERCOUPON_HEAD_INFO"
|
||||
+ " WHERE WORKER_ID = ?"
|
||||
+ " AND FARE_OFFICE_ID = ?"
|
||||
+ " AND BOOTH_ID = ?"
|
||||
+ " AND YEAR = ?"
|
||||
+ " AND MONTH = ?"
|
||||
+ " AND DAY = ?"
|
||||
+ " AND WORK_STT_TIME = ?"
|
||||
+ " AND WORK_END_TIME = ?";
|
||||
|
||||
psSls = conn.prepareStatement(query);
|
||||
|
||||
query = " INSERT INTO OVERCOUPON_HEAD_INFO ( "
|
||||
+ " WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, "
|
||||
+ " WORK_STT_TIME, WORK_END_TIME, OVERCOUPON_COUNT, COUPON_RETURN_COUNT, "
|
||||
+ " COUPON_DISUSE_COUNT, K_OVERCOUPON_CNT, K_COUPON_RET_CNT, "
|
||||
+ " K_COUPON_DISUSE_CNT, CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') "
|
||||
+ " ";
|
||||
|
||||
psIns1 = conn.prepareStatement(query);
|
||||
|
||||
query = " INSERT INTO OVERCOUPON_DETAIL_INFO( "
|
||||
+ " WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, "
|
||||
+ " WORK_STT_TIME, WORK_END_TIME, SEQNO, FARE_TIME, OVER_KBN, COUPON_COUNT, "
|
||||
+ " CAR_NO, CAR_TYPE_NAME, OWNER, TEL_NO, REMARKS, INPUT_KBN, COUPON_NO, "
|
||||
+ " RETURN_DATE, RETURN_PERSON, DELETE_YN, MINI_CAR_KBN, CREATE_DATE, "
|
||||
+ " CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns2 = conn.prepareStatement(query);
|
||||
|
||||
query = " INSERT INTO OVERCOUPON_NO_INFO( "
|
||||
+ " WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, "
|
||||
+ " WORK_STT_TIME, WORK_END_TIME, SEQNO, COUPON_NO, MINI_CAR_KBN, "
|
||||
+ " CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ " VALUES (?,?,?,?,?,?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns3 = conn.prepareStatement(query);
|
||||
|
||||
query = "DELETE FROM OVERCOUPON_HEAD_INFO"
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_STT_TIME = ? "
|
||||
+ " AND WORK_END_TIME = ? ";
|
||||
|
||||
psDel1 = conn.prepareStatement(query);
|
||||
|
||||
query = "DELETE FROM OVERCOUPON_DETAIL_INFO "
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_STT_TIME = ? "
|
||||
+ " AND WORK_END_TIME = ? ";
|
||||
|
||||
psDel2 = conn.prepareStatement(query);
|
||||
|
||||
query = "DELETE FROM OVERCOUPON_NO_INFO "
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_STT_TIME = ? "
|
||||
+ " AND WORK_END_TIME = ? ";
|
||||
|
||||
psDel3 = conn.prepareStatement(query);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psSls != null) psSls.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns1 != null) psIns1.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns2 != null) psIns2.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns3 != null) psIns3.close(); }catch(Exception ignore){}
|
||||
try{ if(psDel1 != null) psDel1.close(); }catch(Exception ignore){}
|
||||
try{ if(psDel2 != null) psDel2.close(); }catch(Exception ignore){}
|
||||
try{ if(psDel3 != null) psDel3.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(OverCouponDataRecord record) throws SQLException , Exception {
|
||||
int iParam;
|
||||
|
||||
try{
|
||||
char sPrcsKbn = record.getItem(OverCouponDataRecord.D_DATA_TYPE).charAt(0); // 자료구분
|
||||
|
||||
switch (sPrcsKbn) { // 자료구분
|
||||
case 'H':
|
||||
|
||||
iParam = 1;
|
||||
psSls.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORKER_ID ).trim()); // '징수원ID'
|
||||
psSls.setString(iParam++, record.getItem( OverCouponDataRecord.H_FARE_OFFICE_ID ).trim()); // '요금소코드'
|
||||
psSls.setString(iParam++, record.getItem( OverCouponDataRecord.H_BOOTH_ID ).trim()); // '차로'
|
||||
psSls.setString(iParam++, record.getItem( OverCouponDataRecord.H_YEAR ).trim()); // '년도'
|
||||
psSls.setString(iParam++, record.getItem( OverCouponDataRecord.H_MONTH ).trim()); // '월'
|
||||
psSls.setString(iParam++, record.getItem( OverCouponDataRecord.H_DAY ).trim()); // '일'
|
||||
psSls.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psSls.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
rs = psSls.executeQuery();
|
||||
rs.next();
|
||||
|
||||
if (rs.getInt(1) > 0) {
|
||||
iParam = 1;
|
||||
psDel3.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORKER_ID ).trim()); // '징수원ID'
|
||||
psDel3.setString(iParam++, record.getItem( OverCouponDataRecord.H_FARE_OFFICE_ID ).trim()); // '요금소코드'
|
||||
psDel3.setString(iParam++, record.getItem( OverCouponDataRecord.H_BOOTH_ID ).trim()); // '차로'
|
||||
psDel3.setString(iParam++, record.getItem( OverCouponDataRecord.H_YEAR ).trim()); // '년도'
|
||||
psDel3.setString(iParam++, record.getItem( OverCouponDataRecord.H_MONTH ).trim()); // '월'
|
||||
psDel3.setString(iParam++, record.getItem( OverCouponDataRecord.H_DAY ).trim()); // '일'
|
||||
psDel3.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psDel3.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psDel3.executeUpdate();
|
||||
|
||||
iParam = 1;
|
||||
psDel2.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORKER_ID ).trim()); // '징수원ID'
|
||||
psDel2.setString(iParam++, record.getItem( OverCouponDataRecord.H_FARE_OFFICE_ID ).trim()); // '요금소코드'
|
||||
psDel2.setString(iParam++, record.getItem( OverCouponDataRecord.H_BOOTH_ID ).trim()); // '차로'
|
||||
psDel2.setString(iParam++, record.getItem( OverCouponDataRecord.H_YEAR ).trim()); // '년도'
|
||||
psDel2.setString(iParam++, record.getItem( OverCouponDataRecord.H_MONTH ).trim()); // '월'
|
||||
psDel2.setString(iParam++, record.getItem( OverCouponDataRecord.H_DAY ).trim()); // '일'
|
||||
psDel2.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psDel2.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psDel2.executeUpdate();
|
||||
|
||||
iParam = 1;
|
||||
psDel1.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORKER_ID ).trim()); // '징수원ID'
|
||||
psDel1.setString(iParam++, record.getItem( OverCouponDataRecord.H_FARE_OFFICE_ID ).trim()); // '요금소코드'
|
||||
psDel1.setString(iParam++, record.getItem( OverCouponDataRecord.H_BOOTH_ID ).trim()); // '차로'
|
||||
psDel1.setString(iParam++, record.getItem( OverCouponDataRecord.H_YEAR ).trim()); // '년도'
|
||||
psDel1.setString(iParam++, record.getItem( OverCouponDataRecord.H_MONTH ).trim()); // '월'
|
||||
psDel1.setString(iParam++, record.getItem( OverCouponDataRecord.H_DAY ).trim()); // '일'
|
||||
psDel1.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psDel1.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psDel1.executeUpdate();
|
||||
|
||||
nDeleteCount++;
|
||||
}
|
||||
|
||||
iParam = 1;
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORKER_ID ).trim()); // '징수원ID'
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_FARE_OFFICE_ID ).trim()); // '요금소코드'
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_BOOTH_ID ).trim()); // '차로코드'
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_YEAR ).trim()); // '년도'
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_MONTH ).trim()); // '월'
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_DAY ).trim()); // '일'
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_OVERCOUPON_COUNT ).trim()); // '과잉쿠폰 매수'
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_COUPON_RETURN_COUNT ).trim()); // '반환쿠폰 매수'
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_COUPON_DISUSE_COUNT ).trim()); // '폐기쿠폰 매수'
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_K_OVERCOUPON_CNT ).trim()); // '경차 과잉쿠폰 매수'
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_K_COUPON_RET_CNT ).trim()); // '경차 반환쿠폰 매수'
|
||||
psIns1.setString(iParam++, record.getItem( OverCouponDataRecord.H_K_COUPON_DISUSE_CNT ).trim()); // '경차 폐기쿠폰 매수'
|
||||
psIns1.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
|
||||
iParam = 1;
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_WORKER_ID ).trim()); // '징수원ID'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_FARE_OFFICE_ID ).trim()); // '요금소코드'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_BOOTH_ID ).trim()); // '차로코드'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_YEAR ).trim()); // '년도'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_MONTH ).trim()); // '월'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_DAY ).trim()); // '일'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_SEQNO ).trim()); // '일련번호'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_FARE_TIME ).trim()); // '징수시간'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_OVER_KBN ).trim()); // '과잉구분'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_COUPON_COUNT ).trim()); // '쿠폰매수'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_CAR_NO ).trim()); // '차량번호'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_CARS_TYPE_NAME ).trim()); // '차종명'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_OWNER ).trim()); // '수령자'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_TEL_NO ).trim()); // '수령자 연락번호'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_REMARKS ).trim()); // '비고'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_INPUT_KBN ).trim()); // '입력여부'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_COUPON_NO ).trim()); // '쿠폰번호'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_RETURN_DATE ).trim()); // '반환일자'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_RETURN_PERSON ).trim()); // '반환자'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_DELETE_YN ).trim()); // '삭제여부'
|
||||
psIns2.setString(iParam++, record.getItem( OverCouponDataRecord.D_C_REPAY_KBN ).trim()); // '경차구분'
|
||||
psIns2.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
|
||||
iParam = 1;
|
||||
psIns3.setString(iParam++, record.getItem( OverCouponDataRecord.C_WORKER_ID ).trim()); // '징수원ID'
|
||||
psIns3.setString(iParam++, record.getItem( OverCouponDataRecord.C_FARE_OFFICE_ID ).trim()); // '요금소코드'
|
||||
psIns3.setString(iParam++, record.getItem( OverCouponDataRecord.C_BOOTH_ID ).trim()); // '차로코드'
|
||||
psIns3.setString(iParam++, record.getItem( OverCouponDataRecord.C_YEAR ).trim()); // '년도'
|
||||
psIns3.setString(iParam++, record.getItem( OverCouponDataRecord.C_MONTH ).trim()); // '월'
|
||||
psIns3.setString(iParam++, record.getItem( OverCouponDataRecord.C_DAY ).trim()); // '일'
|
||||
psIns3.setString(iParam++, record.getItem( OverCouponDataRecord.C_WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psIns3.setString(iParam++, record.getItem( OverCouponDataRecord.C_WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psIns3.setString(iParam++, record.getItem( OverCouponDataRecord.C_SEQNO ).trim()); // '일련번호'
|
||||
psIns3.setString(iParam++, record.getItem( OverCouponDataRecord.C_COUPON_NO ).trim()); // '쿠폰번호'
|
||||
psIns3.setString(iParam++, record.getItem( OverCouponDataRecord.C_MINI_CAR_KBN ).trim()); // '경차구분'
|
||||
psIns3.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}finally{
|
||||
try{ if(rs != null) rs.close(); }catch(Exception ignore){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,259 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.OverFareDataRecord;
|
||||
|
||||
/**
|
||||
* 과오납정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyOverFare extends FileWorker
|
||||
{
|
||||
|
||||
private String sPrcsName = "ApplyOverFare";
|
||||
public static final int REC_LEN = 280; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private ResultSet rs = null;
|
||||
private PreparedStatement psSls = null;
|
||||
private PreparedStatement psIns = null;
|
||||
private PreparedStatement psUpd = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
if( sTemp.charAt(10) == 'D'){
|
||||
// 데이터 반영
|
||||
processRecord(new OverFareDataRecord(sTemp));
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(".... DB Update Count : "+ nUpdateCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
|
||||
query = "SELECT COUNT(*) "
|
||||
+ " FROM OVERFARE_INFO "
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_STT_TIME = ? "
|
||||
+ " AND WORK_END_TIME = ? "
|
||||
+ " AND OVERFARE_SEQNO = ? ";
|
||||
|
||||
psSls = conn.prepareStatement(query);
|
||||
|
||||
query = "INSERT INTO OVERFARE_INFO( "
|
||||
+ " WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, WORK_STT_TIME, WORK_END_TIME, "
|
||||
+ " OVERFARE_SEQNO, OWNER, CAR_NO, RESIDENT_NO, RESIDENT_DATE, OVERFARE_TIMES, "
|
||||
+ " OVERFARE_KBN, OVERFARE_AMOUNT, REMARKS, REFUND_KBN, REFUND_WORKER_ID, "
|
||||
+ " REFUND_FARE_OFFICE_ID, REFUND_BOOTH_ID, REFUND_YEAR, REFUND_MONTH, "
|
||||
+ " REFUND_DAY, REFUND_TIMES, REFUND_OWNER, REFUND_COMMUMI, PROCESS_KBN, "
|
||||
+ " DELETE_YN, CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ "VALUES (?,?,?,?,?, ?,?,?,?,?, ?,?,TO_DATE(?,'yyyymmdd'),?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE OVERFARE_INFO "
|
||||
+ " SET OWNER = ? "
|
||||
+ " , CAR_NO = ? "
|
||||
+ " , RESIDENT_NO = ? "
|
||||
+ " , RESIDENT_DATE = TO_DATE(?,'yyyymmdd') "
|
||||
+ " , OVERFARE_TIMES = ? "
|
||||
+ " , OVERFARE_KBN = ? "
|
||||
+ " , OVERFARE_AMOUNT = ? "
|
||||
+ " , REMARKS = ? "
|
||||
+ " , REFUND_KBN = ? "
|
||||
+ " , REFUND_WORKER_ID = ? "
|
||||
+ " , REFUND_FARE_OFFICE_ID = ? "
|
||||
+ " , REFUND_BOOTH_ID = ? "
|
||||
+ " , REFUND_YEAR = ? "
|
||||
+ " , REFUND_MONTH = ? "
|
||||
+ " , REFUND_DAY = ? "
|
||||
+ " , REFUND_TIMES = ? "
|
||||
+ " , REFUND_OWNER = ? "
|
||||
+ " , REFUND_COMMUMI = ? "
|
||||
+ " , PROCESS_KBN = ? "
|
||||
+ " , DELETE_YN = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE "
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_STT_TIME = ? "
|
||||
+ " AND WORK_END_TIME = ? "
|
||||
+ " AND OVERFARE_SEQNO = ? ";
|
||||
|
||||
psUpd = conn.prepareStatement(query);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psSls != null) psSls.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns != null) psIns.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd != null) psUpd.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(OverFareDataRecord record) throws SQLException , Exception {
|
||||
int iParam = 1;
|
||||
|
||||
try{
|
||||
psSls.setString(iParam++, record.getItem( OverFareDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psSls.setString(iParam++, record.getItem( OverFareDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psSls.setString(iParam++, record.getItem( OverFareDataRecord.BOOTH_ID ).trim()); // '차로'
|
||||
psSls.setString(iParam++, record.getItem( OverFareDataRecord.YEAR ).trim()); // '년'
|
||||
psSls.setString(iParam++, record.getItem( OverFareDataRecord.MONTH ).trim()); // '월'
|
||||
psSls.setString(iParam++, record.getItem( OverFareDataRecord.DAY ).trim()); // '일'
|
||||
psSls.setString(iParam++, record.getItem( OverFareDataRecord.WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psSls.setString(iParam++, record.getItem( OverFareDataRecord.WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psSls.setString(iParam++, record.getItem( OverFareDataRecord.OVERFARE_SEQNO ).trim()); // '일련번호'
|
||||
rs = psSls.executeQuery();
|
||||
|
||||
rs.next();
|
||||
if (rs.getInt(1) == 0) {
|
||||
iParam = 1;
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.BOOTH_ID ).trim()); // '차로'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.YEAR ).trim()); // '년'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.MONTH ).trim()); // '월'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.DAY ).trim()); // '일'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.OVERFARE_SEQNO ).trim()); // '일련번호'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.OWNER ).trim()); // '소유주'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.CARS_NO ).trim()); // '차량번호'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.RESIDENT_NO ).trim()); // '주민/법인번호'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.RESIDENT_DATE ).trim()); // '등록일자'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.OVERFARE_TIMES ).trim()); // '통행시간'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.OVERFARE_KBN ).trim()); // '과오납구분'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.OVERFARE_AMOUNT ).trim()); // '과오납금'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.REMARKS ).trim()); // '비고'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_KBN ).trim()); // '환급구분'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_WORKER_ID ).trim()); // '환급징수원ID'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_FARE_OFFICE_ID ).trim()); // '환급요금소'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_BOOTH_ID ).trim()); // '환급차로'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_YEAR ).trim()); // '환급년도'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_MONTH ).trim()); // '환급월'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_DAY ).trim()); // '환급일'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_TIMES ).trim()); // '환급시간'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_OWNER ).trim()); // '환급수령자'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_COMMUMI ).trim()); // '환급연락처'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.PROCESS_KBN ).trim()); // '집계처리구분'
|
||||
psIns.setString(iParam++, record.getItem( OverFareDataRecord.DELETE_YN ).trim()); // '삭제구분'
|
||||
psIns.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
} else if (rs.getInt(1) > 0) {
|
||||
iParam = 1;
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.OWNER ).trim()); // '소유주'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.CARS_NO ).trim()); // '차량번호'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.RESIDENT_NO ).trim()); // '주민/법인번호'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.RESIDENT_DATE ).trim()); // '등록일자'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.OVERFARE_TIMES ).trim()); // '통행시간'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.OVERFARE_KBN ).trim()); // '과오납구분'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.OVERFARE_AMOUNT ).trim()); // '과오납금'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.REMARKS ).trim()); // '비고'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_KBN ).trim()); // '환급구분'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_WORKER_ID ).trim()); // '환급징수원ID'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_FARE_OFFICE_ID ).trim()); // '환급요금소'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_BOOTH_ID ).trim()); // '환급차로'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_YEAR ).trim()); // '환급년도'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_MONTH ).trim()); // '환급월'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_DAY ).trim()); // '환급일'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_TIMES ).trim()); // '환급시간'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_OWNER ).trim()); // '환급수령자'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.REFUND_COMMUMI ).trim()); // '환급연락처'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.PROCESS_KBN ).trim()); // '집계처리구분'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.DELETE_YN ).trim()); // '삭제구분'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.BOOTH_ID ).trim()); // '차로'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.YEAR ).trim()); // '년'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.MONTH ).trim()); // '월'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.DAY ).trim()); // '일'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.WORK_STT_TIME ).trim()); // '근무시작시간'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.WORK_END_TIME ).trim()); // '근무종료시간'
|
||||
psUpd.setString(iParam++, record.getItem( OverFareDataRecord.OVERFARE_SEQNO ).trim()); // '일련번호'
|
||||
psUpd.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle; }finally{
|
||||
try{ if(rs != null) rs.close(); }catch(Exception ignore){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,211 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.RepayInfoDataRecord;
|
||||
|
||||
/**
|
||||
* 카드환불정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyRepayInfo extends FileWorker
|
||||
{
|
||||
|
||||
private String sPrcsName = "ApplyRepayInfo";
|
||||
public static final int REC_LEN = 170; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private ResultSet rs = null;
|
||||
private PreparedStatement psSls = null;
|
||||
private PreparedStatement psIns = null;
|
||||
private PreparedStatement psUpd = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
if( sTemp.charAt(10) == 'D'){
|
||||
// 데이터 반영
|
||||
processRecord(new RepayInfoDataRecord(sTemp));
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(".... DB Update Count : "+ nUpdateCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
|
||||
query = " SELECT COUNT(*) "
|
||||
+ " FROM RF_REPAY_INFO "
|
||||
+ " WHERE WORKER_ID = ?"
|
||||
+ " AND FARE_OFFICE_ID = ?"
|
||||
+ " AND BOOTH_ID = ?"
|
||||
+ " AND YEAR = ?"
|
||||
+ " AND MONTH = ?"
|
||||
+ " AND DAY = ?"
|
||||
+ " AND WORK_TIMES = ?"
|
||||
+ " AND SEQNO = ?";
|
||||
|
||||
psSls = conn.prepareStatement(query);
|
||||
|
||||
query = " INSERT INTO RF_REPAY_INFO( "
|
||||
+ " WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, WORK_TIMES, "
|
||||
+ " SEQNO, CAR_TYPE_ID, COLLECT_ID, WORK_STT_TIME, WORK_END_TIME, "
|
||||
+ " IN_OUT_KBN, LEVY_AMOUNT, CAR_NO, DAY_END_FLAG, MONTH_END_FLAG, "
|
||||
+ " NOTE_TRANS_YN, NOTE_INPUT_REMARKS, C_REPAY_KBN, CREATE_DATE, CREATER, "
|
||||
+ " UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns = conn.prepareStatement(query);
|
||||
|
||||
query = " UPDATE RF_REPAY_INFO "
|
||||
+ " SET C_REPAY_KBN = ? "
|
||||
+ " , LEVY_AMOUNT = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE "
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE WORKER_ID = ? "
|
||||
+ " AND FARE_OFFICE_ID = ? "
|
||||
+ " AND BOOTH_ID = ? "
|
||||
+ " AND YEAR = ? "
|
||||
+ " AND MONTH = ? "
|
||||
+ " AND DAY = ? "
|
||||
+ " AND WORK_TIMES = ? "
|
||||
+ " AND SEQNO = ? ";
|
||||
|
||||
psUpd = conn.prepareStatement(query);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psSls != null) psSls.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns != null) psIns.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd != null) psUpd.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(RepayInfoDataRecord record) throws SQLException , Exception {
|
||||
int iParam = 1;
|
||||
|
||||
try{
|
||||
psSls.setString(iParam++, record.getItem( RepayInfoDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psSls.setString(iParam++, record.getItem( RepayInfoDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psSls.setString(iParam++, record.getItem( RepayInfoDataRecord.BOOTH_ID ).trim()); // '차로'
|
||||
psSls.setString(iParam++, record.getItem( RepayInfoDataRecord.YEAR ).trim()); // '년도'
|
||||
psSls.setString(iParam++, record.getItem( RepayInfoDataRecord.MONTH ).trim()); // '월'
|
||||
psSls.setString(iParam++, record.getItem( RepayInfoDataRecord.DAY ).trim()); // '일'
|
||||
psSls.setString(iParam++, record.getItem( RepayInfoDataRecord.WORK_TIMES ).trim()); // '통행시간'
|
||||
psSls.setString(iParam++, record.getItem( RepayInfoDataRecord.DATA_SEQNO3 ).trim()); // '일련번호'
|
||||
rs = psSls.executeQuery();
|
||||
rs.next();
|
||||
|
||||
if (rs.getInt(1) == 0) {
|
||||
iParam = 1;
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.WORKER_ID ).trim()); // '징수원 ID'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.FARE_OFFICE_ID ).trim()); // '요금소 코드'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.BOOTH_ID ).trim()); // '차로 코드'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.YEAR ).trim()); // '년도'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.MONTH ).trim()); // '월'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.DAY ).trim()); // '일'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.WORK_TIMES ).trim()); // '통행시간'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.DATA_SEQNO3 ).trim()); // '일련번호'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.CAR_TYPE_ID ).trim()); // '차종코드'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.COLLECT_ID ).trim()); // '징수유형 코드'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.WORK_STT_TIME ).trim()); // '근무 시작시간'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.WORK_END_TIME ).trim()); // '근무 종료시간'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.IN_OUT_KBN ).trim()); // '유출입구분'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.LEVY_AMOUNT ).trim()); // '징수금액'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.CAR_NO ).trim()); // '차량번호'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.DAY_END_FLAG ).trim()); // '일마감 Flag'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.MONTH_END_FLAG ).trim()); // '월마감 Flag'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.NOTE_KBN ).trim()); // '수기통행여부'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.NOTE_REMARKS ).trim()); // '수기입력사유'
|
||||
psIns.setString(iParam++, record.getItem( RepayInfoDataRecord.REPAY_KBN ).trim()); // '환불여부'
|
||||
psIns.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
} else if (rs.getInt(1) > 0) {
|
||||
iParam = 1;
|
||||
psUpd.setString(iParam++, record.getItem( RepayInfoDataRecord.REPAY_KBN ).trim()); // '환불구분'
|
||||
psUpd.setString(iParam++, record.getItem( RepayInfoDataRecord.LEVY_AMOUNT ).trim()); // '환불금액'
|
||||
psUpd.setString(iParam++, record.getItem( RepayInfoDataRecord.WORKER_ID ).trim()); // '징수원ID'
|
||||
psUpd.setString(iParam++, record.getItem( RepayInfoDataRecord.FARE_OFFICE_ID ).trim()); // '요금소'
|
||||
psUpd.setString(iParam++, record.getItem( RepayInfoDataRecord.BOOTH_ID ).trim()); // '차로'
|
||||
psUpd.setString(iParam++, record.getItem( RepayInfoDataRecord.YEAR ).trim()); // '년도'
|
||||
psUpd.setString(iParam++, record.getItem( RepayInfoDataRecord.MONTH ).trim()); // '월'
|
||||
psUpd.setString(iParam++, record.getItem( RepayInfoDataRecord.DAY ).trim()); // '일'
|
||||
psUpd.setString(iParam++, record.getItem( RepayInfoDataRecord.WORK_TIMES ).trim()); // '통행시간'
|
||||
psUpd.setString(iParam++, record.getItem( RepayInfoDataRecord.DATA_SEQNO3 ).trim()); // '일련번호'
|
||||
psUpd.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}finally{
|
||||
try{ if(rs != null) rs.close(); }catch(Exception ignore){}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,174 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.PreCardDataRecord;
|
||||
|
||||
/**
|
||||
* 선불 반송 정보 적용<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyResultPre extends FileWorker
|
||||
{
|
||||
public static final int REC_LEN = 300; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private PreparedStatement pstmt = null;
|
||||
private String sCreater;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
String sPrcsName = "ApplyResultPre";
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
if(sPrcsName.length() <= 10 ) sCreater = sPrcsName;
|
||||
else sCreater = sPrcsName.substring(0, 10);
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null){
|
||||
nReadCount++;
|
||||
if( sTemp.startsWith("D")){
|
||||
PreCardDataRecord record = new PreCardDataRecord(sTemp);
|
||||
// 결과가 정상이 아닐 경우
|
||||
if( ! record.getItem(PreCardDataRecord.REFUSE_CODE).equals("00")){
|
||||
// 반송 데이터 반영
|
||||
applyRefuseData( record );
|
||||
}
|
||||
}else if( sTemp.startsWith("H")){
|
||||
this.sBaseDate = sTemp.substring(1,9);
|
||||
logger.logInfo( ".... file create date : "+sBaseDate);
|
||||
}else if( sTemp.startsWith("T")){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 프로시져 Call
|
||||
logger.logInfo( ".. procedure call ");
|
||||
runProcedure();
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName+ " apply fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
nDeleteCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String sQuery = " INSERT INTO CARD_TRANS_DETAIL_INFO "
|
||||
+ " ( WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, WORK_TIMES, SEQNO, "
|
||||
+ " CARD_NO, JOIN_CARD_NUMBER, NOMAL_DATE, REJECT_KBN, REJECT_ID, LEVY_AMOUNT, "
|
||||
+ " CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ " SELECT rf.WORKER_ID, rf.FARE_OFFICE_ID, rf.BOOTH_ID, rf.YEAR, rf.MONTH, rf.DAY, rf.WORK_TIMES, rf.SEQNO, "
|
||||
+ " rf.CARD_NO, joint.typical_id, SYSDATE, "
|
||||
+ " DECODE(rf.COLLECT_ID,'21','1','22','2','23','1','24','2','0'), ?, rf.LEVY_AMOUNT, "
|
||||
+ " SYSDATE, ?, SYSDATE, ? "
|
||||
+ " FROM rf_terminal_info rf, "
|
||||
+ " join_card_info joint "
|
||||
+ " WHERE rf.FARE_OFFICE_ID = joint.FARE_OFFICE_ID "
|
||||
+ " AND rf.ISSUE_ID = joint.ISSUE_ID "
|
||||
+ " AND rf.WORKER_ID = ? "
|
||||
+ " AND rf.FARE_OFFICE_ID = ? "
|
||||
+ " AND rf.BOOTH_ID = ? "
|
||||
+ " AND rf.YEAR = ? "
|
||||
+ " AND rf.MONTH = ? "
|
||||
+ " AND rf.DAY = ? "
|
||||
+ " AND rf.WORK_TIMES = ? ";
|
||||
|
||||
pstmt = conn.prepareStatement(sQuery);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( "RFID use info apply fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(pstmt != null) pstmt.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* RFID 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void applyRefuseData(PreCardDataRecord record) throws SQLException , Exception{
|
||||
try{
|
||||
String sTransactionID = record.getItem(PreCardDataRecord.TRANSACTION_ID);
|
||||
String sTradeTime = record.getItem(PreCardDataRecord.TRADE_TIME);
|
||||
|
||||
int iParam = 1;
|
||||
pstmt.setString(iParam++,record.getItem(PreCardDataRecord.REFUSE_CODE));
|
||||
pstmt.setString(iParam++,sCreater);
|
||||
pstmt.setString(iParam++,sCreater);
|
||||
pstmt.setString(iParam++,sTransactionID.substring( 0, 6));
|
||||
pstmt.setString(iParam++,sTransactionID.substring( 0, 2));
|
||||
pstmt.setString(iParam++,sTransactionID.substring( 6, 8));
|
||||
pstmt.setString(iParam++,sTradeTime.substring( 0, 4));
|
||||
pstmt.setString(iParam++,sTradeTime.substring( 4, 6));
|
||||
pstmt.setString(iParam++,sTradeTime.substring( 6, 8));
|
||||
pstmt.setString(iParam++,sTradeTime.substring( 8,14));
|
||||
|
||||
int nInsert = pstmt.executeUpdate();
|
||||
if( nInsert == 0 ) throw new SQLException("no rows updated");
|
||||
|
||||
nInsertCount++;
|
||||
if( nInsertCount%LOG_COUNT == 0 ) {
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getData() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 프로시져 수행(선불 반송 반영)
|
||||
*/
|
||||
private void runProcedure() throws SQLException , Exception{
|
||||
String query = "{ call SP_CARD_BANSONG_SUNBUL() }";
|
||||
CallableStatement cs = null;
|
||||
cs = conn.prepareCall(query);
|
||||
cs.execute();
|
||||
}
|
||||
}
|
||||
@ -1,185 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.PreCardDataRecordEB;
|
||||
|
||||
/**
|
||||
* 이비카드 선불 반송 정보 적용<BR>
|
||||
* @author jckim, dekim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성, 2011-10-15 이비카드 추가수정..
|
||||
*/
|
||||
public class ApplyResultPreEB extends FileWorker
|
||||
{
|
||||
public static final int REC_LEN = 300; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private PreparedStatement pstmt = null;
|
||||
private String sCreater;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
String sPrcsName = "ApplyResultPreEB";
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
if(sPrcsName.length() <= 10 ) sCreater = sPrcsName;
|
||||
else sCreater = sPrcsName.substring(0, 10);
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null){
|
||||
nReadCount++;
|
||||
if( sTemp.startsWith("D")){
|
||||
PreCardDataRecordEB record = new PreCardDataRecordEB(sTemp);
|
||||
// 결과가 정상이 아닐 경우
|
||||
if( ! record.getItem(PreCardDataRecordEB.REFUSE_CODE).equals("000")){
|
||||
// 반송 데이터 반영
|
||||
applyRefuseData( record );
|
||||
}
|
||||
}else if( sTemp.startsWith("H")){
|
||||
this.sBaseDate = sTemp.substring(1,9);
|
||||
logger.logInfo( ".... file create date : "+sBaseDate);
|
||||
}else if( sTemp.startsWith("T")){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 프로시져 Call
|
||||
logger.logInfo( ".. procedure call ");
|
||||
runProcedure();
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName+ " apply fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
nDeleteCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String sQuery = " INSERT INTO CARD_TRANS_DETAIL_INFO "
|
||||
+ " ( WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, WORK_TIMES, SEQNO, "
|
||||
+ " CARD_NO, JOIN_CARD_NUMBER, NOMAL_DATE, REJECT_KBN, REJECT_ID, LEVY_AMOUNT, "
|
||||
+ " CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ " SELECT rf.WORKER_ID, rf.FARE_OFFICE_ID, rf.BOOTH_ID, rf.YEAR, rf.MONTH, rf.DAY, rf.WORK_TIMES, rf.SEQNO, "
|
||||
+ " rf.CARD_NO, joint.typical_id, SYSDATE, "
|
||||
+ " DECODE(rf.COLLECT_ID,'21','1','22','2','23','1','24','2','0'), ?, rf.LEVY_AMOUNT, "
|
||||
+ " SYSDATE, ?, SYSDATE, ? "
|
||||
+ " FROM rf_terminal_info rf, "
|
||||
+ " join_card_info joint "
|
||||
+ " WHERE rf.FARE_OFFICE_ID = joint.FARE_OFFICE_ID "
|
||||
+ " AND rf.ISSUE_ID = joint.ISSUE_ID "
|
||||
+ " AND rf.WORKER_ID = ? "
|
||||
+ " AND rf.FARE_OFFICE_ID = ? "
|
||||
+ " AND rf.BOOTH_ID = ? "
|
||||
+ " AND rf.YEAR = ? "
|
||||
+ " AND rf.MONTH = ? "
|
||||
+ " AND rf.DAY = ? "
|
||||
+ " AND rf.WORK_TIMES = ? ";
|
||||
|
||||
pstmt = conn.prepareStatement(sQuery);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( "PrepayEB use info apply fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(pstmt != null) pstmt.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 이비카드 선불반송 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void applyRefuseData(PreCardDataRecordEB record) throws SQLException , Exception{
|
||||
try{
|
||||
String sTransactionID = record.getItem(PreCardDataRecordEB.TRANSACTION_ID);
|
||||
String sTradeTime = record.getItem(PreCardDataRecordEB.TRADE_TIME);
|
||||
// 반송코드 수정. 티머니는 2자리인데 이비카드는 3자리여서 티머니 반송코드로 치환하여 적용하기 위함임.
|
||||
String sRefusecode = record.getItem(PreCardDataRecordEB.REFUSE_CODE);
|
||||
|
||||
if(sRefusecode.equals("111")){
|
||||
sRefusecode = "06";
|
||||
}else if(sRefusecode.equals("203")){
|
||||
sRefusecode = "07";
|
||||
}else {
|
||||
sRefusecode = "99";
|
||||
}
|
||||
|
||||
int iParam = 1;
|
||||
//pstmt.setString(iParam++,record.getItem(PreCardDataRecordEB.REFUSE_CODE));
|
||||
pstmt.setString(iParam++,sRefusecode);
|
||||
pstmt.setString(iParam++,sCreater);
|
||||
pstmt.setString(iParam++,sCreater);
|
||||
pstmt.setString(iParam++,sTransactionID.substring( 0, 6));
|
||||
pstmt.setString(iParam++,sTransactionID.substring( 0, 2));
|
||||
pstmt.setString(iParam++,sTransactionID.substring( 6, 8));
|
||||
pstmt.setString(iParam++,sTradeTime.substring( 0, 4));
|
||||
pstmt.setString(iParam++,sTradeTime.substring( 4, 6));
|
||||
pstmt.setString(iParam++,sTradeTime.substring( 6, 8));
|
||||
pstmt.setString(iParam++,sTradeTime.substring( 8,14));
|
||||
|
||||
int nInsert = pstmt.executeUpdate();
|
||||
if( nInsert == 0 ) throw new SQLException("no rows updated");
|
||||
|
||||
nInsertCount++;
|
||||
if( nInsertCount%LOG_COUNT == 0 ) {
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getData() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 프로시져 수행(선불 반송 반영) - 이비카드...ㅠㅠ
|
||||
*/
|
||||
private void runProcedure() throws SQLException , Exception{
|
||||
String query = "{ call SP_CARD_BANSONG_SUNBUL_EB() }";
|
||||
CallableStatement cs = null;
|
||||
cs = conn.prepareCall(query);
|
||||
cs.execute();
|
||||
}
|
||||
}
|
||||
@ -1,167 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.RfCardDataRecord;
|
||||
|
||||
/**
|
||||
* 후불 반송 정보 적용<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyResultRF extends FileWorker
|
||||
{
|
||||
public static final int REC_LEN = 400; // 레코드 길이
|
||||
public static final int LOG_COUNT = 10000; // log count
|
||||
|
||||
private PreparedStatement pstmt = null;
|
||||
private String sCreater;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
String sPrcsName = "ApplyResultRF";
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
if(sPrcsName.length() <= 10 ) sCreater = sPrcsName;
|
||||
else sCreater = sPrcsName.substring(0, 10);
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null){
|
||||
nReadCount++;
|
||||
if( sTemp.startsWith("D")){
|
||||
// 데이터 반영
|
||||
applyRefuseData(new RfCardDataRecord(sTemp));
|
||||
}else if( sTemp.startsWith("H")){
|
||||
this.sBaseDate = sTemp.substring(1,9);
|
||||
logger.logInfo( ".... file create date : "+sBaseDate);
|
||||
}else if( sTemp.startsWith("T")){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 프로시져 Call
|
||||
logger.logInfo( ".. procedure call ");
|
||||
runProcedure();
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName+ " apply fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
nDeleteCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String sQuery = " INSERT INTO CARD_TRANS_DETAIL_INFO "
|
||||
+ " ( WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, WORK_TIMES, SEQNO, "
|
||||
+ " CARD_NO, JOIN_CARD_NUMBER, NOMAL_DATE, REJECT_KBN, REJECT_ID, LEVY_AMOUNT, "
|
||||
+ " CREATE_DATE, CREATER, UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ " SELECT rf.WORKER_ID, rf.FARE_OFFICE_ID, rf.BOOTH_ID, rf.YEAR, rf.MONTH, rf.DAY, rf.WORK_TIMES, rf.SEQNO, "
|
||||
+ " rf.CARD_NO, rf.card_office_id, SYSDATE, "
|
||||
+ " DECODE(rf.COLLECT_ID,'21','1','22','2','23','1','24','2','0'), ?, rf.LEVY_AMOUNT, "
|
||||
+ " SYSDATE, ?, SYSDATE, ? "
|
||||
+ " FROM rf_terminal_info rf "
|
||||
+ " WHERE rf.WORKER_ID = ? "
|
||||
+ " AND rf.FARE_OFFICE_ID = ? "
|
||||
+ " AND rf.BOOTH_ID = ? "
|
||||
+ " AND rf.YEAR = ? "
|
||||
+ " AND rf.MONTH = ? "
|
||||
+ " AND rf.DAY = ? "
|
||||
+ " AND rf.WORK_TIMES = ? ";
|
||||
|
||||
pstmt = conn.prepareStatement(sQuery);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( "RFID use info apply fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(pstmt != null) pstmt.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* RFID 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void applyRefuseData(RfCardDataRecord record) throws SQLException , Exception{
|
||||
try{
|
||||
String sTransactionID = record.getItem(RfCardDataRecord.TRANSACTION_ID);
|
||||
String sTradeTime = record.getItem(RfCardDataRecord.TRADE_TIME);
|
||||
|
||||
int iParam = 1;
|
||||
pstmt.setString(iParam++,record.getItem(RfCardDataRecord.REFUSE_CODE));
|
||||
pstmt.setString(iParam++,sCreater);
|
||||
pstmt.setString(iParam++,sCreater);
|
||||
pstmt.setString(iParam++,sTransactionID.substring( 0, 6));
|
||||
pstmt.setString(iParam++,sTransactionID.substring( 0, 2));
|
||||
pstmt.setString(iParam++,sTransactionID.substring( 6, 8));
|
||||
pstmt.setString(iParam++,sTradeTime.substring( 0, 4));
|
||||
pstmt.setString(iParam++,sTradeTime.substring( 4, 6));
|
||||
pstmt.setString(iParam++,sTradeTime.substring( 6, 8));
|
||||
pstmt.setString(iParam++,sTradeTime.substring( 8,14));
|
||||
|
||||
int nInsert = pstmt.executeUpdate();
|
||||
if( nInsert == 0 ) throw new SQLException("no rows updated");
|
||||
|
||||
nInsertCount++;
|
||||
if( nInsertCount%LOG_COUNT == 0 ) {
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getData() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 프로시져 수행(후불 반송 반영)
|
||||
*/
|
||||
private void runProcedure() throws SQLException , Exception{
|
||||
String query = "{ call SP_CARD_BANSONG_WHOBUL() }";
|
||||
CallableStatement cs = null;
|
||||
cs = conn.prepareCall(query);
|
||||
cs.execute();
|
||||
}
|
||||
}
|
||||
@ -1,131 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.RfidUseDataRecord;
|
||||
|
||||
/**
|
||||
* RFID 사용 정보 적용<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyRfidUse extends FileWorker
|
||||
{
|
||||
public static final int REC_LEN = 84; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private PreparedStatement pstmt = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
String sPrcsName = "ApplyRfidUse";
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null){
|
||||
nReadCount++;
|
||||
if( sTemp.startsWith("D")){
|
||||
// 데이터 반영
|
||||
insertRfidUseInfo(new RfidUseDataRecord(sTemp));
|
||||
}else if( sTemp.startsWith("H")){
|
||||
this.sBaseDate = sTemp.substring(1,9);
|
||||
logger.logInfo( ".... file create date : "+sBaseDate);
|
||||
}else if( sTemp.startsWith("T")){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
pstmt.executeBatch();
|
||||
pstmt.clearBatch();
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( "RFID use info apply fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
nDeleteCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String sQuery = " INSERT INTO RFID_NAMSAN_TEMP "
|
||||
+ " (WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, "
|
||||
+ " WORK_TIMES, SEQNO, RFID_KBN, RFID_TAG1, RFID_TAG2)"
|
||||
+ " VALUES(?,?,?,?,?,?,?,?,?,?,?) ";
|
||||
|
||||
pstmt = conn.prepareStatement(sQuery);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( "RFID use info apply fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(pstmt != null) pstmt.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* RFID 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void insertRfidUseInfo(RfidUseDataRecord record) throws SQLException , Exception{
|
||||
int iParam = 1;
|
||||
pstmt.setString(iParam++,record.getItem(RfidUseDataRecord.WORKER_ID));
|
||||
pstmt.setString(iParam++,record.getItem(RfidUseDataRecord.FARE_OFFICE_ID));
|
||||
pstmt.setString(iParam++,record.getItem(RfidUseDataRecord.BOOTH_ID));
|
||||
pstmt.setString(iParam++,record.getItem(RfidUseDataRecord.YEAR));
|
||||
pstmt.setString(iParam++,record.getItem(RfidUseDataRecord.MONTH));
|
||||
pstmt.setString(iParam++,record.getItem(RfidUseDataRecord.DAY));
|
||||
pstmt.setString(iParam++,record.getItem(RfidUseDataRecord.WORK_TIMES));
|
||||
pstmt.setInt (iParam++,Integer.parseInt(record.getItem(RfidUseDataRecord.SEQNO)));
|
||||
pstmt.setString(iParam++,record.getItem(RfidUseDataRecord.RFID_KBN));
|
||||
pstmt.setString(iParam++,record.getItem(RfidUseDataRecord.RFID_TAG1));
|
||||
pstmt.setString(iParam++,record.getItem(RfidUseDataRecord.RFID_TAG2));
|
||||
pstmt.addBatch();
|
||||
|
||||
nInsertCount++;
|
||||
if( nInsertCount%LOG_COUNT == 0 ) {
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
pstmt.executeBatch();
|
||||
pstmt.clearBatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,133 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.TaxesInfoDataRecord;
|
||||
|
||||
/**
|
||||
* 과오납시세입정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyTaxesInfo extends FileWorker
|
||||
{
|
||||
|
||||
private String sPrcsName = "ApplyTaxesInfo";
|
||||
public static final int REC_LEN = 150; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private ResultSet rs = null;
|
||||
private PreparedStatement psIns = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
if( sTemp.charAt(10) == 'D'){
|
||||
// 데이터 반영
|
||||
processRecord(new TaxesInfoDataRecord(sTemp));
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
|
||||
query = "INSERT INTO OVERFARE_TAXES_INFO( "
|
||||
+ " FARE_OFFICE_ID, ENTRY_YEAR, ENTRY_MONTH, ENTRY_DAY, ENTRY_SEQNO, "
|
||||
+ " CITY_TAXES_COUNT, CITY_TAXES_AMONT, OVERFACE_YEAR, OVERFACE_MONTH, "
|
||||
+ " USER_ID, USER_NAME, REMARKS, CREATE_DATE, CREATER, UPDATE_DATE, "
|
||||
+ " UPDATER "
|
||||
+ " ) "
|
||||
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns = conn.prepareStatement(query);
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psIns != null) psIns.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(TaxesInfoDataRecord record) throws SQLException , Exception {
|
||||
int iParam = 1;
|
||||
try{
|
||||
psIns.setString(iParam++, record.getItem( TaxesInfoDataRecord.FARE_OFFICE_ID ).trim()); // '요금소 코드'
|
||||
psIns.setString(iParam++, record.getItem( TaxesInfoDataRecord.ENTRY_YEAR ).trim()); // '발생년도'
|
||||
psIns.setString(iParam++, record.getItem( TaxesInfoDataRecord.ENTRY_MONTH ).trim()); // '발생월'
|
||||
psIns.setString(iParam++, record.getItem( TaxesInfoDataRecord.ENTRY_DAY ).trim()); // '발생일'
|
||||
psIns.setString(iParam++, record.getItem( TaxesInfoDataRecord.ENTRY_SEQNO ).trim()); // '일련번호'
|
||||
psIns.setString(iParam++, record.getItem( TaxesInfoDataRecord.CITY_TAXES_COUNT ).trim()); // '시세입 건수'
|
||||
psIns.setString(iParam++, record.getItem( TaxesInfoDataRecord.CITY_TAXES_AMOUNT ).trim()); // '시세입 금액'
|
||||
psIns.setString(iParam++, record.getItem( TaxesInfoDataRecord.OVERFARE_YEAR ).trim()); // '과오납 적용년도'
|
||||
psIns.setString(iParam++, record.getItem( TaxesInfoDataRecord.OVERFARE_MONTH ).trim()); // '과오납 적용월'
|
||||
psIns.setString(iParam++, record.getItem( TaxesInfoDataRecord.USER_ID ).trim()); // '근무자 ID'
|
||||
psIns.setString(iParam++, record.getItem( TaxesInfoDataRecord.USER_NAME ).trim()); // '근무자명'
|
||||
psIns.setString(iParam++, record.getItem( TaxesInfoDataRecord.REMARKS ).trim()); // '비고'
|
||||
psIns.executeUpdate();
|
||||
nInsertCount++;
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,180 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
|
||||
import center.data.format.WrongPayCarDataRecord;
|
||||
|
||||
/**
|
||||
* 과오납차적정보<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class ApplyWrongPayCar extends FileWorker
|
||||
{
|
||||
|
||||
private String sPrcsName = "ApplyWrongPayCar";
|
||||
public static final int REC_LEN = 270; // 레코드 길이
|
||||
public static final int LOG_COUNT = 50000; // log count
|
||||
|
||||
private ResultSet rs = null;
|
||||
private PreparedStatement psSls = null;
|
||||
private PreparedStatement psIns = null;
|
||||
private PreparedStatement psUpd1 = null;
|
||||
private PreparedStatement psUpd2 = null;
|
||||
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
logger.logInfo( ".... file name : " + file.getName() );
|
||||
|
||||
initialize(); // 초기화
|
||||
|
||||
String sTemp = null;
|
||||
while((sTemp = inFile.readBytes(REC_LEN)) != null && sTemp.length() > 2){
|
||||
nReadCount++;
|
||||
if( sTemp.charAt(10) == 'D'){
|
||||
// 데이터 반영
|
||||
processRecord(new WrongPayCarDataRecord(sTemp));
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
|
||||
logger.logInfo(".... File Read Count : "+ nReadCount );
|
||||
logger.logInfo(".... DB Insert Count : "+ nInsertCount);
|
||||
logger.logInfo(".... DB Update Count : "+ nUpdateCount);
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
try{ conn.rollback();}catch(Exception e){}
|
||||
logger.logFail( sPrcsName + " fail");
|
||||
logger.logTrace(ex);
|
||||
throw ex;
|
||||
}finally{
|
||||
finalize();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 초기화
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void initialize() throws SQLException{
|
||||
try
|
||||
{
|
||||
nReadCount = 0;
|
||||
nInsertCount = 0;
|
||||
nUpdateCount = 0;
|
||||
|
||||
inFile = new FileStreamParser();
|
||||
inFile.openReadFile(file);
|
||||
|
||||
String query;
|
||||
|
||||
query = "SELECT COUNT(*) "
|
||||
+ " FROM OVERFARE_ORDER_INFO "
|
||||
+ " WHERE CAR_NO = ? "
|
||||
+ " AND RESIDENT_NO = ? ";
|
||||
|
||||
psSls = conn.prepareStatement(query);
|
||||
|
||||
query = " INSERT INTO OVERFARE_ORDER_INFO( "
|
||||
+ " OWNER, CAR_NO, RESIDENT_DATE, CAR_TYPE_NAME, RESIDENT_NO, POST_NO1, "
|
||||
+ " POST_NO2, ADDRESS_NAME, ADDRESS_NUMBER, CREATE_DATE, CREATER, "
|
||||
+ " UPDATE_DATE, UPDATER "
|
||||
+ " ) "
|
||||
+ " VALUES (?,?,TO_DATE(?,'yyyymmdd'),?,?,?,?,?,?,SYSDATE,'COMM',SYSDATE,'COMM') ";
|
||||
|
||||
psIns = conn.prepareStatement(query);
|
||||
|
||||
query = "UPDATE OVERFARE_ORDER_INFO "
|
||||
+ " SET CAR_TYPE_NAME = ? "
|
||||
+ " , POST_NO1 = ? "
|
||||
+ " , POST_NO2 = ? "
|
||||
+ " , ADDRESS_NAME = ? "
|
||||
+ " , ADDRESS_NUMBER = ? "
|
||||
+ " , UPDATE_DATE = SYSDATE "
|
||||
+ " , UPDATER = 'COMM' "
|
||||
+ " WHERE CAR_NO = ? "
|
||||
+ " AND RESIDENT_NO = ? ";
|
||||
|
||||
psUpd1 = conn.prepareStatement(query);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
logger.logFail( sPrcsName + " initialize fail");
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finalize
|
||||
*/
|
||||
@Override
|
||||
public void finalize() {
|
||||
try{ if(psSls != null) psSls.close(); }catch(Exception ignore){}
|
||||
try{ if(psIns != null) psIns.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd1 != null) psUpd1.close(); }catch(Exception ignore){}
|
||||
try{ if(psUpd2 != null) psUpd2.close(); }catch(Exception ignore){}
|
||||
try{ if(inFile != null) inFile.closeFile(); }catch(Exception ignore){}
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param Id
|
||||
* @throws SQLException
|
||||
*/
|
||||
private void processRecord(WrongPayCarDataRecord record) throws SQLException , Exception {
|
||||
int iParam = 1;
|
||||
|
||||
try{
|
||||
psSls.setString(iParam++, record.getItem( WrongPayCarDataRecord.CAR_NO ).trim()); // '차량번호'
|
||||
psSls.setString(iParam++, record.getItem( WrongPayCarDataRecord.RESIDENT_NO ).trim()); // '주민/법인번호'
|
||||
rs = psSls.executeQuery();
|
||||
rs.next();
|
||||
if (rs.getInt(1) == 0) {
|
||||
iParam = 1;
|
||||
psIns.setString(iParam++, record.getItem( WrongPayCarDataRecord.OWNER ).trim()); // '소유주'
|
||||
psIns.setString(iParam++, record.getItem( WrongPayCarDataRecord.CAR_NO ).trim()); // '차량번호'
|
||||
psIns.setString(iParam++, record.getItem( WrongPayCarDataRecord.RESIDENT_DATE ).trim()); // '차량등록일자'
|
||||
psIns.setString(iParam++, record.getItem( WrongPayCarDataRecord.CAR_TYPE_NAME ).trim()); // '차종명'
|
||||
psIns.setString(iParam++, record.getItem( WrongPayCarDataRecord.RESIDENT_NO ).trim()); // '주민/법인번호'
|
||||
psIns.setString(iParam++, record.getItem( WrongPayCarDataRecord.POST_NO1 ).trim()); // '우편번호1'
|
||||
psIns.setString(iParam++, record.getItem( WrongPayCarDataRecord.POST_NO2 ).trim()); // '우편번호2'
|
||||
psIns.setString(iParam++, record.getItem( WrongPayCarDataRecord.ADDRESS_NAME ).trim()); // '현주소'
|
||||
psIns.setString(iParam++, record.getItem( WrongPayCarDataRecord.ADDRESS_NUMBER ).trim()); // '현주소 번지'
|
||||
psIns.executeUpdate();
|
||||
|
||||
nInsertCount++;
|
||||
} else if (rs.getInt(1) > 0) {
|
||||
iParam = 1;
|
||||
psUpd1.setString(iParam++, record.getItem( WrongPayCarDataRecord.CAR_TYPE_NAME ).trim()); // '차종명'
|
||||
psUpd1.setString(iParam++, record.getItem( WrongPayCarDataRecord.POST_NO1 ).trim()); // '우편번호1'
|
||||
psUpd1.setString(iParam++, record.getItem( WrongPayCarDataRecord.POST_NO1 ).trim()); // '우편번호2'
|
||||
psUpd1.setString(iParam++, record.getItem( WrongPayCarDataRecord.POST_NO2 ).trim()); // '현주소'
|
||||
psUpd1.setString(iParam++, record.getItem( WrongPayCarDataRecord.ADDRESS_NAME ).trim()); // '현주소 번지'
|
||||
psUpd1.setString(iParam++, record.getItem( WrongPayCarDataRecord.CAR_NO ).trim()); // '차량번호'
|
||||
psUpd1.setString(iParam++, record.getItem( WrongPayCarDataRecord.RESIDENT_NO ).trim()); // '주민/법인번호'
|
||||
psUpd1.executeUpdate();
|
||||
|
||||
nUpdateCount++;
|
||||
}
|
||||
}catch(SQLException sqle){
|
||||
logger.logFail( "[" + record.getRecord() +"]" );
|
||||
logger.logTrace(sqle);
|
||||
throw sqle;
|
||||
}finally{
|
||||
try{ if(rs != null) rs.close(); }catch(Exception ignore){}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,155 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
import com.exception.AppException;
|
||||
import com.exception.IllegalRecordException;
|
||||
import com.resources.data.Info;
|
||||
|
||||
import center.dao.VanTransDAO;
|
||||
/**
|
||||
* 면제차량정보 파일 생성<BR>
|
||||
* @author jhban
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2015-05-13 초기 작성
|
||||
*/
|
||||
public class MakeExemptCar extends FileWorker {
|
||||
|
||||
public static final int LOG_COUNT = 10000; // log count
|
||||
|
||||
public MakeExemptCar(){
|
||||
}
|
||||
/**
|
||||
* 면제차량정보 생성 실행
|
||||
*/
|
||||
@Override
|
||||
public void execute(){
|
||||
String sFileName = null;
|
||||
String sPrcsName = "MakeExemptCar";
|
||||
VanTransDAO commDAO; // 파일 전송 이력 클래스 변수
|
||||
|
||||
try{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
|
||||
String sPrcsOption = System.getProperty("option");
|
||||
if (sPrcsOption == null || sPrcsOption.equals("")) {
|
||||
sBaseDate = TODAY;
|
||||
}else{
|
||||
sBaseDate = sPrcsOption;
|
||||
}
|
||||
|
||||
sFileName = "FC_" + sBaseDate.substring(2) +".txt";
|
||||
logger.logInfo( ".... file name : " + sFileName );
|
||||
|
||||
conn = getConnection();
|
||||
conn.setAutoCommit(false);
|
||||
|
||||
//commonDAO = new TunnelTransDAO(conn);
|
||||
|
||||
outFile = new FileStreamParser();
|
||||
outFile.openWriteFile(new File(freeDir, sFileName));
|
||||
/**
|
||||
* auth : redkaras
|
||||
* history : 2016.04.22 파일생성이 후 집계서버 배포를 위한 처리 추가
|
||||
* **/
|
||||
if( writeDataRecord() ){
|
||||
commDAO = new VanTransDAO(conn);
|
||||
String sCreater;
|
||||
if(sPrcsName.length() <= 10 )
|
||||
sCreater = sPrcsName;
|
||||
else sCreater = sPrcsName.substring(0, 10);
|
||||
|
||||
Info transInfo = null;
|
||||
transInfo = new Info();
|
||||
transInfo.setString("FILE_KIND_ID" , "1G" );
|
||||
transInfo.setString("FORMAT_DATE" , TODAY );
|
||||
transInfo.setString("FARE_OFFICE_ID" , "TM");
|
||||
transInfo.setString("FILE_TRANS_KBN" , "R" );
|
||||
transInfo.setString("FILE_TRANS_YN" , "Y" );
|
||||
transInfo.setString("DATA_PROCESS_KBN", "9" );
|
||||
transInfo.setString("DIR_NAME" , freeDir );
|
||||
transInfo.setString("FILE_NAME" , sFileName.trim() );
|
||||
transInfo.setString("CREATER" , sCreater);
|
||||
|
||||
//파일코드를 통한 순번 획득
|
||||
long nSeqNo = commDAO.getNextSeq("1G");
|
||||
transInfo.setLong ("DATA_SEQNO" , nSeqNo );
|
||||
//전송처리해야할 파일에 대한 정보저장
|
||||
commDAO.insertFileTransInfo( transInfo );
|
||||
//1호 요금소 전송을 위한 정보등록
|
||||
transInfo.setString("FARE_OFFICE_ID" , "01");
|
||||
commDAO.insertOfficeTransInfo( transInfo );
|
||||
//3호 요금소 전송을 위한 정보등록
|
||||
transInfo.setString("FARE_OFFICE_ID" , "03");
|
||||
commDAO.insertOfficeTransInfo( transInfo );
|
||||
conn.commit();
|
||||
}
|
||||
logger.logInfo("----------------------------------" );
|
||||
logger.logInfo(".... DB Select Count : "+ nSelectCount);
|
||||
logger.logInfo(".... File Write Count : "+ nWriteCount );
|
||||
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}catch(Exception e){
|
||||
try{ if(conn != null){ conn.rollback(); }}catch(Exception ignore){}
|
||||
logger.logFail(sPrcsName + " 프로세스 실패");
|
||||
logger.logTrace(e);
|
||||
}finally{
|
||||
try{ if(outFile != null){ outFile.closeFile(); }}catch(Exception ignore){}
|
||||
try{ if(conn != null){ conn.close(); }}catch(Exception ignore){}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Data Format 작성
|
||||
* @return
|
||||
* @throws SQLException
|
||||
* @throws IllegalRecordException
|
||||
* @throws AppException
|
||||
*/
|
||||
private boolean writeDataRecord() throws SQLException, IllegalRecordException, AppException {
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try{
|
||||
/**
|
||||
* auth : redkaras
|
||||
* history : 2016.09.05 파일생성시 면제차량구분(1:장애인)을 제외한 데이터만 생성하기 위하여 "EXEMPT_KBN <> '1'" 조건 추가
|
||||
* **/
|
||||
StringBuffer sbQuery = new StringBuffer();
|
||||
sbQuery.append(" SELECT DISTINCT CAR_NO, ")
|
||||
.append(" EXEMPT_KBN ")
|
||||
.append(" FROM EXEMPT_CARS_INFO ")
|
||||
.append(" WHERE TO_CHAR(ENFORCE_DATE, 'YYYYMMDD') <= TO_CHAR(sysdate, 'YYYYMMDD') ")
|
||||
.append(" AND TO_CHAR(END_DATE, 'YYYYMMDD') >= TO_CHAR(sysdate, 'YYYYMMDD') ")
|
||||
.append(" AND EXEMPT_KBN <> '1' ");
|
||||
|
||||
stmt = conn.prepareStatement(sbQuery.toString());
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
while(rs.next()){
|
||||
nSelectCount++;
|
||||
|
||||
String str = rs.getString("CAR_NO");
|
||||
String kbn = rs.getString("EXEMPT_KBN");
|
||||
|
||||
outFile.writeData(str.trim() + "," + kbn.trim());
|
||||
outFile.writeData("\n");
|
||||
|
||||
nWriteCount++;
|
||||
if( nWriteCount%LOG_COUNT == 0 ) {
|
||||
logger.logInfo(".... File Write Count : "+ nWriteCount);
|
||||
}
|
||||
}
|
||||
logger.logInfo(".... File Write Count : "+ nWriteCount);
|
||||
|
||||
}finally{
|
||||
if(stmt != null){ try{ stmt.close(); }catch(Exception ignore){} }
|
||||
if(rs != null){ try{ rs.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,155 +0,0 @@
|
||||
package center.data;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
import com.exception.AppException;
|
||||
import com.exception.IllegalRecordException;
|
||||
import com.util.StringUtil;
|
||||
|
||||
/**
|
||||
* RFID사용정보 시청제공 자료 생성<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class MakeRfidUse extends FileWorker {
|
||||
public static final String FILE_KIND_CODE = "53"; // RFID 사용정보
|
||||
public static final int LOG_COUNT = 10000; // log count
|
||||
public static final String DATA_SEP = "|"; // 데이터 구분자
|
||||
|
||||
private String sCreater;
|
||||
|
||||
public MakeRfidUse(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
String sFileName = null;
|
||||
String sPrcsName = "MakeRfidUse";
|
||||
|
||||
try{
|
||||
logger.logInfo(sPrcsName + " is started");
|
||||
|
||||
String sPrcsOption = System.getProperty("option");
|
||||
if (sPrcsOption == null || sPrcsOption.equals("")) {
|
||||
sBaseDate = TODAY;
|
||||
}else{
|
||||
sBaseDate = sPrcsOption;
|
||||
}
|
||||
|
||||
sFileName = "RfidUse_"+sBaseDate.substring(2)+".dat";
|
||||
|
||||
String sFtpDownDir = config.getProperty("rfid.down");
|
||||
|
||||
logger.logInfo( ".... file name : " + sFileName );
|
||||
|
||||
conn = getConnection();
|
||||
conn.setAutoCommit(false);
|
||||
|
||||
outFile = new FileStreamParser();
|
||||
outFile.openWriteFile(new File(fileDir, sFileName));
|
||||
|
||||
writeHeaderRecord();
|
||||
writeDataRecord();
|
||||
writeTrailerRecord();
|
||||
|
||||
if(sPrcsName.length() <= 10 ) sCreater = sPrcsName;
|
||||
else sCreater = sPrcsName.substring(0, 10);
|
||||
|
||||
copy(fileDir + sFileName, sFtpDownDir + "RFID_NAMSAN_"+sBaseDate );
|
||||
conn.commit();
|
||||
|
||||
logger.logInfo("----------------------------------" );
|
||||
logger.logInfo(".... DB Select Count : "+ nSelectCount);
|
||||
logger.logInfo(".... File Write Count : "+ nWriteCount );
|
||||
|
||||
logger.logInfo(sPrcsName + " is ended");
|
||||
}catch(Exception e){
|
||||
try{ if(conn != null){ conn.rollback(); }}catch(Exception ignore){}
|
||||
logger.logFail(sPrcsName + " process is failed");
|
||||
logger.logTrace(e);
|
||||
}finally{
|
||||
try{ if(outFile != null){ outFile.closeFile(); }}catch(Exception ignore){}
|
||||
try{ if(conn != null){ conn.close(); }}catch(Exception ignore){}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Header data write
|
||||
* @return boolean
|
||||
* @throws IllegalRecordException
|
||||
* @throws AppException
|
||||
*/
|
||||
public boolean writeHeaderRecord() throws IllegalRecordException, AppException{
|
||||
outFile.writeData("X"
|
||||
+sBaseDate+StringUtil.getString(' ',91));
|
||||
outFile.writeData("\n");
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Data Format 작성
|
||||
* @param purchaseDay
|
||||
* @return
|
||||
* @throws SQLException
|
||||
* @throws IllegalRecordException
|
||||
* @throws AppException
|
||||
*/
|
||||
private boolean writeDataRecord() throws SQLException, IllegalRecordException, AppException {
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try{
|
||||
StringBuffer sbQuery = new StringBuffer();
|
||||
sbQuery.append(" select CAR_NO1, ")
|
||||
.append(" YEAR||MONTH||DAY||WORK_TIMES USEDATE, ")
|
||||
.append(" FARE_OFFICE_ID, ")
|
||||
.append(" BOOTH_ID, ")
|
||||
.append(" RFID_KBN, ")
|
||||
.append(" RFID_TAG, ")
|
||||
.append(" CAR_NO2, ")
|
||||
.append(" COLLECT_ID ") // 070105 KJC 추가 - 통행구분추가요청(시청)
|
||||
.append(" FROM RFID_NAMSAN_INFO ")
|
||||
.append(" WHERE YEAR || MONTH || DAY = TO_CHAR(TO_DATE(?,'yyyymmdd')-1,'YYYYMMDD') ");
|
||||
|
||||
pstmt = conn.prepareStatement(sbQuery.toString());
|
||||
pstmt.setString(1, sBaseDate);
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
while(rs.next()){
|
||||
outFile.writeData("Y" + DATA_SEP
|
||||
+ rs.getString("CAR_NO1") + DATA_SEP
|
||||
+ rs.getString("USEDATE") + DATA_SEP
|
||||
+ rs.getString("FARE_OFFICE_ID") + DATA_SEP
|
||||
+ rs.getString("BOOTH_ID") + DATA_SEP
|
||||
+ rs.getString("RFID_KBN") + DATA_SEP
|
||||
+ rs.getString("RFID_TAG") + DATA_SEP
|
||||
+ rs.getString("CAR_NO2") + DATA_SEP
|
||||
+ rs.getString("COLLECT_ID") ); // 070105 KJC 추가 - 통행구분추가요청(시청)
|
||||
outFile.writeData("\n");
|
||||
nWriteCount++;
|
||||
if( nWriteCount%10000 == 0 ) logger.logInfo(".... File Write Count : "+ nWriteCount);
|
||||
}
|
||||
}finally{
|
||||
if(rs != null){ try{ rs.close(); }catch(Exception ignore){} }
|
||||
if(pstmt != null){ try{ pstmt.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Trailer data write
|
||||
* @return boolean
|
||||
* @throws IllegalRecordException
|
||||
* @throws AppException
|
||||
*/
|
||||
public boolean writeTrailerRecord() throws IllegalRecordException, AppException{
|
||||
outFile.writeData("Z"
|
||||
+ sBaseDate
|
||||
+ StringUtil.justify(StringUtil.RIGHT,""+nWriteCount,"0",8)
|
||||
+ StringUtil.getString(' ',83));
|
||||
outFile.writeData("\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 차로구분 정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class BoothInfoDataRecord extends Record {
|
||||
private int RECORD_LEN = 150; // 레코드 길이
|
||||
public static final int S_MARK = 0; // 시작표시
|
||||
public static final int DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int DATA_TYPE = 2; // 자료구분
|
||||
public static final int DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int SERIAL_NO = 4; // 일련번호
|
||||
public static final int FARE_OFFICE_ID = 5; // 요금소코드
|
||||
public static final int BOOTH_ID = 6; // 차로구분코드
|
||||
public static final int BOOTH_FULL_NAME = 7; // 차로 명
|
||||
public static final int BOOTH_ABB_NAME = 8; // 차로 약명
|
||||
public static final int IN_OUT_KBN = 9; // 유출입 구분
|
||||
public static final int USE_YN = 10; // 사용여부
|
||||
public static final int IUD_KBN = 11; // 입력구분
|
||||
public static final int RESERVED = 12; // Filler
|
||||
public static final int E_MARK = 13; // 종료표시
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public BoothInfoDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case SERIAL_NO : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case FARE_OFFICE_ID : return getStringInLine(record, 20, 22); // 요금소코드
|
||||
case BOOTH_ID : return getStringInLine(record, 22, 24); // 차로구분코드
|
||||
case BOOTH_FULL_NAME : return getStringInLine(record, 24, 84); // 차로 명
|
||||
case BOOTH_ABB_NAME : return getStringInLine(record, 84, 124); // 차로 약명
|
||||
case IN_OUT_KBN : return getStringInLine(record, 124, 125); // 유출입 구분
|
||||
case USE_YN : return getStringInLine(record, 125, 126); // 사용여부
|
||||
case IUD_KBN : return getStringInLine(record, 126, 127); // 입력구분
|
||||
case RESERVED : return getStringInLine(record, 127, 149); // Filler
|
||||
case E_MARK : return getStringInLine(record, 149, 150); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 가맹점 정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class CardJoinDataRecord extends Record {
|
||||
private int RECORD_LEN = 150; // 레코드 길이
|
||||
public static final int S_MARK = 0; // 시작표시
|
||||
public static final int DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int DATA_TYPE = 2; // 자료구분
|
||||
public static final int DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int SEQNO = 4; // 일련번호
|
||||
public static final int FARE_OFFICE_ID = 5; // 요금소코드
|
||||
public static final int JOIN_CHAIN_NO = 6; // 가맹점번호
|
||||
public static final int STT_DATE = 7; // 시작일자
|
||||
public static final int END_DATE = 8; // 종료일자
|
||||
public static final int COLLECT_ID = 9; // 징수유형코드
|
||||
public static final int ISSUER_ID = 10; // 카드발행사코드
|
||||
public static final int JOIN_CHAIN_NAME = 11; // 가맹점명
|
||||
public static final int CARD_RATE = 12; // 수수료율
|
||||
public static final int REATE_AMOUNT = 13; // 수수료금액
|
||||
public static final int USE_KBN = 14; // 사용여부
|
||||
public static final int RESERVED = 15; // Filler
|
||||
public static final int E_MARK = 16; // 종료표시
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public CardJoinDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case SEQNO : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case FARE_OFFICE_ID : return getStringInLine(record, 20, 22); // 요금소코드
|
||||
case JOIN_CHAIN_NO : return getStringInLine(record, 22, 42); // 가맹점번호
|
||||
case STT_DATE : return getStringInLine(record, 42, 50); // 시작일자
|
||||
case END_DATE : return getStringInLine(record, 50, 58); // 종료일자
|
||||
case COLLECT_ID : return getStringInLine(record, 58, 60); // 징수유형코드
|
||||
case ISSUER_ID : return getStringInLine(record, 60, 67); // 카드발행사코드
|
||||
case JOIN_CHAIN_NAME : return getStringInLine(record, 67,127); // 가맹점명
|
||||
case CARD_RATE : return getStringInLine(record,127,132); // 수수료율
|
||||
case REATE_AMOUNT : return getStringInLine(record,132,137); // 수수료금액
|
||||
case USE_KBN : return getStringInLine(record,137,138); // 사용여부
|
||||
case RESERVED : return getStringInLine(record,138,149); // Filler
|
||||
case E_MARK : return getStringInLine(record,149,150); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,149 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 징수원 정산정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class CollectSettleDataRecord extends Record {
|
||||
private int RECORD_LEN = 330; // 레코드 길이
|
||||
public static final int S_MARK = 0; // 시작표시
|
||||
public static final int DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int DATA_TYPE = 2; // 자료구분
|
||||
public static final int DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int SEQNO = 4; // 일련번호
|
||||
public static final int WORKER_ID = 5; // 징수원ID
|
||||
public static final int FARE_OFFICE_ID = 6; // 요금소코드
|
||||
public static final int BOOTH_ID = 7; // 차로코드
|
||||
public static final int YEAR = 8; // 년도
|
||||
public static final int MONTH = 9; // 월
|
||||
public static final int DAY = 10; // 일
|
||||
public static final int WORK_STT_TIME = 11; // 근무시작시간
|
||||
public static final int WORK_END_TIME = 12; // 근무종료시간
|
||||
public static final int EXEMPTION_QUANTITY = 13; // 면제 통행량
|
||||
public static final int CASH_QUANTITY = 14; // 현금 통행량
|
||||
public static final int COUPON_QUANTITY = 15; // 쿠폰회수 통행량
|
||||
public static final int NONPAYMENT_QUANTITY = 16; // 미납 통행량
|
||||
public static final int CARD_BEFORE_QUANTITY = 17; // 선불카드 통행량
|
||||
public static final int CARD_AFTER_QUANTITY = 18; // 후불카드 통행량
|
||||
public static final int COUPON_SALE_QUANTITY = 19; // 정액권 판매 권수
|
||||
public static final int TOTAL_INCOME = 20; // 총 수입금액
|
||||
public static final int CASH_INCOME = 21; // 현금 수입금액
|
||||
public static final int CARD_BEFORE_INCOME = 22; // 선불카드 수입금액
|
||||
public static final int CARD_AFTER_INCOME = 23; // 후불카드 수입금액
|
||||
public static final int COUPON_INCOME = 24; // 쿠폰 수입금액
|
||||
public static final int COUPON_SALE = 25; // 쿠폰 판매금액
|
||||
public static final int DEPOSIT_PAY = 26; // 입금액
|
||||
public static final int CREDIT_PAY = 27; // 출금액
|
||||
public static final int OVERFARE_IN_AMOUNT = 28; // 과오납 입금액
|
||||
public static final int OVERFARE_OUT_AMOUNT = 29; // 과오납 출금액
|
||||
public static final int OVERCOUPON_COUNT = 30; // 과잉쿠폰 매수
|
||||
public static final int COUPON_RETURN_COUNT = 31; // 쿠폰반환 매수
|
||||
public static final int NOTE_QUANTITY = 32; // 수기 통행량
|
||||
public static final int NOTE_INCOME = 33; // 수기 통행금액
|
||||
public static final int FARE_ADJUST_YN = 34; // 정산완료여부
|
||||
public static final int CASH_Q = 35; // 경차현금 통행량
|
||||
public static final int COUPON_Q = 36; // 경차쿠폰 통행량
|
||||
public static final int CARD_SUN_Q = 37; // 경차선불카드 통행량
|
||||
public static final int CARD_WHO_Q = 38; // 경차후불카드 통행량
|
||||
public static final int COUPON_SALE_Q = 39; // 경차정액권 판매권수
|
||||
public static final int K_CASH_INCOME = 40; // 경차현금 수입금액
|
||||
public static final int CARD_SUN_INCOME = 41; // 경차선불카드 수입금액
|
||||
public static final int CARD_WHO_INCOME = 42; // 경차후불카드 수입금액
|
||||
public static final int COUPON_SALE_INCOME = 43; // 경차정액권 판매금액
|
||||
public static final int OVERCOUPON_CNT = 44; // 경차과잉쿠폰 매수
|
||||
public static final int COUPON_RET_CNT = 45; // 경차과잉쿠폰 반납매수
|
||||
public static final int NOTE_Q = 46; // 경차 수기 통행량
|
||||
public static final int K_NOTE_INCOME = 47; // 경차 수기 수입금액
|
||||
public static final int REPAY_CNT = 48; // 환불건수
|
||||
public static final int REPAY_AMOUNT = 49; // 환불금액
|
||||
public static final int C_AMPM = 50; // 오전/오후구분
|
||||
public static final int OTHER_SEQNO = 51; // 중복방지번호
|
||||
public static final int SALE_CARD_Q = 52; // 일반정액권카드판매권수
|
||||
public static final int SALE_CARD_M = 53; // 일반정액권카드판매금액
|
||||
public static final int K_SALE_CARD_Q = 54; // 경차정액권카드판매권수
|
||||
public static final int K_SALE_CARD_M = 55; // 경차정액권카드판매금액
|
||||
public static final int RESERVED = 56; // Filler
|
||||
public static final int E_MARK = 57; // 종료표시
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public CollectSettleDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case SEQNO : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case WORKER_ID : return getStringInLine(record, 24, 26) + getStringInLine(record, 20, 24);
|
||||
// 징수원ID
|
||||
case FARE_OFFICE_ID : return getStringInLine(record, 24, 26); // 요금소코드
|
||||
case BOOTH_ID : return getStringInLine(record, 26, 28); // 차로코드
|
||||
case YEAR : return getStringInLine(record, 28, 32); // 년도
|
||||
case MONTH : return getStringInLine(record, 32, 34); // 월
|
||||
case DAY : return getStringInLine(record, 34, 36); // 일
|
||||
case WORK_STT_TIME : return getStringInLine(record, 36, 42); // 근무시작시간
|
||||
case WORK_END_TIME : return getStringInLine(record, 42, 48); // 근무종료시간
|
||||
case EXEMPTION_QUANTITY : return getStringInLine(record, 48, 53); // 면제 통행량
|
||||
case CASH_QUANTITY : return getStringInLine(record, 53, 58); // 현금 통행량
|
||||
case COUPON_QUANTITY : return getStringInLine(record, 58, 63); // 쿠폰회수 통행량
|
||||
case NONPAYMENT_QUANTITY : return getStringInLine(record, 63, 68); // 미납 통행량
|
||||
case CARD_BEFORE_QUANTITY : return getStringInLine(record, 68, 73); // 선불카드 통행량
|
||||
case CARD_AFTER_QUANTITY : return getStringInLine(record, 73, 78); // 후불카드 통행량
|
||||
case COUPON_SALE_QUANTITY : return getStringInLine(record, 78, 83); // 정액권 판매 권수
|
||||
case TOTAL_INCOME : return getStringInLine(record, 83, 92); // 총 수입금액
|
||||
case CASH_INCOME : return getStringInLine(record, 92, 101); // 현금 수입금액
|
||||
case CARD_BEFORE_INCOME : return getStringInLine(record, 101, 110); // 선불카드 수입금액
|
||||
case CARD_AFTER_INCOME : return getStringInLine(record, 110, 119); // 후불카드 수입금액
|
||||
case COUPON_INCOME : return getStringInLine(record, 119, 128); // 쿠폰 수입금액
|
||||
case COUPON_SALE : return getStringInLine(record, 128, 137); // 쿠폰 판매금액
|
||||
case DEPOSIT_PAY : return getStringInLine(record, 137, 146); // 입금액
|
||||
case CREDIT_PAY : return getStringInLine(record, 146, 155); // 출금액
|
||||
case OVERFARE_IN_AMOUNT : return getStringInLine(record, 155, 164); // 과오납 입금액
|
||||
case OVERFARE_OUT_AMOUNT : return getStringInLine(record, 164, 173); // 과오납 출금액
|
||||
case OVERCOUPON_COUNT : return getStringInLine(record, 173, 178); // 과잉쿠폰 매수
|
||||
case COUPON_RETURN_COUNT : return getStringInLine(record, 178, 183); // 쿠폰반환 매수
|
||||
case NOTE_QUANTITY : return getStringInLine(record, 183, 188); // 수기 통행량
|
||||
case NOTE_INCOME : return getStringInLine(record, 188, 197); // 수기 통행금액
|
||||
case FARE_ADJUST_YN : return getStringInLine(record, 197, 198); // 정산완료여부
|
||||
case CASH_Q : return getStringInLine(record, 198, 203); // 경차현금 통행량
|
||||
case COUPON_Q : return getStringInLine(record, 203, 208); // 경차쿠폰 통행량
|
||||
case CARD_SUN_Q : return getStringInLine(record, 208, 213); // 경차선불카드 통행량
|
||||
case CARD_WHO_Q : return getStringInLine(record, 213, 218); // 경차후불카드 통행량
|
||||
case COUPON_SALE_Q : return getStringInLine(record, 218, 223); // 경차정액권 판매권수
|
||||
case K_CASH_INCOME : return getStringInLine(record, 223, 232); // 경차현금 수입금액
|
||||
case CARD_SUN_INCOME : return getStringInLine(record, 232, 241); // 경차선불카드 수입금액
|
||||
case CARD_WHO_INCOME : return getStringInLine(record, 241, 250); // 경차후불카드 수입금액
|
||||
case COUPON_SALE_INCOME : return getStringInLine(record, 250, 259); // 경차정액권 판매금액
|
||||
case OVERCOUPON_CNT : return getStringInLine(record, 259, 264); // 경차과잉쿠폰 매수
|
||||
case COUPON_RET_CNT : return getStringInLine(record, 264, 269); // 경차과잉쿠폰 반납매수
|
||||
case NOTE_Q : return getStringInLine(record, 269, 274); // 경차 수기 통행량
|
||||
case K_NOTE_INCOME : return getStringInLine(record, 274, 283); // 경차 수기 수입금액
|
||||
case REPAY_CNT : return getStringInLine(record, 283, 288); // 환불건수
|
||||
case REPAY_AMOUNT : return getStringInLine(record, 288, 297); // 환불금액
|
||||
case C_AMPM : return getStringInLine(record, 297, 298); // 오전/오후구분
|
||||
case OTHER_SEQNO : return getStringInLine(record, 298, 299); // 중복방지번호
|
||||
case SALE_CARD_Q : return getStringInLine(record, 299, 302); // 일반정액권카드판매권수
|
||||
case SALE_CARD_M : return getStringInLine(record, 302, 310); // 일반정액권카드판매금액
|
||||
case K_SALE_CARD_Q : return getStringInLine(record, 310, 313); // 경차정액권카드판매권수
|
||||
case K_SALE_CARD_M : return getStringInLine(record, 313, 321); // 경차정액권카드판매금액
|
||||
case RESERVED : return getStringInLine(record, 321, 329); // Filler
|
||||
case E_MARK : return getStringInLine(record, 329, 330); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 징수원정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class CollectorDataRecord extends Record {
|
||||
private int RECORD_LEN = 250; // 레코드 길이
|
||||
|
||||
public static final int S_MARK = 0; // 시작표시
|
||||
public static final int DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int DATA_TYPE = 2; // 자료구분
|
||||
public static final int DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int SEQNO = 4; // 일련번호
|
||||
public static final int WORKER_ID = 5; // 징수원 ID
|
||||
public static final int WORKER_SEQNO = 6; // 징수원번호
|
||||
public static final int PASSWORD = 7; // 패스워드
|
||||
public static final int WORKER_NAME = 8; // 징수원명
|
||||
public static final int SHIFT = 9; // SHIFT
|
||||
public static final int RESIDENT_NO = 10; // 주민번호
|
||||
public static final int TEL_NO = 11; // 전화번호
|
||||
public static final int PCS_NO = 12; // 핸드폰번호
|
||||
public static final int POST_NO1 = 13; // 우편번호1
|
||||
public static final int POST_NO2 = 14; // 우편번호2
|
||||
public static final int ADDRESS_NAME = 15; // 주소
|
||||
public static final int ADDRESS_NUMBER = 16; // 주소번지
|
||||
public static final int OFFICE_NAME = 17; // 근무회사명
|
||||
public static final int WORK_END_YN = 18; // 근무완료여부
|
||||
public static final int IUD_KBN = 19; // 입력/수정여부
|
||||
public static final int RESERVED = 20; // Filler
|
||||
public static final int E_MARK = 21; // 종료표시
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public CollectorDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case SEQNO : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case WORKER_ID : return getStringInLine(record, 20, 26); // 징수원 ID
|
||||
case WORKER_SEQNO : return getStringInLine(record, 26, 28); // 징수원번호
|
||||
case PASSWORD : return getStringInLine(record, 28, 36); // 패스워드
|
||||
case WORKER_NAME : return getStringInLine(record, 36, 46); // 징수원명
|
||||
case SHIFT : return getStringInLine(record, 46, 47); // SHIFT
|
||||
case RESIDENT_NO : return getStringInLine(record, 47, 60); // 주민번호
|
||||
case TEL_NO : return getStringInLine(record, 60, 75); // 전화번호
|
||||
case PCS_NO : return getStringInLine(record, 75, 90); // 핸드폰번호
|
||||
case POST_NO1 : return getStringInLine(record, 90, 94); // 우편번호1
|
||||
case POST_NO2 : return getStringInLine(record, 94, 98); // 우편번호2
|
||||
case ADDRESS_NAME : return getStringInLine(record, 98, 158); // 주소
|
||||
case ADDRESS_NUMBER : return getStringInLine(record,158, 198); // 주소번지
|
||||
case OFFICE_NAME : return getStringInLine(record,198, 238); // 근무회사명
|
||||
case WORK_END_YN : return getStringInLine(record,238, 239); // 근무완료여부
|
||||
case IUD_KBN : return getStringInLine(record,239, 240); // 입력/수정여부
|
||||
case RESERVED : return getStringInLine(record,240, 249); // Filler
|
||||
case E_MARK : return getStringInLine(record,249, 250); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,69 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 쿠폰폐기정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class CpnDisuseDataRecord extends Record {
|
||||
private int RECORD_LEN = 200; // 레코드 길이
|
||||
public static final int S_MARK = 0; // 시작표시
|
||||
public static final int DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int DATA_TYPE = 2; // 자료구분
|
||||
public static final int DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int SEQNO = 4; // 일련번호
|
||||
public static final int FARE_OFFICE_ID = 5; // 요금소코드
|
||||
public static final int DISUSE_DATE = 6; // 폐기일자
|
||||
public static final int DISUSE_SEQNO = 7; // 일련번호
|
||||
public static final int COUPON_KBN = 8; // 쿠폰구분
|
||||
public static final int FARE_YEAR = 9; // 년도
|
||||
public static final int FARE_MONTH = 10; // 월
|
||||
public static final int FARE_DAY = 11; // 일
|
||||
public static final int COUPON_COUNT = 12; // 쿠폰매수
|
||||
public static final int DISUSE_PERSON = 13; // 폐기자
|
||||
public static final int DISUSE_COUNT = 14; // 폐기매수
|
||||
public static final int K_COUPON_CNT = 15; // 경차쿠폰매수
|
||||
public static final int K_DISUSE_CNT = 16; // 경차폐기매수
|
||||
public static final int RESERVED = 17; // Filler
|
||||
public static final int E_MARK = 18; // 종료표시
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public CpnDisuseDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case SEQNO : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case FARE_OFFICE_ID : return getStringInLine(record, 20, 22); // 요금소코드
|
||||
case DISUSE_DATE : return getStringInLine(record, 22, 30); // 폐기일자
|
||||
case DISUSE_SEQNO : return getStringInLine(record, 30, 32); // 일련번호
|
||||
case COUPON_KBN : return getStringInLine(record, 32, 33); // 쿠폰구분
|
||||
case FARE_YEAR : return getStringInLine(record, 33, 37); // 년도
|
||||
case FARE_MONTH : return getStringInLine(record, 37, 39); // 월
|
||||
case FARE_DAY : return getStringInLine(record, 39, 41); // 일
|
||||
case COUPON_COUNT : return getStringInLine(record, 41, 46); // 쿠폰매수
|
||||
case DISUSE_PERSON : return getStringInLine(record, 46, 56); // 폐기자
|
||||
case DISUSE_COUNT : return getStringInLine(record, 56, 61); // 폐기매수
|
||||
case K_COUPON_CNT : return getStringInLine(record, 61, 66); // 경차쿠폰매수
|
||||
case K_DISUSE_CNT : return getStringInLine(record, 66, 71); // 경차폐기매수
|
||||
case RESERVED : return getStringInLine(record, 71, 199); // Filler
|
||||
case E_MARK : return getStringInLine(record, 199, 200); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,119 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 요금단말정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class FareTermDataRecord extends Record {
|
||||
private int RECORD_LEN = 380; // 레코드 길이
|
||||
public static final int S_MARK = 0; // 시작표시
|
||||
public static final int DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int DATA_TYPE = 2; // 자료구분
|
||||
public static final int DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int SEQNO1 = 4; // 일련번호
|
||||
public static final int WORKER_ID = 5; // 징수원ID
|
||||
public static final int FARE_OFFICE_ID = 6; // 요금소코드
|
||||
public static final int BOOTH_ID = 7; // 차로코드
|
||||
public static final int YEAR = 8; // 년도
|
||||
public static final int MONTH = 9; // 월
|
||||
public static final int DAY = 10; // 일
|
||||
public static final int WORK_TIMES = 11; // 통행시간
|
||||
public static final int SEQNO = 12; // 일련번호
|
||||
public static final int ENFORCE_DATE = 13; // 시행일자
|
||||
public static final int CAR_TYPE_ID = 14; // 차종코드
|
||||
public static final int STT_DATE = 15; // 시작일자
|
||||
public static final int COLLECT_ID = 16; // 징수유형코드
|
||||
public static final int CARD_ISSUE_ID = 17; // 발행사코드
|
||||
public static final int WORK_STT_TIME = 18; // 근무시작시간
|
||||
public static final int WORK_END_TIME = 19; // 근무종료시간
|
||||
public static final int IN_OUT_KBN = 20; // 유출입구분
|
||||
public static final int LEVY_AMOUNT = 21; // 징수금액
|
||||
public static final int READING_ID = 22; // 판독구분코드
|
||||
public static final int FOREIGN_CARS_KBN = 23; // 외국인차량구분
|
||||
public static final int ARMY_CARS_KBN = 24; // 미군용차량구분
|
||||
public static final int CARS_MOVE_PICTURE_FILE = 25; // 동영상파일명
|
||||
public static final int CARS_STOP_PICTURE_FILE = 26; // 정지영상파일명
|
||||
public static final int CAR_NO = 27; // 차량번호
|
||||
public static final int READER = 28; // 판독자 ID
|
||||
public static final int READING_DATE = 29; // 판독일자
|
||||
public static final int REMARKS = 30; // 비고
|
||||
public static final int X_POSITION = 31; // 번호판 X좌표
|
||||
public static final int Y_POSITION = 32; // 번호판 Y좌표
|
||||
public static final int GARO_LEN = 33; // 번호판 가로길이
|
||||
public static final int SERO_LEN = 34; // 번호판 세로길이
|
||||
public static final int NOTE_TRANS_YN = 35; // 수기통행여부
|
||||
public static final int NEW_DATA_YN = 36; // 입력여부
|
||||
public static final int NOTE_INPUT_REMARKS = 37; // 수기입력사유
|
||||
public static final int DELETE_YN = 38; // 삭제여부
|
||||
public static final int OTHER_SEQNO = 39; // 중복방지번호
|
||||
public static final int URGENT_KBN = 40; // 비상데이터구분
|
||||
public static final int RESERVED = 41; // Filler
|
||||
public static final int E_MARK = 42; // 종료표시
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public FareTermDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case SEQNO1 : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case WORKER_ID : return getStringInLine(record, 24, 26) + getStringInLine(record, 20, 24);
|
||||
// 징수원ID
|
||||
case FARE_OFFICE_ID : return getStringInLine(record, 24, 26); // 요금소코드
|
||||
case BOOTH_ID : return getStringInLine(record, 26, 28); // 차로코드
|
||||
case YEAR : return getStringInLine(record, 28, 32); // 년도
|
||||
case MONTH : return getStringInLine(record, 32, 34); // 월
|
||||
case DAY : return getStringInLine(record, 34, 36); // 일
|
||||
case WORK_TIMES : return getStringInLine(record, 36, 42); // 통행시간
|
||||
case SEQNO : return getStringInLine(record, 42, 51); // 일련번호
|
||||
case ENFORCE_DATE : return getStringInLine(record, 51, 59); // 시행일자
|
||||
case CAR_TYPE_ID : return getStringInLine(record, 59, 60); // 차종코드
|
||||
case STT_DATE : return getStringInLine(record, 60, 68); // 시작일자
|
||||
case COLLECT_ID : return getStringInLine(record, 68, 70); // 징수유형코드
|
||||
case CARD_ISSUE_ID : return getStringInLine(record, 70, 77); // 발행사코드
|
||||
case WORK_STT_TIME : return getStringInLine(record, 77, 83); // 근무시작시간
|
||||
case WORK_END_TIME : return getStringInLine(record, 83, 89); // 근무종료시간
|
||||
case IN_OUT_KBN : return getStringInLine(record, 89, 90); // 유출입구분
|
||||
case LEVY_AMOUNT : return getStringInLine(record, 90, 98); // 징수금액
|
||||
case READING_ID : return getStringInLine(record, 98, 100); // 판독구분코드
|
||||
case FOREIGN_CARS_KBN : return getStringInLine(record, 100, 101); // 외국인차량구분
|
||||
case ARMY_CARS_KBN : return getStringInLine(record, 101, 102); // 미군용차량구분
|
||||
case CARS_MOVE_PICTURE_FILE : return getStringInLine(record, 102, 152); // 동영상파일명
|
||||
case CARS_STOP_PICTURE_FILE : return getStringInLine(record, 152, 202); // 정지영상파일명
|
||||
case CAR_NO : return getStringInLine(record, 202, 222); // 차량번호
|
||||
case READER : return getStringInLine(record, 222, 228); // 판독자 ID
|
||||
case READING_DATE : return getStringInLine(record, 228, 236); // 판독일자
|
||||
case REMARKS : return getStringInLine(record, 236, 296); // 비고
|
||||
case X_POSITION : return getStringInLine(record, 296, 299); // 번호판 X좌표
|
||||
case Y_POSITION : return getStringInLine(record, 299, 302); // 번호판 Y좌표
|
||||
case GARO_LEN : return getStringInLine(record, 302, 305); // 번호판 가로길이
|
||||
case SERO_LEN : return getStringInLine(record, 305, 308); // 번호판 세로길이
|
||||
case NOTE_TRANS_YN : return getStringInLine(record, 308, 309); // 수기통행여부
|
||||
case NEW_DATA_YN : return getStringInLine(record, 309, 310); // 입력여부
|
||||
case NOTE_INPUT_REMARKS : return getStringInLine(record, 310, 370); // 수기입력사유
|
||||
case DELETE_YN : return getStringInLine(record, 370, 371); // 삭제여부
|
||||
case OTHER_SEQNO : return getStringInLine(record, 371, 372); // 중복방지번호
|
||||
case URGENT_KBN : return getStringInLine(record, 372, 373); // 비상데이터구분
|
||||
case RESERVED : return getStringInLine(record, 372, 379); // Filler
|
||||
case E_MARK : return getStringInLine(record, 379, 380); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,70 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 요금단말 변경정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class FareTermUpdDataRecord extends Record {
|
||||
private int RECORD_LEN = 200; // 레코드 길이
|
||||
public static final int S_MARK = 0; // 시작표시
|
||||
public static final int DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int DATA_TYPE = 2; // 자료구분
|
||||
public static final int DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int SEQNO1 = 4; // 일련번호
|
||||
public static final int WORKER_ID = 5; // 징수원ID
|
||||
public static final int FARE_OFFICE_ID = 6; // 요금소코드
|
||||
public static final int BOOTH_ID = 7; // 차로코드
|
||||
public static final int YEAR = 8; // 년도
|
||||
public static final int MONTH = 9; // 월
|
||||
public static final int DAY = 10; // 일
|
||||
public static final int WORK_TIMES = 11; // 통행시간
|
||||
public static final int SEQNO = 12; // 일련번호
|
||||
public static final int UPDATE_SEQNO = 13; // 이력일련번호
|
||||
public static final int UPDATE_HISTORY_DATE = 14; // 변경일자
|
||||
public static final int UPDATE_REASON = 15; // 변경사유
|
||||
public static final int COLLECT_ID = 16; // 수정 징수유형
|
||||
public static final int RESERVED = 17; // Filler
|
||||
public static final int E_MARK = 18; // 종료표시
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public FareTermUpdDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case SEQNO1 : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case WORKER_ID : return getStringInLine(record, 24, 26) + getStringInLine(record, 20, 24);
|
||||
// 징수원ID
|
||||
case FARE_OFFICE_ID : return getStringInLine(record, 24, 26); // 요금소코드
|
||||
case BOOTH_ID : return getStringInLine(record, 26, 28); // 차로코드
|
||||
case YEAR : return getStringInLine(record, 28, 32); // 년도
|
||||
case MONTH : return getStringInLine(record, 32, 34); // 월
|
||||
case DAY : return getStringInLine(record, 34, 36); // 일
|
||||
case WORK_TIMES : return getStringInLine(record, 36, 42); // 통행시간
|
||||
case SEQNO : return getStringInLine(record, 42, 51); // 일련번호
|
||||
case UPDATE_SEQNO : return getStringInLine(record, 51, 54); // 이력일련번호
|
||||
case UPDATE_HISTORY_DATE : return getStringInLine(record, 54, 62); // 변경일자
|
||||
case UPDATE_REASON : return getStringInLine(record, 62, 182); // 변경사유
|
||||
case COLLECT_ID : return getStringInLine(record, 182, 184); // 수정 징수유형
|
||||
case RESERVED : return getStringInLine(record, 184, 199); // Filler
|
||||
case E_MARK : return getStringInLine(record, 199, 200); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,98 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 정액권 수불정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class FixTicketDataRecord extends Record {
|
||||
|
||||
private int RECORD_LEN = 210; // 레코드 길이
|
||||
|
||||
public static final int H_S_MARK = 0; // 시작표시
|
||||
public static final int H_DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int H_DATA_TYPE = 2; // 자료구분
|
||||
public static final int H_DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int H_SEQNO1 = 4; // 일련번호
|
||||
public static final int H_FARE_OFFICE_ID = 5; // 요금소코드
|
||||
public static final int H_YEAR = 6; // 년도
|
||||
public static final int H_MONTH = 7; // 월
|
||||
public static final int H_DAY = 8; // 일
|
||||
public static final int H_IN_OUT_KBN = 9; // 수불구분
|
||||
public static final int H_IN_OUT_COUNT = 10; // 권수
|
||||
public static final int H_RESERVED = 11; // Filler
|
||||
public static final int H_E_MARK = 12; // 종료표시
|
||||
public static final int D_S_MARK = 13; // 시작표시
|
||||
public static final int D_DATA_SEQNO1 = 14; // 자료번호
|
||||
public static final int D_DATA_TYPE = 15; // 자료구분
|
||||
public static final int D_DATA_SEQNO2 = 16; // 자료번호
|
||||
public static final int D_SEQNO1 = 17; // 일련번호
|
||||
public static final int D_FARE_OFFICE_ID = 18; // 요금소코드
|
||||
public static final int D_YEAR = 19; // 년도
|
||||
public static final int D_MONTH = 20; // 월
|
||||
public static final int D_DAY = 21; // 일
|
||||
public static final int D_IN_OUT_KBN = 22; // 수불구분
|
||||
public static final int D_SEQNO = 23; // 일련번호
|
||||
public static final int D_BOOTH_ID = 24; // 차로구분
|
||||
public static final int D_STT_SEQNO = 25; // Stt-일련번호
|
||||
public static final int D_END_SEQNO = 26; // End-일련번호
|
||||
public static final int D_IN_OUT_COUNT = 27; // 권수
|
||||
public static final int D_REMARKS = 28; // 반납사유
|
||||
public static final int D_DAY_END_PROCESS_FLAG = 29; // 일마감
|
||||
public static final int D_RESERVED = 30; // Filler
|
||||
public static final int D_E_MARK = 31; // 종료표시
|
||||
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public FixTicketDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case H_S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case H_DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case H_DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case H_DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case H_SEQNO1 : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case H_FARE_OFFICE_ID : return getStringInLine(record, 20, 22); // 요금소코드
|
||||
case H_YEAR : return getStringInLine(record, 22, 26); // 년도
|
||||
case H_MONTH : return getStringInLine(record, 26, 28); // 월
|
||||
case H_DAY : return getStringInLine(record, 28, 30); // 일
|
||||
case H_IN_OUT_KBN : return getStringInLine(record, 30, 32); // 수불구분
|
||||
case H_IN_OUT_COUNT : return getStringInLine(record, 32, 35); // 권수
|
||||
case H_RESERVED : return getStringInLine(record, 35, 209); // Filler
|
||||
case H_E_MARK : return getStringInLine(record, 209, 210); // 종료표시
|
||||
case D_S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case D_DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case D_DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case D_DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case D_SEQNO1 : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case D_FARE_OFFICE_ID : return getStringInLine(record, 20, 22); // 요금소코드
|
||||
case D_YEAR : return getStringInLine(record, 22, 26); // 년도
|
||||
case D_MONTH : return getStringInLine(record, 26, 28); // 월
|
||||
case D_DAY : return getStringInLine(record, 28, 30); // 일
|
||||
case D_IN_OUT_KBN : return getStringInLine(record, 30, 32); // 수불구분
|
||||
case D_SEQNO : return getStringInLine(record, 32, 35); // 일련번호
|
||||
case D_BOOTH_ID : return getStringInLine(record, 35, 37); // 차로구분
|
||||
case D_STT_SEQNO : return getStringInLine(record, 37, 57); // Stt-일련번호
|
||||
case D_END_SEQNO : return getStringInLine(record, 57, 77); // End-일련번호
|
||||
case D_IN_OUT_COUNT : return getStringInLine(record, 77, 81); // 권수
|
||||
case D_REMARKS : return getStringInLine(record, 81, 201); // 반납사유
|
||||
case D_DAY_END_PROCESS_FLAG : return getStringInLine(record, 201, 202); // 일마감
|
||||
case D_RESERVED : return getStringInLine(record, 202, 209); // Filler
|
||||
case D_E_MARK : return getStringInLine(record, 209, 210); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 입출금정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class InOutAmtDataRecord extends Record {
|
||||
private int RECORD_LEN = 250; // 레코드 길이
|
||||
public static final int S_MARK = 0; // 시작표시
|
||||
public static final int DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int DATA_TYPE = 2; // 자료구분
|
||||
public static final int DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int SEQNO1 = 4; // 일련번호
|
||||
public static final int WORKER_ID = 5; // 징수원ID
|
||||
public static final int FARE_OFFICE_ID = 6; // 요금소코드
|
||||
public static final int BOOTH_ID = 7; // 차로코드
|
||||
public static final int YEAR = 8; // 년도
|
||||
public static final int MONTH = 9; // 월
|
||||
public static final int DAY = 10; // 일
|
||||
public static final int WORK_STT_TIME = 11; // 근무시작시간
|
||||
public static final int WORK_END_TIME = 12; // 근무종료시간
|
||||
public static final int IO_SEQNO = 13; // 일련번호
|
||||
public static final int IN_OUT_KBN = 14; // 입출금 구분
|
||||
public static final int IN_OUT_CONTENTS = 15; // 입출금 내역
|
||||
public static final int IN_OUT_AMOUNT = 16; // 입출금 금액
|
||||
public static final int DELETE_YN = 17; // 삭제여부
|
||||
public static final int REMARKS = 18; // 비고
|
||||
public static final int RESERVED = 19; // Filler
|
||||
public static final int E_MARK = 20; // 종료표시
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public InOutAmtDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case SEQNO1 : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case WORKER_ID : return getStringInLine(record, 24, 26) + getStringInLine(record, 20, 24);
|
||||
// 징수원ID
|
||||
case FARE_OFFICE_ID : return getStringInLine(record, 24, 26); // 요금소코드
|
||||
case BOOTH_ID : return getStringInLine(record, 26, 28); // 차로코드
|
||||
case YEAR : return getStringInLine(record, 28, 32); // 년도
|
||||
case MONTH : return getStringInLine(record, 32, 34); // 월
|
||||
case DAY : return getStringInLine(record, 34, 36); // 일
|
||||
case WORK_STT_TIME : return getStringInLine(record, 36, 42); // 근무시작시간
|
||||
case WORK_END_TIME : return getStringInLine(record, 42, 48); // 근무종료시간
|
||||
case IO_SEQNO : return getStringInLine(record, 48, 50); // 일련번호
|
||||
case IN_OUT_KBN : return getStringInLine(record, 50, 51); // 입출금 구분
|
||||
case IN_OUT_CONTENTS : return getStringInLine(record, 51, 171); // 입출금 내역
|
||||
case IN_OUT_AMOUNT : return getStringInLine(record, 171, 180); // 입출금 금액
|
||||
case DELETE_YN : return getStringInLine(record, 180, 181); // 삭제여부
|
||||
case REMARKS : return getStringInLine(record, 181, 241); // 비고
|
||||
case RESERVED : return getStringInLine(record, 241, 249); // Filler
|
||||
case E_MARK : return getStringInLine(record, 249, 250); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,99 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 수입금정산정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class IncomeInfoDataRecord extends Record {
|
||||
private int RECORD_LEN = 260; // 레코드 길이
|
||||
public static final int S_MARK = 0; // 시작표시
|
||||
public static final int DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int DATA_TYPE = 2; // 자료구분
|
||||
public static final int DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int INCOME_SEQNO = 4; // 일련번호
|
||||
public static final int FARE_OFFICE_ID = 5; // 요금소코드
|
||||
public static final int INCOME_DATE = 6; // 정산일자
|
||||
public static final int INCOME_PART = 7; // 정산그룹
|
||||
public static final int CASH_QUANTITY = 8; // 현금 통행량
|
||||
public static final int CARD_BEFORE_QUANTITY = 9; // 선불카드 통행량
|
||||
public static final int CARD_AFTER_QUANTITY = 10; // 후불카드 통행량
|
||||
public static final int COUPON_QUANTITY = 11; // 쿠폰회수 통행량
|
||||
public static final int EXEMPTION_QUANTITY = 12; // 면제 통행량
|
||||
public static final int NONPAYMENT_QUANTITY = 13; // 미납 통행량
|
||||
public static final int COUPON_SALE_QUANTITY = 14; // 정액권 판매권수
|
||||
public static final int CASH_INCOME = 15; // 현금 수입금액
|
||||
public static final int COUPON_SALE_INCOME = 16; // 정액권 판매금액
|
||||
public static final int CUSTOM_NAME = 17; // 징수 회사명
|
||||
public static final int CUSTOM_PERSON = 18; // 징수 담당자명
|
||||
public static final int K_CASH_Q = 19; // 경차현금 통행량
|
||||
public static final int K_SUN_Q = 20; // 경차선불카드 통행량
|
||||
public static final int K_WHO_Q = 21; // 경차후불카드 통행량
|
||||
public static final int K_COUPON_Q = 22; // 경차쿠폰회수 통행량
|
||||
public static final int K_COUPON_SALE_Q = 23; // 경차정액권 판매권수
|
||||
public static final int K_CASH_INCOME = 24; // 경차현금 수입금액
|
||||
public static final int K_COUPON_SALE_INCOME = 25; // 경차정액권 판매금액
|
||||
public static final int REPAY_Q = 26; // 카드환불건수
|
||||
public static final int REPAY_M = 27; // 카드환불금액
|
||||
public static final int SALE_CARD_Q = 28; // 정액권카드판매권수
|
||||
public static final int SALE_CARD_M = 29; // 정액권카드판매금액
|
||||
public static final int K_SALE_CARD_Q = 30; // 경차정액권카드판매권수
|
||||
public static final int K_SALE_CARD_M = 31; // 경차정액권카드판매금액
|
||||
public static final int RESERVED = 32; // Filler
|
||||
public static final int E_MARK = 33; // 종료표시
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public IncomeInfoDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case INCOME_SEQNO : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case FARE_OFFICE_ID : return getStringInLine(record, 20, 22); // 요금소코드
|
||||
case INCOME_DATE : return getStringInLine(record, 22, 30); // 정산일자
|
||||
case INCOME_PART : return getStringInLine(record, 30, 31); // 정산그룹
|
||||
case CASH_QUANTITY : return getStringInLine(record, 31, 36); // 현금 통행량
|
||||
case CARD_BEFORE_QUANTITY : return getStringInLine(record, 36, 41); // 선불카드 통행량
|
||||
case CARD_AFTER_QUANTITY : return getStringInLine(record, 41, 46); // 후불카드 통행량
|
||||
case COUPON_QUANTITY : return getStringInLine(record, 46, 51); // 쿠폰회수 통행량
|
||||
case EXEMPTION_QUANTITY : return getStringInLine(record, 51, 56); // 면제 통행량
|
||||
case NONPAYMENT_QUANTITY : return getStringInLine(record, 56, 61); // 미납 통행량
|
||||
case COUPON_SALE_QUANTITY : return getStringInLine(record, 61, 66); // 정액권 판매권수
|
||||
case CASH_INCOME : return getStringInLine(record, 66, 75); // 현금 수입금액
|
||||
case COUPON_SALE_INCOME : return getStringInLine(record, 75, 84); // 정액권 판매금액
|
||||
case CUSTOM_NAME : return getStringInLine(record, 84, 114); // 징수 회사명
|
||||
case CUSTOM_PERSON : return getStringInLine(record, 114, 134); // 징수 담당자명
|
||||
case K_CASH_Q : return getStringInLine(record, 134, 139); // 경차현금 통행량
|
||||
case K_SUN_Q : return getStringInLine(record, 139, 144); // 경차선불카드 통행량
|
||||
case K_WHO_Q : return getStringInLine(record, 144, 149); // 경차후불카드 통행량
|
||||
case K_COUPON_Q : return getStringInLine(record, 149, 154); // 경차쿠폰회수 통행량
|
||||
case K_COUPON_SALE_Q : return getStringInLine(record, 154, 159); // 경차정액권 판매권수
|
||||
case K_CASH_INCOME : return getStringInLine(record, 159, 168); // 경차현금 수입금액
|
||||
case K_COUPON_SALE_INCOME : return getStringInLine(record, 168, 177); // 경차정액권 판매금액
|
||||
case REPAY_Q : return getStringInLine(record, 177, 186); // 카드환불건수
|
||||
case REPAY_M : return getStringInLine(record, 186, 201); // 카드환불금액
|
||||
case SALE_CARD_Q : return getStringInLine(record, 201, 210); // 정액권카드판매권수
|
||||
case SALE_CARD_M : return getStringInLine(record, 210, 225); // 정액권카드판매금액
|
||||
case K_SALE_CARD_Q : return getStringInLine(record, 225, 234); // 경차정액권카드판매권수
|
||||
case K_SALE_CARD_M : return getStringInLine(record, 234, 249); // 경차정액권카드판매금액
|
||||
case RESERVED : return getStringInLine(record, 249, 259); // Filler
|
||||
case E_MARK : return getStringInLine(record, 259, 260); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,173 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 과잉쿠폰 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class OverCouponDataRecord extends Record {
|
||||
private int RECORD_LEN = 280; // 레코드 길이
|
||||
|
||||
public static final int H_S_MARK = 0; // 시작표시
|
||||
public static final int H_DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int H_DATA_TYPE = 2; // 자료구분
|
||||
public static final int H_DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int H_SEQNO1 = 4; // 일련번호
|
||||
public static final int H_WORKER_ID = 5; // 징수원ID
|
||||
public static final int H_FARE_OFFICE_ID = 6; // 요금소코드
|
||||
public static final int H_BOOTH_ID = 7; // 차로코드
|
||||
public static final int H_YEAR = 8; // 년도
|
||||
public static final int H_MONTH = 9; // 월
|
||||
public static final int H_DAY = 10; // 일
|
||||
public static final int H_WORK_STT_TIME = 11; // 근무시작시간
|
||||
public static final int H_WORK_END_TIME = 12; // 근무종료시간
|
||||
public static final int H_OVERCOUPON_COUNT = 13; // 과잉쿠폰 매수
|
||||
public static final int H_COUPON_RETURN_COUNT = 14; // 반환쿠폰 매수
|
||||
public static final int H_COUPON_DISUSE_COUNT = 15; // 폐기쿠폰 매수
|
||||
public static final int H_K_OVERCOUPON_CNT = 16; // 경차 과잉쿠폰 매수
|
||||
public static final int H_K_COUPON_RET_CNT = 17; // 경차 반환쿠폰 매수
|
||||
public static final int H_K_COUPON_DISUSE_CNT = 18; // 경차 폐기쿠폰 매수
|
||||
public static final int H_RESERVED = 19; // Filler
|
||||
public static final int H_E_MARK = 20; // 종료표시
|
||||
public static final int D_S_MARK = 21; // 시작표시
|
||||
public static final int D_DATA_SEQNO1 = 22; // 자료번호
|
||||
public static final int D_DATA_TYPE = 23; // 자료구분
|
||||
public static final int D_DATA_SEQNO2 = 24; // 자료번호
|
||||
public static final int D_SEQNO1 = 25; // 일련번호
|
||||
public static final int D_WORKER_ID = 26; // 징수원ID
|
||||
public static final int D_FARE_OFFICE_ID = 27; // 요금소코드
|
||||
public static final int D_BOOTH_ID = 28; // 차로코드
|
||||
public static final int D_YEAR = 29; // 년도
|
||||
public static final int D_MONTH = 30; // 월
|
||||
public static final int D_DAY = 31; // 일
|
||||
public static final int D_WORK_STT_TIME = 32; // 근무시작시간
|
||||
public static final int D_WORK_END_TIME = 33; // 근무종료시간
|
||||
public static final int D_SEQNO = 34; // 일련번호
|
||||
public static final int D_FARE_TIME = 35; // 징수시간
|
||||
public static final int D_OVER_KBN = 36; // 과잉구분
|
||||
public static final int D_COUPON_COUNT = 37; // 쿠폰매수
|
||||
public static final int D_CAR_NO = 38; // 차량번호
|
||||
public static final int D_CARS_TYPE_NAME = 39; // 차종명
|
||||
public static final int D_OWNER = 40; // 수령자
|
||||
public static final int D_TEL_NO = 41; // 수령자 연락번호
|
||||
public static final int D_REMARKS = 42; // 비고
|
||||
public static final int D_INPUT_KBN = 43; // 입력여부
|
||||
public static final int D_COUPON_NO = 44; // 쿠폰번호
|
||||
public static final int D_RETURN_DATE = 45; // 반환일자
|
||||
public static final int D_RETURN_PERSON = 46; // 반환자
|
||||
public static final int D_DELETE_YN = 47; // 삭제여부
|
||||
public static final int D_C_REPAY_KBN = 48; // 경차구분
|
||||
public static final int D_RESERVED = 49; // Filler
|
||||
public static final int D_E_MARK = 50; // 종료표시
|
||||
public static final int C_S_MARK = 51; // 시작표시
|
||||
public static final int C_DATA_SEQNO1 = 52; // 자료번호
|
||||
public static final int C_DATA_TYPE = 53; // 자료구분
|
||||
public static final int C_DATA_SEQNO2 = 54; // 자료번호
|
||||
public static final int C_SEQNO1 = 55; // 일련번호
|
||||
public static final int C_WORKER_ID = 56; // 징수원ID
|
||||
public static final int C_FARE_OFFICE_ID = 57; // 요금소코드
|
||||
public static final int C_BOOTH_ID = 58; // 차로코드
|
||||
public static final int C_YEAR = 59; // 년도
|
||||
public static final int C_MONTH = 60; // 월
|
||||
public static final int C_DAY = 61; // 일
|
||||
public static final int C_WORK_STT_TIME = 62; // 근무시작시간
|
||||
public static final int C_WORK_END_TIME = 63; // 근무종료시간
|
||||
public static final int C_SEQNO = 64; // 일련번호
|
||||
public static final int C_COUPON_NO = 65; // 쿠폰번호
|
||||
public static final int C_MINI_CAR_KBN = 66; // 경차구분
|
||||
public static final int C_RESERVED = 67; // Filler
|
||||
public static final int C_E_MARK = 68; // 종료표시
|
||||
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public OverCouponDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
|
||||
case H_S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case H_DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case H_DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case H_DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case H_SEQNO1 : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case H_WORKER_ID : return getStringInLine(record, 20, 26); // 징수원ID
|
||||
case H_FARE_OFFICE_ID : return getStringInLine(record, 26, 28); // 요금소코드
|
||||
case H_BOOTH_ID : return getStringInLine(record, 28, 30); // 차로코드
|
||||
case H_YEAR : return getStringInLine(record, 30, 34); // 년도
|
||||
case H_MONTH : return getStringInLine(record, 34, 36); // 월
|
||||
case H_DAY : return getStringInLine(record, 36, 38); // 일
|
||||
case H_WORK_STT_TIME : return getStringInLine(record, 38, 44); // 근무시작시간
|
||||
case H_WORK_END_TIME : return getStringInLine(record, 44, 50); // 근무종료시간
|
||||
case H_OVERCOUPON_COUNT : return getStringInLine(record, 50, 55); // 과잉쿠폰 매수
|
||||
case H_COUPON_RETURN_COUNT : return getStringInLine(record, 55, 60); // 반환쿠폰 매수
|
||||
case H_COUPON_DISUSE_COUNT : return getStringInLine(record, 60, 65); // 폐기쿠폰 매수
|
||||
case H_K_OVERCOUPON_CNT : return getStringInLine(record, 65, 70); // 경차 과잉쿠폰 매수
|
||||
case H_K_COUPON_RET_CNT : return getStringInLine(record, 70, 75); // 경차 반환쿠폰 매수
|
||||
case H_K_COUPON_DISUSE_CNT : return getStringInLine(record, 75, 80); // 경차 폐기쿠폰 매수
|
||||
case H_RESERVED : return getStringInLine(record, 80, 279); // Filler
|
||||
case H_E_MARK : return getStringInLine(record, 279, 280); // 종료표시
|
||||
case D_S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case D_DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case D_DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case D_DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case D_SEQNO1 : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case D_WORKER_ID : return getStringInLine(record, 20, 26); // 징수원ID
|
||||
case D_FARE_OFFICE_ID : return getStringInLine(record, 26, 28); // 요금소코드
|
||||
case D_BOOTH_ID : return getStringInLine(record, 28, 30); // 차로코드
|
||||
case D_YEAR : return getStringInLine(record, 30, 34); // 년도
|
||||
case D_MONTH : return getStringInLine(record, 34, 36); // 월
|
||||
case D_DAY : return getStringInLine(record, 36, 38); // 일
|
||||
case D_WORK_STT_TIME : return getStringInLine(record, 38, 44); // 근무시작시간
|
||||
case D_WORK_END_TIME : return getStringInLine(record, 44, 50); // 근무종료시간
|
||||
case D_SEQNO : return getStringInLine(record, 50, 52); // 일련번호
|
||||
case D_FARE_TIME : return getStringInLine(record, 52, 58); // 징수시간
|
||||
case D_OVER_KBN : return getStringInLine(record, 58, 59); // 과잉구분
|
||||
case D_COUPON_COUNT : return getStringInLine(record, 59, 64); // 쿠폰매수
|
||||
case D_CAR_NO : return getStringInLine(record, 64, 84); // 차량번호
|
||||
case D_CARS_TYPE_NAME : return getStringInLine(record, 84, 124); // 차종명
|
||||
case D_OWNER : return getStringInLine(record, 124, 154); // 수령자
|
||||
case D_TEL_NO : return getStringInLine(record, 154, 169); // 수령자 연락번호
|
||||
case D_REMARKS : return getStringInLine(record, 169, 229); // 비고
|
||||
case D_INPUT_KBN : return getStringInLine(record, 229, 230); // 입력여부
|
||||
case D_COUPON_NO : return getStringInLine(record, 230, 250); // 쿠폰번호
|
||||
case D_RETURN_DATE : return getStringInLine(record, 250, 258); // 반환일자
|
||||
case D_RETURN_PERSON : return getStringInLine(record, 258, 268); // 반환자
|
||||
case D_DELETE_YN : return getStringInLine(record, 268, 269); // 삭제여부
|
||||
case D_C_REPAY_KBN : return getStringInLine(record, 269, 270); // 경차구분
|
||||
case D_RESERVED : return getStringInLine(record, 270, 279); // Filler
|
||||
case D_E_MARK : return getStringInLine(record, 279, 280); // 종료표시
|
||||
case C_S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case C_DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case C_DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case C_DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case C_SEQNO1 : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case C_WORKER_ID : return getStringInLine(record, 20, 26); // 징수원ID
|
||||
case C_FARE_OFFICE_ID : return getStringInLine(record, 26, 28); // 요금소코드
|
||||
case C_BOOTH_ID : return getStringInLine(record, 28, 30); // 차로코드
|
||||
case C_YEAR : return getStringInLine(record, 30, 34); // 년도
|
||||
case C_MONTH : return getStringInLine(record, 34, 36); // 월
|
||||
case C_DAY : return getStringInLine(record, 36, 38); // 일
|
||||
case C_WORK_STT_TIME : return getStringInLine(record, 38, 44); // 근무시작시간
|
||||
case C_WORK_END_TIME : return getStringInLine(record, 44, 50); // 근무종료시간
|
||||
case C_SEQNO : return getStringInLine(record, 50, 52); // 일련번호
|
||||
case C_COUPON_NO : return getStringInLine(record, 52, 72); // 쿠폰번호
|
||||
case C_MINI_CAR_KBN : return getStringInLine(record, 72, 73); // 경차구분
|
||||
case C_RESERVED : return getStringInLine(record, 73, 279); // Filler
|
||||
case C_E_MARK : return getStringInLine(record, 279, 280); // 종료표시
|
||||
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,104 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 과오납 정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class OverFareDataRecord extends Record {
|
||||
private int RECORD_LEN = 280; // 레코드 길이
|
||||
public static final int S_MARK = 0; // 시작표시
|
||||
public static final int DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int DATA_TYPE = 2; // 자료구분
|
||||
public static final int DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int SERIAL_NO1 = 4; // 일련번호
|
||||
public static final int WORKER_ID = 5; // 징수원ID
|
||||
public static final int FARE_OFFICE_ID = 6; // 요금소코드
|
||||
public static final int BOOTH_ID = 7; // 차로코드
|
||||
public static final int YEAR = 8; // 년도
|
||||
public static final int MONTH = 9; // 월
|
||||
public static final int DAY = 10; // 일
|
||||
public static final int WORK_STT_TIME = 11; // 근무시작시간
|
||||
public static final int WORK_END_TIME = 12; // 근무종료시간
|
||||
public static final int OVERFARE_SEQNO = 13; // 일련번호
|
||||
public static final int OWNER = 14; // 소유주
|
||||
public static final int CARS_NO = 15; // 차량번호
|
||||
public static final int RESIDENT_NO = 16; // 주민번호
|
||||
public static final int RESIDENT_DATE = 17; // 차량등록일자
|
||||
public static final int OVERFARE_TIMES = 18; // 통행시간
|
||||
public static final int OVERFARE_KBN = 19; // 과오납 구분
|
||||
public static final int OVERFARE_AMOUNT = 20; // 과오납 금액
|
||||
public static final int REMARKS = 21; // 비고
|
||||
public static final int REFUND_KBN = 22; // 환급 구분
|
||||
public static final int REFUND_WORKER_ID = 23; // 환급 징수원 ID
|
||||
public static final int REFUND_FARE_OFFICE_ID = 24; // 환급 요금소 코드
|
||||
public static final int REFUND_BOOTH_ID = 25; // 환급 차로 코드
|
||||
public static final int REFUND_YEAR = 26; // 환급 년도
|
||||
public static final int REFUND_MONTH = 27; // 환급 월
|
||||
public static final int REFUND_DAY = 28; // 환급 일
|
||||
public static final int REFUND_TIMES = 29; // 환급 시간
|
||||
public static final int REFUND_OWNER = 30; // 환급 수령자
|
||||
public static final int REFUND_COMMUMI = 31; // 환급 연락처
|
||||
public static final int PROCESS_KBN = 32; // 집계처리구분
|
||||
public static final int DELETE_YN = 33; // 삭제여부
|
||||
public static final int RESERVED = 34; // Filler
|
||||
public static final int E_MARK = 35; // 종료표시
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public OverFareDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case SERIAL_NO1 : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case WORKER_ID : return getStringInLine(record, 24, 26) + getStringInLine(record, 20, 24);
|
||||
// 징수원ID
|
||||
case FARE_OFFICE_ID : return getStringInLine(record, 24, 26); // 요금소코드
|
||||
case BOOTH_ID : return getStringInLine(record, 26, 28); // 차로코드
|
||||
case YEAR : return getStringInLine(record, 28, 32); // 년도
|
||||
case MONTH : return getStringInLine(record, 32, 34); // 월
|
||||
case DAY : return getStringInLine(record, 34, 36); // 일
|
||||
case WORK_STT_TIME : return getStringInLine(record, 36, 42); // 근무시작시간
|
||||
case WORK_END_TIME : return getStringInLine(record, 42, 48); // 근무종료시간
|
||||
case OVERFARE_SEQNO : return getStringInLine(record, 48, 50); // 일련번호
|
||||
case OWNER : return getStringInLine(record, 50, 80); // 소유주
|
||||
case CARS_NO : return getStringInLine(record, 80, 100); // 차량번호
|
||||
case RESIDENT_NO : return getStringInLine(record, 100, 113); // 주민번호
|
||||
case RESIDENT_DATE : return getStringInLine(record, 113, 121); // 차량등록일자
|
||||
case OVERFARE_TIMES : return getStringInLine(record, 121, 127); // 통행시간
|
||||
case OVERFARE_KBN : return getStringInLine(record, 127, 128); // 과오납 구분
|
||||
case OVERFARE_AMOUNT : return getStringInLine(record, 128, 133); // 과오납 금액
|
||||
case REMARKS : return getStringInLine(record, 133, 193); // 비고
|
||||
case REFUND_KBN : return getStringInLine(record, 193, 194); // 환급 구분
|
||||
case REFUND_WORKER_ID : return getStringInLine(record, 194, 200); // 환급 징수원 ID
|
||||
case REFUND_FARE_OFFICE_ID : return getStringInLine(record, 200, 202); // 환급 요금소 코드
|
||||
case REFUND_BOOTH_ID : return getStringInLine(record, 202, 204); // 환급 차로 코드
|
||||
case REFUND_YEAR : return getStringInLine(record, 204, 208); // 환급 년도
|
||||
case REFUND_MONTH : return getStringInLine(record, 208, 210); // 환급 월
|
||||
case REFUND_DAY : return getStringInLine(record, 210, 212); // 환급 일
|
||||
case REFUND_TIMES : return getStringInLine(record, 212, 216); // 환급 시간
|
||||
case REFUND_OWNER : return getStringInLine(record, 216, 246); // 환급 수령자
|
||||
case REFUND_COMMUMI : return getStringInLine(record, 246, 276); // 환급 연락처
|
||||
case PROCESS_KBN : return getStringInLine(record, 276, 277); // 집계처리구분
|
||||
case DELETE_YN : return getStringInLine(record, 277, 278); // 삭제여부
|
||||
case RESERVED : return getStringInLine(record, 278, 279); // Filler
|
||||
case E_MARK : return getStringInLine(record, 279, 280); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,85 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 카드환불 정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class RepayInfoDataRecord extends Record {
|
||||
private int RECORD_LEN = 170; // 레코드 길이
|
||||
public static final int S_MARK = 0; // 시작표시
|
||||
public static final int DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int DATA_TYPE = 2; // 자료구분
|
||||
public static final int DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int SEQNO = 4; // 일련번호
|
||||
public static final int WORKER_ID = 5; // 징수원 ID
|
||||
public static final int FARE_OFFICE_ID = 6; // 요금소 코드
|
||||
public static final int BOOTH_ID = 7; // 차로 코드
|
||||
public static final int YEAR = 8; // 년도
|
||||
public static final int MONTH = 9; // 월
|
||||
public static final int DAY = 10; // 일
|
||||
public static final int WORK_TIMES = 11; // 통행시간
|
||||
public static final int DATA_SEQNO3 = 12; // 일련번호
|
||||
public static final int CAR_TYPE_ID = 13; // 차종코드
|
||||
public static final int COLLECT_ID = 14; // 징수유형 코드
|
||||
public static final int WORK_STT_TIME = 15; // 근무 시작시간
|
||||
public static final int WORK_END_TIME = 16; // 근무 종료시간
|
||||
public static final int IN_OUT_KBN = 17; // 유출입구분
|
||||
public static final int LEVY_AMOUNT = 18; // 징수금액
|
||||
public static final int CAR_NO = 19; // 차량번호
|
||||
public static final int DAY_END_FLAG = 20; // 일마감 Flag
|
||||
public static final int MONTH_END_FLAG = 21; // 월마감 Flag
|
||||
public static final int NOTE_KBN = 22; // 수기통행여부
|
||||
public static final int NOTE_REMARKS = 23; // 수기입력사유
|
||||
public static final int REPAY_KBN = 24; // 환불여부
|
||||
public static final int RESERVED = 25; // Filler
|
||||
public static final int E_MARK = 26; // 종료표시
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public RepayInfoDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case SEQNO : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case WORKER_ID : return getStringInLine(record, 20, 26); // 징수원 ID
|
||||
case FARE_OFFICE_ID : return getStringInLine(record, 26, 28); // 요금소 코드
|
||||
case BOOTH_ID : return getStringInLine(record, 28, 30); // 차로 코드
|
||||
case YEAR : return getStringInLine(record, 30, 34); // 년도
|
||||
case MONTH : return getStringInLine(record, 34, 36); // 월
|
||||
case DAY : return getStringInLine(record, 36, 38); // 일
|
||||
case WORK_TIMES : return getStringInLine(record, 38, 44); // 통행시간
|
||||
case DATA_SEQNO3 : return getStringInLine(record, 44, 53); // 일련번호
|
||||
case CAR_TYPE_ID : return getStringInLine(record, 53, 54); // 차종코드
|
||||
case COLLECT_ID : return getStringInLine(record, 54, 56); // 징수유형 코드
|
||||
case WORK_STT_TIME : return getStringInLine(record, 56, 62); // 근무 시작시간
|
||||
case WORK_END_TIME : return getStringInLine(record, 62, 68); // 근무 종료시간
|
||||
case IN_OUT_KBN : return getStringInLine(record, 68, 69); // 유출입구분
|
||||
case LEVY_AMOUNT : return getStringInLine(record, 69, 75); // 징수금액
|
||||
case CAR_NO : return getStringInLine(record, 75, 95); // 차량번호
|
||||
case DAY_END_FLAG : return getStringInLine(record, 95, 96); // 일마감 Flag
|
||||
case MONTH_END_FLAG : return getStringInLine(record, 96, 97); // 월마감 Flag
|
||||
case NOTE_KBN : return getStringInLine(record, 97, 98); // 수기통행여부
|
||||
case NOTE_REMARKS : return getStringInLine(record, 98, 158); // 수기입력사유
|
||||
case REPAY_KBN : return getStringInLine(record, 158, 159); // 환불여부
|
||||
case RESERVED : return getStringInLine(record, 159, 169); // Filler
|
||||
case E_MARK : return getStringInLine(record, 169, 170); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,81 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
import com.util.StringUtil;
|
||||
/**
|
||||
* RFID 승인정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2006-12-20 초기 작성
|
||||
*/
|
||||
public class RfidDataRecord extends Record{
|
||||
public static final int RECORD_LEN = 53; // 레코드 길이
|
||||
public static final int RFID_TAG = 0; // 태그번호
|
||||
public static final int CAR_NO = 1; // 차량번호
|
||||
public static final int CAR_TYPE_KBN = 2; // 차량유형
|
||||
public static final int WEEK_WRONG_NO = 3; // 위반횟수
|
||||
public static final int DAMAGE_NO = 4; // 훼손횟수
|
||||
|
||||
private String sRfidTag, sCarNo, sCarTypeKbn, nWeekWrongNo, sDamageNo;
|
||||
/**
|
||||
* Constructor
|
||||
* @param record
|
||||
*/
|
||||
public RfidDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
* @param sRfidTag
|
||||
* @param sCarNo
|
||||
* @param sCarTypeKbn
|
||||
* @param nWeekWrongNo
|
||||
* @param nDamageNo
|
||||
*/
|
||||
public RfidDataRecord(String sRfidTag,String sCarNo, String sCarTypeKbn, int nWeekWrongNo, int nDamageNo){
|
||||
this.sRfidTag = sRfidTag;
|
||||
this.sCarNo = StringUtil.justify(StringUtil.LEFT ,sCarNo," ",15);
|
||||
this.sCarTypeKbn = sCarTypeKbn;
|
||||
this.nWeekWrongNo = StringUtil.justify(StringUtil.RIGHT,""+nWeekWrongNo,"0",5);
|
||||
this.sDamageNo = StringUtil.justify(StringUtil.RIGHT,""+nDamageNo,"0",5);
|
||||
}
|
||||
/**
|
||||
* 레코드 정보를 String으로 return
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
@Override
|
||||
public String getRecord() throws IllegalRecordException{
|
||||
String result
|
||||
= new StringBuffer(sRfidTag ) //
|
||||
.append(sCarNo ) //
|
||||
.append(sCarTypeKbn ) //
|
||||
.append(nWeekWrongNo) //
|
||||
.append(sDamageNo ) //
|
||||
.toString();
|
||||
|
||||
if(checkLength(result, RECORD_LEN)){
|
||||
return result;
|
||||
}else{
|
||||
throw new IllegalRecordException(
|
||||
"Cannot create DATA record : [" + result.length() + "] " + result);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case RFID_TAG : return getStringInLine(record, 0,24);
|
||||
case CAR_NO : return getStringInLine(record,24,39).trim();
|
||||
case CAR_TYPE_KBN : return getStringInLine(record,39,43);
|
||||
case WEEK_WRONG_NO : return getStringInLine(record,43,48);
|
||||
case DAMAGE_NO : return getStringInLine(record,48,53);
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,104 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
import com.util.StringUtil;
|
||||
/**
|
||||
* RFID 사용정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class RfidUseDataRecord extends Record{
|
||||
public static final int DATA_TYPE = 99; //
|
||||
public static final int WORKER_ID = 0; // 징수원ID(요금소코드(2)+징수원ID(4))
|
||||
public static final int FARE_OFFICE_ID = 1; // 요금소코드(01:1호터널,03:3호터널)
|
||||
public static final int BOOTH_ID = 2; // 차로코드(01~10)
|
||||
public static final int YEAR = 3; // 통행년도
|
||||
public static final int MONTH = 4; // 통행월
|
||||
public static final int DAY = 5; // 통행일
|
||||
public static final int WORK_TIMES = 6; // 통행시간
|
||||
public static final int SEQNO = 7; // Number
|
||||
public static final int RFID_KBN = 8; // RFID구분
|
||||
public static final int RFID_TAG1 = 9; // 태그번호1
|
||||
public static final int RFID_TAG2 = 10; // 태그번호2
|
||||
|
||||
protected static final int RECORD_LEN = 84;
|
||||
String sDataType, sWorkerID, sFareOfficeID, sBoothID, sYear, sMonth, sDay, sWorkTimes, nSeqNo, sRfidKbn, sRfidTag1, sRfidTag2;
|
||||
/**
|
||||
* 생성자
|
||||
* @param record
|
||||
*/
|
||||
public RfidUseDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* 생성자
|
||||
* @param sWorkerID
|
||||
* @param sFareOfficeID
|
||||
* @param sBoothID
|
||||
* @param sYear
|
||||
* @param sMonth
|
||||
* @param sDay
|
||||
* @param sWorkTimes
|
||||
* @param nSeqNo
|
||||
* @param sRfidKbn
|
||||
* @param sRfidTag1
|
||||
* @param sRfidTag2
|
||||
*/
|
||||
public RfidUseDataRecord(String sDataType,String sWorkerID, String sFareOfficeID,
|
||||
String sBoothID,String sYear, String sMonth, String sDay, String sWorkTimes,
|
||||
int nSeqNo, String sRfidKbn, String sRfidTag1, String sRfidTag2){
|
||||
this.sDataType = sDataType ;
|
||||
this.sWorkerID = sWorkerID ;
|
||||
this.sFareOfficeID = sFareOfficeID ;
|
||||
this.sBoothID = sBoothID ;
|
||||
this.sYear = sYear ;
|
||||
this.sMonth = sMonth ;
|
||||
this.sDay = sDay ;
|
||||
this.sWorkTimes = sWorkTimes ;
|
||||
this.nSeqNo = StringUtil.justify(false, String.valueOf(nSeqNo), "0", 9);
|
||||
this.sRfidKbn = sRfidKbn ;
|
||||
this.sRfidTag1 = sRfidTag1 ;
|
||||
this.sRfidTag2 = sRfidTag2 ;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case DATA_TYPE : return getStringInLine(record, 0, 1); //
|
||||
case WORKER_ID : return getStringInLine(record, 1, 7); // 징수원ID
|
||||
case FARE_OFFICE_ID : return getStringInLine(record, 7, 9); // 요금소코드
|
||||
case BOOTH_ID : return getStringInLine(record, 9,11); // 차로코드
|
||||
case YEAR : return getStringInLine(record,11,15); // 통행년도
|
||||
case MONTH : return getStringInLine(record,15,17); // 통행월
|
||||
case DAY : return getStringInLine(record,17,19); // 통행일
|
||||
case WORK_TIMES : return getStringInLine(record,19,25); // 통행시간
|
||||
case SEQNO : return getStringInLine(record,25,34); // Number
|
||||
case RFID_KBN : return getStringInLine(record,34,36); // RFID구분
|
||||
case RFID_TAG1 : return getStringInLine(record,36,60); // 태그번호1
|
||||
case RFID_TAG2 : return getStringInLine(record,60,84); // 태그번호2
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 레코드 리턴
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
@Override
|
||||
public String getRecord() throws IllegalRecordException{
|
||||
String result = sDataType +sWorkerID + sFareOfficeID + sBoothID + sYear + sMonth + sDay
|
||||
+ sWorkTimes + nSeqNo + sRfidKbn + sRfidTag1 + sRfidTag2;
|
||||
if(checkLength(result, RECORD_LEN)){
|
||||
return result;
|
||||
}else{
|
||||
throw new IllegalRecordException(
|
||||
"Cannot create DATA record : [" + result.length() + "] " + result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,69 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 과오납 시세입 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class TaxesInfoDataRecord extends Record {
|
||||
private int RECORD_LEN = 150; // 레코드 길이
|
||||
public static final int S_MARK = 0; // 시작표시
|
||||
public static final int DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int DATA_TYPE = 2; // 자료구분
|
||||
public static final int DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int SEQNO = 4; // 일련번호
|
||||
public static final int FARE_OFFICE_ID = 5; // 요금소코드
|
||||
public static final int ENTRY_YEAR = 6; // 년도
|
||||
public static final int ENTRY_MONTH = 7; // 월
|
||||
public static final int ENTRY_DAY = 8; // 일
|
||||
public static final int ENTRY_SEQNO = 9; // 일련번호
|
||||
public static final int CITY_TAXES_COUNT = 10; // 시세입 건수
|
||||
public static final int CITY_TAXES_AMOUNT = 11; // 시세입 금액
|
||||
public static final int OVERFARE_YEAR = 12; // 시세입 적용년도
|
||||
public static final int OVERFARE_MONTH = 13; // 시세입 적용월
|
||||
public static final int USER_ID = 14; // 징수원 ID
|
||||
public static final int USER_NAME = 15; // 징수원 명
|
||||
public static final int REMARKS = 16; // 비고
|
||||
public static final int RESERVED = 17; // Filler
|
||||
public static final int E_MARK = 18; // 종료표시
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public TaxesInfoDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case SEQNO : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case FARE_OFFICE_ID : return getStringInLine(record, 20, 22); // 요금소코드
|
||||
case ENTRY_YEAR : return getStringInLine(record, 22, 26); // 년도
|
||||
case ENTRY_MONTH : return getStringInLine(record, 26, 28); // 월
|
||||
case ENTRY_DAY : return getStringInLine(record, 28, 30); // 일
|
||||
case ENTRY_SEQNO : return getStringInLine(record, 30, 32); // 일련번호
|
||||
case CITY_TAXES_COUNT : return getStringInLine(record, 32, 37); // 시세입 건수
|
||||
case CITY_TAXES_AMOUNT : return getStringInLine(record, 37, 46); // 시세입 금액
|
||||
case OVERFARE_YEAR : return getStringInLine(record, 46, 50); // 시세입 적용년도
|
||||
case OVERFARE_MONTH : return getStringInLine(record, 50, 52); // 시세입 적용월
|
||||
case USER_ID : return getStringInLine(record, 52, 58); // 징수원 ID
|
||||
case USER_NAME : return getStringInLine(record, 58, 68); // 징수원 명
|
||||
case REMARKS : return getStringInLine(record, 68, 128); // 비고
|
||||
case RESERVED : return getStringInLine(record, 128, 149); // Filler
|
||||
case E_MARK : return getStringInLine(record, 149, 150); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
package center.data.format;
|
||||
|
||||
import com.base.Record;
|
||||
import com.exception.IllegalRecordException;
|
||||
/**
|
||||
* 과오납 차장정보 데이터 포멧<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class WrongPayCarDataRecord extends Record {
|
||||
private int RECORD_LEN = 270; // 레코드 길이
|
||||
public static final int S_MARK = 0; // 시작표시
|
||||
public static final int DATA_SEQNO1 = 1; // 자료번호
|
||||
public static final int DATA_TYPE = 2; // 자료구분
|
||||
public static final int DATA_SEQNO2 = 3; // 자료번호
|
||||
public static final int SEQNO = 4; // 일련번호
|
||||
public static final int OWNER = 5; // 소유주
|
||||
public static final int CAR_NO = 6; // 차량번호
|
||||
public static final int RESIDENT_DATE = 7; // 등록일자
|
||||
public static final int CAR_TYPE_NAME = 8; // 차종명
|
||||
public static final int RESIDENT_NO = 9; // 주민/법인번호
|
||||
public static final int POST_NO1 = 10; // 우편번호1
|
||||
public static final int POST_NO2 = 11; // 우편번호2
|
||||
public static final int ADDRESS_NAME = 12; // 현주소
|
||||
public static final int ADDRESS_NUMBER = 13; // 현주소 번지
|
||||
public static final int IUD_KBN = 14; // 입력수정구분
|
||||
public static final int RESERVED = 15; // Filler
|
||||
public static final int E_MARK = 16; // 종료표시
|
||||
/**
|
||||
* Counstructor
|
||||
* @param record
|
||||
*/
|
||||
public WrongPayCarDataRecord(String record){
|
||||
this.record = record;
|
||||
}
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case S_MARK : return getStringInLine(record, 0, 1); // 시작표시
|
||||
case DATA_SEQNO1 : return getStringInLine(record, 1, 10); // 자료번호
|
||||
case DATA_TYPE : return getStringInLine(record, 10, 11); // 자료구분
|
||||
case DATA_SEQNO2 : return getStringInLine(record, 11, 17); // 자료번호
|
||||
case SEQNO : return getStringInLine(record, 17, 20); // 일련번호
|
||||
case OWNER : return getStringInLine(record, 20, 50); // 소유주
|
||||
case CAR_NO : return getStringInLine(record, 50, 70); // 차량번호
|
||||
case RESIDENT_DATE : return getStringInLine(record, 70, 78); // 등록일자
|
||||
case CAR_TYPE_NAME : return getStringInLine(record, 78, 118); // 차종명
|
||||
case RESIDENT_NO : return getStringInLine(record, 118, 131); // 주민/법인번호
|
||||
case POST_NO1 : return getStringInLine(record, 131, 135); // 우편번호1
|
||||
case POST_NO2 : return getStringInLine(record, 135, 139); // 우편번호2
|
||||
case ADDRESS_NAME : return getStringInLine(record, 139, 199); // 현주소
|
||||
case ADDRESS_NUMBER : return getStringInLine(record, 199, 259); // 현주소 번지
|
||||
case IUD_KBN : return getStringInLine(record, 259, 260); // 입력수정구분
|
||||
case RESERVED : return getStringInLine(record, 260, 269); // Filler
|
||||
case E_MARK : return getStringInLine(record, 269, 270); // 종료표시
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,220 +0,0 @@
|
||||
package center.green;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import com.base.FileStreamParser;
|
||||
import com.base.FileWorker;
|
||||
import com.util.Log4JLogger;
|
||||
import com.util.Properties;
|
||||
import com.util.StringUtil;
|
||||
|
||||
import center.data.format.PreCardDataRecord;
|
||||
import center.data.format.PreCardDataRecordEB;
|
||||
import center.data.format.RfCardDataRecord;
|
||||
|
||||
public class DayCloseReturnTest extends FileWorker {
|
||||
|
||||
private String strUrl = "";
|
||||
private String strType = "";
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
this.TODAY = StringUtil.getDate("yyyyMMdd");
|
||||
|
||||
this.config = new Properties();
|
||||
try {
|
||||
config.load("/gpta/source-web/cfs/tMoney/NAMSAN/conf/btoll.conf");
|
||||
} catch (IOException ie) {
|
||||
System.err.println("Can not find Configuration file.");
|
||||
System.exit(0);
|
||||
}
|
||||
// log file setting
|
||||
String fileDir = config.getProperty("file.dir");
|
||||
if (fileDir == null) {
|
||||
System.err.println("Can not find Configuration data : file.dir");
|
||||
System.exit(0);
|
||||
}
|
||||
try {
|
||||
logger = new Log4JLogger(fileDir + "MakeData_DayCloseReturn.log");
|
||||
logger.logInfo("=== DayCloseReturn Start ");
|
||||
} catch (Exception e) {
|
||||
logger.logFail("Creating logger is failed.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
this.strUrl = config.getProperty("web.api");
|
||||
}
|
||||
|
||||
public void executeVZ() throws Exception {
|
||||
String sPrcsName = "ApplyResultPreEB";
|
||||
try {
|
||||
|
||||
int nReadCount = 0;
|
||||
System.out.println("=========== executeVZ 1 : " );
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
System.out.println("=========== executeVZ 2 : " );
|
||||
String str = "callDayCloseReturnPrepayEB.do";
|
||||
System.out.println("=========== executeVZ 3 : " );
|
||||
map.put("refuse", "32");
|
||||
System.out.println("=========== executeVZ 4 : " );
|
||||
|
||||
System.err.println("================= AAAA ");
|
||||
System.err.println(strUrl + str);
|
||||
str = callWebServicePostJson(strUrl + str, map);
|
||||
System.out.println(".... File Read Count : " + nReadCount);
|
||||
System.out.println(sPrcsName + " is ended");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.out.println(sPrcsName + " apply fail");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
private void applyRefuseDataWJ(RfCardDataRecord record) throws SQLException, Exception {
|
||||
|
||||
String sTransactionID = "";
|
||||
String sTradeTime = "";
|
||||
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put("worker_id", sTransactionID.substring(0, 6));
|
||||
map.put("fare_id", sTransactionID.substring(0, 2));
|
||||
map.put("booth_id", sTransactionID.substring(6, 8));
|
||||
map.put("year", sTradeTime.substring(0, 4));
|
||||
map.put("month", sTradeTime.substring(4, 6));
|
||||
map.put("day", sTradeTime.substring(6, 8));
|
||||
map.put("work_times", sTradeTime.substring(8, 14));
|
||||
|
||||
System.out.println("=========== applyRefuseDataWJ 1 ");
|
||||
String str = "insertDayCloseReturnPostpay.do";
|
||||
map.put("refuse", "22");
|
||||
|
||||
System.out.println("=========== applyRefuseDataWJ 2 ");
|
||||
str = callWebServicePostJson(strUrl + str, map);
|
||||
System.out.println("=========== applyRefuseDataWJ 3 ");
|
||||
System.out.println(str);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private String callWebServicePostJson(String uri, Map<String, String> map) {
|
||||
HttpURLConnection connection = null;
|
||||
|
||||
System.out.println("callWebServicePostJson uri : " + uri );
|
||||
JSONObject jsonParam = new JSONObject();
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
jsonParam.put(entry.getKey().toString(), entry.getValue().toString());
|
||||
System.out.println("key : " + entry.getKey() + " , value : " + entry.getValue());
|
||||
}
|
||||
|
||||
String param = jsonParam.toString();
|
||||
|
||||
InputStream is = null;
|
||||
InputStreamReader isr = null;
|
||||
BufferedReader br = null;
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
try {
|
||||
URL url = new URL(uri);
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setRequestMethod("POST");
|
||||
// 요청응답 타임아웃 설정
|
||||
connection.setConnectTimeout(60 * 1000); // 30 sec
|
||||
// 읽기 타임아웃 설정
|
||||
connection.setReadTimeout(60 * 1000);
|
||||
// connection.setAllowUserInteraction(true);
|
||||
|
||||
// Http Header Setting
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
|
||||
// Http Parameter Sending
|
||||
BufferedOutputStream bos = new BufferedOutputStream(connection.getOutputStream());
|
||||
bos.write(param.getBytes("UTF-8"));
|
||||
bos.flush();
|
||||
bos.close();
|
||||
|
||||
int resCode = connection.getResponseCode();
|
||||
String inputLine = null;
|
||||
|
||||
System.out.println("==== resCode : " + resCode);
|
||||
if (resCode == HttpsURLConnection.HTTP_OK) {
|
||||
is = connection.getInputStream();
|
||||
isr = new InputStreamReader(is, "UTF-8");
|
||||
br = new BufferedReader(isr);
|
||||
|
||||
while ((inputLine = br.readLine()) != null) {
|
||||
sb.append(inputLine);
|
||||
}
|
||||
|
||||
// System.out.println("==== " + sb.toString());
|
||||
} else {
|
||||
if (connection.getErrorStream() != null) {
|
||||
br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
|
||||
|
||||
while ((inputLine = br.readLine()) != null) {
|
||||
sb.append(inputLine);
|
||||
}
|
||||
|
||||
System.out.println("==== Http Error Resopnse : " + sb.toString());
|
||||
} else {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (is != null)
|
||||
is.close();
|
||||
if (isr != null)
|
||||
isr.close();
|
||||
if (br != null)
|
||||
br.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.err.println("=========================");
|
||||
if(args.length < 3) {
|
||||
System.err.println("총 3개의 args를 입력하지 않았습니다.");
|
||||
System.err.println("sType, sFileDir, sFileName");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
DayCloseReturnTest obj = new DayCloseReturnTest();
|
||||
|
||||
try {
|
||||
obj.initialize();
|
||||
obj.executeVZ();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
package center.green;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.util.Properties;
|
||||
|
||||
public class RunProc {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//System.setProperty("java.net.preferIPv4Stack", "true");
|
||||
|
||||
if(args.length == 0) {
|
||||
System.err.println("args를 입력하지 않았습니다.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
String runGubun = args[0];
|
||||
System.out.println("============== 1");
|
||||
if(runGubun.equals("0") == true) {
|
||||
DayCloseApi obj = new DayCloseApi();
|
||||
System.out.println("============== 2");
|
||||
obj.initialize();
|
||||
obj.execute();
|
||||
System.out.println("============== 3");
|
||||
}
|
||||
else if(runGubun.equals("1") == true) {
|
||||
System.out.println("============== 4");
|
||||
Properties config = new Properties();
|
||||
try {
|
||||
config.load("/gpta/source-web/cfs/tMoney/NAMSAN/conf/btoll.conf");
|
||||
}
|
||||
catch (IOException ie) {
|
||||
System.err.println("Can not find Configuration file.");
|
||||
System.exit(0);
|
||||
}
|
||||
// log file setting
|
||||
String fileDir = config.getProperty( "file.dir" );
|
||||
if(fileDir == null){
|
||||
System.out.println("Can not find Configuration data : file.dir");
|
||||
System.exit(0);
|
||||
}
|
||||
try{
|
||||
System.out.println("MakeData.log");
|
||||
}catch(Exception e){
|
||||
System.out.println("Creating logger is failed.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
System.out.println("============== 5");
|
||||
TMSendClientGreen obj = new TMSendClientGreen(config);
|
||||
obj.startup();
|
||||
System.out.println("============== 6");
|
||||
}
|
||||
else
|
||||
System.out.println("=== 잘못된 파라미터 입력 ");
|
||||
|
||||
System.out.println("============== 7");
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,83 +0,0 @@
|
||||
package center.green;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public class test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
String str = "123하1234";
|
||||
// default charset으로 인코딩된 바이트 배열
|
||||
byte[] bytes = str.getBytes();
|
||||
// 인코딩된 바이트 출력
|
||||
System.out.print("Default charset encoding: ");
|
||||
|
||||
System.out.println();
|
||||
// default charset으로 디코딩된 문자열 출력
|
||||
String decoded = new String(bytes);
|
||||
System.out.println(decoded);
|
||||
|
||||
System.out.println();
|
||||
try {
|
||||
// UTF-8로 인코딩된 바이트 배열
|
||||
bytes = str.getBytes("UTF-8");
|
||||
System.out.print("UTF-8 charset encoding: ");
|
||||
for (int i = 0; i < bytes.length; i++)
|
||||
System.out.print(bytes[i] + " ");
|
||||
System.out.println();
|
||||
// 이 바이트 배열을 default charset으로 디코딩된 문자열 출력 : charset이 다르므로 한글이 깨짐.
|
||||
decoded = new String(bytes);
|
||||
System.out.println(decoded);
|
||||
// 인코딩된 UTF-8로 디코딩되어 한글이 깨지지 않음.
|
||||
decoded = new String(bytes, "UTF-8");
|
||||
System.out.println(decoded);
|
||||
|
||||
System.out.println("================= ");
|
||||
|
||||
// euc-kr로 인코딩된 바이트 배열
|
||||
bytes = str.getBytes("euc-kr");
|
||||
System.out.println(bytes.length);
|
||||
System.out.print("euc-kr charset encoding: ");
|
||||
for (int i = 0; i < bytes.length; i++)
|
||||
System.out.print(bytes[i] + " ");
|
||||
System.out.println();
|
||||
// 이 바이트 배열을 default charset으로 디코딩된 문자열 출력 : charset이 다르므로 한글이 깨짐.
|
||||
decoded = new String(bytes);
|
||||
System.out.println(decoded);
|
||||
System.out.println(decoded.getBytes().length);
|
||||
// 인코딩된 UTF-8로 디코딩되어 한글이 깨지지 않음.
|
||||
decoded = new String(bytes, "euc-kr");
|
||||
System.out.println(decoded);
|
||||
|
||||
System.out.println(decoded.getBytes().length);
|
||||
|
||||
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
try{
|
||||
File file = new File("./aaa.txt");
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
baos.write(bytes, 0, bytes.length);;
|
||||
|
||||
fos.write(baos.toByteArray());
|
||||
fos.close();
|
||||
|
||||
baos.close();
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace(System.out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,176 +0,0 @@
|
||||
package center.online;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.exception.AppException;
|
||||
import com.util.Log4JLogger;
|
||||
import com.util.Properties;
|
||||
import com.util.StringUtil;
|
||||
|
||||
import center.transfer.Constant;
|
||||
/**
|
||||
* 데이터 수신 서버 공통 클래스
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class OnCommon {
|
||||
|
||||
protected Properties config;
|
||||
protected String ip;
|
||||
protected int port;
|
||||
protected Log4JLogger logger;
|
||||
protected InputStream reader;
|
||||
protected OutputStream writer;
|
||||
|
||||
protected Socket sock = null;
|
||||
protected ServerSocket serverSocket;
|
||||
protected int logLevel = 3;
|
||||
|
||||
protected int TIME_OUT = 1 * 60 * 1000;
|
||||
|
||||
/**
|
||||
* DB Connection 처리
|
||||
*/
|
||||
protected final Connection getConnection() throws Exception {
|
||||
//String driver = config.getProperty("db.driver");
|
||||
String url = config.getProperty("db.url");
|
||||
String user = config.getProperty("db.user");
|
||||
String password = config.getProperty("db.password");
|
||||
// 드라이버 로드 위치 변경. --> OnServer01.startup()
|
||||
//try {
|
||||
// Class.forName(driver);
|
||||
//} catch(ClassNotFoundException cnfe) {
|
||||
// throw new Exception("ClassNotFoundException : " + driver);
|
||||
//}
|
||||
|
||||
try {
|
||||
return DriverManager.getConnection(url, user, password);
|
||||
} catch(SQLException se) {
|
||||
se.printStackTrace();
|
||||
throw new AppException("Cannot get connection : " + url);
|
||||
}
|
||||
}
|
||||
|
||||
/* 전문 생성 */
|
||||
protected String makeMessage(String sMsgCode, int nLength, String sReturnCode, String sMessage) {
|
||||
String sLength = StringUtil.justify(StringUtil.RIGHT, String.valueOf(nLength) ,"0", 4);
|
||||
return "S" + sMsgCode + sLength + sReturnCode + sMessage + "E";
|
||||
}
|
||||
|
||||
/* 메시지를 전송한다. */
|
||||
protected final void sendMessage(String sMessage) throws IOException {
|
||||
writer.write(sMessage.getBytes());
|
||||
writer.flush();
|
||||
if (logger != null) {
|
||||
logger.logInfo("SEND [" + sMessage + "]");
|
||||
}
|
||||
}
|
||||
|
||||
/** 메시지를 수신시데이터작부를 검사한다. */
|
||||
protected final boolean checkSTX() throws IOException {
|
||||
byte[] buf = new byte[1];
|
||||
reader.read(buf, 0, 1);
|
||||
return 'S' == buf[0] ? true : false;
|
||||
}
|
||||
|
||||
/** 메시지를 수신데이터마지막부를 검사한다. */
|
||||
protected final boolean checkETX() throws IOException {
|
||||
byte[] buf = new byte[1];
|
||||
reader.read(buf, 0, 1);
|
||||
return 'E' == buf[0] ? true : false;
|
||||
}
|
||||
|
||||
/** 메시지를 수신한다. */
|
||||
protected final String recvMessage(int nLength) throws IOException {
|
||||
byte[] buf = new byte[nLength];
|
||||
int start = 0, reads = 0, length = nLength;
|
||||
|
||||
do {
|
||||
start += reads;
|
||||
length -= reads;
|
||||
reads = reader.read(buf, start, length);
|
||||
|
||||
if (reads < 0) {
|
||||
throw new IOException("read past eof.");
|
||||
}
|
||||
} while (reads < length);
|
||||
|
||||
String sMessage = new String(buf,0, nLength);
|
||||
|
||||
if (logger != null) {
|
||||
logger.logInfo("RECV [" + sMessage + "]");
|
||||
}
|
||||
return sMessage;
|
||||
}
|
||||
/**
|
||||
* 디버그 모드로 로그 출력
|
||||
* @param message
|
||||
*/
|
||||
protected final void logDebug(String message) {
|
||||
if (logLevel >= Constant.LOGLEVEL_DEBUG) {
|
||||
logger.logDebug(message);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 디버그 모드로 예외 출력
|
||||
* @param message
|
||||
*/
|
||||
protected final void logDebug(Exception ex) {
|
||||
if (logLevel >= Constant.LOGLEVEL_DEBUG) {
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 정보 모드로 로그 출력
|
||||
* @param message
|
||||
*/
|
||||
protected final void logInfo(String message) {
|
||||
if (logLevel >= Constant.LOGLEVEL_INFO) {
|
||||
logger.logInfo(message);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 경고 모드로 로그 출력
|
||||
* @param message
|
||||
*/
|
||||
protected final void logWarn(String message) {
|
||||
if (logLevel >= Constant.LOGLEVEL_WARN) {
|
||||
logger.logWarn(message);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 경고 모드로 예외 출력
|
||||
* @param message
|
||||
*/
|
||||
protected final void logWarn(Exception ex) {
|
||||
if (logLevel >= Constant.LOGLEVEL_WARN) {
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 장애 모드로 로그 출력
|
||||
* @param message
|
||||
*/
|
||||
protected final void logFail(String message) {
|
||||
if (logLevel >= Constant.LOGLEVEL_ERROR) {
|
||||
logger.logFail(message);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 장애 모드로 예외 출력
|
||||
* @param message
|
||||
*/
|
||||
protected final void logFail(Exception ex) {
|
||||
if (logLevel >= Constant.LOGLEVEL_ERROR) {
|
||||
logger.logTrace(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,226 +0,0 @@
|
||||
package center.online;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.SocketException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.util.Log4JLogger;
|
||||
import com.util.Properties;
|
||||
|
||||
import center.online.process.DefaultFareReadInfo;
|
||||
import center.online.process.FareAdjustInfo;
|
||||
import center.online.process.FareTerminalInfo;
|
||||
import center.online.process.RFRepayInfo;
|
||||
import center.online.process.RFTerminalInfo;
|
||||
/**
|
||||
* 남산 1호로부터 실시간 데이터 수신
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class OnServer01 extends OnCommon {
|
||||
|
||||
private String sServerCode = "01";
|
||||
|
||||
public OnServer01(Properties config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* startup
|
||||
*/
|
||||
public void startup() {
|
||||
|
||||
// Logger Create
|
||||
try {
|
||||
String sLogDir = config.getProperty( "log.dir" );
|
||||
this.logger = new Log4JLogger( sLogDir + "OnServer_"+sServerCode+".log" );
|
||||
// 로그 레벨 지정
|
||||
String sLogLevel = config.getProperty( "log.level" );
|
||||
if( sLogLevel != null ) this.logLevel = Integer.parseInt( sLogLevel );
|
||||
} catch ( Exception e ) {
|
||||
System.out.println( "로거를 생성하지 못했습니다.\n" + e.getMessage() );
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try{
|
||||
this.port = Integer.parseInt(config.getProperty( "server_"+sServerCode+".port" ));
|
||||
} catch(Exception e) {
|
||||
logger.logFail("ERROR : 서버 포트번호가 지정되지 않았습니다.");
|
||||
System.exit(1);
|
||||
}
|
||||
// db driver setting
|
||||
String driver = null;
|
||||
try{
|
||||
driver = config.getProperty("db.driver");
|
||||
if( driver == null ) throw new Exception ();
|
||||
}catch(Exception e){
|
||||
System.err.println("ERROR : DB driver가 지정되지 않았습니다.");
|
||||
System.exit(1);
|
||||
}
|
||||
try{
|
||||
Class.forName(driver);
|
||||
}catch(ClassNotFoundException cnfe){
|
||||
System.err.println("ClassNotFoundException : " + driver);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
public void run() {
|
||||
try{
|
||||
serverSocket = new ServerSocket(port);
|
||||
while (true) {
|
||||
try {
|
||||
sock = serverSocket.accept();
|
||||
sock.setSoTimeout(TIME_OUT);
|
||||
|
||||
// logInfo(sock.toString()); // 접근 IP check
|
||||
reader = sock.getInputStream();
|
||||
writer = sock.getOutputStream();
|
||||
execute();
|
||||
} catch (SocketException se ) {
|
||||
logFail( se.getMessage() );
|
||||
} catch (IOException ie ) {
|
||||
logFail( ie );
|
||||
} catch(Exception ex ){
|
||||
logFail( ex );
|
||||
} finally{
|
||||
try { if(reader!=null) reader.close(); } catch (Exception e) {}
|
||||
try { if(writer!=null) writer.close(); } catch (Exception e) {}
|
||||
try { if(sock!=null) sock.close(); } catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
System.out.println("Exception port:"+port);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 온라인 메시지 수신 로직
|
||||
* @throws IOException
|
||||
* @throws Exception
|
||||
*/
|
||||
public void execute() throws IOException, Exception{
|
||||
String sReturn = null;
|
||||
Connection conn = null;
|
||||
String sMsgComm = null;
|
||||
String sMsgData = null;
|
||||
String sMsgCode = null;
|
||||
String sMsgSize = null;
|
||||
|
||||
try {
|
||||
FareTerminalInfo fareTerminal = new FareTerminalInfo();
|
||||
FareAdjustInfo fareAdjust = new FareAdjustInfo();
|
||||
RFTerminalInfo rfTerminal = new RFTerminalInfo();
|
||||
DefaultFareReadInfo defaultFareRead = new DefaultFareReadInfo();
|
||||
RFRepayInfo rfRepayInfo = new RFRepayInfo();
|
||||
|
||||
conn = this.getConnection();
|
||||
|
||||
while (true) {
|
||||
if (checkSTX() == false) return; //continue;
|
||||
sMsgComm = recvMessage(10);
|
||||
sMsgCode = sMsgComm.substring(0, 3);
|
||||
sMsgSize = sMsgComm.substring(3, 7);
|
||||
//String sRtnCode = sMsgComm.substring(7,10);
|
||||
|
||||
int nSize;
|
||||
try {
|
||||
nSize = Integer.parseInt(sMsgSize);
|
||||
} catch (Exception e) {
|
||||
sReturn = "800"; // 전문 오류
|
||||
throw e;
|
||||
}
|
||||
|
||||
sMsgData = recvMessage(Integer.parseInt(sMsgSize));
|
||||
if (checkETX() == false) {
|
||||
logFail("전송 레코드의 끝표시값이 이상합니다.");
|
||||
return ; //break;
|
||||
}
|
||||
|
||||
try {
|
||||
if( sMsgCode.equals("001")) // Fare_Terminal_Info
|
||||
sReturn = fareTerminal.applyData(sMsgData, logger, conn);
|
||||
else if( sMsgCode.equals("002")) // Fare_Adjust_Info
|
||||
sReturn = fareAdjust.applyData(sMsgData, logger, conn);
|
||||
else if( sMsgCode.equals("003")) // RF_Terminal_Info
|
||||
sReturn = rfTerminal.applyData(sMsgData, logger, conn);
|
||||
else if( sMsgCode.equals("004")) // Default_Fare_Read_Info
|
||||
sReturn = defaultFareRead.applyData(sMsgData, logger, conn);
|
||||
else if( sMsgCode.equals("005")) // RF_Repay_INFO
|
||||
sReturn = rfRepayInfo.applyData(sMsgData, logger, conn);
|
||||
else
|
||||
sReturn = "800"; // 전문 오류
|
||||
} catch (SQLException ex) {
|
||||
int ERROR_CODE = ex.getErrorCode();
|
||||
if(ERROR_CODE==1){
|
||||
sReturn = "001"; // 무결성 제약 조건 ERROR
|
||||
}else{
|
||||
sReturn = "900"; // SQLException
|
||||
logFail("[ERROR 900] " + ex.getMessage());
|
||||
logFail("[ERROR 900] " + sMsgData );
|
||||
logFail(ex);
|
||||
}
|
||||
}
|
||||
|
||||
sendMessage( makeMessage(sMsgCode, 0 ,sReturn, "") );
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
sendMessage( makeMessage( sMsgCode, 0 ,"999", "") );
|
||||
logFail("[ERROR 999] " + ex.getMessage());
|
||||
logFail("[ERROR 999] [" + sMsgComm + sMsgData +"]");
|
||||
logFail(ex);
|
||||
throw ex;
|
||||
} finally {
|
||||
try { if( conn != null ) conn.close(); } catch(Exception e) {}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Help 메시지 출력
|
||||
*/
|
||||
public static void showHelp(String sClass) {
|
||||
System.err.println("Command :");
|
||||
System.err.println("\tjava" + " -Donline.conf=CONFIG_FILE " + sClass);
|
||||
System.err.println("");
|
||||
}
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
if(args.length != 0){
|
||||
showHelp("center.online.OnServer01");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
String sConfFile = System.getProperty("online.conf");
|
||||
if (sConfFile == null) {
|
||||
showHelp("center.online.OnServer01");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Properties config = new Properties();
|
||||
try {
|
||||
config.load(sConfFile);
|
||||
}
|
||||
catch (IOException ie) {
|
||||
System.err.println("환경파일을 읽어 들일 수 없습니다.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
OnServer01 server = new OnServer01(config);
|
||||
server.startup();
|
||||
server.run();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println("데몬을 구동하는데 실패했습니다.");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,226 +0,0 @@
|
||||
package center.online;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.SocketException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.util.Log4JLogger;
|
||||
import com.util.Properties;
|
||||
|
||||
import center.online.process.DefaultFareReadInfo;
|
||||
import center.online.process.FareAdjustInfo;
|
||||
import center.online.process.FareTerminalInfo;
|
||||
import center.online.process.RFRepayInfo;
|
||||
import center.online.process.RFTerminalInfo;
|
||||
/**
|
||||
* 남산 3호로부터 실시간 데이터 수신
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class OnServer03 extends OnCommon {
|
||||
|
||||
private String sServerCode = "03";
|
||||
|
||||
public OnServer03(Properties config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* startup
|
||||
*/
|
||||
public void startup() {
|
||||
// Logger Create
|
||||
try {
|
||||
String sLogDir = config.getProperty( "log.dir" );
|
||||
this.logger = new Log4JLogger( sLogDir + "OnServer_"+sServerCode+".log" );
|
||||
// 로그 레벨 지정
|
||||
String sLogLevel = config.getProperty( "log.level" );
|
||||
if( sLogLevel != null ) this.logLevel = Integer.parseInt( sLogLevel );
|
||||
} catch ( Exception e ) {
|
||||
System.out.println( "로거를 생성하지 못했습니다.\n" + e.getMessage() );
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try{
|
||||
this.port = Integer.parseInt(config.getProperty( "server_"+sServerCode+".port" ));
|
||||
} catch(Exception e) {
|
||||
logger.logFail("ERROR : 서버 포트번호가 지정되지 않았습니다.");
|
||||
System.exit(1);
|
||||
}
|
||||
// db driver setting
|
||||
String driver = null;
|
||||
try{
|
||||
driver = config.getProperty("db.driver");
|
||||
if( driver == null ) throw new Exception ();
|
||||
}catch(Exception e){
|
||||
System.err.println("ERROR : DB driver가 지정되지 않았습니다.");
|
||||
System.exit(1);
|
||||
}
|
||||
try{
|
||||
Class.forName(driver);
|
||||
}catch(ClassNotFoundException cnfe){
|
||||
System.err.println("ClassNotFoundException : " + driver);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 실행
|
||||
*/
|
||||
public void run() {
|
||||
try{
|
||||
serverSocket = new ServerSocket(port);
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
sock = serverSocket.accept();
|
||||
sock.setSoTimeout(TIME_OUT);
|
||||
|
||||
// logInfo(sock.toString()); // 접근 IP check
|
||||
reader = sock.getInputStream();
|
||||
writer = sock.getOutputStream();
|
||||
execute();
|
||||
} catch (SocketException se ) {
|
||||
logFail( se.getMessage() );
|
||||
} catch (IOException ie ) {
|
||||
logFail( ie );
|
||||
} catch(Exception ex ){
|
||||
logFail( ex );
|
||||
} finally{
|
||||
try { if(reader!=null) reader.close(); } catch (Exception e) {}
|
||||
try { if(writer!=null) writer.close(); } catch (Exception e) {}
|
||||
try { if(sock!=null) sock.close(); } catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
System.out.println("Exception port:"+port);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 온라인 메시지 수신 로직
|
||||
* @throws IOException
|
||||
* @throws Exception
|
||||
*/
|
||||
public void execute() throws IOException, Exception{
|
||||
String sReturn = null;
|
||||
Connection conn = null;
|
||||
String sMsgComm = null;
|
||||
String sMsgData = null;
|
||||
String sMsgCode = null;
|
||||
String sMsgSize = null;
|
||||
|
||||
try {
|
||||
FareTerminalInfo fareTerminal = new FareTerminalInfo();
|
||||
FareAdjustInfo fareAdjust = new FareAdjustInfo();
|
||||
RFTerminalInfo rfTerminal = new RFTerminalInfo();
|
||||
DefaultFareReadInfo defaultFareRead = new DefaultFareReadInfo();
|
||||
RFRepayInfo rfRepayInfo = new RFRepayInfo();
|
||||
|
||||
conn = this.getConnection();
|
||||
|
||||
while (true) {
|
||||
if (checkSTX() == false) return; //continue;
|
||||
sMsgComm = recvMessage(10);
|
||||
sMsgCode = sMsgComm.substring(0, 3);
|
||||
sMsgSize = sMsgComm.substring(3, 7);
|
||||
//String sRtnCode = sMsgComm.substring(7,10);
|
||||
|
||||
int nSize;
|
||||
try {
|
||||
nSize = Integer.parseInt(sMsgSize);
|
||||
} catch (Exception e) {
|
||||
sReturn = "800"; // 전문 오류
|
||||
throw e;
|
||||
}
|
||||
|
||||
sMsgData = recvMessage(Integer.parseInt(sMsgSize));
|
||||
if (checkETX() == false) {
|
||||
logFail("전송 레코드의 끝표시값이 이상합니다.");
|
||||
return ; //break;
|
||||
}
|
||||
|
||||
try {
|
||||
if( sMsgCode.equals("001")) // Fare_Terminal_Info
|
||||
sReturn = fareTerminal.applyData(sMsgData, logger, conn);
|
||||
else if( sMsgCode.equals("002")) // Fare_Adjust_Info
|
||||
sReturn = fareAdjust.applyData(sMsgData, logger, conn);
|
||||
else if( sMsgCode.equals("003")) // RF_Terminal_Info
|
||||
sReturn = rfTerminal.applyData(sMsgData, logger, conn);
|
||||
else if( sMsgCode.equals("004")) // Default_Fare_Read_Info
|
||||
sReturn = defaultFareRead.applyData(sMsgData, logger, conn);
|
||||
else if( sMsgCode.equals("005")) // RF_Repay_INFO
|
||||
sReturn = rfRepayInfo.applyData(sMsgData, logger, conn);
|
||||
else
|
||||
sReturn = "800"; // 전문 오류
|
||||
} catch (SQLException ex) {
|
||||
int ERROR_CODE = ex.getErrorCode();
|
||||
if(ERROR_CODE==1){
|
||||
sReturn = "001"; // 무결성 제약 조건 ERROR
|
||||
}else{
|
||||
sReturn = "900"; // SQLException
|
||||
logFail("[ERROR 900] " + ex.getMessage());
|
||||
logFail("[ERROR 900] " + sMsgData );
|
||||
logFail(ex);
|
||||
}
|
||||
}
|
||||
|
||||
sendMessage( makeMessage(sMsgCode, 0 ,sReturn, "") );
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
sendMessage( makeMessage( sMsgCode, 0 ,"999", "") );
|
||||
logFail("[ERROR 999] " + ex.getMessage());
|
||||
logFail("[ERROR 999] [" + sMsgComm + sMsgData +"]");
|
||||
logFail(ex);
|
||||
throw ex;
|
||||
} finally {
|
||||
try { if( conn != null ) conn.close(); } catch(Exception e) {}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Help 메시지 출력
|
||||
*/
|
||||
public static void showHelp(String sClass) {
|
||||
System.err.println("Command :");
|
||||
System.err.println("\tjava" + " -Donline.conf=CONFIG_FILE " + sClass);
|
||||
System.err.println("");
|
||||
}
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
if(args.length != 0){
|
||||
showHelp("center.online.OnServer03");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
String sConfFile = System.getProperty("online.conf");
|
||||
if (sConfFile == null) {
|
||||
showHelp("center.online.OnServer03");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Properties config = new Properties();
|
||||
try {
|
||||
config.load(sConfFile);
|
||||
}
|
||||
catch (IOException ie) {
|
||||
System.err.println("환경파일을 읽어 들일 수 없습니다.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
OnServer03 server = new OnServer03(config);
|
||||
server.startup();
|
||||
server.run();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println("데몬을 구동하는데 실패했습니다.");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,150 +0,0 @@
|
||||
package center.online.process;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.exception.IllegalRecordException;
|
||||
import com.util.Log4JLogger;
|
||||
/**
|
||||
* 미납차량 판독정보 데이터 실시간 반영<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class DefaultFareReadInfo {
|
||||
|
||||
private byte [] record;
|
||||
private StringBuffer sbInsert = new StringBuffer();
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public DefaultFareReadInfo(){
|
||||
sbInsert.append("INSERT INTO DEFAULT_FARE_READ_INFO ( WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, ");
|
||||
sbInsert.append(" DAY, WORK_TIMES, SEQNO, COLLECT_ID, READING_ID, CARS_MOVE_PICTURE_FILE, CARS_STOP_PICTURE_FILE, ");
|
||||
sbInsert.append(" CAR_NO, READING_DATE, X_POSITION, Y_POSITION, GARO_LEN, SERO_LEN, CREATE_DATE, CREATER, ");
|
||||
sbInsert.append(" UPDATE_DATE, UPDATER ");
|
||||
sbInsert.append(") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,TO_DATE(?,'yyyymmddhh24miss'),?,?,?,?, ");
|
||||
sbInsert.append(" SYSDATE, 'ONLINEPROC', SYSDATE, 'ONLINEPROC')");
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param sData
|
||||
* @param logger
|
||||
* @param conn
|
||||
* @return String
|
||||
* @throws SQLException
|
||||
* @throws Exception
|
||||
*/
|
||||
public String applyData(String sData, Log4JLogger logger, Connection conn) throws SQLException, Exception{
|
||||
PreparedStatement psInsert = null;
|
||||
|
||||
try{
|
||||
record = sData.getBytes();
|
||||
// 송신 파일 정보 등록
|
||||
int idx = 1;
|
||||
psInsert = conn.prepareStatement(sbInsert.toString());
|
||||
psInsert.setString(idx ++, getItem(WORKER_ID ) ); // 근무자 ID
|
||||
psInsert.setString(idx ++, getItem(FARE_OFFICE_ID ) ); // 요금소 코드
|
||||
psInsert.setString(idx ++, getItem(BOOTH_ID ) ); // 차로코드
|
||||
psInsert.setString(idx ++, getItem(YEAR ) ); // 년도
|
||||
psInsert.setString(idx ++, getItem(MONTH ) ); // 월
|
||||
psInsert.setString(idx ++, getItem(DAY ) ); // 일
|
||||
psInsert.setString(idx ++, getItem(WORK_TIMES ) ); // 근무시간
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(SEQNO ))); // 일련번호
|
||||
psInsert.setString(idx ++, getItem(COLLECT_ID ) ); // 징수유형코드
|
||||
psInsert.setString(idx ++, getItem(READING_ID ) ); // 판독구분 코드
|
||||
psInsert.setString(idx ++, getItem(CARS_MOVE_PICTURE_FILE).trim() ); // 차량 동영상 정보
|
||||
psInsert.setString(idx ++, getItem(CARS_STOP_PICTURE_FILE).trim() ); // 차량 정지화상 정보
|
||||
psInsert.setString(idx ++, getItem(CAR_NO ).trim() ); // 차량번호
|
||||
psInsert.setString(idx ++, getItem(READING_DATE ) ); // 판독일자
|
||||
String sXPos = getItem(X_POSITION);
|
||||
String sYPos = getItem(Y_POSITION);
|
||||
String sXLen = getItem(GARO_LEN);
|
||||
String sYLen = getItem(SERO_LEN);
|
||||
if( sXPos.indexOf(" ") < 0 ) {
|
||||
psInsert.setInt (idx ++ , Integer.parseInt( sXPos ) ); // X좌표
|
||||
}else{
|
||||
psInsert.setString (idx ++ , null );
|
||||
}
|
||||
if( sYPos.indexOf(" ") < 0 ) {
|
||||
psInsert.setInt (idx ++ , Integer.parseInt( sYPos ) ); // Y좌표
|
||||
}else{
|
||||
psInsert.setString (idx ++ , null );
|
||||
}
|
||||
if( sXLen.indexOf(" ") < 0 ) {
|
||||
psInsert.setInt (idx ++ , Integer.parseInt( sXLen ) ); // 가로길이
|
||||
}else{
|
||||
psInsert.setString (idx ++ , null );
|
||||
}
|
||||
if( sYLen.indexOf(" ") < 0 ) {
|
||||
psInsert.setInt (idx ++ , Integer.parseInt( sYLen ) ); // 세로길이
|
||||
}else{
|
||||
psInsert.setString (idx ++ , null );
|
||||
}
|
||||
|
||||
psInsert.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
}catch(SQLException sqle){
|
||||
logger.logDebug(sbInsert.toString());
|
||||
throw sqle;
|
||||
}catch(Exception ex){
|
||||
throw ex;
|
||||
}finally{
|
||||
if(psInsert != null){ try{ psInsert.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
|
||||
return "000";
|
||||
}
|
||||
private static final int WORKER_ID = 0; // 근무자 ID
|
||||
private static final int FARE_OFFICE_ID = 1; // 요금소 코드
|
||||
private static final int BOOTH_ID = 2; // 차로코드
|
||||
private static final int YEAR = 3; // 년도
|
||||
private static final int MONTH = 4; // 월
|
||||
private static final int DAY = 5; // 일
|
||||
private static final int WORK_TIMES = 6; // 근무시간
|
||||
private static final int SEQNO = 7; // 일련번호
|
||||
private static final int COLLECT_ID = 8; // 징수유형코드
|
||||
private static final int READING_ID = 9; // 판독구분 코드
|
||||
private static final int CARS_MOVE_PICTURE_FILE = 10; // 차량 동영상 정보
|
||||
private static final int CARS_STOP_PICTURE_FILE = 11; // 차량 정지화상 정보
|
||||
private static final int CAR_NO = 12; // 차량번호
|
||||
private static final int READING_DATE = 13; // 판독일자
|
||||
private static final int X_POSITION = 14; // X좌표
|
||||
private static final int Y_POSITION = 15; // Y좌표
|
||||
private static final int GARO_LEN = 16; // 가로길이
|
||||
private static final int SERO_LEN = 17; // 세로길이
|
||||
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case WORKER_ID : return new String(record, 0, 6); // 근무자 ID
|
||||
case FARE_OFFICE_ID : return new String(record, 6, 2); // 요금소 코드
|
||||
case BOOTH_ID : return new String(record, 8, 2); // 차로코드
|
||||
case YEAR : return new String(record, 10, 4); // 년도
|
||||
case MONTH : return new String(record, 14, 2); // 월
|
||||
case DAY : return new String(record, 16, 2); // 일
|
||||
case WORK_TIMES : return new String(record, 18, 6); // 근무시간
|
||||
case SEQNO : return new String(record, 24, 9); // 일련번호
|
||||
case COLLECT_ID : return new String(record, 33, 2); // 징수유형코드
|
||||
case READING_ID : return new String(record, 35, 2); // 판독구분 코드
|
||||
case CARS_MOVE_PICTURE_FILE : return new String(record, 37, 50); // 차량 동영상 정보
|
||||
case CARS_STOP_PICTURE_FILE : return new String(record, 87, 50); // 차량 정지화상 정보
|
||||
case CAR_NO : return new String(record, 137, 20); // 차량번호
|
||||
case READING_DATE : return new String(record, 157, 14); // 판독일자
|
||||
case X_POSITION : return new String(record, 171, 3); // X좌표
|
||||
case Y_POSITION : return new String(record, 174, 3); // Y좌표
|
||||
case GARO_LEN : return new String(record, 177, 3); // 가로길이
|
||||
case SERO_LEN : return new String(record, 180, 3); // 세로길이
|
||||
|
||||
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,188 +0,0 @@
|
||||
package center.online.process;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.exception.IllegalRecordException;
|
||||
import com.util.Log4JLogger;
|
||||
/**
|
||||
* 요금정산 정보 데이터 실시간 반영<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class FareAdjustInfo {
|
||||
private byte [] record;
|
||||
private StringBuffer sbInsert = new StringBuffer();
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public FareAdjustInfo(){
|
||||
sbInsert.append("INSERT INTO FARE_ADJUST_INFO ( ");
|
||||
sbInsert.append(" WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, WORK_STT_TIME, WORK_END_TIME, ");
|
||||
sbInsert.append(" EXEMPTION_QUANTITY, CASH_QUANTITY, COUPON_QUANTITY, NONPAYMENT_QUANTITY, CARD_BEFORE_QUANTITY, ");
|
||||
sbInsert.append(" CARD_AFTER_QUANTITY, COUPON_SALE_QUANTITY, K_CASH_Q, K_COUPON_Q, K_CARD_SUN_Q, K_CARD_WHO_Q, ");
|
||||
sbInsert.append(" K_COUPON_SALE_Q, TOTAL_INCOME, CASH_INCOME, CARD_BEFORE_INCOME, CARD_AFTER_INCME, COUPON_INCOME, ");
|
||||
sbInsert.append(" COUPON_SALE, K_CASH_INCOME, K_CARD_SUN_INCOME, K_CARD_WHO_INCOME, K_COUPON_SALE_INCOME, REPAY_CNT,");
|
||||
sbInsert.append(" REPAY_AMOUNT, INCOME_DATE, INCOME_PART, COUPON_DISUSE_YN, TRANS_FILE_CREATE_YN, OTHER_SEQNO, ");
|
||||
sbInsert.append(" CREATE_DATE, CREATER, UPDATE_DATE, UPDATER ) ");
|
||||
sbInsert.append("VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ");
|
||||
sbInsert.append(" SYSDATE, 'ONLINEPROC', SYSDATE, 'ONLINEPROC' ) ");
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param sData
|
||||
* @param logger
|
||||
* @param conn
|
||||
* @return String
|
||||
* @throws SQLException
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public String applyData(String sData, Log4JLogger logger, Connection conn) throws SQLException, Exception{
|
||||
PreparedStatement psInsert = null;
|
||||
|
||||
try{
|
||||
record = sData.getBytes();
|
||||
// 송신 파일 정보 등록
|
||||
int idx = 1;
|
||||
psInsert = conn.prepareStatement(sbInsert.toString());
|
||||
psInsert.setString(idx ++, getItem(WORKER_ID ) ); // 근무자 ID
|
||||
psInsert.setString(idx ++, getItem(FARE_OFFICE_ID ) ); // 요금소 코드
|
||||
psInsert.setString(idx ++, getItem(BOOTH_ID ) ); // 차로 코드
|
||||
psInsert.setString(idx ++, getItem(YEAR ) ); // 년도
|
||||
psInsert.setString(idx ++, getItem(MONTH ) ); // 월
|
||||
psInsert.setString(idx ++, getItem(DAY ) ); // 일
|
||||
psInsert.setString(idx ++, getItem(WORK_STT_TIME ) ); // 근무 시작 시간
|
||||
psInsert.setString(idx ++, getItem(WORK_END_TIME ) ); // 근무 종료 시간
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(EXEMPTION_QUANTITY ))); // 면제 통행량
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(CASH_QUANTITY ))); // 현금 통행량
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(COUPON_QUANTITY ))); // 쿠폰 통행량
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(NONPAYMENT_QUANTITY ))); // 미납 통행량
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(CARD_BEFORE_QUANTITY))); // 카드_선불 통행량
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(CARD_AFTER_QUANTITY ))); // 카드_후불 통행량
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(COUPON_SALE_QUANTITY))); // 쿠폰 판매량
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(K_CASH_Q ))); // 경차현금통행량
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(K_COUPON_Q ))); // 경차쿠폰통행량
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(K_CARD_SUN_Q ))); // 경차카드선불통행량
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(K_CARD_WHO_Q ))); // 경차카드후불통행량
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(K_COUPON_SALE_Q ))); // 경차정액권판매량
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(TOTAL_INCOME ))); // 총 수입 금액
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(CASH_INCOME ))); // 현금 수입 금액
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(CARD_BEFORE_INCOME ))); // 카드_선불 수입금액
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(CARD_AFTER_INCME ))); // 카드_후불 수입금액
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(COUPON_INCOME ))); // 쿠폰 수입금액
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(COUPON_SALE ))); // 쿠폰 판매금액
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(K_CASH_INCOME ))); // 경차현금수입금액
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(K_CARD_SUN_INCOME ))); // 경차카드선불수입금액
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(K_CARD_WHO_INCOME ))); // 경차카드후불수입금액
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(K_COUPON_SALE_INCOME))); // 경차정액권판매금액
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(REPAY_CNT ))); // 환불건수
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(REPAY_AMOUNT ))); // 환불금액
|
||||
psInsert.setString(idx ++, getItem(INCOME_DATE ).trim() ); // 수입금 정산일자
|
||||
psInsert.setString(idx ++, getItem(INCOME_PART ).trim() ); // 수입금 정산그룹
|
||||
psInsert.setString(idx ++, getItem(COUPON_DISUSE_YN ) ); // 회수쿠폰 폐기여부
|
||||
psInsert.setString(idx ++, getItem(TRANS_FILE_CREATE_YN) ); // 전송화일 생성여부
|
||||
psInsert.setString(idx ++, getItem(OTHER_SEQNO ) ); // 중복방지번호
|
||||
|
||||
psInsert.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
}catch(SQLException sqle){
|
||||
logger.logDebug(sbInsert.toString());
|
||||
throw sqle;
|
||||
}catch(Exception ex){
|
||||
throw ex;
|
||||
}finally{
|
||||
if(psInsert != null){ try{ psInsert.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
|
||||
return "000";
|
||||
}
|
||||
private static final int WORKER_ID = 0; // 근무자 ID
|
||||
private static final int FARE_OFFICE_ID = 1; // 요금소 코드
|
||||
private static final int BOOTH_ID = 2; // 차로 코드
|
||||
private static final int YEAR = 3; // 년도
|
||||
private static final int MONTH = 4; // 월
|
||||
private static final int DAY = 5; // 일
|
||||
private static final int WORK_STT_TIME = 6; // 근무 시작 시간
|
||||
private static final int WORK_END_TIME = 7; // 근무 종료 시간
|
||||
private static final int EXEMPTION_QUANTITY = 8; // 면제 통행량
|
||||
private static final int CASH_QUANTITY = 9; // 현금 통행량
|
||||
private static final int COUPON_QUANTITY = 10; // 쿠폰 통행량
|
||||
private static final int NONPAYMENT_QUANTITY = 11; // 미납 통행량
|
||||
private static final int CARD_BEFORE_QUANTITY = 12; // 카드_선불 통행량
|
||||
private static final int CARD_AFTER_QUANTITY = 13; // 카드_후불 통행량
|
||||
private static final int COUPON_SALE_QUANTITY = 14; // 쿠폰 판매량
|
||||
private static final int K_CASH_Q = 15; // 경차현금통행량
|
||||
private static final int K_COUPON_Q = 16; // 경차쿠폰통행량
|
||||
private static final int K_CARD_SUN_Q = 17; // 경차카드선불통행량
|
||||
private static final int K_CARD_WHO_Q = 18; // 경차카드후불통행량
|
||||
private static final int K_COUPON_SALE_Q = 19; // 경차정액권판매량
|
||||
private static final int TOTAL_INCOME = 20; // 총 수입 금액
|
||||
private static final int CASH_INCOME = 21; // 현금 수입 금액
|
||||
private static final int CARD_BEFORE_INCOME = 22; // 카드_선불 수입금액
|
||||
private static final int CARD_AFTER_INCME = 23; // 카드_후불 수입금액
|
||||
private static final int COUPON_INCOME = 24; // 쿠폰 수입금액
|
||||
private static final int COUPON_SALE = 25; // 쿠폰 판매금액
|
||||
private static final int K_CASH_INCOME = 26; // 경차현금수입금액
|
||||
private static final int K_CARD_SUN_INCOME = 27; // 경차카드선불수입금액
|
||||
private static final int K_CARD_WHO_INCOME = 28; // 경차카드후불수입금액
|
||||
private static final int K_COUPON_SALE_INCOME = 29; // 경차정액권판매금액
|
||||
private static final int REPAY_CNT = 30; // 환불건수
|
||||
private static final int REPAY_AMOUNT = 31; // 환불금액
|
||||
private static final int INCOME_DATE = 32; // 수입금 정산일자
|
||||
private static final int INCOME_PART = 33; // 수입금 정산그룹
|
||||
private static final int COUPON_DISUSE_YN = 34; // 회수쿠폰 폐기여부
|
||||
private static final int TRANS_FILE_CREATE_YN = 35; // 전송화일 생성여부
|
||||
private static final int OTHER_SEQNO = 36; // 중복방지번호
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case WORKER_ID : return new String(record, 0, 6); // 근무자 ID
|
||||
case FARE_OFFICE_ID : return new String(record, 6, 2); // 요금소 코드
|
||||
case BOOTH_ID : return new String(record, 8, 2); // 차로 코드
|
||||
case YEAR : return new String(record, 10, 4); // 년도
|
||||
case MONTH : return new String(record, 14, 2); // 월
|
||||
case DAY : return new String(record, 16, 2); // 일
|
||||
case WORK_STT_TIME : return new String(record, 18, 6); // 근무 시작 시간
|
||||
case WORK_END_TIME : return new String(record, 24, 6); // 근무 종료 시간
|
||||
case EXEMPTION_QUANTITY : return new String(record, 30, 5); // 면제 통행량
|
||||
case CASH_QUANTITY : return new String(record, 35, 5); // 현금 통행량
|
||||
case COUPON_QUANTITY : return new String(record, 40, 5); // 쿠폰 통행량
|
||||
case NONPAYMENT_QUANTITY : return new String(record, 45, 5); // 미납 통행량
|
||||
case CARD_BEFORE_QUANTITY : return new String(record, 50, 5); // 카드_선불 통행량
|
||||
case CARD_AFTER_QUANTITY : return new String(record, 55, 5); // 카드_후불 통행량
|
||||
case COUPON_SALE_QUANTITY : return new String(record, 60, 5); // 쿠폰 판매량
|
||||
case K_CASH_Q : return new String(record, 65, 5); // 경차현금통행량
|
||||
case K_COUPON_Q : return new String(record, 70, 5); // 경차쿠폰통행량
|
||||
case K_CARD_SUN_Q : return new String(record, 75, 5); // 경차카드선불통행량
|
||||
case K_CARD_WHO_Q : return new String(record, 80, 5); // 경차카드후불통행량
|
||||
case K_COUPON_SALE_Q : return new String(record, 85, 5); // 경차정액권판매량
|
||||
case TOTAL_INCOME : return new String(record, 90, 9); // 총 수입 금액
|
||||
case CASH_INCOME : return new String(record, 99, 9); // 현금 수입 금액
|
||||
case CARD_BEFORE_INCOME : return new String(record, 108, 9); // 카드_선불 수입금액
|
||||
case CARD_AFTER_INCME : return new String(record, 117, 9); // 카드_후불 수입금액
|
||||
case COUPON_INCOME : return new String(record, 126, 9); // 쿠폰 수입금액
|
||||
case COUPON_SALE : return new String(record, 135, 9); // 쿠폰 판매금액
|
||||
case K_CASH_INCOME : return new String(record, 144, 9); // 경차현금수입금액
|
||||
case K_CARD_SUN_INCOME : return new String(record, 153, 9); // 경차카드선불수입금액
|
||||
case K_CARD_WHO_INCOME : return new String(record, 162, 9); // 경차카드후불수입금액
|
||||
case K_COUPON_SALE_INCOME : return new String(record, 171, 9); // 경차정액권판매금액
|
||||
case REPAY_CNT : return new String(record, 180, 9); // 환불건수
|
||||
case REPAY_AMOUNT : return new String(record, 189, 9); // 환불금액
|
||||
case INCOME_DATE : return new String(record, 198, 8); // 수입금 정산일자
|
||||
case INCOME_PART : return new String(record, 206, 1); // 수입금 정산그룹
|
||||
case COUPON_DISUSE_YN : return new String(record, 207, 1); // 회수쿠폰 폐기여부
|
||||
case TRANS_FILE_CREATE_YN : return new String(record, 208, 1); // 전송화일 생성여부
|
||||
case OTHER_SEQNO : return new String(record, 209, 1); // 중복방지번호
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,192 +0,0 @@
|
||||
package center.online.process;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.exception.IllegalRecordException;
|
||||
import com.util.Log4JLogger;
|
||||
/**
|
||||
* 요금단말정보 데이터 실시간 반영<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class FareTerminalInfo {
|
||||
private byte [] record;
|
||||
private StringBuffer sbInsert = new StringBuffer();
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public FareTerminalInfo(){
|
||||
sbInsert.append("INSERT INTO FARE_TERMINAL_INFO ( ");
|
||||
sbInsert.append(" WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, WORK_TIMES, SEQNO, ");
|
||||
sbInsert.append(" CAR_TYPE_ID, COLLECT_ID, IN_OUT_KBN, LEVY_AMOUNT, READING_ID, ");
|
||||
sbInsert.append(" FOREIGN_CARS_KBN, ARMY_CARS_KBN, CAR_NO, CARS_MOVE_PICTURE_FILE, ");
|
||||
sbInsert.append(" CARS_STOP_PICTURE_FILE, READER, REMARKS, TRANS_FILE_CREATE_YN, X_POSITION, ");
|
||||
sbInsert.append(" Y_POSITION, GARO_LEN, SERO_LEN, OTHER_SEQNO, RFID_KBN, RFID_TAG1, RFID_TAG2,");
|
||||
sbInsert.append(" CREATE_DATE, CREATER, UPDATE_DATE, UPDATER, READING_DATE ");
|
||||
sbInsert.append(" ) ");
|
||||
sbInsert.append("VALUES ");
|
||||
sbInsert.append(" (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ");
|
||||
sbInsert.append(" SYSDATE, 'ONLINEPROC', SYSDATE, 'ONLINEPROC', TO_DATE(?,'yyyymmddhh24miss') ");
|
||||
sbInsert.append(" ) ");
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param sData
|
||||
* @param logger
|
||||
* @param conn
|
||||
* @return String
|
||||
* @throws SQLException
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public String applyData(String sData, Log4JLogger logger, Connection conn) throws SQLException, Exception{
|
||||
PreparedStatement psInsert = null;
|
||||
|
||||
try{
|
||||
record = sData.getBytes();
|
||||
// 송신 파일 정보 등록
|
||||
int idx = 1;
|
||||
psInsert = conn.prepareStatement(sbInsert.toString());
|
||||
psInsert.setString (idx ++ , getItem( WORKER_ID )); // 근무자 ID
|
||||
psInsert.setString (idx ++ , getItem( FARE_OFFICE_ID )); // 요금소 코드
|
||||
psInsert.setString (idx ++ , getItem( BOOTH_ID )); // 차로코드
|
||||
psInsert.setString (idx ++ , getItem( YEAR )); // 년도
|
||||
psInsert.setString (idx ++ , getItem( MONTH )); // 월
|
||||
psInsert.setString (idx ++ , getItem( DAY )); // 일
|
||||
psInsert.setString (idx ++ , getItem( WORK_TIMES )); // 근무시간
|
||||
psInsert.setInt (idx ++ , Integer.parseInt(getItem( SEQNO ))); // 일련번호
|
||||
psInsert.setString (idx ++ , getItem( CAR_TYPE_ID )); // 차종코드
|
||||
psInsert.setString (idx ++ , getItem( COLLECT_ID )); // 징수유형코드
|
||||
psInsert.setString (idx ++ , getItem( IN_OUT_KBN )); // 유출_입 구분
|
||||
psInsert.setInt (idx ++ , Integer.parseInt(getItem( LEVY_AMOUNT ))); // 징수액
|
||||
psInsert.setString (idx ++ , getItem( READING_ID )); // 차량 판독 구분 코드
|
||||
psInsert.setString (idx ++ , getItem( FOREIGN_CARS_KBN )); // 외국인 차량 구분
|
||||
psInsert.setString (idx ++ , getItem( ARMY_CARS_KBN )); // 미군용 차량 구분
|
||||
psInsert.setString (idx ++ , getItem( CAR_NO ).trim()); // 차량번호
|
||||
psInsert.setString (idx ++ , getItem( CARS_MOVE_PICTURE_FILE ).trim()); // 차량 동영상 정보
|
||||
psInsert.setString (idx ++ , getItem( CARS_STOP_PICTURE_FILE ).trim()); // 차량 정지화상 정보
|
||||
psInsert.setString (idx ++ , getItem( READER ).trim()); // 차량 판독자 ID
|
||||
psInsert.setString (idx ++ , getItem( REMARKS ).trim()); // 비 고
|
||||
psInsert.setString (idx ++ , getItem( TRANS_FILE_CREATE_YN )); // 전송화일 생성여부
|
||||
|
||||
String sXPos = getItem(X_POSITION);
|
||||
String sYPos = getItem(Y_POSITION);
|
||||
String sXLen = getItem(GARO_LEN);
|
||||
String sYLen = getItem(SERO_LEN);
|
||||
if( sXPos.indexOf(" ") < 0 ) {
|
||||
psInsert.setInt (idx ++ , Integer.parseInt( sXPos ) ); // X좌표
|
||||
}else{
|
||||
psInsert.setString (idx ++ , null );
|
||||
}
|
||||
if( sYPos.indexOf(" ") < 0 ) {
|
||||
psInsert.setInt (idx ++ , Integer.parseInt( sYPos ) ); // Y좌표
|
||||
}else{
|
||||
psInsert.setString (idx ++ , null );
|
||||
}
|
||||
if( sXLen.indexOf(" ") < 0 ) {
|
||||
psInsert.setInt (idx ++ , Integer.parseInt( sXLen ) ); // 가로길이
|
||||
}else{
|
||||
psInsert.setString (idx ++ , null );
|
||||
}
|
||||
if( sYLen.indexOf(" ") < 0 ) {
|
||||
psInsert.setInt (idx ++ , Integer.parseInt( sYLen ) ); // 세로길이
|
||||
}else{
|
||||
psInsert.setString (idx ++ , null );
|
||||
}
|
||||
|
||||
psInsert.setString (idx ++ , getItem( OTHER_SEQNO )); // 중복방지번호
|
||||
psInsert.setString (idx ++ , getItem( RFID_KBN )); // 감면구분
|
||||
psInsert.setString (idx ++ , getItem( RFID_TAG1 )); // TAG1
|
||||
psInsert.setString (idx ++ , getItem( RFID_TAG2 )); // TAG2
|
||||
psInsert.setString (idx ++ , getItem( READING_DATE )); // 차량 판독일자
|
||||
|
||||
psInsert.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
}catch(SQLException sqle){
|
||||
logger.logDebug(sbInsert.toString());
|
||||
throw sqle;
|
||||
}catch(Exception ex){
|
||||
throw ex;
|
||||
}finally{
|
||||
if(psInsert != null){ try{ psInsert.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
|
||||
return "000";
|
||||
}
|
||||
private static final int WORKER_ID = 0; // 근무자 ID
|
||||
private static final int FARE_OFFICE_ID = 1; // 요금소 코드
|
||||
private static final int BOOTH_ID = 2; // 차로코드
|
||||
private static final int YEAR = 3; // 년도
|
||||
private static final int MONTH = 4; // 월
|
||||
private static final int DAY = 5; // 일
|
||||
private static final int WORK_TIMES = 6; // 근무시간
|
||||
private static final int SEQNO = 7; // 일련번호
|
||||
private static final int CAR_TYPE_ID = 8; // 차종코드
|
||||
private static final int COLLECT_ID = 9; // 징수유형코드
|
||||
private static final int IN_OUT_KBN = 10; // 유출_입 구분
|
||||
private static final int LEVY_AMOUNT = 11; // 징수액
|
||||
private static final int READING_ID = 12; // 차량 판독 구분 코드
|
||||
private static final int FOREIGN_CARS_KBN = 13; // 외국인 차량 구분
|
||||
private static final int ARMY_CARS_KBN = 14; // 미군용 차량 구분
|
||||
private static final int CAR_NO = 15; // 차량번호
|
||||
private static final int CARS_MOVE_PICTURE_FILE = 16; // 차량 동영상 정보
|
||||
private static final int CARS_STOP_PICTURE_FILE = 17; // 차량 정지화상 정보
|
||||
private static final int READER = 18; // 차량 판독자 ID
|
||||
private static final int REMARKS = 19; // 비 고
|
||||
private static final int TRANS_FILE_CREATE_YN = 20; // 전송화일 생성여부
|
||||
private static final int X_POSITION = 21; // X좌표
|
||||
private static final int Y_POSITION = 22; // Y좌표
|
||||
private static final int GARO_LEN = 23; // 가로길이
|
||||
private static final int SERO_LEN = 24; // 세로길이
|
||||
private static final int OTHER_SEQNO = 25; // 중복방지번호
|
||||
private static final int RFID_KBN = 26; // 감면구분
|
||||
private static final int RFID_TAG1 = 27; // TAG1
|
||||
private static final int RFID_TAG2 = 28; // TAG2
|
||||
private static final int READING_DATE = 29; // 차량 판독일자
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case WORKER_ID : return new String(record, 0, 6); // 근무자 ID
|
||||
case FARE_OFFICE_ID : return new String(record, 6, 2); // 요금소 코드
|
||||
case BOOTH_ID : return new String(record, 8, 2); // 차로코드
|
||||
case YEAR : return new String(record, 10, 4); // 년도
|
||||
case MONTH : return new String(record, 14, 2); // 월
|
||||
case DAY : return new String(record, 16, 2); // 일
|
||||
case WORK_TIMES : return new String(record, 18, 6); // 근무시간
|
||||
case SEQNO : return new String(record, 24, 9); // 일련번호
|
||||
case CAR_TYPE_ID : return new String(record, 33, 1); // 차종코드
|
||||
case COLLECT_ID : return new String(record, 34, 2); // 징수유형코드
|
||||
case IN_OUT_KBN : return new String(record, 36, 1); // 유출_입 구분
|
||||
case LEVY_AMOUNT : return new String(record, 37, 10); // 징수액
|
||||
case READING_ID : return new String(record, 47, 2); // 차량 판독 구분 코드
|
||||
case FOREIGN_CARS_KBN : return new String(record, 49, 1); // 외국인 차량 구분
|
||||
case ARMY_CARS_KBN : return new String(record, 50, 1); // 미군용 차량 구분
|
||||
case CAR_NO : return new String(record, 51, 20); // 차량번호
|
||||
case CARS_MOVE_PICTURE_FILE : return new String(record, 71, 50); // 차량 동영상 정보
|
||||
case CARS_STOP_PICTURE_FILE : return new String(record, 121, 50); // 차량 정지화상 정보
|
||||
case READER : return new String(record, 171, 6); // 차량 판독자 ID
|
||||
case REMARKS : return new String(record, 177, 60); // 비 고
|
||||
case TRANS_FILE_CREATE_YN : return new String(record, 237, 1); // 전송화일 생성여부
|
||||
case X_POSITION : return new String(record, 238, 3); // X좌표
|
||||
case Y_POSITION : return new String(record, 241, 3); // Y좌표
|
||||
case GARO_LEN : return new String(record, 244, 3); // 가로길이
|
||||
case SERO_LEN : return new String(record, 247, 3); // 세로길이
|
||||
case OTHER_SEQNO : return new String(record, 250, 1); // 중복방지번호
|
||||
case RFID_KBN : return new String(record, 251, 2); // 감면구분
|
||||
case RFID_TAG1 : return new String(record, 253, 24); // TAG1
|
||||
case RFID_TAG2 : return new String(record, 277, 24); // TAG2
|
||||
case READING_DATE : return new String(record, 301, 14); // 차량 판독일자
|
||||
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,123 +0,0 @@
|
||||
package center.online.process;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.exception.IllegalRecordException;
|
||||
import com.util.Log4JLogger;
|
||||
/**
|
||||
* 환불정보 데이터 실시간 반영<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성
|
||||
*/
|
||||
public class RFRepayInfo {
|
||||
|
||||
private byte [] record;
|
||||
private StringBuffer sbInsert = new StringBuffer();
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public RFRepayInfo(){
|
||||
sbInsert.append("INSERT INTO RF_Repay_INFO ");
|
||||
sbInsert.append("( WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, WORK_TIMES, SEQNO, ");
|
||||
sbInsert.append(" CAR_TYPE_ID, COLLECT_ID, IN_OUT_KBN, LEVY_AMOUNT, CAR_NO, NOTE_TRANS_YN, ");
|
||||
sbInsert.append(" NOTE_INPUT_REMARKS, C_REPAY_KBN, ");
|
||||
sbInsert.append(" CREATE_DATE, CREATER, UPDATE_DATE, UPDATER ) ");
|
||||
sbInsert.append("VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ");
|
||||
sbInsert.append(" SYSDATE, 'ONLINEPROC', SYSDATE, 'ONLINEPROC' ) ");
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param sData
|
||||
* @param logger
|
||||
* @param conn
|
||||
* @return String
|
||||
* @throws SQLException
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public String applyData(String sData, Log4JLogger logger, Connection conn) throws SQLException, Exception{
|
||||
PreparedStatement psInsert = null;
|
||||
|
||||
try{
|
||||
record = sData.getBytes();
|
||||
// 송신 파일 정보 등록
|
||||
int idx = 1;
|
||||
psInsert = conn.prepareStatement(sbInsert.toString());
|
||||
psInsert.setString(idx ++, getItem(WORKER_ID ) ); // 근무자 ID
|
||||
psInsert.setString(idx ++, getItem(FARE_OFFICE_ID ) ); // 요금소 코드
|
||||
psInsert.setString(idx ++, getItem(BOOTH_ID ) ); // 차로코드
|
||||
psInsert.setString(idx ++, getItem(YEAR ) ); // 년도
|
||||
psInsert.setString(idx ++, getItem(MONTH ) ); // 월
|
||||
psInsert.setString(idx ++, getItem(DAY ) ); // 일
|
||||
psInsert.setString(idx ++, getItem(WORK_TIMES ) ); // 근무시간
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(SEQNO ))); // 일련번호
|
||||
psInsert.setString(idx ++, getItem(CAR_TYPE_ID ) ); // 차종코드
|
||||
psInsert.setString(idx ++, getItem(COLLECT_ID ) ); // 징수유형코드
|
||||
psInsert.setString(idx ++, getItem(IN_OUT_KBN ) ); // 유출_입 구분
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(LEVY_AMOUNT ))); // 징수액
|
||||
psInsert.setString(idx ++, getItem(CAR_NO ).trim() ); // 차량번호
|
||||
psInsert.setString(idx ++, getItem(NOTE_TRANS_YN ) ); // 수기여부
|
||||
psInsert.setString(idx ++, getItem(NOTE_INPUT_REMARKS) ); // 수기입력 사유
|
||||
psInsert.setString(idx ++, getItem(C_REPAY_KBN ) ); // 환불여부
|
||||
|
||||
psInsert.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
}catch(SQLException sqle){
|
||||
logger.logDebug(sbInsert.toString());
|
||||
throw sqle;
|
||||
}catch(Exception ex){
|
||||
throw ex;
|
||||
}finally{
|
||||
if(psInsert != null){ try{ psInsert.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
|
||||
return "000";
|
||||
}
|
||||
private static final int WORKER_ID = 0; // 근무자 ID
|
||||
private static final int FARE_OFFICE_ID = 1; // 요금소 코드
|
||||
private static final int BOOTH_ID = 2; // 차로코드
|
||||
private static final int YEAR = 3; // 년도
|
||||
private static final int MONTH = 4; // 월
|
||||
private static final int DAY = 5; // 일
|
||||
private static final int WORK_TIMES = 6; // 근무시간
|
||||
private static final int SEQNO = 7; // 일련번호
|
||||
private static final int CAR_TYPE_ID = 8; // 차종코드
|
||||
private static final int COLLECT_ID = 9; // 징수유형코드
|
||||
private static final int IN_OUT_KBN = 10; // 유출_입 구분
|
||||
private static final int LEVY_AMOUNT = 11; // 징수액
|
||||
private static final int CAR_NO = 12; // 차량번호
|
||||
private static final int NOTE_TRANS_YN = 13; // 수기여부
|
||||
private static final int NOTE_INPUT_REMARKS = 14; // 수기입력 사유
|
||||
private static final int C_REPAY_KBN = 15; // 환불여부
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case WORKER_ID : return new String(record, 0, 6); // 근무자 ID
|
||||
case FARE_OFFICE_ID : return new String(record, 6, 2); // 요금소 코드
|
||||
case BOOTH_ID : return new String(record, 8, 2); // 차로코드
|
||||
case YEAR : return new String(record, 10, 4); // 년도
|
||||
case MONTH : return new String(record, 14, 2); // 월
|
||||
case DAY : return new String(record, 16, 2); // 일
|
||||
case WORK_TIMES : return new String(record, 18, 6); // 근무시간
|
||||
case SEQNO : return new String(record, 24, 9); // 일련번호
|
||||
case CAR_TYPE_ID : return new String(record, 33, 1); // 차종코드
|
||||
case COLLECT_ID : return new String(record, 34, 2); // 징수유형코드
|
||||
case IN_OUT_KBN : return new String(record, 36, 1); // 유출_입 구분
|
||||
case LEVY_AMOUNT : return new String(record, 37, 6); // 징수액
|
||||
case CAR_NO : return new String(record, 43, 20); // 차량번호
|
||||
case NOTE_TRANS_YN : return new String(record, 63, 1); // 수기여부
|
||||
case NOTE_INPUT_REMARKS : return new String(record, 64, 60); // 수기입력 사유
|
||||
case C_REPAY_KBN : return new String(record, 124, 1); // 환불여부
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,186 +0,0 @@
|
||||
package center.online.process;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.exception.IllegalRecordException;
|
||||
import com.util.Log4JLogger;
|
||||
/**
|
||||
* 요금단말정보(RF) 데이터 실시간 반영<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-11-01 초기 작성, 2011.12.12 kde 이비카드 추가.. 컬럼 사이즈 변경...
|
||||
*/
|
||||
public class RFTerminalInfo {
|
||||
|
||||
private byte [] record;
|
||||
private StringBuffer sbInsert = new StringBuffer();
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public RFTerminalInfo(){
|
||||
sbInsert.append("INSERT INTO RF_TERMINAL_INFO ");
|
||||
sbInsert.append("( WORKER_ID, FARE_OFFICE_ID, BOOTH_ID, YEAR, MONTH, DAY, WORK_TIMES, SEQNO, AFTER_KBN, ");
|
||||
sbInsert.append(" CARD_NO, IN_OUT_KBN, TRANS_FILE_CREATE_YN, COLLECT_ID, LEVY_AMOUNT, REMAIND_AMOUNT, ");
|
||||
sbInsert.append(" CARD_OFFICE_ID, C_REPAY_KBN, RFID_KBN, RFID_TAG1, RFID_TAG2, TERMINAL_ID, SAM_ID, ");
|
||||
sbInsert.append(" SAM_SEQNO, CARD_SEQNO, BEFORE_AMOUNT, ALGORITHM_ID, KEY_VERSION, E_CASH_IDENTIFIER, ");
|
||||
sbInsert.append(" SAM_TOT_SEQNO, SAM_COLLECT_CNT, SAM_TOT_AMOUNT, SIGN_VALUE, PERSON_CODE, ZIPGE_ID, ");
|
||||
sbInsert.append(" ALIAS_NO, ISSUE_ID, ");
|
||||
sbInsert.append(" CREATE_DATE, CREATER, UPDATE_DATE, UPDATER ) ");
|
||||
sbInsert.append("VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ");
|
||||
sbInsert.append(" SYSDATE, 'ONLINEPROC', SYSDATE, 'ONLINEPROC' ) ");
|
||||
}
|
||||
/**
|
||||
* 데이터 반영
|
||||
* @param sData
|
||||
* @param logger
|
||||
* @param conn
|
||||
* @return String
|
||||
* @throws SQLException
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public String applyData(String sData, Log4JLogger logger, Connection conn) throws SQLException, Exception{
|
||||
PreparedStatement psInsert = null;
|
||||
|
||||
try{
|
||||
record = sData.getBytes();
|
||||
// 송신 파일 정보 등록
|
||||
int idx = 1;
|
||||
psInsert = conn.prepareStatement(sbInsert.toString());
|
||||
psInsert.setString(idx ++, getItem(WORKER_ID ) ); // 근무자 ID
|
||||
psInsert.setString(idx ++, getItem(FARE_OFFICE_ID ) ); // 요금소 코드
|
||||
psInsert.setString(idx ++, getItem(BOOTH_ID ) ); // 차로코드
|
||||
psInsert.setString(idx ++, getItem(YEAR ) ); // 년도
|
||||
psInsert.setString(idx ++, getItem(MONTH ) ); // 월
|
||||
psInsert.setString(idx ++, getItem(DAY ) ); // 일
|
||||
psInsert.setString(idx ++, getItem(WORK_TIMES ) ); // 근무시간
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(SEQNO ))); // 일련번호
|
||||
psInsert.setString(idx ++, getItem(AFTER_KBN ) ); // 선_후불 구분
|
||||
psInsert.setString(idx ++, getItem(CARD_NO ) ); // 카드 번호
|
||||
psInsert.setString(idx ++, getItem(IN_OUT_KBN ) ); // 유출_입 구분
|
||||
psInsert.setString(idx ++, getItem(TRANS_FILE_CREATE_YN) ); // 전송화일 생성여부
|
||||
psInsert.setString(idx ++, getItem(COLLECT_ID ) ); // 징수유형코드
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(LEVY_AMOUNT ))); // 징수금액
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(REMAIND_AMOUNT ))); // 사용후잔액
|
||||
psInsert.setString(idx ++, getItem(CARD_OFFICE_ID ) ); // 카드사코드
|
||||
psInsert.setString(idx ++, getItem(C_REPAY_KBN ) ); // 경차환불여부
|
||||
psInsert.setString(idx ++, getItem(RFID_KBN ) ); // 감면구분
|
||||
psInsert.setString(idx ++, getItem(RFID_TAG1 ).trim() ); // TAG1
|
||||
psInsert.setString(idx ++, getItem(RFID_TAG2 ).trim() ); // TAG2
|
||||
psInsert.setString(idx ++, getItem(TERMINAL_ID ) ); // 단말기 ID
|
||||
psInsert.setString(idx ++, getItem(SAM_ID ).trim() ); // SAM ID
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(SAM_SEQNO ))); // SAM 거래 일련번호
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(CARD_SEQNO ))); // 카드거래 일련번호
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(BEFORE_AMOUNT ))); // 거래 전 카드잔액
|
||||
psInsert.setString(idx ++, getItem(ALGORITHM_ID ) ); // 알고리즘 ID
|
||||
psInsert.setString(idx ++, getItem(KEY_VERSION ) ); // 개별거래 수집 키 버전
|
||||
psInsert.setString(idx ++, getItem(E_CASH_IDENTIFIER ) ); // 전자화폐 식별자
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(SAM_TOT_SEQNO ))); // SAM 총액거래 수집일련번호
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(SAM_COLLECT_CNT ))); // SAM 거래 수집건수
|
||||
psInsert.setInt (idx ++, Integer.parseInt(getItem(SAM_TOT_AMOUNT ))); // SAM 누적거래 총액
|
||||
psInsert.setString(idx ++, getItem(SIGN_VALUE ) ); // SIGN 값
|
||||
psInsert.setString(idx ++, getItem(PERSON_CODE ) ); // 카드소지자 구분코드
|
||||
psInsert.setString(idx ++, getItem(ZIPGE_ID ) ); // 집계 ID
|
||||
psInsert.setString(idx ++, getItem(ALIAS_NO ) ); // Alias 번호
|
||||
psInsert.setString(idx ++, getItem(ISSUE_ID ) ); // 발행사 ID
|
||||
|
||||
psInsert.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
}catch(SQLException sqle){
|
||||
logger.logDebug(sbInsert.toString());
|
||||
throw sqle;
|
||||
}catch(Exception ex){
|
||||
throw ex;
|
||||
}finally{
|
||||
if(psInsert != null){ try{ psInsert.close(); }catch(Exception ignore){} }
|
||||
}
|
||||
|
||||
return "000";
|
||||
}
|
||||
private static final int WORKER_ID = 0; // 근무자 ID
|
||||
private static final int FARE_OFFICE_ID = 1; // 요금소 코드
|
||||
private static final int BOOTH_ID = 2; // 차로코드
|
||||
private static final int YEAR = 3; // 년도
|
||||
private static final int MONTH = 4; // 월
|
||||
private static final int DAY = 5; // 일
|
||||
private static final int WORK_TIMES = 6; // 근무시간
|
||||
private static final int SEQNO = 7; // 일련번호
|
||||
private static final int AFTER_KBN = 8; // 선_후불 구분
|
||||
private static final int CARD_NO = 9; // 카드 번호
|
||||
private static final int IN_OUT_KBN = 10; // 유출_입 구분
|
||||
private static final int TRANS_FILE_CREATE_YN = 11; // 전송화일 생성여부
|
||||
private static final int COLLECT_ID = 12; // 징수유형코드
|
||||
private static final int LEVY_AMOUNT = 13; // 징수금액
|
||||
private static final int REMAIND_AMOUNT = 14; // 사용후잔액
|
||||
private static final int CARD_OFFICE_ID = 15; // 카드사코드
|
||||
private static final int C_REPAY_KBN = 16; // 경차환불여부
|
||||
private static final int RFID_KBN = 17; // 감면구분
|
||||
private static final int RFID_TAG1 = 18; // TAG1
|
||||
private static final int RFID_TAG2 = 19; // TAG2
|
||||
private static final int TERMINAL_ID = 20; // 단말기 ID
|
||||
private static final int SAM_ID = 21; // SAM ID
|
||||
private static final int SAM_SEQNO = 22; // SAM 거래 일련번호
|
||||
private static final int CARD_SEQNO = 23; // 카드거래 일련번호
|
||||
private static final int BEFORE_AMOUNT = 24; // 거래 전 카드잔액
|
||||
private static final int ALGORITHM_ID = 25; // 알고리즘 ID
|
||||
private static final int KEY_VERSION = 26; // 개별거래 수집 키 버전
|
||||
private static final int E_CASH_IDENTIFIER = 27; // 전자화폐 식별자
|
||||
private static final int SAM_TOT_SEQNO = 28; // SAM 총액거래 수집일련번호
|
||||
private static final int SAM_COLLECT_CNT = 29; // SAM 거래 수집건수
|
||||
private static final int SAM_TOT_AMOUNT = 30; // SAM 누적거래 총액
|
||||
private static final int SIGN_VALUE = 31; // SIGN 값
|
||||
private static final int PERSON_CODE = 32; // 카드소지자 구분코드
|
||||
private static final int ZIPGE_ID = 33; // 집계 ID
|
||||
private static final int ALIAS_NO = 34; // Alias 번호
|
||||
private static final int ISSUE_ID = 35; // 발행사 ID
|
||||
/**
|
||||
* Data Recorde Format
|
||||
* @param itemName
|
||||
* @return String
|
||||
* @throws IllegalRecordException
|
||||
*/
|
||||
public String getItem(int itemName) throws IllegalRecordException{
|
||||
switch(itemName){
|
||||
case WORKER_ID : return new String(record, 0, 6); // 근무자 ID
|
||||
case FARE_OFFICE_ID : return new String(record, 6, 2); // 요금소 코드
|
||||
case BOOTH_ID : return new String(record, 8, 2); // 차로코드
|
||||
case YEAR : return new String(record, 10, 4); // 년도
|
||||
case MONTH : return new String(record, 14, 2); // 월
|
||||
case DAY : return new String(record, 16, 2); // 일
|
||||
case WORK_TIMES : return new String(record, 18, 6); // 근무시간
|
||||
case SEQNO : return new String(record, 24, 9); // 일련번호
|
||||
case AFTER_KBN : return new String(record, 33, 1); // 선_후불 구분
|
||||
case CARD_NO : return new String(record, 34, 20); // 카드 번호
|
||||
case IN_OUT_KBN : return new String(record, 54, 1); // 유출_입 구분
|
||||
case TRANS_FILE_CREATE_YN : return new String(record, 55, 1); // 전송화일 생성여부
|
||||
case COLLECT_ID : return new String(record, 56, 2); // 징수유형코드
|
||||
case LEVY_AMOUNT : return new String(record, 58, 10); // 징수금액
|
||||
case REMAIND_AMOUNT : return new String(record, 68, 10); // 사용후잔액
|
||||
case CARD_OFFICE_ID : return new String(record, 78, 1); // 카드사코드
|
||||
case C_REPAY_KBN : return new String(record, 79, 1); // 경차환불여부
|
||||
case RFID_KBN : return new String(record, 80, 2); // 감면구분
|
||||
case RFID_TAG1 : return new String(record, 82, 24); // TAG1
|
||||
case RFID_TAG2 : return new String(record, 106, 24); // TAG2
|
||||
case TERMINAL_ID : return new String(record, 130, 9); // 단말기 ID
|
||||
case SAM_ID : return new String(record, 139, 16); // SAM ID
|
||||
case SAM_SEQNO : return new String(record, 155, 10); // SAM 거래 일련번호
|
||||
case CARD_SEQNO : return new String(record, 165, 10); // 카드거래 일련번호
|
||||
case BEFORE_AMOUNT : return new String(record, 175, 10); // 거래 전 카드잔액
|
||||
case ALGORITHM_ID : return new String(record, 185, 3); // 알고리즘 ID , 2011.12.12 kde 2 -> 3 하위로 변경됨...
|
||||
case KEY_VERSION : return new String(record, 188, 3); // 개별거래 수집 키 버전 , 2011.12.12 kde 2 -> 3
|
||||
case E_CASH_IDENTIFIER : return new String(record, 191, 3); // 전자화폐 식별자 , 2011.12.12 kde 2 -> 3
|
||||
case SAM_TOT_SEQNO : return new String(record, 194, 10); // SAM 총액거래 수집일련번호
|
||||
case SAM_COLLECT_CNT : return new String(record, 204, 5); // SAM 거래 수집건수
|
||||
case SAM_TOT_AMOUNT : return new String(record, 209, 10); // SAM 누적거래 총액
|
||||
case SIGN_VALUE : return new String(record, 219, 10); // SIGN 값 , 2011.12.12 kde 8 -> 10
|
||||
case PERSON_CODE : return new String(record, 229, 2); // 카드소지자 구분코드
|
||||
case ZIPGE_ID : return new String(record, 231, 12); // 집계 ID
|
||||
case ALIAS_NO : return new String(record, 243, 10); // Alias 번호
|
||||
case ISSUE_ID : return new String(record, 253, 7); // 발행사 ID
|
||||
default : throw new IllegalRecordException( "Cannot find item : " + itemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,492 +0,0 @@
|
||||
/**
|
||||
* <pre>
|
||||
* SamServer
|
||||
* </pre>
|
||||
* 통신 프로토콜 수신 클라이언트
|
||||
*
|
||||
* @since 2006/07/27
|
||||
* @version 1.0 - 2006/07/27
|
||||
*
|
||||
* @author 김종채, <br>
|
||||
* 작성 : 2006/07/27<br>
|
||||
*/
|
||||
package center.transfer;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.util.*;
|
||||
import com.exception.*;
|
||||
import com.resources.data.*;
|
||||
import center.dao.*;
|
||||
/**
|
||||
* 삼원 파일 수신 클라이언트 프로세스<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class SWRecvClient extends CommClient {
|
||||
private int COMM_LENGTH = 28;
|
||||
private int M600_LENGTH = 77;
|
||||
private int M610_LENGTH = 77;
|
||||
private int M620_LENGTH = 35;
|
||||
private int M630_LENGTH = 52;
|
||||
private int M640_LENGTH = 52;
|
||||
private int M300_LENGTH = 38;
|
||||
private int M310_LENGTH = 39;
|
||||
private int M320_LENGTH = 39;
|
||||
|
||||
private CenterTransDAO commDAO; // 파일 전송 이력 클래스 변수
|
||||
private String CARD_RECV;
|
||||
private String RFDATA_RECV;
|
||||
/**
|
||||
* Constructor
|
||||
* @param config
|
||||
*/
|
||||
public SWRecvClient(Properties config){
|
||||
super(config, "SW", "BT" );
|
||||
}
|
||||
/**
|
||||
* startup
|
||||
*/
|
||||
public void startup() {
|
||||
CARD_RECV = config.getProperty("card.recv");
|
||||
RFDATA_RECV = config.getProperty("rfdata.recv");
|
||||
while (true) {
|
||||
try{
|
||||
// 통신 소켓 Open
|
||||
socket = new Socket(sOrgAddr, Integer.parseInt(sLocalPort));
|
||||
System.out.println("CONNECT");
|
||||
reader = socket.getInputStream();
|
||||
writer = socket.getOutputStream();
|
||||
startClient();
|
||||
}catch (ConnectException ce) { // 네트워크 연결 오류
|
||||
// if (logger != null) logFail(" " + ce.getMessage());
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch (SocketException se) { // 소켓 오류
|
||||
// if (logger != null) logFail(" " + se.getMessage());
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch(IOException ioe){ // System 오류
|
||||
if (logger != null) {
|
||||
logFail(" " + ioe.getMessage());
|
||||
logDebug(ioe);
|
||||
}
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch(Exception ex){ // System 오류
|
||||
if (logger != null) {
|
||||
logFail(" " + ex.getMessage());
|
||||
logDebug(ex);
|
||||
}
|
||||
// 10 Min Sleep
|
||||
try { Thread.sleep(SLEEP_10_MIN); } catch (InterruptedException ie) {}
|
||||
}finally{
|
||||
try{ if(reader!=null) reader.close(); }catch(Exception e){}
|
||||
try{ if(writer!=null) writer.close(); }catch(Exception e){}
|
||||
try{ if(socket!=null) socket.close(); }catch(Exception e){}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* startClient
|
||||
*/
|
||||
protected void startClient() throws SocketException, IOException, Exception{
|
||||
while(true){
|
||||
File[] files = receiveFiles();
|
||||
|
||||
for (int i=0; i<files.length; i++) {
|
||||
File f = files[i];
|
||||
logInfo("Recveive File [" + f.getName() +"]");
|
||||
logInfo("Recveive File Size [" + f.length() +"]");
|
||||
}
|
||||
logInfo("File Recveive END");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 파일 수신 처리
|
||||
* @return File[]
|
||||
* @throws IOException
|
||||
* @throws Exception
|
||||
*/
|
||||
public File[] receiveFiles() throws IOException, Exception{
|
||||
boolean done = false;
|
||||
|
||||
Vector vectFiles = new Vector();
|
||||
String sMessage, sSendMsg = null;
|
||||
|
||||
try {
|
||||
String sRecvFileName = null;
|
||||
// 레코드가 담기는 한개의 블럭
|
||||
int nBlockNo = 1;
|
||||
int nRecordSize = 0;
|
||||
// ------------------------------------------------------------- //
|
||||
// 0600 : 업무개시전문 수신 (001:업무개시)
|
||||
// ------------------------------------------------------------- //
|
||||
sMessage = recvMessage(M600_LENGTH);
|
||||
// 전문 체크
|
||||
if (! isSuccessMessage( "0600", sMessage)) {
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// 파일 수신 시작시 디비 접속
|
||||
TODAY = StringUtil.getDate("yyyyMMdd");
|
||||
conn = getConnection();
|
||||
conn.setAutoCommit(false);
|
||||
commDAO = new CenterTransDAO(conn);
|
||||
// ------------------------------------------------------------- //
|
||||
// 0610 : 업무개시전문 송신 (001:업무개시)
|
||||
// ------------------------------------------------------------- //
|
||||
sSendMsg = "FTP 0610RC "
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "001 ";
|
||||
sendMessage(sSendMsg);
|
||||
// FTP 전송처리
|
||||
|
||||
do {
|
||||
sMessage = recvMessage(COMM_LENGTH);
|
||||
String sMsgCode = sMessage.substring(11, 15);
|
||||
// 전문 체크
|
||||
if (! isSuccessMessage(sMessage)) {
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 0600 : 업무종료전문 수신 (004:전체업무종료)
|
||||
// ------------------------------------------------------------- //
|
||||
if( sMsgCode.equals("0600") ){
|
||||
|
||||
sMessage += recvMessage(M600_LENGTH-COMM_LENGTH);
|
||||
if( sMessage.substring(38, 41).equals("004")) break;
|
||||
else throw new Exception(sMessage);
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 0630 : 파일정보지시
|
||||
// ------------------------------------------------------------- //
|
||||
sMessage += recvMessage(M630_LENGTH-COMM_LENGTH);
|
||||
|
||||
// 파일명을 추출하여 코드에 맞는 데이터 및 로그 파일을 생성한다.
|
||||
sFileCode = sMessage.substring(17, 25);
|
||||
sFileName = sMessage.substring(28, 36);
|
||||
|
||||
// 수신중 임시파일명 셋팅
|
||||
sRecvFileName = sFileName.trim();
|
||||
Info data = commDAO.getFileInfo(sFileCode.substring(0,2));
|
||||
if( data == null ){
|
||||
throw new Exception("Unregistered file code :"+sFileCode);
|
||||
}
|
||||
sFileDir = getPath(sFileCode.substring(0,2), data.getString("FILE_DIR"),sRecvFileName );
|
||||
checkDirectory(sFileDir);
|
||||
nDataSize = data.getInt("REC_LEN"); // 레코드길이
|
||||
nDataCount = data.getInt("REC_CNT"); // 시퀀스 당 레코드 건수
|
||||
nSequenceCount = data.getInt("SEQ_CNT"); // 블럭 당 시퀀스 건수
|
||||
|
||||
byte [][] sBytes = new byte[nSequenceCount][]; // data 저장 변수
|
||||
clearBlock(sBytes);
|
||||
|
||||
int nMessageSize = Integer.parseInt(sMessage.substring(36, 48));
|
||||
|
||||
nRecordSize = nDataSize * nDataCount;
|
||||
|
||||
//File dataFile = new File(sDirectory, sFileName);
|
||||
File dataFile = new File(sRecvDir, sRecvFileName);
|
||||
|
||||
long nFileSize = dataFile.exists() ? dataFile.length() : 0;
|
||||
// 통신 중 장애가 발생하면 기존에 전송된 블럭 다음부터 전송되므로 append 모드로 파일 생성
|
||||
fileOutputStream = new FileOutputStream(dataFile, true);
|
||||
// ------------------------------------------------------------- //
|
||||
// 0640 : 파일수신 응답전문 송신
|
||||
// ------------------------------------------------------------- //
|
||||
sSendMsg = "FTP 0640RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ sFileName
|
||||
+ StringUtil.ltos(nFileSize , 12)
|
||||
+ StringUtil.ntos(nRecordSize, 4);
|
||||
sendMessage(sSendMsg);
|
||||
// 전문에서 읽을 바이트수를 결정
|
||||
int recvSize = nMessageSize > nRecordSize ? nRecordSize : nMessageSize;
|
||||
while (true) {
|
||||
// 전문의 공통부분 Read
|
||||
sMessage = recvMessage(COMM_LENGTH);
|
||||
// 전문코드 추출
|
||||
sMsgCode = sMessage.substring(11, 15);
|
||||
if( ! isSuccessMessage(sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- //
|
||||
// 0320 : DATA 송신, 0310 : 결번 통보
|
||||
// ------------------------------------------------------------- //
|
||||
if (sMsgCode.equals("0320") || sMsgCode.equals("0310")) {
|
||||
// 블럭 번호 조회
|
||||
int nRemoteBlock = Integer.parseInt(recvMessage(4));
|
||||
// 이전까지 수신된 블럭과 현재 수신된 블럭이 다를 경우
|
||||
if (nBlockNo != nRemoteBlock) {
|
||||
// 이전까지 수신된 블럭을 파일로 저장한다.
|
||||
appendBlock(sBytes, nDataSize);
|
||||
clearBlock(sBytes);
|
||||
// 현재의 블럭번호를 변경한다.
|
||||
nBlockNo = nRemoteBlock;
|
||||
}
|
||||
// 레코드 번호
|
||||
sMessage = recvMessage(3);
|
||||
int nRecordNo = Integer.parseInt(sMessage);
|
||||
// 데이터 부분총길이
|
||||
sMessage = recvMessage(4);
|
||||
int nDataLength = Integer.parseInt(sMessage);
|
||||
// 전문의 데이터을 읽어들인다.
|
||||
RCV0320(sBytes, nRecordNo, nDataLength, recvSize );
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 0620 : 결번확인지시
|
||||
// ------------------------------------------------------------- //
|
||||
else if (sMsgCode.equals("0620")) {
|
||||
String sBlockNo = recvMessage(4);
|
||||
String sSequenceNo = recvMessage(3);
|
||||
|
||||
int nLastNo = Integer.parseInt(sSequenceNo);
|
||||
|
||||
// 재전송해야 할 결번을 얻어온다.
|
||||
int nCount = getMissingCount(sBytes, nLastNo);
|
||||
String sMissing = getMissingRecords(sBytes);
|
||||
// 0300 : 결번확인보고
|
||||
sSendMsg = "FTP 0300RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ sBlockNo
|
||||
+ sSequenceNo
|
||||
+ StringUtil.ntos(nCount, 3)
|
||||
+ sMissing;
|
||||
sendMessage(sSendMsg);
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 송신완료지시
|
||||
// ------------------------------------------------------------- //
|
||||
else if (sMsgCode.equals("0600")) {
|
||||
sMessage = recvMessage(M600_LENGTH-COMM_LENGTH);
|
||||
// 마지막 수신된 블럭을 파일에 저장한 후 종료한다.
|
||||
appendBlock(sBytes, nDataSize);
|
||||
clearBlock(sBytes);
|
||||
fileOutputStream.close();
|
||||
// ------------------------------------------------------------- //
|
||||
// 0610 : 송신완료보고 (003:개별업무종료)
|
||||
// ------------------------------------------------------------- //
|
||||
sSendMsg = "FTP 0610RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "003 ";
|
||||
sendMessage(sSendMsg);
|
||||
// 송수신 파일정보 입력
|
||||
Info transInfo = null;
|
||||
|
||||
if( sFileName.substring(0,2).compareTo("WK") >= 0 &&
|
||||
sFileName.substring(0,2).compareTo("WZ") <= 0 ){
|
||||
transInfo = new Info();
|
||||
transInfo.setString("FILE_KIND_ID" , sFileCode.substring(0,2) );
|
||||
transInfo.setString("FORMAT_DATE" , TODAY );
|
||||
transInfo.setString("FARE_OFFICE_ID" , "SW");
|
||||
transInfo.setString("FILE_TRANS_KBN" , "R" );
|
||||
transInfo.setString("FILE_TRANS_YN" , "Y" );
|
||||
transInfo.setString("DATA_PROCESS_KBN", "9" );
|
||||
transInfo.setString("DIR_NAME" , sFileDir );
|
||||
transInfo.setString("FILE_NAME" , sFileName.trim() );
|
||||
transInfo.setString("CREATER" , "SamServer");
|
||||
commDAO.insertRecvFileInfo( transInfo );
|
||||
|
||||
long nSeqNo = commDAO.getNextSeq(sFileCode.substring(0,2));
|
||||
|
||||
transInfo.setLong ("DATA_SEQNO" , nSeqNo );
|
||||
commDAO.insertFileTransInfo( transInfo );
|
||||
|
||||
transInfo.setString("FARE_OFFICE_ID" , "01");
|
||||
commDAO.insertOfficeTransInfo( transInfo );
|
||||
|
||||
transInfo.setString("FARE_OFFICE_ID" , "03");
|
||||
commDAO.insertOfficeTransInfo( transInfo );
|
||||
}else{
|
||||
transInfo = new Info();
|
||||
transInfo.setString("FILE_KIND_ID" , sFileCode.substring(0,2) );
|
||||
transInfo.setString("FORMAT_DATE" , TODAY );
|
||||
transInfo.setString("FARE_OFFICE_ID" , "SW");
|
||||
transInfo.setString("FILE_TRANS_KBN" , "R" );
|
||||
transInfo.setString("FILE_TRANS_YN" , "Y" );
|
||||
transInfo.setString("DATA_PROCESS_KBN", "0" );
|
||||
transInfo.setString("DIR_NAME" , sFileDir );
|
||||
transInfo.setString("FILE_NAME" , sFileName.trim() );
|
||||
transInfo.setString("CREATER" , "SamServer");
|
||||
commDAO.insertRecvFileInfo( transInfo );
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
else {
|
||||
throw new Exception(sMessage);
|
||||
}
|
||||
}
|
||||
} while (!done);
|
||||
// ------------------------------------------------------------- //
|
||||
// 0610 : 업무종료보고 (004:전체업무종료)
|
||||
// ------------------------------------------------------------- //
|
||||
sSendMsg = "FTP 0610RC"
|
||||
+ " "
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "004 ";
|
||||
sendMessage(sSendMsg);
|
||||
rename( sRecvDir+sRecvFileName, sFileDir+sFileName.trim() );
|
||||
vectFiles.add(new File(sFileDir, sFileName.trim()));
|
||||
|
||||
conn.commit();
|
||||
}catch (SocketException se){ // 소켓 오류
|
||||
throw se;
|
||||
}catch (IOException ie){ // 입출력 오류
|
||||
throw ie;
|
||||
}catch (Exception ex){ // 시스템 오류
|
||||
throw ex;
|
||||
}finally{
|
||||
try{ if(fileOutputStream!=null) fileOutputStream.close(); }catch(Exception e){}
|
||||
try{ if(conn!=null) conn.close(); }catch(Exception e){}
|
||||
}
|
||||
File[] files = new File[vectFiles.size()];
|
||||
vectFiles.toArray(files);
|
||||
return files;
|
||||
}
|
||||
/**
|
||||
* 결번 개수를 구한다.
|
||||
* @param sRecords
|
||||
* @param nLastNo
|
||||
* @return
|
||||
*/
|
||||
private int getMissingCount(byte[][] sBytes, int nLastNo) {
|
||||
int nCount = 0;
|
||||
for (int i = 0; i < nLastNo; i++) {
|
||||
if (sBytes[i] == null) {
|
||||
nCount++;
|
||||
}
|
||||
}
|
||||
return nCount;
|
||||
}
|
||||
/**
|
||||
* 스트링에서 결번을 읽어들인다.('0': 미수신, '1': 수신)
|
||||
* @param sMessage
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
private String getMissingRecords(byte[][] sBytes) {
|
||||
char []caMissing = new char[sBytes.length];
|
||||
for (int i = 0; i < sBytes.length; i++) {
|
||||
if (sBytes[i] == null) {
|
||||
caMissing[i] = '0'; // 미수신 '0'
|
||||
}
|
||||
else {
|
||||
caMissing[i] = '1'; // 수신 '1'
|
||||
}
|
||||
}
|
||||
return String.valueOf(caMissing);
|
||||
}
|
||||
/**
|
||||
* 수신된 데이터를 블럭단위로 파일에 기록
|
||||
* @param sBytes
|
||||
* @param nDataSize
|
||||
* @throws IOException
|
||||
*/
|
||||
private void appendBlock(byte[][] sBytes, int nDataSize)
|
||||
throws IOException {
|
||||
for (int i = 0; i < sBytes.length; i++) {
|
||||
// 최종 레코드까지 기록
|
||||
if (sBytes[i] == null) {
|
||||
break;
|
||||
}
|
||||
fileOutputStream.write(sBytes[i]);
|
||||
}
|
||||
fileOutputStream.flush();
|
||||
}
|
||||
/**
|
||||
* 블럭의 레코드(String) 들을 초기화
|
||||
* @param sBytes
|
||||
*/
|
||||
private void clearBlock(byte[][] sBytes) {
|
||||
for (int i = 0; i < sBytes.length; i++) {
|
||||
sBytes[i] = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 파일에 따라 저장할 디렉토리 정보를 추출
|
||||
* @param sFileKindCode
|
||||
* @param sBaseDir
|
||||
* @param sFileName
|
||||
* @return String
|
||||
*/
|
||||
public String getPath(String sFileKindCode,String sBaseDir, String sFileName){
|
||||
StringBuffer sFileDir = new StringBuffer(sBaseDir);
|
||||
if( sFileKindCode.compareTo("WK") >= 0 && sFileKindCode.compareTo("WZ") <= 0 ){ // RF 운영정보
|
||||
sFileDir.append( TODAY + File.separator );
|
||||
}else if( sFileKindCode.startsWith("TY") || sFileKindCode.startsWith("WJ") ){ // 반송내역
|
||||
}
|
||||
return sFileDir.toString();
|
||||
}
|
||||
/**
|
||||
* 파일 디렉토리 존재유무를 체크하고 생성하는 메소드
|
||||
* @param sFileDir
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean checkDirectory(String sFileDir){
|
||||
String sTemp [] = sFileDir.split(File.separator);
|
||||
String sCreatDir = "";
|
||||
if( sTemp != null ){
|
||||
for( int idx = 0; idx < sTemp.length; idx++){
|
||||
sCreatDir = sCreatDir + sTemp[idx] + File.separator;
|
||||
if( !new File(sCreatDir).isDirectory() ){
|
||||
new File(sCreatDir).mkdir();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Help 메시지 출력
|
||||
*/
|
||||
public static void showHelp(String sClass) {
|
||||
System.err.println("Command :");
|
||||
System.err.println("\tjava " + sClass + " -Dftp.conf=CONFIG_FILE");
|
||||
System.err.println("");
|
||||
}
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
if(args.length != 0){
|
||||
showHelp("center.transfer.SWRecvClient");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
String sConfFile = System.getProperty("ftp.conf");
|
||||
if (sConfFile == null || sConfFile.equals("")) {
|
||||
showHelp("center.transfer.SWRecvClient");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Properties config = new Properties();
|
||||
try {
|
||||
config.load(sConfFile);
|
||||
}
|
||||
catch (IOException ie) {
|
||||
System.err.println("Can not read configuration file.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
SWRecvClient client = new SWRecvClient(config);
|
||||
client.startup();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println("Starting Demon is failed");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,415 +0,0 @@
|
||||
package center.transfer;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.sql.Connection;
|
||||
import java.util.Date;
|
||||
|
||||
import com.util.*;
|
||||
import com.exception.*;
|
||||
import com.resources.data.*;
|
||||
import center.dao.*;
|
||||
/**
|
||||
* 삼원 파일 송신 클라이언트 프로세스<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class SWSendClient extends CommClient {
|
||||
private int COMM_LENGTH = 28;
|
||||
private int M600_LENGTH = 77;
|
||||
private int M610_LENGTH = 77;
|
||||
private int M620_LENGTH = 35;
|
||||
private int M630_LENGTH = 52;
|
||||
private int M640_LENGTH = 52;
|
||||
private int M300_LENGTH = 38;
|
||||
private int M310_LENGTH = 39;
|
||||
private int M320_LENGTH = 39;
|
||||
/**
|
||||
* Constructor
|
||||
* @param config
|
||||
*/
|
||||
public SWSendClient(Properties config){
|
||||
super(config, "SW", "PT" );
|
||||
}
|
||||
/**
|
||||
* startup
|
||||
*/
|
||||
public void startup() {
|
||||
Info fileInfo = null;
|
||||
Connection conn = null; // Connection
|
||||
CenterTransDAO commDAO = null; // 파일 전송 이력 클래스 변수
|
||||
|
||||
try{
|
||||
conn = getConnection();
|
||||
conn.setAutoCommit(false);
|
||||
commDAO = new CenterTransDAO(conn);
|
||||
|
||||
while (true) {
|
||||
try{
|
||||
// 미전송 파일 정보 조회(S:송신,0:미처리)
|
||||
fileInfo = commDAO.getSendFileInfo(sOrgCode, "S", "N");
|
||||
if( fileInfo != null ){
|
||||
// 통신 소켓 Open
|
||||
socket = new Socket(sOrgAddr, Integer.parseInt(sOrgPort));
|
||||
System.out.println("CONNECT");
|
||||
reader = socket.getInputStream();
|
||||
writer = socket.getOutputStream();
|
||||
|
||||
nSeq = fileInfo.getLong("SEQ");
|
||||
|
||||
// 레코드 길이
|
||||
this.nDataSize = fileInfo.getInt("REC_LEN");
|
||||
// 레코드 건수
|
||||
this.nDataCount = fileInfo.getInt("REC_CNT");
|
||||
// 블럭당 시퀀스 개수
|
||||
this.nSequenceCount = fileInfo.getInt("SEQ_CNT");
|
||||
// 파일전송코드
|
||||
this.sFileCode = fileInfo.getString("FILE_CODE")+" ";
|
||||
// 파일명
|
||||
this.sFileName = fileInfo.getString("FILE_NAME");
|
||||
// 파일 디렉토리
|
||||
this.sFileDir = fileInfo.getString("DIR_NAME");
|
||||
|
||||
File fSendFile = new File(sFileDir, sFileName);
|
||||
|
||||
logInfo("");
|
||||
logInfo("File Send START");
|
||||
logInfo("Send File : " + sFileName);
|
||||
logInfo("Send File Size: " + fSendFile.length());
|
||||
// 파일 전송
|
||||
int nReturn = sendFile(fSendFile);
|
||||
logInfo("File Send END ["+nReturn+"]");
|
||||
|
||||
if( nReturn == 0 ){ // 파일 전송 완료 후 파일 전송 상태 반영
|
||||
commDAO.updTransFileInfo(nSeq, "Y", "SamClient");
|
||||
conn.commit();
|
||||
}else if( nReturn == 1 ){ // 파일 미존재시
|
||||
commDAO.updTransFileInfo(nSeq, "X", "SamClient");
|
||||
conn.commit();
|
||||
}
|
||||
}
|
||||
else { // 전송자료 미존재
|
||||
// 1 Min Sleep
|
||||
try { Thread.sleep(SLEEP_01_MIN); } catch (InterruptedException ie) {}
|
||||
}
|
||||
}catch (ConnectException ce) { // 네트워크 연결 오류
|
||||
if (logger != null) logFail(" " + ce.getMessage());
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch (SocketException se) { // 소켓 오류
|
||||
if (logger != null) logFail(" " + se.getMessage());
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch(IOException ioe){ // System 오류
|
||||
if (logger != null) {
|
||||
logFail(" " + ioe.getMessage());
|
||||
logDebug(ioe);
|
||||
}
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch(Exception ex){ // System 오류
|
||||
if (logger != null) {
|
||||
logFail(" " + ex.getMessage());
|
||||
logDebug(ex);
|
||||
}
|
||||
// 10 Min Sleep
|
||||
try { Thread.sleep(SLEEP_10_MIN); } catch (InterruptedException ie) {}
|
||||
}finally{
|
||||
try{ if(reader!=null) reader.close(); }catch(Exception e){}
|
||||
try{ if(writer!=null) writer.close(); }catch(Exception e){}
|
||||
try{ if(socket!=null) socket.close(); }catch(Exception e){}
|
||||
}
|
||||
// 3 Sec Sleep
|
||||
try { Thread.sleep( SLEEP_03_SEC ); } catch (InterruptedException ie) {}
|
||||
}
|
||||
}catch(Exception e){
|
||||
logDebug(e);
|
||||
}finally{
|
||||
try{ if(conn!=null)conn.close(); }catch(Exception e){}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 파일전송 (0:정상처리, 1:FILE NOT FOUND, 2:수신전문 오류)
|
||||
* @param file
|
||||
* @return int
|
||||
* @throws SocketException
|
||||
* @throws IOException
|
||||
* @throws Exception
|
||||
*/
|
||||
public int sendFile(File file) throws Exception{
|
||||
int nReturn = 0;
|
||||
|
||||
try {
|
||||
int nBlockNo = 1;
|
||||
String sMessage, sSendMsg = null;
|
||||
|
||||
// Read File
|
||||
fileAccess = new RandomAccessFile(file,"r");
|
||||
|
||||
int nRecordSize = nDataSize * nDataCount;
|
||||
long nFileSize = fileAccess.length();
|
||||
// ------------------------------------- //
|
||||
// 업무개시전문 송신 (0600 / 001)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0600RC"
|
||||
+ " "
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "001 ";
|
||||
sMessage = dialogMessage(sSendMsg, M600_LENGTH);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0610", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
|
||||
// ------------------------------------- //
|
||||
// 파일수신 요청전문 송신 (0630)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0630RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ sFileName
|
||||
+ StringUtil.ltos(nFileSize , 12)
|
||||
+ StringUtil.ntos(nRecordSize, 4);
|
||||
sMessage = dialogMessage(sSendMsg, M630_LENGTH);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0640", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
|
||||
// 센터에 이미 파일이 존재하면 그 크기만큼 파일을 스킵한다.
|
||||
long nRemoteFileSize = 0;
|
||||
nRemoteFileSize = Long.parseLong( sMessage.substring(36, 48));
|
||||
|
||||
while (true) {
|
||||
int nCount = 0;
|
||||
// 한 블럭(최대 100개의 레코드)의 데이터를 파일로부터 읽어들인다.
|
||||
for( int i = 0, nRecordNo = 1; i< nSequenceCount; i++, nRecordNo++){
|
||||
// setting offset for reading file data
|
||||
long nOffSet
|
||||
= ((nBlockNo-1)*nSequenceCount*nRecordSize) + (i*nRecordSize) + nRemoteFileSize;
|
||||
|
||||
if( nOffSet+1 > nFileSize ) { // offset 이 파일크기보다 클때 종료
|
||||
break;
|
||||
}
|
||||
byte [] buff // 파일 Read
|
||||
= getFileData(fileAccess, nOffSet, nRecordSize);
|
||||
// ------------------------------------- //
|
||||
// 데이터 전송 (0320)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0320RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ StringUtil.ntos(nBlockNo, 4)
|
||||
+ StringUtil.ntos(nRecordNo, 3)
|
||||
+ StringUtil.ntos(buff.length, 4);
|
||||
sendBinaryMessage(sSendMsg.getBytes()); // send message header
|
||||
sendBinaryMessage(buff); // send file data
|
||||
nCount++;
|
||||
}
|
||||
|
||||
// 송신할 레코드가 없을 경우 송신을 완료한다.
|
||||
if (nCount == 0) {
|
||||
break;
|
||||
}
|
||||
while (true) {
|
||||
// ------------------------------------- //
|
||||
// 결번확인 요청 및 응답 (0620, 0300)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0620RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ StringUtil.ntos(nBlockNo, 4)
|
||||
+ StringUtil.ntos(nCount, 3) ;
|
||||
|
||||
sMessage = dialogMessage(sSendMsg, M300_LENGTH + nSequenceCount);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0300", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// 재전송해야 할 결번을 얻어온다.
|
||||
int[] nMissing = getMissingRecords(sMessage, nCount);
|
||||
// 결번이 없을 경우 다음 블럭을 전송하도록 한다.
|
||||
if (nMissing == null || nMissing.length == 0) {
|
||||
// Sleep Time 5 Second
|
||||
try{
|
||||
Thread.sleep(BLOCK_SLEEP_TIME);
|
||||
}catch(Exception se){
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 결번을 재전송한다.
|
||||
for (int i = 0; i < nMissing.length; i++) {
|
||||
int nMissNo = nMissing[i];
|
||||
// setting offset for reading file data
|
||||
long nOffSet
|
||||
= ((nBlockNo-1)*nSequenceCount*nRecordSize) + ((nMissNo-1) * nRecordSize)+nRemoteFileSize;
|
||||
|
||||
if( nOffSet > nFileSize ) { // offset 이 파일크기보다 클때 종료
|
||||
break;
|
||||
}
|
||||
byte [] buff // 파일 Read
|
||||
= getFileData(fileAccess, nOffSet, nRecordSize);
|
||||
// ------------------------------------- //
|
||||
// 결번 데이터 전송 (0310)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0310RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ StringUtil.ntos(nBlockNo, 4)
|
||||
+ StringUtil.ntos(nMissNo, 3)
|
||||
+ StringUtil.ntos(buff.length, 4);
|
||||
sendBinaryMessage(sSendMsg.getBytes()); // send message header
|
||||
sendBinaryMessage(buff); // send file data
|
||||
|
||||
if (nMissNo > nCount ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nBlockNo++;
|
||||
}
|
||||
|
||||
// ------------------------------------- //
|
||||
// 파일수신 종료전문 송신 (0600 / 003)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0600RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "003 ";
|
||||
sMessage = dialogMessage(sSendMsg, M600_LENGTH);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0610", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// ------------------------------------- //
|
||||
// 종료전문 송신 (0600 / 004)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0600RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "004 ";
|
||||
sMessage = dialogMessage(sSendMsg, M600_LENGTH);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0610", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
}catch (FileNotFoundException fe) { // 파일 미존재
|
||||
nReturn = 1;
|
||||
if (logger != null) logFail("[ERROR 800] " + fe.getMessage());
|
||||
}catch (MessageException me){ // 수신전문 오류
|
||||
nReturn = 2;
|
||||
try { sendMessage(CMDFAIL("800")); }catch (Exception ex) { }
|
||||
if (logger != null) { logFail("[ERROR 800] " + me.getMessage()); }
|
||||
}catch (SocketException se){ // 소켓 오류
|
||||
throw se;
|
||||
}catch (IOException ie){ // 입출력 오류
|
||||
try { sendMessage(CMDFAIL("090")); }catch (Exception ex) { }
|
||||
throw ie;
|
||||
}catch (Exception ex){ // 시스템 오류
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
try { if (fileAccess != null) { fileAccess.close(); } } catch (IOException ie) { }
|
||||
}
|
||||
return nReturn;
|
||||
}
|
||||
/**
|
||||
* read file data
|
||||
* @param fileAccess
|
||||
* @param offset
|
||||
* @param nBufferSize
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
private byte[] getFileData(RandomAccessFile fileAccess, long offset, int nBufferSize) throws IOException{
|
||||
byte[] buf = new byte[nBufferSize];
|
||||
fileAccess.seek(offset);
|
||||
int nLen = fileAccess.read(buf);
|
||||
if(nLen < nBufferSize){
|
||||
byte[] dest = new byte[nLen];
|
||||
System.arraycopy(buf, 0, dest, 0, nLen);
|
||||
buf = dest;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
/**
|
||||
* 스트링에서 결번을 읽어들인다.('0': 미수신, '1': 수신)
|
||||
* @param sMessage
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
private int[] getMissingRecords(String sMessage, int len) {
|
||||
int index = 0;
|
||||
int []intArr = new int[len];
|
||||
String sMissing = sMessage.substring(M300_LENGTH);
|
||||
// 레코드 번호는 1부터 시작된다.
|
||||
for (int i = 0; i < len; i++) {
|
||||
// 값이 '0'이면 미수신 레코드
|
||||
if (sMissing.charAt(i) == '0') {
|
||||
intArr[index]=i;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
int [] nMissing = new int[index];
|
||||
System.arraycopy(intArr, 0, nMissing, 0, index);
|
||||
|
||||
return nMissing;
|
||||
}
|
||||
/**
|
||||
* 오류메시지 전문 생성
|
||||
* @param sErrorCode
|
||||
* @return String
|
||||
*/
|
||||
public String CMDFAIL(String sErrorCode) {
|
||||
String sFailMsg = "FTP 0600RC "
|
||||
+ sErrorCode // error code
|
||||
+ dateFormat.format(new Date())
|
||||
+ "004 ";
|
||||
return sFailMsg;
|
||||
}
|
||||
/**
|
||||
* Help 메시지 출력
|
||||
*/
|
||||
public static void showHelp(String sClass) {
|
||||
System.err.println("Command :");
|
||||
System.err.println("\tjava " + sClass + " -Dftp.conf=CONFIG_FILE");
|
||||
System.err.println("");
|
||||
}
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
if(args.length != 0){
|
||||
showHelp("center.transfer.SWSendClient");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
String sConfFile = System.getProperty("ftp.conf");
|
||||
if (sConfFile == null || sConfFile.equals("")) {
|
||||
showHelp("center.transfer.SWSendClient");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Properties config = new Properties();
|
||||
try {
|
||||
config.load(sConfFile);
|
||||
}
|
||||
catch (IOException ie) {
|
||||
System.err.println("Can not read configuration file.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
SWSendClient client = new SWSendClient(config);
|
||||
client.startup();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println("Starting Demon is failed.");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,449 +0,0 @@
|
||||
package center.transfer;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.sql.Connection;
|
||||
import java.util.Date;
|
||||
|
||||
import center.dao.VanTransDAO;
|
||||
|
||||
import com.util.*;
|
||||
import com.exception.*;
|
||||
import com.resources.data.*;
|
||||
/**
|
||||
* 스마트카드 파일 송신 클라이언트 프로세스<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class TMSendClient extends CommClient {
|
||||
private int COMM_LENGTH = 28;
|
||||
private int M600_LENGTH = 77;
|
||||
private int M610_LENGTH = 77;
|
||||
private int M620_LENGTH = 35;
|
||||
private int M630_LENGTH = 52;
|
||||
private int M640_LENGTH = 52;
|
||||
private int M300_LENGTH = 38;
|
||||
private int M310_LENGTH = 39;
|
||||
private int M320_LENGTH = 39;
|
||||
|
||||
private static String JOB_CODE = "FTP";
|
||||
private static String ORGANIZATION_CODE = "70000007";
|
||||
private static int TCPIP_HEADER = 4;
|
||||
private static String GUBUN_CODE = "R";
|
||||
private static String SENDER_FLAG = "E";
|
||||
private static String USERNAME = "SAMWONFA ";
|
||||
private static String PASSWORD = "samwonfa ";
|
||||
/**
|
||||
* Constructor
|
||||
* @param config
|
||||
*/
|
||||
public TMSendClient(Properties config){
|
||||
super(config, "TM", "PT" );
|
||||
}
|
||||
/**
|
||||
* startup
|
||||
*/
|
||||
public void startup() {
|
||||
Info fileInfo = null;
|
||||
Connection conn = null; // Connection
|
||||
VanTransDAO commDAO = null; // 파일 전송 이력 클래스 변수
|
||||
|
||||
try{
|
||||
conn = getConnection();
|
||||
conn.setAutoCommit(false);
|
||||
commDAO = new VanTransDAO(conn);
|
||||
|
||||
while (true) {
|
||||
try{
|
||||
// 미전송 파일 정보 조회(S:송신,0:미처리)
|
||||
fileInfo = commDAO.getSendFileInfo(sOrgCode, "S", "N");
|
||||
if( fileInfo != null ){
|
||||
// 통신 소켓 Open
|
||||
socket = new Socket(sOrgAddr, Integer.parseInt(sOrgPort));
|
||||
System.out.println("CONNECT");
|
||||
reader = socket.getInputStream();
|
||||
writer = socket.getOutputStream();
|
||||
|
||||
nSeq = fileInfo.getLong("SEQ");
|
||||
|
||||
// 레코드 길이
|
||||
this.nDataSize = fileInfo.getInt("REC_LEN");
|
||||
// 레코드 건수
|
||||
this.nDataCount = fileInfo.getInt("REC_CNT");
|
||||
// 블럭당 시퀀스 개수
|
||||
this.nSequenceCount = fileInfo.getInt("SEQ_CNT");
|
||||
// 파일전송코드
|
||||
this.sFileCode = fileInfo.getString("FILE_NAME");
|
||||
// 파일명
|
||||
this.sFileName = fileInfo.getString("FILE_NAME");
|
||||
// 파일 디렉토리
|
||||
this.sFileDir = fileInfo.getString("DIR_NAME");
|
||||
logInfo("REC_LEN : " + nDataSize);
|
||||
logInfo("REC_CNT : " + nDataCount);
|
||||
logInfo("SEQ_CNT : " + nSequenceCount);
|
||||
logInfo("FILE_CODE : " + sFileCode);
|
||||
logInfo("FILE_NAME : " + sFileName);
|
||||
logInfo("DIR_NAME : " + sFileDir);
|
||||
File fSendFile = new File(sFileDir, sFileName);
|
||||
|
||||
logInfo("");
|
||||
logInfo("File Send START");
|
||||
logInfo("Send File : " + sFileName);
|
||||
logInfo("Send File Size: " + fSendFile.length());
|
||||
// 파일 전송
|
||||
int nReturn = sendFile(fSendFile);
|
||||
logInfo("File Send END ["+nReturn+"]");
|
||||
|
||||
if( nReturn == 0 ){ // 파일 전송 완료 후 파일 전송 상태 반영
|
||||
commDAO.updTransFileInfo(nSeq, "S","Y","9", "CoreClient");
|
||||
conn.commit();
|
||||
}if( nReturn == 1 ){ // 파일 미존재시
|
||||
commDAO.updTransFileInfo(nSeq, "S","N",nReturn+"", "CoreClient");
|
||||
conn.commit();
|
||||
}if( nReturn == 2 ){ // 파일 기송신 완료
|
||||
commDAO.updTransFileInfo(nSeq, "S","Y",nReturn+"", "CoreClient");
|
||||
conn.commit();
|
||||
}if( nReturn == 4 ){ // 송신 파일 사이즈 오류
|
||||
commDAO.updTransFileInfo(nSeq, "S","N",nReturn+"", "CoreClient");
|
||||
conn.commit();
|
||||
}
|
||||
}
|
||||
else { // 전송자료 미존재
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}
|
||||
}catch (ConnectException ce) { // 네트워크 연결 오류
|
||||
if (logger != null) logFail(" " + ce.getMessage());
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch (SocketException se) { // 소켓 오류
|
||||
if (logger != null) logFail(" " + se.getMessage());
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch(IOException ioe){ // System 오류
|
||||
if (logger != null) {
|
||||
logFail(" " + ioe.getMessage());
|
||||
logDebug(ioe);
|
||||
}
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch(Exception ex){ // System 오류
|
||||
if (logger != null) {
|
||||
logFail(" " + ex.getMessage());
|
||||
logDebug(ex);
|
||||
}
|
||||
// 10 Min Sleep
|
||||
try { Thread.sleep(SLEEP_10_MIN); } catch (InterruptedException ie) {}
|
||||
}finally{
|
||||
try{ if(reader!=null) reader.close(); }catch(Exception e){}
|
||||
try{ if(writer!=null) writer.close(); }catch(Exception e){}
|
||||
try{ if(socket!=null) socket.close(); }catch(Exception e){}
|
||||
}
|
||||
// 2 Sec Sleep
|
||||
try { Thread.sleep( SLEEP_02_SEC ); } catch (InterruptedException ie) {}
|
||||
}
|
||||
}catch(Exception e){
|
||||
logDebug(e);
|
||||
}finally{
|
||||
try{ if(conn!=null)conn.close(); }catch(Exception e){}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 파일전송 (0:정상처리, 1:FILE NOT FOUND, 2:수신전문 오류, 3: 응답코드 오류, 4:송신파일사이즈오류)
|
||||
* @param file
|
||||
* @return int
|
||||
* @throws SocketException
|
||||
* @throws IOException
|
||||
* @throws Exception
|
||||
*/
|
||||
public int sendFile(File file) throws Exception{
|
||||
int nReturn = 0;
|
||||
|
||||
try {
|
||||
int nBlockNo = 1;
|
||||
String sMessage, sSendMsg, sMsgLength = null;
|
||||
|
||||
// Read File
|
||||
fileAccess = new RandomAccessFile(file,"r");
|
||||
|
||||
int nRecordSize = nDataSize * nDataCount;
|
||||
long nFileSize = fileAccess.length();
|
||||
// 응답코드 체크(000:정상)
|
||||
if( nFileSize == 0 ){
|
||||
nReturn = 4;
|
||||
return nReturn;
|
||||
}
|
||||
// ------------------------------------- //
|
||||
// 업무개시전문 송신 (0600 / 001)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = JOB_CODE+ORGANIZATION_CODE+"0600"+GUBUN_CODE+SENDER_FLAG
|
||||
+ " "
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "001"+USERNAME+PASSWORD;
|
||||
sMsgLength = StringUtil.ltos(sSendMsg.length(), 4);
|
||||
sMessage = dialogMessage(sMsgLength+sSendMsg, M600_LENGTH + TCPIP_HEADER).substring(TCPIP_HEADER);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0610", sMessage)){
|
||||
nReturn = 3;
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
|
||||
// ------------------------------------- //
|
||||
// 파일수신 요청전문 송신 (0630)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = JOB_CODE+ORGANIZATION_CODE+"0630"+GUBUN_CODE+SENDER_FLAG
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ sFileName
|
||||
+ StringUtil.ltos(nFileSize , 12)
|
||||
+ StringUtil.ntos(nRecordSize + M310_LENGTH, 4);
|
||||
|
||||
sMsgLength = StringUtil.ltos(sSendMsg.length(), 4);
|
||||
sMessage = dialogMessage(sMsgLength+sSendMsg, M630_LENGTH + TCPIP_HEADER).substring(TCPIP_HEADER);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0640", sMessage)){
|
||||
nReturn = 3;
|
||||
if(sMessage.substring(25, 28).equals("630")) nReturn = 2;
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
|
||||
// 센터에 이미 파일이 존재하면 그 크기만큼 파일을 스킵한다.
|
||||
long nRemoteFileSize = 0;
|
||||
nRemoteFileSize = Long.parseLong( sMessage.substring(36, 48));
|
||||
|
||||
while (true) {
|
||||
int nCount = 0;
|
||||
// 한 블럭(최대 100개의 레코드)의 데이터를 파일로부터 읽어들인다.
|
||||
for( int i = 0, nRecordNo = 1; i< nSequenceCount; i++, nRecordNo++){
|
||||
// setting offset for reading file data
|
||||
long nOffSet
|
||||
= ((nBlockNo-1)*nSequenceCount*nRecordSize) + (i*nRecordSize) + nRemoteFileSize;
|
||||
|
||||
if( nOffSet+1 > nFileSize ) { // offset 이 파일크기보다 클때 종료
|
||||
break;
|
||||
}
|
||||
byte [] buff // 파일 Read
|
||||
= getFileData(fileAccess, nOffSet, nRecordSize);
|
||||
// ------------------------------------- //
|
||||
// 데이터 전송 (0320)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = JOB_CODE+ORGANIZATION_CODE+"0320"+GUBUN_CODE+SENDER_FLAG
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ StringUtil.ntos(nBlockNo, 4)
|
||||
+ StringUtil.ntos(nRecordNo, 3)
|
||||
+ StringUtil.ntos(buff.length, 4);
|
||||
sMsgLength = StringUtil.ltos(sSendMsg.length()+buff.length, 4);
|
||||
sendBinaryMessage((sMsgLength+sSendMsg).getBytes()); // send message header
|
||||
sendBinaryMessage(buff); // send file data
|
||||
nCount++;
|
||||
}
|
||||
|
||||
// 송신할 레코드가 없을 경우 송신을 완료한다.
|
||||
if (nCount == 0) {
|
||||
break;
|
||||
}
|
||||
while (true) {
|
||||
// ------------------------------------- //
|
||||
// 결번확인 요청 및 응답 (0620, 0300)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = JOB_CODE+ORGANIZATION_CODE+"0620"+GUBUN_CODE+SENDER_FLAG
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ StringUtil.ntos(nBlockNo, 4)
|
||||
+ StringUtil.ntos(nCount, 3) ;
|
||||
|
||||
sMsgLength = StringUtil.ltos(sSendMsg.length(), 4);
|
||||
sMessage = dialogMessage(sMsgLength+sSendMsg, M300_LENGTH + nSequenceCount + TCPIP_HEADER).substring(TCPIP_HEADER);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0300", sMessage)){
|
||||
nReturn = 3;
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// 재전송해야 할 결번을 얻어온다.
|
||||
int[] nMissing = getMissingRecords(sMessage, nCount);
|
||||
// 결번이 없을 경우 다음 블럭을 전송하도록 한다.
|
||||
if (nMissing == null || nMissing.length == 0) {
|
||||
break;
|
||||
}
|
||||
// 결번을 재전송한다.
|
||||
for (int i = 0; i < nMissing.length; i++) {
|
||||
int nMissNo = nMissing[i];
|
||||
// setting offset for reading file data
|
||||
long nOffSet
|
||||
= ((nBlockNo-1)*nSequenceCount*nRecordSize) + ((nMissNo-1) * nRecordSize)+nRemoteFileSize;
|
||||
|
||||
if( nOffSet > nFileSize ) { // offset 이 파일크기보다 클때 종료
|
||||
break;
|
||||
}
|
||||
byte [] buff // 파일 Read
|
||||
= getFileData(fileAccess, nOffSet, nRecordSize);
|
||||
// ------------------------------------- //
|
||||
// 결번 데이터 전송 (0310)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = JOB_CODE+ORGANIZATION_CODE+"0310"+GUBUN_CODE+SENDER_FLAG
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ StringUtil.ntos(nBlockNo, 4)
|
||||
+ StringUtil.ntos(nMissNo, 3)
|
||||
+ StringUtil.ntos(buff.length, 4);
|
||||
sMsgLength = StringUtil.ltos(sSendMsg.length()+buff.length, 4);
|
||||
sendBinaryMessage((sMsgLength+sSendMsg).getBytes()); // send message header
|
||||
sendBinaryMessage(buff); // send file data
|
||||
|
||||
if (nMissNo > nCount ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nBlockNo++;
|
||||
}
|
||||
|
||||
// ------------------------------------- //
|
||||
// 파일수신 종료전문 송신 (0600 / 003)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = JOB_CODE+ORGANIZATION_CODE+"0600"+GUBUN_CODE+SENDER_FLAG
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "003"+USERNAME+PASSWORD;
|
||||
sMsgLength = StringUtil.ltos(sSendMsg.length(), 4);
|
||||
sMessage = dialogMessage(sMsgLength+sSendMsg, M600_LENGTH + TCPIP_HEADER).substring(TCPIP_HEADER);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0610", sMessage)){
|
||||
nReturn = 3;
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// ------------------------------------- //
|
||||
// 종료전문 송신 (0600 / 004)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = JOB_CODE+ORGANIZATION_CODE+"0600"+GUBUN_CODE+SENDER_FLAG
|
||||
+ " "
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "004"+USERNAME+PASSWORD;
|
||||
sMsgLength = StringUtil.ltos(sSendMsg.length(), 4);
|
||||
sMessage = dialogMessage(sMsgLength+sSendMsg, M600_LENGTH + TCPIP_HEADER).substring(TCPIP_HEADER);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0610", sMessage)){
|
||||
nReturn = 3;
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
}catch (FileNotFoundException fe) { // 파일 미존재
|
||||
nReturn = 1;
|
||||
if (logger != null) logFail("[ERROR 800] " + fe.getMessage());
|
||||
}catch (MessageException me){ // 수신전문 오류
|
||||
try { sendMessage(CMDFAIL("800")); }catch (Exception ex) { }
|
||||
if (logger != null) { logFail("[ERROR 800] " + me.getMessage()); }
|
||||
}catch (SocketException se){ // 소켓 오류
|
||||
throw se;
|
||||
}catch (IOException ie){ // 입출력 오류
|
||||
try { sendMessage(CMDFAIL("090")); }catch (Exception ex) { }
|
||||
throw ie;
|
||||
}catch (Exception ex){ // 시스템 오류
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
try { if (fileAccess != null) { fileAccess.close(); } } catch (IOException ie) { }
|
||||
}
|
||||
return nReturn;
|
||||
}
|
||||
/**
|
||||
* read file data
|
||||
* @param fileAccess
|
||||
* @param offset
|
||||
* @param nBufferSize
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
private byte[] getFileData(RandomAccessFile fileAccess, long offset, int nBufferSize) throws IOException{
|
||||
byte[] buf = new byte[nBufferSize];
|
||||
fileAccess.seek(offset);
|
||||
int nLen = fileAccess.read(buf);
|
||||
if(nLen < nBufferSize){
|
||||
byte[] dest = new byte[nLen];
|
||||
System.arraycopy(buf, 0, dest, 0, nLen);
|
||||
buf = dest;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
/**
|
||||
* 스트링에서 결번을 읽어들인다.('0': 미수신, '1': 수신)
|
||||
* @param sMessage
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
private int[] getMissingRecords(String sMessage, int len) {
|
||||
int index = 0;
|
||||
int []intArr = new int[len];
|
||||
String sMissing = sMessage.substring(M300_LENGTH);
|
||||
// 레코드 번호는 1부터 시작된다.
|
||||
for (int i = 0; i < len; i++) {
|
||||
// 값이 '0'이면 미수신 레코드
|
||||
if (sMissing.charAt(i) == '0') {
|
||||
intArr[index]=i;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
int [] nMissing = new int[index];
|
||||
System.arraycopy(intArr, 0, nMissing, 0, index);
|
||||
|
||||
return nMissing;
|
||||
}
|
||||
/**
|
||||
* 오류메시지 전문 생성
|
||||
* @param sErrorCode
|
||||
* @return String
|
||||
*/
|
||||
public String CMDFAIL(String sErrorCode) {
|
||||
String sFailMsg = "FTP 0600RC "
|
||||
+ sErrorCode // error code
|
||||
+ dateFormat.format(new Date())
|
||||
+ "004"+USERNAME+PASSWORD;
|
||||
String sMsgLength = StringUtil.ltos(sFailMsg.length(), 4);
|
||||
return sMsgLength+sFailMsg;
|
||||
}
|
||||
/**
|
||||
* Help 메시지 출력
|
||||
*/
|
||||
public static void showHelp(String sClass) {
|
||||
System.err.println("Command :");
|
||||
System.err.println("\tjava " + sClass + " -Dftp.conf=CONFIG_FILE");
|
||||
System.err.println("");
|
||||
}
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
if(args.length != 0){
|
||||
showHelp("center.transfer.TMSendClient");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
String sConfFile = System.getProperty("ftp.conf");
|
||||
if (sConfFile == null || sConfFile.equals("")) {
|
||||
showHelp("center.transfer.TMSendClient");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Properties config = new Properties();
|
||||
try {
|
||||
config.load(sConfFile);
|
||||
}
|
||||
catch (IOException ie) {
|
||||
System.err.println("환경파일을 읽어 들일 수 없습니다.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
TMSendClient client = new TMSendClient(config);
|
||||
client.startup();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println("데몬을 구동하는데 실패했습니다.");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,610 +0,0 @@
|
||||
/**
|
||||
* <pre>
|
||||
* SamServer
|
||||
* </pre>
|
||||
* 통신 프로토콜 수신 서버
|
||||
*
|
||||
* @since 2006/07/27
|
||||
* @version 1.0 - 2006/07/27
|
||||
*
|
||||
* @author 김종채, <br>
|
||||
* 작성 : 2006/07/27<br>
|
||||
*/
|
||||
|
||||
package center.transfer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.exception.MessageException;
|
||||
import com.resources.data.Info;
|
||||
import com.util.Properties;
|
||||
import com.util.StringUtil;
|
||||
|
||||
import center.dao.CenterTransDAO;
|
||||
/**
|
||||
* 남산 1호터널 파일 수신 서버 프로세스<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class TNRecvServer01 extends CommClient
|
||||
{
|
||||
private int COMM_LENGTH = 28;
|
||||
private int M600_LENGTH = 77;
|
||||
private int M610_LENGTH = 77;
|
||||
private int M620_LENGTH = 35;
|
||||
private int M630_LENGTH = 84;
|
||||
private int M640_LENGTH = 84;
|
||||
private int M300_LENGTH = 38;
|
||||
private int M310_LENGTH = 39;
|
||||
private int M320_LENGTH = 39;
|
||||
|
||||
private CenterTransDAO commDAO; // 파일 전송 이력 클래스 변수
|
||||
|
||||
private String DOTR_BASE;
|
||||
private String RFDATA_SEND;
|
||||
private String RFID_BASE;
|
||||
private String sOfficeID;
|
||||
/**
|
||||
* Constructor
|
||||
* @param config
|
||||
*/
|
||||
public TNRecvServer01(Properties config){
|
||||
super(config, "TN_01", "BT");
|
||||
}
|
||||
/**
|
||||
* startup
|
||||
*/
|
||||
public void startup()
|
||||
{
|
||||
try
|
||||
{
|
||||
DOTR_BASE = config.getProperty("dotr.dir");
|
||||
RFDATA_SEND = config.getProperty("rfdata.send");
|
||||
RFID_BASE = config.getProperty("file.dir");
|
||||
sOfficeID = config.getProperty(sOrgCode+".office");
|
||||
|
||||
int iSvrPort = Integer.parseInt(sLocalPort);
|
||||
oSvrSock = new ServerSocket(iSvrPort);
|
||||
while (true)
|
||||
{
|
||||
try{
|
||||
// client를 기다림
|
||||
socket = oSvrSock.accept();
|
||||
socket.setSoTimeout( TIME_OUT );
|
||||
System.err.println( socket.getInetAddress() + " Client is connected");
|
||||
reader = socket.getInputStream();
|
||||
writer = socket.getOutputStream();
|
||||
|
||||
startClient();
|
||||
}catch(Exception e){
|
||||
System.err.println(e.getMessage());
|
||||
}finally{
|
||||
try{ if(reader!=null) reader.close(); }catch(Exception e){}
|
||||
try{ if(writer!=null) writer.close(); }catch(Exception e){}
|
||||
try{ if(socket!=null) socket.close(); }catch(Exception e){}
|
||||
}
|
||||
} // while end
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.logTrace(e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* startClient
|
||||
*/
|
||||
protected void startClient() throws Exception{
|
||||
try{
|
||||
TODAY = StringUtil.getDate("yyyyMMdd");
|
||||
|
||||
conn = getConnection();
|
||||
conn.setAutoCommit(false);
|
||||
commDAO = new CenterTransDAO(conn);
|
||||
|
||||
logInfo("");
|
||||
logInfo("File Recveive START");
|
||||
|
||||
File[] files = receiveFiles();
|
||||
|
||||
for (int i=0; i<files.length; i++) {
|
||||
File f = files[i];
|
||||
logInfo("Recveive File [" + f.getName() +"]");
|
||||
logInfo("Recveive File Size [" + f.length() +"]");
|
||||
}
|
||||
logInfo("File Recveive END");
|
||||
}catch(Exception e){
|
||||
if(logger!=null)logDebug(e);
|
||||
throw e;
|
||||
}finally{
|
||||
try{ if(conn !=null) conn.close(); }catch(Exception e){}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 파일 수신 처리
|
||||
* @return File[]
|
||||
* @throws IOException
|
||||
* @throws Exception
|
||||
*/
|
||||
public File[] receiveFiles() throws IOException, Exception{
|
||||
boolean done = false;
|
||||
|
||||
Vector vectFiles = new Vector();
|
||||
String sMessage, sSendMsg = null;
|
||||
|
||||
try {
|
||||
String sRecvFileName = null;
|
||||
// 레코드가 담기는 한개의 블럭
|
||||
int nBlockNo = 1;
|
||||
int nDataCount = 0;
|
||||
int nRecordSize = 0;
|
||||
// ------------------------------------------------------------- //
|
||||
// 0600 : 업무개시전문 수신 (001:업무개시)
|
||||
// ------------------------------------------------------------- //
|
||||
sMessage = recvMessage(M600_LENGTH);
|
||||
// 전문 체크
|
||||
if (! isSuccessMessage( "0600", sMessage)) {
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 0610 : 업무개시전문 송신 (001:업무개시)
|
||||
// ------------------------------------------------------------- //
|
||||
sSendMsg = "FTP 0610RC "
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "001 ";
|
||||
sendMessage(sSendMsg);
|
||||
// FTP 전송처리
|
||||
do {
|
||||
sMessage = recvMessage(COMM_LENGTH);
|
||||
String sMsgCode = sMessage.substring(11, 15);
|
||||
// 응답코드 체크(000:정상)
|
||||
if (! isSuccessMessage( sMessage)) {
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 0600 : 업무종료전문 수신 (004:전체업무종료)
|
||||
// ------------------------------------------------------------- //
|
||||
if( sMsgCode.equals("0600") ){
|
||||
|
||||
sMessage += recvMessage(M600_LENGTH-COMM_LENGTH);
|
||||
if( sMessage.substring(38, 41).equals("004")) break;
|
||||
else throw new Exception(sMessage);
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 0630 : 파일정보지시
|
||||
// ------------------------------------------------------------- //
|
||||
sMessage += recvMessage(M630_LENGTH-COMM_LENGTH);
|
||||
|
||||
// 파일명을 추출하여 코드에 맞는 데이터 및 로그 파일을 생성한다.
|
||||
sFileCode = sMessage.substring(17, 25);
|
||||
sFileName = sMessage.substring(28, 68);
|
||||
|
||||
// 수신중 임시파일명 셋팅
|
||||
sRecvFileName = sFileName.trim();
|
||||
Info data = commDAO.getFileInfo(sFileCode.substring(0,2));
|
||||
if( data == null ){
|
||||
throw new Exception("Unregistered file Code :"+sFileCode);
|
||||
}
|
||||
sFileDir = getPath(sFileCode.substring(0,2), data.getString("FILE_DIR"),sRecvFileName, sOfficeID );
|
||||
nDataSize = data.getInt("REC_LEN"); // 레코드길이
|
||||
nDataCount = data.getInt("REC_CNT"); // 시퀀스 당 레코드 건수
|
||||
nSequenceCount = data.getInt("SEQ_CNT");// 블럭 당 시퀀스 건수
|
||||
|
||||
byte [][] sBytes = new byte[nSequenceCount][]; // data 저장 변수
|
||||
clearBlock(sBytes);
|
||||
|
||||
int nMessageSize = Integer.parseInt(sMessage.substring(80, 84));
|
||||
|
||||
nRecordSize = nDataSize * nDataCount;
|
||||
|
||||
File dataFile = new File(sRecvDir, sRecvFileName);
|
||||
|
||||
long nFileSize = dataFile.exists() ? dataFile.length() : 0;
|
||||
// 통신 중 장애가 발생하면 기존에 전송된 블럭 다음부터 전송되므로 append 모드로 파일 생성
|
||||
fileOutputStream = new FileOutputStream(dataFile, true);
|
||||
// ------------------------------------------------------------- //
|
||||
// 0640 : 파일수신 응답전문 송신
|
||||
// ------------------------------------------------------------- //
|
||||
sSendMsg = "FTP 0640RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ sFileName
|
||||
+ StringUtil.ltos(nFileSize , 12)
|
||||
+ StringUtil.ntos(nRecordSize, 4);
|
||||
sendMessage(sSendMsg);
|
||||
// 전문에서 읽을 바이트수를 결정
|
||||
int recvSize = nMessageSize > nRecordSize ? nRecordSize : nMessageSize;
|
||||
while (true) {
|
||||
// 전문의 공통부분 Read
|
||||
sMessage = recvMessage(COMM_LENGTH);
|
||||
// 전문코드 추출
|
||||
sMsgCode = sMessage.substring(11, 15);
|
||||
// 응답코드 체크(000:정상)
|
||||
if (! isSuccessMessage( sMessage)) {
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- //
|
||||
// 0320 : DATA 송신, 0310 : 결번 통보
|
||||
// ------------------------------------------------------------- //
|
||||
if (sMsgCode.equals("0320") || sMsgCode.equals("0310")) {
|
||||
// 블럭 번호 조회
|
||||
int nRemoteBlock = Integer.parseInt(recvMessage(4));
|
||||
// 이전까지 수신된 블럭과 현재 수신된 블럭이 다를 경우
|
||||
if (nBlockNo != nRemoteBlock) {
|
||||
// 이전까지 수신된 블럭을 파일로 저장한다.
|
||||
appendBlock(sBytes, nDataSize);
|
||||
clearBlock(sBytes);
|
||||
// 현재의 블럭번호를 변경한다.
|
||||
nBlockNo = nRemoteBlock;
|
||||
}
|
||||
// 레코드 번호
|
||||
sMessage = recvMessage(3);
|
||||
int nRecordNo = Integer.parseInt(sMessage);
|
||||
// 데이터 부분총길이
|
||||
sMessage = recvMessage(4);
|
||||
int nDataLength = Integer.parseInt(sMessage);
|
||||
// 전문의 데이터을 읽어들인다.
|
||||
RCV0320(sBytes, nRecordNo, nDataLength, recvSize );
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 0620 : 결번확인지시
|
||||
// ------------------------------------------------------------- //
|
||||
else if (sMsgCode.equals("0620")) {
|
||||
String sBlockNo = recvMessage(4);
|
||||
String sSequenceNo = recvMessage(3);
|
||||
|
||||
int nLastNo = Integer.parseInt(sSequenceNo);
|
||||
|
||||
// 재전송해야 할 결번을 얻어온다.
|
||||
int nCount = getMissingCount(sBytes, nLastNo);
|
||||
String sMissing = getMissingRecords(sBytes);
|
||||
// 0300 : 결번확인보고
|
||||
sSendMsg = "FTP 0300RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ sBlockNo
|
||||
+ sSequenceNo
|
||||
+ StringUtil.ntos(nCount, 3)
|
||||
+ sMissing;
|
||||
sendMessage(sSendMsg);
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 송신완료지시
|
||||
// ------------------------------------------------------------- //
|
||||
else if (sMsgCode.equals("0600")) {
|
||||
sMessage = recvMessage(M600_LENGTH-COMM_LENGTH);
|
||||
// 마지막 수신된 블럭을 파일에 저장한 후 종료한다.
|
||||
appendBlock(sBytes, nDataSize);
|
||||
clearBlock(sBytes);
|
||||
fileOutputStream.close();
|
||||
// ------------------------------------------------------------- //
|
||||
// 0610 : 송신완료보고 (003:개별업무종료)
|
||||
// ------------------------------------------------------------- //
|
||||
sSendMsg = "FTP 0610RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "003 ";
|
||||
sendMessage(sSendMsg);
|
||||
// 송수신 파일정보 입력
|
||||
Info transInfo = new Info();
|
||||
|
||||
transInfo.setString("FILE_KIND_ID" , sFileCode.substring(0,2) );
|
||||
transInfo.setString("FORMAT_DATE" , TODAY );
|
||||
transInfo.setString("FARE_OFFICE_ID" , sOfficeID );
|
||||
transInfo.setString("FILE_TRANS_KBN" , "R" );
|
||||
transInfo.setString("FILE_TRANS_YN" , "Y" );
|
||||
transInfo.setString("DIR_NAME" , sFileDir );
|
||||
transInfo.setString("FILE_NAME" , sRecvFileName );
|
||||
transInfo.setString("CREATER" , "SamServer");
|
||||
|
||||
if( sFileCode.substring(0,2).equals("WU") ||
|
||||
sFileCode.substring(0,2).equals("WV") ||
|
||||
sFileCode.substring(0,2).equals("WW")){
|
||||
transInfo.setString("DATA_PROCESS_KBN", "9" );
|
||||
commDAO.insertRecvFileInfo( transInfo );
|
||||
|
||||
transInfo.setString("FARE_OFFICE_ID" , "TM");
|
||||
transInfo.setString("FILE_TRANS_KBN" , "S" );
|
||||
transInfo.setString("FILE_TRANS_YN" , "N" );
|
||||
transInfo.setString("DATA_PROCESS_KBN", "9" );
|
||||
commDAO.insertRecvFileInfo( transInfo );
|
||||
}else{
|
||||
if( sFileCode.substring(0,2).equals("54") ||
|
||||
sFileCode.substring(0,2).equals("55") ||
|
||||
sFileCode.substring(0,2).equals("WW")){
|
||||
transInfo.setString("DATA_PROCESS_KBN", "9" );
|
||||
}else{
|
||||
transInfo.setString("DATA_PROCESS_KBN", "0" );
|
||||
}
|
||||
commDAO.insertRecvFileInfo( transInfo );
|
||||
}
|
||||
checkDirectory(sFileDir);
|
||||
rename( sRecvDir+sRecvFileName, sFileDir+sRecvFileName );
|
||||
break;
|
||||
}
|
||||
else {
|
||||
throw new Exception(sMessage);
|
||||
}
|
||||
}
|
||||
} while (!done);
|
||||
// ------------------------------------------------------------- //
|
||||
// 0610 : 업무종료보고 (004:전체업무종료)
|
||||
// ------------------------------------------------------------- //
|
||||
sSendMsg = "FTP 0610RC"
|
||||
+ " "
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "004 ";
|
||||
|
||||
sendMessage(sSendMsg);
|
||||
vectFiles.add(new File(sFileDir, sRecvFileName));
|
||||
|
||||
conn.commit();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
if (logger != null) {
|
||||
logFail("[ERROR 999] " + ex.getMessage());
|
||||
logDebug(ex);
|
||||
}
|
||||
throw ex;
|
||||
}finally{
|
||||
try{ if(fileOutputStream!=null) fileOutputStream.close(); }catch(Exception e){}
|
||||
}
|
||||
File[] files = new File[vectFiles.size()];
|
||||
vectFiles.toArray(files);
|
||||
return files;
|
||||
}
|
||||
/**
|
||||
* 결번 개수를 구한다.
|
||||
* @param sRecords
|
||||
* @param nLastNo
|
||||
* @return
|
||||
*/
|
||||
private int getMissingCount(byte[][] sBytes, int nLastNo) {
|
||||
int nCount = 0;
|
||||
for (int i = 0; i < nLastNo; i++) {
|
||||
if (sBytes[i] == null) {
|
||||
nCount++;
|
||||
}
|
||||
}
|
||||
return nCount;
|
||||
}
|
||||
/**
|
||||
* 스트링에서 결번을 읽어들인다.('0': 미수신, '1': 수신)
|
||||
* @param sMessage
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
private String getMissingRecords(byte[][] sBytes) {
|
||||
char []caMissing = new char[sBytes.length];
|
||||
for (int i = 0; i < sBytes.length; i++) {
|
||||
if (sBytes[i] == null) {
|
||||
caMissing[i] = '0'; // 미수신 '0'
|
||||
}
|
||||
else {
|
||||
caMissing[i] = '1'; // 수신 '1'
|
||||
}
|
||||
}
|
||||
return String.valueOf(caMissing);
|
||||
}
|
||||
/**
|
||||
* 수신된 데이터를 블럭단위로 파일에 기록
|
||||
* @param sBytes
|
||||
* @param nDataSize
|
||||
* @throws IOException
|
||||
*/
|
||||
private void appendBlock(byte[][] sBytes, int nDataSize)
|
||||
throws IOException {
|
||||
for (int i = 0; i < sBytes.length; i++) {
|
||||
// 최종 레코드까지 기록
|
||||
if (sBytes[i] == null) {
|
||||
break;
|
||||
}
|
||||
fileOutputStream.write(sBytes[i]);
|
||||
}
|
||||
fileOutputStream.flush();
|
||||
}
|
||||
/**
|
||||
* 블럭의 레코드(String) 들을 초기화
|
||||
* @param sBytes
|
||||
*/
|
||||
private void clearBlock(byte[][] sBytes) {
|
||||
for (int i = 0; i < sBytes.length; i++) {
|
||||
sBytes[i] = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 파일에 따라 저장할 디렉토리 정보를 추출
|
||||
* @param sFileKindCode
|
||||
* @param sBaseDir
|
||||
* @param sFileName
|
||||
* @param sOfficeID
|
||||
* @return String
|
||||
*/
|
||||
public String getPath(String sFileKindCode,String sBaseDir, String sFileName, String sOfficeID ){
|
||||
StringBuffer sFileDir = new StringBuffer(sBaseDir);
|
||||
|
||||
if( sFileKindCode.equals("54") ){ // JPG File
|
||||
sFileDir.append( sFileName.substring(4,12) + File.separator )
|
||||
.append( sFileName.substring(0, 2) + File.separator )
|
||||
.append( "IMAGE" + File.separator );
|
||||
}else if( sFileKindCode.equals("55") ){ // JPG File
|
||||
sFileDir.append( sFileName.substring(4,12) + File.separator )
|
||||
.append( sFileName.substring(0, 2) + File.separator )
|
||||
.append( "IMAGE" + File.separator );
|
||||
}else if( sFileKindCode.equals("26") ){ // 카드사코드정보
|
||||
sFileDir.append( sFileName.substring(6,10) + File.separator )
|
||||
.append( "ACARD" + File.separator );
|
||||
}else if( sFileKindCode.equals("25") ){ // 카드발행사코드정보
|
||||
sFileDir.append( sFileName.substring(6,10) + File.separator )
|
||||
.append( "BCARD" + File.separator );
|
||||
}else if( sFileKindCode.equals("2A") ){ // 요금소코드정보
|
||||
sFileDir.append( sFileName.substring(7,11) + File.separator )
|
||||
.append( "OFFICE" + File.separator );
|
||||
}else if( sFileKindCode.equals("23") ){ // 근무정보
|
||||
sFileDir.append( sFileName.substring(5,9) + File.separator )
|
||||
.append( "WORK" + File.separator );
|
||||
}else if( sFileKindCode.equals("2C") ){ // 징수유형코드정보
|
||||
sFileDir.append( sFileName.substring(8,12) + File.separator )
|
||||
.append( "COLLECT" + File.separator );
|
||||
}else if( sFileKindCode.equals("24") ){ // 면제차량정보
|
||||
sFileDir.append( sFileName.substring(8,12) + File.separator )
|
||||
.append( "Default" + File.separator );
|
||||
}else if( sFileKindCode.equals("1F") ){ // 요금정보
|
||||
sFileDir.append( sFileName.substring(5,9) + File.separator )
|
||||
.append( "Fare" + File.separator );
|
||||
}else if( sFileKindCode.equals("27") ){ // 차종코드정보
|
||||
sFileDir.append( sFileName.substring(10,14) + File.separator )
|
||||
.append( "CARTYPE" + File.separator );
|
||||
}else if( sFileKindCode.equals("2B") ){ // 차로구분코드
|
||||
sFileDir.append( sFileName.substring(9,13) + File.separator )
|
||||
.append( sFileName.substring(6, 8) + File.separator )
|
||||
.append( "BOOTH" + File.separator );
|
||||
}else if( sFileName.equals("11") ){ // RF 단말 정보
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4,6) + File.separator )
|
||||
.append( "RFT" + File.separator );
|
||||
}else if( sFileKindCode.equals("12") ){ // RFU File
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4, 6) + File.separator )
|
||||
.append( "RFU" + File.separator );
|
||||
}else if( sFileKindCode.equals("21") ){ // 근무자 정보
|
||||
sFileDir.append( TODAY.substring(0,4) + File.separator )
|
||||
.append( sOfficeID + File.separator )
|
||||
.append( "Person" + File.separator );
|
||||
}else if( sFileKindCode.equals("14") ){ // 요금단말정보
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4, 6) + File.separator )
|
||||
.append( "FAT" + File.separator );
|
||||
}else if( sFileKindCode.equals("15") ){ // FAU File
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4, 6) + File.separator )
|
||||
.append( "FAU" + File.separator );
|
||||
}else if( sFileKindCode.equals("17") ){ // 요금정산정보
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4, 6) + File.separator )
|
||||
.append( "FAA" + File.separator );
|
||||
}else if( sFileKindCode.equals("1A") ){ // 과잉쿠폰 정보
|
||||
sFileDir.append( sFileName.substring(6,14) + File.separator )
|
||||
.append( sFileName.substring(3, 5) + File.separator )
|
||||
.append( "CO" + File.separator );
|
||||
}else if( sFileKindCode.equals("1B") ){ // 과오납 정보
|
||||
sFileDir.append( sFileName.substring(6,14) + File.separator )
|
||||
.append( sFileName.substring(3, 5) + File.separator )
|
||||
.append( "OF" + File.separator );
|
||||
}else if( sFileKindCode.equals("1C") ){ // 입.출금 정보
|
||||
sFileDir.append( sFileName.substring(6,14) + File.separator )
|
||||
.append( sFileName.substring(3, 5) + File.separator )
|
||||
.append( "IO" + File.separator );
|
||||
}else if( sFileKindCode.equals("1D") ){ // 정액권 정보
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4, 6) + File.separator )
|
||||
.append( "FCO" + File.separator );
|
||||
}else if( sFileKindCode.equals("1E") ){ // 쿠폰폐기정보
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4, 6) + File.separator )
|
||||
.append( "COW" + File.separator );
|
||||
}else if( sFileKindCode.equals("1H") ){ // 수입금정산정보
|
||||
sFileDir.append( sFileName.substring(10,18) + File.separator )
|
||||
.append( sFileName.substring(7, 9) + File.separator )
|
||||
.append( "INCOME" + File.separator );
|
||||
}else if( sFileKindCode.equals("1I") ){ // 시세입 정보
|
||||
sFileDir.append( sFileName.substring(9,17) + File.separator )
|
||||
.append( sFileName.substring(6, 8) + File.separator )
|
||||
.append( "TAXES" + File.separator );
|
||||
}else if( sFileKindCode.equals("1J") ){ // 가맹점정보
|
||||
sFileDir.append( sFileName.substring(13,21) + File.separator )
|
||||
.append( sFileName.substring(10,12) + File.separator )
|
||||
.append( "JOIN" + File.separator );
|
||||
}else if( sFileKindCode.equals("18") ){ // 카드환불정보
|
||||
sFileDir.append( sFileName.substring(9,17) + File.separator )
|
||||
.append( sFileName.substring(6, 8) + File.separator )
|
||||
.append( "REPAY" + File.separator );
|
||||
}else if( sFileKindCode.equals("2D") ){ // 과오납 차량소유자 정보
|
||||
sFileDir.append( sFileName.substring(10,14) + File.separator )
|
||||
.append( "CAROWNER" + File.separator );
|
||||
}else if( sFileKindCode.equals("WK") || sFileKindCode.equals("WM") ||
|
||||
sFileKindCode.equals("WN") || sFileKindCode.equals("WO") ||
|
||||
sFileKindCode.equals("WP") || sFileKindCode.equals("WQ") ||
|
||||
sFileKindCode.equals("WR") || sFileKindCode.equals("WS") ||
|
||||
sFileKindCode.equals("WT") || sFileKindCode.equals("WU") ||
|
||||
sFileKindCode.equals("WV") || sFileKindCode.equals("WW") ){ // RF 운영정보
|
||||
sFileDir.append(TODAY + File.separator);
|
||||
}else if( sFileKindCode.equals("52") ){ // RFID 정보
|
||||
sFileDir.append("pl" + File.separator);
|
||||
}else if( sFileKindCode.equals("53") ){ // RFID 사용 정보
|
||||
sFileDir.append("use" + File.separator);
|
||||
}else{
|
||||
|
||||
}
|
||||
return sFileDir.toString();
|
||||
}
|
||||
/**
|
||||
* 파일 디렉토리 존재유무를 체크하고 생성하는 메소드
|
||||
* @param sFileDir
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean checkDirectory(String sFileDir){
|
||||
String sTemp [] = sFileDir.split(File.separator);
|
||||
String sCreatDir = "";
|
||||
if( sTemp != null ){
|
||||
for( int idx = 0; idx < sTemp.length; idx++){
|
||||
sCreatDir = sCreatDir + sTemp[idx] + File.separator;
|
||||
if( !new File(sCreatDir).isDirectory() ){
|
||||
new File(sCreatDir).mkdir();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Help 메시지 출력
|
||||
*/
|
||||
public static void showHelp(String sClass) {
|
||||
System.err.println("Command :");
|
||||
System.err.println("\tjava " + sClass + " -Dftp.conf=CONFIG_FILE");
|
||||
System.err.println("");
|
||||
}
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
if(args.length != 0){
|
||||
showHelp("center.transfer.TNRecvServer01");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
String sConfFile = System.getProperty("ftp.conf");
|
||||
if (sConfFile == null || sConfFile.equals("")) {
|
||||
showHelp("center.transfer.TNRecvServer01");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Properties config = new Properties();
|
||||
try {
|
||||
config.load(sConfFile);
|
||||
}
|
||||
catch (IOException ie) {
|
||||
System.err.println("Can not read configuration file.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
TNRecvServer01 server = new TNRecvServer01(config);
|
||||
server.startup();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println("Starting Demon is failed.");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,611 +0,0 @@
|
||||
/**
|
||||
* <pre>
|
||||
* SamServer
|
||||
* </pre>
|
||||
* 통신 프로토콜 수신 서버
|
||||
*
|
||||
* @since 2006/07/27
|
||||
* @version 1.0 - 2006/07/27
|
||||
*
|
||||
* @author 김종채, <br>
|
||||
* 작성 : 2006/07/27<br>
|
||||
*/
|
||||
|
||||
package center.transfer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.exception.MessageException;
|
||||
import com.resources.data.Info;
|
||||
import com.util.Properties;
|
||||
import com.util.StringUtil;
|
||||
|
||||
import center.dao.CenterTransDAO;
|
||||
/**
|
||||
* 남산 3호터널 파일 수신 서버 프로세스<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class TNRecvServer03 extends CommClient
|
||||
{
|
||||
private int COMM_LENGTH = 28;
|
||||
private int M600_LENGTH = 77;
|
||||
private int M610_LENGTH = 77;
|
||||
private int M620_LENGTH = 35;
|
||||
private int M630_LENGTH = 84;
|
||||
private int M640_LENGTH = 84;
|
||||
private int M300_LENGTH = 38;
|
||||
private int M310_LENGTH = 39;
|
||||
private int M320_LENGTH = 39;
|
||||
|
||||
private CenterTransDAO commDAO; // 파일 전송 이력 클래스 변수
|
||||
|
||||
private String DOTR_BASE;
|
||||
private String RFDATA_SEND;
|
||||
private String RFID_BASE;
|
||||
private String sOfficeID;
|
||||
/**
|
||||
* Constructor
|
||||
* @param config
|
||||
*/
|
||||
public TNRecvServer03(Properties config){
|
||||
super(config, "TN_03", "BT");
|
||||
}
|
||||
/**
|
||||
* startup
|
||||
*/
|
||||
public void startup()
|
||||
{
|
||||
try
|
||||
{
|
||||
DOTR_BASE = config.getProperty("dotr.dir");
|
||||
RFDATA_SEND = config.getProperty("rfdata.send");
|
||||
RFID_BASE = config.getProperty("file.dir");
|
||||
sOfficeID = config.getProperty(sOrgCode+".office");
|
||||
|
||||
int iSvrPort = Integer.parseInt(sLocalPort);
|
||||
oSvrSock = new ServerSocket(iSvrPort);
|
||||
|
||||
while (true)
|
||||
{
|
||||
try{
|
||||
// client를 기다림
|
||||
socket = oSvrSock.accept();
|
||||
socket.setSoTimeout( TIME_OUT );
|
||||
System.err.println( socket.getInetAddress() + " Client is connected");
|
||||
reader = socket.getInputStream();
|
||||
writer = socket.getOutputStream();
|
||||
|
||||
startClient();
|
||||
}catch(Exception e){
|
||||
System.err.println(e.getMessage());
|
||||
}finally{
|
||||
try{ if(reader!=null) reader.close(); }catch(Exception e){}
|
||||
try{ if(writer!=null) writer.close(); }catch(Exception e){}
|
||||
try{ if(socket!=null) socket.close(); }catch(Exception e){}
|
||||
}
|
||||
} // while end
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.logTrace(e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* startClient
|
||||
*/
|
||||
protected void startClient() throws Exception{
|
||||
try{
|
||||
TODAY = StringUtil.getDate("yyyyMMdd");
|
||||
|
||||
conn = getConnection();
|
||||
conn.setAutoCommit(false);
|
||||
commDAO = new CenterTransDAO(conn);
|
||||
|
||||
logInfo("");
|
||||
logInfo("File Recveive START");
|
||||
|
||||
File[] files = receiveFiles();
|
||||
|
||||
for (int i=0; i<files.length; i++) {
|
||||
File f = files[i];
|
||||
logInfo("Recveive File [" + f.getName() +"]");
|
||||
logInfo("Recveive File Size [" + f.length() +"]");
|
||||
}
|
||||
logInfo("File Recveive END");
|
||||
}catch(Exception e){
|
||||
if(logger!=null)logDebug(e);
|
||||
throw e;
|
||||
}finally{
|
||||
try{ if(conn !=null) conn.close(); }catch(Exception e){}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 파일 수신 처리
|
||||
* @return File[]
|
||||
* @throws IOException
|
||||
* @throws Exception
|
||||
*/
|
||||
public File[] receiveFiles() throws IOException, Exception{
|
||||
boolean done = false;
|
||||
|
||||
Vector vectFiles = new Vector();
|
||||
String sMessage, sSendMsg = null;
|
||||
|
||||
try {
|
||||
String sRecvFileName = null;
|
||||
// 레코드가 담기는 한개의 블럭
|
||||
int nBlockNo = 1;
|
||||
int nDataCount = 0;
|
||||
int nRecordSize = 0;
|
||||
// ------------------------------------------------------------- //
|
||||
// 0600 : 업무개시전문 수신 (001:업무개시)
|
||||
// ------------------------------------------------------------- //
|
||||
sMessage = recvMessage(M600_LENGTH);
|
||||
// 전문 체크
|
||||
if (! isSuccessMessage( "0600", sMessage)) {
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 0610 : 업무개시전문 송신 (001:업무개시)
|
||||
// ------------------------------------------------------------- //
|
||||
sSendMsg = "FTP 0610RC "
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "001 ";
|
||||
sendMessage(sSendMsg);
|
||||
// FTP 전송처리
|
||||
do {
|
||||
sMessage = recvMessage(COMM_LENGTH);
|
||||
String sMsgCode = sMessage.substring(11, 15);
|
||||
// 응답코드 체크(000:정상)
|
||||
if (! isSuccessMessage( sMessage)) {
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 0600 : 업무종료전문 수신 (004:전체업무종료)
|
||||
// ------------------------------------------------------------- //
|
||||
if( sMsgCode.equals("0600") ){
|
||||
|
||||
sMessage += recvMessage(M600_LENGTH-COMM_LENGTH);
|
||||
if( sMessage.substring(38, 41).equals("004")) break;
|
||||
else throw new Exception(sMessage);
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 0630 : 파일정보지시
|
||||
// ------------------------------------------------------------- //
|
||||
sMessage += recvMessage(M630_LENGTH-COMM_LENGTH);
|
||||
|
||||
// 파일명을 추출하여 코드에 맞는 데이터 및 로그 파일을 생성한다.
|
||||
sFileCode = sMessage.substring(17, 25);
|
||||
sFileName = sMessage.substring(28, 68);
|
||||
|
||||
// 수신중 임시파일명 셋팅
|
||||
sRecvFileName = sFileName.trim();
|
||||
Info data = commDAO.getFileInfo(sFileCode.substring(0,2));
|
||||
if( data == null ){
|
||||
throw new Exception("Unregistered file Code :"+sFileCode);
|
||||
}
|
||||
sFileDir = getPath(sFileCode.substring(0,2), data.getString("FILE_DIR"),sRecvFileName, sOfficeID );
|
||||
nDataSize = data.getInt("REC_LEN"); // 레코드길이
|
||||
nDataCount = data.getInt("REC_CNT"); // 시퀀스 당 레코드 건수
|
||||
nSequenceCount = data.getInt("SEQ_CNT");// 블럭 당 시퀀스 건수
|
||||
|
||||
byte [][] sBytes = new byte[nSequenceCount][]; // data 저장 변수
|
||||
clearBlock(sBytes);
|
||||
|
||||
int nMessageSize = Integer.parseInt(sMessage.substring(80, 84));
|
||||
|
||||
nRecordSize = nDataSize * nDataCount;
|
||||
|
||||
File dataFile = new File(sRecvDir, sRecvFileName);
|
||||
|
||||
long nFileSize = dataFile.exists() ? dataFile.length() : 0;
|
||||
// 통신 중 장애가 발생하면 기존에 전송된 블럭 다음부터 전송되므로 append 모드로 파일 생성
|
||||
fileOutputStream = new FileOutputStream(dataFile, true);
|
||||
// ------------------------------------------------------------- //
|
||||
// 0640 : 파일수신 응답전문 송신
|
||||
// ------------------------------------------------------------- //
|
||||
sSendMsg = "FTP 0640RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ sFileName
|
||||
+ StringUtil.ltos(nFileSize , 12)
|
||||
+ StringUtil.ntos(nRecordSize, 4);
|
||||
sendMessage(sSendMsg);
|
||||
// 전문에서 읽을 바이트수를 결정
|
||||
int recvSize = nMessageSize > nRecordSize ? nRecordSize : nMessageSize;
|
||||
while (true) {
|
||||
// 전문의 공통부분 Read
|
||||
sMessage = recvMessage(COMM_LENGTH);
|
||||
// 전문코드 추출
|
||||
sMsgCode = sMessage.substring(11, 15);
|
||||
// 응답코드 체크(000:정상)
|
||||
if (! isSuccessMessage( sMessage)) {
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- //
|
||||
// 0320 : DATA 송신, 0310 : 결번 통보
|
||||
// ------------------------------------------------------------- //
|
||||
if (sMsgCode.equals("0320") || sMsgCode.equals("0310")) {
|
||||
// 블럭 번호 조회
|
||||
int nRemoteBlock = Integer.parseInt(recvMessage(4));
|
||||
// 이전까지 수신된 블럭과 현재 수신된 블럭이 다를 경우
|
||||
if (nBlockNo != nRemoteBlock) {
|
||||
// 이전까지 수신된 블럭을 파일로 저장한다.
|
||||
appendBlock(sBytes, nDataSize);
|
||||
clearBlock(sBytes);
|
||||
// 현재의 블럭번호를 변경한다.
|
||||
nBlockNo = nRemoteBlock;
|
||||
}
|
||||
// 레코드 번호
|
||||
sMessage = recvMessage(3);
|
||||
int nRecordNo = Integer.parseInt(sMessage);
|
||||
// 데이터 부분총길이
|
||||
sMessage = recvMessage(4);
|
||||
int nDataLength = Integer.parseInt(sMessage);
|
||||
// 전문의 데이터을 읽어들인다.
|
||||
RCV0320(sBytes, nRecordNo, nDataLength, recvSize );
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 0620 : 결번확인지시
|
||||
// ------------------------------------------------------------- //
|
||||
else if (sMsgCode.equals("0620")) {
|
||||
String sBlockNo = recvMessage(4);
|
||||
String sSequenceNo = recvMessage(3);
|
||||
|
||||
int nLastNo = Integer.parseInt(sSequenceNo);
|
||||
|
||||
// 재전송해야 할 결번을 얻어온다.
|
||||
int nCount = getMissingCount(sBytes, nLastNo);
|
||||
String sMissing = getMissingRecords(sBytes);
|
||||
// 0300 : 결번확인보고
|
||||
sSendMsg = "FTP 0300RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ sBlockNo
|
||||
+ sSequenceNo
|
||||
+ StringUtil.ntos(nCount, 3)
|
||||
+ sMissing;
|
||||
sendMessage(sSendMsg);
|
||||
}
|
||||
// ------------------------------------------------------------- //
|
||||
// 송신완료지시
|
||||
// ------------------------------------------------------------- //
|
||||
else if (sMsgCode.equals("0600")) {
|
||||
sMessage = recvMessage(M600_LENGTH-COMM_LENGTH);
|
||||
// 마지막 수신된 블럭을 파일에 저장한 후 종료한다.
|
||||
appendBlock(sBytes, nDataSize);
|
||||
clearBlock(sBytes);
|
||||
fileOutputStream.close();
|
||||
// ------------------------------------------------------------- //
|
||||
// 0610 : 송신완료보고 (003:개별업무종료)
|
||||
// ------------------------------------------------------------- //
|
||||
sSendMsg = "FTP 0610RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "003 ";
|
||||
sendMessage(sSendMsg);
|
||||
// 송수신 파일정보 입력
|
||||
Info transInfo = new Info();
|
||||
|
||||
transInfo.setString("FILE_KIND_ID" , sFileCode.substring(0,2) );
|
||||
transInfo.setString("FORMAT_DATE" , TODAY );
|
||||
transInfo.setString("FARE_OFFICE_ID" , sOfficeID );
|
||||
transInfo.setString("FILE_TRANS_KBN" , "R" );
|
||||
transInfo.setString("FILE_TRANS_YN" , "Y" );
|
||||
transInfo.setString("DIR_NAME" , sFileDir );
|
||||
transInfo.setString("FILE_NAME" , sRecvFileName );
|
||||
transInfo.setString("CREATER" , "SamServer");
|
||||
|
||||
if( sFileCode.substring(0,2).equals("WU") ||
|
||||
sFileCode.substring(0,2).equals("WV") ||
|
||||
sFileCode.substring(0,2).equals("WW")){
|
||||
transInfo.setString("DATA_PROCESS_KBN", "9" );
|
||||
commDAO.insertRecvFileInfo( transInfo );
|
||||
|
||||
transInfo.setString("FARE_OFFICE_ID" , "TM");
|
||||
transInfo.setString("FILE_TRANS_KBN" , "S" );
|
||||
transInfo.setString("FILE_TRANS_YN" , "N" );
|
||||
transInfo.setString("DATA_PROCESS_KBN", "9" );
|
||||
commDAO.insertRecvFileInfo( transInfo );
|
||||
}else{
|
||||
if( sFileCode.substring(0,2).equals("54") ||
|
||||
sFileCode.substring(0,2).equals("55") ||
|
||||
sFileCode.substring(0,2).equals("WW")){
|
||||
transInfo.setString("DATA_PROCESS_KBN", "9" );
|
||||
}else{
|
||||
transInfo.setString("DATA_PROCESS_KBN", "0" );
|
||||
}
|
||||
commDAO.insertRecvFileInfo( transInfo );
|
||||
}
|
||||
checkDirectory(sFileDir);
|
||||
rename( sRecvDir+sRecvFileName, sFileDir+sRecvFileName );
|
||||
break;
|
||||
}
|
||||
else {
|
||||
throw new Exception(sMessage);
|
||||
}
|
||||
}
|
||||
} while (!done);
|
||||
// ------------------------------------------------------------- //
|
||||
// 0610 : 업무종료보고 (004:전체업무종료)
|
||||
// ------------------------------------------------------------- //
|
||||
sSendMsg = "FTP 0610RC"
|
||||
+ " "
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "004 ";
|
||||
|
||||
sendMessage(sSendMsg);
|
||||
vectFiles.add(new File(sFileDir, sRecvFileName));
|
||||
|
||||
conn.commit();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
if (logger != null) {
|
||||
logFail("[ERROR 999] " + ex.getMessage());
|
||||
logDebug(ex);
|
||||
}
|
||||
throw ex;
|
||||
}finally{
|
||||
try{ if(fileOutputStream!=null) fileOutputStream.close(); }catch(Exception e){}
|
||||
}
|
||||
File[] files = new File[vectFiles.size()];
|
||||
vectFiles.toArray(files);
|
||||
return files;
|
||||
}
|
||||
/**
|
||||
* 결번 개수를 구한다.
|
||||
* @param sRecords
|
||||
* @param nLastNo
|
||||
* @return
|
||||
*/
|
||||
private int getMissingCount(byte[][] sBytes, int nLastNo) {
|
||||
int nCount = 0;
|
||||
for (int i = 0; i < nLastNo; i++) {
|
||||
if (sBytes[i] == null) {
|
||||
nCount++;
|
||||
}
|
||||
}
|
||||
return nCount;
|
||||
}
|
||||
/**
|
||||
* 스트링에서 결번을 읽어들인다.('0': 미수신, '1': 수신)
|
||||
* @param sMessage
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
private String getMissingRecords(byte[][] sBytes) {
|
||||
char []caMissing = new char[sBytes.length];
|
||||
for (int i = 0; i < sBytes.length; i++) {
|
||||
if (sBytes[i] == null) {
|
||||
caMissing[i] = '0'; // 미수신 '0'
|
||||
}
|
||||
else {
|
||||
caMissing[i] = '1'; // 수신 '1'
|
||||
}
|
||||
}
|
||||
return String.valueOf(caMissing);
|
||||
}
|
||||
/**
|
||||
* 수신된 데이터를 블럭단위로 파일에 기록
|
||||
* @param sBytes
|
||||
* @param nDataSize
|
||||
* @throws IOException
|
||||
*/
|
||||
private void appendBlock(byte[][] sBytes, int nDataSize)
|
||||
throws IOException {
|
||||
for (int i = 0; i < sBytes.length; i++) {
|
||||
// 최종 레코드까지 기록
|
||||
if (sBytes[i] == null) {
|
||||
break;
|
||||
}
|
||||
fileOutputStream.write(sBytes[i]);
|
||||
}
|
||||
fileOutputStream.flush();
|
||||
}
|
||||
/**
|
||||
* 블럭의 레코드(String) 들을 초기화
|
||||
* @param sBytes
|
||||
*/
|
||||
private void clearBlock(byte[][] sBytes) {
|
||||
for (int i = 0; i < sBytes.length; i++) {
|
||||
sBytes[i] = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 파일에 따라 저장할 디렉토리 정보를 추출
|
||||
* @param sFileKindCode
|
||||
* @param sBaseDir
|
||||
* @param sFileName
|
||||
* @param sOfficeID
|
||||
* @return String
|
||||
*/
|
||||
public String getPath(String sFileKindCode,String sBaseDir, String sFileName, String sOfficeID ){
|
||||
StringBuffer sFileDir = new StringBuffer(sBaseDir);
|
||||
|
||||
if( sFileKindCode.equals("54") ){ // JPG File
|
||||
sFileDir.append( sFileName.substring(4,12) + File.separator )
|
||||
.append( sFileName.substring(0, 2) + File.separator )
|
||||
.append( "IMAGE" + File.separator );
|
||||
}else if( sFileKindCode.equals("55") ){ // JPG File
|
||||
sFileDir.append( sFileName.substring(4,12) + File.separator )
|
||||
.append( sFileName.substring(0, 2) + File.separator )
|
||||
.append( "IMAGE" + File.separator );
|
||||
}else if( sFileKindCode.equals("26") ){ // 카드사코드정보
|
||||
sFileDir.append( sFileName.substring(6,10) + File.separator )
|
||||
.append( "ACARD" + File.separator );
|
||||
}else if( sFileKindCode.equals("25") ){ // 카드발행사코드정보
|
||||
sFileDir.append( sFileName.substring(6,10) + File.separator )
|
||||
.append( "BCARD" + File.separator );
|
||||
}else if( sFileKindCode.equals("2A") ){ // 요금소코드정보
|
||||
sFileDir.append( sFileName.substring(7,11) + File.separator )
|
||||
.append( "OFFICE" + File.separator );
|
||||
}else if( sFileKindCode.equals("23") ){ // 근무정보
|
||||
sFileDir.append( sFileName.substring(5,9) + File.separator )
|
||||
.append( "WORK" + File.separator );
|
||||
}else if( sFileKindCode.equals("2C") ){ // 징수유형코드정보
|
||||
sFileDir.append( sFileName.substring(8,12) + File.separator )
|
||||
.append( "COLLECT" + File.separator );
|
||||
}else if( sFileKindCode.equals("24") ){ // 면제차량정보
|
||||
sFileDir.append( sFileName.substring(8,12) + File.separator )
|
||||
.append( "Default" + File.separator );
|
||||
}else if( sFileKindCode.equals("1F") ){ // 요금정보
|
||||
sFileDir.append( sFileName.substring(5,9) + File.separator )
|
||||
.append( "Fare" + File.separator );
|
||||
}else if( sFileKindCode.equals("27") ){ // 차종코드정보
|
||||
sFileDir.append( sFileName.substring(10,14) + File.separator )
|
||||
.append( "CARTYPE" + File.separator );
|
||||
}else if( sFileKindCode.equals("2B") ){ // 차로구분코드
|
||||
sFileDir.append( sFileName.substring(9,13) + File.separator )
|
||||
.append( sFileName.substring(6, 8) + File.separator )
|
||||
.append( "BOOTH" + File.separator );
|
||||
}else if( sFileName.equals("11") ){ // RF 단말 정보
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4,6) + File.separator )
|
||||
.append( "RFT" + File.separator );
|
||||
}else if( sFileKindCode.equals("12") ){ // RFU File
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4, 6) + File.separator )
|
||||
.append( "RFU" + File.separator );
|
||||
}else if( sFileKindCode.equals("21") ){ // 근무자 정보
|
||||
sFileDir.append( TODAY.substring(0,4) + File.separator )
|
||||
.append( sOfficeID + File.separator )
|
||||
.append( "Person" + File.separator );
|
||||
}else if( sFileKindCode.equals("14") ){ // 요금단말정보
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4, 6) + File.separator )
|
||||
.append( "FAT" + File.separator );
|
||||
}else if( sFileKindCode.equals("15") ){ // FAU File
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4, 6) + File.separator )
|
||||
.append( "FAU" + File.separator );
|
||||
}else if( sFileKindCode.equals("17") ){ // 요금정산정보
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4, 6) + File.separator )
|
||||
.append( "FAA" + File.separator );
|
||||
}else if( sFileKindCode.equals("1A") ){ // 과잉쿠폰 정보
|
||||
sFileDir.append( sFileName.substring(6,14) + File.separator )
|
||||
.append( sFileName.substring(3, 5) + File.separator )
|
||||
.append( "CO" + File.separator );
|
||||
}else if( sFileKindCode.equals("1B") ){ // 과오납 정보
|
||||
sFileDir.append( sFileName.substring(6,14) + File.separator )
|
||||
.append( sFileName.substring(3, 5) + File.separator )
|
||||
.append( "OF" + File.separator );
|
||||
}else if( sFileKindCode.equals("1C") ){ // 입.출금 정보
|
||||
sFileDir.append( sFileName.substring(6,14) + File.separator )
|
||||
.append( sFileName.substring(3, 5) + File.separator )
|
||||
.append( "IO" + File.separator );
|
||||
}else if( sFileKindCode.equals("1D") ){ // 정액권 정보
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4, 6) + File.separator )
|
||||
.append( "FCO" + File.separator );
|
||||
}else if( sFileKindCode.equals("1E") ){ // 쿠폰폐기정보
|
||||
sFileDir.append( sFileName.substring(7,15) + File.separator )
|
||||
.append( sFileName.substring(4, 6) + File.separator )
|
||||
.append( "COW" + File.separator );
|
||||
}else if( sFileKindCode.equals("1H") ){ // 수입금정산정보
|
||||
sFileDir.append( sFileName.substring(10,18) + File.separator )
|
||||
.append( sFileName.substring(7, 9) + File.separator )
|
||||
.append( "INCOME" + File.separator );
|
||||
}else if( sFileKindCode.equals("1I") ){ // 시세입 정보
|
||||
sFileDir.append( sFileName.substring(9,17) + File.separator )
|
||||
.append( sFileName.substring(6, 8) + File.separator )
|
||||
.append( "TAXES" + File.separator );
|
||||
}else if( sFileKindCode.equals("1J") ){ // 가맹점정보
|
||||
sFileDir.append( sFileName.substring(13,21) + File.separator )
|
||||
.append( sFileName.substring(10,12) + File.separator )
|
||||
.append( "JOIN" + File.separator );
|
||||
}else if( sFileKindCode.equals("18") ){ // 카드환불정보
|
||||
sFileDir.append( sFileName.substring(9,17) + File.separator )
|
||||
.append( sFileName.substring(6, 8) + File.separator )
|
||||
.append( "REPAY" + File.separator );
|
||||
}else if( sFileKindCode.equals("2D") ){ // 과오납 차량소유자 정보
|
||||
sFileDir.append( sFileName.substring(10,14) + File.separator )
|
||||
.append( "CAROWNER" + File.separator );
|
||||
}else if( sFileKindCode.equals("WK") || sFileKindCode.equals("WM") ||
|
||||
sFileKindCode.equals("WN") || sFileKindCode.equals("WO") ||
|
||||
sFileKindCode.equals("WP") || sFileKindCode.equals("WQ") ||
|
||||
sFileKindCode.equals("WR") || sFileKindCode.equals("WS") ||
|
||||
sFileKindCode.equals("WT") || sFileKindCode.equals("WU") ||
|
||||
sFileKindCode.equals("WV") || sFileKindCode.equals("WW") ){ // RF 운영정보
|
||||
sFileDir.append(TODAY + File.separator);
|
||||
}else if( sFileKindCode.equals("52") ){ // RFID 정보
|
||||
sFileDir.append("pl" + File.separator);
|
||||
}else if( sFileKindCode.equals("53") ){ // RFID 사용 정보
|
||||
sFileDir.append("use" + File.separator);
|
||||
}else{
|
||||
|
||||
}
|
||||
return sFileDir.toString();
|
||||
}
|
||||
/**
|
||||
* 파일 디렉토리 존재유무를 체크하고 생성하는 메소드
|
||||
* @param sFileDir
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean checkDirectory(String sFileDir){
|
||||
String sTemp [] = sFileDir.split(File.separator);
|
||||
String sCreatDir = "";
|
||||
if( sTemp != null ){
|
||||
for( int idx = 0; idx < sTemp.length; idx++){
|
||||
sCreatDir = sCreatDir + sTemp[idx] + File.separator;
|
||||
if( !new File(sCreatDir).isDirectory() ){
|
||||
new File(sCreatDir).mkdir();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Help 메시지 출력
|
||||
*/
|
||||
public static void showHelp(String sClass) {
|
||||
System.err.println("Command :");
|
||||
System.err.println("\tjava " + sClass + " -Dftp.conf=CONFIG_FILE");
|
||||
System.err.println("");
|
||||
}
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
if(args.length != 0){
|
||||
showHelp("center.transfer.TNRecvServer01");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
String sConfFile = System.getProperty("ftp.conf");
|
||||
if (sConfFile == null || sConfFile.equals("")) {
|
||||
showHelp("center.transfer.TNRecvServer03");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Properties config = new Properties();
|
||||
try {
|
||||
config.load(sConfFile);
|
||||
}
|
||||
catch (IOException ie) {
|
||||
System.err.println("Can not read configuration file.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
TNRecvServer03 server = new TNRecvServer03(config);
|
||||
server.startup();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println("Starting Demon is failed.");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,441 +0,0 @@
|
||||
package center.transfer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.net.ConnectException;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.sql.Connection;
|
||||
import java.util.Date;
|
||||
|
||||
import com.exception.MessageException;
|
||||
import com.resources.data.Info;
|
||||
import com.util.Properties;
|
||||
import com.util.StringUtil;
|
||||
|
||||
import center.dao.CenterTransDAO;
|
||||
/**
|
||||
* 남산 1호터널 파일 송신 클라이언트 프로세스<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class TNSendClient01 extends CommClient {
|
||||
private int COMM_LENGTH = 28;
|
||||
private int M600_LENGTH = 77;
|
||||
private int M610_LENGTH = 77;
|
||||
private int M620_LENGTH = 35;
|
||||
private int M630_LENGTH = 84;
|
||||
private int M640_LENGTH = 84;
|
||||
private int M300_LENGTH = 38;
|
||||
private int M310_LENGTH = 39;
|
||||
private int M320_LENGTH = 39;
|
||||
/**
|
||||
* Constructor
|
||||
* @param config
|
||||
*/
|
||||
public TNSendClient01(Properties config){
|
||||
super(config, "TN_01", "PT" );
|
||||
}
|
||||
/**
|
||||
* startup
|
||||
*/
|
||||
public void startup() {
|
||||
Info fileInfo = null;
|
||||
Connection conn = null; // Connection
|
||||
CenterTransDAO commDAO = null; // 파일 전송 이력 클래스 변수
|
||||
|
||||
try{
|
||||
String sOfficeID = config.getProperty(sOrgCode+".office");
|
||||
|
||||
conn = getConnection();
|
||||
conn.setAutoCommit(false);
|
||||
commDAO = new CenterTransDAO(conn);
|
||||
|
||||
while (true) {
|
||||
try{
|
||||
// 미전송 파일 정보 조회(S:송신,0:미처리)
|
||||
fileInfo = commDAO.getTunnelSendInfo(sOfficeID);
|
||||
if( fileInfo != null ){
|
||||
// 통신 소켓 Open
|
||||
socket = new Socket(sOrgAddr, Integer.parseInt(sOrgPort));
|
||||
System.out.println("CONNECT");
|
||||
reader = socket.getInputStream();
|
||||
writer = socket.getOutputStream();
|
||||
|
||||
sDataSeq = fileInfo.getString("SEQ");
|
||||
|
||||
// 레코드 길이
|
||||
this.nDataSize = fileInfo.getInt("REC_LEN");
|
||||
// 레코드 건수
|
||||
this.nDataCount = fileInfo.getInt("REC_CNT");
|
||||
// 블럭당 시퀀스 개수
|
||||
this.nSequenceCount = fileInfo.getInt("SEQ_CNT");
|
||||
// 파일전송코드
|
||||
this.sFileCode = fileInfo.getString("FILE_CODE")+" ";
|
||||
// 파일명
|
||||
this.sFileName = fileInfo.getString("FILE_NAME");
|
||||
// 파일 디렉토리
|
||||
this.sFileDir = fileInfo.getString("DIR_NAME");
|
||||
|
||||
File fSendFile = new File(sFileDir, sFileName);
|
||||
|
||||
logInfo("");
|
||||
logInfo("File Send START");
|
||||
logInfo("Send File : " + sFileName);
|
||||
logInfo("Send File Size: " + fSendFile.length());
|
||||
// 파일 전송
|
||||
int nReturn = sendFile(fSendFile);
|
||||
logInfo("File Send END ["+nReturn+"]");
|
||||
|
||||
String sKBN = "0";
|
||||
if( fileInfo.getString("FILE_CODE").equals("51") ){
|
||||
sKBN = "1";
|
||||
}else if( fileInfo.getString("FILE_CODE").equals("WR") ){
|
||||
sKBN = "1";
|
||||
}else if( fileInfo.getString("FILE_CODE").equals("WS") ){
|
||||
sKBN = "3";
|
||||
}else if( fileInfo.getString("FILE_CODE").equals("WT") ){
|
||||
sKBN = "7";
|
||||
}
|
||||
|
||||
if( nReturn == 0 ){ // 파일 전송 완료 후 파일 전송 상태 반영
|
||||
commDAO.updTunnelSendInfo(sDataSeq, sOfficeID, fileInfo.getString("FILE_CODE"));
|
||||
commDAO.insertCardTransLog(sFileName, sOfficeID, sKBN, "집계전송완료");
|
||||
conn.commit();
|
||||
}else{
|
||||
if( nReturn == 1 ){ // 파일 미존재시
|
||||
commDAO.updTunnelSendInfo(sDataSeq, sOfficeID, fileInfo.getString("FILE_CODE"));
|
||||
}
|
||||
if( sKBN.equals("1")){
|
||||
commDAO.insertCardTransLog(sFileName, sOfficeID, sKBN, "집계전송실패");
|
||||
}
|
||||
conn.commit();
|
||||
}
|
||||
}
|
||||
else { // 전송자료 미존재
|
||||
// 1 Min Sleep
|
||||
try { Thread.sleep(SLEEP_01_MIN); } catch (InterruptedException ie) {}
|
||||
}
|
||||
}catch (ConnectException ce) { // 네트워크 연결 오류
|
||||
if (logger != null) logFail(" " + ce.getMessage());
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch (SocketException se) { // 소켓 오류
|
||||
if (logger != null) logFail(" " + se.getMessage());
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch(IOException ioe){ // System 오류
|
||||
if (logger != null) {
|
||||
logFail(" " + ioe.getMessage());
|
||||
logDebug(ioe);
|
||||
}
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch(Exception ex){ // System 오류
|
||||
if (logger != null) {
|
||||
logFail(" " + ex.getMessage());
|
||||
logDebug(ex);
|
||||
}
|
||||
// 10 Min Sleep
|
||||
try { Thread.sleep(SLEEP_10_MIN); } catch (InterruptedException ie) {}
|
||||
}finally{
|
||||
try{ if(reader!=null) reader.close(); }catch(Exception e){}
|
||||
try{ if(writer!=null) writer.close(); }catch(Exception e){}
|
||||
try{ if(socket!=null) socket.close(); }catch(Exception e){}
|
||||
}
|
||||
// 3 Sec Sleep
|
||||
try { Thread.sleep( SLEEP_03_SEC ); } catch (InterruptedException ie) {}
|
||||
}
|
||||
}catch(Exception e){
|
||||
logDebug(e);
|
||||
}finally{
|
||||
try{ if(conn!=null)conn.close(); }catch(Exception e){}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 파일전송 (0:정상처리, 1:FILE NOT FOUND, 2:수신전문 오류)
|
||||
* @param file
|
||||
* @return int
|
||||
* @throws SocketException
|
||||
* @throws IOException
|
||||
* @throws Exception
|
||||
*/
|
||||
public int sendFile(File file) throws Exception{
|
||||
int nReturn = 0;
|
||||
|
||||
try {
|
||||
int nBlockNo = 1;
|
||||
String sMessage, sSendMsg = null;
|
||||
|
||||
// Read File
|
||||
fileAccess = new RandomAccessFile(file,"r");
|
||||
|
||||
int nRecordSize = nDataSize * nDataCount;
|
||||
long nFileSize = fileAccess.length();
|
||||
// ------------------------------------- //
|
||||
// 업무개시전문 송신 (0600 / 001)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0600RC"
|
||||
+ " "
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "001 ";
|
||||
sMessage = dialogMessage(sSendMsg, M600_LENGTH);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0610", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
|
||||
// ------------------------------------- //
|
||||
// 파일수신 요청전문 송신 (0630)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0630RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ sFileName + StringUtil.getString(' ', 40-sFileName.length())
|
||||
+ StringUtil.ltos(nFileSize , 12)
|
||||
+ StringUtil.ntos(nRecordSize, 4);
|
||||
sMessage = dialogMessage(sSendMsg, M630_LENGTH);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0640", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
|
||||
// 센터에 이미 파일이 존재하면 그 크기만큼 파일을 스킵한다.
|
||||
long nRemoteFileSize = 0;
|
||||
nRemoteFileSize = Long.parseLong( sMessage.substring(68, 80));
|
||||
|
||||
while (true) {
|
||||
int nCount = 0;
|
||||
// 한 블럭(최대 100개의 레코드)의 데이터를 파일로부터 읽어들인다.
|
||||
for( int i = 0, nRecordNo = 1; i< nSequenceCount; i++, nRecordNo++){
|
||||
// setting offset for reading file data
|
||||
long nOffSet
|
||||
= ((nBlockNo-1)*nSequenceCount*nRecordSize) + (i*nRecordSize) + nRemoteFileSize;
|
||||
|
||||
if( nOffSet+1 > nFileSize ) { // offset 이 파일크기보다 클때 종료
|
||||
break;
|
||||
}
|
||||
byte [] buff // 파일 Read
|
||||
= getFileData(fileAccess, nOffSet, nRecordSize);
|
||||
// ------------------------------------- //
|
||||
// 데이터 전송 (0320)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0320RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ StringUtil.ntos(nBlockNo, 4)
|
||||
+ StringUtil.ntos(nRecordNo, 3)
|
||||
+ StringUtil.ntos(buff.length, 4);
|
||||
sendBinaryMessage(sSendMsg.getBytes()); // send message header
|
||||
sendBinaryMessage(buff); // send file data
|
||||
nCount++;
|
||||
}
|
||||
|
||||
// 송신할 레코드가 없을 경우 송신을 완료한다.
|
||||
if (nCount == 0) {
|
||||
break;
|
||||
}
|
||||
while (true) {
|
||||
// ------------------------------------- //
|
||||
// 결번확인 요청 및 응답 (0620, 0300)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0620RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ StringUtil.ntos(nBlockNo, 4)
|
||||
+ StringUtil.ntos(nCount, 3) ;
|
||||
|
||||
sMessage = dialogMessage(sSendMsg, M300_LENGTH + nSequenceCount);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0300", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// 재전송해야 할 결번을 얻어온다.
|
||||
int[] nMissing = getMissingRecords(sMessage, nCount);
|
||||
// 결번이 없을 경우 다음 블럭을 전송하도록 한다.
|
||||
if (nMissing == null || nMissing.length == 0) {
|
||||
// Sleep Time 5 Second
|
||||
try{
|
||||
Thread.sleep(BLOCK_SLEEP_TIME);
|
||||
}catch(Exception se){
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 결번을 재전송한다.
|
||||
for (int i = 0; i < nMissing.length; i++) {
|
||||
int nMissNo = nMissing[i];
|
||||
// setting offset for reading file data
|
||||
long nOffSet
|
||||
= ((nBlockNo-1)*nSequenceCount*nRecordSize) + ((nMissNo-1) * nRecordSize)+nRemoteFileSize;
|
||||
|
||||
if( nOffSet > nFileSize ) { // offset 이 파일크기보다 클때 종료
|
||||
break;
|
||||
}
|
||||
byte [] buff // 파일 Read
|
||||
= getFileData(fileAccess, nOffSet, nRecordSize);
|
||||
// ------------------------------------- //
|
||||
// 결번 데이터 전송 (0310)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0310RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ StringUtil.ntos(nBlockNo, 4)
|
||||
+ StringUtil.ntos(nMissNo, 3)
|
||||
+ StringUtil.ntos(buff.length, 4);
|
||||
sendBinaryMessage(sSendMsg.getBytes()); // send message header
|
||||
sendBinaryMessage(buff); // send file data
|
||||
|
||||
if (nMissNo > nCount ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nBlockNo++;
|
||||
}
|
||||
|
||||
// ------------------------------------- //
|
||||
// 파일수신 종료전문 송신 (0600 / 003)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0600RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "003 ";
|
||||
sMessage = dialogMessage(sSendMsg, M600_LENGTH);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0610", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// ------------------------------------- //
|
||||
// 종료전문 송신 (0600 / 004)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0600RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "004 ";
|
||||
sMessage = dialogMessage(sSendMsg, M600_LENGTH);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0610", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
}catch (FileNotFoundException fe) { // 파일 미존재
|
||||
nReturn = 1;
|
||||
if (logger != null) logFail("[ERROR 800] " + fe.getMessage());
|
||||
}catch (MessageException me){ // 수신전문 오류
|
||||
nReturn = 2;
|
||||
try { sendMessage(CMDFAIL("800")); }catch (Exception ex) { }
|
||||
if (logger != null) { logFail("[ERROR 800] " + me.getMessage()); }
|
||||
}catch (SocketException se){ // 소켓 오류
|
||||
throw se;
|
||||
}catch (IOException ie){ // 입출력 오류
|
||||
try { sendMessage(CMDFAIL("090")); }catch (Exception ex) { }
|
||||
throw ie;
|
||||
}catch (Exception ex){ // 시스템 오류
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
try { if (fileAccess != null) { fileAccess.close(); } } catch (IOException ie) { }
|
||||
}
|
||||
return nReturn;
|
||||
}
|
||||
/**
|
||||
* read file data
|
||||
* @param fileAccess
|
||||
* @param offset
|
||||
* @param nBufferSize
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
private byte[] getFileData(RandomAccessFile fileAccess, long offset, int nBufferSize) throws IOException{
|
||||
byte[] buf = new byte[nBufferSize];
|
||||
fileAccess.seek(offset);
|
||||
int nLen = fileAccess.read(buf);
|
||||
if(nLen < nBufferSize){
|
||||
byte[] dest = new byte[nLen];
|
||||
System.arraycopy(buf, 0, dest, 0, nLen);
|
||||
buf = dest;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
/**
|
||||
* 스트링에서 결번을 읽어들인다.('0': 미수신, '1': 수신)
|
||||
* @param sMessage
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
private int[] getMissingRecords(String sMessage, int len) {
|
||||
int index = 0;
|
||||
int []intArr = new int[len];
|
||||
String sMissing = sMessage.substring(M300_LENGTH);
|
||||
// 레코드 번호는 1부터 시작된다.
|
||||
for (int i = 0; i < len; i++) {
|
||||
// 값이 '0'이면 미수신 레코드
|
||||
if (sMissing.charAt(i) == '0') {
|
||||
intArr[index]=i;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
int [] nMissing = new int[index];
|
||||
System.arraycopy(intArr, 0, nMissing, 0, index);
|
||||
|
||||
return nMissing;
|
||||
}
|
||||
/**
|
||||
* 오류메시지 전문 생성
|
||||
* @param sErrorCode
|
||||
* @return String
|
||||
*/
|
||||
public String CMDFAIL(String sErrorCode) {
|
||||
String sFailMsg = "FTP 0600RC "
|
||||
+ sErrorCode // error code
|
||||
+ dateFormat.format(new Date())
|
||||
+ "004 ";
|
||||
return sFailMsg;
|
||||
}
|
||||
/**
|
||||
* Help 메시지 출력
|
||||
*/
|
||||
public static void showHelp(String sClass) {
|
||||
System.err.println("Command :");
|
||||
System.err.println("\tjava " + sClass + " -Dftp.conf=CONFIG_FILE");
|
||||
System.err.println("");
|
||||
}
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
if(args.length != 0){
|
||||
showHelp("center.transfer.TNSendClient01");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
String sConfFile = System.getProperty("ftp.conf");
|
||||
if (sConfFile == null || sConfFile.equals("")) {
|
||||
showHelp("center.transfer.TNSendClient01");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Properties config = new Properties();
|
||||
try {
|
||||
config.load(sConfFile);
|
||||
}
|
||||
catch (IOException ie) {
|
||||
System.err.println("Can not read configuration file.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
TNSendClient01 client = new TNSendClient01(config);
|
||||
client.startup();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println("Starting Demon is failed.");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,443 +0,0 @@
|
||||
package center.transfer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.net.ConnectException;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.sql.Connection;
|
||||
import java.util.Date;
|
||||
|
||||
import com.exception.MessageException;
|
||||
import com.resources.data.Info;
|
||||
import com.util.Properties;
|
||||
import com.util.StringUtil;
|
||||
|
||||
import center.dao.CenterTransDAO;
|
||||
/**
|
||||
* 남산 3호터널 파일 송신 클라이언트 프로세스<BR>
|
||||
* @author jckim
|
||||
* @since JDK 1.4.1
|
||||
* @version 0.1, 2007-09-28 초기 작성
|
||||
*/
|
||||
public class TNSendClient03 extends CommClient {
|
||||
private int COMM_LENGTH = 28;
|
||||
private int M600_LENGTH = 77;
|
||||
private int M610_LENGTH = 77;
|
||||
private int M620_LENGTH = 35;
|
||||
private int M630_LENGTH = 84;
|
||||
private int M640_LENGTH = 84;
|
||||
private int M300_LENGTH = 38;
|
||||
private int M310_LENGTH = 39;
|
||||
private int M320_LENGTH = 39;
|
||||
/**
|
||||
* Constructor
|
||||
* @param config
|
||||
*/
|
||||
public TNSendClient03(Properties config){
|
||||
super(config, "TN_03", "PT" );
|
||||
}
|
||||
/**
|
||||
* startup
|
||||
*/
|
||||
public void startup() {
|
||||
Info fileInfo = null;
|
||||
Connection conn = null; // Connection
|
||||
CenterTransDAO commDAO = null; // 파일 전송 이력 클래스 변수
|
||||
|
||||
try{
|
||||
String sOfficeID = config.getProperty(sOrgCode+".office");
|
||||
|
||||
conn = getConnection();
|
||||
conn.setAutoCommit(false);
|
||||
commDAO = new CenterTransDAO(conn);
|
||||
|
||||
while (true) {
|
||||
try{
|
||||
// 미전송 파일 정보 조회(S:송신,0:미처리)
|
||||
fileInfo = commDAO.getTunnelSendInfo(sOfficeID);
|
||||
if( fileInfo != null ){
|
||||
// 통신 소켓 Open
|
||||
socket = new Socket(sOrgAddr, Integer.parseInt(sOrgPort));
|
||||
System.out.println("CONNECT");
|
||||
reader = socket.getInputStream();
|
||||
writer = socket.getOutputStream();
|
||||
|
||||
sDataSeq = fileInfo.getString("SEQ");
|
||||
|
||||
// 레코드 길이
|
||||
this.nDataSize = fileInfo.getInt("REC_LEN");
|
||||
// 레코드 건수
|
||||
this.nDataCount = fileInfo.getInt("REC_CNT");
|
||||
// 블럭당 시퀀스 개수
|
||||
this.nSequenceCount = fileInfo.getInt("SEQ_CNT");
|
||||
// 파일전송코드
|
||||
this.sFileCode = fileInfo.getString("FILE_CODE")+" ";
|
||||
// 파일명
|
||||
this.sFileName = fileInfo.getString("FILE_NAME");
|
||||
// 파일 디렉토리
|
||||
this.sFileDir = fileInfo.getString("DIR_NAME");
|
||||
|
||||
File fSendFile = new File(sFileDir, sFileName);
|
||||
|
||||
logInfo("");
|
||||
logInfo("File Send START");
|
||||
logInfo("Send File : " + sFileName);
|
||||
logInfo("Send File Size: " + fSendFile.length());
|
||||
// 파일 전송
|
||||
int nReturn = sendFile(fSendFile);
|
||||
logInfo("File Send END ["+nReturn+"]");
|
||||
|
||||
String sKBN = "0";
|
||||
if( fileInfo.getString("FILE_CODE").equals("51") ){
|
||||
sKBN = "1";
|
||||
}else if( fileInfo.getString("FILE_CODE").equals("WR") ){
|
||||
sKBN = "1";
|
||||
}else if( fileInfo.getString("FILE_CODE").equals("WS") ){
|
||||
sKBN = "3";
|
||||
}else if( fileInfo.getString("FILE_CODE").equals("WT") ){
|
||||
sKBN = "7";
|
||||
}else if( fileInfo.getString("FILE_CODE").equals("52") ){
|
||||
sKBN = "9";
|
||||
}
|
||||
|
||||
if( nReturn == 0 ){ // 파일 전송 완료 후 파일 전송 상태 반영
|
||||
commDAO.updTunnelSendInfo(sDataSeq, sOfficeID, fileInfo.getString("FILE_CODE"));
|
||||
commDAO.insertCardTransLog(sFileName, sOfficeID, sKBN, "집계전송완료");
|
||||
conn.commit();
|
||||
}else{
|
||||
if( nReturn == 1 ){ // 파일 미존재시
|
||||
commDAO.updTunnelSendInfo(sDataSeq, sOfficeID, fileInfo.getString("FILE_CODE"));
|
||||
}
|
||||
if( sKBN.equals("1")){
|
||||
commDAO.insertCardTransLog(sFileName, sOfficeID, sKBN, "집계전송실패");
|
||||
}
|
||||
conn.commit();
|
||||
}
|
||||
}
|
||||
else { // 전송자료 미존재
|
||||
// 1 Min Sleep
|
||||
try { Thread.sleep(SLEEP_01_MIN); } catch (InterruptedException ie) {}
|
||||
}
|
||||
}catch (ConnectException ce) { // 네트워크 연결 오류
|
||||
if (logger != null) logFail(" " + ce.getMessage());
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch (SocketException se) { // 소켓 오류
|
||||
if (logger != null) logFail(" " + se.getMessage());
|
||||
// 5 Min Sleep
|
||||
try { Thread.sleep(SLEEP_05_MIN); } catch (InterruptedException ie) {}
|
||||
}catch(IOException ioe){ // System 오류
|
||||
if (logger != null) {
|
||||
logFail(" " + ioe.getMessage());
|
||||
logDebug(ioe);
|
||||
}
|
||||
// 1 Min Sleep
|
||||
try { Thread.sleep(SLEEP_01_MIN); } catch (InterruptedException ie) {}
|
||||
}catch(Exception ex){ // System 오류
|
||||
if (logger != null) {
|
||||
logFail(" " + ex.getMessage());
|
||||
logDebug(ex);
|
||||
}
|
||||
// 10 Min Sleep
|
||||
try { Thread.sleep(SLEEP_10_MIN); } catch (InterruptedException ie) {}
|
||||
}finally{
|
||||
try{ if(reader!=null) reader.close(); }catch(Exception e){}
|
||||
try{ if(writer!=null) writer.close(); }catch(Exception e){}
|
||||
try{ if(socket!=null) socket.close(); }catch(Exception e){}
|
||||
}
|
||||
// 3 Sec Sleep
|
||||
try { Thread.sleep( SLEEP_03_SEC ); } catch (InterruptedException ie) {}
|
||||
}
|
||||
}catch(Exception e){
|
||||
logDebug(e);
|
||||
}finally{
|
||||
try{ if(conn!=null)conn.close(); }catch(Exception e){}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 파일전송 (0:정상처리, 1:FILE NOT FOUND, 2:수신전문 오류)
|
||||
* @param file
|
||||
* @return int
|
||||
* @throws SocketException
|
||||
* @throws IOException
|
||||
* @throws Exception
|
||||
*/
|
||||
public int sendFile(File file) throws Exception{
|
||||
int nReturn = 0;
|
||||
|
||||
try {
|
||||
int nBlockNo = 1;
|
||||
String sMessage, sSendMsg = null;
|
||||
|
||||
// Read File
|
||||
fileAccess = new RandomAccessFile(file,"r");
|
||||
|
||||
int nRecordSize = nDataSize * nDataCount;
|
||||
long nFileSize = fileAccess.length();
|
||||
// ------------------------------------- //
|
||||
// 업무개시전문 송신 (0600 / 001)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0600RC"
|
||||
+ " "
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "001 ";
|
||||
sMessage = dialogMessage(sSendMsg, M600_LENGTH);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0610", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
|
||||
// ------------------------------------- //
|
||||
// 파일수신 요청전문 송신 (0630)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0630RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ sFileName + StringUtil.getString(' ', 40-sFileName.length())
|
||||
+ StringUtil.ltos(nFileSize , 12)
|
||||
+ StringUtil.ntos(nRecordSize, 4);
|
||||
sMessage = dialogMessage(sSendMsg, M630_LENGTH);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0640", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
|
||||
// 센터에 이미 파일이 존재하면 그 크기만큼 파일을 스킵한다.
|
||||
long nRemoteFileSize = 0;
|
||||
nRemoteFileSize = Long.parseLong( sMessage.substring(68, 80));
|
||||
|
||||
while (true) {
|
||||
int nCount = 0;
|
||||
// 한 블럭(최대 100개의 레코드)의 데이터를 파일로부터 읽어들인다.
|
||||
for( int i = 0, nRecordNo = 1; i< nSequenceCount; i++, nRecordNo++){
|
||||
// setting offset for reading file data
|
||||
long nOffSet
|
||||
= ((nBlockNo-1)*nSequenceCount*nRecordSize) + (i*nRecordSize) + nRemoteFileSize;
|
||||
|
||||
if( nOffSet+1 > nFileSize ) { // offset 이 파일크기보다 클때 종료
|
||||
break;
|
||||
}
|
||||
byte [] buff // 파일 Read
|
||||
= getFileData(fileAccess, nOffSet, nRecordSize);
|
||||
// ------------------------------------- //
|
||||
// 데이터 전송 (0320)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0320RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ StringUtil.ntos(nBlockNo, 4)
|
||||
+ StringUtil.ntos(nRecordNo, 3)
|
||||
+ StringUtil.ntos(buff.length, 4);
|
||||
sendBinaryMessage(sSendMsg.getBytes()); // send message header
|
||||
sendBinaryMessage(buff); // send file data
|
||||
nCount++;
|
||||
}
|
||||
|
||||
// 송신할 레코드가 없을 경우 송신을 완료한다.
|
||||
if (nCount == 0) {
|
||||
break;
|
||||
}
|
||||
while (true) {
|
||||
// ------------------------------------- //
|
||||
// 결번확인 요청 및 응답 (0620, 0300)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0620RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ StringUtil.ntos(nBlockNo, 4)
|
||||
+ StringUtil.ntos(nCount, 3) ;
|
||||
|
||||
sMessage = dialogMessage(sSendMsg, M300_LENGTH + nSequenceCount);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0300", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// 재전송해야 할 결번을 얻어온다.
|
||||
int[] nMissing = getMissingRecords(sMessage, nCount);
|
||||
// 결번이 없을 경우 다음 블럭을 전송하도록 한다.
|
||||
if (nMissing == null || nMissing.length == 0) {
|
||||
// Sleep Time 5 Second
|
||||
try{
|
||||
Thread.sleep(BLOCK_SLEEP_TIME);
|
||||
}catch(Exception se){
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 결번을 재전송한다.
|
||||
for (int i = 0; i < nMissing.length; i++) {
|
||||
int nMissNo = nMissing[i];
|
||||
// setting offset for reading file data
|
||||
long nOffSet
|
||||
= ((nBlockNo-1)*nSequenceCount*nRecordSize) + ((nMissNo-1) * nRecordSize)+nRemoteFileSize;
|
||||
|
||||
if( nOffSet > nFileSize ) { // offset 이 파일크기보다 클때 종료
|
||||
break;
|
||||
}
|
||||
byte [] buff // 파일 Read
|
||||
= getFileData(fileAccess, nOffSet, nRecordSize);
|
||||
// ------------------------------------- //
|
||||
// 결번 데이터 전송 (0310)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0310RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ StringUtil.ntos(nBlockNo, 4)
|
||||
+ StringUtil.ntos(nMissNo, 3)
|
||||
+ StringUtil.ntos(buff.length, 4);
|
||||
sendBinaryMessage(sSendMsg.getBytes()); // send message header
|
||||
sendBinaryMessage(buff); // send file data
|
||||
|
||||
if (nMissNo > nCount ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nBlockNo++;
|
||||
}
|
||||
|
||||
// ------------------------------------- //
|
||||
// 파일수신 종료전문 송신 (0600 / 003)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0600RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "003 ";
|
||||
sMessage = dialogMessage(sSendMsg, M600_LENGTH);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0610", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
// ------------------------------------- //
|
||||
// 종료전문 송신 (0600 / 004)
|
||||
// ------------------------------------- //
|
||||
sSendMsg = "FTP 0600RC"
|
||||
+ sFileCode
|
||||
+ "000"
|
||||
+ dateFormat.format(new Date())
|
||||
+ "004 ";
|
||||
sMessage = dialogMessage(sSendMsg, M600_LENGTH);
|
||||
// 응답코드 체크(000:정상)
|
||||
if( ! isSuccessMessage("0610", sMessage)){
|
||||
throw new MessageException(sMessage);
|
||||
}
|
||||
}catch (FileNotFoundException fe) { // 파일 미존재
|
||||
nReturn = 1;
|
||||
if (logger != null) logFail("[ERROR 800] " + fe.getMessage());
|
||||
}catch (MessageException me){ // 수신전문 오류
|
||||
nReturn = 2;
|
||||
try { sendMessage(CMDFAIL("800")); }catch (Exception ex) { }
|
||||
if (logger != null) { logFail("[ERROR 800] " + me.getMessage()); }
|
||||
}catch (SocketException se){ // 소켓 오류
|
||||
throw se;
|
||||
}catch (IOException ie){ // 입출력 오류
|
||||
try { sendMessage(CMDFAIL("090")); }catch (Exception ex) { }
|
||||
throw ie;
|
||||
}catch (Exception ex){ // 시스템 오류
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
try { if (fileAccess != null) { fileAccess.close(); } } catch (IOException ie) { }
|
||||
}
|
||||
return nReturn;
|
||||
}
|
||||
/**
|
||||
* read file data
|
||||
* @param fileAccess
|
||||
* @param offset
|
||||
* @param nBufferSize
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
private byte[] getFileData(RandomAccessFile fileAccess, long offset, int nBufferSize) throws IOException{
|
||||
byte[] buf = new byte[nBufferSize];
|
||||
fileAccess.seek(offset);
|
||||
int nLen = fileAccess.read(buf);
|
||||
if(nLen < nBufferSize){
|
||||
byte[] dest = new byte[nLen];
|
||||
System.arraycopy(buf, 0, dest, 0, nLen);
|
||||
buf = dest;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
/**
|
||||
* 스트링에서 결번을 읽어들인다.('0': 미수신, '1': 수신)
|
||||
* @param sMessage
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
private int[] getMissingRecords(String sMessage, int len) {
|
||||
int index = 0;
|
||||
int []intArr = new int[len];
|
||||
String sMissing = sMessage.substring(M300_LENGTH);
|
||||
// 레코드 번호는 1부터 시작된다.
|
||||
for (int i = 0; i < len; i++) {
|
||||
// 값이 '0'이면 미수신 레코드
|
||||
if (sMissing.charAt(i) == '0') {
|
||||
intArr[index]=i;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
int [] nMissing = new int[index];
|
||||
System.arraycopy(intArr, 0, nMissing, 0, index);
|
||||
|
||||
return nMissing;
|
||||
}
|
||||
/**
|
||||
* 오류메시지 전문 생성
|
||||
* @param sErrorCode
|
||||
* @return String
|
||||
*/
|
||||
public String CMDFAIL(String sErrorCode) {
|
||||
String sFailMsg = "FTP 0600RC "
|
||||
+ sErrorCode // error code
|
||||
+ dateFormat.format(new Date())
|
||||
+ "004 ";
|
||||
return sFailMsg;
|
||||
}
|
||||
/**
|
||||
* Help 메시지 출력
|
||||
*/
|
||||
public static void showHelp(String sClass) {
|
||||
System.err.println("Command :");
|
||||
System.err.println("\tjava " + sClass + " -Dftp.conf=CONFIG_FILE");
|
||||
System.err.println("");
|
||||
}
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
if(args.length != 0){
|
||||
showHelp("center.transfer.TNSendClient01");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
String sConfFile = System.getProperty("ftp.conf");
|
||||
if (sConfFile == null || sConfFile.equals("")) {
|
||||
showHelp("center.transfer.TNSendClient03");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
Properties config = new Properties();
|
||||
try {
|
||||
config.load(sConfFile);
|
||||
}
|
||||
catch (IOException ie) {
|
||||
System.err.println("Can not read configuration file.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
TNSendClient03 client = new TNSendClient03(config);
|
||||
client.startup();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
System.err.println("Starting Demon is failed.");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue