Commit ab839bf8 authored by kpandey's avatar kpandey

Created a new method to load attendanceCompliance and complianceSummary data in ang form

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@192432 ce508802-f39f-4f6c-b175-0d175dae99d5
parent eaa99809
......@@ -12,13 +12,13 @@ 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.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.ejb.Stateless;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@Stateless
......@@ -275,6 +275,131 @@ public class AttendanceCompliance extends ValidatorEJB implements AttendanceComp
return rowDataPendingTaskJson;
}
//Added by KAMAL P .[Start]
public String getAttendanceData(String empCode, String viewOptionSelectd, String transDB) throws ITMException
{
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
System.out.println("In getAttendanceData() empCode = "+empCode+"viewOptionSelectd = "+viewOptionSelectd+"transDB "+transDB);
String attendanceComplianceData = "";
String salesPersCode = "", salesPersName = "", userImagePath = "", tran_image = "";
String state = "", reportHead = "", notReportingDays = "", mobileNo = "";
viewOptionSelectd = "JNJ";
/*String sql = "SELECT A.SALES_PERS, SP.SP_NAME, A.LAST_REPORT, " +
"ROUND(TRUNC(sysdate)-TRUNC(A.LAST_REPORT)) NOT_REPORTED_DAYS, I.DESCR DIVISION , " +
"E.HOBBY1 REGION, S.DESCR STATE, (NVL(TRIM(E1.EMP_FNAME),'') ||NVL(TRIM(E1.EMP_MNAME),' ')" +
" ||NVL(TRIM(E1.EMP_LNAME),'')) EMP_NAME, E.MOBILE_NO FROM (SELECT t.SALES_PERS, " +
" MAX(T.EVENT_DATE) LAST_REPORT FROM SPRS_ACT_TRAN T WHERE T.SALEs_PERS IN " +
"(SELECT S.SALES_pERS FROM SALES_PErS S INNER JOIN EMPLOYEE E ON " +
"S.SALES_PERS = E.EMP_CODE WHERE E.STATUS ='Y' START WITH e.emp_code = '" + empCode + "' " +
"CONNECT BY prior E.EMP_CODE = E.REPORT_TO ) AND T.CONFIRMED='Y' " +
"GROUP BY t.SALES_PERS )A INNER JOIN SALES_PERS SP ON A.SALES_PERS = SP.SALES_PERS " +
"INNER JOIN EMPLOYEE E ON SP.SALES_PERS = E.EMP_CODE INNER JOIN ITEMSER I " +
"ON I.ITEM_SER=SP.ITEM_SER LEFT OUTER JOIN EMPLOYEE E1 ON E1.EMP_CODE = E.REPORT_TO " +
"LEFT OUTER JOIN STATE S ON S.STATE_CODE = E.CUR_STATE";*/
String sql = "SELECT A.SALES_PERS, SP.SP_NAME, A.LAST_REPORT, " +
"ROUND(TRUNC(sysdate)-TRUNC(A.LAST_REPORT)) NOT_REPORTED_DAYS, I.DESCR DIVISION , " +
"E.HOBBY1 REGION, S.DESCR STATE, (NVL(TRIM(E1.EMP_FNAME),'') ||NVL(TRIM(E1.EMP_MNAME),' ')" +
" ||NVL(TRIM(E1.EMP_LNAME),'')) EMP_NAME, E.MOBILE_NO FROM (SELECT t.SALES_PERS, " +
" MAX(T.EVENT_DATE) LAST_REPORT FROM SPRS_ACT_TRAN T WHERE T.SALEs_PERS IN " +
"(SELECT S.SALES_pERS FROM SALES_PErS S INNER JOIN EMPLOYEE E ON " +
"S.SALES_PERS = E.EMP_CODE WHERE e.emp_code = '" + empCode + "' " +
"CONNECT BY prior E.EMP_CODE = E.REPORT_TO ) AND T.CONFIRMED='Y' " +
"GROUP BY t.SALES_PERS )A INNER JOIN SALES_PERS SP ON A.SALES_PERS = SP.SALES_PERS " +
"INNER JOIN EMPLOYEE E ON SP.SALES_PERS = E.EMP_CODE INNER JOIN ITEMSER I " +
"ON I.ITEM_SER=SP.ITEM_SER LEFT OUTER JOIN EMPLOYEE E1 ON E1.EMP_CODE = E.REPORT_TO " +
"LEFT OUTER JOIN STATE S ON S.STATE_CODE = E.CUR_STATE";
System.out.println("sql===>"+sql);
try
{
conn = connDriver.getConnectDB(transDB);
E12GenericUtility e12GenUtil = new E12GenericUtility();
JSONArray attendanceComplianceArray = new JSONArray();
pstmt = conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = pstmt.executeQuery();
while(rs.next())
{
JSONObject attendanceComplianceObject = new JSONObject();
salesPersCode = checkNull(rs.getString("SALES_PERS"));
salesPersName = checkNull(rs.getString("SP_NAME"));
state = checkNull(rs.getString("STATE"));
reportHead = checkNull(rs.getString("EMP_NAME"));
notReportingDays = checkNull(rs.getString("NOT_REPORTED_DAYS"));
mobileNo = checkNull(rs.getString("MOBILE_NO"));
// Update by Prajyot R on 24/05/2018 Start
//userImagePath = CommonConstants.TOMCAT_HOME+"/ibase/CustomMenuImageServlet?fldValue="+salesPersCode+"&object="+object+"&objName="+object+"&ALT_FLD_VALUE="+salesPersName;
userImagePath = e12GenUtil.getCustomImageURL("SALES_PERS", "SalesPers", salesPersCode, salesPersName, "Icon");
// Update by Prajyot R on 24/05/2018 End
tran_image = "<img class='dashboard-userAvatar' src='"+userImagePath+"' />";
String devisonWiseRegion = checkNull(rs.getString("DIVISION"))+" "+checkNull(rs.getString("REGION"));
//added by vishal pathare on 8.2.18 for[feed data for links implementation]Start
System.out.println("Inside getAttendanceData() checkNUll salesPersCode=>["+ salesPersCode +"] salesPersName["+salesPersName+"] state["+state+"] reportHead["+reportHead+"] notReportingDays["+notReportingDays+"] mobileNo["+mobileNo+"] tran_image["+tran_image+"]");
attendanceComplianceObject.put( "sales_pers", salesPersCode );
attendanceComplianceObject.put( "sp_name", salesPersName );
attendanceComplianceObject.put( "state", state );
attendanceComplianceObject.put( "emp_name", reportHead );
attendanceComplianceObject.put( "not_reported_days", notReportingDays );
attendanceComplianceObject.put( "mobile_no", mobileNo );
attendanceComplianceObject.put( "devisonWiseRegion", devisonWiseRegion );
attendanceComplianceArray.add(attendanceComplianceObject);
}
attendanceComplianceData = attendanceComplianceArray.toString();
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
System.out.println("Exception in attendanceComplianceArray.getAttendanceData() "+e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
conn = null;
}
}
catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in attendace compliance method " + d.getMessage());
throw new ITMException(d);
}
}
return attendanceComplianceData;
}
//Added by KAMAL P.[End]
//Added by Anjali R.[Start]
public String getComplianceSummary(String dataSourceName, String loginId, String period,String dummy) throws RemoteException, ITMException
{
......@@ -478,4 +603,133 @@ public class AttendanceCompliance extends ValidatorEJB implements AttendanceComp
return str;
}
}
//Added by KAMAL P.[Start]
public String getAttendancComplianceSummData( String loginId, String period, String transDB ) throws Exception
{
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
String attendancComplianceSummData = "";
int reportedDays = 0, nonReportedDays = 0, total;
if(period != null && period.length()>0)
{
period = period;
}
else
{
conn = connDriver.getConnectDB(transDB);
String sql = "select code from period Where To_Date(Sysdate) Between Fr_Date and To_Date";
pstmt = conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = pstmt.executeQuery();
if (rs.next())
{
period = checkNull(rs.getString("code"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
String sql = "SELECT SUM(CASE WHEN REP_NONREP='R' THEN 1 ELSE 0 END ) AS Reported , " +
" SUM(CASE WHEN REP_NONREP='NR' THEN 1 ELSE 0 END ) AS NonReported, " +
" SUM(CASE WHEN REP_NONREP='R' THEN 1 ELSE 0 END + CASE WHEN REP_NONREP='NR' THEN 1 ELSE 0 END) AS TOTAL " +
" FROM " +
" (SELECT SALES_PERS_AV.AVAILABLE_DY ,SPRS_ACT_TRAN.ACTIVITY_CODE, " +
" (CASE WHEN ( ROW_NUMBER() OVER ( PARTITION BY SALES_PERS_AV.SALESPERS ,AVAILABLE_DY ORDER BY SALES_PERS_AV.SALESPERS ,AVAILABLE_DY ) ) = 1 AND SPRS_ACT_TRAN.SALES_PERS IS NOT NULL THEN 'R' " +
" WHEN ( ROW_NUMBER() OVER ( PARTITION BY SALES_PERS_AV.SALESPERS ,AVAILABLE_DY ORDER BY SALES_PERS_AV.SALESPERS ,AVAILABLE_DY ) ) <> 1 AND SPRS_ACT_TRAN.SALES_PERS IS NOT NULL THEN '-' " +
" ELSE 'NR' END ) AS REP_NONREP ,NVL(STRG_CUSTOMER.FIRST_NAME, '')|| NVL(STRG_CUSTOMER.MIDDLE_NAME, '')|| NVL(STRG_CUSTOMER.LAST_NAME, '') AS CUSTOMER_NAME " +
" FROM " +
" (SELECT users.CODE AS SALESPERS ,AV_DATES.available_dy AS AVAILABLE_DY " +
" FROM " +
" (SELECT CODE ,'a' AS a FROM users) users, " +
" (SELECT dt AS available_dy ,'a' AS a FROM sfa_time WHERE DT BETWEEN (SELECT fr_date FROM period WHERE code='"+period+"') AND (SELECT to_date FROM period WHERE code='"+period+"')) AV_DATES " +
" WHERE users.a = AV_DATES.a AND users.CODE IN " +
" (SELECT emp_code FROM employee START WITH emp_code =(SELECT emp_code FROM users WHERE code = '"+loginId+"' AND STATUS='A') CONNECT BY prior emp_code = report_to) " +
" MINUS " +
" SELECT EMPLOYEE.EMP_CODE AS SALESPERS,holiday.hol_date AS AVAILABLE_DY FROM holiday,EMPLOYEE WHERE holiday.hol_tblno = EMPLOYEE.hol_tblno " +
" AND holiday.hol_date BETWEEN (SELECT fr_date FROM period WHERE code='"+period+"') AND (SELECT to_date FROM period WHERE code ='"+period+"') " +
" AND emp_code IN((SELECT emp_code FROM employee START WITH emp_code = (SELECT emp_code FROM users WHERE code = '"+loginId+"' AND STATUS='A') CONNECT BY prior emp_code = report_to)) " +
" AND NOT EXISTS " +
" (SELECT sales_pers,event_date FROM sprs_act_tran s WHERE s.sales_pers = employee.emp_code AND s.event_date = holiday.hol_date)) SALES_PERS_AV " +
" LEFT OUTER JOIN " +
" (SELECT S.SALES_PERS,S.EVENT_DATE,S.DCR_ID,S.ACTIVITY_CODE FROM SPRS_ACT_TRAN S WHERE S.ACTIVITY_CODE <> 'PR' AND S.CONFIRMED = 'Y') "+
" SPRS_ACT_TRAN ON SPRS_ACT_TRAN.SALES_PERS = SALES_PERS_AV.SALESPERS AND SPRS_ACT_TRAN.EVENT_DATE = SALES_PERS_AV.AVAILABLE_DY " +
" LEFT OUTER JOIN (SELECT S.SALES_PERS,S.DCR_ID,S.EVENT_DATE,S.STRG_CODE FROM STRG_MEET S WHERE S.EVENT_TYPE <> 'PR') "+
" STRG_MEET ON SPRS_ACT_TRAN.SALES_PERS = STRG_MEET.SALES_PERS AND SPRS_ACT_TRAN.EVENT_DATE = STRG_MEET.EVENT_DATE "+
" AND SPRS_ACT_TRAN.DCR_ID = STRG_MEET.DCR_ID " +
" LEFT OUTER JOIN STRG_CUSTOMER ON STRG_MEET.STRG_CODE = STRG_CUSTOMER.SC_CODE " +
" WHERE SALES_PERS_AV.SALESPERS IN(SELECT emp_code FROM employee START WITH emp_code =(SELECT emp_code FROM users WHERE code = '"+loginId+"' AND STATUS='A')CONNECT BY prior emp_code = report_to))A " ;
System.out.println("sql===>"+sql);
try
{
conn = connDriver.getConnectDB(transDB);
E12GenericUtility e12GenUtility = new E12GenericUtility();
JSONArray attendancComplianceSummArray = new JSONArray();
pstmt = conn.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = pstmt.executeQuery();
while(rs.next())
{
JSONObject reportedObject = new JSONObject();
JSONObject nonReportedObject = new JSONObject();
reportedDays = Integer.parseInt(checkNumber(rs.getString("Reported")));
nonReportedDays = Integer.parseInt(checkNumber(rs.getString("NonReported")));
total = Integer.parseInt(checkNumber(rs.getString("TOTAL")));
System.out.println("reportedDays: "+reportedDays+" nonReportedDays: "+nonReportedDays+" total: "+total);
reportedObject.put("reportedDays", reportedDays);
reportedObject.put("reported_nonReported", "Reported");
nonReportedObject.put("reportedDays", nonReportedDays);
nonReportedObject.put("reported_nonReported", "Not_Reported");
attendancComplianceSummArray.add(reportedObject);
attendancComplianceSummArray.add(nonReportedObject);
}
attendancComplianceSummData = attendancComplianceSummArray.toString();
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
System.out.println("Exception in AttendanceCompliance.getAttendancComplianceSummData() "+e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if (conn != null)
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
conn = null;
}
}
catch (Exception d)
{
d.printStackTrace();
System.out.println("AttendanceCompliance.getAttendancComplianceSummData()" + d.getMessage());
throw new ITMException(d);
}
}
return attendancComplianceSummData;
}
//Added by KAMAL P.[End]
}
......@@ -3,7 +3,9 @@ package ibase.dashboard.sfa.ejb;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.SQLException;
import javax.ejb.Local;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@Local
......@@ -15,5 +17,9 @@ public abstract interface AttendanceComplianceLocal extends ValidatorLocal
public String getAttendance(String dataSourceName, String empCode, String viewOptionSelectd,String dummy)throws RemoteException, ITMException;
public String getComplianceSummary(String dataSourceName, String loginId, String period,String dummy) throws RemoteException, ITMException;
//Added by Anjali R.[End]
//Added by Kamal P.[Start]
public String getAttendanceData(String empCode, String viewOptionSelectd, String transDB) throws ITMException ;
public String getAttendancComplianceSummData(String loginId, String period, String transDB) throws Exception ;
//Added by Kamal P.[End]
}
......@@ -3,7 +3,9 @@ package ibase.dashboard.sfa.ejb;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.SQLException;
import javax.ejb.Remote;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@Remote
......@@ -14,6 +16,10 @@ public abstract interface AttendanceComplianceRemote extends ValidatorRemote
//Added by Anjali R.[Start]
public String getAttendance(String dataSourceName, String empCode, String viewOptionSelectd,String dummy)throws RemoteException, ITMException;
public String getComplianceSummary(String dataSourceName, String loginId, String period,String dummy) throws RemoteException, ITMException;
//Added by Anjali R.[End]
//Added by Anjali R.[End]
//Added by Kamal P.[Start]
public String getAttendanceData(String empCode, String viewOptionSelectd, String transDB) throws ITMException ;
public String getAttendancComplianceSummData(String loginId, String period, String transDB) throws Exception ;
//Added by Kamal P.[END]
}
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