|
78 | 78 | import com.health.model.PromoVideo; |
79 | 79 | import com.health.model.ResearchPaper; |
80 | 80 | import com.health.model.State; |
| 81 | +import com.health.model.StateDistrictMapping; |
81 | 82 | import com.health.model.Testimonial; |
82 | 83 | import com.health.model.Topic; |
83 | 84 | import com.health.model.TopicCategoryMapping; |
|
117 | 118 | import com.health.service.PromoVideoService; |
118 | 119 | import com.health.service.ResearchPaperService; |
119 | 120 | import com.health.service.RoleService; |
| 121 | +import com.health.service.StateDistrictMappingService; |
120 | 122 | import com.health.service.StateService; |
121 | 123 | import com.health.service.TestimonialService; |
122 | 124 | import com.health.service.TopicCategoryMappingService; |
@@ -300,6 +302,9 @@ public class AjaxController { |
300 | 302 | @Autowired |
301 | 303 | private ProjectReportService projectReportService; |
302 | 304 |
|
| 305 | + @Autowired |
| 306 | + private StateDistrictMappingService stateDistrictMappingService; |
| 307 | + |
303 | 308 | @Value("${downloadLimit}") |
304 | 309 | private int downloadLimit; |
305 | 310 |
|
@@ -2444,6 +2449,227 @@ public ResponseEntity<String> deleteProjectReport(@RequestParam("projectReportId |
2444 | 2449 | } |
2445 | 2450 | } |
2446 | 2451 |
|
| 2452 | + /* |
| 2453 | + * Function to load District and FileType by State Author: Alok Kumar |
| 2454 | + */ |
| 2455 | + |
| 2456 | + @RequestMapping("/loadDistrictAndFileTypeByState") |
| 2457 | + public @ResponseBody ArrayList<Map<String, Integer>> getDistrictAndFileTypeByState( |
| 2458 | + @RequestParam(value = "stateId") int stateId, @RequestParam(value = "districtId") int districtId, |
| 2459 | + @RequestParam(value = "fileTypeId") int fileTypeId) { |
| 2460 | + |
| 2461 | + ArrayList<Map<String, Integer>> arlist = new ArrayList<>(); |
| 2462 | + |
| 2463 | + Map<String, Integer> fileTypes = new TreeMap<>(); |
| 2464 | + |
| 2465 | + Map<String, Integer> districts = new TreeMap<>(); |
| 2466 | + |
| 2467 | + State state = stateId != 0 ? stateService.findById(stateId) : null; |
| 2468 | + District district = districtId != 0 ? disService.findById(districtId) : null; |
| 2469 | + Map<Integer, String> fileTypeIdAndValue = fileTypeId != 0 ? ServiceUtility.getFileTypeIdAndValue(fileTypeId) |
| 2470 | + : null; |
| 2471 | + |
| 2472 | + List<StateDistrictMapping> localStateDistrictList = new ArrayList<>(); |
| 2473 | + |
| 2474 | + // To find FileTypes |
| 2475 | + if (state != null && district != null) { |
| 2476 | + StateDistrictMapping sdm = stateDistrictMappingService.findByStateAndDistrict(state, district); |
| 2477 | + if (sdm != null) |
| 2478 | + localStateDistrictList.add(sdm); |
| 2479 | + } else if (state != null) { |
| 2480 | + localStateDistrictList = stateDistrictMappingService.findByState(state); |
| 2481 | + } else { |
| 2482 | + localStateDistrictList = stateDistrictMappingService.findAll(); |
| 2483 | + } |
| 2484 | + |
| 2485 | + List<ProjectReport> prList = projectReportService |
| 2486 | + .findByStateDistrictMappingInAndStatusTrue(localStateDistrictList); |
| 2487 | + |
| 2488 | + if (!prList.isEmpty()) { |
| 2489 | + |
| 2490 | + for (ProjectReport temp : prList) { |
| 2491 | + |
| 2492 | + ServiceUtility.getFileTypeIdAndValueforProjectReport(temp) |
| 2493 | + .forEach((id, type) -> fileTypes.put(type, id)); |
| 2494 | + |
| 2495 | + } |
| 2496 | + } |
| 2497 | + |
| 2498 | + // to find districts |
| 2499 | + if (state != null) { |
| 2500 | + localStateDistrictList = stateDistrictMappingService.findByState(state); |
| 2501 | + } else { |
| 2502 | + localStateDistrictList = stateDistrictMappingService.findAll(); |
| 2503 | + } |
| 2504 | + |
| 2505 | + prList = projectReportService.findByStateDistrictMappingInAndStatusTrue(localStateDistrictList); |
| 2506 | + List<ProjectReport> newprList1 = new ArrayList<>(); |
| 2507 | + if (fileTypeIdAndValue != null && !fileTypeIdAndValue.isEmpty()) { |
| 2508 | + Map.Entry<Integer, String> entry = fileTypeIdAndValue.entrySet().iterator().next(); |
| 2509 | + int id = entry.getKey(); |
| 2510 | + for (ProjectReport temp : prList) { |
| 2511 | + if (ServiceUtility.isProjectReportFilePresent(temp, id)) { |
| 2512 | + newprList1.add(temp); |
| 2513 | + } |
| 2514 | + } |
| 2515 | + } |
| 2516 | + if (!newprList1.isEmpty()) |
| 2517 | + prList = newprList1; |
| 2518 | + |
| 2519 | + for (ProjectReport pr : prList) { |
| 2520 | + |
| 2521 | + District dis = pr.getStateDistrictMapping().getDistrict(); |
| 2522 | + districts.put(dis.getDistrictName(), dis.getId()); |
| 2523 | + |
| 2524 | + } |
| 2525 | + |
| 2526 | + arlist.add(districts); |
| 2527 | + arlist.add(fileTypes); |
| 2528 | + |
| 2529 | + return arlist; |
| 2530 | + |
| 2531 | + } |
| 2532 | + |
| 2533 | + /* |
| 2534 | + * Function to load State and FileType by District Author: Alok Kumar |
| 2535 | + */ |
| 2536 | + |
| 2537 | + @RequestMapping("/loadStateAndFileTypeByDistrict") |
| 2538 | + public @ResponseBody ArrayList<Map<String, Integer>> getStateAndFileTypeByDistrict( |
| 2539 | + @RequestParam(value = "stateId") int stateId, @RequestParam(value = "districtId") int districtId, |
| 2540 | + @RequestParam(value = "fileTypeId") int fileTypeId) { |
| 2541 | + ArrayList<Map<String, Integer>> arlist = new ArrayList<>(); |
| 2542 | + |
| 2543 | + Map<String, Integer> states = new TreeMap<>(); |
| 2544 | + Map<String, Integer> fileTypes = new TreeMap<>(); |
| 2545 | + |
| 2546 | + State state = stateId != 0 ? stateService.findById(stateId) : null; |
| 2547 | + District district = districtId != 0 ? disService.findById(districtId) : null; |
| 2548 | + Map<Integer, String> fileTypeIdAndValue = fileTypeId != 0 ? ServiceUtility.getFileTypeIdAndValue(fileTypeId) |
| 2549 | + : null; |
| 2550 | + |
| 2551 | + List<StateDistrictMapping> sdm = district != null ? stateDistrictMappingService.findByDistrict(district) |
| 2552 | + : stateDistrictMappingService.findAll(); |
| 2553 | + List<ProjectReport> prList = projectReportService.findByStateDistrictMappingInAndStatusTrue(sdm); |
| 2554 | + List<ProjectReport> newprList = new ArrayList<>(); |
| 2555 | + if (fileTypeIdAndValue != null && !fileTypeIdAndValue.isEmpty()) { |
| 2556 | + Map.Entry<Integer, String> entry = fileTypeIdAndValue.entrySet().iterator().next(); |
| 2557 | + int id = entry.getKey(); |
| 2558 | + for (ProjectReport temp : prList) { |
| 2559 | + if (ServiceUtility.isProjectReportFilePresent(temp, id)) { |
| 2560 | + newprList.add(temp); |
| 2561 | + } |
| 2562 | + } |
| 2563 | + } |
| 2564 | + |
| 2565 | + if (!newprList.isEmpty()) |
| 2566 | + prList = newprList; |
| 2567 | + |
| 2568 | + for (ProjectReport pr : prList) { |
| 2569 | + // To find State |
| 2570 | + State stateTemp = pr.getStateDistrictMapping().getState(); |
| 2571 | + int prStateId = stateTemp.getId(); |
| 2572 | + states.put(stateTemp.getStateName(), stateTemp.getId()); |
| 2573 | + |
| 2574 | + // To find FileType |
| 2575 | + if (stateId == 0 || prStateId == stateId) { |
| 2576 | + ServiceUtility.getFileTypeIdAndValueforProjectReport(pr).forEach((id, type) -> fileTypes.put(type, id)); |
| 2577 | + } |
| 2578 | + |
| 2579 | + } |
| 2580 | + |
| 2581 | + arlist.add(states); |
| 2582 | + arlist.add(fileTypes); |
| 2583 | + |
| 2584 | + return arlist; |
| 2585 | + |
| 2586 | + } |
| 2587 | + |
| 2588 | + /* |
| 2589 | + * Function to load State and District by FileType Author: Alok Kumar |
| 2590 | + */ |
| 2591 | + |
| 2592 | + @RequestMapping("/loadStateAndDistrictByFileType") |
| 2593 | + public @ResponseBody ArrayList<Map<String, Integer>> getStateAndDistrictByFileType( |
| 2594 | + @RequestParam(value = "stateId") int stateId, @RequestParam(value = "districtId") int districtId, |
| 2595 | + @RequestParam(value = "fileTypeId") int fileTypeId) { |
| 2596 | + |
| 2597 | + ArrayList<Map<String, Integer>> arlist = new ArrayList<>(); |
| 2598 | + Map<String, Integer> states = new TreeMap<>(); |
| 2599 | + Map<String, Integer> districts = new TreeMap<>(); |
| 2600 | + |
| 2601 | + State state = stateId != 0 ? stateService.findById(stateId) : null; |
| 2602 | + District district = districtId != 0 ? disService.findById(districtId) : null; |
| 2603 | + |
| 2604 | + Map<Integer, String> fileTypeIdAndValue = fileTypeId != 0 ? ServiceUtility.getFileTypeIdAndValue(fileTypeId) |
| 2605 | + : null; |
| 2606 | + |
| 2607 | + List<StateDistrictMapping> localstateDistrictList = new ArrayList<>(); |
| 2608 | + if (district != null) { |
| 2609 | + localstateDistrictList = stateDistrictMappingService.findByDistrict(district); |
| 2610 | + } else { |
| 2611 | + localstateDistrictList = stateDistrictMappingService.findAll(); |
| 2612 | + } |
| 2613 | + |
| 2614 | + List<ProjectReport> prList = projectReportService |
| 2615 | + .findByStateDistrictMappingInAndStatusTrue(localstateDistrictList); |
| 2616 | + List<ProjectReport> newprList = new ArrayList<>(); |
| 2617 | + if (fileTypeIdAndValue != null && !fileTypeIdAndValue.isEmpty()) { |
| 2618 | + Map.Entry<Integer, String> entry = fileTypeIdAndValue.entrySet().iterator().next(); |
| 2619 | + int id = entry.getKey(); |
| 2620 | + for (ProjectReport temp : prList) { |
| 2621 | + if (ServiceUtility.isProjectReportFilePresent(temp, id)) { |
| 2622 | + newprList.add(temp); |
| 2623 | + } |
| 2624 | + } |
| 2625 | + } |
| 2626 | + |
| 2627 | + if (!newprList.isEmpty()) |
| 2628 | + prList = newprList; |
| 2629 | + |
| 2630 | + for (ProjectReport pr : prList) { |
| 2631 | + // To find State |
| 2632 | + State stateTemp = pr.getStateDistrictMapping().getState(); |
| 2633 | + states.put(stateTemp.getStateName(), stateTemp.getId()); |
| 2634 | + |
| 2635 | + } |
| 2636 | + |
| 2637 | + // to find districts |
| 2638 | + |
| 2639 | + if (state != null) { |
| 2640 | + localstateDistrictList = stateDistrictMappingService.findByState(state); |
| 2641 | + } else { |
| 2642 | + localstateDistrictList = stateDistrictMappingService.findAll(); |
| 2643 | + } |
| 2644 | + |
| 2645 | + prList = projectReportService.findByStateDistrictMappingInAndStatusTrue(localstateDistrictList); |
| 2646 | + List<ProjectReport> newprList1 = new ArrayList<>(); |
| 2647 | + if (fileTypeIdAndValue != null && !fileTypeIdAndValue.isEmpty()) { |
| 2648 | + Map.Entry<Integer, String> entry = fileTypeIdAndValue.entrySet().iterator().next(); |
| 2649 | + int id = entry.getKey(); |
| 2650 | + for (ProjectReport temp : prList) { |
| 2651 | + if (ServiceUtility.isProjectReportFilePresent(temp, id)) { |
| 2652 | + newprList1.add(temp); |
| 2653 | + } |
| 2654 | + } |
| 2655 | + } |
| 2656 | + if (!newprList1.isEmpty()) |
| 2657 | + prList = newprList1; |
| 2658 | + |
| 2659 | + for (ProjectReport pr : prList) { |
| 2660 | + |
| 2661 | + District dis = pr.getStateDistrictMapping().getDistrict(); |
| 2662 | + districts.put(dis.getDistrictName(), dis.getId()); |
| 2663 | + |
| 2664 | + } |
| 2665 | + |
| 2666 | + arlist.add(states); |
| 2667 | + arlist.add(districts); |
| 2668 | + |
| 2669 | + return arlist; |
| 2670 | + |
| 2671 | + } |
| 2672 | + |
2447 | 2673 | /********************************** Projet Report End *************************/ |
2448 | 2674 |
|
2449 | 2675 | @RequestMapping("/loadTopicByCategoryInAssignContri") |
|
0 commit comments