Commit 9f2edb3d authored by vkadam's avatar vkadam

Auto Allocation order scheduler Req [D15ASUN001]


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97832 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 4a6d87b5
/***
* VALLABH KADAM
* AutoAllocOrdrSch.java
* 07/APR/2015
* Request Id:-[D15ASUN001]
* */
package ibase.webitm.ejb.dis;
import java.io.File;
import java.io.FileOutputStream;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
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.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException;
public class AutoAllocOrdrSch implements Schedule
{
FileOutputStream fos1 = null;
java.util.Date startDate = new java.util.Date(System.currentTimeMillis());
java.util.Date endDate = new java.util.Date(System.currentTimeMillis());
Calendar calendar = Calendar.getInstance();
String startDateStr = null;
String endDateStr = null;
E12GenericUtility genericUtility = new E12GenericUtility();
@Override
public String schedule(HashMap arg0) throws Exception
{
// TODO Auto-generated method stub
return null;
}
@Override
public String schedule(String scheduleParamXML) throws Exception
{
int childNodeListLength = 0;
String childNodeName = null;
String loginSiteCode="",autoAlloc="";
ibase.utility.UserInfoBean userInfo = null;
int noOfParam=0;
String sysDate ="";
String retString="";
String retString1="";
String xtraParams = "",siteCode="",logRetStr="",strToWrite="";
NodeList parentNodeList = null,childNodeList = null;
Node parentNode = null,childNode = null;
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
// String windowName="w_sordalloc";
String windowName="w_sordalloc_sh";
StockAllocationPrc stAlcPrc=new StockAllocationPrc();
System.out.println("scheduleParamXML :- "+scheduleParamXML);
Document dom = null;
userInfo = new ibase.utility.UserInfoBean( scheduleParamXML );
loginSiteCode = userInfo.getSiteCode();
autoAlloc="Y";
try
{
xtraParams = "loginCode="+userInfo.getLoginCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+loginSiteCode+
"~~loginEmpCode="+userInfo.getEmpCode()+"~~autoAlloc="+autoAlloc;
System.out.println("XTRAPARAMS:"+xtraParams);
dom=genericUtility.parseString(scheduleParamXML);
java.util.Date today=new java.util.Date();
Calendar cal = Calendar.getInstance();
cal.setTime(today);
today = cal.getTime();
SimpleDateFormat sdf=new SimpleDateFormat(genericUtility.getApplDateFormat());
sysDate=sdf.format(today);
NodeList paramList = dom.getElementsByTagName( "SCHEDULE" );
noOfParam = paramList.getLength();
parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("childNodeListLength :-["+childNodeListLength+"]");
for(int ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName!=null && !"#text".equalsIgnoreCase(childNodeName))
{
if(ctr==0)
{
siteCode = childNode.getFirstChild().getNodeValue();
}
}
}
System.out.println("Site code :-"+siteCode);
/**
* Initialize Log here.
* before getData();
* */
logRetStr=intializingLog("AutoAllocOdrSh_log");
System.out.println("Log Return String :- ["+logRetStr+"]");
String xmlString1="<Detail1 dbID=\"\" domID=\"1\" objContext=\"1\" objName=\"sordalloc\">"
+ "<attribute pkNames=\"\" selected=\"N\" status=\"N\" updateFlag=\"A\"/>"
+ "<site_code><![CDATA["+siteCode+"]]></site_code>" //TA821
+ "<post_order_flag><![CDATA[N]]></post_order_flag>" //Strictly N
+ "<default_qty_flag><![CDATA[Y]]></default_qty_flag>" //Strictly Y
+ "<item_ser__from><![CDATA[00]]></item_ser__from><item_ser__to><![CDATA[ZZ]]></item_ser__to>"
+ "<cust_code__from><![CDATA[00]]></cust_code__from><cust_code__to><![CDATA[ZZ]]></cust_code__to>"
+ "<sale_order__from><![CDATA[00]]></sale_order__from><sale_order__to><![CDATA[ZZ]]></sale_order__to>"
+ "<due_date__from><![CDATA["+sysDate+"]]></due_date__from><due_date__to><![CDATA["+sysDate+"]]></due_date__to>"
+ "<item_code__from><![CDATA[00]]></item_code__from><item_code__to><![CDATA[ZZ]]></item_code__to>"
+ "<active_pick_allow/><dis_opt><![CDATA[S]]></dis_opt>" //Strictly S
+ "<batch_id/></Detail1>";
String xmlString2="<DocumentRoot><description>Datawindow Root</description>"
+ "<group0><description>Group0 description</description><Header0><description>Header0 members</description>"
+ "<Detail1 dbID=\"\" domID=\"1\" objContext=\"1\" objName=\"sordalloc\">"
+ "<attribute pkNames=\"\" selected=\"N\" status=\"N\" updateFlag=\"A\"/>"
+ "<site_code><![CDATA["+siteCode+"]]></site_code>"
+ "<post_order_flag><![CDATA[N]]></post_order_flag>"
+ "<default_qty_flag><![CDATA[Y]]></default_qty_flag>"
+ "<item_ser__from><![CDATA[00]]></item_ser__from><item_ser__to><![CDATA[ZZ]]></item_ser__to>"
+ "<cust_code__from><![CDATA[00]]></cust_code__from><cust_code__to><![CDATA[ZZ]]></cust_code__to>"
+ "<sale_order__from><![CDATA[00]]></sale_order__from><sale_order__to><![CDATA[ZZ]]></sale_order__to>"
+ "<due_date__from><![CDATA["+sysDate+"]]></due_date__from><due_date__to><![CDATA["+sysDate+"]]></due_date__to>"
+ "<item_code__from><![CDATA[00]]></item_code__from><item_code__to><![CDATA[ZZ]]></item_code__to>"
+ "<active_pick_allow/><dis_opt><![CDATA[S]]></dis_opt>"
+ "<batch_id/></Detail1>"
+ "</Header0></group0></DocumentRoot>";
System.out.println("xmlString1@@@@@@@@@@@@@@@@:["+xmlString1+"]");
System.out.println("xmlString2@@@@@@@@@@@@@@@@:["+xmlString2+"]");
retString=stAlcPrc.getData(xmlString1, xmlString2, windowName, xtraParams);
System.out.println("Get DATA retString :- ["+retString+"]");
/**
* Writing log after getData();
* */
startDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
strToWrite=" For Site code:- "+siteCode+", Post order:-'N' , Default Qty flag :- 'Y'"
+", Item Sceries from:- 00 To:- ZZ, Cust Code :- 00 To:- ZZ, Sales Order from:- 00 To:- ZZ,"
+ " Due Date from:- "+sysDate+" To:- "+sysDate+", Item Code from :- 00 To:- ZZ, Display Option:- 'S';\r\n\r\n"
+ " selected :-"+retString+" ";
/**
* Append Start date
* */
strToWrite=strToWrite+startDate+"\r\n\r\n";
retString1=stAlcPrc.process(xmlString1, retString, windowName, xtraParams);
System.out.println("Process String :-["+retString1+"]");
/**
* Writing log after process();
* */
endDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
endDateStr = sdf1.format(endDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
strToWrite=strToWrite+endDateStr;
strToWrite=" "+strToWrite+retString1+"\r\n\r\n";
System.out.println("Str write :-----------["+strToWrite+"]");
fos1.write(strToWrite.getBytes());
System.out.println("End Time for transaction"+endDateStr+"string to write"+strToWrite);
return retString;
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
private String intializingLog(String fileName)
{
String log="intializingLog_Failed";
String currTime = null;
try{
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
try
{
currTime = sdf1.format(new Timestamp(System.currentTimeMillis())).toString();
currTime = currTime.replaceAll("-","");
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
fileName = fileName+currTime+calendar.get(Calendar.HOUR)+""+calendar.get(Calendar.MINUTE)+".txt";
fos1 = new FileOutputStream(CommonConstants.JBOSSHOME + File.separator +"EDI"+File.separator+fileName);
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
e.printStackTrace();
}
startDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
fos1.write(("Fetching Records Started At " + startDateStr +"\r\n").getBytes());
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
e.printStackTrace();
}
log ="intializingLog_Successesfull";
return log;
}
@Override
public String schedulePriority(String arg0) throws Exception
{
// TODO Auto-generated method stub
return null;
}
}
......@@ -134,6 +134,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
detailDom = genericUtility.parseString(xmlString2);
}
rtrStr = getData(headerDom, detailDom, windowName, xtraParams);
System.out.println("@@@@@@@@@@@RTR STR:- ["+rtrStr+"]");
}
catch (Exception e)
{
......@@ -413,6 +414,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
+" ITEM.ITEM_SER <=? AND "
+" CUSTOMER.CUST_CODE >=? AND "
+" CUSTOMER.CUST_CODE <=? AND "
+" SORDER.SALE_ORDER >= ? AND "
+" SORDER.SALE_ORDER <= ? AND "
+" SORDER.DUE_DATE >= ? AND"
......@@ -420,7 +422,9 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
+" SORDITEM.ITEM_CODE >= ? AND "
+" SORDITEM.ITEM_CODE <= ? "
+" AND CASE WHEN SORDDET.STATUS IS NULL THEN 'P' ELSE SORDDET.STATUS end <> 'C' "
+" AND CASE WHEN SORDER.STATUS IS NULL THEN 'P' ELSE SORDER.STATUS end IN ('P','H') " ; //change done by Kunal on 22/10/12 as per S Manoharan instruction ,consider Hold status
+" AND CASE WHEN SORDER.STATUS IS NULL THEN 'P' ELSE SORDER.STATUS end IN ('P','H') " ;
//change done by Kunal on 22/10/12 as per S Manoharan instruction ,consider Hold status
if( "A".equalsIgnoreCase(disOpt)) // added condition by cpatil on 17/12/13
{
getDataSql = getDataSql + "AND (SORDITEM.QUANTITY*SORDITEM.CONV__QTY_STDQTY) - (SORDITEM.QTY_DESP*SORDITEM.CONV__QTY_STDQTY) - SORDITEM.QTY_ALLOC >= 0 ";
......@@ -429,6 +433,19 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
{
getDataSql = getDataSql + "AND (SORDITEM.QUANTITY*SORDITEM.CONV__QTY_STDQTY) - (SORDITEM.QTY_DESP*SORDITEM.CONV__QTY_STDQTY) - SORDITEM.QTY_ALLOC > 0 ";
}
/**
*VALLABH KADAM Add condition 7/APR/15
*for Scheduler [AutoAllocOrdrSch.java]
* Req Id:- [D15ASUN001]
* */
if(windowName.equalsIgnoreCase("w_sordalloc_sh")){
System.out.println("In if win name===='w_sordalloc_sh'");
getDataSql = getDataSql +" AND CASE WHEN CUSTOMER.AUTO_STK_ALLOC IS NULL THEN 'Y' ELSE CUSTOMER.AUTO_STK_ALLOC end = 'Y' ";
}
/**
* VALLABH KADAM Add condition 7/APR/15 END
* */
getDataSql = getDataSql + " AND SORDITEM.LINE_TYPE = 'I' "
+ " ORDER BY SORDER.CUST_CODE,SORDER.SALE_ORDER,SORDITEM.ITEM_CODE__ORD ";
......@@ -941,11 +958,13 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
{
headerDom = genericUtility.parseString(xmlString);
System.out.println("headerDom" + headerDom);
System.out.println("HeaderDoM :-["+xmlString+"]");
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
System.out.println("detailDom" + detailDom);
System.out.println("DetailDoM :-["+xmlString2+"]");
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
......@@ -1825,6 +1844,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
String allocqtyStr = "";
boolean allocQtyFlag = false;
boolean isdetFlag = false;
String autoAlloc=""; //VALLABH KADAM 08/APR/15
// ADDED BY RITESH ON 15/07/14 END
try
{
......@@ -2354,6 +2374,22 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
xmlBuff.append("<batch_id><![CDATA["+ batchId +"]]></batch_id>"); //VALLABH BATCH_ID to save.
xmlBuff.append("<alloc_source><![CDATA[P]]></alloc_source>");
xmlBuff.append("<alloc_flag><![CDATA[A]]></alloc_flag>");
/**
* VALLABH KADAM 08/APR/15
* EDI_STAT set to 'N'
* For AutoAllocOrdrSch.java
* Req Id:- [D15ASUN001]
* */
autoAlloc=genericUtility.getValueFromXTRA_PARAMS(xtraParams, "autoAlloc");
System.out.println("Xtra Param autoAlloc :- ["+autoAlloc+"]");
if(autoAlloc!=null && ("Y".equalsIgnoreCase(autoAlloc))){
xmlBuff.append("<edi_stat><![CDATA[N]]></edi_stat>");
}
/**
* VALLABH KADAM 08/APR/15 END
* */
xmlBuff.append("</Detail1>");
}
HashMap mapDet = new HashMap();
......
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