Commit 126f9325 authored by sbade's avatar sbade

Added Java file for Target Vs Achievement dashboard.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@100342 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 6db5db01
package ibase.dashboard.sfa.ejb;
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.Calendar;
import javax.ejb.Stateless;
import org.json.simple.JSONObject;
@Stateless
public class TargetVsAchievement extends ValidatorEJB implements TargetVsAchievementRemote, TargetVsAchievementLocal
{
GenericUtility genericUtility = new GenericUtility();
/********** Start of method getTargetVsAchievement()
* EJB Name : TargetVsAchievement.java
* Method Name : getTargetVsAchievement(String,String)
* Servlet Name : TargetVsAchievementServlet
* Metadata xml Name : targetvsachievement.xml
*
* */
@SuppressWarnings("unchecked")
public JSONObject getTargetVsAchievement(String dataSourceName,String prdCode) throws RemoteException, ITMException
{
JSONObject rawEffTimeJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
int count=0;
SimpleDateFormat simpleDateFormat = null;
Calendar calendar = null;
try
{
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
System.out.println(" Inside getSDNoAttemptAnalyticsTopServlet() for Data Soruc Name ="+dataSourceName);
/*if ( (prdCode == null || prdCode.trim().length()==0 ) ||(prdCode.equals("")))
{
simpleDateFormat = new SimpleDateFormat( "yyyyMM");
calendar = Calendar.getInstance();
calendar.add(calendar.MONTH, -1);
prdCode = simpleDateFormat.format(calendar.getTime());
System.out.println("getTargetVsAchievement prdCode: "+prdCode);
}*/
System.out.println("prdCode: "+prdCode);
sql = " Select dense_rank() over (order by tgt_act desc) as Rank," +
" Sales_Id, Salespers_Name, tgt_amt, ach_amt " +
" From ( Select Sales_Pers__For as Sales_ID, sp.sp_name as Salespers_Name, " +
" det.target_amt as tgt_amt, det.ach_amt as ach_amt, " +
" (det.ach_amt*100)/det.target_amt as tgt_act from TD_Sales_Bud hdr, " +
" td_sales_bud_det det, Sales_pers SP " +
" WHere hdr.tran_id = det.tran_id " +
" And det.Sales_Pers__For = sp.Sales_Pers " +
" And hdr.Prd_Code = '"+prdCode+"' ) " +
" Order By Rank,tgt_amt desc ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
rowData = new JSONObject();
rowData.put("rank", checkNull(rs.getString("RANK")));
rowData.put("sales_id", checkNull(rs.getString("SALES_ID")));
rowData.put("salespers_name", checkNull(rs.getString("SALESPERS_NAME")));
rowData.put("tgt_amt", checkNull(rs.getString("TGT_AMT")));
rowData.put("ach_amt", checkNull(rs.getString("ACH_AMT")));
rawEffTimeJson.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 :EmpAnalytics : getSDNoAttemptAnalyticsTopServlet() :" + d.getMessage());
throw new ITMException(d);
}
}
return rawEffTimeJson;
}
/********** End of method getTargetVsAchievement() ******/
private String checkNull(String str)
{
if (str == null)
{
return "";
} else
{
return str;
}
}
}
package ibase.dashboard.sfa.ejb;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.json.simple.JSONObject;
@Local
public abstract interface TargetVsAchievementLocal extends ValidatorLocal
{
public JSONObject getTargetVsAchievement(String dataSourceName,String prdCode) 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;
import org.json.simple.JSONObject;
@Remote
public abstract interface TargetVsAchievementRemote extends ValidatorRemote
{
public JSONObject getTargetVsAchievement(String dataSourceName,String prdCode) 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