From 25f8499abdcac2bcacba9563ce41a14ce8951f14 Mon Sep 17 00:00:00 2001 From: AJITHKUMAR12 Date: Wed, 14 May 2025 16:47:18 +0530 Subject: [PATCH] education commit --- .../Controller/BuildingAssetController.java | 557 ++++++ .../Controller/DropdownsController.java | 477 +++++ backend/school/Controller/MainController.java | 128 ++ .../Controller/SchoolPropertyController.java | 720 ++++++++ .../Controller/SchoolReportController.java | 48 + .../school/Service/BuildingAssetService.java | 1030 +++++++++++ backend/school/Service/DropdownsService.java | 188 ++ .../school/Service/SchoolPropertyService.java | 970 ++++++++++ .../school/Service/SchoolReportService.java | 298 ++++ frontend/school/addelectricalasset.html | 732 ++++++++ frontend/school/addfurnitureasset.html | 728 ++++++++ frontend/school/assetmanagement.html | 819 +++++++++ frontend/school/building.html | 1582 ++++++++++++++++ frontend/school/dashboard.html | 322 ++++ frontend/school/drinkingwater.html | 1525 ++++++++++++++++ frontend/school/electricalassets.html | 405 +++++ frontend/school/furnitureassets.html | 411 +++++ frontend/school/itassets.html | 602 +++++++ frontend/school/kitchen.html | 930 ++++++++++ frontend/school/otherdetails.html | 982 ++++++++++ frontend/school/playground.html | 815 +++++++++ frontend/school/reports.html | 478 +++++ frontend/school/room.html | 827 +++++++++ frontend/school/roomassets.html | 1589 +++++++++++++++++ frontend/school/staffdetails.html | 775 ++++++++ frontend/school/studentdetails.html | 687 +++++++ frontend/school/toilets.html | 567 ++++++ 27 files changed, 19192 insertions(+) create mode 100644 backend/school/Controller/BuildingAssetController.java create mode 100644 backend/school/Controller/DropdownsController.java create mode 100644 backend/school/Controller/MainController.java create mode 100644 backend/school/Controller/SchoolPropertyController.java create mode 100644 backend/school/Controller/SchoolReportController.java create mode 100644 backend/school/Service/BuildingAssetService.java create mode 100644 backend/school/Service/DropdownsService.java create mode 100644 backend/school/Service/SchoolPropertyService.java create mode 100644 backend/school/Service/SchoolReportService.java create mode 100644 frontend/school/addelectricalasset.html create mode 100644 frontend/school/addfurnitureasset.html create mode 100644 frontend/school/assetmanagement.html create mode 100644 frontend/school/building.html create mode 100644 frontend/school/dashboard.html create mode 100644 frontend/school/drinkingwater.html create mode 100644 frontend/school/electricalassets.html create mode 100644 frontend/school/furnitureassets.html create mode 100644 frontend/school/itassets.html create mode 100644 frontend/school/kitchen.html create mode 100644 frontend/school/otherdetails.html create mode 100644 frontend/school/playground.html create mode 100644 frontend/school/reports.html create mode 100644 frontend/school/room.html create mode 100644 frontend/school/roomassets.html create mode 100644 frontend/school/staffdetails.html create mode 100644 frontend/school/studentdetails.html create mode 100644 frontend/school/toilets.html diff --git a/backend/school/Controller/BuildingAssetController.java b/backend/school/Controller/BuildingAssetController.java new file mode 100644 index 0000000..164018e --- /dev/null +++ b/backend/school/Controller/BuildingAssetController.java @@ -0,0 +1,557 @@ +package in.gov.chennaicorporation.gccoffice.school.Controller; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import in.gov.chennaicorporation.gccoffice.school.Service.BuildingAssetService; +import in.gov.chennaicorporation.gccoffice.school.Service.SchoolPropertyService; + +@RestController +@RequestMapping("/gcc/api/gccschool/buildingasset") +public class BuildingAssetController { + + private BuildingAssetService buildingAssetService; + + @Autowired + public BuildingAssetController(BuildingAssetService buildingAssetService) { + this.buildingAssetService = buildingAssetService; + } + + // For Buildings + @PostMapping(value = "/saveBuildings") + public String saveBuildings(@RequestBody List> buildingList) { + try { + for (Map building : buildingList) { + String building_name = (String) building.get("building_name"); + int total_floor = Integer.parseInt(building.get("total_floor").toString()); + int building_material = Integer.parseInt(building.get("building_material").toString()); + int roof_material = Integer.parseInt(building.get("roof_material").toString()); + // int building_order = + // Integer.parseInt(building.get("building_order").toString()); + int school_id = Integer.parseInt(building.get("school_id").toString()); + int check_building = buildingAssetService.checkBuilding(building_name, school_id); + if (check_building == 1) { + return "Building Name Alredy Exist"; + } else if (check_building == 5) { + return "error"; + } + int building_id = buildingAssetService.saveBuildings(building_name, total_floor, building_material, + roof_material, school_id); + System.out.println("Hi"); + for (int i = 1; i <= total_floor; i++) { + Map floor = buildingAssetService.getFloor(i); + + String floor_name = (String) floor.get("content"); + int floor_master_id = Integer.parseInt(floor.get("floor_master_id").toString()); + buildingAssetService.saveFloor(floor_name, building_id, floor_master_id, school_id); + System.out.println("Saved Floor Master ID: " + floor_master_id); + } + } + return "Building Saved sucessfully"; + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + + // To Get Saved Buildings + @GetMapping("/getSavedBuildings") + public ResponseEntity> getSavedBuildings(int school_id) { + try { + List> data = buildingAssetService.getSavedBuildings(school_id); + int lastId = buildingAssetService.getLastBuildingOrder(school_id); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + response.put("lastId", lastId); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + response.put("lastId", lastId); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + // Log the exception details for debugging + e.printStackTrace(); + + // Provide a user-friendly error message + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + + // To Get floor Data by buildings + @GetMapping("/getFloorDetails") + public ResponseEntity> getFloorDetails(int building_id) { + try { + List> data = buildingAssetService.getFloorDetails(building_id); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + } + + return ResponseEntity.ok(response); + } catch (Exception e) { + // Log the exception details for debugging + e.printStackTrace(); + + // Provide a user-friendly error message + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + + // For Room mapping --add room + /* + * @PostMapping(value = "/saveRoom") public String saveRoom(@RequestBody + * Map rooms) { try { int building_id = (int) + * rooms.get("building_id"); int floors_id = (int) rooms.get("floors_id"); int + * room_type = Integer.parseInt(rooms.get("room_type").toString()); + * + * String room_num = (String) rooms.get("room_num"); int school_id = (int) + * rooms.get("school_id"); buildingAssetService.saveRoomDetails(room_type, + * room_num, building_id, floors_id, school_id); return + * "Rooms Mapped Sucessfully"; } catch (Exception e) { e.printStackTrace(); + * return "error"; } } + */ + + // vishnu save + @PostMapping(value = "/saveRoom") + public String saveRoom(@RequestBody Map rooms) { + try { + int building_id = Integer.parseInt(rooms.get("building_id").toString()); + int floors_id = Integer.parseInt(rooms.get("floors_id").toString()); + int room_type = Integer.parseInt(rooms.get("room_type").toString()); + String room_num = rooms.get("room_num").toString(); + int school_id = Integer.parseInt(rooms.get("school_id").toString()); + + buildingAssetService.saveRoomDetails(room_type, room_num, building_id, floors_id, school_id); + return "Rooms Mapped Sucessfully"; + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + + // For Edit Room mapping +// @PostMapping(value = "/editRoom") +// public String editRoom(@RequestBody Map rooms) { +// try { +// int room_id = (int) rooms.get("room_id"); +// int building_id = (int) rooms.get("building_id"); +// int floors_id = (int) rooms.get("floors_id"); +// int room_type = (int) rooms.get("room_type"); +// String room_num = (String) rooms.get("room_num"); +// int school_id = (int) rooms.get("school_id"); +// buildingAssetService.editRoom(room_type, room_num, building_id, floors_id, school_id, room_id); +// return "Rooms Edited Sucessfully"; +// } catch (Exception e) { +// e.printStackTrace(); +// return "error"; +// } +// } + + // vishnu edit room + @PostMapping(value = "/editRoom") + public String editRoom(@RequestBody Map rooms) { + try { + if (rooms.get("room_id") == null || rooms.get("building_id") == null || rooms.get("floors_id") == null + || rooms.get("room_type") == null || rooms.get("room_num") == null + || rooms.get("school_id") == null) { + + return "Missing required fields"; + } + + int room_id = Integer.parseInt(rooms.get("room_id").toString()); + int building_id = Integer.parseInt(rooms.get("building_id").toString()); + int floors_id = Integer.parseInt(rooms.get("floors_id").toString()); + int room_type = Integer.parseInt(rooms.get("room_type").toString()); + String room_num = rooms.get("room_num").toString(); + int school_id = Integer.parseInt(rooms.get("school_id").toString()); + + buildingAssetService.editRoom(room_type, room_num, building_id, floors_id, school_id, room_id); + return "Rooms Edited Sucessfully"; + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + + // For Delete Room mapping + /* + * @PostMapping(value = "/deleteRoom") public String deleteRoom(@RequestParam + * int room_id, @RequestParam boolean is_delete) { try { // // from assets // + * List> assets = buildingAssetService.getAssets(room_id); + * // if(!assets.isEmpty()) { // for(Map asset : assets) { // // + * } // } buildingAssetService.deleteRoom(room_id, is_delete); return + * "Rooms Edited Sucessfully"; } catch (Exception e) { e.printStackTrace(); + * return "error"; } } + */ +//vishnu + + @GetMapping("/getBuildingbyid") + public ResponseEntity> getSimpleBuilding(@RequestParam int building_id) { + try { + Map building = buildingAssetService.getSimpleBuildingById(building_id); + if (building != null) { + return ResponseEntity.ok(Map.of("status", "OK", "data", building)); + } else { + return ResponseEntity.status(HttpStatus.NOT_FOUND) + .body(Map.of("status", "Failed", "message", "Building not found")); + } + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Something went wrong")); + } + } + + @GetMapping("/getAllMaterials") + public ResponseEntity> getAllMaterials() { + try { + Map>> materials = buildingAssetService.getAllMaterials(); + + return ResponseEntity.ok(Map.of("status", "OK", "buildingMaterials", materials.get("buildingMaterials"), + "roofMaterials", materials.get("roofMaterials"))); + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Failed to load material data")); + } + } + + @GetMapping("/getFloorsByBuildingId") + public ResponseEntity> getFloorsByBuildingId(@RequestParam int buildingId) { + try { + List> floors = buildingAssetService.getFloorsByBuildingId(buildingId); + + return ResponseEntity.ok(Map.of("status", "OK", "floors", floors)); + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Could not load floor list")); + } + } + + @PostMapping(value = "/deleteBuilding") + public String deleteBuilding(@RequestParam int building_id, @RequestParam boolean is_delete) { + + return buildingAssetService.executeDelete(building_id, is_delete); + + } + + @PostMapping(value = "/deleteRoom") + public String deleteRoom(@RequestParam int room_id, @RequestParam boolean is_delete) { + try { + // from assets + List asset_ID = buildingAssetService.getassetRoomID(room_id); + List> electrical_asset = buildingAssetService.getElectricalAssetMasterByRoomId(room_id); + List> furniture_asset = buildingAssetService.getFurnitureAssetMasterByRoomId(room_id); + for (Integer it_details_id : asset_ID) { + buildingAssetService.unmapItAssetMaster(it_details_id); + } + for (Map ele_data : electrical_asset) { + int school_id = (Integer) ele_data.get("school_id"); + int sub_asset_id = (Integer) ele_data.get("sub_asset_id"); + int asset_qty = (Integer) ele_data.get("asset_qty"); + String assetType = "electricalasset"; + Map assetMaster = buildingAssetService.getAssetMasterBySchlId(sub_asset_id, school_id, + assetType); + int mapped = assetMaster.get("mapped_qty") != null ? (Integer) assetMaster.get("mapped_qty") : 0; + int unMapped = assetMaster.get("unmapped_qty") != null ? (Integer) assetMaster.get("unmapped_qty") : 0; + int map = mapped - asset_qty; + int unMap = unMapped + asset_qty; + buildingAssetService.updateAssetmaster(map, unMap, school_id, sub_asset_id, assetType); + } + for (Map fur_data : furniture_asset) { + int school_id = (Integer) fur_data.get("school_id"); + int sub_asset_id = (Integer) fur_data.get("sub_asset_id"); + int asset_qty = (Integer) fur_data.get("asset_qty"); + String assetType = "furnitureasset"; + Map assetMaster = buildingAssetService.getAssetMasterBySchlId(sub_asset_id, school_id, + assetType); + int mapped = assetMaster.get("mapped_qty") != null ? (Integer) assetMaster.get("mapped_qty") : 0; + int unMapped = assetMaster.get("unmapped_qty") != null ? (Integer) assetMaster.get("unmapped_qty") : 0; + int map = mapped - asset_qty; + int unMap = unMapped + asset_qty; + buildingAssetService.updateAssetmaster(map, unMap, school_id, sub_asset_id, assetType); + } + buildingAssetService.unmapAssets(room_id, is_delete); + buildingAssetService.deleteRoom(room_id, is_delete); + return "Rooms Edited Sucessfully"; + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + + @PostMapping(value = "/editBuildings") + public String editBuilding(@RequestParam int building_id, @RequestParam int floor_id) { + + return buildingAssetService.editBuildings(building_id, floor_id); + } + + @PostMapping(value = "/addFloor") + public String addFloor(@RequestParam int building_id, @RequestParam int exe_order) { + return buildingAssetService.addFloor(building_id, exe_order); + } + + @PostMapping(value = "/updateBuilding") + public String updateBuilding(@RequestParam int building_id, @RequestParam String building_name, + @RequestParam int total_floor, @RequestParam String building_material, @RequestParam String roof_material, + @RequestParam int school_id) { + try { + buildingAssetService.updateBuilding(building_id, building_name, total_floor, building_material, + roof_material, school_id); + return "Success"; + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } + } + + @GetMapping("/getRoomDetails") + public ResponseEntity> getRoomDetails(@RequestParam int school_id) { + try { + List> data = buildingAssetService.getRoomDetailsBySchoolId(school_id); + Map response = new HashMap<>(); + + if (data != null && !data.isEmpty()) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + } + + return ResponseEntity.ok(response); + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error fetching room details: " + e.getMessage())); + } + } + + @GetMapping("/getRoomById") + public ResponseEntity> getRoomById(@RequestParam int room_id) { + try { + Map room = buildingAssetService.getRoomDetailsById(room_id); + return ResponseEntity.ok(Map.of("status", "OK", "data", room)); + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "ERROR", "data", "Room not found")); + } + } + + @GetMapping(value = "/getItAssetMapping") + public ResponseEntity> getItAssetMapping(int room_id, String assetType) { + Map response = new HashMap<>(); + List> data = buildingAssetService.getItAssetMapping(room_id, assetType); + response.put("Status", "OK"); + response.put("data", data); + return ResponseEntity.ok(response); + + } + + @PostMapping(value = "/deleteAssetMapping") + public ResponseEntity> deleteAssetMapping(int it_map_id, boolean is_delete) { + Map response = new HashMap<>(); + Map it_Details = buildingAssetService.getIt_Details(it_map_id); + int it_details_id = (Integer) it_Details.get("it_details_id"); + String data = buildingAssetService.deleteAssetMapping(it_map_id, is_delete); + buildingAssetService.unmapItAssetMaster(it_details_id); + response.put("status", "Sucess"); + response.put("data", data); + return ResponseEntity.ok(response); + + } + + // For update assets + @PostMapping(value = "/updateassets") + public String updateassets(@RequestBody List> assets) { + return buildingAssetService.updateAssetExecution(assets); + } + + @GetMapping(value = "/getSchoolAsset") + public ResponseEntity> getSchoolAsset(@RequestParam int school_id, @RequestParam String type) { + Map response = new HashMap<>(); + List> data = buildingAssetService.getSchoolAsset(school_id, type); + if (!data.isEmpty()) { + response.put("status", "Success"); + response.put("data", data); + } else { + response.put("status", "Error"); + } + return ResponseEntity.ok(response); + } + + @PostMapping(value = "/mapAssets") + public String mapAssets(@RequestBody List> assets) { + try { + for (Map asset : assets) { + int room_id = Integer.parseInt(asset.get("room_id").toString()); + int floor_id = Integer.parseInt(asset.get("floor_id").toString()); + int school_id = Integer.parseInt(asset.get("school_id").toString()); + int it_details_id = Integer.parseInt(asset.get("it_details_id").toString()); + int building_id = Integer.parseInt(asset.get("building_id").toString()); + buildingAssetService.mapAssets(room_id, floor_id, school_id, it_details_id, building_id); + } + return "Success"; + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } + + } + + @PostMapping(value = "/addFurAsset") + public String addFurAsset(@RequestParam int sub_asset_id, @RequestParam int asset_qty, @RequestParam int room_id, + @RequestParam int building_id, @RequestParam int floor_id, @RequestParam int school_id, + @RequestParam String assetType) { + + return buildingAssetService.assetUpdation(asset_qty, assetType, sub_asset_id, school_id, room_id, building_id, + floor_id); + } + + // Asset Management + + @GetMapping(value = "/getAssetManagement") + public ResponseEntity> getSchoolAssetForManagement(@RequestParam int school_id) { + Map response = new HashMap<>(); + List> data = buildingAssetService.getSchoolAssetForManagement(school_id); + if (!data.isEmpty()) { + response.put("status", "Sucess"); + response.put("data", data); + } else { + response.put("status", "Error"); + } + return ResponseEntity.ok(response); + } + + @PostMapping(value = "/addAsset") + public String addAsset(@RequestParam String code, @RequestParam String name, @RequestParam String source, + @RequestParam String serialNum, @RequestParam String vendorDetail, @RequestParam String invoice_num, + @RequestParam String udise, @RequestParam boolean is_online, @RequestParam int school_id) { + try { + int count = buildingAssetService.getAssetCount(udise, is_online); + String assetCode = ""; + if (count >= 0) { + String series = String.format("%04d", count + 1); + String school = String.format("%03d", school_id); + assetCode = code + school + series; + + } else { + return "Error"; + } + return buildingAssetService.addAsset(assetCode, name, source, serialNum, vendorDetail, invoice_num, udise, + is_online); + + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } + + } + + @GetMapping(value = "/getAssets") + public ResponseEntity> getAssets(@RequestParam int it_details_id) { + Map response = new HashMap<>(); + Map data = buildingAssetService.getAssets(it_details_id); + if (!data.isEmpty()) { + response.put("status", "Success"); + response.put("data", data); + } else { + response.put("Status", "Error"); + } + return ResponseEntity.ok(response); + } + + @PostMapping(value = "/editAsset") + public String editAsset(@RequestParam String assetCode, @RequestParam String name, @RequestParam String source, + @RequestParam String serialNum, @RequestParam String vendorDetail, @RequestParam String invoice_num, + @RequestParam int it_details_id) { + try { + + return buildingAssetService.editAsset(assetCode, name, source, serialNum, vendorDetail, invoice_num, + it_details_id); + + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } + + } + + @GetMapping("/getStudentStrengthBySchoolId") + public ResponseEntity> getStudentStrengthBySchoolId(@RequestParam int schoolId) { + try { + List> studentStrength = buildingAssetService.getStudentStrengthBySchoolId(schoolId); + + if (!studentStrength.isEmpty()) { + return ResponseEntity.ok(Map.of("status", "OK", "studentStrength", studentStrength)); + } else { + return ResponseEntity.ok(Map.of("status", "NEW", "studentStrength", studentStrength)); + } + + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Could not load student strength data")); + } + } + + @GetMapping("/getotherdetailsBySchoolId") + public ResponseEntity> getotherdetailsBySchoolId(@RequestParam int schoolId) { + try { + List> getotherdetailsBySchool = buildingAssetService + .getotherdetailsBySchoolId(schoolId); + + if (!getotherdetailsBySchool.isEmpty()) { + return ResponseEntity.ok(Map.of("status", "OK", "otherdetailsBySchool", getotherdetailsBySchool)); + } else { + return ResponseEntity.ok(Map.of("status", "NEW", "otherdetailsBySchool", getotherdetailsBySchool)); + } + + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Could not load student strength data")); + } + } + + @GetMapping("/getStaffStrengthBySchoolId") + public ResponseEntity> getStaffStrengthBySchoolId(@RequestParam int schoolId) { + try { + List> staffStrength = buildingAssetService.getStaffStrengthBySchoolId(schoolId); + + if (!staffStrength.isEmpty()) { + return ResponseEntity.ok(Map.of("status", "OK", "staffStrength", staffStrength)); + } else { + return ResponseEntity.ok(Map.of("status", "NEW", "staffStrength", staffStrength)); + } + + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Could not load student strength data")); + } + } + +} diff --git a/backend/school/Controller/DropdownsController.java b/backend/school/Controller/DropdownsController.java new file mode 100644 index 0000000..7abdf8b --- /dev/null +++ b/backend/school/Controller/DropdownsController.java @@ -0,0 +1,477 @@ +package in.gov.chennaicorporation.gccoffice.school.Controller; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import in.gov.chennaicorporation.gccoffice.school.Service.DropdownsService; + +@RestController +@RequestMapping("/gcc/api/gccschool/dropdown") +public class DropdownsController { + @Autowired + private DropdownsService dropdownsService; + + @Autowired + public DropdownsController(DropdownsService dropdownsService) { + this.dropdownsService = dropdownsService; + } + + // To Get Court Dropdown Data + @GetMapping("/getCourtData") + public ResponseEntity> getCourtData() { + try { + List> data = dropdownsService.getCourtData(); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + // Log the exception details for debugging + e.printStackTrace(); + + // Provide a user-friendly error message + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + + // To Get Equipmengt Dropdown Data + @GetMapping("/getEquipmentData") + public ResponseEntity> getEquipmentData() { + try { + List> data = dropdownsService.getEquipmentData(); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + // Log the exception details for debugging + e.printStackTrace(); + + // Provide a user-friendly error message + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + + // To Get Building Material Dropdown Data + @GetMapping("/getBuildingMaterial") + public ResponseEntity> getBuildingMaterial() { + try { + List> data = dropdownsService.getBuildingMaterial(); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + // Log the exception details for debugging + e.printStackTrace(); + + // Provide a user-friendly error message + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + + // To Get Roof Material Dropdown Data + @GetMapping("/getRoofMaterial") + public ResponseEntity> getRoofMaterial() { + try { + List> data = dropdownsService.getRoofMaterial(); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + // Log the exception details for debugging + e.printStackTrace(); + + // Provide a user-friendly error message + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + + // To Get Water Source Dropdown Data + @GetMapping("/getWaterSource") + public ResponseEntity> getWaterSource() { + try { + List> data = dropdownsService.getWaterSource(); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + // Log the exception details for debugging + e.printStackTrace(); + + // Provide a user-friendly error message + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + + // To Get Water Storage Dropdown Data + @GetMapping("/getWaterStorage") + public ResponseEntity> getWaterStorage() { + try { + List> data = dropdownsService.getWaterStorage(); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + // Log the exception details for debugging + e.printStackTrace(); + + // Provide a user-friendly error message + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + + // To Get Rooms Dropdown Data + @GetMapping("/getRooms") + public ResponseEntity> getRooms() { + try { + List> data = dropdownsService.getRooms(); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + // Log the exception details for debugging + e.printStackTrace(); + + // Provide a user-friendly error message + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + + @GetMapping("/getFloorsByBuilding") + public ResponseEntity> getFloorsByBuilding(@RequestParam("building_id") int buildingId) { + try { + List> data = dropdownsService.getFloorsByBuilding(buildingId); + Map response = new HashMap<>(); + if (!data.isEmpty()) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No floors found for the selected building."); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Failed to fetch floors.")); + } + } + + @GetMapping("/getBuildingsBySchoolId") + public ResponseEntity> getBuildingsBySchoolId(@RequestParam int school_id) { + try { + List> data = dropdownsService.getBuildingsBySchoolId(school_id); + Map response = new HashMap<>(); + if (!data.isEmpty()) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No buildings found for the selected school."); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Failed to fetch buildings.")); + } + } + + @GetMapping("/getDropdownValues") + public List> getDropdownValues(@RequestParam String user_id) { + List> resultList = new ArrayList<>(); + Map response = new HashMap<>(); + + String schoolId = dropdownsService.getSchoolId(user_id); + if (schoolId == null || schoolId.trim().isEmpty() || schoolId.equalsIgnoreCase("error")) { + response.put("Message", "Failure"); + response.put("Data", List.of()); + resultList.add(response); + return resultList; + } + + List> udiseData = dropdownsService.getUdiseNumbersBySchoolId(schoolId); + if (!udiseData.isEmpty()) { + List udiseList = udiseData.stream().map(m -> (String) m.get("udise")).collect(Collectors.toList()); + + response.put("Message", "Success"); + response.put("Data", udiseList); + } else { + response.put("Message", "No Data Found"); + response.put("Data", List.of()); + } + + resultList.add(response); + return resultList; + } + + @GetMapping("/getCategoryValues") + public List> getCategoryValues(@RequestParam String user_id) { + List> resultList = new ArrayList<>(); + Map response = new HashMap<>(); + + String schoolId = dropdownsService.getSchoolId(user_id); + if (schoolId == null || schoolId.trim().isEmpty() || schoolId.equalsIgnoreCase("error")) { + response.put("Message", "Failure"); + response.put("Data", List.of()); + resultList.add(response); + return resultList; + } + + List> categoryData = dropdownsService.getCategoryBySchoolId(schoolId); + if (!categoryData.isEmpty()) { + List categoryList = categoryData.stream().map(m -> (String) m.get("category")) + .collect(Collectors.toList()); + + response.put("Message", "Success"); + response.put("Data", categoryList); + } else { + response.put("Message", "No Data Found"); + response.put("Data", List.of()); + } + + resultList.add(response); + return resultList; + } + + @GetMapping("/getZoneValues") + public List> getZoneValues(@RequestParam String user_id) { + List> resultList = new ArrayList<>(); + Map response = new HashMap<>(); + + String schoolId = dropdownsService.getSchoolId(user_id); + if (schoolId == null || schoolId.trim().isEmpty() || schoolId.equalsIgnoreCase("error")) { + response.put("Message", "Failure"); + response.put("Data", List.of()); + resultList.add(response); + return resultList; + } + + List> zoneData = dropdownsService.getZoneBySchoolId(schoolId); + if (!zoneData.isEmpty()) { + List zoneList = zoneData.stream().map(m -> (String) m.get("zone")).collect(Collectors.toList()); + + response.put("Message", "Success"); + response.put("Data", zoneList); + } else { + response.put("Message", "No Data Found"); + response.put("Data", List.of()); + } + + resultList.add(response); + return resultList; + } + + @GetMapping("/getwardValues") + public List> getWardValues(@RequestParam String user_id) { + List> resultList = new ArrayList<>(); + Map response = new HashMap<>(); + + String schoolId = dropdownsService.getSchoolId(user_id); + if (schoolId == null || schoolId.trim().isEmpty() || schoolId.equalsIgnoreCase("error")) { + response.put("Message", "Failure"); + response.put("Data", List.of()); + resultList.add(response); + return resultList; + } + + List> wardData = dropdownsService.getWardBySchoolId(schoolId); + if (!wardData.isEmpty()) { + List wardList = wardData.stream().map(m -> (String) m.get("division")).collect(Collectors.toList()); + + response.put("Message", "Success"); + response.put("Data", wardList); + } else { + response.put("Message", "No Data Found"); + response.put("Data", List.of()); + } + + resultList.add(response); + return resultList; + } + + @GetMapping("/getAllDropdownValues") + public ResponseEntity getAllDropdownValues(@RequestParam String user_id, @RequestParam String type) { + Map response = new HashMap<>(); + List dropdownList = Collections.emptyList(); + + // First get school_id(s) for this user + String schoolId = dropdownsService.getSchoolId(user_id); + + if (schoolId.equals("error")) { + response.put("Message", "Failed to fetch school ID"); + response.put("Data", dropdownList); + return ResponseEntity.ok(Collections.singletonList(response)); + } + + try { + List> rawData; + + switch (type.toLowerCase()) { + case "udise": + rawData = dropdownsService.getUdiseNumbersBySchoolId(schoolId); + dropdownList = rawData.stream().map(map -> String.valueOf(map.get("udise"))) + .collect(Collectors.toList()); + break; + case "category": + rawData = dropdownsService.getCategoryBySchoolId(schoolId); + dropdownList = rawData.stream().map(map -> String.valueOf(map.get("category"))).distinct() + .collect(Collectors.toList()); + break; + case "zone": + rawData = dropdownsService.getZoneBySchoolId(schoolId); + dropdownList = rawData.stream().map(map -> String.valueOf(map.get("zone"))).distinct() + .collect(Collectors.toList()); + break; + case "ward": + rawData = dropdownsService.getWardBySchoolId(schoolId); + dropdownList = rawData.stream().map(map -> String.valueOf(map.get("division"))).distinct() + .collect(Collectors.toList()); + break; + default: + response.put("Message", "Invalid dropdown type"); + response.put("Data", dropdownList); + return ResponseEntity.badRequest().body(Collections.singletonList(response)); + } + + response.put("Message", "Success"); + response.put("Data", dropdownList); + return ResponseEntity.ok(Collections.singletonList(response)); + } catch (Exception e) { + e.printStackTrace(); + response.put("Message", "Error while processing dropdown values"); + response.put("Data", dropdownList); + return ResponseEntity.ok(Collections.singletonList(response)); + } + } + + // To Get Asset Types Data + @GetMapping("/getAssetType") + public ResponseEntity> getAssetType() { + try { + List> data = dropdownsService.getAssetType(); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + // Log the exception details for debugging + e.printStackTrace(); + + // Provide a user-friendly error message + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + + // To Get Sub Asset Types Data + @GetMapping("/getSubAssetType") + public ResponseEntity> getSubAssetType(int assetid) { + try { + List> data = dropdownsService.getSubAssetType(assetid); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + + e.printStackTrace(); + + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + + @GetMapping("/getSplSubAssetType") + public ResponseEntity> getSplSubAssetType(int school_id, int assetid) { + try { + List assets = dropdownsService.getAssetList(school_id, assetid); + List> data = dropdownsService.getSplSubAssetType(assets, assetid); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + + e.printStackTrace(); + + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + +} diff --git a/backend/school/Controller/MainController.java b/backend/school/Controller/MainController.java new file mode 100644 index 0000000..24775a8 --- /dev/null +++ b/backend/school/Controller/MainController.java @@ -0,0 +1,128 @@ +package in.gov.chennaicorporation.gccoffice.school.Controller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; + +@Controller("schoolcontroller") +@RequestMapping("/gcc/school") +public class MainController { + + @GetMapping("/otherdetails") + public String otherdetails(Model model) { + + return "modules/school/otherdetails"; + } + + @GetMapping("/schooldetails") + public String viewschool(Model model) { + return "modules/school/schooldetails"; + } + + @GetMapping("/schoolmodule") + public String viewmodule(Model model) { + String loginUserId = LoginUserInfo.getLoginUserId(); + model.addAttribute("user_id", loginUserId); + System.out.println("loginUserId..........." + loginUserId); + return "modules/school/dashboard"; + } + + @GetMapping("/staffdetails") + public String staffdetails(Model model) { + return "modules/school/staffdetails"; + } + + @GetMapping("/roomassets") + public String roomassets(Model model) { + + return "modules/school/roomassets"; + } + + @GetMapping("/assetmanagement") + public String assetmanagement(Model model) { + + return "modules/school/assetmanagement"; + } + +// @GetMapping("/itassets") +// public String itassets(Model model) { +// +// System.out.println("okokokok==="); +// +// return "modules/school/itassets"; +// } + + @GetMapping("/studentdetails") + public String studentdetails(Model model) { + + return "modules/school/studentdetails"; + } + + @GetMapping("/building") + public String buildings(Model model) { + + return "modules/school/building"; + } + + @GetMapping("/room") + public String roomlist(Model model) { + + return "modules/school/room"; + } + + @GetMapping("/playground") + public String playground(Model model) { + + return "modules/school/playground"; + } + + @GetMapping("/drinkingwater") + public String drinkingwater(Model model) { + + return "modules/school/drinkingwater"; + } + + @GetMapping("/toilets") + public String toilet(Model model) { + + return "modules/school/toilets"; + } + +// @GetMapping("/electricalassets") +// public String electricalassets(Model model) { +// +// return "modules/school/electricalassets"; +// } +// +// @GetMapping("/furnitureassets") +// public String furnitureassets(Model model) { +// +// return "modules/school/furnitureassets"; +// } + + @GetMapping("/kitchen") + public String kitchen(Model model) { + + return "modules/school/kitchen"; + } + + @GetMapping("/addelectricalasset") + public String addelectricalasset(Model model) { + + return "modules/school/addelectricalasset"; + } + + @GetMapping("/addfurnitureasset") + public String addfurnitureasset(Model model) { + + return "modules/school/addfurnitureasset"; + } + @GetMapping("/reports") + public String reportpage(Model model) { + + return "modules/school/reports"; + } +} \ No newline at end of file diff --git a/backend/school/Controller/SchoolPropertyController.java b/backend/school/Controller/SchoolPropertyController.java new file mode 100644 index 0000000..056f6e1 --- /dev/null +++ b/backend/school/Controller/SchoolPropertyController.java @@ -0,0 +1,720 @@ +package in.gov.chennaicorporation.gccoffice.school.Controller; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.transaction.Transactional; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import in.gov.chennaicorporation.gccoffice.school.Service.SchoolPropertyService; + +@RestController +@CrossOrigin() +@RequestMapping("/gcc/api/gccschool/schoolproperty") +public class SchoolPropertyController { + + @Autowired + private SchoolPropertyService schoolPropertyService; + + @Autowired + public SchoolPropertyController(SchoolPropertyService schoolPropertyService) { + this.schoolPropertyService = schoolPropertyService; + } + + // To Get School Data + @GetMapping("/getSchoolData") + public ResponseEntity> getSchoolData(@RequestParam String udise) { + try { + List> data = schoolPropertyService.getSchoolData(udise); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + } else { + response.put("status", "Failed"); + response.put("data", "No Data Found"); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + // Log the exception details for debugging + e.printStackTrace(); + + // Provide a user-friendly error message + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + +// For Other Details + @PostMapping(value = "/saveSchoolBuildupArea") + public String saveSchoolBuildupArea(@RequestParam("land_area") Double land_area, + @RequestParam("buildup_area") Double buildup_area, @RequestParam("is_compound") Boolean is_compound, + @RequestParam("is_nameboard") Boolean is_nameboard, @RequestParam("is_pasystem") Boolean is_pasystem, + @RequestParam("is_bell") Boolean is_bell, @RequestParam("is_generator") Boolean is_generator, + @RequestParam("school_id") int school_id) { + + return schoolPropertyService.saveSchoolBuildupArea(land_area, buildup_area, is_compound, is_nameboard, + is_pasystem, is_bell, is_generator, school_id); + } + +// For Student Strength + @PostMapping(value = "/saveStudentStrength") + public String saveStudentStrength(@RequestParam("total_students") int total_students, + @RequestParam("total_girls") int total_girls, @RequestParam("total_boys") int total_boys, + @RequestParam("others") int others, @RequestParam("school_id") int school_id) { + + return schoolPropertyService.saveStudentStrength(total_students, total_girls, total_boys, others, school_id); + } + +// For Staff Strength +// @PostMapping(value="/saveStaffStrength") +// public String saveStaffStrength( +// @RequestParam("tot_staff") int tot_staff, +// @RequestParam("sg_staff") int sg_staff, +// @RequestParam("bt_staff") int bt_staff, +// @RequestParam("pg_staff") int pg_staff, +// @RequestParam("temp_staff") int temp_staff, +// @RequestParam("ngo_staff") int ngo_staff, +// @RequestParam("kg_staff") int kg_staff, +// @RequestParam("pt_staff") int pt_staff, +// @RequestParam("part_staff") int part_staff, +// @RequestParam("qa_staff") int qa_staff, +// @RequestParam("kg_ayha") int kg_ayha, +// @RequestParam("watchman") int watchman, +// @RequestParam("comp_asst") int comp_asst, +// @RequestParam("scavengers") int scavengers, +// @RequestParam("maint_workers") int maint_workers, +// @RequestParam("school_id") int school_id) { +// +// return schoolPropertyService.saveStaffStrength(tot_staff, sg_staff, bt_staff,pg_staff, temp_staff, ngo_staff, kg_staff, pt_staff,part_staff, qa_staff, kg_ayha, watchman, comp_asst, scavengers, maint_workers, school_id); +// } + +// For Toilets + @PostMapping(value = "/saveToilets") + public String saveToilets(@RequestParam("total_toiletBlocks") int total_toiletBlocks, + @RequestParam("total_male_urinals") int total_male_urinals, + @RequestParam("total_wc_male") int total_wc_male, @RequestParam("total_wc_female") int total_wc_female, + @RequestParam("total_diffAbled_toilet") int total_diffAbled_toilet, + @RequestParam("is_napkins") Boolean is_napkins, @RequestParam("school_id") int school_id) { + + return schoolPropertyService.saveToilets(total_toiletBlocks, total_male_urinals, total_wc_male, total_wc_female, + total_diffAbled_toilet, is_napkins, school_id); + } + +// For Kitchen + @PostMapping(value = "/saveKitchen") + public String saveKitchen(@RequestParam(value = "is_cmbfs") Boolean is_cmbfs, + @RequestParam(value = "is_cmbfsIndividual", required = false) Boolean is_cmbfsIndividual, + @RequestParam(value = "is_noonmeal") Boolean is_noonmeal, + @RequestParam(value = "is_noonIndividual", required = false) Boolean is_noonIndividual, + @RequestParam(value = "is_vegGarden", required = false) Boolean is_vegGarden, + @RequestParam(value = "is_anganwadi") Boolean is_anganwadi, + @RequestParam(value = "anganwadi_unique", required = false) String anganwadi_unique, + @RequestParam(value = "is_anganwadiIndividual", required = false) Boolean is_anganwadiIndividual, + @RequestParam(value = "school_id") int school_id) { + + if (anganwadi_unique != null && anganwadi_unique.trim().isEmpty()) { + anganwadi_unique = null; + } + + return schoolPropertyService.saveKitchen(is_cmbfs, is_cmbfsIndividual, is_noonmeal, is_noonIndividual, + is_vegGarden, is_anganwadi, anganwadi_unique, is_anganwadiIndividual, school_id); + } + +// For Playground + @PostMapping(value = "/savePlayground") + public ResponseEntity> savePlayground(@RequestBody Map payload) { + Map response = new HashMap<>(); + try { + Boolean is_playground = (Boolean) payload.get("is_playground"); + Double playground_area = Double.valueOf(payload.get("playground_area").toString()); + Boolean is_court = (Boolean) payload.get("is_court"); + int school_id = Integer.parseInt(payload.get("school_id").toString()); + // Boolean is_active = (Boolean) payload.get("is_active"); + + List equipmentidRaw = (List) payload.get("equipmentid"); + List courtidRaw = (List) payload.get("courtid"); + + // Convert string IDs to integers +// List equipmentid = equipmentidRaw.stream().map(Integer::parseInt).toList(); +// List courtid = courtidRaw.stream().map(Integer::parseInt).toList(); + + int playground_id = schoolPropertyService.savePlayground(is_playground, playground_area, is_court, + school_id); + + for (String equipment_id : equipmentidRaw) { + schoolPropertyService.saveEquipmentDetails(equipment_id, school_id, playground_id); + } + + for (String court_id : courtidRaw) { + schoolPropertyService.saveCourtDetails(court_id, school_id, playground_id); + } + + response.put("status", "OK"); + response.put("message", "Playground Details saved successfully"); + return ResponseEntity.ok(response); + + } catch (Exception e) { + e.printStackTrace(); + response.put("status", "ERROR"); + response.put("message", "Failed to save playground details"); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + } + + // For Drinking Water + @PostMapping(value = "/saveDrinkingWater") + public ResponseEntity> saveDrinkingWater(@RequestBody Map requestData) { + try { + // Extract data from the map + List> water = (List>) requestData.get("water"); + Boolean is_purifier = "1".equals(requestData.get("is_purifier")); + Double purifier_capacity = requestData.get("purifier_capacity") != null + ? Double.valueOf(requestData.get("purifier_capacity").toString()) + : null; + Boolean is_borewell = "1".equals(requestData.get("is_borewell")); + Integer borewell_count = requestData.get("borewell_count") != null + ? Integer.valueOf(requestData.get("borewell_count").toString()) + : null; + Boolean is_storage = "1".equals(requestData.get("is_storage")); + List> storage = (List>) requestData.get("storage"); + int school_id = Integer.parseInt(requestData.get("school_id").toString()); + + Map response = new HashMap<>(); + + int drinking_water_id = schoolPropertyService.saveDrinkingWater(is_purifier, purifier_capacity, is_borewell, + borewell_count, is_storage, school_id); + for (Map waterSupply : water) { + int source_water_id = (int) waterSupply.get("source_water_id"); + String supply_type = (String) waterSupply.get("supply_type"); + schoolPropertyService.saveWaterSupply(source_water_id, supply_type, drinking_water_id, school_id); + } + if (!storage.isEmpty()) { + for (Map waterStorage : storage) { + double capacity = Double.valueOf(waterStorage.get("capacity").toString()); + int storage_water_id = (int) waterStorage.get("storage_water_id"); + schoolPropertyService.saveWaterStorage(capacity, storage_water_id, drinking_water_id, school_id); + } + } + + response.put("status", "OK"); + return ResponseEntity.ok(response); + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error saving data: " + e.getMessage())); + } + } + + @PostMapping("/saveStaffStrength") + public String saveStaffStrength(@RequestParam int sgRegTeacher, @RequestParam int sgTempTeacher, + @RequestParam int sgPtTeacher, @RequestParam int sgNgoTeacher, @RequestParam int btRegTeacher, + @RequestParam int btTempTeacher, @RequestParam int btPtTeacher, @RequestParam int btNgoTeacher, + @RequestParam int pgRegTeacher, @RequestParam int pgTempTeacher, @RequestParam int pgPtTeacher, + @RequestParam int pgNgoTeacher, @RequestParam int kgRegTeacher, @RequestParam int kgTempTeacher, + @RequestParam int petRegTeacher, @RequestParam int petTempTeacher, @RequestParam int petGrade1Teacher, + @RequestParam int petGrade2Teacher, @RequestParam int totOa, @RequestParam int kgAyah, + @RequestParam int compAss, @RequestParam int watchmen, @RequestParam int scavengers, + @RequestParam int maintenanceWork, @RequestParam int schoolId) { + + // Call service method + schoolPropertyService.saveStaffStrength(sgRegTeacher, sgTempTeacher, sgPtTeacher, sgNgoTeacher, btRegTeacher, + btTempTeacher, btPtTeacher, btNgoTeacher, pgRegTeacher, pgTempTeacher, pgPtTeacher, pgNgoTeacher, + kgRegTeacher, kgTempTeacher, petRegTeacher, petTempTeacher, petGrade1Teacher, petGrade2Teacher, totOa, + kgAyah, compAss, watchmen, scavengers, maintenanceWork, schoolId); + + return "Staff strength details saved successfully!"; + } + + // For login + @GetMapping(value = "/getLoginDetails") + public List> getLoginDetails(@RequestParam String user_id) { + List> schoolData = new ArrayList<>(); + Map response = new HashMap<>(); + String schoolId = schoolPropertyService.getSchoolId(user_id); + if (schoolId == null || schoolId.trim().isEmpty() || schoolId.equalsIgnoreCase("error")) { + response.put("Message", "Failure"); + response.put("Data", List.of()); + schoolData.add(response); + return schoolData; + } + List> sch = schoolPropertyService.getSchoolData1(schoolId); + if (!sch.isEmpty()) { + response.put("Message", "Success"); + response.put("Data", sch); + schoolData.add(response); + return schoolData; + } else { + response.put("Message", "No Data Found"); + response.put("Data", List.of()); + schoolData.add(response); + return schoolData; + } + } + + @GetMapping("/getSchoolDetails") + public ResponseEntity> getSchoolDetails(@RequestParam Long schoolId) { + try { + Map data = schoolPropertyService.getSchoolDetails(schoolId); + if (data != null && !data.isEmpty()) { + return ResponseEntity.ok(data); + } else { + return ResponseEntity.status(HttpStatus.NOT_FOUND) + .body(Map.of("status", "Failed", "message", "No school found with given ID")); + } + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", e.getMessage())); + } + } + + @GetMapping("/filterSchools") + public ResponseEntity filterSchools(@RequestParam String user_id, @RequestParam(required = false) String udise, + @RequestParam(required = false) String category, @RequestParam(required = false) String zone, + @RequestParam(required = false) String ward) { + + List> filteredSchools = schoolPropertyService.filterSchools(user_id, udise, category, zone, + ward); + + Map result = new HashMap<>(); + result.put("Message", "Success"); + result.put("Data", filteredSchools); + + return ResponseEntity.ok(Collections.singletonList(result)); + } + + @PostMapping("/updateOtherDetails") + public String updateOtherDetails(@RequestParam("land_area") Double land_area, + @RequestParam("buildup_area") Double buildup_area, @RequestParam("is_compound") Boolean is_compound, + @RequestParam("is_nameboard") Boolean is_nameboard, @RequestParam("is_pasystem") Boolean is_pasystem, + @RequestParam("is_bell") Boolean is_bell, @RequestParam("is_generator") Boolean is_generator, + @RequestParam("school_id") int school_id) { + try { + return schoolPropertyService.updateOtherDetails(land_area, buildup_area, is_compound, is_nameboard, + is_pasystem, is_bell, is_generator, school_id); + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } + } + + @PostMapping(value = "/updateStudentDetails") + public String updateStudentDetails(@RequestParam("total_students") int total_students, + @RequestParam("total_girls") int total_girls, @RequestParam("total_boys") int total_boys, + @RequestParam("others") int others, @RequestParam("school_id") int school_id) { + System.out.println("Update Request => total: " + total_students + ", boys: " + total_boys + ", girls: " + + total_girls + ", others: " + others + ", school_id: " + school_id); + try { + return schoolPropertyService.updateStudentDetails(total_students, total_girls, total_boys, others, + school_id); + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } + } + + @GetMapping("/checkPlaygroundDetails") + public ResponseEntity checkPlaygroundDetails(@RequestParam int school_id) { + + Map playgroundDetails = schoolPropertyService.checkPlaygroundDetails(school_id); + List> courtDetails = schoolPropertyService.checkCourtDetails(school_id); + List> equipmentDetails = schoolPropertyService.checkEquipmentDetails(school_id); + + Map result = new HashMap<>(); + result.put("Message", "Success"); + result.put("playgroundDetails", playgroundDetails); + result.put("CourtDetails", courtDetails); + result.put("EquipmentDetails", equipmentDetails); + + return ResponseEntity.ok(Collections.singletonList(result)); + } + + /* + * @PostMapping(value = "/updatePlayground") public ResponseEntity + * updatePlayground(@RequestBody Map payload) { try { Boolean + * is_playground = (Boolean) payload.get("is_playground"); Double + * playground_area = Double.valueOf(payload.get("playground_area").toString()); + * Boolean is_court = (Boolean) payload.get("is_court"); int school_id = + * Integer.parseInt(payload.get("school_id").toString()); int playground_id = + * Integer.parseInt(payload.get("playground_id").toString()); + * + * List> equipments = (List>) + * payload.get("equipments"); List> courts = + * (List>) payload.get("courts"); + * + * String result = schoolPropertyService.updatePlaygroundDetails( is_playground, + * playground_area, is_court, equipments, courts, playground_id, school_id ); + * return ResponseEntity.ok(result); + * + * } catch (Exception e) { e.printStackTrace(); return + * ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Error"); } } + */ +// @PostMapping(value = "/updatePlayground") +// public ResponseEntity> updatePlayground(@RequestBody Map payload) { +// Map response = new HashMap<>(); +// try { +// Boolean is_playground = (Boolean) payload.get("is_playground"); +// Double playground_area = Double.valueOf(payload.get("playground_area").toString()); +// Boolean is_court = (Boolean) payload.get("is_court"); +// int school_id = Integer.parseInt(payload.get("school_id").toString()); +// //Boolean is_active = (Boolean) payload.get("is_active"); +// int playground_id = Integer.parseInt(payload.get("playground_id").toString()); +// +// +// List equipmentidRaw = (List) payload.get("equipments"); +// List courtidRaw = (List) payload.get("courts"); +// +// // Convert string IDs to integers +// List equipmentid = equipmentidRaw.stream().map(Integer::parseInt).toList(); +// List courtid = courtidRaw.stream().map(Integer::parseInt).toList(); +// schoolPropertyService.deactiveCourts(school_id); +// schoolPropertyService.deactiveEquipments(school_id); +// schoolPropertyService.updatePlayground(is_playground, playground_area, is_court, school_id, playground_id); +// //int playground_id = schoolPropertyService.savePlayground(is_playground, playground_area, is_court, +// // school_id); +// +// for (Integer equipment_id : equipmentid) { +// schoolPropertyService.saveEquipmentDetails(equipment_id, school_id, playground_id); +// } +// +// for (Integer court_id : courtid) { +// schoolPropertyService.saveCourtDetails(court_id, school_id, playground_id); +// } +// +// response.put("status", "OK"); +// response.put("message", "Playground Details updated successfully"); +// return ResponseEntity.ok(response); +// +// } catch (Exception e) { +// e.printStackTrace(); +// response.put("status", "ERROR"); +// response.put("message", "Failed to updated playground details"); +// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); +// } +// } + + @PostMapping(value = "/updatePlayground") + public ResponseEntity> updatePlayground(@RequestBody Map payload) { + Map response = new HashMap<>(); + try { + Boolean is_playground = (Boolean) payload.get("is_playground"); + Double playground_area = Double.valueOf(payload.get("playground_area").toString()); + Boolean is_court = (Boolean) payload.get("is_court"); + int school_id = Integer.parseInt(payload.get("school_id").toString()); + int playground_id = Integer.parseInt(payload.get("playground_id").toString()); + + List> equipmentList = (List>) payload.get("equipments"); + List> courtList = (List>) payload.get("courts"); + + String status = schoolPropertyService.updatePlaygroundDetails(is_playground, playground_area, is_court, + equipmentList, courtList, playground_id, school_id); + + response.put("status", status.equals("Success") ? "OK" : "ERROR"); + response.put("message", + status.equals("Success") ? "Playground updated successfully" : "Failed to update playground"); + + return ResponseEntity.ok(response); + } catch (Exception e) { + e.printStackTrace(); + response.put("status", "ERROR"); + response.put("message", "Exception occurred during update"); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + } + + @PostMapping(value = "/updateKitchenDetails") + public String updateKitchenDetails(@RequestParam(value = "is_cmbfs") Boolean is_cmbfs, + @RequestParam(value = "is_cmbfsIndividual", required = false) Boolean is_cmbfsIndividual, + @RequestParam(value = "is_noonmeal") Boolean is_noonmeal, + @RequestParam(value = "is_noonIndividual", required = false) Boolean is_noonIndividual, + @RequestParam(value = "is_vegGarden", required = false) Boolean is_vegGarden, + @RequestParam(value = "is_anganwadi") Boolean is_anganwadi, + @RequestParam(value = "anganwadi_unique", required = false) String anganwadi_unique, + @RequestParam(value = "is_anganwadiIndividual", required = false) Boolean is_anganwadiIndividual, + @RequestParam(value = "school_id") int school_id) { + try { + + return schoolPropertyService.updateKitchenDetails(is_cmbfs, is_cmbfsIndividual, is_noonmeal, + is_noonIndividual, is_vegGarden, is_anganwadi, anganwadi_unique, is_anganwadiIndividual, school_id); + + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } + + } + + @GetMapping("/checkKitchenDetails") + public ResponseEntity checkKitchenDetails(@RequestParam int school_id) { + + Map kitchenDetails = schoolPropertyService.checkKitchenDetails(school_id); + + Map result = new HashMap<>(); + result.put("Message", "Success"); + result.put("Data", kitchenDetails); + + return ResponseEntity.ok(Collections.singletonList(result)); + } + + @PostMapping(value = "/updateStaffDetails") + public String updateStaffDetails(@RequestParam int sgRegTeacher, @RequestParam int sgTempTeacher, + @RequestParam int sgPtTeacher, @RequestParam int sgNgoTeacher, @RequestParam int btRegTeacher, + @RequestParam int btTempTeacher, @RequestParam int btPtTeacher, @RequestParam int btNgoTeacher, + @RequestParam int pgRegTeacher, @RequestParam int pgTempTeacher, @RequestParam int pgPtTeacher, + @RequestParam int pgNgoTeacher, @RequestParam int kgRegTeacher, @RequestParam int kgTempTeacher, + @RequestParam int petRegTeacher, @RequestParam int petTempTeacher, @RequestParam int petGrade1Teacher, + @RequestParam int petGrade2Teacher, @RequestParam int totOa, @RequestParam int kgAyah, + @RequestParam int compAss, @RequestParam int watchmen, @RequestParam int scavengers, + @RequestParam int maintenanceWork, @RequestParam int school_id) { + try { + + return schoolPropertyService.updateStaffDetails(sgRegTeacher, sgTempTeacher, sgPtTeacher, sgNgoTeacher, + btRegTeacher, btTempTeacher, btPtTeacher, btNgoTeacher, pgRegTeacher, pgTempTeacher, pgPtTeacher, + pgNgoTeacher, kgRegTeacher, kgTempTeacher, petRegTeacher, petTempTeacher, petGrade1Teacher, + petGrade2Teacher, totOa, kgAyah, compAss, watchmen, scavengers, maintenanceWork, school_id); + + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } + + } + /* + * @GetMapping("/checkWaterDetails") public ResponseEntity checkWaterDetails( + * + * @RequestParam int school_id) { + * + * Map drinkingWater = + * schoolPropertyService.checkWaterDetails(school_id); List> + * waterSource = schoolPropertyService.checkWaterSource(school_id); + * List> waterStorage = + * schoolPropertyService.checkWaterStotage(school_id); + * + * Map result = new HashMap<>(); result.put("Message", + * "Success"); result.put("DrinkingWater", drinkingWater); + * result.put("WaterSource", waterSource); result.put("WaterStorage", + * waterStorage); + * + * return ResponseEntity.ok(Collections.singletonList(result)); } + */ +// @PostMapping(value = "/updateDrinkingWater") +// public String updateDrinkingWater(@RequestParam("is_purifier") Boolean is_purifier, @RequestParam("purifier_capacity") Double purifier_capacity, +// @RequestParam("is_borewell") Boolean is_borewell, @RequestParam("borewell_count") int borewell_count, @RequestParam("is_storage") Boolean is_storage, +// @RequestParam("drinking_water_id") int drinking_water_id, @RequestParam("school_id") int school_id, @RequestParam("supply") List> supply, +// @RequestParam("storage") List> storage) { +// try { +// +// return schoolPropertyService.updateDrinkingWater(is_purifier, purifier_capacity, is_borewell, borewell_count, is_storage, drinking_water_id, school_id, supply, storage); +// +// } catch (Exception e) { +// e.printStackTrace(); +// return "Error"; +// } +// +// } + + @PostMapping(value = "/updateDrinkingWater") + public ResponseEntity> updateDrinkingWater(@RequestBody Map requestData) { + try { + System.out.println("Received update payload: " + requestData); + + // Extract data from the map + // List> water = (List>) + // requestData.get("water"); + List> water = (List>) requestData.getOrDefault("supply", + new ArrayList<>()); + List> storage = (List>) requestData.getOrDefault("storage", + new ArrayList<>()); + + Boolean is_purifier = (Boolean) requestData.get("is_purifier"); + Double purifier_capacity = requestData.get("purifier_capacity") != null + ? Double.valueOf(requestData.get("purifier_capacity").toString()) + : 0; + Boolean is_borewell = (Boolean) requestData.get("is_borewell"); + Integer borewell_count = requestData.get("borewell_count") != null + ? Integer.valueOf(requestData.get("borewell_count").toString()) + : 0; + Boolean is_storage = (Boolean) requestData.get("is_storage"); + // List> storage = (List>) + // requestData.get("storage"); + int school_id = Integer.parseInt(requestData.get("school_id").toString()); + int drinking_water_id = Integer.parseInt(requestData.get("drinking_water_id").toString()); + + Map response = new HashMap<>(); + + schoolPropertyService.updateDrinkWater(is_purifier, purifier_capacity, is_borewell, borewell_count, + is_storage, school_id, drinking_water_id); + schoolPropertyService.deactiveWaterSupply(school_id, drinking_water_id); + schoolPropertyService.deactiveWaterStorage(school_id, drinking_water_id); + for (Map waterSupply : water) { + int source_water_id = (int) waterSupply.get("source_water_id"); + String supply_type = (String) waterSupply.get("supply_type"); + schoolPropertyService.saveWaterSupply(source_water_id, supply_type, drinking_water_id, school_id); + } + if (!storage.isEmpty()) { + for (Map waterStorage : storage) { + double capacity = Double.valueOf(waterStorage.get("capacity").toString()); + int storage_water_id = (int) waterStorage.get("storage_water_id"); + schoolPropertyService.saveWaterStorage(capacity, storage_water_id, drinking_water_id, school_id); + } + } + + response.put("status", "OK"); + return ResponseEntity.ok(response); + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error saving data: " + e.getMessage())); + } + } + + @GetMapping("/checkWaterDetails") + public ResponseEntity> checkWaterDetails(@RequestParam int school_id) { + System.out.println("CHECK 11"); + try { + System.out.println("CHECK 1"); + Map drinkingWater = schoolPropertyService.checkWaterDetails(school_id); + List> waterSource = schoolPropertyService.checkWaterSource(school_id); + List> waterStorage = schoolPropertyService.checkWaterStotage(school_id); + System.out.println("WATER SOURCE = " + waterSource); + + Map response = new HashMap<>(); + response.put("DrinkingWater", drinkingWater); + response.put("WaterSource", waterSource); + response.put("WaterStorage", waterStorage); + + // ✅ Set status based on content presence + if (drinkingWater != null && !drinkingWater.isEmpty()) { + response.put("status", "OK"); + } else { + response.put("status", "NEW"); + } + + return ResponseEntity.ok(response); + + } catch (Exception e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Could not load drinking water data")); + } + } + + @GetMapping("/checkToiletDetails") + public ResponseEntity checkToiletDetails(@RequestParam int school_id) { + + List> toiletDetails = schoolPropertyService.checkToiletDetails(school_id); + + Map result = new HashMap<>(); + result.put("Message", "Success"); + result.put("Data", toiletDetails); + + return ResponseEntity.ok(Collections.singletonList(result)); + } + + @PostMapping(value = "/updateToiletDetails") + public String updateToiletDetails(@RequestParam("total_toiletBlocks") int total_toiletBlocks, + @RequestParam("total_male_urinals") int total_male_urinals, + @RequestParam("total_wc_male") int total_wc_male, @RequestParam("total_wc_female") int total_wc_female, + @RequestParam("total_diffAbled_toilet") int total_diffAbled_toilet, + @RequestParam("is_napkins") Boolean is_napkins, @RequestParam("school_id") int school_id) { + try { + + return schoolPropertyService.updateToiletDetails(total_toiletBlocks, total_male_urinals, total_wc_male, + total_wc_female, total_diffAbled_toilet, is_napkins, school_id); + + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } + + } + + @PostMapping(value = "/saveAssetMaster") + public ResponseEntity> saveAssetMaster(@RequestBody Map payload) { + Map response = new HashMap<>(); + String status = ""; + try { + + int school_id = Integer.parseInt(payload.get("school_id").toString()); + int asset_id = Integer.parseInt(payload.get("asset_id").toString()); + + List> equipmentList = (List>) payload.get("data"); + + for (Map asset : equipmentList) { + int sub_asset_id = Integer.parseInt(asset.get("sub_asset_id").toString()); + int master_qty = Integer.parseInt(asset.get("master_qty").toString()); + + status = schoolPropertyService.saveAssetMaster(sub_asset_id, master_qty, school_id, asset_id); + + } + + response.put("status", status.equals("Success") ? "OK" : "ERROR"); + response.put("message", + status.equals("Success") ? "Asset Master Saved successfully" : "Failed to Save Asset Master"); + + return ResponseEntity.ok(response); + } catch (Exception e) { + e.printStackTrace(); + response.put("status", "ERROR"); + response.put("message", "Exception occurred during update"); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + } + + @GetMapping("/getAssetMaster") + public ResponseEntity getAssetMaster(@RequestParam int school_id, @RequestParam int asset_id) { + + List> data = schoolPropertyService.getAssetMaster(school_id, asset_id); + // System.out.println("data=="+data); + Map result = new HashMap<>(); + result.put("status", "Success"); + result.put("data", data); + + return ResponseEntity.ok(result); + } + + @GetMapping("/getAssetMasterById") + public ResponseEntity getAssetMasterById(@RequestParam int assetMasterId, @RequestParam int asset_id) { + + Map data = schoolPropertyService.getAssetMasterById(assetMasterId, asset_id); + + Map result = new HashMap<>(); + result.put("status", "Success"); + result.put("data", data); + + return ResponseEntity.ok(result); + } + + @PostMapping(value = "/updateAssetMaster") + public String updateStudentDetails(@RequestParam("master_qty") int master_qty, + @RequestParam("assetMasterId") int assetMasterId, @RequestParam("asset_id") int asset_id) { + + try { + Map assetMaster = schoolPropertyService.getAssetMasterById(assetMasterId, asset_id); + int qty = (Integer) assetMaster.get("master_qty"); + int unmapped_asset = (Integer) assetMaster.get("unmapped_qty"); + int master = qty + master_qty; + int unmapped = master_qty + unmapped_asset; + return schoolPropertyService.updateAssetMaster(assetMasterId, master, asset_id, unmapped); + + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } + } + +} diff --git a/backend/school/Controller/SchoolReportController.java b/backend/school/Controller/SchoolReportController.java new file mode 100644 index 0000000..c31d00a --- /dev/null +++ b/backend/school/Controller/SchoolReportController.java @@ -0,0 +1,48 @@ +package in.gov.chennaicorporation.gccoffice.school.Controller; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +import in.gov.chennaicorporation.gccoffice.school.Service.SchoolReportService; + + +@RestController +@RequestMapping("/gcc/api/gccschool/report") +public class SchoolReportController { + @Autowired + private SchoolReportService schoolReportService; + + @Autowired + public SchoolReportController(SchoolReportService schoolReportService) { + this.schoolReportService = schoolReportService; + } + + @GetMapping("/getAEOList") + public ResponseEntity getAEOList(){ + return schoolReportService.getAEOList(); + } + + @GetMapping("/getAEOZone") + public ResponseEntity getAEOZone(@RequestParam String udise){ + return schoolReportService.getAEOZone(udise); + } + + @GetMapping("/getAEOWard") + public ResponseEntity getAEOWard(@RequestParam String udise, @RequestParam String zone){ + return schoolReportService.getAEOWard(udise, zone); + } + + @GetMapping("/getAEOSchoolData") + public ResponseEntity getAEOSchoolData(@RequestParam (required = false) List udise, + @RequestParam (required = false) String zone, + @RequestParam (required = false) String ward){ + return schoolReportService.getAEOSchoolData(udise, zone, ward); + } +} diff --git a/backend/school/Service/BuildingAssetService.java b/backend/school/Service/BuildingAssetService.java new file mode 100644 index 0000000..426aba5 --- /dev/null +++ b/backend/school/Service/BuildingAssetService.java @@ -0,0 +1,1030 @@ +package in.gov.chennaicorporation.gccoffice.school.Service; + +import java.sql.PreparedStatement; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; +import org.springframework.jdbc.support.GeneratedKeyHolder; +import org.springframework.jdbc.support.KeyHolder; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestParam; + +@Service +public class BuildingAssetService { + private JdbcTemplate jdbcTemplate; + + @Autowired + private NamedParameterJdbcTemplate namedParameterJdbcTemplate; + + @Autowired + public void setDataSourcemysql(@Qualifier("mysqlSchoolDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + this.namedParameterJdbcTemplate= new NamedParameterJdbcTemplate(dataSource); + } + + @Transactional + public int saveBuildings(String building_name, int total_floor, int building_material, int roof_material, + int school_id) { + String sql = "INSERT INTO buildings (building_name, total_floor, building_material, roof_material, school_id) VALUES (?, ?, ?, ?, ?)"; + try { + KeyHolder keyHolder = new GeneratedKeyHolder(); + jdbcTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + ps.setString(1, building_name); + ps.setInt(2, total_floor); + ps.setInt(3, building_material); + ps.setInt(4, roof_material); + ps.setInt(5, school_id); + return ps; + }, keyHolder); + Number generatedDataId = keyHolder.getKey(); + int buildingID = generatedDataId.intValue(); + return buildingID; + } catch (DataAccessException e) { + e.printStackTrace(); + return 0; + } + + } + + @Transactional + public Map getFloor(int i) { + String sql = "SELECT * FROM floor_master WHERE execution_order = ? "; + return jdbcTemplate.queryForMap(sql, i); + } + + @Transactional + public void saveFloor(String floor_name, int building_id, int floor_master_id, int school_id) { + String sql = "INSERT INTO floor_list (floor_name, building_id, floor_master_id, school_id) VALUES (?, ?, ?, ?)"; + try { + jdbcTemplate.update(sql, floor_name, building_id, floor_master_id, school_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + +// @Transactional +// public List> getFloorDetails(int building_id) { +// String sql = "SELECT fl.*,rd.room_type\r\n" +// + "FROM floor_list fl\r\n" +// + "left JOIN room_details rd ON rd.floors_id=fl.floors_id\r\n" +// + "WHERE fl.building_id = ? ORDER BY fl.floors_id"; +// System.out.println(sql); +// return jdbcTemplate.queryForList(sql, building_id); +// +// +// } + + @Transactional + public List> getFloorDetails(int building_id) { + String sql = "SELECT fl.floors_id, fl.floor_name, fl.building_id, fl.is_active, fl.is_delete, \r\n" + + " fl.floor_master_id, fl.status, \r\n" + + " COALESCE(GROUP_CONCAT( DISTINCT rm.room_type ORDER BY rm.room_master_id SEPARATOR ', '), '') AS room_types \r\n" + + " FROM floor_list fl \r\n" + + " LEFT JOIN room_details rd ON rd.floors_id = fl.floors_id \r\n" + + " LEFT JOIN room_master rm ON rm.room_master_id = rd.room_type \r\n" + + " WHERE fl.building_id = ? \r\n" + + " GROUP BY fl.floors_id, fl.floor_name, fl.building_id, fl.is_active, fl.is_delete, \r\n" + + " fl.floor_master_id, fl.status \r\n" + " ORDER BY fl.floors_id"; + + return jdbcTemplate.queryForList(sql, building_id); + + } + + public int getLastBuildingOrder(@RequestParam int schoolId) { + String sql = "SELECT COALESCE(MAX(building_order), 0) FROM buildings WHERE school_id = ?"; + int lastBuildingOrder = jdbcTemplate.queryForObject(sql, Integer.class, schoolId); + return lastBuildingOrder; + } + + @Transactional + public List> getSavedBuildings(int school_id) { + String sql = "SELECT b.*,bm.content as building_material_name,rm.content as roof_material_name\r\n" + + "FROM buildings b\r\n" + "JOIN building_material_master bm ON bm.bm_id=b.building_material\r\n" + + "JOIN roof_material_master rm ON rm.rm_id=b.roof_material\r\n" + + "WHERE b.school_id = ? and b.is_delete=0 and b.is_active=1 ORDER BY b.buildng_id"; + return jdbcTemplate.queryForList(sql, school_id); + } + + @Transactional + public void saveRoomDetails(int room_type, String room_num, int building_id, int floors_id, int school_id) { + String sql = "INSERT INTO room_details (room_type, room_num, building_id, floors_id, school_id) VALUES (?, ?, ?, ?, ?)"; + try { + jdbcTemplate.update(sql, room_type, room_num, building_id, floors_id, school_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + public Map getSimpleBuildingById(int buildingId) { + String sql = "SELECT b.*, rm.content as roofmaterial ,bm.content as buildingmaterial FROM buildings b join building_material_master bm on\r\n" + + " bm.execution_order=b.building_material inner join roof_material_master rm on rm.execution_order=b.roof_material WHERE buildng_id = ?"; + try { + return jdbcTemplate.queryForMap(sql, buildingId); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List> getFloorsByBuildingId(int buildingId) { + String sql = "SELECT fl.floors_id as floors_id,fl.floor_name as floor_name,fm.execution_order as execution_order FROM floor_list fl left join floor_master fm on fm.floor_master_id=fl.floor_master_id\r\n" + + " WHERE fl.building_id = ? AND fl.is_active = 1 AND fl.is_delete = 0\r\n" + + " ORDER BY 1 DESc"; + + return jdbcTemplate.queryForList(sql, buildingId); + } + + @Transactional + public void updateBuilding(int building_id, String building_name, int total_floor, String building_material, + String roof_material, int school_id) { + String sql = "UPDATE buildings SET building_name = ?, total_floor = ?, building_material = ?, roof_material = ?, school_id = ? WHERE buildng_id = ? "; + try { + jdbcTemplate.update(sql, building_name, total_floor, building_material, roof_material, school_id, + building_id); + + } catch (DataAccessException e) { + e.printStackTrace(); + + } + + } + + // add floor + @Transactional + public String addFloor(int building_id, int exe_order) { + + try { + exe_order = exe_order + 1; + Map data = getfloorName(exe_order); + String name = (String) data.get("content"); + int id = (int) data.get("floor_master_id"); + addFloordetails(name, building_id, id); + return "Sucess"; + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } + } + + private void addFloordetails(String name, int building_id, int id) { + String sql = "INSERT INTO floor_list (floor_name, building_id, floor_master_id) VALUES (?, ?, ?)"; + try { + jdbcTemplate.update(sql, name, building_id, id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + private Map getfloorName(int exe_order) { + String sql = "SELECT * FROM floor_master WHERE execution_order = ?"; + try { + return jdbcTemplate.queryForMap(sql, exe_order); + } catch (DataAccessException e) { + e.printStackTrace(); + return null; + } + } + + // delete floor + @Transactional + public String editBuildings(int building_id, int floor_id) { + try { + List data = getassetFloorID(floor_id); + for(Integer it_details_id : data) { + unmapItAssetMaster(it_details_id); + } + editItAsset(floor_id, building_id); + + List> electrical_asset= getElectricalAssetMasterByFloorId(floor_id); + List> furniture_asset= getFurnitureAssetMasterByFloorId(floor_id); + + for(Map ele_data : electrical_asset) { + int school_id = (Integer) ele_data.get("school_id"); + int sub_asset_id = (Integer) ele_data.get("sub_asset_id"); + int asset_qty = (Integer) ele_data.get("asset_qty"); + String assetType="electricalasset"; + Map assetMaster = getAssetMasterBySchlId(sub_asset_id, school_id, assetType); + int mapped = assetMaster.get("mapped_qty") != null ? (Integer) assetMaster.get("mapped_qty") : 0; + int unMapped = assetMaster.get("unmapped_qty") != null ? (Integer) assetMaster.get("unmapped_qty") : 0; + int map = mapped - asset_qty; + int unMap = unMapped+asset_qty; + updateAssetmaster(map, unMap, school_id, sub_asset_id, assetType); + } + + editElectricalAsset(floor_id, building_id); + + for(Map fur_data : furniture_asset) { + int school_id = (Integer) fur_data.get("school_id"); + int sub_asset_id = (Integer) fur_data.get("sub_asset_id"); + int asset_qty = (Integer) fur_data.get("asset_qty"); + String assetType="furnitureasset"; + Map assetMaster = getAssetMasterBySchlId(sub_asset_id, school_id, assetType); + int mapped = assetMaster.get("mapped_qty") != null ? (Integer) assetMaster.get("mapped_qty") : 0; + int unMapped = assetMaster.get("unmapped_qty") != null ? (Integer) assetMaster.get("unmapped_qty") : 0; + int map = mapped-asset_qty; + int unMap = unMapped+asset_qty; + updateAssetmaster(map, unMap, school_id, sub_asset_id, assetType); + } + + editFurnitureAsset(floor_id, building_id); + + editRoom(floor_id, building_id); + + editFloor(floor_id, building_id); + + return "sucess"; + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + + } + + + public List getassetFloorID(int floor_id) { + List assetIds = new ArrayList<>(); + try { + String sql = "SELECT it_details_id FROM it_mapping WHERE floor_id = ?"; + assetIds = jdbcTemplate.queryForList(sql, Integer.class, floor_id); + } catch (Exception e) { + e.printStackTrace(); + } + return assetIds; + + } + + private void editElectricalAsset(int floor_id, int building_id) { + String sql = "UPDATE electrical_mapping SET is_active = false, is_delete = true WHERE floor_id = ? And building_id=?"; + try { + jdbcTemplate.update(sql, floor_id, building_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + private void editFurnitureAsset(int floor_id, int building_id) { + String sql = "UPDATE furniture_mapping SET is_active = false, is_delete = true WHERE floor_id = ? And building_id=?"; + try { + jdbcTemplate.update(sql, floor_id, building_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + private void editItAsset(int floor_id, int building_id) { + String sql = "UPDATE it_mapping SET is_active = false, is_delete = true WHERE floor_id = ? And building_id=?"; + try { + jdbcTemplate.update(sql, floor_id, building_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + private void editRoom(int floor_id, int building_id) { + String sql = "UPDATE room_details SET is_active = false, is_delete = true WHERE floors_id = ? And building_id=?"; + try { + jdbcTemplate.update(sql, floor_id, building_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + private void editFloor(int floor_id, int building_id) { + String sql = "UPDATE floor_list SET is_active = false, is_delete = true WHERE floors_id = ? And building_id=?"; + try { + jdbcTemplate.update(sql, floor_id, building_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + @Transactional + public void unmapAssets(int room_id, boolean is_delete) { + String sql = "UPDATE it_mapping SET is_delete = ?,is_active=0 WHERE room_id = ?"; + String sql1 = "UPDATE furniture_mapping SET is_delete = ?,is_active=0 WHERE room_id = ?"; + String sql2 = "UPDATE electrical_mapping SET is_delete = ?,is_active=0 WHERE room_id = ?"; + try { + jdbcTemplate.update(sql, is_delete, room_id); + jdbcTemplate.update(sql1, is_delete, room_id); + jdbcTemplate.update(sql2, is_delete, room_id); + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + @Transactional + public void deleteRoom(int room_id, boolean is_delete) { + String sql = "UPDATE room_details SET is_delete = ?,is_active=0 WHERE room_id = ? "; + try { + jdbcTemplate.update(sql, is_delete, room_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + @Transactional + public String executeDelete(int building_id, boolean is_delete) { + try { + deleteItAsset(building_id, is_delete); + List data = getassetBuildingID(building_id); + for(Integer it_details_id : data) { + unmapItAssetMaster(it_details_id); + } + + List> electrical_asset= getElectricalAssetMasterByBuildingId(building_id); + List> furniture_asset= getFurnitureAssetMasterByBuildingId(building_id); + + for(Map ele_data : electrical_asset) { + int school_id = (Integer) ele_data.get("school_id"); + int sub_asset_id = (Integer) ele_data.get("sub_asset_id"); + int asset_qty = (Integer) ele_data.get("asset_qty"); + String assetType="electricalasset"; + Map assetMaster = getAssetMasterBySchlId(sub_asset_id, school_id, assetType); + int mapped = assetMaster.get("mapped_qty") != null ? (Integer) assetMaster.get("mapped_qty") : 0; + int unMapped = assetMaster.get("unmapped_qty") != null ? (Integer) assetMaster.get("unmapped_qty") : 0; + int map = mapped-asset_qty; + int unMap = unMapped+asset_qty; + updateAssetmaster(map, unMap, school_id, sub_asset_id, assetType); + } + + deleteElectricalAsset(building_id, is_delete); + + for(Map fur_data : furniture_asset) { + int school_id = (Integer) fur_data.get("school_id"); + int sub_asset_id = (Integer) fur_data.get("sub_asset_id"); + int asset_qty = (Integer) fur_data.get("asset_qty"); + String assetType="furnitureasset"; + Map assetMaster = getAssetMasterBySchlId(sub_asset_id, school_id, assetType); + int mapped = assetMaster.get("mapped_qty") != null ? (Integer) assetMaster.get("mapped_qty") : 0; + int unMapped = assetMaster.get("unmapped_qty") != null ? (Integer) assetMaster.get("unmapped_qty") : 0; + int map = mapped-asset_qty; + int unMap = unMapped+asset_qty; + updateAssetmaster(map, unMap, school_id, sub_asset_id, assetType); + } + + deleteFurnitureAsset(building_id, is_delete); + + deleteRoomById(building_id, is_delete); + deleteFloor(building_id, is_delete); + deleteBuilding(building_id, is_delete); + return "Building Deleted Sucessfully"; + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + + public List getassetBuildingID(int building_id) { + List assetIds = new ArrayList<>(); + try { + String sql = "SELECT it_details_id FROM it_mapping WHERE building_id = ?"; + assetIds = jdbcTemplate.queryForList(sql, Integer.class, building_id); + } catch (Exception e) { + e.printStackTrace(); + } + return assetIds; + } + + private void deleteBuilding(int building_id, boolean is_delete) { + String sql = "UPDATE buildings SET is_active=false,is_delete = ? WHERE buildng_id = ?;"; + try { + jdbcTemplate.update(sql, is_delete, building_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + private void deleteFloor(int building_id, boolean is_delete) { + String sql = "UPDATE floor_list SET is_active=false,is_delete = ? WHERE building_id = ?;"; + try { + jdbcTemplate.update(sql, is_delete, building_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + private void deleteRoomById(int building_id, boolean is_delete) { + String sql = "UPDATE room_details SET is_active=false,is_delete = ? WHERE building_id = ?;"; + try { + jdbcTemplate.update(sql, is_delete, building_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + private void deleteElectricalAsset(int building_id, boolean is_delete) { + String sql = "UPDATE electrical_mapping SET is_active=false,is_delete = ? WHERE building_id = ?;"; + try { + jdbcTemplate.update(sql, is_delete, building_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + private void deleteFurnitureAsset(int building_id, boolean is_delete) { + String sql = "UPDATE furniture_mapping SET is_active=false,is_delete = ? WHERE building_id = ? ;"; + try { + jdbcTemplate.update(sql, is_delete, building_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + private void deleteItAsset(int building_id, boolean is_delete) { + String sql = "UPDATE it_mapping SET is_active=false,is_delete = ? WHERE building_id = ?;"; + try { + jdbcTemplate.update(sql, is_delete, building_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + public Map>> getAllMaterials() { + String buildingMaterialSql = "SELECT execution_order, content FROM building_material_master ORDER BY execution_order"; + String roofMaterialSql = "SELECT execution_order, content FROM roof_material_master ORDER BY execution_order"; + + List> buildingMaterials = jdbcTemplate.queryForList(buildingMaterialSql); + List> roofMaterials = jdbcTemplate.queryForList(roofMaterialSql); + + Map>> result = new HashMap<>(); + result.put("buildingMaterials", buildingMaterials); + result.put("roofMaterials", roofMaterials); + + return result; + } + + @Transactional + public List> getRoomDetailsBySchoolId(int schoolId) { + String sql = "SELECT rd.room_id, " + " rd.room_num AS room_name, " + " bd.building_name, " + + " rd.building_id, " + " fl.floor_name AS floor, " + // ✅ FIXED HERE + " rm.room_type, " + " rd.school_id, " + " rm.room_master_id, " + + " fl.floors_id " + "FROM room_details rd " + + "JOIN buildings bd ON bd.buildng_id = rd.building_id " + + "JOIN floor_list fl ON fl.floors_id = rd.floors_id " + // ✅ REMOVED floor_master JOIN + "JOIN room_master rm ON rd.room_type = rm.room_master_id " + + "WHERE rd.school_id = ? AND rd.is_active = 1 AND rd.is_delete = 0"; + + return jdbcTemplate.queryForList(sql, schoolId); + } + + @Transactional + public Map getRoomDetailsById(int roomId) { + String sql = "SELECT rd.room_id, " + " rd.room_num AS room_name, " + " bd.building_name, " + + " fl.floor_name AS floor, " + // ✅ FIXED HERE + " rm.room_type, " + " rd.school_id, " + " rm.room_master_id, " + + " fl.floors_id " + "FROM room_details rd " + + "JOIN buildings bd ON bd.buildng_id = rd.building_id " + + "JOIN floor_list fl ON fl.floors_id = rd.floors_id " + // ✅ REMOVED floor_master JOIN + "JOIN room_master rm ON rd.room_type = rm.room_master_id " + + "WHERE rd.room_id = ? AND rd.is_active = 1 AND rd.is_delete = 0"; + + return jdbcTemplate.queryForMap(sql, roomId); + } + + @Transactional + public void editRoom(int room_type, String room_num, int building_id, int floors_id, int school_id, int room_id) { + String sql = "UPDATE room_details SET room_type = ?, room_num = ?, building_id = ?, floors_id = ?, school_id = ? WHERE room_id = ? "; + try { + jdbcTemplate.update(sql, room_type, room_num, building_id, floors_id, school_id, room_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + /* + * @Transactional public void deleteRoom(int room_id, boolean is_delete) { + * String sql = "UPDATE room_details SET is_delete = ? WHERE room_id = ? "; try + * { jdbcTemplate.update(sql, is_delete, room_id); }catch (DataAccessException + * e) { e.printStackTrace(); } + * + * } + */ + + @Transactional + public List> getItAssetMapping(int roomId, String assetType) { + String sql = ""; + if (assetType.equalsIgnoreCase("itasset")) { + sql = "SELECT md.*,m.it_map_id \r\n" + "FROM it_mapping m\r\n" + + "JOIN it_master_details md ON m.it_details_id = md.it_details_id\r\n" + + "WHERE m.room_id = ? and m.is_active='1' and m.is_delete='0'\r\n"; + } else if (assetType.equalsIgnoreCase("furnitureasset")) { + sql = " select sm.asset_name as assetname,fm.* from asset_sub_master sm inner join \r\n" + + " furniture_mapping fm on sm.sub_asset_id = fm.sub_asset_id where fm.is_active='1' and fm.is_delete='0' and fm.room_id = ?"; + } else if (assetType.equalsIgnoreCase("electricalasset")) { + sql = "select sm.asset_name as assetname,em.* from asset_sub_master sm inner join \r\n" + + " electrical_mapping em on sm.sub_asset_id = em.sub_asset_id where em.is_active='1' and em.is_delete='0' and em.room_id = ?"; + } + + try { + return jdbcTemplate.queryForList(sql, roomId); + } catch (Exception e) { + e.printStackTrace(); + return new ArrayList<>(); + } + + } + + @Transactional + public String deleteAssetMapping(int it_map_id, boolean is_delete) { + String sql = "UPDATE it_mapping SET is_delete = ? WHERE it_map_id = ? "; + + try { + jdbcTemplate.update(sql, is_delete, it_map_id); + return "Asset Deleted"; + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + + @Transactional + public String updateFurturQty(int id, int qty, String assetType) { + + String sql = ""; + if (assetType.equalsIgnoreCase("furnitureasset")) { + sql = "UPDATE furniture_mapping SET asset_qty = ? WHERE furniture_map_id = ?"; + } else if (assetType.equalsIgnoreCase("electricalasset")) { + sql = "UPDATE electrical_mapping SET asset_qty = ? WHERE electrical_map_id = ?"; + } + + try { + jdbcTemplate.update(sql, qty, id); + return "sucess"; + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + + @Transactional + public List> getSchoolAssetForManagement(int school_id) { + String sql = "SELECT md.* FROM school_list m INNER JOIN it_master_details md ON m.udise COLLATE utf8mb4_general_ci = md.udise\r\n" + + "WHERE m.id = ?"; + try { + return jdbcTemplate.queryForList(sql, school_id); + } catch (Exception e) { + e.printStackTrace(); + return new ArrayList<>(); + } + } + + @Transactional + public List> getSchoolAsset(int school_id, String type) { + String sql = "SELECT md.* FROM school_list m INNER JOIN it_master_details md ON m.udise COLLATE utf8mb4_general_ci = md.udise\r\n" + + "WHERE m.id = ? and md.is_mapped = 0 and md.hardware_type LIKE '%" + type + "%'"; + try { + return jdbcTemplate.queryForList(sql, school_id); + } catch (Exception e) { + e.printStackTrace(); + return new ArrayList<>(); + } + } + + @Transactional + public String addAsset(String assetCode, String name, String source, String serialNum, String vendorDetail, + String invoice_num, String udise, boolean is_online) { + String sql = "INSERT INTO it_master_details (asset_name, source_of_asset, serial_no, hardware_type, vendor_name, udise, is_online, invoice_num) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; + try { + jdbcTemplate.update(sql, assetCode, source, serialNum, name, vendorDetail, udise, is_online, invoice_num); + return "Sucess"; + } catch (DataAccessException e) { + e.printStackTrace(); + return "Error"; + } + + } + + @Transactional + public Map getAssets(int it_details_id) { + + String sql = "SELECT * FROM it_master_details WHERE it_details_id = ? "; + return jdbcTemplate.queryForMap(sql, it_details_id); + } + + @Transactional + public String editAsset(String assetCode, String name, String source, String serialNum, String vendorDetail, + String invoice_num, int it_details_id) { + String sql = "UPDATE it_master_details SET asset_name = ?, source_of_asset = ?, serial_no = ?, hardware_type = ?, vendor_name = ?, invoice_num = ? WHERE it_details_id = ? "; + try { + jdbcTemplate.update(sql, assetCode, source, serialNum, name, vendorDetail, invoice_num, it_details_id); + return "Success"; + } catch (DataAccessException e) { + e.printStackTrace(); + return "Error"; + } + } + + @Transactional + public void mapAssets(int room_id, int floor_id, int school_id, int it_details_id, int building_id) { + + saveAssetMapping(room_id, floor_id, school_id, it_details_id, building_id); + updateMapping(it_details_id); + + } + + private void updateMapping(int it_details_id) { + String sql = "UPDATE it_master_details SET is_mapped = true WHERE it_details_id = ?"; + try { + jdbcTemplate.update(sql, it_details_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + private void saveAssetMapping(int room_id, int floor_id, int school_id, int it_details_id, int building_id) { + String sql = "INSERT INTO it_mapping (room_id, floor_id, school_id, it_details_id, building_id) VALUES (?, ?, ?, ?, ?)"; + try { + jdbcTemplate.update(sql, room_id, floor_id, school_id, it_details_id, building_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + @Transactional + public void addFurAsset(int sub_asset_id, int asset_qty, int room_id, int building_id, int floor_id, int school_id, + String assetType) { + String sql = ""; + if (assetType.equalsIgnoreCase("furnitureasset")) { + sql = "INSERT INTO furniture_mapping (sub_asset_id, asset_qty, room_id,building_id, floor_id, school_id) VALUES (?,?, ?, ?, ?, ?)"; + } else if (assetType.equalsIgnoreCase("electricalasset")) { + sql = "INSERT INTO electrical_mapping (sub_asset_id, asset_qty, room_id,building_id, floor_id, school_id) VALUES (?,?, ?, ?, ?, ?)"; + } + try { + jdbcTemplate.update(sql, sub_asset_id, asset_qty, room_id, building_id, floor_id, school_id); + + } catch (DataAccessException e) { + e.printStackTrace(); + + } + } + + // checking for view + public List> getStudentStrengthBySchoolId(@RequestParam int schoolId) { + String sql = "SELECT total_boys, total_girls, others, total_students FROM student_strength WHERE school_id = ?"; + + return jdbcTemplate.queryForList(sql, schoolId); + } + + public List> getotherdetailsBySchoolId(@RequestParam int schoolId) { + String sql = "select*from school_buildup_area where school_id=?"; + + return jdbcTemplate.queryForList(sql, schoolId); + } + + public List> getStaffStrengthBySchoolId(@RequestParam int schoolId) { + String sql = "SELECT * FROM staff_strength_1 WHERE school_id = ?"; + + return jdbcTemplate.queryForList(sql, schoolId); + } + + @Transactional + public Map getIt_Details(int it_map_id) { + Map result = new HashMap<>(); + try { + String sql = "SELECT * FROM it_mapping WHERE it_map_id = ? "; + result = jdbcTemplate.queryForMap(sql, it_map_id); + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + +// @Transactional +// public String unmapAsset(int it_details_id) { +// String sql = "UPDATE it_master_details SET is_mapped = false WHERE it_details_id = ? "; +// +// try { +// jdbcTemplate.update(sql, it_details_id); +// return "Asset Unmapped"; +// } catch (Exception e) { +// e.printStackTrace(); +// return "error"; +// } +// } + + @Transactional + public List getassetRoomID(int room_id) { + List assetIds = new ArrayList<>(); + try { + String sql = "SELECT it_details_id FROM it_mapping WHERE room_id = ?"; + assetIds = jdbcTemplate.queryForList(sql, Integer.class, room_id); + } catch (Exception e) { + e.printStackTrace(); + } + return assetIds; + } + + @Transactional + public void unmapItAssetMaster(Integer it_details_id) { + String sql = "UPDATE it_master_details SET is_mapped = false WHERE it_details_id = ? "; + + try { + jdbcTemplate.update(sql, it_details_id); + + } catch (Exception e) { + e.printStackTrace(); + + } + + } + + @Transactional + public int checkBuilding(String building_name, int school_id) { + + String sql = "SELECT CASE \r\n" + + " WHEN COUNT(*) > 0 THEN 1 \r\n" + + " ELSE 0 \r\n" + + " END AS is_existing\r\n" + + "FROM buildings\r\n" + + "WHERE school_id = ? AND building_name = ?"; + + try { + return jdbcTemplate.queryForObject(sql, Integer.class, school_id, building_name); + + } catch (Exception e) { + e.printStackTrace(); + return 5; + + } + + + } + + @Transactional + public int getAssetCount(String udise, boolean is_online) { + String sql = "SELECT COUNT(*) FROM it_master_details WHERE is_online = ? and udise = ?;"; + + try { + return jdbcTemplate.queryForObject(sql, Integer.class, is_online, udise); + + } catch (Exception e) { + e.printStackTrace(); + return -1; + + } + } + @Transactional + public String assetUpdation(int asset_qty, String assetType, int sub_asset_id, int school_id, int room_id, + int building_id, int floor_id) { + int check = mapAssetMaster(asset_qty, assetType, sub_asset_id, school_id); + if(check ==1) { + Map data = ckeckAssetQty(room_id, sub_asset_id, assetType); + + int asset_Map_Id = (Integer) data.get("asset_Map_Id") !=null ? (Integer) data.get("asset_Map_Id") : 0; + int qty = (Integer) data.get("asset_qty") !=null ? (Integer) data.get("asset_qty") : 0; + int total = qty+asset_qty; + + if(asset_Map_Id!=0) { + updateAssetQty(asset_Map_Id, assetType, total); + }else { + addFurAsset(sub_asset_id, asset_qty, room_id,building_id, floor_id, school_id, assetType ); + } + return "Sucess"; + } else { + return "Add Sufficient Quantity"; + } + } + + private void updateAssetQty(int asset_Map_Id, String assetType, int total) { + String sql=""; + if (assetType.equalsIgnoreCase("furnitureasset")) { + sql = "UPDATE furniture_mapping SET asset_qty = ? WHERE furniture_map_id = ?"; + } else if (assetType.equalsIgnoreCase("electricalasset")) { + sql = "UPDATE electrical_mapping SET asset_qty = ? WHERE electrical_map_id = ?"; + } + jdbcTemplate.update(sql, total, asset_Map_Id); + + } + + public Map ckeckAssetQty(int room_id, int sub_asset_id, String assetType) { + String sql = ""; + if ("furnitureasset".equalsIgnoreCase(assetType)) { + sql = "SELECT furniture_map_id as asset_Map_Id, asset_qty FROM furniture_mapping WHERE room_id = ? AND sub_asset_id = ?"; + } else if ("electricalasset".equalsIgnoreCase(assetType)) { + sql = "SELECT electrical_map_id as asset_Map_Id, asset_qty FROM electrical_mapping WHERE room_id = ? AND sub_asset_id = ?"; + } + + try { + return jdbcTemplate.queryForMap(sql, room_id, sub_asset_id); + } catch (Exception e) { + e.printStackTrace(); + return Map.of(); + } + } + + @Transactional + public int mapAssetMaster(int asset_qty, String assetType, int sub_asset_id, int school_id) { + Map assetMaster = getAssetMasterBySchlId(sub_asset_id, school_id, assetType); + + int mapped = assetMaster.get("mapped_qty") != null ? (Integer) assetMaster.get("mapped_qty") : 0; + int unMapped = assetMaster.get("unmapped_qty") != null ? (Integer) assetMaster.get("unmapped_qty") : 0; + if(unMapped>=asset_qty) { + int map = mapped+asset_qty; + int unMap = unMapped-asset_qty; + return updateAssetmaster(map, unMap, school_id, sub_asset_id, assetType); + } + return 0; + + } + + @Transactional + public int updateAssetmaster(int map, int unMap, int school_id, int sub_asset_id, String assetType) { + String sql=""; + if (assetType.equalsIgnoreCase("furnitureasset")) { + sql = "UPDATE furniture_master SET mapped_qty = ?, unmapped_qty = ? WHERE school_id = ? and sub_asset_id = ?"; + } else if (assetType.equalsIgnoreCase("electricalasset")) { + sql = "UPDATE electrical_master SET mapped_qty = ?, unmapped_qty = ? WHERE school_id = ? and sub_asset_id = ?"; + } + try { + jdbcTemplate.update(sql, map, unMap, school_id, sub_asset_id); + return 1; + } catch (DataAccessException e) { + e.printStackTrace(); + return 0; + } + + } + + + + @Transactional + public Map getAssetMasterBySchlId(int sub_asset_id, int school_id, String assetType) { + String sql=""; + if (assetType.equalsIgnoreCase("furnitureasset")) { + sql = "SELECT * from furniture_master where school_id = ? and sub_asset_id = ?"; + } else if (assetType.equalsIgnoreCase("electricalasset")) { + sql = "SELECT * from electrical_master where school_id = ? and sub_asset_id = ?"; + } + try { + List> data =jdbcTemplate.queryForList(sql, school_id, sub_asset_id); + if(data!=null && !data.isEmpty()) { + return data.get(0); + } + return Map.of(); + } catch (Exception e) { + e.printStackTrace(); + return Map.of(); + } + } + + @Transactional + public List> getElectricalAssetMasterByRoomId(int room_id) { + try { + String sql = "select sub_asset_id, school_id, asset_qty from electrical_mapping where room_id=? and is_active = 1 and is_delete = 0"; + + return jdbcTemplate.queryForList(sql, room_id); + } catch (Exception e) { + e.printStackTrace(); + return List.of(); + } + } + + @Transactional + public List> getFurnitureAssetMasterByRoomId(int room_id) { + try { + String sql = "select sub_asset_id, school_id, asset_qty from furniture_mapping where room_id=? and is_active = 1 and is_delete = 0"; + + return jdbcTemplate.queryForList(sql, room_id); + } catch (Exception e) { + e.printStackTrace(); + return List.of(); + } + } + + @Transactional + private List> getElectricalAssetMasterByFloorId(int floor_id) { + try { + String sql = "select sub_asset_id, school_id, asset_qty from electrical_mapping where floor_id=? and is_active = 1 and is_delete = 0"; + + return jdbcTemplate.queryForList(sql, floor_id); + } catch (Exception e) { + e.printStackTrace(); + return List.of(); + } + } + @Transactional + private List> getFurnitureAssetMasterByFloorId(int floor_id) { + try { + String sql = "select sub_asset_id, school_id, asset_qty from furniture_mapping where floor_id=? and is_active = 1 and is_delete = 0"; + + return jdbcTemplate.queryForList(sql, floor_id); + } catch (Exception e) { + e.printStackTrace(); + return List.of(); + } + } + + @Transactional + private List> getElectricalAssetMasterByBuildingId(int building_id) { + try { + String sql = "select sub_asset_id, school_id, asset_qty from electrical_mapping where building_id=? and is_active = 1 and is_delete = 0"; + + return jdbcTemplate.queryForList(sql, building_id); + } catch (Exception e) { + e.printStackTrace(); + return List.of(); + } + } + + @Transactional + private List> getFurnitureAssetMasterByBuildingId(int building_id) { + try { + String sql = "select sub_asset_id, school_id, asset_qty from furniture_mapping where building_id=? and is_active = 1 and is_delete = 0"; + + return jdbcTemplate.queryForList(sql, building_id); + } catch (Exception e) { + e.printStackTrace(); + return List.of(); + } + } + + @Transactional + public String updateAssetExecution(List> assets) { + try { + for(Map asset : assets) { + int id = Integer.parseInt(asset.get("id").toString()); + + int qty = Integer.parseInt(asset.get("qty").toString()); + String assetType = (String) asset.get("assetType"); + int school_id = Integer.parseInt(asset.get("schid").toString()); + int sub_asset_id = Integer.parseInt(asset.get("subid").toString()); + int flag = Integer.parseInt(asset.get("flag").toString()); + int originalQty = Integer.parseInt(asset.get("originalQty").toString()); + + Map assetMaster = getAssetMasterBySchlId(sub_asset_id, school_id, assetType); + int mapped = assetMaster.get("mapped_qty") != null ? (Integer) assetMaster.get("mapped_qty") : 0; + int unMapped = assetMaster.get("unmapped_qty") != null ? (Integer) assetMaster.get("unmapped_qty") : 0; + int master = assetMaster.get("master_qty") != null ? (Integer) assetMaster.get("master_qty") : 0; + + int map = 0; + int unmap = 0; + + if(flag == -1) { + int diff = originalQty-qty; + map=mapped-diff; + unmap = unMapped+diff; + if(unmap<=master) { + int result = updateAssetmaster(map, unmap, school_id, sub_asset_id, assetType); + } else { + return "Add Sufficient Master Quantity"; + } + + } else if (flag == 0) { + + }else if(flag == 1) { + int diff = qty-originalQty; + map=mapped+diff; + unmap = unMapped-diff; + if(map<=master) { + int result = updateAssetmaster(map, unmap, school_id, sub_asset_id, assetType); + } else { + return "Add Sufficient Master Quantity"; + } + } + String data = updateFurturQty(id, qty, assetType); + + } + return "Sucess"; + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } + } + + + + +} diff --git a/backend/school/Service/DropdownsService.java b/backend/school/Service/DropdownsService.java new file mode 100644 index 0000000..84d0bf5 --- /dev/null +++ b/backend/school/Service/DropdownsService.java @@ -0,0 +1,188 @@ +package in.gov.chennaicorporation.gccoffice.school.Service; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.sql.DataSource; +import javax.transaction.Transactional; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; +import org.springframework.stereotype.Service; + +@Service +public class DropdownsService { + private JdbcTemplate jdbcTemplate; + +// @Autowired + private NamedParameterJdbcTemplate namedParameterJdbcTemplate; + + + @Autowired + public void setDataSourcemysql(@Qualifier("mysqlSchoolDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + this.namedParameterJdbcTemplate= new NamedParameterJdbcTemplate(dataSource); + } + + @Transactional + public List> getCourtData() { + String sql = "SELECT * FROM courts_master "; + return jdbcTemplate.queryForList(sql); + } + + @Transactional + public List> getEquipmentData() { + String sql = "SELECT * FROM equipment_master "; + return jdbcTemplate.queryForList(sql); + } + + @Transactional + public List> getBuildingMaterial() { + String sql = "SELECT * FROM building_material_master ORDER BY execution_order"; + return jdbcTemplate.queryForList(sql); + } + + @Transactional + public List> getRoofMaterial() { + String sql = "SELECT * FROM roof_material_master ORDER BY execution_order"; + return jdbcTemplate.queryForList(sql); + } + + @Transactional + public List> getWaterSource() { + String sql = "SELECT * FROM source_water ORDER BY execution_order"; + return jdbcTemplate.queryForList(sql); + } + + @Transactional + public List> getWaterStorage() { + String sql = "SELECT * FROM water_storage_master ORDER BY execution_order"; + return jdbcTemplate.queryForList(sql); + } + + @Transactional + public List> getRooms() { + String sql = "SELECT * FROM room_master ORDER BY execution_order"; + return jdbcTemplate.queryForList(sql); + } + + + + + @Transactional + public List> getFloorsByBuilding(int buildingId) { + String sql = "SELECT * FROM floor_list WHERE building_id = ? and is_active = true and is_delete = false"; + return jdbcTemplate.queryForList(sql, buildingId); + } + + @Transactional + public List> getBuildingsBySchoolId(int schoolId) { + String sql = "SELECT buildng_id, building_name FROM buildings WHERE school_id = ? and is_active = true and is_delete = false"; + return jdbcTemplate.queryForList(sql, schoolId); + } + + // Reuse this for school_id retrieval + @Transactional + public String getSchoolId(String user_id) { + String sql = "SELECT school_id FROM login_details WHERE user_id = ?"; + try { + return jdbcTemplate.queryForObject(sql, String.class, user_id); + } catch (DataAccessException e) { + return "error"; + } + } + + // New method to fetch UDISE numbers for a given school_id + public List> getUdiseNumbersBySchoolId(String schoolId) { + String sql = "SELECT udise FROM school_list WHERE id IN(" + schoolId + ")"; + try { + return jdbcTemplate.queryForList(sql); + } catch (DataAccessException e) { + e.printStackTrace(); + return List.of(); + } + } + + public List> getCategoryBySchoolId(String schoolId) { + String sql = "SELECT category FROM school_list WHERE id IN(" + schoolId + ")"; + try { + return jdbcTemplate.queryForList(sql); + } catch (DataAccessException e) { + e.printStackTrace(); + return List.of(); + } + } + + + public List> getZoneBySchoolId(String schoolId) { + String sql = "SELECT zone FROM school_list WHERE id IN(" + schoolId + ")"; + try { + return jdbcTemplate.queryForList(sql); + } catch (DataAccessException e) { + e.printStackTrace(); + return List.of(); + } + } + + public List> getWardBySchoolId(String schoolId) { + String sql = "SELECT division FROM school_list WHERE id IN(" + schoolId + ")"; + try { + return jdbcTemplate.queryForList(sql); + } catch (DataAccessException e) { + e.printStackTrace(); + return List.of(); + } + } + + @Transactional + public List> getAssetType() { + String sql = "SELECT * FROM asset_master ORDER BY execution_order"; + return jdbcTemplate.queryForList(sql); + } + + @Transactional + public List> getSubAssetType(int assetid) { + String sql = "SELECT * FROM asset_sub_master WHERE asset_master_id = ? ORDER BY execution_order"; + return jdbcTemplate.queryForList(sql, assetid); + } + + @Transactional + public List> getSplSubAssetType(List assets, int assetid) { + String sql; + Map params = new HashMap<>(); + params.put("assetid", assetid); + + if (assets == null || assets.isEmpty()) { + + sql = "SELECT * FROM asset_sub_master WHERE asset_master_id = :assetid ORDER BY execution_order"; + + } else { + + sql = "SELECT * FROM asset_sub_master WHERE asset_master_id = :assetid AND asset_name NOT IN (:assets) ORDER BY execution_order"; + params.put("assets", assets); + } + + return namedParameterJdbcTemplate.queryForList(sql, params); + } + @Transactional + public List getAssetList(int school_id, int assetid) { + String sql =""; + if(assetid==2) { + sql = "SELECT asm.asset_name from electrical_master em \r\n" + + "INNER JOIN asset_sub_master asm ON em.sub_asset_id = asm.sub_asset_id\r\n" + + "WHERE em.school_id = ?"; + } else if(assetid==3) { + sql = "SELECT asm.asset_name from furniture_master fm \r\n" + + "INNER JOIN asset_sub_master asm ON fm.sub_asset_id = asm.sub_asset_id\r\n" + + "WHERE fm.school_id = ?"; + } + return jdbcTemplate.queryForList(sql, String.class, school_id); + } + +} diff --git a/backend/school/Service/SchoolPropertyService.java b/backend/school/Service/SchoolPropertyService.java new file mode 100644 index 0000000..f30b76a --- /dev/null +++ b/backend/school/Service/SchoolPropertyService.java @@ -0,0 +1,970 @@ +package in.gov.chennaicorporation.gccoffice.school.Service; + +import java.sql.PreparedStatement; +import java.sql.Statement; +import java.sql.Types; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.support.GeneratedKeyHolder; +import org.springframework.jdbc.support.KeyHolder; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class SchoolPropertyService { + + private JdbcTemplate jdbcTemplate; + + @Autowired + public void setDataSourcemysql(@Qualifier("mysqlSchoolDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + + } + + @Transactional + public List> getSchoolData(String udise) { + String sql = "SELECT * FROM school_list WHERE udise = ?"; + return jdbcTemplate.queryForList(sql, udise); + } + + @Transactional + public String saveSchoolBuildupArea(Double land_area, Double buildup_area, Boolean is_compound, + Boolean is_nameboard, Boolean is_pasystem, Boolean is_bell, Boolean is_generator, int school_id) { + String sql = "INSERT INTO school_buildup_area (land_area, buildup_area, is_compound, is_nameboard, is_pasystem, is_bell, is_generator, school_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; + try { + jdbcTemplate.update(sql, land_area, buildup_area, is_compound, is_nameboard, is_pasystem, is_bell, + is_generator, school_id); + return "Other Details saved sucessfully"; + } catch (DataAccessException e) { + e.printStackTrace(); + return "error"; + } + + } + + @Transactional + public String saveStudentStrength(int total_students, int total_girls, int total_boys, int others, int school_id) { + String sql = "INSERT INTO student_strength (total_students, total_girls, total_boys,others,school_id) VALUES (?,?, ?, ?, ?)"; + try { + jdbcTemplate.update(sql, total_students, total_girls, total_boys, others, school_id); + return "Student Strength saved sucessfully"; + } catch (DataAccessException e) { + e.printStackTrace(); + return "error"; + } + } + +// @Transactional +// public String saveStaffStrength(int tot_staff, int sg_staff, int bt_staff, int pg_staff, int temp_staff, +// int ngo_staff, int kg_staff, int pt_staff, int part_staff, int qa_staff, int kg_ayha, int watchman, +// int comp_asst, int scavengers, int maint_workers, int school_id) { +// String sql = "INSERT INTO staff_strength (tot_staff, sg_staff, bt_staff, pg_staff,temp_staff, ngo_staff, kg_staff, pt_staff,part_staff, qa_staff, kg_ayha, watchman, comp_asst, scavengers, maint_workers, school_id) VALUES (?,?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; +// try { +// jdbcTemplate.update(sql, tot_staff, sg_staff, bt_staff, pg_staff, temp_staff, ngo_staff, kg_staff, pt_staff, +// part_staff, qa_staff, kg_ayha, watchman, comp_asst, scavengers, maint_workers, school_id); +// return "Staff Strength saved sucessfully"; +// } catch (DataAccessException e) { +// e.printStackTrace(); +// return "error"; +// } +// } + + @Transactional + public String saveToilets(int total_toiletBlocks, int total_male_urinals, int total_wc_male, int total_wc_female, + int total_diffAbled_toilet, Boolean is_napkins, int school_id) { + String sql = "INSERT INTO toilet (total_toiletBlocks, total_male_urinals, total_wc_male, total_wc_female, total_diffAbled_toilet, is_napkins, school_id) VALUES (?, ?, ?, ?, ?, ?, ?)"; + try { + jdbcTemplate.update(sql, total_toiletBlocks, total_male_urinals, total_wc_male, total_wc_female, + total_diffAbled_toilet, is_napkins, school_id); + return "Toilet Details saved sucessfully"; + } catch (DataAccessException e) { + e.printStackTrace(); + return "error"; + } + } + + @Transactional + public String saveKitchen(Boolean is_cmbfs, Boolean is_cmbfsIndividual, Boolean is_noonmeal, + Boolean is_noonIndividual, Boolean is_vegGarden, Boolean is_anganwadi, String anganwadi_unique, + Boolean is_anganwadiIndividual, int school_id) { + String sql = "INSERT INTO kitchen (is_cmbfs, is_cmbfsIndividual, is_noonmeal, is_noonIndividual, is_vegGarden, is_anganwadi, anganwadi_unique, is_anganwadiIndividual, school_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; + try { + jdbcTemplate.update(sql, is_cmbfs, is_cmbfsIndividual, is_noonmeal, is_noonIndividual, is_vegGarden, + is_anganwadi, anganwadi_unique, is_anganwadiIndividual, school_id); + return "Kitchen Details saved sucessfully"; + } catch (DataAccessException e) { + e.printStackTrace(); + return "error"; + } + } + + @Transactional + public int savePlayground(Boolean is_playground, Double playground_area, Boolean is_court, int school_id) { + String sql = "INSERT INTO playground (is_playground, playground_area, is_court, school_id) VALUES (?, ?, ?, ?)"; + try { + KeyHolder keyHolder = new GeneratedKeyHolder(); + jdbcTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + ps.setBoolean(1, is_playground); + ps.setDouble(2, playground_area); + ps.setBoolean(3, is_court); + ps.setInt(4, school_id); + return ps; + }, keyHolder); + Number generatedDataId = keyHolder.getKey(); + int playgoundID = generatedDataId.intValue(); + return playgoundID; + } catch (DataAccessException e) { + e.printStackTrace(); + return 0; + } + + } + + @Transactional + public void saveEquipmentDetails(String equipment_id, int school_id, int playground_id) { + String sql = "INSERT INTO equipment_details (equipment_id, school_id, playground_id) VALUES (?, ?, ?)"; + try { + jdbcTemplate.update(sql, equipment_id, school_id, playground_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + } + @Transactional + public void updatePlayground(Boolean is_playground, Double playground_area, Boolean is_court, int school_id, int playground_id) { + String sql = "UPDATE playground SET is_playground = ?, playground_area = ?, is_court = ? WHERE playground_id = ? AND school_id = ?"; + try { + int rows = jdbcTemplate.update(sql, is_playground, playground_area, is_court, playground_id, school_id); + System.out.println("✅ Rows affected (playground): " + rows); + } catch (DataAccessException e) { + e.printStackTrace(); + } + } + + + @Transactional + public void saveCourtDetails(String court_id, int school_id, int playground_id) { + String sql = "INSERT INTO courts_details (court_id, school_id, playground_id) VALUES (?, ?, ?)"; + try { + jdbcTemplate.update(sql, court_id, school_id, playground_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + @Transactional + public int saveDrinkingWater(Boolean is_purifier, Double purifier_capacity, Boolean is_borewell, + Integer borewell_count, Boolean is_storage, int school_id) { + String sql = "INSERT INTO drinking_water (is_purifier, purifier_capacity, is_borewell, borewell_count, is_storage, school_id) VALUES (?, ?, ?, ?, ?, ?)"; + try { + KeyHolder keyHolder = new GeneratedKeyHolder(); + jdbcTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + ps.setBoolean(1, is_purifier); + // Handle possible null values + if (purifier_capacity != null) { + ps.setDouble(2, purifier_capacity); + } else { + ps.setNull(2, Types.DOUBLE); + } + + ps.setBoolean(3, is_borewell); + if (borewell_count != null) { + ps.setInt(4, borewell_count); + } else { + ps.setNull(4, Types.INTEGER); + } + ps.setBoolean(5, is_storage); + ps.setInt(6, school_id); + return ps; + }, keyHolder); + Number generatedDataId = keyHolder.getKey(); + int drinking_water_id = generatedDataId.intValue(); + return drinking_water_id; + } catch (DataAccessException e) { + e.printStackTrace(); + return 0; + } + + } + + @Transactional + public void saveWaterSupply(int source_water_id, String supply_type, int drinking_water_id, int school_id) { + String sql = "INSERT INTO water_supply (source_water_id, supply_type, drinking_water_id, school_id) VALUES (?, ?, ?, ?)"; + try { + jdbcTemplate.update(sql, source_water_id, supply_type, drinking_water_id, school_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + @Transactional + public void saveWaterStorage(double capacity, int storage_water_id, int drinking_water_id, int school_id) { + String sql = "INSERT INTO water_storage (capacity, storage_water_id, drinking_water_id, school_id) VALUES (?, ?, ?, ?)"; + try { + jdbcTemplate.update(sql, capacity, storage_water_id, drinking_water_id, school_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + + } + + @Transactional + public void saveStaffStrength(int sgRegTeacher, int sgTempTeacher, int sgPtTeacher, int sgNgoTeacher, + int btRegTeacher, int btTempTeacher, int btPtTeacher, int btNgoTeacher, int pgRegTeacher, int pgTempTeacher, + int pgPtTeacher, int pgNgoTeacher, int kgRegTeacher, int kgTempTeacher, int petRegTeacher, int petTempTeacher, int petGrade1Teacher, int petGrade2Teacher, int totOa, int kgAyah, int compAss, + int watchmen, int scavengers, int maintenanceWork, int schoolId) { + String sql = "INSERT INTO staff_strength_1 (" + + "sg_reg_teacher, sg_temp_teacher, sg_pt_teacher, sg_ngo_teacher, " + + "bt_reg_teacher, bt_temp_teacher, bt_pt_teacher, bt_ngo_teacher, " + + "pg_reg_teacher, pg_temp_teacher, pg_pt_teacher, pg_ngo_teacher, " + + "kg_reg_teacher, kg_temp_teacher, pet_reg_teacher, pet_temp_teacher, pet_grade1_teacher, pet_grade2_teacher, tot_oa, kg_ayah, comp_ass, " + + "watchmen, scavengers, maintenance_work, school_id) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + + jdbcTemplate.update(sql, sgRegTeacher, sgTempTeacher, sgPtTeacher, sgNgoTeacher, btRegTeacher, btTempTeacher, + btPtTeacher, btNgoTeacher, pgRegTeacher, pgTempTeacher, pgPtTeacher, pgNgoTeacher, kgRegTeacher, kgTempTeacher, + petRegTeacher, petTempTeacher, petGrade1Teacher, petGrade2Teacher, totOa, kgAyah, compAss, watchmen, scavengers, maintenanceWork, schoolId); + } + + @Transactional + public String getSchoolId(String user_id) { + String sql = "SELECT school_id FROM login_details WHERE user_id = ?"; + try { + return jdbcTemplate.queryForObject(sql, String.class, user_id); + } catch (DataAccessException e) { + + return "error"; + } + } + + public List> getSchoolData1(String schoolId) { + String sql = "SELECT * FROM school_list WHERE id In(" + schoolId + ")"; + try { + return jdbcTemplate.queryForList(sql); + } catch (DataAccessException e) { + e.printStackTrace(); + return List.of(); + } + } + + + @Transactional + public Map getSchoolDetails(Long schoolId) { + String sql = "SELECT * FROM school_list WHERE id = ?"; + return jdbcTemplate.queryForMap(sql, schoolId); + } + + public List> filterSchools(String userId, String udise, String category, String zone, String ward) { + String sql = """ + SELECT + s.id, + s.udise, + s.school_name, + s.category, + s.zone, + s.division, + s.address + FROM + school_list s + JOIN + login_details l ON FIND_IN_SET(s.id, l.school_id) > 0 + WHERE + l.user_id = ? + AND (? = '' OR s.udise = ?) + AND (? = '' OR s.category = ?) + AND (? = '' OR s.zone = ?) + AND (? = '' OR s.division = ?) + """; + + return jdbcTemplate.queryForList( + sql, + userId, + udise, udise, + category, category, + zone, zone, + ward, ward + ); + } + @Transactional + public String updateOtherDetails(Double land_area, Double buildup_area, Boolean is_compound, Boolean is_nameboard, + Boolean is_pasystem, Boolean is_bell, Boolean is_generator, int school_id) { + String sql = "UPDATE school_buildup_area SET land_area = ?, buildup_area = ?, is_compound = ?, is_nameboard = ?, is_pasystem = ?, is_bell = ?, is_generator = ? WHERE school_id = ? "; + try { + jdbcTemplate.update(sql, land_area, buildup_area, is_compound, is_nameboard, is_pasystem, is_bell, + is_generator, school_id); + return "Success"; + } catch (DataAccessException e) { + e.printStackTrace(); + return "Error"; + } + } + @Transactional + public String updateStudentDetails(int total_students, int total_girls, int total_boys, int others, int school_id) { + String sql = "UPDATE student_strength SET total_students = ?, total_girls = ?, total_boys = ?, others = ? WHERE school_id = ? "; + try { + jdbcTemplate.update(sql, total_students, total_girls, total_boys, others, school_id); + return "Success"; + }catch (DataAccessException e) { + e.printStackTrace(); + return "Error"; + } + } + + @Transactional + public Map checkPlaygroundDetails(int school_id) { + String sql = "SELECT * FROM playground WHERE school_id = ?"; + try { + return jdbcTemplate.queryForMap(sql, school_id); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyMap(); + } + } + private void updateCourtDetails(int court_id, int courts_detais_id) { + String sql = "UPDATE courts_details SET court_id = ? WHERE courts_detais_id = ? "; + try { + jdbcTemplate.update(sql, court_id, courts_detais_id); + + }catch (DataAccessException e) { + e.printStackTrace(); + + } + + } +// @Transactional +// public List> checkCourtDetails(int school_id) { +// String sql = "select cm.court_type,cd.Courts_detais_id \r\n" +// + "FROM \r\n" +// + "playground p\r\n" +// + "INNER JOIN \r\n" +// + " courts_details cd ON p.playground_id = cd.playground_id\r\n" +// + "INNER JOIN \r\n" +// + " courts_master cm ON cd.court_id = cm.court_id\r\n" +// + " WHERE \r\n" +// + " p.school_id = ?"; +// try { +// return jdbcTemplate.queryForList(sql, school_id); +// } catch (Exception e) { +// e.printStackTrace(); +// return List.of(); +// } +// } + + @Transactional + public List> checkCourtDetails(int school_id) { + String sql = """ + SELECT cm.court_type, cd.Courts_detais_id, cd.court_id + FROM playground p + INNER JOIN courts_details cd ON p.playground_id = cd.playground_id + INNER JOIN courts_master cm ON cd.court_id = cm.court_id + WHERE p.school_id = ? and cd.is_active = 1 + """; + try { + return jdbcTemplate.queryForList(sql, school_id); + } catch (Exception e) { + e.printStackTrace(); + return List.of(); + } + } + + + @Transactional +// public List> checkEquipmentDetails(int school_id) { +// String sql = "select em.equipment_type,ed.equipment_detais_id \r\n" +// + "FROM \r\n" +// + "playground p\r\n" +// + "INNER JOIN \r\n" +// + " equipment_details ed ON p.playground_id = ed.playground_id\r\n" +// + "INNER JOIN \r\n" +// + " equipment_master em ON ed.equipment_id = em.equipment_id\r\n" +// + " WHERE \r\n" +// + " p.school_id = ?"; +// try { +// return jdbcTemplate.queryForList(sql, school_id); +// } catch (Exception e) { +// e.printStackTrace(); +// return List.of(); +// } +// } + //ajith + public List> checkEquipmentDetails(int school_id) { + String sql = """ + SELECT em.equipment_id, em.equipment_type, ed.equipment_detais_id + FROM playground p + INNER JOIN equipment_details ed ON p.playground_id = ed.playground_id + INNER JOIN equipment_master em ON ed.equipment_id = em.equipment_id + WHERE p.school_id = ? and ed.is_active = 1 """; + try { + return jdbcTemplate.queryForList(sql, school_id); + } catch (Exception e) { + e.printStackTrace(); + return List.of(); + } + } + +private void updateEquipmentDetails(Integer equipment_id, int equipment_detais_id) { + + String sql = "UPDATE equipment_details SET equipment_id = ? WHERE equipment_detais_id = ? "; + try { + jdbcTemplate.update(sql, equipment_id, equipment_detais_id); + + }catch (DataAccessException e) { + e.printStackTrace(); + + } + } + + /*private void updatePlayground(Boolean is_playground, Double playground_area, Boolean is_court, int school_id, int playground_id) { + String sql = "UPDATE playground SET is_playground = ?, playground_area = ?, is_court = ? WHERE playground_id = ? and school_id = ? "; + try { + jdbcTemplate.update(sql, is_playground, playground_area, is_court, playground_id, school_id); + + + }catch (DataAccessException e) { + e.printStackTrace(); + + } + + }*/ + + + + + + +// @Transactional +// public String updatePlaygroundDetails(Boolean is_playground, Double playground_area, Boolean is_court, +// List> equipments, List> courts, int playground_id, int school_id) { +// try { +// // Update playground main record +// updatePlayground(is_playground, playground_area, is_court, school_id, playground_id); +// +// // Update equipment details with null-safe checks +// for (Map equipment : equipments) { +// Object equipDetIdObj = equipment.get("equipment_detais_id"); +// Object equipIdObj = equipment.get("equipment_id"); +// +// if (equipDetIdObj != null && equipIdObj != null) { +// int equipment_detais_id = Integer.parseInt(equipDetIdObj.toString()); +// int equipment_id = Integer.parseInt(equipIdObj.toString()); +// updateEquipmentDetails(equipment_id, equipment_detais_id); +// } else { +// System.out.println("⚠️ Skipping equipment update — missing equipment_id or equipment_detais_id: " + equipment); +// } +// } +// if(is_court.booleanValue()) { +// // Update court details with null-safe checks +// for (Map court : courts) { +// Object courtDetIdObj = court.get("Courts_detais_id"); +// Object courtIdObj = court.get("court_id"); +// +// if (courtDetIdObj != null && courtIdObj != null) { +// int Courts_detais_id = Integer.parseInt(courtDetIdObj.toString()); +// int court_id = Integer.parseInt(courtIdObj.toString()); +// updateCourtDetails(court_id, Courts_detais_id); +// } else { +// System.out.println("⚠️ Skipping court update — missing court_id or Courts_detais_id: " + court); +// } +// } +// } +// else { +// //inactiveCourtDetails(school_id); +// } +// return "Success"; +// +// } catch (Exception e) { +// e.printStackTrace(); +// return "Error"; +// } +// } +@Transactional +public String updatePlaygroundDetails(Boolean is_playground, Double playground_area, Boolean is_court, + List> equipments, List> courts, int playground_id, int school_id) { + try { + // Step 1: Update main playground table + updatePlayground(is_playground, playground_area, is_court, school_id, playground_id); + + // Step 2: Deactivate old entries + deactiveCourts(school_id); + deactiveEquipments(school_id); + + // Step 3: Re-insert new equipment selections + for (Map equipment : equipments) { + Object equipmentIdObj = equipment.get("equipment_id"); + if (equipmentIdObj != null) { + String equipment_id = equipmentIdObj.toString(); + saveEquipmentDetails(equipment_id, school_id, playground_id); + } else { + System.out.println("⚠️ Skipping equipment insert — missing equipment_id: " + equipment); + } + } + + // Step 4: Re-insert new court selections (only if court is enabled) + if (Boolean.TRUE.equals(is_court)) { + for (Map court : courts) { + Object courtIdObj = court.get("court_id"); + if (courtIdObj != null) { + String court_id = courtIdObj.toString(); + saveCourtDetails(court_id, school_id, playground_id); + } else { + System.out.println("⚠️ Skipping court insert — missing court_id: " + court); + } + } + } + + return "Success"; + + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } +} + + @Transactional + public void deactiveCourts(int school_id) { + String sql = "UPDATE courts_details SET is_active = false WHERE school_id = ? "; + try { + jdbcTemplate.update(sql, school_id); + + }catch (DataAccessException e) { + e.printStackTrace(); + + } + } + + @Transactional + public void deactiveEquipments(int school_id) { + String sql = "UPDATE equipment_details SET is_active = false WHERE school_id = ? "; + try { + jdbcTemplate.update(sql, school_id); + + }catch (DataAccessException e) { + e.printStackTrace(); + + } + + } + + @Transactional + public String updateKitchenDetails(Boolean is_cmbfs, Boolean is_cmbfsIndividual, Boolean is_noonmeal, + Boolean is_noonIndividual, Boolean is_vegGarden, Boolean is_anganwadi, String anganwadi_unique, + Boolean is_anganwadiIndividual, int school_id) { + String sql = "UPDATE kitchen SET is_cmbfs = ?, is_cmbfsIndividual = ?, is_noonmeal = ?, is_noonIndividual = ?, is_vegGarden = ?, is_anganwadi = ?, anganwadi_unique = ?, is_anganwadiIndividual = ? WHERE school_id = ? "; + try { + jdbcTemplate.update(sql, is_cmbfs, is_cmbfsIndividual, is_noonmeal, is_noonIndividual, is_vegGarden, + is_anganwadi, anganwadi_unique, is_anganwadiIndividual, school_id); + return "Success"; + } catch (DataAccessException e) { + e.printStackTrace(); + return "Error"; + } + } + @Transactional + public Map checkKitchenDetails(int school_id) { + String sql = "SELECT * FROM kitchen WHERE school_id = ?"; + try { + return jdbcTemplate.queryForMap(sql, school_id); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyMap(); + } + } + /*@Transactional + public String updateStaffDetails(int sgRegTeacher, int sgTempTeacher, int sgPtTeacher, int sgNgoTeacher, + int btRegTeacher, int btTempTeacher, int btPtTeacher, int btNgoTeacher, + int pgRegTeacher, int pgTempTeacher, int pgPtTeacher, int pgNgoTeacher, + int kgTeacher, int petTeacher, int totOa, int kgAyah, int compAss, + int watchmen, int scavengers, int maintenanceWork, int school_id) { + String sql = "UPDATE staff_strength_1 SET sg_reg_teacher = ?, sg_temp_teacher = ?, sg_pt_teacher = ?, sg_ngo_teacher = ?," + + " bt_reg_teacher = ?, bt_temp_teacher = ?, bt_pt_teacher = ?, bt_ngo_teacher = ?, " + + "pg_reg_teacher = ?, pg_temp_teacher = ?, pg_pt_teacher = ?, pg_ngo_teacher = ?," + + "kg_teacher = ?, pet_teacher = ?, tot_oa = ?, kg_ayah = ?, comp_ass = ?, watchmen = ?," + + " scavengers = ?, maintenance_work = ?WHERE school_id = ? "; + try { + jdbcTemplate.update(sql, sgRegTeacher, sgTempTeacher, sgPtTeacher, sgNgoTeacher, + btRegTeacher, btTempTeacher, btPtTeacher, btNgoTeacher, + pgRegTeacher, pgTempTeacher, pgPtTeacher, pgNgoTeacher, + kgTeacher, petTeacher, totOa, kgAyah, compAss, + watchmen, scavengers, maintenanceWork, school_id); + return "Success"; + }catch (DataAccessException e) { + e.printStackTrace(); + return "Error"; + } + }*/ + @Transactional + public String updateStaffDetails(int sgRegTeacher, int sgTempTeacher, int sgPtTeacher, int sgNgoTeacher, + int btRegTeacher, int btTempTeacher, int btPtTeacher, int btNgoTeacher, + int pgRegTeacher, int pgTempTeacher, int pgPtTeacher, int pgNgoTeacher, + int kgRegTeacher, int kgTempTeacher, int petRegTeacher, int petTempTeacher, int petGrade1Teacher, int petGrade2Teacher, int totOa, int kgAyah, int compAss, + int watchmen, int scavengers, int maintenanceWork, int school_id) { + + String sql = "UPDATE staff_strength_1 SET sg_reg_teacher = ?, sg_temp_teacher = ?, sg_pt_teacher = ?, sg_ngo_teacher = ?," + + " bt_reg_teacher = ?, bt_temp_teacher = ?, bt_pt_teacher = ?, bt_ngo_teacher = ?, " + + " pg_reg_teacher = ?, pg_temp_teacher = ?, pg_pt_teacher = ?, pg_ngo_teacher = ?," + + " kg_reg_teacher = ?, kg_temp_teacher = ?, pet_reg_teacher = ?, pet_temp_teacher = ?, pet_grade1_teacher = ?, pet_grade2_teacher = ?, tot_oa = ?, kg_ayah = ?, comp_ass = ?, watchmen = ?," + + " scavengers = ?, maintenance_work = ? WHERE school_id = ?"; + + try { + int rowsAffected = jdbcTemplate.update(sql, sgRegTeacher, sgTempTeacher, sgPtTeacher, sgNgoTeacher, + btRegTeacher, btTempTeacher, btPtTeacher, btNgoTeacher, + pgRegTeacher, pgTempTeacher, pgPtTeacher, pgNgoTeacher, + kgRegTeacher, kgTempTeacher, petRegTeacher, petTempTeacher, petGrade1Teacher, petGrade2Teacher, totOa, kgAyah, compAss, + watchmen, scavengers, maintenanceWork, school_id); + + if (rowsAffected == 0) { + return "No data found for given school_id"; + } else { + return "Success"; + } + } catch (DataAccessException e) { + e.printStackTrace(); + return "Error"; + } + } + @Transactional + public Map checkWaterDetails(int school_id) { + String sql = "select drinking_water_id, is_purifier, borewell_count, is_borewell, is_storage, purifier_capacity from drinking_water where school_id = ?"; + try { + return jdbcTemplate.queryForMap(sql, school_id); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyMap(); + } + } + + @Transactional + public List> checkWaterSource(int school_id) { + String sql = "select ws.water_supply_id, ws.source_water_id, ws.supply_type, sw.water_type \r\n" + + "FROM \r\n" + + "drinking_water dw\r\n" + + "INNER JOIN \r\n" + + " water_supply ws ON dw.drinking_water_id = ws.drinking_water_id\r\n" + + "INNER JOIN \r\n" + + " source_water sw ON ws.source_water_id = sw.source_water_id\r\n" + + " WHERE \r\n" + + " dw.school_id = ? and ws.is_active = 1"; + try { + return jdbcTemplate.queryForList(sql, school_id); + } catch (Exception e) { + e.printStackTrace(); + return List.of(); + } + } +// @Transactional +// public String updateDrinkingWater(Boolean is_purifier, Double purifier_capacity, Boolean is_borewell, +// int borewell_count, Boolean is_storage, int drinking_water_id, int school_id, +// List> supply, List> storage) { +// try { +// updateDrinkWater(is_purifier, purifier_capacity, is_borewell, borewell_count, is_storage, school_id, drinking_water_id); +// for (Map supplies : supply) { +// int water_supply_id = Integer.parseInt(supplies.get("water_supply_id").toString()); +// int source_water_id = Integer.parseInt(supplies.get("source_water_id").toString()); +// String supply_type = (String) supplies.get("supply_type"); +// updateWaterSupplyDetails(water_supply_id, source_water_id, supply_type); +// } +// +// for (Map store : storage) { +// int water_storage_id = Integer.parseInt(store.get("water_storage_id").toString()); +// int storage_water_id = Integer.parseInt(store.get("storage_water_id").toString()); +// Double capacity = (Double) store.get("capacity"); +// updateWaterStorageDetails(water_storage_id, storage_water_id, capacity); +// } +// return "Sucess"; +// } catch (Exception e) { +// e.printStackTrace(); +// return "Error"; +// } +// } + + //Ajithh + @Transactional + public String updateDrinkingWater(Boolean is_purifier, Double purifier_capacity, Boolean is_borewell, + int borewell_count, Boolean is_storage, int drinking_water_id, int school_id, + List> supply, List> storage) { + try { + // Step 1: Update main table + updateDrinkWater(is_purifier, purifier_capacity, is_borewell, borewell_count, is_storage, school_id, drinking_water_id); + + // Step 2: UPSERT for water supply + for (Map item : supply) { + int source_water_id = Integer.parseInt(item.get("source_water_id").toString()); + String supply_type = item.get("supply_type").toString(); + + // Check if record exists + String checkSql = "SELECT COUNT(*) FROM water_supply WHERE drinking_water_id = ? AND source_water_id = ?"; + Integer count = jdbcTemplate.queryForObject(checkSql, Integer.class, drinking_water_id, source_water_id); + + if (count != null && count > 0) { + // Update existing + jdbcTemplate.update("UPDATE water_supply SET supply_type = ?, is_active = 1 WHERE drinking_water_id = ? AND source_water_id = ?", + supply_type, drinking_water_id, source_water_id); + + + } else { + // Insert new + jdbcTemplate.update("INSERT INTO water_supply (drinking_water_id, source_water_id, supply_type, school_id) VALUES (?, ?, ?, ?)", + drinking_water_id, source_water_id, supply_type, school_id); + } + } + + // Step 3: UPSERT for water storage + for (Map item : storage) { + int storage_water_id = Integer.parseInt(item.get("storage_water_id").toString()); + double capacity = Double.parseDouble(item.get("capacity").toString()); + + String checkSql = "SELECT COUNT(*) FROM water_storage WHERE drinking_water_id = ? AND storage_water_id = ?"; + Integer count = jdbcTemplate.queryForObject(checkSql, Integer.class, drinking_water_id, storage_water_id); + + if (count != null && count > 0) { + jdbcTemplate.update("UPDATE water_storage SET capacity = ?, is_active = 1 WHERE drinking_water_id = ? AND storage_water_id = ?", + capacity, drinking_water_id, storage_water_id); + + } else { + jdbcTemplate.update("INSERT INTO water_storage (drinking_water_id, storage_water_id, capacity, school_id) VALUES (?, ?, ?, ?)", + drinking_water_id, storage_water_id, capacity, school_id); + } + } + + return "Sucess"; + + } catch (Exception e) { + e.printStackTrace(); + return "Error"; + } + } + + + +// private void updateWaterStorageDetails(int water_storage_id, int storage_water_id, Double capacity) { +// String sql = "UPDATE water_storage SET capacity = ?, storage_water_id = ? WHERE water_storage_id = ? "; +// try { +// jdbcTemplate.update(sql, capacity, storage_water_id, water_storage_id); +// +// }catch (DataAccessException e) { +// e.printStackTrace(); +// +// } +// +// } +// +// private void updateWaterSupplyDetails(int water_supply_id, int source_water_id, String supply_type) { +// String sql = "UPDATE water_supply SET source_water_id = ?, supply_type = ? WHERE water_supply_id = ? "; +// try { +// jdbcTemplate.update(sql, source_water_id, supply_type, water_supply_id); +// +// }catch (DataAccessException e) { +// e.printStackTrace(); +// +// } +// +// } +// +// private void updateDrinkWater(Boolean is_purifier, Double purifier_capacity, Boolean is_borewell, +// int borewell_count, Boolean is_storage, int school_id, int drinking_water_id) { +// +// String sql = "UPDATE drinking_water SET is_purifier = ?, purifier_capacity = ?, is_borewell = ?, borewell_count = ?, is_storage = ? WHERE drinking_water_id = ? and school_id = ? "; +// try { +// jdbcTemplate.update(sql, is_purifier, purifier_capacity, is_borewell, borewell_count, is_storage, drinking_water_id, school_id); +// +// }catch (DataAccessException e) { +// e.printStackTrace(); +// +// } +// } + //ajith + @Transactional + public void updateDrinkWater(Boolean is_purifier, Double purifier_capacity, Boolean is_borewell, + int borewell_count, Boolean is_storage, int school_id, int drinking_water_id) { + System.out.println("===================helooo================="); + + String sql = "UPDATE drinking_water SET is_purifier = ?, purifier_capacity = ?, is_borewell = ?, borewell_count = ?, is_storage = ? WHERE drinking_water_id = ? and school_id = ? "; + try { + jdbcTemplate.update(sql, is_purifier, purifier_capacity, is_borewell, borewell_count, is_storage, drinking_water_id, school_id); + + }catch (DataAccessException e) { + e.printStackTrace(); + + } + } + + @Transactional + public void deactiveWaterSupply(int school_id, int drinking_water_id) { + String sql = "UPDATE water_supply SET is_active = false WHERE school_id = ? and drinking_water_id = ? "; + try { + jdbcTemplate.update(sql, school_id, drinking_water_id); + + }catch (DataAccessException e) { + e.printStackTrace(); + + } + + } + + @Transactional + public void deactiveWaterStorage(int school_id, int drinking_water_id) { + String sql = "UPDATE water_storage SET is_active = false WHERE school_id = ? and drinking_water_id = ? "; + try { + jdbcTemplate.update(sql, school_id, drinking_water_id); + + }catch (DataAccessException e) { + e.printStackTrace(); + + } + + } + + private void updateWaterSupplyDetails(int water_supply_id, int source_water_id, String supply_type) { + String sql = "UPDATE water_supply SET source_water_id = ?, supply_type = ? WHERE water_supply_id = ?"; + try { + jdbcTemplate.update(sql, source_water_id, supply_type, water_supply_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + } + + private void updateWaterStorageDetails(int water_storage_id, int storage_water_id, Double capacity) { + String sql = "UPDATE water_storage SET capacity = ?, storage_water_id = ? WHERE water_storage_id = ?"; + try { + jdbcTemplate.update(sql, capacity, storage_water_id, water_storage_id); + } catch (DataAccessException e) { + e.printStackTrace(); + } + } + + + + @Transactional + public List> checkWaterStotage(int school_id) { + String sql = " select wst.water_storage_id, wst.capacity, wstm.storage_type\r\n" + + " FROM \r\n" + + " drinking_water dw\r\n" + + " INNER JOIN\r\n" + + " water_storage wst ON dw.drinking_water_id = wst.drinking_water_id \r\n" + + "INNER JOIN\r\n" + + " water_storage_master wstm ON wst.storage_water_id = wstm.storage_water_id \r\n" + + "WHERE \r\n" + + " dw.school_id = ? and wst.is_active = 1"; + try { + return jdbcTemplate.queryForList(sql, school_id); + } catch (Exception e) { + e.printStackTrace(); + return List.of(); + } + } + + @Transactional + public List> checkToiletDetails(int school_id) { + String sql = "SELECT * FROM toilet WHERE school_id = ?"; + try { + return jdbcTemplate.queryForList(sql, school_id); + } catch (Exception e) { + e.printStackTrace(); + return List.of(); + } + } + + @Transactional + public String updateToiletDetails(int total_toiletBlocks, int total_male_urinals, int total_wc_male, + int total_wc_female, int total_diffAbled_toilet, Boolean is_napkins, int school_id) { + String sql = "UPDATE toilet SET total_toiletBlocks = ?, total_male_urinals = ?, total_wc_male = ?, total_wc_female = ?, total_diffAbled_toilet = ?, is_napkins = ? WHERE school_id = ? "; + try { + jdbcTemplate.update(sql, total_toiletBlocks, total_male_urinals, total_wc_male, total_wc_female, + total_diffAbled_toilet, is_napkins, school_id); + return "Success"; + } catch (DataAccessException e) { + e.printStackTrace(); + return "Error"; + } + } + + @Transactional + public String saveAssetMaster(int sub_asset_id, int master_qty, int school_id, int asset_id) { + String sql =""; + if(asset_id==2) { + sql = "INSERT INTO electrical_master (sub_asset_id, master_qty, unmapped_qty, school_id) VALUES (?, ?, ?, ?)"; + } else if(asset_id==3) { + sql = "INSERT INTO furniture_master (sub_asset_id, master_qty, unmapped_qty, school_id) VALUES (?, ?, ?, ?)"; + } + try { + jdbcTemplate.update(sql, sub_asset_id, master_qty, master_qty, school_id); + return "Success"; + } catch (DataAccessException e) { + e.printStackTrace(); + return "Error"; + } + } + + @Transactional + public List> getAssetMaster(int school_id, int asset_id) { + String sql=""; + if(asset_id==2) { + sql = "SELECT asm.asset_name, em.electrical_master_id, em.master_qty, em.mapped_qty, em.unmapped_qty, em.scrap_qty from electrical_master em \r\n" + + "INNER JOIN asset_sub_master asm ON em.sub_asset_id = asm.sub_asset_id\r\n" + + " WHERE em.school_id = ?"; + } else if(asset_id==3) { + sql = "SELECT asm.asset_name, fm.furniture_master_id, fm.master_qty, fm.mapped_qty, fm.unmapped_qty, fm.scrap_qty from furniture_master fm \r\n" + + "INNER JOIN asset_sub_master asm ON fm.sub_asset_id = asm.sub_asset_id\r\n" + + " WHERE fm.school_id = ?"; + } + try { + return jdbcTemplate.queryForList(sql, school_id); + } catch (Exception e) { + e.printStackTrace(); + return List.of(); + } + } + + @Transactional + public Map getAssetMasterById(int assetMasterId, int asset_id) { + String sql=""; + if(asset_id==2) { + sql = "SELECT em.*,asm.asset_name from electrical_master em INNER JOIN asset_sub_master asm ON em.sub_asset_id = asm.sub_asset_id where em.electrical_master_id = ?"; + } else if(asset_id==3) { + sql = "SELECT fm.*,asm.asset_name from furniture_master fm INNER JOIN asset_sub_master asm ON fm.sub_asset_id = asm.sub_asset_id where fm.furniture_master_id = ?"; + } + try { + return jdbcTemplate.queryForMap(sql, assetMasterId); + } catch (Exception e) { + e.printStackTrace(); + return Map.of(); + } + } + + @Transactional + public String updateAssetMaster(int assetMasterId, int master, int asset_id, int unmapped) { + String sql =""; + if (asset_id == 2) { + sql = "UPDATE electrical_master SET master_qty = ?, unmapped_qty = ? WHERE electrical_master_id = ? "; + } else if(asset_id==3) { + sql = "UPDATE furniture_master SET master_qty = ?, unmapped_qty = ? WHERE furniture_master_id = ? "; + } + try { + jdbcTemplate.update(sql, master, unmapped, assetMasterId); + return "Success"; + } catch (DataAccessException e) { + e.printStackTrace(); + return "Error"; + } + } + + + + +} diff --git a/backend/school/Service/SchoolReportService.java b/backend/school/Service/SchoolReportService.java new file mode 100644 index 0000000..a9399bc --- /dev/null +++ b/backend/school/Service/SchoolReportService.java @@ -0,0 +1,298 @@ +package in.gov.chennaicorporation.gccoffice.school.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.sql.DataSource; +import javax.transaction.Transactional; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.dao.DataAccessException; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; + +@Service +public class SchoolReportService { + private JdbcTemplate jdbcTemplate; + + @Autowired + public void setDataSourcemysql(@Qualifier("mysqlSchoolDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + @Transactional + public ResponseEntity getAEOList() { + Map result = new HashMap<>(); + String sql = "SELECT aeo_details_id, aeo_num, udise FROM aeo_details"; + + try { + List> data = jdbcTemplate.queryForList(sql); + result.put("Message", "Success"); + result.put("data", data); + return ResponseEntity.ok(result); + } catch (Exception e) { + e.printStackTrace(); + result.put("Message", "Error"); + result.put("Error", "Failed to fetch AEO List: " + e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result); + } + } + + @Transactional + public ResponseEntity getAEOZone(String udise) { + Map result = new HashMap<>(); + + String sql = "SELECT DISTINCT zone FROM school_list WHERE udise In(" + udise + ") ORDER BY zone ASC"; + try { + List data = jdbcTemplate.queryForList(sql, String.class); + result.put("message", "Success"); + result.put("data", data); + return ResponseEntity.ok(result); + } catch (DataAccessException e) { + e.printStackTrace(); + result.put("message", "Error"); + result.put("Error", "Failed to Zone List: " + e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result); + } + } + + @Transactional + public ResponseEntity getAEOWard(String udise, String zone) { + Map result = new HashMap<>(); + + String sql = "SELECT DISTINCT division AS Ward FROM school_list WHERE udise In(" + udise + ") and zone = ? ORDER BY Ward ASC"; + try { + List data = jdbcTemplate.queryForList(sql, String.class, zone); + result.put("message", "Success"); + result.put("data", data); + return ResponseEntity.ok(result); + } catch (DataAccessException e) { + e.printStackTrace(); + result.put("message", "Error"); + result.put("Error", "Failed to Ward List: " + e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result); + } + } + + @Transactional + public ResponseEntity getAEOSchoolData(List udise, String zone, String ward) { + Map response = new HashMap<>(); + + List> data = new ArrayList>(); + if(udise==null || udise.isEmpty()) { + udise=getUDISE(); + } + for(String udises:udise) { + List school = getschoolId(udises, zone, ward); + if(!school.isEmpty() && school!=null) { + for(String sch:school) { + //System.out.println("School_ID = "+sch); + + Map result = new HashMap<>(); + Map report = getSchoolReport(sch); + result.putAll(report); + String num = (String) report.get("udise"); + Map report1 = getSchoolReport1(sch); + result.putAll(report1); + int pending=0; + for (Map.Entry entry : report1.entrySet()) { + if(entry.getValue().toString().equalsIgnoreCase("Pending")) { + + ++pending; + } + } + result.put("overall_status", pending==0 ? "Completed" : "Pending"); + + Map report2 = getAEO(num); + result.putAll(report2); + data.add(result); + + } + response.put("message", "Success"); + response.put("data", data); + } + } +// System.out.println(data.get(0)); +// System.out.println(data.get(1)); + System.out.println(response.get("message")); +// System.out.println(response.get("data")); + return ResponseEntity.ok(response); + + } + + private List getUDISE() { + String sql = "SELECT udise FROM aeo_details"; + try { + return jdbcTemplate.queryForList(sql, String.class); + + } catch (Exception e) { + e.printStackTrace(); + return List.of(); + } + } + + private Map getAEO(String num) { + String sql = "SELECT aeo_num FROM aeo_details WHERE FIND_IN_SET(?, udise) > 0"; + try { + return jdbcTemplate.queryForMap(sql, num); + + } catch (Exception e) { + e.printStackTrace(); + return Map.of(); + } + } + + private Map getSchoolReport1(String sch) { + String sql = "SELECT " + + " CASE " + + " WHEN EXISTS ( " + + " SELECT 1 " + + " FROM school_buildup_area sba " + + " WHERE sba.school_id = ? " + + " ) THEN 'Completed' " + + " ELSE 'Pending' " + + " END AS other_details, " + + " CASE " + + " WHEN EXISTS ( " + + " SELECT 1 " + + " FROM staff_strength_1 ss " + + " WHERE ss.school_id = ? " + + " ) THEN 'Completed' " + + " ELSE 'Pending' " + + " END AS staff_details, " + + " CASE " + + " WHEN EXISTS ( " + + " SELECT 1 " + + " FROM student_strength sts " + + " WHERE sts.school_id = ? " + + " ) THEN 'Completed' " + + " ELSE 'Pending' " + + " END AS students_details, " + + " CASE " + + " WHEN EXISTS ( " + + " SELECT 1 " + + " FROM playground pg " + + " WHERE pg.school_id = ? " + + " ) THEN 'Completed' " + + " ELSE 'Pending' " + + " END AS playground_details, " + + " CASE " + + " WHEN EXISTS (" + + " SELECT 1 " + + " FROM drinking_water dw " + + " WHERE dw.school_id = ? " + + " ) THEN 'Completed' " + + " ELSE 'Pending' " + + " END AS drinkingwater_details, " + + " CASE " + + " WHEN EXISTS ( " + + " SELECT 1 " + + " FROM toilet tot " + + " WHERE tot.school_id = ? " + + " ) THEN 'Completed' " + + " ELSE 'Pending' " + + " END AS toilet_details, " + + " CASE " + + " WHEN EXISTS ( " + + " SELECT 1 " + + " FROM kitchen kit " + + " WHERE kit.school_id = ? " + + " ) THEN 'Completed' " + + " ELSE 'Pending' " + + " END AS kitchen_details, " + + " CASE " + + " WHEN NOT EXISTS ( " + + " SELECT 1 FROM buildings WHERE school_id = ? and is_active=1 and is_delete=0 " + + " ) THEN 'Pending' " + + " WHEN ( " + + " SELECT COUNT(*) FROM buildings WHERE school_id = ? and is_active=1 and is_delete=0 " + + " ) = ( " + + " SELECT COUNT(DISTINCT rd.building_id) " + + " FROM room_details rd " + + " JOIN buildings b ON b.buildng_id = rd.building_id " + + " WHERE b.school_id = ? and b.is_active=1 and b.is_delete=0 and rd.is_active=1 and rd.is_delete=0 " + + " ) THEN 'Completed' " + + " ELSE 'Partially Completed' " + + "END AS buildings, " + + "CASE " + + " WHEN NOT EXISTS ( " + + " SELECT 1 FROM room_details WHERE school_id = ? and is_active=1 and is_delete=0 " + + " ) THEN 'Pending' " + + " WHEN ( " + + " SELECT COUNT(DISTINCT room_id) " + + " FROM room_details " + + " WHERE school_id = ? and is_active=1 and is_delete=0 " + + " ) = ( " + + " SELECT COUNT(DISTINCT rd.room_id) " + + " FROM room_details rd " + + " JOIN it_mapping im ON im.room_id = rd.room_id " + + " JOIN electrical_mapping em ON em.room_id = rd.room_id " + + " JOIN furniture_mapping fm ON fm.room_id = rd.room_id " + + " WHERE rd.school_id = ? and rd.is_active=1 and rd.is_delete=0 " + + " and im.is_active=1 and im.is_delete=0 and em.is_active=1 and em.is_delete=0 " + + " and fm.is_active=1 and fm.is_delete=0 " + + " AND (im.room_id IS NOT NULL OR em.room_id IS NOT NULL OR fm.room_id IS NOT NULL) " + + " ) THEN 'Completed' " + + " WHEN ( " + + " SELECT COUNT(DISTINCT rd.room_id) " + + " FROM room_details rd " + + " JOIN it_mapping im ON im.room_id = rd.room_id " + + " JOIN electrical_mapping em ON em.room_id = rd.room_id " + + " JOIN furniture_mapping fm ON fm.room_id = rd.room_id " + + " WHERE rd.school_id = ? and rd.is_active=1 and rd.is_delete=0 " + + " and im.is_active=1 and im.is_delete=0 and em.is_active=1 and em.is_delete=0 " + + " and fm.is_active=1 and fm.is_delete=0 " + + " AND (im.room_id IS NOT NULL OR em.room_id IS NOT NULL OR fm.room_id IS NOT NULL) " + + " ) > 0 THEN 'Partially Completed' " + + " ELSE 'Pending' " + + "END AS school_assets "; + try { + return jdbcTemplate.queryForMap(sql, sch, sch, sch, sch, sch, sch, sch, sch, sch, sch, sch, sch, sch, sch); + + } catch (Exception e) { + e.printStackTrace(); + return Map.of(); + } + } + + private Map getSchoolReport(String sch) { + String sql = "SELECT id as school_id, zone, division, udise FROM school_list WHERE id = ?"; + try { + return jdbcTemplate.queryForMap(sql, sch); + + } catch (Exception e) { + e.printStackTrace(); + return Map.of(); + } + } + + private List getschoolId(String udise, String zone, String ward) { + String sql = ""; + if (zone != null && !zone.isEmpty() && ward != null && !ward.isEmpty()) { + //System.out.println("check1"); + sql = "SELECT id FROM school_list WHERE udise In(" + udise + ") and zone = ? and division = ?"; + } else if (zone != null && !zone.isEmpty() && (ward == null || ward.isEmpty())) { + sql = "SELECT id FROM school_list WHERE udise In(" + udise + ") and zone = ?"; + } else if ((zone == null || zone.isEmpty()) && (ward == null || ward.isEmpty())) { + sql = "SELECT id FROM school_list WHERE udise In(" + udise + ")"; + } + try { + if (sql.contains("zone = ?") && sql.contains("division = ?")) { + return jdbcTemplate.queryForList(sql, String.class, zone, ward); + } else if (sql.contains("zone = ?")) { + return jdbcTemplate.queryForList(sql, String.class, zone); + } else { + return jdbcTemplate.queryForList(sql, String.class); + } + + } catch (DataAccessException e) { + e.printStackTrace(); + return List.of(); + } + } +} diff --git a/frontend/school/addelectricalasset.html b/frontend/school/addelectricalasset.html new file mode 100644 index 0000000..4b6ba7d --- /dev/null +++ b/frontend/school/addelectricalasset.html @@ -0,0 +1,732 @@ + + + + + + Add Electrical Asset In Master + + + + + + + + + + + + + +
+
+
+
+
+
+
+ +
+
+ +
+ List of Electrical Assets + +
+
+ + + + + + + + + + + + + + +
S.NOASSET TYPEMASTER QTYMAPPED QTYUNMAPPED QTYACTION
+
+
+
+
+ + +
+
+
+
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/school/addfurnitureasset.html b/frontend/school/addfurnitureasset.html new file mode 100644 index 0000000..c27b646 --- /dev/null +++ b/frontend/school/addfurnitureasset.html @@ -0,0 +1,728 @@ + + + + + + Add Furniture Asset In Master + + + + + + + + + +
+
+
+
+
+
+
+ +
+
+ +
+ List of Furniture Assets + +
+
+ + + + + + + + + + + + + + +
S.NOASSET TYPEMASTER QTYMAPPED QTYUNMAPPED QTYACTION
+
+
+
+
+ + +
+
+
+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/school/assetmanagement.html b/frontend/school/assetmanagement.html new file mode 100644 index 0000000..c489e98 --- /dev/null +++ b/frontend/school/assetmanagement.html @@ -0,0 +1,819 @@ + + + + + + + + +
+
+
+
+
+
+
+ +
+
+ +
+ List of IT Assets + +
+
+ + + + + + + + + + + + + + + + + + +
S.NOASSET CODENAMESOURCESERIAL NUMBERRECEIVED DATERECEIVED BYVENDOR DETAILSINVOICE NUMBERACTION
+
+
+
+
+ + +
+
+
+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/school/building.html b/frontend/school/building.html new file mode 100644 index 0000000..62710c4 --- /dev/null +++ b/frontend/school/building.html @@ -0,0 +1,1582 @@ + + + + + + + + + +
+
+
+
+
+
+ +
+
+ +

Buildings

+ +
+ +
+
+ + +
+
+
+
+ + + + + + + + + + + + + + + + +
S.NOBuilding NameTotal FloorBuilding MaterialRoof MaterialAction
+ +
+
+
+
+ + + +
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/school/dashboard.html b/frontend/school/dashboard.html new file mode 100644 index 0000000..cb68c13 --- /dev/null +++ b/frontend/school/dashboard.html @@ -0,0 +1,322 @@ + + + + + + + + +
+
+
+
+ +
+
+
School Module - Dashboard
+ +
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + + + + + + + + + + + + + + + + +
S.NoUDISE NumberNameCategoryZoneWardAddress
+
+
+ + +
+
+ +
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/frontend/school/drinkingwater.html b/frontend/school/drinkingwater.html new file mode 100644 index 0000000..fbb63f7 --- /dev/null +++ b/frontend/school/drinkingwater.html @@ -0,0 +1,1525 @@ + + + + + + + + + + +
+
+
+ + +
+
+ Drinking Water +
+ + + + + + + +
+ + +
+
+ +
+
+
+
+
+ +
+
+ +
+ Yes + No +
+
+ +
+ +
+ + +
+ +
+
+ +
+ + Yes + No +
+
+
+ + + +
+ +
+
+ +
+
+ + + + +
+
+ + + + + + + +
+ + + \ No newline at end of file diff --git a/frontend/school/electricalassets.html b/frontend/school/electricalassets.html new file mode 100644 index 0000000..fcd5311 --- /dev/null +++ b/frontend/school/electricalassets.html @@ -0,0 +1,405 @@ + + + + + + + + +
+
+
+
+
+
+
School Module - Master Details - {Id 3232193827918}
+ +
+ + +
+
+
School Information
+ + + + + + + + + + + + + + + + + + + + + + + + + +
School Name:CPS KOLATHUR IIUDISE Code:33020401404
Category:Primary SchoolMedium:Tamil, English
School Type:GovernmentZone:Zone 11
Ward:Ward 122Address:1a, school road, Venkat Nagar, Kolathur, Chennai.
+
+
+ +
+
+

Room Wise Asset Mapping - Furniture Assets

+ +
+ +
+
+ + + + +
+
+
+
+ +
List of Electrical Assets
+
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
S.NOASSET CODENAMESOURCESERIAL NUMBERRECEIVED DATERECEIVED BYVENDOR DETAILSINVOICE NUMBERLOCATION
1TH40V40ICAMERAGCC22023293837281JUN 23, 2025 12:40 PMRECEIVED BYN/A2345676543ERCHENNAI
2TH40V40ICAMERAGCC22023293837281JUN 23, 2025 12:40 PMRECEIVED BYN/A2345676543ERCHENNAI
3TH40V40ICAMERAGCC22023293837281JUN 23, 2025 12:40 PMRECEIVED BYN/A2345676543ERCHENNAI
+
+
+
+
+
+ + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/school/furnitureassets.html b/frontend/school/furnitureassets.html new file mode 100644 index 0000000..ddc6b2a --- /dev/null +++ b/frontend/school/furnitureassets.html @@ -0,0 +1,411 @@ + + + + + + + + +
+
+
+
+
+
+
School Module - Master Details - {Id 3232193827918}
+ +
+ + +
+
+
School Information
+ + + + + + + + + + + + + + + + + + + + + + + + + +
School Name:CPS KOLATHUR IIUDISE Code:33020401404
Category:Primary SchoolMedium:Tamil, English
School Type:GovernmentZone:Zone 11
Ward:Ward 122Address:1a, school road, Venkat Nagar, Kolathur, Chennai.
+
+
+ +
+
+

Room Wise Asset Mapping - Furniture Assets

+ +
+ +
+
+ + + + +
+
+
+
+ +
List of Furniture Assets
+
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
S.NOASSET CODENAMESOURCESERIAL NUMBERRECEIVED DATERECEIVED BYVENDOR DETAILSINVOICE NUMBERLOCATION
1TH40V40ICAMERAGCC22023293837281JUN 23, 2025 12:40 PMRECEIVED BYN/A2345676543ERCHENNAI
2TH40V40ICAMERAGCC22023293837281JUN 23, 2025 12:40 PMRECEIVED BYN/A2345676543ERCHENNAI
3TH40V40ICAMERAGCC22023293837281JUN 23, 2025 12:40 PMRECEIVED BYN/A2345676543ERCHENNAI
+
+
+
+
+
+ + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/school/itassets.html b/frontend/school/itassets.html new file mode 100644 index 0000000..bc4dc23 --- /dev/null +++ b/frontend/school/itassets.html @@ -0,0 +1,602 @@ + + + + + + + + +
+
+
+
+
+
+ +
+
+

Room Wise Asset Mapping - IT Assits

+ +
+ +
+
+ + + + +
+
+
+
+ +
List of IT Assets
+
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
S.NOASSET CODENAMESOURCESERIAL NUMBERRECEIVED DATERECEIVED BYVENDOR DETAILSINVOICE NUMBERLOCATION
1TH40V40ICAMERAGCC22023293837281JUN 23, 2025 12:40 PMRECEIVED BYN/A2345676543ERCHENNAI
2TH40V40ICAMERAGCC22023293837281JUN 23, 2025 12:40 PMRECEIVED BYN/A2345676543ERCHENNAI
3TH40V40ICAMERAGCC22023293837281JUN 23, 2025 12:40 PMRECEIVED BYN/A2345676543ERCHENNAI
+
+
+
+
+
+ +
+
+
+
+
Building Wise Asset Mapping status - IT Assets
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
S.NOBUILDING NAMEFLOORSSTATUSACTION
1RIPON BUILDING3COMPLETEDAdd Room + Mapping
2GREEN BUILDING2PENDINGAdd Room + Mapping
+
+
+
+
+
+ + + +
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/school/kitchen.html b/frontend/school/kitchen.html new file mode 100644 index 0000000..f2c9477 --- /dev/null +++ b/frontend/school/kitchen.html @@ -0,0 +1,930 @@ + + + + + + + + +
+
+
+
+
+
+
+ +
+
+ +
CMBFS-Kitchen
+ + + +
+ + + + + +
+
+
+ + +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/frontend/school/otherdetails.html b/frontend/school/otherdetails.html new file mode 100644 index 0000000..d8f0b54 --- /dev/null +++ b/frontend/school/otherdetails.html @@ -0,0 +1,982 @@ + + + + + + + + +
+
+
+
+
+
+
School Module - Master Details
+ +
+ + +
+
+
+ School Information +
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/school/playground.html b/frontend/school/playground.html new file mode 100644 index 0000000..65e0968 --- /dev/null +++ b/frontend/school/playground.html @@ -0,0 +1,815 @@ + + + + + Playground Details + + + + + + + + + + +
+
+
+ +
+
+
+ Playground +
+ +
+
+ +
+ Yes + No +
+
+ + +
+ +
+
+ +
+ Yes + No +
+
+ + + + + + + + +
+ +
+
+ + + +
+ + +
+ + +
+
+
+ + + + + + + \ No newline at end of file diff --git a/frontend/school/reports.html b/frontend/school/reports.html new file mode 100644 index 0000000..1048914 --- /dev/null +++ b/frontend/school/reports.html @@ -0,0 +1,478 @@ + + + + + + + +
+ + +
+ +
+ +
+ + + +
+
+ + + +
+
+
+
+ Reports Filters +
+
+
+
+ + +
+ + +
+ + +
+ +
+ + +
+ +
+ + + +
+
+ + + +
+
+
+
+
+
+ + +
+
+
+
+ Reports List +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
S.NoAEOZoneWardUDISE codeOther DetailsStaff DetailsStudent DetailsBuildingsPlaygroundDrinking WaterToiletsSchool AssetsKitchenOverall status
+
+
+
+
+
+ +
+ +
+ + + +
+
+
+ + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/school/room.html b/frontend/school/room.html new file mode 100644 index 0000000..15d4852 --- /dev/null +++ b/frontend/school/room.html @@ -0,0 +1,827 @@ + + + + + + + + + +
+
+
+
+
+
+ +
+
+ +

Rooms

+ +
+ +
+
+ + +
+
+
+
+ + + + + + + + + + + + + + + + +
S.NORoom NameBuilding NameFloorRoom TypeAction
+ +
+
+
+
+ + + + + + +
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/school/roomassets.html b/frontend/school/roomassets.html new file mode 100644 index 0000000..4782103 --- /dev/null +++ b/frontend/school/roomassets.html @@ -0,0 +1,1589 @@ + + + + + + + +
+
+
+
+
+
+
+ +
+
+ +
Room List
+
+ + + + + + + + + + + + + + +
S.NORoom NameBuilding NameFloorRoom TypeAction
+
+
+
+ + + + + + +
+ + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/school/staffdetails.html b/frontend/school/staffdetails.html new file mode 100644 index 0000000..ccdaa17 --- /dev/null +++ b/frontend/school/staffdetails.html @@ -0,0 +1,775 @@ + + + + + Staff Strength Management + + + + + + + + + +
+
+
+ + +
+ + + + + + +
+
+ +
+
+
+ 1. SG Teachers * +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+ 2. BT Teachers * +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+ 3. PG Teachers * +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+
+ +
+ 4. PET Teachers* +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+
+ +
+ 5. kG Teachers* +
+
+
+ + +
+
+ + +
+ +
+
+
+ + +
+
+
+ Other Details * +
+
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+ + + + +
+ +
+
+
+ + + + + + + + + + + + diff --git a/frontend/school/studentdetails.html b/frontend/school/studentdetails.html new file mode 100644 index 0000000..faa7d1d --- /dev/null +++ b/frontend/school/studentdetails.html @@ -0,0 +1,687 @@ + + + + + + + + +
+
+
+
+
+
+ +
+ +
+ Student Details + +
+ + + + + + + + + +
+ + + + +
+ +
+
+
+ + + + + + + \ No newline at end of file diff --git a/frontend/school/toilets.html b/frontend/school/toilets.html new file mode 100644 index 0000000..1dd77d7 --- /dev/null +++ b/frontend/school/toilets.html @@ -0,0 +1,567 @@ + + + + + + + + + +
+
+
+ +
+
+ Toilets +
+
+ + + +
+ + + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+ Yes + No +
+
+
+ + +
+
+ + +
+ +
+
+ + + + + + + + + + + + + + \ No newline at end of file