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.

895 lines
48 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
2 years ago
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
2 years ago
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
2 years ago
2 years ago
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
2 years ago
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
2 years ago
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
2 years ago
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
2 years ago
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
  1. package in.gov.chennaicorporation.gccoffice.pensioner.service;
  2. import java.text.ParseException;
  3. import java.text.SimpleDateFormat;
  4. import java.time.LocalDate;
  5. import java.time.LocalDateTime;
  6. import java.time.format.DateTimeFormatter;
  7. import java.time.format.DateTimeParseException;
  8. import java.util.ArrayList;
  9. import java.util.Collections;
  10. import java.util.HashMap;
  11. import java.util.List;
  12. import java.util.Map;
  13. import javax.sql.DataSource;
  14. import java.util.Comparator;
  15. import java.util.Date;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.beans.factory.annotation.Qualifier;
  18. import org.springframework.dao.EmptyResultDataAccessException;
  19. import org.springframework.jdbc.core.JdbcTemplate;
  20. import org.springframework.stereotype.Service;
  21. import org.springframework.transaction.annotation.Transactional;
  22. import org.springframework.web.client.RestTemplate;
  23. import com.fasterxml.jackson.databind.JsonNode;
  24. import com.fasterxml.jackson.databind.ObjectMapper;
  25. import in.gov.chennaicorporation.gccoffice.configuration.AppConfig;
  26. @Service
  27. public class NewEntryService {
  28. @Autowired
  29. private JdbcTemplate jdbcTemplate;
  30. private RestTemplate restTemplate;
  31. private ObjectMapper objectMapper;
  32. @Autowired
  33. private AppConfig appconfig;
  34. public NewEntryService(RestTemplate restTemplate, ObjectMapper objectMapper) {
  35. this.restTemplate = restTemplate;
  36. this.objectMapper = objectMapper;
  37. }
  38. @Autowired
  39. public void setDataSource(@Qualifier("mysqlPensionerDataSource") DataSource dataSource) {
  40. this.jdbcTemplate = new JdbcTemplate(dataSource);
  41. }
  42. @Autowired
  43. public GetFileStatusService getFileStatus;
  44. // old retiment list getting method
  45. // public Map<String, Object> fetchEmplyeeDetails(String fromDate, String toDate, Integer deptId) {
  46. // Map<String, Object> response = new HashMap<>();
  47. //
  48. // String apiUrl = appconfig.qaqcurl + "serviceId=common_api"
  49. // + "&jsonResp=Yes"
  50. // + "&subService=getEmpPenDetDuration"
  51. // + "&fromDate=" + fromDate
  52. // + "&toDate=" + toDate
  53. // + "&deptId=" + deptId;
  54. //
  55. // System.out.println("url: " + apiUrl);
  56. // System.out.println("deptId:" + deptId);
  57. // try {
  58. // String rawResponse = restTemplate.getForObject(apiUrl, String.class);
  59. // System.out.println("Raw Response: " + rawResponse); // Debugging step
  60. //
  61. // if (isValidJson(rawResponse)) {
  62. // JsonNode jsonResponse = objectMapper.readTree(rawResponse);
  63. //
  64. // // Extract the "ListResult" array
  65. // JsonNode details = jsonResponse.path("ListResult");
  66. //
  67. // if (details.isArray() && details.size() > 0) {
  68. // List<Map<String, String>> list = new ArrayList<>();
  69. // for (JsonNode detail : details) {
  70. // Map<String, String> listResult = new HashMap<>();
  71. //
  72. // listResult.put("RETIREMENT_DATE", getNonNullValue(detail.path("RETIREMENT_DATE")));
  73. // listResult.put("DEATH_DATE", getNonNullValue(detail.path("DEATH_DATE")));
  74. // listResult.put("COMMUNITY_NAME", getNonNullValue(detail.path("COMMUNITY_NAME")));
  75. // listResult.put("GROUP_TYPE", getNonNullValue(detail.path("GROUP_TYPE")));
  76. // listResult.put("ID_DEPT", getNonNullValue(detail.path("ID_DEPT")));
  77. // listResult.put("EMPLOYEE_CODE", getNonNullValue(detail.path("EMPLOYEE_CODE")));
  78. // listResult.put("FUNCTIONARY", getNonNullValue(detail.path("FUNCTIONARY")));
  79. // listResult.put("IS_HANDICAPPED", getNonNullValue(detail.path("IS_HANDICAPPED")));
  80. // listResult.put("GENDER", getNonNullValue(detail.path("GENDER")));
  81. // listResult.put("DATE_OF_BIRTH", getNonNullValue(detail.path("DATE_OF_BIRTH")));
  82. // listResult.put("DATE_OF_APPOINTMENT", getNonNullValue(detail.path("DATE_OF_APPOINTMENT")));
  83. // listResult.put("DESIGNATION", getNonNullValue(detail.path("DESIGNATION")));
  84. // listResult.put("EMPLOYEE_NAME", getNonNullValue(detail.path("EMPLOYEE_NAME")));
  85. // listResult.put("DEPARTMENT", getNonNullValue(detail.path("DEPARTMENT")));
  86. // list.add(listResult);
  87. // }
  88. // // Sort the list by RETIREMENT_DATE in ascending order
  89. // list.sort(Comparator.comparing(map -> parseDate(((Map<String, String>) map).get("RETIREMENT_DATE"))));
  90. //
  91. // response.put("list", list);
  92. //
  93. // } else {
  94. // response.put("list", Collections.emptyList());
  95. // }
  96. // } else {
  97. // System.err.println("Invalid JSON Response: " + rawResponse);
  98. // response.put("list", Collections.emptyList());
  99. // }
  100. //
  101. // } catch (Exception e) {
  102. // e.printStackTrace();
  103. // response.put("list", Collections.emptyList());
  104. // }
  105. // return response;
  106. // }
  107. // new retirement list getting method with condition
  108. public Map<String, Object> fetchEmplyeeDetails(String fromDate, String toDate, Integer deptId) {
  109. Map<String, Object> response = new HashMap<>();
  110. String apiUrl = appconfig.qaqcurl + "serviceId=common_api"
  111. + "&jsonResp=Yes"
  112. + "&subService=getEmpPenDetDuration"
  113. + "&fromDate=" + fromDate
  114. + "&toDate=" + toDate
  115. + "&deptId=" + deptId;
  116. System.out.println("url: " + apiUrl);
  117. System.out.println("deptId:" + deptId);
  118. try {
  119. String rawResponse = restTemplate.getForObject(apiUrl, String.class);
  120. System.out.println("Raw Response: " + rawResponse); // Debugging step
  121. if (isValidJson(rawResponse)) {
  122. JsonNode jsonResponse = objectMapper.readTree(rawResponse);
  123. JsonNode details = jsonResponse.path("ListResult");
  124. if (details.isArray() && details.size() > 0) {
  125. List<Map<String, String>> list = new ArrayList<>();
  126. LocalDate currentDate = LocalDate.now(); // Get today's date
  127. for (JsonNode detail : details) {
  128. String retirementDateStr = getNonNullValue(detail.path("RETIREMENT_DATE"));
  129. LocalDate retirementDate = parseDate(retirementDateStr);
  130. // Only add to the list if RETIREMENT_DATE is today or in the future
  131. if (retirementDate != null && !retirementDate.isBefore(currentDate)) {
  132. Map<String, String> listResult = new HashMap<>();
  133. listResult.put("RETIREMENT_DATE", retirementDateStr);
  134. listResult.put("DEATH_DATE", getNonNullValue(detail.path("DEATH_DATE")));
  135. listResult.put("COMMUNITY_NAME", getNonNullValue(detail.path("COMMUNITY_NAME")));
  136. listResult.put("GROUP_TYPE", getNonNullValue(detail.path("GROUP_TYPE")));
  137. listResult.put("ID_DEPT", getNonNullValue(detail.path("ID_DEPT")));
  138. listResult.put("EMPLOYEE_CODE", getNonNullValue(detail.path("EMPLOYEE_CODE")));
  139. listResult.put("FUNCTIONARY", getNonNullValue(detail.path("FUNCTIONARY")));
  140. listResult.put("IS_HANDICAPPED", getNonNullValue(detail.path("IS_HANDICAPPED")));
  141. listResult.put("GENDER", getNonNullValue(detail.path("GENDER")));
  142. listResult.put("DATE_OF_BIRTH", getNonNullValue(detail.path("DATE_OF_BIRTH")));
  143. listResult.put("DATE_OF_APPOINTMENT", getNonNullValue(detail.path("DATE_OF_APPOINTMENT")));
  144. listResult.put("DESIGNATION", getNonNullValue(detail.path("DESIGNATION")));
  145. listResult.put("EMPLOYEE_NAME", getNonNullValue(detail.path("EMPLOYEE_NAME")));
  146. listResult.put("DEPARTMENT", getNonNullValue(detail.path("DEPARTMENT")));
  147. list.add(listResult);
  148. }
  149. }
  150. // Sort the list by RETIREMENT_DATE in ascending order
  151. list.sort(Comparator.comparing(map -> parseDate(map.get("RETIREMENT_DATE"))));
  152. response.put("list", list);
  153. } else {
  154. response.put("list", Collections.emptyList());
  155. }
  156. } else {
  157. System.err.println("Invalid JSON Response: " + rawResponse);
  158. response.put("list", Collections.emptyList());
  159. }
  160. } catch (Exception e) {
  161. e.printStackTrace();
  162. response.put("list", Collections.emptyList());
  163. }
  164. return response;
  165. }
  166. public Map<String, Object> fetchEmplyeeDetailsbyCode(String empCode) {
  167. Map<String, Object> response = new HashMap<>();
  168. String apiUrl = appconfig.qaqcurl + "serviceId=common_api"
  169. + "&jsonResp=Yes"
  170. + "&subService=getEmpWorkDet"
  171. + "&empCode=" + empCode;
  172. System.out.println("url: " + apiUrl);
  173. System.out.println("empCode:" + empCode);
  174. try {
  175. String rawResponse = restTemplate.getForObject(apiUrl, String.class);
  176. System.out.println("Raw Response: " + rawResponse); // Debugging step
  177. if (isValidJson(rawResponse)) {
  178. JsonNode jsonResponse = objectMapper.readTree(rawResponse);
  179. // Extract the "ListResult" array
  180. JsonNode details = jsonResponse.path("ListResult");
  181. if (details.isArray() && details.size() > 0) {
  182. List<Map<String, String>> list = new ArrayList<>();
  183. for (JsonNode detail : details) {
  184. Map<String, String> listResult = new HashMap<>();
  185. listResult.put("RETIREMENT_DATE", formatToISODate(getNonNullValue(detail.path("RETIREMENT_DATE"))));
  186. listResult.put("TO_DATE", parseDate(getNonNullValue(detail.path("TO_DATE"))).toString());
  187. listResult.put("DEATH_DATE", getNonNullValue(detail.path("DEATH_DATE")));
  188. listResult.put("COMMUNITY_NAME", getNonNullValue(detail.path("COMMUNITY_NAME")));
  189. listResult.put("GROUP_TYPE", getNonNullValue(detail.path("GROUP_TYPE")));
  190. listResult.put("ID_DEPT", getNonNullValue(detail.path("ID_DEPT")));
  191. listResult.put("EMPLOYEE_CODE", getNonNullValue(detail.path("EMPLOYEE_CODE")));
  192. listResult.put("FUNCTIONARY", getNonNullValue(detail.path("FUNCTIONARY")));
  193. listResult.put("IS_HANDICAPPED", getNonNullValue(detail.path("IS_HANDICAPPED")));
  194. listResult.put("GENDER", getNonNullValue(detail.path("GENDER")));
  195. listResult.put("DATE_OF_BIRTH", getNonNullValue(detail.path("DATE_OF_BIRTH")));
  196. listResult.put("DATE_OF_APPOINTMENT", getNonNullValue(detail.path("DATE_OF_APPOINTMENT")));
  197. listResult.put("DESIGNATION", getNonNullValue(detail.path("DESIGNATION")));
  198. listResult.put("EMPLOYEE_NAME", getNonNullValue(detail.path("EMPLOYEE_NAME")));
  199. listResult.put("DEPARTMENT", getNonNullValue(detail.path("DEPARTMENT")));
  200. list.add(listResult);
  201. }
  202. // Sort the list by RETIREMENT_DATE in ascending order
  203. list.sort(Comparator.comparing(map -> parseDate(((Map<String, String>) map).get("RETIREMENT_DATE"))));
  204. response.put("list", list);
  205. System.out.println("listresult: "+list);
  206. } else {
  207. response.put("list", Collections.emptyList());
  208. }
  209. } else {
  210. System.err.println("Invalid JSON Response: " + rawResponse);
  211. response.put("list", Collections.emptyList());
  212. }
  213. } catch (Exception e) {
  214. e.printStackTrace();
  215. response.put("list", Collections.emptyList());
  216. }
  217. return response;
  218. }
  219. // Utility method to convert DD-MM-YYYY to YYYY-MM-DD
  220. private String formatToISODate(String date) {
  221. if (date == null || date.isEmpty()) {
  222. return "";
  223. }
  224. try {
  225. SimpleDateFormat inputFormat = new SimpleDateFormat("dd-MM-yyyy");
  226. SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd");
  227. Date parsedDate = inputFormat.parse(date);
  228. return outputFormat.format(parsedDate);
  229. } catch (ParseException e) {
  230. System.err.println("Date parsing error: " + e.getMessage());
  231. return date; // Return original date if parsing fails
  232. }
  233. }
  234. //getting deptId from login
  235. public Integer getloginuserDeptId(int userId) {
  236. String query = "select emp_dept_id from login_details where gcc_login_id = ?";
  237. try {
  238. // Use queryForObject to return a single value
  239. return jdbcTemplate.queryForObject(query, Integer.class, userId);
  240. } catch (EmptyResultDataAccessException e) {
  241. // Log the issue and handle the case when no result is found
  242. System.out.println("No department found for user ID: " + userId);
  243. return null; // Or return a default value if required
  244. }
  245. }
  246. private LocalDate parseDate(String date) {
  247. if (date == null || date.isEmpty()) {
  248. return LocalDate.MIN; // Use a minimum value for invalid or empty dates
  249. }
  250. try {
  251. // Remove time part if present
  252. if (date.contains(" ")) {
  253. date = date.split(" ")[0]; // Extract only the date part before space
  254. }
  255. DateTimeFormatter formatter;
  256. if (date.matches("\\d{4}-\\d{2}-\\d{2}")) { // yyyy-MM-dd
  257. formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
  258. } else if (date.matches("\\d{2}-\\d{2}-\\d{4}")) { // dd-MM-yyyy
  259. formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
  260. } else {
  261. System.err.println("Unknown date format: " + date);
  262. return LocalDate.MIN;
  263. }
  264. return LocalDate.parse(date, formatter);
  265. } catch (DateTimeParseException e) {
  266. e.printStackTrace();
  267. return LocalDate.MIN; // Fallback for invalid dates
  268. }
  269. }
  270. // private LocalDate parseDate(String date) {
  271. // if (date == null || date.isEmpty()) {
  272. // return LocalDate.MIN; // Use a minimum value for invalid or empty dates
  273. // }
  274. // try {
  275. // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); // Adjust format as needed
  276. // return LocalDate.parse(date, formatter);
  277. // } catch (DateTimeParseException e) {
  278. // e.printStackTrace();
  279. // return LocalDate.MIN; // Fallback for invalid dates
  280. // }
  281. // }
  282. private boolean isValidJson(String json) {
  283. try {
  284. objectMapper.readTree(json);
  285. return true;
  286. } catch (Exception e) {
  287. return false;
  288. }
  289. }
  290. private String getNonNullValue(JsonNode node) {
  291. //String value = node.isMissingNode() || node.isNull() || node.asText().isEmpty() ? "N/A" : node.asText();
  292. String value = node.isMissingNode() || node.isNull() || node.asText().isEmpty() || node.asText().isBlank() ? "N/A" : node.asText();
  293. //2024-565EAT
  294. return "null".equals(value) ? "N/A" : value; // Check for string "null"
  295. }
  296. public String getDeptNameById(Integer deptId) {
  297. String query = "SELECT dept_name FROM department_master WHERE dept_id=? AND isactive=1 AND isdelete=0";
  298. try {
  299. // Query execution and returning the department name
  300. //return jdbcTemplate.queryForObject(query, new Object[]{deptId}, String.class);
  301. return jdbcTemplate.queryForObject(query, String.class,deptId);
  302. } catch (Exception e) {
  303. // Handle exception if deptId is not found or query fails
  304. e.printStackTrace();
  305. return null;
  306. }
  307. }
  308. @Transactional
  309. public boolean saveRetirementEmployeeDetails(Map<String, Object> requestData) {
  310. try {
  311. String empNo = (String) requestData.get("empNo");
  312. String empName = (String) requestData.get("empName");
  313. String deptName = (String) requestData.get("deptName");
  314. String designation = (String) requestData.get("designation");
  315. String typeOfRetirement = (String) requestData.get("typeOfRetirement");
  316. String retirementdate = (String) requestData.get("retirementdate");
  317. String retirementclass = (String) requestData.get("retirementclass");
  318. String dateToAudit = (String) requestData.get("dateToAudit");
  319. String filemovedby =(String)requestData.get("filemovedby");
  320. String remarks = (String) requestData.get("remarks");
  321. String dept_Id = (String) requestData.get("deptId");
  322. String file_category = (String) requestData.get("filecategory");
  323. // Safely parse integer values
  324. int deptId;
  325. int filecategory;
  326. try {
  327. deptId = Integer.parseInt(dept_Id);
  328. filecategory = Integer.parseInt(file_category);
  329. } catch (NumberFormatException e) {
  330. System.out.println("Invalid number format for deptId or filecategory.");
  331. return false;
  332. }
  333. int filestatus = getFileStatus.getFileStatus1Id();
  334. if (filestatus == 0) {
  335. System.out.println("File status not found. Aborting insertion.");
  336. return false;
  337. }
  338. // Execute a query to fetch the required String based on filecategory
  339. String additionalDataQuery = "SELECT file_name FROM file_category_master WHERE id = ?";
  340. String fc_name = jdbcTemplate.queryForObject(additionalDataQuery,String.class,filecategory);
  341. System.out.println("fc_name==="+fc_name);
  342. String fileentrytype ="NEW";
  343. System.out.println("filemovedby====="+filemovedby);
  344. // Generate the variable (PR + current date + current time)
  345. String currentTimestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("ddMMyyHHmmss"));
  346. String temp_id = "PR" + currentTimestamp;
  347. String query = "INSERT INTO pensioner_details (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,dept_id,file_category_name,temp_id) VALUES (?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?)";
  348. int rowsInserted = jdbcTemplate.update(query, empNo, empName, deptName, designation, typeOfRetirement,retirementdate ,retirementclass,dateToAudit, remarks,filecategory,filestatus,fileentrytype,deptId,fc_name,temp_id);
  349. String query1 = "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 (?,?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?)";
  350. int rowsInsertedHistory = jdbcTemplate.update(query1, empNo, empName, deptName, designation, typeOfRetirement,retirementdate ,retirementclass,dateToAudit, remarks,filecategory,filestatus,fileentrytype,filemovedby,deptId,fc_name,temp_id);
  351. String query2 = "INSERT INTO file_movement_history (emp_no,file_moved_date,file_status,file_moved_by,remarks,temp_id) VALUES (?, ?, ?, ?, ?,?)";
  352. int rowsInsertedFileMovement = jdbcTemplate.update(query2, empNo,dateToAudit,filestatus,filemovedby,remarks,temp_id);
  353. return rowsInserted > 0 && rowsInsertedHistory > 0 && rowsInsertedFileMovement > 0;
  354. } catch (Exception e) {
  355. e.printStackTrace();
  356. return false; // Return false if an exception occurs
  357. }
  358. }
  359. public List<Map<String, Object>> getRegisteredEmps(Integer deptId,Integer file_category) {
  360. String query="select distinct emp_no from pensioner_details where dept_id=?";
  361. List<Map<String, Object>>emps= jdbcTemplate.queryForList(query,deptId);
  362. System.out.println("emps===="+emps);
  363. if(emps.isEmpty())
  364. {
  365. return Collections.emptyList();
  366. }
  367. else
  368. {
  369. return emps;
  370. }
  371. }
  372. public Integer getRetirementFileCategoryId() {
  373. String query = "SELECT id FROM file_category_master WHERE file_name = 'Retirement'";
  374. try {
  375. return jdbcTemplate.queryForObject(query, Integer.class);
  376. } catch (EmptyResultDataAccessException e) {
  377. return null; // or handle as needed
  378. }
  379. }
  380. public Integer getFamilyPensionFileCategoryId() {
  381. String query = "SELECT id FROM file_category_master WHERE file_name = 'Family Pension'";
  382. try {
  383. return jdbcTemplate.queryForObject(query, Integer.class);
  384. } catch (EmptyResultDataAccessException e) {
  385. return null; // or handle as needed
  386. }
  387. }
  388. public Integer getPendencyFileCategoryId() {
  389. String query = "SELECT id FROM file_category_master WHERE file_name = 'Pendency'";
  390. try {
  391. return jdbcTemplate.queryForObject(query, Integer.class);
  392. } catch (EmptyResultDataAccessException e) {
  393. return null; // or handle as needed
  394. }
  395. }
  396. public Integer getGISFileCategoryId() {
  397. String query = "SELECT id FROM file_category_master WHERE file_name = 'GIS'";
  398. try {
  399. return jdbcTemplate.queryForObject(query, Integer.class);
  400. } catch (EmptyResultDataAccessException e) {
  401. return null; // or handle as needed
  402. }
  403. }
  404. public Integer getPRFileCategoryId() {
  405. String query = "SELECT id FROM file_category_master WHERE file_name = 'Provisional Retirement'";
  406. try {
  407. return jdbcTemplate.queryForObject(query, Integer.class);
  408. } catch (EmptyResultDataAccessException e) {
  409. return null; // or handle as needed
  410. }
  411. }
  412. public Integer getCPSFileCategoryId() {
  413. String query = "SELECT id FROM file_category_master WHERE file_name = 'Contributory Pension Scheme'";
  414. try {
  415. return jdbcTemplate.queryForObject(query, Integer.class);
  416. } catch (EmptyResultDataAccessException e) {
  417. return null; // or handle as needed
  418. }
  419. }
  420. @Transactional
  421. public boolean saveFamilyPensionDetails(Map<String, Object> requestData) {
  422. try {
  423. // Extract data from the request body
  424. String empNo = (String) requestData.get("empNo");
  425. String empName = (String) requestData.get("empName");
  426. String deptName = (String) requestData.get("deptName");
  427. String designation = (String) requestData.get("designation");
  428. String sanctionedgis = (String) requestData.get("sanctionedgis");
  429. String serviceDeath =(String) requestData.get("serviceDeath");
  430. String deceased =(String) requestData.get("deceased");
  431. String dateToAudit = (String) requestData.get("dateToAudit");
  432. String remarks = (String) requestData.get("remarks");
  433. String filemovedby =(String)requestData.get("filemovedby");
  434. String pendingDuration = (String) requestData.get("pendingDuration");
  435. String reasonPending = (("yes".equals(pendingDuration) || "no".equals(pendingDuration))
  436. && requestData.get("reasonPending") != null) ? requestData.get("reasonPending").toString() : null;
  437. String dept_Id = (String) requestData.get("deptId");
  438. int deptId = Integer.parseInt(dept_Id);
  439. String file_category = (String) requestData.get("filecategory");
  440. int filecategory = Integer.parseInt(file_category);
  441. // Execute a query to fetch the required String based on filecategory
  442. String additionalDataQuery = "SELECT file_name FROM file_category_master WHERE id = ?";
  443. String fc_name = jdbcTemplate.queryForObject(additionalDataQuery, String.class,filecategory);
  444. System.out.println("fc_name==="+fc_name);
  445. int filestatus = getFileStatus.getFileStatus1Id();
  446. if (filestatus == 0) {
  447. System.out.println("File status not found. Aborting insertion.");
  448. return false;
  449. }
  450. String fileentrytype ="NEW";
  451. int rowsInserted=0;
  452. // Generate the variable (PR + current date + current time)
  453. String currentTimestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("ddMMyyHHmmss"));
  454. String temp_id = "PF" + currentTimestamp;
  455. String query = "INSERT INTO pensioner_details (emp_no, emp_name, dept_name, designation, sanctioned_gis_amount,service_death,relationship_deceased,file_moved_date, remarks,dept_id,file_category,file_status,file_entry_type,file_category_name,temp_id,pending_duration,reason_for_pending) VALUES (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?)";
  456. rowsInserted = jdbcTemplate.update(query, empNo, empName, deptName, designation, sanctionedgis,serviceDeath ,deceased,dateToAudit, remarks,deptId,filecategory,filestatus,fileentrytype,fc_name,temp_id, pendingDuration,reasonPending);
  457. String query1 = "INSERT INTO pensioner_details_history (emp_no, emp_name, dept_name, designation, sanctioned_gis_amount,service_death,relationship_deceased,file_moved_date, remarks,dept_id,file_category,file_status,file_entry_type,file_moved_by,file_category_name,temp_id,pending_duration,reason_for_pending) VALUES (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?)";
  458. rowsInserted = jdbcTemplate.update(query1, empNo, empName, deptName, designation, sanctionedgis,serviceDeath ,deceased,dateToAudit, remarks,deptId,filecategory,filestatus,fileentrytype,filemovedby,fc_name,temp_id, pendingDuration,reasonPending);
  459. String query2 = "INSERT INTO file_movement_history (emp_no,file_moved_date,file_status,file_moved_by,remarks,temp_id) VALUES (?, ?, ?, ?, ?,?)";
  460. rowsInserted = jdbcTemplate.update(query2, empNo,dateToAudit,filestatus,filemovedby,remarks,temp_id);
  461. return rowsInserted > 0;
  462. } catch (Exception e) {
  463. e.printStackTrace();
  464. return false; // Return false if an exception occurs
  465. }
  466. }
  467. ///gis saving method service
  468. @Transactional
  469. public boolean savenewEntryDetailsGis(Map<String, Object> requestData) {
  470. try {
  471. String empNo = (String) requestData.get("empNo");
  472. String empName = (String) requestData.get("empName");
  473. String deptName = (String) requestData.get("deptName");
  474. String designation = (String) requestData.get("designation");
  475. String dateToPension = (String) requestData.get("dateToPension");
  476. String filemovedby =(String)requestData.get("filemovedby");
  477. String remarks = (String) requestData.get("remarks");
  478. String serviceDeath =(String) requestData.get("serviceDeath");
  479. String deceased =(String) requestData.get("deceased");
  480. String gisentry = (String) requestData.get("gisentry");
  481. String gisAdvanceamount =(String) requestData.get("gisAdvanceamount");
  482. String gisAdvance = (String) requestData.get("gisAdvance");
  483. String dept_Id = (String) requestData.get("deptId");
  484. int deptId = Integer.parseInt(dept_Id);
  485. String file_category = (String) requestData.get("filecategory");
  486. int filecategory = Integer.parseInt(file_category);
  487. // Execute a query to fetch the required String based on filecategory
  488. String additionalDataQuery = "SELECT file_name FROM file_category_master WHERE id = ?";
  489. String fc_name = jdbcTemplate.queryForObject(additionalDataQuery, String.class,filecategory);
  490. System.out.println("fc_name==="+fc_name);
  491. int filestatus = getFileStatus.getFileStatus7Id();
  492. if (filestatus == 0) {
  493. System.out.println("File status not found. Aborting insertion.");
  494. return false;
  495. }
  496. String fileentrytype ="NEW";
  497. System.out.println("filemovedby====="+filemovedby);
  498. // Generate the variable (PR + current date + current time)
  499. String currentTimestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("ddMMyyHHmmss"));
  500. String temp_id = "PG" + currentTimestamp;
  501. String query = "INSERT INTO pensioner_details (emp_no, emp_name, dept_name, designation,file_moved_date, remarks,service_death,relationship_deceased,gis_entry,gis_advance_amount,gis_advance ,file_category,file_status,file_entry_type,dept_id,file_category_name,temp_id) VALUES (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?)";
  502. int rowsInserted = jdbcTemplate.update(query, empNo, empName, deptName, designation, dateToPension, remarks,serviceDeath,deceased,gisentry,gisAdvanceamount,gisAdvance,filecategory,filestatus,fileentrytype,deptId,fc_name,temp_id);
  503. String query1 = "INSERT INTO pensioner_details_history (emp_no, emp_name, dept_name, designation,file_moved_date, remarks,service_death,relationship_deceased,gis_entry,gis_advance_amount,gis_advance ,file_category,file_status,file_entry_type,file_moved_by,dept_id,file_category_name,temp_id) VALUES (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?)";
  504. int rowsInsertedHistory = jdbcTemplate.update(query1, empNo, empName, deptName, designation,dateToPension, remarks,serviceDeath,deceased,gisentry,gisAdvanceamount,gisAdvance,filecategory,filestatus,fileentrytype,filemovedby,deptId,fc_name,temp_id);
  505. String query2 = "INSERT INTO file_movement_history (emp_no,file_moved_date,file_status,file_moved_by,remarks,temp_id) VALUES (?, ?, ?, ?, ?,?)";
  506. int rowsInsertedFileMovement = jdbcTemplate.update(query2, empNo,dateToPension,filestatus,filemovedby,remarks,temp_id);
  507. //
  508. return rowsInserted > 0 && rowsInsertedHistory > 0 && rowsInsertedFileMovement > 0;
  509. } catch (Exception e) {
  510. e.printStackTrace();
  511. return false; // Return false if an exception occurs
  512. }
  513. }
  514. //provisional retirement method service
  515. @Transactional
  516. public boolean savenewEntryDetailsProvisionalretirement(Map<String, Object> requestData) {
  517. try {
  518. String empNo = (String) requestData.get("empNo");
  519. String empName = (String) requestData.get("empName");
  520. String deptName = (String) requestData.get("deptName");
  521. String designation = (String) requestData.get("designation");
  522. String typeOfRetirement = (String) requestData.get("typeOfRetirement");
  523. String ReasonofPension = (String) requestData.get("ReasonofPension");
  524. String retirementClass = (String) requestData.get("retirementClass");
  525. String retirementDate = (String) requestData.get("retirementDate");
  526. String pendingDuration = (String) requestData.get("pendingDuration");
  527. String reasonofPending = (String) requestData.get("reasonofPending");
  528. String dp = (String) requestData.get("dp");
  529. String otherReason = (String) requestData.get("otherReason");
  530. String dateToAudit = (String) requestData.get("dateToAudit");
  531. String filemovedby =(String)requestData.get("filemovedby");
  532. String remarks = (String) requestData.get("remarks");
  533. String dept_Id = (String) requestData.get("deptId");
  534. int deptId = Integer.parseInt(dept_Id);
  535. String file_category = (String) requestData.get("filecategory");
  536. int filecategory = Integer.parseInt(file_category);
  537. // Execute a query to fetch the required String based on filecategory
  538. String additionalDataQuery = "SELECT file_name FROM file_category_master WHERE id = ?";
  539. String fc_name = jdbcTemplate.queryForObject(additionalDataQuery, String.class,filecategory);
  540. System.out.println("fc_name==="+fc_name);
  541. int filestatus = getFileStatus.getFileStatus7Id();
  542. if (filestatus == 0) {
  543. System.out.println("File status not found. Aborting insertion.");
  544. return false;
  545. }
  546. String fileentrytype ="NEW";
  547. System.out.println("filemovedby====="+filemovedby);
  548. // Generate the variable (PR + current date + current time)
  549. String currentTimestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("ddMMyyHHmmss"));
  550. String temp_id = "PPR" + currentTimestamp;
  551. String query = "INSERT INTO pensioner_details (emp_no, emp_name, dept_name, designation,type_of_retirement,retirement_class,retirement_date , reason_for_provisional_pension,file_moved_date, pending_duration,reason_for_pending,dp,remarks,file_category,file_status,file_entry_type,dept_id,file_category_name,others_provisional_pension,temp_id) VALUES (?,?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?,?)";
  552. int rowsInserted = jdbcTemplate.update(query, empNo, empName, deptName, designation, typeOfRetirement,retirementClass ,retirementDate , ReasonofPension,dateToAudit,pendingDuration,reasonofPending,dp,remarks,filecategory,filestatus,fileentrytype,deptId,fc_name,otherReason,temp_id);
  553. String query1 = "INSERT INTO pensioner_details_history (emp_no, emp_name, dept_name, designation,type_of_retirement,retirement_class, retirement_date,reason_for_provisional_pension ,file_moved_date, remarks,pending_duration,reason_for_pending,dp ,file_category,file_status,file_entry_type,file_moved_by,dept_id,file_category_name,others_provisional_pension,temp_id) VALUES (?,?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?,?,?)";
  554. int rowsInsertedHistory = jdbcTemplate.update(query1, empNo, empName, deptName, designation,typeOfRetirement,retirementClass,retirementDate ,ReasonofPension,dateToAudit,pendingDuration,reasonofPending,dp,remarks,filecategory,filestatus,fileentrytype,filemovedby,deptId,fc_name,otherReason,temp_id);
  555. String query2 = "INSERT INTO file_movement_history (emp_no,file_moved_date,file_status,file_moved_by,remarks,temp_id) VALUES (?, ?, ?, ?, ?,?)";
  556. int rowsInsertedFileMovement = jdbcTemplate.update(query2, empNo,dateToAudit,filestatus,filemovedby,remarks,temp_id);
  557. //
  558. return rowsInserted > 0 && rowsInsertedHistory > 0 && rowsInsertedFileMovement > 0;
  559. } catch (Exception e) {
  560. e.printStackTrace();
  561. return false; // Return false if an exception occurs
  562. }
  563. }
  564. //cps saving method:
  565. @Transactional
  566. public boolean savenewEntryDetailspensionscheme(Map<String, Object> requestData) {
  567. try {
  568. // Safely extract input values from requestData
  569. String empNo = requestData.get("empNo") != null ? requestData.get("empNo").toString() : null;
  570. String empName = requestData.get("empName") != null ? requestData.get("empName").toString() : null;
  571. String deptName = requestData.get("deptName") != null ? requestData.get("deptName").toString() : null;
  572. String designation = requestData.get("designation") != null ? requestData.get("designation").toString() : null;
  573. String classes = requestData.get("classes") != null ? requestData.get("classes").toString() : null;
  574. String fileMovedBy = requestData.get("fileMovedBy") != null ? requestData.get("fileMovedBy").toString() : null;
  575. String remarks = requestData.get("remarks") != null ? requestData.get("remarks").toString() : null;
  576. String retirementType = requestData.get("retirementType") != null ? requestData.get("retirementType").toString() : null;
  577. String uac = (String) requestData.get("uac");
  578. String uacDate = "yes".equals(uac) && requestData.get("uacDate") != null ? requestData.get("uacDate").toString() : null;
  579. String pendingDuration = (String) requestData.get("pendingDuration");
  580. String reasonPending = "yes".equals(pendingDuration) && requestData.get("reasonPending") != null
  581. ? requestData.get("reasonPending").toString() : null;
  582. String cps =(String) requestData.get("cps");
  583. String cpsAmount = "yes".equals(cps) && requestData.get("cpsAmount") != null ? requestData.get("cpsAmount").toString() : null;
  584. String elOrLpa = (String)requestData.get("elOrLpa");
  585. String elOrLpaAmount = "yes".equals(elOrLpa) && requestData.get("elOrLpaAmount") != null ? requestData.get("elOrLpaAmount").toString() : null;
  586. String spfgs = (String) requestData.get("spfgs");
  587. String spfgsAmount = "yes".equals(spfgs) && requestData.get("spfgsAmount") != null ? requestData.get("spfgsAmount").toString() : null;
  588. int deptId = requestData.get("deptId") != null ? Integer.parseInt(requestData.get("deptId").toString()) : 0;
  589. // Default static values
  590. String file_category = (String) requestData.get("filecategory");
  591. int filecategory = Integer.parseInt(file_category);
  592. int fileStatus = getFileStatus.getFileStatus11Id();
  593. if (fileStatus == 0) {
  594. System.out.println("File status not found. Aborting insertion.");
  595. return false;
  596. }
  597. String fileEntryType = "FILE_COMPLETED";
  598. // Fetch file_category_name dynamically
  599. String fileCategoryQuery = "SELECT file_name FROM file_category_master WHERE id = ?";
  600. String fileCategoryName = jdbcTemplate.queryForObject(fileCategoryQuery, String.class,filecategory);
  601. // Generate the variable (PR + current date + current time)
  602. String currentTimestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("ddMMyyHHmmss"));
  603. String temp_id = "PC" + currentTimestamp;
  604. // Insert into cps_pensioner_details
  605. String queryDetails = "INSERT INTO cps_pensioner_details " +
  606. "(emp_no, emp_name, dept_name, designation, file_category, retirement_class, type_of_retirement, uac, uac_date, " +
  607. "pending_duration,reason_for_pending ,cps, cps_amount, el_or_lpa, el_or_lpa_amount, spfgs, spfgs_amount, remarks, " +
  608. "file_status, file_entry_type, dept_id, file_category_name,temp_id) " +
  609. "VALUES (?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)";
  610. int rowsInsertedDetails = jdbcTemplate.update(queryDetails,
  611. empNo, empName, deptName, designation, filecategory, classes, retirementType, uac, uacDate,
  612. pendingDuration,reasonPending ,cps, cpsAmount, elOrLpa, elOrLpaAmount, spfgs, spfgsAmount, remarks,
  613. fileStatus, fileEntryType, deptId, fileCategoryName,temp_id);
  614. // Insert into cps_pensioner_details_history
  615. String queryHistory = "INSERT INTO cps_pensioner_details_history " +
  616. "(emp_no, emp_name, dept_name, designation, file_category, retirement_class, type_of_retirement, uac, uac_date, " +
  617. "pending_duration,reason_for_pending ,cps, cps_amount, el_or_lpa, el_or_lpa_amount, spfgs, spfgs_amount, remarks, " +
  618. "file_status, file_entry_type, file_moved_by, dept_id, file_category_name,temp_id) " +
  619. "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)";
  620. int rowsInsertedHistory = jdbcTemplate.update(queryHistory,
  621. empNo, empName, deptName, designation, filecategory, classes, retirementType, uac, uacDate,
  622. pendingDuration, reasonPending,cps, cpsAmount, elOrLpa, elOrLpaAmount, spfgs, spfgsAmount, remarks,
  623. fileStatus, fileEntryType, fileMovedBy, deptId, fileCategoryName,temp_id);
  624. // Current date and time
  625. LocalDateTime fileMovedDate = LocalDateTime.now();
  626. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
  627. String formattedFileMovedDate = fileMovedDate.format(formatter);
  628. // Insert into file_movement_history
  629. String queryFileMovement = "INSERT INTO file_movement_history (emp_no, file_status,file_moved_date, file_moved_by, remarks,temp_id) " +
  630. "VALUES (?, ?, ?, ?, ?,?)";
  631. int rowsInsertedFileMovement = jdbcTemplate.update(queryFileMovement, empNo, fileStatus, formattedFileMovedDate, fileMovedBy, remarks,temp_id);
  632. // Return true if all inserts were successful
  633. return rowsInsertedDetails > 0 && rowsInsertedHistory > 0 && rowsInsertedFileMovement > 0;
  634. } catch (Exception e) {
  635. e.printStackTrace();
  636. return false; // Return false if an exception occurs
  637. }
  638. }
  639. //pendency saving method
  640. @Transactional
  641. public boolean savePendencyDetails(Map<String, Object> requestData) {
  642. try {
  643. String empNo = (String) requestData.get("empNo");
  644. String empName = (String) requestData.get("empName");
  645. String deptName = (String) requestData.get("deptName");
  646. String designation = (String) requestData.get("designation");
  647. String retirementclass = (String) requestData.get("retirementclass");
  648. String typeOfRetirement = (String) requestData.get("typeOfRetirement");
  649. String retirementDate = (String) requestData.get("retirementDate");
  650. //String pendencyCategory=(String)requestData.get("pendencyCategory");
  651. String pendencyCategory="Retirement";
  652. String dateToAudit = (String) requestData.get("dateToAudit");
  653. String remarks = (String) requestData.get("remarks");
  654. String filemovedby =(String)requestData.get("filemovedby");
  655. String pendingDuration = (String) requestData.get("pendingDuration");
  656. String reasonPending =requestData.get("reasonPending") != null ? requestData.get("reasonPending").toString() : null;
  657. String dept_Id = (String) requestData.get("deptId");
  658. System.out.println("dept_Id = "+dept_Id);
  659. int deptId = Integer.parseInt(dept_Id);
  660. String file_category = (String) requestData.get("filecategory");
  661. int filecategory = Integer.parseInt(file_category);
  662. int filestatus = getFileStatus.getFileStatus1Id();
  663. if (filestatus == 0) {
  664. System.out.println("File status not found. Aborting insertion.");
  665. return false;
  666. }
  667. String fileentrytype ="NEW";
  668. int rowsInserted = 0;
  669. // Generate the variable (PR + current date + current time)
  670. String currentTimestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("ddMMyyHHmmss"));
  671. String temp_id = "PP" + currentTimestamp;
  672. String query = "INSERT INTO pensioner_details (emp_no, emp_name, dept_name, designation, retirement_class,retirement_date,pending_duration,reason_for_pending,file_moved_date,dept_id,remarks,file_category,file_status,file_entry_type,file_category_name,type_of_retirement,temp_id) VALUES (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?)";
  673. rowsInserted = jdbcTemplate.update(query, empNo, empName, deptName, designation, retirementclass,retirementDate,pendingDuration,reasonPending,dateToAudit, deptId,remarks,filecategory,filestatus,fileentrytype,pendencyCategory,typeOfRetirement,temp_id);
  674. String query1 = "INSERT INTO pensioner_details_history (emp_no, emp_name, dept_name, designation, retirement_class,retirement_date,pending_duration,reason_for_pending,file_moved_date,dept_id,remarks,file_category,file_status,file_entry_type,file_category_name,type_of_retirement,file_moved_by,temp_id) VALUES (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?)";
  675. rowsInserted = jdbcTemplate.update(query1, empNo, empName, deptName, designation, retirementclass,retirementDate,pendingDuration,reasonPending,dateToAudit, deptId,remarks,filecategory,filestatus,fileentrytype,pendencyCategory,typeOfRetirement,filemovedby,temp_id);
  676. String query2 = "INSERT INTO file_movement_history (emp_no,file_moved_date,file_status,file_moved_by,remarks,temp_id) VALUES (?,?, ?, ?, ?, ?)";
  677. rowsInserted = jdbcTemplate.update(query2, empNo,dateToAudit,filestatus,filemovedby,remarks,temp_id);
  678. return rowsInserted > 0;
  679. } catch (Exception e) {
  680. e.printStackTrace();
  681. return false; // Return false if an exception occurs
  682. }
  683. }
  684. public boolean doesEmployeeExistRPR(String empCode) {
  685. String sql = "SELECT COUNT(*) FROM ( " +
  686. " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,4,5,6) " +
  687. " UNION ALL " +
  688. " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " +
  689. ") AS combined";
  690. // Note: Pass empCode twice since there are two placeholders.
  691. Integer count = jdbcTemplate.queryForObject(sql, Integer.class,empCode,empCode);
  692. return count != null && count > 0;
  693. }
  694. public boolean doesEmployeeExist(String empCode) {
  695. String sql = "SELECT COUNT(*) FROM ( " +
  696. " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,3,5) "+
  697. " UNION ALL " +
  698. " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " +
  699. ") AS combined";
  700. // Note: Pass empCode twice since there are two placeholders.
  701. Integer count = jdbcTemplate.queryForObject(sql,Integer.class,empCode,empCode);
  702. System.out.println("count<<<<<<<<<<<"+count);
  703. return count != null && count > 0;
  704. }
  705. public boolean doesEmployeeExistgis(String empCode) {
  706. String sql = "SELECT COUNT(*) FROM ( " +
  707. " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,5,6) " +
  708. " UNION ALL " +
  709. " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " +
  710. ") AS combined";
  711. // Note: Pass empCode twice since there are two placeholders.
  712. Integer count = jdbcTemplate.queryForObject(sql, Integer.class,empCode,empCode);
  713. return count != null && count > 0;
  714. }
  715. public boolean doesEmployeeExistfp(String empCode) {
  716. String sql = "SELECT COUNT(*) FROM ( " +
  717. " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,5) AND is_closed IN (0)" +
  718. " UNION ALL " +
  719. " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " +
  720. ") AS combined";
  721. // Note: Pass empCode twice since there are two placeholders.
  722. Integer count = jdbcTemplate.queryForObject(sql, Integer.class,empCode,empCode);
  723. return count != null && count > 0;
  724. }
  725. }