Commit d7ba5110 authored by manohar's avatar manohar

DI89SUN223 file seq to store in invoice table and incremented for each day/customer


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91147 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c9f35f11
......@@ -38,6 +38,9 @@ public class DownloadCSVBatchBean implements Schedule
String xmlToCsvStr = null;
HashMap tranFileMip = new HashMap();
// 11/09/09 manoharan DI89SUN223
HashMap tranSeqMap = new HashMap();
// end 11/09/09 manoharan
String tranId = null;
String custCode = null;
......@@ -70,6 +73,11 @@ public class DownloadCSVBatchBean implements Schedule
java.sql.Connection conn = null;
java.sql.PreparedStatement pstmt = null;
java.sql.ResultSet rs = null;
// 11/09/09 manoharan to store and get the sequence (file suffix) in invoice table
java.sql.PreparedStatement pstmtSeq = null;
java.sql.ResultSet rsSeq = null;
java.sql.Timestamp tranDate = null;
// end 11/09/09 manoharan to store and get the sequence (file suffix) in invoice table
ConnDriver connDriver = new ConnDriver();
try
......@@ -122,9 +130,13 @@ public class DownloadCSVBatchBean implements Schedule
String str = null;
client = new TranXmlData();
// 11/09/09 manoharan DI89SUN223 to store the sequence number (file suffix) in invoice table and increment for the same day
pstmtSeq = conn.prepareStatement("SELECT MAX(download_file_seq) INVOICE WHERE CUST_CODE = ? AND TRAN_DATE = ?");
// end 11/09/09 manoharan to store the sequence number (file suffix) in invoice table and increment for the same day
//start - select all the undownloaded invoice, if found, then download for each.
sql = "SELECT iv.INVOICE_ID TRAN_ID, iv.CUST_CODE, cu.UNIFORM_CODE, "
+" to_char( iv.tran_date, 'ddmmyyyy' ) dt "
+" to_char( iv.tran_date, 'ddmmyyyy' ) dt , iv.tran_date tran_date"
+" FROM INVOICE iv, CUSTOMER cu, site_customer sc "
+" WHERE iv.cust_code = cu.cust_code( + ) "
+" and iv.site_code = sc.site_code "
......@@ -148,32 +160,58 @@ public class DownloadCSVBatchBean implements Schedule
custCode = rs.getString( "CUST_CODE" );
uniformCode = rs.getString( "UNIFORM_CODE" );
dt = rs.getString( "dt" );
tranDate = rs.getTimestamp( "tran_date" );
if( custCode.equalsIgnoreCase( prvCustCode ) && dt.equalsIgnoreCase( previousDay ) )
{
recCounter++;
}
else
{
// 11/09/09 DI89SUN223 manoharan to store the sequence number (file suffix) in invoice table and increment for the same day
//recCounter = 1;
rsSeq = pstmtSeq.executeQuery();
pstmtSeq.setString(1,custCode);
pstmtSeq.setTimestamp(2,tranDate);
if( rsSeq.next() )
{
recCounter = = rsSeq.getInt("download_file_seq");
}
rsSeq.close();
rsSeq = null;
if (recCounter == 0 )
{
recCounter = 1;
}
// end 11/09/09 manoharan to store the sequence number (file suffix) in invoice table and increment for the same day
}
dnldFileName = ( uniformCode == null ? "" : uniformCode.trim() ) + "_" + dt + "_" + ( new java.text.DecimalFormat( "000" ) ).format( recCounter );
prvCustCode = custCode;
previousDay = dt;
tranFileMip.put( tranId, dnldFileName );
// 11/09/09 DI89SUN223 manoharan to store the sequence number (file suffix) in invoice table and increment for the same day
tranSeqMap.put(tranId, new Integer(recCounter));
// end 11/09/09 manoharan to store the sequence number (file suffix) in invoice table and increment for the same day
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
// 11/09/09 DI89SUN223 manoharan to store the sequence (file suffix) in invoice table and increment the same
pstmtSeq.close();
pstmtSeq = null;
// end 11/09/09 manoharan to store the sequence (file suffix) in invoice table and increment the same
//end - select all the undownloaded invoice, if found, then download for each.
pstmt = conn.prepareStatement( "update invoice set download_flag = 'Y' where invoice_id = ?" );
// 11/09/09 DI89SUN223 manoharan to store the sequence (file suffix) in invoice table and increment the same
//pstmt = conn.prepareStatement( "update invoice set download_flag = 'Y' where invoice_id = ?" );
pstmt = conn.prepareStatement( "update invoice set download_flag = 'Y', download_file_seq = ? where invoice_id = ?" );
// end 11/09/09 manoharan to store the sequence (file suffix) in invoice table and increment the same
Iterator tranItr = tranFileMip.keySet().iterator();
while( tranItr.hasNext() )
{
try
......@@ -201,7 +239,12 @@ public class DownloadCSVBatchBean implements Schedule
fw = null;
//Changed by Rupali [update the Download_flag after each invoice files downloading].Start
//pstmt.addBatch();
pstmt.setString( 1, tranId );
// 11/09/09 DI89SUN223 manoharan to store the sequence (file suffix) in invoice table and increment the same
recCounter = (( Integer )tranSeqMap.get( tranId )).intValue();
// end 11/09/09 manoharan to store the sequence (file suffix) in invoice table and increment the same
pstmt.setInt( 1, recCounter );
pstmt.setString( 2, tranId );
int rowCnt = pstmt.executeUpdate();
if(rowCnt >= 1){
conn.commit();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment