Commit b6a301c4 authored by cpatil's avatar cpatil

request id D15HSUN009. [ Scheduler to create for batch load of Adjustment...

 request id D15HSUN009. [ Scheduler to create for batch load of Adjustment Receipts and Distribution issue. ]


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@99303 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 739116d8
package ibase.webitm.ejb.dis;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.MasterApplyEJBLocal;
import ibase.webitm.utility.ITMException;
import java.sql.*;
import java.io.*;
import javax.naming.InitialContext;
public class BatchLoadIdSpecificSch implements Schedule
{
E12GenericUtility genericUtility = new E12GenericUtility();
//FileOutputStream fos1 = null;
@Override
public String schedule(String scheduleParamXML)throws Exception
{
System.out.println("BatchLoadIdSpecificSch : schedule( )");
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String batchId = null;
ibase.utility.UserInfoBean userInfoBean = new ibase.utility.UserInfoBean( scheduleParamXML );
String objName="";
String sql="",retString="";
try
{
E12GenericUtility genericUtility= new E12GenericUtility();
System.out.println("scheduleParamXML-----"+scheduleParamXML);
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
Document dom=genericUtility.parseString(scheduleParamXML);
//Condition Added By Manoj 25/01/2013 to load batch Win Name wise.
objName=genericUtility.getColumnValue("ACTUALPARAMETER",dom);
/*if(objName==null)
{
//Changed By Mahesh Patidar on 23-SEP-13[to avoid batchloading if tran_id_ref is not null]
// query = "SELECT BATCH_ID FROM BATCHLOAD WHERE LOAD_STAT = 'N' ";
query = "SELECT BATCH_ID FROM BATCHLOAD WHERE LOAD_STAT = 'N' AND TRAN_ID__REF IS NULL ";
//Ended By Mahesh Patidar on 23-SEP-13[to avoid batchloading if tran_id_ref is not null]
}
else
{
//Changed By Mahesh Patidar on 23-SEP-13[to avoid batchloading if tran_id_ref is not null]
// query = "SELECT BATCH_ID FROM BATCHLOAD WHERE LOAD_STAT = 'N' and WIN_NAME='"+objName+"'";
query = "SELECT BATCH_ID FROM BATCHLOAD WHERE LOAD_STAT = 'N' and WIN_NAME='"+objName+"' AND TRAN_ID__REF IS NULL ";
//Ended By Mahesh Patidar on 23-SEP-13[to avoid batchloading if tran_id_ref is not null]
}*/
/*
sql = "SELECT BATCH_ID FROM BATCHLOAD WHERE LOAD_STAT='N' AND TRAN_ID__REF IS NULL AND "+
"BATCH_ID LIKE '117%' AND WIN_NAME ='w_wo_close' ";
*/
sql = "SELECT BATCH_ID FROM BATCHLOAD WHERE LOAD_STAT='N' AND TRAN_ID__REF IS NULL AND "+
"BATCH_ID LIKE '900%' AND WIN_NAME IN('w_adj_rcp','w_dist_issue')";
System.out.println("Query executed [" + sql + "]");
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
String xtraParams = null;
AppConnectParm appConnect = new AppConnectParm();
InitialContext ctx = new InitialContext ( appConnect.getProperty() );
MasterApplyEJBLocal masterApplyLocal = ( MasterApplyEJBLocal ) ctx.lookup("ibase/MasterApplyEJB/local");
while( rs.next())
{
batchId = rs.getString("BATCH_ID");
System.out.println("batchId>>>>>"+batchId);
try
{
retString = masterApplyLocal.applyMasterTable( batchId, xtraParams, userInfoBean );
System.out.println("@@@@@@@@@@@ retString["+retString+"]");
}
catch (Exception e)
{
e.printStackTrace();
FileOutputStream fileOutputStream = new FileOutputStream( CommonConstants.JBOSSHOME + File.separator +"LOG"+File.separator+userInfoBean.getEmpCode()+"_"+batchId+"_BatchUpload.log" );
byte convertStringToByte[] = e.toString().getBytes();
fileOutputStream.write( convertStringToByte );
fileOutputStream.close( );
}
}
rs.close();
rs=null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
System.out.println(">>>>>>>>>>>>>BatchLoadIdSpecificSch In catch:");
System.out.println(e);
}
finally
{
if(conn != null)
{
conn.close();
conn = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
return retString;
}
@Override
public String schedule(HashMap arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public String schedulePriority(String arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
}
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