2 Commits
8b23aad328
...
cb9977f5da
| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
cb9977f5da |
New modules added
|
2 years ago |
|
|
195d45d74e |
nulm module and Fine Module added
NULM Module and Fine Module Added |
2 years ago |
-
BIN.DS_Store
-
1.gitignore
-
BINmobileservice/.DS_Store
-
BINmobileservice/gcc_mobile_service_uploads/.DS_Store
-
BINmobileservice/gcc_mobile_service_uploads/app_icon/.DS_Store
-
BINmobileservice/gcc_mobile_service_uploads/app_icon/menu/.DS_Store
-
BINmobileservice/gcc_mobile_service_uploads/app_icon/menu/1.png
-
BINmobileservice/gcc_mobile_service_uploads/app_icon/menu/1_1.png
-
BINmobileservice/gcc_mobile_service_uploads/app_icon/menu/1_2.png
-
BINmobileservice/gcc_mobile_service_uploads/app_icon/menu/2.png
-
BINmobileservice/gcc_mobile_service_uploads/app_icon/menu/2_3.png
-
BINmobileservice/gcc_mobile_service_uploads/app_icon/menu/2_4.png
-
BINmobileservice/gcc_mobile_service_uploads/app_icon/menu/2_5.png
-
BINmobileservice/gcc_mobile_service_uploads/app_icon/menu/3.png
-
BINmobileservice/gcc_mobile_service_uploads/app_icon/menu/3_1.png
-
BINmobileservice/gcc_mobile_service_uploads/app_icon/menu/3_2.png
-
BINmobileservice/gcc_mobile_service_uploads/app_icon/menu/3_3.png
-
BINmobileservice/gcc_mobile_service_uploads/asset_activity/.DS_Store
-
BINmobileservice/gcc_mobile_service_uploads/asset_images/.DS_Store
-
BINmobileservice/gcc_mobile_service_uploads/brr_activity_images/.DS_Store
-
BINmobileservice/gcc_mobile_service_uploads/sos_rescue_activity_images/.DS_Store
-
6mobileservice/pom.xml
-
BINmobileservice/src/.DS_Store
-
BINmobileservice/src/main/.DS_Store
-
BINmobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/1_approved.jpg
-
BINmobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/1_rejected.jpg
-
4mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/MobileServiceApplication.java
-
9mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/AppConfig.java
-
58mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/DataSourceConfig.java
-
10mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/controller/APIOfficialController.java
-
11mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/controller/MainController.java
-
13mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccactivity/controller/APIActivityController.java
-
128mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccactivity/service/Activity.java
-
8mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccactivity/service/MassClearn.java
-
909mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/controller/ParksController.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/controller/package-info.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/package-info.java
-
30mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/ErrorResponse.java
-
45mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/GlobalExceptionHandler.java
-
8mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/NoDataException.java
-
2000mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/ParksService.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/package-info.java
-
934mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/controller/SchoolUserController.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/controller/package-info.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/package-info.java
-
1063mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/service/SchoolUserActivity.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/service/package-info.java
-
51mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/controller/APIOfficerController.java
-
9mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/controller/APIUserController.java
-
361mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/service/OfficerActivity.java
-
37mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/service/UserActivity.java
-
869mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/controller/UserApiController.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/controller/package-info.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/package-info.java
-
1317mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/service/UserService.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/service/package-info.java
-
3mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/nulm/service/NULMOfficerActivity.java
-
113mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/controller/APICattleCatchController.java
-
6mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/controller/APIPenaltyController.java
-
96mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/controller/APIPenaltyControllerPOS.java
-
779mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/CattleCatchService.java
-
112mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/PenaltyService.java
-
649mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/PenaltyServicePOS.java
-
30mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/service/MainService.java
-
38mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/service/OfficialAPIService.java
-
76mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/controller/APIController.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/controller/package-info.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/package-info.java
-
324mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/service/activity.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/service/package-info.java
-
9mobileservice/src/main/resources/application.properties
@ -0,0 +1 @@ |
|||||
|
.DS_Store |
||||
|
Before Width: 43 | Height: 43 | Size: 1.9 KiB |
|
Before Width: 41 | Height: 40 | Size: 1.3 KiB |
|
Before Width: 40 | Height: 40 | Size: 1.2 KiB |
|
Before Width: 40 | Height: 40 | Size: 3.1 KiB |
|
Before Width: 40 | Height: 40 | Size: 981 B |
|
Before Width: 40 | Height: 40 | Size: 2.3 KiB |
|
Before Width: 40 | Height: 40 | Size: 1.6 KiB |
|
Before Width: 40 | Height: 40 | Size: 2.9 KiB |
|
Before Width: 40 | Height: 40 | Size: 2.5 KiB |
|
Before Width: 40 | Height: 40 | Size: 2.3 KiB |
|
Before Width: 40 | Height: 40 | Size: 1.6 KiB |
|
After Width: 1280 | Height: 720 | Size: 388 KiB |
|
After Width: 1280 | Height: 720 | Size: 550 KiB |
@ -0,0 +1,909 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccparks.controller; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.util.Collections; |
||||
|
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.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.util.MultiValueMap; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import in.gov.chennaicorporation.mobileservice.gccparks.service.NoDataException; |
||||
|
import in.gov.chennaicorporation.mobileservice.gccparks.service.ParksService; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/api/parks") |
||||
|
@RestController("gccofficalapparksrest") |
||||
|
public class ParksController { |
||||
|
|
||||
|
@Autowired |
||||
|
private ParksService parksService; |
||||
|
|
||||
|
@GetMapping("/saveAssets") |
||||
|
public List<?> saveAssets(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "categoryId", required = false) String categoryId, |
||||
|
@RequestParam(value = "assetTypeId", required = false) String assetTypeId, |
||||
|
@RequestParam(value = "latitude", required = false) String latitude, |
||||
|
@RequestParam(value = "longitude", required = false) String longitude, |
||||
|
@RequestParam(value = "zone", required = false) String zone, |
||||
|
@RequestParam(value = "ward", required = false) String ward, |
||||
|
@RequestParam(value = "streeId", required = false) String streeId, |
||||
|
@RequestParam(value = "streetName", required = false) String streetName, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId, |
||||
|
@RequestParam(value = "name", required = false) String name, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile file) { |
||||
|
return parksService.saveAsset(formData, categoryId, assetTypeId, latitude, longitude, zone, ward, streeId, |
||||
|
streetName, loginId, name, file); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/filterAssets") |
||||
|
public List<?> getAssets(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "categoryId", required = false) String categoryId, |
||||
|
@RequestParam(value = "assetTypeId", required = false) String assetTypeId, |
||||
|
@RequestParam(value = "latitude", required = false) String latitude, |
||||
|
@RequestParam(value = "longitude", required = false) String longitude) { |
||||
|
return parksService.loadAssetByFilter(categoryId, assetTypeId, latitude, longitude); |
||||
|
} |
||||
|
|
||||
|
// ----------------------------------------------Enumeration |
||||
|
// API------------------------------------------------ |
||||
|
@PostMapping("/centerMedianEnumeration") |
||||
|
public ResponseEntity<String> centerMedianEnumeration(@RequestParam("EnterParkName") String EnterParkName, |
||||
|
@RequestParam("maintained_By") int maintained_By, @RequestParam("Enu_Area_Meters") Double Enu_Area_Meters, |
||||
|
@RequestParam("TypeofCenterMedian") int TypeofCenterMedian, // ask |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude, |
||||
|
@RequestParam("zone") String zone, @RequestParam("ward") String ward, |
||||
|
@RequestParam(value = "location", required = false) String location, @RequestParam("UserId") String UserId, |
||||
|
@RequestParam("Enumeration_Image") MultipartFile photo, |
||||
|
@RequestParam("enumeration_type") String enumeration_type |
||||
|
|
||||
|
) throws Exception { |
||||
|
|
||||
|
int centerMedianEnumeration = parksService.centerMedianEnumeration(EnterParkName, maintained_By, |
||||
|
Enu_Area_Meters, TypeofCenterMedian, latitude, longitude, zone, ward, location, UserId, photo, |
||||
|
enumeration_type); |
||||
|
|
||||
|
if (centerMedianEnumeration == 0 || centerMedianEnumeration == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/trafficIslandEnumeration") |
||||
|
public ResponseEntity<String> trafficIslandEnumeration( |
||||
|
@RequestParam("maintained_By") int maintained_By, @RequestParam("Enu_Area_Meters") Double Enu_Area_Meters, |
||||
|
@RequestParam("TypeofCenterMedian") int Type_of_Traffic_Island, // ask |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude, |
||||
|
@RequestParam("zone") String zone, @RequestParam("ward") String ward, |
||||
|
@RequestParam(value = "location", required = false) String location, @RequestParam("UserId") String UserId, |
||||
|
@RequestParam("Enumeration_Image") MultipartFile photo, |
||||
|
@RequestParam("enumeration_type") String enumeration_type) throws Exception { |
||||
|
|
||||
|
int trafficIslandEnumeration = parksService.trafficIslandEnumeration(maintained_By, Enu_Area_Meters, |
||||
|
Type_of_Traffic_Island, latitude, longitude, zone, ward, location, UserId, photo, enumeration_type); |
||||
|
if (trafficIslandEnumeration == 0 || trafficIslandEnumeration == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/parkEnumeration") |
||||
|
public ResponseEntity<String> parkEnumeration(@RequestParam("EnterParkName") String EnterParkName, |
||||
|
@RequestParam("maintained_By") int maintained_By, @RequestParam("latitude") String latitude, |
||||
|
@RequestParam("longitude") String longitude, @RequestParam("zone") String zone, |
||||
|
@RequestParam("ward") String ward, @RequestParam(value = "location", required = false) String location, |
||||
|
@RequestParam("UserId") String UserId, @RequestParam("Zone_Available") String Zone_Available, // reading zone |
||||
|
@RequestParam("Enumeration_Image") MultipartFile photo, |
||||
|
@RequestParam("enumeration_type") String enumeration_type) throws Exception { |
||||
|
|
||||
|
int parkEnumeration = parksService.parkEnumeration(EnterParkName, maintained_By, latitude, longitude, zone, |
||||
|
ward, location, UserId, photo, Zone_Available, enumeration_type); |
||||
|
|
||||
|
if (parkEnumeration == 0 || parkEnumeration == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/beautificationRoadEnumeration") |
||||
|
public ResponseEntity<String> beautificationRoad( |
||||
|
// @RequestParam("Area") String Area,//location |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude, |
||||
|
@RequestParam("zone") String zone, @RequestParam("ward") String ward, |
||||
|
@RequestParam(value = "location", required = false) String location, @RequestParam("UserId") String UserId, |
||||
|
@RequestParam("Enumeration_Image") MultipartFile photo, |
||||
|
@RequestParam("enumeration_type") String enumeration_type) throws Exception { |
||||
|
|
||||
|
int beautificationRoad = parksService.beautificationRoad(latitude, longitude, zone, ward, location, UserId, |
||||
|
photo, enumeration_type); |
||||
|
|
||||
|
if (beautificationRoad == 0 || beautificationRoad == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/readingZoneEnumeration") |
||||
|
public ResponseEntity<String> readingZone( |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude, |
||||
|
@RequestParam("zone") String zone, @RequestParam("ward") String ward, |
||||
|
@RequestParam(value = "location", required = false) String location, @RequestParam("UserId") String UserId, |
||||
|
// @RequestParam("Zone_Available_name") String Zone_Available_name,//reading zone |
||||
|
@RequestParam("Enumeration_Image") MultipartFile photo, |
||||
|
@RequestParam("enumeration_type") String enumeration_type, @RequestParam("park_name") String park_name // name |
||||
|
) throws Exception { |
||||
|
|
||||
|
int readingZone = parksService.readingZone(latitude, longitude, zone, ward, location, UserId, photo, |
||||
|
enumeration_type, park_name); |
||||
|
|
||||
|
if (readingZone == 0 || readingZone == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/miyawakiNewEnumeration") |
||||
|
public ResponseEntity<String> miyawakiNew(@RequestParam("latitude") String latitude, |
||||
|
@RequestParam("longitude") String longitude, @RequestParam("zone") String zone, |
||||
|
@RequestParam("ward") String ward, @RequestParam(value = "location", required = false) String location, |
||||
|
@RequestParam("UserId") String UserId, @RequestParam("Type_of_place") String Type_of_place, // reading zone |
||||
|
@RequestParam("Enumeration_Image") MultipartFile photo, |
||||
|
@RequestParam("enumeration_type") String enumeration_type) throws Exception { |
||||
|
|
||||
|
int miyawakiNew = parksService.miyawakiNew(Type_of_place, latitude, longitude, zone, ward, location, UserId, |
||||
|
photo, enumeration_type); |
||||
|
|
||||
|
if (miyawakiNew == 0 || miyawakiNew == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/miyawakiExistingEnumeration") |
||||
|
public ResponseEntity<String> miyawakiExisting(@RequestParam("latitude") String latitude, |
||||
|
@RequestParam("longitude") String longitude, @RequestParam("zone") String zone, |
||||
|
@RequestParam("ward") String ward, @RequestParam(value = "location", required = false) String location, |
||||
|
@RequestParam("UserId") String UserId, @RequestParam("maintained_By") int maintained_By, |
||||
|
@RequestParam("Enumeration_Image") MultipartFile photo, |
||||
|
@RequestParam("enumeration_type") String enumeration_type) throws Exception { |
||||
|
|
||||
|
int miyawakiExisting = parksService.miyawakiExisting(maintained_By, latitude, longitude, zone, ward, location, |
||||
|
UserId, photo, enumeration_type); |
||||
|
|
||||
|
if (miyawakiExisting == 0 || miyawakiExisting == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
|
||||
|
// To fetch park name within 500 meter radius |
||||
|
@GetMapping("/location") |
||||
|
public ResponseEntity<List<Map<String, Object>>> location(@RequestParam("latitude") String latitude, |
||||
|
@RequestParam("longitude") String longitude, @RequestParam("enumeration_type") String enumeration_type) throws Exception { |
||||
|
List<Map<String, Object>> dataByLocation = parksService.getDateByLocation(latitude, longitude,enumeration_type); |
||||
|
|
||||
|
if (dataByLocation == null || dataByLocation.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(dataByLocation); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* // To fetch park name with reading zone available |
||||
|
* |
||||
|
* @PostMapping("/parkname") public ResponseEntity<List<Map<String, Object>>> |
||||
|
* parkname() throws Exception { List<Map<String, Object>> parkName = |
||||
|
* parksService.parkName(); |
||||
|
* |
||||
|
* return ResponseEntity.ok(parkName); } |
||||
|
*/ |
||||
|
|
||||
|
@GetMapping("/parkname") |
||||
|
public ResponseEntity<List<Map<String, Object>>> parkname(@RequestParam("latitude") String latitude, |
||||
|
@RequestParam("longitude") String longitude) throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> dataByLocation = parksService.getReadingZoneParkByLocation(latitude, longitude, |
||||
|
latitude); |
||||
|
|
||||
|
return ResponseEntity.ok(dataByLocation); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// -----------------------------------------------Feedback |
||||
|
// API----------------------------------------------------------------- |
||||
|
|
||||
|
@PostMapping("/centerMedianFeedback") |
||||
|
public ResponseEntity<String> centerMedian(@RequestParam("irrigationProperlyQa") String irrigationProperlyQa, |
||||
|
@RequestParam("irrigationProperlyAns") String irrigationProperlyAns, |
||||
|
@RequestParam("trimmingProperlyQa") String trimmingProperlyQa, |
||||
|
@RequestParam("trimmingProperlyAns") String trimmingProperlyAns, |
||||
|
@RequestParam("weedingQa") String weedingQa, @RequestParam("weedingans") String weedingAns, |
||||
|
@RequestParam("HandRailingQa") String HandRailingQa, @RequestParam("HandRailingAns") String HandRailingAns, |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude, |
||||
|
@RequestParam("zone") String zone, @RequestParam("ward") String ward, |
||||
|
@RequestParam("location") String location, @RequestParam("enumeration_id") String enumeration_id, |
||||
|
@RequestParam("enumeration_type") String enumeration_type, @RequestParam("userId") String userId, |
||||
|
@RequestParam("centerMedian_Image") MultipartFile photo) throws Exception { |
||||
|
|
||||
|
int centerMedian = parksService.centerMedian(irrigationProperlyQa, irrigationProperlyAns, trimmingProperlyQa, |
||||
|
trimmingProperlyAns, weedingQa, weedingAns, HandRailingQa, HandRailingAns, latitude, longitude, zone, |
||||
|
ward, location, enumeration_type, userId, enumeration_id, photo); |
||||
|
|
||||
|
if (centerMedian == 0 || centerMedian == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
/*// Patch 23-11-2024 |
||||
|
@PostMapping("/trafficIslandFeedback") |
||||
|
public ResponseEntity<String> trafficIsland( |
||||
|
// gap filling meter |
||||
|
@RequestParam("irrigationProperlyQa") String irrigationProperlyQa, |
||||
|
@RequestParam("irrigationProperlyAns") String irrigationProperlyAns, |
||||
|
@RequestParam("trimmingProperlyQa") String trimmingProperlyQa, |
||||
|
@RequestParam("trimmingProperlyAns") String trimmingProperlyAns, |
||||
|
@RequestParam("weedingQa") String weedingQa, @RequestParam("weedingans") String weedingans, |
||||
|
@RequestParam("HandRailingQa") String HandRailingQa, @RequestParam("HandRailingAns") String HandRailingAns, |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude, |
||||
|
@RequestParam("zone") String zone, @RequestParam("ward") String ward, |
||||
|
@RequestParam("location") String location, @RequestParam("userId") String userId, |
||||
|
@RequestParam("enumerationi_id") String enumerationi_id, |
||||
|
@RequestParam("enumeration_type") String enumeration_type, @RequestParam("gapFilingQa") String gapFillingQa, |
||||
|
@RequestParam("gapFilingAns") String gapFilingAns, @RequestParam("improvementQa") String improvementQa, // ask |
||||
|
@RequestParam("improvementAns") String improvementAns, // ask |
||||
|
@RequestParam("trafficIsland_Image") MultipartFile photo |
||||
|
|
||||
|
) throws Exception { |
||||
|
|
||||
|
int trafficIsland = parksService.trafficIsland(irrigationProperlyQa, irrigationProperlyAns, trimmingProperlyQa, |
||||
|
trimmingProperlyAns, weedingQa, weedingans, HandRailingQa, HandRailingAns, latitude, longitude, zone, |
||||
|
ward, location, userId, enumeration_type, enumerationi_id, gapFillingQa, gapFilingAns, improvementQa, |
||||
|
improvementAns, photo); |
||||
|
|
||||
|
if (trafficIsland == 0 || trafficIsland == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
*/ |
||||
|
@PostMapping("/trafficIslandFeedback") |
||||
|
public ResponseEntity<String> trafficIsland( |
||||
|
// gap filling meter |
||||
|
@RequestParam("irrigationProperlyQa") String irrigationProperlyQa, |
||||
|
@RequestParam("irrigationProperlyAns") String irrigationProperlyAns, |
||||
|
@RequestParam("trimmingProperlyQa") String trimmingProperlyQa, |
||||
|
@RequestParam("trimmingProperlyAns") String trimmingProperlyAns, |
||||
|
@RequestParam("weedingQa") String weedingQa, @RequestParam("weedingans") String weedingans, |
||||
|
@RequestParam("HandRailingQa") String HandRailingQa, @RequestParam("HandRailingAns") String HandRailingAns, |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude, |
||||
|
@RequestParam("zone") String zone, @RequestParam("ward") String ward, |
||||
|
@RequestParam("location") String location, @RequestParam("userId") String userId, |
||||
|
@RequestParam("enumerationi_id") String enumerationi_id, |
||||
|
@RequestParam("enumeration_type") String enumeration_type, @RequestParam("gapFilingQa") String gapFillingQa, |
||||
|
@RequestParam("gapFilingAns") String gapFilingAns, @RequestParam("improvementQa") String improvementQa, // ask |
||||
|
@RequestParam("improvementAns") String improvementAns, // ask |
||||
|
@RequestParam("fountainAvailableQa") String fountainAvailableQa, |
||||
|
@RequestParam("fountainAvailableAns") String fountainAvailableAns, |
||||
|
@RequestParam("fountainWorkingQa") String fountainWorkingQa, // ask |
||||
|
@RequestParam("fountainWorkingAns") String fountainWorkingAns, |
||||
|
@RequestParam("trafficIsland_Image") MultipartFile photo |
||||
|
|
||||
|
) throws Exception { |
||||
|
|
||||
|
int trafficIsland = parksService.trafficIsland(irrigationProperlyQa, irrigationProperlyAns, trimmingProperlyQa, |
||||
|
trimmingProperlyAns, weedingQa, weedingans, HandRailingQa, HandRailingAns, latitude, longitude, zone, |
||||
|
ward, location, userId, enumeration_type, enumerationi_id, gapFillingQa, gapFilingAns, improvementQa, |
||||
|
improvementAns, fountainAvailableQa, fountainAvailableAns,fountainWorkingQa,fountainWorkingAns, photo); |
||||
|
|
||||
|
if (trafficIsland == 0 || trafficIsland == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/beautificationFeedback") |
||||
|
public ResponseEntity<String> beautification( |
||||
|
@RequestParam("irrigationProperlyQa") String irrigationProperlyQa, |
||||
|
@RequestParam("irrigationProperlyAns") String irrigationProperlyAns, |
||||
|
@RequestParam("trimmingProperlyQa") String trimmingProperlyQa, |
||||
|
@RequestParam("trimmingProperlyAns") String trimmingProperlyAns, |
||||
|
@RequestParam("weedingQa") String weedingQa, @RequestParam("weedingans") String weedingans, |
||||
|
@RequestParam("gapFillingQa") String gapFillingQa, @RequestParam("gapFillingAns") String gapFillingAns, |
||||
|
@RequestParam("improvementQa") String improvementQa, @RequestParam("improvementAns") String improvementAns, |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude, |
||||
|
@RequestParam("zone") String zone, @RequestParam("ward") String ward, |
||||
|
@RequestParam("location") String location, @RequestParam("beautification_Image") MultipartFile photo, // image |
||||
|
@RequestParam("enumerationi_id") String enumerationi_id, @RequestParam("userId") String userId, |
||||
|
@RequestParam("enumeration_type") String enumeration_type) throws Exception { |
||||
|
|
||||
|
int beautification = parksService.beautification(irrigationProperlyQa, irrigationProperlyAns, |
||||
|
trimmingProperlyQa, trimmingProperlyAns, weedingQa, weedingans, gapFillingQa, gapFillingAns, |
||||
|
improvementQa, improvementAns, latitude, longitude, zone, ward, location, enumerationi_id, userId, |
||||
|
enumeration_type, photo); |
||||
|
|
||||
|
if (beautification == 0 || beautification == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/parkInspectionFeedback") |
||||
|
public ResponseEntity<String> prakInspection(@RequestParam("openedQa") String openedQa, |
||||
|
@RequestParam("openedAns") String openedAns, |
||||
|
@RequestParam("irrigationProperlyQa") String irrigationProperlyQa, |
||||
|
@RequestParam("irrigationProperlyAns") String irrigationProperlyAns, |
||||
|
@RequestParam("trimmingProperlyQa") String trimmingProperlyQa, |
||||
|
@RequestParam("trimmingProperlyAns") String trimmingProperlyAns, |
||||
|
@RequestParam("weedingQa") String weedingQa, @RequestParam("weedingans") String weedingans, |
||||
|
@RequestParam("gapFillingQa") String gapFillingQa, @RequestParam("gapFillingAns") String gapFillingAns, |
||||
|
@RequestParam("playandGymQa") String playandGymQa, @RequestParam("playandGymAns") String playandGymAns, |
||||
|
@RequestParam("overAllQa") String overAllQa, @RequestParam("overAllans") String overAllAns, |
||||
|
@RequestParam("properLightQa") String properLightQa, @RequestParam("properLightAns") String properLightAns, |
||||
|
@RequestParam("debrisRemovalQa") String debrisRemovalQa, |
||||
|
@RequestParam("debrisRemovalAns") String debrisRemovalAns, @RequestParam("ToiletQA") String ToiletAQA, |
||||
|
@RequestParam("ToiletAns") String ToiletAns, @RequestParam("latitude") String latitude, |
||||
|
@RequestParam("longitude") String longitude, @RequestParam("zone") String zone, |
||||
|
@RequestParam("ward") String ward, @RequestParam("location") String location, |
||||
|
@RequestParam("enumerationi_id") String enumerationi_id, @RequestParam("userId") String userId, |
||||
|
@RequestParam("enumeration_type") String enumeration_type, |
||||
|
@RequestParam("prakInspection_Image") MultipartFile photo, @RequestParam("CivilWorkQa") String CivilWorkQa, |
||||
|
@RequestParam("CivilWorkAns") String CivilWorkAns, // type |
||||
|
@RequestParam("NoWatchmenQa") String NoWatchmenQa, @RequestParam("NoWatchmenAns") String NoWatchmenAns, // type |
||||
|
@RequestParam("NoSweeperQa") String NoSweeperQa, @RequestParam("NoSweeperAns") String NoSweeperAns |
||||
|
|
||||
|
) throws Exception { |
||||
|
|
||||
|
int prakInspection = parksService.parkInspection(openedQa, openedAns, irrigationProperlyQa, |
||||
|
irrigationProperlyAns, trimmingProperlyQa, trimmingProperlyAns, weedingQa, weedingans, gapFillingQa, |
||||
|
gapFillingAns, playandGymQa, playandGymAns, overAllQa, overAllAns, properLightQa, properLightAns, |
||||
|
debrisRemovalQa, debrisRemovalAns, ToiletAQA, ToiletAns, latitude, longitude, zone, ward, location, |
||||
|
userId, enumeration_type, enumerationi_id, CivilWorkQa, CivilWorkAns, NoWatchmenQa, NoWatchmenAns, |
||||
|
NoSweeperQa, NoSweeperAns, photo); |
||||
|
|
||||
|
if (prakInspection == 0 || prakInspection == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/readingZoneFeedback") |
||||
|
public ResponseEntity<String> readingZone( |
||||
|
@RequestParam("openedOrNotQa") String openedOrNotQa, @RequestParam("openedOrNotAns") String openedOrNotAns, |
||||
|
@RequestParam("bookAvailableQa") String bookAvailableQa, |
||||
|
@RequestParam("bookAvailableAns") String bookAvailableAns, |
||||
|
@RequestParam("NewsapaperAvailableQa") String NewsapaperAvailableQa, |
||||
|
@RequestParam("NewsapaperAvailableAns") String NewsapaperAvailableAns, |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude, |
||||
|
@RequestParam("zone") String zone, @RequestParam("ward") String ward, |
||||
|
@RequestParam("location") String location, @RequestParam("enumerationi_id") String enumerationi_id, |
||||
|
@RequestParam("userId") String userId, @RequestParam("enumeration_type") String enumeration_type, |
||||
|
@RequestParam("readingZone_Image") MultipartFile photo, |
||||
|
@RequestParam("improvementQa") String improvementQa, // type |
||||
|
@RequestParam("improvementAns") String improvementAns// type |
||||
|
|
||||
|
) throws Exception { |
||||
|
|
||||
|
int readingZone = parksService.readingZone(openedOrNotQa, openedOrNotAns, bookAvailableQa, bookAvailableAns, |
||||
|
NewsapaperAvailableQa, NewsapaperAvailableAns, latitude, longitude, zone, ward, location, userId, |
||||
|
enumeration_type, enumerationi_id, improvementQa, improvementAns, photo); |
||||
|
|
||||
|
if (readingZone == 0 || readingZone == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/miyawakiNewFeedback") |
||||
|
public ResponseEntity<String> miyawakiNew( |
||||
|
@RequestParam("debrisCleaningQa") String debrisCleaningQa, |
||||
|
@RequestParam("debrisCleaningAns") String debrisCleaningAns, |
||||
|
@RequestParam("landpreprarationQa") String landpreprarationQa, |
||||
|
@RequestParam("landpreprarationAns") String landpreprarationAns, |
||||
|
@RequestParam("plantingDoneQa") String plantingDoneQa, |
||||
|
@RequestParam("plantingDoneAns") String plantingDoneAns, @RequestParam("cctvQa") String cctvQa, |
||||
|
@RequestParam("cctvAns") String cctvAns, @RequestParam("latitude") String latitude, |
||||
|
@RequestParam("longitude") String longitude, @RequestParam("zone") String zone, |
||||
|
@RequestParam("ward") String ward, @RequestParam("location") String location, |
||||
|
@RequestParam("enumerationi_id") String enumerationi_id, @RequestParam("userId") String userId, |
||||
|
@RequestParam("enumeration_type") String enumeration_type, |
||||
|
@RequestParam("SaplingAvailbilityQa") String saplingAvailQa, |
||||
|
@RequestParam("SaplingAvailbilityAns") String saplingAvailAns, |
||||
|
@RequestParam("fencingAvailbilityQa") String fencingAvailbilityQa, |
||||
|
@RequestParam("fencingAvailbilityAns") String fencingAvailbilityAns, |
||||
|
@RequestParam("sourcaOfIrrigationQa") String sourcaOfIrrigationQa, // type |
||||
|
@RequestParam("sourcaOfIrrigationAns") String sourcaOfIrrigationAns, // type |
||||
|
|
||||
|
@RequestParam("miyawakiNew_Image") MultipartFile photo) throws Exception { |
||||
|
|
||||
|
int miyawakiNew = parksService.miyawakiNew(debrisCleaningQa, debrisCleaningAns, landpreprarationQa, |
||||
|
landpreprarationAns, plantingDoneQa, plantingDoneAns, cctvQa, cctvAns, latitude, longitude, zone, ward, |
||||
|
location, userId, enumeration_type, enumerationi_id, saplingAvailQa, saplingAvailAns, |
||||
|
fencingAvailbilityQa, fencingAvailbilityAns, sourcaOfIrrigationQa, sourcaOfIrrigationAns, photo); |
||||
|
|
||||
|
if (miyawakiNew == 0 || miyawakiNew == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the detailse"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/miyawakiExisitingFeedback") |
||||
|
public ResponseEntity<String> miyawakiExisiting( |
||||
|
@RequestParam("weedingQa") String weedingQa, @RequestParam("weedingAns") String weedingAns, |
||||
|
@RequestParam("purningQa") String purningQa, @RequestParam("purningans") String purningans, |
||||
|
@RequestParam("gapFillingQa") String gapFillingQa, @RequestParam("gapFillingAns") String gapFillingAns, |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude, |
||||
|
@RequestParam("zone") String zone, @RequestParam("ward") String ward, |
||||
|
@RequestParam("location") String location, @RequestParam("enumerationi_id") String enumerationi_id, |
||||
|
@RequestParam("userId") String userId, @RequestParam("enumeration_type") String enumeration_type, |
||||
|
@RequestParam("improvmetReqQa") String improvmetReqQa, |
||||
|
@RequestParam("improvmetReqAns") String improvmetReqAns, |
||||
|
@RequestParam("sourceOfirrigationQa") String sourceOfirrigationQa, |
||||
|
@RequestParam("sourceOfirrigationAns") String sourceOfirrigationAns, |
||||
|
@RequestParam("miyawakiExisiting_Image") MultipartFile photo) throws Exception { |
||||
|
|
||||
|
int miyawakiExisiting = parksService.miyawakiExisiting(weedingQa, weedingAns, purningQa, purningans, |
||||
|
gapFillingQa, gapFillingAns, latitude, longitude, zone, ward, location, userId, enumeration_type, |
||||
|
enumerationi_id, improvmetReqQa, improvmetReqAns, sourceOfirrigationQa, sourceOfirrigationAns, photo); |
||||
|
|
||||
|
if (miyawakiExisiting == 0 || miyawakiExisiting == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
} |
||||
|
|
||||
|
// To fetch Category ID and Name for reports |
||||
|
|
||||
|
@GetMapping("/enuumerationType") |
||||
|
public ResponseEntity<List<Map<String, Object>>> enuumerationType() { |
||||
|
List<Map<String, Object>> parkName = parksService.categoryType(); |
||||
|
return ResponseEntity.ok(parkName); |
||||
|
} |
||||
|
|
||||
|
// To fetch master category type based on enumeration type |
||||
|
@GetMapping("/masterCategoryType") |
||||
|
public ResponseEntity<List<Map<String, Object>>> masterCategoryType( |
||||
|
@RequestParam("enumeration_type_id") String Cat_enumeration_id) { |
||||
|
List<Map<String, Object>> parkName = parksService.masterCategoryType(Cat_enumeration_id); |
||||
|
return ResponseEntity.ok(parkName); |
||||
|
} |
||||
|
|
||||
|
// To fetch sub category type based on master category type |
||||
|
@GetMapping("/subCategoryType") |
||||
|
public ResponseEntity<List<Map<String, Object>>> subCategoryType( |
||||
|
@RequestParam("master_category_id") String masterCategory) { |
||||
|
|
||||
|
List<Map<String, Object>> parkName = parksService.subCategoryType(masterCategory); |
||||
|
return ResponseEntity.ok(parkName); |
||||
|
} |
||||
|
|
||||
|
// ------------------------------------------Tree Feedback |
||||
|
// API----------------------------------------------------- |
||||
|
|
||||
|
@PostMapping("/treeDetails") |
||||
|
public ResponseEntity<Map<String, Object>> SaveTreeDetailes( |
||||
|
@RequestParam("No_of_trees_required") int No_of_trees_required, |
||||
|
@RequestParam("enumeration_type") String enumeration_type, @RequestParam("tree_Image") MultipartFile tree_Image, |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude, |
||||
|
@RequestParam("zone") String zone, @RequestParam("ward") String ward, |
||||
|
@RequestParam("location") String location, @RequestParam("parkname") String parkname, |
||||
|
// @RequestParam(value = "painting_status", required = false) String painting_status, |
||||
|
@RequestParam("userId") String userId) throws IOException { |
||||
|
|
||||
|
Map<String, Object> saveTreeDetailes = parksService.SaveTreeDetailes(No_of_trees_required, enumeration_type, |
||||
|
latitude, longitude, zone, ward, location, parkname, userId, tree_Image); |
||||
|
return ResponseEntity.ok(saveTreeDetailes); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@PostMapping("/SaveTreeimage") |
||||
|
public ResponseEntity<Map<String, Object>> SaveTreeimage(@RequestParam("tree_id") int tree_id, |
||||
|
@RequestParam("enumeration_type") String enumeration_type, @RequestParam("tree_Image") MultipartFile tree_Image, |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude, |
||||
|
// @RequestParam("enumeration_type") String enumeration_type, |
||||
|
@RequestParam("userId") String userId) throws Exception { |
||||
|
|
||||
|
Map<String, Object> saveTreeDetailes = parksService.SaveimageDetailes(enumeration_type, latitude, longitude, |
||||
|
userId, tree_Image, tree_id); |
||||
|
return ResponseEntity.ok(saveTreeDetailes); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// ------------------------------------------Enumeration Report |
||||
|
// API----------------------------------------------------- |
||||
|
|
||||
|
@GetMapping("/zoneCount") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getZoneCount(@RequestParam("fromdate") String fromdate, |
||||
|
@RequestParam("todate") String todate, @RequestParam("enumeration_type") String enumeration_type, |
||||
|
@RequestParam("userId") String userId) throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> zoneCountData = parksService.getZoneCount(fromdate, todate, enumeration_type, userId); |
||||
|
if (zoneCountData == null || zoneCountData.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(zoneCountData); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/wardCount") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getwardCount(@RequestParam("zone") String zone, |
||||
|
@RequestParam("userId") String userId, @RequestParam("fromdate") String fromdate, |
||||
|
@RequestParam("todate") String todate, @RequestParam("enumeration_type") String enumeration_type) |
||||
|
throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> wardCountData = parksService.getwardCount(zone, fromdate, todate, enumeration_type, userId); |
||||
|
if (wardCountData == null || wardCountData.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(wardCountData); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/activityCount") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getActivityCount(@RequestParam("ward") String ward, |
||||
|
@RequestParam("fromdate") String fromdate, @RequestParam("todate") String todate, |
||||
|
@RequestParam("enumeration_type") String enumeration_type) throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> activityByWard = parksService.getActivityCount(ward, fromdate, todate, |
||||
|
enumeration_type); |
||||
|
if (activityByWard == null || activityByWard.isEmpty()) { |
||||
|
throw new NoDataException("No Activity is performed "); |
||||
|
} |
||||
|
return ResponseEntity.ok(activityByWard); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/activityDetails") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getActivityDetails(@RequestParam("ward") String ward, |
||||
|
@RequestParam("fromdate") String fromdate, @RequestParam("todate") String todate, |
||||
|
@RequestParam("enumeration_type") String enumeration_type, |
||||
|
@RequestParam("enumerationId") String enumerationId) throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> activityDetailsByWard = parksService.getActivityDetails(ward, fromdate, todate, |
||||
|
enumeration_type, enumerationId); |
||||
|
if (activityDetailsByWard == null || activityDetailsByWard.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(activityDetailsByWard); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getInspectionDetails") |
||||
|
public ResponseEntity<List<List<Map<String, Object>>>> getInspectionDetails( |
||||
|
@RequestParam("activityId") String activityId, @RequestParam("fromdate") String fromdate, |
||||
|
@RequestParam("todate") String todate, @RequestParam("enumerationId") String enumerationId) |
||||
|
throws Exception { |
||||
|
|
||||
|
List<List<Map<String, Object>>> activityDetailsByWard = parksService.getInspectionDetails(activityId, fromdate, |
||||
|
todate, enumerationId); |
||||
|
if (activityDetailsByWard == null || activityDetailsByWard.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(activityDetailsByWard); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// tofxcvbn |
||||
|
@GetMapping("/getParkCount") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getParkCount(@RequestParam("fromdate") String fromdate, |
||||
|
@RequestParam("todate") String todate, @RequestParam("ward") String ward, |
||||
|
@RequestParam("userId") String userId, @RequestParam("enumeration_type") String enumeration_type) |
||||
|
throws Exception { |
||||
|
|
||||
|
try { |
||||
|
List<Map<String, Object>> dateByLocation = parksService.getParkCount(ward, fromdate, todate, |
||||
|
enumeration_type); |
||||
|
|
||||
|
if (dateByLocation == null || dateByLocation.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} else { |
||||
|
return ResponseEntity.ok(dateByLocation); |
||||
|
} |
||||
|
} catch (NoDataException e) { |
||||
|
// TODO Auto-generated catch block |
||||
|
throw new NoDataException("no data"); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getParkDetails") |
||||
|
public ResponseEntity<List<List<Map<String, Object>>>> getParkDetails( |
||||
|
@RequestParam(value = "enumeration_type", required = false) String enumeration_type, |
||||
|
@RequestParam("userId") String userId, @RequestParam("fromdate") String fromdate, |
||||
|
@RequestParam("todate") String todate) throws Exception { |
||||
|
|
||||
|
List<List<Map<String, Object>>> dateByLocation = parksService.getParkDetails(enumeration_type, fromdate, todate, userId); |
||||
|
if (dateByLocation == null || dateByLocation.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(dateByLocation); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
//////////////////// ------------------------------tree-------------------/////////////////////////// |
||||
|
|
||||
|
@GetMapping("/treeWishZoneCount") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getWishtreeZoneCount(@RequestParam("fromdate") String fromdate, |
||||
|
@RequestParam("todate") String todate, @RequestParam("enumeration_type") String enumeration_type, |
||||
|
@RequestParam("userId") String userId) throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> dateByLocation = parksService.getWishtreeZoneCount(fromdate, todate, |
||||
|
enumeration_type); |
||||
|
if (dateByLocation == null || dateByLocation.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(dateByLocation); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// to |
||||
|
@GetMapping("/treeWardCount") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getTreewardCount(@RequestParam("fromdate") String fromdate, |
||||
|
@RequestParam("todate") String todate, @RequestParam("zone") String zone, |
||||
|
@RequestParam("userId") String userId, @RequestParam("enumeration_type") String enumeration_type) |
||||
|
throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> dateByLocation = parksService.getTreewardCount(zone, fromdate, todate, |
||||
|
enumeration_type); |
||||
|
if (dateByLocation == null || dateByLocation.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(dateByLocation); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/wardWishTreedata") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getwardWishTreedata(@RequestParam("ward") String ward, |
||||
|
@RequestParam("userId") String userId) throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> dateByLocation = parksService.getwardWishTreedata(ward); |
||||
|
if (dateByLocation == null || dateByLocation.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(dateByLocation); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getTreeWardWiseCountDetails") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getTreeWardWiseCountDetails(@RequestParam("ward") String ward, |
||||
|
@RequestParam("enumeration_type") String enumeration_type,@RequestParam("fromdate") String fromdate, |
||||
|
@RequestParam("todate") String todate) throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> treeCountByWard = parksService.getTreeWardWiseCountDetails(ward,enumeration_type,fromdate,todate); |
||||
|
if (treeCountByWard == null || treeCountByWard.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(treeCountByWard); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getTreeImageDetails") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getTreeImageDetails(@RequestParam("tree_Id") String tree_Id, |
||||
|
@RequestParam("enumeration_type") String enumeration_type, @RequestParam("fromdate") String fromdate, |
||||
|
@RequestParam("todate") String todate) throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> treeImageDetails = parksService.getTreeImageDetails(tree_Id,enumeration_type, fromdate, todate); |
||||
|
if (treeImageDetails == null || treeImageDetails.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(treeImageDetails); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getTreeDetails") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getTreeDetails(@RequestParam("tree_Id") String tree_Id, |
||||
|
@RequestParam("userId") String userId) throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> dateByLocation = parksService.getTreeDetails(tree_Id); |
||||
|
if (dateByLocation == null || dateByLocation.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(dateByLocation); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// feedback |
||||
|
|
||||
|
@GetMapping("/enumerationFeedback") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getEnumerationFeedback( |
||||
|
@RequestParam("enumerationId") String enumerationId, |
||||
|
@RequestParam("enumeration_type") String enumeration_type) throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> feedbackData = parksService.getEnumeration_feedback(enumerationId, enumeration_type); |
||||
|
|
||||
|
if (feedbackData == null || feedbackData.isEmpty()) { |
||||
|
throw new NoDataException("No feedback data found."); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok(feedbackData); |
||||
|
} |
||||
|
|
||||
|
// To Get Brief Report |
||||
|
@GetMapping("/getBriefReport") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getBriefReport(@RequestParam("fromdate") String fromdate, |
||||
|
@RequestParam("todate") String todate, @RequestParam("enumeration_type") String category, |
||||
|
@RequestParam("division") String divison, @RequestParam("zone") String zone, |
||||
|
@RequestParam("park_name") String park_name) throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> briefReport = parksService.getBriefReport(fromdate, todate, category, divison, zone, |
||||
|
park_name); |
||||
|
if (briefReport == null || briefReport.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(briefReport); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getUserBasedEnumAndStatus") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getUserBasedEnum(@RequestParam("userId") String tree_user_id, |
||||
|
@RequestParam("latitude") String tree_latitude, @RequestParam("longitude") String tree_longitude, |
||||
|
@RequestParam("Status") String tree_Status, @RequestParam("enumeration_type") String enumeration_type) throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> userBasedEnum = parksService.getUserBasedEnum(tree_user_id, tree_latitude, |
||||
|
tree_longitude, tree_Status, enumeration_type); |
||||
|
if (userBasedEnum == null || userBasedEnum.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(userBasedEnum); |
||||
|
} |
||||
|
|
||||
|
// @GetMapping("/getEnumByRadiusAndStatus") |
||||
|
// public ResponseEntity<List<Map<String, Object>>> getUserBasedEnum( |
||||
|
// @RequestParam("latitude") String tree_latitude,@RequestParam("longitude") String tree_longitude,@RequestParam("Status") String tree_Status |
||||
|
// ) |
||||
|
// { |
||||
|
// |
||||
|
// List<Map<String, Object>> userBasedEnum = parksService.getUserBasedEnum(tree_latitude,tree_longitude,tree_Status); |
||||
|
// |
||||
|
// if (userBasedEnum == null || userBasedEnum.isEmpty()) { |
||||
|
// throw new NoDataException("no data "); |
||||
|
// } |
||||
|
// return ResponseEntity.ok(userBasedEnum); |
||||
|
// } |
||||
|
|
||||
|
@GetMapping("/getparkNameByRadius") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getparkNameByRadius(@RequestParam("latitude") String tree_latitude, |
||||
|
@RequestParam("longitude") String tree_longitude) { |
||||
|
|
||||
|
List<Map<String, Object>> getparkNameByRadius = parksService.getparkNameByRadius(tree_latitude, tree_longitude); |
||||
|
if (getparkNameByRadius == null || getparkNameByRadius.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(getparkNameByRadius); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getTreeDetailsBasedonLocation") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getTreeDetailsBasedonLocation( |
||||
|
@RequestParam("parkName") String parkName, @RequestParam("location") String location, |
||||
|
@RequestParam("ward") String ward) throws Exception { |
||||
|
|
||||
|
List<Map<String, Object>> treeDataByLocation = parksService.getTreeDetailsBasedonLocation(parkName, location, |
||||
|
ward); |
||||
|
if (treeDataByLocation == null || treeDataByLocation.isEmpty()) { |
||||
|
throw new NoDataException("no data "); |
||||
|
} |
||||
|
return ResponseEntity.ok(treeDataByLocation); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// flowering and Non Flowering API |
||||
|
|
||||
|
@GetMapping("/getparkNameByEnumType") |
||||
|
public ResponseEntity<List<Map<String,Object>>> getparkNameByEnumType(@RequestParam("enum_Type") int enum_Type, |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude){ |
||||
|
|
||||
|
List<Map<String,Object>> parkNameByEnum = parksService.getparkNameByEnumType(enum_Type,latitude,longitude); |
||||
|
|
||||
|
if(parkNameByEnum == null || parkNameByEnum.isEmpty()) |
||||
|
{ |
||||
|
throw new NoDataException("No Data found"); |
||||
|
}else { |
||||
|
return ResponseEntity.ok(parkNameByEnum); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
@PostMapping("/saveFloweringandNonFlowering") |
||||
|
public ResponseEntity<String> saveFloweringandNonFlowering( |
||||
|
@RequestParam("enumType") String enumType,@RequestParam("parkname") String parkname, @RequestParam("userId") String userId, |
||||
|
@RequestParam("enumerationId") int enumerationId, @RequestParam(value="floweringPlantCount", required = false) int floweringPlantCount, |
||||
|
@RequestParam(value="nonFloweringPlantCount", required = false) int nonFloweringPlantCount, |
||||
|
@RequestParam(value="floweringImage", required = false) MultipartFile floweringImg, |
||||
|
@RequestParam(value="nonFloweringImage", required = false) MultipartFile nonFloweringImg) throws Exception { |
||||
|
|
||||
|
int flowringData = parksService.saveFlowringandNonFlowringDetails(enumerationId, enumType,parkname, floweringPlantCount, floweringImg, |
||||
|
nonFloweringPlantCount, nonFloweringImg, userId); |
||||
|
|
||||
|
if (flowringData == 0 || flowringData == -1) { |
||||
|
return ResponseEntity.ok("Failed to save the details"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok("Details were saved successfully"); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
@GetMapping("/getFlowringZoneCount") |
||||
|
public ResponseEntity<List<Map<String,Object>>> getFlowringZoneData(@RequestParam("enumeration_type") String enumeration_type, |
||||
|
@RequestParam("fromdate") String fromdate, @RequestParam("todate") String todate, |
||||
|
@RequestParam(value="userId", required = false) String userId){ |
||||
|
|
||||
|
List<Map<String, Object>> floweringZoneCount = parksService.getFloweringZoneCount(enumeration_type,fromdate,todate,userId); |
||||
|
|
||||
|
if(floweringZoneCount == null || floweringZoneCount.isEmpty()) { |
||||
|
throw new NoDataException("No data found"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok(floweringZoneCount); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@GetMapping("/getFlowringWardCount") |
||||
|
public ResponseEntity<List<Map<String,Object>>> getFlowringWardData(@RequestParam("enumeration_type") String enumeration_type, |
||||
|
@RequestParam("fromdate") String fromdate, @RequestParam("todate") String todate, |
||||
|
@RequestParam(value="userId", required = false) String userId, @RequestParam("zone") String zone){ |
||||
|
|
||||
|
List<Map<String, Object>> floweringWardCount = parksService.getFloweringWardCount(zone, fromdate, todate, enumeration_type, userId); |
||||
|
|
||||
|
if (floweringWardCount == null || floweringWardCount.isEmpty()) { |
||||
|
throw new NoDataException("No data found"); |
||||
|
} |
||||
|
return ResponseEntity.ok(floweringWardCount); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@GetMapping("/getFloweringDetails") |
||||
|
public ResponseEntity<List<Map<String,Object>>> getFloweringDetails(@RequestParam("enumeration_type") String enumeration_type, |
||||
|
@RequestParam("zone") String zone, @RequestParam("ward") String ward, @RequestParam("fromdate") String fromdate, |
||||
|
@RequestParam("todate") String todate, @RequestParam(value="userId" , required = false) String userId, |
||||
|
@RequestParam("parkname") String parkname){ |
||||
|
|
||||
|
List<Map<String,Object>> floweringDetails = parksService.getFloweringDetails(enumeration_type, zone, ward, fromdate, todate, userId, parkname); |
||||
|
if(floweringDetails == null || floweringDetails.isEmpty()) |
||||
|
{ |
||||
|
throw new NoDataException( "No data found"); |
||||
|
} |
||||
|
return ResponseEntity.ok(floweringDetails); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getParkwiseFloweringCount") |
||||
|
public ResponseEntity<List<Map<String,Object>>> getParkwiseFloweringCount(@RequestParam("enumeration_type") String enumeration_type, |
||||
|
@RequestParam("zone") String zone, @RequestParam("ward") String ward, @RequestParam("fromdate") String fromdate, |
||||
|
@RequestParam("todate") String todate, @RequestParam(value="userId", required = false) String userId){ |
||||
|
|
||||
|
|
||||
|
List<Map<String,Object>> parkwiseCount = parksService.getParkwiseFloweringCount(enumeration_type, zone, ward, fromdate, todate, userId); |
||||
|
|
||||
|
if(parkwiseCount == null || parkwiseCount.isEmpty()) |
||||
|
{ |
||||
|
throw new NoDataException( "No data found"); |
||||
|
} |
||||
|
return ResponseEntity.ok(parkwiseCount); |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccparks.controller; |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccparks; |
||||
@ -0,0 +1,30 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccparks.service; |
||||
|
|
||||
|
public class ErrorResponse { |
||||
|
private int statusCode; |
||||
|
private String message; |
||||
|
|
||||
|
// Constructor, getters, and setters |
||||
|
|
||||
|
public ErrorResponse(int statusCode, String message) { |
||||
|
this.statusCode = statusCode; |
||||
|
this.message = message; |
||||
|
} |
||||
|
|
||||
|
public int getStatusCode() { |
||||
|
return statusCode; |
||||
|
} |
||||
|
|
||||
|
public void setStatusCode(int statusCode) { |
||||
|
this.statusCode = statusCode; |
||||
|
} |
||||
|
|
||||
|
public String getMessage() { |
||||
|
return message; |
||||
|
} |
||||
|
|
||||
|
public void setMessage(String message) { |
||||
|
this.message = message; |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,45 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccparks.service; |
||||
|
|
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
import org.springframework.web.bind.annotation.ControllerAdvice; |
||||
|
import org.springframework.web.bind.annotation.ExceptionHandler; |
||||
|
import org.springframework.web.servlet.NoHandlerFoundException; |
||||
|
|
||||
|
@ControllerAdvice |
||||
|
public class GlobalExceptionHandler { |
||||
|
@ExceptionHandler(NoHandlerFoundException.class) |
||||
|
public ResponseEntity<String> handlePageNotFoundException(NoHandlerFoundException ex) { |
||||
|
// Log the exception |
||||
|
ex.printStackTrace(); |
||||
|
|
||||
|
// Get the requested URL from the exception |
||||
|
String requestedUrl = ex.getRequestURL(); |
||||
|
|
||||
|
// Create an error message with the requested URL |
||||
|
String errorMessage = "Page not found: " + requestedUrl; |
||||
|
|
||||
|
// Return a ResponseEntity with a 404 Not Found status code and error message |
||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(errorMessage); |
||||
|
} |
||||
|
@ExceptionHandler(Exception.class) |
||||
|
public ResponseEntity<ErrorResponse> handleException(Exception ex) { |
||||
|
// Log the exception |
||||
|
ex.printStackTrace(); |
||||
|
|
||||
|
// Create an error response object |
||||
|
ErrorResponse errorResponse = new ErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "An error occurred: " + ex.getMessage()); |
||||
|
|
||||
|
// Return a ResponseEntity with an appropriate HTTP status code and error response object |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse); |
||||
|
} |
||||
|
|
||||
|
@ExceptionHandler(NoDataException.class) |
||||
|
public ResponseEntity<ErrorResponse> noDataException(NoDataException ex){ |
||||
|
|
||||
|
ErrorResponse errorResponse = new ErrorResponse(HttpStatus.NOT_FOUND.value(),ex.getMessage()); |
||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(errorResponse); |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccparks.service; |
||||
|
|
||||
|
public class NoDataException extends RuntimeException { |
||||
|
|
||||
|
public NoDataException(String msg){ |
||||
|
super(msg); |
||||
|
} |
||||
|
} |
||||
2000
mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/ParksService.java
File diff suppressed because it is too large
View File
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccparks.service; |
||||
@ -0,0 +1,934 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccschools.controller; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
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 java.util.stream.Collectors; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.dao.EmptyResultDataAccessException; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||
|
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 org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import in.gov.chennaicorporation.mobileservice.gccschools.service.SchoolUserActivity; |
||||
|
//import in.gov.chennaicorporation.mobileservice.gccsos.service.UserActivity; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/api/gccschools/user/") |
||||
|
@RestController("gccofficialappUserSchoolsRest") |
||||
|
public class SchoolUserController { |
||||
|
@Autowired |
||||
|
private JdbcTemplate jdbcSchoolsTemplate; |
||||
|
@Autowired |
||||
|
private SchoolUserActivity schoolUserActivity; |
||||
|
|
||||
|
@PostMapping("/saveschool") |
||||
|
public ResponseEntity<String> saveSchool( |
||||
|
@RequestParam String latitude, |
||||
|
@RequestParam String longitude, |
||||
|
@RequestParam(required = false) MultipartFile photo, |
||||
|
@RequestParam Integer schoolType, |
||||
|
@RequestParam String schoolName, |
||||
|
@RequestParam String earmark, |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam String user_id |
||||
|
) { |
||||
|
try { |
||||
|
// Save school details if type is valid |
||||
|
schoolUserActivity.saveSchool(latitude, longitude, photo, schoolType, schoolName, earmark, zone, division, user_id); |
||||
|
return new ResponseEntity<>("School details saved successfully.", HttpStatus.OK); |
||||
|
} catch (IllegalArgumentException e) { |
||||
|
return new ResponseEntity<>("Failed to save school details: " + e.getMessage(), HttpStatus.BAD_REQUEST); |
||||
|
} catch (Exception e) { |
||||
|
return new ResponseEntity<>("Failed to save school details: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/savetype") |
||||
|
public ResponseEntity<Integer> saveSchoolType(@RequestParam String schoolType) { |
||||
|
Integer schoolTypeId = schoolUserActivity.saveSchoolType(schoolType); |
||||
|
return ResponseEntity.ok(schoolTypeId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getCategoryWithQuestions") |
||||
|
public ResponseEntity<Map<String, Object>> getCategoryWithQuestions( |
||||
|
@RequestParam int categoryId |
||||
|
) { |
||||
|
try { |
||||
|
Map<String, Object> categoryDetails = schoolUserActivity.getCategoryWithQuestions(categoryId); |
||||
|
return ResponseEntity.ok(categoryDetails); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(500).body(Map.of("error", "Failed to retrieve category details: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getFeedback") |
||||
|
public ResponseEntity<?> getFeedback(@RequestParam int catQuestionId) { |
||||
|
try { |
||||
|
// Call the service method to fetch feedback |
||||
|
List<Map<String, Object>> feedbackDetails = schoolUserActivity.getFeedbackByQuestionId(catQuestionId); |
||||
|
|
||||
|
// Check if feedback exists for the given catQuestionId |
||||
|
if (feedbackDetails.isEmpty()) { |
||||
|
return new ResponseEntity<>("No feedback found for the provided category question ID.", HttpStatus.NOT_FOUND); |
||||
|
} |
||||
|
|
||||
|
return new ResponseEntity<>(feedbackDetails, HttpStatus.OK); |
||||
|
} catch (Exception e) { |
||||
|
return new ResponseEntity<>("Failed to retrieve feedback: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
||||
|
} |
||||
|
} |
||||
|
@GetMapping("/getSchools") |
||||
|
public ResponseEntity<?> getSchools( |
||||
|
@RequestParam String latitude, |
||||
|
@RequestParam String longitude |
||||
|
) { |
||||
|
try { |
||||
|
// Validate latitude and longitude |
||||
|
double lat = Double.parseDouble(latitude); |
||||
|
double lon = Double.parseDouble(longitude); |
||||
|
|
||||
|
if (lat < -90 || lat > 90 || lon < -180 || lon > 180) { |
||||
|
return ResponseEntity.badRequest() |
||||
|
.body(Collections.singletonList("Latitude must be between -90 and 90, and longitude between -180 and 180.")); |
||||
|
} |
||||
|
//String latitude1=latitude; |
||||
|
|
||||
|
// Get schools based on location |
||||
|
List<Map<String, Object>> schools = schoolUserActivity.getSchoolsByLocationAndType(latitude, longitude); |
||||
|
|
||||
|
if (schools.isEmpty()) { |
||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND) |
||||
|
.body(Collections.singletonList("No schools found for the specified location.")); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok(schools); |
||||
|
} catch (NumberFormatException e) { |
||||
|
return ResponseEntity.badRequest() |
||||
|
.body(Collections.singletonList("Invalid latitude or longitude format.")); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Collections.singletonList("Failed to retrieve schools: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@PostMapping("/savechennaiboard") |
||||
|
public ResponseEntity<?> saveChennaiBoard( |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String newboardconstructQa, |
||||
|
@RequestParam String newboardconstructAns, |
||||
|
@RequestParam String SchoolunderConstructQa, |
||||
|
@RequestParam String SchoolunderConstructAns, |
||||
|
@RequestParam(required = false) MultipartFile feedPhoto, // file is optional |
||||
|
@RequestParam(required = false) int school_details_id, // school_details_id is optional |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam double latitude, |
||||
|
@RequestParam double longitude, |
||||
|
@RequestParam String user_id ) { |
||||
|
|
||||
|
try { |
||||
|
// Save feedback for both questions |
||||
|
schoolUserActivity.saveChennaiSchoolBoard(categoryId, newboardconstructQa, newboardconstructAns, |
||||
|
SchoolunderConstructQa, SchoolunderConstructAns, feedPhoto, school_details_id, zone, division,latitude,longitude,user_id); |
||||
|
|
||||
|
return new ResponseEntity<>("Feedback saved successfully.", HttpStatus.OK); |
||||
|
} catch (Exception e) { |
||||
|
return new ResponseEntity<>("Failed to save feedback: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/saveDrinkingWater") |
||||
|
public ResponseEntity<?> saveDrinkingWater( |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String MetroWaterFacilitiesQa, |
||||
|
@RequestParam String MetroWaterFacilitiesAns, |
||||
|
@RequestParam String SumpFacilitiesAvailableQa, |
||||
|
@RequestParam String SumpFacilitiesAvailableAns, |
||||
|
@RequestParam String SumpGoodConditionQa, |
||||
|
@RequestParam String SumpGoodConditionAns, |
||||
|
@RequestParam String ROFacilitiesAvailableQa, |
||||
|
@RequestParam String ROFacilitiesAvailableAns, |
||||
|
@RequestParam String ROGoodConditionQa, |
||||
|
@RequestParam String ROGoodConditionAns,//Drinking water facilities available or not |
||||
|
@RequestParam String DrinkingwaterfacilitiesQa, |
||||
|
@RequestParam String DrinkingwaterfacilitiesAns, |
||||
|
@RequestParam String typeoffacilitiesQa, |
||||
|
@RequestParam String typeoffacilitiesAns, |
||||
|
|
||||
|
@RequestParam(required = false) MultipartFile feedPhoto, |
||||
|
@RequestParam(required = false) int school_details_id, |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam double latitude, |
||||
|
@RequestParam double longitude, |
||||
|
@RequestParam String user_id |
||||
|
) { |
||||
|
|
||||
|
try { |
||||
|
// Call the service method to save feedback |
||||
|
schoolUserActivity.savewaterfd(categoryId, MetroWaterFacilitiesQa, MetroWaterFacilitiesAns, |
||||
|
SumpFacilitiesAvailableQa, SumpFacilitiesAvailableAns, |
||||
|
SumpGoodConditionQa, SumpGoodConditionAns, |
||||
|
ROFacilitiesAvailableQa, ROFacilitiesAvailableAns, |
||||
|
ROGoodConditionQa, ROGoodConditionAns,DrinkingwaterfacilitiesQa,DrinkingwaterfacilitiesAns, |
||||
|
typeoffacilitiesQa,typeoffacilitiesAns, |
||||
|
feedPhoto, school_details_id, zone, division,latitude,longitude,user_id); |
||||
|
|
||||
|
return new ResponseEntity<>("Feedback saved successfully.", HttpStatus.OK); |
||||
|
} catch (Exception e) { |
||||
|
return new ResponseEntity<>("Failed to save feedback: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@PostMapping("/FirstAidKit") |
||||
|
public ResponseEntity<?> FirstAidKit( |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String FirstAidKitAvailableQa, |
||||
|
@RequestParam String FirstAidKitAvailableAns, |
||||
|
@RequestParam(required = false) MultipartFile feedPhoto, |
||||
|
@RequestParam(required = false) int school_details_id, |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam String division , |
||||
|
@RequestParam double latitude, |
||||
|
@RequestParam double longitude, |
||||
|
@RequestParam String user_id) { |
||||
|
|
||||
|
try { |
||||
|
// Call the service method to save feedback |
||||
|
schoolUserActivity.saveFirstAidKitFeedback(categoryId, FirstAidKitAvailableQa, FirstAidKitAvailableAns, |
||||
|
feedPhoto, school_details_id, zone, division, latitude,longitude,user_id); |
||||
|
|
||||
|
return new ResponseEntity<>("Feedback saved successfully.", HttpStatus.OK); |
||||
|
} catch (Exception e) { |
||||
|
return new ResponseEntity<>("Failed to save feedback: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/Cleaning") |
||||
|
public ResponseEntity<?> Cleaning( |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String ToiletsAvailableQa, |
||||
|
@RequestParam String ToiletsAvailableAns, |
||||
|
@RequestParam String UrinariesAvailableQa, |
||||
|
@RequestParam String UrinariesAvailableAns, |
||||
|
@RequestParam String SweepersAvailableQa, |
||||
|
@RequestParam String SweepersAvailableAns, |
||||
|
@RequestParam String SewagesAvailableQa, |
||||
|
@RequestParam String SewagesAvailableAns, |
||||
|
@RequestParam String RoomsAvailableQa, |
||||
|
@RequestParam String RoomsAvailableAns, |
||||
|
@RequestParam String PlaygroundAvailableQa, |
||||
|
@RequestParam String PlaygroundAvailableAns, |
||||
|
@RequestParam String DrainageAvailableQa, |
||||
|
@RequestParam String DrainageAvailableAns, |
||||
|
@RequestParam(required = false) MultipartFile toiletfeedPhoto, |
||||
|
@RequestParam(required = false) MultipartFile RoomsfeedPhoto, |
||||
|
@RequestParam(required = false) MultipartFile PlaygroundfeedPhoto, |
||||
|
@RequestParam(required = false) int school_details_id, |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam double latitude, |
||||
|
@RequestParam double longitude, |
||||
|
@RequestParam String user_id) { |
||||
|
|
||||
|
try { |
||||
|
// Call the service method to save feedback |
||||
|
schoolUserActivity.saveCleaningFeedback( |
||||
|
categoryId, |
||||
|
ToiletsAvailableQa, ToiletsAvailableAns, |
||||
|
UrinariesAvailableQa, UrinariesAvailableAns, |
||||
|
SweepersAvailableQa, SweepersAvailableAns, |
||||
|
SewagesAvailableQa, SewagesAvailableAns, |
||||
|
RoomsAvailableQa, RoomsAvailableAns, |
||||
|
PlaygroundAvailableQa, PlaygroundAvailableAns, |
||||
|
DrainageAvailableQa, DrainageAvailableAns, |
||||
|
toiletfeedPhoto, RoomsfeedPhoto, PlaygroundfeedPhoto, |
||||
|
school_details_id, zone, division, latitude, longitude,user_id |
||||
|
); |
||||
|
|
||||
|
return new ResponseEntity<>("Feedback saved successfully.", HttpStatus.OK); |
||||
|
} catch (Exception e) { |
||||
|
return new ResponseEntity<>("Failed to save feedback: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
@PostMapping("/NoonMealKitchenCenter") |
||||
|
public ResponseEntity<?> NoonMealKitchenCenter( |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String NoonMealKitchenAvailableQa, |
||||
|
@RequestParam String NoonMealKitchenAvailableAns, |
||||
|
@RequestParam String GasStoveQa, |
||||
|
@RequestParam String GasStoveAns, |
||||
|
@RequestParam String StoreRoomAvailableQa, |
||||
|
@RequestParam String StoreRoomAvailableAns, |
||||
|
@RequestParam String UtensilsAvailableQa, |
||||
|
@RequestParam String UtensilsAvailableAns, |
||||
|
@RequestParam String SufficientNumberQa, |
||||
|
@RequestParam String SufficientNumberAns, |
||||
|
@RequestParam String BlockageInWashAreaQa, |
||||
|
@RequestParam String BlockageInWashAreaAns, |
||||
|
@RequestParam String SeepageQa, |
||||
|
@RequestParam String SeepageAns, |
||||
|
@RequestParam(required = false) MultipartFile feedPhoto, |
||||
|
@RequestParam(required = false) int school_details_id, |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam Double latitude, |
||||
|
@RequestParam Double longitude, |
||||
|
@RequestParam String user_id) { |
||||
|
|
||||
|
try { |
||||
|
// Call the service method to save feedback |
||||
|
schoolUserActivity.saveNoonMealFeedback( |
||||
|
categoryId, |
||||
|
NoonMealKitchenAvailableQa, NoonMealKitchenAvailableAns, |
||||
|
GasStoveQa, GasStoveAns, |
||||
|
StoreRoomAvailableQa, StoreRoomAvailableAns, |
||||
|
UtensilsAvailableQa, UtensilsAvailableAns, |
||||
|
SufficientNumberQa, SufficientNumberAns, |
||||
|
BlockageInWashAreaQa, BlockageInWashAreaAns, |
||||
|
SeepageQa, SeepageAns, |
||||
|
feedPhoto, school_details_id, zone, division,latitude,longitude,user_id |
||||
|
); |
||||
|
|
||||
|
return new ResponseEntity<>("Feedback saved successfully.", HttpStatus.OK); |
||||
|
} catch (Exception e) { |
||||
|
return new ResponseEntity<>("Failed to save feedback: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/Electricity") |
||||
|
public ResponseEntity<?> Electricity( |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String FansAvailableQa, |
||||
|
@RequestParam String FansAvailableAns, |
||||
|
@RequestParam String FansNotAvailableQa, |
||||
|
@RequestParam String FansNotAvailableAns, |
||||
|
@RequestParam String LightsAvailableQa, |
||||
|
@RequestParam String LightsAvailableAns, |
||||
|
@RequestParam String LightsNotAvailableQa, |
||||
|
@RequestParam String LightsNotAvailableAns, |
||||
|
@RequestParam String SwitchBoardQa, |
||||
|
@RequestParam String SwitchBoardAns, |
||||
|
@RequestParam String GenSetQa, |
||||
|
@RequestParam String GenSetAns, |
||||
|
@RequestParam String GenSetconditionQa, |
||||
|
@RequestParam String GenSetconditionAns, |
||||
|
@RequestParam(required = false) MultipartFile feedPhoto, |
||||
|
@RequestParam(required = false) int school_details_id, |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam double latitude , |
||||
|
@RequestParam double longitude, |
||||
|
@RequestParam String user_id) { |
||||
|
|
||||
|
try { |
||||
|
// Call the service method to save feedback |
||||
|
schoolUserActivity.saveElectricityFeedback( |
||||
|
categoryId, |
||||
|
FansAvailableQa, FansAvailableAns, FansNotAvailableQa, FansNotAvailableAns, |
||||
|
LightsAvailableQa, LightsAvailableAns, LightsNotAvailableQa, LightsNotAvailableAns, |
||||
|
SwitchBoardQa, SwitchBoardAns, |
||||
|
GenSetQa, GenSetAns,GenSetconditionQa,GenSetconditionAns, |
||||
|
feedPhoto, school_details_id, zone, division,latitude,longitude,user_id |
||||
|
); |
||||
|
|
||||
|
return new ResponseEntity<>("Feedback saved successfully.", HttpStatus.OK); |
||||
|
} catch (Exception e) { |
||||
|
return new ResponseEntity<>("Failed to save feedback: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
||||
|
} |
||||
|
} |
||||
|
@PostMapping("/ITAssets") |
||||
|
public ResponseEntity<?> ITAssets( |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String SystemAvailableQa, |
||||
|
@RequestParam String SystemAvailableAns, |
||||
|
@RequestParam String SystemNotAvailableQa, |
||||
|
@RequestParam String SystemNotAvailableAns, |
||||
|
@RequestParam String PrinterAvailableQa, |
||||
|
@RequestParam String PrinterAvailableAns, |
||||
|
@RequestParam String PrinterNotAvailableQa, |
||||
|
@RequestParam String PrinterNotAvailableAns, |
||||
|
@RequestParam String UPSAvailableQa, |
||||
|
@RequestParam String UPSAvailableAns, |
||||
|
@RequestParam String UPSNotAvailableQa, |
||||
|
@RequestParam String UPSNotAvailableAns, |
||||
|
@RequestParam String NetworkAvailableQa, |
||||
|
@RequestParam String NetworkAvailableAns, |
||||
|
@RequestParam String projectorgoodconditionQa, |
||||
|
@RequestParam String projectorgoodconditionAns, |
||||
|
@RequestParam String smartboardgoodconditionQa, |
||||
|
@RequestParam String smartboardgoodconditionAns, |
||||
|
@RequestParam(required = false) MultipartFile feedPhoto, |
||||
|
@RequestParam(required = false) int school_details_id, |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam Double latitude, |
||||
|
@RequestParam double longitude, |
||||
|
@RequestParam String user_id) { |
||||
|
|
||||
|
try { |
||||
|
// Call the service method to save feedback |
||||
|
schoolUserActivity.saveITAssetsFeedback( |
||||
|
categoryId, |
||||
|
SystemAvailableQa, SystemAvailableAns, SystemNotAvailableQa, SystemNotAvailableAns, |
||||
|
PrinterAvailableQa, PrinterAvailableAns, PrinterNotAvailableQa, PrinterNotAvailableAns, |
||||
|
UPSAvailableQa, UPSAvailableAns, UPSNotAvailableQa, UPSNotAvailableAns, |
||||
|
NetworkAvailableQa, NetworkAvailableAns, |
||||
|
projectorgoodconditionQa, projectorgoodconditionAns, |
||||
|
smartboardgoodconditionQa, smartboardgoodconditionAns, |
||||
|
feedPhoto, school_details_id, zone, division,latitude,longitude,user_id |
||||
|
); |
||||
|
|
||||
|
return new ResponseEntity<>("Feedback saved successfully.", HttpStatus.OK); |
||||
|
} catch (Exception e) { |
||||
|
return new ResponseEntity<>("Failed to save feedback: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/SeepageSchool") |
||||
|
public ResponseEntity<?> SeepageSchool( |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String SeepageinSchoolQa, |
||||
|
@RequestParam String SeepageinSchoolAns, |
||||
|
@RequestParam String HowmanyLocationsQa, |
||||
|
@RequestParam String HowmanyLocationsAns, |
||||
|
//@RequestParam(required = false) MultipartFile feedPhoto, |
||||
|
@RequestParam(required = false) int school_details_id, |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam(required = false) Double latitude, |
||||
|
@RequestParam Double longitude, |
||||
|
@RequestParam String user_id) { // Add latitude parameter |
||||
|
|
||||
|
try { |
||||
|
// Call the service method to save feedback |
||||
|
schoolUserActivity.saveSeepageSchoolFeedback( |
||||
|
categoryId, |
||||
|
SeepageinSchoolQa, SeepageinSchoolAns, |
||||
|
HowmanyLocationsQa, HowmanyLocationsAns, |
||||
|
school_details_id, zone, division, |
||||
|
latitude,longitude,user_id // Pass latitude to the service |
||||
|
); |
||||
|
|
||||
|
return new ResponseEntity<>("Feedback saved successfully.", HttpStatus.OK); |
||||
|
} catch (Exception e) { |
||||
|
return new ResponseEntity<>("Failed to save feedback: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/subCategories") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getAllSubCategories() { |
||||
|
List<Map<String, Object>> subCategories = schoolUserActivity.getAllSubCategories(); |
||||
|
|
||||
|
if (subCategories.isEmpty()) { |
||||
|
return ResponseEntity.status(404).body(null); // or use a different response if needed |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok(subCategories); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getschooltype") |
||||
|
public ResponseEntity<Map<String, Object>> getSchoolType(@RequestParam int id) { |
||||
|
Map<String, Object> schoolType = schoolUserActivity.getSchoolTypeById(id); |
||||
|
return ResponseEntity.ok(schoolType); |
||||
|
} |
||||
|
@GetMapping("/get") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getSchoolTypes() { |
||||
|
List<Map<String, Object>> schoolTypes = schoolUserActivity.getAllSchoolTypes(); |
||||
|
return ResponseEntity.ok(schoolTypes); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getcountsdivision") |
||||
|
public ResponseEntity<?> getFeedbackCountByDivision(@RequestParam String division) { |
||||
|
try { |
||||
|
List<Map<String, Object>> feedbackCount = schoolUserActivity.getFeedbackCountByDivision(division); |
||||
|
return ResponseEntity.ok(feedbackCount); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Collections.singletonList("Failed to retrieve feedback count: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/overallreport") |
||||
|
public Map<String, Object> getFeedbackBySchoolId( |
||||
|
@RequestParam int schoolId, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, |
||||
|
@RequestParam String user_id) { |
||||
|
|
||||
|
return schoolUserActivity.getFeedbackBySchoolId(schoolId, division, zone, categoryId, fromDate, toDate, user_id); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/feedbackdetails") |
||||
|
public Map<String, Object> getFeedbackByFeedRef( |
||||
|
@RequestParam String feedref, |
||||
|
@RequestParam String user_id) { |
||||
|
|
||||
|
return schoolUserActivity.getFeedbackByFeedRef(feedref, user_id); |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
* @GetMapping("/overallreport") |
||||
|
public ResponseEntity<?> getFeedbackBySchoolId( |
||||
|
@RequestParam int schoolId, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, |
||||
|
@RequestParam (required = false) String user_id |
||||
|
) { |
||||
|
try { |
||||
|
List<Map<String, Object>> feedbackList = schoolUserActivity.getFeedbackBySchoolId(schoolId, division, zone, categoryId, fromDate, toDate, user_id); |
||||
|
|
||||
|
if (feedbackList.isEmpty()) { |
||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND) |
||||
|
.body(Collections.singletonList("No feedback found for the specified parameters.")); |
||||
|
} |
||||
|
|
||||
|
// Initialize response structure |
||||
|
List<Map<String, Object>> responseList = new ArrayList<>(); |
||||
|
|
||||
|
// Create a map to store the last inserted data for each question |
||||
|
Map<String, Map<String, Object>> lastInsertedData = new HashMap<>(); |
||||
|
|
||||
|
// Create a map to store the common data |
||||
|
Map<String, Object> commonData = feedbackList.get(0); |
||||
|
|
||||
|
// Retrieve the schoolId from the feedbackList |
||||
|
Integer schoolIdValue = (Integer) feedbackList.get(0).get("schoolId"); |
||||
|
|
||||
|
// Create a map to store the grouped feedbacks |
||||
|
Map<String, List<Map<String, Object>>> groupedFeedbacks = new HashMap<>(); |
||||
|
|
||||
|
// Create a set to store the common photos |
||||
|
Set<String> commonPhotos = new HashSet<>(); |
||||
|
|
||||
|
for (Map<String, Object> feedback : feedbackList) { |
||||
|
String[] questions = ((String) feedback.get("category_questions")).split(","); |
||||
|
String feedbackResponse = (String) feedback.get("feedback"); |
||||
|
String feedbackPhotos = (String) feedback.get("feedbackphotos"); |
||||
|
|
||||
|
if (feedbackPhotos != null && !feedbackPhotos.isEmpty()) { |
||||
|
String[] photos = feedbackPhotos.split(","); |
||||
|
for (String photo : photos) { |
||||
|
commonPhotos.add(photo.trim()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
for (String question : questions) { |
||||
|
question = question.trim(); |
||||
|
|
||||
|
// Check if the question already exists in the last inserted data map |
||||
|
if (lastInsertedData.containsKey(question)) { |
||||
|
Map<String, Object> existingEntry = lastInsertedData.get(question); |
||||
|
existingEntry.put("feedback", feedbackResponse); |
||||
|
existingEntry.put("feedback_photos", new ArrayList<>(commonPhotos)); |
||||
|
} else { |
||||
|
Map<String, Object> newEntry = new HashMap<>(); |
||||
|
newEntry.put("feedback", feedbackResponse); |
||||
|
newEntry.put("category_question", question); |
||||
|
newEntry.put("feedback_photos", new ArrayList<>(commonPhotos)); |
||||
|
lastInsertedData.put(question, newEntry); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Create a key for the common data |
||||
|
String key = commonData.get("division") + "_" + commonData.get("cdate") + "_" + commonData.get("zone") + "_" + commonData.get("schoolId") + "_" + commonData.get("school_name") + "_" + commonData.get("category"); |
||||
|
|
||||
|
// Add the feedbacks to the grouped feedbacks map |
||||
|
if (!groupedFeedbacks.containsKey(key)) { |
||||
|
groupedFeedbacks.put(key, new ArrayList<>()); |
||||
|
} |
||||
|
|
||||
|
for (Map<String, Object> entry : lastInsertedData.values()) { |
||||
|
groupedFeedbacks.get(key).add(entry); |
||||
|
} |
||||
|
|
||||
|
// Create the response list with the grouped feedbacks |
||||
|
for (Map.Entry<String, List<Map<String, Object>>> entry : groupedFeedbacks.entrySet()) { |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
String[] parts = entry.getKey().split("_"); |
||||
|
response.put("division", parts[0]); |
||||
|
response.put("cdate", parts[1]); |
||||
|
response.put("zone", parts[2]); |
||||
|
response.put("school_details_id", schoolId); |
||||
|
response.put("school_name", parts[4]); |
||||
|
response.put("category", parts[5]); |
||||
|
response.put("feedbacks", entry.getValue()); |
||||
|
|
||||
|
// Add the common photos to the response |
||||
|
for (Map<String, Object> feedback : (List<Map<String, Object>>) response.get("feedbacks")) { |
||||
|
feedback.put("feedback_photos", new ArrayList<>(commonPhotos)); |
||||
|
} |
||||
|
|
||||
|
responseList.add(response); |
||||
|
} |
||||
|
|
||||
|
// Find which photo belongs to which question |
||||
|
List<String> questions = new ArrayList<>(); |
||||
|
for (Map<String, Object> feedback : feedbackList) { |
||||
|
String[] questionArray = ((String) feedback.get("category_questions")).split(","); |
||||
|
questions.addAll(Arrays.asList(questionArray)); |
||||
|
} |
||||
|
|
||||
|
Map<String, List<String>> questionPhotos = new HashMap<>(); |
||||
|
for (String question : questions) { |
||||
|
List<String> photos = getPhotosForQuestion(question, lastInsertedData); |
||||
|
questionPhotos.put(question, photos); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok(responseList); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Collections.singletonList(" Failed to retrieve feedback: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
*/ |
||||
|
private List<String> getPhotosForQuestion(String question, Map<String, Map<String, Object>> lastInsertedData) { |
||||
|
List<String> photos = new ArrayList<>(); |
||||
|
for (Map<String, Object> entry : lastInsertedData.values()) { |
||||
|
if (entry.get("category_question").equals(question)) { |
||||
|
photos.addAll((List<String>) entry.get("feedback_photos")); |
||||
|
} |
||||
|
} |
||||
|
return photos; |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/categories") |
||||
|
public ResponseEntity<?> getCategories() { |
||||
|
try { |
||||
|
List<Map<String, Object>> categories = schoolUserActivity.getActiveCategories(); |
||||
|
|
||||
|
return ResponseEntity.ok(categories); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Collections.singletonList("Failed to retrieve categories: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@GetMapping("/categorydates") |
||||
|
public ResponseEntity<?> getFeedbackCountByCategoryAndDate( |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String startDate, // Change to String |
||||
|
@RequestParam String endDate, |
||||
|
@RequestParam (required = false) String user_id) { // Change to String |
||||
|
try { |
||||
|
// Define the date formatter |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
||||
|
LocalDate start = LocalDate.parse(startDate, formatter); |
||||
|
LocalDate end = LocalDate.parse(endDate, formatter); |
||||
|
|
||||
|
List<Map<String, Object>> feedbackCounts = schoolUserActivity.getFeedbackCountByCategoryAndDate(categoryId, start, end, user_id); |
||||
|
if (feedbackCounts.isEmpty()) { |
||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND) |
||||
|
.body(Collections.singletonList("No feedback found for the specified category and date range.")); |
||||
|
} |
||||
|
return ResponseEntity.ok(feedbackCounts); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Collections.singletonList("Failed to retrieve feedback count: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/divisionschools") |
||||
|
public ResponseEntity<?> getFeedbackCountByDivisionAndSchool( |
||||
|
@RequestParam String division, |
||||
|
@RequestParam String categoryId, // Add categoryId parameter |
||||
|
@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, |
||||
|
@RequestParam (required = false) String user_id |
||||
|
) { |
||||
|
try { |
||||
|
// Define the date formatter |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
||||
|
LocalDate from = LocalDate.parse(fromDate, formatter); |
||||
|
LocalDate to = LocalDate.parse(toDate, formatter); |
||||
|
|
||||
|
List<Map<String, Object>> feedbackCounts = schoolUserActivity.getFeedbackCountByDivisionAndSchool(division, categoryId, from, to, user_id); |
||||
|
|
||||
|
if (feedbackCounts.isEmpty()) { |
||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND) |
||||
|
.body(Collections.singletonList("No feedback found for the specified division and date range.")); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok(feedbackCounts); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Collections.singletonList("Failed to retrieve feedback count: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/divisionschoolslist") |
||||
|
public ResponseEntity<?> getFeedbackCountByDivisionAndSchoolList( |
||||
|
@RequestParam String schoolId, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam String categoryId, // Add categoryId parameter |
||||
|
@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, |
||||
|
@RequestParam (required = false) String user_id |
||||
|
) { |
||||
|
try { |
||||
|
// Define the date formatter |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
||||
|
LocalDate from = LocalDate.parse(fromDate, formatter); |
||||
|
LocalDate to = LocalDate.parse(toDate, formatter); |
||||
|
|
||||
|
List<Map<String, Object>> feedbackCounts = schoolUserActivity.getFeedbackCountByDivisionAndSchoolList(division, schoolId, categoryId, from, to, user_id); |
||||
|
|
||||
|
if (feedbackCounts.isEmpty()) { |
||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND) |
||||
|
.body(Collections.singletonList("No feedback found for the specified division and date range.")); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok(feedbackCounts); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Collections.singletonList("Failed to retrieve feedback count: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/myreportlist") |
||||
|
public ResponseEntity<?> getMyReportList( |
||||
|
@RequestParam String categoryId, // Add categoryId parameter |
||||
|
@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, |
||||
|
@RequestParam (required = true) String user_id |
||||
|
) { |
||||
|
try { |
||||
|
// Define the date formatter |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
||||
|
LocalDate from = LocalDate.parse(fromDate, formatter); |
||||
|
LocalDate to = LocalDate.parse(toDate, formatter); |
||||
|
|
||||
|
List<Map<String, Object>> feedbackCounts = schoolUserActivity.getFeedbackCountSchoolListByUserId(categoryId, from, to, user_id); |
||||
|
|
||||
|
if (feedbackCounts.isEmpty()) { |
||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND) |
||||
|
.body(Collections.singletonList("No feedback found for the specified division and date range.")); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok(feedbackCounts); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Collections.singletonList("Failed to retrieve feedback count: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/zonecatschool") |
||||
|
public ResponseEntity<List<Map<String, Object>>> getFeedbackCountByZoneCat( |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, |
||||
|
@RequestParam(required = false) String user_id) { |
||||
|
|
||||
|
// Parse the date strings to LocalDate |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
||||
|
LocalDate from = LocalDate.parse(fromDate, formatter); |
||||
|
LocalDate to = LocalDate.parse(toDate, formatter); |
||||
|
|
||||
|
// Call the service method |
||||
|
List<Map<String, Object>> feedbackCounts = schoolUserActivity.getFeedbackCountByZoneCat(zone, categoryId, from, to, user_id); |
||||
|
|
||||
|
return ResponseEntity.ok(feedbackCounts); |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
@GetMapping("/zonecatschool") |
||||
|
public ResponseEntity<?> getFeedbackCountByZoneCat( |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String fromDate, // Change to String |
||||
|
@RequestParam String toDate, |
||||
|
@RequestParam (required = false) String user_id) { // Change to String |
||||
|
try { |
||||
|
// Define the date formatter for dd-MM-yyyy |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
||||
|
LocalDate from = LocalDate.parse(fromDate, formatter); |
||||
|
LocalDate to = LocalDate.parse(toDate, formatter); |
||||
|
|
||||
|
List<Map<String, Object>> feedbackCounts = schoolUserActivity.getFeedbackCountByZoneCat(zone, categoryId, from, to, user_id); |
||||
|
|
||||
|
if (feedbackCounts.isEmpty()) { |
||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND) |
||||
|
.body(Collections.singletonList("No feedback found for the specified zone and date range.")); |
||||
|
} |
||||
|
|
||||
|
// Assuming all feedback counts have the same division, extract it |
||||
|
String division = feedbackCounts.get(0).get("division").toString(); |
||||
|
|
||||
|
// Build the response |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("division", division); |
||||
|
|
||||
|
// Sum up feedback counts as Long |
||||
|
long totalFeedbackCount = feedbackCounts.stream() |
||||
|
.mapToLong(feedback -> ((Number) feedback.get("feedback_count")).longValue()) |
||||
|
.sum(); |
||||
|
|
||||
|
response.put("feedback_count", totalFeedbackCount); |
||||
|
|
||||
|
// Wrap the response in a list |
||||
|
return ResponseEntity.ok(Collections.singletonList(response)); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Collections.singletonList("Failed to retrieve feedback count: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
@GetMapping("/divisioncatschool") |
||||
|
public ResponseEntity<?> getFeedbackCountByDivCat( |
||||
|
@RequestParam String division, |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String fromDate, // Change to String |
||||
|
@RequestParam String toDate, |
||||
|
@RequestParam (required = false) String user_id) { // Change to String |
||||
|
try { |
||||
|
// Define the date formatter for dd-MM-yyyy |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
||||
|
LocalDate from = LocalDate.parse(fromDate, formatter); |
||||
|
LocalDate to = LocalDate.parse(toDate, formatter); |
||||
|
|
||||
|
List<Map<String, Object>> feedbackCounts = schoolUserActivity.getFeedbackCountByDivCat(division, categoryId, from, to); |
||||
|
|
||||
|
if (feedbackCounts.isEmpty()) { |
||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND) |
||||
|
.body(Collections.singletonList("No feedback found for the specified division.")); |
||||
|
} |
||||
|
|
||||
|
// Create a map to aggregate feedback counts by division |
||||
|
Map<String, Long> aggregatedCounts = new HashMap<>(); |
||||
|
|
||||
|
for (Map<String, Object> feedback : feedbackCounts) { |
||||
|
String div = (String) feedback.get("division"); |
||||
|
Long count = (Long) feedback.get("feedback_count"); |
||||
|
|
||||
|
// Aggregate feedback counts |
||||
|
aggregatedCounts.put(div, aggregatedCounts.getOrDefault(div, 0L) + count); |
||||
|
} |
||||
|
|
||||
|
// Build the response |
||||
|
List<Map<String, Object>> response = new ArrayList<>(); |
||||
|
for (Map.Entry<String, Long> entry : aggregatedCounts.entrySet()) { |
||||
|
Map<String, Object> divisionData = new HashMap<>(); |
||||
|
divisionData.put("division", entry.getKey()); |
||||
|
divisionData.put("feedback_count", entry.getValue()); |
||||
|
response.add(divisionData); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok(response); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Collections.singletonList("Failed to retrieve feedback count: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/saveCmSheme") |
||||
|
public ResponseEntity<?> CmSheme( |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String BreakFastQualityQa, |
||||
|
@RequestParam String BreakFastQualityAns, |
||||
|
@RequestParam String CMBFhelpersPresentSchoolQa, |
||||
|
@RequestParam String CMBFhelpersPresentSchoolAns, |
||||
|
@RequestParam String DinningAreaKeptQa, |
||||
|
@RequestParam String DinningAreaKeptAns, |
||||
|
@RequestParam String IsschoolhygienicallyQa, |
||||
|
@RequestParam String IsschoolhygienicallyAns, |
||||
|
@RequestParam(required = false) MultipartFile feedPhoto, |
||||
|
@RequestParam(required = false) int school_details_id, |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam Double latitude, |
||||
|
@RequestParam double longitude, |
||||
|
@RequestParam String user_id, |
||||
|
@RequestParam (required = false) String question_id |
||||
|
) { |
||||
|
|
||||
|
try { |
||||
|
// Call the service method to save feedback |
||||
|
schoolUserActivity.saveCmSheme( |
||||
|
categoryId, |
||||
|
BreakFastQualityQa, BreakFastQualityAns, |
||||
|
CMBFhelpersPresentSchoolQa, CMBFhelpersPresentSchoolAns, |
||||
|
DinningAreaKeptQa, DinningAreaKeptAns, |
||||
|
IsschoolhygienicallyQa, IsschoolhygienicallyAns, |
||||
|
feedPhoto, school_details_id, zone, division,latitude,longitude,user_id,question_id |
||||
|
); |
||||
|
|
||||
|
return new ResponseEntity<>("Feedback saved successfully.", HttpStatus.OK); |
||||
|
} catch (Exception e) { |
||||
|
return new ResponseEntity<>("Failed to save feedback: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/saveClusterKitchen") |
||||
|
public ResponseEntity<?> ClusterKitchen( |
||||
|
@RequestParam int categoryId, |
||||
|
@RequestParam String ClusterKitchencleanandneatQa, |
||||
|
@RequestParam String ClusterKitchencleanandneatAns, |
||||
|
@RequestParam String SampleoffoodmaintainedQa, |
||||
|
@RequestParam String SampleoffoodmaintainedAns, |
||||
|
@RequestParam String cookingstaffwearingQa, |
||||
|
@RequestParam String cookingstaffwearingAns, |
||||
|
@RequestParam String fooditemsmatchwiththestockQa , |
||||
|
@RequestParam String fooditemsmatchwiththestockAns, |
||||
|
@RequestParam String FooditemsusedofgoodqualityQa , |
||||
|
@RequestParam String FooditemsusedofgoodqualityAns, |
||||
|
@RequestParam(required = false) MultipartFile feedPhoto, |
||||
|
@RequestParam(required = false) int school_details_id, |
||||
|
@RequestParam String zone, |
||||
|
@RequestParam String division, |
||||
|
@RequestParam Double latitude, |
||||
|
@RequestParam double longitude, |
||||
|
@RequestParam String user_id, |
||||
|
@RequestParam (required = false) String question_id |
||||
|
) { |
||||
|
|
||||
|
try { |
||||
|
// Call the service method to save feedback |
||||
|
schoolUserActivity.saveClusterKitchen( |
||||
|
categoryId, |
||||
|
ClusterKitchencleanandneatQa, ClusterKitchencleanandneatAns, |
||||
|
SampleoffoodmaintainedQa, SampleoffoodmaintainedAns, |
||||
|
cookingstaffwearingQa, cookingstaffwearingAns, |
||||
|
fooditemsmatchwiththestockQa, fooditemsmatchwiththestockAns, |
||||
|
FooditemsusedofgoodqualityQa,FooditemsusedofgoodqualityAns, |
||||
|
feedPhoto, school_details_id, zone, division,latitude,longitude,user_id,question_id |
||||
|
); |
||||
|
|
||||
|
return new ResponseEntity<>("Feedback saved successfully.", HttpStatus.OK); |
||||
|
} catch (Exception e) { |
||||
|
return new ResponseEntity<>("Failed to save feedback: " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccschools.controller; |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccschools; |
||||
1063
mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/service/SchoolUserActivity.java
File diff suppressed because it is too large
View File
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccschools.service; |
||||
@ -0,0 +1,869 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccstraydogs.controller; |
||||
|
|
||||
|
import jakarta.servlet.http.HttpServletResponse; |
||||
|
|
||||
|
import java.io.ByteArrayInputStream; |
||||
|
import java.io.IOException; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
import org.hibernate.internal.build.AllowSysOut; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.core.io.InputStreamResource; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
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.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
import java.sql.Timestamp; |
||||
|
import java.text.ParseException; |
||||
|
import java.text.SimpleDateFormat; |
||||
|
import java.time.LocalDate; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.time.temporal.ChronoUnit; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Date; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.LinkedHashMap; |
||||
|
import java.util.List; |
||||
|
|
||||
|
import org.springframework.http.HttpHeaders; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.MediaType; |
||||
|
|
||||
|
import in.gov.chennaicorporation.mobileservice.gccstraydogs.service.UserService; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/api/gccstraydogs/user/") |
||||
|
@RestController("gccofficialappUserStraydogRest") |
||||
|
public class UserApiController { |
||||
|
|
||||
|
@Autowired |
||||
|
private UserService userService; |
||||
|
|
||||
|
@PostMapping("/step1") |
||||
|
public ResponseEntity<Map<String, Object>> saveStep1(@RequestParam("qr_id") String qr_id, |
||||
|
@RequestParam("userid_1") String userid_1, @RequestParam("date1") String date1, |
||||
|
@RequestParam("lat_1") String lat_1, @RequestParam("long_1") String long_1, |
||||
|
@RequestParam("location_1") String location_1, @RequestParam("zone_1") String zone_1, |
||||
|
@RequestParam("ward_1") String ward_1, @RequestParam("streetid_1") String streetid_1, |
||||
|
@RequestParam(value = "streetname_1", required = false, defaultValue = "-") String streetname_1, |
||||
|
@RequestParam("photo1") MultipartFile photo1, @RequestParam("sex_1") String sex_1, |
||||
|
@RequestParam("contraception_1") boolean contraception_1, |
||||
|
@RequestParam("flow_location") boolean flow_location) { |
||||
|
|
||||
|
try { |
||||
|
|
||||
|
int stage = 1; |
||||
|
Timestamp date_1 = Timestamp.valueOf(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") |
||||
|
.format(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(date1))); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
|
||||
|
String result = userService.checkQrId(qr_id); |
||||
|
|
||||
|
if (result.equalsIgnoreCase("false")) { |
||||
|
|
||||
|
String step = userService.saveStep1(qr_id, userid_1, date_1, lat_1, long_1, location_1, zone_1, ward_1, |
||||
|
streetid_1, streetname_1, photo1, sex_1, contraception_1, stage, flow_location); |
||||
|
response.put("status", "OK"); |
||||
|
response.put("QR_id", qr_id); |
||||
|
response.put("Step", step); |
||||
|
} else { |
||||
|
response.put("Message", "Provided QRID = " + qr_id + " already exists"); |
||||
|
response.put("QR_id", qr_id); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok(response); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Map.of("status", "ERROR", "message", "Error saving Step_1: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value = "/getABCCenter") |
||||
|
public List<?> getAlert(@RequestParam(value = "latitude", required = false) String latitude, |
||||
|
@RequestParam(value = "longitude", required = false) String longitude) { |
||||
|
return userService.getABCCenter(latitude, longitude); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value = "/getABCCenterList") |
||||
|
public List<?> getABCCenterList() { |
||||
|
return userService.getABCCenterList(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/step2") |
||||
|
public ResponseEntity<Map<String, Object>> saveStep2(@RequestParam("qr_id") String qr_id, |
||||
|
@RequestParam("userid_2") String userid_2, @RequestParam("date2") String date2, |
||||
|
@RequestParam("lat_2") String lat_2, @RequestParam("long_2") String long_2, |
||||
|
@RequestParam("location_2") String location_2, |
||||
|
@RequestParam(value = "zone_2", required = false, defaultValue = "-") String zone_2, |
||||
|
@RequestParam(value = "ward_2", required = false, defaultValue = "-") String ward_2, |
||||
|
@RequestParam(value = "streetid_2", required = false, defaultValue = "-") String streetid_2, |
||||
|
@RequestParam(value = "streetname_2", required = false, defaultValue = "-") String streetname_2, |
||||
|
@RequestParam("abc_center_2") String abc_center_2, @RequestParam("photo2") MultipartFile photo2, |
||||
|
@RequestParam("sex_2") String sex_2, @RequestParam("contraception_2") boolean contraception_2) { |
||||
|
|
||||
|
try { |
||||
|
int stage = 2; |
||||
|
Timestamp date_2 = Timestamp.valueOf(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") |
||||
|
.format(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(date2))); |
||||
|
|
||||
|
// String photo_2 = photo2.getOriginalFilename(); |
||||
|
|
||||
|
String step = userService.saveStep2(qr_id, userid_2, date_2, lat_2, long_2, location_2, zone_2, ward_2, |
||||
|
streetid_2, streetname_2, abc_center_2, photo2, sex_2, contraception_2, stage); |
||||
|
|
||||
|
// Prepare and return the response |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "OK"); |
||||
|
response.put("QR_id", qr_id); |
||||
|
response.put("Step", step); |
||||
|
|
||||
|
return ResponseEntity.ok(response); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Map.of("status", "ERROR", "message", "Error saving Step_2: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/step3") |
||||
|
public ResponseEntity<Map<String, Object>> saveStep3(@RequestParam("qr_id") String qr_id, |
||||
|
@RequestParam("rf_id") String rf_id, @RequestParam("userid_3") String userid_3, |
||||
|
@RequestParam("sex_3") String sex_3, @RequestParam("body_weight_3") String body_weight_3, |
||||
|
@RequestParam("temperature_3") String temperature_3, |
||||
|
@RequestParam("surgery_fitness_3") boolean surgery_fitness_3, |
||||
|
@RequestParam("surgery_type_3") String surgery_type_3) { |
||||
|
|
||||
|
int stage = 0; |
||||
|
String step = ""; |
||||
|
String qrid = ""; |
||||
|
Timestamp surgery_date = new Timestamp(new Date().getTime()); // Current timestamp |
||||
|
|
||||
|
try { |
||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
|
String formattedDate = sdf.format(surgery_date); |
||||
|
|
||||
|
// Fetch logs using rf_id |
||||
|
List<Map<String, Object>> data = userService.getlogsrfid(rf_id); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
|
||||
|
if (data != null && !data.isEmpty()) { |
||||
|
for (Map<String, Object> map : data) { |
||||
|
if (map.get("date_5") != null) { |
||||
|
int days = userService.getVaccineDue(rf_id, formattedDate); |
||||
|
if (days == 99999) { |
||||
|
} else if (days <= 10) { |
||||
|
|
||||
|
stage = 5; |
||||
|
step = userService.updateStage(rf_id, qr_id, stage); |
||||
|
} else { |
||||
|
stage = 6; |
||||
|
step = userService.updateStage(rf_id, qr_id, stage); |
||||
|
} |
||||
|
|
||||
|
// response.put("ARV_Expiry", Integer.toString(days)); |
||||
|
// response.put("DHPPI_Expiry", Integer.toString(days)); |
||||
|
} |
||||
|
} |
||||
|
String qrIDD = userService.updateStage3(rf_id, qr_id); |
||||
|
|
||||
|
} else { |
||||
|
if (surgery_fitness_3) { |
||||
|
stage = 4; |
||||
|
} else { |
||||
|
|
||||
|
stage = 5; |
||||
|
} |
||||
|
step = userService.updateStage(rf_id, qr_id, stage); |
||||
|
qrid = userService.saveStep3(qr_id, rf_id, userid_3, sex_3, body_weight_3, temperature_3, |
||||
|
surgery_fitness_3, surgery_type_3, surgery_date); |
||||
|
} |
||||
|
|
||||
|
// Create response |
||||
|
response.put("QR_id", qr_id); |
||||
|
response.put("RF_id", rf_id); |
||||
|
response.put("Step", step); |
||||
|
response.put("status", "OK"); |
||||
|
|
||||
|
return ResponseEntity.ok(response); |
||||
|
|
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Map.of("status", "ERROR", "message", "Error saving Step_3: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/step4") |
||||
|
public ResponseEntity<Map<String, Object>> saveStep4(@RequestParam("rf_id") String rf_id, |
||||
|
@RequestParam("qr_id") String qr_id, @RequestParam("userid_4") String userid_4, |
||||
|
@RequestParam("surgery_complication_4") boolean surgery_complication_4, |
||||
|
@RequestParam("complication_type_4") String complication_type_4, |
||||
|
@RequestParam("ready_to_release_4") boolean ready_to_release_4) { |
||||
|
try { |
||||
|
int stage = 0; |
||||
|
if (ready_to_release_4) { |
||||
|
stage = 5; // Assuming stage is hardcoded to 5 for Step 4 |
||||
|
} else { |
||||
|
stage = 0; |
||||
|
} |
||||
|
|
||||
|
String qrid = userService.saveStep4(qr_id, rf_id, userid_4, surgery_complication_4, complication_type_4, |
||||
|
ready_to_release_4); |
||||
|
String step = userService.updateStage(rf_id, qr_id, stage); |
||||
|
|
||||
|
// Prepare response |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("QR_id", qrid); |
||||
|
response.put("RF_id", rf_id); |
||||
|
response.put("Step", step); |
||||
|
response.put("status", "OK"); |
||||
|
|
||||
|
return ResponseEntity.ok(response); |
||||
|
|
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Map.of("status", "ERROR", "message", "Error saving Step 4: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/step5") |
||||
|
public ResponseEntity<Map<String, Object>> saveStep5(@RequestParam("rf_id") String rf_id, |
||||
|
@RequestParam("qr_id") String qr_id, @RequestParam("userid_5") String userid_5, |
||||
|
@RequestParam("arv_5") boolean arv_5, @RequestParam("dhppi_5") boolean dhppi_5, |
||||
|
@RequestParam("photo_5") MultipartFile photo_5, @RequestParam("lat_5") String lat_5, |
||||
|
@RequestParam("long_5") String long_5, @RequestParam("location_5") String location_5, |
||||
|
@RequestParam("zone_5") String zone_5, @RequestParam("ward_5") String ward_5, |
||||
|
@RequestParam(value = "streetid_5", required = false, defaultValue = "-") String streetid_5, |
||||
|
@RequestParam(value = "streetname_5", required = false, defaultValue = "-") String streetname_5, |
||||
|
@RequestParam("date_5") String date_5) { |
||||
|
try { |
||||
|
int stage = 6; // Assuming stage is set to 6 for Step 5 |
||||
|
Timestamp date5 = parseDate(date_5); |
||||
|
int days = userService.getVaccineDue(rf_id, date5.toString()); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
|
||||
|
String qrid; |
||||
|
String step; |
||||
|
|
||||
|
if (days <= 10 && days != 99999) { |
||||
|
qrid = userService.saveNewStep5(rf_id, qr_id, userid_5, arv_5, dhppi_5, photo_5, lat_5, long_5, |
||||
|
location_5, zone_5, ward_5, streetid_5, date5); |
||||
|
step = userService.updateStage(rf_id, qr_id, stage); |
||||
|
response.put("status", "OK"); |
||||
|
response.put("Qr_id", qrid); |
||||
|
response.put("Step", step); |
||||
|
} else if (days > 10 && days != 99999) { |
||||
|
qrid = userService.saveUpdateStep5(rf_id, qr_id, userid_5, arv_5, dhppi_5, photo_5, lat_5, long_5, |
||||
|
location_5, zone_5, ward_5, streetid_5, streetname_5, date5); |
||||
|
step = userService.updateStage(rf_id, qr_id, stage); |
||||
|
response.put("status", "OK"); |
||||
|
response.put("Qr_id", qrid); |
||||
|
response.put("Step", step); |
||||
|
} else if (days == 99999) { |
||||
|
response.put("status", "Provided RFID = " + rf_id + " is wrong"); |
||||
|
response.put("Rf_id", rf_id); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok(response); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Map.of("status", "ERROR", "message", "Error saving Step 5: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private Timestamp parseDate(String dateStr) throws ParseException { |
||||
|
SimpleDateFormat inputFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); |
||||
|
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
|
Date date = inputFormat.parse(dateStr); |
||||
|
return Timestamp.valueOf(outputFormat.format(date)); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/step6") |
||||
|
public ResponseEntity<Map<String, Object>> saveStep6(@RequestParam("qr_id") String qr_id, |
||||
|
@RequestParam("userid_6") String userid_6, @RequestParam("lat_6") String lat_6, |
||||
|
@RequestParam("long_6") String long_6, @RequestParam("location_6") String location_6, |
||||
|
@RequestParam("zone_6") String zone_6, @RequestParam("ward_6") String ward_6, |
||||
|
@RequestParam("streetid_6") String streetid_6, |
||||
|
@RequestParam(value = "streetname_6", required = false, defaultValue = "-") String streetname_6, |
||||
|
@RequestParam("date_6") String date_6, @RequestParam("photo_6") MultipartFile photo_6) { |
||||
|
try { |
||||
|
int stage = 0; // Assuming stage 0 is a valid value, adjust as needed |
||||
|
|
||||
|
Timestamp date6 = parseDate(date_6); |
||||
|
// String photoFilename = photo_6.getOriginalFilename(); // Retrieve the |
||||
|
// filename of the uploaded photo |
||||
|
|
||||
|
String step = userService.saveStep6(qr_id, userid_6, lat_6, long_6, location_6, zone_6, ward_6, streetid_6, |
||||
|
streetname_6, date6, photo_6, stage); |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "OK"); |
||||
|
response.put("Qr_id", qr_id); |
||||
|
response.put("Step", step); |
||||
|
|
||||
|
return ResponseEntity.ok(response); |
||||
|
} catch (Exception e) { |
||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
||||
|
.body(Map.of("status", "ERROR", "message", "Error saving Step 6: " + e.getMessage())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private Timestamp parseDate1(String dateStr) throws ParseException { |
||||
|
SimpleDateFormat inputFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); |
||||
|
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
|
Date date = inputFormat.parse(dateStr); |
||||
|
return Timestamp.valueOf(outputFormat.format(date)); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getMasterData") |
||||
|
public ResponseEntity<Map<String, Object>> getMasterData(@RequestParam String rf_id) { |
||||
|
try { |
||||
|
|
||||
|
List<Map<String, Object>> data = userService.getMasterData(rf_id); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
|
||||
|
Timestamp surgery_date = new Timestamp(new Date().getTime()); // Current timestamp |
||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
|
String formattedDate = sdf.format(surgery_date); |
||||
|
|
||||
|
int days = userService.getVaccineDue(rf_id, formattedDate); |
||||
|
|
||||
|
if (!data.isEmpty() && days != 99999) { |
||||
|
for (Map<String, Object> map : data) { |
||||
|
map.put("ARV_Expiry", days); |
||||
|
map.put("DHPPI_Expiry", days); |
||||
|
} |
||||
|
response.put("status", "OK"); |
||||
|
response.put("data", data); |
||||
|
} else { |
||||
|
response.put("status", "Failed"); |
||||
|
response.put("message", "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("/getLogData") |
||||
|
public ResponseEntity<Map<String, Object>> getLogData(@RequestParam String qr_id) { |
||||
|
try { |
||||
|
List<Map<String, Object>> data = userService.getLogData(qr_id); |
||||
|
Map<String, Object> 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())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Get Overall Data |
||||
|
@GetMapping("getoveralldata") |
||||
|
public ResponseEntity<Map<String, Object>> getOverallData(@RequestParam String fromDate, |
||||
|
@RequestParam String toDate) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
List<Map<String, Object>> result = userService.getOverallData(fromDate, toDate); |
||||
|
if (!result.isEmpty()) { |
||||
|
|
||||
|
response.put("Message", "success"); |
||||
|
response.put("Data", result); |
||||
|
} else { |
||||
|
|
||||
|
response.put("Message", "Failed"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok().body(response); |
||||
|
} |
||||
|
|
||||
|
// Get Overall Catched Data |
||||
|
@GetMapping("getoverallcatcheddata") |
||||
|
public List<Map<String, Object>> getoverallcatcheddata(@RequestParam String fromDate, @RequestParam String toDate) { |
||||
|
return userService.getoverallcatcheddata(fromDate, toDate); |
||||
|
} |
||||
|
|
||||
|
// Get Overall Released Data |
||||
|
@GetMapping("getoverallreleaseddata") |
||||
|
public List<Map<String, Object>> getoverallreleaseddata(@RequestParam String fromDate, |
||||
|
@RequestParam String toDate) { |
||||
|
return userService.getoverallreleaseddata(fromDate, toDate); |
||||
|
} |
||||
|
|
||||
|
// Get AbcCenterwiseData |
||||
|
@GetMapping("getAbcCenterwiseData") |
||||
|
public ResponseEntity<Map<String, Object>> getAbcCenterwiseData(@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, @RequestParam String abcCenter) { |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
List<Map<String, Object>> result = userService.getAbcCenterwiseData(fromDate, toDate, abcCenter); |
||||
|
if (!result.isEmpty()) { |
||||
|
|
||||
|
response.put("Message", "success"); |
||||
|
response.put("Data", result); |
||||
|
} else { |
||||
|
|
||||
|
response.put("Message", "Failed"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok().body(response); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// Unstrelized |
||||
|
//Get Unstrelized zone breakup |
||||
|
@GetMapping("getUnstrelizedZoneBreakup") |
||||
|
public List<Map<String, Object>> getUnstrelizedZoneBreakup(@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, @RequestParam String abcCenter) { |
||||
|
return userService.getUnstrelizedZoneBreakup(fromDate, toDate, abcCenter); |
||||
|
} |
||||
|
|
||||
|
// Get Unstrelized division breakup |
||||
|
@GetMapping("getUnstrelizedDivisionBreakup") |
||||
|
public List<Map<String, Object>> getUnstrelizedDivisionBreakup(@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, @RequestParam String abcCenter, @RequestParam String zone) { |
||||
|
return userService.getUnstrelizedDivisionBreakup(fromDate, toDate, abcCenter, zone); |
||||
|
} |
||||
|
|
||||
|
// Get Unstrelized street breakup |
||||
|
@GetMapping("getUnstrelizedStreetBreakup") |
||||
|
public List<Map<String, Object>> getUnstrelizedStreetBreakup(@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, @RequestParam String abcCenter, @RequestParam String ward, |
||||
|
@RequestParam String zone) { |
||||
|
return userService.getUnstrelizedStreetBreakup(ward, fromDate, toDate, abcCenter, zone); |
||||
|
} |
||||
|
|
||||
|
// Get Unstrelized dogs breakup |
||||
|
@GetMapping("getUnstrelizedDogsBreakup") |
||||
|
public Map<String, Object> getUnstrelizedDogsBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone, |
||||
|
@RequestParam String streetID, @RequestParam String sex) { |
||||
|
Map<String, Object> response = new LinkedHashMap<>(); |
||||
|
|
||||
|
try { |
||||
|
List<Map<String, Object>> data = userService.getUnstrelizedDogsBreakup(ward, fromDate, toDate, abcCenter, |
||||
|
zone, streetID, sex); |
||||
|
|
||||
|
Map<String, List<Map<String, Object>>> groupedData = new LinkedHashMap<>(); |
||||
|
for (Map<String, Object> record : data) { |
||||
|
String rfId = (String) record.get("rf_id"); |
||||
|
groupedData.putIfAbsent(rfId, new ArrayList<>()); |
||||
|
groupedData.get(rfId).add(record); |
||||
|
} |
||||
|
|
||||
|
List<Map<String, Object>> list1 = new ArrayList<>(); |
||||
|
for (Map.Entry<String, List<Map<String, Object>>> entry : groupedData.entrySet()) { |
||||
|
Map<String, Object> object1 = new LinkedHashMap<>(); |
||||
|
object1.put("rfid", entry.getKey()); |
||||
|
object1.put("rfid_data", entry.getValue()); |
||||
|
list1.add(object1); |
||||
|
} |
||||
|
|
||||
|
response.put("message", "success"); |
||||
|
response.put("data", list1); |
||||
|
return response; |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
response.put("message", "Error"); |
||||
|
response.put("data", "No Data Found"); |
||||
|
return response; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Strelized |
||||
|
// Get Strelized zone breakup |
||||
|
@GetMapping("getStrelizedZoneBreakup") |
||||
|
public List<Map<String, Object>> geStrelizedZoneBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter) { |
||||
|
return userService.getStrelizedZoneBreakup(fromDate, toDate, abcCenter); |
||||
|
} |
||||
|
|
||||
|
// Get Strelized division breakup |
||||
|
@GetMapping("getStrelizedDivisionBreakup") |
||||
|
public List<Map<String, Object>> getStrelizedDivisionBreakup(@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, @RequestParam String abcCenter, @RequestParam String zone) { |
||||
|
return userService.getStrelizedDivisionBreakup(fromDate, toDate, abcCenter, zone); |
||||
|
} |
||||
|
|
||||
|
// Get Strelized street breakup |
||||
|
@GetMapping("getStrelizedStreetBreakup") |
||||
|
public List<Map<String, Object>> getStrelizedStreetBreakup(@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, @RequestParam String abcCenter, @RequestParam String ward, |
||||
|
@RequestParam String zone) { |
||||
|
return userService.getStrelizedStreetBreakup(ward, fromDate, toDate, abcCenter, zone); |
||||
|
} |
||||
|
|
||||
|
// Get Strelized dogs breakup |
||||
|
@GetMapping("getStrelizedDogsBreakup") |
||||
|
public Map<String, Object> getStrelizedDogsBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone, |
||||
|
@RequestParam String streetID, @RequestParam String sex) { |
||||
|
Map<String, Object> response = new LinkedHashMap<>(); |
||||
|
|
||||
|
try { |
||||
|
List<Map<String, Object>> data = userService.getStrelizedDogsBreakup(ward, fromDate, toDate, abcCenter, |
||||
|
zone, streetID, sex); |
||||
|
|
||||
|
Map<String, List<Map<String, Object>>> groupedData = new LinkedHashMap<>(); |
||||
|
for (Map<String, Object> record : data) { |
||||
|
String rfId = (String) record.get("rf_id"); |
||||
|
groupedData.putIfAbsent(rfId, new ArrayList<>()); |
||||
|
groupedData.get(rfId).add(record); |
||||
|
} |
||||
|
|
||||
|
List<Map<String, Object>> list1 = new ArrayList<>(); |
||||
|
for (Map.Entry<String, List<Map<String, Object>>> entry : groupedData.entrySet()) { |
||||
|
Map<String, Object> object1 = new LinkedHashMap<>(); |
||||
|
object1.put("rfid", entry.getKey()); |
||||
|
object1.put("rfid_data", entry.getValue()); |
||||
|
list1.add(object1); |
||||
|
} |
||||
|
|
||||
|
response.put("message", "success"); |
||||
|
response.put("data", list1); |
||||
|
return response; |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
response.put("message", "Error"); |
||||
|
response.put("data", "No Data Found"); |
||||
|
return response; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//Unfit |
||||
|
// Get Unfit zone breakup |
||||
|
@GetMapping("getUnfitZoneBreakup") |
||||
|
public List<Map<String, Object>> getUnfitZoneBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter) { |
||||
|
return userService.getUnfitZoneBreakup(fromDate, toDate, abcCenter); |
||||
|
} |
||||
|
|
||||
|
// Get Unfit division breakup |
||||
|
@GetMapping("getUnfitDivisionBreakup") |
||||
|
public List<Map<String, Object>> getUnfitDivisionBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter, @RequestParam String zone) { |
||||
|
return userService.getUnfitDivisionBreakup(fromDate, toDate, abcCenter, zone); |
||||
|
} |
||||
|
|
||||
|
// Get Unfit street breakup |
||||
|
@GetMapping("getUnfitStreetBreakup") |
||||
|
public List<Map<String, Object>> getUnfitStreetBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone) { |
||||
|
return userService.getUnfitStreetBreakup(ward, zone, fromDate, toDate, abcCenter); |
||||
|
} |
||||
|
|
||||
|
// Get Unfit dogs breakup |
||||
|
@GetMapping("getUnfitDogsBreakup") |
||||
|
public Map<String, Object> getUnfitDogsBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone, |
||||
|
@RequestParam String streetID, @RequestParam String sex) { |
||||
|
Map<String, Object> response = new LinkedHashMap<>(); |
||||
|
|
||||
|
try { |
||||
|
List<Map<String, Object>> data = userService.getUnfitDogsBreakup(ward, fromDate, toDate, abcCenter, zone, |
||||
|
streetID, sex); |
||||
|
|
||||
|
Map<String, List<Map<String, Object>>> groupedData = new LinkedHashMap<>(); |
||||
|
for (Map<String, Object> record : data) { |
||||
|
String rfId = (String) record.get("rf_id"); |
||||
|
groupedData.putIfAbsent(rfId, new ArrayList<>()); |
||||
|
groupedData.get(rfId).add(record); |
||||
|
} |
||||
|
|
||||
|
List<Map<String, Object>> list1 = new ArrayList<>(); |
||||
|
for (Map.Entry<String, List<Map<String, Object>>> entry : groupedData.entrySet()) { |
||||
|
Map<String, Object> object1 = new LinkedHashMap<>(); |
||||
|
object1.put("rfid", entry.getKey()); |
||||
|
object1.put("rfid_data", entry.getValue()); |
||||
|
list1.add(object1); |
||||
|
} |
||||
|
|
||||
|
response.put("message", "success"); |
||||
|
response.put("data", list1); |
||||
|
return response; |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
response.put("message", "Error"); |
||||
|
response.put("data", "No Data Found"); |
||||
|
return response; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//Surgery |
||||
|
//Get Surgery zone breakup |
||||
|
@GetMapping("getSurgeryZoneBreakup") |
||||
|
public List<Map<String, Object>> getSurgeryZoneBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter) { |
||||
|
return userService.getSurgeryZoneBreakup(fromDate, toDate, abcCenter); |
||||
|
} |
||||
|
|
||||
|
//Get Surgery division breakup |
||||
|
@GetMapping("getSurgeryDivisionBreakup") |
||||
|
public List<Map<String, Object>> getSurgeryDivisionBreakup(@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, @RequestParam String abcCenter, @RequestParam String zone) { |
||||
|
return userService.getSurgeryDivisionBreakup(fromDate, toDate, abcCenter, zone); |
||||
|
} |
||||
|
|
||||
|
//Get Surgery street breakup |
||||
|
@GetMapping("getSurgeryStreetBreakup") |
||||
|
public List<Map<String, Object>> getSurgeryStreetBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone) { |
||||
|
return userService.getSurgeryStreetBreakup(ward, zone, fromDate, toDate, abcCenter); |
||||
|
} |
||||
|
|
||||
|
// Get Surgery dogs breakup |
||||
|
@GetMapping("getSurgeryDogsBreakup") |
||||
|
public Map<String, Object> getSurgeryDogsBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone, |
||||
|
@RequestParam String streetID, @RequestParam String sex) { |
||||
|
Map<String, Object> response = new LinkedHashMap<>(); |
||||
|
|
||||
|
try { |
||||
|
List<Map<String, Object>> data = userService.getSurgeryDogsBreakup(ward, fromDate, toDate, abcCenter, zone, |
||||
|
streetID, sex); |
||||
|
|
||||
|
Map<String, List<Map<String, Object>>> groupedData = new LinkedHashMap<>(); |
||||
|
for (Map<String, Object> record : data) { |
||||
|
String rfId = (String) record.get("rf_id"); |
||||
|
groupedData.putIfAbsent(rfId, new ArrayList<>()); |
||||
|
groupedData.get(rfId).add(record); |
||||
|
} |
||||
|
|
||||
|
List<Map<String, Object>> list1 = new ArrayList<>(); |
||||
|
for (Map.Entry<String, List<Map<String, Object>>> entry : groupedData.entrySet()) { |
||||
|
Map<String, Object> object1 = new LinkedHashMap<>(); |
||||
|
object1.put("rfid", entry.getKey()); |
||||
|
object1.put("rfid_data", entry.getValue()); |
||||
|
list1.add(object1); |
||||
|
} |
||||
|
|
||||
|
response.put("message", "success"); |
||||
|
response.put("data", list1); |
||||
|
return response; |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
response.put("message", "Error"); |
||||
|
response.put("data", "No Data Found"); |
||||
|
return response; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//Died |
||||
|
//Get Died zone breakup |
||||
|
@GetMapping("getDiedZoneBreakup") |
||||
|
public List<Map<String, Object>> getDiedZoneBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter) { |
||||
|
return userService.getDiedZoneBreakup(fromDate, toDate, abcCenter); |
||||
|
} |
||||
|
|
||||
|
//Get Died division breakup |
||||
|
@GetMapping("getDiedDivisionBreakup") |
||||
|
public List<Map<String, Object>> getDiedDivisionBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter, @RequestParam String zone) { |
||||
|
return userService.getDiedDivisionBreakup(fromDate, toDate, abcCenter, zone); |
||||
|
} |
||||
|
|
||||
|
//Get Died street breakup |
||||
|
@GetMapping("getDiedStreetBreakup") |
||||
|
public List<Map<String, Object>> getDiedStreetBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone) { |
||||
|
return userService.getDiedStreetBreakup(ward, zone, fromDate, toDate, abcCenter); |
||||
|
} |
||||
|
|
||||
|
// Get Died dogs breakup |
||||
|
@GetMapping("getDiedDogsBreakup") |
||||
|
public Map<String, Object> getDiedDogsBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone, |
||||
|
@RequestParam String streetID, @RequestParam String sex) { |
||||
|
Map<String, Object> response = new LinkedHashMap<>(); |
||||
|
|
||||
|
try { |
||||
|
List<Map<String, Object>> data = userService.getDiedDogsBreakup(ward, fromDate, toDate, abcCenter, zone, |
||||
|
streetID, sex); |
||||
|
|
||||
|
Map<String, List<Map<String, Object>>> groupedData = new LinkedHashMap<>(); |
||||
|
for (Map<String, Object> record : data) { |
||||
|
String rfId = (String) record.get("rf_id"); |
||||
|
groupedData.putIfAbsent(rfId, new ArrayList<>()); |
||||
|
groupedData.get(rfId).add(record); |
||||
|
} |
||||
|
|
||||
|
List<Map<String, Object>> list1 = new ArrayList<>(); |
||||
|
for (Map.Entry<String, List<Map<String, Object>>> entry : groupedData.entrySet()) { |
||||
|
Map<String, Object> object1 = new LinkedHashMap<>(); |
||||
|
object1.put("rfid", entry.getKey()); |
||||
|
object1.put("rfid_data", entry.getValue()); |
||||
|
list1.add(object1); |
||||
|
} |
||||
|
|
||||
|
response.put("message", "success"); |
||||
|
response.put("data", list1); |
||||
|
return response; |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
response.put("message", "Error"); |
||||
|
response.put("data", "No Data Found"); |
||||
|
return response; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//Released |
||||
|
//Get Released zone breakup |
||||
|
@GetMapping("getReleasedZoneBreakup") |
||||
|
public List<Map<String, Object>> getReleasedZoneBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter) { |
||||
|
return userService.getReleasedZoneBreakup(fromDate, toDate, abcCenter); |
||||
|
} |
||||
|
|
||||
|
//Get Released division breakup |
||||
|
@GetMapping("getReleasedDivisionBreakup") |
||||
|
public List<Map<String, Object>> getReleasedDivisionBreakup(@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, @RequestParam String abcCenter, @RequestParam String zone) { |
||||
|
return userService.getReleasedDivisionBreakup(fromDate, toDate, abcCenter, zone); |
||||
|
} |
||||
|
|
||||
|
//Get Released street breakup |
||||
|
@GetMapping("getReleasedStreetBreakup") |
||||
|
public List<Map<String, Object>> getReleasedStreetBreakup(@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, @RequestParam String abcCenter, @RequestParam String ward, |
||||
|
@RequestParam String zone) { |
||||
|
return userService.getReleasedStreetBreakup(ward, zone, fromDate, toDate, abcCenter); |
||||
|
} |
||||
|
|
||||
|
// Get Released dogs breakup |
||||
|
@GetMapping("getReleasedDogsBreakup") |
||||
|
public Map<String, Object> getReleasedDogsBreakup(@RequestParam String fromDate, @RequestParam String toDate, |
||||
|
@RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone, |
||||
|
@RequestParam String streetID, @RequestParam String sex) { |
||||
|
Map<String, Object> response = new LinkedHashMap<>(); |
||||
|
|
||||
|
try { |
||||
|
List<Map<String, Object>> data = userService.getReleasedDogsBreakup(ward, fromDate, toDate, abcCenter, zone, |
||||
|
streetID, sex); |
||||
|
|
||||
|
Map<String, List<Map<String, Object>>> groupedData = new LinkedHashMap<>(); |
||||
|
for (Map<String, Object> record : data) { |
||||
|
String rfId = (String) record.get("rf_id"); |
||||
|
groupedData.putIfAbsent(rfId, new ArrayList<>()); |
||||
|
groupedData.get(rfId).add(record); |
||||
|
} |
||||
|
|
||||
|
List<Map<String, Object>> list1 = new ArrayList<>(); |
||||
|
for (Map.Entry<String, List<Map<String, Object>>> entry : groupedData.entrySet()) { |
||||
|
Map<String, Object> object1 = new LinkedHashMap<>(); |
||||
|
object1.put("rfid", entry.getKey()); |
||||
|
object1.put("rfid_data", entry.getValue()); |
||||
|
list1.add(object1); |
||||
|
} |
||||
|
|
||||
|
response.put("message", "success"); |
||||
|
response.put("data", list1); |
||||
|
return response; |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
response.put("message", "Error"); |
||||
|
response.put("data", "No Data Found"); |
||||
|
return response; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Get List of Zone |
||||
|
@GetMapping("getZoneList") |
||||
|
public ResponseEntity<Map<String, Object>> getZoneList() { |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
List<Map<String, Object>> result = userService.getZoneList(); |
||||
|
if (!result.isEmpty()) { |
||||
|
|
||||
|
response.put("Message", "success"); |
||||
|
response.put("Data", result); |
||||
|
} else { |
||||
|
|
||||
|
response.put("Message", "Failed"); |
||||
|
} |
||||
|
|
||||
|
return ResponseEntity.ok().body(response); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@GetMapping("/overallExcelReport") |
||||
|
public ResponseEntity<InputStreamResource> overallExcelReport(@RequestParam String fromDate, |
||||
|
@RequestParam String toDate) { |
||||
|
|
||||
|
ByteArrayInputStream reportStream = userService.overallExcelReport(fromDate, toDate); |
||||
|
|
||||
|
HttpHeaders headers = new HttpHeaders(); |
||||
|
headers.add("Content-Disposition", "attachment; filename=Zonewise_Overall_Report.xlsx"); |
||||
|
|
||||
|
return ResponseEntity.ok().headers(headers).contentType(MediaType.APPLICATION_OCTET_STREAM) |
||||
|
.body(new InputStreamResource(reportStream)); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/abcCenterExcelReport") |
||||
|
public ResponseEntity<InputStreamResource> abcCenterExcelReport(@RequestParam String fromDate, |
||||
|
@RequestParam String toDate, @RequestParam String abcCenter) { |
||||
|
|
||||
|
ByteArrayInputStream reportStream = userService.abcCenterExcelReport(fromDate, toDate, abcCenter); |
||||
|
|
||||
|
HttpHeaders headers = new HttpHeaders(); |
||||
|
headers.add("Content-Disposition", "attachment; filename=ABC_Centerwise_Report.xlsx"); |
||||
|
|
||||
|
return ResponseEntity.ok().headers(headers).contentType(MediaType.APPLICATION_OCTET_STREAM) |
||||
|
.body(new InputStreamResource(reportStream)); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/saveBuildings") |
||||
|
public ResponseEntity<Map<String, Object>> saveBuildings(@RequestParam("location") String location, |
||||
|
@RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude, |
||||
|
@RequestParam(value = "street_id", required = false) String street_id, |
||||
|
@RequestParam(value = "street_name", required = false) String street_name) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
try { |
||||
|
if (street_id.equals("") || street_id == null && street_name.equals("") || street_name == null) { |
||||
|
|
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); |
||||
|
String dateTime = LocalDateTime.now().format(formatter); |
||||
|
street_id = "L_" + dateTime; |
||||
|
street_name = location; |
||||
|
String data = userService.saveBuildings(location, latitude, longitude, street_id, street_name); |
||||
|
} else { |
||||
|
|
||||
|
String data = userService.saveBuildings(location, latitude, longitude, street_id, street_name); |
||||
|
} |
||||
|
|
||||
|
response.put("Status", "Sucess"); |
||||
|
response.put("Message", "Saved Sucessfuly"); |
||||
|
return ResponseEntity.ok(response); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
response.put("Status", "Error"); |
||||
|
response.put("Message", "Failed to Save"); |
||||
|
return ResponseEntity.ok(response); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value = "/getBuildings") |
||||
|
public List<?> getBuildings(@RequestParam(value = "latitude", required = false) String latitude, |
||||
|
@RequestParam(value = "longitude", required = false) String longitude) { |
||||
|
return userService.getBuildings(latitude, longitude); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccstraydogs.controller; |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccstraydogs; |
||||
1317
mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/service/UserService.java
File diff suppressed because it is too large
View File
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.gccstraydogs.service; |
||||
@ -0,0 +1,96 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.penalty.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.util.MultiValueMap; |
||||
|
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 org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import in.gov.chennaicorporation.mobileservice.penalty.service.PenaltyServicePOS; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/api/penalty/pos") |
||||
|
@RestController("apiPenaltyPOSRest") |
||||
|
public class APIPenaltyControllerPOS { |
||||
|
@Autowired |
||||
|
private PenaltyServicePOS penaltyServicePOS; |
||||
|
|
||||
|
@GetMapping(value="/getPenaltyDepartment") |
||||
|
public List<Map<String, Object>> getPenaltyDepartment( |
||||
|
@RequestParam(value = "loginId", required = false) String loginId |
||||
|
) { |
||||
|
return penaltyServicePOS.getPenaltyDepartment(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getPenaltytypes") |
||||
|
public List<Map<String, Object>> getPenaltyTypes( |
||||
|
@RequestParam(value = "departmentId", required = false) String departmentId, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId) { |
||||
|
return penaltyServicePOS.getPenaltyTypeList(departmentId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getPenaltyAmount") |
||||
|
public List<Map<String, Object>> getPenaltyAmount( |
||||
|
@RequestParam(value = "categoryId", required = false) String categoryId, |
||||
|
@RequestParam(value = "ton", required = false) String ton, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId |
||||
|
) { |
||||
|
return penaltyServicePOS.getPenaltyAmount(categoryId,ton); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getOfflineModeTypes") |
||||
|
public List<Map<String, Object>> getOfflineModeTypes() { |
||||
|
return penaltyServicePOS.getOfflineModeTypes(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getBankList") |
||||
|
public List<Map<String, Object>> getBankList() { |
||||
|
return penaltyServicePOS.getBankList(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/generateChallanPOS") |
||||
|
public List<?> generateChallan(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "categoryId", required = false) String categoryId, |
||||
|
@RequestParam(value = "latitude", required = false) String latitude, |
||||
|
@RequestParam(value = "longitude", required = false) String longitude, |
||||
|
@RequestParam(value = "zone", required = false) String zone, |
||||
|
@RequestParam(value = "ward", required = false) String ward, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId, |
||||
|
@RequestParam(value = "violatorName", required = false) String violatorName, |
||||
|
@RequestParam(value = "violatorPhone", required = false) String violatorPhone, |
||||
|
@RequestParam(value = "ton", required = false) String ton, |
||||
|
@RequestParam(value = "amount", required = false) String amount, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile file |
||||
|
) { |
||||
|
return penaltyServicePOS.generateChallanPOS(formData, categoryId, latitude, longitude, zone, ward,loginId,violatorName,violatorPhone,ton,amount,file); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/storeBankTransaction") |
||||
|
public List<?> storeBankTransaction(@RequestBody Map<String, Object> transactionData) { |
||||
|
return penaltyServicePOS.storeBankTransaction(transactionData); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/storeOfflineTransaction") |
||||
|
public List<?> generateChallan(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "transactionResponseStatus", required = false) String transactionResponseStatus, |
||||
|
@RequestParam(value = "bankName", required = false) String bankName, |
||||
|
@RequestParam(value = "transactionAmount", required = false) String transactionAmount, |
||||
|
@RequestParam(value = "txnDate", required = false) String txnDate, |
||||
|
@RequestParam(value = "txnTime", required = false) String txnTime, |
||||
|
@RequestParam(value = "branchname", required = false) String branchname, |
||||
|
@RequestParam(value = "extraInfo", required = false) String extraInfo, |
||||
|
@RequestParam(value = "extraInfo2", required = false) String extraInfo2, |
||||
|
@RequestParam(value = "extraInfo3", required = false) String extraInfo3, |
||||
|
@RequestParam(value = "txnMode", required = false) String txnMode, |
||||
|
@RequestParam(value = "txnId", required = false) String txnId, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile file |
||||
|
) { |
||||
|
return penaltyServicePOS.storeOfflineTransaction(formData, transactionResponseStatus, bankName, transactionAmount, txnDate, txnTime,branchname,extraInfo,extraInfo2,extraInfo3,txnMode,txnId,file); |
||||
|
} |
||||
|
} |
||||
@ -1,29 +1,800 @@ |
|||||
package in.gov.chennaicorporation.mobileservice.penalty.service; |
package in.gov.chennaicorporation.mobileservice.penalty.service; |
||||
|
|
||||
|
import java.awt.image.BufferedImage; |
||||
|
import java.io.ByteArrayInputStream; |
||||
|
import java.io.ByteArrayOutputStream; |
||||
|
import java.io.IOException; |
||||
|
import java.nio.file.Files; |
||||
|
import java.nio.file.Path; |
||||
|
import java.nio.file.Paths; |
||||
|
import java.security.SecureRandom; |
||||
|
import java.sql.Connection; |
||||
|
import java.sql.PreparedStatement; |
||||
|
import java.sql.SQLException; |
||||
|
import java.time.LocalDate; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.time.format.DateTimeParseException; |
||||
|
import java.util.Collections; |
||||
|
import java.util.HashMap; |
||||
import java.util.List; |
import java.util.List; |
||||
import java.util.Map; |
import java.util.Map; |
||||
|
import java.util.Random; |
||||
|
|
||||
|
import javax.imageio.ImageIO; |
||||
|
import javax.imageio.ImageWriteParam; |
||||
|
import javax.imageio.ImageWriter; |
||||
|
import javax.imageio.stream.ImageOutputStream; |
||||
import javax.sql.DataSource; |
import javax.sql.DataSource; |
||||
|
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.beans.factory.annotation.Qualifier; |
import org.springframework.beans.factory.annotation.Qualifier; |
||||
|
import org.springframework.core.env.Environment; |
||||
|
import org.springframework.dao.DataAccessException; |
||||
import org.springframework.jdbc.core.JdbcTemplate; |
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.jdbc.core.PreparedStatementCreator; |
||||
|
import org.springframework.jdbc.support.GeneratedKeyHolder; |
||||
|
import org.springframework.jdbc.support.KeyHolder; |
||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.util.MultiValueMap; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import in.gov.chennaicorporation.mobileservice.gccactivity.service.DateTimeUtil; |
||||
|
|
||||
@Service |
@Service |
||||
public class CattleCatchService { |
public class CattleCatchService { |
||||
private JdbcTemplate jdbcPenaltyTemplate; |
private JdbcTemplate jdbcPenaltyTemplate; |
||||
|
private final Environment environment; |
||||
|
private String fileBaseUrl; |
||||
|
|
||||
|
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
||||
|
private static final int STRING_LENGTH = 15; |
||||
|
private static final Random RANDOM = new SecureRandom(); |
||||
|
|
||||
@Autowired |
@Autowired |
||||
public void setDataSource(@Qualifier("mysqlPenaltyDataSource") DataSource penaltyDataSource) { |
|
||||
|
public void setDataSource(@Qualifier("mysqlCattleCatchDataSource") DataSource penaltyDataSource) { |
||||
this.jdbcPenaltyTemplate = new JdbcTemplate(penaltyDataSource); |
this.jdbcPenaltyTemplate = new JdbcTemplate(penaltyDataSource); |
||||
} |
} |
||||
|
|
||||
|
@Autowired |
||||
|
public CattleCatchService(Environment environment) { |
||||
|
this.environment = environment; |
||||
|
this.fileBaseUrl=environment.getProperty("fileBaseUrl"); |
||||
|
} |
||||
|
|
||||
|
public static String generateRandomString() { |
||||
|
StringBuilder result = new StringBuilder(STRING_LENGTH); |
||||
|
for (int i = 0; i < STRING_LENGTH; i++) { |
||||
|
result.append(CHARACTERS.charAt(RANDOM.nextInt(CHARACTERS.length()))); |
||||
|
} |
||||
|
return result.toString(); |
||||
|
} |
||||
|
|
||||
|
// Function to convert date string from dd-MM-yyyy to yyyy-MM-dd |
||||
|
public static String convertDateFormat(String inputDate, int add) { |
||||
|
// Check if the inputDate is not null or blank |
||||
|
if (inputDate != null && !inputDate.isBlank()) { |
||||
|
try { |
||||
|
// Define the input and output date formats |
||||
|
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
||||
|
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
||||
|
|
||||
|
// Parse the input date string to LocalDate |
||||
|
LocalDate date = LocalDate.parse(inputDate, inputFormatter); |
||||
|
|
||||
|
// Add the specified number of days to the date if 'add' is greater than 0 |
||||
|
if (add > 0) { |
||||
|
date = date.plusDays(add); |
||||
|
} |
||||
|
|
||||
|
// Format the date to the new format |
||||
|
return date.format(outputFormatter); |
||||
|
|
||||
|
} catch (DateTimeParseException e) { |
||||
|
// Handle the case where the input date is invalid |
||||
|
System.out.println("Invalid date format: " + inputDate); |
||||
|
return ""; |
||||
|
} |
||||
|
} else { |
||||
|
return ""; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private byte[] compressImage(BufferedImage image, float quality) throws IOException { |
||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
||||
|
ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(byteArrayOutputStream); |
||||
|
|
||||
|
ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next(); |
||||
|
writer.setOutput(imageOutputStream); |
||||
|
|
||||
|
ImageWriteParam param = writer.getDefaultWriteParam(); |
||||
|
if (param.canWriteCompressed()) { |
||||
|
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
||||
|
param.setCompressionQuality(quality); |
||||
|
} |
||||
|
|
||||
|
writer.write(null, new javax.imageio.IIOImage(image, null, null), param); |
||||
|
|
||||
|
writer.dispose(); |
||||
|
imageOutputStream.close(); |
||||
|
|
||||
|
return byteArrayOutputStream.toByteArray(); |
||||
|
} |
||||
|
|
||||
|
public String fileUpload(String name, String id, MultipartFile file) { |
||||
|
|
||||
|
int lastInsertId = 0; |
||||
|
// Set the file path where you want to save it |
||||
|
String uploadDirectory = environment.getProperty("file.upload.directory"); |
||||
|
String serviceFolderName = environment.getProperty("cattlecatch_foldername"); |
||||
|
var year =DateTimeUtil.getCurrentYear(); |
||||
|
var month =DateTimeUtil.getCurrentMonth(); |
||||
|
|
||||
|
uploadDirectory = uploadDirectory + serviceFolderName + year +"/"+month+"/"; |
||||
|
|
||||
|
try { |
||||
|
// Create directory if it doesn't exist |
||||
|
Path directoryPath = Paths.get(uploadDirectory); |
||||
|
if (!Files.exists(directoryPath)) { |
||||
|
Files.createDirectories(directoryPath); |
||||
|
} |
||||
|
|
||||
|
// Datetime string |
||||
|
String datetimetxt = DateTimeUtil.getCurrentDateTime(); |
||||
|
// File name |
||||
|
String fileName = name+ "_" +id + "_" + datetimetxt + "_" + file.getOriginalFilename(); |
||||
|
fileName = fileName.replaceAll("\\s+", ""); // Remove space on filename |
||||
|
|
||||
|
String filePath = uploadDirectory + "/" + fileName; |
||||
|
|
||||
|
String filepath_txt = "/"+serviceFolderName + year +"/"+month+"/"+fileName; |
||||
|
|
||||
|
// Create a new Path object |
||||
|
Path path = Paths.get(filePath); |
||||
|
|
||||
|
// Get the bytes of the file |
||||
|
byte[] bytes = file.getBytes(); |
||||
|
|
||||
|
// Compress the image |
||||
|
BufferedImage image = ImageIO.read(new ByteArrayInputStream(bytes)); |
||||
|
byte[] compressedBytes = compressImage(image, 0.5f); // Compress with 50% quality |
||||
|
|
||||
|
// Write the bytes to the file |
||||
|
Files.write(path, compressedBytes); |
||||
|
|
||||
|
System.out.println(filePath); |
||||
|
return filepath_txt; |
||||
|
|
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
return "Failed to save file " + file.getOriginalFilename(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> step1( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String category_id, |
||||
|
String latitude, |
||||
|
String longitude, |
||||
|
String zone, |
||||
|
String ward, |
||||
|
String streeId, |
||||
|
String streetName, |
||||
|
String loginId, |
||||
|
String remarks, |
||||
|
//String isviolatorAvailable, |
||||
|
//String violatorName, |
||||
|
//String violatorPhone, |
||||
|
//String ton, |
||||
|
MultipartFile file) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
int lastInsertId = 0; |
||||
|
|
||||
|
String image = fileUpload("cc_step1",category_id,file); |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO `cc_step1`(`category_id`, `image`, `latitude`, `longitude`, " |
||||
|
+ "`zone`, `ward`, `streetid`, `streetname`, `catch_by`,`remarks`) " |
||||
|
//+ "`violator_info`, `violator_name`, `violator_phone`, `ton`) " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcPenaltyTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
||||
|
ps.setString(1, category_id); |
||||
|
ps.setString(2, image); |
||||
|
ps.setString(3, latitude); |
||||
|
ps.setString(4, longitude); |
||||
|
ps.setString(5, zone); |
||||
|
ps.setString(6, ward); |
||||
|
ps.setString(7, streeId); |
||||
|
ps.setString(8, streetName); |
||||
|
ps.setString(9, loginId); |
||||
|
ps.setString(10, remarks); |
||||
|
//ps.setString(11, isviolatorAvailable); |
||||
|
//ps.setString(12, violatorName); |
||||
|
//ps.setString(13, violatorPhone); |
||||
|
//ps.setString(14, ton); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
response.put("insertId", lastInsertId); |
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "Cattle caught successfully!"); |
||||
|
System.out.println("Cattle caught successfully! Insert ID: " + generatedId); |
||||
|
} else { |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", "Failed to insert a new Penalty (Chellan)."); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
System.out.println("Data Access Exception:"); |
||||
|
Throwable rootCause = e.getMostSpecificCause(); |
||||
|
if (rootCause instanceof SQLException) { |
||||
|
SQLException sqlException = (SQLException) rootCause; |
||||
|
System.out.println("SQL State: " + sqlException.getSQLState()); |
||||
|
System.out.println("Error Code: " + sqlException.getErrorCode()); |
||||
|
System.out.println("Message: " + sqlException.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", sqlException.getMessage()); |
||||
|
response.put("sqlState", sqlException.getSQLState()); |
||||
|
response.put("errorCode", sqlException.getErrorCode()); |
||||
|
} else { |
||||
|
System.out.println("Message: " + rootCause.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", rootCause.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> step1list( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String loginid) { |
||||
|
|
||||
|
String sqlQuery = "SELECT *, " |
||||
|
+ "CONCAT('"+fileBaseUrl+"/gccofficialapp/files',`image`) as imageurl " |
||||
|
+ " From `cc_step1` WHERE (`isactive`=1 AND `isdelete`=0)"; |
||||
|
|
||||
|
if(loginid!=null && !loginid.isEmpty() && !loginid.isBlank()) { |
||||
|
sqlQuery= sqlQuery +" AND `catch_by`='"+loginid+"'"; |
||||
|
} |
||||
|
|
||||
|
sqlQuery = sqlQuery + " LIMIT 1"; |
||||
|
|
||||
|
//System.out.println(sqlQuery); |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Challan Details"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> step2( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String cinfoid, |
||||
|
String depotid, |
||||
|
String latitude, |
||||
|
String longitude, |
||||
|
String zone, |
||||
|
String ward, |
||||
|
String streeId, |
||||
|
String streetName, |
||||
|
String loginId, |
||||
|
String remarks, |
||||
|
MultipartFile file) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
int lastInsertId = 0; |
||||
|
|
||||
|
String image = fileUpload("cc_step2",cinfoid,file); |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO `cc_step2`(`cinfoid`,`image`, `latitude`, `longitude`, " |
||||
|
+ "`zone`, `ward`, `streetid`, `streetname`, `in_by`,`remarks`,`depotid`) " |
||||
|
//+ "`violator_info`, `violator_name`, `violator_phone`, `ton`) " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcPenaltyTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
||||
|
ps.setString(1, cinfoid); |
||||
|
ps.setString(2, image); |
||||
|
ps.setString(3, latitude); |
||||
|
ps.setString(4, longitude); |
||||
|
ps.setString(5, zone); |
||||
|
ps.setString(6, ward); |
||||
|
ps.setString(7, streeId); |
||||
|
ps.setString(8, streetName); |
||||
|
ps.setString(9, loginId); |
||||
|
ps.setString(10, remarks); |
||||
|
ps.setString(11, depotid); |
||||
|
//ps.setString(11, isviolatorAvailable); |
||||
|
//ps.setString(12, violatorName); |
||||
|
//ps.setString(13, violatorPhone); |
||||
|
//ps.setString(14, ton); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
response.put("insertId", lastInsertId); |
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "Cattle successfully checked into the depot!"); |
||||
|
System.out.println("Cattle successfully checked into the depot! Insert ID: " + generatedId); |
||||
|
} else { |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", "Failed to checked into the depot"); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
System.out.println("Data Access Exception:"); |
||||
|
Throwable rootCause = e.getMostSpecificCause(); |
||||
|
if (rootCause instanceof SQLException) { |
||||
|
SQLException sqlException = (SQLException) rootCause; |
||||
|
System.out.println("SQL State: " + sqlException.getSQLState()); |
||||
|
System.out.println("Error Code: " + sqlException.getErrorCode()); |
||||
|
System.out.println("Message: " + sqlException.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", sqlException.getMessage()); |
||||
|
response.put("sqlState", sqlException.getSQLState()); |
||||
|
response.put("errorCode", sqlException.getErrorCode()); |
||||
|
} else { |
||||
|
System.out.println("Message: " + rootCause.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", rootCause.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> step2list( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String orderid) { |
||||
|
|
||||
|
String sqlQuery = "SELECT *, " |
||||
|
+ "CONCAT('"+fileBaseUrl+"/gccofficialapp/files',`image`) as imageurl " |
||||
|
+ " From `cc_step2` WHERE (`isactive`=1 AND `isdelete`=0) AND `status`='in'"; |
||||
|
|
||||
|
if(orderid!=null && !orderid.isEmpty() && !orderid.isBlank()) { |
||||
|
sqlQuery= sqlQuery +" "; |
||||
|
} |
||||
|
|
||||
|
//sqlQuery = sqlQuery + " LIMIT 1"; |
||||
|
|
||||
|
System.out.println(sqlQuery); |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Challan Details"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> step3( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String cinfoids, |
||||
|
String latitude, |
||||
|
String longitude, |
||||
|
String zone, |
||||
|
String ward, |
||||
|
String streeId, |
||||
|
String streetName, |
||||
|
String loginId, |
||||
|
String remarks, |
||||
|
//String isviolatorAvailable, |
||||
|
String violatorName, |
||||
|
String violatorPhone, |
||||
|
String fineAmount, |
||||
|
MultipartFile file) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
int lastInsertId = 0; |
||||
|
|
||||
|
String image = ""; |
||||
|
/*fileUpload("cc_step2",cinfoid,file);*/ |
||||
|
|
||||
|
String orderid = generateRandomString(); |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO `cc_step3`(`cinfoids`, `image`, `latitude`, `longitude`, " |
||||
|
+ "`zone`, `ward`, `streetid`, `streetname`, `challan_by`,`remarks`, " |
||||
|
+ " `violator_name`, `violator_phone`,`fine_amount`,`orderid`) " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcPenaltyTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
||||
|
ps.setString(1, String.join(",", cinfoids)); |
||||
|
ps.setString(2, image); |
||||
|
ps.setString(3, latitude); |
||||
|
ps.setString(4, longitude); |
||||
|
ps.setString(5, zone); |
||||
|
ps.setString(6, ward); |
||||
|
ps.setString(7, streeId); |
||||
|
ps.setString(8, streetName); |
||||
|
ps.setString(9, loginId); |
||||
|
ps.setString(10, remarks); |
||||
|
ps.setString(11, violatorName); |
||||
|
ps.setString(12, violatorPhone); |
||||
|
ps.setString(13, fineAmount); |
||||
|
ps.setString(14, orderid); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
response.put("insertId", lastInsertId); |
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "A new Penalty (Chellan) was generated successfully!"); |
||||
|
System.out.println("A new Penalty (Chellan) was generated successfully! Insert ID: " + generatedId); |
||||
|
|
||||
|
updateStep2(String.join(",", cinfoids),"challan"); |
||||
|
|
||||
|
} else { |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", "Failed to insert a new Penalty (Chellan)."); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
System.out.println("Data Access Exception:"); |
||||
|
Throwable rootCause = e.getMostSpecificCause(); |
||||
|
if (rootCause instanceof SQLException) { |
||||
|
SQLException sqlException = (SQLException) rootCause; |
||||
|
System.out.println("SQL State: " + sqlException.getSQLState()); |
||||
|
System.out.println("Error Code: " + sqlException.getErrorCode()); |
||||
|
System.out.println("Message: " + sqlException.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", sqlException.getMessage()); |
||||
|
response.put("sqlState", sqlException.getSQLState()); |
||||
|
response.put("errorCode", sqlException.getErrorCode()); |
||||
|
} else { |
||||
|
System.out.println("Message: " + rootCause.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", rootCause.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public String updateStep2(String cinfoid, String status) { |
||||
|
String sqlQuery = "UPDATE cc_step2 SET status = ? WHERE cinfoid IN ("+cinfoid+")"; |
||||
|
//System.out.println(sqlQuery); |
||||
|
jdbcPenaltyTemplate.update(sqlQuery, status); |
||||
|
return "success"; |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> getChallanPOSData( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String orderid, |
||||
|
String loginid) { |
||||
|
|
||||
|
String sqlQuery = "SELECT `cinfoids`," |
||||
|
//+ "CONCAT('"+fileBaseUrl+"/gccofficialapp/files',`image`) as imageurl, " |
||||
|
+ "`latitude`, `longitude`, `zone`, `ward`, " |
||||
|
+ "`challan_by`, `violator_name`, `violator_phone`, " |
||||
|
+ "`fine_amount`,`orderid`,`status` From `cc_step3` WHERE (`isactive`=1 AND `isdelete`=0) AND `status`='unpaid'"; |
||||
|
|
||||
|
if(orderid!=null && !orderid.isEmpty() && !orderid.isBlank()) { |
||||
|
sqlQuery= sqlQuery +" AND `orderid`='"+orderid+"'"; |
||||
|
} |
||||
|
if(loginid!=null && !loginid.isEmpty() && !loginid.isBlank()) { |
||||
|
sqlQuery= sqlQuery +" AND `challan_by`='"+loginid+"'"; |
||||
|
} |
||||
|
|
||||
|
//sqlQuery = sqlQuery + " LIMIT 1"; |
||||
|
|
||||
|
//System.out.println(sqlQuery); |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Challan Details"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
@Transactional |
@Transactional |
||||
public List<Map<String, Object>> getPenaltyTypeList() { |
|
||||
String SqlQuery = "SELECT `id`, `name`, `display_name` FROM `penalty_types` WHERE `isdelete`=0 AND `isactive`=1"; |
|
||||
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(SqlQuery); |
|
||||
|
public List<Map<String, Object>> storeBankTransaction(Map<String, Object> transactionData) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
int lastInsertId = 0; |
||||
|
|
||||
|
// Extract data from the JSON object |
||||
|
String transactionResponseStatus = (String) transactionData.get("transactionResponseStatus"); |
||||
|
|
||||
|
// Check if the transaction was successful |
||||
|
if ("Transaction success".equalsIgnoreCase(transactionResponseStatus)) { |
||||
|
|
||||
|
String mid = (String) transactionData.get("mid"); |
||||
|
String tid = (String) transactionData.get("tid"); |
||||
|
String txnId = (String) transactionData.get("txnId"); |
||||
|
|
||||
|
// Fetch nested transaction response data |
||||
|
Map<String, Object> txnResponseData = (Map<String, Object>) transactionData.get("txnResponseData"); |
||||
|
|
||||
|
String bankName = (String) txnResponseData.get("bankName"); |
||||
|
String batchNumber = (String) txnResponseData.get("batchNumber"); |
||||
|
String transactionTitle = (String) txnResponseData.get("transactionTitle"); |
||||
|
String txnAID = (String) txnResponseData.get("txnAID"); |
||||
|
String txnApprCode = (String) txnResponseData.get("txnApprCode"); |
||||
|
String txnCardNo = (String) txnResponseData.get("txnCardNo"); |
||||
|
String txnCardType = (String) txnResponseData.get("txnCardType"); |
||||
|
String txnDate = (String) txnResponseData.get("txnDate"); |
||||
|
String txnInvoice = (String) txnResponseData.get("txnInvoice"); |
||||
|
String txnMode = (String) txnResponseData.get("txnMode"); |
||||
|
String txnRefNo = (String) txnResponseData.get("txnRefNo"); |
||||
|
String txnTC = (String) txnResponseData.get("txnTC"); |
||||
|
String txnTSI = (String) txnResponseData.get("txnTSI"); |
||||
|
String txnTVR = (String) txnResponseData.get("txnTVR"); |
||||
|
String txnTime = (String) txnResponseData.get("txnTime"); |
||||
|
|
||||
|
// Convert transaction amount properly |
||||
|
Double transactionAmount = Double.valueOf((String) txnResponseData.get("transactionAmount")); |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO bank_transactions (mid, tid, txnId, bankName, batchNumber, transactionAmount, " |
||||
|
+ "transactionTitle, txnAID, txnApprCode, txnCardNo, txnCardType, txnDate, txnInvoice, txnMode, txnRefNo, " |
||||
|
+ "txnTC, txnTSI, txnTVR, txnTime) " |
||||
|
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcPenaltyTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
||||
|
ps.setString(1, mid); |
||||
|
ps.setString(2, tid); |
||||
|
ps.setString(3, txnId); |
||||
|
ps.setString(4, bankName); |
||||
|
ps.setString(5, batchNumber); |
||||
|
ps.setDouble(6, transactionAmount); |
||||
|
ps.setString(7, transactionTitle); |
||||
|
ps.setString(8, txnAID); |
||||
|
ps.setString(9, txnApprCode); |
||||
|
ps.setString(10, txnCardNo); |
||||
|
ps.setString(11, txnCardType); |
||||
|
ps.setString(12, txnDate); |
||||
|
ps.setString(13, txnInvoice); |
||||
|
ps.setString(14, txnMode); |
||||
|
ps.setString(15, txnRefNo); |
||||
|
ps.setString(16, txnTC); |
||||
|
ps.setString(17, txnTSI); |
||||
|
ps.setString(18, txnTVR); |
||||
|
ps.setString(19, txnTime); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
|
||||
|
updatePaymentStatus(txnId, transactionResponseStatus); |
||||
|
|
||||
|
// Fetch inserted data for response, joining `penalty_challan` and `bank_transactions` |
||||
|
String sqlQuery_joined = "SELECT pc.category_id, CONCAT('" + fileBaseUrl + "/gccofficialapp/files', pc.image) as imageurl, " |
||||
|
+ "pc.latitude, pc.longitude, pc.zone, pc.ward, pc.challan_by, " |
||||
|
+ "pc.violator_name, pc.violator_phone, pc.fine_amount, pc.orderid, pc.status, " |
||||
|
+ "bt.mid, bt.tid, bt.txnId, bt.bankName, bt.batchNumber, bt.transactionAmount, bt.transactionTitle, " |
||||
|
+ "bt.txnCardNo, bt.txnDate, bt.txnInvoice, bt.txnMode, bt.txnRefNo " |
||||
|
+ "FROM cc_step3 pc " |
||||
|
+ "LEFT JOIN bank_transactions bt ON pc.orderid = bt.txnId " |
||||
|
+ "WHERE pc.isactive = 1 AND pc.isdelete = 0 AND bt.id = ? LIMIT 1"; |
||||
|
System.out.println(sqlQuery_joined); |
||||
|
// Execute the query |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery_joined, lastInsertId); |
||||
|
|
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Transaction stored successfully!"); |
||||
|
response.put("data", result); |
||||
|
} else { |
||||
|
response.put("status", 201); |
||||
|
response.put("message", "Failed to store the transaction."); |
||||
|
response.put("data", ""); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
response.put("status", 500); |
||||
|
response.put("message", "Database error while storing transaction."); |
||||
|
response.put("error", e.getMessage()); |
||||
|
e.printStackTrace(); // This will give you more detail in logs |
||||
|
} |
||||
|
} else { |
||||
|
response.put("status", 400); |
||||
|
response.put("message", "Transaction failed or invalid status."); |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public String updatePaymentStatus(String orderid, String status) { |
||||
|
String sqlQuery = "UPDATE cc_step3 SET status = ? WHERE orderid = ? LIMIT 1"; |
||||
|
jdbcPenaltyTemplate.update(sqlQuery, status, orderid); |
||||
|
return "success"; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> step3list( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String loginid) { |
||||
|
|
||||
|
String sqlQuery = "SELECT *, " |
||||
|
+ "CONCAT('"+fileBaseUrl+"/gccofficialapp/files',`image`) as imageurl " |
||||
|
+ " From `cc_step3` WHERE (`isactive`=1 AND `isdelete`=0) AND `status`<>'unpaid'"; |
||||
|
|
||||
|
if(loginid!=null && !loginid.isEmpty() && !loginid.isBlank()) { |
||||
|
sqlQuery= sqlQuery +" AND `challan_by`='"+loginid+"'"; |
||||
|
} |
||||
|
|
||||
|
//sqlQuery = sqlQuery + " LIMIT 1"; |
||||
|
|
||||
|
//System.out.println(sqlQuery); |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Challan Details"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> step4( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String cinfoid, |
||||
|
String latitude, |
||||
|
String longitude, |
||||
|
String zone, |
||||
|
String ward, |
||||
|
String streeId, |
||||
|
String streetName, |
||||
|
String loginId, |
||||
|
String remarks, |
||||
|
MultipartFile file) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
int lastInsertId = 0; |
||||
|
|
||||
|
String image = fileUpload("cc_step2",cinfoid,file); |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO `cc_step4`(`cinfoid`,`image`, `latitude`, `longitude`, " |
||||
|
+ "`zone`, `ward`, `streetid`, `streetname`, `out_by`,`remarks`) " |
||||
|
//+ "`violator_info`, `violator_name`, `violator_phone`, `ton`) " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcPenaltyTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
||||
|
ps.setString(1, cinfoid); |
||||
|
ps.setString(2, image); |
||||
|
ps.setString(3, latitude); |
||||
|
ps.setString(4, longitude); |
||||
|
ps.setString(5, zone); |
||||
|
ps.setString(6, ward); |
||||
|
ps.setString(7, streeId); |
||||
|
ps.setString(8, streetName); |
||||
|
ps.setString(9, loginId); |
||||
|
ps.setString(10, remarks); |
||||
|
//ps.setString(11, isviolatorAvailable); |
||||
|
//ps.setString(12, violatorName); |
||||
|
//ps.setString(13, violatorPhone); |
||||
|
//ps.setString(14, ton); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
response.put("insertId", lastInsertId); |
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "Cattle successfully checked out from the depot!"); |
||||
|
System.out.println("Cattle successfully checked out from the depot! Insert ID: " + generatedId); |
||||
|
} else { |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", "Failed to checked out from the depot"); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
System.out.println("Data Access Exception:"); |
||||
|
Throwable rootCause = e.getMostSpecificCause(); |
||||
|
if (rootCause instanceof SQLException) { |
||||
|
SQLException sqlException = (SQLException) rootCause; |
||||
|
System.out.println("SQL State: " + sqlException.getSQLState()); |
||||
|
System.out.println("Error Code: " + sqlException.getErrorCode()); |
||||
|
System.out.println("Message: " + sqlException.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", sqlException.getMessage()); |
||||
|
response.put("sqlState", sqlException.getSQLState()); |
||||
|
response.put("errorCode", sqlException.getErrorCode()); |
||||
|
} else { |
||||
|
System.out.println("Message: " + rootCause.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", rootCause.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> zoneReport( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String fromDate, |
||||
|
String toDate, |
||||
|
String loginid) { |
||||
|
|
||||
|
String sqlQuery = "SELECT zone, COUNT(*) AS zone_count FROM `cc_step1` WHERE " |
||||
|
+ "DATE(catch_date) BETWEEN ? AND ? GROUP BY zone ORDER BY zone"; |
||||
|
|
||||
|
if(loginid!=null && !loginid.isEmpty() && !loginid.isBlank()) { |
||||
|
sqlQuery= sqlQuery +" AND `challan_by`='"+loginid+"'"; |
||||
|
} |
||||
|
|
||||
|
//System.out.println(sqlQuery); |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery,fromDate,toDate); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Challan Details"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> wardReport( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String zone, |
||||
|
String fromDate, |
||||
|
String toDate, |
||||
|
String loginid) { |
||||
|
|
||||
|
String sqlQuery = "SELECT ward, COUNT(*) AS zone_count FROM `cc_step1` WHERE " |
||||
|
+ "zone=? AND DATE(catch_date) BETWEEN ? AND ? GROUP BY ward ORDER BY ward"; |
||||
|
|
||||
|
if(loginid!=null && !loginid.isEmpty() && !loginid.isBlank()) { |
||||
|
sqlQuery= sqlQuery +" AND `challan_by`='"+loginid+"'"; |
||||
|
} |
||||
|
|
||||
|
//System.out.println(sqlQuery); |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery,zone,fromDate,toDate); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Challan Details"); |
||||
|
response.put("data", result); |
||||
|
|
||||
return result; |
return result; |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,649 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.penalty.service; |
||||
|
|
||||
|
import java.awt.image.BufferedImage; |
||||
|
import java.io.ByteArrayInputStream; |
||||
|
import java.io.ByteArrayOutputStream; |
||||
|
import java.io.IOException; |
||||
|
import java.nio.file.Files; |
||||
|
import java.nio.file.Path; |
||||
|
import java.nio.file.Paths; |
||||
|
import java.security.SecureRandom; |
||||
|
import java.sql.Connection; |
||||
|
import java.sql.PreparedStatement; |
||||
|
import java.sql.SQLException; |
||||
|
import java.time.LocalDate; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.time.format.DateTimeParseException; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Collections; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Random; |
||||
|
|
||||
|
import javax.imageio.ImageIO; |
||||
|
import javax.imageio.ImageWriteParam; |
||||
|
import javax.imageio.ImageWriter; |
||||
|
import javax.imageio.stream.ImageOutputStream; |
||||
|
import javax.sql.DataSource; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.beans.factory.annotation.Qualifier; |
||||
|
import org.springframework.core.env.Environment; |
||||
|
import org.springframework.dao.DataAccessException; |
||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.jdbc.core.PreparedStatementCreator; |
||||
|
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.util.MultiValueMap; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import in.gov.chennaicorporation.mobileservice.gccactivity.service.DateTimeUtil; |
||||
|
|
||||
|
@Service |
||||
|
public class PenaltyServicePOS { |
||||
|
private JdbcTemplate jdbcPenaltyTemplate; |
||||
|
private final Environment environment; |
||||
|
private String fileBaseUrl; |
||||
|
|
||||
|
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
||||
|
private static final int STRING_LENGTH = 15; |
||||
|
private static final Random RANDOM = new SecureRandom(); |
||||
|
|
||||
|
@Autowired |
||||
|
public void setDataSource(@Qualifier("mysqlPenaltyDataSource") DataSource penaltyDataSource) { |
||||
|
this.jdbcPenaltyTemplate = new JdbcTemplate(penaltyDataSource); |
||||
|
} |
||||
|
|
||||
|
@Autowired |
||||
|
public PenaltyServicePOS(Environment environment) { |
||||
|
this.environment = environment; |
||||
|
this.fileBaseUrl=environment.getProperty("fileBaseUrl"); |
||||
|
} |
||||
|
|
||||
|
public static String generateRandomString() { |
||||
|
StringBuilder result = new StringBuilder(STRING_LENGTH); |
||||
|
for (int i = 0; i < STRING_LENGTH; i++) { |
||||
|
result.append(CHARACTERS.charAt(RANDOM.nextInt(CHARACTERS.length()))); |
||||
|
} |
||||
|
return result.toString(); |
||||
|
} |
||||
|
|
||||
|
// Function to convert date string from dd-MM-yyyy to yyyy-MM-dd |
||||
|
public static String convertDateFormat(String inputDate, int add) { |
||||
|
// Check if the inputDate is not null or blank |
||||
|
if (inputDate != null && !inputDate.isBlank()) { |
||||
|
try { |
||||
|
// Define the input and output date formats |
||||
|
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
||||
|
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
||||
|
|
||||
|
// Parse the input date string to LocalDate |
||||
|
LocalDate date = LocalDate.parse(inputDate, inputFormatter); |
||||
|
|
||||
|
// Add the specified number of days to the date if 'add' is greater than 0 |
||||
|
if (add > 0) { |
||||
|
date = date.plusDays(add); |
||||
|
} |
||||
|
|
||||
|
// Format the date to the new format |
||||
|
return date.format(outputFormatter); |
||||
|
|
||||
|
} catch (DateTimeParseException e) { |
||||
|
// Handle the case where the input date is invalid |
||||
|
System.out.println("Invalid date format: " + inputDate); |
||||
|
return ""; |
||||
|
} |
||||
|
} else { |
||||
|
return ""; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private byte[] compressImage(BufferedImage image, float quality) throws IOException { |
||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
||||
|
ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(byteArrayOutputStream); |
||||
|
|
||||
|
ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next(); |
||||
|
writer.setOutput(imageOutputStream); |
||||
|
|
||||
|
ImageWriteParam param = writer.getDefaultWriteParam(); |
||||
|
if (param.canWriteCompressed()) { |
||||
|
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
||||
|
param.setCompressionQuality(quality); |
||||
|
} |
||||
|
|
||||
|
writer.write(null, new javax.imageio.IIOImage(image, null, null), param); |
||||
|
|
||||
|
writer.dispose(); |
||||
|
imageOutputStream.close(); |
||||
|
|
||||
|
return byteArrayOutputStream.toByteArray(); |
||||
|
} |
||||
|
|
||||
|
public String fileUpload(String name, String id, MultipartFile file) { |
||||
|
|
||||
|
int lastInsertId = 0; |
||||
|
// Set the file path where you want to save it |
||||
|
String uploadDirectory = environment.getProperty("file.upload.directory"); |
||||
|
String serviceFolderName = environment.getProperty("penalty_foldername"); |
||||
|
var year =DateTimeUtil.getCurrentYear(); |
||||
|
var month =DateTimeUtil.getCurrentMonth(); |
||||
|
|
||||
|
uploadDirectory = uploadDirectory + serviceFolderName +"pos/"+ year +"/"+month+"/"; |
||||
|
|
||||
|
try { |
||||
|
// Create directory if it doesn't exist |
||||
|
Path directoryPath = Paths.get(uploadDirectory); |
||||
|
if (!Files.exists(directoryPath)) { |
||||
|
Files.createDirectories(directoryPath); |
||||
|
} |
||||
|
|
||||
|
// Datetime string |
||||
|
String datetimetxt = DateTimeUtil.getCurrentDateTime(); |
||||
|
// File name |
||||
|
String fileName = name+ "_" +id + "_" + datetimetxt + "_" + file.getOriginalFilename(); |
||||
|
fileName = fileName.replaceAll("\\s+", ""); // Remove space on filename |
||||
|
|
||||
|
String filePath = uploadDirectory + "/" + fileName; |
||||
|
|
||||
|
String filepath_txt = "/"+serviceFolderName +"pos/"+ year +"/"+month+"/"+fileName; |
||||
|
|
||||
|
// Create a new Path object |
||||
|
Path path = Paths.get(filePath); |
||||
|
|
||||
|
// Get the bytes of the file |
||||
|
byte[] bytes = file.getBytes(); |
||||
|
|
||||
|
// Compress the image |
||||
|
BufferedImage image = ImageIO.read(new ByteArrayInputStream(bytes)); |
||||
|
byte[] compressedBytes = compressImage(image, 0.5f); // Compress with 50% quality |
||||
|
|
||||
|
// Write the bytes to the file |
||||
|
Files.write(path, bytes); |
||||
|
|
||||
|
System.out.println(filePath); |
||||
|
return filepath_txt; |
||||
|
|
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
return "Failed to save file " + file.getOriginalFilename(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//// POS //// |
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> getPenaltyDepartment() { |
||||
|
String sqlQuery = "SELECT * FROM `penalty_department` WHERE (`isactive`=1 AND `isdelete`=0) "; |
||||
|
sqlQuery = sqlQuery + " ORDER BY `display_order`, `name` ASC"; |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery); |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Department list"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> getPenaltyTypeList(String departmentId) { |
||||
|
String sqlQuery = "SELECT * FROM `penalty_category` WHERE (`isactive`=1 AND `isdelete`=0) "; |
||||
|
|
||||
|
if(departmentId!=null && !departmentId.isEmpty() && !departmentId.isBlank()) { |
||||
|
sqlQuery= sqlQuery +" AND `mappingid`='"+departmentId+"'"; |
||||
|
} |
||||
|
|
||||
|
//sqlQuery = sqlQuery + " ORDER BY `display_order`, `name` ASC"; |
||||
|
sqlQuery = sqlQuery + " ORDER BY `display_order` ASC"; |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery); |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Penalty category list"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> getPenaltyAmount(String categoryId, String ton) { |
||||
|
String sqlQuery = "SELECT * FROM `penalty_amount` WHERE (`isactive`=1 AND `isdelete`=0) "; |
||||
|
|
||||
|
if(categoryId!=null && !categoryId.isEmpty() && !categoryId.isBlank()) { |
||||
|
sqlQuery= sqlQuery +" AND `category_id`='"+categoryId+"'"; |
||||
|
} |
||||
|
if(ton!=null && !ton.isEmpty() && !ton.isBlank()) { |
||||
|
sqlQuery= sqlQuery +" AND `ton`='"+ton+"'"; |
||||
|
} |
||||
|
|
||||
|
sqlQuery = sqlQuery + ""; |
||||
|
|
||||
|
System.out.println(sqlQuery); |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery); |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Penalty amount details"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> getBankList() { |
||||
|
String sqlQuery = "SELECT `id`, `code`, `name`, `narration` FROM `bank_list` WHERE `isactive`=1 AND `isdelete`=0"; |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery); |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Bank list"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> getOfflineModeTypes() { |
||||
|
String sqlQuery = "SELECT `id`, `name` FROM `offline_mode_type` WHERE `isactive`=1 AND `isdelete`=0"; |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery); |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Offline mode types"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> generateChallanPOS( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String category_id, |
||||
|
String latitude, |
||||
|
String longitude, |
||||
|
String zone, |
||||
|
String ward, |
||||
|
String loginId, |
||||
|
String violatorName, |
||||
|
String violatorPhone, |
||||
|
String ton, |
||||
|
String amount, |
||||
|
MultipartFile file) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
int lastInsertId = 0; |
||||
|
String orderid = generateRandomString(); |
||||
|
String image = fileUpload("challan",category_id,file); |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO `penalty_challan`(`category_id`, `image`, `latitude`, `longitude`, " |
||||
|
+ "`zone`, `ward`, `challan_by`, " |
||||
|
+ "`violator_name`, `violator_phone`, `ton`, `fine_amount`,`orderid`) " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcPenaltyTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
||||
|
ps.setString(1, category_id); |
||||
|
ps.setString(2, image); |
||||
|
ps.setString(3, latitude); |
||||
|
ps.setString(4, longitude); |
||||
|
ps.setString(5, zone); |
||||
|
ps.setString(6, ward); |
||||
|
ps.setString(7, loginId); |
||||
|
ps.setString(8, violatorName); |
||||
|
ps.setString(9, violatorPhone); |
||||
|
ps.setString(10, ton); |
||||
|
ps.setString(11, amount); |
||||
|
ps.setString(12, orderid); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
//CONCAT('"+fileBaseUrl+"/gccofficialapp/files', cp.photo_url) AS photos, |
||||
|
String sqlQuery_txt = "SELECT `category_id`,CONCAT('"+fileBaseUrl+"/gccofficialapp/files',`image`) as imageurl, `latitude`, `longitude`, `zone`, `ward`, " |
||||
|
+ "`challan_by`, `violator_name`, `violator_phone`, `ton`, " |
||||
|
+ "`fine_amount`,`orderid` From `penalty_challan` WHERE id='"+lastInsertId+"' LIMIT 1"; |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery_txt); |
||||
|
|
||||
|
//response.put("insertid", lastInsertId); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "A new Penalty (Chellan) was generated successfully!"); |
||||
|
//response.put("orderid", orderid); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
System.out.println("A new Penalty (Chellan) was generated successfully! Insert ID: " + generatedId); |
||||
|
} else { |
||||
|
response.put("status", 201); |
||||
|
response.put("message", "Failed to insert a new Penalty (Chellan)."); |
||||
|
response.put("data", ""); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
System.out.println("Data Access Exception:"); |
||||
|
Throwable rootCause = e.getMostSpecificCause(); |
||||
|
if (rootCause instanceof SQLException) { |
||||
|
SQLException sqlException = (SQLException) rootCause; |
||||
|
System.out.println("SQL State: " + sqlException.getSQLState()); |
||||
|
System.out.println("Error Code: " + sqlException.getErrorCode()); |
||||
|
System.out.println("Message: " + sqlException.getMessage()); |
||||
|
response.put("status", 500); |
||||
|
response.put("message", "Database error while storing new Penalty (Chellan)."); |
||||
|
response.put("error", e.getMessage()); |
||||
|
} else { |
||||
|
System.out.println("Message: " + rootCause.getMessage()); |
||||
|
response.put("status", 400); |
||||
|
response.put("message", "Failed to insert a new Penalty (Chellan)."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> getChallanPOSData( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String orderid, |
||||
|
String id) { |
||||
|
|
||||
|
String sqlQuery = "SELECT `category_id`,CONCAT('"+fileBaseUrl+"/gccofficialapp/files',`image`) as imageurl, `latitude`, `longitude`, `zone`, `ward`, " |
||||
|
+ "`challan_by`, `violator_name`, `violator_phone`, `ton`, " |
||||
|
+ "`fine_amount`,`orderid`,`status` From `penalty_challan` WHERE (`isactive`=1 AND `isdelete`=0) "; |
||||
|
|
||||
|
if(orderid!=null && !orderid.isEmpty() && !orderid.isBlank()) { |
||||
|
sqlQuery= sqlQuery +" AND `orderid`='"+orderid+"'"; |
||||
|
} |
||||
|
if(id!=null && !id.isEmpty() && !id.isBlank()) { |
||||
|
sqlQuery= sqlQuery +" AND `id`='"+id+"'"; |
||||
|
} |
||||
|
|
||||
|
sqlQuery = sqlQuery + " LIMIT 1"; |
||||
|
|
||||
|
//System.out.println(sqlQuery); |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Challan Details"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
/* |
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> updateOrderDetails( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String orderid, |
||||
|
String id) { |
||||
|
|
||||
|
String paymentStatus = "paid"; |
||||
|
|
||||
|
String sqlQuery = "UPDATE `penalty_challan` SET `status`='"+paymentStatus+"'"; |
||||
|
|
||||
|
if(orderid!=null && !orderid.isEmpty() && !orderid.isBlank()) { |
||||
|
sqlQuery= sqlQuery +" AND `orderid`='"+orderid+"'"; |
||||
|
} |
||||
|
|
||||
|
sqlQuery = sqlQuery + " LIMIT 1"; |
||||
|
|
||||
|
System.out.println(sqlQuery); |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery); |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
//response.put("insertid", lastInsertId); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Payment Status updated successfully!"); |
||||
|
response.put("orderid", orderid); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> storeBankTransaction(Map<String, Object> transactionData) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
int lastInsertId = 0; |
||||
|
|
||||
|
// Extract data from the JSON object |
||||
|
String transactionResponseStatus = (String) transactionData.get("transactionResponseStatus"); |
||||
|
|
||||
|
// Check if the transaction was successful |
||||
|
if ("Transaction success".equalsIgnoreCase(transactionResponseStatus)) { |
||||
|
|
||||
|
String mid = (String) transactionData.get("mid"); |
||||
|
String tid = (String) transactionData.get("tid"); |
||||
|
String txnId = (String) transactionData.get("txnId"); |
||||
|
|
||||
|
// Fetch nested transaction response data |
||||
|
Map<String, Object> txnResponseData = (Map<String, Object>) transactionData.get("txnResponseData"); |
||||
|
|
||||
|
String bankName = (String) txnResponseData.get("bankName"); |
||||
|
String batchNumber = (String) txnResponseData.get("batchNumber"); |
||||
|
String transactionTitle = (String) txnResponseData.get("transactionTitle"); |
||||
|
String txnAID = (String) txnResponseData.get("txnAID"); |
||||
|
String txnApprCode = (String) txnResponseData.get("txnApprCode"); |
||||
|
String txnCardNo = (String) txnResponseData.get("txnCardNo"); |
||||
|
String txnCardType = (String) txnResponseData.get("txnCardType"); |
||||
|
String txnDate = (String) txnResponseData.get("txnDate"); |
||||
|
String txnInvoice = (String) txnResponseData.get("txnInvoice"); |
||||
|
String txnMode = (String) txnResponseData.get("txnMode"); |
||||
|
String txnRefNo = (String) txnResponseData.get("txnRefNo"); |
||||
|
String txnTC = (String) txnResponseData.get("txnTC"); |
||||
|
String txnTSI = (String) txnResponseData.get("txnTSI"); |
||||
|
String txnTVR = (String) txnResponseData.get("txnTVR"); |
||||
|
String txnTime = (String) txnResponseData.get("txnTime"); |
||||
|
|
||||
|
// Convert transaction amount properly |
||||
|
Double transactionAmount = Double.valueOf((String) txnResponseData.get("transactionAmount")); |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO bank_transactions (mid, tid, txnId, bankName, batchNumber, transactionAmount, " |
||||
|
+ "transactionTitle, txnAID, txnApprCode, txnCardNo, txnCardType, txnDate, txnInvoice, txnMode, txnRefNo, " |
||||
|
+ "txnTC, txnTSI, txnTVR, txnTime) " |
||||
|
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcPenaltyTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
||||
|
ps.setString(1, mid); |
||||
|
ps.setString(2, tid); |
||||
|
ps.setString(3, txnId); |
||||
|
ps.setString(4, bankName); |
||||
|
ps.setString(5, batchNumber); |
||||
|
ps.setDouble(6, transactionAmount); |
||||
|
ps.setString(7, transactionTitle); |
||||
|
ps.setString(8, txnAID); |
||||
|
ps.setString(9, txnApprCode); |
||||
|
ps.setString(10, txnCardNo); |
||||
|
ps.setString(11, txnCardType); |
||||
|
ps.setString(12, txnDate); |
||||
|
ps.setString(13, txnInvoice); |
||||
|
ps.setString(14, txnMode); |
||||
|
ps.setString(15, txnRefNo); |
||||
|
ps.setString(16, txnTC); |
||||
|
ps.setString(17, txnTSI); |
||||
|
ps.setString(18, txnTVR); |
||||
|
ps.setString(19, txnTime); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
|
||||
|
updatePaymentStatus(txnId, transactionResponseStatus); |
||||
|
|
||||
|
// Fetch inserted data for response, joining `penalty_challan` and `bank_transactions` |
||||
|
String sqlQuery_joined = "SELECT pc.category_id, CONCAT('" + fileBaseUrl + "/gccofficialapp/files', pc.image) as imageurl, " |
||||
|
+ "pc.latitude, pc.longitude, pc.zone, pc.ward, pc.challan_by, " |
||||
|
+ "pc.violator_name, pc.violator_phone, pc.ton, pc.fine_amount, pc.orderid, pc.status, " |
||||
|
+ "bt.mid, bt.tid, bt.txnId, bt.bankName, bt.batchNumber, bt.transactionAmount, bt.transactionTitle, " |
||||
|
+ "bt.txnCardNo, bt.txnDate, bt.txnInvoice, bt.txnMode, bt.txnRefNo " |
||||
|
+ "FROM penalty_challan pc " |
||||
|
+ "LEFT JOIN bank_transactions bt ON pc.orderid = bt.txnId " |
||||
|
+ "WHERE pc.isactive = 1 AND pc.isdelete = 0 AND bt.id = ? LIMIT 1"; |
||||
|
System.out.println(sqlQuery_joined); |
||||
|
// Execute the query |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery_joined, lastInsertId); |
||||
|
/* |
||||
|
// Fetch inserted data for response |
||||
|
String sqlQuery_challan = "SELECT `category_id`,CONCAT('"+fileBaseUrl+"/gccofficialapp/files',`image`) as imageurl, `latitude`, `longitude`, `zone`, `ward`, " |
||||
|
+ "`challan_by`, `violator_name`, `violator_phone`, `ton`, " |
||||
|
+ "`fine_amount`, `orderid`, `status` From `penalty_challan` WHERE (`isactive`=1 AND `isdelete`=0) " |
||||
|
+ "AND `orderid`='"+txnId+"' LIMIT 1"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery_challan, lastInsertId); |
||||
|
|
||||
|
// Fetch inserted data for response |
||||
|
String sqlQuery_txt = "SELECT mid, tid, txnId, bankName, batchNumber, transactionAmount, " |
||||
|
+ "transactionTitle, txnCardNo, txnDate, txnInvoice, txnMode, txnRefNo " |
||||
|
+ "FROM bank_transactions WHERE id = ? LIMIT 1"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery_txt, lastInsertId); |
||||
|
*/ |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Transaction stored successfully!"); |
||||
|
response.put("data", result); |
||||
|
} else { |
||||
|
response.put("status", 201); |
||||
|
response.put("message", "Failed to store the transaction."); |
||||
|
response.put("data", ""); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
response.put("status", 500); |
||||
|
response.put("message", "Database error while storing transaction."); |
||||
|
response.put("error", e.getMessage()); |
||||
|
e.printStackTrace(); // This will give you more detail in logs |
||||
|
} |
||||
|
} else { |
||||
|
response.put("status", 400); |
||||
|
response.put("message", "Transaction failed or invalid status."); |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public String updatePaymentStatus(String orderid, String status) { |
||||
|
String sqlQuery = "UPDATE penalty_challan SET status = ? WHERE orderid = ? LIMIT 1"; |
||||
|
jdbcPenaltyTemplate.update(sqlQuery, status, orderid); |
||||
|
return "success"; |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> storeOfflineTransaction( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String transactionResponseStatus, |
||||
|
String bankName, |
||||
|
String transactionAmount, |
||||
|
String txnDate, |
||||
|
String txnTime, |
||||
|
String branchname, |
||||
|
String extraInfo, |
||||
|
String extraInfo2, |
||||
|
String extraInfo3, |
||||
|
String txnMode, |
||||
|
String txnId, |
||||
|
MultipartFile file) { |
||||
|
|
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
int lastInsertId = 0; |
||||
|
String orderid = generateRandomString(); |
||||
|
|
||||
|
String image = fileUpload("offline",extraInfo,file); |
||||
|
|
||||
|
// Convert transaction amount properly |
||||
|
Double transactionAmount_d = Double.valueOf(transactionAmount); // Corrected line |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO `bank_transactions`(`transactionResponseStatus`, `bankName`, `transactionAmount`, " |
||||
|
+ "`txnDate`, `txnTime`, `branchname`,`extraInfo`,`extraInfo2`, `extraInfo3`,`txnMode`, `txnId`,`file`) " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcPenaltyTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); |
||||
|
ps.setString(1, transactionResponseStatus); |
||||
|
ps.setString(2, bankName); |
||||
|
ps.setString(3, transactionAmount); |
||||
|
ps.setString(4, txnDate); |
||||
|
ps.setString(5, txnTime); |
||||
|
ps.setString(6, branchname); |
||||
|
ps.setString(7, extraInfo); |
||||
|
ps.setString(8, extraInfo2); |
||||
|
ps.setString(9, extraInfo3); |
||||
|
ps.setString(10, txnMode); |
||||
|
ps.setString(11, txnId); |
||||
|
ps.setString(12, image); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
|
||||
|
updatePaymentStatus(txnId, transactionResponseStatus); |
||||
|
|
||||
|
// Fetch inserted data for response, joining `penalty_challan` and `bank_transactions` |
||||
|
String sqlQuery_joined = "SELECT pc.category_id, CONCAT('" + fileBaseUrl + "/gccofficialapp/files', pc.image) as imageurl, " |
||||
|
+ "pc.latitude, pc.longitude, pc.zone, pc.ward, pc.challan_by, " |
||||
|
+ "pc.violator_name, pc.violator_phone, pc.ton, pc.fine_amount, pc.orderid, pc.status, " |
||||
|
+ "bt.mid, bt.tid, bt.txnId, bt.bankName, bt.batchNumber, bt.transactionAmount, bt.transactionTitle, " |
||||
|
+ "bt.txnCardNo, bt.txnDate, bt.txnInvoice, bt.txnMode, bt.txnRefNo, " |
||||
|
+ "bt.branchname, bt.extraInfo, bt.extraInfo2, bt.extraInfo3, CONCAT('" + fileBaseUrl + "/gccofficialapp/files', bt.file) as offlineimageurl " |
||||
|
+ "FROM penalty_challan pc " |
||||
|
+ "LEFT JOIN bank_transactions bt ON pc.orderid = bt.txnId " |
||||
|
+ "WHERE pc.isactive = 1 AND pc.isdelete = 0 AND bt.id = ? LIMIT 1"; |
||||
|
System.out.println(sqlQuery_joined); |
||||
|
// Execute the query |
||||
|
List<Map<String, Object>> result = jdbcPenaltyTemplate.queryForList(sqlQuery_joined, lastInsertId); |
||||
|
|
||||
|
//response.put("insertid", lastInsertId); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "A new Penalty (Chellan) was generated successfully!"); |
||||
|
//response.put("orderid", orderid); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
System.out.println("Transaction stored successfully!"); |
||||
|
} else { |
||||
|
response.put("status", 201); |
||||
|
response.put("message", "Failed to store the transaction."); |
||||
|
response.put("data", ""); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
System.out.println("Data Access Exception:"); |
||||
|
Throwable rootCause = e.getMostSpecificCause(); |
||||
|
if (rootCause instanceof SQLException) { |
||||
|
SQLException sqlException = (SQLException) rootCause; |
||||
|
System.out.println("SQL State: " + sqlException.getSQLState()); |
||||
|
System.out.println("Error Code: " + sqlException.getErrorCode()); |
||||
|
System.out.println("Message: " + sqlException.getMessage()); |
||||
|
response.put("status", 500); |
||||
|
response.put("message", "Database error while storing transaction."); |
||||
|
response.put("error", e.getMessage()); |
||||
|
} else { |
||||
|
System.out.println("Message: " + rootCause.getMessage()); |
||||
|
response.put("status", 400); |
||||
|
response.put("message", "Transaction failed or invalid status."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.service; |
||||
|
|
||||
|
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.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
@Service |
||||
|
public class MainService { |
||||
|
private JdbcTemplate jdbcMainTemplate; |
||||
|
@Autowired |
||||
|
public void setDataSource( |
||||
|
@Qualifier("mysqlActivityDataSource") DataSource activityDataSource) { |
||||
|
this.jdbcMainTemplate = new JdbcTemplate(activityDataSource); |
||||
|
} |
||||
|
/* |
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> versionCheck() { |
||||
|
String sqlQuery = "SELECT * FROM `app_version` WHERE `isactive`=1 LIMIT 1"; |
||||
|
List<Map<String, Object>> result = jdbcMainTemplate.queryForList(sqlQuery); |
||||
|
return result; |
||||
|
} |
||||
|
*/ |
||||
|
} |
||||
@ -0,0 +1,76 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.swmbwg.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import in.gov.chennaicorporation.mobileservice.swmbwg.service.activity; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/api/swmbwg/") |
||||
|
@RestController("gccofficialappswmbwg") |
||||
|
public class APIController { |
||||
|
@Autowired |
||||
|
private activity activity; |
||||
|
|
||||
|
@GetMapping(value="/getClass") |
||||
|
public List<?> getAllClass(){ |
||||
|
return activity.getAllClass(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getBWGTypes") |
||||
|
public List<?> getBWGTypes(){ |
||||
|
return activity.getBWGTypes(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getServiceProviderList") |
||||
|
public List<?> getServiceProviderList(){ |
||||
|
return activity.getServiceProviderList(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/saveRequest") |
||||
|
public List<?> saveRequest( |
||||
|
@RequestParam(value="latitude", required = false) String latitude, |
||||
|
@RequestParam(value="longitude", required = false) String longitude, |
||||
|
@RequestParam(value="zone", required = false) String zone, |
||||
|
@RequestParam(value="ward", required = false) String ward, |
||||
|
@RequestParam(value="streetid", required = false) String streetid, |
||||
|
@RequestParam(value="streetname", required = false) String streetname, |
||||
|
@RequestParam(value="location", required = false) String location, |
||||
|
@RequestParam(value="classid", required = false) String classid, |
||||
|
@RequestParam(value="typeid", required = false) String typeid, |
||||
|
@RequestParam(value="qtyofwaste", required = false) String qtyofwaste, |
||||
|
@RequestParam(value="onsiteprocessing", required = false) String onsiteprocessing, |
||||
|
@RequestParam(value="serviceprovider", required = false) String serviceprovider, |
||||
|
@RequestParam(value="serviceproviderid", required = false) String serviceproviderid, |
||||
|
@RequestParam(value="loginId", required = false) String cby, |
||||
|
@RequestParam(value = "image", required = false) MultipartFile filedata |
||||
|
){ |
||||
|
return activity.saveRequest(latitude, longitude, |
||||
|
zone, ward, streetid, streetname, location, classid, |
||||
|
typeid, qtyofwaste, onsiteprocessing, serviceprovider, |
||||
|
serviceproviderid, cby, filedata); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getZoneWiseCount") |
||||
|
public List<?> getZoneWiseCount(){ |
||||
|
return activity.getZoneWiseCount(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getWardWiseCount") |
||||
|
public List<?> getWardWiseCount(@RequestParam(value="zone", required = true) String zone){ |
||||
|
return activity.getWardWiseCount(zone); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getReport") |
||||
|
public List<?> getReport(@RequestParam(value="ward", required = true) String ward){ |
||||
|
return activity.getReport(ward); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.swmbwg.controller; |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.swmbwg; |
||||
@ -0,0 +1,324 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.swmbwg.service; |
||||
|
|
||||
|
import java.awt.image.BufferedImage; |
||||
|
import java.io.ByteArrayInputStream; |
||||
|
import java.io.ByteArrayOutputStream; |
||||
|
import java.io.IOException; |
||||
|
import java.nio.file.Files; |
||||
|
import java.nio.file.Path; |
||||
|
import java.nio.file.Paths; |
||||
|
import java.security.SecureRandom; |
||||
|
import java.sql.Connection; |
||||
|
import java.sql.PreparedStatement; |
||||
|
import java.sql.SQLException; |
||||
|
import java.util.Collections; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Random; |
||||
|
|
||||
|
import javax.imageio.ImageIO; |
||||
|
import javax.imageio.ImageWriteParam; |
||||
|
import javax.imageio.ImageWriter; |
||||
|
import javax.imageio.stream.ImageOutputStream; |
||||
|
import javax.sql.DataSource; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.beans.factory.annotation.Qualifier; |
||||
|
import org.springframework.core.env.Environment; |
||||
|
import org.springframework.dao.DataAccessException; |
||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||
|
import org.springframework.jdbc.core.PreparedStatementCreator; |
||||
|
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.util.MultiValueMap; |
||||
|
import org.springframework.web.multipart.MultipartFile; |
||||
|
|
||||
|
import in.gov.chennaicorporation.mobileservice.gccactivity.service.DateTimeUtil; |
||||
|
|
||||
|
@Service("gccofficialappswmbwgactivity") |
||||
|
public class activity { |
||||
|
private JdbcTemplate jdbcBWGTemplate; |
||||
|
private final Environment environment; |
||||
|
private String fileBaseUrl; |
||||
|
|
||||
|
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
||||
|
private static final int STRING_LENGTH = 15; |
||||
|
private static final Random RANDOM = new SecureRandom(); |
||||
|
|
||||
|
@Autowired |
||||
|
public void setDataSource(@Qualifier("mysqlActivityDataSource") DataSource bwgDataSource) { |
||||
|
this.jdbcBWGTemplate = new JdbcTemplate(bwgDataSource); |
||||
|
} |
||||
|
|
||||
|
@Autowired |
||||
|
public activity(Environment environment) { |
||||
|
this.environment = environment; |
||||
|
this.fileBaseUrl=environment.getProperty("fileBaseUrl"); |
||||
|
} |
||||
|
|
||||
|
public static String generateRandomString() { |
||||
|
StringBuilder result = new StringBuilder(STRING_LENGTH); |
||||
|
for (int i = 0; i < STRING_LENGTH; i++) { |
||||
|
result.append(CHARACTERS.charAt(RANDOM.nextInt(CHARACTERS.length()))); |
||||
|
} |
||||
|
return result.toString(); |
||||
|
} |
||||
|
|
||||
|
private byte[] compressImage(BufferedImage image, float quality) throws IOException { |
||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
||||
|
ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(byteArrayOutputStream); |
||||
|
|
||||
|
ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next(); |
||||
|
writer.setOutput(imageOutputStream); |
||||
|
|
||||
|
ImageWriteParam param = writer.getDefaultWriteParam(); |
||||
|
if (param.canWriteCompressed()) { |
||||
|
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
||||
|
param.setCompressionQuality(quality); |
||||
|
} |
||||
|
|
||||
|
writer.write(null, new javax.imageio.IIOImage(image, null, null), param); |
||||
|
|
||||
|
writer.dispose(); |
||||
|
imageOutputStream.close(); |
||||
|
|
||||
|
return byteArrayOutputStream.toByteArray(); |
||||
|
} |
||||
|
|
||||
|
public String fileUpload(String name, String id, MultipartFile file) { |
||||
|
|
||||
|
int lastInsertId = 0; |
||||
|
// Set the file path where you want to save it |
||||
|
String uploadDirectory = environment.getProperty("file.upload.directory"); |
||||
|
String serviceFolderName = environment.getProperty("swm_bwg_foldername"); |
||||
|
var year = DateTimeUtil.getCurrentYear(); |
||||
|
var month = DateTimeUtil.getCurrentMonth(); |
||||
|
|
||||
|
uploadDirectory = uploadDirectory + serviceFolderName + year + "/" + month; |
||||
|
|
||||
|
try { |
||||
|
// Create directory if it doesn't exist |
||||
|
Path directoryPath = Paths.get(uploadDirectory); |
||||
|
if (!Files.exists(directoryPath)) { |
||||
|
Files.createDirectories(directoryPath); |
||||
|
} |
||||
|
|
||||
|
// Datetime string |
||||
|
String datetimetxt = DateTimeUtil.getCurrentDateTime(); |
||||
|
// File name |
||||
|
String fileName = name + "_" + id + "_" + datetimetxt + "_" + file.getOriginalFilename(); |
||||
|
fileName = fileName.replaceAll("\\s+", ""); // Remove space on filename |
||||
|
|
||||
|
String filePath = uploadDirectory + "/" + fileName; |
||||
|
|
||||
|
String filepath_txt = "/" + serviceFolderName + year + "/" + month + "/" + fileName; |
||||
|
|
||||
|
// Create a new Path object |
||||
|
Path path = Paths.get(filePath); |
||||
|
|
||||
|
// Get the bytes of the file |
||||
|
byte[] bytes = file.getBytes(); |
||||
|
|
||||
|
// Compress the image |
||||
|
BufferedImage image = ImageIO.read(new ByteArrayInputStream(bytes)); |
||||
|
byte[] compressedBytes = compressImage(image, 0.5f); // Compress with 50% quality |
||||
|
|
||||
|
// Write the bytes to the file |
||||
|
Files.write(path, compressedBytes); |
||||
|
|
||||
|
System.out.println(filePath); |
||||
|
return filepath_txt; |
||||
|
|
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
return "Failed to save file " + file.getOriginalFilename(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getAllClass(){ |
||||
|
|
||||
|
String sqlQuery = "SELECT `cid`, `name` " |
||||
|
+ "FROM `swm_bwg_class` " |
||||
|
+ "WHERE `isactive`=1 AND `isdelete`=0"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcBWGTemplate.queryForList(sqlQuery); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "Success"); |
||||
|
response.put("message", "SWM - BWG Class List"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getBWGTypes(){ |
||||
|
|
||||
|
String sqlQuery = "SELECT `tid`, `name` " |
||||
|
+ "FROM `swm_bwg_types` " |
||||
|
+ "WHERE `isactive`=1 AND `isdelete`=0"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcBWGTemplate.queryForList(sqlQuery); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "Success"); |
||||
|
response.put("message", "SWM - BWG Type List"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getServiceProviderList(){ |
||||
|
|
||||
|
String sqlQuery = "SELECT `splid`, `name` " |
||||
|
+ "FROM `swm_bwg_service_provider_list` " |
||||
|
+ "WHERE `isactive`=1 AND `isdelete`=0"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcBWGTemplate.queryForList(sqlQuery); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "Success"); |
||||
|
response.put("message", "SWM - BWG Service Provider List"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> saveRequest(String latitude, |
||||
|
String longitude, String zone, String ward, String streetid, String streetname, String location, |
||||
|
String classtxt, String type, String qtyofwaste, String onsiteprocessing, |
||||
|
String serviceprovider, String serviceproviderid, String cby, MultipartFile file) { |
||||
|
List<Map<String, Object>> result = null; |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
int lastInsertId = 0; |
||||
|
|
||||
|
String image = ""; |
||||
|
|
||||
|
// Handle file upload if a file is provided |
||||
|
if (file != null && !file.isEmpty()) { |
||||
|
var year = DateTimeUtil.getCurrentYear(); |
||||
|
var month = DateTimeUtil.getCurrentMonth(); |
||||
|
image = fileUpload(year, month, file); |
||||
|
} |
||||
|
|
||||
|
String processingimg = image; |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO `swm_bwg_data`" |
||||
|
+ "(`latitude`, `longitude`, `zone`, `ward`, `streetid`, " |
||||
|
+ "`streetname`, `location`, `class`, `type`, `qtyofwaste`, `onsiteprocessing`, " |
||||
|
+ "`processingimg`, `serviceprovider`, `serviceproviderid`, `cby`) " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcBWGTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[] { "id" }); |
||||
|
ps.setString(1, latitude); |
||||
|
ps.setString(2, longitude); |
||||
|
ps.setString(3, zone); |
||||
|
ps.setString(4, ward); |
||||
|
ps.setString(5, streetid); |
||||
|
ps.setString(6, streetname); |
||||
|
ps.setString(7, location); |
||||
|
ps.setString(8, classtxt); |
||||
|
ps.setString(9, type); |
||||
|
ps.setString(10, qtyofwaste); |
||||
|
ps.setString(11, onsiteprocessing); |
||||
|
ps.setString(12, processingimg); |
||||
|
ps.setString(13, serviceprovider); |
||||
|
ps.setString(14, serviceproviderid); |
||||
|
ps.setString(15, cby); |
||||
|
return ps; |
||||
|
} |
||||
|
}, keyHolder); |
||||
|
|
||||
|
if (affectedRows > 0) { |
||||
|
Number generatedId = keyHolder.getKey(); |
||||
|
lastInsertId = (generatedId != null) ? generatedId.intValue() : 0; |
||||
|
response.put("insertId", lastInsertId); |
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "A new asset was inserted successfully!"); |
||||
|
System.out.println("A new asset was inserted successfully! Insert ID: " + generatedId); |
||||
|
} else { |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", "Failed to insert a new asset."); |
||||
|
} |
||||
|
} catch (DataAccessException e) { |
||||
|
System.out.println("Data Access Exception:"); |
||||
|
Throwable rootCause = e.getMostSpecificCause(); |
||||
|
if (rootCause instanceof SQLException) { |
||||
|
SQLException sqlException = (SQLException) rootCause; |
||||
|
System.out.println("SQL State: " + sqlException.getSQLState()); |
||||
|
System.out.println("Error Code: " + sqlException.getErrorCode()); |
||||
|
System.out.println("Message: " + sqlException.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", sqlException.getMessage()); |
||||
|
response.put("sqlState", sqlException.getSQLState()); |
||||
|
response.put("errorCode", sqlException.getErrorCode()); |
||||
|
} else { |
||||
|
System.out.println("Message: " + rootCause.getMessage()); |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", rootCause.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getZoneWiseCount(){ |
||||
|
|
||||
|
String sqlQuery = "SELECT sbd.zone, count(sbd.did) totalcount FROM `swm_bwg_data` sbd " |
||||
|
+ "WHERE isactive=1 and isdelete=0 GROUP BY sbd.zone ORDER BY sbd.zone"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcBWGTemplate.queryForList(sqlQuery); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "Success"); |
||||
|
response.put("message", "Zone wise count List"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getWardWiseCount(String zone){ |
||||
|
|
||||
|
String sqlQuery = "SELECT sbd.ward, count(sbd.did) totalcount " |
||||
|
+ "FROM " |
||||
|
+ "`swm_bwg_data` sbd " |
||||
|
+ "WHERE (isactive=1 and isdelete=0) and zone=? GROUP BY sbd.ward ORDER BY sbd.ward"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcBWGTemplate.queryForList(sqlQuery,zone); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "Success"); |
||||
|
response.put("message", "Ward wise count List"); |
||||
|
response.put("zone", zone); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getReport(String ward){ |
||||
|
|
||||
|
String sqlQuery = "SELECT sbd.*," |
||||
|
+ "CONCAT('"+fileBaseUrl+"/gccofficialapp/files', sbd.processingimg) AS photos, " |
||||
|
+ "sbc.name as classname, " |
||||
|
+ "sbt.name as typename, " |
||||
|
+ "spl.name as serviceprovidername " |
||||
|
+ "FROM " |
||||
|
+ "`swm_bwg_data` sbd, " |
||||
|
+ "`swm_bwg_class` sbc, " |
||||
|
+ "`swm_bwg_types` sbt, " |
||||
|
+ "`swm_bwg_service_provider_list` spl " |
||||
|
+ "WHERE (sbd.class=sbc.cid AND sbd.type=sbt.tid AND sbd.serviceproviderid=spl.splid) AND ward=?"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcBWGTemplate.queryForList(sqlQuery,ward); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "Success"); |
||||
|
response.put("message", "SWM - BWG List"); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.swmbwg.service; |
||||