Commit 60289e93 authored by pborate's avatar pborate

Updated changes in customerInfo class for top brands

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@192262 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 92e55478
......@@ -235,6 +235,98 @@ public class CustomerInfoDao {
return custCallHistJsonArr;
}
public JSONArray getTopBrands(String empCode,String sprsCode) throws Exception {
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 BRAND_CODE," +
" 'COLOR_' || ROWNUM AS COLOUR," +
" ( SELECT DESCRIPTION FROM BRAND WHERE BRAND_CODE=BRAND_PITCH.BRAND_CODE" +
" ) DESCR," +
" BRAND_PITCH_CNT" +
" FROM" +
" (SELECT BRAND_CODE," +
" COUNT(BRAND_CODE) BRAND_PITCH_CNT" +
" FROM STRG_BRAND_PITCH" +
" WHERE SALES_PERS = '"+empCode+"'" +
" AND SC_CODE ='"+sprsCode+"'" +
" GROUP BY BRAND_CODE" +
" ORDER BY BRAND_PITCH_CNT DESC" +
" ) BRAND_PITCH" +
" WHERE ROWNUM < 11"
+ ") WHERE BRAND_CODE IS NOT NULL AND DESCR IS NOT NULL";
System.out.println("getTopBrands+++"+custCallHistSql);
pstmt = conn.prepareStatement(custCallHistSql);
rs = pstmt.executeQuery();
while(rs.next())
{
System.out.println("Inside ");
JSONObject custCallHistJson = new JSONObject();
String brandCode = rs.getString("BRAND_CODE");
String descr = rs.getString("DESCR");
Integer brandPitchCnt = rs.getInt("BRAND_PITCH_CNT");
String colour = rs.getString("COLOUR");
custCallHistJson.put("BRAND_CODE", checkNull(brandCode));
custCallHistJson.put("DESCRIPTION", checkNull(descr));
custCallHistJson.put("BRAND_PITCH_CNT", brandPitchCnt);
custCallHistJson.put("COLOUR", colour);
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("getTopBrands Result :: "+custCallHistJsonArr);
return custCallHistJsonArr;
}
public JSONArray getCustomerDetails(JSONArray custHistArr) throws JSONException, ITMException{
for(int i = 0; i < custHistArr.length(); i++) {
......
......@@ -38,6 +38,7 @@ public class CustomerInfoService {
UserInfoBean userInfo = getUserInfo();
E12GenericUtility genericUtility = new E12GenericUtility();
String empCode="";
try
{
......@@ -56,14 +57,17 @@ public class CustomerInfoService {
toDate = sdf.format(new java.util.Date());
System.out.println("getCustomerInfo toDate [" + toDate + "]");
}
empCode=userInfo.getEmpCode();
CustomerInfoDao customerInfoDao = new CustomerInfoDao();
customerInfoDao.setUserInfo(userInfo);
customerInfoObj = customerInfoDao.getCustInfoData(strgCode);
JSONArray custHistArr = customerInfoDao.getCustomerCallHistory(strgCode, fromDate, toDate);
custHistArr = customerInfoDao.getCustomerDetails(custHistArr);
customerInfoObj.put("CALL_HISTORY", custHistArr);
customerInfoObj.put("CALL_HISTORY", custHistArr);
JSONArray topBrandsArray = customerInfoDao.getTopBrands(empCode,strgCode);
customerInfoObj.put("TOP_BRANDS", topBrandsArray);
}
}
catch (Exception e)
......
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