You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
6.7 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. package in.gov.chennaicorporation.gccoffice.callcenter.service;
  2. import java.util.List;
  3. import java.util.Map;
  4. import javax.sql.DataSource;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.beans.factory.annotation.Qualifier;
  7. import org.springframework.jdbc.core.JdbcTemplate;
  8. import org.springframework.stereotype.Service;
  9. @Service
  10. public class AttendanceService {
  11. // private JdbcTemplate jdbcTemplate;
  12. //
  13. //
  14. // @Autowired
  15. // public void setDataSource(@Qualifier("BiometricDataSource") DataSource dataSource) {
  16. // this.jdbcTemplate = new JdbcTemplate(dataSource);
  17. // }
  18. //
  19. //
  20. // public List<Map<String, Object>> getAttendanceReport(String fromDate, String toDate) {
  21. // String reportQuery;
  22. //
  23. // if (fromDate != null && toDate != null) {
  24. // // Query with date filter if dates are provided
  25. // reportQuery = "SELECT d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, " +
  26. // "c.device_name, CAST(a.officepunch AS DATE) AS punch_date, MIN(a.OFFICEPUNCH) AS PUNCHIN, " +
  27. // "CASE WHEN MAX(a.OFFICEPUNCH) = MIN(a.OFFICEPUNCH) THEN NULL ELSE MAX(a.OFFICEPUNCH) END AS PUNCHOUT " +
  28. // "FROM machinerawpunch a, tbl_realtime_userinfo b, tbl_fkdevice_status c, zone_div_mast d, " +
  29. // "tblemployee e, tbldepartment f " +
  30. // "WHERE a.paycode = b.user_id AND a.deviceid = c.device_id AND c.device_name = d.devname " +
  31. // "AND a.paycode = e.paycode AND e.departmentcode = f.departmentcode " +
  32. // "AND CAST(a.officepunch AS DATE) BETWEEN ? AND ? " +
  33. // "AND a.paycode LIKE '%19130%' " +
  34. // "GROUP BY d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, " +
  35. // "c.device_name, CAST(a.officepunch AS DATE) " +
  36. // "ORDER BY d.zone, d.division, b.user_id, CAST(a.officepunch AS DATE)";
  37. //
  38. // // Execute query with date parameters
  39. // return jdbcTemplate.queryForList(reportQuery, fromDate, toDate);
  40. //
  41. // } else {
  42. // // Query without date filter
  43. // reportQuery = "SELECT d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, " +
  44. // "c.device_name, CAST(a.officepunch AS DATE) AS punch_date, MIN(a.OFFICEPUNCH) AS PUNCHIN, " +
  45. // "CASE WHEN MAX(a.OFFICEPUNCH) = MIN(a.OFFICEPUNCH) THEN NULL ELSE MAX(a.OFFICEPUNCH) END AS PUNCHOUT " +
  46. // "FROM machinerawpunch a, tbl_realtime_userinfo b, tbl_fkdevice_status c, zone_div_mast d, " +
  47. // "tblemployee e, tbldepartment f " +
  48. // "WHERE a.paycode = b.user_id AND a.deviceid = c.device_id AND c.device_name = d.devname " +
  49. // "AND a.paycode = e.paycode AND e.departmentcode = f.departmentcode " +
  50. // "AND a.paycode LIKE '%19130%' " +
  51. // "GROUP BY d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, " +
  52. // "c.device_name, CAST(a.officepunch AS DATE) " +
  53. // "ORDER BY d.zone, d.division, b.user_id, CAST(a.officepunch AS DATE)";
  54. //
  55. // // Execute query without date parameters
  56. // return jdbcTemplate.queryForList(reportQuery);
  57. // }
  58. // }
  59. //
  60. //
  61. //
  62. //// public List<Map<String, Object>> getAttendanceReport(String fromDate, String toDate) {
  63. //// System.out.println("Service Layer: Generating attendance report");
  64. ////
  65. //// String reportQuery = "SELECT d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, c.device_name, " +
  66. //// "CAST(a.officepunch AS DATE) AS punch_date, MIN(a.OFFICEPUNCH) AS PUNCHIN, " +
  67. //// "CASE WHEN MAX(a.OFFICEPUNCH) = MIN(a.OFFICEPUNCH) THEN NULL ELSE MAX(a.OFFICEPUNCH) END AS PUNCHOUT " +
  68. //// "FROM machinerawpunch a, tbl_realtime_userinfo b, tbl_fkdevice_status c, zone_div_mast d, " +
  69. //// "tblemployee e, tbldepartment f " +
  70. //// "WHERE a.paycode = b.user_id AND a.deviceid = c.device_id AND c.device_name = d.devname " +
  71. //// "AND a.paycode = e.paycode AND e.departmentcode = f.departmentcode ";
  72. ////
  73. //// // Dynamic date filter
  74. //// if (fromDate != null && toDate != null) {
  75. //// reportQuery += "AND CAST(a.officepunch AS DATE) BETWEEN ? AND ? ";
  76. //// } else if (fromDate != null) {
  77. //// reportQuery += "AND CAST(a.officepunch AS DATE) = ? ";
  78. //// } else {
  79. //// throw new IllegalArgumentException("fromDate or toDate must be provided");
  80. //// }
  81. ////
  82. //// reportQuery += "AND a.paycode LIKE '%19130%' " +
  83. //// "GROUP BY d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, c.device_name, " +
  84. //// "CAST(a.officepunch AS DATE) " +
  85. //// "ORDER BY d.zone, d.division, b.user_id, CAST(a.officepunch AS DATE)";
  86. ////
  87. //// // Execute query based on dates
  88. //// if (fromDate != null && toDate != null) {
  89. //// return jdbcTemplate.queryForList(reportQuery, fromDate, toDate);
  90. //// } else {
  91. //// return jdbcTemplate.queryForList(reportQuery, fromDate);
  92. //// }
  93. //// }
  94. //
  95. //// public List<Map<String, Object>> getAttendanceReport() {
  96. //// System.out.println("check 2");
  97. //// String reportQuery ="SELECT d.zone,d.division,b.user_id,b.user_name,f.departmentname,e.designation,c.device_name,CAST(a.officepunch AS DATE) as punch_date,MIN(a.OFFICEPUNCH) AS PUNCHIN,\r\n"
  98. //// + "CASE WHEN MAX(a.OFFICEPUNCH) = MIN(a.OFFICEPUNCH) THEN NULL ELSE MAX(a.OFFICEPUNCH) END AS PUNCHOUT FROM machinerawpunch a,tbl_realtime_userinfo b,tbl_fkdevice_status c,\r\n"
  99. //// + "zone_div_mast d,tblemployee e,tbldepartment f WHERE a.paycode = b.user_id AND a.deviceid = c.device_id AND c.device_name = d.devname AND a.paycode = e.paycode AND \r\n"
  100. //// + "e.departmentcode = f.departmentcode AND CAST(officepunch AS DATE) BETWEEN '2024-10-01' AND '2024-10-10'\r\n"
  101. //// + "AND a.paycode LIKE '%19130%' \r\n"
  102. //// + "GROUP BY d.zone,d.division,b.user_id,b.user_name,f.departmentname,e.designation,c.device_name,CAST(a.officepunch AS DATE)\r\n"
  103. //// + "ORDER BY d.zone,d.division,b.user_id,CAST(a.officepunch AS DATE)";
  104. //// System.out.println("check 3");
  105. //// List<Map<String,Object>> reports = jdbcTemplate.queryForList(reportQuery);
  106. //// System.out.println("check 4");
  107. //// return reports;
  108. //// }
  109. }