Commit b1932ffc authored by jshinde's avatar jshinde

Request Id: W15JSUN010

,Repalletization or pallet consolidation.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@99929 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a52305df
/**
* PURPOSE :ConsolidatePalletIC component
* AUTHOR : Jagruti Shinde
* DATE : 14-01-2016
*/
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 ibase.webitm.utility.wms.CommonWmsUtil;
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 ConsolidatePalletIC extends ValidatorEJB implements ConsolidatePalletICLocal, ConsolidatePalletICRemote
{
@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,editFlag);
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,String editFlag) 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 = "", locCode = "",lotSl="",lotNo="",itemCode="",sqlQ="",sql="";
ArrayList <String> errList = new ArrayList<String>();
ArrayList <String>errFields = new ArrayList <String> ();
GenericUtility genericUtility;
String remarks="",addUser="",addTerm="",addDate="",chgUser="",chgTerm="",chgDate="",descr="" , sql1="";
double quantity=0,noArt=0,qtyPerArt,noArtQuot=0,noArtRem =0 , notArt = 0,palTcnt=0;
int locCount = 0;
String familyGrp="",tranId="",familyGrpDB="",qcType="",qcTypeDB="";
ResultSet rs= null ,rsQ = null;
Document currFormDataDom = dom;
String loginSite = "",objName="",itemCodeDB="",lotNoDB="",qcSampleTypeDB="",statusDB="",status="",stroPref="",
stroPrefDB="",qcSampleType="";
ArrayList<String> palletList = new ArrayList();
ArrayList ArrList = new ArrayList();
PreparedStatement pstmt = null,pstmtQ = null;
int palletCount = 0;
Connection conn = null;
double quantityStock=0,noArtStock=0, noArtD=0,quantityStockQ=0;
String siteCode = "",userId = "",childNodeName = "",errString = "";
int ctr = 0, currentFormNo = 0, childNodeListLength = 0, siteCount = 0, cnt = 0,loccnt=0,palcnt=0,cntLoc = 0,count=0;
objName = getObjNameFromDom(dom, "objName", "2");
System.out.println("objName----->>["+objName+"]");
System.out.println("editFlag----->>["+editFlag+"]");
HashMap hm2 = new HashMap();
HashMap hm = new HashMap();
HashMap hm1 = new HashMap();
try
{
genericUtility = GenericUtility.getInstance();
CommonWmsUtil commonWmsUtility = CommonWmsUtil.getInstance();
System.out.println("xtraParam----->>["+xtraParams+"]");
loginSite = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" ));
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);
}
switch ( currentFormNo ) // Switch Case for form number
{
case 1:
System.out.println("DOM---->>["+genericUtility.serializeDom(dom).toString()+"]");
System.out.println("DOM1----->>["+genericUtility.serializeDom(dom1).toString()+"]");
System.out.println("DOM2----->>["+genericUtility.serializeDom(dom2).toString()+"]");
System.out.println("editFlag----->>["+editFlag+"]");
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+"]");
}//for loop
break;
case 2:
System.out.println("------in case 2---------------");
System.out.println("DOM---->>["+genericUtility.serializeDom(dom).toString()+"]");
System.out.println("DOM1----->>["+genericUtility.serializeDom(dom1).toString()+"]");
System.out.println("DOM2----->>["+genericUtility.serializeDom(dom2).toString()+"]");
System.out.println("editFlag----->>["+editFlag+"]");
String palletNo = "";
parentNodeList = dom2.getElementsByTagName("Detail2");
for(int intPrnt = 0;intPrnt < parentNodeList.getLength();intPrnt++)
{
parentNode = parentNodeList.item(intPrnt);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
palletNo = checkNullAndTrim(genericUtility.getColumnValue("pallet_no",dom));
tranId = checkNullAndTrim(genericUtility.getColumnValue("tran_id",dom));
System.out.println("tran id---" +tranId);
System.out.println("PALLET NO---" +palletNo);
if(palletNo.length() == 0 || palletNo.equalsIgnoreCase(""))
{
errCode = "VMPALLENUL";//pallet no cannot be blank
errList.add( errCode );
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
errFields.add( childNodeName.toLowerCase() );
break;
}
else
{
sql = "SELECT COUNT(1) FROM LOCATION WHERE INV_STAT = ? AND LOC_CODE =? AND SITE_CODE=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "AWMS");
//pstmt.setString(2, "AWMSQ");
pstmt.setString(2, palletNo);
//pstmt.setString(4, palletNo+"Q");
pstmt.setString(3, loginSite);
rs = pstmt.executeQuery();
if(rs.next()){ cntLoc = rs.getInt(1);}
if(pstmt != null){pstmt.close();pstmt = null;}
if(rs != null)
{
rs.close();
rs = null;
}
if(cntLoc == 0)
{
System.out.println("awms pallet count" +cntLoc);
errCode = "VMPALLEEXT";//pallet
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
break;
}
sql = "select fn_chk_rpz(trim(?),?) from dual ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, palletNo);
pstmt.setString(2, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
palTcnt = rs.getInt(1);
}
if (pstmt != null) { pstmt.close(); pstmt = null; }
if (rs != null) { rs.close(); rs = null; }
if (palTcnt > 0)
{
System.out.println("PRESENT IN SWMS" + palTcnt);
errCode = "VMPALDCOEX";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
//System.out.println("IN PALLET REQUEST EDIT FLAG");
palletList = checkDuplicaterecord(dom2);
Set s = new HashSet(palletList);
System.out.println("Size of arrayList ["+palletList.size()+"]");
System.out.println("Size of Set ["+s.size()+"]");
if(s.size() < palletList.size())
{
System.out.println("pallet exist");
errList.add( "VMPALLETSM" );
errFields.add( childNodeName.toLowerCase() );
break;
}
s.clear();
sql1 = "SELECT COUNT(1) FROM STOCK WHERE INV_STAT =? AND LOC_CODE=? AND SITE_CODE=? AND QUANTITY>0";
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1, "AWMS");
pstmt.setString(2, palletNo);
pstmt.setString(3, loginSite);
rs = pstmt.executeQuery();
if(rs.next())
{
//System.out.println("count stock>>>>>>>" +rs.getInt(1));
System.out.println("PALLET_NO FOR AWMS" +palletNo);
palcnt = rs.getInt(1);
System.out.println("awms pallet count" +palcnt);
if(palcnt==0)
{
System.out.println("awms pallet count" +palcnt);
errCode = "VMPALLETQN";//pallet quantity should be more than zero
errList.add( errCode );
errFields.add( childNodeName.toLowerCase() );
break;
}
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
////////////loc_zone_pref validation
/* sql = "SELECT COUNT(*) FROM STOCK WHERE LOC_CODE = ? "
+ "AND SITE_CODE = ? AND INV_STAT NOT IN (?,?) AND QUANTITY > 0 ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, palletNo);
pstmt.setString(2, loginSite);
pstmt.setString(3, "AWMS");
pstmt.setString(4, "AWMSQ");
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
if(pstmt != null){pstmt.close();pstmt = null;}
if(rs != null){rs.close();rs = null;}
if(count <= 0)
{
System.out.println("No record found :::::::::: ");
errCode = "VTINVREC";
errList.add( errCode );
errFields.add(childNodeName.toLowerCase());
}
else
{
hm2 = getScanItem(palletNo, loginSite, conn);
itemCodeDB = (String) hm2.get("ITEM_CODE");
lotNoDB = (String) hm2.get("LOT_NO");
//lotSlDB = (String) hm2.get("LOT_SL");
qcSampleTypeDB = (String) hm2.get("QC_SAMPLE_TYPE");
System.out.println("itemCodeDB :::::::::: " + itemCodeDB);
System.out.println("lotNoDB :::::::::: " + lotNoDB);
System.out.println("qcSampleTypeDB :::::::::: " + qcSampleTypeDB);
if(itemCodeDB.length() > 0)
{
// Validation for Analysis Class
hm = commonWmsUtility.getPalletizedAttributes(itemCode, loginSite, conn);
familyGrp = (String) hm.get("LOC_ZONE__PREF");
qcType = (String) hm.get("PROC_MTH");
stroPref = (String) hm.get("ANALYSIS_CLASS");
hm1 = commonWmsUtility.getPalletizedAttributes(itemCodeDB, loginSite, conn);
familyGrpDB = (String) hm1.get("LOC_ZONE__PREF");
qcTypeDB = (String) hm1.get("PROC_MTH");
stroPrefDB = (String) hm1.get("ANALYSIS_CLASS");
if(!familyGrpDB.equalsIgnoreCase(familyGrp) || !qcTypeDB.equalsIgnoreCase(qcType) || !stroPrefDB.equalsIgnoreCase(stroPref))
{
System.out.println(" item code is not of same analysis grp :::::::::: ");
errCode = "VTINVAC";
errList.add( errCode );
errFields.add(childNodeName.toLowerCase());
}
// Validation for QC Order Status
System.out.println("Checking validation for QC order status :::::::::: " );
statusDB = getItemQcStatus(itemCodeDB, lotNoDB, loginSite, conn);
status = getItemQcStatus(itemCode, lotNo, loginSite, conn);
if("".equalsIgnoreCase(statusDB) || statusDB == null)
{
statusDB = "C";
}
if("".equalsIgnoreCase(status) || status == null)
{
status = "C";
}
System.out.println("value of statusDB after if :::::::::: " + statusDB);
System.out.println("value of status after if :::::::::: " + status);
if(!statusDB.equalsIgnoreCase(status))
{
System.out.println(" item code is not of same qc order status :::::::::: ");
errCode = "VTINVQCS";
errList.add( errCode );
errFields.add(childNodeName.toLowerCase());
}
// Validation for QC Sample Type
System.out.println("Checking validation for QC Sample Type :::::::::: " );
System.out.println("value of qcSampleTypeDB :::::::::: " + qcSampleTypeDB);
System.out.println("value of qcSampleType :::::::::: " + qcSampleType);
if(!qcSampleTypeDB.equalsIgnoreCase(qcSampleType))
{
System.out.println(" item code is not of same qc sample type :::::::::: ");
errCode = "VTINVQST";
errList.add( errCode );
errFields.add(childNodeName.toLowerCase());
}
}
}
*/ }//ELSE END
}//for c
}//for p
break;
} //switch end
System.out.println("after switch"+errList);
int errListSize = errList.size();
System.out.println("errListSize .........." + errListSize);
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();
}//try end
catch ( Exception e )
{
System.out.println ( "Exception: ConsolidatePalletIC: 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 : ConsolidatePalletIC:wfValData : " + e.getMessage() );
throw new ITMException(e);
}
}
System.out.println( "errString>>>>>>>::"+errString );
return errString;
}//wf end
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 :ConsolidatePalletIC :itemChanged(String,String):" + e.getMessage() + ":" );
throw new ITMException(e);
}
System.out.println ( "returning from ConsolidatePalletIC 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;
StringBuffer valueXmlString;
String loginSite = "",loginEmpCode = "",chgUser = "" , chgTerm = "",siteDescr = "", siteCodeSupp = "" ,tranDate = "";
String siteCode = "",lotNo="",lotSl="",itemCode="",palletNo="",noArtStr="",quantityStr="",sql="",locCode="",locDescr="";
int currentFormNo = 0;
ResultSet rs=null;
double quantity=0,noArt=0,qtyPerArt=0,noArtQuot=0,noArtRem =0 , notArt = 0, totalQuantity = 0, noArtD=0;
System.out.println("xtraParams=["+xtraParams+"]");
GenericUtility genericUtility = GenericUtility.getInstance();
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>").append( editFlag );
try
{
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"));
System.out.println("loginEmpCode---->>["+loginEmpCode+"] chgUser---->>["+chgUser+"]");
System.out.println("currFormDataDom---->>["+genericUtility.serializeDom(currFormDataDom)+"] ");
System.out.println("hdrDataDom---->>["+genericUtility.serializeDom(hdrDataDom)+"] ");
System.out.println("allFormDataDom---->>["+genericUtility.serializeDom(allFormDataDom)+"] ");
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat simpleDateFormatObj = new SimpleDateFormat(genericUtility.getApplDateFormat());
tranDate = simpleDateFormatObj.format(currentDate.getTime());
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>\r\n" );
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
{
System.out.println("loginSite : ["+loginSite+"]");
siteDescr = checkNullAndTrim(getColumnDescr(conn, "descr", "site", "site_code", loginSite));
valueXmlString.append( "<site_code><![CDATA[" ).append( loginSite ).append( "]]></site_code>\r\n" );
valueXmlString.append( "<site_descr><![CDATA[" ).append( siteDescr ).append( "]]></site_descr>\r\n" );
}
/*else if( currentColumn.trim().equalsIgnoreCase( "site_code" ) )
{
siteCode = checkNullAndTrim(genericUtility.getColumnValue("site_code",currFormDataDom));
System.out.println("siteCode : ["+siteCode+"]");
if(siteCode.length() > 0)
{
siteDescr = checkNullAndTrim(getColumnDescr(conn, "descr", "site", "site_code", siteCode));
valueXmlString.append( "<site_descr><![CDATA[" ).append( siteDescr ).append( "]]></site_descr>\r\n" );
}
else
{
valueXmlString.append( "<site_descr><![CDATA[" ).append( "" ).append( "]]></site_descr>\r\n" );
}
}*/
/*else if( currentColumn.trim().equalsIgnoreCase( "loc_code" ) )
{
locCode = checkNullAndTrim(genericUtility.getColumnValue("loc_code",currFormDataDom));
System.out.println("loc_code : ["+locCode+"]");
if(locCode.length() > 0)
{
locDescr = checkNullAndTrim(getColumnDescr(conn, "descr", "location", "loc_code", locCode));
valueXmlString.append( "<location_descr><![CDATA[" ).append( locDescr ).append( "]]></location_descr>\r\n" );
}
else
{
valueXmlString.append( "<location_descr><![CDATA[" ).append( "" ).append( "]]></location_descr>\r\n" );
}
}*/
valueXmlString.append( "<add_user><![CDATA[" ).append( chgUser ).append( "]]></add_user>\r\n" );
valueXmlString.append( "<confirmed><![CDATA[" ).append( "N" ).append( "]]></confirmed>\r\n" );
valueXmlString.append( "<tran_type><![CDATA[" ).append( "R" ).append( "]]></tran_type>\r\n" );
valueXmlString.append( "<tran_date><![CDATA[" ).append( tranDate ).append( "]]></tran_date>\r\n" );
valueXmlString.append( "<add_date><![CDATA[" ).append( tranDate ).append( "]]></add_date>\r\n" );
valueXmlString.append( "<add_user><![CDATA[" ).append( chgUser ).append( "]]></add_user>\r\n" );
valueXmlString.append( "<add_term><![CDATA[" ).append( chgTerm ).append( "]]></add_term>\r\n" );
valueXmlString.append("</Detail1>\r\n");
} //Case 1. End
break;
case 2:
{
System.out.println("header dom2 "+genericUtility.serializeDom(hdrDataDom));
System.out.println("header dom2 "+genericUtility.serializeDom(allFormDataDom));
valueXmlString.append( "<Detail2>\r\n" );
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
{
/*locCode = checkNullAndTrim(genericUtility.getColumnValue("loc_code",hdrDataDom));
System.out.println("location Code : ["+locCode+"]");
valueXmlString.append( "<loc_code><![CDATA[" ).append( locCode ).append( "]]></loc_code>\r\n" );
locDescr = null;
locDescr = checkNullAndTrim(genericUtility.getColumnValue("location_descr",hdrDataDom));
valueXmlString.append( "<location_descr><![CDATA[" ).append( locDescr ).append( "]]></location_descr>\r\n" );*/
valueXmlString.append( "<status><![CDATA[" ).append( "P" ).append( "]]></status>\r\n" );
//valueXmlString.append( "<no_art><![CDATA[" ).append( "1" ).append( "]]></no_art>\r\n" );
}
/*else if( currentColumn.trim().equalsIgnoreCase( "pallet_no" ) )
{
palletNo = checkNullAndTrim(genericUtility.getColumnValue("pallet_no",currFormDataDom));
System.out.println( "palletNo item change::"+palletNo);
}*/
valueXmlString.append( "</Detail2>\r\n" );
}
break;
}//switch
valueXmlString.append( "</Root>\r\n" );
}//End of try block
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 getDBRowCount(Connection conn, String table_name, String whrCondCol, String whrCondVal)
{
int count=0;
ResultSet rs=null;
PreparedStatement pstmt = null;
String sql="";
sql="select count(*) 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 PalletReqIC 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) 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 ");
e.printStackTrace();
throw new Exception(e);
}
finally
{
if(rs!=null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
}
System.out.println("returning String from getColumnDescr " + findValue);
return findValue;
}
public boolean isRecordPresentInMiscDrCrRcp(Connection conn,
String invoiceID) {
// TODO Auto-generated method stub
return false;
}
private ArrayList checkDuplicaterecord(Document dom) throws ITMException
{
ArrayList arryList = new ArrayList();
NodeList parentNodeList = null, childNodeList = null;
Node parentNode = null, childNode = null;
int parentNodeListLength = 0;
String childNodeName = "";
String updateFlag = getAttribValue(parentNode,"attribute", "updateFlag"); //(parentNode, "attribute", "status"));
try
{
parentNodeList = dom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
for (int row = 0; row < parentNodeList.getLength(); row++)
{
parentNode = parentNodeList.item(row);
System.out.println(" sumit updateFlag ["+updateFlag+"]");
childNodeList = parentNode.getChildNodes();
//System.out.println("************* first For loop *************["+ parentNode.getNodeName() + "]");
for (int col = 0; col < childNodeList.getLength(); col++) {
childNode = childNodeList.item(col);
if (childNode.getNodeType() == childNode.ELEMENT_NODE) {
childNodeName = childNode.getNodeName();
//System.out.println("childNodeNamechildNodeName ** ["+childNodeName+"]");
if( !"D".equalsIgnoreCase(updateFlag))
{
if ("pallet_no".equalsIgnoreCase(childNodeName))
{
arryList.add(childNode.getFirstChild().getNodeValue().trim());
//arrayList.add(i,childNode.getFirstChild().getNodeValue());
//map = sprsCode != null ? sprsCode : "";
System.out.println("===palletno-->[" + arryList+ "]");
}
}
}
}
System.out.println("ELSE FOR CHECK");
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return arryList;
}
private String getAttribValue(Node detailNode, String nodeName, String attribStr)
{
String attribValue = "",domStr="";
try
{
domStr = GenericUtility.getInstance().serializeDom(detailNode);
Document dom = GenericUtility.getInstance().parseString(domStr);
if( dom != null /*&& dom.getAttributes() != null*/)
{
Node attributeNode = dom.getElementsByTagName( nodeName ).item(0);
attribValue = getAttribValue(attributeNode, attribStr);
}
}
catch(Exception e)
{
System.out.println("Exception : getAttribValue :" + e.getMessage());
}
return attribValue;
}
private String getAttribValue(Node detailNode, String attribStr)
{
String attribValue = "";
try
{
if( detailNode != null && detailNode.getAttributes() != null)
{
Node attribNode = detailNode.getAttributes().getNamedItem( attribStr );
if( attribNode != null )
{
attribValue = checkNull( attribNode.getNodeValue() );
}
}
}
catch(Exception e)
{
System.out.println("Exception : getAttribValue :" + e.getMessage());
}
return attribValue;
}
//Changed for pallet request with stock details [Start]Request Id:W15HSUN003
public boolean isRecordExist(Document dom) throws ITMException
{
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int childNodeListLength = 0;
boolean isExist=false;
String childNodeName = null,palletNo = "",itemCode = "",lotNo = "",lotSl ="",quantity="",PalletKey="",updateFlag="";
ArrayList<String> palletDetailList=new ArrayList<String>();
if(dom != null)
{
GenericUtility genericUtility = GenericUtility.getInstance();
parentNodeList = dom.getElementsByTagName("Detail2");
childNodeListLength = parentNodeList.getLength();
System.out.println("serializeDom----->>"+genericUtility.serializeDom(dom));
System.out.println("childNodeListLength----->>"+childNodeListLength);
for (int ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = parentNodeList.item(ctr);
childNodeName = childNode.getNodeName();
updateFlag = getAttribValue(childNode,"attribute", "updateFlag"); //(parentNode, "attribute", "status"));
System.out.println("Child name --->> "+childNodeName);
if (childNode.getNodeType() == Node.ELEMENT_NODE)
{
Element eElement = (Element) childNode;
palletNo = checkNull(eElement.getElementsByTagName("pallet_no").item(0).getTextContent());
itemCode = checkNull(eElement.getElementsByTagName("item_code").item(0).getTextContent());
lotNo = checkNull(eElement.getElementsByTagName("lot_no").item(0).getTextContent());
lotSl = checkNull(eElement.getElementsByTagName("lot_sl").item(0).getTextContent());
System.out.println("palletNo---->"+palletNo+ " PalletNo--->["+palletNo+"]");
if( !"D".equalsIgnoreCase(updateFlag))
{
System.out.println("updateFlag --->> "+updateFlag);
PalletKey=palletNo+":"+itemCode+":"+lotNo+":"+lotSl;
palletDetailList.add(PalletKey);
}
}
}
System.out.println("palletDetail --->> "+palletDetailList);
Set<String> uniqueSet = new HashSet<String>(palletDetailList);
for (String temp : uniqueSet)
{
System.out.println(temp + ": " + Collections.frequency(palletDetailList, temp));
int i = Collections.frequency(palletDetailList, temp);
System.out.println("frequency --->> "+i);
if(i > 1)
{
isExist = true;
break;
}
}
}
else
{
System.out.println("dom is null please check.........");
}
System.out.println("dom is null please check........."+isExist);
return isExist ;
}
private String getObjNameFromDom( Document dom, String attribute, String objContext ) throws RemoteException,ITMException
{
NodeList detailList = null;
Node currDetail = null,reqDetail = null;
String objName = "";
int detailListLength = 0;
try
{
detailList = dom.getElementsByTagName("Detail"+objContext);
detailListLength = detailList.getLength();
for (int ctr = 0; ctr < detailListLength; ctr++)
{
currDetail = detailList.item(ctr);
objName = currDetail.getAttributes().getNamedItem(attribute).getNodeValue();
if( objName != null && objName.trim().length() > 0)
{
return objName;
}
}
}
catch ( Exception e )
{
throw new ITMException(e);
}
return objName;
}
private HashMap getScanItem(String palletNo, String siteCode, Connection conn) throws Exception
{
HashMap hm = new HashMap();
PreparedStatement pstmt = null ;
ResultSet rs = null ;
String sql = "", itemCodeDB = "", lotNoDB = "", lotSlDB = "", qcSampleTypeDB = "";
try
{
sql ="select distinct(item_code) as item_code, lot_no, d.qc_sample_type from pallet_hdr h, pallet_det d where d.pallet_no = ? and "
+ "h.confirmed = ? and h.site_code = ? and d.tran_id = h.tran_id and rownum < 2 ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, palletNo);
pstmt.setString(2, "N");
pstmt.setString(3, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
itemCodeDB = checkNullAndTrim(rs.getString("item_code"));
lotNoDB = checkNullAndTrim(rs.getString("lot_no"));
qcSampleTypeDB = checkNullAndTrim(rs.getString("qc_sample_type"));
//lotSlDB = checkNullAndTrim(rs.getString("lot_sl"));
}
if(pstmt != null){ pstmt.close(); pstmt = null; }
if(rs != null){ rs.close(); rs = null; }
hm.put("ITEM_CODE", itemCodeDB);
hm.put("LOT_NO", lotNoDB);
hm.put("QC_SAMPLE_TYPE", qcSampleTypeDB);
//hm.put("LOT_SL", lotSlDB);
}
catch(Exception e)
{
System.out.println("Exception in getScanItem ::::::: " + e);
e.printStackTrace();
throw new Exception(e);
}
finally
{
if(rs!=null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
}
System.out.println("return value from getScanItem :::::::::: " + hm);
return hm;
}
private String getItemQcStatus(String itemCode, String lotNo, String siteCode, Connection conn) throws Exception
{
PreparedStatement pstmt = null ;
ResultSet rs = null ;
String sql = "", status = "";
try
{
sql ="select status from qc_order where item_code = ? and lot_no = ? and site_code = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, lotNo);
pstmt.setString(3, siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
status = checkNullAndTrim(rs.getString("status"));
}
if(pstmt != null){ pstmt.close(); pstmt = null; }
if(rs != null){ rs.close(); rs = null; }
}
catch(Exception e)
{
System.out.println("Exception in getItemQcStatus ::::::: " + e);
e.printStackTrace();
throw new Exception(e);
}
finally
{
if(rs!=null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
}
System.out.println("return value from getItemQcStatus :::::::::: " + status);
return status;
}
}
/**
* PURPOSE : Local Interface for ConsolidatePalletIC component
* AUTHOR : Jagruti Shinde
* DATE : 14-01-2016
*/
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 ConsolidatePalletICLocal 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 dom, Document dom1, Document dom2, String objContext, String xtraParams,String editFlag) 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;
}
/**
* PURPOSE : Remote Interface for ConsolidatePalletIC component
* AUTHOR : Jagruti Shinde
* DATE : 14-01-2016
*/
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 ConsolidatePalletICRemote 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 dom, Document dom1, Document dom2, String objContext, String xtraParams,String editFlag) 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;
}
...@@ -19,328 +19,341 @@ import javax.ejb.Stateless; ...@@ -19,328 +19,341 @@ import javax.ejb.Stateless;
@Stateless @Stateless
public class PalletReqConf extends ActionHandlerEJB public class PalletReqConf extends ActionHandlerEJB
implements PalletReqConfLocal, PalletReqConfRemote implements PalletReqConfLocal, PalletReqConfRemote
{ {
String loginEmpCode = ""; String loginEmpCode = "";
String confDateStr = ""; String confDateStr = "";
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
public String confirm(String tranID, String xtraParams, String forcedFlag) public String confirm(String tranID, String xtraParams, String forcedFlag)
throws RemoteException, ITMException throws RemoteException, ITMException
{ {
String retString = ""; String retString = "";
Connection conn = null; Connection conn = null;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
boolean isConn = true; boolean isConn = true;
try try
{ {
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false); conn.setAutoCommit(false);
connDriver = null; connDriver = null;
retString = confirm(tranID, xtraParams, forcedFlag, conn, isConn); retString = confirm(tranID, xtraParams, forcedFlag, conn, isConn);
if ((retString == null) && (retString.length() < 0)) if ((retString == null) && (retString.length() < 0))
{ {
throw new Exception("Exception while calling confirm for tran Id:[" + tranID + "]"); throw new Exception("Exception while calling confirm for tran Id:[" + tranID + "]");
} }
} }
catch (Exception exception) catch (Exception exception)
{ {
System.out.println("Exception in [PalletReqConf] " + exception.getMessage()); System.out.println("Exception in [PalletReqConf] " + exception.getMessage());
} }
return retString; return retString;
} }
public String confirm(String tranId, String xtraParams, String forcedFlag, Connection conn, boolean conStat) throws RemoteException, ITMException public String confirm(String tranId, String xtraParams, String forcedFlag, Connection conn, boolean conStat) throws RemoteException, ITMException
{ {
System.out.println("PalletReqConf Called........"); System.out.println("PalletReqConf Called........");
boolean isError = false; boolean isError = false;
String confirmed = ""; String confirmed = "";
String sql = ""; String sql = "";
ResultSet rs = null; ResultSet rs1 = null; ResultSet rs = null; ResultSet rs1 = null;
PreparedStatement pstmt = null; PreparedStatement pstmt1 = null; PreparedStatement pstmt = null; PreparedStatement pstmt1 = null;
String errString = ""; Timestamp tranDate = null; String errString = ""; Timestamp tranDate = null;
String palletNo = ""; String palletStatus = "F"; String palletNo = ""; String palletStatus = "F";
String lineNo = ""; String itemCode = ""; String lotNo = ""; String lotSl = ""; String noArt = ""; String quantity = ""; String lineNo = ""; String itemCode = ""; String lotNo = ""; String lotSl = ""; String noArt = ""; String quantity = "";
String empCodeAprv = ""; String siteCode = ""; String empCodeAprv = ""; String siteCode = "";
String loginSite = ""; String qtyPerArt = ""; String refSer = "PRS"; String loginSite = ""; String qtyPerArt = ""; String refSer = "PRS";
String descr = ""; String unit = ""; String itemType = ""; String mfgDate = ""; String expiryDate = ""; String descr = "",unit = "",itemType = "",mfgDate = "", expiryDate = "",tranType="";
ArrayList palletList = new ArrayList(); ArrayList palletList = new ArrayList();
ArrayList lineList = new ArrayList(); ArrayList lineList = new ArrayList();
int cntPal = 0; int cntPal = 0;
ITMDBAccessEJB itmdbAccess = new ITMDBAccessEJB(); ITMDBAccessEJB itmdbAccess = new ITMDBAccessEJB();
ArrayList interfaceArrList = new ArrayList(); ArrayList interfaceArrList = new ArrayList();
Timestamp today = new Timestamp(System.currentTimeMillis()); Timestamp today = new Timestamp(System.currentTimeMillis());
CommonWmsUtil commonWmsUtility = CommonWmsUtil.getInstance(); CommonWmsUtil commonWmsUtility = CommonWmsUtil.getInstance();
try try
{ {
System.out.println(" tranId [" + tranId + "]"); System.out.println(" tranId [" + tranId + "]");
System.out.println(" force flag [" + forcedFlag + "]"); System.out.println(" force flag [" + forcedFlag + "]");
System.out.println(" xtraParams --> [" + xtraParams + "]"); System.out.println(" xtraParams --> [" + xtraParams + "]");
empCodeAprv = this.genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"); empCodeAprv = this.genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
siteCode = this.genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSite"); siteCode = this.genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSite");
System.out.println(" site code [" + siteCode + "]"); System.out.println(" site code [" + siteCode + "]");
SimpleDateFormat sdf = new SimpleDateFormat(this.genericUtility.getDBDateTimeFormat()); SimpleDateFormat sdf = new SimpleDateFormat(this.genericUtility.getDBDateTimeFormat());
java.util.Date confDate = new java.util.Date(); java.util.Date confDate = new java.util.Date();
this.confDateStr = sdf.format(confDate); this.confDateStr = sdf.format(confDate);
sql = "SELECT CONFIRMED FROM PALLET_REQ_HDR WHERE TRAN_ID=?"; sql = "SELECT CONFIRMED FROM PALLET_REQ_HDR WHERE TRAN_ID=?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
confirmed = checkNullAndTrim(rs.getString("CONFIRMED")); confirmed = checkNullAndTrim(rs.getString("CONFIRMED"));
System.out.println("CONFIRMED >>>>>>>" + confirmed); System.out.println("CONFIRMED >>>>>>>" + confirmed);
} }
rs.close(); rs.close();
pstmt.close(); pstmt.close();
String str1; String str1;
if ((confirmed != null) && (confirmed.equalsIgnoreCase("Y"))) if ((confirmed != null) && (confirmed.equalsIgnoreCase("Y")))
{ {
System.out.println("error" + errString); System.out.println("error" + errString);
errString = itmdbAccess.getErrorString("", "VMTRANSCOF", "", "", errString = itmdbAccess.getErrorString("", "VMTRANSCOF", "", "",
conn); conn);
str1 = errString; str1 = errString;
int count; int count;
return str1; return str1;
} }
sql = "SELECT COUNT(1) FROM PALLET_REQ_DET WHERE TRAN_ID=?"; sql = "SELECT COUNT(1) FROM PALLET_REQ_DET WHERE TRAN_ID=?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
cntPal = rs.getInt(1); cntPal = rs.getInt(1);
System.out.println("pallet_count---" + cntPal); System.out.println("pallet_count---" + cntPal);
} }
if (pstmt != null) if (pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if (rs != null) if (rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if (cntPal == 0) if (cntPal == 0)
{ {
System.out.println("palletno cannot be blank for confirm"); System.out.println("palletno cannot be blank for confirm");
errString = itmdbAccess.getErrorString("", "VMPALLETCF", "", "", conn); errString = itmdbAccess.getErrorString("", "VMPALLETCF", "", "", conn);
str1 = errString; str1 = errString;
int count; int count;
return str1; return str1;
} }
sql = "UPDATE PALLET_REQ_HDR SET CONFIRMED=? ,CONF_DATE=? ,EMP_CODE__APRV=? WHERE TRAN_ID=?"; sql = "UPDATE PALLET_REQ_HDR SET CONFIRMED=? ,CONF_DATE=? ,EMP_CODE__APRV=? WHERE TRAN_ID=?";
System.out.println("pallet_req_hdr [" + this.confDateStr + "]"); System.out.println("pallet_req_hdr [" + this.confDateStr + "]");
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "Y"); pstmt.setString(1, "Y");
pstmt.setDate(2, new java.sql.Date(System.currentTimeMillis())); pstmt.setDate(2, new java.sql.Date(System.currentTimeMillis()));
pstmt.setString(3, empCodeAprv); pstmt.setString(3, empCodeAprv);
pstmt.setString(4, tranId); pstmt.setString(4, tranId);
int count = pstmt.executeUpdate(); int count = pstmt.executeUpdate();
if (count > 0) if (count > 0)
{ {
System.out.println(" count --> [" + count + "]"); System.out.println(" count --> [" + count + "]");
} }
if (pstmt != null) if (pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
sql = "SELECT D.PALLET_NO ,D.LINE_NO,D.ITEM_CODE,D.LOT_NO,D.LOT_SL,D.NO_ART,D.QUANTITY FROM PALLET_REQ_DET D WHERE TRAN_ID=?"; sql = "SELECT D.PALLET_NO ,D.LINE_NO,D.ITEM_CODE,D.LOT_NO,D.LOT_SL,D.NO_ART,D.QUANTITY ,H.TRAN_TYPE FROM PALLET_REQ_DET D ,PALLET_REQ_HDR H WHERE D.TRAN_ID = H.TRAN_ID AND D.TRAN_ID=?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
for (int i = 0; i < palletList.size(); i++) for (int i = 0; i < palletList.size(); i++)
{ {
System.out.println("palletarray" + (String)palletList.get(i)); System.out.println("palletarray" + (String)palletList.get(i));
} }
for (int i = 0; i < lineList.size(); i++) for (int i = 0; i < lineList.size(); i++)
{ {
System.out.println("linearray" + (String)lineList.get(i)); System.out.println("linearray" + (String)lineList.get(i));
} }
palletNo = checkNullAndTrim(rs.getString("PALLET_NO")); palletNo = checkNullAndTrim(rs.getString("PALLET_NO"));
itemCode = checkNullAndTrim(rs.getString("ITEM_CODE")); itemCode = checkNullAndTrim(rs.getString("ITEM_CODE"));
lotNo = checkNullAndTrim(rs.getString("LOT_NO")); lotNo = checkNullAndTrim(rs.getString("LOT_NO"));
lotSl = checkNullAndTrim(rs.getString("LOT_SL")); lotSl = checkNullAndTrim(rs.getString("LOT_SL"));
noArt = checkNullAndTrim(rs.getString("NO_ART")); noArt = checkNullAndTrim(rs.getString("NO_ART"));
quantity = checkNullAndTrim(rs.getString("QUANTITY")); quantity = checkNullAndTrim(rs.getString("QUANTITY"));
lineNo = checkNullAndTrim(rs.getString("LINE_NO")); lineNo = checkNullAndTrim(rs.getString("LINE_NO"));
tranType=checkNullAndTrim(rs.getString("TRAN_TYPE"));
if ((itemCode != null) && (itemCode.length() > 0)) System.out.println("Tran Type="+tranType);
{
sql = "SELECT S.QTY_PER_ART,I.DESCR ,S.UNIT,I.ITEM_TYPE ,S.MFG_DATE,S.EXP_DATE FROM STOCK S ,ITEM I WHERE S.SITE_CODE=? AND S.LOC_CODE IN (?,?) AND S.ITEM_CODE= ? AND S.LOT_NO= ? AND S.LOT_SL= ? AND S.ITEM_CODE=I.ITEM_CODE"; //if((tranType == null) && (tranType.length() == 0))
if(tranType == null || tranType.length() == 0)
{
System.out.println(" in null trantype");
if ((itemCode != null) && (itemCode.length() > 0))
{
sql = "SELECT S.QTY_PER_ART,I.DESCR ,S.UNIT,I.ITEM_TYPE ,S.MFG_DATE,S.EXP_DATE FROM STOCK S ,ITEM I WHERE S.SITE_CODE=? AND S.LOC_CODE IN (?,?) AND S.ITEM_CODE= ? AND S.LOT_NO= ? AND S.LOT_SL= ? AND S.ITEM_CODE=I.ITEM_CODE";
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, siteCode); pstmt1.setString(1, siteCode);
pstmt1.setString(2, palletNo); pstmt1.setString(2, palletNo);
pstmt1.setString(3, palletNo + "Q"); pstmt1.setString(3, palletNo + "Q");
pstmt1.setString(4, itemCode); pstmt1.setString(4, itemCode);
pstmt1.setString(5, lotNo); pstmt1.setString(5, lotNo);
pstmt1.setString(6, lotSl); pstmt1.setString(6, lotSl);
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
if (rs1.next()) if (rs1.next())
{ {
qtyPerArt = checkNullAndTrim(rs1.getString("QTY_PER_ART")); qtyPerArt = checkNullAndTrim(rs1.getString("QTY_PER_ART"));
descr = checkNullAndTrim(rs1.getString("DESCR")); descr = checkNullAndTrim(rs1.getString("DESCR"));
unit = checkNullAndTrim(rs1.getString("UNIT")); unit = checkNullAndTrim(rs1.getString("UNIT"));
itemType = checkNullAndTrim(rs1.getString("ITEM_TYPE")); itemType = checkNullAndTrim(rs1.getString("ITEM_TYPE"));
mfgDate = checkNullAndTrim(rs1.getString("MFG_DATE")); mfgDate = checkNullAndTrim(rs1.getString("MFG_DATE"));
expiryDate = checkNullAndTrim(rs1.getString("EXP_DATE")); expiryDate = checkNullAndTrim(rs1.getString("EXP_DATE"));
palletStatus = CommonWmsUtil.getFullOrPrtialPalletOut(palletNo, refSer, tranId, siteCode, conn); palletStatus = CommonWmsUtil.getFullOrPrtialPalletOut(palletNo, refSer, tranId, siteCode, conn);
System.out.println("palletStatus for PRS" + palletStatus); System.out.println("palletStatus for PRS" + palletStatus);
HashMap hm = new HashMap(); HashMap hm = new HashMap();
hm.put("ITEM_CODE", itemCode); hm.put("ITEM_CODE", itemCode);
hm.put("REF_ID", tranId); hm.put("REF_ID", tranId);
hm.put("REF_SER", refSer); hm.put("REF_SER", refSer);
hm.put("TRAN_DATE", checkNullAndTrim(String.valueOf(today))); hm.put("TRAN_DATE", checkNullAndTrim(String.valueOf(today)));
hm.put("QTY_PER_ART", qtyPerArt); hm.put("QTY_PER_ART", qtyPerArt);
hm.put("LOT_NO", lotNo); hm.put("LOT_NO", lotNo);
hm.put("LOT_SL", lotSl); hm.put("LOT_SL", lotSl);
hm.put("QUANTITY", noArt); hm.put("QUANTITY", noArt);
hm.put("TOTAL_QTY", quantity); hm.put("TOTAL_QTY", quantity);
hm.put("PALLET_NO", palletNo); hm.put("PALLET_NO", palletNo);
hm.put("LINE_NO", lineNo); hm.put("LINE_NO", lineNo);
hm.put("DESCR", descr); hm.put("DESCR", descr);
hm.put("UNIT", unit); hm.put("UNIT", unit);
hm.put("ITEM_TYPE", itemType); hm.put("ITEM_TYPE", itemType);
hm.put("FAMILY_GRP", ""); hm.put("FAMILY_GRP", "");
hm.put("TRAN_ID", ""); hm.put("TRAN_ID", "");
hm.put("IN_OUT", "O"); hm.put("IN_OUT", "O");
hm.put("EXP_DATE", expiryDate); hm.put("EXP_DATE", expiryDate);
hm.put("MFG_DATE", mfgDate); hm.put("MFG_DATE", mfgDate);
hm.put("PALLET_STATUS", palletStatus); hm.put("PALLET_STATUS", palletStatus);
hm.put("MSG_STAT", "N"); hm.put("MSG_STAT", "N");
hm.put("LOCK_STAT", ""); hm.put("LOCK_STAT", "");
hm.put("ERR_COD", ""); hm.put("ERR_COD", "");
hm.put("ERR_DESC", ""); hm.put("ERR_DESC", "");
hm.put("QC_TYPE", ""); hm.put("QC_TYPE", "");
hm.put("TRANS_DT_ACK", ""); hm.put("TRANS_DT_ACK", "");
hm.put("STRO_PREF", ""); hm.put("STRO_PREF", "");
interfaceArrList.add(hm); interfaceArrList.add(hm);
System.out.println("interfacearraylist" + interfaceArrList.size()); System.out.println("interfacearraylist::PRS" + interfaceArrList.size());
} }
rs1.close(); rs1.close();
pstmt1.close(); pstmt1.close();
} }
else else
{ {
HashMap hm = new HashMap(); HashMap hm = new HashMap();
hm.put("REF_ID", tranId); hm.put("REF_ID", tranId);
hm.put("REF_SER", "PR"); hm.put("REF_SER", "PR");
hm.put("TRAN_DATE", checkNullAndTrim(String.valueOf(today))); hm.put("TRAN_DATE", checkNullAndTrim(String.valueOf(today)));
hm.put("PALLET_NO", palletNo); hm.put("PALLET_NO", palletNo);
hm.put("LINE_NO", lineNo); hm.put("LINE_NO", lineNo);
hm.put("DESCR", ""); hm.put("DESCR", "");
hm.put("UNIT", ""); hm.put("UNIT", "");
hm.put("ITEM_TYPE", ""); hm.put("ITEM_TYPE", "");
hm.put("FAMILY_GRP", ""); hm.put("FAMILY_GRP", "");
hm.put("TRAN_ID", ""); hm.put("TRAN_ID", "");
hm.put("IN_OUT", "O"); hm.put("IN_OUT", "O");
hm.put("EXP_DATE", ""); hm.put("EXP_DATE", "");
hm.put("MFG_DATE", ""); hm.put("MFG_DATE", "");
hm.put("PALLET_STATUS", palletStatus); hm.put("PALLET_STATUS", palletStatus);
hm.put("MSG_STAT", "N"); hm.put("MSG_STAT", "N");
hm.put("LOCK_STAT", ""); hm.put("LOCK_STAT", "");
hm.put("ERR_COD", ""); hm.put("ERR_COD", "");
hm.put("ERR_DESC", ""); hm.put("ERR_DESC", "");
hm.put("QC_TYPE", ""); hm.put("QC_TYPE", "");
hm.put("TRANS_DT_ACK", ""); hm.put("TRANS_DT_ACK", "");
hm.put("STRO_PREF", ""); hm.put("STRO_PREF", "");
interfaceArrList.add(hm); interfaceArrList.add(hm);
System.out.println("interfacearraylist" + interfaceArrList.size()); System.out.println("interfacearraylist::PR" + interfaceArrList.size());
} }
} }//IF TRAN_TYPE END
rs.close(); else
pstmt.close(); {
commonWmsUtility.updateAwmsInterface(interfaceArrList, siteCode, conn); System.out.println(" in rpz trantype");
HashMap hm = new HashMap();
hm.put("REF_ID", tranId);
hm.put("REF_SER", "RPZ");
hm.put("TRAN_DATE", checkNullAndTrim(String.valueOf(today)));
hm.put("PALLET_NO", palletNo);
hm.put("LINE_NO", lineNo);
hm.put("DESCR", "");
hm.put("UNIT", "");
hm.put("ITEM_TYPE", "");
hm.put("FAMILY_GRP", "");
hm.put("TRAN_ID", "");
hm.put("IN_OUT", "R");
hm.put("EXP_DATE", "");
hm.put("MFG_DATE", "");
hm.put("PALLET_STATUS", palletStatus);
hm.put("MSG_STAT", "N");
hm.put("LOCK_STAT", "");
hm.put("ERR_COD", "");
hm.put("ERR_DESC", "");
hm.put("QC_TYPE", "");
hm.put("TRANS_DT_ACK", "");
hm.put("STRO_PREF", "");
interfaceArrList.add(hm);
System.out.println("interfacearraylist::RPZ" + interfaceArrList.size());
}
}
rs.close();
pstmt.close();
commonWmsUtility.updateAwmsInterface(interfaceArrList, siteCode, conn);
System.out.println("Inserted into SWMS TO AWMS table ::::::::: "); System.out.println("Inserted into SWMS TO AWMS table ::::::::: ");
} }
catch (Exception e) catch (Exception e)
{ {
isError = true; isError = true;
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
finally finally
{ {
try try
{ {
System.out.println("is error in finally" + isError); System.out.println("is error in finally" + isError);
if (isError) if (isError)
{ {
conn.rollback(); conn.rollback();
} }
else else
{ {
conn.commit(); conn.commit();
errString = itmdbAccess.getErrorString("", "VMTRANSACN", "", "", conn); errString = itmdbAccess.getErrorString("", "VMTRANSACN", "", "", conn);
} }
if (conn != null) if (conn != null)
{ {
conn.close(); conn.close();
conn = null; conn = null;
} }
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
} }
/*try
{
int count;
System.out.println("is error in finally" + isError);
if (isError)
{
conn.rollback();
}
else
{
conn.commit();
errString = itmdbAccess.getErrorString("", "VMTRANSACN", "", "", conn);
}
if (conn != null)
{
conn.close();
conn = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}*/
return errString; return errString;
} }
private String checkNullAndTrim(String inputVal) private String checkNullAndTrim(String inputVal)
{ {
if (inputVal == null) if (inputVal == null)
{ {
inputVal = ""; inputVal = "";
} }
else else
{ {
inputVal = inputVal.trim(); inputVal = inputVal.trim();
} }
return inputVal; return inputVal;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment