You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

563 lines
24 KiB
Java

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){} }
}
}
}