Commit 469c686a authored by rtiwari's avatar rtiwari

updated for single_lot condition


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@95674 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a2ffba46
...@@ -20,6 +20,7 @@ import javax.naming.InitialContext; ...@@ -20,6 +20,7 @@ import javax.naming.InitialContext;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.adv.StockAllocPrc;
import ibase.webitm.utility.GenericUtility; import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.TransIDGenerator; import ibase.webitm.utility.TransIDGenerator;
...@@ -30,6 +31,10 @@ import ibase.system.config.*; ...@@ -30,6 +31,10 @@ import ibase.system.config.*;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;
import javax.ejb.Stateless; // added for ejb3 import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3 @Stateless // added for ejb3
...@@ -219,7 +224,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -219,7 +224,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
if(postOrderFg == null || postOrderFg.trim().length() == 0) if(postOrderFg == null || postOrderFg.trim().length() == 0)
{ {
postOrderFg = ""; postOrderFg = "";
System.out.println("Site Code From is Null..."); System.out.println("Post Order From is Null...");
errString = itmDBAccessEJB.getErrorString("","VTMRPPARM","","",conn); errString = itmDBAccessEJB.getErrorString("","VTMRPPARM","","",conn);
return errString; return errString;
} }
...@@ -888,7 +893,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -888,7 +893,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
Document detailDom = null; Document detailDom = null;
Document headerDom = null; Document headerDom = null;
GenericUtility genericUtility = GenericUtility.getInstance(); //GenericUtility genericUtility = GenericUtility.getInstance();
System.out.println("below genericUtility--------------->>>>>>>>>"); System.out.println("below genericUtility--------------->>>>>>>>>");
try try
{ {
...@@ -970,15 +975,17 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -970,15 +975,17 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
boolean flag = false,isFlag = true,allocqtyflag = false,pendingOrderFlag=false; boolean flag = false,isFlag = true,allocqtyflag = false,pendingOrderFlag=false;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String sql = "",shipStatus=""; String sql = "",shipStatus="";
try try
{ {
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"); chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
connDriver = null; connDriver = null;
parentNodeList = detailDom.getElementsByTagName("Detail2"); parentNodeList = detailDom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength(); parentNodeListLength = parentNodeList.getLength();
System.out.println("parentNodeListLength------------------->"+parentNodeListLength); System.out.println("parentNodeListLength------------------->"+parentNodeListLength);
...@@ -1026,6 +1033,10 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1026,6 +1033,10 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
{ {
expLev = childNode.getFirstChild().getNodeValue(); expLev = childNode.getFirstChild().getNodeValue();
} }
if (childNodeName.equals("cust_code"))
{
custCode = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("hold_flag")) if (childNodeName.equals("hold_flag"))
{ {
holdFlag = childNode.getFirstChild().getNodeValue(); holdFlag = childNode.getFirstChild().getNodeValue();
...@@ -1200,7 +1211,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1200,7 +1211,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
if(allocQty > 0 && flag == false) if(allocQty > 0 && flag == false)
{ {
System.out.println("if calling........"); System.out.println("if calling........");
errString = sorderAllocate(saleOrder, lineNo, itemCode, allocQty, expLev ,holdFlag,activeAllow); errString = sorderAllocate(saleOrder, lineNo, itemCode, allocQty, expLev ,holdFlag,activeAllow,xtraParams);
System.out.println("@@@@@@ sorderAllocate return string["+errString+"]"); System.out.println("@@@@@@ sorderAllocate return string["+errString+"]");
if (errString != null && errString.trim().length() > 0) if (errString != null && errString.trim().length() > 0)
{ {
...@@ -1447,7 +1458,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1447,7 +1458,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
* @return * @return
* @throws ITMException * @throws ITMException
*/ */
private String sorderAllocate(String saleOrder, String lineNo, String itemCode, double allocQty, String expLev ,String holdFlag,String activeAllow) throws ITMException private String sorderAllocate(String saleOrder, String lineNo, String itemCode, double allocQty, String expLev ,String holdFlag,String activeAllow,String xtraParams) throws ITMException
{ {
System.out.println("updateSOrder calling .............."); System.out.println("updateSOrder calling ..............");
String getDataSql = null; String getDataSql = null;
...@@ -1469,7 +1480,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1469,7 +1480,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
java.sql.Date expDate = new java.sql.Date(System.currentTimeMillis()); java.sql.Date expDate = new java.sql.Date(System.currentTimeMillis());
java.sql.Date mfgDate = new java.sql.Date(System.currentTimeMillis()); java.sql.Date mfgDate = new java.sql.Date(System.currentTimeMillis());
java.sql.Date dateAlloc= new java.sql.Date(System.currentTimeMillis()); java.sql.Date dateAlloc= new java.sql.Date(System.currentTimeMillis());
String forcedFlag=null;
String updateSorditem = null; String updateSorditem = null;
String insertSql = null; String insertSql = null;
String updateSordalloc = null; String updateSordalloc = null;
...@@ -1485,6 +1496,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1485,6 +1496,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
double convQtyStduom = 0 ; double convQtyStduom = 0 ;
double quantityStduom = 0 ; double quantityStduom = 0 ;
double pendingQuantity = 0; double pendingQuantity = 0;
double qty=0;
int intCnt=0; int intCnt=0;
int updCnt=0; int updCnt=0;
int pendingQty = 0; int pendingQty = 0;
...@@ -1500,12 +1512,41 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1500,12 +1512,41 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
Statement st = null; Statement st = null;
ResultSet rs = null ; ResultSet rs = null ;
ResultSet rsSItem = null; ResultSet rsSItem = null;
StringBuffer xmlBuff = null;
String xmlString = null,retString = null;
DistCommon dComm = new DistCommon(); DistCommon dComm = new DistCommon();
Timestamp sysDate = null;
Calendar currentDate = Calendar.getInstance();
double minSelfLife=0; double minSelfLife=0;
// ADDED BY RITESH ON 15/07/14 START
String singleLot = "";
TreeMap stockLot=new TreeMap<String,Double>();
TreeMap<String,ArrayList<String>>stockLotDetail=new TreeMap<String, ArrayList<String>>();
ArrayList<String> lotList= new ArrayList<String>();
ArrayList<String> lotDeatilList = new ArrayList<String>();
PreparedStatement pstmtShip = null;
ResultSet rsShip = null;
String sqlShip = "";
double shipperSizeLot = 0;
boolean getLotFlag = false ;
double totalQtyAvailAlloc = 0d;
boolean isQtyAvail = false ;
int linenoDet = 0;
// ADDED BY RITESH ON 15/07/14 END
try try
{ {
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDateStr = sdf.format(currentDate.getTime());
System.out.println("Now the date is :=> " + sysDateStr);
sysDate = Timestamp.valueOf(genericUtility.getValidDateString(
sysDateStr, genericUtility.getApplDateFormat(),
genericUtility.getDBDateFormat())
+ " 00:00:00.0");
StockAllocPrc allocPrc=new StockAllocPrc();
//SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
//connDriver = null; //connDriver = null;
// 21/08/12 manoharan get the shipping site // 21/08/12 manoharan get the shipping site
getDataSql = "SELECT SITE_CODE__SHIP FROM SORDER WHERE SALE_ORDER = ? "; getDataSql = "SELECT SITE_CODE__SHIP FROM SORDER WHERE SALE_ORDER = ? ";
...@@ -1622,6 +1663,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1622,6 +1663,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
+"SORDER.SITE_CODE,SORDITEM.EXP_LEV, " +"SORDER.SITE_CODE,SORDITEM.EXP_LEV, "
+"SORDER.PART_QTY AS PART_QTY, CUSTOMER.SINGLE_LOT AS SINGLE_LOT, SORDITEM.MIN_SHELF_LIFE AS MIN_SHELF_LIFE "//Gulzar 5/13/2012 +"SORDER.PART_QTY AS PART_QTY, CUSTOMER.SINGLE_LOT AS SINGLE_LOT, SORDITEM.MIN_SHELF_LIFE AS MIN_SHELF_LIFE "//Gulzar 5/13/2012
+" ,SORDER.ALLOC_FLAG AS ALLOC_FLAG , WAVE_TYPE.MASTER_PACK_ALLOW , WAVE_TYPE.ACTIVE_PICK_ALLOW , WAVE_TYPE.STOCK_TO_DOCK_ALLOW " +" ,SORDER.ALLOC_FLAG AS ALLOC_FLAG , WAVE_TYPE.MASTER_PACK_ALLOW , WAVE_TYPE.ACTIVE_PICK_ALLOW , WAVE_TYPE.STOCK_TO_DOCK_ALLOW "
+ " ,CUSTOMER.SINGLE_LOT AS SINGLE_LOT " //ADDED BY RITESH ON 15/07/14
+"FROM SORDDET,SORDER,SORDITEM,CUSTOMER,ITEM , WAVE_TYPE " +"FROM SORDDET,SORDER,SORDITEM,CUSTOMER,ITEM , WAVE_TYPE "
//Changed by sumit 20/08/12 getting column data end. //Changed by sumit 20/08/12 getting column data end.
+"WHERE ( SORDER.SALE_ORDER = SORDDET.SALE_ORDER ) AND " +"WHERE ( SORDER.SALE_ORDER = SORDDET.SALE_ORDER ) AND "
...@@ -1655,6 +1697,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1655,6 +1697,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
if(rs.next()) if(rs.next())
{ {
pendingQty = rs.getInt("PENDING_QUANTITY"); pendingQty = rs.getInt("PENDING_QUANTITY");
singleLot = rs.getString("SINGLE_LOT"); //ADDED BY RITESH ON 15/07/14
} }
rs.close(); rs.close();
rs = null; rs = null;
...@@ -1703,7 +1746,8 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1703,7 +1746,8 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
getDataSql = getDataSql.concat(" AND LOCATION.INV_STAT NOT IN(?,?) "); getDataSql = getDataSql.concat(" AND LOCATION.INV_STAT NOT IN(?,?) ");
} }
//Added by manoj dtd 09/08/2013 to implement FEFO concept //Added by manoj dtd 09/08/2013 to implement FEFO concept
getDataSql=getDataSql+"AND (MONTHS_BETWEEN(TO_DATE(STOCK.EXP_DATE),SYSDATE) > ? ) "; // getDataSql=getDataSql+"AND (MONTHS_BETWEEN(TO_DATE(STOCK.EXP_DATE),SYSDATE) > ? ) ";
getDataSql=getDataSql+"AND (MONTHS_BETWEEN(TO_DATE(STOCK.EXP_DATE),SYSDATE) > ? ) AND STOCK.LOC_CODE NOT IN ('D1911C')";
if(checkLocation) //added by kunal on 14/NOV/13 DI3ESUN009 if(checkLocation) //added by kunal on 14/NOV/13 DI3ESUN009
{ {
...@@ -1757,10 +1801,16 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1757,10 +1801,16 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
rs = pstmtStock.executeQuery(); rs = pstmtStock.executeQuery();
System.out.println("siteCode------"+ siteCodeShip); System.out.println("siteCode------"+ siteCodeShip);
System.out.println("itemCode------"+ itemCode); System.out.println("itemCode------"+ itemCode);
System.out.println("saleOrder------"+ saleOrder);
System.out.println("siteCode------"+ siteCode);
System.out.println("chgTerm------"+ chgTerm);
System.out.println("chgUser------"+ chgUser);
System.out.println("activeAllow------"+ activeAllow);
System.out.println("Select completed"); System.out.println("Select completed");
while(rs.next()) //CHANGE BY RITESH ON 18/07/14 START
while(rs.next())//for(lotListNew)
{ {
System.out.println( "INSIDE WHILE LOOP............."); System.out.println( " INSIDE WHILE LOOP.............SINGLELOT ["+singleLot+"]");
//LOT_NO //LOT_NO
lotNo = rs.getString(1); lotNo = rs.getString(1);
//LOT_SL //LOT_SL
...@@ -1784,6 +1834,159 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1784,6 +1834,159 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
//SITE_CODE__MFG //SITE_CODE__MFG
siteCodeMfg = rs.getString(11); siteCodeMfg = rs.getString(11);
// ArrayList<String> stockList=new ArrayList<String>();
sqlShip = "select shipper_size from item_lot_packsize where item_code = ? and '"+lotNo+"' between lot_no__from and lot_no__to";
pstmtShip = conn.prepareStatement(sqlShip);
pstmtShip.setString(1,itemCode);
rsShip = pstmtShip.executeQuery();
if(rsShip.next())
{
shipperSizeLot = rsShip.getDouble(1);
}
pstmtShip.close();pstmtShip = null;
rsShip.close();rsShip = null;
System.out.print(":: qtyAvailAlloc ::"+qtyAvailAlloc);
System.out.print(":: shipperSizeLot ::"+shipperSizeLot);
double sz = 0;
if("N".equalsIgnoreCase(activeAllow))
{
sz = qtyAvailAlloc % shipperSizeLot;
}else
{
sz = 0;
}
if(sz == 0 )
{
if("N".equalsIgnoreCase(singleLot.trim()))
{
totalQtyAvailAlloc = totalQtyAvailAlloc + qtyAvailAlloc ;
if(totalQtyAvailAlloc >= allocQty)
{
isQtyAvail = true;
}
lotDeatilList.add(lotNo+"@"+lotSl+"@"+locCode+"@"+unit+"@"+qtyAvailAlloc+"@"+grade+"@"+convQtyStduom+"@"+quantity+"@"+siteCodeMfg);
}
//ADDED BY RITESH ON 16/07/14 START
if("Y".equalsIgnoreCase(singleLot.trim()))
{
if(stockLot.containsKey(lotNo))
{
stockLot.put(lotNo, ((Double)stockLot.get(lotNo)+qtyAvailAlloc));
ArrayList<String> stockList=new ArrayList<String>();
stockList=stockLotDetail.get(lotNo);
System.out.println(lotNo+"@@"+lotSl+"@"+locCode+"@"+locDescr+"@"+qtyAvailAlloc);
// stockList.add(lotNo+"@"+lotSl+"@"+locCode+"@"+locDescr+"@"+qtyAvailAlloc);
stockList.add(lotNo+"@"+lotSl+"@"+locCode+"@"+unit+"@"+qtyAvailAlloc+"@"+grade+"@"+convQtyStduom+"@"+quantity+"@"+siteCodeMfg);
stockLotDetail.put(lotNo, stockList);
}
else
{
stockLot.put(lotNo,qtyAvailAlloc);
ArrayList<String> stockList=new ArrayList<String>();
//stockList=stockLotDetail.get(lotNo);
System.out.println(lotNo+"@"+lotSl+"@"+locCode+"@"+locDescr+"@"+qtyAvailAlloc);
// stockList.add(lotNo+"@"+lotSl+"@"+locCode+"@"+locDescr+"@"+qtyAvailAlloc);
stockList.add(lotNo+"@"+lotSl+"@"+locCode+"@"+unit+"@"+qtyAvailAlloc+"@"+grade+"@"+convQtyStduom+"@"+quantity+"@"+siteCodeMfg);
stockLotDetail.put(lotNo, stockList);
}
stockLotDetail.descendingMap();
stockLot.descendingMap();
System.out.println("stockLot ::"+stockLot);
System.out.println("stockLotDetail ::"+stockLotDetail);
// String lotDetail="";
Set<String> lotKey=stockLot.keySet();
Iterator<String> lot=lotKey.iterator();
System.out.println("lotKey :: [-"+lotKey+"-]");
while(lot.hasNext())
{
String lotKeyVal=lot.next();
double qty1=Double.parseDouble(""+stockLot.get(lotKeyVal));
System.out.println("qty1---"+qty1+"---qty to be allocate---"+allocQty);
if(qty1>=allocQty)
{
// lotDetail=stockLotDetail.get(lotKeyVal).get(0);
getLotFlag = true; // break add lot no
lotDeatilList = stockLotDetail.get(lotKeyVal);
isQtyAvail = true; // check avail qty
break;
}
}
}
}
if(getLotFlag)
{
break;
}
System.out.println(getLotFlag+"--"+lotNo+"@"+lotSl+"@"+locCode+"@"+unit+"@"+qtyAvailAlloc+"@"+grade+"@"+convQtyStduom+"@"+quantity+"@"+siteCodeMfg);
}
System.out.println(" lotDeatilList ::"+lotDeatilList);
System.out.println(" isQtyAvail ::["+isQtyAvail+"]");
if(lotDeatilList.size() > 0 && isQtyAvail)
{
System.out.println("New Record Inserting*********============***********");
xmlBuff = new StringBuffer();
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("sord_alloc").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
xmlBuff.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"sord_alloc\" objContext=\"1\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<TRAN_DATE><![CDATA["+ sdf.format(sysDate) +"]]></TRAN_DATE>");
xmlBuff.append("<cust_code><![CDATA["+ custCode +"]]></cust_code>");
xmlBuff.append("<sale_order><![CDATA["+ saleOrder +"]]></sale_order>");
xmlBuff.append("<site_code><![CDATA["+ siteCode +"]]></site_code>");//
xmlBuff.append("<site_code__ship><![CDATA["+ siteCodeShip +"]]></site_code__ship>");
xmlBuff.append("<chg_date><![CDATA["+sdf.format(sysDate)+"]]></chg_date>");
xmlBuff.append("<chg_term><![CDATA["+ chgTerm +"]]></chg_term>");
xmlBuff.append("<chg_user><![CDATA["+ chgUser +"]]></chg_user>");
xmlBuff.append("<add_date><![CDATA["+sdf.format(sysDate)+"]]></add_date>");
xmlBuff.append("<add_term><![CDATA["+ chgTerm +"]]></add_term>");
xmlBuff.append("<add_user><![CDATA["+ chgUser +"]]></add_user>");
xmlBuff.append("<active_pick_allow><![CDATA["+ activeAllow +"]]></active_pick_allow>");
xmlBuff.append("</Detail1>");
for(int i = 0; i < lotDeatilList.size();i++)
{
String lotDetailData = lotDeatilList.get(i);
System.out.println("lotDetailData::["+lotDetailData+"]");
if(lotDetailData.contains("@"))
{
String[] detailArr = lotDetailData.split("@");
lotNo = detailArr[0];
lotSl = detailArr[1];
locCode = detailArr[2];
unit = detailArr[3];
qtyAvailAlloc = Double.parseDouble(detailArr[4]);
grade = detailArr[5];
convQtyStduom=Double.parseDouble(detailArr[6]);
quantity= Double.parseDouble(detailArr[7]);
siteCodeMfg = detailArr[8];
}
invallocTrace.setRefSer("S-ALC"); invallocTrace.setRefSer("S-ALC");
invallocTrace.setRefId(saleOrder); invallocTrace.setRefId(saleOrder);
invallocTrace.setRefLine(lineNo); invallocTrace.setRefLine(lineNo);
...@@ -1792,8 +1995,8 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1792,8 +1995,8 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
invallocTrace.setLocCode(locCode); invallocTrace.setLocCode(locCode);
invallocTrace.setLotNo(lotNo); invallocTrace.setLotNo(lotNo);
invallocTrace.setLotSl(lotSl); invallocTrace.setLotSl(lotSl);
PreparedStatement pstmt = null; PreparedStatement pstmt = null,pstmt2=null;
ResultSet rs1 = null; ResultSet rs1 = null,rs2=null;
String sqls = ""; String sqls = "";
double shipperSize = 0; double shipperSize = 0;
lotQtyToBeAllocated = 0; lotQtyToBeAllocated = 0;
...@@ -1849,14 +2052,130 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1849,14 +2052,130 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
} }
//added by ritesh on 07/10/13 for request DI3ESUN009 end //added by ritesh on 07/10/13 for request DI3ESUN009 end
System.out.println("allocQty =::2"+allocQty);
invallocTrace.setAllocQty(lotQtyToBeAllocated); invallocTrace.setAllocQty(lotQtyToBeAllocated);
// //
allocQty -= lotQtyToBeAllocated ; allocQty -= lotQtyToBeAllocated ;
System.out.print("AllocQty = " + lotQtyToBeAllocated); System.out.print("AllocQty = " + lotQtyToBeAllocated);
if (lotQtyToBeAllocated > 0) /*generate new confirmed transaction while process the data from manual
stock allocation process.Created new Transaction for allocated quantity for StockAllocation.
It will save and confirm the Stock allocation transactionfor allocated quantity
*/
//added by priyanka for request id D14BSUN002 as per manoj sharma instruction on 15/05/2014
if(lotQtyToBeAllocated>0)
{
sql="SELECT ITEM_CODE,((CASE WHEN quantity IS NULL THEN 0 ELSE quantity END)*CONV__QTY_STDQTY - CASE WHEN qty_alloc IS NULL THEN 0 ELSE qty_alloc END - (CASE WHEN qty_desp IS NULL THEN 0 ELSE qty_desp END)*CONV__QTY_STDQTY ), EXP_LEV FROM SORDITEM WHERE SALE_ORDER = ? AND LINE_NO = ?";
pstmt2 = conn.prepareStatement(sql);
pstmt2.setString(1,saleOrder);
pstmt2.setString(2,lineNo);
rs2 = pstmt2.executeQuery();
if(rs2.next())
{
itemCode = rs2.getString("ITEM_CODE");
qty = rs2.getDouble(2);
expLev = rs2.getString("EXP_LEV");
System.out.println("=========qty========="+qty);
}
rs2.close();
rs2 = null;
pstmt2.close();
pstmt2 = null;
// System.out.println("New Record Inserting*********============***********");
// xmlBuff = new StringBuffer();
// xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
// xmlBuff.append("<DocumentRoot>");
// xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
// xmlBuff.append("<group0>");
// xmlBuff.append("<description>").append("Group0 description").append("</description>");
// xmlBuff.append("<Header0>");
// xmlBuff.append("<objName><![CDATA[").append("sord_alloc").append("]]></objName>");
// xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
// xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
// xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
// xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
// xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
// xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
// xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
// xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
// xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
// xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
// xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
// xmlBuff.append("<description>").append("Header0 members").append("</description>");
// xmlBuff.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"sord_alloc\" objContext=\"1\">");
// xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
// xmlBuff.append("<tran_id/>");
// xmlBuff.append("<TRAN_DATE><![CDATA["+ sdf.format(sysDate) +"]]></TRAN_DATE>");
// xmlBuff.append("<cust_code><![CDATA["+ custCode +"]]></cust_code>");
// xmlBuff.append("<sale_order><![CDATA["+ saleOrder +"]]></sale_order>");
// xmlBuff.append("<site_code><![CDATA["+ siteCode +"]]></site_code>");//
// xmlBuff.append("<site_code__ship><![CDATA["+ siteCodeShip +"]]></site_code__ship>");
// xmlBuff.append("<chg_date><![CDATA["+sdf.format(sysDate)+"]]></chg_date>");
// xmlBuff.append("<chg_term><![CDATA["+ chgTerm +"]]></chg_term>");
// xmlBuff.append("<chg_user><![CDATA["+ chgUser +"]]></chg_user>");
// xmlBuff.append("<add_date><![CDATA["+sdf.format(sysDate)+"]]></add_date>");
// xmlBuff.append("<add_term><![CDATA["+ chgTerm +"]]></add_term>");
// xmlBuff.append("<add_user><![CDATA["+ chgUser +"]]></add_user>");
// xmlBuff.append("<active_pick_allow><![CDATA["+ activeAllow +"]]></active_pick_allow>");
// xmlBuff.append("</Detail1>");
linenoDet ++;
xmlBuff.append("<Detail2 dbID='' domID=\"1\" objName=\"sord_alloc\" objContext=\"2\">");
xmlBuff.append("<attribute pkNames=\"\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
xmlBuff.append("<line_no><![CDATA["+linenoDet+"]]></line_no>");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<sale_order><![CDATA["+ saleOrder +"]]></sale_order>");
xmlBuff.append("<line_no__sord><![CDATA["+lineNo +"]]></line_no__sord>");
xmlBuff.append("<item_code><![CDATA["+ itemCode +"]]></item_code>");
xmlBuff.append("<loc_code><![CDATA["+locCode+"]]></loc_code>");
xmlBuff.append("<lot_no><![CDATA["+ lotNo +"]]></lot_no>");
xmlBuff.append("<lot_sl><![CDATA["+lotSl+"]]></lot_sl>");
xmlBuff.append("<quantity><![CDATA["+ lotQtyToBeAllocated +"]]></quantity>");
xmlBuff.append("<dealloc_qty><![CDATA[0]]></dealloc_qty>");
xmlBuff.append("<site_code><![CDATA["+ siteCode +"]]></site_code>");
xmlBuff.append("<exp_lev><![CDATA["+ expLev +"]]></exp_lev>");
xmlBuff.append("<pending_qty><![CDATA["+ qty +"]]></pending_qty>");
xmlBuff.append("</Detail2>");
// xmlBuff.append("</Header0>");
// xmlBuff.append("</group0>");
// xmlBuff.append("</DocumentRoot>");
// xmlString = xmlBuff.toString();
// System.out.println("@@@@@2: xmlString:"+xmlBuff.toString());
// System.out.println("...............just before savdata()");
// System.out.println("Getting site code value");
// siteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
// System.out.println("==site code =="+siteCode);
// System.out.println("Printing xmlString"+xmlString);
// System.out.println("Going to save data method++++++++++++++++++++++++");
//
// retString = saveData(siteCode,xmlString,conn);
// System.out.println("@@@@@2: retString11111111111:"+retString);
// if (retString.indexOf("Success") > -1)
// {
// System.out.println("@@@@@@3: retString22222222222"+retString);
//
// String[] arrayForTranId = retString.split("<TranID>");
// int endIndex = arrayForTranId[1].indexOf("</TranID>");
// System.out.println("***********going for confirmation************");
// String tranIdForIssue = arrayForTranId[1].substring(0,endIndex);
// System.out.println("tranIdForIssue"+ tranIdForIssue);
// retString=allocPrc.confirm(tranIdForIssue, xtraParams, "",conn);
//
// System.out.println("@@@@@@3: retString Confirm"+retString);
// System.out.println("=====Its Confirmed=====");
// System.out.println("retString from conf ::"+retString);
// }
// else
// {
// //System.out.println("[" + retString + "]");
// return retString;
// }
}
/*if (lotQtyToBeAllocated > 0)
{ {
invallocTrace.setChgUser(chgUser); invallocTrace.setChgUser(chgUser);
invallocTrace.setChgTerm(chgTerm); invallocTrace.setChgTerm(chgTerm);
...@@ -1999,7 +2318,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -1999,7 +2318,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
//QUANTITY__STDUOM //QUANTITY__STDUOM
pstmtStockInsertSordAlloc.setDouble(21,quantityStduom); pstmtStockInsertSordAlloc.setDouble(21,quantityStduom);
System.out.println("quantityStduom------->"+quantityStduom); System.out.println("quantityStduom------->"+quantityStduom);
//MFG_DATE 1788//MFG_DATE
pstmtStockInsertSordAlloc.setDate(22,mfgDate); pstmtStockInsertSordAlloc.setDate(22,mfgDate);
System.out.println("mfgDate------->"+mfgDate); System.out.println("mfgDate------->"+mfgDate);
//SITE_CODE__MFG //SITE_CODE__MFG
...@@ -2027,20 +2346,57 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -2027,20 +2346,57 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
//ended by akhilesh //ended by akhilesh
}//end of if(lotQtyToBeAllocated > 0) }//end of if(lotQtyToBeAllocated > 0)
*/
}//end of while }//end of while
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlString = xmlBuff.toString();
System.out.println("@@@@@2: xmlString:"+xmlBuff.toString());
System.out.println("...............just before savdata()");
System.out.println("Getting site code value");
siteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("==site code =="+siteCode);
System.out.println("Printing xmlString"+xmlString);
System.out.println("Going to save data method++++++++++++++++++++++++");
retString = saveData(siteCode,xmlString,conn);
System.out.println("@@@@@2: retString11111111111:"+retString);
if (retString.indexOf("Success") > -1)
{
System.out.println("@@@@@@3: retString22222222222"+retString);
String[] arrayForTranId = retString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
System.out.println("***********going for confirmation************");
String tranIdForIssue = arrayForTranId[1].substring(0,endIndex);
System.out.println("tranIdForIssue"+ tranIdForIssue);
retString=allocPrc.confirm(tranIdForIssue, xtraParams, "",conn);
System.out.println("@@@@@@3: retString Confirm"+retString);
System.out.println("=====Its Confirmed=====");
System.out.println("retString from conf ::"+retString);
}
else
{
//System.out.println("[" + retString + "]");
return retString;
}
} //CHANGE BY RITESH ON 18/07/14 END
rs.close(); rs.close();
pstmtStock.clearParameters(); pstmtStock.clearParameters();
pstmtStock.close(); pstmtStock.close();
System.out.println("manohar connection commited errString :::"+ errString ); System.out.println("manohar connection errString :::"+ errString );
System.out.println("manoj if Quantity is fuly allocated commiting transaction else rollbacking :::"+ allocQty ); System.out.println("manoj if Quantity is fuly allocated commiting transaction else rollbacking :::"+ allocQty );
if(allocQty==0) if(allocQty==0)
{ {
conn.commit(); conn.commit();
System.out.println("Transaction commited while allocQty =="+allocQty);
} }
else else
{ {
System.out.println("connection rollback____[]");
//errCode = "VSTQTYER"; //errCode = "VSTQTYER";
errString = itmDBAccessEJB.getErrorString("", "VSTQTYER", "", "", conn); errString = itmDBAccessEJB.getErrorString("", "VSTQTYER", "", "", conn);
//errString = "VSTQTYER"; //errString = "VSTQTYER";
...@@ -2083,6 +2439,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -2083,6 +2439,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
{ {
System.out.println("manohar connection commited errString :::"+ errString ); System.out.println("manohar connection commited errString :::"+ errString );
conn.commit(); conn.commit();
} }
if(conn != null) if(conn != null)
{ {
...@@ -2478,6 +2835,43 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -2478,6 +2835,43 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
{ {
itemCodeMap.clear(); itemCodeMap.clear();
} }
private String saveData(String siteCode,String xmlString, Connection conn) throws ITMException
{
//System.out.println("saving data...........");
InitialContext ctx = null;
String retString = null;
MasterStatefulLocal masterStateful = null; // for ejb3
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local");
System.out.println("-----------masterStateful------- " + masterStateful);
String [] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
System.out.println("xmlString to masterstateful [" + xmlString + "]");
retString = masterStateful.processRequest(authencate, siteCode, true, xmlString,true,conn);
System.out.println("--retString - -"+retString);
}
catch(ITMException itme)
{
System.out.println("ITMException :CreateDistOrder :saveData :==>");
throw itme;
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception :CreateDistOrder :saveData :==>");
throw new ITMException(e);
}
return retString;
}
private HashMap getItemVoumeMap(String itemCode,String lotNo,Connection con)throws Exception private HashMap getItemVoumeMap(String itemCode,String lotNo,Connection con)throws Exception
{ {
double packSize = 0,itemSize = 0,lotSize = 0; double packSize = 0,itemSize = 0,lotSize = 0;
...@@ -2549,8 +2943,6 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -2549,8 +2943,6 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
} }
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
...@@ -2575,4 +2967,4 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc ...@@ -2575,4 +2967,4 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
return dataVolumeMap; return dataVolumeMap;
} }
} }
\ 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