Commit a0c24ec6 authored by dpawar's avatar dpawar

added multiple PTCN source code


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97129 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c2c384de
package ibase.webitm.ejb.wms;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.io.File;
import java.rmi.RemoteException;
import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.*;
@javax.ejb.Stateless
public class MultiplePtcnWiz extends ValidatorEJB implements PickIssICLocal, PickIssICRemote
{
/**
* The method is defined without any parameter and returns blank string
*/
@Override
public String wfValData() throws RemoteException, ITMException
{
return "";
}
/**
* The public method is used for converting the current form data into a document(DOM)
* The dom is then given as argument to the overloaded function wfValData to perform validation
* Returns validation string if exists else returns null in XML format
* @param xmlString contains the current form data in XML format
* @param xmlString1 contains all the header information in the XML format
* @param xmlString2 contains the data of all the forms in XML format
* @param objContext represents the form number
* @param editFlag represents the mode of transaction(A-Add or E-Edit)
* @param xtraParams contains additional information such as loginEmpCode,loginCode,chgTerm etc
*/
@Override
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext,String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
System.out.println( "xmlString ::" + xmlString);
System.out.println( "xmlString1 ::" + xmlString1);
System.out.println( "xmlString2 ::" + xmlString2);
if(xmlString != null && xmlString.trim().length()!=0)
{
dom = genericUtility.parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length()!=0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = wfValData( dom, dom1, dom2, objContext, xtraParams);
System.out.println( "ErrString: " + errString);
}
catch(Exception e)
{
errString = genericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
return (errString);
}
/**
* The public overloaded method takes a document as input and is used for the validation of required fields
* Returns validation string if exist otherwise returns null in XML format
* @param currFormDataDom contains the current form data as a document object model
* @param hdrDataDom contains all the header information
* @param allFormDataDom contains the field data of all the forms
* @param objContext represents form number
* @param editFlag represents the mode of transaction(A-Add or E-Edit)
* @param xtraParams contains additional information such as loginEmpCode,loginCode,chgTerm etc
*/
@Override
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String xtraParams) throws RemoteException, ITMException
{
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
String errorType = "", errCode = "", docLocCode = "" ,statusPkord= "", locCode = "";
ArrayList <String> errList = new ArrayList<String>();
ArrayList <String>errFields = new ArrayList <String> ();
GenericUtility genericUtility;
HashMap itmVolumeMap = new HashMap();
ResultSet rs= null;
PreparedStatement pstmt = null;
Connection conn = null;
String assignTo = "",userId = "",childNodeName = "",errString = "",remarks = "",qtyStr = "",pickOrder = "",
sql = "";
int ctr = 0, currentFormNo = 0, childNodeListLength = 0, cnt = 0;
double quantity = 0;
try
{
genericUtility = GenericUtility.getInstance();
System.out.println("xtraParam----->>["+xtraParams+"]");
System.out.println("DOM---->>["+genericUtility.serializeDom(dom).toString()+"]");
System.out.println("DOM1----->>["+genericUtility.serializeDom(dom1).toString()+"]");
System.out.println("DOM2----->>["+genericUtility.serializeDom(dom2).toString()+"]");
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if (objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext);
}
System.out.println("IN WAFVAL DATA....................................DADASO3");
switch ( currentFormNo ) // Switch Case for form number
{
case 1:
System.out.println("------in detail1 validation----------------");
System.out.println("DOM---->>["+genericUtility.serializeDom(dom).toString()+"]");
System.out.println("DOM1----->>["+genericUtility.serializeDom(dom1).toString()+"]");
System.out.println("DOM2----->>["+genericUtility.serializeDom(dom2).toString()+"]");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName11------->>["+childNodeName+"]");
if("remarks".equalsIgnoreCase(childNodeName))
{
remarks = checkNull(genericUtility.getColumnValue("remarks",dom));
System.out.println("remarks l---------->>["+remarks.length()+"]");
}
}
break;
case 2:
System.out.println("------in detail2 validation----------------");
System.out.println("DOM---->>["+genericUtility.serializeDom(dom).toString()+"]");
System.out.println("DOM1----->>["+genericUtility.serializeDom(dom1).toString()+"]");
System.out.println("DOM2----->>["+genericUtility.serializeDom(dom2).toString()+"]");
parentNodeList = dom2.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
System.out.println("parentNode >>>{"+parentNode+"}");
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("value of child node name ["+childNodeName + "]");
if("ptcn".equalsIgnoreCase(childNodeName))
{
String ptcn = "",status = "",holdStatus = "",cancel = "";
int ptcnYCount = 0,rowCnt = 0;
ptcn = checkNull(genericUtility.getColumnValue("ptcn",dom2));
System.out.println("PTCN11------>>["+ptcn+"]");
if(ptcn.length() == 0)
{
errCode = "VTPTCNNN";// PTCN blank validation
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
else
{
cnt=getDBRowCount(conn, "wave_task_det", "ptcn", ptcn);
if(cnt == 0)
{
errCode = "VTPTCNNE";//Entered PTCN is not defined in wave_task_det master.
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
}
//validation for check PTCN confirmed or not.
rowCnt = getDBRowCount(conn, "WAVE_TASK_DET", "PTCN", ptcn);
sql ="SELECT STATUS FROM WAVE_TASK_DET WHERE PTCN = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ptcn);
rs = pstmt.executeQuery();
while(rs.next())
{
status = checkNull(rs.getString("STATUS"));
if("Y".equalsIgnoreCase(status))
{
ptcnYCount++;
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
System.out.println("rowCnt---->["+rowCnt+" ptcnYCount----->>["+ptcnYCount+"]");
if(ptcnYCount == rowCnt)
{
errCode = "VTPTCNAC";//Entered PTCN confirmed.
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
rowCnt = getDBRowCount(conn, "MULTI_PICK_ISS_HDR", "PTCN", ptcn);
if(rowCnt > 1)
{
errCode = "VTPTCNAS";//Entered PTCN already scanned.
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
sql = "SELECT T.HOLD_STATUS,T.CANCEL FROM WAVE_TASK_DET D ,WAVE_TASK T "
+ "WHERE D.WAVE_ID = T.WAVE_ID AND D.PTCN = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ptcn);
rs = pstmt.executeQuery();
while(rs.next())
{
holdStatus = checkNull(rs.getString(1));
cancel = checkNull(rs.getString(2));
if("Y".equalsIgnoreCase(holdStatus))
{
errCode = "VTPTCNOH";//Entered PTCN on hold
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
break;
}
if("Y".equalsIgnoreCase(cancel))
{
errCode = "VTPTCNIC";//Entered PTCN is cancel.
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
break;
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
status = "";
sql ="SELECT STATUS FROM WAVE_TASK_DET WHERE REF_ID IN ("
+ "SELECT REPL_ORDER FROM PICK_ORD_DET WHERE PICK_ORDER IN ("
+ "SELECT REF_ID FROM WAVE_TASK_DET WHERE PTCN = ?))";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ptcn);
rs = pstmt.executeQuery();
if(rs.next())
{
status = checkNull(rs.getString("STATUS"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("status--------->>["+status+"]");
if("N".equalsIgnoreCase(status))
{
errCode = "VTPTCNTNC";//Dependent task not completed
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
break;
}
}
} //end detail2 for loop
break;
case 3:
System.out.println("------in detail3 validation----------------");
System.out.println("DOM---->>["+genericUtility.serializeDom(dom).toString()+"]");
System.out.println("DOM1----->>["+genericUtility.serializeDom(dom1).toString()+"]");
System.out.println("DOM2----->>["+genericUtility.serializeDom(dom2).toString()+"]");
parentNodeList = dom2.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName11------->>["+childNodeName+"]");
System.out.println("value of child node : "+childNode);
if("ptcn".equalsIgnoreCase(childNodeName))
{
String ptcn = "";
ptcn = checkNull(genericUtility.getColumnValue("ptcn",dom1,"2"));
System.out.println("PTCN11------>>["+ptcn+"]");
ptcn = checkNull(genericUtility.getColumnValue("ptcn",dom2,"3"));
System.out.println("PTCN12------>>["+ptcn+"]");
if(ptcn.length() == 0)
{
errCode = "VTPTCNNN";// PTCN blank validation
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
}
else if("quantity".equalsIgnoreCase(childNodeName))
{
String itemCode = "";
double ordQuantity = 0,quantityL = 0;
System.out.println("quantity validation............");
qtyStr = checkNull(genericUtility.getColumnValue("quantity",dom2,"3"));
qtyStr = qtyStr.length() == 0 ? "0" :qtyStr;
quantityL = Double.parseDouble(qtyStr);
System.out.println("qtyStr----->>["+qtyStr+"]");
pickOrder = checkNull(genericUtility.getColumnValue("pick_order",dom2,"3"));
System.out.println("pickOrder----->>["+pickOrder+"]");
itemCode = checkNull(genericUtility.getColumnValue("item_code",dom2,"3"));
System.out.println("itemCode----->>["+itemCode+"]");
sql = "SELECT QUANTITY FROM PICK_ORD_DET WHERE PICK_ORDER = ? AND ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, pickOrder);
pstmt.setString(2, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
ordQuantity = rs.getDouble(1);
}
System.out.println("quantityL--ordQuantity--->>["+quantityL+"] ["+ordQuantity+"]");
if(quantityL > ordQuantity)
{
errCode = "VTPTCNQG";// Quantity is greater
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
}
}
}
break;
case 4:
{
}
}//End of switch statement
int errListSize = errList.size();
cnt =0;
String errFldName = null;
if ( errList != null && errListSize > 0 )
{
for (cnt = 0; cnt < errListSize; cnt++ )
{
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
System.out.println("errCode .........."+errCode);
errString = getErrorString( errFldName, errCode, userId );
errorType = errorType( conn, errCode );
if ( errString.length() > 0)
{
String bifurErrString = errString.substring( errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>"));
bifurErrString =bifurErrString+errString.substring( errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
System.out.println("errStringXml .........."+errStringXml);
errString = "";
}
if ( errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer( "" );
}
errString = errStringXml.toString();
}
catch ( Exception e )
{
System.out.println ( "Exception: PickIssIC: wfValData( Document currFormDataDom ): " + e.getMessage() + ":" );
//throw new ITMException(e);
e.printStackTrace();
}
finally
{
try
{
if (conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println( "Exception : PickIssIC:wfValData : " + e.getMessage() );
throw new ITMException(e);
}
}
System.out.println( "errString>>>>>>>::"+errString );
return errString;
}
private String errorType( Connection conn , String errorCode )
{
String msgType = "";
PreparedStatement pstmt = null ;
ResultSet rs = null;
try
{
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
while( rs.next() )
{
msgType = rs.getString("MSG_TYPE");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch ( Exception e )
{
e.printStackTrace();
}
}
return msgType;
}
/**
* The public method is defined without any parameters and returns blank string
*/
@Override
public String itemChanged() throws RemoteException, ITMException
{
return "";
}
/**
* The public method is used for converting the current form data into a document(dom)
* The dom is then given as argument to the overloaded function wfValData to perform validation
* Returns validation string if exists else returns null in XML format
* @param xmlString contains the current form data in XML format
* @param xmlString1 contains all the header information in the XML format
* @param xmlString2 contains the data of all the forms in XML format
* @param objContext represents the form number
* @param editFlag represents the mode of transaction(A-Add or E-Edit)
* @param xtraParams contains additional information such as loginEmpCode,loginCode,chgTerm etc
*/
@Override
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document currFormDataDom = null;
Document hdrDataDom = null;
Document allFormDataDom = null;
String errString = null;
GenericUtility genericUtility = GenericUtility.getInstance();
System.out.println("xmlString ["+xmlString+"]");
System.out.println("xmlString1 ["+xmlString1+"]");
System.out.println("xmlString2 ["+xmlString2+"]");
try
{
if (xmlString != null && xmlString.trim().length()!=0)
{
currFormDataDom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length()!=0)
{
hdrDataDom = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length()!=0)
{
allFormDataDom = genericUtility.parseString(xmlString2);
}
System.out.println ( "Calling itemChanged( currFormDataDom, hdrDataDom, allFormDataDom, objContext, currentColumn, editFlag, xtraParams )");
errString = itemChanged( currFormDataDom, hdrDataDom, allFormDataDom, objContext, currentColumn, editFlag, xtraParams );
System.out.println ( "ErrString :" + errString);
}
catch (Exception e)
{
System.out.println ( "Exception :PickIssIC :itemChanged(String,String):" + e.getMessage() + ":" );
throw new ITMException(e);
}
System.out.println ( "returning from PickIssIC itemChanged \n[" + errString + "]" );
return errString;
}
/**
* The public overloaded method takes a document as input and is used for the validation of required fields
* Returns validation string if exist otherwise returns null in XML format
* @param currFormDataDom contains the current form data as a document object model
* @param hdrDataDom contains all the header information
* @param allFormDataDom contains the field data of all the forms
* @param objContext represents form number
* @param currentColumn represents the current field
* @param editFlag represents the mode of transaction(A-Add or E-Edit)
* @param xtraParams contains additional information
*/
@Override
public String itemChanged( Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String currentColumn,String editFlag, String xtraParams ) throws RemoteException,ITMException
{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs =null;
HashMap itmVolumeMap = new HashMap();
StringBuffer valueXmlString;
Date tranDateD = null;
String retString = "",sql = "",tranId = "" , tranDate = "",siteCode = "", siteCodeDescr = "" ,confirmed = "";
String remarks = "" , chgUser = "",chgTerm = "",loginCode= "",loginEmpCode = "",loginSite = "",empCodeUser = "";
String siteCodeShip = "", waveId = "",refId = "",status = "",saleOrder = "",ptcnL = "" ;
int currentFormNo = 0;
System.out.println("xtraParams=["+xtraParams+"]");
System.out.println("MultiplePtcnWizCalled123........................... : ["+currentColumn+"]");
int lineNo = 1;
DistCommon distCommon = new DistCommon();
GenericUtility genericUtility = GenericUtility.getInstance();
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>").append( editFlag );
try
{
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String currDate = sdf.format(currentDate.getTime());
DateFormat dtFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
loginSite = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" ));
loginEmpCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
chgUser = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
chgTerm = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"));
String dbDateFormat = genericUtility.getDBDateFormat();
String applDateFormat = genericUtility.getApplDateFormat();
System.out.println("loginEmpCode---->>["+loginEmpCode+"] chgUser---->>["+chgUser+"]");
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB( "DriverITM" );
connDriver = null;
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
System.out.println("current form no["+currentFormNo+"]");
valueXmlString.append("</editFlag>\r\n</Header>\r\n");
switch ( currentFormNo )
{
case 1:
{
//valueXmlString.append( "<Detail1 domID='1'>\r\n" );
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
{
System.out.println("in itm_default.........."+loginSite);
sql = "SELECT TRAN_ID,TRAN_DATE,SITE_CODE,CONFIRMED,REMARKS,EMP_CODE__USER FROM MULTI_PICK_ISS "
+ "WHERE CHG_USER = ? "
+ "AND CASE WHEN CONFIRMED IS NULL THEN 'N' ELSE CONFIRMED END = 'N'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,chgUser);
rs = pstmt.executeQuery();
if(rs.next())
{
tranId = checkNull(rs.getString("TRAN_ID"));
tranDateD = rs.getDate("TRAN_DATE");
siteCode = checkNull(rs.getString("SITE_CODE"));
confirmed = checkNull(rs.getString("CONFIRMED"));
remarks = checkNull(rs.getString("REMARKS"));
empCodeUser = checkNull(rs.getString("EMP_CODE__USER"));
valueXmlString.append("<Detail1 domID='1' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\" pkNames=\"\" />\r\n");
valueXmlString.append( "<tran_id><![CDATA[" ).append( tranId ).append( "]]></tran_id>\r\n" );
valueXmlString.append( "<tran_date><![CDATA[" ).append( sdf.format(tranDateD).toString() ).append( "]]></tran_date>\r\n" );
valueXmlString.append( "<site_code><![CDATA[" ).append( siteCode ).append( "]]></site_code>\r\n" );
siteCodeDescr=checkNull(getColumnDescr(conn, "descr", "site", "site_code", siteCode));
valueXmlString.append( "<site_descr><![CDATA[" ).append( siteCodeDescr ).append( "]]></site_descr>\r\n" );
valueXmlString.append( "<confirmed><![CDATA[" ).append( confirmed ).append( "]]></confirmed>\r\n" );
valueXmlString.append( "<remarks><![CDATA[" ).append( remarks ).append( "]]></remarks>\r\n" );
valueXmlString.append( "<emp_code__user><![CDATA[" ).append( empCodeUser ).append( "]]></emp_code__user>\r\n" );
valueXmlString.append( "<chg_user><![CDATA[" ).append( chgUser ).append( "]]></chg_user>\r\n" );
valueXmlString.append( "<chg_date><![CDATA[" ).append( currDate ).append( "]]></chg_date>\r\n" );
valueXmlString.append( "<chg_term><![CDATA[" ).append( chgTerm ).append( "]]></chg_term>\r\n" );
}
else
{
valueXmlString.append("<Detail1 domID='1' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
valueXmlString.append( "<tran_id><![CDATA[" ).append( "" ).append( "]]></tran_id>\r\n" );
valueXmlString.append( "<tran_date><![CDATA[" ).append( currDate ).append( "]]></tran_date>\r\n" );
valueXmlString.append( "<site_code><![CDATA[" ).append( loginSite ).append( "]]></site_code>\r\n" );
siteCodeDescr=checkNull(getColumnDescr(conn, "descr", "site", "site_code", loginSite));
valueXmlString.append( "<site_descr><![CDATA[" ).append( siteCodeDescr ).append( "]]></site_descr>\r\n" );
valueXmlString.append( "<status><![CDATA[" ).append( "O" ).append( "]]></status>\r\n" );
valueXmlString.append( "<status_date><![CDATA[" ).append( currDate ).append( "]]></status_date>\r\n" );
valueXmlString.append( "<confirmed><![CDATA[" ).append( "N" ).append( "]]></confirmed>\r\n" );
valueXmlString.append( "<remarks><![CDATA[" ).append( " " ).append( "]]></remarks>\r\n" );
valueXmlString.append( "<emp_code__user><![CDATA[" ).append( loginEmpCode ).append( "]]></emp_code__user>\r\n" );
valueXmlString.append( "<chg_user><![CDATA[" ).append( chgUser ).append( "]]></chg_user>\r\n" );
valueXmlString.append( "<chg_date><![CDATA[" ).append( currDate ).append( "]]></chg_date>\r\n" );
valueXmlString.append( "<chg_term><![CDATA[" ).append( chgTerm ).append( "]]></chg_term>\r\n" );
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
valueXmlString.append("</Detail1>\r\n");
} //Case 1. End
break;
case 2:
{
System.out.println("inside case 2 itemchange");
//valueXmlString.append( "<Detail2 domID='1'>\r\n" );
tranId = checkNull(genericUtility.getColumnValue( "tran_id", hdrDataDom ));
System.out.println("Tran_id123@----------->>["+tranId+"]");
System.out.println("hdrDataDom------->>["+genericUtility.serializeDom(hdrDataDom)+"]");
System.out.println("currFormDataDom------>>["+genericUtility.serializeDom(currFormDataDom)+"]");
System.out.println("allFormDataDom------>>["+genericUtility.serializeDom(allFormDataDom)+"]");
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
{
String lineNoStr = "";
System.out.println("in itm_default@@@@@.........."+tranId);
if(tranId.length() > 0)
{
sql = "SELECT LINE_NO,WAVE_ID,SALE_ORDER,PTCN FROM "
+ "MULTI_PICK_ISS_HDR WHERE TRAN_ID = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
lineNoStr = checkNull(rs.getString("LINE_NO"));
waveId = checkNull(rs.getString("WAVE_ID"));
saleOrder = checkNull(rs.getString("SALE_ORDER"));
ptcnL = checkNull(rs.getString("PTCN"));
valueXmlString.append("<Detail2 domID='1' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\" pkNames=\"\" />\r\n");
valueXmlString.append( "<tran_id><![CDATA[" ).append( tranId ).append( "]]></tran_id>\r\n" );
valueXmlString.append( "<line_no><![CDATA[" ).append( lineNoStr ).append( "]]></line_no>\r\n" );
valueXmlString.append( "<ptcn><![CDATA[" ).append( ptcnL ).append( "]]></ptcn>\r\n" );
valueXmlString.append( "<sale_order><![CDATA[" ).append( saleOrder ).append( "]]></sale_order>\r\n" );
valueXmlString.append( "<wave_id><![CDATA[" ).append( waveId ).append( "]]></wave_id>\r\n" );
valueXmlString.append("</Detail2>\r\n");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
//System.out.println("in else$$$$$$..............");
valueXmlString.append("<Detail2 domID='1' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
/*valueXmlString.append( "<tran_id><![CDATA[" ).append( tranId ).append( "]]></tran_id>\r\n" );
valueXmlString.append( "<line_no><![CDATA[" ).append( lineNo ).append( "]]></line_no>\r\n" );
valueXmlString.append( "<ptcn><![CDATA[" ).append( ptcnL ).append( "]]></ptcn>\r\n" );
valueXmlString.append( "<sale_order><![CDATA[" ).append( saleOrder ).append( "]]></sale_order>\r\n" );
valueXmlString.append( "<wave_id><![CDATA[" ).append( waveId ).append( "]]></wave_id>\r\n" );*/
valueXmlString.append("</Detail2>\r\n");
}
sql = "";
}
if( currentColumn.trim().equalsIgnoreCase( "ptcn" ) )
{
int lineNoL = 0 ;
String ptcn = checkNull(genericUtility.getColumnValue( "ptcn", allFormDataDom ));
tranId = checkNull(genericUtility.getColumnValue( "tran_id", hdrDataDom ));
System.out.println("in ptcn item change.............. : "+ptcn+" ["+tranId+"]");
sql = "SELECT WAVE_ID,REF_ID,STATUS,SALE_ORDER FROM WAVE_TASK_DET WHERE PTCN = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ptcn);
rs = pstmt.executeQuery();
if(rs.next())
{
waveId = checkNull(rs.getString("WAVE_ID"));
refId = checkNull(rs.getString("REF_ID"));
status = checkNull(rs.getString("STATUS"));
saleOrder = checkNull(rs.getString("SALE_ORDER"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(tranId.length() > 0)
{
int lineNoMax = getMaxLineNo(tranId,conn);
String sale_order = checkNull(genericUtility.getColumnValue( "sale_order", allFormDataDom ));
String wave_id = checkNull(genericUtility.getColumnValue( "wave_id", allFormDataDom ));
String line_no = checkNull(genericUtility.getColumnValue( "line_no", allFormDataDom ));
System.out.println("sale_order----->>"+sale_order);
System.out.println("wave_id----->>"+wave_id);
System.out.println("line_no----->>"+line_no);
valueXmlString.append("<Detail2 domID='"+lineNoMax+"' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
valueXmlString.append( "<tran_id><![CDATA[" ).append( tranId ).append( "]]></tran_id>\r\n" );
valueXmlString.append( "<line_no><![CDATA[" ).append( lineNoMax ).append( "]]></line_no>\r\n" );
valueXmlString.append( "<ptcn><![CDATA[" ).append(ptcn ).append( "]]></ptcn>\r\n" );
valueXmlString.append( "<sale_order><![CDATA[" ).append( saleOrder).append( "]]></sale_order>\r\n" );
valueXmlString.append( "<wave_id><![CDATA[" ).append( waveId).append( "]]></wave_id>\r\n" );
valueXmlString.append("</Detail2>\r\n");
}
else
{
lineNoL = getLineNo(allFormDataDom);
System.out.println("lineNoLlineNoL----->>"+lineNoL);
valueXmlString.append("<Detail2 domID='"+lineNoL+"' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
valueXmlString.append( "<tran_id><![CDATA[" ).append( tranId ).append( "]]></tran_id>\r\n" );
//valueXmlString.append( "<line_no><![CDATA[" ).append( lineNoL ).append( "]]></line_no>\r\n" );
valueXmlString.append( "<ptcn><![CDATA[" ).append(ptcn ).append( "]]></ptcn>\r\n" );
valueXmlString.append( "<sale_order><![CDATA[" ).append( saleOrder).append( "]]></sale_order>\r\n" );
valueXmlString.append( "<wave_id><![CDATA[" ).append( waveId).append( "]]></wave_id>\r\n" );
valueXmlString.append("</Detail2>\r\n");
}
}
if( currentColumn.trim().equalsIgnoreCase( "itm_default_add" ) )
{
System.out.println("itm_default_add item change22@@..............");
tranId = checkNull(genericUtility.getColumnValue( "tran_id", hdrDataDom ));
int lineNoL = 0, lineNoMax = 0 ;
if(tranId.length() > 0)
{
lineNoMax = getMaxLineNo(tranId,conn);
valueXmlString.append("<Detail2 domID='"+lineNoMax+"' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
valueXmlString.append( "<tran_id><![CDATA[" ).append( tranId ).append( "]]></tran_id>\r\n" );
valueXmlString.append( "<line_no><![CDATA[" ).append( lineNoMax ).append( "]]></line_no>\r\n" );
valueXmlString.append("</Detail2>\r\n");
}
else
{
lineNoMax = getLineNo(allFormDataDom);
System.out.println("lineNoMax----->>"+lineNoMax);
valueXmlString.append("<Detail2 domID='"+lineNoMax+"' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
//valueXmlString.append( "<tran_id><![CDATA[" ).append( tranId ).append( "]]></tran_id>\r\n" );
//valueXmlString.append( "<line_no><![CDATA[" ).append( lineNoMax ).append( "]]></line_no>\r\n" );
valueXmlString.append("</Detail2>\r\n");
}
}
} //Case 2. End
break;
case 3://Case 3. Start
{
System.out.println("item change form 3........");
ArrayList<String> ptcnList = null;
String pickOrder = "" ,saleOrderL = "",itemCode = "" ,locCode = "" ,lotNo = "" ,lotSl = "",subSql = "",
ptcnNo = "" ,mark = "",cartonNo = "",itemDescr = "",outerCartenNo = "",sorderLine = "";
int noArt = 0,count = 0,domId = 0 ;
double quantity = 0,deAllQuantity = 0;
tranId = checkNull(genericUtility.getColumnValue( "tran_id", hdrDataDom ));
String qty = checkNull(genericUtility.getColumnValue( "quantity", allFormDataDom ));
String qty1 = checkNull(genericUtility.getColumnValue( "quantity", currFormDataDom ));
System.out.println("allFormDataDom qty........:"+qty);
System.out.println("currFormDataDom qty1........:"+qty1);
System.out.println("hdrDataDom------->>["+genericUtility.serializeDom(hdrDataDom)+"]");
System.out.println("currFormDataDom------>>["+genericUtility.serializeDom(currFormDataDom)+"]");
System.out.println("allFormDataDom------>>["+genericUtility.serializeDom(allFormDataDom)+"]");
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
{
System.out.println("item change form 3........itm_default");
ptcnList = getPtcnNo("ptcn", allFormDataDom, "2");
System.out.println("ptcnList@----->"+ptcnList);
for(int i=0 ;i < ptcnList.size();i++)
{
subSql = subSql + ","+ptcnList.get(i);
}
subSql = subSql.substring(1,subSql.length()) ;
System.out.println("@@@ sql in @@@ :["+subSql+"]");
StringBuffer sqlBuf = new StringBuffer();
sqlBuf.append("SELECT PODET.SALE_ORDER,PODET.LINE_NO__SORD,PODET.PICK_ORDER,PODET.LINE_NO,PODET.ITEM_CODE,PODET.SITE_CODE,PODET.LOC_CODE,PODET.LOT_NO, "
+ "PODET.LOT_SL, PODET.NO_ART, (PODET.QUANTITY - (CASE WHEN PODET.DEALLOC_QTY IS NULL THEN 0 ELSE PODET.DEALLOC_QTY END )) AS "
+ "QUANTITY ,PODET.CARTON_NO, PODET.DEALLOC_QTY,PODET.PACK_CODE, ITEM.DESCR ITEM_DESCR, ITEM.UNIT UNIT, LOC_CODE__TO "
+ "FROM PICK_ORD_DET PODET, ITEM ITEM WHERE PODET.PICK_ORDER IN "
+ "(SELECT REF_ID FROM WAVE_TASK_DET WHERE PTCN IN (");
for (int i= 0;i < ptcnList.size();i++)
{
mark = mark + "?,";
}
mark = mark.substring(0,mark.length() - 1);
sqlBuf.append(mark);
sqlBuf.append( ") AND REF_SER IN ('A-PICK','C-PICK','M-PICK')) "
+ "AND PODET.ITEM_CODE = ITEM.ITEM_CODE AND (PODET.QUANTITY - (CASE WHEN PODET.DEALLOC_QTY IS NULL THEN 0 ELSE PODET.DEALLOC_QTY END )) > 0 "
+ "ORDER BY PODET.LOC_CODE, PODET.ITEM_CODE");
System.out.println("sqlBuf : "+sqlBuf.toString());
pstmt = conn.prepareStatement(sqlBuf.toString());
for (int i= 0;i < ptcnList.size();i++)
{
pstmt.setString(i+1, ptcnList.get(i));
}
rs =pstmt.executeQuery();
if(tranId.length() > 0)
{
while(rs.next())
{
domId++;
saleOrderL = checkNull(rs.getString("SALE_ORDER"));
pickOrder = checkNull(rs.getString("PICK_ORDER"));
lineNo = rs.getInt("LINE_NO");
itemCode = checkNull(rs.getString("ITEM_CODE"));
siteCode = checkNull(rs.getString("SITE_CODE"));
locCode = checkNull(rs.getString("LOC_CODE"));
lotNo = rs.getString("LOT_NO");
lotSl = rs.getString("LOT_SL");
noArt = rs.getInt("NO_ART");
quantity = rs.getDouble("QUANTITY");
cartonNo = checkNull(rs.getString("CARTON_NO"));
deAllQuantity = rs.getDouble("DEALLOC_QTY");
sorderLine = checkNull(rs.getString("LINE_NO__SORD"));
if(ptcnList !=null && ptcnList.size() > 0)
{
ptcnNo = ptcnList.get(count);
}
count++;
valueXmlString.append("<Detail3 domID='"+domId+"' selected=\"N\">\r\n");
//valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\" pkNames=\"\" />\r\n");
valueXmlString.append( "<tran_id><![CDATA[" ).append( "").append( "]]></tran_id>\r\n" );
valueXmlString.append( "<line_no><![CDATA[" ).append( lineNo).append( "]]></line_no>\r\n" );
/*valueXmlString.append( "<site_code><![CDATA[" ).append( siteCode).append( "]]></site_code>\r\n" );
siteCodeDescr = checkNull(getColumnDescr(conn, "descr", "site", "site_code", siteCode));
valueXmlString.append( "<site_descr><![CDATA[" ).append( siteCodeDescr).append( "]]></site_descr>\r\n" );
valueXmlString.append( "<ptcn><![CDATA[" ).append(ptcnNo ).append( "]]></ptcn>\r\n" );
valueXmlString.append( "<pick_order><![CDATA[" ).append( pickOrder).append( "]]></pick_order>\r\n" );
valueXmlString.append( "<sale_order><![CDATA[" ).append( saleOrderL).append( "]]></sale_order>\r\n" );
valueXmlString.append( "<line_no__sord><![CDATA[" ).append( sorderLine).append( "]]></line_no__sord>\r\n" );
valueXmlString.append( "<item_code><![CDATA[" ).append( itemCode).append( "]]></item_code>\r\n" );
itemDescr = checkNull(getColumnDescr(conn, "descr", "item", "item_code", itemCode));
valueXmlString.append( "<item_descr><![CDATA[" ).append( itemDescr).append( "]]></item_descr>\r\n" );
valueXmlString.append( "<lot_no><![CDATA[" ).append( lotNo).append( "]]></lot_no>\r\n" );
valueXmlString.append( "<lot_sl><![CDATA[" ).append( lotSl).append( "]]></lot_sl>\r\n" );
valueXmlString.append( "<quantity><![CDATA[" ).append( quantity).append( "]]></quantity>\r\n" );
valueXmlString.append( "<loc_code><![CDATA[" ).append( locCode).append( "]]></loc_code>\r\n" );*/
valueXmlString.append( "<site_code><![CDATA[" ).append( siteCode).append( "]]></site_code>\r\n" );
siteCodeDescr = checkNull(getColumnDescr(conn, "descr", "site", "site_code", siteCode));
valueXmlString.append( "<site_descr><![CDATA[" ).append( siteCodeDescr).append( "]]></site_descr>\r\n" );
valueXmlString.append( "<ptcn><![CDATA[" ).append(ptcnNo ).append( "]]></ptcn>\r\n" );
valueXmlString.append( "<pick_order><![CDATA[" ).append( pickOrder).append( "]]></pick_order>\r\n" );
valueXmlString.append( "<sale_order><![CDATA[" ).append( saleOrderL).append( "]]></sale_order>\r\n" );
valueXmlString.append( "<item_code><![CDATA[" ).append( itemCode).append( "]]></item_code>\r\n" );
itemDescr = checkNull(getColumnDescr(conn, "descr", "item", "item_code", itemCode));
valueXmlString.append( "<item_descr><![CDATA[" ).append( itemDescr).append( "]]></item_descr>\r\n" );
valueXmlString.append( "<lot_no><![CDATA[" ).append( lotNo).append( "]]></lot_no>\r\n" );
valueXmlString.append( "<lot_sl><![CDATA[" ).append( lotSl).append( "]]></lot_sl>\r\n" );
valueXmlString.append( "<quantity><![CDATA[" ).append( quantity).append( "]]></quantity>\r\n" );
valueXmlString.append( "<loc_code><![CDATA[" ).append( locCode).append( "]]></loc_code>\r\n" );
valueXmlString.append( "<no_art><![CDATA[" ).append( noArt == 0 ? "" : noArt).append( "]]></no_art>\r\n" );
valueXmlString.append( "<line_no__sord><![CDATA[" ).append( sorderLine).append( "]]></line_no__sord>\r\n" );
valueXmlString.append( "<carton_no><![CDATA[" ).append( cartonNo).append( "]]></carton_no>\r\n" );
valueXmlString.append( "<dealloc_qty><![CDATA[" ).append( deAllQuantity).append( "]]></dealloc_qty>\r\n" );
if(cartonNo.length() > 0)
{
outerCartenNo = checkNull(getColumnDescr(conn, "master_carton", "carton_master", "carton_no", cartonNo));
valueXmlString.append( "<outer_carton_no><![CDATA[" ).append( outerCartenNo).append( "]]></outer_carton_no>\r\n" );
}
valueXmlString.append("</Detail3>\r\n");
}
}
else
{
while(rs.next())
{
domId++;
saleOrderL = checkNull(rs.getString("SALE_ORDER"));
pickOrder = checkNull(rs.getString("PICK_ORDER"));
lineNo = rs.getInt("LINE_NO");
itemCode = checkNull(rs.getString("ITEM_CODE"));
siteCode = checkNull(rs.getString("SITE_CODE"));
locCode = checkNull(rs.getString("LOC_CODE"));
lotNo = rs.getString("LOT_NO");
lotSl = rs.getString("LOT_SL");
noArt = rs.getInt("NO_ART");
quantity = rs.getDouble("QUANTITY");
cartonNo = checkNull(rs.getString("CARTON_NO"));
deAllQuantity = rs.getDouble("DEALLOC_QTY");
sorderLine = checkNull(rs.getString("LINE_NO__SORD"));
if(ptcnList !=null && ptcnList.size() > 0)
{
ptcnNo = ptcnList.get(count);
}
count++;
valueXmlString.append("<Detail3 domID='"+domId+"' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
valueXmlString.append( "<tran_id><![CDATA[" ).append( "").append( "]]></tran_id>\r\n" );
valueXmlString.append( "<line_no><![CDATA[" ).append( lineNo).append( "]]></line_no>\r\n" );
valueXmlString.append( "<site_code><![CDATA[" ).append( siteCode).append( "]]></site_code>\r\n" );
siteCodeDescr = checkNull(getColumnDescr(conn, "descr", "site", "site_code", siteCode));
valueXmlString.append( "<site_descr><![CDATA[" ).append( siteCodeDescr).append( "]]></site_descr>\r\n" );
valueXmlString.append( "<ptcn><![CDATA[" ).append(ptcnNo ).append( "]]></ptcn>\r\n" );
valueXmlString.append( "<pick_order><![CDATA[" ).append( pickOrder).append( "]]></pick_order>\r\n" );
valueXmlString.append( "<sale_order><![CDATA[" ).append( saleOrderL).append( "]]></sale_order>\r\n" );
valueXmlString.append( "<item_code><![CDATA[" ).append( itemCode).append( "]]></item_code>\r\n" );
itemDescr = checkNull(getColumnDescr(conn, "descr", "item", "item_code", itemCode));
valueXmlString.append( "<item_descr><![CDATA[" ).append( itemDescr).append( "]]></item_descr>\r\n" );
valueXmlString.append( "<lot_no><![CDATA[" ).append( lotNo).append( "]]></lot_no>\r\n" );
valueXmlString.append( "<lot_sl><![CDATA[" ).append( lotSl).append( "]]></lot_sl>\r\n" );
valueXmlString.append( "<quantity><![CDATA[" ).append( quantity).append( "]]></quantity>\r\n" );
valueXmlString.append( "<loc_code><![CDATA[" ).append( locCode).append( "]]></loc_code>\r\n" );
valueXmlString.append( "<no_art><![CDATA[" ).append( noArt == 0 ? "" : noArt).append( "]]></no_art>\r\n" );
valueXmlString.append( "<line_no__sord><![CDATA[" ).append( sorderLine).append( "]]></line_no__sord>\r\n" );
valueXmlString.append( "<carton_no><![CDATA[" ).append( cartonNo).append( "]]></carton_no>\r\n" );
valueXmlString.append( "<dealloc_qty><![CDATA[" ).append( deAllQuantity).append( "]]></dealloc_qty>\r\n" );
if(cartonNo.length() > 0)
{
outerCartenNo = checkNull(getColumnDescr(conn, "master_carton", "carton_master", "carton_no", cartonNo));
valueXmlString.append( "<outer_carton_no><![CDATA[" ).append( outerCartenNo).append( "]]></outer_carton_no>\r\n" );
}
valueXmlString.append("</Detail3>\r\n");
}
}
}
if( currentColumn.trim().equalsIgnoreCase( "itm_default_add" ) )
{
System.out.println("item change form 3........itm_default_add");
valueXmlString.append("<Detail3 domID='1' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
valueXmlString.append( "<tran_id><![CDATA[" ).append( "").append( "]]></tran_id>\r\n" );
valueXmlString.append( "<line_no><![CDATA[" ).append( "").append( "]]></line_no>\r\n" );
valueXmlString.append( "<site_code><![CDATA[" ).append( "").append( "]]></site_code>\r\n" );
valueXmlString.append( "<ptcn><![CDATA[" ).append( "").append( "]]></ptcn>\r\n" );
valueXmlString.append( "<pick_order><![CDATA[" ).append( "").append( "]]></pick_order>\r\n" );
valueXmlString.append( "<item_code><![CDATA[" ).append( "").append( "]]></item_code>\r\n" );
valueXmlString.append( "<lot_no><![CDATA[" ).append( "").append( "]]></lot_no>\r\n" );
valueXmlString.append( "<lot_sl><![CDATA[" ).append( "").append( "]]></lot_sl>\r\n" );
valueXmlString.append( "<quantity><![CDATA[" ).append( "").append( "]]></quantity>\r\n" );
valueXmlString.append( "<loc_code><![CDATA[" ).append( "").append( "]]></loc_code>\r\n" );
valueXmlString.append("</Detail3>\r\n");
}
} //Case 3. End
break;
case 4:
{
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
{
}
}//Case 4. End
}//End of switch block
valueXmlString.append( "</Root>\r\n" );
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if ( conn != null )
{
conn.close();
conn = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println( "valueXmlString.toString()>>>>>>>::"+valueXmlString.toString());
return valueXmlString.toString();
}
/**
* The function checks whether the input string is null.
* If null, the function returns blank string.
* @param input
*/
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input.trim();
}
/**
* The function checks whether the input string is null.
* If null, the function returns blank string otherwise trim the input string and return.
* @param input
*/
private String checkNullAndTrim( String inputVal )
{
if ( inputVal == null )
{
inputVal = "";
}
else
{
inputVal = inputVal.trim();
}
return inputVal;
}
private int getLineNo(Document dom)
{
String lineNoStr = "";
int lineNo = 0;
try
{
/*DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(dom);*/
if(dom != null)
{
NodeList nList = dom.getElementsByTagName("Detail2");
//for (int i= 0; i< nList.getLength(); i++) {
Node nNode = nList.item(0);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
lineNoStr = checkNull(eElement.getAttribute("domID"));
System.out.println("getLineNo str domid: " + eElement.getAttribute("domID"));
}
System.out.println();
lineNoStr = lineNoStr.length() == 0 ? "0" : lineNoStr;
if(lineNoStr.length() > 0)
{
lineNo = Integer.parseInt(lineNoStr);
}
else
{
lineNo = 1;
}
}
else
{
System.out.println("dom is null...................");
}
}
catch(Exception e)
{
e.printStackTrace();
}
System.out.println("return from getLineNo ---->>["+lineNo+"]");
return lineNo;
}
private int getMaxLineNo(String tranId,Connection conn)
{
ResultSet rs = null;
PreparedStatement pstmt = null;
String sql = "";
int lineNo = 0;
try
{
sql ="SELECT MAX(LINE_NO) FROM MULTI_PICK_ISS_HDR WHERE TRAN_ID = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
lineNo = rs.getInt(1);
}
rs.close();
rs = null;
++lineNo;
}
catch(Exception e)
{
e.printStackTrace();
}
return lineNo;
}
public ArrayList<String> getPtcnNo(String colName, Document dom, String formNo)
{
ArrayList<String> colVal = new ArrayList<String>();
Node elementName = null, parentNode = null;
NodeList elementList = null;
Element elementAttr = null;
String columnName = "";
String columnValue = null;
boolean continueLoop = true;
boolean isFormNo = false;
int ctr;
try
{
elementList = dom.getElementsByTagName(colName);
if (Integer.parseInt(formNo) < 1)
{
isFormNo = true;
}
for(ctr = 0; ctr < elementList.getLength(); ctr++)
{
elementName = elementList.item(ctr);
parentNode = elementName.getParentNode();
elementAttr = (Element)parentNode;
if(elementAttr.getAttribute("objContext").equals(formNo) || elementAttr.getAttribute("formno").equals(formNo) || isFormNo)
{
columnName = elementName.getNodeName();
columnValue = "";
if(elementName.getFirstChild()!=null)
{
columnValue = elementName.getFirstChild().getNodeValue();
colVal.add(columnValue);
}
else
{
columnValue = null;
colVal.add(columnValue);
}
}
}
}
catch(Exception e)
{
System.out.println("Exception : [getPtcnNo(2)] :==>\n"+e.getMessage());
}
finally
{
elementName = null;
parentNode = null;
elementList = null;
elementAttr = null;
columnName = null;
}
return colVal;
}
private String getSiteCode( String xtraParams, Connection conn ) throws ITMException
{
String defaultSite = "";
String empSite = "";
String workSite = "";
String sql = "";
String loginCode = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
loginCode = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" ));
sql = "SELECT USERS.EMP_CODE, USERS.ENTITY_CODE, USERS.SITE_CODE__DEF, EMP.EMP_SITE, EMP.WORK_SITE "+
"FROM USERS USERS, EMPLOYEE EMP WHERE USERS.EMP_CODE = EMP.EMP_CODE AND USERS.CODE = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, loginCode );
rs = pstmt.executeQuery();
if( rs.next() )
{
defaultSite = checkNull(rs.getString("SITE_CODE__DEF"));
empSite = checkNull(rs.getString("EMP_SITE"));
workSite = checkNull(rs.getString("WORK_SITE"));
}
if ( defaultSite.trim().length() == 0 && empSite.trim().length() > 0 )
{
defaultSite = empSite;
}
rs.close();rs = null;
pstmt.close();pstmt = null;
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("defaultSite = ["+defaultSite+"]");
return defaultSite;
}
private int getDBRowCount(Connection conn, String table_name, String whrCondCol, String whrCondVal)
{
int count=0;
ResultSet rs=null;
PreparedStatement pstmt = null;
String sql="select count(1) from "+table_name+" where "+whrCondCol+" = ?";
System.out.println("SQL in getDBRowCount method : "+sql);
try{
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,whrCondVal);
rs = pstmt.executeQuery();
if(rs.next()){
count = rs.getInt(1);
}
if(pstmt!=null){
pstmt.close();
pstmt = null;
}
if(rs!=null){
rs.close();
rs = null;
}
}
catch(Exception ex){
System.out.println("Exception In getDBRowCount method of MultiplePtcnWiz Class : "+ex.getMessage());
ex.printStackTrace();
}
System.out.println("Return count from getDBRowCount ----->>["+count+"]");
return count;
}
private String getColumnDescr(Connection conn, String columnName ,String tableName, String columnName2, String value)
{
PreparedStatement pstmt = null ;
ResultSet rs = null ;
String sql = "";
String findValue = "";
try
{
sql = "SELECT " + columnName + " from " + tableName + " where " + columnName2 +"= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,value);
rs = pstmt.executeQuery();
if(rs.next())
{
findValue = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
System.out.println("Exception in getColumnDescr ");
e.printStackTrace();
}
System.out.println("returning String from getColumnDescr " + findValue);
return findValue;
}
}
\ No newline at end of file
package ibase.webitm.ejb.wms;
import ibase.webitm.utility.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.*;
import ibase.system.config.*;
import ibase.webitm.utility.ITMException;
import ibase.utility.CommonConstants;
import java.io.*;
import java.rmi.RemoteException;
import java.sql.*;
import java.util.*;
import java.text.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import javax.ejb.Stateless;
import org.w3c.dom.*;
@Stateless
public class MultiplePtcnWizConf extends ActionHandlerEJB implements MultiplePtcnWizConfLocal, MultiplePtcnWizConfRemote
{
boolean isError = false;
GenericUtility genericUtility = GenericUtility.getInstance();
String chgUser = "",chgTerm = "",empCode = "";
public String confirm(String tranID,String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
String retString = "";
boolean isConn= false;
Connection conn = null;
try
{
retString = confirm( tranID, xtraParams, forcedFlag, conn, isConn );
System.out.println("retString after confirmed------>>["+retString+"]");
if ( retString != null && retString.length() > 0 )
{
throw new Exception("Exception while calling confirm for tran Id:["+tranID+"] "+retString);
}
}
catch(Exception exception)
{
System.out.println("Exception in [MultiplePtcnWizConf] getCurrdateAppFormat " + exception.getMessage());
try {
throw new Exception("Exception while calling confirm for tran Id:["+tranID+"] "+retString);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return retString;
}
public String confirm( String tranId, String xtraParams,String forcedFlag, Connection conn, boolean connStatus ) throws Exception
{
System.out.println("@@@@@@@@ Call MultiplePtcnWizConf confirm Method @@@@@@@@");
ResultSet rs = null,rsStock = null,rs1 = null,rsSord = null;
PreparedStatement pstmt = null,pstmtStock = null,pstmt1 = null,pstmt2 = null,pstmtUpd = null,pstmtSord = null;
PreparedStatement pstmtUpdPickOrdDet =null;
String sql = "",errorString = "",confirmed = "";
String itemCode = "",siteCode = "",locCode = "",lotNo = "",lotSl = "",locCodeTo = "",saleOrder = "",
lineNoSord = "",replOrder = "",pickType = "",dExpLev = "",remarks = "",dimension = "";
String acctCodeDr = "",cctrCodeDr = "",packCode = "",siteCodeMfg = "",stagingLoc = "",
packInstr = "",suppCodeMfg = "",unitAlt = "",batchNo = "",unit = "",grade = "",
expLev = "",itemCodeOrd = "",itemRef = "",status = "",itemGrade = "",waveId = "",retString = "",
allocMode = "",reasCode = "",unitStd = "",sSQL = "",updateSql = "",ptcn = "",refSer = "";
int lineNoOrd= 0,lineNo= 0,updCnt = 0,rowsCount = 0;
double quantity = 0,noArt =0,stkGrossRate = 0,convQtyStduom = 0,batchSize = 0,holdQuantity = 0,stkRate = 0;
double shipperSize = 0, itemGrossWeight = 0, caseGrossWeight = 0, itemNetWeight = 0, caseNetWeight = 0,
qtyOrd = 0,sordAllocQty = 0;
isError = false;
boolean isUpdatehdr= false;
java.sql.Timestamp expDate = null,currDate = null, mfgDate = null,restestDate = null,dateAlloc = null;
HashMap updateRowMap = new HashMap();
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
DistCommon distCommon = new DistCommon();
StockUpdate stkUpdate = null;
InvAllocTraceBean invAllocTrace = null;
HashMap itmVolumeMap = new HashMap();
HashMap strAllocate = null;
HashMap <String,String>dataMap = new HashMap<String,String>();
try
{
currDate = new java.sql.Timestamp( System.currentTimeMillis() );
empCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginEmpCode" );
chgUser = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
chgTerm = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"));
String dbDateFormat = genericUtility.getDBDateFormat();
String applDateFormat = genericUtility.getApplDateFormat();
java.util.Date currDate1 = new java.util.Date();
SimpleDateFormat sdf = new SimpleDateFormat(applDateFormat);
String currDateStr = sdf.format(currDate1);
java.sql.Timestamp tranDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString( currDateStr , applDateFormat, dbDateFormat ) + " 00:00:00.0") ;
confirmed = checkNull(getColumnDescr(conn, "confirmed", "multi_pick_iss", "tran_id", tranId));
System.out.println("confirmed----->>["+confirmed+"]");
confirmed = confirmed.length() == 0 ? "N" :confirmed;
if("Y".equalsIgnoreCase(confirmed))
{
errorString = itmDBAccess.getErrorString("","PCKISSCONF","");
return errorString;
}
else
{
stagingLoc = checkNull(distCommon.getDisparams( "999999", "STAGING_LOC", conn)==null?"":distCommon.getDisparams( "999999", "STAGING_LOC", conn));
System.out.println("stagingLoc------>>["+stagingLoc+"]");
stkUpdate = new StockUpdate();
invAllocTrace = new InvAllocTraceBean();
sql = "select acct_code__inv, cctr_code__inv, "
+ "exp_date, pack_code, mfg_date, site_code__mfg, "
+ "pack_instr, supp_code__mfg, retest_date, rate, "
+ "gross_rate, conv__qty_stduom, unit__alt, batch_no, batch_size, unit, grade, remarks, "
+ "dimension ,hold_qty from stock "
+ "where item_code = ? "
+ "and site_code = ? "
+ "and loc_code = ? "
+ "and lot_no = ? "
+ "and lot_sl = ? ";
pstmtStock = conn.prepareStatement(sql);
sql = "SELECT H.WAVE_ID WAVE_ID,R.PTCN PTCN,R.TRAN_ID,R.LINE_NO LINE_NO, R.ITEM_CODE ITEM_CODE, R.SITE_CODE SITE_CODE, "
+ "R.LOC_CODE LOC_CODE, R.LOT_NO LOT_NO, R.LOT_SL LOT_SL, "
+ "(R.QUANTITY - (CASE WHEN R.DEALLOC_QTY IS NULL THEN 0 ELSE R.DEALLOC_QTY END )) AS QUANTITY,"
+ " R.NO_ART NO_ART,O.SALE_ORDER SALE_ORDER, O.LINE_NO__SORD LINE_NO__SORD, O.PICK_ORDER,H.PICK_TYPE,"
+ "O.EXP_LEV EXP_LEV "
+ " FROM MULTI_PICK_ISS_DET R, PICK_ORD_DET O ,PICK_ORD_HDR H WHERE R.TRAN_ID = ? "
+ " AND R.PICK_ORDER = O.PICK_ORDER AND H.PICK_ORDER = O.PICK_ORDER "
+ " AND O.LINE_NO = R.LINE_NO__SORD "
+ " AND (R.QUANTITY - (CASE WHEN R.DEALLOC_QTY IS NULL THEN 0 ELSE R.DEALLOC_QTY END )) > 0 ";
//+ " AND R.LOC_CODE <> R.LOC_CODE__TO";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
if(dataMap != null && dataMap.size() > 0)
{
System.out.println("dataMap clear..............");
dataMap.clear();
}
System.out.println("WHILE CONDITION.........."+(++rowsCount));
waveId = checkNull(rs.getString( "WAVE_ID" ));
ptcn = checkNull(rs.getString( "PTCN" ));
itemCode = rs.getString( "ITEM_CODE" );
siteCode = rs.getString( "SITE_CODE" );
locCode = rs.getString( "LOC_CODE" );
lotNo = rs.getString( "LOT_NO" );
lotSl = rs.getString( "LOT_SL" );
quantity = rs.getDouble( "QUANTITY" );
//noArt = rs.getDouble( "NO_ART" );
//locCodeTo = rs.getString( "loc_code__to" );
saleOrder = rs.getString( "SALE_ORDER" );
lineNoSord = rs.getString( "LINE_NO__SORD" );
lineNoSord = " " + lineNoSord;
lineNoSord = lineNoSord.substring(lineNoSord.length()-3);
replOrder = rs.getString( "PICK_ORDER" );
pickType = rs.getString( "PICK_TYPE" );
lineNoOrd = rs.getInt( "LINE_NO__SORD" );
dExpLev = checkNull(rs.getString( "EXP_LEV" ));
System.out.println("dExpLev->> ["+dExpLev+"]");
System.out.println("locCode->> ["+locCode+"]");
itmVolumeMap.clear();
itmVolumeMap = getItemVoumeMap(itemCode,lotNo,conn);
shipperSize = (Double) itmVolumeMap.get("SHIPPER_SIZE");
itemGrossWeight = (Double) itmVolumeMap.get("ITEM_GROSS_WEIGHT");
caseGrossWeight = (Double) itmVolumeMap.get("CASE_GROSS_WEIGHT");
itemNetWeight = (Double) itmVolumeMap.get("ITEM_NET_WEIGHT");
caseNetWeight = (Double) itmVolumeMap.get("CASE_NET_WEIGHT");
dataMap.put("wave_id", waveId);
dataMap.put("ptcn", ptcn);
dataMap.put("item_code", itemCode);
dataMap.put("site_code", siteCode);
dataMap.put("lot_no", lotNo);
dataMap.put("lot_sl", lotSl);
dataMap.put("quantity", ""+quantity);
dataMap.put("sale_order", saleOrder);
dataMap.put("line_no__sord", lineNoSord);
dataMap.put("line_no", ""+lineNo);
dataMap.put("pick_order", replOrder);
dataMap.put("pick_type", pickType);
dataMap.put("stag_loc", stagingLoc);
if(lotNo == null || lotNo.trim().length() == 0)
{
lotNo =" ";
}
if(lotSl == null || lotSl.trim().length()==0)
{
lotSl = " ";
}
lineNo = rs.getInt( "LINE_NO" );
pstmtStock.setString(1,itemCode);
pstmtStock.setString(2,siteCode);
pstmtStock.setString(3,locCode);
pstmtStock.setString(4,lotNo);
pstmtStock.setString(5,lotSl);
rsStock = pstmtStock.executeQuery();
if ( rsStock.next() )
{
acctCodeDr = rsStock.getString("acct_code__inv");
cctrCodeDr = rsStock.getString("cctr_code__inv");
expDate = rsStock.getTimestamp("exp_date");
packCode = rsStock.getString("pack_code");
mfgDate = rsStock.getTimestamp("mfg_date");
siteCodeMfg = rsStock.getString("site_code__mfg");
packInstr = rsStock.getString("pack_instr");
suppCodeMfg = rsStock.getString("supp_code__mfg");
restestDate = rsStock.getTimestamp("retest_date");
stkRate = rsStock.getDouble("rate");
stkGrossRate = rsStock.getDouble("gross_rate");
convQtyStduom = rsStock.getDouble("conv__qty_stduom");
unitAlt = rsStock.getString("unit__alt");
batchNo = rsStock.getString("batch_no");
batchSize = rsStock.getDouble("batch_size");
unit = rsStock.getString("unit");
grade = rsStock.getString("grade");
remarks = rsStock.getString("remarks");
dimension = rsStock.getString("dimension");
holdQuantity = rsStock.getDouble("hold_qty");
}
rsStock.close(); rsStock = null;
pstmtStock.clearParameters();
if(holdQuantity > 0)
{
errorString = getError(siteCode, lotNo, lotSl, itemCode, locCode, "INVITMQTST", conn);
return errorString;
}
updateRowMap.put("item_code", itemCode);
updateRowMap.put("site_code", siteCode);
updateRowMap.put("loc_code", locCode);
updateRowMap.put("lot_no", lotNo);
updateRowMap.put("lot_sl", lotSl);
updateRowMap.put("quantity", ""+quantity);
updateRowMap.put("no_art", noArt);
updateRowMap.put("tran_ser", "PICISS");
updateRowMap.put("acct_code__cr",acctCodeDr);
updateRowMap.put("cctr_code__cr",cctrCodeDr);
updateRowMap.put("acct_code_inv",acctCodeDr);
updateRowMap.put("cctr_code_inv",cctrCodeDr);
updateRowMap.put("rate",Double.toString(stkRate));
updateRowMap.put("gross_rate",Double.toString(stkGrossRate));
updateRowMap.put("tran_id", tranId );
// 17/10/11 manoharan
updateRowMap.put("line_no", "" + lineNo );
// end 17/10/11 manoharan
updateRowMap.put("tran_date", tranDate );
updateRowMap.put("tran_type","ID");
updateRowMap.put("qty_stduom", ""+quantity);
updateRowMap.put("unit",unit);
updateRowMap.put("grade",grade);
updateRowMap.put("remarks",remarks);
updateRowMap.put("dimension",dimension);
updateRowMap.put("exp_date", expDate);
updateRowMap.put("pack_code", packCode);
updateRowMap.put("mfg_date", mfgDate);
updateRowMap.put("site_code__mfg", siteCodeMfg);
updateRowMap.put("pack_instr", packInstr);
updateRowMap.put("supp_code__mfg", suppCodeMfg);
updateRowMap.put("retest_date", restestDate);
updateRowMap.put("conv__qty_stduom", ""+convQtyStduom);
updateRowMap.put("unit__alt", unitAlt);
updateRowMap.put("batch_no", batchNo);
updateRowMap.put("batch_size", ""+batchSize);
System.out.println("quantity---->>["+quantity+" shipperSize--->>["+shipperSize+"]");
if(quantity < shipperSize || shipperSize == 0)
{
noArt = 1;
}
else
{
noArt = Math.floor((quantity) / shipperSize) ;
}
dataMap.put("no_art", ""+noArt);
updateRowMap.put("no_art", noArt);
updateRowMap.put("gross_weight", caseGrossWeight * noArt);
updateRowMap.put("net_weight", caseNetWeight * noArt);
updateRowMap.put("tare_weight", (caseGrossWeight - caseNetWeight) * noArt);
System.out.println("errorString BEFORE updateStock1----->["+errorString+"]");
errorString = stkUpdate.updateStock( updateRowMap, xtraParams, conn );
System.out.println("errorString after updateStock1----->["+errorString+"]");
if ( errorString != null && errorString.trim().length() > 0 )
{
isError = true;
break;
}
updateRowMap.put("loc_code", stagingLoc);
updateRowMap.put("tran_type", "R");//Creating receipt
System.out.println("errorString BEFORE updateStock2..........");
errorString = stkUpdate.updateStock( updateRowMap, xtraParams, conn );
System.out.println("errorString after updateStock2----->["+errorString+"]");
if ( errorString != null && errorString.trim().length() > 0 )
{
isError = true;
break;
}
updateRowMap.clear();
strAllocate = new HashMap();
strAllocate.put("tran_date",tranDate);
strAllocate.put("ref_ser","M-PTCN");
strAllocate.put("ref_id",tranId);
strAllocate.put("ref_line", "" + lineNo);
strAllocate.put("site_code",siteCode);
strAllocate.put("item_code",itemCode);
strAllocate.put("loc_code", stagingLoc);
strAllocate.put("lot_no",lotNo);
strAllocate.put("lot_sl",lotSl);
strAllocate.put("alloc_qty",new Double(quantity));
strAllocate.put("chg_user",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginCode"));
strAllocate.put("chg_term",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"termId"));
strAllocate.put("chg_win","w_multi_pick_iss");
errorString = invAllocTrace.updateInvallocTrace(strAllocate, conn);
System.out.println("errorString after updateInvallocTrace----->["+errorString+"]");
// To check the sordalloc allocated quantity > quantity then insert new record deducte quantity from old location.
sql = " SELECT EXP_LEV, ITEM_CODE__ORD, "
+ " ITEM_REF, UNIT, DATE_ALLOC, STATUS, ITEM_GRADE, EXP_DATE, ALLOC_MODE, SITE_CODE, "
+ " CONV__QTY_STDUOM, UNIT__STD, MFG_DATE, SITE_CODE__MFG, REAS_CODE,QUANTITY,QTY_ALLOC FROM SORDALLOC "
+ " WHERE SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? "
+ " AND QTY_ALLOC > 0";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, saleOrder);
pstmt1.setString(2, lineNoSord);
pstmt1.setString(3, itemCode);
pstmt1.setString(4, locCode);
pstmt1.setString(5, lotNo);
pstmt1.setString(6, lotSl);
rs1 = pstmt1.executeQuery();
if( rs1.next())
{
System.out.println("Inside the Query the Exp level["+expLev+"]");
expLev = rs1.getString( "EXP_LEV" );
System.out.println("Inside the Query the Exp level["+expLev+"]");
if (expLev == null || expLev.trim().length() == 0)
{
expLev = dExpLev;
}
if (expLev == null || expLev.trim().length() == 0)
{
expLev = " ";
}
itemCodeOrd = rs1.getString( "ITEM_CODE__ORD" );
itemRef = rs1.getString( "ITEM_REF" );
unit = rs1.getString( "UNIT" );
status = rs1.getString( "STATUS" );
itemGrade = rs1.getString( "ITEM_GRADE" );
allocMode = rs1.getString( "ALLOC_MODE" );
siteCode = rs1.getString( "SITE_CODE" );
siteCodeMfg = rs1.getString( "SITE_CODE__MFG" );
reasCode = rs1.getString( "REAS_CODE" );
unitStd = rs1.getString( "UNIT__STD" );
convQtyStduom = rs1.getDouble( "CONV__QTY_STDUOM" );
dateAlloc = rs1.getTimestamp("DATE_ALLOC");
expDate = rs1.getTimestamp("EXP_DATE");
mfgDate = rs1.getTimestamp("MFG_DATE");
qtyOrd = rs1.getDouble( "QUANTITY" );
sordAllocQty = rs1.getDouble( "QTY_ALLOC" );
}
else
{
isError = true;
errorString = itmDBAccess.getErrorString("","RECNOTSORA","");
return errorString;
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
sSQL = "SELECT COUNT(*) AS COUNT FROM SORDALLOC WHERE "
+ " SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? ";
int count = 0;
System.out.println("sordAllocQty---->>["+sordAllocQty+" quantity--->["+quantity+"]");
if(sordAllocQty > quantity)
{
System.out.println("sordAllocQty in greater.................");
updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC - ? ,QUANTITY__STDUOM = QUANTITY__STDUOM - ?, WAVE_FLAG = 'Y' "
+ " WHERE SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? "
+ " AND QTY_ALLOC > 0";
pstmtUpd = conn.prepareStatement(updateSql);
pstmtUpd.setDouble(1, quantity);
//Changed by sumit on 10/09/13 setting
pstmtUpd.setDouble(2, quantity * convQtyStduom);
pstmtUpd.setString(3, saleOrder);
pstmtUpd.setString(4, lineNoSord);
pstmtUpd.setString(5, itemCode);
pstmtUpd.setString(6, locCode);
pstmtUpd.setString(7, lotNo);
pstmtUpd.setString(8, lotSl);
updCnt = pstmtUpd.executeUpdate();
if(pstmtUpd !=null)
{
pstmtUpd.close();
pstmtUpd=null;
}
System.out.println(" sordalloc updated updCnt [" + updCnt + "]");
if (expLev == null || expLev.trim().length() == 0)
{
System.out.println("Check1l["+expLev+"]");
expLev = dExpLev;
}
System.out.println("Finally the Exp level["+expLev+"]");
pstmtSord = conn.prepareStatement(sSQL);
pstmtSord.setString(1, saleOrder);
pstmtSord.setString(2, lineNoSord);
pstmtSord.setString(3, itemCode);
pstmtSord.setString(4, stagingLoc);
pstmtSord.setString(5, lotNo);
pstmtSord.setString(6, lotSl);
rsSord = pstmtSord.executeQuery();
if(rsSord.next())
{
count = rsSord.getInt(1);
}
System.out.println("count SORDALLOC@@------>>["+count+"]");
if(count > 0)
{
System.out.println(" sordalloc If alrady exist Location Update Inside grater updCnt1st [" + updCnt + "]");
//updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC + ? ,QUANTITY__STDUOM = QUANTITY__STDUOM + ?"
updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC + ? ,QUANTITY__STDUOM = QUANTITY__STDUOM + ?, WAVE_FLAG = 'Y' "
+ " WHERE SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? "
+ " AND QTY_ALLOC > 0";
pstmtUpd = conn.prepareStatement(updateSql);
pstmtUpd.setDouble(1, quantity);
pstmtUpd.setDouble(2, quantity);
pstmtUpd.setString(3, saleOrder);
pstmtUpd.setString(4, lineNoSord);
pstmtUpd.setString(5, itemCode);
pstmtUpd.setString(6, stagingLoc);
pstmtUpd.setString(7, lotNo);
pstmtUpd.setString(8, lotSl);
updCnt = pstmtUpd.executeUpdate();
if(pstmtUpd !=null)
{
pstmtUpd.close();
pstmtUpd=null;
}
System.out.println(" sordalloc If alrady exist Location Update Inside grater updCnt2nd [" + updCnt + "]");
}
else
{
System.out.println("--------insert record in SORDALLOC table--------------");
updateSql = "INSERT INTO SORDALLOC( SALE_ORDER, LINE_NO, EXP_LEV, ITEM_CODE__ORD, "
+ " ITEM_CODE, LOT_NO, LOT_SL, LOC_CODE, ITEM_REF, QUANTITY, UNIT, "
+ " QTY_ALLOC, DATE_ALLOC, STATUS, ITEM_GRADE, EXP_DATE, ALLOC_MODE, SITE_CODE, "
+ " CONV__QTY_STDUOM, UNIT__STD, QUANTITY__STDUOM, MFG_DATE, SITE_CODE__MFG, "
+ " REAS_CODE, WAVE_FLAG ) "
+ " VALUES (?, ?, ?, ?, "
+ " ?, ?, ? , ?, ?, ?, ?, "
+ " ?,?, ?, ?, ?, ?, ?, "
+ " ?, ?, ? , ?, ?, ?, ? ) ";
pstmtUpd = conn.prepareStatement(updateSql);
pstmtUpd.setString(1, saleOrder);
pstmtUpd.setString(2, lineNoSord);
pstmtUpd.setString(3, expLev);
pstmtUpd.setString(4, itemCodeOrd);
pstmtUpd.setString(5, itemCode);
pstmtUpd.setString(6, lotNo);
pstmtUpd.setString(7, lotSl);
pstmtUpd.setString(8, stagingLoc);
pstmtUpd.setString(9, itemRef);
pstmtUpd.setDouble(10, qtyOrd);
pstmtUpd.setString(11, unit);
pstmtUpd.setDouble(12, quantity);
pstmtUpd.setTimestamp(13, dateAlloc);
pstmtUpd.setString(14, status);
pstmtUpd.setString(15, itemGrade);
pstmtUpd.setTimestamp(16, expDate);
pstmtUpd.setString(17, allocMode);
pstmtUpd.setString(18, siteCode);
pstmtUpd.setDouble(19, convQtyStduom );
pstmtUpd.setString(20, unitStd);
pstmtUpd.setDouble(21, quantity * convQtyStduom);
pstmtUpd.setTimestamp(22, mfgDate );
pstmtUpd.setString(23, siteCodeMfg);
pstmtUpd.setString(24, reasCode);
pstmtUpd.setString(25, "Y");
updCnt = pstmtUpd.executeUpdate();
System.out.println(" INSERT in sordalloc updCnt [" + updCnt + "]");
if(pstmtUpd != null)
{
pstmtUpd.close();
pstmtUpd=null;
}
}
}
else
{
System.out.println("sordAllocQty in lesser.................");
pstmtSord = conn.prepareStatement(sSQL);
pstmtSord.setString(1, saleOrder);
pstmtSord.setString(2, lineNoSord);
pstmtSord.setString(3, itemCode);
pstmtSord.setString(4, stagingLoc);
pstmtSord.setString(5, lotNo);
pstmtSord.setString(6, lotSl);
rsSord = pstmtSord.executeQuery();
if(rsSord.next())
{
count = rsSord.getInt(1);
}
System.out.println("count SORDALLOC--->>"+count);
if(count > 0)
{
//updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC - ? " //LOC_CODE = ? ,LOT_SL = ? "
updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC - ?, WAVE_FLAG = 'Y' "
+ " WHERE SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? "
+ " AND QTY_ALLOC > 0";
pstmtUpd = conn.prepareStatement(updateSql);
pstmtUpd.setDouble(1, quantity);
pstmtUpd.setString(2, saleOrder);
pstmtUpd.setString(3, lineNoSord);
pstmtUpd.setString(4, itemCode);
pstmtUpd.setString(5, locCode);
pstmtUpd.setString(6, lotNo);
pstmtUpd.setString(7, lotSl);
updCnt = pstmtUpd.executeUpdate();
System.out.println(" sordalloc If alrady exist Location Update updCnt1st [" + updCnt + "]");
if(pstmtUpd !=null)
{
pstmtUpd.close();
pstmtUpd=null;
}
//updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC + ? ,QUANTITY__STDUOM = QUANTITY__STDUOM + ?"
updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC + ? ,QUANTITY__STDUOM = QUANTITY__STDUOM + ?, WAVE_FLAG = 'Y' "
+ " WHERE SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? "
+ " AND QTY_ALLOC > 0";
pstmtUpd = conn.prepareStatement(updateSql);
pstmtUpd.setDouble(1, quantity);
pstmtUpd.setDouble(2, quantity);
pstmtUpd.setString(3, saleOrder);
pstmtUpd.setString(4, lineNoSord);
pstmtUpd.setString(5, itemCode);
pstmtUpd.setString(6, stagingLoc);
pstmtUpd.setString(7, lotNo);
pstmtUpd.setString(8, lotSl);
updCnt = pstmtUpd.executeUpdate();
System.out.println(" sordalloc If alrady exist Location Update updCnt2nd [" + updCnt + "]");
if(pstmtUpd != null)
{
pstmtUpd.close();
pstmtUpd=null;
}
}
else
{
//updateSql = "UPDATE SORDALLOC SET LOC_CODE = ? "
updateSql = "UPDATE SORDALLOC SET LOC_CODE = ?, WAVE_FLAG = 'Y' "
+ " WHERE SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? "
+ " AND QTY_ALLOC > 0";
pstmtUpd = conn.prepareStatement(updateSql);
pstmtUpd.setString(1, stagingLoc);
pstmtUpd.setString(2, saleOrder);
pstmtUpd.setString(3, lineNoSord);
pstmtUpd.setString(4, itemCode);
pstmtUpd.setString(5, locCode);
pstmtUpd.setString(6, lotNo);
pstmtUpd.setString(7, lotSl);
updCnt = pstmtUpd.executeUpdate();
if(pstmtUpd !=null)
{
pstmtUpd.close();
pstmtUpd=null;
}
}
System.out.println(" sordalloc Update updCnt [" + updCnt + "]");
}
if(rsSord != null)
{
rsSord.close();
rsSord=null;
}
if(pstmtSord != null)
{
pstmtSord.close();
pstmtSord=null;
}
String updatePickOrdSql = "UPDATE PICK_ORD_DET SET STATUS = ? "
+ " WHERE PICK_ORDER = ? AND LINE_NO = ? ";
pstmtUpdPickOrdDet = conn.prepareStatement(updatePickOrdSql);
pstmtUpdPickOrdDet.setString(1, "C");
pstmtUpdPickOrdDet.setString(2, replOrder);
pstmtUpdPickOrdDet.setInt(3, lineNoOrd);
int updCntPickOrdDet = pstmtUpdPickOrdDet.executeUpdate();
if(updCntPickOrdDet > 0)
{
isUpdatehdr = updatePickOrderHeader(replOrder,conn);
}
if(pstmtUpdPickOrdDet != null)
{
pstmtUpdPickOrdDet.close();
pstmtUpdPickOrdDet=null;
}
updatePickOrdSql = "UPDATE MULTI_PICK_ISS_DET SET LOC_CODE = ? "
+ " WHERE TRAN_ID = ? AND LINE_NO = ? ";
pstmtUpdPickOrdDet = conn.prepareStatement(updatePickOrdSql);
pstmtUpdPickOrdDet.setString(1, stagingLoc);
pstmtUpdPickOrdDet.setString(2, tranId);
pstmtUpdPickOrdDet.setInt(3, lineNo);
updCntPickOrdDet = pstmtUpdPickOrdDet.executeUpdate();
if(updCntPickOrdDet > 0)
{
isUpdatehdr = updatePickOrderHeader(replOrder,conn);
}
if(pstmtUpdPickOrdDet != null)
{
pstmtUpdPickOrdDet.close();
pstmtUpdPickOrdDet=null;
}
String str = insertPickIssHdrDet(dataMap, conn);
System.out.println("Return from insertPickIssHdrDet------->>["+str+"]");
str = insertPackHdrDet(dataMap,conn);
System.out.println("Return from insertPackHdrDet------->>["+str+"]");
if(isUpdatehdr)
{
sql = "SELECT REF_SER,PTCN FROM WAVE_TASK_DET WHERE REF_ID = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,replOrder);
rs = pstmt.executeQuery();
if( rs.next() )
{
refSer = rs.getString("ref_ser");
refSer = refSer == null?"":refSer;
ptcn = rs.getString("ptcn");
ptcn = ptcn == null?"":ptcn;
}
System.out.println(" ref_ser ["+refSer+"]");
rs.close();rs = null;
pstmt.close();pstmt = null;
if(!("A".equalsIgnoreCase(pickType)) && !"P-PICK".equalsIgnoreCase(refSer) && !"A-PICK".equalsIgnoreCase(refSer) )
{
//update wave_status of wave_task_det, same time of updating status 'Y'
updateSql = "UPDATE WAVE_TASK_DET SET STATUS = 'Y', WAVE_STATUS = 'V' WHERE REF_ID = ? ";
pstmt = conn.prepareStatement(updateSql);
pstmt.setString(1, replOrder);
updCnt = pstmt.executeUpdate();
if( updCnt > 0 )
{
System.out.println( updCnt + " rows updated successfully" );
}
pstmt.close();pstmt = null;
}
sql = " SELECT * FROM PICK_ORD_HDR WHERE PICK_ORDER = ? AND PICK_TYPE = 'M' ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, replOrder);
rs1 = pstmt1.executeQuery();
if( rs1.next())
{
updateSql = "UPDATE WAVE_TASK_DET SET WAVE_STATUS = 'C' WHERE REF_SER = 'M-PACK'" +
" AND WAVE_ID = ? AND SALE_ORDER = ? ";
pstmt2 = conn.prepareStatement(updateSql);
pstmt2.setString(1, rs1.getString("WAVE_ID"));
pstmt2.setString(2, rs1.getString("SALE_ORDER"));
updCnt = pstmt2.executeUpdate();
if( updCnt > 0 )
{
System.out.println( updCnt + " M-PACK rows updated successfully" );
}
pstmt2.close();pstmt2 = null;
}
rs1.close(); rs1 = null;
pstmt1.close(); pstmt1 = null;
updCnt= 0;
// Checking whether all task are done for particular wave_id and sale order
updCnt = waveStatusUpdate(replOrder, conn);
if( updCnt > 0)
{
System.out.println( updCnt + " row of wave_status updated successfully" );
}
sql = "UPDATE SORDER SET SHIP_STATUS = ? WHERE SALE_ORDER = ?";
pstmtSord = conn.prepareStatement(sql);
int updateSorder = 0;
pstmtSord.setString(1, "P");
pstmtSord.setString(2, saleOrder);
updateSorder = pstmtSord.executeUpdate();
if(updateSorder > 0)
{
System.out.println(" SORDER UPDATE COUNT ["+updateSorder+"]");
}
pstmtSord.clearParameters();
if(pstmtSord != null)
{
pstmtSord.close();
pstmtSord = null;
}
System.out.println("Header updated successfully");
ConsolidatToDoc conToDoc = new ConsolidatToDoc();
retString = conToDoc.process(ptcn, conn,xtraParams);
if (retString != null && retString.trim().length() > 0 )
{
isError = true;
return retString;
}
System.out.println("ret string :"+retString);
}
} //end while
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;//While close.
}
if(pstmtStock != null)
{
pstmtStock.close();
pstmtStock = null;
}
if (errorString != null && errorString.trim().length() > 0 )
{
isError = true;
return errorString;
}
updateSql = "UPDATE MULTI_PICK_ISS SET CONFIRMED = 'Y', CONF_DATE = ?, EMP_CODE__USER = ?"
+ " WHERE TRAN_ID = ? ";
pstmt = conn.prepareStatement(updateSql);
pstmt.setTimestamp(1, currDate);
pstmt.setString(2, empCode);
pstmt.setString(3, tranId);
updCnt = pstmt.executeUpdate();
if( updCnt > 0 )
{
System.out.println( updCnt + " MULTI_PICK_ISS rows updated successfully" );
}
pstmt.close();
pstmt = null;
}//end else of confirmed cndition
}
catch(Exception e)
{
isError = true;
e.printStackTrace();
throw new Exception (e);
}
return errorString;
}
private String insertPickIssHdrDet(HashMap<String,String>issueDataMap,Connection conn) throws Exception
{
System.out.println("insertPickIssHdrDet----------->>"+issueDataMap);
ResultSet rs = null;
PreparedStatement pstmt = null; //currDate
java.sql.Timestamp currDate = null;
String sql = "",keyString = "",keyCol = "",tranSer = "",xmlValues = "",siteCode = "",tranId = "",
currDateStr = "",cartonNo = "",packCode ="";
int count = 0 ;
try
{
if(issueDataMap != null && issueDataMap.size() > 0)
{
siteCode = checkNull(issueDataMap.get("site_code"));
SimpleDateFormat sdfAppl = new SimpleDateFormat(genericUtility.getApplDateFormat());
currDate = new java.sql.Timestamp(System.currentTimeMillis());
currDateStr = sdfAppl.format(currDate);
sql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
//System.out.println("selSql :"+selSql);
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, "w_active_pick" );
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
keyCol = rs.getString("TRAN_ID_COL");
tranSer = rs.getString("REF_SER");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer :"+tranSer);
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>" + currDateStr + "</tran_date>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer, keyCol, keyString, conn);
System.out.println("@@tranId@@ ---->>["+tranId+"]");
sql = "INSERT INTO PICK_ISS_HDR (TRAN_DATE,EMP_CODE__APRV,CHG_DATE,CONFIRMED,PICK_ORDER,CHG_TERM,"
+ "CHG_USER,TRAN_ID,PICK_TYPE,SITE_CODE,PTCN,CONF_DATE ) "
+ "values (?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, currDate);
pstmt.setString(2, empCode);
pstmt.setTimestamp(3, currDate);
pstmt.setString(4, "Y");
pstmt.setString(5, checkNull(issueDataMap.get("pick_order")));
pstmt.setString(6, chgTerm);
pstmt.setString(7, chgUser);
pstmt.setString(8, tranId);
pstmt.setString(9, checkNull(issueDataMap.get("pick_type")));
pstmt.setString(10, siteCode);
pstmt.setString(11, checkNull(issueDataMap.get("ptcn")));
pstmt.setTimestamp(12, currDate);
int rowIns = pstmt.executeUpdate();
if(rowIns > 0)
{
count++;
System.out.println("row insert in PICK_ISS_HDR table.................");
}
pstmt.close();
pstmt =null;
sql = " SELECT CARTON_NO,PACK_CODE FROM CARTON_MASTER WHERE PICK_ORDER = ?"
+ " AND LINE_NO__PICK = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, checkNull(issueDataMap.get("pick_order")));
pstmt.setString(2, checkNull(issueDataMap.get("line_no__sord")));
rs = pstmt.executeQuery();
if(rs.next())
{
cartonNo = checkNull(rs.getString("CARTON_NO"));
packCode = checkNull(rs.getString("PACK_CODE"));
}
rs.close();
rs = null;
pstmt.close();
pstmt =null;
sql = "INSERT INTO PICK_ISS_DET(LOC_CODE__SYS,CARTON_NO,LOT_SL,PICK_ORDER,PACK_CODE,QUANTITY,LOC_CODE__TO,"
+ "TRAN_ID,LINE_NO,SITE_CODE,NO_ART,LINE_NO__ORD,LOT_NO,ITEM_CODE,LOC_CODE) "
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, checkNull(issueDataMap.get("stag_loc")));
pstmt.setString(2, cartonNo);
pstmt.setString(3, issueDataMap.get("lot_sl"));
pstmt.setString(4, checkNull(issueDataMap.get("pick_order")));
pstmt.setString(5, packCode);
pstmt.setDouble(6, Double.parseDouble(checkNull(issueDataMap.get("quantity"))));
pstmt.setString(7, checkNull(issueDataMap.get("stag_loc")));
pstmt.setString(8, tranId);
pstmt.setString(9, checkNull(issueDataMap.get("line_no")));
pstmt.setString(10, siteCode);
pstmt.setString(11, checkNull(issueDataMap.get("no_art")));
pstmt.setString(12, issueDataMap.get("line_no__sord"));
pstmt.setString(13, issueDataMap.get("lot_no"));
pstmt.setString(14, checkNull(issueDataMap.get("item_code")));
pstmt.setString(15, checkNull(issueDataMap.get("stag_loc")));
rowIns = pstmt.executeUpdate();
if(rowIns > 0)
{
count++;
System.out.println("row insert in PICK_ISS_DET table.................");
}
if(count == 2 )
{
return "Success";
}
}
}
catch(Exception e)
{
throw e;
}
return "Error";
}
private String insertPackHdrDet(HashMap<String,String>packDataMap,Connection conn) throws Exception
{
System.out.println("insertPackHdrDet----------->>"+packDataMap);
ResultSet rs = null,rs1 = null;
PreparedStatement pstmt = null,pstmt1= null,pstmtIns =null; //currDate
java.sql.Timestamp currDate = null;
String sql = "",keyString = "",keyCol = "",tranSer = "",xmlValues = "",siteCode = "",tranId = "",
currDateStr = "",cartonNo = "",packCode ="",status = "",cartonType = "",pickOrder = "",ptcn = "",
masterCarton = "",updSql = "",sql1 = "",insSql;
double tareWgt = 0,fillerWgt = 0;
int count = 0,rowIns = 0,successCnt = 0 ;
try
{
siteCode = checkNull(packDataMap.get("site_code"));
SimpleDateFormat sdfAppl = new SimpleDateFormat(genericUtility.getApplDateFormat());
currDate = new java.sql.Timestamp(System.currentTimeMillis());
currDateStr = sdfAppl.format(currDate);
sql = "SELECT CARTON_NO,STATUS,PTCN,CARTON_TYPE,PICK_ORDER,PACK_CODE,MASTER_CARTON,TARE_WEIGHT,"
+ "FILLER_WEIGHT FROM CARTON_MASTER WHERE PTCN = ? AND CARTON_TYPE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, checkNull(packDataMap.get("ptcn")));
pstmt.setString(2, "M");
rs = pstmt.executeQuery();
while(rs.next())
{
cartonNo = checkNull(rs.getString("CARTON_NO"));
status = checkNull(rs.getString("STATUS"));
ptcn = checkNull(rs.getString("PTCN"));
cartonType = checkNull(rs.getString("CARTON_TYPE"));
pickOrder = checkNull(rs.getString("PICK_ORDER"));
packCode = checkNull(rs.getString("PACK_CODE"));
masterCarton = checkNull(rs.getString("MASTER_CARTON"));
tareWgt = rs.getDouble("TARE_WEIGHT");
fillerWgt = rs.getDouble("FILLER_WEIGHT");
sql1 = "SELECT COUNT(*) FROM PACK_HDR WHERE TRAN_ID = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, pickOrder);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
count = rs1.getInt(1);
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("PACK_HDR count---->>"+count);
if(count > 0)
{
successCnt++;
updSql = "UPDATE PACK_HDR SET CONFIRMED = ?,CONF_DATE = ?,EMP_CODE__APRV = ? ,CHG_DATE = ?,CHG_TERM = ?,"
+ "CHG_USER = ?,TARE_WEIGHT = ?,FILLER_WEIGHT = ? WHERE PICK_ORDER = ?";
pstmt1 = conn.prepareStatement(updSql);
pstmt1.setString(1, "Y");
pstmt1.setTimestamp(2, currDate);
pstmt1.setString(3, empCode);
pstmt1.setTimestamp(4, currDate);
pstmt1.setString(5, chgTerm);
pstmt1.setString(6, chgUser);
pstmt1.setDouble(7, tareWgt);
pstmt1.setDouble(8, fillerWgt);
pstmt1.setString(9, pickOrder);
rowIns = pstmt1.executeUpdate();
if(rowIns > 0)
{
System.out.println("row successfully updated for pack_hdr table......."+rowIns);
}
pstmt1.close();
pstmt1 = null;
}
sql1 = "SELECT CARTON_NO,STATUS,PTCN,CARTON_TYPE,PICK_ORDER,MASTER_CARTON,PACK_CODE"
+ " FROM CARTON_MASTER WHERE MASTER_CARTON = ? AND CARTON_TYPE = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, cartonNo);
pstmt1.setString(2, "C");
rs1 = pstmt1.executeQuery();
int lineNoCount = 0;
while(rs1.next())
{
String cartonNoL ="",statusL = "",ptcnL = "",cartonTypeL = "",pickOrderL ="",masterCartonL ="",packCodeL ="";
lineNoCount++;
successCnt++;
cartonNoL = checkNull(rs1.getString("CARTON_NO"));
statusL = checkNull(rs1.getString("STATUS"));
ptcnL = checkNull(rs1.getString("PTCN"));
cartonTypeL = checkNull(rs1.getString("CARTON_TYPE"));
pickOrderL = checkNull(rs1.getString("PICK_ORDER"));
masterCartonL = checkNull(rs1.getString("MASTER_CARTON"));
packCodeL = checkNull(rs1.getString("PACK_CODE"));
insSql = "INSERT INTO PACK_DET (TRAN_ID,LINE_NO,SALE_ORDER,LINE_NO__SORD,SITE_CODE,ITEM_CODE,LOC_CODE,LOT_NO,"
+ " LOT_SL,QUANTITY,LOC_CODE__TO,CARTON_NO,NO_ART,STATUS ) "
+ "VALUES (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?, )";
pstmtIns = conn.prepareStatement(insSql);
pstmtIns.setString(1, pickOrder);
pstmtIns.setInt(2, lineNoCount);
pstmtIns.setString(3, checkNull(packDataMap.get("sale_order")));
pstmtIns.setString(4, packDataMap.get("line_no__sord"));
pstmtIns.setString(5, checkNull(packDataMap.get("site_code")));
pstmtIns.setString(6, checkNull(packDataMap.get("item_code")));
pstmtIns.setString(7, checkNull(packDataMap.get("stag_loc")));
pstmtIns.setString(8, checkNull(packDataMap.get("lot_no")));
pstmtIns.setString(9, checkNull(packDataMap.get("lot_sl")));
pstmtIns.setDouble(10, Double.parseDouble(packDataMap.get("quantity")));
pstmtIns.setString(11, checkNull(packDataMap.get("stag_loc")));//LOC_CODE__TO
pstmtIns.setString(12, cartonNoL);
pstmtIns.setInt(13, 1);
pstmtIns.setString(14, "P");
rowIns = pstmtIns.executeUpdate();
if(pstmtIns != null)
{
pstmtIns.close();
pstmtIns = null;
}
} //end detail while
if(rs1 != null)
{
rs1.close();
rs1 = null;
}
if(pstmt1 !=null)
{
pstmt1.close();
pstmt1 = null;
}
}//end while
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt !=null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
throw e;
}
if(successCnt > 1)
{
return "Success";
}
return "Error";
}
private boolean updatePickOrderHeader(String pickOrder ,Connection conn) throws ITMException
{
PreparedStatement pstmtPickOrdHdr =null;
PreparedStatement pstmtUpdPickOrdHdr=null;
ResultSet rsPicKordHdr =null;
String status = "";
Boolean isUpdateHdr=true;
int updCntPickOrdHdr= 0;
double pickQty = 0;
try {
String sqlPickOrd = "SELECT STATUS,(QUANTITY - (CASE WHEN DEALLOC_QTY IS NULL THEN 0 ELSE DEALLOC_QTY END )) AS QUANTITY FROM PICK_ORD_DET WHERE PICK_ORDER = ? ";
pstmtPickOrdHdr = conn.prepareStatement(sqlPickOrd);
pstmtPickOrdHdr.setString(1, pickOrder);
rsPicKordHdr = pstmtPickOrdHdr.executeQuery();
while(rsPicKordHdr.next())
{
status = rsPicKordHdr.getString("STATUS") == null ? "": rsPicKordHdr.getString("STATUS").trim();
pickQty = rsPicKordHdr.getDouble("QUANTITY");
System.out.println("@@@@ Inside Check Status["+status+"]pickQty["+pickQty+"]");
if( !("C".equalsIgnoreCase(status) ) && pickQty > 0)
{
isUpdateHdr =false;
break;
}
}
if(pstmtPickOrdHdr != null)
{
pstmtPickOrdHdr.close();
pstmtPickOrdHdr=null;
}
if(isUpdateHdr)
{
System.out.println("@@@@ Updating hader status as C ");
String updatePickOrdSql = "UPDATE PICK_ORD_HDR SET STATUS = ? "
+ " WHERE PICK_ORDER = ? ";
pstmtUpdPickOrdHdr = conn.prepareStatement(updatePickOrdSql);
pstmtUpdPickOrdHdr.setString(1, "C");
pstmtUpdPickOrdHdr.setString(2, pickOrder);
updCntPickOrdHdr = pstmtUpdPickOrdHdr.executeUpdate();
if(pstmtUpdPickOrdHdr !=null)
{
pstmtUpdPickOrdHdr.close();
pstmtUpdPickOrdHdr=null;
}
if(updCntPickOrdHdr > 0)
{
System.out.println("@@@@ Update Successfully");
return true;
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
isError = true;
throw new ITMException(e);
}
return false;
}
private int waveStatusUpdate(String replOrder, Connection conn) throws ITMException
{
String sql = "", sql1 = "";
String waveId = "";
String saleOrder = "";
PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs = null, rs1 = null;
int updateCount = 0;
int firstCount = 0, secCount = 0;
try
{
sql = "SELECT WAVE_ID, SALE_ORDER FROM PICK_ORD_HDR WHERE PICK_ORDER = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, replOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
waveId = rs.getString("WAVE_ID");
saleOrder = rs.getString("SALE_ORDER");
sql1 = "SELECT COUNT(*) AS CONT FROM WAVE_TASK_DET WHERE WAVE_ID = ? AND SALE_ORDER = ? AND REF_SER <> 'S-DSP' ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, waveId);
pstmt1.setString(2, saleOrder);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
firstCount = rs1.getInt("CONT");
}
rs1.close();rs1 = null;
pstmt1.close();pstmt1 = null;
//Changed by sumit on 19/03/13 changing condition
//sql1 = "SELECT COUNT(*) AS CONT FROM WAVE_TASK_DET WHERE WAVE_STATUS = 'V' AND WAVE_ID = ? AND SALE_ORDER = ? AND REF_SER <> 'S-DSP' ";
sql1 = "SELECT COUNT(*) AS CONT FROM WAVE_TASK_DET WHERE STATUS = 'Y' AND WAVE_ID = ? AND SALE_ORDER = ? AND REF_SER <> 'S-DSP' ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, waveId);
pstmt1.setString(2, saleOrder);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
secCount = rs1.getInt("CONT");
}
rs1.close();rs1 = null;
pstmt1.close();pstmt1 = null;
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if( secCount == firstCount)
{
sql = "UPDATE WAVE_TASK_DET SET WAVE_STATUS = 'C' WHERE WAVE_ID = ? AND SALE_ORDER = ? AND REF_SER = 'S-DSP' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, waveId);
pstmt.setString(2, saleOrder);
updateCount = pstmt.executeUpdate();
pstmt.close();pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return updateCount;
}
private HashMap getItemVoumeMap(String itemCode,String lotNo,Connection con)throws Exception
{
double shipperSize = 0,itemVolume = 0,caseVolume = 0;
PreparedStatement pstmt = null;
String sql="";
ResultSet rs = null;
double itmLen = 0,itmWidth = 0,itmHeight = 0,itemGrossWeight = 0,lotLen = 0 ,lotHeight = 0,lotWidth = 0,caseGrossWeight = 0,itemNetWeight = 0, caseNetWeight = 0;
HashMap dataVolumeMap = new HashMap();
try {
sql = "SELECT I.LENGTH ITEM_LEN,I.WIDTH ITEM_WID,I.HEIGHT ITEM_HEIGHT,I.GROSS_WEIGHT ITEM_GROSS_WEIGHT,I.NET_WEIGHT ITEM_NET_WEIGHT,"
+" L.LENGTH LITEM_LEN,L.WIDTH LITEM_WID,L.HEIGHT LITEM_HEIGHT,L.SHIPPER_SIZE SHIPSIZE,L.GROSS_WEIGHT CASE_GROSS_WEIGHT,L.NET_WEIGHT CASE_NET_WEIGHT FROM"
+" ITEM I,ITEM_LOT_PACKSIZE L"
+" WHERE I.ITEM_CODE = L.ITEM_CODE"
+" AND L.LOT_NO__FROM <= ? AND L.LOT_NO__TO >= ?"
+" AND I.ITEM_CODE = ?";
pstmt = con.prepareStatement(sql);
if(lotNo != null && lotNo.length() > 0)
{
pstmt.setString(1, lotNo);
pstmt.setString(2, lotNo);
}
else
{
pstmt.setString(1, "00");
pstmt.setString(2, "ZZ");
}
pstmt.setString(3, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
itmLen = rs.getDouble("ITEM_LEN");
itmWidth = rs.getDouble("ITEM_WID");
itmHeight = rs.getDouble("ITEM_HEIGHT");
itemGrossWeight = rs.getDouble("ITEM_GROSS_WEIGHT");
lotLen = rs.getDouble("LITEM_LEN");
lotWidth = rs.getDouble("LITEM_WID");
lotHeight = rs.getDouble("LITEM_HEIGHT");
shipperSize = rs.getDouble("SHIPSIZE");
caseGrossWeight = rs.getDouble("CASE_GROSS_WEIGHT");
itemNetWeight = rs.getDouble("ITEM_NET_WEIGHT");
caseNetWeight = rs.getDouble("CASE_NET_WEIGHT");
}
//shipperSize = (lotHeight * lotWidth * lotLen)/(itmLen * itmWidth * itmHeight);
itemVolume = (itmLen * itmWidth * itmHeight);
caseVolume = (lotHeight * lotWidth * lotLen);
dataVolumeMap.put("SHIPPER_SIZE", shipperSize);
dataVolumeMap.put("ITEM_VOLUME", itemVolume);
dataVolumeMap.put("CASE_VOLUME", caseVolume);
dataVolumeMap.put("ITEM_GROSS_WEIGHT", itemGrossWeight);
dataVolumeMap.put("CASE_GROSS_WEIGHT", caseGrossWeight);
dataVolumeMap.put("ITEM_NET_WEIGHT", itemNetWeight);
dataVolumeMap.put("CASE_NET_WEIGHT", caseNetWeight);
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
} catch (Exception e) {
// TODO: handle exception
isError = true;
throw e;
}
finally
{
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
return dataVolumeMap;
}
private String getColumnDescr(Connection conn, String columnName ,String tableName, String columnName2, String value) throws Exception
{
PreparedStatement pstmt = null ;
ResultSet rs = null ;
String sql = "";
String findValue = "";
try
{
sql = "SELECT " + columnName + " from " + tableName + " where " + columnName2 +"= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,value);
rs = pstmt.executeQuery();
if(rs.next())
{
findValue = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
System.out.println("Exception in getColumnDescr ");
isError = true;
e.printStackTrace();
throw new Exception(e);
}
System.out.println("returning String from getColumnDescr " + findValue);
return findValue;
}
private String getError(String siteCode,String lotNo,String lotSl,String itemCode,String locCode,String Code,Connection conn) throws ITMException, Exception
{
String mainStr ="";
try
{
String errString = "";
errString = new ITMDBAccessEJB().getErrorString("",Code,"","",conn);
String begPart = errString.substring(0,errString.indexOf("<message>")+9);
String endDesc = errString.substring(errString.indexOf("</description>"));
mainStr= begPart+"Inventory is on hold"+"</message><description>";
mainStr= mainStr+"Hold Quantity present in Site [" + siteCode + "] Lot No ["+lotNo+"] and Lot Sl ["+lotSl+"] Item Code["+itemCode+"] Location ="+locCode+" "+endDesc;
System.out.println("mainStr:::::::::::::::::: "+mainStr);
begPart = null;
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return mainStr;
}
private String checkNull(String str)
{
if(str == null)
{
str = "";
}
return str.trim();
}
}
/*
Purpose: Local Interface created for PickIssConf Component
Author: Gulzar on 13/09/11
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import java.sql.Connection;
@javax.ejb.Local
public interface MultiplePtcnWizConfLocal extends ActionHandlerLocal
{
public String confirm( String tranId, String xtraParams, String forcedFlag )throws RemoteException,ITMException;
public String confirm( String tranId, String xtraParams,String forcedFlag, Connection conn, boolean connStatus) throws RemoteException,ITMException, Exception;
}
\ No newline at end of file
/*
Purpose: Remote Interface created for PickIssConf Component
Author: Gulzar on 13/09/11
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import java.sql.Connection;
@javax.ejb.Remote
public interface MultiplePtcnWizConfRemote extends ActionHandlerRemote
{
public String confirm( String tranId, String xtraParams, String forcedFlag ) throws RemoteException,ITMException;;
public String confirm( String tranId, String xtraParams,String forcedFlag, Connection conn, boolean connStatus) throws RemoteException,ITMException,Exception;
}
\ No newline at end of file
/**
* PURPOSE : Local Interface for PickIssIC component
* AUTHOR : Gulzar
* DATE : 12/09/11
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import javax.ejb.*;
@javax.ejb.Local
public interface MultiplePtcnWizLocal extends ValidatorLocal
{
public String wfValData() throws RemoteException, ITMException;
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext,String editFlag, String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String xtraParams) throws RemoteException, ITMException;
public String itemChanged() throws RemoteException, ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException;
public String itemChanged( Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String currentColumn,String editFlag, String xtraParams ) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.wms;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.dis.InvAllocTraceBean;
import ibase.webitm.ejb.dis.StockUpdate;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@javax.ejb.Stateless
public class MultiplePtcnWizPos extends ValidatorEJB implements MultiplePtcnWizPosLocal, MultiplePtcnWizPosRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
boolean isError = false;
public String postSave()throws RemoteException,ITMException
{
return "";
}
public String postSave( String domString, String tranId,String editFlag, String xtraParams) throws RemoteException,ITMException
{
return "";
}
public String postSave(String domString, String tranId,String editFlag, String xtraParams, Connection conn ) throws ITMException
{
isError = false;
System.out.println("**** MultiplePtcnWizPos ***** postSave ");
System.out.println("**** MultiplePtcnWizPos ***** tranId ["+tranId+"]");
System.out.println("**** MultiplePtcnWizPos ***** editFlag ["+editFlag+"]");
System.out.println("**** MultiplePtcnWizPos ***** xtraParams ["+xtraParams+"]");
System.out.println("**** MultiplePtcnWizPos ***** domString ["+domString+"]");
Document dom = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
String errorString = "",sql = "";
int count = 0,nodeLength = 0,cnt = 0;
NodeList detail3List = null;
MultiplePtcnWizConf MultiplePtcnWizConfobj = null;
try
{
conn.setAutoCommit(false);
dom = genericUtility.parseString(domString);
if(dom != null)
{
detail3List = dom.getElementsByTagName("Detail3");
}
sql = "select count(*) from multi_pick_iss_hdr where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select count(*) from multi_pick_iss_det where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("multi_pick_iss_hdr count---->>["+count+"]");
System.out.println("multi_pick_iss_det count---->>["+cnt+"]");
nodeLength = detail3List.getLength();
System.out.println("nodeLength count---->>["+nodeLength+"]");
if(detail3List != null && count != 0 && cnt == count)
{
MultiplePtcnWizConfobj = new MultiplePtcnWizConf();
System.out.println("Detail3 length = "+detail3List.getLength());
errorString = MultiplePtcnWizConfobj.confirm( tranId, xtraParams,"", conn, false ) ;
//errorString = confirmedMultiplePickIssue(tranId, xtraParams, conn);
}
System.out.println("errorString postSave------->>["+errorString+"]");
if(errorString != null && errorString.length() > 0)
{
throw new Exception(errorString);
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
System.out.println("in finally........."+isError);
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
return "";
}
private String confirmedMultiplePickIssue(String tranId,String xtraParams,Connection conn) throws Exception
{
System.out.println("@@@@@@@@ Call confirmedMultiplePickIssue Method @@@@@@@@");
ResultSet rs = null,rsStock = null,rs1 = null,rsSord = null;
PreparedStatement pstmt = null,pstmtStock = null,pstmt1 = null,pstmtUpd = null,pstmtSord = null;
PreparedStatement pstmtUpdPickOrdDet =null;
String sql = "",errorString = "",empCode = "",confirmed = "";
String itemCode = "",siteCode = "",locCode = "",lotNo = "",lotSl = "",locCodeTo = "",saleOrder = "",
lineNoSord = "",replOrder = "",pickType = "",dExpLev = "",remarks = "",dimension = "";
String acctCodeDr = "",cctrCodeDr = "",packCode = "",siteCodeMfg = "",stagingLoc = "",
packInstr = "",suppCodeMfg = "",unitAlt = "",batchNo = "",unit = "",grade = "",
expLev = "",itemCodeOrd = "",itemRef = "",status = "",itemGrade = "",
allocMode = "",reasCode = "",unitStd = "",sSQL = "",updateSql = "";
int lineNoOrd= 0,lineNo= 0,updCnt = 0,rowsCount = 0;
double quantity = 0,noArt =0,stkGrossRate = 0,convQtyStduom = 0,batchSize = 0,holdQuantity = 0,stkRate = 0;
double shipperSize = 0, itemGrossWeight = 0, caseGrossWeight = 0, itemNetWeight = 0, caseNetWeight = 0,
qtyOrd = 0,sordAllocQty = 0;
isError = false;
boolean isUpdatehdr= false;
java.sql.Timestamp expDate = null;
java.sql.Timestamp mfgDate = null;
java.sql.Timestamp restestDate = null;
java.sql.Timestamp dateAlloc = null;
HashMap updateRowMap = new HashMap();
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
DistCommon distCommon = new DistCommon();
StockUpdate stkUpdate = null;
InvAllocTraceBean invAllocTrace = null;
HashMap itmVolumeMap = new HashMap();
HashMap strAllocate = null;
try
{
java.sql.Timestamp currDate = new java.sql.Timestamp( System.currentTimeMillis() );
empCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginEmpCode" );
String dbDateFormat = genericUtility.getDBDateFormat();
String applDateFormat = genericUtility.getApplDateFormat();
java.util.Date currDate1 = new java.util.Date();
SimpleDateFormat sdf = new SimpleDateFormat(applDateFormat);
String currDateStr = sdf.format(currDate1);
java.sql.Timestamp tranDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString( currDateStr , applDateFormat, dbDateFormat ) + " 00:00:00.0") ;
confirmed = checkNull(getColumnDescr(conn, "confirmed", "multi_pick_iss", "tran_id", tranId));
System.out.println("confirmed----->>["+confirmed+"]");
confirmed = confirmed.length() == 0 ? "N" :confirmed;
if("Y".equalsIgnoreCase(confirmed))
{
errorString = itmDBAccess.getErrorString("","PCKISSCONF","");
return errorString;
}
else
{
stagingLoc = checkNull(distCommon.getDisparams( "999999", "STAGING_LOC", conn)==null?"":distCommon.getDisparams( "999999", "STAGING_LOC", conn));
System.out.println("stagingLoc------>>["+stagingLoc+"]");
stkUpdate = new StockUpdate();
invAllocTrace = new InvAllocTraceBean();
sql = "select acct_code__inv, cctr_code__inv, "
+ "exp_date, pack_code, mfg_date, site_code__mfg, "
+ "pack_instr, supp_code__mfg, retest_date, rate, "
+ "gross_rate, conv__qty_stduom, unit__alt, batch_no, batch_size, unit, grade, remarks, "
+ "dimension ,hold_qty from stock "
+ "where item_code = ? "
+ "and site_code = ? "
+ "and loc_code = ? "
+ "and lot_no = ? "
+ "and lot_sl = ? ";
pstmtStock = conn.prepareStatement(sql);
sql = "SELECT R.TRAN_ID,R.LINE_NO LINE_NO, R.ITEM_CODE ITEM_CODE, R.SITE_CODE SITE_CODE, "
+ "R.LOC_CODE LOC_CODE, R.LOT_NO LOT_NO, R.LOT_SL LOT_SL, "
+ "(R.QUANTITY - (CASE WHEN R.DEALLOC_QTY IS NULL THEN 0 ELSE R.DEALLOC_QTY END )) AS QUANTITY,"
+ " R.NO_ART NO_ART,O.SALE_ORDER SALE_ORDER, O.LINE_NO__SORD LINE_NO__SORD, O.PICK_ORDER,H.PICK_TYPE,"
+ "O.EXP_LEV EXP_LEV "
+ " FROM MULTI_PICK_ISS_DET R, PICK_ORD_DET O ,PICK_ORD_HDR H WHERE R.TRAN_ID = ? "
+ " AND R.PICK_ORDER = O.PICK_ORDER AND H.PICK_ORDER = O.PICK_ORDER "
+ " AND O.LINE_NO = R.LINE_NO__SORD "
+ " AND (R.QUANTITY - (CASE WHEN R.DEALLOC_QTY IS NULL THEN 0 ELSE R.DEALLOC_QTY END )) > 0 ";
//+ " AND R.LOC_CODE <> R.LOC_CODE__TO";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
System.out.println("WHILE CONDITION.........."+(++rowsCount));
itemCode = rs.getString( "item_code" );
siteCode = rs.getString( "site_code" );
locCode = rs.getString( "loc_code" );
lotNo = checkNull(rs.getString( "lot_no" ));
lotSl = checkNull(rs.getString( "lot_sl" ));
quantity = rs.getDouble( "quantity" );
noArt = rs.getDouble( "no_art" );
//locCodeTo = rs.getString( "loc_code__to" );
saleOrder = rs.getString( "SALE_ORDER" );
lineNoSord = rs.getString( "LINE_NO__SORD" );
lineNoSord = " " + lineNoSord;
lineNoSord = lineNoSord.substring(lineNoSord.length()-3);
replOrder = rs.getString( "PICK_ORDER" );
pickType = rs.getString( "PICK_TYPE" );
lineNoOrd = rs.getInt( "LINE_NO__SORD" );
dExpLev = checkNull(rs.getString( "EXP_LEV" ));
System.out.println("dExpLev->> ["+dExpLev+"]");
System.out.println("locCode->> ["+locCode+"]");
itmVolumeMap.clear();
itmVolumeMap = getItemVoumeMap(itemCode,lotNo,conn);
shipperSize = (Double) itmVolumeMap.get("SHIPPER_SIZE");
itemGrossWeight = (Double) itmVolumeMap.get("ITEM_GROSS_WEIGHT");
caseGrossWeight = (Double) itmVolumeMap.get("CASE_GROSS_WEIGHT");
itemNetWeight = (Double) itmVolumeMap.get("ITEM_NET_WEIGHT");
caseNetWeight = (Double) itmVolumeMap.get("CASE_NET_WEIGHT");
if(lotNo == null || lotNo.trim().length() == 0)
{
lotNo =" ";
}
if(lotSl == null || lotSl.trim().length()==0)
{
lotSl = " ";
}
lineNo = rs.getInt( "LINE_NO" );
pstmtStock.setString(1,itemCode);
pstmtStock.setString(2,siteCode);
pstmtStock.setString(3,locCode);
pstmtStock.setString(4,lotNo);
pstmtStock.setString(5,lotSl);
rsStock = pstmtStock.executeQuery();
if ( rsStock.next() )
{
acctCodeDr = rsStock.getString("acct_code__inv");
cctrCodeDr = rsStock.getString("cctr_code__inv");
expDate = rsStock.getTimestamp("exp_date");
packCode = rsStock.getString("pack_code");
mfgDate = rsStock.getTimestamp("mfg_date");
siteCodeMfg = rsStock.getString("site_code__mfg");
packInstr = rsStock.getString("pack_instr");
suppCodeMfg = rsStock.getString("supp_code__mfg");
restestDate = rsStock.getTimestamp("retest_date");
stkRate = rsStock.getDouble("rate");
stkGrossRate = rsStock.getDouble("gross_rate");
convQtyStduom = rsStock.getDouble("conv__qty_stduom");
unitAlt = rsStock.getString("unit__alt");
batchNo = rsStock.getString("batch_no");
batchSize = rsStock.getDouble("batch_size");
unit = rsStock.getString("unit");
grade = rsStock.getString("grade");
remarks = rsStock.getString("remarks");
dimension = rsStock.getString("dimension");
holdQuantity = rsStock.getDouble("hold_qty");
}
rsStock.close(); rsStock = null;
pstmtStock.clearParameters();
if(holdQuantity > 0)
{
errorString = getError(siteCode, lotNo, lotSl, itemCode, locCode, "INVITMQTST", conn);
return errorString;
}
updateRowMap.put("item_code", itemCode);
updateRowMap.put("site_code", siteCode);
updateRowMap.put("loc_code", locCode);
updateRowMap.put("lot_no", lotNo);
updateRowMap.put("lot_sl", lotSl);
updateRowMap.put("quantity", ""+quantity);
updateRowMap.put("no_art", noArt);
updateRowMap.put("tran_ser", "PICISS");
updateRowMap.put("acct_code__cr",acctCodeDr);
updateRowMap.put("cctr_code__cr",cctrCodeDr);
updateRowMap.put("acct_code_inv",acctCodeDr);
updateRowMap.put("cctr_code_inv",cctrCodeDr);
updateRowMap.put("rate",Double.toString(stkRate));
updateRowMap.put("gross_rate",Double.toString(stkGrossRate));
updateRowMap.put("tran_id", tranId );
// 17/10/11 manoharan
updateRowMap.put("line_no", "" + lineNo );
// end 17/10/11 manoharan
updateRowMap.put("tran_date", tranDate );
updateRowMap.put("tran_type","ID");
updateRowMap.put("qty_stduom", ""+quantity);
updateRowMap.put("unit",unit);
updateRowMap.put("grade",grade);
updateRowMap.put("remarks",remarks);
updateRowMap.put("dimension",dimension);
updateRowMap.put("exp_date", expDate);
updateRowMap.put("pack_code", packCode);
updateRowMap.put("mfg_date", mfgDate);
updateRowMap.put("site_code__mfg", siteCodeMfg);
updateRowMap.put("pack_instr", packInstr);
updateRowMap.put("supp_code__mfg", suppCodeMfg);
updateRowMap.put("retest_date", restestDate);
updateRowMap.put("conv__qty_stduom", ""+convQtyStduom);
updateRowMap.put("unit__alt", unitAlt);
updateRowMap.put("batch_no", batchNo);
updateRowMap.put("batch_size", ""+batchSize);
System.out.println("quantity---->>["+quantity+" shipperSize--->>["+shipperSize+"]");
if(quantity < shipperSize || shipperSize == 0)
{
noArt = 1;
}
else
{
noArt = Math.floor((quantity) / shipperSize) ;
}
updateRowMap.put("no_art", noArt);
updateRowMap.put("gross_weight", caseGrossWeight * noArt);
updateRowMap.put("net_weight", caseNetWeight * noArt);
updateRowMap.put("tare_weight", (caseGrossWeight - caseNetWeight) * noArt);
System.out.println("errorString BEFORE updateStock1----->["+errorString+"]");
errorString = stkUpdate.updateStock( updateRowMap, xtraParams, conn );
System.out.println("errorString after updateStock1----->["+errorString+"]");
if ( errorString != null && errorString.trim().length() > 0 )
{
isError = true;
break;
}
updateRowMap.put("loc_code", stagingLoc);
updateRowMap.put("tran_type", "R");//Creating receipt
System.out.println("errorString BEFORE updateStock2..........");
errorString = stkUpdate.updateStock( updateRowMap, xtraParams, conn );
System.out.println("errorString after updateStock2----->["+errorString+"]");
if ( errorString != null && errorString.trim().length() > 0 )
{
isError = true;
break;
}
updateRowMap.clear();
strAllocate = new HashMap();
strAllocate.put("tran_date",tranDate);
strAllocate.put("ref_ser","M-PTCN");
strAllocate.put("ref_id",tranId);
strAllocate.put("ref_line", "" + lineNo);
strAllocate.put("site_code",siteCode);
strAllocate.put("item_code",itemCode);
strAllocate.put("loc_code", stagingLoc);
strAllocate.put("lot_no",lotNo);
strAllocate.put("lot_sl",lotSl);
strAllocate.put("alloc_qty",new Double(quantity));
strAllocate.put("chg_user",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginCode"));
strAllocate.put("chg_term",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"termId"));
strAllocate.put("chg_win","w_multi_pick_iss");
errorString = invAllocTrace.updateInvallocTrace(strAllocate, conn);
System.out.println("errorString after updateInvallocTrace----->["+errorString+"]");
// To check the sordalloc allocated quantity > quantity then insert new record deducte quantity from old location.
sql = " SELECT EXP_LEV, ITEM_CODE__ORD, "
+ " ITEM_REF, UNIT, DATE_ALLOC, STATUS, ITEM_GRADE, EXP_DATE, ALLOC_MODE, SITE_CODE, "
+ " CONV__QTY_STDUOM, UNIT__STD, MFG_DATE, SITE_CODE__MFG, REAS_CODE,QUANTITY,QTY_ALLOC FROM SORDALLOC "
+ " WHERE SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? "
+ " AND QTY_ALLOC > 0";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, saleOrder);
pstmt1.setString(2, lineNoSord);
pstmt1.setString(3, itemCode);
pstmt1.setString(4, locCode);
pstmt1.setString(5, lotNo);
pstmt1.setString(6, lotSl);
rs1 = pstmt1.executeQuery();
if( rs1.next())
{
System.out.println("Inside the Query the Exp level["+expLev+"]");
expLev = rs1.getString( "EXP_LEV" );
System.out.println("Inside the Query the Exp level["+expLev+"]");
if (expLev == null || expLev.trim().length() == 0)
{
expLev = dExpLev;
}
if (expLev == null || expLev.trim().length() == 0)
{
expLev = " ";
}
itemCodeOrd = rs1.getString( "ITEM_CODE__ORD" );
itemRef = rs1.getString( "ITEM_REF" );
unit = rs1.getString( "UNIT" );
status = rs1.getString( "STATUS" );
itemGrade = rs1.getString( "ITEM_GRADE" );
allocMode = rs1.getString( "ALLOC_MODE" );
siteCode = rs1.getString( "SITE_CODE" );
siteCodeMfg = rs1.getString( "SITE_CODE__MFG" );
reasCode = rs1.getString( "REAS_CODE" );
unitStd = rs1.getString( "UNIT__STD" );
convQtyStduom = rs1.getDouble( "CONV__QTY_STDUOM" );
dateAlloc = rs1.getTimestamp("DATE_ALLOC");
expDate = rs1.getTimestamp("EXP_DATE");
mfgDate = rs1.getTimestamp("MFG_DATE");
qtyOrd = rs1.getDouble( "QUANTITY" );
sordAllocQty = rs1.getDouble( "QTY_ALLOC" );
}
else
{
isError = true;
errorString = itmDBAccess.getErrorString("","RECNOTSORA","");
return errorString;
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
sSQL = "SELECT COUNT(*) AS COUNT FROM SORDALLOC WHERE "
+ " SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? ";
int count = 0;
System.out.println("sordAllocQty---->>["+sordAllocQty+" quantity--->["+quantity+"]");
if(sordAllocQty > quantity)
{
System.out.println("sordAllocQty in greater.................");
updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC - ? ,QUANTITY__STDUOM = QUANTITY__STDUOM - ?, WAVE_FLAG = 'Y' "
+ " WHERE SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? "
+ " AND QTY_ALLOC > 0";
pstmtUpd = conn.prepareStatement(updateSql);
pstmtUpd.setDouble(1, quantity);
//Changed by sumit on 10/09/13 setting
pstmtUpd.setDouble(2, quantity * convQtyStduom);
pstmtUpd.setString(3, saleOrder);
pstmtUpd.setString(4, lineNoSord);
pstmtUpd.setString(5, itemCode);
pstmtUpd.setString(6, locCode);
pstmtUpd.setString(7, lotNo);
pstmtUpd.setString(8, lotSl);
updCnt = pstmtUpd.executeUpdate();
if(pstmtUpd !=null)
{
pstmtUpd.close();
pstmtUpd=null;
}
System.out.println(" sordalloc updated updCnt [" + updCnt + "]");
if (expLev == null || expLev.trim().length() == 0)
{
System.out.println("Check1l["+expLev+"]");
expLev = dExpLev;
}
System.out.println("Finally the Exp level["+expLev+"]");
pstmtSord = conn.prepareStatement(sSQL);
pstmtSord.setString(1, saleOrder);
pstmtSord.setString(2, lineNoSord);
pstmtSord.setString(3, itemCode);
pstmtSord.setString(4, stagingLoc);
pstmtSord.setString(5, lotNo);
pstmtSord.setString(6, lotSl);
rsSord = pstmtSord.executeQuery();
if(rsSord.next())
{
count = rsSord.getInt(1);
}
System.out.println("count SORDALLOC@@------>>["+count+"]");
if(count > 0)
{
System.out.println(" sordalloc If alrady exist Location Update Inside grater updCnt1st [" + updCnt + "]");
//updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC + ? ,QUANTITY__STDUOM = QUANTITY__STDUOM + ?"
updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC + ? ,QUANTITY__STDUOM = QUANTITY__STDUOM + ?, WAVE_FLAG = 'Y' "
+ " WHERE SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? "
+ " AND QTY_ALLOC > 0";
pstmtUpd = conn.prepareStatement(updateSql);
pstmtUpd.setDouble(1, quantity);
pstmtUpd.setDouble(2, quantity);
pstmtUpd.setString(3, saleOrder);
pstmtUpd.setString(4, lineNoSord);
pstmtUpd.setString(5, itemCode);
pstmtUpd.setString(6, stagingLoc);
pstmtUpd.setString(7, lotNo);
pstmtUpd.setString(8, lotSl);
updCnt = pstmtUpd.executeUpdate();
if(pstmtUpd !=null)
{
pstmtUpd.close();
pstmtUpd=null;
}
System.out.println(" sordalloc If alrady exist Location Update Inside grater updCnt2nd [" + updCnt + "]");
}
else
{
System.out.println("--------insert record in SORDALLOC table--------------");
updateSql = "INSERT INTO SORDALLOC( SALE_ORDER, LINE_NO, EXP_LEV, ITEM_CODE__ORD, "
+ " ITEM_CODE, LOT_NO, LOT_SL, LOC_CODE, ITEM_REF, QUANTITY, UNIT, "
+ " QTY_ALLOC, DATE_ALLOC, STATUS, ITEM_GRADE, EXP_DATE, ALLOC_MODE, SITE_CODE, "
+ " CONV__QTY_STDUOM, UNIT__STD, QUANTITY__STDUOM, MFG_DATE, SITE_CODE__MFG, "
+ " REAS_CODE, WAVE_FLAG ) "
+ " VALUES (?, ?, ?, ?, "
+ " ?, ?, ? , ?, ?, ?, ?, "
+ " ?,?, ?, ?, ?, ?, ?, "
+ " ?, ?, ? , ?, ?, ?, ? ) ";
pstmtUpd = conn.prepareStatement(updateSql);
pstmtUpd.setString(1, saleOrder);
pstmtUpd.setString(2, lineNoSord);
pstmtUpd.setString(3, expLev);
pstmtUpd.setString(4, itemCodeOrd);
pstmtUpd.setString(5, itemCode);
pstmtUpd.setString(6, lotNo);
pstmtUpd.setString(7, lotSl);
pstmtUpd.setString(8, stagingLoc);
pstmtUpd.setString(9, itemRef);
pstmtUpd.setDouble(10, qtyOrd);
pstmtUpd.setString(11, unit);
pstmtUpd.setDouble(12, quantity);
pstmtUpd.setTimestamp(13, dateAlloc);
pstmtUpd.setString(14, status);
pstmtUpd.setString(15, itemGrade);
pstmtUpd.setTimestamp(16, expDate);
pstmtUpd.setString(17, allocMode);
pstmtUpd.setString(18, siteCode);
pstmtUpd.setDouble(19, convQtyStduom );
pstmtUpd.setString(20, unitStd);
pstmtUpd.setDouble(21, quantity * convQtyStduom);
pstmtUpd.setTimestamp(22, mfgDate );
pstmtUpd.setString(23, siteCodeMfg);
pstmtUpd.setString(24, reasCode);
pstmtUpd.setString(25, "Y");
updCnt = pstmtUpd.executeUpdate();
System.out.println(" INSERT in sordalloc updCnt [" + updCnt + "]");
if(pstmtUpd != null)
{
pstmtUpd.close();
pstmtUpd=null;
}
}
}
else
{
System.out.println("sordAllocQty in lesser.................");
pstmtSord = conn.prepareStatement(sSQL);
pstmtSord.setString(1, saleOrder);
pstmtSord.setString(2, lineNoSord);
pstmtSord.setString(3, itemCode);
pstmtSord.setString(4, stagingLoc);
pstmtSord.setString(5, lotNo);
pstmtSord.setString(6, lotSl);
rsSord = pstmtSord.executeQuery();
if(rsSord.next())
{
count = rsSord.getInt(1);
}
System.out.println("count SORDALLOC--->>"+count);
if(count > 0)
{
//updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC - ? " //LOC_CODE = ? ,LOT_SL = ? "
updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC - ?, WAVE_FLAG = 'Y' "
+ " WHERE SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? "
+ " AND QTY_ALLOC > 0";
pstmtUpd = conn.prepareStatement(updateSql);
pstmtUpd.setDouble(1, quantity);
pstmtUpd.setString(2, saleOrder);
pstmtUpd.setString(3, lineNoSord);
pstmtUpd.setString(4, itemCode);
pstmtUpd.setString(5, locCode);
pstmtUpd.setString(6, lotNo);
pstmtUpd.setString(7, lotSl);
updCnt = pstmtUpd.executeUpdate();
System.out.println(" sordalloc If alrady exist Location Update updCnt1st [" + updCnt + "]");
if(pstmtUpd !=null)
{
pstmtUpd.close();
pstmtUpd=null;
}
//updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC + ? ,QUANTITY__STDUOM = QUANTITY__STDUOM + ?"
updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC + ? ,QUANTITY__STDUOM = QUANTITY__STDUOM + ?, WAVE_FLAG = 'Y' "
+ " WHERE SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? "
+ " AND QTY_ALLOC > 0";
pstmtUpd = conn.prepareStatement(updateSql);
pstmtUpd.setDouble(1, quantity);
pstmtUpd.setDouble(2, quantity);
pstmtUpd.setString(3, saleOrder);
pstmtUpd.setString(4, lineNoSord);
pstmtUpd.setString(5, itemCode);
pstmtUpd.setString(6, stagingLoc);
pstmtUpd.setString(7, lotNo);
pstmtUpd.setString(8, lotSl);
updCnt = pstmtUpd.executeUpdate();
System.out.println(" sordalloc If alrady exist Location Update updCnt2nd [" + updCnt + "]");
if(pstmtUpd != null)
{
pstmtUpd.close();
pstmtUpd=null;
}
}
else
{
//updateSql = "UPDATE SORDALLOC SET LOC_CODE = ? "
updateSql = "UPDATE SORDALLOC SET LOC_CODE = ?, WAVE_FLAG = 'Y' "
+ " WHERE SALE_ORDER = ? AND LINE_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? "
+ " AND QTY_ALLOC > 0";
pstmtUpd = conn.prepareStatement(updateSql);
pstmtUpd.setString(1, stagingLoc);
pstmtUpd.setString(2, saleOrder);
pstmtUpd.setString(3, lineNoSord);
pstmtUpd.setString(4, itemCode);
pstmtUpd.setString(5, locCode);
pstmtUpd.setString(6, lotNo);
pstmtUpd.setString(7, lotSl);
updCnt = pstmtUpd.executeUpdate();
if(pstmtUpd !=null)
{
pstmtUpd.close();
pstmtUpd=null;
}
}
System.out.println(" sordalloc Update updCnt [" + updCnt + "]");
}
if(rsSord != null)
{
rsSord.close();
rsSord=null;
}
if(pstmtSord != null)
{
pstmtSord.close();
pstmtSord=null;
}
String updatePickOrdSql = "UPDATE PICK_ORD_DET SET STATUS = ? "
+ " WHERE PICK_ORDER = ? AND LINE_NO = ? ";
pstmtUpdPickOrdDet = conn.prepareStatement(updatePickOrdSql);
pstmtUpdPickOrdDet.setString(1, "C");
pstmtUpdPickOrdDet.setString(2, replOrder);
pstmtUpdPickOrdDet.setInt(3, lineNoOrd);
int updCntPickOrdDet = pstmtUpdPickOrdDet.executeUpdate();
if(updCntPickOrdDet > 0)
{
isUpdatehdr = updatePickOrderHeader(replOrder,conn);
}
if(pstmtUpdPickOrdDet != null)
{
pstmtUpdPickOrdDet.close();
pstmtUpdPickOrdDet=null;
}
updatePickOrdSql = "UPDATE MULTI_PICK_ISS_DET SET LOC_CODE = ? "
+ " WHERE TRAN_ID = ? AND LINE_NO = ? ";
pstmtUpdPickOrdDet = conn.prepareStatement(updatePickOrdSql);
pstmtUpdPickOrdDet.setString(1, stagingLoc);
pstmtUpdPickOrdDet.setString(2, tranId);
pstmtUpdPickOrdDet.setInt(3, lineNo);
updCntPickOrdDet = pstmtUpdPickOrdDet.executeUpdate();
if(updCntPickOrdDet > 0)
{
isUpdatehdr = updatePickOrderHeader(replOrder,conn);
}
if(pstmtUpdPickOrdDet != null)
{
pstmtUpdPickOrdDet.close();
pstmtUpdPickOrdDet=null;
}
} //end while
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;//While close.
}
if(pstmtStock != null)
{
pstmtStock.close();
pstmtStock = null;
}
if (errorString != null && errorString.trim().length() > 0 )
{
isError = true;
return errorString;
}
updateSql = "UPDATE MULTI_PICK_ISS SET CONFIRMED = 'Y', CONF_DATE = ?, EMP_CODE__USER = ?"
+ " WHERE TRAN_ID = ? ";
pstmt = conn.prepareStatement(updateSql);
pstmt.setTimestamp(1, currDate);
pstmt.setString(2, empCode);
pstmt.setString(3, tranId);
updCnt = pstmt.executeUpdate();
if( updCnt > 0 )
{
System.out.println( updCnt + " MULTI_PICK_ISS rows updated successfully" );
}
pstmt.close();
pstmt = null;
System.out.println("isUpdatehdr-------->>["+isUpdatehdr+"]");
if(isUpdatehdr)
{
}
}
}
catch(Exception e)
{
isError = true;
e.printStackTrace();
throw new Exception (e);
}
return errorString;
}
private String getColumnDescr(Connection conn, String columnName ,String tableName, String columnName2, String value) throws Exception
{
PreparedStatement pstmt = null ;
ResultSet rs = null ;
String sql = "";
String findValue = "";
try
{
sql = "SELECT " + columnName + " from " + tableName + " where " + columnName2 +"= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,value);
rs = pstmt.executeQuery();
if(rs.next())
{
findValue = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
System.out.println("Exception in getColumnDescr ");
isError = true;
e.printStackTrace();
throw new Exception(e);
}
System.out.println("returning String from getColumnDescr " + findValue);
return findValue;
}
private String getError(String siteCode,String lotNo,String lotSl,String itemCode,String locCode,String Code,Connection conn) throws ITMException, Exception
{
String mainStr ="";
try
{
String errString = "";
errString = new ITMDBAccessEJB().getErrorString("",Code,"","",conn);
String begPart = errString.substring(0,errString.indexOf("<message>")+9);
String endDesc = errString.substring(errString.indexOf("</description>"));
mainStr= begPart+"Inventory is on hold"+"</message><description>";
mainStr= mainStr+"Hold Quantity present in Site [" + siteCode + "] Lot No ["+lotNo+"] and Lot Sl ["+lotSl+"] Item Code["+itemCode+"] Location ="+locCode+" "+endDesc;
System.out.println("mainStr:::::::::::::::::: "+mainStr);
begPart = null;
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return mainStr;
}
private boolean updatePickOrderHeader(String pickOrder ,Connection conn) throws ITMException
{
PreparedStatement pstmtPickOrdHdr =null;
PreparedStatement pstmtUpdPickOrdHdr=null;
ResultSet rsPicKordHdr =null;
String status = "";
Boolean isUpdateHdr=true;
int updCntPickOrdHdr= 0;
double pickQty = 0;
try {
String sqlPickOrd = "SELECT STATUS,(QUANTITY - (CASE WHEN DEALLOC_QTY IS NULL THEN 0 ELSE DEALLOC_QTY END )) AS QUANTITY FROM PICK_ORD_DET WHERE PICK_ORDER = ? ";
pstmtPickOrdHdr = conn.prepareStatement(sqlPickOrd);
pstmtPickOrdHdr.setString(1, pickOrder);
rsPicKordHdr = pstmtPickOrdHdr.executeQuery();
while(rsPicKordHdr.next())
{
status = rsPicKordHdr.getString("STATUS") == null ? "": rsPicKordHdr.getString("STATUS").trim();
pickQty = rsPicKordHdr.getDouble("QUANTITY");
System.out.println("@@@@ Inside Check Status["+status+"]pickQty["+pickQty+"]");
if( !("C".equalsIgnoreCase(status) ) && pickQty > 0)
{
isUpdateHdr =false;
break;
}
}
if(pstmtPickOrdHdr != null)
{
pstmtPickOrdHdr.close();
pstmtPickOrdHdr=null;
}
if(isUpdateHdr)
{
System.out.println("@@@@ Updating hader status as C ");
String updatePickOrdSql = "UPDATE PICK_ORD_HDR SET STATUS = ? "
+ " WHERE PICK_ORDER = ? ";
pstmtUpdPickOrdHdr = conn.prepareStatement(updatePickOrdSql);
pstmtUpdPickOrdHdr.setString(1, "C");
pstmtUpdPickOrdHdr.setString(2, pickOrder);
updCntPickOrdHdr = pstmtUpdPickOrdHdr.executeUpdate();
if(pstmtUpdPickOrdHdr !=null)
{
pstmtUpdPickOrdHdr.close();
pstmtUpdPickOrdHdr=null;
}
if(updCntPickOrdHdr > 0)
{
System.out.println("@@@@ Update Successfully");
return true;
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
isError = true;
throw new ITMException(e);
}
return false;
}
private HashMap getItemVoumeMap(String itemCode,String lotNo,Connection con)throws Exception
{
double shipperSize = 0,itemVolume = 0,caseVolume = 0;
PreparedStatement pstmt = null;
String sql="";
ResultSet rs = null;
double itmLen = 0,itmWidth = 0,itmHeight = 0,itemGrossWeight = 0,lotLen = 0 ,lotHeight = 0,lotWidth = 0,caseGrossWeight = 0,itemNetWeight = 0, caseNetWeight = 0;
HashMap dataVolumeMap = new HashMap();
try {
sql = "SELECT I.LENGTH ITEM_LEN,I.WIDTH ITEM_WID,I.HEIGHT ITEM_HEIGHT,I.GROSS_WEIGHT ITEM_GROSS_WEIGHT,I.NET_WEIGHT ITEM_NET_WEIGHT,"
+" L.LENGTH LITEM_LEN,L.WIDTH LITEM_WID,L.HEIGHT LITEM_HEIGHT,L.SHIPPER_SIZE SHIPSIZE,L.GROSS_WEIGHT CASE_GROSS_WEIGHT,L.NET_WEIGHT CASE_NET_WEIGHT FROM"
+" ITEM I,ITEM_LOT_PACKSIZE L"
+" WHERE I.ITEM_CODE = L.ITEM_CODE"
+" AND L.LOT_NO__FROM <= ? AND L.LOT_NO__TO >= ?"
+" AND I.ITEM_CODE = ?";
pstmt = con.prepareStatement(sql);
if(lotNo != null && lotNo.length() > 0)
{
pstmt.setString(1, lotNo);
pstmt.setString(2, lotNo);
}
else
{
pstmt.setString(1, "00");
pstmt.setString(2, "ZZ");
}
pstmt.setString(3, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
itmLen = rs.getDouble("ITEM_LEN");
itmWidth = rs.getDouble("ITEM_WID");
itmHeight = rs.getDouble("ITEM_HEIGHT");
itemGrossWeight = rs.getDouble("ITEM_GROSS_WEIGHT");
lotLen = rs.getDouble("LITEM_LEN");
lotWidth = rs.getDouble("LITEM_WID");
lotHeight = rs.getDouble("LITEM_HEIGHT");
shipperSize = rs.getDouble("SHIPSIZE");
caseGrossWeight = rs.getDouble("CASE_GROSS_WEIGHT");
itemNetWeight = rs.getDouble("ITEM_NET_WEIGHT");
caseNetWeight = rs.getDouble("CASE_NET_WEIGHT");
}
//shipperSize = (lotHeight * lotWidth * lotLen)/(itmLen * itmWidth * itmHeight);
itemVolume = (itmLen * itmWidth * itmHeight);
caseVolume = (lotHeight * lotWidth * lotLen);
dataVolumeMap.put("SHIPPER_SIZE", shipperSize);
dataVolumeMap.put("ITEM_VOLUME", itemVolume);
dataVolumeMap.put("CASE_VOLUME", caseVolume);
dataVolumeMap.put("ITEM_GROSS_WEIGHT", itemGrossWeight);
dataVolumeMap.put("CASE_GROSS_WEIGHT", caseGrossWeight);
dataVolumeMap.put("ITEM_NET_WEIGHT", itemNetWeight);
dataVolumeMap.put("CASE_NET_WEIGHT", caseNetWeight);
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
} catch (Exception e) {
// TODO: handle exception
isError = true;
throw e;
}
finally
{
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
return dataVolumeMap;
}
private String checkNull(String str)
{
if(str == null)
{
str = "";
}
return str.trim();
}
}
/**
Title : PickPostSaveLocalEJB
Date : 04/11/11
Author: Chitranjan Pandey
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import org.w3c.dom.*;
@javax.ejb.Local
public interface MultiplePtcnWizPosLocal
{
public String postSave()throws RemoteException,ITMException;
public String postSave( String domString,String tranId, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException, Exception;
public String postSave( String domString,String tranId, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/**
Title : PickPostSaveRemoteEJB
Date : 04/11/11
Author: Chitranjan Pandey
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import org.w3c.dom.*;
@javax.ejb.Remote
public interface MultiplePtcnWizPosRemote
{
public String postSave()throws RemoteException,ITMException;
public String postSave( String domString,String tranId, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException;
public String postSave( String domString,String tranId, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/**
* PURPOSE : Remote Interface for PicklIssIC component
* AUTHOR : Gulzar
* DATE : 12/09/11
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import javax.ejb.*;
@javax.ejb.Remote
public interface MultiplePtcnWizRemote extends ValidatorRemote
{
public String wfValData() throws RemoteException, ITMException;
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext,String editFlag, String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String xtraParams) throws RemoteException, ITMException;
public String itemChanged() throws RemoteException, ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException;
public String itemChanged( Document currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String currentColumn,String editFlag, String xtraParams ) throws RemoteException, ITMException;
}
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