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.

935 lines
51 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
​
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<String> getRegisteredEmps(Integer deptId, Integer file_category) {
  360. String query = "SELECT DISTINCT emp_no FROM pensioner_details WHERE dept_id=? " +
  361. "UNION ALL " +
  362. "SELECT DISTINCT emp_no FROM cps_pensioner_details WHERE dept_id=?";
  363. List<String> emps = jdbcTemplate.queryForList(query, String.class, deptId, deptId);
  364. System.out.println("emps====" + emps);
  365. return emps;
  366. }
  367. public Integer getRetirementFileCategoryId() {
  368. String query = "SELECT id FROM file_category_master WHERE file_name = 'Retirement'";
  369. try {
  370. return jdbcTemplate.queryForObject(query, Integer.class);
  371. } catch (EmptyResultDataAccessException e) {
  372. return null; // or handle as needed
  373. }
  374. }
  375. public Integer getFamilyPensionFileCategoryId() {
  376. String query = "SELECT id FROM file_category_master WHERE file_name = 'Family Pension'";
  377. try {
  378. return jdbcTemplate.queryForObject(query, Integer.class);
  379. } catch (EmptyResultDataAccessException e) {
  380. return null; // or handle as needed
  381. }
  382. }
  383. public Integer getPendencyFileCategoryId() {
  384. String query = "SELECT id FROM file_category_master WHERE file_name = 'Pendency'";
  385. try {
  386. return jdbcTemplate.queryForObject(query, Integer.class);
  387. } catch (EmptyResultDataAccessException e) {
  388. return null; // or handle as needed
  389. }
  390. }
  391. public Integer getGISFileCategoryId() {
  392. String query = "SELECT id FROM file_category_master WHERE file_name = 'GIS'";
  393. try {
  394. return jdbcTemplate.queryForObject(query, Integer.class);
  395. } catch (EmptyResultDataAccessException e) {
  396. return null; // or handle as needed
  397. }
  398. }
  399. public Integer getPRFileCategoryId() {
  400. String query = "SELECT id FROM file_category_master WHERE file_name = 'Provisional Retirement'";
  401. try {
  402. return jdbcTemplate.queryForObject(query, Integer.class);
  403. } catch (EmptyResultDataAccessException e) {
  404. return null; // or handle as needed
  405. }
  406. }
  407. public Integer getCPSFileCategoryId() {
  408. String query = "SELECT id FROM file_category_master WHERE file_name = 'Contributory Pension Scheme'";
  409. try {
  410. return jdbcTemplate.queryForObject(query, Integer.class);
  411. } catch (EmptyResultDataAccessException e) {
  412. return null; // or handle as needed
  413. }
  414. }
  415. @Transactional
  416. public boolean saveFamilyPensionDetails(Map<String, Object> requestData) {
  417. try {
  418. // Extract data from the request body
  419. String empNo = (String) requestData.get("empNo");
  420. String empName = (String) requestData.get("empName");
  421. String deptName = (String) requestData.get("deptName");
  422. String designation = (String) requestData.get("designation");
  423. String sanctionedgis = (String) requestData.get("sanctionedgis");
  424. String serviceDeath =(String) requestData.get("serviceDeath");
  425. String deceased =(String) requestData.get("deceased");
  426. String dateToAudit = (String) requestData.get("dateToAudit");
  427. String remarks = (String) requestData.get("remarks");
  428. String filemovedby =(String)requestData.get("filemovedby");
  429. String pendingDuration = (String) requestData.get("pendingDuration");
  430. String reasonPending = (("yes".equals(pendingDuration) || "no".equals(pendingDuration))
  431. && requestData.get("reasonPending") != null) ? requestData.get("reasonPending").toString() : null;
  432. String dept_Id = (String) requestData.get("deptId");
  433. int deptId = Integer.parseInt(dept_Id);
  434. String file_category = (String) requestData.get("filecategory");
  435. int filecategory = Integer.parseInt(file_category);
  436. // Execute a query to fetch the required String based on filecategory
  437. String additionalDataQuery = "SELECT file_name FROM file_category_master WHERE id = ?";
  438. String fc_name = jdbcTemplate.queryForObject(additionalDataQuery, String.class,filecategory);
  439. System.out.println("fc_name==="+fc_name);
  440. int filestatus = getFileStatus.getFileStatus1Id();
  441. if (filestatus == 0) {
  442. System.out.println("File status not found. Aborting insertion.");
  443. return false;
  444. }
  445. String fileentrytype ="NEW";
  446. int rowsInserted=0;
  447. // Generate the variable (PR + current date + current time)
  448. String currentTimestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("ddMMyyHHmmss"));
  449. String temp_id = "PF" + currentTimestamp;
  450. 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 (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?)";
  451. rowsInserted = jdbcTemplate.update(query, empNo, empName, deptName, designation, sanctionedgis,serviceDeath ,deceased,dateToAudit, remarks,deptId,filecategory,filestatus,fileentrytype,fc_name,temp_id, pendingDuration,reasonPending);
  452. 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 (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?)";
  453. rowsInserted = jdbcTemplate.update(query1, empNo, empName, deptName, designation, sanctionedgis,serviceDeath ,deceased,dateToAudit, remarks,deptId,filecategory,filestatus,fileentrytype,filemovedby,fc_name,temp_id, pendingDuration,reasonPending);
  454. String query2 = "INSERT INTO file_movement_history (emp_no,file_moved_date,file_status,file_moved_by,remarks,temp_id) VALUES (?, ?, ?, ?, ?,?)";
  455. rowsInserted = jdbcTemplate.update(query2, empNo,dateToAudit,filestatus,filemovedby,remarks,temp_id);
  456. return rowsInserted > 0;
  457. } catch (Exception e) {
  458. e.printStackTrace();
  459. return false; // Return false if an exception occurs
  460. }
  461. }
  462. ///gis saving method service
  463. @Transactional
  464. public boolean savenewEntryDetailsGis(Map<String, Object> requestData) {
  465. try {
  466. String empNo = (String) requestData.get("empNo");
  467. String empName = (String) requestData.get("empName");
  468. String deptName = (String) requestData.get("deptName");
  469. String designation = (String) requestData.get("designation");
  470. String dateToPension = (String) requestData.get("dateToPension");
  471. String filemovedby =(String)requestData.get("filemovedby");
  472. String remarks = (String) requestData.get("remarks");
  473. String serviceDeath =(String) requestData.get("serviceDeath");
  474. String deceased =(String) requestData.get("deceased");
  475. String gisentry = (String) requestData.get("gisentry");
  476. String gisAdvanceamount =(String) requestData.get("gisAdvanceamount");
  477. String gisAdvance = (String) requestData.get("gisAdvance");
  478. String dept_Id = (String) requestData.get("deptId");
  479. int deptId = Integer.parseInt(dept_Id);
  480. String file_category = (String) requestData.get("filecategory");
  481. int filecategory = Integer.parseInt(file_category);
  482. // Execute a query to fetch the required String based on filecategory
  483. String additionalDataQuery = "SELECT file_name FROM file_category_master WHERE id = ?";
  484. String fc_name = jdbcTemplate.queryForObject(additionalDataQuery, String.class,filecategory);
  485. System.out.println("fc_name==="+fc_name);
  486. int filestatus = getFileStatus.getFileStatus7Id();
  487. if (filestatus == 0) {
  488. System.out.println("File status not found. Aborting insertion.");
  489. return false;
  490. }
  491. String fileentrytype ="NEW";
  492. System.out.println("filemovedby====="+filemovedby);
  493. // Generate the variable (PR + current date + current time)
  494. String currentTimestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("ddMMyyHHmmss"));
  495. String temp_id = "PG" + currentTimestamp;
  496. 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 (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?)";
  497. int rowsInserted = jdbcTemplate.update(query, empNo, empName, deptName, designation, dateToPension, remarks,serviceDeath,deceased,gisentry,gisAdvanceamount,gisAdvance,filecategory,filestatus,fileentrytype,deptId,fc_name,temp_id);
  498. 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 (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?)";
  499. 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);
  500. String query2 = "INSERT INTO file_movement_history (emp_no,file_moved_date,file_status,file_moved_by,remarks,temp_id) VALUES (?, ?, ?, ?, ?,?)";
  501. int rowsInsertedFileMovement = jdbcTemplate.update(query2, empNo,dateToPension,filestatus,filemovedby,remarks,temp_id);
  502. //
  503. return rowsInserted > 0 && rowsInsertedHistory > 0 && rowsInsertedFileMovement > 0;
  504. } catch (Exception e) {
  505. e.printStackTrace();
  506. return false; // Return false if an exception occurs
  507. }
  508. }
  509. //provisional retirement method service
  510. @Transactional
  511. public boolean savenewEntryDetailsProvisionalretirement(Map<String, Object> requestData) {
  512. try {
  513. String empNo = (String) requestData.get("empNo");
  514. String empName = (String) requestData.get("empName");
  515. String deptName = (String) requestData.get("deptName");
  516. String designation = (String) requestData.get("designation");
  517. String typeOfRetirement = (String) requestData.get("typeOfRetirement");
  518. String ReasonofPension = (String) requestData.get("ReasonofPension");
  519. String retirementClass = (String) requestData.get("retirementClass");
  520. String retirementDate = (String) requestData.get("retirementDate");
  521. String pendingDuration = (String) requestData.get("pendingDuration");
  522. String reasonofPending = (String) requestData.get("reasonofPending");
  523. String dp = (String) requestData.get("dp");
  524. String otherReason = (String) requestData.get("otherReason");
  525. String dateToAudit = (String) requestData.get("dateToAudit");
  526. String filemovedby =(String)requestData.get("filemovedby");
  527. String remarks = (String) requestData.get("remarks");
  528. String dept_Id = (String) requestData.get("deptId");
  529. int deptId = Integer.parseInt(dept_Id);
  530. String file_category = (String) requestData.get("filecategory");
  531. int filecategory = Integer.parseInt(file_category);
  532. // Execute a query to fetch the required String based on filecategory
  533. String additionalDataQuery = "SELECT file_name FROM file_category_master WHERE id = ?";
  534. String fc_name = jdbcTemplate.queryForObject(additionalDataQuery, String.class,filecategory);
  535. System.out.println("fc_name==="+fc_name);
  536. int filestatus = getFileStatus.getFileStatus7Id();
  537. if (filestatus == 0) {
  538. System.out.println("File status not found. Aborting insertion.");
  539. return false;
  540. }
  541. String fileentrytype ="NEW";
  542. System.out.println("filemovedby====="+filemovedby);
  543. // Generate the variable (PR + current date + current time)
  544. String currentTimestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("ddMMyyHHmmss"));
  545. String temp_id = "PPR" + currentTimestamp;
  546. 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 (?,?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?,?)";
  547. 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);
  548. 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 (?,?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?,?,?)";
  549. int rowsInsertedHistory = jdbcTemplate.update(query1, empNo, empName, deptName, designation,typeOfRetirement,retirementClass,retirementDate ,ReasonofPension,dateToAudit,remarks,pendingDuration,reasonofPending,dp,filecategory,filestatus,fileentrytype,filemovedby,deptId,fc_name,otherReason,temp_id);
  550. String query2 = "INSERT INTO file_movement_history (emp_no,file_moved_date,file_status,file_moved_by,remarks,temp_id) VALUES (?, ?, ?, ?, ?,?)";
  551. int rowsInsertedFileMovement = jdbcTemplate.update(query2, empNo,dateToAudit,filestatus,filemovedby,remarks,temp_id);
  552. //
  553. return rowsInserted > 0 && rowsInsertedHistory > 0 && rowsInsertedFileMovement > 0;
  554. } catch (Exception e) {
  555. e.printStackTrace();
  556. return false; // Return false if an exception occurs
  557. }
  558. }
  559. //cps saving method:
  560. @Transactional
  561. public boolean savenewEntryDetailspensionscheme(Map<String, Object> requestData) {
  562. try {
  563. // Safely extract input values from requestData
  564. String empNo = requestData.get("empNo") != null ? requestData.get("empNo").toString() : null;
  565. String empName = requestData.get("empName") != null ? requestData.get("empName").toString() : null;
  566. String deptName = requestData.get("deptName") != null ? requestData.get("deptName").toString() : null;
  567. String designation = requestData.get("designation") != null ? requestData.get("designation").toString() : null;
  568. String classes = requestData.get("classes") != null ? requestData.get("classes").toString() : null;
  569. String fileMovedBy = requestData.get("fileMovedBy") != null ? requestData.get("fileMovedBy").toString() : null;
  570. String remarks = requestData.get("remarks") != null ? requestData.get("remarks").toString() : null;
  571. String retirementType = requestData.get("retirementType") != null ? requestData.get("retirementType").toString() : null;
  572. String retirementdate = requestData.get("retirementdate") !=null ? requestData.get("retirementdate").toString() : null;
  573. String uac = (String) requestData.get("uac");
  574. String uacDate = "yes".equals(uac) && requestData.get("uacDate") != null ? requestData.get("uacDate").toString() : null;
  575. String pendingDuration = (String) requestData.get("pendingDuration");
  576. String reasonPending = "yes".equals(pendingDuration) && requestData.get("reasonPending") != null
  577. ? requestData.get("reasonPending").toString() : null;
  578. String cps =(String) requestData.get("cps");
  579. String cpsAmount = "yes".equals(cps) && requestData.get("cpsAmount") != null ? requestData.get("cpsAmount").toString() : null;
  580. String elOrLpa = (String)requestData.get("elOrLpa");
  581. String elOrLpaAmount = "yes".equals(elOrLpa) && requestData.get("elOrLpaAmount") != null ? requestData.get("elOrLpaAmount").toString() : null;
  582. String spfgs = (String) requestData.get("spfgs");
  583. String spfgsAmount = "yes".equals(spfgs) && requestData.get("spfgsAmount") != null ? requestData.get("spfgsAmount").toString() : null;
  584. int deptId = requestData.get("deptId") != null ? Integer.parseInt(requestData.get("deptId").toString()) : 0;
  585. // Default static values
  586. String file_category = (String) requestData.get("filecategory");
  587. int filecategory = Integer.parseInt(file_category);
  588. int fileStatus = getFileStatus.getFileStatus11Id();
  589. if (fileStatus == 0) {
  590. System.out.println("File status not found. Aborting insertion.");
  591. return false;
  592. }
  593. String fileEntryType = "FILE_COMPLETED";
  594. // Fetch file_category_name dynamically
  595. String fileCategoryQuery = "SELECT file_name FROM file_category_master WHERE id = ?";
  596. String fileCategoryName = jdbcTemplate.queryForObject(fileCategoryQuery, String.class,filecategory);
  597. // Generate the variable (PR + current date + current time)
  598. String currentTimestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("ddMMyyHHmmss"));
  599. String temp_id = "PC" + currentTimestamp;
  600. // Insert into cps_pensioner_details
  601. String queryDetails = "INSERT INTO cps_pensioner_details " +
  602. "(emp_no, emp_name, dept_name, designation, file_category, retirement_class, retirement_date,type_of_retirement, uac, uac_date, " +
  603. "pending_duration,reason_for_pending ,cps, cps_amount, el_or_lpa, el_or_lpa_amount, spfgs, spfgs_amount, remarks, " +
  604. "file_status, file_entry_type, dept_id, file_category_name,temp_id) " +
  605. "VALUES (?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)";
  606. int rowsInsertedDetails = jdbcTemplate.update(queryDetails,
  607. empNo, empName, deptName, designation, filecategory, classes, retirementdate,retirementType, uac, uacDate,
  608. pendingDuration,reasonPending ,cps, cpsAmount, elOrLpa, elOrLpaAmount, spfgs, spfgsAmount, remarks,
  609. fileStatus, fileEntryType, deptId, fileCategoryName,temp_id);
  610. // Insert into cps_pensioner_details_history
  611. String queryHistory = "INSERT INTO cps_pensioner_details_history " +
  612. "(emp_no, emp_name, dept_name, designation, file_category, retirement_class, retirement_date,type_of_retirement, uac, uac_date, " +
  613. "pending_duration,reason_for_pending ,cps, cps_amount, el_or_lpa, el_or_lpa_amount, spfgs, spfgs_amount, remarks, " +
  614. "file_status, file_entry_type, file_moved_by, dept_id, file_category_name,temp_id) " +
  615. "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?)";
  616. int rowsInsertedHistory = jdbcTemplate.update(queryHistory,
  617. empNo, empName, deptName, designation, filecategory, classes, retirementdate,retirementType, uac, uacDate,
  618. pendingDuration, reasonPending,cps, cpsAmount, elOrLpa, elOrLpaAmount, spfgs, spfgsAmount, remarks,
  619. fileStatus, fileEntryType, fileMovedBy, deptId, fileCategoryName,temp_id);
  620. // Current date and time
  621. LocalDateTime fileMovedDate = LocalDateTime.now();
  622. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
  623. String formattedFileMovedDate = fileMovedDate.format(formatter);
  624. // Insert into file_movement_history
  625. String queryFileMovement = "INSERT INTO file_movement_history (emp_no, file_status,file_moved_date, file_moved_by, remarks,temp_id) " +
  626. "VALUES (?, ?, ?, ?, ?,?)";
  627. int rowsInsertedFileMovement = jdbcTemplate.update(queryFileMovement, empNo, fileStatus, formattedFileMovedDate, fileMovedBy, remarks,temp_id);
  628. // Return true if all inserts were successful
  629. return rowsInsertedDetails > 0 && rowsInsertedHistory > 0 && rowsInsertedFileMovement > 0;
  630. } catch (Exception e) {
  631. e.printStackTrace();
  632. return false; // Return false if an exception occurs
  633. }
  634. }
  635. //pendency saving method
  636. @Transactional
  637. public boolean savePendencyDetails(Map<String, Object> requestData) {
  638. try {
  639. String empNo = (String) requestData.get("empNo");
  640. String empName = (String) requestData.get("empName");
  641. String deptName = (String) requestData.get("deptName");
  642. String designation = (String) requestData.get("designation");
  643. String retirementclass = (String) requestData.get("retirementclass");
  644. String typeOfRetirement = (String) requestData.get("typeOfRetirement");
  645. String retirementDate = (String) requestData.get("retirementDate");
  646. //String pendencyCategory=(String)requestData.get("pendencyCategory");
  647. String pendencyCategory="Retirement";
  648. String dateToAudit = (String) requestData.get("dateToAudit");
  649. String remarks = (String) requestData.get("remarks");
  650. String filemovedby =(String)requestData.get("filemovedby");
  651. String pendingDuration = (String) requestData.get("pendingDuration");
  652. String reasonPending =requestData.get("reasonPending") != null ? requestData.get("reasonPending").toString() : null;
  653. String dept_Id = (String) requestData.get("deptId");
  654. System.out.println("dept_Id = "+dept_Id);
  655. int deptId = Integer.parseInt(dept_Id);
  656. String file_category = (String) requestData.get("filecategory");
  657. int filecategory = Integer.parseInt(file_category);
  658. int filestatus = getFileStatus.getFileStatus1Id();
  659. if (filestatus == 0) {
  660. System.out.println("File status not found. Aborting insertion.");
  661. return false;
  662. }
  663. String fileentrytype ="NEW";
  664. int rowsInserted = 0;
  665. // Generate the variable (PR + current date + current time)
  666. String currentTimestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("ddMMyyHHmmss"));
  667. String temp_id = "PP" + currentTimestamp;
  668. 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 (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?)";
  669. rowsInserted = jdbcTemplate.update(query, empNo, empName, deptName, designation, retirementclass,retirementDate,pendingDuration,reasonPending,dateToAudit, deptId,remarks,filecategory,filestatus,fileentrytype,pendencyCategory,typeOfRetirement,temp_id);
  670. 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 (?,?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?)";
  671. rowsInserted = jdbcTemplate.update(query1, empNo, empName, deptName, designation, retirementclass,retirementDate,pendingDuration,reasonPending,dateToAudit, deptId,remarks,filecategory,filestatus,fileentrytype,pendencyCategory,typeOfRetirement,filemovedby,temp_id);
  672. String query2 = "INSERT INTO file_movement_history (emp_no,file_moved_date,file_status,file_moved_by,remarks,temp_id) VALUES (?,?, ?, ?, ?, ?)";
  673. rowsInserted = jdbcTemplate.update(query2, empNo,dateToAudit,filestatus,filemovedby,remarks,temp_id);
  674. return rowsInserted > 0;
  675. } catch (Exception e) {
  676. e.printStackTrace();
  677. return false; // Return false if an exception occurs
  678. }
  679. }
  680. public boolean doesEmployeeExistRPR(String empCode) {
  681. String sql = "SELECT COUNT(*) FROM ( " +
  682. " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,4,5) " +
  683. " UNION ALL " +
  684. " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " +
  685. ") AS combined";
  686. // Note: Pass empCode twice since there are two placeholders.
  687. Integer count = jdbcTemplate.queryForObject(sql, Integer.class,empCode,empCode);
  688. return count != null && count > 0;
  689. }
  690. // public boolean doesEmployeeExist(String empCode) {
  691. //
  692. // String sql = "SELECT COUNT(*) FROM ( " +
  693. // " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,3,5) "+
  694. // " UNION ALL " +
  695. // " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " +
  696. // ") AS combined";
  697. // // Note: Pass empCode twice since there are two placeholders.
  698. // Integer count = jdbcTemplate.queryForObject(sql,Integer.class,empCode,empCode);
  699. // System.out.println("count<<<<<<<<<<<"+count);
  700. // return count != null && count > 0;
  701. // }
  702. //
  703. //
  704. // public boolean doesEmployeeExistgis(String empCode) {
  705. // String sql = "SELECT COUNT(*) FROM ( " +
  706. // " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,5,6) " +
  707. // " UNION ALL " +
  708. // " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " +
  709. // ") AS combined";
  710. // // Note: Pass empCode twice since there are two placeholders.
  711. // Integer count = jdbcTemplate.queryForObject(sql, Integer.class,empCode,empCode);
  712. // return count != null && count > 0;
  713. // }
  714. //
  715. //
  716. // public boolean doesEmployeeExistfp(String empCode) {
  717. //
  718. // String sql = "SELECT COUNT(*) FROM ( " +
  719. //
  720. // " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,5) AND is_closed IN (0)" +
  721. // " UNION ALL " +
  722. //
  723. // " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " +
  724. // ") AS combined";
  725. //
  726. // // Note: Pass empCode twice since there are two placeholders.
  727. // Integer count = jdbcTemplate.queryForObject(sql, Integer.class,empCode,empCode);
  728. // return count != null && count > 0;
  729. // }
  730. public boolean doesEmployeeExist(String empCode) {
  731. String sql = "SELECT COUNT(*) FROM ( " +
  732. " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (3,4,5) "+
  733. " UNION ALL " +
  734. " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1) AND is_closed=0 "+
  735. " UNION ALL " +
  736. " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " +
  737. ") AS combined";
  738. // Note: Pass empCode twice since there are two placeholders.
  739. Integer count = jdbcTemplate.queryForObject(sql,Integer.class,empCode,empCode,empCode);
  740. System.out.println("count<<<<<<<<<<<"+count);
  741. return count != null && count > 0;
  742. }
  743. public boolean doesEmployeeExistgis(String empCode) {
  744. String sql = "SELECT COUNT(*) FROM ( " +
  745. " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,5) " +
  746. " UNION ALL " +
  747. " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " +
  748. ") AS combined";
  749. // Note: Pass empCode twice since there are two placeholders.
  750. Integer count = jdbcTemplate.queryForObject(sql, Integer.class,empCode,empCode);
  751. return count != null && count > 0;
  752. }
  753. public boolean doesEmployeeExistfp(String empCode) {
  754. String sql = "SELECT COUNT(*) FROM ( " +
  755. " SELECT emp_no FROM pensioner_details WHERE emp_no = ? AND file_category IN (1,2,3,5) AND is_closed IN (0)" +
  756. " UNION ALL " +
  757. " SELECT emp_no FROM cps_pensioner_details WHERE emp_no = ? AND file_category IN (6) " +
  758. ") AS combined";
  759. // Note: Pass empCode twice since there are two placeholders.
  760. Integer count = jdbcTemplate.queryForObject(sql, Integer.class,empCode,empCode);
  761. return count != null && count > 0;
  762. }
  763. }