Commit 0ce58e25 authored by smestry's avatar smestry

W15FSUN008, Updated the commonWmsUtil.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98815 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 06e1eae7
......@@ -452,7 +452,7 @@ public class CommonWmsUtil {
if(conn != null){conn.close();conn = null;}
}
}
private static String checkNullAndTrim(String input)
public static String checkNullAndTrim(String input)
{
if (input==null)
{
......@@ -463,162 +463,182 @@ public class CommonWmsUtil {
//Changed by wasim on 09-10-15 to for AWMS interface2 table [END]
// Changed by Sneha on 23-10-2015, for generation of transaction id [start]
public String generateTranTd( String windowName, String tranDate, String siteCode, Connection conn )throws ITMException, SQLException
{
System.out.println("inside generateTranTd@@.........");
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String tranId = "";
String tranSer1 = "",keyString = "",keyCol = "";
CommonConstants commonConstants = new CommonConstants();
try
{
public String generateTranTd( String windowName, String tranDate, String siteCode, Connection conn )throws ITMException, SQLException
{
System.out.println("inside generateTranTd@@.........");
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String tranId = "";
String tranSer1 = "",keyString = "",keyCol = "";
CommonConstants commonConstants = new CommonConstants();
try
{
sql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, windowName);
rs = pstmt.executeQuery();
System.out.println("keyString :"+sql);
if (rs.next())
{
keyString = rs.getString(1);
keyCol = rs.getString(2);
tranSer1 = rs.getString(3);
}
else
{
sql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, windowName);
pstmt.setString(1, "GENERAL");
rs = pstmt.executeQuery();
System.out.println("keyString :"+sql);
System.out.println("keyString :"+sql);
if (rs.next())
{
keyString = rs.getString(1);
keyCol = rs.getString(2);
tranSer1 = rs.getString(3);
}
else
{
sql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "GENERAL");
rs = pstmt.executeQuery();
System.out.println("keyString :"+sql);
if (rs.next())
{
keyString = rs.getString(1);
keyCol = rs.getString(2);
tranSer1 = rs.getString(3);
}
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer1 :"+tranSer1);
String xmlValues = "";
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>"+ tranDate + "</tran_date>";
xmlValues = xmlValues + "<tran_type>"+"U"+"</tran_type>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", commonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer1, keyCol, keyString, conn);
System.out.println("tranId ::"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +sql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
if(rs!=null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer1 :"+tranSer1);
String xmlValues = "";
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>"+ tranDate + "</tran_date>";
xmlValues = xmlValues + "<tran_type>"+"U"+"</tran_type>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", commonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer1, keyCol, keyString, conn);
System.out.println("tranId ::"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +sql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
return tranId;
}
public HashMap getItemVoumeMap(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
{
System.out.println("@@LOT NO["+lotNo+"]");
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.trim()).length() > 0)
{
pstmt.setString(1, lotNo);
pstmt.setString(2, lotNo);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
else
{
return dataVolumeMap = getItemVoumeMap(itemCode, con);
}
finally
pstmt.setString(3, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
if(rs!=null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
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");
}
return tranId;
}
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;
public HashMap getItemVoumeMap(String itemCode,String lotNo,Connection con)throws Exception
}
} catch (Exception e) {
throw e;
}
finally
{
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
{
System.out.println("@@LOT NO["+lotNo+"]");
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.trim()).length() > 0)
{
pstmt.setString(1, lotNo);
pstmt.setString(2, lotNo);
}
else
{
return dataVolumeMap = getItemVoumeMap(itemCode, con);
}
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");
}
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();
......@@ -631,98 +651,97 @@ public class CommonWmsUtil {
rs = null;
}
} catch (Exception e) {
throw e;
}
finally
catch(Exception e)
{
try
{
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
throw e;
}
throw e;
}
return dataVolumeMap;
}
private HashMap getItemVoumeMap(String itemCode,Connection con)throws Exception
return dataVolumeMap;
}
private HashMap getItemVoumeMap(String itemCode,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();
System.out.println("As Lot No Passed as Blank Calling Override method for getItemVoumeMap");
try
{
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();
System.out.println("As Lot No Passed as Blank Calling Override method for getItemVoumeMap");
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__TO IN (SELECT MAX(LOT_NO__TO) FROM ITEM_LOT_PACKSIZE WHERE ITEM_CODE = ?)"
+" AND I.ITEM_CODE = ?";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
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__TO IN (SELECT MAX(LOT_NO__TO) FROM ITEM_LOT_PACKSIZE WHERE ITEM_CODE = ?)"
+" AND I.ITEM_CODE = ?";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, 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");
}
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);
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");
}
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();
......@@ -735,33 +754,14 @@ public class CommonWmsUtil {
rs = null;
}
} catch (Exception e) {
throw e;
}
finally
catch(Exception e)
{
try
{
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
throw e;
}
throw e;
}
return dataVolumeMap;
}
// Changed by Sneha on 23-10-2015, for generation of transaction id [end]
return dataVolumeMap;
}
// Changed by Sneha on 23-10-2015, for generation of transaction id [end]
}
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