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.

214 lines
11 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. public class DepartmentForwardService {
  15. @Autowired
  16. private JdbcTemplate jdbcTemplate;
  17. private RestTemplate restTemplate;
  18. private ObjectMapper objectMapper;
  19. @Autowired
  20. private AppConfig appconfig;
  21. public DepartmentForwardService(RestTemplate restTemplate, ObjectMapper objectMapper) {
  22. this.restTemplate = restTemplate;
  23. this.objectMapper = objectMapper;
  24. }
  25. @Autowired
  26. public void setDataSource(@Qualifier("mysqlPensionerDataSource") DataSource dataSource) {
  27. this.jdbcTemplate = new JdbcTemplate(dataSource);
  28. }
  29. public List<Map<String, Object>> fetchDepatmentForwardEmpfiles(Integer file_cat) {
  30. String query = "SELECT * " +
  31. "FROM pensioner_details " +
  32. "WHERE file_status=4 AND file_category=? AND is_closed=0";
  33. return jdbcTemplate.queryForList(query,file_cat);
  34. }
  35. @Transactional
  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 = 5;
  46. String updateQuery = "UPDATE pensioner_details SET file_status = ?,file_moved_date=?,remarks=?,updated_date= CURRENT_TIMESTAMP WHERE temp_id = ? LIMIT 1";
  47. int rowsUpdated = jdbcTemplate.update(updateQuery,filestatus,dateToAudit, remarks,tempId);
  48. System.out.println("Rows inserted in pd:"+rowsUpdated);
  49. if(rowsUpdated>0)
  50. {
  51. // Optional: Insert into file movement history for auditing
  52. String historyQuery = "INSERT INTO file_movement_history (emp_no, file_moved_date, file_status, file_moved_by, remarks,temp_id) VALUES (?,?, ?, ?, ?, ?)";
  53. int rowsUpdated1=jdbcTemplate.update(historyQuery, empNo, dateToAudit, filestatus, filemovedby, remarks,tempId);
  54. System.out.println("Rows inserted in fmh:"+rowsUpdated1);
  55. return true;
  56. }
  57. else {
  58. return false;
  59. }
  60. }
  61. @Transactional
  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. //save the updatedfamilypensionReturn
  99. @Transactional
  100. public boolean saveFamilyPensionForwardHistory(List<Map<String, Object>> emp_details,String filemovedby) {
  101. try {
  102. // Loop through the list of employee details
  103. for (Map<String, Object> emp : emp_details) {
  104. // Extract individual fields from the map
  105. String empNo = emp.get("emp_no").toString();
  106. String empName = emp.get("emp_name").toString();
  107. String deptName = emp.get("dept_name").toString();
  108. String designation = emp.get("designation").toString();
  109. String fileCategoryName = emp.get("file_category_name").toString();
  110. String pendingDuration=emp.get("pending_duration").toString();
  111. String pendingReason=emp.get("reason_for_pending") != null ? emp.get("reason_for_pending").toString() : null;
  112. String sericeDeath = emp.get("service_death").toString();
  113. String relationshipDeceased = emp.get("relationship_deceased").toString();
  114. String sanctionedGis = emp.get("sanctioned_gis_amount").toString();
  115. String fileMovedDate = emp.get("file_moved_date").toString();
  116. String remarks = emp.get("remarks").toString();
  117. int fileStatus = Integer.parseInt(emp.get("file_status").toString());
  118. String fileEntryType = emp.get("file_entry_type").toString();
  119. int file_category = Integer.parseInt(emp.get("file_category").toString());
  120. int dept_id = Integer.parseInt(emp.get("dept_id").toString());
  121. String temp_id = emp.get("temp_id").toString();
  122. // Prepare the insert query
  123. 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 (?,?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?)";
  124. // Execute the query
  125. int rowsInserted = jdbcTemplate.update(insertQuery, empNo, empName, deptName,designation,sericeDeath,relationshipDeceased,sanctionedGis,fileMovedDate,remarks,file_category,fileStatus,fileEntryType,filemovedby,dept_id,fileCategoryName,temp_id,pendingDuration,pendingReason);
  126. System.out.println("Rows inserted in pdh:"+rowsInserted);
  127. // Check if the insertion was successful
  128. if (rowsInserted <= 0) {
  129. return false; // Return false if any insertion fails
  130. }
  131. }
  132. return true; // Return true if all insertions succeed
  133. } catch (Exception e) {
  134. e.printStackTrace();
  135. return false; // Return false in case of any exception
  136. }
  137. }
  138. //update save pendency history
  139. @Transactional
  140. public boolean savePendencyForwardHistory(List<Map<String, Object>> emp_details,String filemovedby) {
  141. try {
  142. // Loop through the list of employee details
  143. for (Map<String, Object> emp : emp_details) {
  144. // Extract individual fields from the map
  145. String empNo = emp.get("emp_no").toString();
  146. String empName = emp.get("emp_name").toString();
  147. String deptName = emp.get("dept_name").toString();
  148. String designation = emp.get("designation").toString();
  149. String retirementClass = emp.get("retirement_class").toString();
  150. String retirementDate=emp.get("retirement_date").toString();
  151. //String fileCategoryName = emp.get("file_category_name").toString();
  152. String pendingDuration=emp.get("pending_duration").toString();
  153. String pendingReason=emp.get("reason_for_pending") != null ? emp.get("reason_for_pending").toString() : null;
  154. String typeOfCategory=emp.get("file_category_name").toString();
  155. String typeOfRetirement=emp.get("type_of_retirement").toString();
  156. String fileMovedDate = emp.get("file_moved_date").toString();
  157. String remarks = emp.get("remarks").toString();
  158. int fileStatus = Integer.parseInt(emp.get("file_status").toString());
  159. String fileEntryType = emp.get("file_entry_type").toString();
  160. int file_category = Integer.parseInt(emp.get("file_category").toString());
  161. int dept_id = Integer.parseInt(emp.get("dept_id").toString());
  162. String temp_id = emp.get("temp_id").toString();
  163. // Prepare the insert query
  164. 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 (?,?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?)";
  165. // Execute the query
  166. 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);
  167. System.out.println("Rows inserted in pdh:"+rowsInserted);
  168. // Check if the insertion was successful
  169. if (rowsInserted <= 0) {
  170. return false; // Return false if any insertion fails
  171. }
  172. }
  173. return true; // Return true if all insertions succeed
  174. } catch (Exception e) {
  175. e.printStackTrace();
  176. return false; // Return false in case of any exception
  177. }
  178. }
  179. }