diff --git a/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java b/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java deleted file mode 100644 index f6474c4..0000000 --- a/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.gcc.commissionerreview.configuration; - -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; - -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import javax.sql.DataSource; - -@Configuration -@EnableTransactionManagement -public class DataSourceConfig { - - private static String host = "localhost:3306"; - private static String dbpassword = "root"; - - // private static String host = - // "gcc-facial-db-instance-1.cf48eqcciziq.ap-south-1.rds.amazonaws.com:3306"; - // private static String dbpassword = "gcc-facial-password"; - - public static class MyDataSourceConfig { - @Primary - @Bean(name = "mydatasource") - - public DataSource MyDataSource() { - // DriverManagerDataSource dataSource = new DriverManagerDataSource(); - // dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); - // dataSource.setUrl("jdbc:mysql://"+host+"/dashboard_service"); - // dataSource.setUsername("root"); - // dataSource.setPassword("root"); - // return dataSource; - - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setUrl("jdbc:mysql://" + host + "/commissioner_review"); - // dataSource.setUrl("jdbc:mysql://"+host+"/dashboard_service"); - dataSource.setUsername("root"); - dataSource.setPassword(dbpassword); - dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); - return dataSource; - - } - - @Primary - @Bean(name = "myTransactionManager") - public PlatformTransactionManager myTransactionManager(@Qualifier("mydatasource") DataSource dataSource) { - return new DataSourceTransactionManager(dataSource); - } - } - - ////////////////////////////// Domestic Waste Management - ////////////////////////////// //////////////////////// - @Bean(name = "mysqlSofaBedCollectionDataSource") - public DataSource mysqlSofaBedCollectionDataSource() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://" + host + "/domestic_waste_management"); - dataSource.setUsername("root"); - dataSource.setPassword(dbpassword); - return dataSource; - } - - ////////////////////////////// Food distribution //////////////////////// - @Bean(name = "mysqlFoodDistributionDataSource") - public DataSource mysqlFoodDistributionDataSource() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://" + host + "/gcc_food_distribution"); - dataSource.setUsername("root"); - dataSource.setPassword(dbpassword); - return dataSource; - } - - ////////////////////////////// ORACLE //////////////////////// - @Bean(name = "oracleDataSource") - public DataSource oracleDataSource() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName("oracle.jdbc.OracleDriver"); - dataSource.setUrl("jdbc:oracle:thin:@10.1.0.14:1521:chncorp"); - dataSource.setUsername("FAS"); - dataSource.setPassword("FAS"); - return dataSource; - } -} diff --git a/src/main/java/com/gcc/commissionerreview/controller/FoodSchemeController.java b/src/main/java/com/gcc/commissionerreview/controller/FoodSchemeController.java deleted file mode 100644 index d0979e0..0000000 --- a/src/main/java/com/gcc/commissionerreview/controller/FoodSchemeController.java +++ /dev/null @@ -1,213 +0,0 @@ -package com.gcc.commissionerreview.controller; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import com.gcc.commissionerreview.service.FoodSchemeService; - -@RestController -@RequestMapping("/commissionerreview/api") -public class FoodSchemeController { - - @Autowired - private FoodSchemeService foodSchemeService; - - /* - * @GetMapping("/feedback-summary") - * public List> getFeedbackSummary(@RequestParam String - * date) { - * return feedbackService.getFeedbackSummary(date); - * } - * - * @GetMapping("/driver-report") - * public List> getDriverReport(@RequestParam String date) { - * //System.out.println("Date received in controller: " + date); - * return feedbackService.getDriverReport(date); - * } - */ - // ak - @GetMapping("/feedback-summary") - public ResponseEntity getFeedbackSummary(@RequestParam String date) { - try { - List> data = foodSchemeService.getFeedbackSummary(date); - - Map response = new HashMap<>(); - response.put("status", "success"); - response.put("date", date); - response.put("data", data); - - return ResponseEntity.ok(response); - - } catch (Exception e) { - Map error = new HashMap<>(); - error.put("status", "error"); - error.put("message", e.getMessage()); - - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); - } - } - - // ak - @GetMapping("/zone-details") - public ResponseEntity getZoneDetails( - @RequestParam int qid, - @RequestParam String column, - @RequestParam String date) { - - try { - List> data = foodSchemeService.getZoneDetails(qid, column, date); - - Map response = new HashMap<>(); - response.put("status", "success"); - response.put("date", date); - response.put("data", data); - - return ResponseEntity.ok(response); - - } catch (Exception e) { - Map error = new HashMap<>(); - error.put("status", "error"); - error.put("message", e.getMessage()); - - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); - } - } - - - - @GetMapping("/ward-details") - public ResponseEntity getWardDetails( - @RequestParam int qid, - @RequestParam String column, - @RequestParam String date, - @RequestParam int zoneId) { - - return ResponseEntity.ok(Map.of( - "status", "success", - "date", date, - "data", foodSchemeService.getWardDetails(qid, column, date, zoneId))); - } - - @GetMapping("/driver-report") - public ResponseEntity getDriverReport(@RequestParam String date, @RequestParam(required = false) Integer zone) { - try { - List> data = foodSchemeService.getDriverReport(date, zone); - - Map response = new HashMap<>(); - response.put("status", "success"); - response.put("date", date); - response.put("data", data); - - return ResponseEntity.ok(response); - - } catch (Exception e) { - Map error = new HashMap<>(); - error.put("status", "error"); - error.put("message", e.getMessage()); - - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); - } - } - - @GetMapping("/zones") - public ResponseEntity getZones() { - List> data = foodSchemeService.getZones(); - return ResponseEntity.ok(Map.of("data", data)); - } - - /// yogi - @GetMapping("/abstract") - public ResponseEntity getAbstractReport(@RequestParam String date) { - try { - List> report = foodSchemeService.getAbstractReport(date); - // System.out.println("report : " + report); - - Map response = new HashMap<>(); - response.put("status", "success"); - response.put("date", date); - response.put("data", report); - - return ResponseEntity.ok(response); - - } catch (Exception e) { - Map error = new HashMap<>(); - error.put("status", "error"); - error.put("message", e.getMessage()); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); - } - } - - @GetMapping("/zoneandshiftbasedreport") - public ResponseEntity getZoneWiseShiftBasedReport(@RequestParam String date, @RequestParam Integer shiftId) { - try { - List> report = foodSchemeService.getZoneWiseShiftBasedReport(date, shiftId); - // System.out.println("report : " + report); - - Map response = new HashMap<>(); - response.put("status", "success"); - response.put("date", date); - response.put("data", report); - - return ResponseEntity.ok(response); - - } catch (Exception e) { - Map error = new HashMap<>(); - error.put("status", "error"); - error.put("message", e.getMessage()); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); - } - } - - @GetMapping("/wardwiseShiftReport") - public ResponseEntity getWardWiseShiftReport( - @RequestParam String date, - @RequestParam Integer shiftId, - @RequestParam Integer zone) { - - try { - List> data = foodSchemeService.getWardWiseShiftReport(shiftId, zone, date); - - Map response = new HashMap<>(); - response.put("status", "success"); - response.put("zone", zone); - response.put("data", data); - - return ResponseEntity.ok(response); - - } catch (Exception e) { - Map error = new HashMap<>(); - error.put("status", "error"); - error.put("message", e.getMessage()); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); - } - } - - @GetMapping("/wardlocationreport") - public ResponseEntity getWardLocationReport(@RequestParam String date) { - try { - List> report = foodSchemeService.getWardLocationWiseReport(date); - - Map response = new HashMap<>(); - response.put("status", "success"); - response.put("date", date); - response.put("data", report); - - return ResponseEntity.ok(response); - } catch (Exception e) { - Map error = new HashMap<>(); - error.put("status", "error"); - error.put("message", e.getMessage()); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); - } - } - -} diff --git a/src/main/java/com/gcc/commissionerreview/service/FoodSchemeService.java b/src/main/java/com/gcc/commissionerreview/service/FoodSchemeService.java deleted file mode 100644 index 95ec871..0000000 --- a/src/main/java/com/gcc/commissionerreview/service/FoodSchemeService.java +++ /dev/null @@ -1,1865 +0,0 @@ -package com.gcc.commissionerreview.service; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import javax.imageio.ImageIO; -import javax.sql.DataSource; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.env.Environment; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Service; -import java.net.URL; -import java.awt.image.BufferedImage; -import java.io.ByteArrayOutputStream; -import javax.imageio.ImageIO; - -import java.util.Arrays; -import java.util.Base64; -import java.util.concurrent.ConcurrentHashMap; -import java.util.Map; - -import com.gcc.commissionerreview.configuration.AppConfig; - -@Service -public class FoodSchemeService { - - @Autowired - private JdbcTemplate jdbcTemplate; - @Autowired - private Environment environment; - @Autowired - private AppConfig appConfig; - - @Autowired - @Value("${fileBaseUrl}") - - private String fileBaseUrl; - - // ak for pdf image render - // private final Map imageCache = new ConcurrentHashMap<>(); - - @Autowired - public void setFeedbackDataSource(@Qualifier("mysqlFoodDistributionDataSource") DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); - } - - public FoodSchemeService(Environment environment) { - - this.environment = environment; - - this.fileBaseUrl = environment.getProperty("fileBaseUrl"); - } - /* - * private String convertUrlToBase64(String url) { - * try { - * if (imageCache.containsKey(url)) { - * return imageCache.get(url); - * } - * - * URL imageUrl = new URL(url); - * BufferedImage image = ImageIO.read(imageUrl); - * - * ByteArrayOutputStream baos = new ByteArrayOutputStream(); - * ImageIO.write(image, "jpeg", baos); - * - * String base64 = "data:image/jpeg;base64," + - * Base64.getEncoder().encodeToString(baos.toByteArray()); - * - * imageCache.put(url, base64); - * return base64; - * - * } catch (Exception e) { - * e.printStackTrace(); - * return null; - * } - * } - */ - - public List> getFeedbackSummary(String date) { - - String sql = "SELECT " + - " fq.qid, " + - " fq.question, " + - "fq.qid, " + - - " SUM(CASE WHEN fq.qid = 1 AND fd.q1 = '1' THEN 1 ELSE 0 END) AS on_time_distribution, " + - " SUM(CASE WHEN fq.qid = 1 AND fd.q1 = '2' THEN 1 ELSE 0 END) AS delayeded, " + - - " SUM(CASE WHEN fq.qid = 2 AND fd.q2 = '3' THEN 1 ELSE 0 END) AS good, " + - " SUM(CASE WHEN fq.qid = 2 AND fd.q2 = '4' THEN 1 ELSE 0 END) AS average, " + - - " SUM(CASE WHEN fq.qid = 3 AND fd.q3 = '5' THEN 1 ELSE 0 END) AS sufficient_food_quantity, " + - " SUM(CASE WHEN fq.qid = 3 AND fd.q3 = '6' THEN 1 ELSE 0 END) AS less_quantity " + - - "FROM feedback_questions fq " + // ← space added - "LEFT JOIN feedback_data fd " + // ← space added - " ON fd.isactive = 1 " + // ← space added - " AND fd.isdelete = 0 " + // ← space added - " AND DATE(fd.feedback_date) = ? " + // ← space added - - "WHERE fq.isactive = 1 " + - "AND fq.isdelete = 0 " + - - "GROUP BY fq.qid, fq.question " + - "ORDER BY fq.orderby"; - - return jdbcTemplate.queryForList(sql, date); - - } - - // ak - public List> getZoneDetails(int qid, String column, String date) { - - String sql = "SELECT lm.zone, fq.qid, fq.question, " + - "SUM(CASE " + - " WHEN ? = 'on_time_distribution' AND fd.q1 = '1' THEN 1 " + - " WHEN ? = 'delayeded' AND fd.q1 = '2' THEN 1 " + - - " WHEN ? = 'good' AND fd.q2 = '3' THEN 1 " + - " WHEN ? = 'average' AND fd.q2 = '4' THEN 1 " + - - " WHEN ? = 'sufficient_food_quantity' AND fd.q3 = '5' THEN 1 " + - " WHEN ? = 'less_quantity' AND fd.q3 = '6' THEN 1 " + - " ELSE 0 END) AS count_value " + - - "FROM feedback_data fd " + - "INNER JOIN location_mapping lm ON fd.feedback_by = lm.siloginid " + - "INNER JOIN feedback_questions fq ON fq.qid = ? " + - - "WHERE fd.isactive = 1 " + - "AND fd.isdelete = 0 " + - "AND DATE(fd.feedback_date) = ? " + - - "GROUP BY lm.zone, fq.qid, fq.question " + - "ORDER BY lm.zone"; - - return jdbcTemplate.queryForList( - sql, - column, column, column, column, column, column, // 6 column comparisons - qid, // qid - date // date - ); - } - - /* - * public List> getZoneDetails(int qid, String column, - * String date) { - * - * String sql = "SELECT lm.zone, fq.qid, fq.question, " + - * "SUM(CASE " + - * " WHEN ? = 'on_time_distribution' AND fd.q1 = '1' THEN 1 " + - * " WHEN ? = 'delayeded' AND fd.q1 = '2' THEN 1 " + - * - * " WHEN ? = 'good' AND fd.q2 = '3' THEN 1 " + - * " WHEN ? = 'average' AND fd.q2 = '4' THEN 1 " + - * - * " WHEN ? = 'sufficient_food_quantity' AND fd.q3 = '5' THEN 1 " + - * " WHEN ? = 'less_quantity' AND fd.q3 = '6' THEN 1 " + - * " ELSE 0 END) AS count_value " + - * - * "FROM location_mapping lm " + - * "LEFT JOIN feedback_data fd ON fd.feedback_by = lm.siloginid " + - * " AND fd.isactive = 1 " + - * " AND fd.isdelete = 0 " + - * " AND DATE(fd.feedback_date) = ? " + - * - * "LEFT JOIN feedback_questions fq ON fq.qid = ? " + - * - * "GROUP BY lm.zone, fq.qid, fq.question " + - * "ORDER BY lm.zone"; - * - * return jdbcTemplate.queryForList(sql, - * column, column, column, column, column, column, // bind 6 times - * date, // date - * qid // qid - * ); - * } - */ - - public List> getDriverReport(String date, Integer zone) { - // System.out.println("File Base URL: " + fileBaseUrl);. - String zoneCondition = ""; - if (zone != null) { - zoneCondition = " AND lm.zone = " + zone + " "; - } - System.out.println("zoneCondition: " + zone); - - String sql = "SELECT lm.location AS LocationDescription, " + - "dl.username AS DriverName, " + - "lm.zone AS Zone, " + - "lm.ward AS Ward, " + - "SUBSTRING(dss_start.driver_live_mobile, 4) AS DriverMobile, " + - "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', dss_start.image) AS StartImage, " + - // "CONCAT(dss_start.latitude, ', ', dss_start.longitude) AS StartPoint, " + - "dss_start.address AS StartAddress, " + - - // "DATE_FORMAT(dss_start.datetime, '%Y-%m-%d %H:%i') AS StartTime, " + - "DATE_FORMAT(dss_start.datetime, '%h:%i %p') AS StartTime," + - // "CONCAT(dss_stop.latitude, ', ', dss_stop.longitude) AS EndPoint, " + - "dss_stop.address AS EndAddress, " + - "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', dss_stop.image) AS EndImage, " + - // "DATE_FORMAT(dss_stop.datetime, '%Y-%m-%d %H:%i') AS EndTime " + - "DATE_FORMAT(dss_stop.datetime, '%h:%i %p') AS EndTime " + - - "FROM location_mapping lm " + - "INNER JOIN driver_login dl ON dl.loginid = lm.driverid " + - - "LEFT JOIN driver_start_stop dss_start " + - "ON dss_start.loginid = lm.driverid " + - "AND dss_start.action = 'Start' " + - - "LEFT JOIN driver_start_stop dss_stop " + - "ON dss_stop.loginid = lm.driverid " + - "AND dss_stop.action = 'Stop' " + - "AND dss_stop.startid = dss_start.locationid " + - - "WHERE DATE(dss_start.datetime) = ?" + zoneCondition + - "order by dss_start.datetime"; - - return jdbcTemplate.queryForList(sql, date); - } - - public List> getZones() { - String sql = "SELECT DISTINCT zone FROM location_mapping "; - return jdbcTemplate.queryForList(sql); - } - - // yogi used has old without isactive isdelete - // public List> getAbstractReport(String date) { - - // String sql = """ - // SELECT * FROM ( - - // SELECT - - // sm.name AS shift_name, - // sm.Code as shift_code, - // sm.shiftid as shiftid, - // IFNULL(SUM(gru.total_food_requested), 0) AS food_requested, - // IFNULL(SUM(gru.total_food_received), 0) AS food_delivered, - // IFNULL(SUM(dr.nulm + dr.private + dr.permanent), 0) AS overall_count, - // IFNULL(SUM(dr.nulm + dr.private + dr.permanent), 0) AS present_count, - // IFNULL(SUM(gru.today_absentees_nulm + gru.today_absentees_private + - // gru.today_absentees_permanent), 0) AS unplanned_count, - // IFNULL(SUM(dr.absentees_nulm + dr.absentees_private + - // dr.absentees_permanent), 0) AS absent_count, - // IFNULL(SUM(gru.total_box_shortfall), 0) AS food_shortfall - // FROM shift_master sm - // LEFT JOIN daily_request dr - // ON sm.shiftid = dr.shiftid AND dr.required_date = ? - // LEFT JOIN gcc_received_update gru - // ON gru.requestid = dr.requestid - // GROUP BY sm.shiftid, sm.name - - // UNION ALL - - // SELECT - // 'Total' AS shift_name, - // 'TOTAL' AS shift_code, - // 'TOTAL' as shift_id, - // IFNULL(SUM(gru.total_food_requested), 0), - // IFNULL(SUM(gru.total_food_received), 0), - // IFNULL(SUM(dr.nulm + dr.private + dr.permanent), 0), - // IFNULL(SUM(dr.nulm + dr.private + dr.permanent), 0), - // IFNULL(SUM(gru.today_absentees_nulm + gru.today_absentees_private + - // gru.today_absentees_permanent), 0), - // IFNULL(SUM(dr.absentees_nulm + dr.absentees_private + - // dr.absentees_permanent), 0), - // IFNULL(SUM(gru.total_box_shortfall), 0) - // FROM shift_master sm - // LEFT JOIN daily_request dr - // ON sm.shiftid = dr.shiftid AND dr.required_date = ? - // LEFT JOIN gcc_received_update gru - // ON gru.requestid = dr.requestid - // ) AS final_result - // """; - - // return jdbcTemplate.queryForList(sql, date, date); - // } - - // new abstract report old - // public List> getAbstractReport(String date) { - - // String sql = """ - // SELECT * FROM ( - - // /* ================= SHIFT-WISE SUMMARY ================= */ - // SELECT - // sm.name AS shift_name, - // sm.code AS shift_code, - // sm.shiftid AS shiftid, - - // /* ---------------- TOTAL COMPLEMENT ---------------- */ - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) AS - // total_complement, - - // /* ---------------- WEEKLY OFF ---------------- */ - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + - // dr.weeklyoff_others + dr.weeklyoff_nmr), 0) AS weekly_off, - - // /* ---------------- PLANNED LEAVE ---------------- */ - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm - // + - // dr.absentees_others + dr.absentees_nmr), 0) AS planned_leave, - - // /* ---------------- PRESENT COUNT ---------------- */ - // ( - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - // - - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + - // dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - // - - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm - // + - // dr.absentees_others + dr.absentees_nmr), 0) - // ) AS present_count, - - // /* ---------------- FOOD REQUESTED ---------------- */ - // ( - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - // - - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + - // dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - // - - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm - // + - // dr.absentees_others + dr.absentees_nmr), 0) - // ) AS food_requested, - - // /* ---------------- FOOD DELIVERED ---------------- */ - // IFNULL(SUM(gru.total_food_received), 0) AS food_delivered, - - // /* ---------------- FOOD SHORTFALL ---------------- */ - // ( - // ( - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - // - - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + - // dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - // - - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm - // + - // dr.absentees_others + dr.absentees_nmr), 0) - // ) - // - - // IFNULL(SUM(gru.total_food_received), 0) - // ) AS food_shortfall - - // FROM shift_master sm - // LEFT JOIN daily_request dr - // ON sm.shiftid = dr.shiftid AND dr.required_date = ? - // LEFT JOIN gcc_received_update gru - // ON gru.requestid = dr.requestid - // WHERE sm.isactive = 1 AND sm.isdelete = 0 - // GROUP BY sm.shiftid, sm.name - - // UNION ALL - - // /* ================= TOTAL SUMMARY ================= */ - // SELECT - // 'Total' AS shift_name, - // 'TOTAL' AS shift_code, - // 'TOTAL' AS shiftid, - - // /* TOTAL COMPLEMENT */ - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0), - - // /* WEEKLY OFF */ - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + - // dr.weeklyoff_others + dr.weeklyoff_nmr), 0), - - // /* PLANNED LEAVE */ - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm - // + - // dr.absentees_others + dr.absentees_nmr), 0), - - // /* PRESENT COUNT */ - // ( - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - // - - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + - // dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - // - - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm - // + - // dr.absentees_others + dr.absentees_nmr), 0) - // ), - - // /* FOOD REQUESTED */ - // ( - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - // - - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + - // dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - // - - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm - // + - // dr.absentees_others + dr.absentees_nmr), 0) - // ), - - // /* FOOD DELIVERED */ - // IFNULL(SUM(gru.total_food_received), 0), - - // /* FOOD SHORTFALL */ - // ( - // ( - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - // - - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + - // dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - // - - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm - // + - // dr.absentees_others + dr.absentees_nmr), 0) - // ) - // - - // IFNULL(SUM(gru.total_food_received), 0) - // ) - - // FROM shift_master sm - // LEFT JOIN daily_request dr - // ON sm.shiftid = dr.shiftid AND dr.required_date = ? - // LEFT JOIN gcc_received_update gru - // ON gru.requestid = dr.requestid - // WHERE sm.isactive = 1 AND sm.isdelete = 0 - // ) final_table - // """; - - // return jdbcTemplate.queryForList(sql, date, date); - // } - - // with using isactive and isdelete - public List> getAbstractReport(String date) { - - String sql = """ - SELECT * FROM ( - - /* ================= SHIFT-WISE SUMMARY ================= */ - SELECT - sm.name AS shift_name, - sm.code AS shift_code, - sm.shiftid AS shiftid, - - /* TOTAL COMPLEMENT */ - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) AS total_complement, - - /* WEEKLY OFF */ - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm + - dr.weeklyoff_others + dr.weeklyoff_nmr), 0) AS weekly_off, - - /* PLANNED LEAVE */ - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm + - dr.absentees_others + dr.absentees_nmr), 0) AS planned_leave, - - /* PRESENT COUNT */ - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm + - dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - - - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm + - dr.absentees_others + dr.absentees_nmr), 0) - ) AS present_count, - - /* FOOD REQUESTED = PRESENT COUNT */ - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm + - dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - - - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm + - dr.absentees_others + dr.absentees_nmr), 0) - ) AS food_requested, - - /* FOOD DELIVERED */ - IFNULL(SUM(gru.total_food_received), 0) AS food_delivered, - - /* FOOD SHORTFALL */ - ( - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm + - dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - - - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm + - dr.absentees_others + dr.absentees_nmr), 0) - ) - - - IFNULL(SUM(gru.total_food_received), 0) - ) AS food_shortfall - - FROM shift_master sm - LEFT JOIN daily_request dr - ON sm.shiftid = dr.shiftid - AND dr.required_date = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - LEFT JOIN gcc_received_update gru - ON gru.requestid = dr.requestid - AND gru.isactive = 1 - AND gru.isdelete = 0 - WHERE sm.isactive = 1 AND sm.isdelete = 0 - GROUP BY sm.shiftid, sm.name - - UNION ALL - - /* ================= TOTAL SUMMARY ================= */ - SELECT - 'Total' AS shift_name, - 'TOTAL' AS shift_code, - 'TOTAL' AS shiftid, - - /* TOTAL COMPLEMENT */ - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0), - - /* WEEKLY OFF */ - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm + - dr.weeklyoff_others + dr.weeklyoff_nmr), 0), - - /* PLANNED LEAVE */ - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm + - dr.absentees_others + dr.absentees_nmr), 0), - - /* PRESENT COUNT */ - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm + - dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - - - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm + - dr.absentees_others + dr.absentees_nmr), 0) - ), - - /* FOOD REQUESTED */ - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm + - dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - - - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm + - dr.absentees_others + dr.absentees_nmr), 0) - ), - - /* FOOD DELIVERED */ - IFNULL(SUM(gru.total_food_received), 0), - - /* FOOD SHORTFALL */ - ( - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm + - dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - - - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm + - dr.absentees_others + dr.absentees_nmr), 0) - ) - - - IFNULL(SUM(gru.total_food_received), 0) - ) - - FROM shift_master sm - LEFT JOIN daily_request dr - ON sm.shiftid = dr.shiftid - AND dr.required_date = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - LEFT JOIN gcc_received_update gru - ON gru.requestid = dr.requestid - AND gru.isactive = 1 - AND gru.isdelete = 0 - WHERE sm.isactive = 1 AND sm.isdelete = 0 - ) final_table - """; - - return jdbcTemplate.queryForList(sql, date, date); - } - - public List> getWardDetails(int qid, String column, String date, int zone) { - - String imageColumn = ""; - String whereCondition = ""; // <-- will be used in WHERE - String sumCondition = ""; // <-- used inside SUM() - - switch (column) { - case "on_time_distribution": - imageColumn = "fd.q1_img"; - whereCondition = "fd.q1 = '1'"; - sumCondition = "fd.q1 = '1'"; - break; - - case "delayeded": - imageColumn = "fd.q1_img"; - whereCondition = "fd.q1 = '2'"; - sumCondition = "fd.q1 = '2'"; - break; - - case "good": - imageColumn = "fd.q2_img"; - whereCondition = "fd.q2 = '3'"; - sumCondition = "fd.q2 = '3'"; - break; - - case "average": - imageColumn = "fd.q2_img"; - whereCondition = "fd.q2 = '4'"; - sumCondition = "fd.q2 = '4'"; - break; - - case "sufficient_food_quantity": - imageColumn = "fd.q3_img"; - whereCondition = "fd.q3 = '5'"; - sumCondition = "fd.q3 = '5'"; - break; - - case "less_quantity": - imageColumn = "fd.q3_img"; - whereCondition = "fd.q3 = '6'"; - sumCondition = "fd.q3 = '6'"; - break; - } - - String sql = "SELECT lm.ward,lm.location, fq.question, " + - "SUM(CASE WHEN " + sumCondition + " THEN 1 ELSE 0 END) AS count_value, " + - "CONCAT('" + fileBaseUrl + "/gccofficialapp/files'," + imageColumn + ") AS feedbackImage " + - "FROM feedback_data fd " + - "INNER JOIN location_mapping lm ON fd.feedback_by = lm.siloginid " + - "INNER JOIN feedback_questions fq ON fq.qid = ? " + - "WHERE lm.zone = ? " + - "AND DATE(fd.feedback_date) = ? " + - "AND fd.isactive = 1 AND fd.isdelete = 0 " + - "AND " + whereCondition + " " + // <-- EXACT MATCH ADDED - "GROUP BY lm.ward,lm.location,fq.question, " + imageColumn + " " + - "ORDER BY lm.ward"; - - return jdbcTemplate.queryForList(sql, qid, zone, date); - } - - // with using isactive and isdelete - // public List> getZoneWiseShiftBasedReport(String date, int - // shiftId) { - - // String sql = """ - // SELECT * - // FROM ( - - // /* ================= ZONE-WISE SUMMARY ================= */ - // SELECT - // z.zone AS zone, - - // /* -------- TOTAL COMPLEMENT -------- */ - // ( - // SELECT IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), - // 0) - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) AS total_complement, - - // /* -------- WEEKLY OFF -------- */ - // ( - // SELECT IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + - // dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) AS weekly_off, - - // /* -------- PLANNED LEAVE -------- */ - // ( - // SELECT IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + - // dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr), 0) - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) AS planned_leave, - - // /* -------- PRESENT COUNT -------- */ - // ( - // ( - // SELECT IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), - // 0) - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) - // - - // ( - // SELECT IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + - // dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) - // - - // ( - // SELECT IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + - // dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr), 0) - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) - // ) AS present_count, - - // /* -------- FOOD REQUESTED -------- */ - // ( - // ( - // SELECT IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), - // 0) - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) - // - - // ( - // SELECT IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + - // dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) - // - - // ( - // SELECT IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + - // dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr), 0) - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) - // ) AS food_requested, - - // /* -------- FOOD DELIVERED -------- */ - // ( - // SELECT IFNULL(SUM(gru.total_food_received), 0) - // FROM gcc_received_update gru - // WHERE gru.shiftid = ? - // AND gru.requestid IN ( - // SELECT dr.requestid - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) - // ) AS food_delivered, - - // /* -------- FOOD SHORTFALL (UPDATED) -------- */ - // ( - // ( - // ( - // SELECT IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), - // 0) - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) - // - - // ( - // SELECT IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + - // dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) - // - - // ( - // SELECT IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + - // dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr), 0) - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) - // ) - // - - // ( - // SELECT IFNULL(SUM(gru.total_food_received), 0) - // FROM gcc_received_update gru - // WHERE gru.shiftid = ? - // AND gru.requestid IN ( - // SELECT dr.requestid - // FROM daily_request dr - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - // AND dr.request_by IN ( - // SELECT lm.siloginid FROM location_mapping lm WHERE lm.zone = z.zone - // ) - // ) - // ) - // ) AS food_shortfall - - // FROM ( - // SELECT DISTINCT zone - // FROM location_mapping - // WHERE zone IS NOT NULL - // ORDER BY CAST(zone AS UNSIGNED) - // ) z - - // UNION ALL - - // /* ================= GRAND TOTAL ================= */ - // SELECT - // 'TOTAL' AS zone, - - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0), - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + - // dr.weeklyoff_others + dr.weeklyoff_nmr), 0), - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm - // + - // dr.absentees_others + dr.absentees_nmr), 0), - - // ( - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - // - - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + - // dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - // - - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm - // + - // dr.absentees_others + dr.absentees_nmr), 0) - // ), - - // /* food_requested total = present_count total */ - // ( - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - // - - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + - // dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - // - - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm - // + - // dr.absentees_others + dr.absentees_nmr), 0) - // ), - - // /* delivered */ - // IFNULL(SUM(gru.total_food_received), 0), - - // /* -------- TOTAL FOOD SHORTFALL -------- */ - // ( - // ( - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - // - - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + - // dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - // - - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm - // + - // dr.absentees_others + dr.absentees_nmr), 0) - // ) - // - - // IFNULL(SUM(gru.total_food_received), 0) - // ) - - // FROM daily_request dr - // LEFT JOIN gcc_received_update gru - // ON gru.requestid = dr.requestid - // WHERE dr.required_date = ? - // AND dr.shiftid = ? - - // ) final_output - - // ORDER BY - // CASE WHEN zone = 'TOTAL' THEN 1 ELSE 0 END, - // CAST(zone AS UNSIGNED); - // """; - - // return jdbcTemplate.queryForList(sql, - // /* zone-wise params */ - // date, shiftId, - // date, shiftId, - // date, shiftId, - // date, shiftId, date, shiftId, date, shiftId, - // date, shiftId, date, shiftId, date, shiftId, - // shiftId, date, shiftId, - - // /* shortfall zone params */ - // date, shiftId, date, shiftId, date, shiftId, - // shiftId, date, shiftId, - - // /* total row */ - // date, shiftId); - // } - - // with using isactive isdelete - public List> getZoneWiseShiftBasedReport(String date, int shiftId) { - - String sql = """ - SELECT * - FROM ( - - /* ================= ZONE-WISE SUMMARY ================= */ - SELECT - z.zone AS zone, - - /* -------- TOTAL COMPLEMENT -------- */ - ( - SELECT IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) AS total_complement, - - /* -------- WEEKLY OFF -------- */ - ( - SELECT IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) AS weekly_off, - - /* -------- PLANNED LEAVE -------- */ - ( - SELECT IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr), 0) - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) AS planned_leave, - - /* -------- PRESENT COUNT -------- */ - ( - ( - SELECT IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) - - - ( - SELECT IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) - - - ( - SELECT IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr), 0) - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) - ) AS present_count, - - /* -------- FOOD REQUESTED -------- */ - ( - ( - SELECT IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) - - - ( - SELECT IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) - - - ( - SELECT IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr), 0) - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) - ) AS food_requested, - - /* -------- FOOD DELIVERED -------- */ - ( - SELECT IFNULL(SUM(gru.total_food_received), 0) - FROM gcc_received_update gru - WHERE gru.shiftid = ? - AND gru.isactive = 1 - AND gru.isdelete = 0 - AND gru.requestid IN ( - SELECT dr.requestid - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) - ) AS food_delivered, - - /* -------- FOOD SHORTFALL -------- */ - ( - ( - ( - SELECT IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) - - - ( - SELECT IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) - - - ( - SELECT IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr), 0) - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) - ) - - - ( - SELECT IFNULL(SUM(gru.total_food_received), 0) - FROM gcc_received_update gru - WHERE gru.shiftid = ? - AND gru.isactive = 1 - AND gru.isdelete = 0 - AND gru.requestid IN ( - SELECT dr.requestid - FROM daily_request dr - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - AND dr.request_by IN ( - SELECT lm.siloginid - FROM location_mapping lm - WHERE lm.zone = z.zone - AND lm.isactive = 1 - AND lm.isdelete = 0 - ) - ) - ) - ) AS food_shortfall - - FROM ( - SELECT DISTINCT zone - FROM location_mapping - WHERE zone IS NOT NULL - AND isactive = 1 - AND isdelete = 0 - ORDER BY CAST(zone AS UNSIGNED) - ) z - - UNION ALL - - /* ================= GRAND TOTAL ================= */ - SELECT - 'TOTAL' AS zone, - - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0), - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm + - dr.weeklyoff_others + dr.weeklyoff_nmr), 0), - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm + - dr.absentees_others + dr.absentees_nmr), 0), - - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm + - dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - - - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm + - dr.absentees_others + dr.absentees_nmr), 0) - ), - - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm + - dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - - - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm + - dr.absentees_others + dr.absentees_nmr), 0) - ), - - IFNULL(SUM(gru.total_food_received), 0), - - ( - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm + - dr.weeklyoff_others + dr.weeklyoff_nmr), 0) - - - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm + - dr.absentees_others + dr.absentees_nmr), 0) - ) - - - IFNULL(SUM(gru.total_food_received), 0) - ) - - FROM daily_request dr - LEFT JOIN gcc_received_update gru - ON gru.requestid = dr.requestid - AND gru.isactive = 1 - AND gru.isdelete = 0 - WHERE dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - - ) final_output - - ORDER BY - CASE WHEN zone = 'TOTAL' THEN 1 ELSE 0 END, - CAST(zone AS UNSIGNED); - """; - - return jdbcTemplate.queryForList( - sql, - - /* zone-wise params */ - date, shiftId, - date, shiftId, - date, shiftId, - date, shiftId, date, shiftId, date, shiftId, - date, shiftId, date, shiftId, date, shiftId, - shiftId, date, shiftId, - - /* shortfall zone params */ - date, shiftId, date, shiftId, date, shiftId, - shiftId, date, shiftId, - - /* total row */ - date, shiftId); - } - - // without using isactive and isdelete - // public List> getWardWiseShiftReport(Integer shiftId, - // Integer zone, String date) { - - // String sql = """ - // WITH ward_data AS ( - // SELECT - // w.ward, - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others),0) AS - // total_complement, - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + dr.weeklyoff_others + dr.weeklyoff_nmr),0) AS weekly_off, - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.absentees_nulm - // + dr.absentees_others + dr.absentees_nmr),0) AS planned_leave, - - // -- PRESENT COUNT - // ( - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others),0) - // - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + - // dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr),0) - // - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + - // dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr),0) - // ) AS present_count, - - // -- FOOD REQUESTED - // ( - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others),0) - // - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + - // dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr),0) - // - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + - // dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr),0) - // ) AS food_requested, - - // IFNULL(SUM(gru.total_food_received),0) AS food_delivered, - - // -- FOOD SHORTFALL (corrected logic) - // CASE - // WHEN IFNULL(SUM(gru.total_food_received),0) >= ( - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr),0) - // - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_nulm + - // dr.weeklyoff_private + dr.weeklyoff_nmr),0) - // - IFNULL(SUM(dr.absentees_permanent + dr.absentees_nulm + - // dr.absentees_private + dr.absentees_nmr),0) - // ) - // THEN 0 - // ELSE ( - // ( - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr),0) - // - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_nulm + - // dr.weeklyoff_private + dr.weeklyoff_nmr),0) - // - IFNULL(SUM(dr.absentees_permanent + dr.absentees_nulm + - // dr.absentees_private + dr.absentees_nmr),0) - // ) - // - IFNULL(SUM(gru.total_food_received),0) - // ) - // END AS food_shortfall - - // FROM (SELECT DISTINCT ward FROM location_mapping WHERE zone = ? AND ward IS - // NOT NULL) w - // LEFT JOIN location_mapping lm ON lm.ward = w.ward AND lm.zone = ? - // LEFT JOIN daily_request dr ON dr.request_by = lm.siloginid - // AND dr.required_date = ? - // AND dr.shiftid = ? - // LEFT JOIN gcc_received_update gru ON gru.requestid = dr.requestid - - // GROUP BY w.ward - // ) - - // SELECT * FROM ward_data - - // UNION ALL - - // SELECT - // 'TOTAL' AS ward, - // SUM(total_complement), - // SUM(weekly_off), - // SUM(planned_leave), - // SUM(present_count), - // SUM(food_requested), - // SUM(food_delivered), - // SUM(food_shortfall) - // FROM ward_data - - // ORDER BY CASE WHEN ward = 'TOTAL' THEN 1 ELSE 0 END, ward; - // """; - - // Object[] params = new Object[] { - // zone, // w.zone - // zone, // lm.zone - // date, // dr.required_date - // shiftId // dr.shiftid - // }; - - // return jdbcTemplate.queryForList(sql, params); - // } - - // with using isactive isdelete - public List> getWardWiseShiftReport(Integer shiftId, Integer zone, String date) { - - String sql = """ - WITH ward_data AS ( - SELECT - w.ward, - - /* TOTAL COMPLEMENT */ - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) AS total_complement, - - /* WEEKLY OFF */ - IFNULL(SUM( - dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr - ), 0) AS weekly_off, - - /* PLANNED LEAVE */ - IFNULL(SUM( - dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr - ), 0) AS planned_leave, - - /* PRESENT COUNT */ - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM( - dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr - ), 0) - - - IFNULL(SUM( - dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr - ), 0) - ) AS present_count, - - /* FOOD REQUESTED */ - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM( - dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr - ), 0) - - - IFNULL(SUM( - dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr - ), 0) - ) AS food_requested, - - /* FOOD DELIVERED */ - IFNULL(SUM(gru.total_food_received), 0) AS food_delivered, - - /* FOOD SHORTFALL */ - CASE - WHEN IFNULL(SUM(gru.total_food_received), 0) >= - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM( - dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr - ), 0) - - - IFNULL(SUM( - dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr - ), 0) - ) - THEN 0 - ELSE - ( - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM( - dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr - ), 0) - - - IFNULL(SUM( - dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr - ), 0) - ) - - - IFNULL(SUM(gru.total_food_received), 0) - ) - END AS food_shortfall - - FROM ( - SELECT DISTINCT ward - FROM location_mapping - WHERE zone = ? - AND ward IS NOT NULL - AND isactive = 1 - AND isdelete = 0 - ) w - - LEFT JOIN location_mapping lm - ON lm.ward = w.ward - AND lm.zone = ? - AND lm.isactive = 1 - AND lm.isdelete = 0 - - LEFT JOIN daily_request dr - ON dr.request_by = lm.siloginid - AND dr.required_date = ? - AND dr.shiftid = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - - LEFT JOIN gcc_received_update gru - ON gru.requestid = dr.requestid - AND gru.isactive = 1 - AND gru.isdelete = 0 - - GROUP BY w.ward - ) - - SELECT * FROM ward_data - - UNION ALL - - SELECT - 'TOTAL' AS ward, - SUM(total_complement), - SUM(weekly_off), - SUM(planned_leave), - SUM(present_count), - SUM(food_requested), - SUM(food_delivered), - SUM(food_shortfall) - FROM ward_data - - ORDER BY - CASE WHEN ward = 'TOTAL' THEN 1 ELSE 0 END, - ward; - """; - - Object[] params = new Object[] { - zone, // ward subquery zone - zone, // lm.zone - date, // dr.required_date - shiftId // dr.shiftid - }; - - return jdbcTemplate.queryForList(sql, params); - } - - // without using isactive and isdelete - // public List> getWardLocationWiseReport(String date) { - - // String sql = """ - // SELECT * FROM ( - // -- ================= LOCATION WISE ================= - // SELECT - // lm.driverid, - // lm.zone, - // lm.ward, - // lm.location, - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others),0) AS - // total_complement, - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + dr.weeklyoff_others + dr.weeklyoff_nmr),0) AS weekly_off, - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.nulm + - // dr.absentees_others + dr.absentees_nmr),0) AS planned_leave, - // (IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others),0) - // - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.nulm + - // dr.weeklyoff_others + dr.weeklyoff_nmr),0) - // - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.nulm + - // dr.absentees_others + dr.absentees_nmr),0) - // ) AS present_count, - // (IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others),0) - // - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.nulm + - // dr.weeklyoff_others + dr.weeklyoff_nmr),0) - // - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.nulm + - // dr.absentees_others + dr.absentees_nmr),0) - // ) AS food_requested, - // IFNULL(SUM(gru.total_food_received),0) AS food_delivered, - // -- ===== FOOD SHORTFALL LOGIC ===== - // (IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others),0) - // - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.nulm + - // dr.weeklyoff_others + dr.weeklyoff_nmr),0) - // - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.nulm + - // dr.absentees_others + dr.absentees_nmr),0) - // ) - IFNULL(SUM(gru.total_food_received),0) AS food_shortfall - // FROM location_mapping lm - // LEFT JOIN daily_request dr - // ON dr.request_by = lm.siloginid AND dr.required_date = ? - // LEFT JOIN gcc_received_update gru - // ON gru.received_by = lm.siloginid AND gru.requestid = dr.requestid - // WHERE lm.ward IS NOT NULL AND lm.location IS NOT NULL - // GROUP BY lm.driverid, lm.zone, lm.ward, lm.location - - // UNION ALL - - // -- ================= TOTAL ROW ================= - // SELECT - // 999999 AS driverid, - // 'TOTAL' AS zone, - // 'TOTAL' AS ward, - // 'TOTAL' AS location, - // IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others),0) AS - // total_complement, - // IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.weeklyoff_nulm - // + dr.weeklyoff_others + dr.weeklyoff_nmr),0) AS weekly_off, - // IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.nulm + - // dr.absentees_others + dr.absentees_nmr),0) AS planned_leave, - // (IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others),0) - // - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + - // dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr),0) - // - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.nulm + - // dr.absentees_others + dr.absentees_nmr),0) - // ) AS present_count, - // (IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others),0) - // - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.nulm + - // dr.weeklyoff_others + dr.weeklyoff_nmr),0) - // - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.nulm + - // dr.absentees_others + dr.absentees_nmr),0) - // ) AS food_requested, - // IFNULL(SUM(gru.total_food_received),0) AS food_delivered, - // -- ===== FOOD SHORTFALL TOTAL ===== - // (IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others),0) - // - IFNULL(SUM(dr.weeklyoff_permanent + dr.weeklyoff_private + dr.nulm + - // dr.weeklyoff_others + dr.weeklyoff_nmr),0) - // - IFNULL(SUM(dr.absentees_permanent + dr.absentees_private + dr.nulm + - // dr.absentees_others + dr.absentees_nmr),0) - // ) - IFNULL(SUM(gru.total_food_received),0) AS food_shortfall - // FROM daily_request dr - // LEFT JOIN gcc_received_update gru ON gru.requestid = dr.requestid - // WHERE dr.required_date = ? - // ) final_output - // ORDER BY driverid ASC - // """; - - // Object[] params = new Object[] { date, date }; // first for location JOIN, - // second for TOTAL row - // return jdbcTemplate.queryForList(sql, params); - // } - - // with using isactive isdelete - public List> getWardLocationWiseReport(String date) { - - String sql = """ - SELECT * FROM ( - /* ================= LOCATION WISE ================= */ - SELECT - lm.driverid, - lm.zone, - lm.ward, - lm.location, - - /* TOTAL COMPLEMENT */ - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) AS total_complement, - - /* WEEKLY OFF */ - IFNULL(SUM( - dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr - ), 0) AS weekly_off, - - /* PLANNED LEAVE */ - IFNULL(SUM( - dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr - ), 0) AS planned_leave, - - /* PRESENT COUNT */ - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM( - dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr - ), 0) - - - IFNULL(SUM( - dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr - ), 0) - ) AS present_count, - - /* FOOD REQUESTED */ - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM( - dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr - ), 0) - - - IFNULL(SUM( - dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr - ), 0) - ) AS food_requested, - - /* FOOD DELIVERED */ - IFNULL(SUM(gru.total_food_received), 0) AS food_delivered, - - /* FOOD SHORTFALL */ - ( - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM( - dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr - ), 0) - - - IFNULL(SUM( - dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr - ), 0) - ) - - - IFNULL(SUM(gru.total_food_received), 0) - ) AS food_shortfall - - FROM location_mapping lm - LEFT JOIN daily_request dr - ON dr.request_by = lm.siloginid - AND dr.required_date = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - - LEFT JOIN gcc_received_update gru - ON gru.requestid = dr.requestid - AND gru.received_by = lm.siloginid - AND gru.isactive = 1 - AND gru.isdelete = 0 - - WHERE lm.ward IS NOT NULL - AND lm.location IS NOT NULL - AND lm.isactive = 1 - AND lm.isdelete = 0 - - GROUP BY - lm.driverid, - lm.zone, - lm.ward, - lm.location - - UNION ALL - - /* ================= TOTAL ROW ================= */ - SELECT - 999999 AS driverid, - 'TOTAL' AS zone, - 'TOTAL' AS ward, - 'TOTAL' AS location, - - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0), - IFNULL(SUM( - dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr - ), 0), - IFNULL(SUM( - dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr - ), 0), - - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM( - dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr - ), 0) - - - IFNULL(SUM( - dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr - ), 0) - ), - - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM( - dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr - ), 0) - - - IFNULL(SUM( - dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr - ), 0) - ), - - IFNULL(SUM(gru.total_food_received), 0), - - ( - ( - IFNULL(SUM(dr.permanent + dr.nulm + dr.private + dr.nmr + dr.others), 0) - - - IFNULL(SUM( - dr.weeklyoff_permanent + dr.weeklyoff_private + - dr.weeklyoff_nulm + dr.weeklyoff_others + dr.weeklyoff_nmr - ), 0) - - - IFNULL(SUM( - dr.absentees_permanent + dr.absentees_private + - dr.absentees_nulm + dr.absentees_others + dr.absentees_nmr - ), 0) - ) - - - IFNULL(SUM(gru.total_food_received), 0) - ) - - FROM daily_request dr - LEFT JOIN gcc_received_update gru - ON gru.requestid = dr.requestid - AND gru.isactive = 1 - AND gru.isdelete = 0 - WHERE dr.required_date = ? - AND dr.isactive = 1 - AND dr.isdelete = 0 - - ) final_output - ORDER BY driverid ASC - """; - - Object[] params = new Object[] { - date, // location-wise join - date // total row - }; - - return jdbcTemplate.queryForList(sql, params); - } - -} - -/* - * String sql = "SELECT lm.location AS LocationDescription, "+ - * "dl.username AS DriverName, "+ - * " CONCAT('" - * +fileBaseUrl+"/gccofficialapp/files',dss_start.image) as upload_image_url, "+ - * " CONCAT(dss_start.latitude, ', ', dss_start.longitude) AS StartPoint, "+ - * "Date(dss_start.datetime) AS StartTime, "+ - * - * " CONCAT(dss_stop.latitude, ', ', dss_stop.longitude) AS EndPoint, "+ - * Date(dss_stop.datetime) AS EndTime - * - * FROM location_mapping lm - * INNER JOIN driver_login dl - * ON dl.loginid = lm.driverid - * - * LEFT JOIN driver_start_stop dss_start - * ON dss_start.loginid = lm.driverid - * AND dss_start.action = 'Start' - * - * - * LEFT JOIN driver_start_stop dss_stop - * ON dss_stop.loginid = lm.driverid - * AND dss_stop.action = 'Stop' - * AND dss_stop.startid = dss_start.locationid - * WHERE DATE(dss_start.datetime) = ?"; - * change for full query - */ \ No newline at end of file diff --git a/src/main/resources/templates/modules/food_scheme/driverreport.html b/src/main/resources/templates/modules/food_scheme/driverreport.html deleted file mode 100644 index 2efef0c..0000000 --- a/src/main/resources/templates/modules/food_scheme/driverreport.html +++ /dev/null @@ -1,430 +0,0 @@ - - - - - Food Scheme Operations Dashboard - - - - - - - - - - - - - - -
-

Food Scheme Report

-
- - - -
-
- -
-
Driver Logistics Report
- - -
- - -
- - -
- - -
- - -
- - -
- - -
- -
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/modules/food_scheme/feedbackreport.html b/src/main/resources/templates/modules/food_scheme/feedbackreport.html deleted file mode 100644 index 44ce2bf..0000000 --- a/src/main/resources/templates/modules/food_scheme/feedbackreport.html +++ /dev/null @@ -1,706 +0,0 @@ - - - - - Feedback Summary Report - - - - - - - - - -
-

Food Scheme – Feedback Summary

-
- -
-
- -
-
Feedback Summary
- -
- - -
-
- -
- -
-
Feedback - Food Distribution Time
- - - - - - - - - -
CategoryCount
-
- -
-
Feedback - Food Taste
- - - - - - - - -
CategoryCount
-
- -
-
Feedback - Food Quantity
- - - - - - - - -
CategoryCount
-
- -
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/modules/food_scheme/foodschemereport.html b/src/main/resources/templates/modules/food_scheme/foodschemereport.html deleted file mode 100644 index cd035e3..0000000 --- a/src/main/resources/templates/modules/food_scheme/foodschemereport.html +++ /dev/null @@ -1,1520 +0,0 @@ - - - - - - - - Food Distribution Operations Dashboard - - - - - - - - - - - - - - -
-

Food Distribution Report

-
- - - -
-
-
Shift Wise Overview
- -
- - - - - - - -
- - -
- - - - - - - - - - - - - - - - - -
ShiftTotal ComplementWeekly OffPlanned LeavePresent CountFood RequestedFood DeliveredFood Shortfall
-
-
- - - -
-
-
Shift A - Daily Food Menu
- - - - - - - - - - - - - - - - - - - - - - - - - -
SundayMondayTuesdayWednesdayThursdayFridaySaturday
Sambar Rice (650g) & Porial (100g)Lemon Rice (5000g) & Potato/yam/Raw banana fry (100g)Veg Biryani (500g) & Brinjal Onion (75g)Tomato Rice (500g) & Potato/yam/Raw banana fry (100g)Coriander/Mint Rice (500g) & Potato/yam/Raw banana fry (100g)Tamarind Rice (500g) & Potato/yam/Raw banana fry (100g)Veg Biryani (500g) & Brinjal Onion (75g)
- -
-
- - - - - - - - - -
-
- - - - -
-
-
-
Zone wise Overallview
- -
- - -
- - - - - - - - - - - - - - -
zoneTotal Complementweekly OffPlanned LeavePresent CountFood RequestedFood DeliveredFood Shortfall
-
-
- - - -
-
-
-
Overall Location wise Overview
-
Select Zone:
- - -
- - - - - - - -
-
- - - - - - - - - - - - - - - - -
ZoneWardLocationsTotal Complementweekly OffPlanned LeavePresent CountFood RequestedFood DeliveredFood Shortfall
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file