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.

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