Subversion Repositories SmartDukaan

Rev

Rev 36941 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36941 Rev 36954
Line 286... Line 286...
286
            "SELECT p.escalation_type lvl, COUNT(DISTINCT p.auth_user_id) total_users," +
286
            "SELECT p.escalation_type lvl, COUNT(DISTINCT p.auth_user_id) total_users," +
287
            " COUNT(DISTINCT CASE WHEN sc.id IS NOT NULL THEN p.auth_user_id END) with_pjp" +
287
            " COUNT(DISTINCT CASE WHEN sc.id IS NOT NULL THEN p.auth_user_id END) with_pjp" +
288
            " FROM cs.position p" +
288
            " FROM cs.position p" +
289
            " LEFT JOIN `user`.beat b ON b.auth_user_id=p.auth_user_id AND b.active=1" +
289
            " LEFT JOIN `user`.beat b ON b.auth_user_id=p.auth_user_id AND b.active=1" +
290
            " LEFT JOIN `user`.beat_schedule sc ON sc.beat_id=b.id AND sc.start_date>=:ms AND sc.start_date<=:me" +
290
            " LEFT JOIN `user`.beat_schedule sc ON sc.beat_id=b.id AND sc.start_date>=:ms AND sc.start_date<=:me" +
291
            " WHERE p.category_id=4 AND p.auth_user_id IN (:auth) AND LOWER(p.escalation_type) NOT IN ('l5','final') GROUP BY p.escalation_type ORDER BY p.escalation_type");
291
            " WHERE p.category_id=4 AND p.auth_user_id IN (:auth) AND LOWER(p.escalation_type) NOT IN ('l4','l5','final') GROUP BY p.escalation_type ORDER BY p.escalation_type");
292
        q.setParameter("ms", ms).setParameter("me", me).setParameterList("auth", auth);
292
        q.setParameter("ms", ms).setParameter("me", me).setParameterList("auth", auth);
293
        List<Map<String, Object>> list = new ArrayList<>();
293
        List<Map<String, Object>> list = new ArrayList<>();
294
        for (Object o : q.getResultList()) {
294
        for (Object o : q.getResultList()) {
295
            Object[] r = (Object[]) o;
295
            Object[] r = (Object[]) o;
296
            long total = asLong(r[1]), with = asLong(r[2]);
296
            long total = asLong(r[1]), with = asLong(r[2]);
Line 313... Line 313...
313
            " COALESCE(ds.disc_min,0) disc_min, COALESCE(wk.work_sec,0) work_sec," +
313
            " COALESCE(ds.disc_min,0) disc_min, COALESCE(wk.work_sec,0) work_sec," +
314
            " COALESCE(ld.leads,0) leads, du.id duid, COALESCE(acp.donep,0) donep" +
314
            " COALESCE(ld.leads,0) leads, du.id duid, COALESCE(acp.donep,0) donep" +
315
            " FROM (SELECT DISTINCT auth_user_id FROM `user`.beat WHERE active=1 AND auth_user_id IN (:auth)) o" +
315
            " FROM (SELECT DISTINCT auth_user_id FROM `user`.beat WHERE active=1 AND auth_user_id IN (:auth)) o" +
316
            " JOIN auth.auth_user au ON au.id=o.auth_user_id" +
316
            " JOIN auth.auth_user au ON au.id=o.auth_user_id" +
317
            " LEFT JOIN dtr.users du ON du.email=au.email_id" +
317
            " LEFT JOIN dtr.users du ON du.email=au.email_id" +
318
            " LEFT JOIN (SELECT auth_user_id, MIN(escalation_type) lvl FROM cs.position WHERE category_id=4 AND LOWER(escalation_type) NOT IN ('l5','final') GROUP BY auth_user_id) lvl ON lvl.auth_user_id=au.id" +
318
            " LEFT JOIN (SELECT auth_user_id, MIN(escalation_type) lvl FROM cs.position WHERE category_id=4 AND LOWER(escalation_type) NOT IN ('l4','l5','final') GROUP BY auth_user_id) lvl ON lvl.auth_user_id=au.id" +
319
            " LEFT JOIN (SELECT b.auth_user_id uid, COUNT(*) planned FROM `user`.beat_schedule sc" +
319
            " LEFT JOIN (SELECT b.auth_user_id uid, COUNT(*) planned FROM `user`.beat_schedule sc" +
320
            "   JOIN `user`.beat b ON b.id=sc.beat_id AND b.active=1 JOIN `user`.beat_route r ON r.beat_id=sc.beat_id AND r.day_number=sc.day_number" +
320
            "   JOIN `user`.beat b ON b.id=sc.beat_id AND b.active=1 JOIN `user`.beat_route r ON r.beat_id=sc.beat_id AND r.day_number=sc.day_number" +
321
            "   WHERE sc.start_date>=:ms AND sc.start_date<=:me GROUP BY b.auth_user_id) pl ON pl.uid=au.id" +
321
            "   WHERE sc.start_date>=:ms AND sc.start_date<=:me GROUP BY b.auth_user_id) pl ON pl.uid=au.id" +
322
            " LEFT JOIN (SELECT b.auth_user_id uid, COUNT(*) planned FROM `user`.beat_schedule sc" +
322
            " LEFT JOIN (SELECT b.auth_user_id uid, COUNT(*) planned FROM `user`.beat_schedule sc" +
323
            "   JOIN `user`.beat b ON b.id=sc.beat_id AND b.active=1 JOIN `user`.lead_route lr ON lr.beat_id=sc.beat_id AND lr.schedule_date=sc.start_date AND lr.status='APPROVED'" +
323
            "   JOIN `user`.beat b ON b.id=sc.beat_id AND b.active=1 JOIN `user`.lead_route lr ON lr.beat_id=sc.beat_id AND lr.schedule_date=sc.start_date AND lr.status='APPROVED'" +
Line 508... Line 508...
508
    // PJP coverage KPI and the coverage-by-level bar drill-downs.
508
    // PJP coverage KPI and the coverage-by-level bar drill-downs.
509
    private List<Map<String, Object>> coverageDetail(Session s, String ms, String me, List<Integer> auth) {
509
    private List<Map<String, Object>> coverageDetail(Session s, String ms, String me, List<Integer> auth) {
510
        NativeQuery<?> q = s.createNativeQuery(
510
        NativeQuery<?> q = s.createNativeQuery(
511
            "SELECT au.id uid, TRIM(CONCAT(au.first_name,' ',COALESCE(au.last_name,''))) nm, p.lvl," +
511
            "SELECT au.id uid, TRIM(CONCAT(au.first_name,' ',COALESCE(au.last_name,''))) nm, p.lvl," +
512
            " MAX(CASE WHEN sc.id IS NOT NULL THEN 1 ELSE 0 END) has_plan" +
512
            " MAX(CASE WHEN sc.id IS NOT NULL THEN 1 ELSE 0 END) has_plan" +
513
            " FROM (SELECT auth_user_id, MIN(escalation_type) lvl FROM cs.position WHERE category_id=4 AND auth_user_id IN (:auth) AND LOWER(escalation_type) NOT IN ('l5','final') GROUP BY auth_user_id) p" +
513
            " FROM (SELECT auth_user_id, MIN(escalation_type) lvl FROM cs.position WHERE category_id=4 AND auth_user_id IN (:auth) AND LOWER(escalation_type) NOT IN ('l4','l5','final') GROUP BY auth_user_id) p" +
514
            " JOIN auth.auth_user au ON au.id=p.auth_user_id" +
514
            " JOIN auth.auth_user au ON au.id=p.auth_user_id" +
515
            " LEFT JOIN `user`.beat b ON b.auth_user_id=p.auth_user_id AND b.active=1" +
515
            " LEFT JOIN `user`.beat b ON b.auth_user_id=p.auth_user_id AND b.active=1" +
516
            " LEFT JOIN `user`.beat_schedule sc ON sc.beat_id=b.id AND sc.start_date>=:ms AND sc.start_date<=:me" +
516
            " LEFT JOIN `user`.beat_schedule sc ON sc.beat_id=b.id AND sc.start_date>=:ms AND sc.start_date<=:me" +
517
            " GROUP BY au.id, nm, p.lvl ORDER BY p.lvl, nm");
517
            " GROUP BY au.id, nm, p.lvl ORDER BY p.lvl, nm");
518
        q.setParameter("ms", ms).setParameter("me", me).setParameterList("auth", auth);
518
        q.setParameter("ms", ms).setParameter("me", me).setParameterList("auth", auth);