You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

557 lines
21 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. package in.gov.chennaicorporation.gccoffice.school.Controller;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import java.util.Map;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.http.HttpStatus;
  7. import org.springframework.http.ResponseEntity;
  8. import org.springframework.web.bind.annotation.GetMapping;
  9. import org.springframework.web.bind.annotation.PostMapping;
  10. import org.springframework.web.bind.annotation.RequestBody;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import org.springframework.web.bind.annotation.RequestParam;
  13. import org.springframework.web.bind.annotation.RestController;
  14. import in.gov.chennaicorporation.gccoffice.school.Service.BuildingAssetService;
  15. import in.gov.chennaicorporation.gccoffice.school.Service.SchoolPropertyService;
  16. @RestController
  17. @RequestMapping("/gcc/api/gccschool/buildingasset")
  18. public class BuildingAssetController {
  19. private BuildingAssetService buildingAssetService;
  20. @Autowired
  21. public BuildingAssetController(BuildingAssetService buildingAssetService) {
  22. this.buildingAssetService = buildingAssetService;
  23. }
  24. // For Buildings
  25. @PostMapping(value = "/saveBuildings")
  26. public String saveBuildings(@RequestBody List<Map<String, Object>> buildingList) {
  27. try {
  28. for (Map<String, Object> building : buildingList) {
  29. String building_name = (String) building.get("building_name");
  30. int total_floor = Integer.parseInt(building.get("total_floor").toString());
  31. int building_material = Integer.parseInt(building.get("building_material").toString());
  32. int roof_material = Integer.parseInt(building.get("roof_material").toString());
  33. // int building_order =
  34. // Integer.parseInt(building.get("building_order").toString());
  35. int school_id = Integer.parseInt(building.get("school_id").toString());
  36. int check_building = buildingAssetService.checkBuilding(building_name, school_id);
  37. if (check_building == 1) {
  38. return "Building Name Alredy Exist";
  39. } else if (check_building == 5) {
  40. return "error";
  41. }
  42. int building_id = buildingAssetService.saveBuildings(building_name, total_floor, building_material,
  43. roof_material, school_id);
  44. System.out.println("Hi");
  45. for (int i = 1; i <= total_floor; i++) {
  46. Map<String, Object> floor = buildingAssetService.getFloor(i);
  47. String floor_name = (String) floor.get("content");
  48. int floor_master_id = Integer.parseInt(floor.get("floor_master_id").toString());
  49. buildingAssetService.saveFloor(floor_name, building_id, floor_master_id, school_id);
  50. System.out.println("Saved Floor Master ID: " + floor_master_id);
  51. }
  52. }
  53. return "Building Saved sucessfully";
  54. } catch (Exception e) {
  55. e.printStackTrace();
  56. return "error";
  57. }
  58. }
  59. // To Get Saved Buildings
  60. @GetMapping("/getSavedBuildings")
  61. public ResponseEntity<Map<String, Object>> getSavedBuildings(int school_id) {
  62. try {
  63. List<Map<String, Object>> data = buildingAssetService.getSavedBuildings(school_id);
  64. int lastId = buildingAssetService.getLastBuildingOrder(school_id);
  65. Map<String, Object> response = new HashMap<>();
  66. if (data.size() != 0) {
  67. response.put("status", "OK");
  68. response.put("data", data);
  69. response.put("lastId", lastId);
  70. } else {
  71. response.put("status", "Failed");
  72. response.put("data", "No Data Found");
  73. response.put("lastId", lastId);
  74. }
  75. return ResponseEntity.ok(response);
  76. } catch (Exception e) {
  77. // Log the exception details for debugging
  78. e.printStackTrace();
  79. // Provide a user-friendly error message
  80. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
  81. .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage()));
  82. }
  83. }
  84. // To Get floor Data by buildings
  85. @GetMapping("/getFloorDetails")
  86. public ResponseEntity<Map<String, Object>> getFloorDetails(int building_id) {
  87. try {
  88. List<Map<String, Object>> data = buildingAssetService.getFloorDetails(building_id);
  89. Map<String, Object> response = new HashMap<>();
  90. if (data.size() != 0) {
  91. response.put("status", "OK");
  92. response.put("data", data);
  93. } else {
  94. response.put("status", "Failed");
  95. response.put("data", "No Data Found");
  96. }
  97. return ResponseEntity.ok(response);
  98. } catch (Exception e) {
  99. // Log the exception details for debugging
  100. e.printStackTrace();
  101. // Provide a user-friendly error message
  102. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
  103. .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage()));
  104. }
  105. }
  106. // For Room mapping --add room
  107. /*
  108. * @PostMapping(value = "/saveRoom") public String saveRoom(@RequestBody
  109. * Map<String, Object> rooms) { try { int building_id = (int)
  110. * rooms.get("building_id"); int floors_id = (int) rooms.get("floors_id"); int
  111. * room_type = Integer.parseInt(rooms.get("room_type").toString());
  112. *
  113. * String room_num = (String) rooms.get("room_num"); int school_id = (int)
  114. * rooms.get("school_id"); buildingAssetService.saveRoomDetails(room_type,
  115. * room_num, building_id, floors_id, school_id); return
  116. * "Rooms Mapped Sucessfully"; } catch (Exception e) { e.printStackTrace();
  117. * return "error"; } }
  118. */
  119. // vishnu save
  120. @PostMapping(value = "/saveRoom")
  121. public String saveRoom(@RequestBody Map<String, Object> rooms) {
  122. try {
  123. int building_id = Integer.parseInt(rooms.get("building_id").toString());
  124. int floors_id = Integer.parseInt(rooms.get("floors_id").toString());
  125. int room_type = Integer.parseInt(rooms.get("room_type").toString());
  126. String room_num = rooms.get("room_num").toString();
  127. int school_id = Integer.parseInt(rooms.get("school_id").toString());
  128. buildingAssetService.saveRoomDetails(room_type, room_num, building_id, floors_id, school_id);
  129. return "Rooms Mapped Sucessfully";
  130. } catch (Exception e) {
  131. e.printStackTrace();
  132. return "error";
  133. }
  134. }
  135. // For Edit Room mapping
  136. // @PostMapping(value = "/editRoom")
  137. // public String editRoom(@RequestBody Map<String, Object> rooms) {
  138. // try {
  139. // int room_id = (int) rooms.get("room_id");
  140. // int building_id = (int) rooms.get("building_id");
  141. // int floors_id = (int) rooms.get("floors_id");
  142. // int room_type = (int) rooms.get("room_type");
  143. // String room_num = (String) rooms.get("room_num");
  144. // int school_id = (int) rooms.get("school_id");
  145. // buildingAssetService.editRoom(room_type, room_num, building_id, floors_id, school_id, room_id);
  146. // return "Rooms Edited Sucessfully";
  147. // } catch (Exception e) {
  148. // e.printStackTrace();
  149. // return "error";
  150. // }
  151. // }
  152. // vishnu edit room
  153. @PostMapping(value = "/editRoom")
  154. public String editRoom(@RequestBody Map<String, Object> rooms) {
  155. try {
  156. if (rooms.get("room_id") == null || rooms.get("building_id") == null || rooms.get("floors_id") == null
  157. || rooms.get("room_type") == null || rooms.get("room_num") == null
  158. || rooms.get("school_id") == null) {
  159. return "Missing required fields";
  160. }
  161. int room_id = Integer.parseInt(rooms.get("room_id").toString());
  162. int building_id = Integer.parseInt(rooms.get("building_id").toString());
  163. int floors_id = Integer.parseInt(rooms.get("floors_id").toString());
  164. int room_type = Integer.parseInt(rooms.get("room_type").toString());
  165. String room_num = rooms.get("room_num").toString();
  166. int school_id = Integer.parseInt(rooms.get("school_id").toString());
  167. buildingAssetService.editRoom(room_type, room_num, building_id, floors_id, school_id, room_id);
  168. return "Rooms Edited Sucessfully";
  169. } catch (Exception e) {
  170. e.printStackTrace();
  171. return "error";
  172. }
  173. }
  174. // For Delete Room mapping
  175. /*
  176. * @PostMapping(value = "/deleteRoom") public String deleteRoom(@RequestParam
  177. * int room_id, @RequestParam boolean is_delete) { try { // // from assets //
  178. * List<Map<String, Object>> assets = buildingAssetService.getAssets(room_id);
  179. * // if(!assets.isEmpty()) { // for(Map<String, Object> asset : assets) { // //
  180. * } // } buildingAssetService.deleteRoom(room_id, is_delete); return
  181. * "Rooms Edited Sucessfully"; } catch (Exception e) { e.printStackTrace();
  182. * return "error"; } }
  183. */
  184. //vishnu
  185. @GetMapping("/getBuildingbyid")
  186. public ResponseEntity<Map<String, Object>> getSimpleBuilding(@RequestParam int building_id) {
  187. try {
  188. Map<String, Object> building = buildingAssetService.getSimpleBuildingById(building_id);
  189. if (building != null) {
  190. return ResponseEntity.ok(Map.of("status", "OK", "data", building));
  191. } else {
  192. return ResponseEntity.status(HttpStatus.NOT_FOUND)
  193. .body(Map.of("status", "Failed", "message", "Building not found"));
  194. }
  195. } catch (Exception e) {
  196. e.printStackTrace();
  197. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
  198. .body(Map.of("status", "Error", "message", "Something went wrong"));
  199. }
  200. }
  201. @GetMapping("/getAllMaterials")
  202. public ResponseEntity<Map<String, Object>> getAllMaterials() {
  203. try {
  204. Map<String, List<Map<String, Object>>> materials = buildingAssetService.getAllMaterials();
  205. return ResponseEntity.ok(Map.of("status", "OK", "buildingMaterials", materials.get("buildingMaterials"),
  206. "roofMaterials", materials.get("roofMaterials")));
  207. } catch (Exception e) {
  208. e.printStackTrace();
  209. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
  210. .body(Map.of("status", "Error", "message", "Failed to load material data"));
  211. }
  212. }
  213. @GetMapping("/getFloorsByBuildingId")
  214. public ResponseEntity<Map<String, Object>> getFloorsByBuildingId(@RequestParam int buildingId) {
  215. try {
  216. List<Map<String, Object>> floors = buildingAssetService.getFloorsByBuildingId(buildingId);
  217. return ResponseEntity.ok(Map.of("status", "OK", "floors", floors));
  218. } catch (Exception e) {
  219. e.printStackTrace();
  220. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
  221. .body(Map.of("status", "Error", "message", "Could not load floor list"));
  222. }
  223. }
  224. @PostMapping(value = "/deleteBuilding")
  225. public String deleteBuilding(@RequestParam int building_id, @RequestParam boolean is_delete) {
  226. return buildingAssetService.executeDelete(building_id, is_delete);
  227. }
  228. @PostMapping(value = "/deleteRoom")
  229. public String deleteRoom(@RequestParam int room_id, @RequestParam boolean is_delete) {
  230. try {
  231. // from assets
  232. List<Integer> asset_ID = buildingAssetService.getassetRoomID(room_id);
  233. List<Map<String, Object>> electrical_asset = buildingAssetService.getElectricalAssetMasterByRoomId(room_id);
  234. List<Map<String, Object>> furniture_asset = buildingAssetService.getFurnitureAssetMasterByRoomId(room_id);
  235. for (Integer it_details_id : asset_ID) {
  236. buildingAssetService.unmapItAssetMaster(it_details_id);
  237. }
  238. for (Map<String, Object> ele_data : electrical_asset) {
  239. int school_id = (Integer) ele_data.get("school_id");
  240. int sub_asset_id = (Integer) ele_data.get("sub_asset_id");
  241. int asset_qty = (Integer) ele_data.get("asset_qty");
  242. String assetType = "electricalasset";
  243. Map<String, Object> assetMaster = buildingAssetService.getAssetMasterBySchlId(sub_asset_id, school_id,
  244. assetType);
  245. int mapped = assetMaster.get("mapped_qty") != null ? (Integer) assetMaster.get("mapped_qty") : 0;
  246. int unMapped = assetMaster.get("unmapped_qty") != null ? (Integer) assetMaster.get("unmapped_qty") : 0;
  247. int map = mapped - asset_qty;
  248. int unMap = unMapped + asset_qty;
  249. buildingAssetService.updateAssetmaster(map, unMap, school_id, sub_asset_id, assetType);
  250. }
  251. for (Map<String, Object> fur_data : furniture_asset) {
  252. int school_id = (Integer) fur_data.get("school_id");
  253. int sub_asset_id = (Integer) fur_data.get("sub_asset_id");
  254. int asset_qty = (Integer) fur_data.get("asset_qty");
  255. String assetType = "furnitureasset";
  256. Map<String, Object> assetMaster = buildingAssetService.getAssetMasterBySchlId(sub_asset_id, school_id,
  257. assetType);
  258. int mapped = assetMaster.get("mapped_qty") != null ? (Integer) assetMaster.get("mapped_qty") : 0;
  259. int unMapped = assetMaster.get("unmapped_qty") != null ? (Integer) assetMaster.get("unmapped_qty") : 0;
  260. int map = mapped - asset_qty;
  261. int unMap = unMapped + asset_qty;
  262. buildingAssetService.updateAssetmaster(map, unMap, school_id, sub_asset_id, assetType);
  263. }
  264. buildingAssetService.unmapAssets(room_id, is_delete);
  265. buildingAssetService.deleteRoom(room_id, is_delete);
  266. return "Rooms Edited Sucessfully";
  267. } catch (Exception e) {
  268. e.printStackTrace();
  269. return "error";
  270. }
  271. }
  272. @PostMapping(value = "/editBuildings")
  273. public String editBuilding(@RequestParam int building_id, @RequestParam int floor_id) {
  274. return buildingAssetService.editBuildings(building_id, floor_id);
  275. }
  276. @PostMapping(value = "/addFloor")
  277. public String addFloor(@RequestParam int building_id, @RequestParam int exe_order) {
  278. return buildingAssetService.addFloor(building_id, exe_order);
  279. }
  280. @PostMapping(value = "/updateBuilding")
  281. public String updateBuilding(@RequestParam int building_id, @RequestParam String building_name,
  282. @RequestParam int total_floor, @RequestParam String building_material, @RequestParam String roof_material,
  283. @RequestParam int school_id) {
  284. try {
  285. buildingAssetService.updateBuilding(building_id, building_name, total_floor, building_material,
  286. roof_material, school_id);
  287. return "Success";
  288. } catch (Exception e) {
  289. e.printStackTrace();
  290. return "Error";
  291. }
  292. }
  293. @GetMapping("/getRoomDetails")
  294. public ResponseEntity<Map<String, Object>> getRoomDetails(@RequestParam int school_id) {
  295. try {
  296. List<Map<String, Object>> data = buildingAssetService.getRoomDetailsBySchoolId(school_id);
  297. Map<String, Object> response = new HashMap<>();
  298. if (data != null && !data.isEmpty()) {
  299. response.put("status", "OK");
  300. response.put("data", data);
  301. } else {
  302. response.put("status", "Failed");
  303. response.put("data", "No Data Found");
  304. }
  305. return ResponseEntity.ok(response);
  306. } catch (Exception e) {
  307. e.printStackTrace();
  308. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
  309. .body(Map.of("status", "Error", "message", "Error fetching room details: " + e.getMessage()));
  310. }
  311. }
  312. @GetMapping("/getRoomById")
  313. public ResponseEntity<Map<String, Object>> getRoomById(@RequestParam int room_id) {
  314. try {
  315. Map<String, Object> room = buildingAssetService.getRoomDetailsById(room_id);
  316. return ResponseEntity.ok(Map.of("status", "OK", "data", room));
  317. } catch (Exception e) {
  318. e.printStackTrace();
  319. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
  320. .body(Map.of("status", "ERROR", "data", "Room not found"));
  321. }
  322. }
  323. @GetMapping(value = "/getItAssetMapping")
  324. public ResponseEntity<Map<String, Object>> getItAssetMapping(int room_id, String assetType) {
  325. Map<String, Object> response = new HashMap<>();
  326. List<Map<String, Object>> data = buildingAssetService.getItAssetMapping(room_id, assetType);
  327. response.put("Status", "OK");
  328. response.put("data", data);
  329. return ResponseEntity.ok(response);
  330. }
  331. @PostMapping(value = "/deleteAssetMapping")
  332. public ResponseEntity<Map<String, Object>> deleteAssetMapping(int it_map_id, boolean is_delete) {
  333. Map<String, Object> response = new HashMap<>();
  334. Map<String, Object> it_Details = buildingAssetService.getIt_Details(it_map_id);
  335. int it_details_id = (Integer) it_Details.get("it_details_id");
  336. String data = buildingAssetService.deleteAssetMapping(it_map_id, is_delete);
  337. buildingAssetService.unmapItAssetMaster(it_details_id);
  338. response.put("status", "Sucess");
  339. response.put("data", data);
  340. return ResponseEntity.ok(response);
  341. }
  342. // For update assets
  343. @PostMapping(value = "/updateassets")
  344. public String updateassets(@RequestBody List<Map<String, Object>> assets) {
  345. return buildingAssetService.updateAssetExecution(assets);
  346. }
  347. @GetMapping(value = "/getSchoolAsset")
  348. public ResponseEntity<Map<String, Object>> getSchoolAsset(@RequestParam int school_id, @RequestParam String type) {
  349. Map<String, Object> response = new HashMap<>();
  350. List<Map<String, Object>> data = buildingAssetService.getSchoolAsset(school_id, type);
  351. if (!data.isEmpty()) {
  352. response.put("status", "Success");
  353. response.put("data", data);
  354. } else {
  355. response.put("status", "Error");
  356. }
  357. return ResponseEntity.ok(response);
  358. }
  359. @PostMapping(value = "/mapAssets")
  360. public String mapAssets(@RequestBody List<Map<String, Object>> assets) {
  361. try {
  362. for (Map<String, Object> asset : assets) {
  363. int room_id = Integer.parseInt(asset.get("room_id").toString());
  364. int floor_id = Integer.parseInt(asset.get("floor_id").toString());
  365. int school_id = Integer.parseInt(asset.get("school_id").toString());
  366. int it_details_id = Integer.parseInt(asset.get("it_details_id").toString());
  367. int building_id = Integer.parseInt(asset.get("building_id").toString());
  368. buildingAssetService.mapAssets(room_id, floor_id, school_id, it_details_id, building_id);
  369. }
  370. return "Success";
  371. } catch (Exception e) {
  372. e.printStackTrace();
  373. return "Error";
  374. }
  375. }
  376. @PostMapping(value = "/addFurAsset")
  377. public String addFurAsset(@RequestParam int sub_asset_id, @RequestParam int asset_qty, @RequestParam int room_id,
  378. @RequestParam int building_id, @RequestParam int floor_id, @RequestParam int school_id,
  379. @RequestParam String assetType) {
  380. return buildingAssetService.assetUpdation(asset_qty, assetType, sub_asset_id, school_id, room_id, building_id,
  381. floor_id);
  382. }
  383. // Asset Management
  384. @GetMapping(value = "/getAssetManagement")
  385. public ResponseEntity<Map<String, Object>> getSchoolAssetForManagement(@RequestParam int school_id) {
  386. Map<String, Object> response = new HashMap<>();
  387. List<Map<String, Object>> data = buildingAssetService.getSchoolAssetForManagement(school_id);
  388. if (!data.isEmpty()) {
  389. response.put("status", "Sucess");
  390. response.put("data", data);
  391. } else {
  392. response.put("status", "Error");
  393. }
  394. return ResponseEntity.ok(response);
  395. }
  396. @PostMapping(value = "/addAsset")
  397. public String addAsset(@RequestParam String code, @RequestParam String name, @RequestParam String source,
  398. @RequestParam String serialNum, @RequestParam String vendorDetail, @RequestParam String invoice_num,
  399. @RequestParam String udise, @RequestParam boolean is_online, @RequestParam int school_id) {
  400. try {
  401. int count = buildingAssetService.getAssetCount(udise, is_online);
  402. String assetCode = "";
  403. if (count >= 0) {
  404. String series = String.format("%04d", count + 1);
  405. String school = String.format("%03d", school_id);
  406. assetCode = code + school + series;
  407. } else {
  408. return "Error";
  409. }
  410. return buildingAssetService.addAsset(assetCode, name, source, serialNum, vendorDetail, invoice_num, udise,
  411. is_online);
  412. } catch (Exception e) {
  413. e.printStackTrace();
  414. return "Error";
  415. }
  416. }
  417. @GetMapping(value = "/getAssets")
  418. public ResponseEntity<Map<String, Object>> getAssets(@RequestParam int it_details_id) {
  419. Map<String, Object> response = new HashMap<>();
  420. Map<String, Object> data = buildingAssetService.getAssets(it_details_id);
  421. if (!data.isEmpty()) {
  422. response.put("status", "Success");
  423. response.put("data", data);
  424. } else {
  425. response.put("Status", "Error");
  426. }
  427. return ResponseEntity.ok(response);
  428. }
  429. @PostMapping(value = "/editAsset")
  430. public String editAsset(@RequestParam String assetCode, @RequestParam String name, @RequestParam String source,
  431. @RequestParam String serialNum, @RequestParam String vendorDetail, @RequestParam String invoice_num,
  432. @RequestParam int it_details_id) {
  433. try {
  434. return buildingAssetService.editAsset(assetCode, name, source, serialNum, vendorDetail, invoice_num,
  435. it_details_id);
  436. } catch (Exception e) {
  437. e.printStackTrace();
  438. return "Error";
  439. }
  440. }
  441. @GetMapping("/getStudentStrengthBySchoolId")
  442. public ResponseEntity<Map<String, Object>> getStudentStrengthBySchoolId(@RequestParam int schoolId) {
  443. try {
  444. List<Map<String, Object>> studentStrength = buildingAssetService.getStudentStrengthBySchoolId(schoolId);
  445. if (!studentStrength.isEmpty()) {
  446. return ResponseEntity.ok(Map.of("status", "OK", "studentStrength", studentStrength));
  447. } else {
  448. return ResponseEntity.ok(Map.of("status", "NEW", "studentStrength", studentStrength));
  449. }
  450. } catch (Exception e) {
  451. e.printStackTrace();
  452. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
  453. .body(Map.of("status", "Error", "message", "Could not load student strength data"));
  454. }
  455. }
  456. @GetMapping("/getotherdetailsBySchoolId")
  457. public ResponseEntity<Map<String, Object>> getotherdetailsBySchoolId(@RequestParam int schoolId) {
  458. try {
  459. List<Map<String, Object>> getotherdetailsBySchool = buildingAssetService
  460. .getotherdetailsBySchoolId(schoolId);
  461. if (!getotherdetailsBySchool.isEmpty()) {
  462. return ResponseEntity.ok(Map.of("status", "OK", "otherdetailsBySchool", getotherdetailsBySchool));
  463. } else {
  464. return ResponseEntity.ok(Map.of("status", "NEW", "otherdetailsBySchool", getotherdetailsBySchool));
  465. }
  466. } catch (Exception e) {
  467. e.printStackTrace();
  468. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
  469. .body(Map.of("status", "Error", "message", "Could not load student strength data"));
  470. }
  471. }
  472. @GetMapping("/getStaffStrengthBySchoolId")
  473. public ResponseEntity<Map<String, Object>> getStaffStrengthBySchoolId(@RequestParam int schoolId) {
  474. try {
  475. List<Map<String, Object>> staffStrength = buildingAssetService.getStaffStrengthBySchoolId(schoolId);
  476. if (!staffStrength.isEmpty()) {
  477. return ResponseEntity.ok(Map.of("status", "OK", "staffStrength", staffStrength));
  478. } else {
  479. return ResponseEntity.ok(Map.of("status", "NEW", "staffStrength", staffStrength));
  480. }
  481. } catch (Exception e) {
  482. e.printStackTrace();
  483. return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
  484. .body(Map.of("status", "Error", "message", "Could not load student strength data"));
  485. }
  486. }
  487. }