35 changed files with 4821 additions and 183 deletions
-
BIN.DS_Store
-
BINmobileservice/.DS_Store
-
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
-
20mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/DataSourceConfig.java
-
16mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccactivity/service/Activity.java
-
28mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/controller/ParksController.java
-
133mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/ParksService.java
-
145mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/controller/SchoolUserController.java
-
247mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/service/SchoolUserActivity.java
-
297mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/hoardings/controller/APIHoardingsController.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/hoardings/controller/package-info.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/hoardings/package-info.java
-
1956mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/hoardings/services/HoardingsService.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/hoardings/services/package-info.java
-
9mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/nulm/controller/APINULMOfficerController.java
-
29mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/nulm/service/NULMOfficerActivity.java
-
79mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/controller/APICattleCatchController.java
-
14mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/controller/APIPenaltyControllerPOS.java
-
791mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/CattleCatchService.java
-
204mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/PenaltyServicePOS.java
-
6mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/service/OfficialAPIService.java
-
18mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/controller/APIController.java
-
78mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/service/activity.java
-
143mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/toilets/controller/APIController.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/toilets/controller/package-info.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/toilets/package-info.java
-
758mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/toilets/service/activity.java
-
1mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/toilets/service/package-info.java
-
BINmobileservice/src/main/resources/.DS_Store
-
19mobileservice/src/main/resources/application.properties
-
BINmobileservice/src/main/resources/static/assets/favicon.ico
-
BINmobileservice/src/main/resources/static/favicon.ico
|
Before Width: 1280 | Height: 720 | Size: 388 KiB |
|
Before Width: 1280 | Height: 720 | Size: 550 KiB |
@ -0,0 +1,297 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.hoardings.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.hoardings.services.HoardingsService; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/hoardings/api") |
||||
|
@RestController("apiHoardingsRest") |
||||
|
public class APIHoardingsController { |
||||
|
@Autowired |
||||
|
private HoardingsService hoardingsService; |
||||
|
|
||||
|
|
||||
|
@GetMapping("/licenseVerify") |
||||
|
public List<?> licenseVerify(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "license_no", required = true) String license_no, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId) { |
||||
|
return hoardingsService.licenseVerify(license_no,latitude,longitude); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/saveHoardings") // Enumeration |
||||
|
public List<?> saveHoardings(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "categoryId", required = false) String categoryId, |
||||
|
@RequestParam(value = "assetName", required = false) String assetName, |
||||
|
@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 = "remarks", required = false) String remarks, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile file, |
||||
|
@RequestParam(value = "hoarding_info_type", required = false) String hoarding_info_type, |
||||
|
@RequestParam(value = "lincenses_info", required = false) String lincenses_info, |
||||
|
@RequestParam(value = "lincenses_no", required = false) String lincenses_no, |
||||
|
@RequestParam(value = "validity_date", required = false) String validity_date, |
||||
|
@RequestParam(value = "case_no", required = false) String case_no, |
||||
|
@RequestParam(value = "ptax_no", required = false) String ptax_no, |
||||
|
@RequestParam(value = "ptax_name", required = false) String ptax_name, |
||||
|
@RequestParam(value = "ptax_mobile", required = false) String ptax_mobile, |
||||
|
@RequestParam(value = "agency_name", required = false) String agency_name, |
||||
|
@RequestParam(value = "agency_mobile", required = false) String agency_mobile, |
||||
|
@RequestParam(value = "fine_to", required = false) String fine_to |
||||
|
) { |
||||
|
return hoardingsService.saveHoardings(formData, categoryId, assetName, latitude, longitude, zone, ward, streeId, |
||||
|
streetName, loginId,remarks,file, |
||||
|
hoarding_info_type, |
||||
|
lincenses_info, |
||||
|
lincenses_no, |
||||
|
validity_date, |
||||
|
case_no, |
||||
|
ptax_no, |
||||
|
ptax_name, |
||||
|
ptax_mobile, |
||||
|
agency_name, |
||||
|
agency_mobile, |
||||
|
fine_to); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/updateHoardingInfo") // Enumeration |
||||
|
public List<?> updateHoardingInfo(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "loginId", required = true) String loginId, |
||||
|
@RequestParam(value = "asset_id", required = true) String asset_id, |
||||
|
@RequestParam(value = "remarks", required = false) String remarks, |
||||
|
@RequestParam(value = "hoarding_info_type", required = false) String hoarding_info_type, |
||||
|
@RequestParam(value = "lincenses_info", required = false) String lincenses_info, |
||||
|
@RequestParam(value = "lincenses_no", required = false) String lincenses_no, |
||||
|
@RequestParam(value = "validity_date", required = false) String validity_date, |
||||
|
@RequestParam(value = "case_no", required = false) String case_no, |
||||
|
@RequestParam(value = "ptax_no", required = false) String ptax_no, |
||||
|
@RequestParam(value = "ptax_name", required = false) String ptax_name, |
||||
|
@RequestParam(value = "ptax_mobile", required = false) String ptax_mobile, |
||||
|
@RequestParam(value = "agency_name", required = false) String agency_name, |
||||
|
@RequestParam(value = "agency_mobile", required = false) String agency_mobile, |
||||
|
@RequestParam(value = "fine_to", required = false) String fine_to |
||||
|
) { |
||||
|
return hoardingsService.updateHoardingInfo(formData, |
||||
|
asset_id, |
||||
|
hoarding_info_type, |
||||
|
remarks, |
||||
|
lincenses_info, |
||||
|
lincenses_no, |
||||
|
validity_date, |
||||
|
case_no, |
||||
|
ptax_no, |
||||
|
ptax_name, |
||||
|
ptax_mobile, |
||||
|
agency_name, |
||||
|
agency_mobile, |
||||
|
fine_to, |
||||
|
loginId); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
@GetMapping("/assetlist") |
||||
|
public List<?> assetlist(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId) { |
||||
|
return hoardingsService.assetlist(formData,loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/assetlistbylogin") |
||||
|
public List<?> assetlistbylogin(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "loginId", required = true) String loginId) { |
||||
|
return hoardingsService.assetlistbylogin(formData,loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/assetlistbylatlong") |
||||
|
public List<?> assetlistbylatlong(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId) { |
||||
|
return hoardingsService.assetlistbylatlong(formData, latitude, longitude,loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getChallanPOSData") |
||||
|
public List<?> getChallanPOSData(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "orderid", required = false) String orderid, |
||||
|
@RequestParam(value = "loginid", required = true) String loginid) { |
||||
|
return hoardingsService.getChallanPOSData(formData,orderid,loginid); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/updateSerialNumber") |
||||
|
public List<?> updateSerialNumber(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "tid", required = true) String tid, |
||||
|
@RequestParam(value = "mid", required = true) String mid, |
||||
|
@RequestParam(value = "serialNumber", required = true) String serialNumber, |
||||
|
@RequestParam(value = "orderid", required = true) String orderid) { |
||||
|
return hoardingsService.updateSerialNumber(formData,tid, mid, serialNumber, orderid); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/storeBankTransaction") |
||||
|
public List<?> storeBankTransaction(@RequestBody Map<String, Object> transactionData) { |
||||
|
return hoardingsService.storeBankTransaction(transactionData); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/storeFailedBankTransaction") |
||||
|
public List<?> storeFailedBankTransaction(@RequestBody Map<String, Object> transactionData) { |
||||
|
return hoardingsService.storeFailedBankTransaction(transactionData); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/updateHoardings") // Enumeration |
||||
|
public List<?> insertHoardingUpdatedData(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "asset_id", required = false) String asset_id, |
||||
|
@RequestParam(value = "update_type", required = false) String update_type, |
||||
|
@RequestParam(value = "removed_type", required = false) String removed_type, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile file, |
||||
|
@RequestParam(value = "licenses_no_visible", required = false) String licenses_no_visible, |
||||
|
@RequestParam(value = "validity_date_visible", required = false) String validity_date_visible, |
||||
|
@RequestParam(value = "not_as_per_size", required = false) String not_as_per_size, |
||||
|
@RequestParam(value = "licenses_no", required = false) String licenses_no, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId |
||||
|
) { |
||||
|
return hoardingsService.insertHoardingUpdatedData(formData, |
||||
|
asset_id, |
||||
|
update_type, |
||||
|
removed_type, |
||||
|
file, |
||||
|
licenses_no_visible, |
||||
|
validity_date_visible, |
||||
|
not_as_per_size, |
||||
|
licenses_no, |
||||
|
loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/unauterrizedassetlistbylogin") |
||||
|
public List<?> unAuterrizedAssetlist(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "loginId", required = true) String loginId) { |
||||
|
return hoardingsService.unAuterrizedAssetlist(formData,loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/unauterrizedassetlistbylatlong") |
||||
|
public List<?> assetlistbylatlong(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "assetid", required = false) String assetid, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId) { |
||||
|
return hoardingsService.unauterrizedassetlistbylatlong(formData, latitude, longitude, assetid, loginId); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/updateHoardingsAE") // Enumeration |
||||
|
public List<?> insertHoardingUpdatedDataAE(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "asset_id", required = false) String asset_id, |
||||
|
@RequestParam(value = "remarks", required = false) String remarks, |
||||
|
@RequestParam(value = "removed_type", required = false) String removed_type, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile file, |
||||
|
//@RequestParam(value = "firfile", required = false) MultipartFile firfile, |
||||
|
//@RequestParam(value = "fir", required = false) String fir, |
||||
|
//@RequestParam(value = "fir_number", required = false) String fir_number, |
||||
|
//@RequestParam(value = "material_collected", required = false) String material_collected, |
||||
|
//@RequestParam(value = "materialfile", required = false) MultipartFile materialfile, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId |
||||
|
) { |
||||
|
return hoardingsService.insertHoardingUpdatedDataAE(formData, |
||||
|
asset_id, |
||||
|
remarks, |
||||
|
removed_type, |
||||
|
file, |
||||
|
//firfile, |
||||
|
//fir, |
||||
|
//fir_number, |
||||
|
//material_collected, |
||||
|
//materialfile, |
||||
|
loginId); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/updateMaterialInfo") // Enumeration |
||||
|
public List<?> updateMaterialInfo(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "id", required = true) String id, |
||||
|
@RequestParam(value = "asset_id", required = true) String asset_id, |
||||
|
@RequestParam(value = "material_collected", required = false) String material_collected, |
||||
|
@RequestParam(value = "material_remarks", required = false) String material_remarks, |
||||
|
@RequestParam(value = "materialfile", required = false) MultipartFile materialfile, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId |
||||
|
) { |
||||
|
return hoardingsService.updateMaterialInfo( |
||||
|
id, |
||||
|
asset_id, |
||||
|
material_collected, |
||||
|
material_remarks, |
||||
|
materialfile); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/updateFirInfo") // Enumeration |
||||
|
public List<?> updateFirInfo(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "id", required = true) String id, |
||||
|
@RequestParam(value = "asset_id", required = true) String asset_id, |
||||
|
@RequestParam(value = "firfile", required = false) MultipartFile firfile, |
||||
|
@RequestParam(value = "fir_number", required = false) String fir_number, |
||||
|
@RequestParam(value = "fir_remarks", required = false) String fir_remarks, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId |
||||
|
) { |
||||
|
return hoardingsService.updateFirInfo( |
||||
|
id, |
||||
|
asset_id, |
||||
|
fir_number, |
||||
|
fir_remarks, |
||||
|
firfile); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/unAuterrizedAssetlistAEPending") |
||||
|
public List<?> unAuterrizedAssetlistAEPending(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "pendingType", required = true) String pendingType, |
||||
|
@RequestParam(value = "loginId", required = true) String loginId) { |
||||
|
return hoardingsService.unAuterrizedAssetlistAEPending(formData, pendingType, loginId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/ReportTile") |
||||
|
public List<?> ReportTile(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "fromDate", required = true) String fromDate, |
||||
|
@RequestParam(value = "toDate", required = true) String toDate, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId) { |
||||
|
return hoardingsService.ReportTile(fromDate, toDate); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/reportZoneList") |
||||
|
public List<?> reportZoneList(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "fromDate", required = true) String fromDate, |
||||
|
@RequestParam(value = "toDate", required = true) String toDate, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId) { |
||||
|
return hoardingsService.reportZoneList(fromDate, toDate); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/reportWardList") |
||||
|
public List<?> reportZoneList(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "zone", required = true) String zone, |
||||
|
@RequestParam(value = "fromDate", required = true) String fromDate, |
||||
|
@RequestParam(value = "toDate", required = true) String toDate, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId) { |
||||
|
return hoardingsService.reportWardList(zone, fromDate, toDate); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/reportListBySelect") |
||||
|
public List<?> reportZoneList(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "ward", required = true) String ward, |
||||
|
@RequestParam(value = "hoarding_info_type", required = true) String hoarding_info_type, |
||||
|
@RequestParam(value = "fromDate", required = true) String fromDate, |
||||
|
@RequestParam(value = "toDate", required = true) String toDate, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId) { |
||||
|
return hoardingsService.reportListBySelect(ward, hoarding_info_type, fromDate, toDate); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.hoardings.controller; |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.hoardings; |
||||
1956
mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/hoardings/services/HoardingsService.java
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.hoardings.services; |
||||
791
mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/CattleCatchService.java
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,143 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.toilets.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
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.toilets.service.activity; |
||||
|
|
||||
|
@RequestMapping("/gccofficialapp/api/toilets/") |
||||
|
@RestController("gccofficialappstoilets") |
||||
|
public class APIController { |
||||
|
@Autowired |
||||
|
private activity activity; |
||||
|
|
||||
|
@GetMapping(value="/getToiletsList") |
||||
|
public List<?> getToiletsList(@RequestParam(value="loginId", required = true) String cby){ |
||||
|
return activity.getToiletsList(cby); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/updateToiletLocation") |
||||
|
public List<?> updateToiletLocation( |
||||
|
@RequestParam(value="loginId", required = true) String cby, |
||||
|
@RequestParam(value="toilet_id", required = true) String toilet_id, |
||||
|
@RequestParam(value="latitude", required = true) String latitude, |
||||
|
@RequestParam(value="longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile filedata |
||||
|
){ |
||||
|
return activity.updateToiletLocation(toilet_id,latitude, longitude, filedata); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/getToiletsListWithButton") |
||||
|
public List<?> getToiletsListWithButton( |
||||
|
@RequestParam(value = "loginId", required = false) String cby) { |
||||
|
return activity.getToiletsListWithButton(cby); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/getQuestionsList") |
||||
|
public List<?> getQuestionsList(@RequestParam(value="loginId", required = false) String cby){ |
||||
|
return activity.getQuestionsList(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/addNewToilet") |
||||
|
public List<?> addNewToilet( |
||||
|
@RequestParam(value="latitude", required = true) String latitude, |
||||
|
@RequestParam(value="longitude", required = true) String longitude, |
||||
|
@RequestParam(value="zone", required = true) String zone, |
||||
|
@RequestParam(value="ward", required = true) String ward, |
||||
|
@RequestParam(value="locality", required = true) String locality, |
||||
|
@RequestParam(value="name", required = true) String name, |
||||
|
@RequestParam(value="loginId", required = false) String cby, |
||||
|
@RequestParam(value = "file", required = false) MultipartFile filedata |
||||
|
){ |
||||
|
return activity.addNewToilet(latitude, longitude, zone, ward, name, locality, cby, filedata); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/toiletlistbylatlong") |
||||
|
public List<?> toiletlistbylatlong(@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value = "latitude", required = true) String latitude, |
||||
|
@RequestParam(value = "longitude", required = true) String longitude, |
||||
|
@RequestParam(value = "assetid", required = true) String id, |
||||
|
@RequestParam(value = "loginId", required = false) String loginId) { |
||||
|
return activity.toiletlistbylatlong(formData, latitude, longitude,id,loginId); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/saveFeedback") |
||||
|
public List<?> saveFeedback( |
||||
|
@RequestParam(value="toilet_id", required = true) String toilet_id, |
||||
|
@RequestParam(value="loginId", required = true) String cby, |
||||
|
@RequestParam(value="latitude", required = true) String latitude, |
||||
|
@RequestParam(value="longitude", required = true) String longitude, |
||||
|
@RequestParam(value="zone", required = true) String zone, |
||||
|
@RequestParam(value="ward", required = true) String ward, |
||||
|
@RequestParam(value="q_1", required = false) String q_1, |
||||
|
@RequestParam(value="q_2", required = false) String q_2, |
||||
|
@RequestParam(value="q_3", required = false) String q_3, |
||||
|
@RequestParam(value="q_4", required = false) String q_4, |
||||
|
@RequestParam(value="q_5", required = false) String q_5, |
||||
|
@RequestParam(value="q_6", required = false) String q_6, |
||||
|
@RequestParam(value="q_7", required = false) String q_7, |
||||
|
@RequestParam(value="q_8", required = false) String q_8, |
||||
|
@RequestParam(value="q_9", required = false) String q_9, |
||||
|
@RequestParam(value="q_10", required = false) String q_10, |
||||
|
@RequestParam(value="q_11", required = false) String q_11, |
||||
|
@RequestParam(value="remarks", required = false) String remarks, |
||||
|
@RequestParam(value = "file", required = true) MultipartFile filedata |
||||
|
){ |
||||
|
return activity.saveFeedback(toilet_id, cby, latitude, longitude, zone, ward, |
||||
|
q_1, q_2, q_3, q_4, q_5, q_6, q_7, q_8, q_9, q_10, q_11, |
||||
|
remarks, filedata); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/zoneReport") |
||||
|
public List<?> zoneReport( |
||||
|
@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value="fromDate", required = true) String fromDate, |
||||
|
@RequestParam(value="toDate", required = true) String toDate, |
||||
|
@RequestParam(value="loginId", required = false) String cby |
||||
|
){ |
||||
|
return activity.zoneReport(formData,fromDate,toDate,cby); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/wardReport") |
||||
|
public List<?> wardReport( |
||||
|
@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value="fromDate", required = true) String fromDate, |
||||
|
@RequestParam(value="toDate", required = true) String toDate, |
||||
|
@RequestParam(value="zone", required = true) String zone, |
||||
|
@RequestParam(value="loginId", required = false) String cby |
||||
|
){ |
||||
|
return activity.wardReport(formData,fromDate,toDate,zone,cby); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/toiletReport") |
||||
|
public List<?> toiletReport( |
||||
|
@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value="fromDate", required = true) String fromDate, |
||||
|
@RequestParam(value="toDate", required = true) String toDate, |
||||
|
@RequestParam(value="ward", required = true) String ward, |
||||
|
@RequestParam(value="loginId", required = false) String cby |
||||
|
){ |
||||
|
return activity.toiletReport(formData,fromDate,toDate,ward,cby); |
||||
|
} |
||||
|
|
||||
|
@GetMapping(value="/feedbackReport") |
||||
|
public List<?> feedbackReport( |
||||
|
@RequestParam MultiValueMap<String, String> formData, |
||||
|
@RequestParam(value="fromDate", required = true) String fromDate, |
||||
|
@RequestParam(value="toDate", required = true) String toDate, |
||||
|
@RequestParam(value="type", required = true) String type, |
||||
|
@RequestParam(value="toilet_id", required = true) String id, |
||||
|
@RequestParam(value="loginId", required = false) String cby |
||||
|
){ |
||||
|
return activity.feedbackReport(formData,fromDate,toDate,type,id,cby); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.toilets.controller; |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.toilets; |
||||
@ -0,0 +1,758 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.toilets.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.LocalTime; |
||||
|
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("gccofficialappstoiletsactivity") |
||||
|
public class activity { |
||||
|
private JdbcTemplate jdbcToiletsTemplate; |
||||
|
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("mysqlToiletsDataSource") DataSource toiletsDataSource) { |
||||
|
this.jdbcToiletsTemplate = new JdbcTemplate(toiletsDataSource); |
||||
|
} |
||||
|
|
||||
|
@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("toilets_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 static String getTypeBasedOnTime() { |
||||
|
// Get the current time |
||||
|
LocalTime now = LocalTime.now(); |
||||
|
|
||||
|
// Define morning and evening time ranges |
||||
|
LocalTime morningStart = LocalTime.of(1, 0); // 1:00 AM |
||||
|
LocalTime eveningStart = LocalTime.of(13, 0); // 1:00 PM |
||||
|
|
||||
|
// Check and return the appropriate type |
||||
|
if (now.isAfter(morningStart) && now.isBefore(eveningStart)) { |
||||
|
return "morning"; |
||||
|
} else { |
||||
|
return "evening"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getToiletsList(String loginid) { |
||||
|
String sql = "SELECT *," |
||||
|
+ " CONCAT('"+fileBaseUrl+"/gccofficialapp/files',image) AS photo " |
||||
|
+ " FROM `gcc_toilet_list` WHERE `user_id`=? AND `isactive`=1 AND `gcc_app_updated`= 0 "; |
||||
|
List<Map<String, Object>> result = jdbcToiletsTemplate.queryForList(sql,loginid); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "Success"); |
||||
|
response.put("message", "Toilets List."); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> updateToiletLocation(String id,String latitude, String longitude, MultipartFile file) { |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
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 toiletimg = image; |
||||
|
String sql = "UPDATE `gcc_toilet_list` SET `gcc_app_updated`=1, `latitude`=?, longitude=?, `image`=? WHERE `id`=?"; |
||||
|
jdbcToiletsTemplate.update(sql, latitude, longitude, toiletimg, id); |
||||
|
|
||||
|
|
||||
|
response.put("status", "success"); |
||||
|
response.put("message", "Toilet Data updated successfully!"); |
||||
|
System.out.println("Toilet Data updated successfully!! Update ID: " + id); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getToiletsListWithButton(String loginid) { |
||||
|
/* |
||||
|
String sql = "SELECT " |
||||
|
+ " `gcc_toilet_list`.*, " |
||||
|
+ " CONCAT('"+fileBaseUrl+"/gccofficialapp/files', `gcc_toilet_list`.`image`) AS photo, " |
||||
|
+ " CASE " |
||||
|
+ " WHEN `toilet_feedback`.`type` = 'morning' THEN true " |
||||
|
+ " ELSE false " |
||||
|
+ " END AS morning_feedback, " |
||||
|
+ " CASE " |
||||
|
+ " WHEN `toilet_feedback`.`type` = 'evening' THEN true " |
||||
|
+ " ELSE false " |
||||
|
+ " END AS evening_feedback " |
||||
|
+ "FROM " |
||||
|
+ " `gcc_toilet_list` " |
||||
|
+ "LEFT JOIN " |
||||
|
+ " `toilet_feedback` " |
||||
|
+ " ON `toilet_feedback`.`toilet_id` = `gcc_toilet_list`.`id` " |
||||
|
+ " AND DATE(`toilet_feedback`.`cdate`) = CURDATE() " |
||||
|
+ "WHERE " |
||||
|
+ " `gcc_toilet_list`.`user_id` = ? " |
||||
|
+ " AND `gcc_toilet_list`.`isactive` = 1"; |
||||
|
*/ |
||||
|
String sql ="SELECT " |
||||
|
+ " `gcc_toilet_list`.*, " |
||||
|
+ " CONCAT('" + fileBaseUrl + "/gccofficialapp/files', " |
||||
|
+ " CASE " |
||||
|
+ " WHEN `gcc_toilet_list`.`image` IS NULL OR `gcc_toilet_list`.`image` = '' " |
||||
|
+ " THEN `toilet_feedback`.`image` " |
||||
|
+ " ELSE `gcc_toilet_list`.`image` " |
||||
|
+ " END " |
||||
|
+ " ) AS photo, " |
||||
|
+ " MAX(CASE WHEN `toilet_feedback`.`type` = 'morning' THEN true ELSE false END) AS morning_feedback, " |
||||
|
+ " MAX(CASE WHEN `toilet_feedback`.`type` = 'evening' THEN true ELSE false END) AS evening_feedback " |
||||
|
+ "FROM " |
||||
|
+ " `gcc_toilet_list` " |
||||
|
+ "LEFT JOIN " |
||||
|
+ " `toilet_feedback` " |
||||
|
+ " ON `toilet_feedback`.`toilet_id` = `gcc_toilet_list`.`id` " |
||||
|
+ " AND DATE(`toilet_feedback`.`cdate`) = CURDATE() " |
||||
|
+ "WHERE " |
||||
|
+ " `gcc_toilet_list`.`user_id` = ? " |
||||
|
+ " AND `gcc_toilet_list`.`isactive` = 1 AND `gcc_app_updated`= 1 " |
||||
|
+ "GROUP BY " |
||||
|
+ " `gcc_toilet_list`.`id`"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcToiletsTemplate.queryForList(sql,loginid); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "Success"); |
||||
|
response.put("message", "Toilets List with extra info."); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
public List<Map<String, Object>> getQuestionsList() { |
||||
|
String sql = "SELECT * FROM question_list WHERE isactive=1"; |
||||
|
List<Map<String, Object>> result = jdbcToiletsTemplate.queryForList(sql); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", "Success"); |
||||
|
response.put("message", "Toilet Question List."); |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> addNewToilet(String latitude, |
||||
|
String longitude, String zone, String ward, String name, String locality, 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 toiletimg = image; |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO `gcc_toilet_list`(" |
||||
|
+ "`zone`, `zone_name`, `ward`, `user_id`, `list`, " |
||||
|
+ "`name`, `locality`, `latitude`, `longitude`, `toilet_availability`, " |
||||
|
+ "`toilet_category`, `toilet_type`, `working_condition`, `refurbishment_type`,`image`) " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcToiletsTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[] { "id" }); |
||||
|
ps.setString(1, zone); |
||||
|
ps.setString(2, ""); |
||||
|
ps.setString(3, ward); |
||||
|
ps.setString(4, cby); |
||||
|
ps.setString(5, ""); |
||||
|
ps.setString(6, name); |
||||
|
ps.setString(7, locality); |
||||
|
ps.setString(8, latitude); |
||||
|
ps.setString(9, longitude); |
||||
|
ps.setString(10, ""); |
||||
|
ps.setString(11, ""); |
||||
|
ps.setString(12, ""); |
||||
|
ps.setString(13, ""); |
||||
|
ps.setString(14, ""); |
||||
|
ps.setString(15, toiletimg); |
||||
|
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); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> toiletlistbylatlong( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String latitude, |
||||
|
String longitude, |
||||
|
String id, |
||||
|
String loginid) { |
||||
|
|
||||
|
String sqlWhere = ""; |
||||
|
|
||||
|
if (latitude != null && longitude != null && !latitude.isBlank() && !latitude.isEmpty() && !longitude.isBlank() |
||||
|
&& !longitude.isEmpty()) { |
||||
|
sqlWhere += " AND ((6371008.8 * acos(ROUND(cos(radians(" + latitude |
||||
|
+ ")) * cos(radians(latitude)) * cos(radians(longitude) - radians(" + longitude |
||||
|
+ ")) + sin(radians(" + latitude + ")) * sin(radians(latitude)), 9))) < 200)" |
||||
|
+ " ORDER BY `id` DESC"; |
||||
|
} |
||||
|
|
||||
|
String sqlQuery = "SELECT *," |
||||
|
+ " CONCAT('"+fileBaseUrl+"/gccofficialapp/files',image) AS photo " |
||||
|
+ " FROM `gcc_toilet_list` WHERE `user_id`=? AND `isactive`=1 AND id = ?" // This is the starting part of WHERE clause |
||||
|
+ sqlWhere; // Here the latitude and longitude condition gets appended if provided |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcToiletsTemplate.queryForList(sqlQuery,loginid, id); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Nearby toilet list."); |
||||
|
if(result.isEmpty()) { |
||||
|
response.put("message", "No toilet found nearby."); |
||||
|
} |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> saveFeedback( |
||||
|
String toilet_id, |
||||
|
String cby, |
||||
|
String latitude, |
||||
|
String longitude, |
||||
|
String zone, |
||||
|
String ward, |
||||
|
String q_1, |
||||
|
String q_2, |
||||
|
String q_3, |
||||
|
String q_4, |
||||
|
String q_5, |
||||
|
String q_6, |
||||
|
String q_7, |
||||
|
String q_8, |
||||
|
String q_9, |
||||
|
String q_10, |
||||
|
String q_11, |
||||
|
String remarks, |
||||
|
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 feedbackimg = image; |
||||
|
String type = getTypeBasedOnTime(); // Get Morning & Evening |
||||
|
|
||||
|
String sqlQuery = "INSERT INTO `toilet_feedback`(" |
||||
|
+ "`toilet_id`, `cby`, " |
||||
|
+ "`q1`, `q2`, `q3`, `q4`, `q5`, `q6`, `q7`, `q8`, `q9`, `q10`, `q11`, " |
||||
|
+ "`remarks`,`latitude`, `longitude`,`zone`,`ward`,`type`,`image`) " |
||||
|
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
||||
|
|
||||
|
KeyHolder keyHolder = new GeneratedKeyHolder(); |
||||
|
|
||||
|
try { |
||||
|
int affectedRows = jdbcToiletsTemplate.update(new PreparedStatementCreator() { |
||||
|
@Override |
||||
|
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { |
||||
|
PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[] { "id" }); |
||||
|
ps.setString(1, toilet_id); |
||||
|
ps.setString(2, cby); |
||||
|
ps.setString(3, q_1); |
||||
|
ps.setString(4, q_2); |
||||
|
ps.setString(5, q_3); |
||||
|
ps.setString(6, q_4); |
||||
|
ps.setString(7, q_5); |
||||
|
ps.setString(8, q_6); |
||||
|
ps.setString(9, q_7); |
||||
|
ps.setString(10, q_8); |
||||
|
ps.setString(11, q_9); |
||||
|
ps.setString(12, q_10); |
||||
|
ps.setString(13, q_11); |
||||
|
ps.setString(14, remarks); |
||||
|
ps.setString(15, latitude); |
||||
|
ps.setString(16, longitude); |
||||
|
ps.setString(17, zone); |
||||
|
ps.setString(18, ward); |
||||
|
ps.setString(19, type); |
||||
|
ps.setString(20, feedbackimg); |
||||
|
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 feedback was inserted successfully!"); |
||||
|
System.out.println("A new feedback was inserted successfully! Insert ID: " + generatedId); |
||||
|
} else { |
||||
|
response.put("status", "error"); |
||||
|
response.put("message", "Failed to insert a new feedback. Asset ID:" + toilet_id); |
||||
|
} |
||||
|
} 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); |
||||
|
} |
||||
|
|
||||
|
// Report |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> zoneReport( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String fromDate, |
||||
|
String toDate, |
||||
|
String loginid) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
String sqlQuery = "SELECT " |
||||
|
+ " `gcc_toilet_list`.`zone`, " |
||||
|
+ " COUNT(DISTINCT `gcc_toilet_list`.`id`) AS Total_Toilets, " |
||||
|
+ " SUM(CASE " |
||||
|
+ " WHEN `gcc_toilet_list`.`gcc_app_updated` = '0' THEN 1 " |
||||
|
+ " ELSE 0 " |
||||
|
+ " END) AS Enumeration_Pending, " |
||||
|
+ " SUM(CASE " |
||||
|
+ " WHEN `toilet_feedback`.`type` = 'morning' THEN 1 " |
||||
|
+ " ELSE 0 " |
||||
|
+ " END) AS Morning_Count, " |
||||
|
+ " SUM(CASE " |
||||
|
+ " WHEN `toilet_feedback`.`type` = 'evening' THEN 1 " |
||||
|
+ " ELSE 0 " |
||||
|
+ " END) AS Evening_Count " |
||||
|
+ "FROM " |
||||
|
+ " `gcc_toilet_list` " |
||||
|
+ "LEFT JOIN " |
||||
|
+ " `toilet_feedback` " |
||||
|
+ " ON `toilet_feedback`.`toilet_id` = `gcc_toilet_list`.`id` " |
||||
|
+ " AND DATE(`toilet_feedback`.`cdate`) BETWEEN STR_TO_DATE(?, '%d-%m-%Y') AND STR_TO_DATE(?, '%d-%m-%Y') " |
||||
|
+ "WHERE " |
||||
|
//+ " `gcc_toilet_list`.`user_id` = ? AND " |
||||
|
+ " `gcc_toilet_list`.`isactive` = 1 " |
||||
|
+ "GROUP BY " |
||||
|
+ " `gcc_toilet_list`.`zone` " |
||||
|
+ "ORDER BY " |
||||
|
+ " `gcc_toilet_list`.`zone`"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcToiletsTemplate.queryForList(sqlQuery, fromDate, toDate); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Zone report."); |
||||
|
if(result.isEmpty()) { |
||||
|
response.put("message", "No data found."); |
||||
|
} |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> wardReport( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String fromDate, |
||||
|
String toDate, |
||||
|
String zone, |
||||
|
String loginid) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
String sqlQuery = "SELECT " |
||||
|
+ " `gcc_toilet_list`.`ward`, " |
||||
|
+ " COUNT(DISTINCT `gcc_toilet_list`.`id`) AS Total_Toilets, " |
||||
|
+ " SUM(CASE " |
||||
|
+ " WHEN `gcc_toilet_list`.`gcc_app_updated` = '0' THEN 1 " |
||||
|
+ " ELSE 0 " |
||||
|
+ " END) AS Enumeration_Pending, " |
||||
|
+ " SUM(CASE " |
||||
|
+ " WHEN `toilet_feedback`.`type` = 'morning' THEN 1 " |
||||
|
+ " ELSE 0 " |
||||
|
+ " END) AS Morning_Count, " |
||||
|
+ " SUM(CASE " |
||||
|
+ " WHEN `toilet_feedback`.`type` = 'evening' THEN 1 " |
||||
|
+ " ELSE 0 " |
||||
|
+ " END) AS Evening_Count " |
||||
|
+ "FROM " |
||||
|
+ " `gcc_toilet_list` " |
||||
|
+ "LEFT JOIN " |
||||
|
+ " `toilet_feedback` " |
||||
|
+ " ON `toilet_feedback`.`toilet_id` = `gcc_toilet_list`.`id` " |
||||
|
+ " AND DATE(`toilet_feedback`.`cdate`) BETWEEN STR_TO_DATE(?, '%d-%m-%Y') AND STR_TO_DATE(?, '%d-%m-%Y') " |
||||
|
+ "WHERE " |
||||
|
+ " `gcc_toilet_list`.`zone` = ? AND " |
||||
|
+ " `gcc_toilet_list`.`isactive` = 1 " |
||||
|
+ "GROUP BY " |
||||
|
+ " `gcc_toilet_list`.`ward` " |
||||
|
+ "ORDER BY " |
||||
|
+ " `gcc_toilet_list`.`ward`"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcToiletsTemplate.queryForList(sqlQuery, fromDate, toDate, zone); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Ward report."); |
||||
|
if(result.isEmpty()) { |
||||
|
response.put("message", "No data found."); |
||||
|
} |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> toiletReport( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String fromDate, |
||||
|
String toDate, |
||||
|
String ward, |
||||
|
String loginid) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
String sqlQuery = "SELECT " |
||||
|
+ " `gcc_toilet_list`.`id`,`gcc_toilet_list`.`name`,`gcc_toilet_list`.`zone`,`gcc_toilet_list`.`ward`, " |
||||
|
+ " CONCAT('"+fileBaseUrl+"/gccofficialapp/files', `gcc_toilet_list`.`image`) AS photo," |
||||
|
+ " SUM(CASE " |
||||
|
+ " WHEN `gcc_toilet_list`.`gcc_app_updated` = '0' THEN 1 " |
||||
|
+ " ELSE 0 " |
||||
|
+ " END) AS Enumeration_Pending, " |
||||
|
+ " SUM(CASE " |
||||
|
+ " WHEN `toilet_feedback`.`type` = 'morning' THEN 1 " |
||||
|
+ " ELSE 0 " |
||||
|
+ " END) AS Morning_Count, " |
||||
|
+ " SUM(CASE " |
||||
|
+ " WHEN `toilet_feedback`.`type` = 'evening' THEN 1 " |
||||
|
+ " ELSE 0 " |
||||
|
+ " END) AS Evening_Count " |
||||
|
+ "FROM " |
||||
|
+ " `gcc_toilet_list` " |
||||
|
+ "LEFT JOIN " |
||||
|
+ " `toilet_feedback` " |
||||
|
+ " ON `toilet_feedback`.`toilet_id` = `gcc_toilet_list`.`id` " |
||||
|
+ " AND DATE(`toilet_feedback`.`cdate`) BETWEEN STR_TO_DATE(?, '%d-%m-%Y') AND STR_TO_DATE(?, '%d-%m-%Y') " |
||||
|
+ "WHERE " |
||||
|
+ " `gcc_toilet_list`.`ward` = ? AND " |
||||
|
+ " `gcc_toilet_list`.`isactive` = 1 " |
||||
|
+ "GROUP BY " |
||||
|
+ " `gcc_toilet_list`.`id` " |
||||
|
+ "ORDER BY " |
||||
|
+ " `gcc_toilet_list`.`id`"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcToiletsTemplate.queryForList(sqlQuery, fromDate, toDate, ward); |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
response.put("message", "Toilet list report."); |
||||
|
if(result.isEmpty()) { |
||||
|
response.put("message", "No data found."); |
||||
|
} |
||||
|
response.put("data", result); |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> feedbackReport( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String fromDate, |
||||
|
String toDate, |
||||
|
//String ward, |
||||
|
String type, |
||||
|
String toiletid, |
||||
|
String loginid) { |
||||
|
|
||||
|
String sqlQuery = "SELECT " |
||||
|
+ " `gcc_toilet_list`.`id` as assetid, " |
||||
|
+ " `gcc_toilet_list`.`name`, " |
||||
|
+ " `gcc_toilet_list`.`zone`, " |
||||
|
+ " `gcc_toilet_list`.`ward`, " |
||||
|
+ " CONCAT('"+fileBaseUrl+"/gccofficialapp/files', `gcc_toilet_list`.`image`) AS toiletPhoto, " |
||||
|
+ " DATE_FORMAT(`toilet_feedback`.`cdate`, '%d-%m-%Y %I:%i %p') as feedbackDate, " |
||||
|
+ " `toilet_feedback`.*, " |
||||
|
+ " CONCAT('"+fileBaseUrl+"/gccofficialapp/files', `toilet_feedback`.`image`) AS feedbackPhoto " |
||||
|
+ "FROM " |
||||
|
+ " `gcc_toilet_list` " |
||||
|
+ "RIGHT JOIN " |
||||
|
+ " `toilet_feedback` " |
||||
|
+ " ON `toilet_feedback`.`toilet_id` = `gcc_toilet_list`.`id` " |
||||
|
+ " AND `toilet_feedback`.`type` = ? " |
||||
|
+ " AND DATE(`toilet_feedback`.`cdate`) BETWEEN STR_TO_DATE(?, '%d-%m-%Y') AND STR_TO_DATE(?, '%d-%m-%Y') " |
||||
|
+ "WHERE " |
||||
|
+ " `gcc_toilet_list`.`id` = ? " |
||||
|
+ " AND `gcc_toilet_list`.`isactive` = 1 " |
||||
|
+ "ORDER BY " |
||||
|
+ " feedbackDate"; |
||||
|
|
||||
|
List<Map<String, Object>> result = jdbcToiletsTemplate.queryForList(sqlQuery, type, fromDate, toDate, toiletid); |
||||
|
|
||||
|
// Questions |
||||
|
String sqlQuestion = "SELECT * FROM `question_list`"; |
||||
|
|
||||
|
List<Map<String, Object>> question = jdbcToiletsTemplate.queryForList(sqlQuestion); |
||||
|
|
||||
|
// Prepare response |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
if (result.isEmpty()) { |
||||
|
response.put("message", "No data found."); |
||||
|
response.put("data", Collections.emptyList()); |
||||
|
response.put("question", Collections.emptyList()); |
||||
|
} else { |
||||
|
response.put("message", "Feedback list report."); |
||||
|
response.put("data", result); |
||||
|
response.put("question", question); |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
/* |
||||
|
@Transactional |
||||
|
public List<Map<String, Object>> feedbackReport( |
||||
|
MultiValueMap<String, String> formData, |
||||
|
String fromDate, |
||||
|
String toDate, |
||||
|
String type, |
||||
|
String toiletid, |
||||
|
String loginid) { |
||||
|
|
||||
|
// Fetch feedback data |
||||
|
String sqlQuery = "SELECT `gcc_toilet_list`.`id` as assetid,`gcc_toilet_list`.`name`,`gcc_toilet_list`.`zone`," |
||||
|
+ "`gcc_toilet_list`.`ward`, CONCAT('https://gccservices.in/gccofficialapp/files', `gcc_toilet_list`.`image`) AS toiletPhoto," |
||||
|
+ " DATE(`toilet_feedback`.`cdate`) as feedbackDate, " |
||||
|
+ "`toilet_feedback`.*, CONCAT('https://gccservices.in/gccofficialapp/files', `toilet_feedback`.`image`) AS feedbackPhoto " |
||||
|
+ "FROM `gcc_toilet_list` JOIN `toilet_feedback` ON `toilet_feedback`.`toilet_id` = `gcc_toilet_list`.`id` " |
||||
|
+ "AND `toilet_feedback`.`type` = ? " |
||||
|
+ "AND DATE(`toilet_feedback`.`cdate`) BETWEEN STR_TO_DATE(?, '%d-%m-%Y') " |
||||
|
+ "AND STR_TO_DATE(?, '%d-%m-%Y') WHERE `gcc_toilet_list`.`id` = ? " |
||||
|
+ "AND `gcc_toilet_list`.`isactive` = 1 GROUP BY `gcc_toilet_list`.`id` ORDER BY feedbackDate"; |
||||
|
|
||||
|
List<Map<String, Object>> feedbackData = jdbcToiletsTemplate.queryForList(sqlQuery, type, fromDate, toDate, toiletid); |
||||
|
|
||||
|
// Fetch question data |
||||
|
String sqlQuestion = "SELECT * FROM `question_list`"; |
||||
|
List<Map<String, Object>> questionData = jdbcToiletsTemplate.queryForList(sqlQuestion); |
||||
|
|
||||
|
// Map questions by ID for easy lookup |
||||
|
Map<String, Map<String, Object>> questionMap = new HashMap<>(); |
||||
|
for (Map<String, Object> question : questionData) { |
||||
|
questionMap.put("q" + question.get("id"), question); |
||||
|
} |
||||
|
|
||||
|
// Enrich feedback data with question English and Tamil fields |
||||
|
for (Map<String, Object> feedback : feedbackData) { |
||||
|
for (int i = 1; i <= 7; i++) { // Assuming there are 7 questions (q1 to q7) |
||||
|
String questionKey = "q" + i; |
||||
|
if (feedback.containsKey(questionKey)) { |
||||
|
Map<String, Object> question = questionMap.get(questionKey); |
||||
|
if (question != null) { |
||||
|
feedback.put(questionKey + "_english", question.get("q_english")); |
||||
|
feedback.put(questionKey + "_tamil", question.get("q_tamil")); |
||||
|
} else { |
||||
|
feedback.put(questionKey + "_english", null); |
||||
|
feedback.put(questionKey + "_tamil", null); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Prepare response |
||||
|
Map<String, Object> response = new HashMap<>(); |
||||
|
response.put("status", 200); |
||||
|
if (feedbackData.isEmpty()) { |
||||
|
response.put("message", "No data found."); |
||||
|
response.put("data", Collections.emptyList()); |
||||
|
} else { |
||||
|
response.put("message", "Feedback list report."); |
||||
|
response.put("data", feedbackData); |
||||
|
} |
||||
|
|
||||
|
return Collections.singletonList(response); |
||||
|
} |
||||
|
*/ |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
package in.gov.chennaicorporation.mobileservice.toilets.service; |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue