Commit 6d7358e4 authored by pborate's avatar pborate

Updated to get filters based on SFAPARM entry & customer info data based on no. of calls

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@195243 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 6f490a97
...@@ -639,6 +639,105 @@ public class CustomerInfoDao { ...@@ -639,6 +639,105 @@ public class CustomerInfoDao {
return conn; return conn;
} }
public JSONArray getCustomerLastCallHistory(String strgCode, int callsCount) throws Exception {
System.out.println("Inside getCustomerCallHistory:::::::::::::::::: strgCode["+strgCode+"] number:["+callsCount+"]");
E12GenericUtility genericUtility = new E12GenericUtility();
PreparedStatement pstmt = null;
ResultSet rs = null;
Connection conn =null;
boolean isLocalConn =false;
JSONArray custCallHistJsonArr = new JSONArray();
try
{
if(conn == null)
{
conn = getConnection();
isLocalConn =true;
}
String custCallHistSql="";
custCallHistSql = "select * from ( select sm.dcr_id, sm.sales_pers,sm.strg_code,sm.event_date, sm.event_time_start,sm.event_time_end, sm.call_outcome, " +
" CASE WHEN CALL_OUTCOME = '0' THEN 'Refused'" +
" WHEN CALL_OUTCOME = '5' THEN 'Supporter'" +
" WHEN CALL_OUTCOME = '6' THEN 'Believer'" +
" WHEN CALL_OUTCOME = '7' THEN 'Non Believer'" +
" ELSE 'NA' END AS call_outcome_descr, sm.remarks" +
" from strg_meet sm" +
" where event_type <>'PR'" +
" and strg_code = '"+strgCode+"'" +
" order by sm.event_date desc )" +
" where Rownum <= "+callsCount;
System.out.println("custInfoSql+++"+custCallHistSql);
pstmt = conn.prepareStatement(custCallHistSql);
rs = pstmt.executeQuery();
while(rs.next())
{
JSONObject custCallHistJson = new JSONObject();
String dcrId = rs.getString("DCR_ID");
String salesPers = rs.getString("SALES_PERS");
String strg_code = rs.getString("STRG_CODE");
String eventDate = rs.getString("EVENT_DATE");
String eventTimeStrt = rs.getString("EVENT_TIME_START");
String eventTimeEnd = rs.getString("EVENT_TIME_END");
String callOutcome = rs.getString("CALL_OUTCOME");
String callOutcomeDesc = rs.getString("CALL_OUTCOME_DESCR");
String remarks = rs.getString("REMARKS");
custCallHistJson.put("DCR_ID", dcrId);
custCallHistJson.put("SALES_PERS", salesPers);
custCallHistJson.put("STRG_CODE", strg_code);
custCallHistJson.put("EVENT_DATE", eventDate);
custCallHistJson.put("EVENT_TIME_START", eventTimeStrt);
custCallHistJson.put("EVENT_TIME_END", eventTimeEnd);
custCallHistJson.put("CALL_OUTCOME", callOutcome);
custCallHistJson.put("CALL_OUTCOME_DESCR", callOutcomeDesc);
custCallHistJson.put("REMARKS", remarks);
custCallHistJsonArr.put(custCallHistJson);
}
}
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(isLocalConn && conn != null && ! conn.isClosed() )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
}
}
System.out.println("custCallHistJson :: "+custCallHistJsonArr);
return custCallHistJsonArr;
}
public String checkNull(String input) public String checkNull(String input)
{ {
if (input == null || "null".equalsIgnoreCase(input)) if (input == null || "null".equalsIgnoreCase(input))
......
...@@ -2,9 +2,13 @@ package ibase.dashboard.common.hibernate.dao; ...@@ -2,9 +2,13 @@ package ibase.dashboard.common.hibernate.dao;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -28,6 +32,7 @@ import org.w3c.dom.NodeList; ...@@ -28,6 +32,7 @@ import org.w3c.dom.NodeList;
import ibase.dashboard.common.hibernate.bean.Pophelp; import ibase.dashboard.common.hibernate.bean.Pophelp;
import ibase.hibernate.utility.HibernateUtil; import ibase.hibernate.utility.HibernateUtil;
import ibase.system.config.AppConnectParm; import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants; import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean; import ibase.utility.UserInfoBean;
...@@ -38,6 +43,20 @@ public class DashboardUtil ...@@ -38,6 +43,20 @@ public class DashboardUtil
{ {
private String userTranDB = "DEFAULT"; private String userTranDB = "DEFAULT";
private UserInfoBean userInfo = null;
public UserInfoBean getUserInfo()
{
return this.userInfo;
}
public void setUserInfo(UserInfoBean userInfo)
{
System.out.println("getUserInfo"+userInfo);
this.userInfo = userInfo;
System.out.println("getUserInfo"+userInfo);
}
//To fetch siteCode of user //To fetch siteCode of user
private String userSite; private String userSite;
...@@ -760,40 +779,79 @@ public class DashboardUtil ...@@ -760,40 +779,79 @@ public class DashboardUtil
//System.out.println("size>>>>>>"+size); //System.out.println("size>>>>>>"+size);
JSONObject fil= filterTemp.getJSONObject(i); JSONObject fil= filterTemp.getJSONObject(i);
System.out.println("filter>>>>>> "+i+" "+fil); System.out.println("filter>>>>>> "+i+" "+fil);
String colName=fil.optString("col_name");
String modName=fil.optString("mod_name");
String type=fil.optString("type");
Object defaultValue=fil.opt("default_value"); boolean addFilter = true;
System.out.println("defaultValue::::"+defaultValue); String parm_name = fil.optString("parm_name");
if(defaultValue ==null || defaultValue instanceof JSONObject) { String parm_value = fil.optString("parm_value");
if(type.equalsIgnoreCase("4")) { if(parm_name != null && parm_name.length() > 0)
System.out.println("Inside if processDashboardFilter 4::::"+sourceDateFormat); {
fil.put("default_value", "CURRENT_DATE"); String parmVal = getSfaParmVal(parm_name);
if(parmVal != null && parmVal.length() > 0 && parm_value != null && parm_value.length() > 0)
{
String[] parmValues = parm_value.split(",");
System.out.println("In parmVal != null"+parmValues+" parm_value :["+parm_value+"]");
if(Arrays.asList(parmValues).contains(parmVal.trim()))
{
addFilter = true;
}
else
{
addFilter = false;
}
System.out.println("In parmVal != null addFilter["+addFilter+"]");
} }
else { else
fil.put("default_value",""); {
if(fil.optString("isDefault").equals("Y"))
{
addFilter = true;
}
else
{
addFilter = false;
}
} }
} }
//TO FETCH SITECODE OF USER LOGGED IN
else if(defaultValue !=null && "CURRENT_SITE".equalsIgnoreCase(defaultValue.toString())) {
fil.put("default_value",userSite+",");
System.out.println("toget user site code => "+fil);
}
System.out.println("default value "+fil); if(addFilter)
System.out.println("Inside type processDashboardFilter>>>>>>"+type); {
JSONObject popHelpData = new JSONObject(); String colName=fil.optString("col_name");
if(type.equalsIgnoreCase("1")) { String modName=fil.optString("mod_name");
System.out.println("Inside if processDashboardFilter::::"); String type=fil.optString("type");
fil=processPophelpData(colName, modName,fil);
} Object defaultValue=fil.opt("default_value");
else { System.out.println("defaultValue::::"+defaultValue);
fil.put("is_pophelp", false); if(defaultValue ==null || defaultValue instanceof JSONObject) {
if(type.equalsIgnoreCase("4")) {
System.out.println("Inside if processDashboardFilter 4::::"+sourceDateFormat);
fil.put("default_value", "CURRENT_DATE");
}
else {
fil.put("default_value","");
}
}
//TO FETCH SITECODE OF USER LOGGED IN
else if(defaultValue !=null && "CURRENT_SITE".equalsIgnoreCase(defaultValue.toString())) {
fil.put("default_value",userSite+",");
System.out.println("toget user site code => "+fil);
}
System.out.println("default value "+fil);
System.out.println("Inside type processDashboardFilter>>>>>>"+type);
JSONObject popHelpData = new JSONObject();
if(type.equalsIgnoreCase("1")) {
System.out.println("Inside if processDashboardFilter::::");
fil=processPophelpData(colName, modName,fil);
}
else {
fil.put("is_pophelp", false);
}
filter.put( fil);
} }
filter.put( fil);
} }
// filters.put("filter", filter); // filters.put("filter", filter);
...@@ -802,23 +860,61 @@ public class DashboardUtil ...@@ -802,23 +860,61 @@ public class DashboardUtil
{ {
JSONObject filterObj= filters.optJSONObject("filter"); JSONObject filterObj= filters.optJSONObject("filter");
System.out.println("filter JSONObject>>>>>>"+filterObj); System.out.println("filter JSONObject>>>>>>"+filterObj);
String colName=filterObj.optString("col_name");
String modName=filterObj.optString("mod_name");
String type=filterObj.optString("type");
System.out.println("Inside type processDashboardFilter>>>>>>"+type);
JSONObject popHelpData = new JSONObject();
if(type.equalsIgnoreCase("1")) { boolean addFilter = true;
System.out.println("Inside if processDashboardFilter::::"); String parm_name = filterObj.optString("parm_name");
filterObj=processPophelpData(colName, modName,filterObj); String parm_value = filterObj.optString("parm_value");
if(parm_name != null && parm_name.length() > 0)
{
String parmVal = getSfaParmVal(parm_name);
if(parmVal != null && parmVal.length() > 0)
{
String[] parmValues = parm_value.split(",");
if(Arrays.asList(parmValues).contains(parmVal))
{
addFilter = true;
}
else
{
addFilter = false;
}
}
else
{
if(filterObj.optString("isDefault").equals("Y"))
{
addFilter = true;
}
else
{
addFilter = false;
}
}
} }
else {
filterObj.put("is_pophelp", false); if(addFilter)
{
String colName=filterObj.optString("col_name");
String modName=filterObj.optString("mod_name");
String type=filterObj.optString("type");
System.out.println("Inside type processDashboardFilter>>>>>>"+type);
JSONObject popHelpData = new JSONObject();
if(type.equalsIgnoreCase("1")) {
System.out.println("Inside if processDashboardFilter::::");
filterObj=processPophelpData(colName, modName,filterObj);
}
else {
filterObj.put("is_pophelp", false);
}
filter =new JSONArray();
filter.put(filterObj);
// filters.put("filter", filter);
} }
filter =new JSONArray();
filter.put(filterObj);
// filters.put("filter", filter);
} }
filters.put("filter", filter); filters.put("filter", filter);
} }
...@@ -1123,5 +1219,110 @@ public class DashboardUtil ...@@ -1123,5 +1219,110 @@ public class DashboardUtil
return reportConfig; return reportConfig;
} }
//Added By Saitej D on [26 Dec 2018] To [Save Explore Report] END //Added By Saitej D on [26 Dec 2018] To [Save Explore Report] END
public String getSfaParmVal( String parm_name ) throws ITMException
{
System.out.println("Inside getSfaParmVal:::::::::::::::::: parm_name["+parm_name+"]");
PreparedStatement pstmt = null;
ResultSet rs = null;
Connection conn =null;
boolean isLocalConn =false;
String sfaParmVal = null;
try
{
if(conn == null)
{
conn = getConnection();
isLocalConn =true;
}
String getSfaParmVal="select PARM_VALUE from sfaparm where PARM_NAME = '"+parm_name+"'";
System.out.println("getSfaParmVal+++"+getSfaParmVal);
pstmt = conn.prepareStatement(getSfaParmVal);
rs = pstmt.executeQuery();
if(rs.next())
{
sfaParmVal = rs.getString("PARM_VALUE");
}
}
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(isLocalConn && conn != null && ! conn.isClosed() )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
}
}
System.out.println("In return getSfaParmVal ["+sfaParmVal+"]");
return sfaParmVal;
}
public Connection getConnection()
{
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
try
{
System.out.println(" In StrgMeetwizardBean :: getConnection() :: ["+this.userInfo+"]");
if(this.userInfo != null)
{
String transDB = this.userInfo.getTransDB();
System.out.println(" StrgMeetwizardBean getConnection :: transDB :: ["+transDB+"]");
if( transDB != null && transDB.trim().length() > 0 && !"null".equalsIgnoreCase(transDB))
{
conn = connDriver.getConnectDB(transDB);
connDriver = null;
System.out.println(" StrgMeetwizardBean getConnection :: transDB :: on if condition :["+transDB+"]");
}
else
{
System.out.println(" StrgMeetwizardBean :: transDB is null :: So that creating connection using DriverITM....");
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
}
}
else
{
System.out.println(" StrgMeetwizardBean :: UserInfo is null :: So that creating connection using DriverITM....");
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
}
}
catch(Exception e)
{
System.out.println("Exception : [StrgMeetwizardBean][getConnection] :==>\n"+e.getMessage());
e.printStackTrace();
}
return conn;
}
} }
...@@ -31,9 +31,10 @@ public class CustomerInfoService { ...@@ -31,9 +31,10 @@ public class CustomerInfoService {
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getCustomerInfo(@QueryParam("STRG_CODE") String strgCode, public String getCustomerInfo(@QueryParam("STRG_CODE") String strgCode,
@QueryParam("fromDate") String fromDate, @QueryParam("fromDate") String fromDate,
@QueryParam("toDate") String toDate) throws Exception @QueryParam("toDate") String toDate,
@QueryParam("NO_OF_CALLS") String noOfCalls) throws Exception
{ {
System.out.println("In getCustomerInfo:: strgCode["+strgCode+"] fromDate:: ["+fromDate+"] toDate:: ["+toDate+"]"); System.out.println("In getCustomerInfo:: strgCode["+strgCode+"] fromDate:: ["+fromDate+"] toDate:: ["+toDate+"] noOfCalls["+noOfCalls+"]");
JSONObject customerInfoObj = new JSONObject(); JSONObject customerInfoObj = new JSONObject();
UserInfoBean userInfo = getUserInfo(); UserInfoBean userInfo = getUserInfo();
...@@ -62,7 +63,21 @@ public class CustomerInfoService { ...@@ -62,7 +63,21 @@ public class CustomerInfoService {
customerInfoDao.setUserInfo(userInfo); customerInfoDao.setUserInfo(userInfo);
customerInfoObj = customerInfoDao.getCustInfoData(strgCode); customerInfoObj = customerInfoDao.getCustInfoData(strgCode);
JSONArray custHistArr = customerInfoDao.getCustomerCallHistory(strgCode, fromDate, toDate); JSONArray custHistArr = new JSONArray();
if(noOfCalls != null && noOfCalls.length() > 0)
{
int callsCount = 0;
try {
callsCount = Integer.parseInt(noOfCalls);
}catch(Exception e) {
callsCount = 0;
}
custHistArr = customerInfoDao.getCustomerLastCallHistory(strgCode, callsCount);
}
else
{
custHistArr = customerInfoDao.getCustomerCallHistory(strgCode, fromDate, toDate);
}
custHistArr = customerInfoDao.getCustomerDetails(custHistArr); custHistArr = customerInfoDao.getCustomerDetails(custHistArr);
customerInfoObj.put("CALL_HISTORY", custHistArr); customerInfoObj.put("CALL_HISTORY", custHistArr);
......
...@@ -91,6 +91,7 @@ public class DashboardService { ...@@ -91,6 +91,7 @@ public class DashboardService {
if(fileCheck) if(fileCheck)
{ {
System.out.println("Inside else of get dashboard config"); System.out.println("Inside else of get dashboard config");
util.setUserInfo(userInfo);
dashboardMetadata = util.getDashboardConfig(dashboardMetadataFilePath,userInfo); dashboardMetadata = util.getDashboardConfig(dashboardMetadataFilePath,userInfo);
dashboardMetadata.put("status","success" ); dashboardMetadata.put("status","success" );
} }
......
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