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 { ...@@ -452,7 +452,7 @@ public class CommonWmsUtil {
if(conn != null){conn.close();conn = null;} if(conn != null){conn.close();conn = null;}
} }
} }
private static String checkNullAndTrim(String input) public static String checkNullAndTrim(String input)
{ {
if (input==null) if (input==null)
{ {
...@@ -463,162 +463,182 @@ public class CommonWmsUtil { ...@@ -463,162 +463,182 @@ public class CommonWmsUtil {
//Changed by wasim on 09-10-15 to for AWMS interface2 table [END] //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] // 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 public String generateTranTd( String windowName, String tranDate, String siteCode, Connection conn )throws ITMException, SQLException
{ {
System.out.println("inside generateTranTd@@........."); System.out.println("inside generateTranTd@@.........");
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
String sql = ""; String sql = "";
String tranId = ""; String tranId = "";
String tranSer1 = "",keyString = "",keyCol = ""; String tranSer1 = "",keyString = "",keyCol = "";
CommonConstants commonConstants = new CommonConstants(); CommonConstants commonConstants = new CommonConstants();
try 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 = ? "; sql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, windowName); pstmt.setString(1, "GENERAL");
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
System.out.println("keyString :"+sql); System.out.println("keyString :"+sql);
if (rs.next()) if (rs.next())
{ {
keyString = rs.getString(1); keyString = rs.getString(1);
keyCol = rs.getString(2); keyCol = rs.getString(2);
tranSer1 = rs.getString(3); tranSer1 = rs.getString(3);
} }
else }
{ rs.close();
sql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? "; rs = null;
pstmt = conn.prepareStatement(sql); pstmt.close();
pstmt.setString(1, "GENERAL"); pstmt = null;
rs = pstmt.executeQuery();
System.out.println("keyString :"+sql); System.out.println("keyString :"+keyString);
if (rs.next()) System.out.println("keyCol :"+keyCol);
{ System.out.println("tranSer1 :"+tranSer1);
keyString = rs.getString(1); String xmlValues = "";
keyCol = rs.getString(2); xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
tranSer1 = rs.getString(3); 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.close();
rs = null; rs = null;
}
if(pstmt!=null)
{
pstmt.close(); pstmt.close();
pstmt = null; 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) }
{ return tranId;
System.out.println("Exception ::" +sql+ ex.getMessage() + ":"); }
ex.printStackTrace();
throw new ITMException(ex); 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) else
{ {
System.out.println("Exception ::" + e.getMessage() + ":"); return dataVolumeMap = getItemVoumeMap(itemCode, con);
e.printStackTrace();
throw new ITMException(e);
} }
finally pstmt.setString(3, itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{ {
if(rs!=null) itmLen = rs.getDouble("ITEM_LEN");
{ itmWidth = rs.getDouble("ITEM_WID");
rs.close(); itmHeight = rs.getDouble("ITEM_HEIGHT");
rs = null; itemWeight = rs.getDouble("ITEM_WEIGHT");
} hazardous = rs.getString("HAZARD");
if(pstmt!=null) lotLen = rs.getDouble("LITEM_LEN");
{ lotWidth = rs.getDouble("LITEM_WID");
pstmt.close(); lotHeight = rs.getDouble("LITEM_HEIGHT");
pstmt = null; 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 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) if(pstmt != null)
{ {
pstmt.close(); pstmt.close();
...@@ -631,98 +651,97 @@ public class CommonWmsUtil { ...@@ -631,98 +651,97 @@ public class CommonWmsUtil {
rs = null; rs = null;
} }
} catch (Exception e) {
throw e;
} }
finally catch(Exception e)
{ {
try throw e;
{
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception 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"); sql = "SELECT I.LENGTH ITEM_LEN,I.WIDTH ITEM_WID,I.HEIGHT ITEM_HEIGHT,I.GROSS_WEIGHT ITEM_WEIGHT,I.HAZARDOUS HAZARD, "
try +" 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");
sql = "SELECT I.LENGTH ITEM_LEN,I.WIDTH ITEM_WID,I.HEIGHT ITEM_HEIGHT,I.GROSS_WEIGHT ITEM_WEIGHT,I.HAZARDOUS HAZARD, " itmWidth = rs.getDouble("ITEM_WID");
+" I.HARMONIZATION_NO HARMONIZATION_NO,I.HARMONIZATION_DESCR HARMONIZATION_DESCR,I.COUNT_CODE__MFG ORIGIN_COUNTRY," itmHeight = rs.getDouble("ITEM_HEIGHT");
+" L.LENGTH LITEM_LEN,L.WIDTH LITEM_WID,L.HEIGHT LITEM_HEIGHT,L.SHIPPER_SIZE SHIPSIZE,L.GROSS_WEIGHT LOT_WEIGHT FROM" itemWeight = rs.getDouble("ITEM_WEIGHT");
+" ITEM I,ITEM_LOT_PACKSIZE L" hazardous = rs.getString("HAZARD");
+" WHERE I.ITEM_CODE = L.ITEM_CODE" lotLen = rs.getDouble("LITEM_LEN");
+" AND L.LOT_NO__TO IN (SELECT MAX(LOT_NO__TO) FROM ITEM_LOT_PACKSIZE WHERE ITEM_CODE = ?)" lotWidth = rs.getDouble("LITEM_WID");
+" AND I.ITEM_CODE = ?"; lotHeight = rs.getDouble("LITEM_HEIGHT");
pstmt = con.prepareStatement(sql); packSize = rs.getDouble("SHIPSIZE");
pstmt.setString(1, itemCode); lotWeight = rs.getDouble("LOT_WEIGHT");
pstmt.setString(2, itemCode); harmonizCode = rs.getString("HARMONIZATION_NO");
harmonizDescr = rs.getString("HARMONIZATION_DESCR");
rs = pstmt.executeQuery(); originCountry = rs.getString("ORIGIN_COUNTRY");
}
if(rs.next()) itemSize = itmLen * itmWidth * itmHeight;
{ lotSize = lotHeight * lotWidth * lotLen;
itmLen = rs.getDouble("ITEM_LEN");
itmWidth = rs.getDouble("ITEM_WID"); dataVolumeMap.put("PACK_SIZE", packSize);
itmHeight = rs.getDouble("ITEM_HEIGHT"); dataVolumeMap.put("ITEM_SIZE", itemSize);
itemWeight = rs.getDouble("ITEM_WEIGHT"); dataVolumeMap.put("LOT_SIZE", lotSize);
hazardous = rs.getString("HAZARD"); dataVolumeMap.put("HAZARDOUS", hazardous);
lotLen = rs.getDouble("LITEM_LEN"); dataVolumeMap.put("ITEM_WEIGHT", itemWeight);
lotWidth = rs.getDouble("LITEM_WID"); dataVolumeMap.put("PACK_WEIGHT", lotWeight);
lotHeight = rs.getDouble("LITEM_HEIGHT"); dataVolumeMap.put("HARMONIZATION_NO", harmonizCode);
packSize = rs.getDouble("SHIPSIZE"); dataVolumeMap.put("HARMONIZATION_DESCR", harmonizDescr);
lotWeight = rs.getDouble("LOT_WEIGHT"); dataVolumeMap.put("ORIGIN_COUNTRY", originCountry);
harmonizCode = rs.getString("HARMONIZATION_NO"); dataVolumeMap.put("ITEM_LEN", itmLen);
harmonizDescr = rs.getString("HARMONIZATION_DESCR"); dataVolumeMap.put("ITEM_WID", itmWidth);
originCountry = rs.getString("ORIGIN_COUNTRY"); dataVolumeMap.put("ITEM_HEIGHT", itmHeight);
} dataVolumeMap.put("LITEM_LEN", lotLen);
itemSize = itmLen * itmWidth * itmHeight; dataVolumeMap.put("LITEM_WID", lotWidth);
lotSize = lotHeight * lotWidth * lotLen; dataVolumeMap.put("LITEM_HEIGHT", lotHeight);
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) if(pstmt != null)
{ {
pstmt.close(); pstmt.close();
...@@ -735,33 +754,14 @@ public class CommonWmsUtil { ...@@ -735,33 +754,14 @@ public class CommonWmsUtil {
rs = null; rs = null;
} }
} catch (Exception e) {
throw e;
} }
finally catch(Exception e)
{ {
try throw e;
{
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception 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