Commit de228fba authored by rtiwari's avatar rtiwari

EJB ADDED FOR MF3GSUP004


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94016 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f7dffef6
......@@ -68,7 +68,8 @@ public class WoTransferIC extends ValidatorEJB implements WoTransferICLocal,WoTr
Node parentNode1 = null;
String childNodeName = null;
String sql = "";
String locCode = "",descr="";
String locCode = "",descr="",worder="";
double batchQuantity=0.0;
int currentFormNo = 0;
Connection conn = null;
PreparedStatement pstmt = null;
......@@ -108,8 +109,34 @@ public class WoTransferIC extends ValidatorEJB implements WoTransferICLocal,WoTr
{
descr = rs.getString("descr");
}
if (pstmt != null)
pstmt.close();
pstmt = null;
if (rs != null)
rs.close();
rs = null;
valueXmlString.append("<descr>").append("<![CDATA["+ descr +"]]>").append("</descr>");
}
if (currentColumn.trim().equalsIgnoreCase("work_order"))
{
worder = genericUtility.getColumnValue("work_order", dom);
System.out.println("::descr::loc_code - " + locCode);
sql = " select quantity from workorder where work_order = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, worder);
rs = pstmt.executeQuery();
if(rs.next())
{
batchQuantity = rs.getDouble("quantity");
}
if (pstmt != null)
pstmt.close();
pstmt = null;
if (rs != null)
rs.close();
rs = null;
valueXmlString.append("<batch_quantity>").append("<![CDATA["+ batchQuantity +"]]>").append("</batch_quantity>");
}
valueXmlString.append("</Detail1>");
}
valueXmlString.append("</Root>");
......
/**
DEVELOPED BY RITESH TIWARI ON 02/11/13
FOR WORK ORDER STOCK TRANSFER
PURPUSE : WORK ORDER STOCK TRANSFER (MF3GSUP004)
*/
package ibase.webitm.ejb.mfg;
import ibase.system.config.AppConnectParm;
......@@ -16,6 +16,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
......@@ -23,109 +24,97 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.XMLType;
import org.w3c.dom.Document;
import javax.xml.rpc.ParameterMode;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.dis.GenerateSaleOrderPrc;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
//import ibase.webitm.ejb.dis.InvAllocTrace;
import ibase.webitm.ejb.dis.adv.StockTransferConf;
//import ibase.webitm.ejb.fin.FinCommon;
@Stateless
public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTransferPrcRemote
{
static
{
System.out.println("-- WoTransferPrc called -- ");
}
public String process() throws RemoteException,ITMException
{
return "";
}
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
Document detailDom = null;
String rtrStr = "";
Document headerDom = null;
GenericUtility genericUtility = GenericUtility.getInstance();
String retStr = "";
Document detailDom = null;
System.out.println("getData(xmlString,xmlString2,windowName,xtraParams CALLED..."+ xmlString);
try
{
System.out.println("xmlString[process]::::::::::;;;"+xmlString);
System.out.println("xmlString2[process]::::::::::;;;"+xmlString2);
System.out.println("windowName[process]::::::::::;;;"+windowName);
System.out.println("xtraParams[process]:::::::::;;;"+xtraParams);
}
catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
System.out.println("headerDom" + headerDom);
System.out.println("XML String :"+xmlString);
headerDom = genericUtility.parseString(xmlString);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
System.out.println("detailDom" + detailDom);
System.out.println("XML String :"+xmlString2);
detailDom = genericUtility.parseString(xmlString2);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
rtrStr = getData(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :WoTransferPrc :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
{
System.out.println("Exception :WoTransferPrcEJB :getData(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
rtrStr = e.getMessage();
}
return retStr;
} //end of confirm method
public String process(Document dom, Document dom2, String windowName,String xtraParams) throws RemoteException, ITMException
return rtrStr;
}
public String getData(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
System.out.println("WoTransferPrc process called........");
String sql = "";
String errString = "";
String siteCode = "",invstat="",invstat1="";
String worder = "",locCodeTo="";
String sql= "",worder="",locCodeTo="",batchQuantity="";
String resultString = "",errCode="";
String invstat="",invstat1="",tranIdInvAlloc="";
int cnt=0;
Connection connOne = null;
ConnDriver connDriver = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
GenericUtility genericUtility = null;
ITMDBAccessEJB itmDBAccessEJB = null;
Connection conn = null;
ResultSet rs = null,rs1= null;
double issQty=0.0,allocQty=0,allocatedQty=0.0,integralQty=0.0;
PreparedStatement pstmt = null,pstmt1=null;
double quantity=0.0;
StringBuffer retTabSepStrBuff = new StringBuffer();
MfgCommon mfgComm = new MfgCommon();
DecimalFormat df = new DecimalFormat("0.000");
retTabSepStrBuff = new StringBuffer("<?xml version = \"1.0\"?>");
retTabSepStrBuff.append("<DocumentRoot>");
retTabSepStrBuff.append("<description>").append("Datawindow Root").append("</description>");
retTabSepStrBuff.append("<group0>");
retTabSepStrBuff.append("<description>").append("Group0 description").append("</description>");
retTabSepStrBuff.append("<Header0>");
try
{
genericUtility = new GenericUtility();
itmDBAccessEJB = new ITMDBAccessEJB();
connDriver = new ConnDriver();
connOne = connDriver.getConnectDB("DriverITM");
System.out.println("WoTransferPrc getData called :: ::");
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
worder = checkNull(genericUtility.getColumnValue("work_order", dom));
locCodeTo = checkNull(genericUtility.getColumnValue("loc_code__to", dom));
worder = checkNull(genericUtility.getColumnValue("work_order", headerDom));
locCodeTo = checkNull(genericUtility.getColumnValue("loc_code__to", headerDom));
batchQuantity = checkNull(genericUtility.getColumnValue("batch_quantity", headerDom));
connOne.setAutoCommit(false);
if(worder == null || worder.trim().length() <= 0)
{
errString = itmDBAccessEJB.getErrorString("","VTWKORD1 ","","",connOne);
System.out.println("worder:: is null "+ worder);
errString = itmDBAccessEJB.getErrorString("","VTWKORD1 ","","",conn);
return errString;
}
if(locCodeTo == null || locCodeTo.trim().length() <= 0)
{
errString = itmDBAccessEJB.getErrorString("","VTLOCCDTO2 ","","",connOne);
System.out.println("loc code to is null:: "+ worder);
errString = itmDBAccessEJB.getErrorString("","VTLOCCDTO2 ","","",conn);
return errString;
}
if(worder != null || worder.trim().length() > 0)
if(worder != null && worder.trim().length() > 0)
{
sql = "select count(*) from workorder where work_order = ? and status not in ('F') ";
pstmt = connOne.prepareStatement(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,worder);
rs = pstmt.executeQuery();
if(rs.next())
......@@ -140,22 +129,44 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
pstmt = null;
if(cnt == 0)
{
errString = itmDBAccessEJB.getErrorString("","VPWOINV ","","",connOne);
errString = itmDBAccessEJB.getErrorString("","VPWOINV ","","",conn);
return errString;
}
}
if(locCodeTo != null || locCodeTo.trim().length() > 0)
sql = "select quantity from workorder where work_order = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,worder);
rs = pstmt.executeQuery();
if(rs.next())
{
quantity = rs.getDouble(1);
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
if(batchQuantity != null && batchQuantity.trim().length() > 0)
{
if(Double.parseDouble(batchQuantity) > quantity)
{
errString = itmDBAccessEJB.getErrorString("","VPBATNOT ","","",conn);
return errString;
}
}
if(locCodeTo != null && locCodeTo.trim().length() > 0)
{
cnt=0;
invstat = mfgComm.getEnvMfg("999999","SUB_ST_INVSTAT", connOne);
invstat1 = mfgComm.getEnvMfg("999999","MAIN_ST_INVSTAT", connOne);
invstat = mfgComm.getEnvMfg("999999","SUB_ST_INVSTAT", conn);
invstat1 = mfgComm.getEnvMfg("999999","MAIN_ST_INVSTAT", conn);
if(invstat.equalsIgnoreCase(invstat1))
{
errString = itmDBAccessEJB.getErrorString("","VTDISPVAR ","","",connOne);
errString = itmDBAccessEJB.getErrorString("","VTDISPVAR ","","",conn);
return errString;
}
sql = "select count(1) from location where loc_code = ? and inv_stat = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
pstmt.setString(2,invstat);
rs = pstmt.executeQuery();
......@@ -171,33 +182,409 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
pstmt = null;
if(cnt == 0)
{
errString = itmDBAccessEJB.getErrorString("","VTLOCCDTO1 ","","",connOne);
errString = itmDBAccessEJB.getErrorString("","VTLOCCDTO1 ","","",conn);
return errString;
}
}
sql = "select tran_id from inv_allocate where WORK_ORDER = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,worder);
rs = pstmt.executeQuery();
if(rs.next())
{
tranIdInvAlloc = checkNull(rs.getString("tran_id"));
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
invstat1 = mfgComm.getEnvMfg("999999","MAIN_ST_INVSTAT", conn);
System.out.println("::: XML Cretation::::");
sql = "select tran_id,line_no,item_code,site_code,lot_no,lot_sl,remarks,loc_code,reas_code,quantity,exp_lev,potency_adj from inv_alloc_det where tran_id = ? " +
" and loc_code in(select loc_code from location where inv_stat = ?) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIdInvAlloc);
pstmt.setString(2,invstat1);
rs = pstmt.executeQuery();
if(rs.next())
{
do
{
issQty = rs.getDouble("quantity");
sql = "select SUM(quantity) from stock_transfer_det where tran_id in (select tran_id from stock_transfer " +
"where ref_id__for = ?) and item_code = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, worder);
pstmt1.setString(2, rs.getString("item_code"));
rs1 = pstmt1.executeQuery();
if ( rs1.next() )
{
allocatedQty = rs1.getDouble(1);
}
if(rs1 != null)
rs1.close();
rs1 = null;
if(pstmt1 != null)
pstmt1.close();
pstmt1 = null;
if(quantity > 0)
{
//allocQty = ((issQty-allocatedQty)/quantity) * Double.parseDouble(batchQuantity);
allocQty = (issQty/quantity) * Double.parseDouble(batchQuantity);
}
System.out.println(" ALLOCATED QUANTITY ::"+allocQty);
//if(allocQty > 0)
//{
retTabSepStrBuff.append("<Detail2>");
retTabSepStrBuff.append("<tran_id>").append("<![CDATA[" + rs.getString("tran_id") +"]]>").append("</tran_id>");
retTabSepStrBuff.append("<line_no>").append("<![CDATA[" + rs.getInt("line_no") +"]]>").append("</line_no>");
retTabSepStrBuff.append("<site_code>").append("<![CDATA[" + rs.getString("site_code") +"]]>").append("</site_code>");
retTabSepStrBuff.append("<item_code>").append("<![CDATA[" + rs.getString("item_code") +"]]>").append("</item_code>");
retTabSepStrBuff.append("<lot_no>").append("<![CDATA[" + rs.getString("lot_no") +"]]>").append("</lot_no>");
retTabSepStrBuff.append("<lot_sl>").append("<![CDATA[" + rs.getString("lot_sl") +"]]>").append("</lot_sl>");
retTabSepStrBuff.append("<actual_qty>").append("<![CDATA[" + df.format(issQty) +"]]>").append("</actual_qty>");
sql = "select INTEGRAL_QTY from item where item_code = ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, rs.getString("item_code"));
rs1 = pstmt1.executeQuery();
if ( rs1.next() )
{
integralQty = rs1.getDouble(1);
}
if(rs1 != null)
rs1.close();
rs1 = null;
if(pstmt1 != null)
pstmt1.close();
pstmt1 = null;
if(allocQty > integralQty ){
if(allocQty % integralQty != 0)
{
retTabSepStrBuff.append("<quantity>").append("<![CDATA[" + df.format((integralQty - (allocQty % integralQty) + allocQty)) +"]]>").append("</quantity>");
}
else
{
retTabSepStrBuff.append("<quantity>").append("<![CDATA[" + df.format(allocQty) +"]]>").append("</quantity>");
}
}else{
retTabSepStrBuff.append("<quantity>").append("<![CDATA[" + df.format(integralQty) +"]]>").append("</quantity>");
}
retTabSepStrBuff.append("<allocated_qty>").append("<![CDATA[" + df.format(allocatedQty) +"]]>").append("</allocated_qty>");
retTabSepStrBuff.append("<remarks>").append("<![CDATA[" + rs.getString("remarks") +"]]>").append("</remarks>");
retTabSepStrBuff.append("<reas_code>").append("<![CDATA[" + checkNull(rs.getString("reas_code")) +"]]>").append("</reas_code>");
retTabSepStrBuff.append("<loc_code>").append("<![CDATA[" + rs.getString("loc_code") +"]]>").append("</loc_code>");
retTabSepStrBuff.append("<exp_lev>").append("<![CDATA[" + rs.getString("exp_lev") +"]]>").append("</exp_lev>");
retTabSepStrBuff.append("<potency_adj>").append("<![CDATA[" + rs.getDouble("potency_adj") +"]]>").append("</potency_adj>");
retTabSepStrBuff.append("<loc_code__to>").append("<![CDATA[" +locCodeTo +"]]>").append("</loc_code__to>");
retTabSepStrBuff.append("<work_order>").append("<![CDATA[" + worder +"]]>").append("</work_order>");
retTabSepStrBuff.append("</Detail2>");
//}
}while(rs.next());
retTabSepStrBuff.append("</Header0>");
retTabSepStrBuff.append("</group0>");
retTabSepStrBuff.append("</DocumentRoot>");
resultString = retTabSepStrBuff.toString();
pstmt.clearParameters();
}
else
{
errCode ="VTNOREC1";
}
if (!errCode.equals(""))
{
resultString = itmDBAccessEJB.getErrorString("", errCode, "", "", conn);
System.out.println("resultString: "+resultString);
}
System.out.println("ResultString....." + resultString);
}
catch (SQLException e)
{
System.out.println("SQLException :WoTransferPrcEJB :getData(Document headerDom, Document detailDom, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ITMException(e);
}
catch (Exception e)
{
System.out.println("Exception :WoTransferPrcEJB :getData(Document headerDom, Document detailDom, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ITMException(e);
}
finally
{
try
{
retTabSepStrBuff = null;
if(conn != null)
{
if(pstmt != null)
{
pstmt.close();
pstmt=null;
}
if(rs != null){
rs.close();
rs = null;
}
conn.close();
conn = null;
}
}
catch(Exception e)
{
errString = e.getMessage();
e.printStackTrace();
throw new ITMException(e);
}
}
return resultString;
}
public String process() throws RemoteException,ITMException
{
return "";
}
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
Document detailDom = null;
Document headerDom = null;
GenericUtility genericUtility = GenericUtility.getInstance();
String retStr = "";
try
{
System.out.println("xmlString[process]::::::::::;;;"+xmlString);
System.out.println("xmlString2[process]::::::::::;;;"+xmlString2);
System.out.println("windowName[process]::::::::::;;;"+windowName);
System.out.println("xtraParams[process]:::::::::;;;"+xtraParams);
}
catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
System.out.println("headerDom" + headerDom);
}
if(errString == null || errString.trim().length() == 0)
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
errString = allocStockToWo(worder,locCodeTo,xtraParams,connOne);
System.out.println("err String from STOCKTRANS ="+errString);
if((errString != null ) && (errString.indexOf("Success") > -1 || errString.indexOf("CONFSUCC") >-1))
detailDom = genericUtility.parseString(xmlString2);
System.out.println("detailDom" + detailDom);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :WoTransferPrc :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
}
return retStr;
} //end of confirm method
public String process(Document headerDom, Document detailDom, String windowName,String xtraParams) throws RemoteException, ITMException
{
System.out.println("WoTransferPrc process called........");
String allocQty="",itemCode="";
String errString = null,sql="";
String siteCode="",explev="",lineno="",lotno="",lotsl="",locCodeFr="",reasCode="";
String worder = "",locCodeTo="",remarks="",tranId="";
Connection connOne = null;
ConnDriver connDriver = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
double actualQty =0.0,trfedQty = 0.0,allocQty2=0.0;
ITMDBAccessEJB itmDBAccessEJB = null;
String childNodeName = "";
Node parentNode = null;
NodeList childNodeList = null;
NodeList parentNodeList = null;
int parentNodeListLength = 0;
int childNodeListLength = 0;
Node childNode = null;
int elements = 0;
boolean allocqtyflag = false;
ArrayList list = new ArrayList();
DecimalFormat df = new DecimalFormat("0.000");
try
{
genericUtility = new GenericUtility();
itmDBAccessEJB = new ITMDBAccessEJB();
connDriver = new ConnDriver();
connOne = connDriver.getConnectDB("DriverITM");
connDriver = null;
connOne.setAutoCommit(false);
parentNodeList = detailDom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
System.out.println("parentNodeListLength------------------->"+parentNodeListLength);
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
parentNode = parentNodeList.item(selectedRow);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("childNodeListLength---->>> "+ childNodeListLength);
for (int childRow = 0; childRow < childNodeListLength; childRow++)
{
connOne.commit();
System.out.println("--process completed--");
errString = itmDBAccessEJB.getErrorString("","VPSUCC1 ","","",connOne);
childNode = childNodeList.item(childRow);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName---->>> "+ childNodeName);
if (childNodeName.equals("tran_id"))
{
tranId = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("line_no"))
{
lineno = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("site_code"))
{
siteCode = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("item_code"))
{
itemCode = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("lot_no"))
{
lotno = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("lot_sl"))
{
lotsl = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("quantity"))
{
allocQty = childNode.getFirstChild().getNodeValue();
allocQty2 = Double.parseDouble(childNode.getFirstChild().getNodeValue());
}
if (childNodeName.equals("reas_code"))
{
if(childNode !=null)
{
if(childNode.getFirstChild() != null)
{
reasCode = childNode.getFirstChild().getNodeValue();
}
}
}if (childNodeName.equals("loc_code"))
{
locCodeFr = childNode.getFirstChild().getNodeValue();
}if (childNodeName.equals("exp_lev"))
{
explev = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("loc_code__to"))
{
locCodeTo = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("work_order"))
{
worder = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("remarks"))
{
remarks = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("actual_qty"))
{
actualQty = Double.parseDouble(childNode.getFirstChild().getNodeValue());
}
if (childNodeName.equals("allocated_qty"))
{
trfedQty = Double.parseDouble(childNode.getFirstChild().getNodeValue());
}
}//inner for loop
System.out.println(" amount values "+actualQty+"::"+trfedQty+"::"+allocQty2);
if(Double.parseDouble(df.format(actualQty - trfedQty)) >= Double.parseDouble(df.format(allocQty2)))
{
errString = allocStockToWo(lineno,siteCode,itemCode,lotno,lotsl,allocQty,reasCode,locCodeFr,explev,locCodeTo,worder,remarks,tranId,xtraParams,connOne);
System.out.println("err String from STOCKTRANS ="+errString);
}
else if(errString != null && errString.indexOf("VTITRF") > -1)
else
{
System.out.println("(((((((((((()]]]]]]]]]]]]]]]]");;
errString = itmDBAccessEJB.getErrorString("","VTITRF ","","",connOne);
allocqtyflag = true;
list.add(lineno);
list.add(itemCode);
elements ++;
System.out.println(" QUANTITY TO BE ALLOCATED NOT VALID");
}
}// out for loop
if(allocqtyflag == true)
{
allocqtyflag= false;
errString = itmDBAccessEJB.getErrorString("","VTALCQTY","","",connOne);
String begPart = errString.substring( 0, errString.indexOf("<trace>") + 7 );
String endPart = errString.substring( errString.indexOf("</trace>"));
String mainStr = begPart + "Following error has occured\n" ;
if(elements > 0 )
{
mainStr = mainStr + "Invalid allocate quantity.\n";
}
else
for(int i = 0; i < elements * 2; i++ )
{
connOne.rollback();
System.out.println("--process not completed--");
errString = itmDBAccessEJB.getErrorString("","VTPRCERR ","","",connOne);
if( i > 0)
{
i -= 1;
}
mainStr = mainStr +
"line no :"+list.get(i++)+ ",item code :"+ list.get(i++) + "\n" ;
}
mainStr = mainStr + endPart;
errString = mainStr;
begPart =null;
endPart =null;
mainStr =null;
return errString;
}
if((errString != null ) && (errString.indexOf("Success") > -1 || errString.indexOf("CONFSUCC") >-1))
{
connOne.commit();
System.out.println("--process completed--");
errString = itmDBAccessEJB.getErrorString("","VPSUCC1 ","","",connOne);
}
else if(errString != null && errString.indexOf("VTITRF") > -1)
{
System.out.println("Item code can not we same)]]");;
errString = itmDBAccessEJB.getErrorString("","VTITRF ","","",connOne);
}
else
{
connOne.rollback();
System.out.println("--process not completed--");
errString = itmDBAccessEJB.getErrorString("","VTPRCERR ","","",connOne);
}
}
catch( Exception e)
......@@ -218,9 +605,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
{
if(errString != null && errString.trim().length() > 0)
{
if(errString.indexOf("VPSUCC1") > -1 )
{
connOne.commit();
System.out.println("--transaction commited--");
......@@ -256,37 +641,29 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
}
return errString;
}
private String allocStockToWo(String worder,String locCodeTo ,String xtraParams, Connection connOne) throws RemoteException, ITMException
private String allocStockToWo(String lineno,String siteCode,String itemCode,String lotno,String lotsl,String allocQty,String reasCode,String locCodeFr,String explev,String locCodeTo,String worder,String remarks,String tranIdInvAlloc,String xtraParams,Connection connOne) throws RemoteException, ITMException
{
String userId = "";
String termId = "";
String sql = "",sql1="", acctCodeInv1 = "",cctrCodeInv1="";
String itemCode="",tranIdInvAlloc="",reasCode="",refno = "",itemSer="",tranType="";
Date tranDate = null,orddate = null;
int notrans =0;
PreparedStatement pstmt = null,pstmt1= null;
ResultSet rs = null,rs1=null;
String itemSer="",tranType="";
Date orddate = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
GenericUtility genericUtility = null;
ITMDBAccessEJB itmDBAccessEJB = null;
Timestamp currDate = null;
String retString = null;
String siteCode = "",empCode = "";
String empCode = "";
String xmlString = "";
MfgCommon mfgComm = null;
StringBuffer xmlBuff = null;
ArrayList list = null;
boolean bool = false;
try
{
list = new ArrayList();
itmDBAccessEJB = new ITMDBAccessEJB();
genericUtility = GenericUtility.getInstance();
mfgComm = new MfgCommon();
System.out.println("@@@@@@@ wostock trans. function called::");
xmlBuff = new StringBuffer();
genericUtility = GenericUtility.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
currDate = java.sql.Timestamp.valueOf(sdf1.format(new java.util.Date()).toString() + " 00:00:00.0");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); System.out.println("--login code--"+userId);
termId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"); System.out.println("--term id--"+termId);
......@@ -313,16 +690,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
rs = pstmt.executeQuery();
if(rs.next())
{
//ordtype = rs.getString("order_type");
itemCode = checkNull(rs.getString("item_code"));
siteCode = checkNull(rs.getString("site_code"));
orddate = rs.getDate("ord_date");
//duedate = rs.getString("due_date");
// bomcode = checkNull(rs.getString("bom_code"));
//lotno = checkNull(rs.getString("lot_no"));
//lotsl = checkNull(rs.getString("lot_sl"));
refno = checkNull(rs.getString("ref_no"));
}
if(rs != null)
rs.close();
......@@ -346,17 +714,19 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
if(pstmt != null)
pstmt.close();
pstmt = null;
sql = "select tran_type,tran_date,tran_id from inv_allocate where WORK_ORDER = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,worder);
sql1 = "select acct_code__inv, cctr_code__inv from stock where item_code = ? and site_code = ? and loc_code = ? and lot_no = ? and lot_sl = ? ";
pstmt = connOne.prepareStatement(sql1);
pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
pstmt.setString(3,locCodeFr);
pstmt.setString(4,lotno);
pstmt.setString(5,lotsl);
rs = pstmt.executeQuery();
if(rs.next())
{
tranType = checkNull(rs.getString("tran_type"));
tranDate = rs.getDate("tran_date");
tranIdInvAlloc = checkNull(rs.getString("tran_id"));
acctCodeInv1 = rs.getString("acct_code__inv")==null?"1440":rs.getString("acct_code__inv");
cctrCodeInv1 = rs.getString("cctr_code__inv")==null?"H651":rs.getString("cctr_code__inv");
}
if(rs != null)
rs.close();
......@@ -365,74 +735,8 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
pstmt.close();
pstmt = null;
String invstat = mfgComm.getEnvMfg("999999","MAIN_ST_INVSTAT", connOne);
System.out.println("::: XML Cretation::::");
//sql1 = "select item_code,quantity,site_code,loc_code__alloc,consider_lot_no__issue from workorder_bill where work_order = ? ";
sql = "select item_code,site_code,lot_no,lot_sl,remarks,line_no,loc_code,quantity from inv_alloc_det where tran_id = ? " +
" and loc_code in(select loc_code from location where inv_stat = ?)";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,tranIdInvAlloc);
pstmt.setString(2,invstat);
rs = pstmt.executeQuery();
while(rs.next())
{
notrans ++;
xmlBuff = new StringBuffer();
sql1 = "select item_ser from item where item_code = ? ";
pstmt1 = connOne.prepareStatement(sql1);
pstmt1.setString(1,rs.getString("item_code"));
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
itemSer = rs1.getString("item_ser");
}
if(rs1 != null)
rs1.close();
rs1 = null;
if(pstmt1 != null)
pstmt1.close();
pstmt1 = null;
sql1 = "select reas_code from inv_alloc_det where tran_id = ? and item_code = ? ";
pstmt1 = connOne.prepareStatement(sql1);
pstmt1.setString(1,tranIdInvAlloc);
pstmt1.setString(2,rs.getString("item_code"));
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
reasCode = checkNull(rs1.getString("reas_code"));
}
if(rs1 != null)
rs1.close();
rs1 = null;
if(pstmt1 != null)
pstmt1.close();
pstmt1 = null;
System.out.println("::: XML Cretation::::");
sql1 = "select acct_code__inv, cctr_code__inv from stock where item_code = ? and site_code = ? and loc_code = ? and lot_no = ? and lot_sl = ? ";
pstmt1 = connOne.prepareStatement(sql1);
pstmt1.setString(1,checkNull(rs.getString("item_code")));
pstmt1.setString(2,checkNull(rs.getString("site_code")));
pstmt1.setString(3,checkNull(rs.getString("loc_code")));
pstmt1.setString(4,checkNull(rs.getString("lot_no")));
pstmt1.setString(5,checkNull(rs.getString("lot_sl")));
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
acctCodeInv1 = rs1.getString("acct_code__inv")==null?"1440":rs1.getString("acct_code__inv");
cctrCodeInv1 = rs1.getString("cctr_code__inv")==null?"H651":rs1.getString("cctr_code__inv");
}
if(rs1 != null)
rs1.close();
rs1 = null;
if(pstmt1 != null)
pstmt1.close();
pstmt1 = null;
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
......@@ -455,91 +759,100 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
xmlBuff.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"stock_transfer\" objContext=\"1\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA["+ sdf.format(currDate).toString()+"]]></tran_date>");
xmlBuff.append("<ref_date><![CDATA[" + sdf.format(orddate).toString() +"]]></ref_date>");
xmlBuff.append("<tran_type><![CDATA["+ tranType +"]]></tran_type>");
xmlBuff.append("<site_code><![CDATA["+ checkNull(rs.getString("site_code")) +"]]></site_code>");
xmlBuff.append("<site_code><![CDATA["+ siteCode +"]]></site_code>");
xmlBuff.append("<item_ser><![CDATA[" + itemSer +"]]></item_ser>");
xmlBuff.append("<emp_code__aprv><![CDATA["+ empCode +"]]></emp_code__aprv>");
xmlBuff.append("<ref_id__for><![CDATA[" + worder +"]]></ref_id__for>");
xmlBuff.append("<REF_SER__FOR><![CDATA[" + "w_ord" +"]]></REF_SER__FOR>");
xmlBuff.append("<reas_code><![CDATA[" + reasCode+" ]]></reas_code>");
xmlBuff.append("<truck_no><![CDATA[ ]]></truck_no>");
xmlBuff.append("</Detail1>");
xmlBuff.append("<Detail2 dbID='' domID=\"1\" objName=\"stock_transfer\" objContext=\"2\">");
xmlBuff.append("<attribute pkNames=\"\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
xmlBuff.append("<tran_id/>");
xmlBuff.append("<item_code><![CDATA["+ checkNull(rs.getString("item_code"))+"]]></item_code>");
xmlBuff.append("<line_no><![CDATA[" + checkNull(rs.getString("line_no")) +"]]></line_no>");
xmlBuff.append("<quantity><![CDATA[" + rs.getDouble("quantity") +"]]></quantity>");
xmlBuff.append("<remarks><![CDATA[" + checkNull(rs.getString("remarks")) +"]]></remarks>");
xmlBuff.append("<loc_code__fr><![CDATA[" + checkNull(rs.getString("loc_code")) +"]]></loc_code__fr>");
xmlBuff.append("<item_code><![CDATA["+ itemCode+"]]></item_code>");
xmlBuff.append("<line_no><![CDATA[1]]></line_no>");
xmlBuff.append("<quantity><![CDATA[" + allocQty +"]]></quantity>");
xmlBuff.append("<remarks><![CDATA[" + remarks +"]]></remarks>");
xmlBuff.append("<loc_code__fr><![CDATA[" + locCodeFr +"]]></loc_code__fr>");
xmlBuff.append("<loc_code__to><![CDATA[" + locCodeTo +"]]></loc_code__to>");
xmlBuff.append("<lot_no__fr><![CDATA[" + checkNull(rs.getString("lot_no")) +"]]></lot_no__fr>");
xmlBuff.append("<lot_sl__fr><![CDATA[" + checkNull(rs.getString("lot_sl")) +"]]></lot_sl__fr>");
xmlBuff.append("<lot_no__to><![CDATA[" + checkNull(rs.getString("lot_no")) +"]]></lot_no__to>");
xmlBuff.append("<lot_sl__to><![CDATA[" + checkNull(rs.getString("lot_sl")) +"]]></lot_sl__to>");
xmlBuff.append("<lot_no__fr><![CDATA[" + lotno +"]]></lot_no__fr>");
xmlBuff.append("<lot_sl__fr><![CDATA[" + lotsl +"]]></lot_sl__fr>");
xmlBuff.append("<lot_no__to><![CDATA[" + lotno +"]]></lot_no__to>");
xmlBuff.append("<lot_sl__to><![CDATA[" + lotsl +"]]></lot_sl__to>");
xmlBuff.append("<acct_code__dr><![CDATA["+ acctCodeInv1 +"]]></acct_code__dr>");
xmlBuff.append("<acct_code__cr><![CDATA["+ acctCodeInv1 +"]]></acct_code__cr>");
xmlBuff.append("<cctr_code__cr><![CDATA["+ cctrCodeInv1 +"]]></cctr_code__cr>");
xmlBuff.append("<cctr_code__dr><![CDATA["+ cctrCodeInv1 +"]]></cctr_code__dr>");
xmlBuff.append("</Detail2>");
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlString = xmlBuff.toString();
System.out.println("@@@@@2: xmlString @ "+notrans+":::: "+xmlBuff.toString());
System.out.println("...............just before savdata() @ "+notrans);
System.out.println("@@@@@2: xmlString :::: "+xmlBuff.toString());
System.out.println("...............just before savdata() ");
siteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("== site code == @"+notrans+": "+siteCode);
System.out.println("== site code == @"+siteCode);
retString = saveData(siteCode,xmlString,connOne);
System.out.println("@@@@@2: retString: @"+notrans+":: "+retString);
System.out.println("@@@@@2: retString: @"+retString);
System.out.println("--retString finished--");
if (retString.indexOf("Success") > -1)
{
connOne.commit();
System.out.println("@@@@@@3: retString @ "+notrans+":::: "+retString);
System.out.println("@@@@@@3: retString @ "+retString);
String[] arrayForTranId = retString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>");
String tranIdForIssue = arrayForTranId[1].substring(0,endIndex);
System.out.println("-tranIdForIssue-"+tranIdForIssue);
list.add(tranIdForIssue);
StockTransferConf stconf = new StockTransferConf();
retString = stconf.confirm(tranIdForIssue,xtraParams,"");
System.out.println("retString from confirmStocktrans :: @:: "+retString);//CONFSUCC
}
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
System.out.println("Total transaction : "+notrans+" total list size"+list.size());
StockTransferConf stconf = new StockTransferConf();
if(list.size() > 0){
for(int i=0;i<= list.size()-1;i++)
{
retString = stconf.confirm((String)list.get(i),xtraParams,"");
System.out.println("retString from confirmStocktrans :: @"+i+":: "+retString);//CONFSUCC
bool = true;
}}
if(bool){
if((retString != null ) && retString.indexOf("Success") > -1 || retString.indexOf("CONFSUCC") >-1)
{
sql = " update inv_alloc_det set loc_Code = ? where tran_id = ? ";
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
pstmt.setString(2,tranIdInvAlloc);
int rows = pstmt.executeUpdate();
System.out.println("--update rows in process --"+ rows);
if(pstmt != null)
pstmt.close();
pstmt = null;
}}
// if((retString != null ) && retString.indexOf("Success") > -1 || retString.indexOf("CONFSUCC") >-1)
// {
//// sql = " update inv_alloc_det set loc_Code = ? where tran_id = ? and item_code = ? ";
//// pstmt = connOne.prepareStatement(sql);
//// pstmt.setString(1,locCodeTo);
//// pstmt.setString(2,tranIdInvAlloc);
//// pstmt.setString(3,itemCode);
//// int rows = pstmt.executeUpdate();
//// System.out.println("--update rows in process --"+ rows);
//// if(pstmt != null)
//// pstmt.close();
//// pstmt = null;
// }
}
catch(Exception e)
......@@ -552,7 +865,6 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
{
try
{
if(pstmt != null)
{
pstmt.close();
......@@ -562,18 +874,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
{
rs.close();
rs = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
}
}
catch(Exception e)
{
......
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