Commit 25b15c14 authored by dkasliwal's avatar dkasliwal

Modify EJB Method for Change SQL. Add date format to format date dd/mm/yy


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98905 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 46cbffb5
...@@ -2,11 +2,13 @@ package ibase.dashboard.sfa.ejb; ...@@ -2,11 +2,13 @@ package ibase.dashboard.sfa.ejb;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless; import javax.ejb.Stateless;
...@@ -32,20 +34,35 @@ public class AttendanceCompliance extends ValidatorEJB implements AttendanceComp ...@@ -32,20 +34,35 @@ public class AttendanceCompliance extends ValidatorEJB implements AttendanceComp
Connection conn = null; Connection conn = null;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
int count = 0; int count = 0;
try try
{ {
SimpleDateFormat convertToDbDate =new SimpleDateFormat(new GenericUtility().getDBDateFormat());
SimpleDateFormat simpleDateFormat =new SimpleDateFormat(new GenericUtility().getApplDateFormat());
//simpleDateFormat.format(convertToDbDate.parse(""));
conn = connDriver.getConnectDB(dataSourceName); conn = connDriver.getConnectDB(dataSourceName);
connDriver = null; connDriver = null;
sql = "SELECT SALES_PERS, SP_NAME, to_char(LAST_REPORT,'dd/mm/yyyy') AS LAST_REPORT, ROUND(TRUNC(SYSDATE)-TRUNC(LAST_REPORT)) NOT_REPORTED," /*sql = "SELECT SALES_PERS, SP_NAME, to_char(LAST_REPORT,'dd/mm/yyyy') AS LAST_REPORT, ROUND(TRUNC(SYSDATE)-TRUNC(LAST_REPORT)) NOT_REPORTED,"
+ " EMP_NAME, MOBILE_NO FROM (SELECT SP.SALES_PERS, SP.SP_NAME,MAX(S.EVENT_DATE) LAST_REPORT," + " EMP_NAME, MOBILE_NO FROM (SELECT SP.SALES_PERS, SP.SP_NAME,MAX(S.EVENT_DATE) LAST_REPORT,"
+ " (NVL(TRIM(E1.EMP_FNAME),'')||NVL(TRIM(E1.EMP_MNAME),' ')||NVL(TRIM(E1.EMP_LNAME),'')) EMP_NAME, " + " (NVL(TRIM(E1.EMP_FNAME),'')||NVL(TRIM(E1.EMP_MNAME),' ')||NVL(TRIM(E1.EMP_LNAME),'')) EMP_NAME, "
+ " E.MOBILE_NO FROM SPRS_ACT_TRAN S INNER JOIN EMPLOYEE E ON S.SALES_PERS = E.EMP_CODE " + " E.MOBILE_NO FROM SPRS_ACT_TRAN S INNER JOIN EMPLOYEE E ON S.SALES_PERS = E.EMP_CODE "
+ " INNER JOIN SALES_PERS SP ON E.EMP_CODE = SP.SALES_PERS LEFT " + " INNER JOIN SALES_PERS SP ON E.EMP_CODE = SP.SALES_PERS LEFT "
+ " OUTER JOIN EMPLOYEE E1 ON E1.EMP_CODE = E.REPORT_TO " + " OUTER JOIN EMPLOYEE E1 ON E1.EMP_CODE = E.REPORT_TO "
+ " WHERE E.REPORT_TO = '" + empCode + "'" + " WHERE E.REPORT_TO = '" + empCode + "'"
+ " GROUP BY SP.SALES_PERS, SP.SP_NAME, (NVL(TRIM(E1.EMP_FNAME),'')||NVL(TRIM(E1.EMP_MNAME),' ')||NVL(TRIM(E1.EMP_LNAME),'')), E.MOBILE_NO) A "; + " GROUP BY SP.SALES_PERS, SP.SP_NAME, (NVL(TRIM(E1.EMP_FNAME),'')||NVL(TRIM(E1.EMP_MNAME),' ')||NVL(TRIM(E1.EMP_LNAME),'')), E.MOBILE_NO) A order by to_date(LAST_REPORT)";
*/
/*sql = "SELECT SALES_PERS, sp_name, LAST_REPORT AS LAST_REPORT, ROUND(TRUNC(SYSDATE)-TRUNC(LAST_REPORT)) NOT_REPORTED, " +
"EMP_NAME, mobile_no FROM (SELECT SP.SALES_PERS, SP.SP_NAME, MAX(S.EVENT_DATE) LAST_REPORT, (NVL(TRIM(E1.EMP_FNAME),'') ||NVL(TRIM(E1.EMP_MNAME),' ') ||NVL(TRIM(E1.EMP_LNAME),'')) EMP_NAME, " +
"E.MOBILE_NO, to_char(MAX(S.EVENT_DATE),'dd/mm/yy') LAST_REPORT1 FROM SPRS_ACT_TRAN S INNER JOIN EMPLOYEE E ON S.SALES_PERS = E.EMP_CODE INNER JOIN SALES_PERS SP ON E.EMP_CODE = SP.SALES_PERS LEFT OUTER JOIN EMPLOYEE E1 ON E1.EMP_CODE = E.REPORT_TO " +
//"WHERE E.REPORT_TO = 'G009' " +
"GROUP BY SP.SALES_PERS, SP.SP_NAME, (NVL(TRIM(E1.EMP_FNAME),'') ||NVL(TRIM(E1.EMP_MNAME),' ') ||NVL(TRIM(E1.EMP_LNAME),'')), E.MOBILE_NO ) a order by last_report desc ";
*/
sql = "SELECT SALES_PERS, sp_name, TRUNC(LAST_REPORT )AS LAST_REPORT, " +
"ROUND(TRUNC(SYSDATE)-TRUNC(LAST_REPORT)) NOT_REPORTED, EMP_NAME, mobile_no FROM (SELECT SP.SALES_PERS, SP.SP_NAME, MAX(S.EVENT_DATE) LAST_REPORT, (NVL(TRIM(E1.EMP_FNAME),'') ||NVL(TRIM(E1.EMP_MNAME),' ') ||NVL(TRIM(E1.EMP_LNAME),'')) EMP_NAME, " +
"E.MOBILE_NO, TO_CHAR(MAX(S.EVENT_DATE),'dd/mm/yy') LAST_REPORT1 FROM SPRS_ACT_TRAN S INNER JOIN EMPLOYEE E ON S.SALES_PERS = E.EMP_CODE INNER JOIN SALES_PERS SP ON E.EMP_CODE = SP.SALES_PERS LEFT OUTER JOIN EMPLOYEE E1 ON E1.EMP_CODE = E.REPORT_TO " +
"WHERE E.REPORT_TO = 'G009' " +
"GROUP BY SP.SALES_PERS, SP.SP_NAME, (NVL(TRIM(E1.EMP_FNAME),'') ||NVL(TRIM(E1.EMP_MNAME),' ') ||NVL(TRIM(E1.EMP_LNAME),'')), E.MOBILE_NO ) a order by trunc(last_report) desc ";
System.out.println("sql is =" + sql); System.out.println("sql is =" + sql);
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -56,7 +73,8 @@ public class AttendanceCompliance extends ValidatorEJB implements AttendanceComp ...@@ -56,7 +73,8 @@ public class AttendanceCompliance extends ValidatorEJB implements AttendanceComp
rowData = new JSONObject(); rowData = new JSONObject();
rowData.put("salespersn", checkNull(rs.getString("SALES_PERS"))); rowData.put("salespersn", checkNull(rs.getString("SALES_PERS")));
rowData.put("spname", checkNull(rs.getString("SP_NAME"))); rowData.put("spname", checkNull(rs.getString("SP_NAME")));
rowData.put("lastreport", (rs.getString("LAST_REPORT"))); //rowData.put("lastreport", (rs.getString("LAST_REPORT")));
rowData.put("lastreport", simpleDateFormat.format(convertToDbDate.parse((rs.getString("LAST_REPORT")))));
rowData.put("notreported", checkNull(rs.getString("NOT_REPORTED"))); rowData.put("notreported", checkNull(rs.getString("NOT_REPORTED")));
rowData.put("empname", checkNull(rs.getString("EMP_NAME"))); rowData.put("empname", checkNull(rs.getString("EMP_NAME")));
rowData.put("mobileno", checkNull(rs.getString("MOBILE_NO"))); rowData.put("mobileno", checkNull(rs.getString("MOBILE_NO")));
......
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