Commit 1bdb1259 authored by dkasliwal's avatar dkasliwal

Add to CustomerDashboard and OrderShipment


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96882 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 4d22802a
package ibase.dashboard.scm.ejb;
import ibase.dashboard.Report.Utility.DashboardUtility;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.ejb.Stateless;
import org.json.simple.JSONObject;
/**
* Session Bean implementation class CustomerInfoEJB
*/
@Stateless
public class CustomerInfoEJB extends ValidatorEJB implements CustomerInfoRemote, CustomerInfoLocal {
/**
* Default constructor.
*/
public CustomerInfoEJB() {
}
GenericUtility genericUtility = GenericUtility.getInstance();
@SuppressWarnings("unchecked")
@Override
public JSONObject getCurrentReceivable(String custCode, String lastMonth,String dataSourceName) throws RemoteException, ITMException
{
JSONObject rawDataCurntRecvbleJson = null;
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashbordUtil = null;
Date frmDate = null;
Date toDate = null;
try
{
System.out.println(" Inside CustomerInfoEJB for getCurrentReceivable Method Data Soruc Name ="+dataSourceName+" custCode:"+custCode+" lastMonth is =" + lastMonth);
dashbordUtil = new DashboardUtility();
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
rawDataCurntRecvbleJson = new JSONObject();
SimpleDateFormat gridDateFormat = new SimpleDateFormat( genericUtility.getApplDateFormat());
SimpleDateFormat convrtToTimStmDate= new SimpleDateFormat(genericUtility.getDBDateFormat());
if(lastMonth!=null && lastMonth.trim().length()>0 )
{
Calendar cal = Calendar.getInstance();
toDate = new Date(cal.get(Calendar.YEAR) - 1900, cal.get(Calendar.MONTH), cal.get(Calendar.DATE));
cal.get(Calendar.MONTH + 1);
cal.add(Calendar.MONTH,-(Integer.parseInt(lastMonth)));
int month = cal.get(Calendar.MONTH);
frmDate = new Date(cal.get(Calendar.YEAR) - 1900, month, cal.get(Calendar.DATE));
}
/** start of Customer name top custoer code conversion**/
custCode = dashbordUtil.getCommaSeparated(custCode);
System.out.println("in recceivalble:"+custCode+":");
/** end of Customer name top custoer code conversion**/
if (custCode!=null && custCode.trim().length()>0 && frmDate != null && toDate != null)
{
sql = " SELECT A.SITE_CODE,A.CUST_CODE,B.CUST_NAME,A.TRAN_SER,A.REF_NO,A.REF_DATE,A.CURR_CODE, "
+" A.EXCH_RATE,TOT_AMT,ADJ_AMT,(TOT_AMT-ADJ_AMT) BAL_AMT, DUE_DATE,trunc(sysdate-DUE_DATE ) as days,A.CR_TERM "
+" FROM RECEIVABLES A,CUSTOMER B WHERE A.CUST_CODE=B.CUST_CODE AND "
+" A.CUST_CODE IN ("+custCode+") AND A.REF_DATE between ? and ? "
+" and TOT_AMT-ADJ_AMT<>0";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(frmDate).toString() + " 00:00:00.0"));
pstmt.setTimestamp(2,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(toDate).toString() + " 00:00:00.0"));
rs = pstmt.executeQuery();
int count = 0;
while (rs.next())
{
rowData = new JSONObject();
rowData.put("site_code", checkNull(rs.getString("SITE_CODE")));
rowData.put("cust_code", checkNull(rs.getString("CUST_CODE")));
rowData.put("cust_name", checkNull(rs.getString("CUST_NAME")));
rowData.put("tran_ser", checkNull(rs.getString("TRAN_SER")));
rowData.put("ref_no", checkNull(rs.getString("REF_NO")));
String refDate =checkNull(rs.getString("REF_DATE"));
if(refDate.trim().length()>0)
{
rowData.put("ref_date", gridDateFormat.format(convrtToTimStmDate.parse(refDate)));
}
else
{
rowData.put("ref_date",checkNull(rs.getString("REF_DATE")));
}
rowData.put("curr_code",checkNull( rs.getString("CURR_CODE")));
rowData.put("exch_rate", checkNull(rs.getString("EXCH_RATE")));
rowData.put("tot_amt", checkNull(rs.getString("TOT_AMT")));
rowData.put("adj_amt",checkNull( rs.getString("ADJ_AMT")));
rowData.put("bal_amt", checkNull(rs.getString("BAL_AMT")));
String dueDate =checkNull(rs.getString("due_date"));
if(dueDate.trim().length()>0)
{
rowData.put("due_date", gridDateFormat.format(convrtToTimStmDate.parse(dueDate)));
}
else
{
rowData.put("due_date",checkNull (rs.getString("DUE_DATE")));
}
rowData.put("cr_term", checkNull(rs.getString("CR_TERM")));
rawDataCurntRecvbleJson.put(count, rowData);
count++;
}
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :CustomerInfoEJB for getCurrentReceivable Method :" + d.getMessage());
throw new ITMException(d);
}
}
return rawDataCurntRecvbleJson;
}
//Add new method for create a Pie chart
@SuppressWarnings("unchecked")
public JSONObject getCurrentReceivableChartView(String custCode, String lastMonth,String dataSourceName) throws RemoteException, ITMException
{
JSONObject rawDataCurntRecvbleChartJson = null;
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashbordUtil = null;
Date frmDate = null;
Date toDate = null;
try
{
System.out.println(" Inside CustomerInfoEJB for getCurrentReceivableChartView Method Data Soruc Name ="+dataSourceName+" custCode:"+custCode+" lastMonth is =" + lastMonth);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
rawDataCurntRecvbleChartJson = new JSONObject();
SimpleDateFormat convrtToTimStmDate= new SimpleDateFormat(genericUtility.getDBDateFormat());
if(lastMonth!=null && lastMonth.trim().length()>0 )
{
Calendar cal = Calendar.getInstance();
toDate = new Date(cal.get(Calendar.YEAR) - 1900, cal.get(Calendar.MONTH), cal.get(Calendar.DATE));
cal.get(Calendar.MONTH + 1);
cal.add(Calendar.MONTH,-(Integer.parseInt(lastMonth)));
int month = cal.get(Calendar.MONTH);
frmDate = new Date(cal.get(Calendar.YEAR) - 1900, month, cal.get(Calendar.DATE));
}
//end date conversion form
dashbordUtil = new DashboardUtility();
/** start of Customer name top custoer code conversion**/
custCode = dashbordUtil.getCommaSeparated(custCode);
System.out.println("in recceivalble:"+custCode+":");
/** end of Customer name top custoer code conversion**/
if (custCode != null && custCode.trim().length() > 0 && frmDate != null && toDate != null)
{
sql = " SELECT sum (bal_amt) as balAmt,days from (SELECT A.SITE_CODE,A.CUST_CODE,B.CUST_NAME,A.TRAN_SER,A.REF_NO,A.REF_DATE,A.CURR_CODE, "
+" A.EXCH_RATE,TOT_AMT,ADJ_AMT,(TOT_AMT-ADJ_AMT) BAL_AMT, DUE_DATE,trunc(sysdate-DUE_DATE ) as days,A.CR_TERM "
+" FROM RECEIVABLES A,CUSTOMER B WHERE A.CUST_CODE=B.CUST_CODE "
+" and A.CUST_CODE IN ("+custCode+") AND A.REF_DATE between ? and ? "
+" and TOT_AMT-ADJ_AMT<>0) group by days order by days";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(frmDate).toString() + " 00:00:00.0"));
pstmt.setTimestamp(2,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(toDate).toString() + " 00:00:00.0"));
rs = pstmt.executeQuery();
int count = 0;
int dueDays=0;
double thirthySlab=0.0;
double sixthySlab=0.0;
double ninthySlab=0.0;
double oneTwinthySlab=0.0;
double oneTwinthyPlus=0.0;
double balAmt=0.0;
while (rs.next())
{
rowData = new JSONObject();
//start code for Pie chart creation
balAmt = Double.parseDouble(rs.getString("balAmt"));
dueDays = Integer.parseInt(rs.getString("days"));
if(dueDays >=0 && dueDays<=30)
{
thirthySlab = thirthySlab+balAmt;
}
else if(dueDays>30 && dueDays<=60)
{
sixthySlab = sixthySlab +balAmt;
}
else if(dueDays>60 && dueDays<=90)
{
ninthySlab = ninthySlab +balAmt;
}
else if(dueDays>90 && dueDays<=120)
{
oneTwinthySlab = oneTwinthySlab +balAmt;
}
else
{
oneTwinthyPlus = oneTwinthyPlus +balAmt;
}
}
rowData = new JSONObject();
rowData.put("thirty", "0-30");
rowData .put("thirty_slab", thirthySlab);
rawDataCurntRecvbleChartJson.put(count, rowData);
count++;
rowData = new JSONObject();
rowData.put("thirty", "30-60");
rowData.put("thirty_slab", sixthySlab);
rawDataCurntRecvbleChartJson.put(count, rowData);
count++;
rowData = new JSONObject();
rowData.put("thirty", "60-90");
rowData.put("thirty_slab", ninthySlab);
rawDataCurntRecvbleChartJson.put(count, rowData);
count++;
rowData = new JSONObject();
rowData.put("thirty","90-120");
rowData.put("thirty_slab",oneTwinthySlab);
rawDataCurntRecvbleChartJson.put(count, rowData);
count++;
rowData = new JSONObject();
rowData.put("thirty", "120 +");
rowData.put("thirty_slab", oneTwinthyPlus);
rawDataCurntRecvbleChartJson.put(count, rowData);
System.out.println("rawDataCurntRecvbleChartJson:"+rawDataCurntRecvbleChartJson);
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :CustomerInfoEJB for getCurrentReceivableChartView Method :" + d.getMessage());
throw new ITMException(d);
}
}
return rawDataCurntRecvbleChartJson;
}
//end of create pie char
@SuppressWarnings("unchecked")
@Override
public JSONObject getPendingOrder(String custCode, String lastMonth,String dataSourceName) throws RemoteException, ITMException
{
JSONObject rawDataPendingOrderJson = null;
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashbordUtil = null;
double pendingValue=0.0;
String qntyStduom="";
String qntyDesp="";
String rate="";
String unit="";
String preUnit="";
double netPendingValue=0.0;
double backOrderValue=0.0;
double totBackOrderValue=0.0;
String month1="";
String itemType="";
String key="";
ArrayList<String> values = null;
LinkedHashMap<String, Double> catValues = null;
LinkedHashMap<String, Double> graphDataMap = new LinkedHashMap<String, Double>();
LinkedHashMap<String, Double> sortedGraphDataMap = new LinkedHashMap<String, Double>();
int totMonth=0;
int frmMonth=0;
int toMonth=0;
ArrayList<String> itemTypeList = new ArrayList<String>();
ArrayList<String> monthList = new ArrayList<String> ();
Date frmDate = null;
Date toDate = null;
try
{
System.out.println(" Inside CustomerInfoEJB for getPendingOrder Method Data Soruc Name ="+dataSourceName+" custCode:"+custCode+" lastMonth is =" + lastMonth);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
rawDataPendingOrderJson = new JSONObject();
dashbordUtil = new DashboardUtility();
//start date conversion form
SimpleDateFormat gridDateFormat = new SimpleDateFormat( genericUtility.getApplDateFormat());
SimpleDateFormat graphDateFormat = new SimpleDateFormat("dd-MMM-yy");
SimpleDateFormat convrtToTimStmDate= new SimpleDateFormat(genericUtility.getDBDateFormat());
Calendar cal = Calendar.getInstance();
if(lastMonth!=null && lastMonth.trim().length()>0 )
{
toDate = new Date(cal.get(Calendar.YEAR) - 1900, cal.get(Calendar.MONTH), cal.get(Calendar.DATE));
cal.get(Calendar.MONTH + 1);
toMonth=cal.get(Calendar.MONTH);
cal.add(Calendar.MONTH,-(Integer.parseInt(lastMonth)));
frmMonth = cal.get(Calendar.MONTH);
frmDate = new Date(cal.get(Calendar.YEAR) - 1900, frmMonth, cal.get(Calendar.DATE));
totMonth = (toMonth-frmMonth);
}
/** start of Customer name top custoer code conversion**/
custCode = dashbordUtil.getCommaSeparated(custCode);
/** end of Customer name top custoer code conversion**/
if (custCode != null && custCode.trim().length() > 0 && frmDate != null && toDate != null )
{
/** Start of rawDataPendingOrderJson object for GRID Chart**/
sql = " SELECT A.SITE_CODE,A.SALE_ORDER,A.ORDER_DATE,A.CUST_CODE,C.CUST_NAME,A.CUST_ORDER__NO, "
+" CASE WHEN A.ORDER_STATUS='O' THEN 'Open' WHEN A.ORDER_STATUS='S' THEN 'Submit' WHEN A.ORDER_STATUS='P' THEN 'Partially Shipped' END ORDER_STATUS, "
+" A.CONFIRMED,A.CONF_DATE, CASE WHEN A.STATUS='P' THEN 'Pending' WHEN A.STATUS='U' THEN 'Under Shipment' WHEN A.STATUS='H' THEN 'Hold' END STATUS,A.STATUS_DATE, "
+" B.ITEM_CODE__ORD,D.DESCR,D.ITEM_SER,B.UNIT,B.QUANTITY__STDUOM, "
+" B.DSP_DATE,B.DSP_DATE-A.ORDER_DATE DELAY_DAYS,B.HOLD_FLAG , A.CUST_CODE__DLV,f.cust_name cust_name_dlv, "
+" a.DLV_CITY,a.CUST_PORD,a.PORD_DATE,e.QTY_DESP,d.site_code,d.item_type, "
+" (select count(1) from despatch des where des.sord_no = a.sale_order) no_of_ship,b.rate, "
+" DDF_STOCK_PICK_RATE((select var_value from disparm where prd_code = '999999' and var_name = 'NET_REAL_PRICE_LIST'), "
+" a.pl_date, B.ITEM_CODE__ORD, null, null, null, A.SITE_CODE) net_rate "
+" FROM SORDER A,SORDDET B,CUSTOMER C,ITEM D, SORDITEM E, CUSTOMER F "
+" WHERE A.SALE_ORDER=B.SALE_ORDER AND A.CUST_CODE=C.CUST_CODE AND B.ITEM_CODE__ORD=D.ITEM_CODE "
+" AND F.CUST_CODE = A.CUST_CODE__DLV AND e.sale_order = a.sale_order and e.line_no = b.line_no "
+" and e.item_code = B.ITEM_CODE__ORD and e.ITEM_FLAG = 'I' and A.CUST_CODE IN ("+custCode+") "
+" and A.ORDER_DATE between ? and ? AND B.sordform_no IS NOT NULL AND A.STATUS NOT IN('C','D','X') AND A.ORDER_STATUS NOT IN('C') "
+" UNION ALL "
+" SELECT A.SITE_CODE,A.TRAN_ID,A.ORDER_DATE,A.CUST_CODE,C.CUST_NAME,'' CUST_ORDER__NO, "
+" '' ORDER_STATUS,'N' CONFIRMED,NULL CONF_DATE,A.STATUS,NULL STATUS_DATE,B.ITEM_CODE,D.DESCR, "
+" D.ITEM_SER,B.UNIT,B.QUANTITY__STDUOM,B.DSP_DATE,B.DSP_DATE-A.ORDER_DATE DELAY_DAYS,'N' HOLD_FLAG , "
+" A.CUST_CODE__DLV,f.cust_name cust_name_dlv,a.DLV_CITY,a.CUST_PORD,a.PORD_DATE,0,d.site_code,d.item_type,0,b.rate, "
+" DDF_STOCK_PICK_RATE((select var_value from disparm where prd_code = '999999' and var_name = 'NET_REAL_PRICE_LIST'), "
+" a.pl_date, B.ITEM_CODE, null, null, null, A.SITE_CODE) net_rate "
+" FROM SORDFORM A,SORDFORMDET B,CUSTOMER C,ITEM D, customer f WHERE A.TRAN_ID=B.TRAN_ID "
+" AND A.CUST_CODE=C.CUST_CODE AND B.ITEM_CODE=D.ITEM_CODE and f.cust_code = a.cust_code__dlv "
+" AND STATUS <> 'S' and A.CUST_CODE IN ("+custCode+") and A.ORDER_DATE between ? and ? ORDER BY ITEM_TYPE,UNIT";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(frmDate).toString() + " 00:00:00.0"));
pstmt.setTimestamp(2,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(toDate).toString() + " 00:00:00.0"));
pstmt.setTimestamp(3,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(frmDate).toString() + " 00:00:00.0"));
pstmt.setTimestamp(4,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(toDate).toString() + " 00:00:00.0"));
rs = pstmt.executeQuery();
int count = 0;
while (rs.next())
{
rowData = new JSONObject();
qntyStduom=(checkNull( rs.getString("QUANTITY__STDUOM")));
qntyDesp=(checkNull(rs.getString("QTY_DESP")));
rate =(checkNull(rs.getString("rate")));
rowData.put("site_code", checkNull(rs.getString("SITE_CODE")));
rowData.put("sale_order", checkNull(rs.getString("SALE_ORDER")));
String ordDate=checkNull(rs.getString("ORDER_DATE"));
if(ordDate!=null && ordDate.trim().length()>0)
{
rowData.put("order_date", gridDateFormat.format(convrtToTimStmDate.parse(ordDate)));
rowData.put("graphdate", String.valueOf(graphDateFormat.format(rs.getDate("ORDER_DATE"))).substring(0, 6));
}
else
{
rowData.put("order_date",checkNull (rs.getString("ORDER_DATE")));
}
rowData.put("cust_code", checkNull(rs.getString("CUST_CODE")));
rowData.put("cust_name", checkNull(rs.getString("CUST_NAME")));
rowData.put("cust_order__no", checkNull(rs.getString("CUST_ORDER__NO")));
rowData.put("order_status",checkNull (rs.getString("ORDER_STATUS")));
rowData.put("confirmed", checkNull(rs.getString("CONFIRMED")));
String confDate=checkNull(rs.getString("CONF_DATE"));
if(confDate!=null && confDate.trim().length()>0)
{
rowData.put("conf_date", gridDateFormat.format(convrtToTimStmDate.parse(confDate)));
}
else
{
rowData.put("conf_date",checkNull (rs.getString("CONF_DATE")));
}
rowData.put("status", checkNull(rs.getString("STATUS")));
rowData.put("status_date", checkNull(rs.getString("STATUS_DATE")));
rowData.put("item_code__ord", checkNull(rs.getString("ITEM_CODE__ORD")));
rowData.put("descr", checkNull(rs.getString("DESCR")));
rowData.put("item_ser", checkNull(rs.getString("ITEM_SER")));
rowData.put("unit", checkNull(rs.getString("UNIT")));
rowData.put("quantity__stduom",checkNull( rs.getString("QUANTITY__STDUOM")));
String dispDate=checkNull(rs.getString("DSP_DATE"));
if(dispDate!=null && dispDate.trim().length()>0)
{
rowData.put("dsp_date", gridDateFormat.format(convrtToTimStmDate.parse(dispDate)));
}
else
{
rowData.put("dsp_date",checkNull (rs.getString("DSP_DATE")));
}
rowData.put("delay_days",checkNull( rs.getString("DELAY_DAYS")));
rowData.put("hold_flag", checkNull(rs.getString("HOLD_FLAG")));
/***************start of newly added arguments*/
rowData.put("cust_code__dlv", checkNull(rs.getString("CUST_CODE__DLV")));
rowData.put("cust_name_dlv", checkNull(rs.getString("cust_name_dlv")));
rowData.put("dlv_city", checkNull(rs.getString("DLV_CITY")));
rowData.put("cust_pord", checkNull(rs.getString("CUST_PORD")));
rowData.put("pord_date", checkNull(rs.getString("PORD_DATE")));
rowData.put("qty_desp", checkNull(rs.getString("QTY_DESP")));
rowData.put("site_code", checkNull(rs.getString("site_code")));
rowData.put("item_type", checkNull(rs.getString("item_type")));
rowData.put("no_of_ship", checkNull(rs.getString("no_of_ship")));
rowData.put("rate", checkNull(rs.getString("rate")));
/*start of pending value and net pending value calculation*/
if(qntyStduom != null && qntyStduom.trim().length()>0 && qntyDesp != null && qntyDesp.trim().length()>0)
{
pendingValue = (Double.parseDouble(qntyStduom) - Double.parseDouble(qntyDesp));
}
rowData.put("pending_value", pendingValue);
if(rate != null && rate.trim().length()>0)
{
netPendingValue = (pendingValue*Double.parseDouble(rate));
}
rowData.put("net_pending_value", netPendingValue);
/*end of pending value and net pending value calculation*/
/*start of Back order value calculation*/
unit = checkNull(rs.getString("UNIT"));
if(("").equalsIgnoreCase(preUnit) && unit != null && unit.trim().length()>0)
{
backOrderValue = pendingValue;
}
if(!("").equalsIgnoreCase(preUnit) && preUnit.equalsIgnoreCase(unit))
{
backOrderValue =backOrderValue + pendingValue;
}
if( !("").equalsIgnoreCase(preUnit) && !preUnit.equalsIgnoreCase(unit) )
{
backOrderValue = pendingValue;
}
rowData.put("back_order_value", backOrderValue);
preUnit=unit;
/*end of Back order value calculation*/
rowData.put("month","");
rowData.put("product_category","");
rowData.put("category_value","");
/********************end of newly added arguments*/
rawDataPendingOrderJson.put(count, rowData);
count++;
//start of code for stack chart hashmap
month1 =String.valueOf(graphDateFormat.format(rs.getDate("ORDER_DATE"))).substring(3, 9);
itemType = checkNull(rs.getString("item_type"));
if(! itemTypeList.contains(itemType))
{
itemTypeList.add(itemType);
}
key = (month1.trim()+"@"+itemType.trim());
if(graphDataMap.size()==0)
{
graphDataMap.put(key, pendingValue);
}
if(graphDataMap !=null && graphDataMap.size()>0)
{
if(graphDataMap.containsKey(key))
{
totBackOrderValue = pendingValue + graphDataMap.get(key);
}
else if(! graphDataMap.containsKey(key))
{
totBackOrderValue = pendingValue;
}
graphDataMap.put(key, totBackOrderValue);
}
//end of code for stack chart hashmap
}
//start of list of month
ArrayList<String> sortMonth = new ArrayList<String>();
cal = Calendar.getInstance();
for(int i=0;i<=totMonth;i++)
{
monthList.add(String.valueOf(graphDateFormat.format(cal.getTime())).substring(3, 9));
cal.add(Calendar.MONTH,-(1));
sortMonth.add(monthList.get(i));
}
System.out.println("sortMonth:;;;"+sortMonth);
for(int k=1;k<=monthList.size();k++)
{
sortMonth.set(k-1, monthList.get(monthList.size()-k));
}
// end of list of month
//start of graphDataMap in sorted format
String itType="";
String grpKey="";
for(int itmCtr=0;itmCtr<itemTypeList.size();itmCtr++)
{
itType = itemTypeList.get(itmCtr);
for (Map.Entry<String, Double> grpentry : graphDataMap.entrySet())
{
String mapGrpKey = grpentry.getKey();
for(int mnthCtr=0;mnthCtr<sortMonth.size();mnthCtr++)
{
grpKey = (sortMonth.get(mnthCtr).trim()+"@"+itType.trim());
if(graphDataMap.containsKey(grpKey))
{
sortedGraphDataMap.put(grpKey, graphDataMap.get(grpKey));
}
if(!graphDataMap.containsKey(grpKey) )
{
sortedGraphDataMap.put(grpKey, 0.0);
}
}
}
}
//end of graphDataMap in sorted format
//start of code for stack chart hashmap to json
rowData = new JSONObject();
String mnth="";
String itmType="",prvItmType="";
values = new ArrayList<String>();
catValues = new LinkedHashMap<String, Double>();
int cnt=0;
for (Map.Entry<String, Double> entry : sortedGraphDataMap.entrySet())
{
cnt++;
String mapKey = entry.getKey();
double value = entry.getValue();
String[] temp;
temp = mapKey.split("@");
mnth = temp[0].trim();
itmType = temp[1].trim();
if( itmType != null && ("").equals(prvItmType) && itmType.trim().length()>0)
{
catValues.put(mnth,value);
rowData.put("month",cnt);
rowData.put("product_category",itmType);
rowData.put("category_value",catValues);
rowData.put("pending_value", "");
}
else if(!("").equals(prvItmType) && prvItmType.equals(itmType))
{
catValues.put(mnth,value);
}
if(!("").equals(prvItmType) && ! prvItmType.equals(itmType))
{
rowData.put("month",cnt);
rowData.put("product_category",prvItmType);
rowData.put("category_value",catValues);
rowData.put("pending_value", "");
rawDataPendingOrderJson.put(count, rowData);
count++;
rowData = new JSONObject();
catValues = new LinkedHashMap<String, Double>();
catValues.put(mnth,value);
}
if(cnt==sortedGraphDataMap.size())
{
rowData.put("month",cnt);
rowData.put("product_category",prvItmType);
rowData.put("category_value",catValues);
rowData.put("pending_value", "");
rawDataPendingOrderJson.put(count, rowData);
}
prvItmType=itmType;
}
System.out.println("rawData in pending order for stack chart:\n"+rawDataPendingOrderJson);
//end of code for stack chart hashmap to json
/** End of rawDataPendingOrderJson object for GRID Chart**/
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :CustomerInfoEJB for getPendingOrder Method :" + d.getMessage());
throw new ITMException(d);
}
}
return rawDataPendingOrderJson;
}
@SuppressWarnings("unchecked")
@Override
public JSONObject getOrderHistory(String custCode, String lastMonth,String dataSourceName) throws RemoteException, ITMException
{
JSONObject rawDataOrderHistoryJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashbordUtil = null;
Date frmDate = null;
Date toDate = null;
try
{
System.out.println(" Inside CustomerInfoEJB for getOrderHistory Method Data Soruc Name ="+dataSourceName+" custCode:"+custCode+" lastMonth is =" + lastMonth);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
//start date conversion form
SimpleDateFormat gridDateFormat = new SimpleDateFormat( genericUtility.getApplDateFormat());
SimpleDateFormat convrtToTimStmDate= new SimpleDateFormat(genericUtility.getDBDateFormat());
SimpleDateFormat graphDateFormat = new SimpleDateFormat("dd-MMM-yy");
if(lastMonth!=null && lastMonth.trim().length()>0 )
{
Calendar cal = Calendar.getInstance();
toDate = new Date(cal.get(Calendar.YEAR) - 1900, cal.get(Calendar.MONTH), cal.get(Calendar.DATE));
cal.get(Calendar.MONTH + 1);
cal.add(Calendar.MONTH,-(Integer.parseInt(lastMonth)));
int month = cal.get(Calendar.MONTH);
frmDate = new Date(cal.get(Calendar.YEAR) - 1900, month, cal.get(Calendar.DATE));
}
//end date conversion form
dashbordUtil = new DashboardUtility();
/** start of Customer name top custoer code conversion**/
custCode = dashbordUtil.getCommaSeparated(custCode);
System.out.println("in recceivalble:"+custCode+":");
/** end of Customer name top custoer code conversion**/
if (custCode != null && custCode.trim().length() > 0 && frmDate != null && toDate != null)
{
sql = " SELECT A.SITE_CODE,A.SALE_ORDER,A.ORDER_DATE,A.CUST_CODE,C.CUST_NAME,A.CUST_ORDER__NO, "
+" CASE WHEN A.ORDER_STATUS='O' THEN 'Open' WHEN A.ORDER_STATUS='S' THEN 'Submit' WHEN A.ORDER_STATUS='P' THEN 'Partially Shipped' WHEN A.ORDER_STATUS='C' THEN 'Fully Shipped' END ORDER_STATUS "
+" ,A.CONFIRMED,A.CONF_DATE,CASE WHEN A.STATUS='P' THEN 'Pending' WHEN A.STATUS='U' THEN 'Under Shipment' WHEN A.STATUS='H' THEN 'Hold' "
+" WHEN A.STATUS='C' THEN 'Closed' WHEN A.STATUS='D' THEN 'Despatched' END STATUS ,A.STATUS_DATE, B.ITEM_CODE__ORD, "
+" D.DESCR,D.ITEM_SER,B.UNIT,B.QUANTITY__STDUOM, B.DSP_DATE,B.DSP_DATE-A.ORDER_DATE DELAY_DAYS,B.HOLD_FLAG "
+" FROM SORDER A,SORDDET B,CUSTOMER C,ITEM D "
+" WHERE A.SALE_ORDER=B.SALE_ORDER AND A.CUST_CODE=C.CUST_CODE AND B.ITEM_CODE__ORD=D.ITEM_CODE "
+" and A.CUST_CODE IN ("+custCode+") AND B.sordform_no IS NOT NULL AND A.STATUS NOT IN('X') AND A.ORDER_STATUS NOT IN('C') "
+" AND A.ORDER_DATE BETWEEN ? AND ? "
+" UNION ALL "
+" SELECT A.SITE_CODE,A.TRAN_ID,A.ORDER_DATE,A.CUST_CODE,C.CUST_NAME,'' CUST_ORDER__NO, "
+" '' ORDER_STATUS,'N' CONFIRMED,NULL CONF_DATE,A.STATUS,NULL STATUS_DATE,B.ITEM_CODE,D.DESCR,"
+" D.ITEM_SER,B.UNIT,B.QUANTITY__STDUOM,B.DSP_DATE,B.DSP_DATE-A.ORDER_DATE DELAY_DAYS,'N' HOLD_FLAG "
+" FROM SORDFORM A,SORDFORMDET B,CUSTOMER C,ITEM D "
+" WHERE A.TRAN_ID=B.TRAN_ID AND A.CUST_CODE=C.CUST_CODE AND B.ITEM_CODE=D.ITEM_CODE AND STATUS<>'S' "
+" and A.CUST_CODE IN ("+custCode+") AND A.ORDER_DATE BETWEEN ? AND ? ORDER BY ORDER_DATE";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(frmDate).toString() + " 00:00:00.0"));
pstmt.setTimestamp(2,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(toDate).toString() + " 00:00:00.0"));
pstmt.setTimestamp(3,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(frmDate).toString() + " 00:00:00.0"));
pstmt.setTimestamp(4,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(toDate).toString() + " 00:00:00.0"));
rs = pstmt.executeQuery();
int count = 0;
while (rs.next())
{
rowData = new JSONObject();
rowData.put("site_code",checkNull (rs.getString("SITE_CODE")));
rowData.put("sale_order", checkNull(rs.getString("SALE_ORDER")));
String ordDate=checkNull(rs.getString("ORDER_DATE"));
if(ordDate.trim().length()>0)
{
rowData.put("order_date", gridDateFormat.format(convrtToTimStmDate.parse(ordDate)));
rowData.put("graphdate", String.valueOf(graphDateFormat.format(rs.getDate("ORDER_DATE"))).substring(0, 6));
}
else{
rowData.put("order_date",checkNull (rs.getString("ORDER_DATE")));
}
rowData.put("cust_code", checkNull(rs.getString("CUST_CODE")));
rowData.put("cust_name", checkNull(rs.getString("CUST_NAME")));
rowData.put("cust_order__no", checkNull(rs.getString("CUST_ORDER__NO")));
rowData.put("order_status", checkNull(rs.getString("ORDER_STATUS")));
rowData.put("status", checkNull(rs.getString("STATUS")));
rowData.put("status_date", checkNull(rs.getString("STATUS_DATE")));
rowData.put("item_code__ord", checkNull(rs.getString("ITEM_CODE__ORD")));
rowData.put("descr", checkNull(rs.getString("DESCR")));
rowData.put("item_ser", checkNull(rs.getString("ITEM_SER")));
rowData.put("unit",checkNull( rs.getString("UNIT")));
rowData.put("quantity__stduom", checkNull(rs.getString("QUANTITY__STDUOM")));
String dispDate=checkNull(rs.getString("DSP_DATE"));
if(dispDate.trim().length()>0)
{
rowData.put("dsp_date", gridDateFormat.format(convrtToTimStmDate.parse(dispDate)));
}
else{
rowData.put("dsp_date",checkNull(rs.getString("DSP_DATE")));
}
rowData.put("delay_days",checkNull(rs.getString("DELAY_DAYS")));
rowData.put("hold_flag", checkNull(rs.getString("HOLD_FLAG")));
rawDataOrderHistoryJson.put(count, rowData);
count++;
}
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :CustomerInfoEJB for getOrderHistory Method :" + d.getMessage());
throw new ITMException(d);
}
}
System.out.println("rawDataOrderHistoryJson--["+rawDataOrderHistoryJson.toString()+"]");
return rawDataOrderHistoryJson;
}
@SuppressWarnings("unchecked")
@Override
public JSONObject getSalesHistory(String custCode, String lastMonth,String dataSourceName) throws RemoteException, ITMException
{
JSONObject rawDataSalesHistoryJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashbordUtil = null;
Date frmDate = null;
Date toDate = null;
try
{
System.out.println(" Inside CustomerInfoEJB for getSalesHistory Method Data Soruc Name ="+dataSourceName+" custCode:"+custCode+" lastMonth is =" + lastMonth);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
dashbordUtil = new DashboardUtility();
//start date conversion form
SimpleDateFormat gridDateFormat = new SimpleDateFormat( genericUtility.getApplDateFormat());
SimpleDateFormat graphDateFormat = new SimpleDateFormat("dd-MMM-yy");
SimpleDateFormat convrtToTimStmDate= new SimpleDateFormat(genericUtility.getDBDateFormat());
if(lastMonth!=null && lastMonth.trim().length()>0 )
{
Calendar cal = Calendar.getInstance();
toDate = new Date(cal.get(Calendar.YEAR) - 1900, cal.get(Calendar.MONTH), cal.get(Calendar.DATE));
cal.get(Calendar.MONTH + 1);
cal.add(Calendar.MONTH,-(Integer.parseInt(lastMonth)));
int month = cal.get(Calendar.MONTH);
frmDate = new Date(cal.get(Calendar.YEAR) - 1900, month, cal.get(Calendar.DATE));
}
//end date conversion form
/** start of Customer name top custoer code conversion**/
custCode = dashbordUtil.getCommaSeparated(custCode);
System.out.println("in recceivalble:"+custCode+":");
/** end of Customer name top custoer code conversion**/
if (custCode!=null && custCode.trim().length()>0 && frmDate != null && toDate != null)
{
sql = " SELECT A.SITE_CODE,A.SORD_NO,B.LINE_NO__SORD,SORD_DATE,A.DESP_DATE,A.CUST_CODE, "
+" C.CUST_NAME,A.CUST_CODE__DLV,A.CURR_CODE,A.EXCH_RATE,B.ITEM_CODE,D.DESCR,D.ITEM_SER, "
+" B.LOT_NO,B.LOT_SL,B.QUANTITY,B.UNIT,B.QUANTITY__STDUOM,B.RATE__STDUOM, "
+" B.QUANTITY__STDUOM*B.RATE__STDUOM AMOUNT,B.NO_ART,B.MFG_DATE,B.EXP_DATE, "
+" B.SITE_CODE__MFG FROM DESPATCH A,DESPATCHDET B,CUSTOMER C,ITEM D "
+" WHERE A.DESP_ID=B.DESP_ID AND A.CUST_CODE=C.CUST_CODE "
+" AND B.ITEM_CODE=D.ITEM_CODE and A.CUST_CODE IN ("+custCode+") AND "
+" A.DESP_DATE BETWEEN ? AND ? order by DESP_DATE,SORD_NO";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(frmDate).toString() + " 00:00:00.0"));
pstmt.setTimestamp(2,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(toDate).toString() + " 00:00:00.0"));
rs = pstmt.executeQuery();
int count = 0;
while (rs.next())
{
rowData = new JSONObject();
rowData.put("site_code", checkNull(rs.getString("SITE_CODE")));
rowData.put("sord_no", checkNull(rs.getString("SORD_NO")));
rowData.put("line_no__sord", checkNull(rs.getString("LINE_NO__SORD")));
String sordDate=checkNull(rs.getString("SORD_DATE"));
String despDate=checkNull(rs.getString("DESP_DATE"));
if(sordDate.trim().length()>0)
{
rowData.put("sord_date", gridDateFormat.format(convrtToTimStmDate.parse(sordDate)));
}
else{
rowData.put("sord_date",checkNull(rs.getString("SORD_DATE")));
}
System.out.println("despDate in sales hisotry : "+despDate);
if(despDate.trim().length()>0)
{
rowData.put("desp_date", gridDateFormat.format(convrtToTimStmDate.parse(despDate)));
rowData.put("graphdate", String.valueOf(graphDateFormat.format(rs.getDate("DESP_DATE"))).substring(0, 6));
}
else{
rowData.put("desp_date",checkNull(rs.getString("DESP_DATE")));
}
rowData.put("cust_code",checkNull (rs.getString("CUST_CODE")));
rowData.put("cust_name",checkNull( rs.getString("CUST_NAME")));
rowData.put("cust_code__dlv",checkNull( rs.getString("CUST_CODE__DLV")));
rowData.put("curr_code", checkNull(rs.getString("CURR_CODE")));
rowData.put("exch_rate", checkNull(rs.getString("EXCH_RATE")));
rowData.put("item_code", checkNull(rs.getString("ITEM_CODE")));
rowData.put("descr", checkNull(rs.getString("DESCR")));
rowData.put("item_ser",checkNull( rs.getString("ITEM_SER")));
rowData.put("lot_no",checkNull( rs.getString("LOT_NO")));
rowData.put("lot_sl", checkNull(rs.getString("LOT_SL")));
rowData.put("quantity", checkNull(rs.getString("QUANTITY")));
rowData.put("unit", checkNull(rs.getString("UNIT")));
rowData.put("quantity__stduom", checkNull(rs.getString("QUANTITY__STDUOM")));
rowData.put("rate__stduom", checkNull(rs.getString("RATE__STDUOM")));
rowData.put("amount", checkNull(rs.getString("AMOUNT")));
rowData.put("no_art", checkNull(rs.getString("NO_ART")));
rowData.put("mfg_date", checkNull(rs.getString("MFG_DATE")));
rowData.put("exp_date", checkNull(rs.getString("EXP_DATE")));
rowData.put("site_code__mfg",checkNull(rs.getString("SITE_CODE__MFG")));
rawDataSalesHistoryJson.put(count, rowData);
count++;
}
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :CustomerInfoEJB for getSalesHistory Method :" + d.getMessage());
throw new ITMException(d);
}
}
return rawDataSalesHistoryJson;
}
@SuppressWarnings("unchecked")
@Override
public JSONObject getTransactionSummary(String custCode, String lastMonth,String dataSourceName) throws RemoteException, ITMException
{
JSONObject rawDataTrnsctionSumryJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashbordUtil = null;
Date frmDate = null;
Date toDate = null;
try
{
System.out.println(" Inside CustomerInfoEJB for getTransactionSummary Method Data Soruc Name ="+dataSourceName+" custCode:"+custCode+" lastMonth is =" + lastMonth);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
//start date conversion form
SimpleDateFormat gridDateFormat = new SimpleDateFormat( genericUtility.getApplDateFormat());
SimpleDateFormat graphDateFormat = new SimpleDateFormat("dd-MMM-yy");
SimpleDateFormat convrtToTimStmDate= new SimpleDateFormat(genericUtility.getDBDateFormat());
if(lastMonth!=null && lastMonth.trim().length()>0 )
{
Calendar cal = Calendar.getInstance();
toDate = new Date(cal.get(Calendar.YEAR) - 1900, cal.get(Calendar.MONTH), cal.get(Calendar.DATE));
cal.get(Calendar.MONTH + 1);
cal.add(Calendar.MONTH,-(Integer.parseInt(lastMonth)));
int month = cal.get(Calendar.MONTH);
frmDate = new Date(cal.get(Calendar.YEAR) - 1900, month, cal.get(Calendar.DATE));
}
//end date conversion form
dashbordUtil = new DashboardUtility();
/** start of Customer name top custoer code conversion**/
custCode = dashbordUtil.getCommaSeparated(custCode);
System.out.println("in recceivalble:"+custCode+":");
/** end of Customer name top custoer code conversion**/
if (custCode!=null && custCode.trim().length()>0 && frmDate != null && toDate != null)
{
sql = " SELECT SDATE,SUM(NO_OF_ORDER) as NO_OF_ORDER ,SUM(ORDER_VALUE) as ORDER_VALUE,SUM(NO_OF_SALES) as NO_OF_SALES,SUM(SALES_VALUE) as SALES_VALUE, "
+" SUM(RECEIVABLES) as RECEIVABLES ,SUM(COLLECTION) as COLLECTION ,SUM(NO_OF_DN) as NO_OF_DN,SUM(DN_VALUE) as DN_VALUE,SUM(NO_OF_CN) as NO_OF_CN, "
+" SUM(CN_VALUE) as CN_VALUE ,SUM(NO_OF_SR) as NO_OF_SR ,SUM(SR_VALUE) as SR_VALUE FROM ( SELECT A.ORDER_DATE SDATE, "
+" 1 NO_OF_ORDER,B.QUANTITY__STDUOM*B.RATE__STDUOM ORDER_VALUE,0 NO_OF_SALES,"
+" 0 SALES_VALUE,0 RECEIVABLES,0 COLLECTION,0 NO_OF_DN,0 DN_VALUE,0 NO_OF_CN, "
+" 0 CN_VALUE,0 NO_OF_SR,0 SR_VALUE FROM SORDER A,SORDDET B "
+" WHERE A.SALE_ORDER=B.SALE_ORDER AND A.CUST_CODE IN ("+custCode+") AND A.ORDER_DATE "
+" BETWEEN ? AND ? AND A.STATUS NOT IN('X') "
+" UNION ALL SELECT A.REF_DATE SDATE,0 NO_OF_ORDER,0 ORDER_VALUE,0 NO_OF_SALES,0 "
+" SALES_VALUE,(TOT_AMT-ADJ_AMT) RECEIVABLES,0 COLLECTION,0 NO_OF_DN,0 DN_VALUE,0 "
+" NO_OF_CN,0 CN_VALUE,0 NO_OF_SR,0 SR_VALUE "
+" FROM RECEIVABLES A where A.CUST_CODE IN ("+custCode+") AND REF_DATE BETWEEN "
+" ? AND ? ) GROUP BY SDATE order by SDATE";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(frmDate).toString() + " 00:00:00.0"));
pstmt.setTimestamp(2,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(toDate).toString() + " 00:00:00.0"));
pstmt.setTimestamp(3,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(frmDate).toString() + " 00:00:00.0"));
pstmt.setTimestamp(4,java.sql.Timestamp.valueOf(convrtToTimStmDate.format(toDate).toString() + " 00:00:00.0"));
rs = pstmt.executeQuery();
int count = 0;
while (rs.next())
{
rowData = new JSONObject();
String sdate=checkNull(rs.getString("SDATE"));
if(sdate.trim().length()>0)
{
rowData.put("sdate", gridDateFormat.format(convrtToTimStmDate.parse(sdate)));
rowData.put("graphdate", String.valueOf(graphDateFormat.format(rs.getDate("SDATE"))).substring(0, 6));
}
else{
rowData.put("sdate",checkNull(rs.getString("SDATE")));
}
/*rowData.put("sdate", sdf1.format(checkNull(rs.getString("SDATE"))));*/
System.out.println("DATE===="+String.valueOf(graphDateFormat.format(rs.getDate("SDATE"))).substring(0, 6));
/*rowData.put("graphdate", String.valueOf(sdf.format(rs.getDate("SDATE"))).substring(0, 6));*/
rowData.put("no_of_order", checkNull(rs.getString("NO_OF_ORDER")));
rowData.put("order_value", checkNull(rs.getString("ORDER_VALUE")));
rowData.put("no_of_sales", checkNull(rs.getString("NO_OF_SALES")));
rowData.put("sales_value", checkNull(rs.getString("SALES_VALUE")));
rowData.put("receivables", checkNull(rs.getString("RECEIVABLES")));
rowData.put("collection", checkNull(rs.getString("COLLECTION")));
rowData.put("no_of_dn", checkNull(rs.getString("NO_OF_DN")));
rowData.put("dn_value", checkNull(rs.getString("DN_VALUE")));
rowData.put("no_of_cn", checkNull(rs.getString("NO_OF_CN")));
rowData.put("cn_value", checkNull(rs.getString("CN_VALUE")));
rowData.put("no_of_sr",checkNull( rs.getString("NO_OF_SR")));
rowData.put("sr_value", checkNull(rs.getString("SR_VALUE")));
rawDataTrnsctionSumryJson.put(count, rowData);
count++;
}
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :CustomerInfoEJB for getTransactionSummary Method :" + d.getMessage());
throw new ITMException(d);
}
}
return rawDataTrnsctionSumryJson;
}
private String checkNull(String str)
{
if(str == null)
{
return "";
}
else
{
return str ;
}
}
}
package ibase.dashboard.scm.ejb;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
import org.json.simple.JSONObject;
@Local
public interface CustomerInfoLocal extends ValidatorLocal
{
public JSONObject getCurrentReceivable(String custCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getPendingOrder(String custCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getOrderHistory(String custCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getSalesHistory(String custCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getTransactionSummary(String custCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getCurrentReceivableChartView(String custCode, String lastMonth,String dataSourceName) throws RemoteException, ITMException;
}
package ibase.dashboard.scm.ejb;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
import org.json.simple.JSONObject;
@Remote
public interface CustomerInfoRemote extends ValidatorRemote
{
public JSONObject getCurrentReceivable(String custCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getPendingOrder(String custCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getOrderHistory(String custCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getSalesHistory(String custCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getTransactionSummary(String custCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getCurrentReceivableChartView(String custCode, String lastMonth,String dataSourceName) throws RemoteException, ITMException;
}
package ibase.dashboard.scm.ejb;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.ejb.Stateless;
import org.json.simple.JSONObject;
/**
* Session Bean implementation class ItemInfo
*/
@Stateless
public class ItemInfoEJB extends ValidatorEJB implements ItemInfoRemote, ItemInfoLocal {
/**
* Default constructor.
*/
public ItemInfoEJB() {
}
@SuppressWarnings("unchecked")
@Override
public JSONObject getCurrentInventory(String itmCode, String prdCode,String dataSourceName) throws RemoteException, ITMException
{
JSONObject rawDataCurntInvJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
try
{
System.out.println(" Inside ItemInfoEJB for getCurrentInventory Method Data Soruc Name ="+dataSourceName+" custCode:"+itmCode+" prdCode is =" + prdCode);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
sql = " /*Put Sql Query */";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
int count = 0;
while (rs.next())
{
rowData = new JSONObject();
/*rowData.put("sp_name", (rs.getString("sp_name")));
rowData.put("max_event_date", (rs.getString("max_event_date")));
rowData.put("year", (rs.getString("yyyymm")));
rowData.put("month", (rs.getString("monyyyy")));
rowData.put("brand_code", (rs.getString("brand_code")));
rowData.put("brand", (rs.getString("brand")));
rowData.put("doc_code", rs.getString("doc_code"));
rowData.put("doc_name", rs.getString("doc_name"));
rowData.put("spl_code", rs.getString("spl_code"));
rowData.put("spl_descr", rs.getString("spl_descr"));
rowData.put("presc_no", rs.getString("presc_no")); */
rawDataCurntInvJson.put(count, rowData);
count++;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :ItemInfoEJB for getCurrentInventory Method :" + d.getMessage());
throw new ITMException(d);
}
}
return rawDataCurntInvJson;
}
@Override
public JSONObject getSalesHistoryInfoQty(String itmCode, String prdCode,String dataSourceName) throws RemoteException, ITMException
{
JSONObject rawDatasalesHisInvQtyJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
try
{
System.out.println(" Inside ItemInfoEJB for getSalesHistoryInfoQty Method Data Soruc Name ="+dataSourceName+" custCode:"+itmCode+" prdCode is =" + prdCode);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
sql = " /*Put Sql Query */";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
int count = 0;
while (rs.next())
{
rowData = new JSONObject();
/*rowData.put("sp_name", (rs.getString("sp_name")));
rowData.put("max_event_date", (rs.getString("max_event_date")));
rowData.put("year", (rs.getString("yyyymm")));
rowData.put("month", (rs.getString("monyyyy")));
rowData.put("brand_code", (rs.getString("brand_code")));
rowData.put("brand", (rs.getString("brand")));
rowData.put("doc_code", rs.getString("doc_code"));
rowData.put("doc_name", rs.getString("doc_name"));
rowData.put("spl_code", rs.getString("spl_code"));
rowData.put("spl_descr", rs.getString("spl_descr"));
rowData.put("presc_no", rs.getString("presc_no")); */
rawDatasalesHisInvQtyJson.put(count, rowData);
count++;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :ItemInfoEJB for getSalesHistoryInfoQty Method :" + d.getMessage());
throw new ITMException(d);
}
}
return rawDatasalesHisInvQtyJson;
}
private String getGeolocation(String geoLocation)
{
String[] geoLocArray = this.getSplitedStrng(geoLocation);
String modifyGeoLoc = "";
if (geoLocArray != null)
{
for (int i = 0; i < geoLocArray.length; i++)
{
if (i == geoLocArray.length - 1)
{
modifyGeoLoc = modifyGeoLoc + "'" + geoLocArray[i] + "'";
} else
{
modifyGeoLoc = modifyGeoLoc + "'" + geoLocArray[i] + "',";
}
}
} else
{
modifyGeoLoc = "";
}
return modifyGeoLoc;
}
private String[] getSplitedStrng(String year)
{
String[] splitedArray = null;
if (year != null && year.length() > 0)
{
splitedArray = year.split(",");
}
return splitedArray;
}
}
package ibase.dashboard.scm.ejb;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
import org.json.simple.JSONObject;
@Local
public interface ItemInfoLocal extends ValidatorLocal
{
public JSONObject getCurrentInventory(String itmCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getSalesHistoryInfoQty(String itmCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
}
package ibase.dashboard.scm.ejb;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
import org.json.simple.JSONObject;
@Remote
public interface ItemInfoRemote extends ValidatorRemote
{
public JSONObject getCurrentInventory(String itmCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getSalesHistoryInfoQty(String itmCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
}
package ibase.dashboard.scm.ejb;
import ibase.dashboard.Report.Utility.DashboardUtility;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
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 javax.ejb.Stateless;
import org.json.simple.JSONObject;
/**
* Session Bean implementation class DespatchOrder
*/
@Stateless
public class OrderVsShipmentEJB extends ValidatorEJB implements OrderVsShipmentRemote, OrderVsShipmentLocal {
/**
* Default constructor.
*/
public OrderVsShipmentEJB() {
}
@SuppressWarnings("unchecked")
public JSONObject getmonthWiseDespatchOrders(String lastMonth,String siteCode,String custCode,String custCodeDlv,String dataSourceName) throws RemoteException, ITMException
{
JSONObject monthWiseDespatchOrdersJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashbordUtil = null;
String custCodeSorder="";
String custCodeDespatch="";
String custCodeDlvSorder="";
String custCodeDlvDespatch="";
try
{
System.out.println(" Inside DespatchOrder for getmonthWiseDespatchOrders() Method Data Soruc Name ="+dataSourceName+" siteCode:"+siteCode +"lastMonth:="+lastMonth+ " custCode:="+custCode+" custCodeDlv:="+custCodeDlv);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
dashbordUtil = new DashboardUtility();
siteCode= dashbordUtil.getCommaSeparated(siteCode);
//lastMonth="6";
//start code for customer code and customer code dlv as dynamic input
/* if (custName != null && custName.length() > 0)
{
custNameArry = custName.split("~");
for (int custCnt = 0; custCnt < custNameArry.length; custCnt++)
{
customerName = custNameArry[custCnt];
sql = "SELECT CUST_CODE FROM CUSTOMER WHERE CUST_NAME = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, customerName);
rs = pstmt.executeQuery();
if(rs.next())
{
if (custCodeBuff.length() != 0)
{
custCodeBuff.append("," + rs.getString("cust_code").trim());
} else
{
custCodeBuff.append(rs.getString("cust_code").trim());
}
System.out.println("custCodeBuff in OrderShipmentEJB===["+custCodeBuff.toString()+"]");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
}
custCode = custCodeBuff.toString();
System.out.println("custCode in OrderShipmentEJB===["+custCode+"]");
}*/
if(custCode!=null && custCode.trim().length()>0)
{
custCode = dashbordUtil.getCommaSeparated(custCode);
custCodeSorder ="and sorder.cust_code in ("+custCode+")";
custCodeDespatch ="and despatch.cust_code in("+custCode+")";
System.out.println("in custcode block :: custCodeSorder-->"+custCodeSorder + "custCodeDespatch-->"+custCodeDespatch);
}
if(custCodeDlv!=null && custCodeDlv.trim().length()>0)
{
custCodeDlv = dashbordUtil.getCommaSeparated(custCodeDlv);
custCodeDlvSorder ="and sorder.cust_code__dlv in ("+custCodeDlv+")";
custCodeDlvDespatch ="and despatch.cust_code__dlv in ("+custCodeDlv+")";
System.out.println("in custCodeDlv block :: custCodeDlvSorder-->"+custCodeDlvSorder + "custCodeDlvDespatch-->"+custCodeDlvDespatch);
}
//end of code dynamic implementation
if((lastMonth!=null && lastMonth.trim().length()>0 ) && (siteCode!=null && siteCode.trim().length()>0))
{
sql = " select month,sum(orders) as orders, sum(despatches) as despatches,month1 "
+" from (select to_char(sorder.order_date, 'Mon-yy') as month,to_char(sorder.order_date, 'MM') as month1, "
+" count(sorder.sale_order) as orders,0 as despatches from sorder "
+" where sorder.order_date between trunc(to_date(TO_CHAR(ADD_MONTHS(SYSDATE, -"+lastMonth+"), 'ddMONyyyy'),'DD-MON-YYYY'),'MM') and "
+" last_day(trunc(sysdate)) "+custCodeSorder + " "+custCodeDlvSorder + " "
+" and sorder.site_code in ("+siteCode+") "
+" and sorder.confirmed = 'Y' group by to_char(sorder.order_date, 'Mon-yy'),to_char(sorder.order_date, 'MM') "
+" union all select to_char(despatch.desp_date, 'Mon-yy') as month,to_char (despatch.desp_date, 'MM') as month1, "
+" 0 as orders,count(despatch.desp_id) as despatches from despatch where despatch.desp_date between trunc(to_date(TO_CHAR(ADD_MONTHS(SYSDATE, -"+lastMonth+"), 'ddMONyyyy'),'DD-MON-YYYY'),'MM') and "
+" last_day(trunc(sysdate)) "+custCodeDespatch + " "+custCodeDlvDespatch + " "
+" and despatch.site_code in ("+siteCode+") "
+" and despatch.confirmed = 'Y' group by to_char(despatch.desp_date, 'Mon-yy'),to_char(despatch.desp_date, 'MM') ) "
+" group by month,month1 order by month1";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
int count = 0;
while (rs.next())
{
rowData = new JSONObject();
rowData.put("month", (rs.getString("month")));
rowData.put("orders", (rs.getString("orders")));
rowData.put("despatches", (rs.getString("despatches")));
monthWiseDespatchOrdersJson.put(count, rowData);
count++;
}
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :DespatchOrder for getmonthWiseDespatchOrders Method :" + d.getMessage());
throw new ITMException(d);
}
}
return monthWiseDespatchOrdersJson;
}
/*for futther planning Dhanendra*/
/*public String getcustCodefrmCust(String splitArry , Connection conn) throws SQLException, ITMException
{
String[] custNameArry = null;
String customerName = "";
String sql="";
PreparedStatement pstmt = null;
ResultSet rs = null;
StringBuffer custCodeBuff = new StringBuffer();
custNameArry = splitArry.split(",");
try
{
for (int custCnt = 0; custCnt < custNameArry.length; custCnt++)
{
customerName = custNameArry[custCnt];
sql = "SELECT CUST_CODE FROM CUSTOMER WHERE CUST_NAME = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, customerName);
rs = pstmt.executeQuery();
if(rs.next())
{
if (custCodeBuff.length() != 0)
{
custCodeBuff.append("," + rs.getString("cust_code").trim());
} else
{
custCodeBuff.append(rs.getString("cust_code").trim());
}
System.out.println("custCodeBuff in OrderShipmentEJB===["+custCodeBuff.toString()+"]");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
}
}catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :DespatchOrder for getmonthWiseDespatchOrders Method :" + d.getMessage());
throw new ITMException(d);
}
}
return custCodeBuff.toString();
}*/
}
package ibase.dashboard.scm.ejb;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
import org.json.simple.JSONObject;
@Local
public interface OrderVsShipmentLocal extends ValidatorLocal
{
public JSONObject getmonthWiseDespatchOrders(String lastMonth,String siteCode,String custCode,String custCodeDlv,String dataSourceName) throws RemoteException, ITMException;
}
package ibase.dashboard.scm.ejb;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
import org.json.simple.JSONObject;
@Remote
public interface OrderVsShipmentRemote extends ValidatorRemote
{
public JSONObject getmonthWiseDespatchOrders(String lastMonth,String siteCode,String custCode,String custCodeDlv,String dataSourceName) throws RemoteException, ITMException;
}
package ibase.dashboard.scm.ejb;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.ejb.Stateless;
import org.json.simple.JSONObject;
/**
* Session Bean implementation class CustomerInfoEJB
*/
@Stateless
public class SupplierInfoEJB extends ValidatorEJB implements SupplierInfoRemote, SupplierInfoLocal {
/**
* Default constructor.
*/
public SupplierInfoEJB() {
}
@SuppressWarnings("unchecked")
@Override
public JSONObject getPendingPurchase(String suppCode, String prdCode,String dataSourceName) throws RemoteException, ITMException
{
JSONObject rawDataPendingPurchJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
try
{
System.out.println(" Inside SupplierInfoEJB for getPendingPurchase Method Data Soruc Name ="+dataSourceName+" suppCode:"+suppCode+" prdCode is =" + prdCode);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
sql = " /*Put Sql Query */";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
int count = 0;
while (rs.next())
{
rowData = new JSONObject();
/*rowData.put("sp_name", (rs.getString("sp_name")));
rowData.put("max_event_date", (rs.getString("max_event_date")));
rowData.put("year", (rs.getString("yyyymm")));
rowData.put("month", (rs.getString("monyyyy")));
rowData.put("brand_code", (rs.getString("brand_code")));
rowData.put("brand", (rs.getString("brand")));
rowData.put("doc_code", rs.getString("doc_code"));
rowData.put("doc_name", rs.getString("doc_name"));
rowData.put("spl_code", rs.getString("spl_code"));
rowData.put("spl_descr", rs.getString("spl_descr"));
rowData.put("presc_no", rs.getString("presc_no")); */
rawDataPendingPurchJson.put(count, rowData);
count++;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :SupplierInfoEJB for getPendingPurchase Method :" + d.getMessage());
throw new ITMException(d);
}
}
return rawDataPendingPurchJson;
}
private String getGeolocation(String geoLocation)
{
String[] geoLocArray = this.getSplitedStrng(geoLocation);
String modifyGeoLoc = "";
if (geoLocArray != null)
{
for (int i = 0; i < geoLocArray.length; i++)
{
if (i == geoLocArray.length - 1)
{
modifyGeoLoc = modifyGeoLoc + "'" + geoLocArray[i] + "'";
} else
{
modifyGeoLoc = modifyGeoLoc + "'" + geoLocArray[i] + "',";
}
}
} else
{
modifyGeoLoc = "";
}
return modifyGeoLoc;
}
private String[] getSplitedStrng(String year)
{
String[] splitedArray = null;
if (year != null && year.length() > 0)
{
splitedArray = year.split(",");
}
return splitedArray;
}
}
package ibase.dashboard.scm.ejb;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
import org.json.simple.JSONObject;
@Local
public interface SupplierInfoLocal extends ValidatorLocal
{
public JSONObject getPendingPurchase(String suppCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
}
package ibase.dashboard.scm.ejb;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
import org.json.simple.JSONObject;
@Remote
public interface SupplierInfoRemote extends ValidatorRemote
{
public JSONObject getPendingPurchase(String suppCode, String prdCode, String dataSourceName) throws RemoteException, ITMException;
}
package ibase.dashboard.scm.servlet;
import ibase.dashboard.scm.ejb.ItemInfoRemote;
import ibase.system.config.AppConnectParm;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
public class CurntInvServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
JSONObject jsonObjMetaData =null;
JSONObject jsonMetaData = null;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
ItemInfoRemote itmInfoRemote = null;
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String itmCode = "";
String prdCode = "";
String reportName="";
try
{
response.setContentType("application/xml");
HttpSession session = request.getSession(true);
dataSourceName =request.getParameter("dataSourceName");
itmCode =request.getParameter("itmCode");
prdCode =request.getParameter("prdCode");
reportName = request.getParameter("reportName");
System.out.println("in doPost" + "itmCode is =" + itmCode );
System.out.println( "prdCode is =" + prdCode );
session.setAttribute("reportName", reportName);
System.out.println("reportName is =" + reportName );
context = new InitialContext(appConnectParm.getProperty());
itmInfoRemote = (ItemInfoRemote)context.lookup("ibase/ItemInfoEJB/remote");
JSONObject jsonObjData = (JSONObject)itmInfoRemote.getCurrentInventory(itmCode,prdCode,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set for CurntInvServlet build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : CurntInvServlet :" + e);
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
}
\ No newline at end of file
package ibase.dashboard.scm.servlet;
import ibase.dashboard.scm.ejb.CustomerInfoRemote;
import ibase.system.config.AppConnectParm;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
public class CurntRecvbleChartServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
CustomerInfoRemote custInfoRemote = null;
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String custCode = "";
String lastMonth = "";
String reportName="";
try
{
response.setContentType("application/xml");
HttpSession session = request.getSession(true);
dataSourceName =request.getParameter("dataSourceName");
custCode =request.getParameter("custCode");
lastMonth =request.getParameter("prdCode");
reportName = request.getParameter("reportName");
session.setAttribute("reportName", reportName);
System.out.println("reportName is =" + reportName );
System.out.println("dataSourceName in CurntRecvbleChartServlet==="+dataSourceName);
System.out.println("custCode in CurntRecvbleChartServlet ==" + custCode );
System.out.println("lastMonth in CurntRecvbleChartServlet ==" + lastMonth );
context = new InitialContext(appConnectParm.getProperty());
custInfoRemote = (CustomerInfoRemote)context.lookup("ibase/CustomerInfoEJB/remote");
JSONObject jsonObjData = (JSONObject)custInfoRemote.getCurrentReceivableChartView(custCode,lastMonth,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set in CurntRecvbleChartServlet build the Graph/Grid===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : CurntRecvbleChartServlet :" + e.getMessage());
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
}
package ibase.dashboard.scm.servlet;
import ibase.dashboard.scm.ejb.CustomerInfoRemote;
import ibase.system.config.AppConnectParm;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
public class CurntRecvbleServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
JSONObject jsonObjMetaData =null;
JSONObject jsonMetaData = null;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
CustomerInfoRemote custInfoRemote = null;
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String custCode = "";
String prdCode = "";
String reportName="";
try
{
response.setContentType("application/xml");
HttpSession session = request.getSession(true);
dataSourceName =request.getParameter("dataSourceName");
custCode =request.getParameter("custCode");
prdCode =request.getParameter("prdCode");
reportName = request.getParameter("reportName");
session.setAttribute("reportName", reportName);
System.out.println("reportName is =" + reportName );
System.out.println("dataSourceName==="+dataSourceName);
System.out.println("custCode is =>" + custCode );
System.out.println( "prdCode is =>" + prdCode );
context = new InitialContext(appConnectParm.getProperty());
custInfoRemote = (CustomerInfoRemote)context.lookup("ibase/CustomerInfoEJB/remote");
JSONObject jsonObjData = (JSONObject)custInfoRemote.getCurrentReceivable(custCode,prdCode,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set for CurntRecvbleServlet build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : CurntRecvbleServlet :" + e);
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
}
\ No newline at end of file
package ibase.dashboard.scm.servlet;
import ibase.dashboard.scm.ejb.CustomerInfoRemote;
import ibase.system.config.AppConnectParm;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
public class OrderHistoryServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
JSONObject jsonObjMetaData =null;
JSONObject jsonMetaData = null;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
CustomerInfoRemote custInfoRemote = null;
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String custCode = "";
String prdCode = "";
String reportName="";
try
{
response.setContentType("application/xml");
HttpSession session = request.getSession(true);
dataSourceName =request.getParameter("dataSourceName");
custCode =request.getParameter("custCode");
prdCode =request.getParameter("prdCode");
reportName = request.getParameter("reportName");
session.setAttribute("reportName", reportName);
System.out.println("reportName is =" + reportName );
System.out.println("in doPost" + "custCode is =" + custCode );
System.out.println( "prdCode is =" + prdCode );
context = new InitialContext(appConnectParm.getProperty());
custInfoRemote = (CustomerInfoRemote)context.lookup("ibase/CustomerInfoEJB/remote");
JSONObject jsonObjData = (JSONObject)custInfoRemote.getOrderHistory(custCode,prdCode,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set for OrderHistoryServlet build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : OrderHistoryServlet :" + e);
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
}
\ No newline at end of file
package ibase.dashboard.scm.servlet;
import ibase.dashboard.scm.ejb.OrderVsShipmentRemote;
import ibase.system.config.AppConnectParm;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
public class OrderVsShipmentServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
JSONObject jsonObjMetaData =null;
JSONObject jsonMetaData = null;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
OrderVsShipmentRemote despatchOrderRemote = null;
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String siteCode = "";
String lastMonth = "";
String reportName="";
String custCode="";
String custCodeDlv="";
try
{
response.setContentType("application/xml");
HttpSession session = request.getSession(true);
dataSourceName = request.getParameter("dataSourceName");
lastMonth = request.getParameter("lastMonth");
siteCode = request.getParameter("siteCode");
custCode = request.getParameter("custCode");
custCodeDlv = request.getParameter("custCodeDlv");
reportName = request.getParameter("reportName");
if(siteCode == null || siteCode.trim().length()<0 || siteCode.equals("") || siteCode == "")
{
ibase.utility.UserInfoBean userInfo = (ibase.utility.UserInfoBean) session.getAttribute("USER_INFO");
siteCode = userInfo.getSiteCode();
System.out.println("in OrderVsShipmentServlet siteCode from Session is=="+siteCode);
}
System.out.println("in doPost" + "siteCode is =" + siteCode+" lastMonth:"+lastMonth+" custCode:"+custCode+" custCodeDlv:"+custCodeDlv);
session.setAttribute("reportName", reportName);
System.out.println("reportName is =" + reportName );
context = new InitialContext(appConnectParm.getProperty());
despatchOrderRemote = (OrderVsShipmentRemote)context.lookup("ibase/OrderVsShipmentEJB/remote");
JSONObject jsonObjData = (JSONObject)despatchOrderRemote.getmonthWiseDespatchOrders(lastMonth,siteCode,custCode,custCodeDlv,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set for OrderVsShipmentServlet build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : OrderVsShipmentServlet :" + e);
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
}
\ No newline at end of file
package ibase.dashboard.scm.servlet;
import ibase.dashboard.scm.ejb.CustomerInfoRemote;
import ibase.system.config.AppConnectParm;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
public class PendingOrderServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
JSONObject jsonObjMetaData =null;
JSONObject jsonMetaData = null;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
CustomerInfoRemote custInfoRemote = null;
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String custCode = "";
String prdCode = "";
String reportName="";
try
{
response.setContentType("application/xml");
HttpSession session = request.getSession(true);
dataSourceName =request.getParameter("dataSourceName");
custCode =request.getParameter("custCode");
prdCode =request.getParameter("prdCode");
reportName = request.getParameter("reportName");
session.setAttribute("reportName", reportName);
System.out.println("reportName is =" + reportName );
System.out.println("in doPost" + "custCode is =" + custCode );
System.out.println( "prdCode is =" + prdCode );
context = new InitialContext(appConnectParm.getProperty());
custInfoRemote = (CustomerInfoRemote)context.lookup("ibase/CustomerInfoEJB/remote");
JSONObject jsonObjData = (JSONObject)custInfoRemote.getPendingOrder(custCode,prdCode,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set for PendingOrderServlet build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : PendingOrderServlet :" + e);
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
}
\ No newline at end of file
package ibase.dashboard.scm.servlet;
import ibase.dashboard.scm.ejb.SupplierInfoRemote;
import ibase.system.config.AppConnectParm;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
public class PendingPurchaseServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
JSONObject jsonObjMetaData =null;
JSONObject jsonMetaData = null;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
SupplierInfoRemote suppInfoRemote = null;
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String suppCode = "";
String prdCode = "";
String reportName="";
try
{
response.setContentType("application/xml");
HttpSession session = request.getSession(true);
dataSourceName =request.getParameter("dataSourceName");
suppCode =request.getParameter("suppCode");
prdCode =request.getParameter("prdCode");
reportName = request.getParameter("reportName");
session.setAttribute("reportName", reportName);
System.out.println("reportName is =" + reportName );
System.out.println("in doPost" + "suppCode is =" + suppCode );
System.out.println( "prdCode is =" + prdCode );
context = new InitialContext(appConnectParm.getProperty());
suppInfoRemote = (SupplierInfoRemote)context.lookup("ibase/SupplierInfoEJB/remote");
JSONObject jsonObjData = (JSONObject)suppInfoRemote.getPendingPurchase(suppCode,prdCode,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set for PendingPurchaseServlet build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : PendingPurchaseServlet :" + e);
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
}
\ No newline at end of file
package ibase.dashboard.scm.servlet;
import ibase.dashboard.scm.ejb.ItemInfoRemote;
import ibase.system.config.AppConnectParm;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
public class SalesHisInfoQtyServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
JSONObject jsonObjMetaData =null;
JSONObject jsonMetaData = null;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
ItemInfoRemote itmInfoRemote = null;
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String itmCode = "";
String prdCode = "";
String reportName="";
try
{
response.setContentType("application/xml");
HttpSession session = request.getSession(true);
dataSourceName =request.getParameter("dataSourceName");
itmCode =request.getParameter("itmCode");
prdCode =request.getParameter("prdCode");
reportName = request.getParameter("reportName");
session.setAttribute("reportName", reportName);
System.out.println("reportName is =" + reportName );
System.out.println("in doPost" + "itmCode is =" + itmCode );
System.out.println( "prdCode is =" + prdCode );
context = new InitialContext(appConnectParm.getProperty());
itmInfoRemote = (ItemInfoRemote)context.lookup("ibase/ItemInfoEJB/remote");
JSONObject jsonObjData = (JSONObject)itmInfoRemote.getSalesHistoryInfoQty(itmCode,prdCode,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set for getSalesHistoryInfoQty build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : getSalesHistoryInfoQty :" + e);
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
}
\ No newline at end of file
package ibase.dashboard.scm.servlet;
import ibase.dashboard.scm.ejb.CustomerInfoRemote;
import ibase.system.config.AppConnectParm;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
public class SalesHistoryServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
JSONObject jsonObjMetaData =null;
JSONObject jsonMetaData = null;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
CustomerInfoRemote custInfoRemote = null;
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String custCode = "";
String prdCode = "";
String reportName="";
try
{
response.setContentType("application/xml");
HttpSession session = request.getSession(true);
dataSourceName =request.getParameter("dataSourceName");
custCode =request.getParameter("custCode");
prdCode =request.getParameter("prdCode");
reportName = request.getParameter("reportName");
session.setAttribute("reportName", reportName);
System.out.println("reportName is =" + reportName );
System.out.println("in doPost" + "custCode is =" + custCode );
System.out.println( "prdCode is =" + prdCode );
context = new InitialContext(appConnectParm.getProperty());
custInfoRemote = (CustomerInfoRemote)context.lookup("ibase/CustomerInfoEJB/remote");
JSONObject jsonObjData = (JSONObject)custInfoRemote.getSalesHistory(custCode,prdCode,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set for SalesHistoryServlet build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : SalesHistoryServlet :" + e);
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
}
\ No newline at end of file
package ibase.dashboard.scm.servlet;
import ibase.dashboard.scm.ejb.CustomerInfoRemote;
import ibase.system.config.AppConnectParm;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
public class TranstnSummaryServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
JSONObject jsonObjMetaData =null;
JSONObject jsonMetaData = null;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
CustomerInfoRemote custInfoRemote = null;
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String custCode = "";
String prdCode = "";
String reportName="";
try
{
response.setContentType("application/xml");
HttpSession session = request.getSession(true);
dataSourceName =request.getParameter("dataSourceName");
custCode =request.getParameter("custCode");
prdCode =request.getParameter("prdCode");
reportName = request.getParameter("reportName");
session.setAttribute("reportName", reportName);
System.out.println("reportName is =" + reportName );
System.out.println("in doPost" + "custCode is =" + custCode );
System.out.println( "prdCode is =" + prdCode );
context = new InitialContext(appConnectParm.getProperty());
custInfoRemote = (CustomerInfoRemote)context.lookup("ibase/CustomerInfoEJB/remote");
JSONObject jsonObjData = (JSONObject)custInfoRemote.getTransactionSummary(custCode,prdCode,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" Final data set for TranstnSummaryServlet build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : TranstnSummaryServlet :" + e);
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
}
\ No newline at end of file
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