Commit 33dcd938 authored by msinkar's avatar msinkar

Added For HCP-Dashboard

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@186821 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 7b661a65
package ibase.dashboard.sfa.ejb;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
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.text.SimpleDateFormat;
import java.util.Date;
import javax.ejb.Stateless;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@Stateless
public class HealthCareEJB extends ValidatorEJB implements HealthCareEJBLocal,HealthCareEJBRemote
{
public HealthCareEJB()
{
}
//added by mrunalini sinkar for Esi KPI Report(start)
@Override
public String getHealthCareData(String loginCode, String dataSourceName, String fromDate, String toDate, String teamArgs ,String profileId) throws RemoteException,ITMException
{
JSONArray returnJsonArr = new JSONArray();
System.out.println("In HealthCareEJB loginCode["+loginCode+"] dataSourceName["+dataSourceName+"] fromDateStr["+fromDate+"] toDateStr["+toDate+"] teamArgs["+teamArgs+"] profileId["+profileId+"]");
Connection mConnection = null;
PreparedStatement mStatement = null;
ResultSet mResultSet = null;
ConnDriver connDriver = new ConnDriver();
E12GenericUtility e12genericUtil = new E12GenericUtility();
try
{
SimpleDateFormat dateFormat = new SimpleDateFormat(e12genericUtil.getApplDateFormat());
Date date = new Date();
if( "".equals( E12GenericUtility.checkNull(fromDate) ) )
{
fromDate = dateFormat.format(date);
System.out.println("fromDateStr:::["+fromDate+"]");
}
if( "".equals( E12GenericUtility.checkNull(toDate) ) )
{
toDate = dateFormat.format(date);
System.out.println("toDateStr:::["+toDate+"]");
}
if(mConnection == null)
{
mConnection = connDriver.getConnectDB( dataSourceName );
}
fromDate = e12genericUtil.getValidDateString(fromDate, e12genericUtil.getApplDateFormat(), e12genericUtil.getDBDateFormat());
toDate = e12genericUtil.getValidDateString(toDate, e12genericUtil.getApplDateFormat(), e12genericUtil.getDBDateFormat());
System.out.println("fromDateStr["+fromDate+"] toDateStr["+toDate+"]");
String query = ""; //$NON-NLS-1$
query=
"SELECT EMPLOYEE.HOBBY1 AS REGION, "
+"(SELECT EMP_FNAME ||' '|| EMP_LNAME FROM EMPLOYEE WHERE EMP_CODE = SUPERVISOR.EMP_CODE) AS SUPERVISOR_NAME, "
+"(SELECT DESCR FROM STATION WHERE STAN_CODE = ABM.STAN_CODE__HQ) AS ABM_HQ, "
+"(SELECT DESCR FROM STATION WHERE STAN_CODE = EMP.STAN_CODE__HQ) AS ESI_HQ, "
+"EMPLOYEE.EMP_CODE AS ESI_EMP_CODE, "
+"EMPLOYEE.DESIGNATION AS ESI_DSG, "
+"EMPLOYEE.EMP_FNAME ||' '|| EMPLOYEE.EMP_LNAME AS MR_NAME, "
+"SM.EVENT_DATE, "
+"SC.FIRST_NAME||' '||SC.LAST_NAME AS CUSTOMER_NAME "
+"FROM FIELDACTIVITY F, "
+"STRG_MEET SM LEFT OUTER JOIN STRG_CUSTOMER SC "
+"ON SM.STRG_CODE=SC.SC_CODE, "
+"EMPLOYEE EMPLOYEE LEFT OUTER JOIN ORG_STRUCTURE EMP "
+"ON EMPLOYEE.EMP_CODE = EMP.EMP_CODE "
+"LEFT OUTER JOIN ORG_STRUCTURE ABM "
+"ON EMP.POS_CODE__REPTO = ABM.POS_CODE "
+"LEFT OUTER JOIN ORG_STRUCTURE SUPERVISOR "
+"ON ABM.POS_CODE__REPTO = SUPERVISOR.POS_CODE "
+"WHERE F.ACTIVITY_CODE =SM.EVENT_TYPE "
+"AND SM.SALES_PERS =EMP.EMP_CODE "
+"AND EMPLOYEE.EMP_CODE IN "+getFormattedUserId(teamArgs)+" "
+"AND SM.EVENT_DATE BETWEEN ? AND ? "
+"AND SM.STRG_TYPE ='D' "
+"AND F.ACTIVITY_TYPE='FW' ";
mStatement = mConnection.prepareStatement(query);
mStatement.setDate(1, java.sql.Date.valueOf(fromDate) );
mStatement.setDate(2, java.sql.Date.valueOf(toDate) );
mResultSet = mStatement.executeQuery();
while(mResultSet.next())
{
JSONObject rowDataVar = new JSONObject();
rowDataVar.put("REGION", E12GenericUtility.checkNull(mResultSet.getString("REGION")));
rowDataVar.put("SUPERVISOR_NAME", E12GenericUtility.checkNull(mResultSet.getString("SUPERVISOR_NAME")));
rowDataVar.put("ABM_HQ", E12GenericUtility.checkNull(mResultSet.getString("ABM_HQ")));
rowDataVar.put("ESI_HQ", E12GenericUtility.checkNull(mResultSet.getString("ESI_HQ")));
rowDataVar.put("ESI_EMP_CODE", E12GenericUtility.checkNull(mResultSet.getString("ESI_EMP_CODE")));
rowDataVar.put("ESI_DSG", E12GenericUtility.checkNull(mResultSet.getString("ESI_DSG")));
rowDataVar.put("MR_NAME", E12GenericUtility.checkNull(mResultSet.getString("MR_NAME")));
rowDataVar.put("EVENT_DATE", e12genericUtil.getValidDateString( E12GenericUtility.checkNull(mResultSet.getDate("EVENT_DATE").toString()), e12genericUtil.getDBDateFormat(), e12genericUtil.getApplDateFormat()) );
rowDataVar.put("CUSTOMER_NAME", E12GenericUtility.checkNull(mResultSet.getString("CUSTOMER_NAME")));
returnJsonArr.add(rowDataVar);
System.out.println("returnJsonArr is:["+returnJsonArr+"]");
}
if(mStatement!=null)
{
mStatement.close();
mStatement=null;
}
if(mResultSet!=null)
{
mResultSet.close();
mResultSet = null;
}
if(mConnection!= null && !mConnection.isClosed())
{
mConnection.close();
mConnection = null;
}
}
catch ( Exception e)
{
System.out.println("Exception in HealthCareEJB.getHealthCareData():["+e.getMessage()+"]");
e.printStackTrace();
JSONObject errMsgJson = new JSONObject();
errMsgJson.put("result", getResponseMessage("No Data Found ! ","Failure") );
return errMsgJson.toString();
//throw new ITMException(e);
}
finally
{
try
{
if(mStatement!=null)
{
mStatement.close();
mStatement=null;
}
if(mResultSet!=null)
{
mResultSet.close();
mResultSet = null;
}
if(mConnection!= null && !mConnection.isClosed())
{
mConnection.close();
mConnection = null;
}
}
catch(SQLException se)
{
System.out.println("HealthCareEJB.getHealthCareData.finally["+se.getMessage()+"]");
se.printStackTrace();
JSONObject errMsgJson = new JSONObject();
errMsgJson.put("result", getResponseMessage("No Data Found ! ","Failure") );
return errMsgJson.toString();
}
}
System.out.println("returnJsonArr:::["+returnJsonArr+"]");
return returnJsonArr.toString();
}
public static String getFormattedUserId( String userId )
{
StringBuffer userIdSql = new StringBuffer();
try
{
System.out.println("@@@ getFormattedProfileId userId:::["+userId+"]");
if( userId.contains(",") )
{
userIdSql.append("(");
String[] pArr = userId.split(",");
for( int i = 0; i < pArr.length; i++ )
{
if( i == pArr.length - 1 )
{
userIdSql.append("'"+pArr[i]+"'");
}
else
{
userIdSql.append("'"+pArr[i]+"',");
}
}
userIdSql.append(")");
}
else
{
userIdSql.append("('"+userId+"')");
}
System.out.println("@@@ getFormattedProfileId profileIdSql:::["+userIdSql.toString()+"]");
}
catch( Exception e )
{
System.out.println("Exception : [E12GenericUtility][getFormattedProfileId] :==>\n"+e.getMessage());
e.printStackTrace();
}
return userIdSql.toString();
}
private JSONObject getResponseMessage(String successResponse, String status)
{
JSONObject respMessage = new JSONObject();
try
{
respMessage.put("message", successResponse);
respMessage.put("status", status);
}
catch (Exception e)
{
e.printStackTrace();
}
return respMessage;
}
}
package ibase.dashboard.sfa.ejb;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
@Local
public interface HealthCareEJBLocal extends ValidatorLocal
{
public String getHealthCareData(String loginCode, String dataSourceName, String fromDate, String toDate, String teamArgs ,String profileId) throws RemoteException,ITMException;
}
package ibase.dashboard.sfa.ejb;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
@Remote
public interface HealthCareEJBRemote extends ValidatorRemote
{
public String getHealthCareData(String loginCode, String dataSourceName, String fromDate, String toDate, String teamArgs ,String profileId) throws RemoteException,ITMException;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment