Commit ecb0fb5e authored by pborate's avatar pborate

Added new Fields in sales trends and added new method in shortage inventory

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@193866 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 99c33985
......@@ -107,6 +107,7 @@ public class SalesTrends extends ValidatorEJB implements SalesTrendsLocal, Sales
" DSS.NET_SALES_VALUE, " +
" DSS.SALES_QTY, " +
" DSS.FREE_SALES_VALUE, " +
" DSS.REPL_QTY, " +
" DSS.FREE_QTY, " +
" DSS.GROSS_SALES_VALUE " +
" from DWH_SALES_SUM DSS " +
......@@ -145,6 +146,7 @@ public class SalesTrends extends ValidatorEJB implements SalesTrendsLocal, Sales
rowData.put("DESCR", rs.getString("DESCR"));
rowData.put("FREE_SALES_VALUE", rs.getInt("FREE_SALES_VALUE"));
rowData.put("FREE_QTY", rs.getInt("FREE_QTY"));
rowData.put("REPL_QTY", rs.getInt("REPL_QTY"));
rowData.put("GROSS SALES VALUE", rs.getInt("GROSS_SALES_VALUE"));
rowData.put("PRODUCT_LINE", rs.getString("PRODUCT_LINE"));
rowData.put("PRODUCT_LINE_DESCR", rs.getString("PRODUCT_LINE_DESCR"));
......
......@@ -13,6 +13,7 @@ import java.util.Map;
import java.util.TreeMap;
import org.json.simple.JSONArray;
import org.json.JSONObject;
import ibase.dashboard.Report.Utility.DashboardUtility;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseLogger;
import ibase.utility.CommonConstants;
......@@ -597,6 +598,136 @@ public class ShortageInventory extends ValidatorEJB implements ShortageInventor
return shortageInvJSON;
}
@SuppressWarnings("unchecked")
public JSONArray getInventoryShortage (String dataSourceName, String siteCodefr , String siteCodeto, String locCodefr , String locCodeto, String available ) throws RemoteException, ITMException
{
BaseLogger.log("2",null,null,"INSIDE getInventoryShortage" );
JSONArray inventoryShortage = new JSONArray();
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
try
{
BaseLogger.log("2",null,null,"DATASOURCENAME FROM getInventoryShortage := "+dataSourceName );
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
sql = " SELECT INVENTORY.SITE_CODE, " +
" SITE.SH_DESCR AS SITE_SH_DESCR, " +
" SITE.DESCR AS SITE_DESCR, " +
" INVENTORY.ITEM_CODE, " +
" ITEM.SH_DESCR AS ITEM_SH_DESCR, " +
" ITEM.DESCR AS ITEM_DESCR, " +
" ITEM.UNIT AS ITEM_UNIT, " +
" INVENTORY.AVAIL_STOCK_QTY, " +
" INVENTORY.PEND_ORD_QTY, " +
" INVENTORY.AVG_SALE, " +
" CASE WHEN INVENTORY.AVG_SALE > 0 AND ( INVENTORY.AVAIL_STOCK_QTY - INVENTORY.PEND_ORD_QTY ) > 0 THEN FLOOR( ( INVENTORY.AVAIL_STOCK_QTY - INVENTORY.PEND_ORD_QTY ) / INVENTORY.AVG_SALE ) ELSE 0 END AS STOCK_NO_DAYS " +
" FROM " +
" (SELECT STOCK.SITE_CODE , " +
" STOCK.ITEM_CODE , " +
" SUM(QUANTITY - ALLOC_QTY) AS AVAIL_STOCK_QTY, " +
" DDF_GET_AVG_SALE(STOCK.SITE_CODE,STOCK.ITEM_CODE,TRUNC(SYSDATE) - 90 , TRUNC(SYSDATE)) AS AVG_SALE, " +
" DDF_GET_PENDORD(STOCK.SITE_CODE,STOCK.ITEM_CODE) AS PEND_ORD_QTY " +
" FROM INVSTAT, " +
" STOCK, " +
" LOCATION " +
" WHERE LOCATION.INV_STAT = INVSTAT.INV_STAT " +
" AND LOCATION.LOC_CODE = STOCK.LOC_CODE " +
" AND STOCK.LOC_CODE >= '"+locCodefr+"' " +
" AND STOCK.LOC_CODE <= '"+locCodeto+"' " +
" AND STOCK.SITE_CODE >= '"+siteCodefr+"' " +
" AND STOCK.SITE_CODE <= '"+siteCodeto+"' " +
" AND INVSTAT.STAT_TYPE <> 'S' " +
" AND INVSTAT.AVAILABLE = '"+available+"' " +
" GROUP BY STOCK.SITE_CODE, STOCK.ITEM_CODE) INVENTORY, SITE, ITEM " +
" WHERE INVENTORY.SITE_CODE = SITE.SITE_CODE " +
" AND INVENTORY.ITEM_CODE = ITEM.ITEM_CODE " +
" ORDER BY INVENTORY.SITE_CODE, INVENTORY.ITEM_CODE ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
rowData = new JSONObject();
rowData.put("SITE_CODE", checkNull(rs.getString("SITE_CODE")).trim());
rowData.put("SITE_SH_DESCR", checkNull(rs.getString("SITE_SH_DESCR")).trim());
rowData.put("SITE_DESCR", checkNull(rs.getString("SITE_DESCR")).trim());
rowData.put("ITEM_CODE", checkNull(rs.getString("ITEM_CODE")).trim());
rowData.put("ITEM_SH_DESCR", checkNull(rs.getString("ITEM_SH_DESCR")).trim());
rowData.put("ITEM_DESCR", checkNull(rs.getString("ITEM_DESCR")).trim());
rowData.put("ITEM_UNIT", checkNull(rs.getString("ITEM_UNIT")).trim());
rowData.put("AVAIL_STOCK_QTY", Math.round(rs.getInt("AVAIL_STOCK_QTY")));
rowData.put("PEND_ORD_QTY", Math.round(rs.getInt("PEND_ORD_QTY")));
rowData.put("AVG_SALE", Math.round(rs.getInt("AVG_SALE")));
rowData.put("STOCK_NO_DAYS", Math.round(rs.getInt("STOCK_NO_DAYS")));
inventoryShortage.add(rowData);
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
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;
}
if (conn != null)
{
conn.close();
conn = null;
}
conn = null;
}
catch (Exception d)
{
d.printStackTrace();
BaseLogger.log("0",null,null,"EXCEPTION IN :ANG : GETINVENTORYSHORTAGE() := " + d.getMessage());
System.out.println();
throw new ITMException(d);
}
}
BaseLogger.log("9",null,null,"GETINVENTORYSHORTAGE JSON ARRAY := " + inventoryShortage);
return inventoryShortage;
}
private String checkNull(String input)
{
if (input == null)
......
......@@ -3,6 +3,7 @@ package ibase.dashboard.scm.ejb;
import java.rmi.RemoteException;
import org.json.JSONObject;
import org.json.simple.JSONArray;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
......@@ -12,4 +13,5 @@ public interface ShortageInventoryLocal extends ValidatorLocal
//return type changed from json object to json array by Vinay
public String getAngShortageInventory(String dataSourceName , String siteCode , String finYear , String fromDate, String toDate) throws RemoteException, ITMException;
public JSONObject getShortageInventory(String dataSourceName , String loginSiteCode , String finYear) throws RemoteException, ITMException;
public JSONArray getInventoryShortage (String dataSourceName, String siteCodefr , String siteCodeto, String locCodefr , String locCodeto, String available) throws RemoteException, ITMException ;
}
......@@ -3,6 +3,7 @@ package ibase.dashboard.scm.ejb;
import java.rmi.RemoteException;
import org.json.JSONObject;
import org.json.simple.JSONArray;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
......@@ -12,5 +13,5 @@ public interface ShortageInventoryRemote extends ValidatorRemote
//return type changed from json object to json array by Vinay
public String getAngShortageInventory(String dataSourceName , String siteCode , String finYear , String fromDate, String toDate) throws RemoteException, ITMException;
public JSONObject getShortageInventory(String dataSourceName , String loginSiteCode , String finYear) throws RemoteException, ITMException;
public JSONArray getInventoryShortage (String dataSourceName, String siteCodefr , String siteCodeto, String locCodefr , String locCodeto, String available) 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