Commit b59879d6 authored by msingh's avatar msingh

New process screen for generate shipper label.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@99949 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b43bce96
/**
* PURPOSE : DefaultItemChanged for shipper label generation process
* AUTHOR : Manish
* Obj_name : shipper_label
*/
package ibase.webitm.ejb.wms;
//changed by sumit on 03/10/12 imported class to find printer in system. start.
import java.awt.print.PrinterJob;
import java.io.File;
import javax.print.PrintService;
//changed by sumit on 03/10/12 imported class to find printer in system. end.
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.dis.SaleOrdItmGen;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
@javax.ejb.Stateless
public class GeneShipLabelsIC extends ValidatorEJB implements GeneShipLabelsICRemote, GeneShipLabelsICLocal{
/**
* The method defined with no parameter and returns nothing
*/
public String itemChanged() throws RemoteException, ITMException
{
return "";
}
/**
* The public method is used for itemchange of required fields which return called overloaded method
* Returns itemchange string in XML format
* @param currXmlDataStr contains the current form data in XML format
* @param hdrXmlDataStr containspoic_wavegen_default_data always header form data in XML format
* @param allXmlDataStr contains all forms data in XML format
* @param objContext represents form no
* @param currentColumn represent Current COlumn
* @param editFlag the mode of the transaction(A-Add or E-Edit)
* @param xtraParams contains additional information such as loginEmpCode,loginCode,chgTerm
etc
*/
public String itemChanged(String currXmlDataStr, String hdrXmlDataStr, String allXmlDataStr, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document currDom = null;
Document hdrDom = null;
Document allDom = null;
String errString = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
if (currXmlDataStr != null && currXmlDataStr.trim().length()!=0)
{
currDom = genericUtility.parseString(currXmlDataStr);
}
if (hdrXmlDataStr != null && hdrXmlDataStr.trim().length()!=0)
{
hdrDom = genericUtility.parseString(hdrXmlDataStr);
}
if (allXmlDataStr != null && allXmlDataStr.trim().length()!=0)
{
allDom = genericUtility.parseString(allXmlDataStr);
}
errString = defaultItemChanged( currDom, hdrDom, allDom, objContext, currentColumn, editFlag, xtraParams );
System.out.println ( "ErrString :" + errString);
}
catch (Exception e)
{
System.out.println ( "Exception :WaveGenerationIC :itemChanged(String,String):" + e.getMessage() + ":" );
errString = genericUtility.createErrorString(e);
}
System.out.println ( "returning from WaveGenerationIC itemChanged" );
return errString;
}
/**
* The public overloaded method is used for itemchange of required fields
* Returns itemchange string in XML format
* @param currDom contains the current form data
* @param hdrDom contains always header form data
* @param allDom contains all forms data
* @param objContext represents form no
* @param editFlag the mode of the transaction(A-Add or E-Edit)
* @param xtraParams contains additional information such as loginEmpCode,loginCode,chgTerm etc
*/
public String defaultItemChanged( Document currDom, Document hdrDom, Document allDom, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException
{
String siteCode = "";
String errString = "";
int currentFormNo = 0;
String columnValue = "";
String sql = "";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
StringBuffer valueXmlString = new StringBuffer( "<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n" );
GenericUtility genericUtility = GenericUtility.getInstance();
java.sql.Date dateFrom = null;
String packCode ="", tranCode = "", descr = "", tranName = "", printer = "";
try
{
String applDateFmt = genericUtility.getApplDateFormat();
String dbDateFmt = genericUtility.getDBDateFormat();
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
siteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
System.out.println("site code ->["+siteCode+"]");
String CurDom= genericUtility.serializeDom(currDom);
System.out.println("currDom ->["+CurDom+"]");
System.out.println("Current Column> > > > ->["+currentColumn+"]");
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
valueXmlString.append("</Header>\r\n" );
switch ( currentFormNo )
{
case 1:
{
if ( currentColumn.trim().equalsIgnoreCase( "itm_default" ))
{
System.out.println("--------------item default --------------");
valueXmlString.append( "<Detail1>\r\n" );
//valueXmlString.append( "<pack_code><![CDATA[" ).append(00).append( "]]></pack_code>\r\n" );
valueXmlString.append( "</Detail1>\r\n" );
System.out.println("valueXmlString-------["+valueXmlString+"]");
}
else if ( currentColumn.trim().equalsIgnoreCase( "pack_code" ))
{
System.out.println("--------------item Change for pack_code --------------");
packCode = genericUtility.getColumnValue("pack_code",currDom);
System.out.println("pack_code ["+packCode+"] ");
valueXmlString.append( "<Detail1>\r\n" );
if( (packCode !=null && packCode.trim().length() > 0) )
{
sql = " SELECT DESCR FROM PACKING WHERE PACK_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, packCode);
rs = pstmt.executeQuery();
if(rs.next())
{
valueXmlString.append( "<descr><![CDATA[" ).append(rs.getString(1) ).append( "]]></descr>\r\n" );
}
else
{
valueXmlString.append( "<descr><![CDATA[" ).append( "" ).append( "]]></descr>\r\n" );
}
}
else
{
valueXmlString.append( "<descr><![CDATA[" ).append( "" ).append( "]]></descr>\r\n" );
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
valueXmlString.append( "</Detail1>\r\n" );
}
else if ( currentColumn.trim().equalsIgnoreCase( "tran_code" ))
{
System.out.println("--------------item Change for tran_code --------------");
tranCode = genericUtility.getColumnValue("tran_code",currDom);
System.out.println("tran_code ["+tranCode+"] ");
valueXmlString.append( "<Detail1>\r\n" );
if( (tranCode !=null && tranCode.trim().length() > 0) )
{
sql = " SELECT TRAN_NAME FROM TRANSPORTER WHERE TRAN_CODE = ? ";
System.out.println("queryString="+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranCode);
rs =pstmt.executeQuery();
if(rs.next())
{
valueXmlString.append( "<tran_name><![CDATA[" ).append( rs.getString(1) ).append( "]]></tran_name>\r\n" );
}
else
{
valueXmlString.append( "<tran_name><![CDATA[" ).append( "" ).append( "]]></tran_name>\r\n" );
}
}
else
{
valueXmlString.append( "<tran_name><![CDATA[" ).append( "" ).append( "]]></tran_name>\r\n" );
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
valueXmlString.append( "</Detail1>\r\n" );
}
else if ( currentColumn.trim().equalsIgnoreCase( "PRINTER_NAME" ))
{
System.out.println("--------------item Change for printer --------------");
printer = genericUtility.getColumnValue("printer_name",currDom);
System.out.println("printer_name ["+printer+"] ");
valueXmlString.append( "<Detail1>\r\n" );
if( (printer !=null && printer.trim().length() > 0) )
{
sql = " SELECT PRINTER_DESCR FROM NET_PRINTERS WHERE PRINTER_NAME = ? ";
System.out.println("queryString="+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,printer);
rs =pstmt.executeQuery();
if(rs.next())
{
valueXmlString.append( "<printer_descr><![CDATA[" ).append( rs.getString(1) ).append( "]]></printer_descr>\r\n" );
}
else
{
valueXmlString.append( "<printer_descr><![CDATA[" ).append( "" ).append( "]]></printer_descr>\r\n" );
}
}
else
{
valueXmlString.append( "<printer_descr><![CDATA[" ).append( "" ).append( "]]></printer_descr>\r\n" );
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
valueXmlString.append( "</Detail1>\r\n" );
}
}
break;
}
valueXmlString.append( "</Root>\r\n" );
}
catch(Exception e)
{
System.out.println("Exception: WaveGenerationIC: defaultItemChanged(Document dom): " + e.getMessage() + ":");
e.printStackTrace();
errString = genericUtility.createErrorString(e);
}
finally
{
try
{
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception es)
{
es.printStackTrace();
errString = genericUtility.createErrorString(es);
}
}
return valueXmlString.toString();
}
private String checkNull( String inputVal )
{
if ( inputVal == null )
{
inputVal = "";
}
return inputVal;
}
/**
* 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 currFormDataDom = null;
Document hdrDataDom = null;
Document allFormDataDom = 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)
{
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);
}
errString = wfValData( currFormDataDom, hdrDataDom, allFormDataDom, objContext,editFlag, 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 currFormDataDom, Document hdrDataDom, Document allFormDataDom, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
System.out.println("wfValData()");
String columnValue ="";
String errString = "";
String sql ="";
String packCode ="";
String ptcn = "";
String printer = "";
String printLabel = "";
String printStatus = "";
String tranCode = "";
String imagePath = "";
int count = 0, cnt = 0;
//int rowCount = 0;
int noOfChilds = 0;
int noOfParent = 0;
GenericUtility genericUtility = GenericUtility.getInstance();
Connection conn = null;
PreparedStatement pstmt = null,pstmt1 = null;
ResultSet rs = null, rs1 = null;
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
String errorType = "", errCode = "";
ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList();
Set errSet = null;
DistCommon discommon = new DistCommon();
try
{
int currentFormNo = 0;
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB( "DriverITM" );
connDriver = null;
boolean packFlag=true;
boolean tranFlag=true;
String userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
if ( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
NodeList parentList = currFormDataDom.getElementsByTagName( "Detail" + currentFormNo );
NodeList childList = null;
noOfParent = parentList.getLength();
switch ( currentFormNo )
{
case 1:
{
childList = parentList.item(0).getChildNodes();
noOfChilds = childList.getLength();
for ( int ctr = 0; ctr < noOfChilds; ctr++ ) //Loop for each node of current detail
{
Node childNode = childList.item( ctr );
if( childNode.getNodeType() != Node.ELEMENT_NODE )
{
continue;
}
String childNodeName = childNode.getNodeName();
if ( childNode != null && childNode.getFirstChild() != null )
{
columnValue = childNode.getFirstChild().getNodeValue();
}
System.out.println(" columnName [" + childNodeName + "] columnValue [" + columnValue + "]");
if ( "ptcn".equalsIgnoreCase( childNodeName ) )
{
if (childNode.getFirstChild() == null)
{
errString = getErrorString("PTCN","VTPTCNNN",userId);
break ;
}
else
{
sql = "SELECT COUNT(*) FROM DESPATCH D, WAVE_TASK W, WAVE_TASK_DET WTD WHERE WTD.WAVE_ID = D.WAVE_ID AND D.CONFIRMED = 'N'" +
" AND WTD.SALE_ORDER = D.SORD_NO AND WTD.REF_ID = D.DESP_ID AND W.WAVE_ID = WTD.WAVE_ID AND W.CANCEL = 'N' AND W.HOLD_STATUS = 'N' AND WTD.PTCN = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, columnValue);
rs1 = pstmt1.executeQuery();
if( rs1.next() )
{
cnt = rs1.getInt(1);
if(cnt == 0)
{
errString = getErrorString("PTCN","VTPTCNNE",userId);
break ;
}
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}
}
else if (( "pack_code".equalsIgnoreCase( childNodeName )) || ( "tran_code".equalsIgnoreCase( childNodeName ) ))
{
packCode = genericUtility.getColumnValue("pack_code",currFormDataDom);
tranCode = genericUtility.getColumnValue("tran_code",currFormDataDom);
System.out.println("packCode man"+packCode);
System.out.println("tranCode man"+tranCode);
if(( packCode == null || packCode.trim().length() == 0 ) && ( tranCode == null || tranCode.trim().length() == 0 ) )
{
errString = getErrorString("","VTPACKTRAN",userId);
break ;
}
else if(packCode != null)
{
System.out.println("packCode manish"+packCode);
sql = "SELECT COUNT(*) FROM PACKING WHERE PACK_CODE = ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, packCode);
rs1 = pstmt1.executeQuery();
if( rs1.next() )
{
cnt = rs1.getInt(1);
if(cnt == 0)
{
errString = getErrorString("PACK_CODE","VMPACKCD",userId);
break ;
}
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}
else if(tranCode != null )
{
System.out.println("tranCode manish"+tranCode);
sql = "SELECT COUNT(*) FROM TRANSPORTER WHERE TRAN_CODE = ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, tranCode);
rs1 = pstmt1.executeQuery();
if( rs1.next() )
{
cnt = rs1.getInt(1);
if(cnt == 0)
{
errString = getErrorString("TRAN_CODE","VMTRAN1",userId);
break ;
}
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}
}
else if ( "printer_name".equalsIgnoreCase( childNodeName ) )
{
if (childNode.getFirstChild() == null)
{
System.out.println(".........no printer........");
}
else
{
sql = "SELECT COUNT(*) FROM NET_PRINTERS WHERE PRINTER_NAME = ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, columnValue);
rs1 = pstmt1.executeQuery();
if( rs1.next() )
{
cnt = rs1.getInt(1);
if(cnt == 0)
{
errString = getErrorString("PRINTER_NAME","INVPRINTER",userId);
break ;
}
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}
}
}
} //End of case 1 Validation
break;
}
}
catch ( Exception e )
{
System.out.println ( "Exception: WaveGenerationIC: wfValData( Document currFormDataDom ): " + e.getMessage() + ":" );
e.printStackTrace();
}
finally
{
try
{
if (rs!=null)
{
rs.close();
rs = null;
}
if( conn != null )
{
conn.close(); conn = null;
}
}
catch(Exception e)
{
System.out.println( "Exception : WaveGenerationIC:wfValData : " + e.getMessage() );
throw new ITMException(e);
}
}
System.out.println( "errString>>>>>>>::"+errString );
return errString;
}
}
/*
Author: Sumit Sarkar 07/03/12 of Req: WM1ESUN006
Reason: Interface Local for EJB Component WaveGenerationIC
*/
package ibase.webitm.ejb.wms;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
@javax.ejb.Local
public interface GeneShipLabelsICLocal extends ibase.webitm.ejb.ValidatorLocal
{
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 dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
//Changed by sumit on 18/09/12 adding validation start.
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 editFlag, String xtraParams) throws RemoteException, ITMException;
//Changed by sumit on 18/09/12 adding validation end.
}
/**
* Author: Sumit Sarkar 07/03/12 of Req: WM1ESUN006
* Reason: Interface Local for EJB Component WaveGenerationIC
*/
package ibase.webitm.ejb.wms;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
@javax.ejb.Remote
public interface GeneShipLabelsICRemote extends ibase.webitm.ejb.ValidatorRemote
{
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 dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
//Changed by sumit on 18/09/12 adding validation start.
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 editFlag, String xtraParams) throws RemoteException, ITMException;
//Changed by sumit on 18/09/12 adding validation end.
}
\ No newline at end of file
/**
* PURPOSE : Process for Fright Updation
* AUTHOR : Samadhan On 21/04/2015
* Obj_name : w_fright_upd
* Request Id: D15AKAT011
*/
package ibase.webitm.ejb.wms;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.net.URL;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Properties;
import java.util.TreeMap;
import javax.imageio.ImageIO;
import javax.naming.InitialContext;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import sun.misc.BASE64Decoder;
import com.adsionline.ADSIShippingWS.ADSIShippingLocator;
import com.adsionline.ADSIShippingWS.ADSIShippingSoap;
import com.adsionline.ADSIShippingWS.Carrier;
import com.adsionline.ADSIShippingWS.CommodityInfo;
import com.adsionline.ADSIShippingWS.Country;
import com.adsionline.ADSIShippingWS.EnumUnitOfMeasure;
import com.adsionline.ADSIShippingWS.ImageRotation;
import com.adsionline.ADSIShippingWS.Package2;
import com.adsionline.ADSIShippingWS.PackageResult2;
import com.adsionline.ADSIShippingWS.ShipWithLabelType;
import com.adsionline.ADSIShippingWS.Shipment2;
import com.adsionline.ADSIShippingWS.ShipmentResult2;
import com.adsionline.ADSIShippingWS.ShipmentResultReturn2;
import com.adsionline.ADSIShippingWS.StringReturn;
@javax.ejb.Stateless
public class GeneShipLabelsPrc extends ProcessEJB implements GeneShipLabelsPrcLocal,GeneShipLabelsPrcRemote //SessionBean
{
DistCommon discommon = new DistCommon();
GenericUtility genericUtility = GenericUtility.getInstance();
String chgUser = null;
public String process() throws RemoteException,ITMException
{
return "";
}
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String retStr = "";
Document detailDom = null;
Document headerDom = null;
GenericUtility genericUtility = GenericUtility.getInstance();
System.out.println("below genericUtility--------------->>>>>>>>>");
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
System.out.println("headerDom" + headerDom);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
System.out.println("detailDom" + detailDom);
}
long startTime22 = System.currentTimeMillis();
retStr = process(headerDom, detailDom, windowName, xtraParams);
long endTime22 = System.currentTimeMillis();
System.out.println("DIFFERANCE IN TIME FOR TOTAL PROCESS IN SECONDS:::["+(endTime22-startTime22)/1000+"]");
}
catch (Exception e)
{
System.out.println("Exception :StockAllocationPrcEJB :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
retStr = e.getMessage();
throw new ITMException(e);
}
return retStr;
}
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
System.out.println("detailDom------------------->"+detailDom);
String childNodeName = "", siteCode = "";
String errCode = "";
String errString = "";
String ptcn = "", tranCode = "", packCode = "";
String sql = "",upddCartonsql = "" ,sqlChgStatus = "",sqlPrintStatus = "",
sqlMaster = "",sqlCrtnChg = "",sqlGetTrack = "";
String printStatus = "";
String confirmed = "";
String adsiShippingURL = "",imagePath = "";
String masterCarton = "",itemCode = "",trackingNo = "",parcelCartonNo = "",
cartonStatus = "",chgStatus = "";
String tempItemCode = "";
String value = "",outerCartonNo = "",trackNo = "",pckgId = "";
long msnNo = 0;
String packTranId = "",serviceCode = "",saleOrder = "", waveId = "";
String printer = "";
long oldMsnNo = 0;
String oldCarrierSymbol = "",carrierSymbol ="";
String oldCarrierFriendlyName = "",carrierFriendlyName = "";
String response = "",refType = "",frtTerm = "",sSQL = "";
Connection conn = null;
int parentNodeListLength = 0;
int childNodeListLength = 0;
int count = 0,noArt = 0;
int package2ArrSize = 0;
double packSize = 0.0;
double weight = 0.0,actWeight = 0.0,itemWeght = 0.0,shipQty = 0.0 ;
String packlength = "", packwidth = "", packheight = "";
double totalFrtAmt = 0.0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
PreparedStatement pstmt = null,pstmt1 = null,ptcnPSTMT = null,
pstmtUpdCarton = null,pstmtChg = null, pstmtPrintStatus = null,
pstmtMaster = null,pstmtCrtnChg = null,pstmtGetTrack = null,pstmtDesp = null;
ResultSet rs = null,rs1 = null,ptcnRS = null ,rsPrintStatus = null,
rsMaster = null,rsGetTrack = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
ADSIShippingLocator locator = null;
ADSIShippingSoap soap = null;
List arryOuterCartonNo = new ArrayList();
LinkedHashMap linkedMap = new LinkedHashMap();
ArrayList ptcnList = new ArrayList();
int pUpd = 0;
String glblPTCN = "";
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
/*chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");*/
parentNodeList = headerDom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(int ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName.editFlag." + childNodeName+".."+childNode.getFirstChild());
}
siteCode = genericUtility.getColumnValue("site_code",headerDom);
ptcn = genericUtility.getColumnValue("ptcn",headerDom);
packCode = genericUtility.getColumnValue("pack_code",headerDom);
tranCode = genericUtility.getColumnValue("tran_code",headerDom);
printer = genericUtility.getColumnValue("printer_name",headerDom);
System.out.println("ptcn: "+ptcn);
System.out.println("packCode: "+packCode);
System.out.println("tranCode: "+tranCode);
System.out.println("printer: "+printer);
upddCartonsql = "UPDATE CARTON_MASTER SET PACK_CODE = ?,TRACKING_NO = ?,MSN_NO = ? ,CARRIER_SYMBOL = ?,CARRIER_FRIENDLYNAME = ? WHERE CARTON_NO = ?";
pstmtUpdCarton = conn.prepareStatement(upddCartonsql);
sqlChgStatus = "UPDATE WAVE_STATUS_ORG SET PRINT_STATUS = ?,TRAN_CODE__NEW =(SELECT TRAN_CODE FROM DESPATCH WHERE PTCN =?) WHERE PTCN = ?";
pstmtChg = conn.prepareStatement(sqlChgStatus);
sqlPrintStatus = "SELECT DISTINCT PRINT_STATUS FROM WAVE_STATUS_ORG WHERE PTCN = ?";
pstmtPrintStatus = conn.prepareStatement(sqlPrintStatus);
sqlMaster = "SELECT MASTER_CARTON,TRACKING_NO,CARTON_NO,STATUS,CHANGE_STATUS,MSN_NO,CARRIER_SYMBOL,CARRIER_FRIENDLYNAME,CARTON_TYPE " +
" ,FILLER_WEIGHT,TARE_WEIGHT " +
" FROM CARTON_MASTER WHERE PTCN = ? AND CARTON_TYPE <> ? ORDER BY CARTON_NO,MASTER_CARTON";
pstmtMaster = conn.prepareStatement(sqlMaster);
sqlCrtnChg = "UPDATE CARTON_MASTER SET CHANGE_STATUS = ? WHERE PTCN = ?";
pstmtCrtnChg = conn.prepareStatement(sqlCrtnChg);
sqlGetTrack = " SELECT TRACKING_NO,MSN_NO,CARRIER_SYMBOL , CARRIER_FRIENDLYNAME FROM CARTON_MASTER WHERE CARTON_NO = ?";
pstmtGetTrack = conn.prepareStatement(sqlGetTrack);
long timeBefore = System.currentTimeMillis();
adsiShippingURL = discommon.getDisparams("999999","WMS_ADSI_SOAP_URL",conn);
imagePath = discommon.getDisparams("999999","SHIP_WITH_PATH",conn);
System.out.println("adsiShippingURL -->"+adsiShippingURL);
System.out.println("imagePath -->"+imagePath);
locator = new ADSIShippingLocator();
System.out.println(" Connecting ADSI server ................");
soap = locator.getADSIShippingSoap(new URL(adsiShippingURL));
long timeAfter = System.currentTimeMillis();
System.out.println(" is server active ["+soap.testADSIServer()+"]");
if(!soap.testADSIServer())
{
errString = itmDBAccessEJB.getErrorString("","ADSISRVERR","","",conn);
return errString;
}
if( ptcn.trim().length() > 0 && packCode == null)
{
sql = "SELECT DISTINCT(S.PACK_CODE) FROM WAVE_TASK_DET W, SORDDET S WHERE W.SALE_ORDER = S.SALE_ORDER AND W.PTCN = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ptcn);
rs = pstmt.executeQuery();
if( rs.next())
{
packCode = rs.getString(1);
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
System.out.println("old packCode : "+packCode);
}
if( ptcn.trim().length() > 0 && tranCode == null)
{
sql = "SELECT DISTINCT(S.TRAN_CODE) FROM WAVE_TASK_DET W, SORDER S WHERE W.SALE_ORDER = S.SALE_ORDER AND W.PTCN = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ptcn);
rs = pstmt.executeQuery();
if( rs.next())
{
tranCode = rs.getString(1);
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
System.out.println("old tranCode: "+tranCode);
}
if(( packCode.trim().length() > 0 && ptcn.trim().length() > 0 ) || ( tranCode.trim().length() > 0 && ptcn.trim().length() > 0 ))
{
sql = " SELECT DISTINCT PTCN,SALE_ORDER,REF_TYPE FROM WAVE_TASK_DET WHERE PTCN = ? AND REF_TYPE IN (?,?,?) ";
ptcnPSTMT = conn.prepareStatement(sql);
ptcnPSTMT.setString(1, ptcn);
ptcnPSTMT.setString(2, "M");
ptcnPSTMT.setString(3, "P");
ptcnPSTMT.setString(4, "A");
ptcnRS = ptcnPSTMT.executeQuery();
}
while(ptcnRS.next())
{
saleOrder = ptcnRS.getString("SALE_ORDER");
ptcn = ptcnRS.getString("PTCN");
refType = ptcnRS.getString("REF_TYPE");
if(ptcnList.contains(ptcn))
{
continue;
}
else
{
ptcnList.add(ptcn);
}
pstmtPrintStatus.setString(1, ptcn);
rsPrintStatus = pstmtPrintStatus.executeQuery();
if(rsPrintStatus.next())
{
printStatus = rsPrintStatus.getString("PRINT_STATUS");
}
//serviceCode = isTranCodeChanged(ptcn, conn);
//serviceCode = "UPSGND";
sql = "SELECT SERVICE_CODE FROM TRANSPORTER WHERE TRAN_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranCode);
rs = pstmt.executeQuery();
if( rs.next() )
{
serviceCode = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "SELECT DISTINCT(WAVE_ID) FROM WAVE_TASK_DET WHERE PTCN = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ptcn);
rs = pstmt.executeQuery();
if( rs.next() )
{
waveId = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("wave id is ---["+waveId+"]");
System.out.println("printStatus ["+printStatus+"] serviceCode ["+serviceCode+"]");
if( "Y".equalsIgnoreCase(printStatus) && "NO".equalsIgnoreCase(serviceCode))
{
/*errString = itmDBAccessEJB.getErrorString("","ALLREPRINT","","",conn);
return errString;*/
continue;
}
File file = new File(imagePath+ File.separator+"Ship_Label"+File.separator+ ptcn + File.separator + ptcn+"_"+"Ship"+".ser" );
System.out.println("file IS ["+file+"]");
if(!file.exists())
{
errString = itmDBAccessEJB.getErrorString("","FILENFOUND","");
return errString;
}
FileInputStream fis = new FileInputStream(imagePath+ File.separator+"Ship_Label"+File.separator+ ptcn + File.separator + ptcn+"_"+"Ship"+".ser" );
ObjectInputStream ois = new ObjectInputStream(fis);
System.out.println(" file loaded ");
Shipment2 shipment2 = (Shipment2) ois.readObject();
System.out.println("objReturn2 ["+shipment2.getPackages2().length+"]" );
package2ArrSize = shipment2.getPackages2().length;
System.out.println("package2ArrSize ["+package2ArrSize+"]");
Package2[] packages2 = new Package2[package2ArrSize];
packages2 = shipment2.getPackages2();
com.adsionline.ADSIShippingWS.Service service = new com.adsionline.ADSIShippingWS.Service();
service = shipment2.getService();
System.out.println("Retriving the Package For update ["+packages2.toString()+"]");
if( !"NO".equalsIgnoreCase(serviceCode))
{
System.out.println(" old service code ["+service.getFriendlyName()+"]");
System.out.println(" new service code ["+serviceCode+"]");
service.setFriendlyName(serviceCode);
}
if( "N".equalsIgnoreCase(printStatus) || !"NO".equalsIgnoreCase(serviceCode) )
{
pstmtMaster.setString(1, ptcn);
pstmtMaster.setString(2, "C");
rsMaster = pstmtMaster.executeQuery();
double fillerWt=0.0;
double tareWt=0.0;
while(rsMaster.next())
{
fillerWt=0.0;
tareWt=0.0;
linkedMap.clear();
masterCarton = rsMaster.getString("MASTER_CARTON");
System.out.println("masterCarton ["+masterCarton+"]");
parcelCartonNo = rsMaster.getString("CARTON_NO");
cartonStatus = rsMaster.getString("STATUS");
chgStatus = rsMaster.getString("CHANGE_STATUS");
oldMsnNo = rsMaster.getLong("MSN_NO");
oldCarrierSymbol = rsMaster.getString("CARRIER_SYMBOL");
refType = rsMaster.getString("CARTON_TYPE");
System.out.println("parcelCartonNo ["+parcelCartonNo+"]CARRIER_SYMBOL["+oldCarrierSymbol+"]["+oldMsnNo+"]Change Status["+chgStatus+"]");
if("M".equalsIgnoreCase(refType))
{
boolean isExist = false;
tempItemCode = "";
int itemCount = 0;
sql = " SELECT CM.ITEM_CODE,WOD.WEIGHT FROM CARTON_MASTER CM, WAVE_STATUS_ORG_DET WOD WHERE CM.PTCN = WOD.PTCN " +
" AND CM.CARTON_NO = WOD.CARTON_NO AND CM.MASTER_CARTON = ? AND CM.CARTON_TYPE = ? AND CM.STATUS <> ? " +
" ORDER BY CM.ITEM_CODE";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, masterCarton);
pstmt1.setString(2, "C");
pstmt1.setString(3, "R");
rs1 = pstmt1.executeQuery();
while( rs1.next())
{
isExist = true;
packSize = rs1.getDouble("WEIGHT");
itemCode = rs1.getString("ITEM_CODE");
weight = weight + packSize;
linkedMap.put(itemCode, weight);
}
System.out.println("Map data ["+linkedMap.toString()+"]");
rs1.close(); rs1 = null;
pstmt1.close(); pstmt1 = null;
if("R".equalsIgnoreCase(cartonStatus))
{
if(packages2[count] != null)
{
System.out.println("UPDATING For MSN NO R ["+packages2[count].getTrackingNumber()+"]");
System.out.println("UPDATING For MSN NO R ["+packages2[count].getWeight()+"]");
}
packages2[count] = null;
System.out.println("CHANGES NOT EXIST[" +count+"]Master Carton ["+masterCarton+"]chgStatus["+chgStatus+"]");
if("Y".equalsIgnoreCase(chgStatus))
{
StringReturn testReturn = soap.voidPackage(oldCarrierSymbol,oldMsnNo);
response = testReturn.getResponse();
System.out.println("response Master Carton void----["+response+"] for master carton["+masterCarton+"]");
}
count++;
continue;
}
else
{
if( weight > 0.0)
{
if(packages2[count] != null)
{
System.out.println("UPDATING For MSN NO weight ["+packages2[count].getTrackingNumber()+"]");
System.out.println("UPDATING For MSN NO weight ["+packages2[count].getWeight()+"]");
}
arryOuterCartonNo.add(masterCarton);
CommodityInfo[] comInfo = new CommodityInfo[linkedMap.size()];
comInfo = setCommodityInfos(linkedMap, masterCarton, saleOrder, soap,refType, conn);
System.out.println("old weight ["+packages2[count].getWeight()+"]");
System.out.println("new weight ["+weight+"]");
System.out.println("weight afer add f and t wt ====>[[[[ "+weight);
fillerWt=rsMaster.getDouble("FILLER_WEIGHT");
tareWt=rsMaster.getDouble("TARE_WEIGHT");
System.out.println("FILLER_WEIGHT====>[[[[ "+fillerWt);
System.out.println("TARE_WEIGHT====>[[[[ "+tareWt);
weight = weight + fillerWt + tareWt;
System.out.println("weight + TARE_WEIGHT + tareWt ====>[[[[ "+weight);
packages2[count].setWeight(weight);
System.out.println("old comodity info length ["+packages2[count].getCommodityInfos().length+"]");
System.out.println("new comodity info length ["+comInfo.length+"]");
packages2[count].setCommodityInfos(comInfo);
}
else
{
if(packages2[count] != null)
{
System.out.println("UPDATING For MSN NO void ["+packages2[count].getTrackingNumber()+"]");
System.out.println("UPDATING For MSN NO void ["+packages2[count].getWeight()+"]");
}
System.out.println("In case of weight zero ["+weight+"]");
packages2[count] = null;
System.out.println("ON ELSE BLOCK CHANGES NOT EXIST[" +count+"]Master Carton ["+masterCarton+"]chgStatus["+chgStatus+"]");
if("Y".equalsIgnoreCase(chgStatus))
{
StringReturn testReturn = soap.voidPackage(oldCarrierSymbol,oldMsnNo);
response = testReturn.getResponse();
System.out.println("on else response Master Carton void----["+response+"] for master carton["+masterCarton+"]");
}
}
count++;
}
weight = 0;
System.out.println(" arryOuterCartonNo.size ["+arryOuterCartonNo.size()+"]");
}
else
{
if("R".equalsIgnoreCase(cartonStatus))
{
packages2[count] = null;
StringReturn testReturn = soap.voidPackage(oldCarrierSymbol,oldMsnNo);
response = testReturn.getResponse();
System.out.println("response Parcel void----["+response+"]");
}
else
{
arryOuterCartonNo.add(parcelCartonNo);
System.out.println("for ref typ["+refType+"]");
if("A".equalsIgnoreCase(refType) )
{
sql = "SELECT ITEM_CODE,SUM(QUANTITY - CASE WHEN DEALLOC_QTY IS NULL THEN 0 ELSE CASE WHEN DEALLOC_QTY IS NULL"
+" THEN 0 ELSE DEALLOC_QTY END END) AS QTY FROM PICK_ORD_DET WHERE CARTON_NO = ? GROUP BY ITEM_CODE";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, parcelCartonNo);
rs1 = pstmt1.executeQuery();
while( rs1.next())
{
itemCode = rs1.getString("ITEM_CODE");
shipQty = rs1.getDouble("QTY");
HashMap itmVolumeMap = getItemVolumeMap(itemCode, "", conn);
itemWeght = (Double)itmVolumeMap.get("ITEM_WEIGHT");
weight = weight + itemWeght * shipQty;
linkedMap.put(itemCode, shipQty);
}
rs1.close(); rs1 = null;
pstmt1.close(); pstmt1 = null;
System.out.println("Map data A ["+linkedMap.toString()+"]");
CommodityInfo[] comInfo = new CommodityInfo[linkedMap.size()];
comInfo = setCommodityInfos(linkedMap, masterCarton, saleOrder, soap,refType, conn);
System.out.println("old weight ["+packages2[count].getWeight()+"]");
System.out.println("new weight ["+weight+"]");
System.out.println("weight afer add f and t wt ====>[[[[ "+weight);
fillerWt=rsMaster.getDouble("FILLER_WEIGHT");
tareWt=rsMaster.getDouble("TARE_WEIGHT");
System.out.println("FILLER_WEIGHT====>[[[[ "+fillerWt);
System.out.println("TARE_WEIGHT====>[[[[ "+tareWt);
weight = weight + fillerWt + tareWt;
System.out.println("weight + TARE_WEIGHT + tareWt ====>[[[[ "+weight);
sql = " SELECT LENGTH,WIDTH,HEIGHT FROM PACKING WHERE PACK_CODE = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, packCode);
rs1 = pstmt1.executeQuery();
if( rs1.next())
{
packlength = rs1.getString(1);
packwidth = rs1.getString(2);
packheight = rs1.getString(3);
}
rs1.close(); rs1 = null;
pstmt1.close(); pstmt1 = null;
packages2[count].setWeight(weight);
packages2[count].setDimension(packlength+"x"+packwidth+"x"+packheight);
System.out.println("old comodity info length ["+packages2[count].getCommodityInfos().length+"]");
System.out.println("new comodity info length ["+comInfo.length+"]");
packages2[count].setCommodityInfos(comInfo);
}
}
oldMsnNo = 0;oldCarrierSymbol = "";
oldCarrierFriendlyName = "";
count++;
}
}
pstmtMaster.clearParameters();
if( rsMaster != null)
{
rsMaster.close();
rsMaster = null;
}
}
if( arryOuterCartonNo.size() == 0)
{
pstmtCrtnChg.setString(1, "N");
pstmtCrtnChg.setString(2, ptcn);
pstmtCrtnChg.executeUpdate();
pstmtChg.setString(1, "Y");
pstmtChg.setString(2, ptcn);
pstmtChg.setString(3, ptcn);
int test = pstmtChg.executeUpdate();
errString = itmDBAccessEJB.getErrorString("Void Records Successfully","NOTHING2PR","");
System.out.println("Only Voiding the Error ["+errString+"]");
errString = "";
}
else
{
System.out.println("arryOuterCartonNo ["+arryOuterCartonNo.toString()+"]");
System.out.println("actual package size ["+packages2.length+"]");
Collections.sort(arryOuterCartonNo);
shipment2.setPackages2(packages2);
java.util.Date date = new java.util.Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
shipment2.setShipDate(calendar);
System.out.println("Generating Label for the date ["+calendar.getTime().getTime()+"]");
ShipmentResultReturn2 objReturn2=soap.shipWithLabel(shipment2, ShipWithLabelType.PNG, ImageRotation.Rotation_Default);
System.out.println("Is successfully Executed ["+objReturn2.isSuccess()+"]");
System.out.println("Return Messages ["+objReturn2.getMessage()+"]");
if(!objReturn2.isSuccess())
{
errString = getError(objReturn2.getMessage(),"SOAPURLUAL", conn);
return errString;
}
else
{
ShipmentResult2 objShipResult = objReturn2.getShipmentResultResponse2();
int lenPacakges = objShipResult.getPackageResults2().length;
carrierSymbol= objShipResult.getServiceSymbol();
System.out.println("serviceSymbol["+carrierSymbol+"]");
carrierSymbol = carrierSymbol.substring(0,carrierSymbol.lastIndexOf(".") );
System.out.println("Carrier Symbol ["+carrierSymbol+"]");
Carrier[] carr = soap.getCarriers().getCarrierList();
for(int j = 0;j<carr.length;j++)
{
Carrier carr1 = carr[j];
System.out.println("Carrier Symbol["+carr1.getSymbol());
System.out.println("Friendly Name["+carr1.getFriendlyName());
System.out.println("Short Name["+carr1.getShortName());
if(carr1.getSymbol().equalsIgnoreCase(carrierSymbol))
{
carrierFriendlyName = carr1.getFriendlyName();
break;
}
}
for(int pCtr=0;pCtr < lenPacakges;pCtr++)
{
PackageResult2 pkg2frm = (PackageResult2)objShipResult.getPackageResults2()[pCtr];
value = pkg2frm.getBase64Label();
pckgId = pkg2frm.getPackageID();
pkg2frm.getAdditionalFields();
trackNo = pkg2frm.getTrackingNumber();
msnNo = pkg2frm.getMSN();
for(int Cadd=0;Cadd<pkg2frm.getAdditionalFields().length;Cadd++)
{
System.out.println("additional fields are Name:"+pkg2frm.getAdditionalFields()[Cadd].getName());
System.out.println("additional fields are Value:"+pkg2frm.getAdditionalFields()[Cadd].getValue());
}
String cnumber = arryOuterCartonNo.get(pCtr).toString();
System.out.println("cnumber is :"+cnumber);
System.out.println("Package ID["+pckgId+"]");
System.out.println("New Tracking No --------------["+pkg2frm.getTrackingNumber()+"]");
System.out.println("NeW MSN No -------------------["+msnNo+"]");
System.out.println("BASE64lABEL Length["+value.length()+"]");
BASE64Decoder decoder = new BASE64Decoder();
System.out.println("Package id for carton no is :[" +decoder.decodeBuffer(pckgId) +"]");
byte[] imgBytes = decoder.decodeBuffer(value);
System.out.println("IMAGE Byte Length ["+imgBytes.length+"]");
BufferedImage bufImg = ImageIO.read(new ByteArrayInputStream(imgBytes));
File imgOutFile = new File(imagePath+ File.separator+"Ship_Label"+File.separator+ ptcn + File.separator + ptcn+"_"+cnumber +".png");
File file1 = new File(imagePath+ File.separator+"Ship_Label"+File.separator+ ptcn + File.separator + ptcn+"_"+cnumber +".png");
if(!file1.exists())
{
//errString = itmDBAccessEJB.getErrorString("","FILENFOUND","");
//return errString;
}
else
{
File oldFile = new File(imagePath+ File.separator+"Ship_Label"+File.separator+ ptcn + File.separator + ptcn+"_"+cnumber +"_old.png");
if(!oldFile.exists())
{
file1.renameTo(oldFile);
}
}
String path = imgOutFile.getPath();
System.out.println("Get Path ["+path+"]");
path = path.substring(0,path.lastIndexOf(File.separator));
System.out.println("after Path ["+path+"]");
File createFolder = new File(path);
if(!createFolder.exists())
{
createFolder.mkdirs();
}
pstmtGetTrack.setString(1, cnumber);
rsGetTrack = pstmtGetTrack.executeQuery();
if( rsGetTrack.next() )
{
oldMsnNo = rsGetTrack.getLong("MSN_NO");
oldCarrierSymbol = rsGetTrack.getString("CARRIER_SYMBOL");
oldCarrierFriendlyName = rsGetTrack.getString("CARRIER_FRIENDLYNAME");
if(oldMsnNo != 0 && oldMsnNo != msnNo)
{
StringReturn testReturn = soap.voidPackage(oldCarrierSymbol,oldMsnNo);
response = testReturn.getResponse();
System.out.println("response delete not old msn as new msn["+response+"]");
if(!response.contains("No Error"))
{
//errString = itmDBAccessEJB.getErrorString(response,"NTVOIDPKGS","");
//errString = getError(response, "NTVOIDPKGS", conn);
//return errString;
}
}
}
pstmtGetTrack.clearParameters();
pstmtUpdCarton.setString(1, packCode);
pstmtUpdCarton.setString(2, trackNo);
pstmtUpdCarton.setLong(3, msnNo);
pstmtUpdCarton.setString(4, carrierSymbol);
pstmtUpdCarton.setString(5, carrierFriendlyName);
pstmtUpdCarton.setString(6, cnumber);
int test = pstmtUpdCarton.executeUpdate();
System.out.println("update statement is :"+test);
if(test==1)
{
System.out.println("updated");
}
else
{
System.out.println("not updated");
}
imgOutFile.createNewFile();
ImageIO.write(bufImg, "png", imgOutFile);
System.out.println("Write File Complete----");
}
pstmtChg.setString(1, "Y");
pstmtChg.setString(2, ptcn);
pstmtChg.setString(3, ptcn);
int test = pstmtChg.executeUpdate();
if( test > 0)
{
System.out.println(" WAVE_STATUS_ORG table updated ");
int wavOrgUpdCount = reUpdateWaveOrgMasterCartonNo(ptcn, conn);
System.out.println(" WAVE_STATUS_ORG_DET table updated ["+wavOrgUpdCount+"]");
}
else
{
throw new Exception("WAVE_STATUS_ORG table table updated");
}
pstmtCrtnChg.setString(1, "N");
pstmtCrtnChg.setString(2, ptcn);
test = pstmtCrtnChg.executeUpdate();
if( test > 0)
{
System.out.println("Carton Master table updated ");
}
else
{
throw new Exception("Carton Master updated");
}
HashMap sordMap = getSordInfo(saleOrder,conn);
frtTerm = (String)sordMap.get("FRT_TERM");
totalFrtAmt = objShipResult.getTotal();
System.out.println("Update in desp update freight Amt totalFrtAmt ["+totalFrtAmt+"] For frtTerm["+frtTerm+"]saleOrder["+saleOrder+"]");
if("B".equalsIgnoreCase(frtTerm))
{
sSQL = "UPDATE DESPATCH SET FREIGHT_AMT_ADD = ? WHERE PTCN = ?";
pstmtDesp = conn.prepareStatement(sSQL);
pstmtDesp.setDouble(1, totalFrtAmt);
pstmtDesp.setString(2, ptcn);
pUpd = pstmtDesp.executeUpdate();
System.out.println("Update in desp update freight Amt upd ["+pUpd+"] For");
if(pstmtDesp != null)
{
pstmtDesp.close();
pstmtDesp = null;
}
sSQL = "UPDATE SHIP_DOCS SET FREIGHT_AMT_ADD = ? WHERE PTCN = ?";
pstmtDesp = conn.prepareStatement(sSQL);
pstmtDesp.setDouble(1, totalFrtAmt);
pstmtDesp.setString(2, ptcn);
pUpd = pstmtDesp.executeUpdate();
System.out.println("Update in Ship Docs update freight Amt upd ["+pUpd+"] For");
if(pstmtDesp != null)
{
pstmtDesp.close();
pstmtDesp = null;
}
}
}
}
}
if(ptcnRS != null)
{
ptcnRS.close();
ptcnRS = null;
}
if(ptcnPSTMT != null)
{
ptcnPSTMT.close();
ptcnPSTMT = null;
}
if(pstmtUpdCarton != null)
{
pstmtUpdCarton.close();
pstmtUpdCarton = null;
}
if(pstmtChg != null)
{
pstmtChg.close();
pstmtChg = null;
}
if(rsPrintStatus != null)
{
rsPrintStatus.close();
rsPrintStatus = null;
}
if(pstmtPrintStatus != null)
{
pstmtPrintStatus.close();
pstmtPrintStatus = null;
}
if( rsMaster != null)
{
rsMaster.close();
rsMaster = null;
}
if(pstmtCrtnChg != null)
{
pstmtCrtnChg.close();
pstmtCrtnChg = null;
}
if(pstmtMaster != null)
{
pstmtMaster.close();
pstmtMaster = null;
}
if(pstmtGetTrack != null)
{
pstmtGetTrack.close();
pstmtGetTrack = null;
}
if(rsGetTrack != null)
{
rsGetTrack.close();
rsGetTrack = null;
}
if(printer != null && printer.trim().length()>0)
{
errString = generatedLabelPrint(waveId,glblPTCN, printer, conn);
}
}
catch(Exception e)
{
try
{
conn.rollback();
}
catch(Exception es)
{
es.printStackTrace();
errString = es.getMessage();
throw new ITMException(es);
}
e.printStackTrace();
System.out.println("Exception :GenerateLabels :process(String xmlString2, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
errString = e.getMessage();
throw new ITMException(e);
}
finally
{
//System.out.println("Closing Connection....");
try
{
if(rs1 != null)
{
rs1.close(); rs1 = null;
}
if(pstmt1 != null)
{
pstmt1.close(); pstmt1 = null;
}
if( rs != null)
{
rs.close(); rs = null;
}
if( pstmt != null)
{
pstmt.close(); pstmt = null;
}
if(ptcnRS != null)
{
ptcnRS.close();
ptcnRS = null;
}
if(ptcnPSTMT != null)
{
ptcnPSTMT.close();
ptcnPSTMT = null;
}
if(pstmtUpdCarton != null)
{
pstmtUpdCarton.close();
pstmtUpdCarton = null;
}
if(pstmtChg != null)
{
pstmtChg.close();
pstmtChg = null;
}
if(rsPrintStatus != null)
{
rsPrintStatus.close();
rsPrintStatus = null;
}
if(pstmtPrintStatus != null)
{
pstmtPrintStatus.close();
pstmtPrintStatus = null;
}
if( rsMaster != null)
{
rsMaster.close();
rsMaster = null;
}
if(pstmtCrtnChg != null)
{
pstmtCrtnChg.close();
pstmtCrtnChg = null;
}
if(pstmtMaster != null)
{
pstmtMaster.close();
pstmtMaster = null;
}
if (errString != null && errString.trim().length() > 0)
{
conn.rollback();
System.out.println("errString ::::::::::::::::::::"+errString);
return errString;
}
else
{
conn.commit();
}
if( errString.trim().length() == 0 )
{
errString="VTCOMPL";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
}
if( conn != null )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
errString = e.getMessage();
e.printStackTrace();
throw new ITMException(e);
}
finally
{
/*if( errString.trim().length() == 0 )
{
errString="VTCOMPL";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
}*/
//return errString;
}
}
return errString;
/*catch(Exception e)
{
try
{
conn.rollback();
}
catch(Exception es)
{
es.printStackTrace();
errString = es.getMessage();
throw new ITMException(es);
}
e.printStackTrace();
System.out.println("Exception :GenerateLabels :process(String xmlString2, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
errString = e.getMessage();
throw new ITMException(e);
}
//=========================
return errString;*/
}
public String isTranCodeChanged(String ptcn, Connection conn) throws ITMException
{
String sql = "";
String shipTranCode = "",cartonMasterTranCode = "";
String errString = "";
String serviceCode = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
String siteCodeShip= "";
try
{
sql = "SELECT TRAN_CODE FROM WAVE_STATUS_ORG WHERE PTCN = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ptcn);
rs = pstmt.executeQuery();
if(rs.next())
{
cartonMasterTranCode = rs.getString("TRAN_CODE");
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
sql = " SELECT DISTINCT S.SITE_CODE__SHIP FROM SORDER S, WAVE_TASK W, WAVE_TASK_DET WT " +
" WHERE W.WAVE_ID = WT.WAVE_ID AND S.SALE_ORDER = WT.SALE_ORDER AND WT.PTCN = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, ptcn );
rs = pstmt.executeQuery();
if( rs.next() )
{
siteCodeShip = checkNull(rs.getString("SITE_CODE__SHIP"));
}
rs.close();rs = null;
pstmt.close();pstmt = null;
sql = "SELECT ST.TRAN_CODE, ST.SERVICE_CODE FROM SHIPMENT S, SHIP_DOCS SD, SITE_TRANSPORTER ST WHERE SD.PTCN = ? " +
" AND S.SHIPMENT_ID = SD.SHIPMENT_ID AND S.TRAN_CODE = ST.TRAN_CODE AND ST.SITE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ptcn);
pstmt.setString(2, siteCodeShip);
rs = pstmt.executeQuery();
if(rs.next())
{
System.out.println("from site_transporter");
shipTranCode = rs.getString("TRAN_CODE");
serviceCode = rs.getString("SERVICE_CODE");
}
else
{
System.out.println("from transporter");
sql = " SELECT S.TRAN_CODE,T.SERVICE_CODE FROM SHIPMENT S , SHIP_DOCS SD, TRANSPORTER T WHERE SD.PTCN = ? " +
" AND S.SHIPMENT_ID = SD.SHIPMENT_ID AND S.TRAN_CODE = T.TRAN_CODE ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ptcn);
rs = pstmt.executeQuery();
if(rs.next())
{
shipTranCode = rs.getString("TRAN_CODE");
serviceCode = rs.getString("SERVICE_CODE");
}
else
{
rs.close(); rs = null;
pstmt.close(); pstmt = null;
sql = "SELECT ST.TRAN_CODE,ST.SERVICE_CODE FROM DESPATCH D,WAVE_TASK_DET W, SITE_TRANSPORTER ST "
+" WHERE D.DESP_ID = W.REF_ID AND W.REF_SER='S-DSP'"
+" AND ST.TRAN_CODE = D.TRAN_CODE AND W.PTCN = ? AND ST.SITE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ptcn);
pstmt.setString(2, siteCodeShip);
rs = pstmt.executeQuery();
if(rs.next())
{
shipTranCode = rs.getString("TRAN_CODE");
serviceCode = rs.getString("SERVICE_CODE");
}
else
{
rs.close(); rs = null;
pstmt.close(); pstmt = null;
sql = "SELECT T.TRAN_CODE,T.SERVICE_CODE FROM DESPATCH D,WAVE_TASK_DET W,TRANSPORTER T "
+" WHERE D.DESP_ID = W.REF_ID AND W.REF_SER='S-DSP'"
+" AND T.TRAN_CODE = D.TRAN_CODE AND W.PTCN = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ptcn);
rs = pstmt.executeQuery();
if(rs.next())
{
shipTranCode = rs.getString("TRAN_CODE");
serviceCode = rs.getString("SERVICE_CODE");
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
}
}
}
if( cartonMasterTranCode.equalsIgnoreCase(shipTranCode))
{
return "NO";
}
else
{
return serviceCode;
}
}
catch(Exception e)
{
errString = e.getMessage();
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);
}
}
}
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input.trim();
}
private CommodityInfo[] setCommodityInfos(LinkedHashMap linkMap,String masterCarton,String saleOrder,ADSIShippingSoap soap,String cartonType ,Connection conn) throws ITMException
{
String itemCode = "";
String harmonizDescr = "";
String harmonizCode = "";
String originCountry = "";
String nafFlag = "";
String shipCountry = "";
double unitValue = 0,caseWeight = 0,itemWeight = 0;
double packSizeCase = 0,noArt =0;
CommodityInfo[] commoList;
int cCtr = 0;
try
{
System.out.println("GenerateLabelsPrc.setCommodityInfos()");
System.out.println("list.size ["+linkMap.size()+"]");
commoList = new CommodityInfo[linkMap.size()];
nafFlag = discommon.getDisparams("999999","NAFTA_FLAG_COUNT",conn);
CommodityInfo comInfo = new CommodityInfo();
Iterator it = linkMap.keySet().iterator();
while(it.hasNext())
{
itemCode = (String)it.next();
comInfo = new CommodityInfo();
System.out.println(" item_code ["+itemCode+"]");
if(!"A".equalsIgnoreCase(cartonType))
{
HashMap itmVolumeMap = getItemVolumeMap(itemCode, "", conn);
harmonizDescr = (String)itmVolumeMap.get("HARMONIZATION_DESCR");
harmonizCode = (String)itmVolumeMap.get("HARMONIZATION_NO");
caseWeight = (Double)itmVolumeMap.get("PACK_WEIGHT");
originCountry = (String)itmVolumeMap.get("ORIGIN_COUNTRY");
packSizeCase = (Double)itmVolumeMap.get("PACK_SIZE");
noArt = getItemCount(masterCarton, itemCode, conn);
comInfo.setQuantity(noArt * packSizeCase);
}
else
{
HashMap itmVolumeMap = getItemVolumeMap(itemCode, "", conn);
harmonizDescr = (String)itmVolumeMap.get("HARMONIZATION_DESCR");
harmonizCode = (String)itmVolumeMap.get("HARMONIZATION_NO");
caseWeight = (Double)itmVolumeMap.get("ITEM_WEIGHT");
originCountry = (String)itmVolumeMap.get("ORIGIN_COUNTRY");
packSizeCase = (Double)itmVolumeMap.get("PACK_SIZE");
noArt = (Double)linkMap.get(itemCode);
comInfo.setQuantity(noArt);
}
unitValue = getRateStdoum(saleOrder, itemCode, conn);
comInfo.setDescription(harmonizDescr);//As per taro Harmonization description
comInfo.setHarmonizedCode(harmonizCode);//As per Taro Haromonization code
comInfo.setUnitValue(unitValue);
comInfo.setUnitWeight(caseWeight);
Country originCountryMfg = soap.getCountry("ISO3", originCountry).getResponseCountry();
comInfo.setOriginCountry(originCountryMfg);
HashMap sordMap = getSordInfo(saleOrder,conn);
shipCountry = sordMap.get("COUNT_CODE").toString();
System.out.println(" shipCountry ["+shipCountry+"]harmonizDescr["+harmonizDescr);
if(nafFlag.indexOf(shipCountry) != -1)
{
comInfo.setNaftaFlag(true);
System.out.println("available in disparm");
}
else
{
System.out.println("not in disparm");
comInfo.setNaftaFlag(false);
}
Calendar calendar = Calendar.getInstance();
comInfo.setExportNumberExpireDate(calendar);
comInfo.setUnitOfMeasure(EnumUnitOfMeasure.uomPCS);
commoList[cCtr] = comInfo;
cCtr++;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return commoList;
}
private HashMap getSordInfo(String saleOrder,Connection conn) throws ITMException
{
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
HashMap sordInfoMap = new HashMap();
String custCode = "",stanCode = "",siteCodeShip = "",stateCodeDlv = "",shipConsGrp = ""
,custName="",custShName = "",shipCity="",shipCountry = "",shipAdd1 = "",shipAdd2 = "",shipAdd3 = "",
shipPh="",shipFax ="",shipMailId = "",custPord = "",frtTerm="";
try
{
sql = "SELECT C.CUST_CODE AS CUST_CODE,"
+" C.STAN_CODE AS STAN_CODE,"
+" S.SITE_CODE__SHIP AS SHIP_CODE,"
+" S.CUST_PORD AS CUST_PORD,"
+" C.STATE_CODE AS STATE_DLV,"
+" C.SHIP_CONS_GRP AS SHIP_CONS_GRP,"
+" C.CUST_NAME AS CUST_NAME,"
+" C.SH_NAME AS SH_NAME,"
+" C.ADDR1 AS ADDR1,"
+" C.ADDR2 AS ADDR2,"
+" C.ADDR3 AS ADDR3,"
+" C.CITY AS CITY,"
+" C.COUNT_CODE AS COUNT_CODE,"
+" C.TELE1 AS PHONE,"
+" C.FAX AS FAX,"
+" C.EMAIL_ADDR AS EMAIL_ID,"
//changed by Pragyan on 23/12/13 for getting FRT TERM.
+" S.FRT_TERM AS FRT_TERM"
+" FROM SORDER S,CUSTOMER C "
+ " WHERE S.CUST_CODE__DLV = C.CUST_CODE "
+ " AND S.SALE_ORDER = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,saleOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
custCode = rs.getString("CUST_CODE");
stanCode = rs.getString("STAN_CODE");
siteCodeShip = rs.getString("SHIP_CODE");
stateCodeDlv = rs.getString("STATE_DLV");
shipConsGrp = rs.getString("SHIP_CONS_GRP");
custName = rs.getString("CUST_NAME");
custShName = rs.getString("SH_NAME");
shipCity = rs.getString("CITY");
shipAdd1 = rs.getString("ADDR1");
shipAdd2 = rs.getString("ADDR2");
shipAdd3 = rs.getString("ADDR3");
shipCountry = rs.getString("COUNT_CODE");
shipPh = rs.getString("PHONE");
shipMailId = rs.getString("EMAIL_ID");
shipFax = rs.getString("FAX");
custPord = rs.getString("CUST_PORD");
frtTerm = rs.getString("FRT_TERM");
}
sordInfoMap.put("CUST_CODE", custCode);
sordInfoMap.put("STAN_CODE", stanCode);
sordInfoMap.put("SHIP_CODE", siteCodeShip);
sordInfoMap.put("STATE_DLV", stateCodeDlv);
sordInfoMap.put("CUST_NAME", custName);
sordInfoMap.put("SH_NAME", custShName);
sordInfoMap.put("CITY", shipCity);
sordInfoMap.put("ADDR1", shipAdd1);
sordInfoMap.put("ADDR2", shipAdd2);
sordInfoMap.put("ADDR3", shipAdd3);
sordInfoMap.put("COUNT_CODE", shipCountry);
sordInfoMap.put("PHONE", shipPh);
sordInfoMap.put("EMAIL_ID", shipMailId);
sordInfoMap.put("FAX", shipFax);
sordInfoMap.put("CUST_PORD", custPord);
if(shipConsGrp != null && shipConsGrp.length() > 0 )
{
sordInfoMap.put("SHIP_CONS_GRP", shipConsGrp);
}
else
{
sordInfoMap.put("SHIP_CONS_GRP", custCode);
}
sordInfoMap.put("FRT_TERM", frtTerm);
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println("Exception in == >"+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 e1)
{
throw new ITMException(e1);
}
}
return sordInfoMap;
}
private HashMap getItemVolumeMap(String itemCode,String lotNo,Connection con)throws Exception
{
double packSize = 0,itemSize = 0,lotSize = 0;
PreparedStatement pstmt = null;
String sql="",hazardous = "";
String harmonizCode = "",harmonizDescr = "",originCountry = "";
ResultSet rs = null;
double itmLen = 0,itmWidth = 0,itmHeight = 0,itemWeight = 0,lotLen = 0 ,lotHeight = 0,lotWidth = 0,lotWeight = 0;
HashMap dataVolumeMap = new HashMap();
try {
sql = "SELECT I.LENGTH ITEM_LEN,I.WIDTH ITEM_WID,I.HEIGHT ITEM_HEIGHT,I.GROSS_WEIGHT ITEM_WEIGHT,I.HAZARDOUS HAZARD, "
+" I.HARMONIZATION_NO HARMONIZATION_NO,I.HARMONIZATION_DESCR HARMONIZATION_DESCR,I.COUNT_CODE__MFG ORIGIN_COUNTRY,"
+" L.LENGTH LITEM_LEN,L.WIDTH LITEM_WID,L.HEIGHT LITEM_HEIGHT,L.SHIPPER_SIZE SHIPSIZE,L.GROSS_WEIGHT LOT_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");
itemWeight = rs.getDouble("ITEM_WEIGHT");
hazardous = rs.getString("HAZARD");
lotLen = rs.getDouble("LITEM_LEN");
lotWidth = rs.getDouble("LITEM_WID");
lotHeight = rs.getDouble("LITEM_HEIGHT");
packSize = rs.getDouble("SHIPSIZE");
lotWeight = rs.getDouble("LOT_WEIGHT");
harmonizCode = rs.getString("HARMONIZATION_NO");
harmonizDescr = rs.getString("HARMONIZATION_DESCR");
originCountry = rs.getString("ORIGIN_COUNTRY");
}
//packSize = (lotHeight * lotWidth * lotLen)/(itmLen * itmWidth * itmHeight);
/*itemSize = Math.floor(itmLen * itmWidth * itmHeight);
lotSize = Math.floor((lotHeight * lotWidth * lotLen));*/
itemSize = itmLen * itmWidth * itmHeight;
lotSize = lotHeight * lotWidth * lotLen;
dataVolumeMap.put("PACK_SIZE", packSize);
dataVolumeMap.put("ITEM_SIZE", itemSize);
dataVolumeMap.put("LOT_SIZE", lotSize);
dataVolumeMap.put("HAZARDOUS", hazardous);
dataVolumeMap.put("ITEM_WEIGHT", itemWeight);
dataVolumeMap.put("PACK_WEIGHT", lotWeight);
dataVolumeMap.put("HARMONIZATION_NO", harmonizCode);
dataVolumeMap.put("HARMONIZATION_DESCR", harmonizDescr);
dataVolumeMap.put("ORIGIN_COUNTRY", originCountry);
dataVolumeMap.put("ITEM_LEN", itmLen);
dataVolumeMap.put("ITEM_WID", itmWidth);
dataVolumeMap.put("ITEM_HEIGHT", itmHeight);
dataVolumeMap.put("LITEM_LEN", lotLen);
dataVolumeMap.put("LITEM_WID", lotWidth);
dataVolumeMap.put("LITEM_HEIGHT", lotHeight);
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
} catch (Exception e) {
throw e;
}
finally
{
try
{
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
throw e;
}
}
return dataVolumeMap;
}
private double getRateStdoum(String saleOrder,String itemCode,Connection conn) throws ITMException
{
String sql = "";
double rateStdOum = 0.0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sql = " SELECT RATE__STDUOM FROM SORDDET WHERE SALE_ORDER = ? AND ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, saleOrder);
pstmt.setString(2, itemCode);
rs = pstmt.executeQuery();
if( rs.next())
{
rateStdOum = rs.getDouble(1);
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
}
catch(Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
return rateStdOum;
}
private double getItemCount(String masterCarton,String itemCode, Connection conn) throws ITMException
{
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
double count = 0;
try
{
sql = "SELECT COUNT(*) FROM CARTON_MASTER WHERE MASTER_CARTON = ? AND CARTON_TYPE = ? AND ITEM_CODE = ? AND STATUS <> ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, masterCarton);
pstmt.setString(2, "C");
pstmt.setString(3, itemCode);
pstmt.setString(4, "R");
rs = pstmt.executeQuery();
if( rs.next())
{
count = rs.getDouble(1);
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
System.out.println(" item count ["+count+"]");
}
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 es)
{
es.printStackTrace();
throw new ITMException(es);
}
}
return count;
}
private String generatedLabelPrint(String waveId, String ptcn, String printer, Connection conn) throws ITMException
{
String errString ="";
String printMode = "";
String outputFilename = "";
TreeMap argMap = null;
String isReplenishment = "N";
String saleOrder = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
String reportObjName = discommon.getDisparams("999999","WAVE_LABEL_OBJ_NAME",conn);
System.out.println("Printer *->["+printer.trim()+"] report_obj_name ["+reportObjName+"] waveId ->["+waveId+"]");
ibase.webitm.reports.utility.JasperReportGenerator jrGenerator = new ibase.webitm.reports.utility.JasperReportGenerator();
String xsdString ="<Arguments>" +
"<Argument id=\"WAVE_ID\" name=\"WAVE_ID\">" +
"<argType>java.lang.String</argType>" +
"<value>"+waveId+"</value>" +
"</Argument>";
if(ptcn != null && ptcn.length() > 0)
{
xsdString = xsdString +
"<Argument id=\"PTCN\" name=\"PTCN\">" +
"<argType>java.lang.String</argType>" +
"<value>"+ptcn+"</value>" +
"</Argument>";
}
xsdString = xsdString +
"<Argument id=\"PRINTVAL\" name=\"PRINTVAL\">" +
"<argType>java.lang.String</argType>" +
//"<value>"+ptcnList.get(i)+"</value>" +
"<value>"+isReplenishment+"</value>" +
"</Argument>" +
"<Argument id=\"x_path\" name=\"x_path\">" +
"<argType>java.lang.String</argType>" +
"<value>/DocumentRoot/pick_label</value>" +
"</Argument>" +
"<Argument id=\"design_source\" name=\"design_source\">" +
"<argType>java.lang.String</argType>" +
"<value>pick_label.jrxml</value>" +
"</Argument>" +
"<Argument id=\"data_source\" name=\"data_source\">" +
"<argType>java.lang.String</argType>" +
"<value>SQL</value>" +
"</Argument>" +
"<Argument id=\"bind_type\" name=\"bind_type\">" +
"<argType>java.lang.Integer</argType>" +
"<value>0</value>" +
"</Argument>" +
"<Argument id=\"report_type\" name=\"report_type\">" +
"<argType>java.lang.String</argType>" +
"<value>JASPER</value>" +
"</Argument>" +
"<Argument id=\"report_save_type\" name=\"report_save_type\">" +
"<argType>java.lang.String</argType>" +
"<value>NATIVE</value>" +
"</Argument>" +
"</Arguments>";
System.out.println(" XSD parser **->["+xsdString+"]");
//changed by sankara on 24/06/14 call report from remote
//changed by sankara on 22/07/14 not require as per pragyan sir start.
/*if(isRemotePrintSrvCofigured("IS_REMOTE_PRNTSRV_CONFIGRD",conn))
{
errString = jrGenerator.callRemotePrintServlet(reportObjName, xsdString, chgUser, printer.trim(), 1, conn);
}
else
{
errString = jrGenerator.printReport(reportObjName, xsdString, chgUser, printer.trim(), 1, conn);
}*/
errString = jrGenerator.callRemotePrintServlet(reportObjName, xsdString, chgUser, printer.trim(), 1, conn);
//changed by sankara on 22/07/14 not require as per pragyan sir ned.
//errString = jrGenerator.printReport(reportObjName, xsdString, chgUser, printer.trim(), 1, conn);
System.out.println(" PRINTING task completed--------**------->");
//}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
private boolean isRemotePrintSrvCofigured(String propertyName , Connection conn) throws ITMException
{
String sql = "";
String flagRemoteRptSrvltCofigured = "N";
PreparedStatement pstmt = null;
ResultSet rs = null;
boolean isConfigured = false;
DistCommon discommon = new DistCommon();
try
{
flagRemoteRptSrvltCofigured = discommon.getDisparams("999999",propertyName,conn);
if("Y".equalsIgnoreCase(flagRemoteRptSrvltCofigured))
{
return isConfigured = true;
}
else
{
return isConfigured;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
}
catch(Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
}
}
//changed by pragyan on 28/08/14 for update wave_status_org_det start.
private int reUpdateWaveOrgMasterCartonNo(String PTCN,Connection conn) throws ITMException
{
String sql = "";
String cartonNo = "";
String orgMasterCarton = "";
String newMasterCarton = "";
int update = 0;
PreparedStatement pstmt = null;
try
{
sql = "UPDATE WAVE_STATUS_ORG_DET W SET (MASTER_CARTON,TRACKING_NO,SHIP_LABEL) = "
+ "( SELECT MASTER_CARTON,TRACKING_NO,SHIP_LABEL FROM CARTON_MASTER B WHERE "
+ " W.PTCN = B.PTCN AND W.CARTON_NO = B.CARTON_NO AND B.PTCN = ?) WHERE W.PTCN = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, PTCN);
pstmt.setString(2, PTCN);
update = pstmt.executeUpdate();
if( update > 0 )
{
System.out.println("update successfully in WAVE_STATUS_ORG DET ["+update+"]");
}
pstmt.close(); pstmt = null;
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(pstmt != null )
{
pstmt.close(); pstmt = null;
}
}
catch(Exception es)
{
es.printStackTrace();
throw new ITMException(es);
}
}
return 0;
}
private String getError(String saleOrder,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+"Invalid Data"+"</message><description>";
mainStr= mainStr+"Sale Order ="+saleOrder+""+endDesc;
System.out.println("mainStr:::::::::::::::::: "+mainStr);
begPart = null;
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return mainStr;
}
}
\ No newline at end of file
package ibase.webitm.ejb.wms;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
@javax.ejb.Local
public interface GeneShipLabelsPrcLocal extends ProcessLocal
{
public String process() throws RemoteException,ITMException;
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.wms;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
@javax.ejb.Remote
public interface GeneShipLabelsPrcRemote extends ProcessRemote
{
public String process() throws RemoteException,ITMException;
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, 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