Commit 6d725e7d authored by vvengurlekar's avatar vvengurlekar

Added sql changes and logic change for 4th and 5th level


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@105349 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 89bbbd8f
...@@ -320,8 +320,9 @@ public class LiveEventMgrWiseDetails extends ValidatorEJB implements LiveEventMg ...@@ -320,8 +320,9 @@ public class LiveEventMgrWiseDetails extends ValidatorEJB implements LiveEventMg
if(participentCode!=null && eventCode!=null) if(participentCode!=null && eventCode!=null)
{ {
sql="WITH as_det1 (code,prd_name,mgr_name,mgr_code,perc,report,resultcnt,total) AS ( SELECT CODE, PRD_NAME, mgr_name, " + sql="WITH as_det1 (code,prd_name,mgr_name,mgr_code,perc,report,resultcnt,total,NEW_TRAN_ID) AS ( SELECT CODE, PRD_NAME, mgr_name, " +
"mgr_code, PERC, REPORT, RESULTCNT, TOTAL FROM ( SELECT DET_PRD.CODE, DET_PRD.NAME , DET_PRD.mgr_name, DET_PRD.EMP_CODE AS mgr_code, " + "mgr_code, PERC, REPORT, RESULTCNT, TOTAL, NEW_TRAN_ID FROM ( SELECT DET_PRD.CODE,DET_PRD.b as NEW_TRAN_ID," +
" DET_PRD.NAME , DET_PRD.mgr_name, DET_PRD.EMP_CODE AS mgr_code, " +
"DET_PRD.PRD_NAME, RESULT, TOTAL, Str((RESULT * 100.0/TOTAL),4,1) AS PERC, 'Marks' AS REPORT, (RESULT) AS RESULTCNT " + "DET_PRD.PRD_NAME, RESULT, TOTAL, Str((RESULT * 100.0/TOTAL),4,1) AS PERC, 'Marks' AS REPORT, (RESULT) AS RESULTCNT " +
"FROM ( SELECT e.CODE, SUM(SUR.RESULT) TOTAL FROM dbo.employee e INNER JOIN dbo.REGION r " + "FROM ( SELECT e.CODE, SUM(SUR.RESULT) TOTAL FROM dbo.employee e INNER JOIN dbo.REGION r " +
"ON e.regionid = r.id INNER JOIN ( SELECT APP.ENTITY_CODE EMP_CODE, SRE.EMP_CODE MGR, SUM(CAST(SRD.result AS INT)) " + "ON e.regionid = r.id INNER JOIN ( SELECT APP.ENTITY_CODE EMP_CODE, SRE.EMP_CODE MGR, SUM(CAST(SRD.result AS INT)) " +
...@@ -350,12 +351,20 @@ public class LiveEventMgrWiseDetails extends ValidatorEJB implements LiveEventMg ...@@ -350,12 +351,20 @@ public class LiveEventMgrWiseDetails extends ValidatorEJB implements LiveEventMg
"ON sra.TRAN_ID=srd.tran_id INNER JOIN dbo.SCOPE_VALUE sv ON sv.scope_code=sca.scope_code LEFT JOIN ( SELECT SCOPE_CODE AS CODE, LTRIM(RTRIM(m.n.value('.[1]','varchar(8000)'))) AS EMP_CODE " + "ON sra.TRAN_ID=srd.tran_id INNER JOIN dbo.SCOPE_VALUE sv ON sv.scope_code=sca.scope_code LEFT JOIN ( SELECT SCOPE_CODE AS CODE, LTRIM(RTRIM(m.n.value('.[1]','varchar(8000)'))) AS EMP_CODE " +
"FROM ( SELECT SCOPE_CODE, CAST('<XMLRoot><RowData>' + REPLACE( SCOPE_VAL_DESCR,',','</RowData><RowData>') + '</RowData></XMLRoot>' AS XML) AS x FROM dbo.SCOPE_VALUE ) t CROSS APPLY x.nodes('/XMLRoot/RowData')m(n) ) A " + "FROM ( SELECT SCOPE_CODE, CAST('<XMLRoot><RowData>' + REPLACE( SCOPE_VAL_DESCR,',','</RowData><RowData>') + '</RowData></XMLRoot>' AS XML) AS x FROM dbo.SCOPE_VALUE ) t CROSS APPLY x.nodes('/XMLRoot/RowData')m(n) ) A " +
"ON a.code =sv.scope_code AND A.EMP_CODE=sra.ENTITY_CODE LEFT JOIN dbo.employee emp ON emp.code =A.EMP_CODE WHERE SURVEY_TEMPL='"+eventCode+"' GROUP BY srd.TRAN_ID, sra.TRAN_ID, srd.SURVEY_CODE, emp.code, srd.result, " + "ON a.code =sv.scope_code AND A.EMP_CODE=sra.ENTITY_CODE LEFT JOIN dbo.employee emp ON emp.code =A.EMP_CODE WHERE SURVEY_TEMPL='"+eventCode+"' GROUP BY srd.TRAN_ID, sra.TRAN_ID, srd.SURVEY_CODE, emp.code, srd.result, " +
"emp.firstname +' '+ emp.lastname, sca.scope_code ) b GROUP BY code, a, b, SURVEY_CODE, PARTICIPANTS_NAME, count_m ) a ) SRD ON SR.TRAN_ID = SRD.b INNER JOIN ( SELECT * FROM dbo.survey_result_appl WHERE APPL_ENTITY = 'E' ) APP " + "emp.firstname +' '+ emp.lastname, sca.scope_code ) b GROUP BY code, a, b, SURVEY_CODE, PARTICIPANTS_NAME, count_m ) a ) SRD " +
"ON SRD.b = APP.TRAN_ID INNER JOIN ( SELECT * FROM dbo.survey_result_appl WHERE APPL_ENTITY = 'I' ) APPR ON SRD.b = APPR.TRAN_ID INNER JOIN dbo.employee e ON APP.ENTITY_CODE = e.code INNER JOIN dbo.survey_master sm " + "ON SR.TRAN_ID = SRD.b INNER JOIN ( SELECT * FROM dbo.survey_result_appl WHERE APPL_ENTITY = 'E' ) APP " +
"ON SRD.SURVEY_CODE = sm.SURVEY_CODE WHERE APP.ENTITY_CODE = '"+participentCode+"' GROUP BY (e.FIRSTNAME +' '+ e.LASTNAME) , APPR.ENTITY_DESCR , e.code, SRE.emp_code, SRD.b ) DET_PRD ON HDR.CODE = DET_PRD.CODE ) X WHERE upper(report)='MARKS' ) , " + "ON SRD.b = APP.TRAN_ID INNER JOIN ( SELECT * FROM dbo.survey_result_appl WHERE APPL_ENTITY = 'I' ) APPR ON SRD.b = APPR.TRAN_ID " +
"N ( LEVEL , EMP_CODE ) AS ( SELECT 1 , EMP_CODE FROM dbo.EMPLOYEE WHERE EMP_CODE = ( SELECT EMP_CODE FROM dbo.USERS WHERE CODE='"+loginCode+"' ) UNION ALL SELECT N . LEVEL + 1 , NPLUS1 . EMP_CODE " + "INNER JOIN dbo.employee e ON APP.ENTITY_CODE = e.code INNER JOIN dbo.survey_master sm " +
"FROM EMPLOYEE AS NPLUS1 , N WHERE N . EMP_CODE = NPLUS1 . REPORT_TO ) SELECT as_det1.*, ( SELECT SUM(result_range_max) AS tot_marks FROM dbo.survey_master WHERE survey_code IN ( SELECT survey_code FROM dbo.survey_templ_det WHERE survey_templ='"+eventCode+"' ) ) " + "ON SRD.SURVEY_CODE = sm.SURVEY_CODE WHERE APP.ENTITY_CODE = '"+participentCode+"' GROUP BY (e.FIRSTNAME +' '+ e.LASTNAME) , " +
"outof_marks , ( employee.firstname +' '+ employee.lastname) AS emp_name, '"+eventCode+"' AS survey_templ FROM AS_DET1 INNER JOIN dbo.employee ON as_det1.code=employee.code INNER JOIN N ON employee.emp_code=n.emp_code "; "APPR.ENTITY_DESCR , e.code, SRE.emp_code, SRD.b ) DET_PRD ON HDR.CODE = DET_PRD.CODE ) X WHERE upper(report)='MARKS' ) , " +
"N ( LEVEL , EMP_CODE ) AS ( SELECT 1 , EMP_CODE FROM dbo.EMPLOYEE WHERE EMP_CODE = ( SELECT EMP_CODE FROM dbo.USERS WHERE " +
"CODE='"+loginCode+"' ) UNION ALL SELECT N . LEVEL + 1 , NPLUS1 . EMP_CODE " +
"FROM EMPLOYEE AS NPLUS1 , N WHERE N . EMP_CODE = NPLUS1 . REPORT_TO ) SELECT as_det1.code, as_det1.prd_name, " +
"as_det1.mgr_name, as_det1.mgr_code, as_det1.perc, as_det1.report, as_det1.resultcnt,as_det1.total, ( SELECT SUM(result_range_max) AS " +
"tot_marks FROM dbo.survey_master WHERE survey_code IN ( SELECT survey_code FROM dbo.survey_templ_det WHERE survey_templ='"+eventCode+"' ) ) " +
"outof_marks , ( employee.firstname +' '+ employee.lastname) AS emp_name, '"+eventCode+"' AS survey_templ, as_det1.NEW_TRAN_ID FROM AS_DET1 INNER JOIN " +
"dbo.employee ON as_det1.code=employee.code INNER JOIN N ON employee.emp_code=n.emp_code ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -385,6 +394,7 @@ public class LiveEventMgrWiseDetails extends ValidatorEJB implements LiveEventMg ...@@ -385,6 +394,7 @@ public class LiveEventMgrWiseDetails extends ValidatorEJB implements LiveEventMg
rowData.put("uniqueCode",checkNull( rs.getString("MGR_CODE"))); rowData.put("uniqueCode",checkNull( rs.getString("MGR_CODE")));
rowData.put("survey_templ",checkNull( rs.getString("SURVEY_TEMPL"))); rowData.put("survey_templ",checkNull( rs.getString("SURVEY_TEMPL")));
rowData.put("tbldisplay", "style='display: visible'"); rowData.put("tbldisplay", "style='display: visible'");
rowData.put("new_tran_id", checkNull(rs.getString("NEW_TRAN_ID")));
rowData.put("circledisplay", "c100"); rowData.put("circledisplay", "c100");
rawDataParticipentProductDetailJson.put(Integer.valueOf(count), rowData); rawDataParticipentProductDetailJson.put(Integer.valueOf(count), rowData);
count++; count++;
...@@ -423,7 +433,7 @@ public class LiveEventMgrWiseDetails extends ValidatorEJB implements LiveEventMg ...@@ -423,7 +433,7 @@ public class LiveEventMgrWiseDetails extends ValidatorEJB implements LiveEventMg
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public JSONObject getProductDetail(String dataSourceName,String personName,String productName,String mgrCode,String eventCode, String loginCode) throws RemoteException, ITMException public JSONObject getProductDetail(String dataSourceName,String personName,String productName,String mgrCode,String eventCode, String loginCode, String newTranId) throws RemoteException, ITMException
{ {
JSONObject rawDataProductDetailJson = new JSONObject(); JSONObject rawDataProductDetailJson = new JSONObject();
JSONObject rowData = null; JSONObject rowData = null;
...@@ -458,7 +468,8 @@ public class LiveEventMgrWiseDetails extends ValidatorEJB implements LiveEventMg ...@@ -458,7 +468,8 @@ public class LiveEventMgrWiseDetails extends ValidatorEJB implements LiveEventMg
" WHERE RTRIM(LTRIM(e.FIRSTNAME +' '+ e.LASTNAME)) = '"+personName+"' " + " WHERE RTRIM(LTRIM(e.FIRSTNAME +' '+ e.LASTNAME)) = '"+personName+"' " +
" AND RTRIM(LTRIM(APPR.ENTITY_DESCR)) = '"+productName+"' " + " AND RTRIM(LTRIM(APPR.ENTITY_DESCR)) = '"+productName+"' " +
" AND SRE.EMP_CODe = '"+mgrCode+"' " + " AND SRE.EMP_CODe = '"+mgrCode+"' " +
" AND std.SURVEY_TEMPL ='"+eventCode+"' )a " + " AND std.SURVEY_TEMPL ='"+eventCode+"' " +
" and srd.tran_id='"+newTranId+"')a " +
" GROUP BY EMP_CODE, SURVEY_CODE, SURVEY, result1 "; " GROUP BY EMP_CODE, SURVEY_CODE, SURVEY, result1 ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
......
...@@ -12,5 +12,5 @@ public interface LiveEventMgrWiseDetailsLocal extends ValidatorLocal ...@@ -12,5 +12,5 @@ public interface LiveEventMgrWiseDetailsLocal extends ValidatorLocal
public JSONObject getParticipentEventSummary(String dataSourceName,String eventCode,String loginCode) throws RemoteException, ITMException; public JSONObject getParticipentEventSummary(String dataSourceName,String eventCode,String loginCode) throws RemoteException, ITMException;
public JSONObject getParticipentEventDetail(String dataSourceName,String eventCode,String participentCode,String loginCode) throws RemoteException, ITMException; public JSONObject getParticipentEventDetail(String dataSourceName,String eventCode,String participentCode,String loginCode) throws RemoteException, ITMException;
public JSONObject getParticipentProductDetail(String dataSourceName,String eventCode,String participentCode,String loginCode) throws RemoteException, ITMException; public JSONObject getParticipentProductDetail(String dataSourceName,String eventCode,String participentCode,String loginCode) throws RemoteException, ITMException;
public JSONObject getProductDetail(String dataSourceName,String personName,String productName,String mgrCode,String eventCode, String loginCode) throws RemoteException, ITMException; public JSONObject getProductDetail(String dataSourceName,String personName,String productName,String mgrCode,String eventCode, String loginCode, String newTranId) throws RemoteException, ITMException;
} }
...@@ -13,5 +13,5 @@ public interface LiveEventMgrWiseDetailsRemote extends ValidatorRemote ...@@ -13,5 +13,5 @@ public interface LiveEventMgrWiseDetailsRemote extends ValidatorRemote
public JSONObject getParticipentEventSummary(String dataSourceName,String eventCode,String loginCode) throws RemoteException, ITMException; public JSONObject getParticipentEventSummary(String dataSourceName,String eventCode,String loginCode) throws RemoteException, ITMException;
public JSONObject getParticipentEventDetail(String dataSourceName,String eventCode,String participentCode,String loginCode) throws RemoteException, ITMException; public JSONObject getParticipentEventDetail(String dataSourceName,String eventCode,String participentCode,String loginCode) throws RemoteException, ITMException;
public JSONObject getParticipentProductDetail(String dataSourceName,String eventCode,String participentCode,String loginCode) throws RemoteException, ITMException; public JSONObject getParticipentProductDetail(String dataSourceName,String eventCode,String participentCode,String loginCode) throws RemoteException, ITMException;
public JSONObject getProductDetail(String dataSourceName,String personName,String productName,String mgrCode,String eventCode, String loginCode) throws RemoteException, ITMException; public JSONObject getProductDetail(String dataSourceName,String personName,String productName,String mgrCode,String eventCode, String loginCode, String newTranId) throws RemoteException, ITMException;
} }
...@@ -33,6 +33,7 @@ public class ProductMgrWiseDetailServlet extends HttpServlet ...@@ -33,6 +33,7 @@ public class ProductMgrWiseDetailServlet extends HttpServlet
String uniqueCode = ""; String uniqueCode = "";
String eventCode = ""; String eventCode = "";
String loginId = ""; String loginId = "";
String newTranId = "";
HttpSession session = null; HttpSession session = null;
UserInfoBean userInfo = null; UserInfoBean userInfo = null;
...@@ -48,10 +49,11 @@ public class ProductMgrWiseDetailServlet extends HttpServlet ...@@ -48,10 +49,11 @@ public class ProductMgrWiseDetailServlet extends HttpServlet
productName = request.getParameter("productName"); productName = request.getParameter("productName");
uniqueCode = request.getParameter("code"); uniqueCode = request.getParameter("code");
eventCode = request.getParameter("eventCode"); eventCode = request.getParameter("eventCode");
newTranId = request.getParameter("newTranId");
System.out.println(" ProductMgrWiseDetailServlet uniqueCode ="+uniqueCode+"=== personName =" + personName + "===== dataSourceName :"+dataSourceName); System.out.println(" ProductMgrWiseDetailServlet uniqueCode ="+uniqueCode+"=== personName =" + personName + "===== dataSourceName :"+dataSourceName);
context = new InitialContext(appConnectParm.getProperty()); context = new InitialContext(appConnectParm.getProperty());
liveEventDetailsRemote = (LiveEventMgrWiseDetailsRemote) context.lookup("ibase/LiveEventMgrWiseDetails/remote"); liveEventDetailsRemote = (LiveEventMgrWiseDetailsRemote) context.lookup("ibase/LiveEventMgrWiseDetails/remote");
JSONObject jsonObjData = (JSONObject) liveEventDetailsRemote.getProductDetail(dataSourceName,personName,productName,uniqueCode,eventCode,loginId); JSONObject jsonObjData = (JSONObject) liveEventDetailsRemote.getProductDetail(dataSourceName,personName,productName,uniqueCode,eventCode,loginId,newTranId);
OutputStream outputStream = response.getOutputStream(); OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes()); outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush(); outputStream.flush();
......
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