Commit fd5e1fe0 authored by sshinde's avatar sshinde

Generating Dynamic query depend on Expiry date and Retest Date


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97191 ce508802-f39f-4f6c-b175-0d175dae99d5
parent bd7ecf2e
......@@ -159,7 +159,8 @@ public class EORLocationStock extends ValidatorEJB implements EORLocationStockRe
int count = 0;
String locCode = "";
String sysDate = "sysdate()";
final String yseStrng = "Yes";
final String yseString = "Yes";
final String noString = "No";
try
{
//sysDate = "sysdate";
......@@ -170,14 +171,25 @@ public class EORLocationStock extends ValidatorEJB implements EORLocationStockRe
{
locCode = "AND loc_code like '" + locationRange + "%'";
}
if (expDate != null && expDate.trim().length() != 0 && expDate.equalsIgnoreCase(yseStrng))
if (expDate != null && expDate.trim().length() != 0 && expDate.equalsIgnoreCase(yseString))
{
sqlStr.append(" and s.exp_date <= " + sysDate);
}
if (reTestDate != null && reTestDate.trim().length() != 0 && reTestDate.equalsIgnoreCase(yseStrng))
else if(expDate != null && expDate.trim().length() != 0 && expDate.equalsIgnoreCase(noString))
{
sqlStr.append(" and s.retest_date <=" + sysDate);
sqlStr.append(" and s.exp_date > " + sysDate);
}
if (reTestDate != null && reTestDate.trim().length() != 0 && reTestDate.equalsIgnoreCase(yseString))
{
sqlStr.append(" and s.retest_date < " + sysDate);
}
else if(reTestDate != null && reTestDate.trim().length() != 0 && reTestDate.equalsIgnoreCase(noString))
{
sqlStr.append(" and s.retest_date > " + sysDate);
}
sql = "select loc_code,loc_phy_row,loc_phy_col,loc_phy_stack from location where loc_phy_area = ? and site_code = ? " + locCode + " order by loc_phy_row, loc_phy_stack ,loc_phy_col";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, locPhyArea);
......@@ -216,9 +228,9 @@ public class EORLocationStock extends ValidatorEJB implements EORLocationStockRe
xmlData.append("<loc_phy_stack stack=\"" + cuurentStack + "\">");
}
xmlData.append("<loc_phy_col col=\"" + checkNull(rs.getString("loc_phy_col")) + "\">");
sql = "select s.item_code, s.site_code, s.loc_code, s.lot_no, s.lot_sl, s.exp_date, s.quantity, s.alloc_qty, s.hold_qty , s.mfg_date, s.exp_date, s.retest_date , i.descr from stock s ,item i where s.quantity >0 and s.exp_date <= sysdate() and s.item_code=i.item_code and s.loc_code =? and s.site_code =? " + sqlStr.toString();
System.out.println("sql is="+sql);
System.out.println(" before generating sql=");
sql = "select s.item_code, s.site_code, s.loc_code, s.lot_no, s.lot_sl, s.exp_date, s.quantity, s.alloc_qty, s.hold_qty , s.mfg_date, s.exp_date, s.retest_date , i.descr from stock s ,item i where s.quantity >0 and s.exp_date <= "+ sysDate +" and s.item_code=i.item_code and s.loc_code = ? and s.site_code = ? " + sqlStr.toString();
System.out.println(" site code sql is="+sql);
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, locationCode);
pstmt1.setString(2, siteCode);
......@@ -229,16 +241,12 @@ public class EORLocationStock extends ValidatorEJB implements EORLocationStockRe
{
xmlData.append("<stock>");
xmlData.append("<item_code>").append("<![CDATA[" + checkNull(rs1.getString("item_code")) + "]]>").append("</item_code>");
xmlData.append("<descr>").append("<![CDATA[" + checkNull(rs1.getString("descr")) + "]]>").append("</descr>");
xmlData.append("<lot_no>").append("<![CDATA[" + checkNull(rs1.getString("lot_no")) + "]]>").append("</lot_no>");
xmlData.append("<lot_sl>").append("<![CDATA[" + checkNull(rs1.getString("lot_sl")) + "]]>").append("</lot_sl>");
xmlData.append("<quantity>").append("<![CDATA[" + rs1.getDouble("quantity") + "]]>").append("</quantity>");
xmlData.append("<hold_qty>").append("<![CDATA[" + rs1.getDouble("hold_qty") + "]]>").append("</hold_qty>");
xmlData.append("<alloc_qty>").append("<![CDATA[" + rs1.getDouble("alloc_qty") + "]]>").append("</alloc_qty>");
if (rs1.getDate("mfg_date") != null)
{
xmlData.append("<mfg_date>").append("<![CDATA[" + rs1.getDate("mfg_date") + "]]>").append("</mfg_date>");
......@@ -246,7 +254,6 @@ public class EORLocationStock extends ValidatorEJB implements EORLocationStockRe
{
xmlData.append("<mfg_date>").append("<![CDATA[ ]]>").append("</mfg_date>");
}
if (rs1.getDate("exp_date") != null)
{
xmlData.append("<exp_date>").append("<![CDATA[" + rs1.getDate("exp_date") + "]]>").append("</exp_date>");
......@@ -254,7 +261,6 @@ public class EORLocationStock extends ValidatorEJB implements EORLocationStockRe
{
xmlData.append("<exp_date>").append("<![CDATA[ ]>").append("</exp_date>");
}
if (rs1.getDate("retest_date") != null)
{
xmlData.append("<retest_date>").append("<![CDATA[" + rs1.getDate("retest_date") + "]]>").append("</retest_date>");
......@@ -271,7 +277,6 @@ public class EORLocationStock extends ValidatorEJB implements EORLocationStockRe
pstmt1 = null;
rs1 = null;
}
if (count > 0)
{
xmlData.append("</loc_phy_stack > ");
......@@ -310,7 +315,6 @@ public class EORLocationStock extends ValidatorEJB implements EORLocationStockRe
if (pstmt1 != null)
pstmt1.close();
pstmt1 = null;
conn.close();
conn = null;
}
......@@ -336,5 +340,4 @@ public class EORLocationStock extends ValidatorEJB implements EORLocationStockRe
}
return input;
}
}
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