Commit e3a663b3 authored by msharma's avatar msharma

Set siteCode in disparm variable named CYCLE_COUNT_SITE for which Cycle count...

Set siteCode in disparm variable named CYCLE_COUNT_SITE for which Cycle count scheduler to be executed


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94247 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 3d072bce
......@@ -74,16 +74,72 @@ public class PhysicalCountSchedule implements Schedule
public String schedule(String scheduleParamXML)throws Exception
{
ibase.utility.UserInfoBean userInfo = null;
//Change by chandrashekar on 13/02/14
String disparmLoginSiteCode="";
ConnDriver connDriver = new ConnDriver();
Connection conn = null;
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String queryString="";
try
{
//Chnaged by Rohan on 7/2/12.start
//insertSchedule();
System.out.println("************ ["+scheduleParamXML+"]");
userInfo = new ibase.utility.UserInfoBean( scheduleParamXML );
loginSiteCode = userInfo.getSiteCode();
System.out.println("Site code======**************====> "+loginSiteCode);
//change done by chandrashekar on 13/2/14 start
disparmLoginSiteCode = new DistCommon().getDisparams("999999","CYCLE_COUNT_SITE", conn);
if (disparmLoginSiteCode == null|| "NULLFOUND".equalsIgnoreCase(disparmLoginSiteCode))
{
disparmLoginSiteCode = "";
}
if(disparmLoginSiteCode.trim().length() == 0)
{
queryString="select distinct(site_code) from stock";
System.out.println("2-Print queryString---"+queryString);
pstmt=conn.prepareStatement(queryString);
rs=pstmt.executeQuery();
while(rs.next())
{
loginSiteCode = rs.getString(1);
System.out.println("Site code======**************====> "+loginSiteCode);
insertSchedule(loginSiteCode,userInfo.getEmpCode(),userInfo);
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(rs!=null)
{
rs.close();
rs=null;
}
}
else
{
String[] arrStr =disparmLoginSiteCode.split(",");
int len =arrStr.length;
for(int i =0;i<len;i++)
{
loginSiteCode =arrStr[i];
if(isExist(conn, "site", "site_code" ,loginSiteCode))
{
System.out.println("Site code from diparm======**************====> "+loginSiteCode);
insertSchedule(loginSiteCode,userInfo.getEmpCode(),userInfo);
}
}
}
//change done by chandrashekar on 13/2/14 end
//loginSiteCode = userInfo.getSiteCode();
//System.out.println("Site code======**************====> "+loginSiteCode);
//insertSchedule(loginSiteCode,userInfo.getEmpCode(),userInfo);
//Chnaged by Rohan on 7/2/12.end
}
......@@ -233,9 +289,10 @@ public class PhysicalCountSchedule implements Schedule
//Added by manoj dtd 05/02/2013 to generate tran id as per keystring
tranId=generateTranId("w_phy_item_scan",loginSiteCode,conn);
queryString="select count(*) from work_calendar where work_date=? and working='Y' ";
queryString="select count(*) from work_calendar where work_date=? and working='Y' and site_code=? ";
pstmt=conn.prepareStatement(queryString);
pstmt.setTimestamp(1,dts);
pstmt.setString(2,loginSiteCode);//added by chandrashekar on 13/02/14
rs=pstmt.executeQuery();
if(rs.next())
{
......@@ -362,8 +419,10 @@ public class PhysicalCountSchedule implements Schedule
chgUser="WMS";
queryString="update physcandet set status='X' where status is null ";
//queryString="update physcandet set status='X' where status is null ";commented by chandrashekar
queryString="update physcandet A set status='X' WHERE 1 IN(SELECT 1 FROM PHYSCAN B WHERE A.TRAN_ID=B.TRAN_ID AND B.SITE_CODE=?) AND A.status is null";
pstmt=conn.prepareStatement(queryString);
pstmt.setString(1,loginSiteCode);
pstmt.executeUpdate();
pstmt.close();
pstmt=null;
......@@ -381,9 +440,10 @@ public class PhysicalCountSchedule implements Schedule
pstmt.close();
pstmt=null;
queryString = "select work_date from work_calendar where work_date < ? and working='N' order by work_date desc ";
queryString = "select work_date from work_calendar where work_date < ? and site_code=? and working='N' order by work_date desc ";
pstmt=conn.prepareStatement(queryString);
pstmt.setTimestamp(1,dts);
pstmt.setString(2, loginSiteCode);//added by chandrashekar on 13/02/14
rs=pstmt.executeQuery();
while(rs.next())
{
......@@ -906,7 +966,7 @@ public class PhysicalCountSchedule implements Schedule
try
{
if(!isError || rec>0)
if(!isError && rec>0)
{
conn.commit();
}
......@@ -945,6 +1005,40 @@ public class PhysicalCountSchedule implements Schedule
}
}
private boolean isExist(Connection conn, String tableName, String columnName, String value) throws ITMException, RemoteException
{
PreparedStatement pstmt = null ;
ResultSet rs = null ;
String sql = "";
boolean status = false;
try
{
sql = "SELECT count(*) from " + tableName + " where " + columnName +" = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,value);
rs = pstmt.executeQuery();
if(rs.next())
{
if(rs.getBoolean(1))
{
status = true;
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
System.out.println("Exception in isExist ");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning String from isExist ");
return status;
}
private Connection getConnection()throws BaseException
{
Connection con = null;
......
......@@ -45057,4 +45057,8 @@ Insert into FINPARM (PRD_CODE,VAR_NAME,VAR_TYPE,VAR_VALUE,CHG_DATE,CHG_USER,CHG_
insert into system_events (obj_name,event_code,event_context,service_code,method_rule,overwrite_core,chg_date,chg_user,chg_term,result_handle,comp_type,comp_name)
values ('sordform_tr','post_validate','1','post_gen_val',null,'0',sysdate,'KUNAL','KUNAL','2','EJB','GenValidate');
--Added by Manoj dtd 14/02/2014 to set siteCode for which Cycle count scheduler to be executed
insert into disparm(PRD_CODE,VAR_NAME,VAR_TYPE,VAR_VALUE,DESCR,VAR_SUBS,CHG_DATE,CHG_USER,CHG_TERM) values ('999999','CYCLE_COUNT_SITE','S','TA821','Site Code Defined for Cycle count Scheduler',null,sysdate,'BASE','BASE');
--Ended by Manoj dtd 14/02/2014 to set siteCode for which Cycle count scheduler to be executed
commit;
\ No newline at end of file
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