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.

228 lines
12 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. package in.gov.chennaicorporation.gccoffice.pensioner.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. import org.springframework.transaction.annotation.Transactional;
  10. import org.springframework.web.client.RestTemplate;
  11. import com.fasterxml.jackson.databind.ObjectMapper;
  12. import in.gov.chennaicorporation.gccoffice.configuration.AppConfig;
  13. @Service
  14. @Transactional
  15. public class PensionAuditService {
  16. @Autowired
  17. private JdbcTemplate jdbcTemplate;
  18. private RestTemplate restTemplate;
  19. private ObjectMapper objectMapper;
  20. @Autowired
  21. private AppConfig appconfig;
  22. public PensionAuditService(RestTemplate restTemplate, ObjectMapper objectMapper) {
  23. this.restTemplate = restTemplate;
  24. this.objectMapper = objectMapper;
  25. }
  26. @Autowired
  27. public void setDataSource(@Qualifier("mysqlPensionerDataSource") DataSource dataSource) {
  28. this.jdbcTemplate = new JdbcTemplate(dataSource);
  29. }
  30. public List<Map<String, Object>> fetchDetailsForAudit(Integer file_cat) {
  31. String query = "SELECT * " +
  32. "FROM pensioner_details " +
  33. "WHERE file_category=? AND (file_status=1 OR file_status=3) AND is_closed=0";
  34. return jdbcTemplate.queryForList(query,file_cat);
  35. }
  36. public boolean updateEntryDetails(Map<String, Object> requestData) {
  37. // TODO Auto-generated method stub
  38. String empNo = (String) requestData.get("empNo");
  39. String tempId = (String) requestData.get("tempId");
  40. String dateToAudit = (String) requestData.get("dateToAudit");
  41. String filemovedby =(String)requestData.get("filemovedby");
  42. String remarks = (String) requestData.get("remarks");
  43. String dept_Id = (String) requestData.get("deptId");
  44. int deptId = Integer.parseInt(dept_Id);
  45. int filestatus = 4;
  46. String file_entry_type="AUDIT_CLEARED";
  47. String updateQuery = "UPDATE pensioner_details SET file_status = ?,file_entry_type=?,file_moved_date=?,remarks=?,updated_date= CURRENT_TIMESTAMP WHERE temp_id = ? LIMIT 1";
  48. int rowsUpdated = jdbcTemplate.update(updateQuery,filestatus,file_entry_type,dateToAudit, remarks,tempId);
  49. System.out.println("Rows inserted in pd:"+rowsUpdated);
  50. if(rowsUpdated>0)
  51. {
  52. // Optional: Insert into file movement history for auditing
  53. String historyQuery = "INSERT INTO file_movement_history (emp_no, file_moved_date, file_status, file_moved_by, remarks,temp_id) VALUES (?,?, ?, ?, ?, ?)";
  54. int rowsUpdated1=jdbcTemplate.update(historyQuery, empNo, dateToAudit, filestatus, filemovedby, remarks,tempId);
  55. System.out.println("Rows inserted in fmh:"+rowsUpdated1);
  56. return true;
  57. }
  58. else {
  59. return false;
  60. }
  61. }
  62. public boolean savehistory(List<Map<String, Object>> emp_details,String filemovedby) {
  63. try {
  64. // Loop through the list of employee details
  65. for (Map<String, Object> emp : emp_details) {
  66. // Extract individual fields from the map
  67. String empNo = emp.get("emp_no").toString();
  68. String empName = emp.get("emp_name").toString();
  69. String deptName = emp.get("dept_name").toString();
  70. String designation = emp.get("designation").toString();
  71. String fileCategoryName = emp.get("file_category_name").toString();
  72. String retirement_date = emp.get("retirement_date").toString();
  73. String retirement_class = emp.get("retirement_class").toString();
  74. String type_of_retirement = emp.get("type_of_retirement").toString();
  75. String fileMovedDate = emp.get("file_moved_date").toString();
  76. String remarks = emp.get("remarks").toString();
  77. int fileStatus = Integer.parseInt(emp.get("file_status").toString());
  78. String fileEntryType = emp.get("file_entry_type").toString();
  79. int file_category = Integer.parseInt(emp.get("file_category").toString());
  80. int dept_id = Integer.parseInt(emp.get("dept_id").toString());
  81. String temp_id = emp.get("temp_id").toString();
  82. // Prepare the insert query
  83. String insertQuery ="INSERT INTO pensioner_details_history (emp_no, emp_name, dept_name, designation, type_of_retirement,retirement_date ,retirement_class,file_moved_date, remarks,file_category,file_status,file_entry_type,file_moved_by,dept_id,file_category_name,temp_id) VALUES (?,?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?)";
  84. // Execute the query
  85. int rowsInserted = jdbcTemplate.update(insertQuery, empNo, empName, deptName,designation,type_of_retirement,retirement_date,retirement_class,fileMovedDate,remarks,file_category,fileStatus,fileEntryType,filemovedby,dept_id,fileCategoryName,temp_id);
  86. System.out.println("Rows inserted in pdh:"+rowsInserted);
  87. // Check if the insertion was successful
  88. if (rowsInserted <= 0) {
  89. return false; // Return false if any insertion fails
  90. }
  91. }
  92. return true; // Return true if all insertions succeed
  93. } catch (Exception e) {
  94. e.printStackTrace();
  95. return false; // Return false in case of any exception
  96. }
  97. }
  98. //gis
  99. public List<Map<String, Object>> fetchDetailsForrecivedGis(Integer file_cat) {
  100. String query = "SELECT * FROM pensioner_details WHERE file_category = ? AND file_status = 7";
  101. return jdbcTemplate.queryForList(query,file_cat);
  102. }
  103. public boolean saveFamilyPensionHistory(List<Map<String, Object>> emp_details,String filemovedby) {
  104. try {
  105. // Loop through the list of employee details
  106. for (Map<String, Object> emp : emp_details) {
  107. // Extract individual fields from the map
  108. String empNo = emp.get("emp_no").toString();
  109. String empName = emp.get("emp_name").toString();
  110. String deptName = emp.get("dept_name").toString();
  111. String designation = emp.get("designation").toString();
  112. String fileCategoryName = emp.get("file_category_name").toString();
  113. String pendingDuration=emp.get("pending_duration").toString();
  114. String pendingReason=emp.get("reason_for_pending") != null ? emp.get("reason_for_pending").toString() : null;
  115. String serviceDeath = emp.get("service_death").toString();
  116. String relationshipDeceased = emp.get("relationship_deceased").toString();
  117. String sanctionedGis = emp.get("sanctioned_gis_amount").toString();
  118. String fileMovedDate = emp.get("file_moved_date").toString();
  119. String remarks = emp.get("remarks").toString();
  120. int fileStatus = Integer.parseInt(emp.get("file_status").toString());
  121. String fileEntryType = emp.get("file_entry_type").toString();
  122. int file_category = Integer.parseInt(emp.get("file_category").toString());
  123. int dept_id = Integer.parseInt(emp.get("dept_id").toString());
  124. String temp_id = emp.get("temp_id").toString();
  125. // Prepare the insert query
  126. String insertQuery ="INSERT INTO pensioner_details_history (emp_no, emp_name, dept_name, designation, service_death,relationship_deceased ,sanctioned_gis_amount,file_moved_date, remarks,file_category,file_status,file_entry_type,file_moved_by,dept_id,file_category_name,temp_id,pending_duration,reason_for_pending) VALUES (?,?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?)";
  127. // Execute the query
  128. int rowsInserted = jdbcTemplate.update(insertQuery, empNo, empName, deptName,designation,serviceDeath,relationshipDeceased,sanctionedGis,fileMovedDate,remarks,file_category,fileStatus,fileEntryType,filemovedby,dept_id,fileCategoryName,temp_id,pendingDuration,pendingReason);
  129. System.out.println("Rows inserted in pdh:"+rowsInserted);
  130. // Check if the insertion was successful
  131. if (rowsInserted <= 0) {
  132. return false; // Return false if any insertion fails
  133. }
  134. }
  135. return true; // Return true if all insertions succeed
  136. } catch (Exception e) {
  137. e.printStackTrace();
  138. return false; // Return false in case of any exception
  139. }
  140. }
  141. public boolean savePendencyHistory(List<Map<String, Object>> emp_details,String filemovedby) {
  142. try {
  143. // Loop through the list of employee details
  144. for (Map<String, Object> emp : emp_details) {
  145. // Extract individual fields from the map
  146. String empNo = emp.get("emp_no").toString();
  147. String empName = emp.get("emp_name").toString();
  148. String deptName = emp.get("dept_name").toString();
  149. String designation = emp.get("designation").toString();
  150. String retirementClass = emp.get("retirement_class").toString();
  151. String retirementDate=emp.get("retirement_date").toString();
  152. //String fileCategoryName = emp.get("file_category_name").toString();
  153. String pendingDuration=emp.get("pending_duration").toString();
  154. String pendingReason=emp.get("reason_for_pending") != null ? emp.get("reason_for_pending").toString() : null;
  155. String typeOfCategory=emp.get("file_category_name").toString();
  156. String typeOfRetirement=emp.get("type_of_retirement").toString();
  157. String fileMovedDate = emp.get("file_moved_date").toString();
  158. String remarks = emp.get("remarks").toString();
  159. int fileStatus = Integer.parseInt(emp.get("file_status").toString());
  160. String fileEntryType = emp.get("file_entry_type").toString();
  161. int file_category = Integer.parseInt(emp.get("file_category").toString());
  162. int dept_id = Integer.parseInt(emp.get("dept_id").toString());
  163. String temp_id = emp.get("temp_id").toString();
  164. // Prepare the insert query
  165. String insertQuery ="INSERT INTO pensioner_details_history (emp_no, emp_name, dept_name, designation,retirement_class,retirement_date,file_category_name,type_of_retirement,file_moved_date, remarks,file_category,file_status,file_entry_type,file_moved_by,dept_id,temp_id,pending_duration,reason_for_pending) VALUES (?,?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?)";
  166. // Execute the query
  167. int rowsInserted = jdbcTemplate.update(insertQuery, empNo, empName, deptName,designation,retirementClass,retirementDate, typeOfCategory,typeOfRetirement,fileMovedDate,remarks,file_category,fileStatus,fileEntryType,filemovedby,dept_id,temp_id,pendingDuration,pendingReason);
  168. System.out.println("Rows inserted in pdh:"+rowsInserted);
  169. // Check if the insertion was successful
  170. if (rowsInserted <= 0) {
  171. return false; // Return false if any insertion fails
  172. }
  173. }
  174. return true; // Return true if all insertions succeed
  175. } catch (Exception e) {
  176. e.printStackTrace();
  177. return false; // Return false in case of any exception
  178. }
  179. }
  180. }