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 ...@@ -68,7 +68,8 @@ public class WoTransferIC extends ValidatorEJB implements WoTransferICLocal,WoTr
Node parentNode1 = null; Node parentNode1 = null;
String childNodeName = null; String childNodeName = null;
String sql = ""; String sql = "";
String locCode = "",descr=""; String locCode = "",descr="",worder="";
double batchQuantity=0.0;
int currentFormNo = 0; int currentFormNo = 0;
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
...@@ -108,8 +109,34 @@ public class WoTransferIC extends ValidatorEJB implements WoTransferICLocal,WoTr ...@@ -108,8 +109,34 @@ public class WoTransferIC extends ValidatorEJB implements WoTransferICLocal,WoTr
{ {
descr = rs.getString("descr"); 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>"); 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("</Detail1>");
} }
valueXmlString.append("</Root>"); valueXmlString.append("</Root>");
......
/** /**
DEVELOPED BY RITESH TIWARI ON 02/11/13 DEVELOPED BY RITESH TIWARI ON 02/11/13
FOR WORK ORDER STOCK TRANSFER PURPUSE : WORK ORDER STOCK TRANSFER (MF3GSUP004)
*/ */
package ibase.webitm.ejb.mfg; package ibase.webitm.ejb.mfg;
import ibase.system.config.AppConnectParm; import ibase.system.config.AppConnectParm;
...@@ -16,6 +16,7 @@ import java.sql.PreparedStatement; ...@@ -16,6 +16,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -23,24 +24,347 @@ import java.util.logging.Level; ...@@ -23,24 +24,347 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.naming.InitialContext; 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 org.w3c.dom.Document;
import javax.xml.rpc.ParameterMode; import org.w3c.dom.Node;
import ibase.webitm.ejb.dis.DistCommon; import org.w3c.dom.NodeList;
import ibase.webitm.ejb.dis.GenerateSaleOrderPrc; //import ibase.webitm.ejb.dis.InvAllocTrace;
import ibase.webitm.ejb.dis.adv.StockTransferConf; import ibase.webitm.ejb.dis.adv.StockTransferConf;
//import ibase.webitm.ejb.fin.FinCommon;
@Stateless @Stateless
public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTransferPrcRemote public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTransferPrcRemote
{ {
static static
{ {
System.out.println("-- WoTransferPrc called -- "); System.out.println("-- WoTransferPrc called -- ");
} }
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String rtrStr = "";
Document headerDom = null;
Document detailDom = null;
System.out.println("getData(xmlString,xmlString2,windowName,xtraParams CALLED..."+ xmlString);
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println("XML String :"+xmlString);
headerDom = genericUtility.parseString(xmlString);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
System.out.println("XML String :"+xmlString2);
detailDom = genericUtility.parseString(xmlString2);
}
rtrStr = getData(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :WoTransferPrcEJB :getData(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
rtrStr = e.getMessage();
}
return rtrStr;
}
public String getData(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
String errString = "";
String sql= "",worder="",locCodeTo="",batchQuantity="";
String resultString = "",errCode="";
String invstat="",invstat1="",tranIdInvAlloc="";
int cnt=0;
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
{
System.out.println("WoTransferPrc getData called :: ::");
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
worder = checkNull(genericUtility.getColumnValue("work_order", headerDom));
locCodeTo = checkNull(genericUtility.getColumnValue("loc_code__to", headerDom));
batchQuantity = checkNull(genericUtility.getColumnValue("batch_quantity", headerDom));
if(worder == null || worder.trim().length() <= 0)
{
System.out.println("worder:: is null "+ worder);
errString = itmDBAccessEJB.getErrorString("","VTWKORD1 ","","",conn);
return errString;
}
if(locCodeTo == null || locCodeTo.trim().length() <= 0)
{
System.out.println("loc code to is null:: "+ worder);
errString = itmDBAccessEJB.getErrorString("","VTLOCCDTO2 ","","",conn);
return errString;
}
if(worder != null && worder.trim().length() > 0)
{
sql = "select count(*) from workorder where work_order = ? and status not in ('F') ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,worder);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
if(cnt == 0)
{
errString = itmDBAccessEJB.getErrorString("","VPWOINV ","","",conn);
return errString;
}
}
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", conn);
invstat1 = mfgComm.getEnvMfg("999999","MAIN_ST_INVSTAT", conn);
if(invstat.equalsIgnoreCase(invstat1))
{
errString = itmDBAccessEJB.getErrorString("","VTDISPVAR ","","",conn);
return errString;
}
sql = "select count(1) from location where loc_code = ? and inv_stat = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
pstmt.setString(2,invstat);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
if(cnt == 0)
{
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 public String process() throws RemoteException,ITMException
{ {
return ""; return "";
...@@ -85,21 +409,30 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -85,21 +409,30 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
return retStr; return retStr;
} //end of confirm method } //end of confirm method
public String process(Document dom, Document dom2, String windowName,String xtraParams) throws RemoteException, ITMException public String process(Document headerDom, Document detailDom, String windowName,String xtraParams) throws RemoteException, ITMException
{ {
System.out.println("WoTransferPrc process called........"); System.out.println("WoTransferPrc process called........");
String sql = ""; String allocQty="",itemCode="";
String errString = ""; String errString = null,sql="";
String siteCode = "",invstat="",invstat1=""; String siteCode="",explev="",lineno="",lotno="",lotsl="",locCodeFr="",reasCode="";
String worder = "",locCodeTo=""; String worder = "",locCodeTo="",remarks="",tranId="";
int cnt=0;
Connection connOne = null; Connection connOne = null;
ConnDriver connDriver = null; ConnDriver connDriver = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
GenericUtility genericUtility = null; double actualQty =0.0,trfedQty = 0.0,allocQty2=0.0;
ITMDBAccessEJB itmDBAccessEJB = null; ITMDBAccessEJB itmDBAccessEJB = null;
MfgCommon mfgComm = new MfgCommon(); 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 try
{ {
genericUtility = new GenericUtility(); genericUtility = new GenericUtility();
...@@ -107,79 +440,135 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -107,79 +440,135 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
connDriver = new ConnDriver(); connDriver = new ConnDriver();
connOne = connDriver.getConnectDB("DriverITM"); connOne = connDriver.getConnectDB("DriverITM");
connDriver = null; 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++)
{
childNode = childNodeList.item(childRow);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName---->>> "+ childNodeName);
worder = checkNull(genericUtility.getColumnValue("work_order", dom)); if (childNodeName.equals("tran_id"))
locCodeTo = checkNull(genericUtility.getColumnValue("loc_code__to", dom)); {
tranId = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("line_no"))
{
lineno = childNode.getFirstChild().getNodeValue();
}
connOne.setAutoCommit(false); if (childNodeName.equals("site_code"))
if(worder == null || worder.trim().length() <= 0)
{ {
errString = itmDBAccessEJB.getErrorString("","VTWKORD1 ","","",connOne); siteCode = childNode.getFirstChild().getNodeValue();
return errString;
} }
if(locCodeTo == null || locCodeTo.trim().length() <= 0)
if (childNodeName.equals("item_code"))
{ {
errString = itmDBAccessEJB.getErrorString("","VTLOCCDTO2 ","","",connOne); itemCode = childNode.getFirstChild().getNodeValue();
return errString;
} }
if(worder != null || worder.trim().length() > 0)
if (childNodeName.equals("lot_no"))
{ {
sql = "select count(*) from workorder where work_order = ? and status not in ('F') "; lotno = childNode.getFirstChild().getNodeValue();
pstmt = connOne.prepareStatement(sql); }
pstmt.setString(1,worder); if (childNodeName.equals("lot_sl"))
rs = pstmt.executeQuery();
if(rs.next())
{ {
cnt = rs.getInt(1); lotsl = childNode.getFirstChild().getNodeValue();
} }
if(rs != null) if (childNodeName.equals("quantity"))
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
if(cnt == 0)
{ {
errString = itmDBAccessEJB.getErrorString("","VPWOINV ","","",connOne); allocQty = childNode.getFirstChild().getNodeValue();
return errString; allocQty2 = Double.parseDouble(childNode.getFirstChild().getNodeValue());
}
if (childNodeName.equals("reas_code"))
{
if(childNode !=null)
{
if(childNode.getFirstChild() != null)
{
reasCode = childNode.getFirstChild().getNodeValue();
} }
} }
if(locCodeTo != null || locCodeTo.trim().length() > 0)
}if (childNodeName.equals("loc_code"))
{ {
cnt=0; locCodeFr = childNode.getFirstChild().getNodeValue();
invstat = mfgComm.getEnvMfg("999999","SUB_ST_INVSTAT", connOne); }if (childNodeName.equals("exp_lev"))
invstat1 = mfgComm.getEnvMfg("999999","MAIN_ST_INVSTAT", connOne);
if(invstat.equalsIgnoreCase(invstat1))
{ {
errString = itmDBAccessEJB.getErrorString("","VTDISPVAR ","","",connOne); explev = childNode.getFirstChild().getNodeValue();
return errString;
} }
sql = "select count(1) from location where loc_code = ? and inv_stat = ? "; if (childNodeName.equals("loc_code__to"))
pstmt = connOne.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
pstmt.setString(2,invstat);
rs = pstmt.executeQuery();
if(rs.next())
{ {
cnt = rs.getInt(1); locCodeTo = childNode.getFirstChild().getNodeValue();
} }
if(rs != null) if (childNodeName.equals("work_order"))
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
if(cnt == 0)
{ {
errString = itmDBAccessEJB.getErrorString("","VTLOCCDTO1 ","","",connOne); worder = childNode.getFirstChild().getNodeValue();
return errString;
} }
if (childNodeName.equals("remarks"))
{
remarks = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("actual_qty"))
{
actualQty = Double.parseDouble(childNode.getFirstChild().getNodeValue());
} }
if(errString == null || errString.trim().length() == 0) if (childNodeName.equals("allocated_qty"))
{ {
errString = allocStockToWo(worder,locCodeTo,xtraParams,connOne); 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); System.out.println("err String from STOCKTRANS ="+errString);
}
else
{
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";
}
for(int i = 0; i < elements * 2; i++ )
{
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)) if((errString != null ) && (errString.indexOf("Success") > -1 || errString.indexOf("CONFSUCC") >-1))
{ {
connOne.commit(); connOne.commit();
...@@ -188,18 +577,16 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -188,18 +577,16 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
} }
else if(errString != null && errString.indexOf("VTITRF") > -1) else if(errString != null && errString.indexOf("VTITRF") > -1)
{ {
System.out.println("(((((((((((()]]]]]]]]]]]]]]]]");; System.out.println("Item code can not we same)]]");;
errString = itmDBAccessEJB.getErrorString("","VTITRF ","","",connOne); errString = itmDBAccessEJB.getErrorString("","VTITRF ","","",connOne);
} }
else else
{ {
connOne.rollback(); connOne.rollback();
System.out.println("--process not completed--"); System.out.println("--process not completed--");
errString = itmDBAccessEJB.getErrorString("","VTPRCERR ","","",connOne); errString = itmDBAccessEJB.getErrorString("","VTPRCERR ","","",connOne);
} }
} }
}
catch( Exception e) catch( Exception e)
{ {
try try
...@@ -218,9 +605,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -218,9 +605,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
{ {
if(errString != null && errString.trim().length() > 0) if(errString != null && errString.trim().length() > 0)
{ {
if(errString.indexOf("VPSUCC1") > -1 ) if(errString.indexOf("VPSUCC1") > -1 )
{ {
connOne.commit(); connOne.commit();
System.out.println("--transaction commited--"); System.out.println("--transaction commited--");
...@@ -256,37 +641,29 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -256,37 +641,29 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
} }
return errString; 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 userId = "";
String termId = ""; String termId = "";
String sql = "",sql1="", acctCodeInv1 = "",cctrCodeInv1=""; String sql = "",sql1="", acctCodeInv1 = "",cctrCodeInv1="";
String itemCode="",tranIdInvAlloc="",reasCode="",refno = "",itemSer="",tranType=""; String itemSer="",tranType="";
Date tranDate = null,orddate = null; Date orddate = null;
int notrans =0; PreparedStatement pstmt = null;
PreparedStatement pstmt = null,pstmt1= null; ResultSet rs = null;
ResultSet rs = null,rs1=null;
GenericUtility genericUtility = null; GenericUtility genericUtility = null;
ITMDBAccessEJB itmDBAccessEJB = null;
Timestamp currDate = null; Timestamp currDate = null;
String retString = null; String retString = null;
String siteCode = "",empCode = ""; String empCode = "";
String xmlString = ""; String xmlString = "";
MfgCommon mfgComm = null;
StringBuffer xmlBuff = null; StringBuffer xmlBuff = null;
ArrayList list = null;
boolean bool = false;
try try
{ {
list = new ArrayList();
itmDBAccessEJB = new ITMDBAccessEJB();
genericUtility = GenericUtility.getInstance();
mfgComm = new MfgCommon();
System.out.println("@@@@@@@ wostock trans. function called::"); System.out.println("@@@@@@@ wostock trans. function called::");
xmlBuff = new StringBuffer();
genericUtility = GenericUtility.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat()); SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
currDate = java.sql.Timestamp.valueOf(sdf1.format(new java.util.Date()).toString() + " 00:00:00.0"); 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); userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); System.out.println("--login code--"+userId);
termId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"); System.out.println("--term id--"+termId); termId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"); System.out.println("--term id--"+termId);
...@@ -313,16 +690,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -313,16 +690,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) 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"); 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) if(rs != null)
rs.close(); rs.close();
...@@ -347,16 +715,18 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -347,16 +715,18 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
sql = "select tran_type,tran_date,tran_id from inv_allocate where WORK_ORDER = ? "; 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(sql); pstmt = connOne.prepareStatement(sql1);
pstmt.setString(1,worder); pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
pstmt.setString(3,locCodeFr);
pstmt.setString(4,lotno);
pstmt.setString(5,lotsl);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
tranType = checkNull(rs.getString("tran_type")); acctCodeInv1 = rs.getString("acct_code__inv")==null?"1440":rs.getString("acct_code__inv");
tranDate = rs.getDate("tran_date"); cctrCodeInv1 = rs.getString("cctr_code__inv")==null?"H651":rs.getString("cctr_code__inv");
tranIdInvAlloc = checkNull(rs.getString("tran_id"));
} }
if(rs != null) if(rs != null)
rs.close(); rs.close();
...@@ -365,73 +735,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -365,73 +735,7 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
String invstat = mfgComm.getEnvMfg("999999","MAIN_ST_INVSTAT", connOne);
System.out.println("::: XML Cretation::::"); 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;
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("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>"); xmlBuff.append("<DocumentRoot>");
...@@ -455,91 +759,100 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -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("<Detail1 dbID=\"\" domID=\"1\" objName=\"stock_transfer\" objContext=\"1\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>"); xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>"); xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA["+ sdf.format(currDate).toString()+"]]></tran_date>"); xmlBuff.append("<tran_date><![CDATA["+ sdf.format(currDate).toString()+"]]></tran_date>");
xmlBuff.append("<ref_date><![CDATA[" + sdf.format(orddate).toString() +"]]></ref_date>"); xmlBuff.append("<ref_date><![CDATA[" + sdf.format(orddate).toString() +"]]></ref_date>");
xmlBuff.append("<tran_type><![CDATA["+ tranType +"]]></tran_type>"); 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("<item_ser><![CDATA[" + itemSer +"]]></item_ser>");
xmlBuff.append("<emp_code__aprv><![CDATA["+ empCode +"]]></emp_code__aprv>"); xmlBuff.append("<emp_code__aprv><![CDATA["+ empCode +"]]></emp_code__aprv>");
xmlBuff.append("<ref_id__for><![CDATA[" + worder +"]]></ref_id__for>"); xmlBuff.append("<ref_id__for><![CDATA[" + worder +"]]></ref_id__for>");
xmlBuff.append("<REF_SER__FOR><![CDATA[" + "w_ord" +"]]></REF_SER__FOR>"); xmlBuff.append("<REF_SER__FOR><![CDATA[" + "w_ord" +"]]></REF_SER__FOR>");
xmlBuff.append("<reas_code><![CDATA[" + reasCode+" ]]></reas_code>"); xmlBuff.append("<reas_code><![CDATA[" + reasCode+" ]]></reas_code>");
xmlBuff.append("<truck_no><![CDATA[ ]]></truck_no>"); xmlBuff.append("<truck_no><![CDATA[ ]]></truck_no>");
xmlBuff.append("</Detail1>"); xmlBuff.append("</Detail1>");
xmlBuff.append("<Detail2 dbID='' domID=\"1\" objName=\"stock_transfer\" objContext=\"2\">"); xmlBuff.append("<Detail2 dbID='' domID=\"1\" objName=\"stock_transfer\" objContext=\"2\">");
xmlBuff.append("<attribute pkNames=\"\" selected=\"N\" updateFlag=\"A\" status=\"N\" />"); xmlBuff.append("<attribute pkNames=\"\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
xmlBuff.append("<tran_id/>"); 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("<item_code><![CDATA["+ itemCode+"]]></item_code>");
xmlBuff.append("<quantity><![CDATA[" + rs.getDouble("quantity") +"]]></quantity>");
xmlBuff.append("<remarks><![CDATA[" + checkNull(rs.getString("remarks")) +"]]></remarks>"); xmlBuff.append("<line_no><![CDATA[1]]></line_no>");
xmlBuff.append("<loc_code__fr><![CDATA[" + checkNull(rs.getString("loc_code")) +"]]></loc_code__fr>");
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("<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__fr><![CDATA[" + lotno +"]]></lot_no__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_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__dr><![CDATA["+ acctCodeInv1 +"]]></acct_code__dr>");
xmlBuff.append("<acct_code__cr><![CDATA["+ acctCodeInv1 +"]]></acct_code__cr>"); xmlBuff.append("<acct_code__cr><![CDATA["+ acctCodeInv1 +"]]></acct_code__cr>");
xmlBuff.append("<cctr_code__cr><![CDATA["+ cctrCodeInv1 +"]]></cctr_code__cr>"); xmlBuff.append("<cctr_code__cr><![CDATA["+ cctrCodeInv1 +"]]></cctr_code__cr>");
xmlBuff.append("<cctr_code__dr><![CDATA["+ cctrCodeInv1 +"]]></cctr_code__dr>"); xmlBuff.append("<cctr_code__dr><![CDATA["+ cctrCodeInv1 +"]]></cctr_code__dr>");
xmlBuff.append("</Detail2>"); xmlBuff.append("</Detail2>");
xmlBuff.append("</Header0>"); xmlBuff.append("</Header0>");
xmlBuff.append("</group0>"); xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>"); xmlBuff.append("</DocumentRoot>");
xmlString = xmlBuff.toString(); xmlString = xmlBuff.toString();
System.out.println("@@@@@2: xmlString @ "+notrans+":::: "+xmlBuff.toString()); System.out.println("@@@@@2: xmlString :::: "+xmlBuff.toString());
System.out.println("...............just before savdata() @ "+notrans); System.out.println("...............just before savdata() ");
siteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"); siteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("== site code == @"+notrans+": "+siteCode); System.out.println("== site code == @"+siteCode);
retString = saveData(siteCode,xmlString,connOne); retString = saveData(siteCode,xmlString,connOne);
System.out.println("@@@@@2: retString: @"+notrans+":: "+retString); System.out.println("@@@@@2: retString: @"+retString);
System.out.println("--retString finished--"); System.out.println("--retString finished--");
if (retString.indexOf("Success") > -1) if (retString.indexOf("Success") > -1)
{ {
connOne.commit(); connOne.commit();
System.out.println("@@@@@@3: retString @ "+notrans+":::: "+retString); System.out.println("@@@@@@3: retString @ "+retString);
String[] arrayForTranId = retString.split("<TranID>"); String[] arrayForTranId = retString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>"); int endIndex = arrayForTranId[1].indexOf("</TranID>");
String tranIdForIssue = arrayForTranId[1].substring(0,endIndex); String tranIdForIssue = arrayForTranId[1].substring(0,endIndex);
System.out.println("-tranIdForIssue-"+tranIdForIssue); System.out.println("-tranIdForIssue-"+tranIdForIssue);
list.add(tranIdForIssue);
}
}
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(); StockTransferConf stconf = new StockTransferConf();
if(list.size() > 0){ retString = stconf.confirm(tranIdForIssue,xtraParams,"");
for(int i=0;i<= list.size()-1;i++) System.out.println("retString from confirmStocktrans :: @:: "+retString);//CONFSUCC
{ }
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 = ? "; // if((retString != null ) && retString.indexOf("Success") > -1 || retString.indexOf("CONFSUCC") >-1)
pstmt = connOne.prepareStatement(sql); // {
pstmt.setString(1,locCodeTo); //// sql = " update inv_alloc_det set loc_Code = ? where tran_id = ? and item_code = ? ";
pstmt.setString(2,tranIdInvAlloc); //// pstmt = connOne.prepareStatement(sql);
int rows = pstmt.executeUpdate(); //// pstmt.setString(1,locCodeTo);
System.out.println("--update rows in process --"+ rows); //// pstmt.setString(2,tranIdInvAlloc);
if(pstmt != null) //// pstmt.setString(3,itemCode);
pstmt.close(); //// int rows = pstmt.executeUpdate();
pstmt = null; //// System.out.println("--update rows in process --"+ rows);
}} //// if(pstmt != null)
//// pstmt.close();
//// pstmt = null;
// }
} }
catch(Exception e) catch(Exception e)
...@@ -552,7 +865,6 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -552,7 +865,6 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
{ {
try try
{ {
if(pstmt != null) if(pstmt != null)
{ {
pstmt.close(); pstmt.close();
...@@ -563,17 +875,6 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr ...@@ -563,17 +875,6 @@ public class WoTransferPrc extends ProcessEJB implements WoTransferPrcLocal,WoTr
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
} }
catch(Exception e) 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