Commit 32e8b9ef authored by nsawalakhe's avatar nsawalakhe

Added new sql and parameter for JNJ


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@100353 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8c1682db
...@@ -41,7 +41,7 @@ public class AttendanceCompliance extends ValidatorEJB implements AttendanceComp ...@@ -41,7 +41,7 @@ public class AttendanceCompliance extends ValidatorEJB implements AttendanceComp
//simpleDateFormat.format(convertToDbDate.parse("")); //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_main = " 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 "
...@@ -49,20 +49,33 @@ public class AttendanceCompliance extends ValidatorEJB implements AttendanceComp ...@@ -49,20 +49,33 @@ public class AttendanceCompliance extends ValidatorEJB implements AttendanceComp
+ " 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 order by to_date(LAST_REPORT)"; + " 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, " + /*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, " + "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 " + "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' " + //"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 "; "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, " + sql_local = "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, " + "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 " + "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' " + "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 "; "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 ";
*/
sql = " select A.SALES_PERS, SP.SP_NAME, A.LAST_REPORT, " +
" ROUND(TRUNC(sysdate)-TRUNC(A.LAST_REPORT)) NOT_REPORTED, I.DESCR ITEM_SERIES," +
" E.HOBBY1 REGION, E.CUR_STATE 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 S.ACTIVE_YN='Y' " +
" start with e.emp_code = '" + empCode + "' " +
" connect by prior E.EMP_CODE = E.REPORT_TO) " +
" 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 ";
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();
...@@ -73,12 +86,23 @@ public class AttendanceCompliance extends ValidatorEJB implements AttendanceComp ...@@ -73,12 +86,23 @@ 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"))); String dueDate =checkNull(rs.getString("LAST_REPORT"));
rowData.put("lastreport", simpleDateFormat.format(convertToDbDate.parse((rs.getString("LAST_REPORT"))))); if(dueDate.trim().length()>0)
{
rowData.put("lastreport", simpleDateFormat.format(convertToDbDate.parse(dueDate)));
}
else
{
rowData.put("lastreport",checkNull (rs.getString("LAST_REPORT")));
}
//rowData.put("lastreport", checkNull(rs.getString("LAST_REPORT")));
rowData.put("notreported", checkNull(rs.getString("NOT_REPORTED"))); rowData.put("notreported", checkNull(rs.getString("NOT_REPORTED")));
rowData.put("itemseries", checkNull(rs.getString("ITEM_SERIES")));
rowData.put("region", checkNull(rs.getString("REGION")));
rowData.put("state", checkNull(rs.getString("STATE")));
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")));
rowDataPendingTaskJson.put(Integer.valueOf(count), rowData); rowDataPendingTaskJson.put(Integer.valueOf(count), rowData);
count++; count++;
} }
......
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