diff --git a/.DS_Store b/.DS_Store index fa161f9..03a2b26 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/mobileservice/.DS_Store b/mobileservice/.DS_Store index 363c90b..70b7800 100644 Binary files a/mobileservice/.DS_Store and b/mobileservice/.DS_Store differ diff --git a/mobileservice/gcc_mobile_service_uploads/.DS_Store b/mobileservice/gcc_mobile_service_uploads/.DS_Store deleted file mode 100644 index 20de68f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/.DS_Store and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/.DS_Store b/mobileservice/gcc_mobile_service_uploads/app_icon/.DS_Store deleted file mode 100644 index f78d987..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/.DS_Store and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/15.png b/mobileservice/gcc_mobile_service_uploads/app_icon/15.png deleted file mode 100644 index 63698d4..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/15.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/30.png b/mobileservice/gcc_mobile_service_uploads/app_icon/30.png deleted file mode 100644 index 2d5d8ee..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/30.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/31.png b/mobileservice/gcc_mobile_service_uploads/app_icon/31.png deleted file mode 100644 index 2816a65..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/31.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/32.png b/mobileservice/gcc_mobile_service_uploads/app_icon/32.png deleted file mode 100644 index f9c500c..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/32.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/5_25092024174715_dog.jpg b/mobileservice/gcc_mobile_service_uploads/app_icon/5_25092024174715_dog.jpg deleted file mode 100644 index b9bb7a3..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/5_25092024174715_dog.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/D_18.png b/mobileservice/gcc_mobile_service_uploads/app_icon/D_18.png deleted file mode 100644 index 1a179f6..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/D_18.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_42.png b/mobileservice/gcc_mobile_service_uploads/app_icon/MI_42.png deleted file mode 100644 index 746a99b..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_42.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_43.png b/mobileservice/gcc_mobile_service_uploads/app_icon/MI_43.png deleted file mode 100644 index 415bd78..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_43.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_44.png b/mobileservice/gcc_mobile_service_uploads/app_icon/MI_44.png deleted file mode 100644 index 4bced05..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_44.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_45.png b/mobileservice/gcc_mobile_service_uploads/app_icon/MI_45.png deleted file mode 100644 index 6678b50..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_45.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_46.png b/mobileservice/gcc_mobile_service_uploads/app_icon/MI_46.png deleted file mode 100644 index 0e52ee5..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_46.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_47.png b/mobileservice/gcc_mobile_service_uploads/app_icon/MI_47.png deleted file mode 100644 index 85c9197..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_47.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_63.png b/mobileservice/gcc_mobile_service_uploads/app_icon/MI_63.png deleted file mode 100644 index ec9185d..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_63.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_64.png b/mobileservice/gcc_mobile_service_uploads/app_icon/MI_64.png deleted file mode 100644 index 8958d37..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/MI_64.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_54.png b/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_54.png deleted file mode 100644 index b75c4be..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_54.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_55.png b/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_55.png deleted file mode 100644 index 144c6c7..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_55.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_56.png b/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_56.png deleted file mode 100644 index 5852876..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_56.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_57.png b/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_57.png deleted file mode 100644 index bc8027f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_57.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_58.png b/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_58.png deleted file mode 100644 index 4e9e6b2..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_58.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_59.png b/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_59.png deleted file mode 100644 index 3e8ebb2..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_59.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_60.png b/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_60.png deleted file mode 100644 index f78e017..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_60.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_61.png b/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_61.png deleted file mode 100644 index 250c26b..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/icons/MI_61.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/.DS_Store b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/.DS_Store deleted file mode 100644 index b0404d5..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/.DS_Store and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/1.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/1.png deleted file mode 100644 index 21a4535..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/1.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/1_1.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/1_1.png deleted file mode 100644 index 9a4be42..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/1_1.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/1_2.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/1_2.png deleted file mode 100644 index d864e9a..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/1_2.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/2.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/2.png deleted file mode 100644 index 0642f24..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/2.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/2_3.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/2_3.png deleted file mode 100644 index 5b6391b..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/2_3.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/2_4.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/2_4.png deleted file mode 100644 index 22d1a8e..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/2_4.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/2_5.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/2_5.png deleted file mode 100644 index 3d50adb..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/2_5.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/3.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/3.png deleted file mode 100644 index 98c5564..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/3.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/3_1.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/3_1.png deleted file mode 100644 index f8b5435..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/3_1.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/3_2.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/3_2.png deleted file mode 100644 index 22d1a8e..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/3_2.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/3_3.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/3_3.png deleted file mode 100644 index 3d50adb..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/3_3.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_1.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_1.png deleted file mode 100644 index 0be5caa..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_1.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_10.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_10.png deleted file mode 100644 index 9455582..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_10.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_11.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_11.png deleted file mode 100644 index 3e5b10f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_11.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_12.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_12.png deleted file mode 100644 index 2315e4e..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_12.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_13.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_13.png deleted file mode 100644 index 44988b6..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_13.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_14.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_14.png deleted file mode 100644 index 24a9578..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_14.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_15.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_15.png deleted file mode 100644 index 74d490f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_15.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_16.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_16.png deleted file mode 100644 index 21a4535..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_16.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_17.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_17.png deleted file mode 100644 index 9a6577b..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_17.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_3.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_3.png deleted file mode 100644 index bc67ac9..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_3.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_5.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_5.png deleted file mode 100644 index 2a61fbb..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_5.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_6.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_6.png deleted file mode 100644 index 53d8bcc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_6.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_7.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_7.png deleted file mode 100644 index ce42bdc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_7.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_8.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_8.png deleted file mode 100644 index 3f35028..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_8.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_9.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_9.png deleted file mode 100644 index 6c6097b..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/D_9.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep.zip b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep.zip deleted file mode 100644 index 06908b0..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep.zip and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/ACCOUNTS CENTRAL CELL.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/ACCOUNTS CENTRAL CELL.png deleted file mode 100644 index a2c2dc4..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/ACCOUNTS CENTRAL CELL.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/BRIDGES.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/BRIDGES.png deleted file mode 100644 index 2315e4e..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/BRIDGES.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/BUILDINGS.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/BUILDINGS.png deleted file mode 100644 index 24a9578..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/BUILDINGS.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/BUS ROUTE ROADS.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/BUS ROUTE ROADS.png deleted file mode 100644 index 44988b6..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/BUS ROUTE ROADS.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/CHIEF ENGINEER OFFICE.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/CHIEF ENGINEER OFFICE.png deleted file mode 100644 index e55d3f1..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/CHIEF ENGINEER OFFICE.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/COUNCIL.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/COUNCIL.png deleted file mode 100644 index cfa10f8..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/COUNCIL.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/DISTRICT FAMILY WELFARE.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/DISTRICT FAMILY WELFARE.png deleted file mode 100644 index 51883eb..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/DISTRICT FAMILY WELFARE.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_1.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_1.png deleted file mode 100644 index 0be5caa..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_1.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_10.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_10.png deleted file mode 100644 index 9455582..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_10.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_11.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_11.png deleted file mode 100644 index 3e5b10f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_11.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_6.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_6.png deleted file mode 100644 index 53d8bcc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_6.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_7.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_7.png deleted file mode 100644 index ce42bdc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/D_7.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/ELECTRICAL.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/ELECTRICAL.png deleted file mode 100644 index bc67ac9..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/ELECTRICAL.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/ELEMENTARY EDUCATION.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/ELEMENTARY EDUCATION.png deleted file mode 100644 index 13676de..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/ELEMENTARY EDUCATION.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/HEALTH.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/HEALTH.png deleted file mode 100644 index 2a61fbb..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/HEALTH.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/LEGAL CELL.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/LEGAL CELL.png deleted file mode 100644 index 6526d59..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/LEGAL CELL.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/PLANNING AND TRAINING.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/PLANNING AND TRAINING.png deleted file mode 100644 index 9a6577b..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/PLANNING AND TRAINING.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/REVENUE.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/REVENUE.png deleted file mode 100644 index 74d490f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/REVENUE.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/SOLID WASTE MANAGEMENT.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/SOLID WASTE MANAGEMENT.png deleted file mode 100644 index 3f35028..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/SOLID WASTE MANAGEMENT.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/STORM WATER DRAINS.png b/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/STORM WATER DRAINS.png deleted file mode 100644 index 6c6097b..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/app_icon/menu/icons Dep/STORM WATER DRAINS.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/.DS_Store b/mobileservice/gcc_mobile_service_uploads/asset_activity/.DS_Store deleted file mode 100644 index 166de2f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/.DS_Store and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_5_08082024115517_1-login.png b/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_5_08082024115517_1-login.png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_5_08082024115517_1-login.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_6_08082024140752_1-login (1).png b/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_6_08082024140752_1-login (1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_6_08082024140752_1-login (1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_after_3_09082024100121_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_after_3_09082024100121_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_after_3_09082024100121_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_10_08082024145025_1-login.png b/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_10_08082024145025_1-login.png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_10_08082024145025_1-login.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_11_08082024150552_1-login.png b/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_11_08082024150552_1-login.png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_11_08082024150552_1-login.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_1_08082024153444_1-login.png b/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_1_08082024153444_1-login.png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_1_08082024153444_1-login.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_1_08082024173336_1-login.png b/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_1_08082024173336_1-login.png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_1_08082024173336_1-login.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_2_08082024161158_1-login.png b/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_2_08082024161158_1-login.png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_2_08082024161158_1-login.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_2_09082024092735_1-login.png b/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_2_09082024092735_1-login.png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_2_09082024092735_1-login.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_3_08082024161506_1-login.png b/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_3_08082024161506_1-login.png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_3_08082024161506_1-login.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_7_08082024142341_1-login.png b/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_7_08082024142341_1-login.png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_7_08082024142341_1-login.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_8_08082024144658_1-login.png b/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_8_08082024144658_1-login.png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_8_08082024144658_1-login.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_9_08082024144748_1-login.png b/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_9_08082024144748_1-login.png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_activity/1/1_before_9_08082024144748_1-login.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_images/.DS_Store b/mobileservice/gcc_mobile_service_uploads/asset_images/.DS_Store deleted file mode 100644 index 166de2f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_images/.DS_Store and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_images/1/1_08082024220731_1-login_(1).png b/mobileservice/gcc_mobile_service_uploads/asset_images/1/1_08082024220731_1-login_(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_images/1/1_08082024220731_1-login_(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_images/1/1_08082024223052_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/asset_images/1/1_08082024223052_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_images/1/1_08082024223052_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/asset_images/1/1_09082024000023_box1.png b/mobileservice/gcc_mobile_service_uploads/asset_images/1/1_09082024000023_box1.png deleted file mode 100644 index ae265a2..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/asset_images/1/1_09082024000023_box1.png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/.DS_Store b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/.DS_Store deleted file mode 100644 index 267a97d..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/.DS_Store and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/1_16082024175625_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/1_16082024175625_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/1_16082024175625_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024202939_CCTNSHitsDB-APP.jpg b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024202939_CCTNSHitsDB-APP.jpg deleted file mode 100644 index 0bbb2dc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024202939_CCTNSHitsDB-APP.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024203001_CCTNSHitsDB-APP.jpg b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024203001_CCTNSHitsDB-APP.jpg deleted file mode 100644 index 0bbb2dc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024203001_CCTNSHitsDB-APP.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024203015_CCTNSHitsDB-APP.jpg b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024203015_CCTNSHitsDB-APP.jpg deleted file mode 100644 index 0bbb2dc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024203015_CCTNSHitsDB-APP.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024230717_CCTNSHitsDB-APP.jpg b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024230717_CCTNSHitsDB-APP.jpg deleted file mode 100644 index 0bbb2dc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024230717_CCTNSHitsDB-APP.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024230856_CCTNSHitsDB-APP.jpg b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024230856_CCTNSHitsDB-APP.jpg deleted file mode 100644 index 0bbb2dc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024230856_CCTNSHitsDB-APP.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024230911_CCTNSHitsDB-APP.jpg b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024230911_CCTNSHitsDB-APP.jpg deleted file mode 100644 index 0bbb2dc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024230911_CCTNSHitsDB-APP.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024230941_CCTNSHitsDB-APP.jpg b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024230941_CCTNSHitsDB-APP.jpg deleted file mode 100644 index 0bbb2dc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024230941_CCTNSHitsDB-APP.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024231147_CCTNSHitsDB-APP.jpg b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024231147_CCTNSHitsDB-APP.jpg deleted file mode 100644 index 0bbb2dc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024231147_CCTNSHitsDB-APP.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024231152_CCTNSHitsDB-APP.jpg b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024231152_CCTNSHitsDB-APP.jpg deleted file mode 100644 index 0bbb2dc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024231152_CCTNSHitsDB-APP.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024231219_CCTNSHitsDB-APP.jpg b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024231219_CCTNSHitsDB-APP.jpg deleted file mode 100644 index 0bbb2dc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024231219_CCTNSHitsDB-APP.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024231300_CCTNSHitsDB-APP.jpg b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024231300_CCTNSHitsDB-APP.jpg deleted file mode 100644 index 0bbb2dc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/after_16082024231300_CCTNSHitsDB-APP.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024175756_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024175756_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024175756_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024175759_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024175759_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024175759_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024175846_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024175846_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024175846_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024180233_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024180233_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024180233_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024180305_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024180305_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024180305_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024180341_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024180341_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024180341_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024181228_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024181228_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024181228_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024181235_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024181235_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024181235_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024193720_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024193720_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024193720_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024194322_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024194322_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024194322_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024194348_1-login(1).png b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024194348_1-login(1).png deleted file mode 100644 index dc4cf5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_16082024194348_1-login(1).png and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_19082024015425_OverAllPending.jpg b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_19082024015425_OverAllPending.jpg deleted file mode 100644 index 2a4d905..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_19082024015425_OverAllPending.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_19082024015459_OverAllPending.jpg b/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_19082024015459_OverAllPending.jpg deleted file mode 100644 index 2a4d905..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/brr_activity_images/2024/08/before_19082024015459_OverAllPending.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/default b/mobileservice/gcc_mobile_service_uploads/default deleted file mode 100644 index 7326c4f..0000000 --- a/mobileservice/gcc_mobile_service_uploads/default +++ /dev/null @@ -1,316 +0,0 @@ -## -# You should look at the following URL's in order to grasp a solid understanding -# of Nginx configuration files in order to fully unleash the power of Nginx. -# https://www.nginx.com/resources/wiki/start/ -# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/ -# https://wiki.debian.org/Nginx/DirectoryStructure -# -# In most cases, administrators will remove this file from sites-enabled/ and -# leave it as reference inside of sites-available where it will continue to be -# updated by the nginx packaging team. -# -# This file will automatically load configuration files provided by other -# applications, such as Drupal or Wordpress. These applications will be made -# available underneath a path with that package name, such as /drupal8. -# -# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. -## - -# Default server configuration -# -server { - #listen 80 default_server; - #listen [::]:80 default_server; - - # SSL configuration - # - listen 443 ssl; - listen [::]:443 ssl; - ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem; - ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key; - ssl_protocols TLSv1.2 TLSv1.3; - # listen 443 ssl default_server; - # listen [::]:443 ssl default_server; - # - # Note: You should disable gzip for SSL traffic. - # See: https://bugs.debian.org/773332 - # - # Read up on ssl_ciphers to ensure a secure configuration. - # See: https://bugs.debian.org/765782 - # - # Self signed certs generated by the ssl-cert package - # Don't use them in a production server! - # - # include snippets/snakeoil.conf; - - root /var/www/html; - - # Add index.php to the list if you are using PHP - index index.php index.html index.htm index.nginx-debian.html; - - server_name _; - - location / { - - if ($server_port = 8061) { - return 301 http://localhost/maintenance.html; - } - # First attempt to serve request as file, then - # as directory, then fall back to displaying a 404. - try_files $uri $uri/ =404; - } - -# PHPMyadmin - location /phpmyadmin { - proxy_pass http://localhost/phpmyadmin; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - } - -#MyPortal - -location /myportal { - proxy_pass http://localhost/myportal/public/index.php; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - -location /myportal/public/css { - alias /var/www/html/myportal/public/css; - } - location /myportal/public/vendor { - alias /var/www/html/myportal/public/vendor; - } - location /myportal/public/index.php/user-uploads { - alias /var/www/html/myportal/public/user-uploads; - } - - } - - location /myportal/public/css { - # alias /var/www/html/myportal/public/css; - } - location /myportal/public/vendor { - # alias /var/www/html/myportal/public/vendor; - } - location /myportal/public/index.php/user-uploads { - # alias /var/www/html/myportal/public/user-uploads; - } - -# Pet reg - location /pet { - proxy_pass http://localhost:8061; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - } - - -# Define a location block to serve files from the /home/mm/projects directory - # location /files/ { - # alias /home/mm/projects/; - # autoindex on; # Enable directory listing if needed - # } - -# Block access to files in /home/mm/projects directory - location /files/ { - deny all; - return 403; - } - - # Allow your web application to serve files from /home/mm/projects directory - location /gcc/upload_files/ { - alias /home/mm/projects/; - } - -# Makkaludan Mudhalvar - location /mm { - proxy_pass http://localhost:8070; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - - location /mm/assets/ { - #proxy_pass http://localhost:8070/assets/; - } - } - -# CM Dashboard - location /cm { - proxy_pass http://localhost:8066; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - } - -# GCC PlayStore Support - location /support { - proxy_pass http://localhost:8069; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - location /support/assets/ { - proxy_pass http://localhost:8069/assets/; - } - location /support/feedback/ { - proxy_pass http://localhost:8069/feedback/; - } - } - -# GCC Official App Mobile (gccofficialapp) - location /gccofficialapp { - proxy_pass http://localhost:8067; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - location /gccofficialapp/assets/ { - proxy_pass http://localhost:8067/assets/; - } - location /gccofficialapp/feedback/ { - proxy_pass http://localhost:8067/feedback/; - } - } - - -# Makkalai Thedi Mayor - location /mtm { - proxy_pass http://localhost:8060; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - location /mtm/assets/ { - proxy_pass http://localhost:8060/assets/; - } - location /mtm/login { - proxy_pass http://localhost:8060/login; - } - location /mtm/api/ { - proxy_pass http://localhost:8060/api/; - } - } -# QR Service - GCC Asset Feedback - location /qrfeedback { - proxy_pass http://localhost:8065/public-feedback; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - location /qrfeedback/assets/ { - proxy_pass http://localhost:8065/assets/; - } - location /qrfeedback/api/ { - proxy_pass http://localhost:8065/api/; - } - } - -# GCC Portal - location /gcc { - proxy_pass http://localhost:8064/gcc; - proxy_connect_timeout 120s; - proxy_read_timeout 240s; - proxy_send_timeout 10s; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - location /gcc/assets/ { - proxy_pass http://localhost:8064/assets/; - } - #For Upload file - location /gcc/uploads/ { - alias /home/mm/projects/gccoffice_uploads/; - #autoindex on; # Enable directory listing if needed - } - } - -# Election Portal - location /election { - proxy_pass http://localhost:8065/election; - proxy_connect_timeout 120s; - proxy_read_timeout 240s; - proxy_send_timeout 10s; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - location /election/assets/ { - proxy_pass http://localhost:8065/assets/; - } - #For Upload file - location /election/uploads/ { - alias /home/mm/projects/election_uploads/; - #autoindex on; # Enable directory listing if needed - } - } - -# Hall Booking - location /communityhall { - proxy_pass http://localhost:8062; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - - location /communityhall/assets/ { - proxy_pass http://localhost:8062/assets/; - } - #For Upload file - location /communityhall/images/ { - alias /home/mm/projects/communityHallDocuments/; - #autoindex on; # Enable directory listing if needed - } - } -#location /support/assets/ { - # proxy_pass http://localhost:8069/assets/; - # proxy_buffering off; - # proxy_set_header X-Real-IP $remote_addr; - # proxy_set_header X-Forwarded-Host $host; - # proxy_set_header X-Forwarded-Port $server_port; - #} - # pass PHP scripts to FastCGI server - # - #location ~ \.php$ { - # include snippets/fastcgi-php.conf; - # - # # With php-fpm (or other unix sockets): - # fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; - # # With php-cgi (or other tcp sockets): - # fastcgi_pass 127.0.0.1:9000; - #} - - # deny access to .htaccess files, if Apache's document root - # concurs with nginx's one - # - #location ~ /\.ht { - # deny all; - #} -} - - -# Virtual Host configuration for example.com -# -# You can move that to a different file under sites-available/ and symlink that -# to sites-enabled/ to enable it. -# -#server { -# listen 80; -# listen [::]:80; -# -# server_name example.com; -# -# root /var/www/example.com; -# index index.html; -# -# location / { -# try_files $uri $uri/ =404; -# } -#} diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2/2_04092024201313_CCTNSHitsDB-APP.jpg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2/2_04092024201313_CCTNSHitsDB-APP.jpg deleted file mode 100644 index 0bbb2dc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2/2_04092024201313_CCTNSHitsDB-APP.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2/2_05092024084212_CCTNSHitsDB-APP.jpg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2/2_05092024084212_CCTNSHitsDB-APP.jpg deleted file mode 100644 index 0bbb2dc..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2/2_05092024084212_CCTNSHitsDB-APP.jpg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024141630_WhatsAppImage2024-08-30at12.49.03(2).jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024141630_WhatsAppImage2024-08-30at12.49.03(2).jpeg deleted file mode 100644 index 23d6d08..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024141630_WhatsAppImage2024-08-30at12.49.03(2).jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024141759_WhatsAppImage2024-08-30at12.49.03(2).jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024141759_WhatsAppImage2024-08-30at12.49.03(2).jpeg deleted file mode 100644 index 23d6d08..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024141759_WhatsAppImage2024-08-30at12.49.03(2).jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024141932_WhatsAppImage2024-08-30at12.49.03(2).jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024141932_WhatsAppImage2024-08-30at12.49.03(2).jpeg deleted file mode 100644 index 23d6d08..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024141932_WhatsAppImage2024-08-30at12.49.03(2).jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024141949_WhatsAppImage2024-08-30at12.49.03(2).jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024141949_WhatsAppImage2024-08-30at12.49.03(2).jpeg deleted file mode 100644 index 23d6d08..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024141949_WhatsAppImage2024-08-30at12.49.03(2).jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024142024_WhatsAppImage2024-08-30at12.49.03(2).jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024142024_WhatsAppImage2024-08-30at12.49.03(2).jpeg deleted file mode 100644 index 23d6d08..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/challan_2_06092024142024_WhatsAppImage2024-08-30at12.49.03(2).jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/close_3_06092024145251_WhatsAppImage2024-08-30at12.49.03(2).jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/close_3_06092024145251_WhatsAppImage2024-08-30at12.49.03(2).jpeg deleted file mode 100644 index 23d6d08..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/close_3_06092024145251_WhatsAppImage2024-08-30at12.49.03(2).jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/close_3_06092024145350_WhatsAppImage2024-08-30at12.49.03(2).jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/close_3_06092024145350_WhatsAppImage2024-08-30at12.49.03(2).jpeg deleted file mode 100644 index 23d6d08..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/close_3_06092024145350_WhatsAppImage2024-08-30at12.49.03(2).jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/close_3_06092024145558_WhatsAppImage2024-08-30at12.49.03(2).jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/close_3_06092024145558_WhatsAppImage2024-08-30at12.49.03(2).jpeg deleted file mode 100644 index 23d6d08..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/close_3_06092024145558_WhatsAppImage2024-08-30at12.49.03(2).jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_1_05092024154815_pan-card.jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_1_05092024154815_pan-card.jpeg deleted file mode 100644 index 267dd5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_1_05092024154815_pan-card.jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_1_05092024154847_pan-card.jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_1_05092024154847_pan-card.jpeg deleted file mode 100644 index 267dd5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_1_05092024154847_pan-card.jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_1_05092024154857_pan-card.jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_1_05092024154857_pan-card.jpeg deleted file mode 100644 index 267dd5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_1_05092024154857_pan-card.jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_3_05092024155003_pan-card.jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_3_05092024155003_pan-card.jpeg deleted file mode 100644 index 267dd5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_3_05092024155003_pan-card.jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_3_05092024155206_pan-card.jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_3_05092024155206_pan-card.jpeg deleted file mode 100644 index 267dd5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_3_05092024155206_pan-card.jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_3_05092024155229_pan-card.jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_3_05092024155229_pan-card.jpeg deleted file mode 100644 index 267dd5f..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/2024/09/fine_3_05092024155229_pan-card.jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175449_WhatsAppImage2024-09-21at18.40.47.jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175449_WhatsAppImage2024-09-21at18.40.47.jpeg deleted file mode 100644 index 7da9ce8..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175449_WhatsAppImage2024-09-21at18.40.47.jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175541_WhatsAppImage2024-09-21at18.40.47.jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175541_WhatsAppImage2024-09-21at18.40.47.jpeg deleted file mode 100644 index 7da9ce8..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175541_WhatsAppImage2024-09-21at18.40.47.jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175630_WhatsAppImage2024-09-21at18.40.47.jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175630_WhatsAppImage2024-09-21at18.40.47.jpeg deleted file mode 100644 index 7da9ce8..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175630_WhatsAppImage2024-09-21at18.40.47.jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175742_WhatsAppImage2024-09-21at18.40.47.jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175742_WhatsAppImage2024-09-21at18.40.47.jpeg deleted file mode 100644 index 7da9ce8..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175742_WhatsAppImage2024-09-21at18.40.47.jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175839_WhatsAppImage2024-09-21at18.40.47.jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175839_WhatsAppImage2024-09-21at18.40.47.jpeg deleted file mode 100644 index 7da9ce8..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024175839_WhatsAppImage2024-09-21at18.40.47.jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024180236_WhatsAppImage2024-09-21at18.40.47.jpeg b/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024180236_WhatsAppImage2024-09-21at18.40.47.jpeg deleted file mode 100644 index 7da9ce8..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/penalty_activity/pos/2024/09/challan_1_30092024180236_WhatsAppImage2024-09-21at18.40.47.jpeg and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/sos_rescue_activity_images/.DS_Store b/mobileservice/gcc_mobile_service_uploads/sos_rescue_activity_images/.DS_Store deleted file mode 100644 index 267a97d..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/sos_rescue_activity_images/.DS_Store and /dev/null differ diff --git a/mobileservice/gcc_mobile_service_uploads/sos_rescue_activity_images/2024/08/24/1_24082024131015_300000-Page1-16884680450038429284263760162296.jpg b/mobileservice/gcc_mobile_service_uploads/sos_rescue_activity_images/2024/08/24/1_24082024131015_300000-Page1-16884680450038429284263760162296.jpg deleted file mode 100644 index 1df2782..0000000 Binary files a/mobileservice/gcc_mobile_service_uploads/sos_rescue_activity_images/2024/08/24/1_24082024131015_300000-Page1-16884680450038429284263760162296.jpg and /dev/null differ diff --git a/mobileservice/pom.xml b/mobileservice/pom.xml index e1cfa2f..23308bc 100644 --- a/mobileservice/pom.xml +++ b/mobileservice/pom.xml @@ -109,6 +109,12 @@ 1.5.7 + + org.apache.poi + poi-ooxml + 5.2.3 + + diff --git a/mobileservice/src/.DS_Store b/mobileservice/src/.DS_Store index 3fa9e7e..41362cc 100644 Binary files a/mobileservice/src/.DS_Store and b/mobileservice/src/.DS_Store differ diff --git a/mobileservice/src/main/.DS_Store b/mobileservice/src/main/.DS_Store index b9a0adb..44b9c1e 100644 Binary files a/mobileservice/src/main/.DS_Store and b/mobileservice/src/main/.DS_Store differ diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/1_approved.jpg b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/1_approved.jpg new file mode 100644 index 0000000..1c44c29 Binary files /dev/null and b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/1_approved.jpg differ diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/1_rejected.jpg b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/1_rejected.jpg new file mode 100644 index 0000000..dbe75ba Binary files /dev/null and b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/1_rejected.jpg differ diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/AppConfig.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/AppConfig.java index 95b0ab7..2dc6828 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/AppConfig.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/AppConfig.java @@ -7,16 +7,15 @@ import org.springframework.web.client.RestTemplate; @Configuration public class AppConfig { - public String qrAssetFeedback = "http://localhost:8063"; - public String mtm = "http://localhost:8060"; - public String petRegistration = "http://localhost:8061"; - public String garbageCollection = "http://localhost:8067"; //117.232.67.158 + public String qrAssetFeedback = "http://117.232.67.158:8063"; + public String mtm = "http://117.232.67.158:8060"; + public String petRegistration = "http://117.232.67.158:8061"; + public String garbageCollection = "http://117.232.67.158:8067"; //117.232.67.158 public String gccappsMysqlPassword = ""; @Bean public RestTemplate restTemplate() { return new RestTemplate(); - } - + } } \ No newline at end of file diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/DataSourceConfig.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/DataSourceConfig.java index 3b89a47..d06d9b3 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/DataSourceConfig.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/configuration/DataSourceConfig.java @@ -74,11 +74,11 @@ public class DataSourceConfig { //////////////////////////////(For GCC Activity Master) //////////////////////// @Bean(name = "mysqlActivityDataSource") public DataSource mysqlActivityDataSource() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://"+host+"/gcc_activity"); - dataSource.setUsername("root"); - dataSource.setPassword(dbpassword); + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://"+host+"/gcc_activity"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); return dataSource; } @@ -93,81 +93,92 @@ public class DataSourceConfig { return dataSource; } + //////////////////////////////(For Cattle Catch Master) //////////////////////// + @Bean(name = "mysqlCattleCatchDataSource") + public DataSource mysqlCattleCatchDataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://"+host+"/gcc_penalty"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); + return dataSource; + } + + //////////////////////////////(For PGR Master) //////////////////////// @Bean(name = "mysqlPGRMasterDataSource") public DataSource mysqlPGRMasterDataSource() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://"+host+"/erp_pgr"); - dataSource.setUsername("root"); - dataSource.setPassword(dbpassword); + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://"+host+"/erp_pgr"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); return dataSource; } //////////////////////////////(For PGR Master) //////////////////////// @Bean(name = "mysqlGCCUserDataSource") public DataSource mysqlGCCUserDataSource() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://"+host+"/gcc_users"); - dataSource.setUsername("root"); - dataSource.setPassword(dbpassword); + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://"+host+"/gcc_users"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); return dataSource; } - //////////////////////////////(For PGR Master) //////////////////////// @Bean(name = "mysqlGccSOSDataSource") public DataSource mysqlGccSOSDataSource() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://"+host+"/gcc_sos"); - dataSource.setUsername("root"); - dataSource.setPassword(dbpassword); + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://"+host+"/gcc_sos"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); return dataSource; } //////////////////////////////(For NULM Staff) //////////////////////// @Bean(name = "mysqlNulmDataSource") public DataSource mysqlNulmDataSource() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://"+host+"/gcc_nulm"); - dataSource.setUsername("root"); - dataSource.setPassword(dbpassword); + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://"+host+"/gcc_nulm"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); return dataSource; } //////////////////////////////(For Stray Dog (veterinary)) //////////////////////// @Bean(name = "mysqlGccStraydogsDataSource") public DataSource mysqlGccStraydogsDataSource() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://"+host+"/gcc_stray_dogs"); - dataSource.setUsername("root"); - dataSource.setPassword(dbpassword); + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://"+host+"/gcc_stray_dogs"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); return dataSource; } //////////////////////////////(For Schools) //////////////////////// @Bean(name = "mysqlGccSchoolsDataSource") public DataSource mysqlGccSchoolsDataSource() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://"+host+"/gcc_schools"); - dataSource.setUsername("root"); - dataSource.setPassword(dbpassword); + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://"+host+"/gcc_schools"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); return dataSource; } //////////////////////////////(For Parks and Playground) //////////////////////// @Bean(name = "mysqlGccParksDataSource") public DataSource mysqlGccParksDataSource() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://"+host+"/gcc_parks_playground"); - dataSource.setUsername("root"); - dataSource.setPassword(dbpassword); + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://"+host+"/gcc_parks_playground"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); return dataSource; } diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/controller/APIOfficialController.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/controller/APIOfficialController.java index f7b5d9c..3cfe2d6 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/controller/APIOfficialController.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/controller/APIOfficialController.java @@ -35,6 +35,11 @@ public class APIOfficialController { return officialAPIService.versionCheck(); } + @GetMapping({"/nammaVersionCheck"}) // Template + public List nammaVersionCheck() { + return officialAPIService.nammaVersionCheck(); + } + // API FOR TOTHER APP @GetMapping(value="/sendOTP") public List sendOTP(HttpServletRequest request, diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/controller/ParksController.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/controller/ParksController.java index 9ba9015..9112fe1 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/controller/ParksController.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/controller/ParksController.java @@ -1,31 +1,38 @@ 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; -@Controller@RequestMapping("/gccofficialapp/api/parks") +@RequestMapping("/gccofficialapp/api/parks") @RestController("gccofficalapparksrest") public class ParksController { - + @Autowired private ParksService parksService; - + @GetMapping("/saveAssets") public List saveAssets(@RequestParam MultiValueMap formData, @RequestParam(value = "categoryId", required = false) String categoryId, - @RequestParam(value = "assetTypeId", required = false) String assetTypeId, - @RequestParam(value = "latitude", required = false) String latitude, + @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, @@ -33,21 +40,870 @@ public class ParksController { @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); + @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 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); + @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 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 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 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 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 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 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 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>> location(@RequestParam("latitude") String latitude, + @RequestParam("longitude") String longitude, @RequestParam("enumeration_type") String enumeration_type) throws Exception { + List> 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>> + * parkname() throws Exception { List> parkName = + * parksService.parkName(); + * + * return ResponseEntity.ok(parkName); } + */ + + @GetMapping("/parkname") + public ResponseEntity>> parkname(@RequestParam("latitude") String latitude, + @RequestParam("longitude") String longitude) throws Exception { + + List> dataByLocation = parksService.getReadingZoneParkByLocation(latitude, longitude, + latitude); + + return ResponseEntity.ok(dataByLocation); + + } + + // -----------------------------------------------Feedback + // API----------------------------------------------------------------- + + @PostMapping("/centerMedianFeedback") + public ResponseEntity 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 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 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 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 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 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 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 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>> enuumerationType() { + List> parkName = parksService.categoryType(); + return ResponseEntity.ok(parkName); + } + + // To fetch master category type based on enumeration type + @GetMapping("/masterCategoryType") + public ResponseEntity>> masterCategoryType( + @RequestParam("enumeration_type_id") String Cat_enumeration_id) { + List> parkName = parksService.masterCategoryType(Cat_enumeration_id); + return ResponseEntity.ok(parkName); + } + + // To fetch sub category type based on master category type + @GetMapping("/subCategoryType") + public ResponseEntity>> subCategoryType( + @RequestParam("master_category_id") String masterCategory) { + + List> parkName = parksService.subCategoryType(masterCategory); + return ResponseEntity.ok(parkName); + } + + // ------------------------------------------Tree Feedback + // API----------------------------------------------------- + + @PostMapping("/treeDetails") + public ResponseEntity> 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 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> 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 saveTreeDetailes = parksService.SaveimageDetailes(enumeration_type, latitude, longitude, + userId, tree_Image, tree_id); + return ResponseEntity.ok(saveTreeDetailes); + + } + + // ------------------------------------------Enumeration Report + // API----------------------------------------------------- + + @GetMapping("/zoneCount") + public ResponseEntity>> getZoneCount(@RequestParam("fromdate") String fromdate, + @RequestParam("todate") String todate, @RequestParam("enumeration_type") String enumeration_type, + @RequestParam("userId") String userId) throws Exception { + + List> 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>> 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> 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>> getActivityCount(@RequestParam("ward") String ward, + @RequestParam("fromdate") String fromdate, @RequestParam("todate") String todate, + @RequestParam("enumeration_type") String enumeration_type) throws Exception { + + List> 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>> 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> 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>>> getInspectionDetails( + @RequestParam("activityId") String activityId, @RequestParam("fromdate") String fromdate, + @RequestParam("todate") String todate, @RequestParam("enumerationId") String enumerationId) + throws Exception { + + List>> 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>> 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> 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>>> 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>> 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>> getWishtreeZoneCount(@RequestParam("fromdate") String fromdate, + @RequestParam("todate") String todate, @RequestParam("enumeration_type") String enumeration_type, + @RequestParam("userId") String userId) throws Exception { + + List> 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>> 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> 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>> getwardWishTreedata(@RequestParam("ward") String ward, + @RequestParam("userId") String userId) throws Exception { + + List> dateByLocation = parksService.getwardWishTreedata(ward); + if (dateByLocation == null || dateByLocation.isEmpty()) { + throw new NoDataException("no data "); + } + return ResponseEntity.ok(dateByLocation); + + } + + @GetMapping("/getTreeWardWiseCountDetails") + public ResponseEntity>> getTreeWardWiseCountDetails(@RequestParam("ward") String ward, + @RequestParam("enumeration_type") String enumeration_type,@RequestParam("fromdate") String fromdate, + @RequestParam("todate") String todate) throws Exception { + + List> 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>> getTreeImageDetails(@RequestParam("tree_Id") String tree_Id, + @RequestParam("enumeration_type") String enumeration_type, @RequestParam("fromdate") String fromdate, + @RequestParam("todate") String todate) throws Exception { + + List> 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>> getTreeDetails(@RequestParam("tree_Id") String tree_Id, + @RequestParam("userId") String userId) throws Exception { + + List> dateByLocation = parksService.getTreeDetails(tree_Id); + if (dateByLocation == null || dateByLocation.isEmpty()) { + throw new NoDataException("no data "); + } + return ResponseEntity.ok(dateByLocation); + + } + + // feedback + + @GetMapping("/enumerationFeedback") + public ResponseEntity>> getEnumerationFeedback( + @RequestParam("enumerationId") String enumerationId, + @RequestParam("enumeration_type") String enumeration_type) throws Exception { + + List> 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>> 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> 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>> 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> 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>> getUserBasedEnum( +// @RequestParam("latitude") String tree_latitude,@RequestParam("longitude") String tree_longitude,@RequestParam("Status") String tree_Status +// ) +// { +// +// List> 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>> getparkNameByRadius(@RequestParam("latitude") String tree_latitude, + @RequestParam("longitude") String tree_longitude) { + + List> 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>> getTreeDetailsBasedonLocation( + @RequestParam("parkName") String parkName, @RequestParam("location") String location, + @RequestParam("ward") String ward) throws Exception { + + List> 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>> getparkNameByEnumType(@RequestParam("enum_Type") int enum_Type, + @RequestParam("latitude") String latitude, @RequestParam("longitude") String longitude){ + + List> 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 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>> getFlowringZoneData(@RequestParam("enumeration_type") String enumeration_type, + @RequestParam("fromdate") String fromdate, @RequestParam("todate") String todate, + @RequestParam(value="userId", required = false) String userId){ + + List> 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>> 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> 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>> 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> 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>> 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> 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); + + } } diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/ErrorResponse.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/ErrorResponse.java new file mode 100644 index 0000000..6a7cd29 --- /dev/null +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/ErrorResponse.java @@ -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; + } +} + diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/GlobalExceptionHandler.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/GlobalExceptionHandler.java new file mode 100644 index 0000000..5d6c052 --- /dev/null +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/GlobalExceptionHandler.java @@ -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 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 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 noDataException(NoDataException ex){ + + ErrorResponse errorResponse = new ErrorResponse(HttpStatus.NOT_FOUND.value(),ex.getMessage()); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(errorResponse); + + + } +} diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/NoDataException.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/NoDataException.java new file mode 100644 index 0000000..5712128 --- /dev/null +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/NoDataException.java @@ -0,0 +1,8 @@ +package in.gov.chennaicorporation.mobileservice.gccparks.service; + +public class NoDataException extends RuntimeException { + + public NoDataException(String msg){ + super(msg); + } +} diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/ParksService.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/ParksService.java index cd3e292..f0bec74 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/ParksService.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccparks/service/ParksService.java @@ -16,6 +16,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.ArrayList; import javax.imageio.ImageIO; import javax.imageio.ImageWriteParam; @@ -43,207 +44,1957 @@ import in.gov.chennaicorporation.mobileservice.gccactivity.service.DateTimeUtil; public class ParksService { private JdbcTemplate jdbcParkseTemplate; - + 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(); - + private static final int STRING_LENGTH = 15; + private static final Random RANDOM = new SecureRandom(); + @Autowired public void setDataSource(@Qualifier("mysqlGccParksDataSource") DataSource parksDataSource) { this.jdbcParkseTemplate = new JdbcTemplate(parksDataSource); } - + @Autowired public ParksService(Environment environment) { this.environment = environment; - this.fileBaseUrl=environment.getProperty("fileBaseUrl"); + 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(); - } - + 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); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(byteArrayOutputStream); - ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next(); - writer.setOutput(imageOutputStream); + ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next(); + writer.setOutput(imageOutputStream); - ImageWriteParam param = writer.getDefaultWriteParam(); - if (param.canWriteCompressed()) { - param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); - param.setCompressionQuality(quality); - } + 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.write(null, new javax.imageio.IIOImage(image, null, null), param); - writer.dispose(); - imageOutputStream.close(); + writer.dispose(); + imageOutputStream.close(); + + return byteArrayOutputStream.toByteArray(); + } - 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("parks_playground_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, bytes); - - System.out.println(filePath); - return filepath_txt; - - } catch (IOException e) { - e.printStackTrace(); - return "Failed to save file " + file.getOriginalFilename(); - } + String uploadDirectory = environment.getProperty("file.upload.directory"); + String serviceFolderName = environment.getProperty("parks_playground_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> saveAsset( - MultiValueMap formData, - String categoryId, - String assetTypeId, - String latitude, - String longitude, - String zone, - String ward, - String streeId, - String streetName, - String loginId, - String name, - MultipartFile file) { - List> result=null; + public List> saveAsset(MultiValueMap formData, String categoryId, + String assetTypeId, String latitude, String longitude, String zone, String ward, String streeId, + String streetName, String loginId, String name, MultipartFile file) { + List> result = null; Map response = new HashMap<>(); int lastInsertId = 0; - - String image = fileUpload(categoryId,assetTypeId,file); - + + String image = fileUpload(categoryId, assetTypeId, file); + String sqlQuery = "INSERT INTO `asset_list`(`category_id`, `assettype_id`, `name`, `image`, `latitude`, `longitude`, " - + "`zone`, `ward`, `streetid`, `streetname`, `cby`) " - + "VALUES (?,?,?,?,?,?,?,?,?,?,?)"; - + + "`zone`, `ward`, `streetid`, `streetname`, `cby`) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?)"; + KeyHolder keyHolder = new GeneratedKeyHolder(); - + try { - int affectedRows = jdbcParkseTemplate.update(new PreparedStatementCreator() { - @Override - public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { - PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[]{"id"}); - ps.setString(1, categoryId); - ps.setString(2, assetTypeId); - ps.setString(3, name); - ps.setString(4, image); - ps.setString(5, latitude); - ps.setString(6, longitude); - ps.setString(7, zone); - ps.setString(8, ward); - ps.setString(9, streeId); - ps.setString(10, streetName); - ps.setString(11, loginId); - 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); - } - + int affectedRows = jdbcParkseTemplate.update(new PreparedStatementCreator() { + @Override + public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { + PreparedStatement ps = connection.prepareStatement(sqlQuery, new String[] { "id" }); + ps.setString(1, categoryId); + ps.setString(2, assetTypeId); + ps.setString(3, name); + ps.setString(4, image); + ps.setString(5, latitude); + ps.setString(6, longitude); + ps.setString(7, zone); + ps.setString(8, ward); + ps.setString(9, streeId); + ps.setString(10, streetName); + ps.setString(11, loginId); + 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> loadAssetByFilter(String categoryId, String assetTypeId, String latitude, String longitude ){ - + public List> loadAssetByFilter(String categoryId, String assetTypeId, String latitude, + String longitude) { + String sqlWhere = "1=1"; - - if(categoryId!=null && !categoryId.isBlank() && !categoryId.isEmpty()){ - sqlWhere += " AND ai.category_id='"+categoryId+"'"; + + if (categoryId != null && !categoryId.isBlank() && !categoryId.isEmpty()) { + sqlWhere += " AND ai.category_id='" + categoryId + "'"; } - - if(categoryId!=null && !assetTypeId.isBlank() && !assetTypeId.isEmpty()){ - sqlWhere += " AND ai.assettype_id='"+assetTypeId+"'"; - } - if(latitude!=null && longitude!=null && !latitude.isBlank() && !latitude.isEmpty() && !longitude.isBlank() && !longitude.isEmpty()){ - sqlWhere += " AND ((6371008.8 * acos(ROUND(cos(radians("+latitude+")) * cos(radians(al.latitude)) * cos(radians(al.longitude) - radians("+longitude+")) + sin(radians("+latitude+")) * sin(radians(al.latitude)), 9))) < 500) "; + + if (categoryId != null && !assetTypeId.isBlank() && !assetTypeId.isEmpty()) { + sqlWhere += " AND ai.assettype_id='" + assetTypeId + "'"; } - - String sqlQuery="SELECT al.`id`, al.`category_id`, al.`assettype_id`, al.`name`, al.`latitude`, al.`longitude`, al.`zone`, " - + "al.`ward`, al.`streetid`, al.`streetname`, " - + "CONCAT('"+fileBaseUrl+"/gccofficialapp/files/', al.image) AS imageUrl " - + "FROM asset_list al WHERE "+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(al.latitude)) * cos(radians(al.longitude) - radians(" + longitude + + ")) + sin(radians(" + latitude + ")) * sin(radians(al.latitude)), 9))) < 500) "; + } + + String sqlQuery = "SELECT al.`id`, al.`category_id`, al.`assettype_id`, al.`name`, al.`latitude`, al.`longitude`, al.`zone`, " + + "al.`ward`, al.`streetid`, al.`streetname`, " + "CONCAT('" + fileBaseUrl + + "/gccofficialapp/files', al.image) AS imageUrl " + "FROM asset_list al WHERE " + sqlWhere; + List> result = jdbcParkseTemplate.queryForList(sqlQuery); return result; } + + // ----------------------------------------------Enumeration + // API------------------------------------------------ + + public int centerMedianEnumeration(String enterParkName, int maintained_By, Double enu_Area_Meters, + int typeofCenterMedian, String latitude, String longitude, String zone, String ward, String location, + String userId, MultipartFile photo, String enumeration_type) throws Exception { + int enumerationImg_Id_master = centerMedianEnum(enterParkName, maintained_By, enu_Area_Meters, + typeofCenterMedian, latitude, longitude, zone, ward, location, userId, enumeration_type); + String name = "centerMedian " + enumerationImg_Id_master; + String imgId = Integer.toString(enumerationImg_Id_master); + try { + String ImageUrl = fileUpload(name, imgId, photo); + // System.out.println("===========................" + ImageUrl); + saveImageForEnumeration(enumerationImg_Id_master, ImageUrl); + return enumerationImg_Id_master; + } catch (Exception e) { + throw new Exception("Error in image saving" + e); + } + } + + private String saveImageForEnumeration(int enumerationImg_Id_master, String imageUrl) { + String sql = "INSERT INTO enumertion_images (photos_enu, enumerationImg_Id_master)" + "VALUES (?, ?)"; + // Execute SQL query to save feedback for the provided question + jdbcParkseTemplate.update(sql, imageUrl, enumerationImg_Id_master); + + return "success"; + } + + private int centerMedianEnum(String enterParkName, int maintained_By, Double enu_Area_Meters, + int typeofCenterMedian, String latitude, String longitude, String zone, String ward, String location, + String userId, String enumeration_type) { + + String sql = "INSERT INTO enumeration_master (park_name, maintained_By, Enu_Area_Meters, Cen_tra_Median_Type, latitude, longitude, zone, ward, location, userId, enumeration_type, cdate, is_Active, is_Delete) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, TRUE, FALSE)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + try { + jdbcParkseTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, new String[] { "enumeration_Id" }); + ps.setString(1, enterParkName); // park_name + ps.setInt(2, maintained_By); // maintained_by_id + ps.setDouble(3, enu_Area_Meters); // Enu_Area_Meters + ps.setInt(4, typeofCenterMedian); // center_median_type_id + ps.setString(5, latitude); // latitude + ps.setString(6, longitude); // longitude + ps.setString(7, zone); // zone + ps.setString(8, ward); // ward + ps.setString(9, location); // loction + ps.setString(10, userId); // userId + ps.setString(11, enumeration_type); // enumeration_type + return ps; + }, keyHolder); + System.out.println("img id master:" + keyHolder.getKey().intValue()); + // Retrieve the auto-generated ID and return it + return keyHolder.getKey().intValue(); + } catch (Exception e) { + e.printStackTrace(); + } + return -1; // Return error indicator + } + + public int trafficIslandEnumeration(int maintainedById, Double enu_Area_Meters, int Type_of_Traffic_Island, + String latitude, String longitude, String zone, String ward, String location, String userId, + MultipartFile photo, String enumeration_type) throws Exception { + int enumerationImg_Id_master = trafficIslandEnum(maintainedById, enu_Area_Meters, Type_of_Traffic_Island, + latitude, longitude, zone, ward, location, userId, enumeration_type); + String name = "trafficIsland " + enumerationImg_Id_master; + String imgId = Integer.toString(enumerationImg_Id_master); + try { + String ImageUrl = fileUpload(name, imgId, photo); + // System.out.println("===========................" + ImageUrl); + saveImageForEnumeration(enumerationImg_Id_master, ImageUrl); + return enumerationImg_Id_master; + } catch (Exception e) { + throw new Exception("Error in image saving " + e); + } + + } + + private int trafficIslandEnum(int maintainedById, Double enu_Area_Meters, int type_of_Traffic_Island, + String latitude, String longitude, String zone, String ward, String location, String userId, + String enumeration_type) { + + String sql = "INSERT INTO enumeration_master (maintained_By, Enu_Area_Meters, Cen_tra_Median_Type, latitude, longitude, zone, ward, location, userId, enumeration_type, cdate, is_Active, is_Delete) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, TRUE, FALSE)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + try { + jdbcParkseTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, new String[] { "enumeration_Id" }); + ps.setInt(1, maintainedById); // maintained_by_id + ps.setDouble(2, enu_Area_Meters); // Enu_Area_Meters + ps.setInt(3, type_of_Traffic_Island); // center_median_type_id + ps.setString(4, latitude); // latitude + ps.setString(5, longitude); // longitude + ps.setString(6, zone); // zone + ps.setString(7, ward); // ward + ps.setString(8, location); // loction + ps.setString(9, userId); // userId + ps.setString(10, enumeration_type); // enumeration_type + return ps; + + }, keyHolder); + // System.out.println("img id master:"+keyHolder.getKey().intValue()); + // Retrieve the auto-generated ID and return it + return keyHolder.getKey().intValue(); + } catch (Exception e) { + e.printStackTrace(); + } + + return -1; // Return error indicator + } + + public int parkEnumeration(String enterParkName, int maintained_By, String latitude, String longitude, String zone, + String ward, String location, String userId, MultipartFile photo, String zone_Available, + String enumeration_type) throws Exception { + + int enumerationImg_Id_master = parkEnum(enterParkName, maintained_By, latitude, longitude, zone, ward, location, + userId, photo, zone_Available, enumeration_type); + // System.out.println("enumerationImg_Id_master"+enumerationImg_Id_master); + String name = "parkEnumeration " + enumerationImg_Id_master; + String imgId = Integer.toString(enumerationImg_Id_master); + // String imgId = enumerationImg_Id_master+""; + + try { + String ImageUrl = fileUpload(name, imgId, photo); + // System.out.println("===========................" + ImageUrl); + saveImageForEnumeration(enumerationImg_Id_master, ImageUrl); + return enumerationImg_Id_master; + } catch (Exception e) { + throw new Exception("Error in image saving" + e); + } + + } + + private int parkEnum(String enterParkName, int maintained_By, String latitude, String longitude, String zone, + String ward, String location, String userId, MultipartFile photo, String zone_Available, + String enumeration_type) { + // System.out.println("Check1"); + String sql = "INSERT INTO enumeration_master (maintained_By, latitude, longitude, zone, ward, location, userId,park_name, Zone_Available,enumeration_type, cdate, is_Active, is_Delete) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?,?,?, CURRENT_TIMESTAMP, TRUE, FALSE)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + System.out.println("Check2"); + + try { + + jdbcParkseTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, new String[] { "enumeration_Id" }); // Primary + // key + // column + + // Set the parameters in the correct order (index starts at 1) + ps.setInt(1, maintained_By); // maintained_By + ps.setString(2, latitude); // latitude + ps.setString(3, longitude); // longitude + ps.setString(4, zone); // zone + ps.setString(5, ward); // ward + ps.setString(6, location); // loction + ps.setString(7, userId); // userId + ps.setString(8, enterParkName); + ps.setString(9, zone_Available); + ps.setString(10, enumeration_type);// park_name + return ps; + }, keyHolder); + + // Retrieve the auto-generated ID (primary key) and return it + return keyHolder.getKey().intValue(); + } catch (Exception e) { + e.printStackTrace(); + } + + return -1; // Return error indicator + } + + public int beautificationRoad(String latitude, String longitude, String zone, String ward, String location, + String userId, MultipartFile photo, String enumeration_type) throws Exception { + + int enumerationImg_Id_master = beautifiRoad(latitude, longitude, zone, ward, location, userId, photo, + enumeration_type); + String name = "beautificationRoad " + enumerationImg_Id_master; + String imgId = Integer.toString(enumerationImg_Id_master); + try { + String ImageUrl = fileUpload(name, imgId, photo); + // System.out.println("===========................" + ImageUrl); + saveImageForEnumeration(enumerationImg_Id_master, ImageUrl); + return enumerationImg_Id_master; + } catch (Exception e) { + throw new Exception("Error in image saving"); + } + } + + private int beautifiRoad(String latitude, String longitude, String zone, String ward, String location, + String userId, MultipartFile photo, String enumeration_type) { + + // SQL query with placeholders for parameters + String sql = "INSERT INTO enumeration_master ( latitude, longitude, zone, ward, location, userId,enumeration_type, cdate, is_Active, is_Delete) " + + "VALUES ( ?, ?, ?, ?, ?, ?,?, CURRENT_TIMESTAMP, TRUE, FALSE)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + try { + jdbcParkseTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, new String[] { "enumeration_Id" }); // Primary + // key + // column + + // Set the parameters in the correct order (index starts at 1) +// ps.setString(1, area); // Area + ps.setString(1, latitude); // latitude + ps.setString(2, longitude); // longitude + ps.setString(3, zone); // zone + ps.setString(4, ward); // ward + ps.setString(5, location); // loction + ps.setString(6, userId); + ps.setString(7, enumeration_type); // userId + return ps; + }, keyHolder); + + // Retrieve the auto-generated ID (primary key) and return it + return keyHolder.getKey().intValue(); + } catch (Exception e) { + e.printStackTrace(); + } + + return -1; // Return error indicator + } + + public int readingZone(String latitude, String longitude, String zone, String ward, String location, String userId, + MultipartFile photo, String enumeration_type, String park_name) throws Exception { + + int enumerationImg_Id_master = parkEnumReadingZone(latitude, longitude, zone, ward, location, userId, photo, + enumeration_type, park_name); + String name = "readingZone " + enumerationImg_Id_master; + String imgId = Integer.toString(enumerationImg_Id_master); + try { + String ImageUrl = fileUpload(name, imgId, photo); + // System.out.println("===========................" + ImageUrl); + saveImageForEnumeration(enumerationImg_Id_master, ImageUrl); + return enumerationImg_Id_master; + } catch (Exception e) { + throw new Exception("Error in image saving"); + } + + } + + private int parkEnumReadingZone(String latitude, String longitude, String zone, String ward, String location, + String userId, MultipartFile photo, String enumeration_type, String park_name) { + + String sql = "INSERT INTO enumeration_master ( latitude, longitude, zone, ward, location, userId,enumeration_type,park_name, cdate, is_Active, is_Delete) " + + "VALUES ( ?, ?, ?, ?, ?, ?,?,?, CURRENT_TIMESTAMP, TRUE, FALSE)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + try { + jdbcParkseTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, new String[] { "enumeration_Id" }); // Primary + // key + // column + + // Set the parameters in the correct order (index starts at 1) +// ps.setString(1, zone_Available_name); // Area + ps.setString(1, latitude); // latitude + ps.setString(2, longitude); // longitude + ps.setString(3, zone); // zone + ps.setString(4, ward); // ward + ps.setString(5, location); // loction + ps.setString(6, userId); // userId + ps.setString(7, enumeration_type); + ps.setString(8, park_name); + return ps; + }, keyHolder); + + // Retrieve the auto-generated ID (primary key) and return it + return keyHolder.getKey().intValue(); + } catch (Exception e) { + e.printStackTrace(); + } + + return -1; // Return error indicator + + } + + public int miyawakiNew(String type_of_place, String latitude, String longitude, String zone, String ward, + String location, String userId, MultipartFile photo, String enumeration_type) throws Exception { + + int enumerationImg_Id_master = miyawakiNeww(type_of_place, latitude, longitude, zone, ward, location, userId, + photo, enumeration_type); + String name = "miyawakiNew " + enumerationImg_Id_master; + String imgId = Integer.toString(enumerationImg_Id_master); + try { + String ImageUrl = fileUpload(name, imgId, photo); + // System.out.println("===========................" + ImageUrl); + saveImageForEnumeration(enumerationImg_Id_master, ImageUrl); + return enumerationImg_Id_master; + } catch (Exception e) { + throw new Exception("Error in image saving"); + } + } + + private int miyawakiNeww(String type_of_place, String latitude, String longitude, String zone, String ward, + String location, String userId, MultipartFile photo, String enumeration_type) { + String sql = "INSERT INTO enumeration_master ( Type_of_place, latitude, longitude, zone, ward, location, userId,enumeration_type, cdate, is_Active, is_Delete) " + + "VALUES (?, ?, ?, ?, ?, ?, ?,?, CURRENT_TIMESTAMP, TRUE, FALSE)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + try { + jdbcParkseTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, new String[] { "enumeration_Id" }); // Primary + // key + // column + + // Set the parameters in the correct order (index starts at 1) + ps.setString(1, type_of_place); // Area + ps.setString(2, latitude); // latitude + ps.setString(3, longitude); // longitude + ps.setString(4, zone); // zone + ps.setString(5, ward); // ward + ps.setString(6, location); // loction + ps.setString(7, userId); + ps.setString(8, enumeration_type);// userId + return ps; + }, keyHolder); + + // Retrieve the auto-generated ID (primary key) and return it + return keyHolder.getKey().intValue(); + } catch (Exception e) { + e.printStackTrace(); + } + return -1; // Return error indicator + } + + public int miyawakiExisting(int maintained_By, String latitude, String longitude, String zone, String ward, + String location, String userId, MultipartFile photo, String enumeration_type) throws Exception { + int enumerationImg_Id_master = miyawakiExistingSer(maintained_By, latitude, longitude, zone, ward, location, + userId, photo, enumeration_type); + String name = "miyawakiExisting " + enumerationImg_Id_master; + String imgId = Integer.toString(enumerationImg_Id_master); + try { + String ImageUrl = fileUpload(name, imgId, photo); + // System.out.println("===========................" + ImageUrl); + saveImageForEnumeration(enumerationImg_Id_master, ImageUrl); + return enumerationImg_Id_master; + } catch (Exception e) { + throw new Exception("Error in image saving"); + } + } + + private int miyawakiExistingSer(int maintained_By, String latitude, String longitude, String zone, String ward, + String location, String userId, MultipartFile photo, String enumeration_type) { + String sql = "INSERT INTO enumeration_master ( maintained_By, latitude, longitude, zone, ward, location, userId,enumeration_type, cdate, is_Active, is_Delete) " + + "VALUES (?, ?, ?, ?, ?, ?, ?,?, CURRENT_TIMESTAMP, TRUE, FALSE)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + try { + jdbcParkseTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, new String[] { "enumeration_Id" }); // Primary + // key + // column + + // Set the parameters in the correct order (index starts at 1) + ps.setInt(1, maintained_By); // Area + ps.setString(2, latitude); // latitude + ps.setString(3, longitude); // longitude + ps.setString(4, zone); // zone + ps.setString(5, ward); // ward + ps.setString(6, location); // loction + ps.setString(7, userId); // userId + ps.setString(8, enumeration_type); + return ps; + }, keyHolder); + + // Retrieve the auto-generated ID (primary key) and return it + return keyHolder.getKey().intValue(); + } catch (Exception e) { + e.printStackTrace(); + } + + return -1; // Return error indicator + } + + // -----------------------------------------------Feedback + // API----------------------------------------------------------------- + + public int centerMedian(String irrigationProperlyQa, String irrigationProperlyAns, String trimmingProperlyQa, + String trimmingProperlyAns, String weedingQa, String weedingAns, String handRailingQa, + String handRailingAns, String latitude, String longitude, String zone, String ward, String location, + String enumeration_type, String userId, String enumeration_id, MultipartFile photo) throws Exception { + String saveImage; + try { + saveImage = fileUpload("CenterMedianFeedback", enumeration_id, photo); + } catch (Exception e) { + throw new Exception(" check photo"); + } + centerMedian(saveImage, enumeration_id); + centerMedian("test_cen", enumeration_id); + int activity_Id = saveActivity(zone, location, latitude, longitude, ward, userId, enumeration_type, + enumeration_id); + // System.out.println(activity_Id); + SaveFeedBack(irrigationProperlyQa, irrigationProperlyAns, activity_Id); + //SaveFeedBack(irrigationProperlyQa, irrigationProperlyAns, activity_Id); + SaveFeedBack(trimmingProperlyQa, trimmingProperlyAns, activity_Id); + SaveFeedBack(weedingQa, weedingAns, activity_Id); + int saveFeedBackId = SaveFeedBack(handRailingQa, handRailingAns, activity_Id); + + return saveFeedBackId; + + } + + private int saveActivity(String zone, String division, String latitude, String longitude, String ward, + String userId, String enumeration_type, String enumeration_id) { + + // SQL query to insert activity details into the activity table + String sql = "INSERT INTO activity (feedback_zone, feedback_location, feedback_latitude, feedback_longitude, cdate, ward,user_Id, feedback_enumeration_Type, feedback_enumeration_Id) " + + "VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP, ?, ?,?,?)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + try { + // Use JdbcTemplate's update method to execute the insert operation + jdbcParkseTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, new String[] { "activity_id" }); // Assuming + // "activity_id" + // is the + // primary + // key + + // Set the parameters for the activity table in the correct order (index starts + // at 1) + ps.setString(1, zone); // feedback_zone + ps.setString(2, division); // feedback_division + ps.setString(3, latitude); // feedback_latitude + ps.setString(4, longitude);// feedback_longitude + ps.setString(5, ward); // user_Id + ps.setString(6, userId); + ps.setString(7, enumeration_type); + ps.setString(8, enumeration_id);// feedback_enumeration_Type + + return ps; + }, keyHolder); + + // Retrieve the auto-generated activity_id and return it + return keyHolder.getKey().intValue(); + } catch (Exception e) { + e.printStackTrace(); + } + + return -1; // Return -1 in case of any error + } + + private int SaveFeedBack(String qaId, String qaName, int activityId) { + + String sql = "INSERT INTO feedback (feedback_Name, feedback_qa_id, activity_id) " + "VALUES (?, ?, ?)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + try { + jdbcParkseTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, new String[] { "feed_id" }); // Primary key + // column + + // Set the parameters in the correct order (index starts at 1) + ps.setString(1, qaName); // feedback_Name + ps.setString(2, qaId); // feedback_qa_id + ps.setInt(3, activityId); // feedback_enumeration_Id + return ps; + }, keyHolder); + + // Retrieve the auto-generated ID (primary key) and return it + return keyHolder.getKey().intValue(); + } catch (Exception e) { + e.printStackTrace(); + } + + return -1; // Return error indicator + } + + private List> centerMedian(String saveImage, String enumeration_id) { + // Update SQL query +// String updateSql = "UPDATE enumeration_master SET centerMedian_image = ? WHERE enumeration_Id = ?"; + + try { + // Perform the update operation +// jdbcParkseTemplate.update( saveImage, enumeration_id); + + // After the update, fetch the updated row + String selectSql = "SELECT * FROM enumeration_master WHERE enumeration_Id = ?"; // Added '=' + + // Return the updated data as a list of maps (each map corresponds to a row) + return jdbcParkseTemplate.queryForList(selectSql, enumeration_id); + + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); // Return an empty list in case of an error + } + } +/* Patch 23-11-2024 + public int trafficIsland(String irrigationProperlyQa, String irrigationProperlyAns, String trimmingProperlyQa, + String trimmingProperlyAns, String weedingQa, String weedingans, String handRailingQa, + String handRailingAns, String latitude, String longitude, String zone, String ward, String location, + String userId, String enumeration_type, String enumeration_id, String gapFillingQa, String gapFilingAns, + String improvementQa, String improvementAns, MultipartFile photo) throws Exception { + + String saveImage; + try { + saveImage = fileUpload("TrafficIslandFeedback", enumeration_id, photo); + } catch (Exception e) { + throw new Exception(" check photo"); + } + + trafficIslandSave(saveImage, enumeration_id); + int activity_Id = saveActivity(zone, location, latitude, longitude, ward, userId, enumeration_type, + enumeration_id); + + SaveFeedBack(improvementQa, improvementAns, activity_Id); + SaveFeedBack(irrigationProperlyQa, irrigationProperlyAns, activity_Id); + SaveFeedBack(trimmingProperlyQa, trimmingProperlyAns, activity_Id); + SaveFeedBack(weedingQa, weedingans, activity_Id); + + int saveFeedBackId = SaveFeedBack(handRailingQa, handRailingAns, activity_Id); + return saveFeedBackId; + + } +*/ + public int trafficIsland(String irrigationProperlyQa, String irrigationProperlyAns, String trimmingProperlyQa, + String trimmingProperlyAns, String weedingQa, String weedingans, String handRailingQa, + String handRailingAns, String latitude, String longitude, String zone, String ward, String location, + String userId, String enumeration_type, String enumeration_id, String gapFillingQa, String gapFilingAns, + String improvementQa, String improvementAns,String fountainAvailableQa, String fountainAvailableAns, + String fountainWorkingQa, String fountainWorkingAns,MultipartFile photo) throws Exception { + + String saveImage; + try { + saveImage = fileUpload("TrafficIslandFeedback", enumeration_id, photo); + } catch (Exception e) { + throw new Exception(" check photo"); + } + + trafficIslandSave(saveImage, enumeration_id); + int activity_Id = saveActivity(zone, location, latitude, longitude, ward, userId, enumeration_type,enumeration_id); + + SaveFeedBack(irrigationProperlyQa, irrigationProperlyAns, activity_Id); + SaveFeedBack(trimmingProperlyQa, trimmingProperlyAns, activity_Id); + SaveFeedBack(weedingQa, weedingans, activity_Id); + SaveFeedBack(improvementQa, improvementAns, activity_Id); + SaveFeedBack(fountainAvailableQa, fountainAvailableAns, activity_Id); + SaveFeedBack(fountainWorkingQa, fountainWorkingAns, activity_Id); + + + int saveFeedBackId = SaveFeedBack(handRailingQa, handRailingAns, activity_Id); + return saveFeedBackId; + } + private List> trafficIslandSave(String saveImage, String enumeration_id) { + // Update SQL query +// String updateSql = "UPDATE enumeration_master SET traffic_image = ? WHERE enumeration_Id = ?"; + + try { + // Perform the update operation +// jdbcParkseTemplate.update(saveImage, enumeration_id); + + // After the update, fetch the updated row + String selectSql = "SELECT * FROM enumeration_master WHERE enumeration_Id = ?"; // Added '=' + + // Return the updated data as a list of maps (each map corresponds to a row) + return jdbcParkseTemplate.queryForList(selectSql, enumeration_id); + + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); // Return an empty list in case of an error + } + } + + public int beautification(String irrigationProperlyQa, String irrigationProperlyAns, String trimmingProperlyQa, + String trimmingProperlyAns, String weedingQa, String weedingans, String gapFillingQa, String gapFillingAns, + String improvementQa, String improvementAns, String latitude, String longitude, String zone, String ward, + String location, String enumeration_id, String userId, String enumeration_type, MultipartFile photo) + throws Exception { + String saveImage; + try { + saveImage = fileUpload("beautificationFeedback", enumeration_id, photo); + } catch (Exception e) { + throw new Exception(" check photo"); + } + + saveBeautification(saveImage, enumeration_id); + int activity_Id = saveActivity(zone, location, latitude, longitude, ward, userId, enumeration_type, + enumeration_id); + + SaveFeedBack(irrigationProperlyQa, irrigationProperlyAns, activity_Id); + SaveFeedBack(trimmingProperlyQa, trimmingProperlyAns, activity_Id); + SaveFeedBack(weedingQa, weedingans, activity_Id); + SaveFeedBack(improvementQa, improvementAns, activity_Id); + int saveFeedBackId = SaveFeedBack(gapFillingQa, gapFillingAns, activity_Id); + return saveFeedBackId; + + } + + private List> saveBeautification(String saveImage, String enumeration_id) { +// String updateSql = "UPDATE enumeration_master SET feed_beautificat = ? WHERE enumeration_Id = ?"; + + try { + // Perform the update operation +// jdbcParkseTemplate.update(saveImage, enumeration_id); + + // After the update, fetch the updated row + String selectSql = "SELECT * FROM enumeration_master WHERE enumeration_Id = ?"; // Added '=' + + // Return the updated data as a list of maps (each map corresponds to a row) + return jdbcParkseTemplate.queryForList(selectSql, enumeration_id); + + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); // Return an empty list in case of an error + } + } + + public int parkInspection(String openedQa, String openedAns, String irrigationProperlyQa, + String irrigationProperlyAns, String trimmingProperlyQa, String trimmingProperlyAns, String weedingQa, + String weedingans, String gapFillingQa, String gapFillingAns, String playandGymQa, String playandGymAns, + String overAllQa, String overAllAns, String properLightQa, String properLightAns, String debrisRemovalQa, + String debrisRemovalAns, String toiletAQA, String toiletAns, String latitude, String longitude, String zone, + String ward, String location, String userId, String enumeration_type, String enumeration_id, + String civilWorkQa, String civilWorkAns, String noWatchmenQa, String noWatchmenAns, String noSweeperQa, + String noSweeperAns, MultipartFile photo) throws Exception { + + String saveImage; + try { + saveImage = fileUpload("ParkInspectionFeedback", enumeration_id, photo); + } catch (Exception e) { + throw new Exception(" check photo"); + } + + saveParkInspection(saveImage, enumeration_id); + int activity_Id = saveActivity(zone, location, latitude, longitude, ward, userId, enumeration_type, + enumeration_id); + + SaveFeedBack(civilWorkQa, civilWorkAns, activity_Id); + SaveFeedBack(noWatchmenQa, noWatchmenAns, activity_Id); + SaveFeedBack(noSweeperQa, noSweeperAns, activity_Id); + + SaveFeedBack(openedQa, openedAns, activity_Id); + SaveFeedBack(irrigationProperlyQa, irrigationProperlyAns, activity_Id); + SaveFeedBack(trimmingProperlyQa, trimmingProperlyAns, activity_Id); + SaveFeedBack(weedingQa, weedingans, activity_Id); + SaveFeedBack(gapFillingQa, gapFillingAns, activity_Id); + + SaveFeedBack(playandGymQa, playandGymAns, activity_Id); + SaveFeedBack(overAllQa, overAllAns, activity_Id); + SaveFeedBack(properLightQa, properLightAns, activity_Id); + SaveFeedBack(debrisRemovalQa, debrisRemovalAns, activity_Id); + + int saveFeedBackId = SaveFeedBack(toiletAQA, toiletAns, activity_Id); + return saveFeedBackId; + + } + + private List> saveParkInspection(String saveImage, String enumeration_id) { +// String updateSql = "UPDATE enumeration_master SET feed_prak_Inspe_image = ? WHERE enumeration_id = ?"; + try { + // Perform the update operation +// jdbcParkseTemplate.update(saveImage, enumeration_id); + + // After the update, fetch the updated row + String selectSql = "SELECT * FROM enumeration_master WHERE enumeration_Id = ?"; // Added '=' + + // Return the updated data as a list of maps (each map corresponds to a row) + return jdbcParkseTemplate.queryForList(selectSql, enumeration_id); + + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); // Return an empty list in case of an error + } + } + + public int readingZone(String openedOrNotQa, String openedOrNotAns, String bookAvailableQa, String bookAvailableAns, + String newsapaperAvailableQa, String newsapaperAvailableAns, String latitude, String longitude, String zone, + String ward, String location, String userId, String enumeration_type, String enumeration_id, + String improvementQa, String improvementAns, MultipartFile photo) throws Exception { + // TODO Auto-generated method + + String saveImage; + try { + saveImage = fileUpload("readinZoneFeedback", enumeration_id, photo); + } catch (Exception e) { + throw new Exception(" check photo"); + } + + saveReadingZone(saveImage, enumeration_id); + int activity_Id = saveActivity(zone, location, latitude, longitude, ward, userId, enumeration_type, + enumeration_id); + + SaveFeedBack(openedOrNotQa, openedOrNotAns, activity_Id); + SaveFeedBack(bookAvailableQa, bookAvailableAns, activity_Id); + SaveFeedBack(improvementQa, improvementAns, activity_Id); + int saveFeedBackId = SaveFeedBack(newsapaperAvailableQa, newsapaperAvailableAns, activity_Id); + + return saveFeedBackId; + + } + + private List> saveReadingZone(String saveImage, String enumeration_id) { +// String updateSql = "UPDATE enumeration_master SET feed_readingZone = ? WHERE enumeration_id = ?"; + try { + // Perform the update operation +// jdbcParkseTemplate.update(saveImage, enumeration_id); + + // After the update, fetch the updated row + String selectSql = "SELECT * FROM enumeration_master WHERE enumeration_Id = ?"; // Added '=' + + // Return the updated data as a list of maps (each map corresponds to a row) + return jdbcParkseTemplate.queryForList(selectSql, enumeration_id); + + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); // Return an empty list in case of an error + } + } + + public int miyawakiNew(String debrisCleaningQa, String debrisCleaningAns, String landpreprarationQa, + String landpreprarationAns, String plantingDoneQa, String plantingDoneAns, String cctvQa, String cctvAns, + String latitude, String longitude, String zone, String ward, String location, String userId, + String enumeration_type, String enumeration_id, String saplingAvailQa, String saplingAvailAns, + String fencingAvailbilityQa, String fencingAvailbilityAns, String sourcaOfIrrigationQa, + String sourcaOfIrrigationAns, MultipartFile photo) throws Exception { + + String saveImage; + try { + saveImage = fileUpload("miyawakiNewFeedback", enumeration_id, photo); + } catch (Exception e) { + throw new Exception(" check photo"); + } + + saveMiyawakiNew(saveImage, enumeration_id); + int activity_Id = saveActivity(zone, location, latitude, longitude, ward, userId, enumeration_type, + enumeration_id); + + SaveFeedBack(saplingAvailQa, saplingAvailAns, activity_Id); + SaveFeedBack(fencingAvailbilityQa, fencingAvailbilityAns, activity_Id); + SaveFeedBack(sourcaOfIrrigationQa, sourcaOfIrrigationAns, activity_Id); + + SaveFeedBack(debrisCleaningQa, debrisCleaningAns, activity_Id); + SaveFeedBack(landpreprarationQa, landpreprarationAns, activity_Id); + SaveFeedBack(plantingDoneQa, plantingDoneAns, activity_Id); + + int saveFeedBackId = SaveFeedBack(cctvQa, cctvAns, activity_Id); + return saveFeedBackId; + } + + private List> saveMiyawakiNew(String saveImage, String enumeration_id) { +// String updateSql = "UPDATE enumeration_master SET feed_miyawakiNew = ? WHERE enumeration_id = ?"; + + try { + // Perform the update operation +// jdbcParkseTemplate.update(saveImage, enumeration_id); + // After the update, fetch the updated row + String selectSql = "SELECT * FROM enumeration_master WHERE enumeration_Id = ?"; // Added '=' + + // Return the updated data as a list of maps (each map corresponds to a row) + return jdbcParkseTemplate.queryForList(selectSql, enumeration_id); + + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); // Return an empty list in case of an error + } + } + + public int miyawakiExisiting(String weedingQa, String weedingAns, String purningQa, String purningans, + String gapFillingQa, String gapFillingAns, String latitude, String longitude, String zone, String ward, + String location, String userId, String enumeration_type, String enumeration_id, String improvmetReqQa, + String improvmetReqAns, String sourceOfirrigationQa, String sourceOfirrigationAns, MultipartFile photo) + throws Exception { + + String saveImage; + try { + saveImage = fileUpload("miywakiExistingFeedback", enumeration_id, photo); + } catch (Exception e) { + throw new Exception(" check photo"); + } + + saveMiyawakiExisiting(saveImage, enumeration_id); + int activity_Id = saveActivity(zone, location, latitude, longitude, ward, userId, enumeration_type, + enumeration_id); + + SaveFeedBack(improvmetReqQa, improvmetReqAns, activity_Id); + SaveFeedBack(sourceOfirrigationQa, sourceOfirrigationAns, activity_Id); + + SaveFeedBack(weedingQa, weedingAns, activity_Id); + SaveFeedBack(purningQa, purningans, activity_Id); + int saveFeedBackId = SaveFeedBack(gapFillingQa, gapFillingAns, activity_Id); + + return saveFeedBackId; + } + + private List> saveMiyawakiExisiting(String saveImage, String enumeration_id) { + +// String updateSql = "UPDATE enumeration_master SET feed_miyawaki_Exit = ? WHERE enumeration_id = ?"; + + try { + // Perform the update operation +// jdbcParkseTemplate.update(saveImage, enumeration_id); + // After the update, fetch the updated row + String selectSql = "SELECT * FROM enumeration_master WHERE enumeration_Id = ?"; // Added '=' + + // Return the updated data as a list of maps (each map corresponds to a row) + return jdbcParkseTemplate.queryForList(selectSql, enumeration_id); + + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); // Return an empty list in case of an error + } + } + + public List> categoryType() { + String sql = "SELECT enumeration_type_id, enumerationName FROM enumerationtype where is_Active = 1 and is_Delete =0 "; + + try { + // Use query to get a list of park names + List> parkDetails = jdbcParkseTemplate.queryForList(sql); + return parkDetails; + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); // Return an empty list in case of an error + } + } + + public List> masterCategoryType(String cat_enumeration_id) { + String sql = "SELECT master_category_id, categoryName FROM mastercategory WHERE Cat_enumeration_id = ? and is_Active = 1 and is_Delete = 0"; + + try { + // Execute the query and pass the parameter + List> categoryDetails = jdbcParkseTemplate.queryForList(sql, + new Object[] { cat_enumeration_id }); + return categoryDetails; + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); // Return an empty list in case of an error + } + } + + public List> subCategoryType(String masterCategory) { + String sql = "SELECT sub_category_id, categoryName FROM subcategory WHERE masterCategory = ? and is_Active = 1 and is_Delete = 0"; + try { + // Execute the query and pass the parameter + List> categoryDetails = jdbcParkseTemplate.queryForList(sql, + new Object[] { masterCategory }); + return categoryDetails; + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); // Return an empty list in case of an error + } + } + + public List> getDateByLocation(String latitude, String longitude, String enumeration_type) throws Exception { + String latitude1 = latitude; + + List> parkByLocation = getParkByLocation(latitude, longitude, latitude1, enumeration_type); + if (parkByLocation == null) { + throw new NoDataException("No data in database"); + } + return parkByLocation; + } + + public List> getReadingZoneParkByLocation(String latitude, String longitude, String latitude1) + throws Exception { +// String sql = "SELECT enutype.enumeration_type_id , enutype.enumerationName, COALESCE(ac.park_name, ac.location) AS park_name, ac.enumeration_Id " +// + "FROM enumeration_master ac left join enumerationtype enutype on enutype.enumeration_type_id = ac.enumeration_type WHERE " +// + " ((6371008.8 * acos( ROUND(cos(radians(?)) * cos(radians(ac.latitude)) * cos(radians(ac.longitude) - radians(?)) + sin(radians(?)) * sin(radians(ac.latitude)), 9) )) < 500)" +// + " AND Zone_Available='yes' " +// + " GROUP BY enutype.enumeration_type_id,enutype.enumerationName, ac.park_name, ac.location "; + String sql = "SELECT enutype.enumeration_type_id , enutype.enumerationName, COALESCE(ac.park_name, ac.location) AS park_name,ac.enumeration_Id " + + "FROM enumeration_master ac left join enumerationtype enutype on enutype.enumeration_type_id = ac.enumeration_type WHERE " + + " ((6371008.8 * acos( ROUND(cos(radians(?)) * cos(radians(ac.latitude)) * cos(radians(ac.longitude) - radians(?)) + sin(radians(?)) * sin(radians(ac.latitude)), 9) )) < 500)" + + " AND ac.Zone_Available='yes' " + + " GROUP BY enutype.enumeration_type_id,enutype.enumerationName, ac.park_name, ac.location,ac.enumeration_Id "; + + // Use latitude, longitude, and schoolType as positional parameters + List> parkByLocation = jdbcParkseTemplate.queryForList(sql, + new Object[] { latitude, longitude, latitude1 }); + + if (parkByLocation == null) { + throw new NoDataException("No data in database"); + } + return parkByLocation; + } + + private List> getParkByLocation(String latitude, String longitude, String latitude1, String enumeration_type) { + String sql = "SELECT ac.enumeration_Id,enutype.enumeration_type_id , enutype.enumerationName, COALESCE(ac.park_name, ac.location) AS park_name " + + "FROM enumeration_master ac left join enumerationtype enutype on enutype.enumeration_type_id = ac.enumeration_type WHERE " + + " ((6371008.8 * acos( ROUND(cos(radians(?)) * cos(radians(ac.latitude)) * cos(radians(ac.longitude) - radians(?)) + sin(radians(?)) * sin(radians(ac.latitude)), 9) )) < 500) " + + "and (ac.park_name is not null or ac.location is not null) and (ac.enumeration_type is not null and ac.enumeration_type =?) " + + " GROUP BY ac.enumeration_Id, enutype.enumeration_type_id,enutype.enumerationName, ac.park_name, ac.location "; + + return jdbcParkseTemplate.queryForList(sql, new Object[] { latitude, longitude, latitude1, enumeration_type }); + } + + public List> parkName() throws Exception { + + List> parkName = getParkName(); + + if (parkName == null) { + throw new NoDataException("The is no park"); + } + return parkName; + + } + + public List> getParkName() { + String sql = "SELECT enumeration_Id, COALESCE(park_name, location) AS park_name FROM enumeration_master WHERE Zone_Available = 'yes'"; + + try { + + List> parkDetails = jdbcParkseTemplate.queryForList(sql); + return parkDetails; + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); // Return an empty list in case of an error + } + } + + // ------------------------------------------Tree Feedback + // API----------------------------------------------------- + + public Map SaveTreeDetailes(int No_of_trees_required, String enumeration_type, String latitude, + String longitude, String zone, String ward, String location, String parkname, String userId, + MultipartFile tree_Image) { + + int No_of_trees = 0; + String tree_Status; + int treeId; + int treeflag = 0; + + if (No_of_trees_required == No_of_trees) { + tree_Status = "completed"; + } + tree_Status = "pending"; + Map saveTreeDetailes = SaveTreeDetails(No_of_trees_required, enumeration_type, No_of_trees, + tree_Status, latitude, longitude, zone, ward, location, parkname, userId); + + if (saveTreeDetailes.containsKey("tree_Id")) { + + treeId = (int) saveTreeDetailes.get("tree_Id"); + + try { + Random random = new Random(); + // Generate a random number between 1000 and 9999 + int treeId1 = 1000 + random.nextInt(9000); + + String saveImage = fileUpload("TreeFeedback", Integer.toString(treeId1), tree_Image); // FileUpload + SaveTreeImage(treeId, saveImage, userId, zone, ward, latitude, longitude, treeflag); + } catch (Exception e) { + throw new NoDataException("check the tree_id "); + } + + } else { + // Handle error case if tree_Id is missing + System.out.println("Error: tree_Id not found in saved data."); + } + return saveTreeDetailes; + + } + + private int SaveTreeImage(int treeId, String saveImage, String userId, String zone, String ward, String latitude, + String longitude, int treeflag) { + + String sql = "INSERT INTO tree_image (tr_image, tree_enumeration_id, tree_user_id, " + + "tree_zone, tree_ward, tree_latitude, tree_longitude, tree_cdate,tree_flag) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP,?)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + try { + jdbcParkseTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, new String[] { "tree_Image_Id" }); // Auto-generated + // primary + // key + ps.setString(1, saveImage); // tr_image + ps.setInt(2, treeId); // tree_enumeration_id + ps.setString(3, userId); // tree_user_id + ps.setString(4, zone); // tree_zone + ps.setString(5, ward); // tree_ward + ps.setString(6, latitude); // tree_latitude + ps.setString(7, longitude); + ps.setInt(8, treeflag); +// ps.setString(8, treeFlag); + // tree_longitude + return ps; + }, keyHolder); + + // Retrieve and return the auto-generated ID + return keyHolder.getKey().intValue(); + } catch (Exception e) { + e.printStackTrace(); + return -1; // Return error code + } + + } + + private Map SaveTreeDetails(int no_of_trees_required, String enumeration_type, int no_of_trees, + String tree_Status, String latitude, String longitude, String zone, String ward, String location, + String parkname, String userId) { + String locationtxt = location.isEmpty() ? null : location; + String parknametxt = parkname.isEmpty() ? null : parkname; + + String sql = "INSERT INTO treeplaintandpruning (No_of_trees, No_of_trees_required, tree_Status, " + + "tree_enumeration_id, tree_user_id,tree_location, tr_parkname, tree_zone, tree_ward, tree_latitude, tree_longitude, " + + "tree_cdate, tree_is_Active, tree_is_Delete) " + + "VALUES (?, ?, ?, ?,?,?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, TRUE, FALSE)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + try { + jdbcParkseTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, new String[] { "tree_Id" }); // Auto-generated + // primary key + ps.setInt(1, no_of_trees); + ps.setInt(2, no_of_trees_required); + ps.setString(3, tree_Status); + ps.setString(4, enumeration_type); + ps.setString(5, userId); + ps.setString(6, locationtxt); + ps.setString(7, parknametxt); + ps.setString(8, zone); + ps.setString(9, ward); + ps.setString(10, latitude); + ps.setString(11, longitude); + return ps; + }, keyHolder); + + int treeId = keyHolder.getKey().intValue(); + + String selectSql = "SELECT * FROM treeplaintandpruning WHERE tree_Id = ?"; + return jdbcParkseTemplate.queryForMap(selectSql, treeId); + + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyMap(); // Return an empty map if there's an error + } + } + + public Map SaveimageDetailes(String enumeration_type, String latitude, String longitude, + String userId, MultipartFile tree_Image, int tree_id) throws Exception { + + List> treeDetailes = getTreeDetails(tree_id); + + if (treeDetailes == null || treeDetailes.isEmpty()) { + throw new NoDataException("check the tree_id "); + } + + Map mapTReeDetailes = treeDetailes.get(0); + + if (mapTReeDetailes.containsKey("No_of_trees_required")) { + int treeId1 = (int) mapTReeDetailes.get("tree_Id"); + int treeNumber = (int) mapTReeDetailes.get("No_of_trees_required"); // total + int trerequired = (int) mapTReeDetailes.get("No_of_trees"); // add tree count + String zone = (String) mapTReeDetailes.get("tree_zone"); + String ward = (String) mapTReeDetailes.get("tree_ward"); + int treeflag = 1; + + // System.out.println("Tree ID: " + treeId1); + // System.out.println("Number of Trees Planted: " + treeNumber); + // System.out.println("Number of Trees Required: " + trerequired); + + int trerequired1 = ((Number) mapTReeDetailes.get("No_of_trees")).intValue(); + String treeStatus = null; + + if (treeNumber > trerequired) { + + try { + Random random = new Random(); + // Generate a random number between 1000 and 9999 + int treeId2 = 1000 + random.nextInt(9000); + String saveImage = fileUpload("TreeImage", Integer.toString(treeId2), tree_Image); + SaveTreeImage(treeId1, saveImage, userId, zone, ward, latitude, longitude, treeflag); + updateTreeRequired(treeId1, trerequired1 + 1); + + if (treeNumber - 1 == trerequired) { + treeStatus = "completed"; + } else { + treeStatus = "pending"; + } + return updateTreeStatusAndGetDetails(treeId1, treeStatus); + } catch (Exception e) { + throw new NoDataException("Error in Saving image"); + } + + } +// if (treeNumber == trerequired -1 ) { +// +// treeStatus = "completed"; +// return updateTreeStatusAndGetDetails(treeId1, treeStatus); +// } + + } + return null; + } + + private Map updateTreeStatusAndGetDetails(int treeId1, String treeStatus) { + String updateSql = "UPDATE treeplaintandpruning SET tree_Status = ? WHERE tree_Id = ?"; + String selectSql = "SELECT * FROM treeplaintandpruning WHERE tree_Id = ?"; + + try { + // Update the tree status + int rowsAffected = jdbcParkseTemplate.update(updateSql, treeStatus, treeId1); + + if (rowsAffected > 0) { + // Fetch the updated tree details after the update + return jdbcParkseTemplate.queryForMap(selectSql, treeId1); + } else { + return null; // Return null if no row was updated + } + } catch (Exception e) { + e.printStackTrace(); + return null; // Return null in case of an error + } + } + + private Map updateTreeRequired(int treeId1, int i) { + String updateSql = "UPDATE treeplaintandpruning SET No_of_trees = ? WHERE tree_Id = ?"; + String selectSql = "SELECT * FROM treeplaintandpruning WHERE tree_Id = ?"; + + try { + // Update the tree status + int rowsAffected = jdbcParkseTemplate.update(updateSql, i, treeId1); + + if (rowsAffected > 0) { + // Fetch the updated tree details after the update + return jdbcParkseTemplate.queryForMap(selectSql, treeId1); + } else { + return null; // Return null if no row was updated + } + } catch (Exception e) { + e.printStackTrace(); + return null; // Return null in case of an error + } + } + + private List> getTreeDetails(int tree_id) { + String sql = "SELECT * FROM treeplaintandpruning WHERE tree_Id = ?"; + + try { + // Query for list with parameter treeId + return jdbcParkseTemplate.queryForList(sql, tree_id); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); // Return an empty list in case of an error + } + } + + // ------------------------------------------Enumeration Report + // API----------------------------------------------------- + /* 23-11-2024 Patch + public List> getZoneCount(String fromdate, String todate, String enumeration_type) + throws Exception { + String sql = "SELECT zone,count(enumeration_Id) as count FROM enumeration_master" + + " where enumeration_type=(?) and DATE(cdate) BETWEEN STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') " + + "AND STR_TO_DATE('" + todate + "', '%d-%m-%Y') group by zone "; + + + return jdbcParkseTemplate.queryForList(sql, new Object[] { enumeration_type}); + + } + */ + public List> getZoneCount(String fromdate, String todate, String enumeration_type, String userId ) + throws Exception { + String sql = "SELECT zone,count(enumeration_Id) as count FROM enumeration_master" + + " where enumeration_type=(?) and UserId = ? and DATE(cdate) BETWEEN STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') " + + "AND STR_TO_DATE('" + todate + "', '%d-%m-%Y') group by zone "; + + + return jdbcParkseTemplate.queryForList(sql, new Object[] { enumeration_type, userId}); + + } + /* 23-11-2024 Patch + public List> getwardCount(String zone, String fromdate, String todate, + String enumeration_type) { + String sql = " SELECT ward,count(enumeration_Id) as count FROM enumeration_master " + + "where zone=(?) and date(cdate) between STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') " + + "and STR_TO_DATE('" + todate + "', '%d-%m-%Y') And enumeration_type =(?) group by ward "; + return jdbcParkseTemplate.queryForList(sql, new Object[] { zone, enumeration_type }); + + } + */ + + public List> getwardCount(String zone, String fromdate, String todate, String enumeration_type, + String userId) { + String sql = " SELECT ward,count(enumeration_Id) as count FROM enumeration_master " + + "where zone=(?) and UserId = ? and date(cdate) between STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') " + + "and STR_TO_DATE('" + todate + "', '%d-%m-%Y') And enumeration_type =(?) group by ward "; + return jdbcParkseTemplate.queryForList(sql, new Object[] { zone, enumeration_type, userId }); + + } + + public List> getActivityCount(String ward, String fromdate, String todate, + String enumeration_type) { + /*String sql = "select act.feedback_enumeration_Id, act.ward,coalesce(em.park_name,em.location) AS location_Park," + + "count(act.feedback_enumeration_Id) as count from activity act left join enumeration_master em on " + + "em.enumeration_Id = act.feedback_enumeration_Id where act.ward=? and act.feedback_enumeration_Type= ? " + + "and date(act.cdate) between STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') and " + + "STR_TO_DATE('" + todate + "', '%d-%m-%Y') group by act.feedback_enumeration_Id, act.ward, location_Park";*/ + + String sql = "select em.enumeration_Id as feedback_enumeration_Id, em.ward, coalesce(em.park_name,em.location) AS location_Park, count(act.feedback_enumeration_Id) as count " + + "from enumeration_master em " + + "left join activity act on act.feedback_enumeration_Id = em.enumeration_Id " + + "where act.ward = ? and act.feedback_enumeration_Type = ? " + + "and date(act.cdate) between STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') and STR_TO_DATE('" + todate + "', '%d-%m-%Y') " + + "group by em.enumeration_Id, em.ward"; + + return jdbcParkseTemplate.queryForList(sql, new Object[] { ward, enumeration_type}); + + } + + public List> getActivityDetails(String ward, String fromdate, String todate, + String enumeration_type, String enumerationId) { + String sql = "SELECT act.feedback_enumeration_Id,act.activity_id, DATE_FORMAT(act.cdate, '%d-%m-%Y %l:%i %p') AS date, " + + "act.feedback_latitude, act.feedback_longitude, et.enumerationName " + "FROM activity act " + + "LEFT JOIN enumerationtype et ON et.enumeration_type_id = act.feedback_enumeration_Type " + + "WHERE act.ward = ? " + "AND act.feedback_enumeration_Type = ? " + + "AND DATE(act.cdate) BETWEEN STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') AND STR_TO_DATE('" + todate + "', '%d-%m-%Y') " + + "and act.feedback_enumeration_Id = ?" + + "GROUP BY act.feedback_enumeration_Id,act.activity_id, act.feedback_latitude, act.feedback_longitude, et.enumerationName"; + + return jdbcParkseTemplate.queryForList(sql, new Object[] { ward, enumeration_type, enumerationId }); + + } + + public List>> getInspectionDetails(String activityId, String fromdate, String todate, + String enumerationId) { + + // Initialize the list that will hold all park details + List>> getEnumDetails1 = new ArrayList<>(); + + // Initialize a list to hold individual park details + List> getParkDetails = new ArrayList<>(); + + // Fetch images and feedback + List> feedback = getEnumfeedback(activityId, fromdate, todate); + List> image = getEnumImage(enumerationId, fromdate, todate); + + // Prepare maps for images and feedback + Map imageMap = new HashMap<>(); + imageMap.put("images", image); + + Map feedbackMap = new HashMap<>(); + feedbackMap.put("feedbacks", feedback); + + // Add ward details, images, and feedback to the park details list + getParkDetails.add(feedbackMap); + getParkDetails.add(imageMap); + + // Add this park's details to the final list + getEnumDetails1.add(getParkDetails); + + return getEnumDetails1; + } + + private List> getEnumfeedback(String activityId, String fromdate, String todate) { + String sql = "select eqm.qa_name, fb.feedback_Name from feedback fb " + + "left join enu_question_master eqm on eqm.qa_id = fb.feedback_qa_id " + + "left join activity act on act.activity_id = fb.activity_id " + + "where fb.activity_id =? and date(act.cdate) between STR_TO_DATE(' "+ fromdate + " ','%Y-%m-%d') and STR_TO_DATE('"+todate+"','%Y-%m-%d')"; + + return jdbcParkseTemplate.queryForList(sql, new Object[] { activityId }); + } + + private List> getEnumImage(String enumerationId, String fromdate, String todate) { + + String sql = "select *,coalesce(em.park_name,em.location) as parkName, " + "CONCAT('" + fileBaseUrl + + "/gccofficialapp/files', eimg.photos_enu) AS imageUrl, em.latitude, em.longitude from enumertion_images eimg " + + "left join enumeration_master em on em.enumeration_Id = eimg.enumerationImg_Id_master " + + "where eimg.enumerationImg_Id_master = ? and date(eimg.cdate) between STR_TO_DATE(' "+ fromdate + " ','%Y-%m-%d') and STR_TO_DATE('"+todate+"','%Y-%m-%d')"; + return jdbcParkseTemplate.queryForList(sql, new Object[] { enumerationId }); + } + + public List> getParkCount(String ward, String fromdate, String todate, + String enumeration_type) { + String sql = "SELECT CASE WHEN park_name IS NULL THEN location ELSE park_name END AS named, " + + "COUNT(enumeration_Id) AS count, " + "DATE_FORMAT(cdate, '%d-%m-%Y') AS formatted_date " + + "FROM enumeration_master " + + "WHERE ward = ? AND DATE(cdate) BETWEEN STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') AND " + + "STR_TO_DATE('" + todate + "', '%d-%m-%Y') And enumeration_type =(?) GROUP BY named, cdate, ward"; + + return jdbcParkseTemplate.queryForList(sql, new Object[] { ward, enumeration_type }); + } + + public List> getWishtreeZoneCount(String fromdate, String todate, String enumeration_type) { + + String sql = "SELECT tree_zone,count(tree_Id) as count FROM treeplaintandpruning " + + " where tree_enumeration_id=(?) and DATE(tree_cdate) between STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') " + + "and STR_TO_DATE('" + todate + "', '%d-%m-%Y') group by tree_zone "; + return jdbcParkseTemplate.queryForList(sql, new Object[] { enumeration_type}); + + } + + public List> getTreewardCount(String zone, String fromdate, String todate, + String enumeration_type) { + String sql = "SELECT tree_ward, COUNT(tree_Id) AS count " + "FROM treeplaintandpruning " + + "WHERE tree_zone = ? AND DATE(tree_cdate) BETWEEN STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') AND " + + "STR_TO_DATE('" + todate + "', '%d-%m-%Y')and tree_enumeration_id=(?) GROUP BY tree_ward"; + + return jdbcParkseTemplate.queryForList(sql, new Object[] { zone, enumeration_type }); + } + + public List> getwardWishTreedata(String ward) { + String sql = "SELECT tree.tree_Id,tree.No_of_trees_required,tree.No_of_trees,tree.tree_enumeration_id,tree.tree_zone,tree.tree_ward," + + "CONCAT('" + fileBaseUrl + + "/gccofficialapp/files', image.tr_image) AS imageUrl FROM treeplaintandpruning AS tree " + + "LEFT JOIN tree_image AS image ON image.tree_enumeration_id = tree.tree_Id WHERE tree.tree_ward =? "; + return jdbcParkseTemplate.queryForList(sql, new Object[] { ward }); + } + + public List> getTreeWardWiseCountDetails(String ward, String enumeration_type, String fromdate,String todate) { + String sql = "select tree_Id, tree_ward, coalesce(tr_parkname,tree_location) as location, count(tree_Id) as count from treeplaintandpruning " + + "where tree_ward=? and tree_enumeration_id = ? and date(tree_cdate) between STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') and " + + "STR_TO_DATE('" + todate + "', '%d-%m-%Y') group by tree_Id, tree_ward, location"; + + return jdbcParkseTemplate.queryForList(sql, new Object[] { ward, enumeration_type, }); + } + + public List> getTreeImageDetails(String tree_Id, String enumeration_type, String fromdate, String todate) { + String sql = "SELECT timg.tree_latitude, timg.tree_longitude, DATE_FORMAT(timg.tree_cdate, '%d-%m-%Y %l:%i %p') AS Date, " + + "tpp.No_of_trees_required AS total, tpp.No_of_trees AS Completed_Count, " + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', timg.tr_image) AS imageUrl " + + "FROM tree_image timg LEFT JOIN treeplaintandpruning tpp ON tpp.tree_id = timg.tree_enumeration_id " + + "WHERE tpp.tree_Id = ? AND tpp.tree_enumeration_id = ? AND DATE(timg.tree_cdate) BETWEEN STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') " + + "AND STR_TO_DATE('" + todate + "', '%d-%m-%Y') and timg.tree_flag = 1"; + return jdbcParkseTemplate.queryForList(sql, new Object[] { tree_Id, enumeration_type }); + } + + + public List> getTreeDetails(String tree_Id) { + String sql = "SELECT * FROM treeplaintandpruning WHERE tree_Id = ?"; + return jdbcParkseTemplate.queryForList(sql, new Object[] { tree_Id }); + } + + public List> getTreeDetailsBasedonLocation(String parkName, String location, String ward) { + String sql = "SELECT *," + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files/', image.tr_image) AS imageUrl " + + "FROM treeplaintandpruning treep left join tree_image image on image.tree_enumeration_id=treep.tree_Id " + + "WHERE treep.tree_ward=? and treep.tr_parkname=? or treep.tree_location =? "; + + try { + return jdbcParkseTemplate.queryForList(sql, new Object[] { ward, parkName, location }); + } catch (Exception e) { + throw new NoDataException("Exception" + e); + } + + } + + public List> getEnumeration_feedback(String enumerationId, String enumeration_type) { + String sql = "SELECT qa.qa_name,feed.feedback_Name, feed.activity_id, act.feedback_enumeration_Id, act.feedback_enumeration_Type " + + "FROM feedback feed " + "LEFT JOIN activity act ON act.activity_id = feed.activity_id " + + "LEFT JOIN enu_question_master qa ON feed.feedback_qa_id = qa.qa_id " + + "WHERE act.feedback_enumeration_Id = ? AND act.feedback_enumeration_Type = ?"; + + try { + return jdbcParkseTemplate.queryForList(sql, enumerationId, enumeration_type); + } catch (Exception e) { + throw new NoDataException("No enumeration feedback found for enumeration_Id: " + enumerationId); + } + } + + /* 23-11-2024 Patch + public List>> getParkDetails(String enumeration_type, String fromdate, String todate) + throws Exception { + // Fetch park data based on the given date range + List> parkData = getParkData(fromdate, todate, enumeration_type); + + // Initialize the list that will hold all park details + List>> getParkDetails1 = new ArrayList<>(); + + // Loop through the parkData list (each map represents a row) + for (Map row : parkData) { + // Extract the enumeration_Id from the row + Object enumId = row.get("enumeration_Id"); // Use the correct key from parkData + System.out.println("enumId: " + enumId); + if (enumId == null) { + System.out.println("No enumeration_Id found in row."); + continue; + } + + // Initialize a list to hold individual park details + List> getParkDetails = new ArrayList<>(); + + // Fetch ward count based on the enumeration_Id + Map getwardCount = getEnumeration_master(enumId.toString(), enumeration_type); + getwardCount.replaceAll((key, value) -> value == null ? "" : value); + // System.out.println(getwardCount); + + // Fetch images and feedback + List> image = getEnumeration_image(enumId.toString(), enumeration_type); + List> feedback = getEnumeration_feedback(enumId.toString(), enumeration_type); + + // Prepare maps for images and feedback + Map imageMap = new HashMap<>(); + imageMap.put("images", image); + + Map feedbackMap = new HashMap<>(); + feedbackMap.put("feedbacks", feedback); + + // Add ward details, images, and feedback to the park details list + getParkDetails.add(getwardCount); + getParkDetails.add(imageMap); + getParkDetails.add(feedbackMap); + + // Add this park's details to the final list + getParkDetails1.add(getParkDetails); + } + + return getParkDetails1; + } +*/ + public List>> getParkDetails(String enumeration_type, String fromdate, String todate, String userId) + throws Exception { + // Fetch park data based on the given date range + Map parkData = getParkData(fromdate, todate, enumeration_type, userId); + + // Initialize the list that will hold all park details + List>> getParkDetails1 = new ArrayList<>(); + + // Loop through the parkData list (each map represents a row) + + // Extract the enumeration_Id from the row + Object enumId = parkData.get("enumeration_Id"); // Use the correct key from parkData + //System.out.println("enumId: " + enumId); + if (enumId == null) { + System.out.println("No enumeration_Id found in row."); + //continue; + } + + // Initialize a list to hold individual park details + List> getParkDetails = new ArrayList<>(); + + // Fetch ward count based on the enumeration_Id + Map getwardCount = getEnumeration_master(enumId.toString(), enumeration_type); + getwardCount.replaceAll((key, value) -> value == null ? "" : value); + // System.out.println(getwardCount); + + // Fetch images and feedback + List> image = getEnumeration_image(enumId.toString(), enumeration_type); + //System.out.println("image: "+image.size()); + List> feedback = getEnumeration_feedback(enumId.toString(), enumeration_type); + //System.out.println("feedback: "+feedback.get(0)); + + // Prepare maps for images and feedback + Map imageMap = new HashMap<>(); + imageMap.put("images", image); + + Map feedbackMap = new HashMap<>(); + feedbackMap.put("feedbacks", feedback); + + // Add ward details, images, and feedback to the park details list + getParkDetails.add(getwardCount); + getParkDetails.add(imageMap); + getParkDetails.add(feedbackMap); + + // Add this park's details to the final list + getParkDetails1.add(getParkDetails); + + return getParkDetails1; + } + + private Map getEnumeration_master(Object enumeration_Id, String enumeration_type) throws Exception { + String sql = "SELECT * FROM enumeration_master WHERE enumeration_Id = ? and enumeration_type =?"; + + try { + return jdbcParkseTemplate.queryForMap(sql, new Object[] { enumeration_Id, enumeration_type }); + } catch (Exception e) { + throw new NoDataException("No enumeration data found for enumeration_Id: " + enumeration_Id); + } + } + + public List> getEnumeration_image(Object enumeration_Id, String enumeration_type) + throws Exception { + String sql = "SELECT *, CONCAT('" + fileBaseUrl + "/gccofficialapp/files/', photos_enu) AS imageUrl " + + "FROM enumertion_images WHERE enumerationImg_Id_master = ?"; + try { + return jdbcParkseTemplate.queryForList(sql, new Object[] { enumeration_Id }); + } catch (Exception e) { + throw new NoDataException("No enumeration image found for enumeration_Id: " + enumeration_Id); + } + } + /* 23-11-2024 Patch + private List> getParkData(String fromdate, String todate, String enumeration_type) { + String sql = "SELECT enumeration_Id " + + "FROM enumeration_master WHERE enumeration_type=? and DATE(cdate) BETWEEN STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') AND " + + "STR_TO_DATE('" + todate + "', '%d-%m-%Y') and park_name IS NOT NULL"; + + return jdbcParkseTemplate.queryForList(sql, new Object[] { enumeration_type}); + } + */ + private Map getParkData(String fromdate, String todate, String enumeration_type, String userId) { + String sql = "SELECT enumeration_Id " + + "FROM enumeration_master WHERE enumeration_type=? and UserId =? " + + "and DATE(cdate) BETWEEN STR_TO_DATE(? , '%d-%m-%Y') AND " + + "STR_TO_DATE(? , '%d-%m-%Y') and park_name IS NOT NULL"; + + return jdbcParkseTemplate.queryForMap(sql, enumeration_type, userId, fromdate, todate); + } + + public List> getBriefReport(String fromdate, String todate, String category, String divison, + String zone, String park_name) { + String sql = "select park_name, latitude, longitude, location, zone from enumeration_master em " + + "where DATE(em.cdate) between STR_TO_DATE('" + fromdate + "', '%d-%m-%Y') and STR_TO_DATE('" + todate + "', '%d-%m-%Y') " + + "and enumeration_type =? and ward = ? and zone = ? and park_name = ? order by em.cdate "; + + return jdbcParkseTemplate.queryForList(sql, category, divison, zone, park_name); + } + + public List> getUserBasedEnum(String tree_user_id, String tree_latitude, String tree_longitude, + String tree_Status, String enumeration_type) { + String sql = "SELECT *,date_format(treep.tree_cdate, '%d-%m-%Y %l:%i %p')as tree_date, COALESCE(treep.tr_parkname,treep.tree_location) AS tr_location," + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', image.tr_image) AS imageUrl " + + " FROM treeplaintandpruning treep left join tree_image image on image.tree_enumeration_id=treep.tree_Id WHERE tree_flag=0 and tree_Status = ? and " + + " ((6371008.8 * acos( ROUND(cos(radians(?)) * cos(radians(treep.tree_latitude)) * cos(radians(treep.tree_longitude) - radians(?)) + sin(radians(?)) * sin(radians(treep.tree_latitude)), 9) )) < 500) " + + " and treep.tree_user_id = ? and treep.tree_enumeration_id=?"; + + return jdbcParkseTemplate.queryForList(sql, + new Object[] { tree_Status, tree_latitude, tree_longitude, tree_latitude, tree_user_id, enumeration_type }); + + } + + private List> getByLocation(String latitude, String longitude, String latitude1) { + String sql = "SELECT enutype.enumeration_type_id , enutype.enumerationName, COALESCE(ac.park_name, ac.location) AS park_name " + + "FROM treeplaintandpruning WHERE tree_Status = 'pending' and " + + " ((6371008.8 * acos( ROUND(cos(radians(?)) * cos(radians(ac.latitude)) * cos(radians(ac.longitude) - radians(?)) + sin(radians(?)) * sin(radians(ac.latitude)), 9) )) < 500)" + + " GROUP BY enutype.enumeration_type_id,enutype.enumerationName, ac.park_name, ac.location "; + + // Use latitude, longitude, and schoolType as positional parameters + return jdbcParkseTemplate.queryForList(sql, new Object[] { latitude, longitude, latitude1 }); + } + + public List> getUserBasedEnum(String tree_latitude, String tree_longitude, String tree_Status) { + String sql = "SELECT * " + + " FROM treeplaintandpruning treep left join tree_image image on image.tree_enumeration_id = treep.tree_Id WHERE tree_flag = 0 and tree_Status = ? and " + + " ((6371008.8 * acos( ROUND(cos(radians(?)) * cos(radians(treep.tree_latitude)) * cos(radians(treep.tree_longitude) - radians(?)) + sin(radians(?)) * sin(radians(treep.tree_latitude)), 9) )) < 500) "; + + // Use latitude, longitude, and schoolType as positional parameters + return jdbcParkseTemplate.queryForList(sql, + new Object[] { tree_Status, tree_latitude, tree_longitude, tree_latitude }); + + } + + public List> getparkNameByRadius(String tree_latitude, String tree_longitude) { + String sql = " SELECT enumeration_Id, park_name\n" + " FROM enumeration_master WHERE\n" + + " ((6371008.8 * acos( ROUND(cos(radians(?)) * cos(radians(latitude)) * cos(radians(longitude) - radians(?)) +\n" + + " sin(radians(?)) * sin(radians(latitude)), 9) )) < 500) and park_name is not null"; + return jdbcParkseTemplate.queryForList(sql, new Object[] { tree_latitude, tree_longitude, tree_latitude }); + + } + + // Added for Flowering and Non-Flowering enumeration + + public List> getparkNameByEnumType(int EnumType, String tree_latitude, String tree_longitude) { + String sql = " SELECT enumeration_Id, COALESCE(park_name, location) AS park_name FROM enumeration_master WHERE enumeration_type = ? and " + + " ((6371008.8 * acos( ROUND(cos(radians(?)) * cos(radians(latitude)) * cos(radians(longitude) - radians(?)) +\n" + + " sin(radians(?)) * sin(radians(latitude)), 9) )) < 500)"; + return jdbcParkseTemplate.queryForList(sql, EnumType, tree_latitude, tree_longitude, tree_latitude); + + } + + public int saveFlowringandNonFlowringDetails(int enumerationId, String enumType, String parkname, int floweringPlantCount, + MultipartFile floweringImg, int nonFloweringPlantCount, MultipartFile nonFloweringImg, String userId) throws Exception { + + int floweringImg_Id = saveFloweringandNonFloweringData(enumerationId, enumType,parkname, floweringPlantCount, nonFloweringPlantCount, userId); + + String name = "floweringImages " + floweringImg_Id; + String imgId = Integer.toString(floweringImg_Id); + + + try { + if(floweringImg != null && !floweringImg.isEmpty()) + { + String floweringImageUrl = fileUpload(name, imgId, floweringImg); + saveFloweringandNonFloweringImage(floweringImg_Id, floweringImageUrl, "Flowering", userId); + System.out.println("===========................" + floweringImageUrl); + } + if(nonFloweringImg != null && !nonFloweringImg.isEmpty()) + { + String nonFloweringImageUrl = fileUpload(name, imgId, nonFloweringImg); + saveFloweringandNonFloweringImage(floweringImg_Id, nonFloweringImageUrl, "NonFlowering", userId ); + System.out.println("===========................" + nonFloweringImageUrl ); + } + return floweringImg_Id; + + } catch (Exception e) { + throw new Exception("Error in image saving " + e); + } + + } + + private int saveFloweringandNonFloweringData(int enumerationId, String enumType, String parkname,int floweringPlantCount, + int nonFloweringPlantCount, String userId) { + + String sql ="Insert into floweringandnonflowering (enumeration_Id, flowering_enumtype, enumeration_type, park_name, flowering_plant_count, " + + "nonflowering_plant_count, userId) values(?, ?, ?, ?, ?, ?, ?)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + try { + jdbcParkseTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, new String[] { "Id" }); + ps.setInt(1, enumerationId); + ps.setInt(2, 12); + ps.setString(3, enumType); + ps.setString(4, parkname); + ps.setInt(5, floweringPlantCount); + ps.setInt(6, nonFloweringPlantCount); + ps.setString(7, userId); + return ps; + + }, keyHolder); + // System.out.println("img id master:"+keyHolder.getKey().intValue()); + // Retrieve the auto-generated ID and return it + return keyHolder.getKey().intValue(); + } catch (Exception e) { + e.printStackTrace(); + } + + return -1; // Return error indicator + } + + private String saveFloweringandNonFloweringImage(int floweringImg_Id, String floweringImageUrl, String status, String userId ) { + + try { + String sqlQuery = "insert into flower_image (flowering_id, flowering_img, flower_status, userid) values (?, ?, ?, ?)"; + jdbcParkseTemplate.update(sqlQuery,floweringImg_Id, floweringImageUrl, status, userId); + + return "Success"; + }catch(Exception e) { + System.out.println("Exception:"+e); + return null; + } + } + + + public List> getFloweringZoneCount(String enumeration_type, String fromdate, String todate, + String userId) { + + StringBuilder sql = new StringBuilder("SELECT en.zone,COUNT(distinct(ff.enumeration_Id)) AS count, sum(ff.flowering_plant_count) as floweringCount, " + + "sum(ff.nonflowering_plant_count) as non_floweringCount FROM floweringandnonflowering ff " + + "LEFT JOIN enumeration_master en ON ff.enumeration_Id = en.enumeration_Id " + + "WHERE ff.enumeration_type = ? " + + "AND DATE(ff.created_date) BETWEEN STR_TO_DATE(?, '%d-%m-%Y') AND STR_TO_DATE(?, '%d-%m-%Y')"); + + if (userId != null && !userId.isEmpty()) { + sql.append("AND ff.userId = ? "); + } + sql.append("GROUP BY en.zone"); + + List params = new ArrayList<>(); + params.add(enumeration_type); + params.add(fromdate); + params.add(todate); + + if (userId != null && !userId.isEmpty()) { + params.add(userId); + } + + return jdbcParkseTemplate.queryForList(sql.toString(),params.toArray()); + } + + public List> getFloweringWardCount(String zone, String fromdate, String todate, + String enumeration_type, String userId) { + + StringBuilder sql = new StringBuilder(" SELECT en.zone, en.ward, count(distinct(ff.enumeration_Id)) as count, sum(ff.flowering_plant_count) as floweringCount, " + + "sum(ff.nonflowering_plant_count) as non_floweringCount FROM floweringandnonflowering ff " + + "left join enumeration_master en on ff.enumeration_Id = en.enumeration_Id " + + "where en.zone=? and date(ff.created_date) between STR_TO_DATE(? , '%d-%m-%Y') " + + "and STR_TO_DATE(? , '%d-%m-%Y') And ff.enumeration_type =? "); + + if (userId != null && !userId.isEmpty()) { + sql.append("AND ff.userId = ? "); + } + sql.append("GROUP BY en.ward"); + + List params = new ArrayList<>(); + params.add(zone); + params.add(fromdate); + params.add(todate); + params.add(enumeration_type); + + if (userId != null && !userId.isEmpty()) { + params.add(userId); + } + + return jdbcParkseTemplate.queryForList(sql.toString(), params.toArray()); + + } + + + public List> getFloweringDetails(String enumeration_type, String zone, String ward, + String fromdate, String todate, String userId, String parkname) { + + StringBuilder sql = new StringBuilder("select et.enumerationName, em.zone, em.ward, ff.park_name as location, em.latitude, em.longitude, ff.flowering_plant_count, " + + "ff.nonflowering_plant_count, date_format(ff.created_date,'%d-%m-%Y %l:%i %p') as date, " + + "COALESCE(GROUP_CONCAT(case when fi.flower_status ='Flowering' then CONCAT('" + fileBaseUrl + "/gccofficialapp/files', fi.flowering_img) else null end),'') as floweringImg," + + "COALESCE(GROUP_CONCAT(case when fi.flower_status ='NonFlowering' then CONCAT('" + fileBaseUrl + "/gccofficialapp/files', fi.flowering_img) else null end),'') as nonFloweringImg" + + " from floweringandnonflowering ff " + + "left join enumeration_master em on ff.enumeration_Id = em.enumeration_Id " + + "left join enumerationtype et on ff.enumeration_type = et.enumeration_type_id " + + "left join flower_image fi on ff.flowering_id = fi.flowering_id " + + "where ff.enumeration_type = ? and em.zone = ? and em.ward = ? and date(ff.created_date) between " + + "STR_TO_DATE(? , '%d-%m-%Y') and STR_TO_DATE(? , '%d-%m-%Y') and ff.park_name = ? "); + + if (userId != null && !userId.isEmpty()) { + sql.append("AND ff.userId = ? "); + } + + sql.append("group by em.latitude,em.longitude, ff.flowering_plant_count, ff.nonflowering_plant_count, ff.created_date"); + + List params = new ArrayList<>(); + params.add(enumeration_type); + params.add(zone); + params.add(ward); + params.add(fromdate); + params.add(todate); + params.add(parkname); + + if (userId != null && !userId.isEmpty()) { + params.add(userId); + } + + return jdbcParkseTemplate.queryForList(sql.toString(), params.toArray()); + } + + public List> getParkwiseFloweringCount(String enumeration_type, String zone, String ward,String fromdate, String todate, + String userId) { + + StringBuilder sql = new StringBuilder("select ff.park_name, sum(ff.flowering_plant_count) as floweringCount, sum(ff.nonflowering_plant_count) as non_floweringCount " + + "from floweringandnonflowering ff " + + "left join enumeration_master em on ff.enumeration_Id = em.enumeration_Id " + + "where ff.enumeration_type = ? and em.zone = ? and em.ward = ? and " + + "date(ff.created_date) between STR_TO_DATE(? , '%d-%m-%Y') and STR_TO_DATE(? , '%d-%m-%Y') "); + + if (userId != null && !userId.isEmpty()) { + sql.append("AND ff.userId = ? "); + } + + sql.append("group by ff.park_name"); + + List params = new ArrayList<>(); + params.add(enumeration_type); + params.add(zone); + params.add(ward); + params.add(fromdate); + params.add(todate); + + if (userId != null && !userId.isEmpty()) { + params.add(userId); + } + + return jdbcParkseTemplate.queryForList(sql.toString(), params.toArray()); + } + } diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/controller/SchoolUserController.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/controller/SchoolUserController.java index da7408d..224cbfb 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/controller/SchoolUserController.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/controller/SchoolUserController.java @@ -324,13 +324,17 @@ public class SchoolUserController { @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 GenSetconditionQa, @RequestParam String GenSetconditionAns, @RequestParam(required = false) MultipartFile feedPhoto, @RequestParam(required = false) int school_details_id, @@ -344,8 +348,8 @@ public class SchoolUserController { // Call the service method to save feedback schoolUserActivity.saveElectricityFeedback( categoryId, - FansAvailableQa, FansAvailableAns, - LightsAvailableQa, LightsAvailableAns, + FansAvailableQa, FansAvailableAns, FansNotAvailableQa, FansNotAvailableAns, + LightsAvailableQa, LightsAvailableAns, LightsNotAvailableQa, LightsNotAvailableAns, SwitchBoardQa, SwitchBoardAns, GenSetQa, GenSetAns,GenSetconditionQa,GenSetconditionAns, feedPhoto, school_details_id, zone, division,latitude,longitude,user_id @@ -361,10 +365,16 @@ public class SchoolUserController { @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, @@ -383,9 +393,9 @@ public class SchoolUserController { // Call the service method to save feedback schoolUserActivity.saveITAssetsFeedback( categoryId, - SystemAvailableQa, SystemAvailableAns, - PrinterAvailableQa, PrinterAvailableAns, - UPSAvailableQa, UPSAvailableAns, + SystemAvailableQa, SystemAvailableAns, SystemNotAvailableQa, SystemNotAvailableAns, + PrinterAvailableQa, PrinterAvailableAns, PrinterNotAvailableQa, PrinterNotAvailableAns, + UPSAvailableQa, UPSAvailableAns, UPSNotAvailableQa, UPSNotAvailableAns, NetworkAvailableQa, NetworkAvailableAns, projectorgoodconditionQa, projectorgoodconditionAns, smartboardgoodconditionQa, smartboardgoodconditionAns, diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/service/SchoolUserActivity.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/service/SchoolUserActivity.java index 3b5996b..69f5110 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/service/SchoolUserActivity.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccschools/service/SchoolUserActivity.java @@ -569,8 +569,12 @@ public class SchoolUserActivity { int categoryId, String FansAvailableQa, String FansAvailableAns, + String FansNotAvailableQa, + String FansNotAvailableAns, String LightsAvailableQa, String LightsAvailableAns, + String LightsNotAvailableQa, + String LightsNotAvailableAns, String SwitchBoardQa, String SwitchBoardAns, String GenSetQa, @@ -598,7 +602,9 @@ public class SchoolUserActivity { String feedref = generateRandomString(); //generate feedback reference text // Save feedback for each question and answer pair saveFeedbackDetails(categoryId, FansAvailableQa, FansAvailableAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); + saveFeedbackDetails(categoryId, FansNotAvailableQa, FansNotAvailableAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); saveFeedbackDetails(categoryId, LightsAvailableQa, LightsAvailableAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); + saveFeedbackDetails(categoryId, LightsNotAvailableQa, LightsNotAvailableAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); saveFeedbackDetails(categoryId, SwitchBoardQa, SwitchBoardAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); saveFeedbackDetails(categoryId, GenSetQa, GenSetAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); saveFeedbackDetails(categoryId, GenSetconditionQa, GenSetconditionAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); @@ -615,10 +621,16 @@ public class SchoolUserActivity { int categoryId, String SystemAvailableQa, String SystemAvailableAns, + String SystemNotAvailableQa, + String SystemNotAvailableAns, String PrinterAvailableQa, String PrinterAvailableAns, + String PrinterNotAvailableQa, + String PrinterNotAvailableAns, String UPSAvailableQa, String UPSAvailableAns, + String UPSNotAvailableQa, + String UPSNotAvailableAns, String NetworkAvailableQa, String NetworkAvailableAns, String projectorgoodconditionQa, @@ -647,8 +659,11 @@ public class SchoolUserActivity { // Save feedback for each question and answer pair saveFeedbackDetails(categoryId, SystemAvailableQa, SystemAvailableAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); + saveFeedbackDetails(categoryId, SystemNotAvailableQa, SystemNotAvailableAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); saveFeedbackDetails(categoryId, PrinterAvailableQa, PrinterAvailableAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); + saveFeedbackDetails(categoryId, PrinterNotAvailableQa, PrinterNotAvailableAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); saveFeedbackDetails(categoryId, UPSAvailableQa, UPSAvailableAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); + saveFeedbackDetails(categoryId, UPSNotAvailableQa, UPSNotAvailableAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); saveFeedbackDetails(categoryId, NetworkAvailableQa, NetworkAvailableAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); saveFeedbackDetails(categoryId, projectorgoodconditionQa, projectorgoodconditionAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); saveFeedbackDetails(categoryId, smartboardgoodconditionQa, smartboardgoodconditionAns, school_details_id, zone, division,latitude,longitude,user_id,feedref); diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/controller/APIOfficerController.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/controller/APIOfficerController.java index 9cac6a2..0e37dd9 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/controller/APIOfficerController.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/controller/APIOfficerController.java @@ -118,4 +118,55 @@ public class APIOfficerController { return officerActivity.getRequestDataById(rescue_id); } + @GetMapping(value="/getFloodGrandData") + public List getFloodGrandData( + @RequestParam(value="", required = true) String fromDate, + @RequestParam(value="", required = true) String toDate + ){ + return officerActivity.getFloodGrandData(fromDate,toDate); + } + + @GetMapping(value="/getFloodAbsData") + public List getFloodAbsData( + @RequestParam(value="", required = true) String fromDate, + @RequestParam(value="", required = true) String toDate + ){ + return officerActivity.getFloodAbsData(fromDate,toDate); + } + + @GetMapping(value="/getFloodZoneData") + public List getFloodZoneData( + @RequestParam(value="", required = true) String fromDate, + @RequestParam(value="", required = true) String toDate, + @RequestParam(value="", required = true) String categorie, + @RequestParam(value="", required = true) String mode, + @RequestParam(value="", required = false) String status + ){ + return officerActivity.getFloodZoneData(fromDate,toDate,categorie,mode,status); + } + + @GetMapping(value="/getFloodWardData") + public List getFloodWardData( + @RequestParam(value="", required = true) String fromDate, + @RequestParam(value="", required = true) String toDate, + @RequestParam(value="", required = true) String categorie, + @RequestParam(value="", required = true) String mode, + @RequestParam(value="", required = true) String zone, + @RequestParam(value="", required = false) String status + ){ + return officerActivity.getFloodWardData(fromDate,toDate,categorie,mode,zone,status); + } + + @GetMapping(value="/getFloodData") + public List getFloodData( + @RequestParam(value="", required = true) String fromDate, + @RequestParam(value="", required = true) String toDate, + @RequestParam(value="", required = true) String categorie, + @RequestParam(value="", required = true) String mode, + @RequestParam(value="", required = true) String zone, + @RequestParam(value="", required = true) String ward, + @RequestParam(value="", required = false) String status + ){ + return officerActivity.getFloodData(fromDate,toDate,categorie,mode,zone,ward,status); + } } diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/controller/APIUserController.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/controller/APIUserController.java index c0b5379..1d7629a 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/controller/APIUserController.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/controller/APIUserController.java @@ -34,12 +34,13 @@ public class APIUserController { @RequestParam(value="if_any", required = false) String if_any, @RequestParam(value="land_mark", required = false) String land_mark, @RequestParam(value="remarks", required = false) String remarks, - @RequestParam(value="loginId", required = false) String loginId + @RequestParam(value="loginId", required = false) String loginId, + @RequestParam(value="mode", required = false) String mode ){ return userActivity.saveRequest(contact_name, contact_number, latitude, longitude, zone, ward, streetid, streetname, location_details, request_type, no_of_count, if_any, - land_mark, remarks, loginId); + land_mark, remarks, loginId,mode); } @GetMapping(value="/getMyRequest") @@ -57,4 +58,8 @@ public class APIUserController { return userActivity.getRequestDataById(rescue_id); } + @GetMapping(value="/getAlert") + public List getAlert(){ + return userActivity.getAlert(); + } } diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/service/OfficerActivity.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/service/OfficerActivity.java index 54502b8..24e3cfb 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/service/OfficerActivity.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/service/OfficerActivity.java @@ -649,4 +649,357 @@ public class OfficerActivity { response.put("Data", result); return Collections.singletonList(response); } + + @Transactional + public List> getFloodGrandData( + String fromDate, + String toDate){ + String sqlQuery = "SELECT IFNULL(SUM(CASE WHEN status = 0 THEN 1 ELSE 0 END), 0) AS Pending, " + + "IFNULL(SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END), 0) AS Completed, " + + "IFNULL(COUNT(id), 0) AS Register FROM rescue " + + "WHERE DATE(cdate) BETWEEN STR_TO_DATE('"+fromDate+"', '%d-%m-%Y') AND STR_TO_DATE('"+toDate+"', '%d-%m-%Y')"; + List> result = jdbcSOSTemplate.queryForList(sqlQuery); + Map response = new HashMap<>(); + response.put("status", "success"); + response.put("message", "Request Information"); + response.put("Data", result); + return Collections.singletonList(response); + } + + @Transactional + public List> getFloodAbsData(String fromDate, String toDate) { + String sqlQuery = "SELECT IFNULL(SUM(CASE WHEN status = 0 THEN 1 ELSE 0 END), 0) AS Pending, " + + "IFNULL(SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END), 0) AS Completed, " + + "IFNULL(COUNT(id), 0) AS Requested " + + "FROM rescue " + + "WHERE DATE(cdate) BETWEEN STR_TO_DATE('" + fromDate + "', '%d-%m-%Y') AND STR_TO_DATE('" + toDate + "', '%d-%m-%Y')"; + List> result = jdbcSOSTemplate.queryForList(sqlQuery); + + if (result.isEmpty()) { + return result; + } + + Map response = new HashMap<>(); + Map dataMap = new HashMap<>(); + dataMap.putAll(result.get(0)); + + // Categories: Medical, Food, Rescue + String[] categories = {"Medical", "Food", "Rescue"}; + String[] modes = {"1913", "whatsapp", "nca"}; + + for (String category : categories) { + Map>> categoryData = new HashMap<>(); + int categoryTotalPending = 0; + int categoryTotalCompleted = 0; + int categoryTotalRequested = 0; + + for (String mode : modes) { + String sqlCategoryQuery = "SELECT IFNULL(SUM(CASE WHEN status = 0 THEN 1 ELSE 0 END), 0) AS Pending, " + + "IFNULL(SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END), 0) AS Completed, " + + "IFNULL(COUNT(id), 0) AS Requested " + + "FROM rescue WHERE `modeofcomplient` = '" + mode + "' AND `request_type` = '" + category + "' " + + "AND DATE(cdate) BETWEEN STR_TO_DATE('" + fromDate + "', '%d-%m-%Y') AND STR_TO_DATE('" + toDate + "', '%d-%m-%Y')"; + List> modeResult = jdbcSOSTemplate.queryForList(sqlCategoryQuery); + + //categoryData.put(mode, modeResult); + if (!modeResult.isEmpty()) { + Map modeData = modeResult.get(0); + categoryData.put(mode, Collections.singletonList(modeData)); + + // Update totals for the category + categoryTotalPending += ((Number) modeData.get("Pending")).intValue(); + categoryTotalCompleted += ((Number) modeData.get("Completed")).intValue(); + categoryTotalRequested += ((Number) modeData.get("Requested")).intValue(); + }else { + // If there's no data for the current mode, add a default entry + Map defaultModeData = new HashMap<>(); + defaultModeData.put("Pending", 0); + defaultModeData.put("Completed", 0); + defaultModeData.put("Requested", 0); + categoryData.put(mode, Collections.singletonList(defaultModeData)); + } + } + // Add the total data for the current category + Map totalData = new HashMap<>(); + totalData.put("Pending", categoryTotalPending); + totalData.put("Completed", categoryTotalCompleted); + totalData.put("Requested", categoryTotalRequested); + categoryData.put("Total", Collections.singletonList(totalData)); + dataMap.put(category, categoryData); + } + + response.put("status", "success"); + response.put("message", "Request Information"); + response.put("fromDate", fromDate); + response.put("toDate", toDate); + response.put("Data", Collections.singletonList(dataMap)); + + return Collections.singletonList(response); + } + /* + @Transactional + public List> getFloodZoneData( + String fromDate, + String toDate, + String categorie, + String mode) { + String sqlQuery = "SELECT zone, " + + "IFNULL(SUM(CASE WHEN status = 0 THEN 1 ELSE 0 END), 0) AS Pending, " + + "IFNULL(SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END), 0) AS Completed, " + + "IFNULL(COUNT(id), 0) AS Register " + + "FROM rescue " + + "WHERE `request_type` = ? " + + "AND `modeofcomplient` = ? " + + "AND DATE(cdate) BETWEEN STR_TO_DATE(?, '%d-%m-%Y') AND STR_TO_DATE(?, '%d-%m-%Y') " + + "GROUP BY zone"; + + List> result = jdbcSOSTemplate.queryForList( + sqlQuery, new Object[]{categorie, mode, fromDate, toDate}); + + Map response = new HashMap<>(); + + if (result.isEmpty()) { + response.put("Data", Collections.emptyList()); + } else { + response.put("Data", result); + } + response.put("status", "success"); + response.put("message", "Request Information"); + response.put("fromDate", fromDate); + response.put("toDate", toDate); + response.put("categorie", categorie); + response.put("mode", mode); + + return Collections.singletonList(response); + } + */ + @Transactional + public List> getFloodZoneData( + String fromDate, + String toDate, + String categorie, + String mode, + String status) { + String whereStatus=""; + String whereMode=""; + // Check if the status is provided and is either "0" or "1" + if ("0".equals(status) || "1".equals(status)) { + whereStatus = "AND `status` = '"+status+"' "; + } + + if ("Total".equals(mode) || "Total".equals(mode)) { + whereMode = "AND `modeofcomplient` <> ? "; + } + else { + whereMode = "AND `modeofcomplient` = ? "; + } + + String sqlQuery = "SELECT zone, " + + "IFNULL(SUM(CASE WHEN status = 0 THEN 1 ELSE 0 END), 0) AS Pending, " + + "IFNULL(SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END), 0) AS Completed, " + + "IFNULL(COUNT(id), 0) AS Register " + + "FROM rescue " + + "WHERE `request_type` = ? " + + whereMode + + "AND DATE(cdate) BETWEEN STR_TO_DATE(?, '%d-%m-%Y') AND STR_TO_DATE(?, '%d-%m-%Y') " + + whereStatus + + "GROUP BY zone"; + + List> result = jdbcSOSTemplate.queryForList( + sqlQuery, new Object[]{categorie, mode, fromDate, toDate}); + + Map response = new HashMap<>(); + int totalPending = 0; + int totalCompleted = 0; + int totalRegister = 0; + + if (!result.isEmpty()) { + for (Map zoneData : result) { + totalPending += ((Number) zoneData.get("Pending")).intValue(); + totalCompleted += ((Number) zoneData.get("Completed")).intValue(); + totalRegister += ((Number) zoneData.get("Register")).intValue(); + } + } + + // Add totals + Map totalData = new HashMap<>(); + totalData.put("Pending", totalPending); + totalData.put("Completed", totalCompleted); + totalData.put("Register", totalRegister); + + response.put("Data", result); + response.put("Total", totalData); + response.put("status", "success"); + response.put("message", "Request Information"); + response.put("fromDate", fromDate); + response.put("toDate", toDate); + response.put("categorie", categorie); + response.put("mode", mode); + + return Collections.singletonList(response); + } + + /* + @Transactional + public List> getFloodWardData( + String fromDate, + String toDate, + String categorie, + String mode, + String zone) { + String sqlQuery = "SELECT ward, " + + "IFNULL(SUM(CASE WHEN status = 0 THEN 1 ELSE 0 END), 0) AS Pending, " + + "IFNULL(SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END), 0) AS Completed, " + + "IFNULL(COUNT(id), 0) AS Register " + + "FROM rescue " + + "WHERE `request_type` = ? " + + "AND `modeofcomplient` = ? " + + "AND `zone` = ? " + + "AND DATE(cdate) BETWEEN STR_TO_DATE(?, '%d-%m-%Y') AND STR_TO_DATE(?, '%d-%m-%Y') " + + "GROUP BY ward"; + + List> result = jdbcSOSTemplate.queryForList( + sqlQuery, new Object[]{categorie, mode, zone, fromDate, toDate}); + + Map response = new HashMap<>(); + + if (result.isEmpty()) { + response.put("Data", Collections.emptyList()); + } else { + response.put("Data", result); + } + response.put("status", "success"); + response.put("message", "Request Information"); + response.put("fromDate", fromDate); + response.put("toDate", toDate); + response.put("categorie", categorie); + response.put("mode", mode); + response.put("zone", zone); + + return Collections.singletonList(response); + }*/ + + @Transactional + public List> getFloodWardData( + String fromDate, + String toDate, + String categorie, + String mode, + String zone, + String status) { + String whereStatus=""; + String whereMode=""; + + // Check if the status is provided and is either "0" or "1" + if ("0".equals(status) || "1".equals(status)) { + whereStatus = "AND `status` = '"+status+"' "; + } + + if ("Total".equals(mode) || "Total".equals(mode)) { + whereMode = "AND `modeofcomplient` <> ? "; + } + else { + whereMode = "AND `modeofcomplient` = ? "; + } + String sqlQuery = "SELECT ward, " + + "IFNULL(SUM(CASE WHEN status = 0 THEN 1 ELSE 0 END), 0) AS Pending, " + + "IFNULL(SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END), 0) AS Completed, " + + "IFNULL(COUNT(id), 0) AS Register " + + "FROM rescue " + + "WHERE `request_type` = ? " + + whereMode + + "AND `zone` = ? " + + "AND DATE(cdate) BETWEEN STR_TO_DATE(?, '%d-%m-%Y') AND STR_TO_DATE(?, '%d-%m-%Y') " + + whereStatus + + "GROUP BY ward"; + + List> result = jdbcSOSTemplate.queryForList( + sqlQuery, new Object[]{categorie, mode, zone, fromDate, toDate}); + + Map response = new HashMap<>(); + int totalPending = 0; + int totalCompleted = 0; + int totalRegister = 0; + + if (!result.isEmpty()) { + for (Map wardData : result) { + totalPending += ((Number) wardData.get("Pending")).intValue(); + totalCompleted += ((Number) wardData.get("Completed")).intValue(); + totalRegister += ((Number) wardData.get("Register")).intValue(); + } + } + + // Add totals + Map totalData = new HashMap<>(); + totalData.put("Pending", totalPending); + totalData.put("Completed", totalCompleted); + totalData.put("Register", totalRegister); + + response.put("Data", result); + response.put("Total", totalData); + response.put("status", "success"); + response.put("message", "Request Information"); + response.put("fromDate", fromDate); + response.put("toDate", toDate); + response.put("categorie", categorie); + response.put("mode", mode); + response.put("zone", zone); + + return Collections.singletonList(response); + } + + @Transactional + public List> getFloodData( + String fromDate, + String toDate, + String categorie, + String mode, + String zone, + String ward, + String status) { + String whereStatus=""; + String whereMode=""; + + // Check if the status is provided and is either "0" or "1" + if ("0".equals(status) || "1".equals(status)) { + whereStatus = "AND `status` = '"+status+"' "; + } + + if ("Total".equals(mode) || "Total".equals(mode)) { + whereMode = "AND `modeofcomplient` <> ? "; + } + else { + whereMode = "AND `modeofcomplient` = ? "; + } + String sqlQuery = "SELECT * " + + "FROM rescue " + + "WHERE `request_type` = ? " + + whereMode + + "AND `zone` = ? " + + "AND `ward` = ? " + + whereStatus + + "AND DATE(cdate) BETWEEN STR_TO_DATE(?, '%d-%m-%Y') AND STR_TO_DATE(?, '%d-%m-%Y') "; + + List> result = jdbcSOSTemplate.queryForList( + sqlQuery, new Object[]{categorie, mode, zone, ward ,fromDate, toDate}); + + Map response = new HashMap<>(); + + if (result.isEmpty()) { + response.put("Data", Collections.emptyList()); + } else { + response.put("Data", result); + } + response.put("status", "success"); + response.put("message", "Request Information"); + response.put("fromDate", fromDate); + response.put("toDate", toDate); + response.put("categorie", categorie); + response.put("mode", mode); + response.put("zone", zone); + response.put("ward", ward); + + return Collections.singletonList(response); + } + } diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/service/UserActivity.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/service/UserActivity.java index daa4451..87fc24f 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/service/UserActivity.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccsos/service/UserActivity.java @@ -77,6 +77,31 @@ public class UserActivity { return byteArrayOutputStream.toByteArray(); } + @Transactional + public List> getAlert(){ + String alertQuery =""; + + alertQuery="SELECT " + + " `id`," + + " `name`," + + " `color`," + + " DATE_FORMAT(`fromdate`, '%d-%m-%Y') AS `fromdate`," + + " DATE_FORMAT(`todate`, '%d-%m-%Y') AS `todate`," + + " `isactive`," + + " `isdelete` " + + "FROM " + + " `alerts` " + + "WHERE isactive=1 AND isdelete=0 LIMIT 1"; + List> result = jdbcSOSTemplate.queryForList(alertQuery); + Map response = new HashMap<>(); + + response.put("status", "success"); + response.put("message", "Request Information"); + response.put("Data", result); + + return Collections.singletonList(response); + } + @Transactional public List> saveRequest( String contact_name, @@ -93,7 +118,8 @@ public class UserActivity { String if_any, String land_mark, String remarks, - String loginId + String loginId, + String mode ) { List> result=null; Map response = new HashMap<>(); @@ -101,8 +127,8 @@ public class UserActivity { String sqlQuery = "INSERT INTO `rescue`(`contact_name`, `contact_number`, `latitude`, `longitude`, `zone`, `ward`, " + "`streetid`, `streetname`, `location_details`, `request_type`, `no_of_count`, `if_any`, `land_mark`, " - + "`remarks`, `user_id`) " - + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + + "`remarks`, `user_id`,`modeofcomplient`) " + + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; KeyHolder keyHolder = new GeneratedKeyHolder(); @@ -126,6 +152,7 @@ public class UserActivity { ps.setString(13, land_mark); ps.setString(14, remarks); ps.setString(15, loginId); + ps.setString(16, mode); return ps; } }, keyHolder); diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/controller/UserApiController.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/controller/UserApiController.java index 1941ee1..193d526 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/controller/UserApiController.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/controller/UserApiController.java @@ -1,8 +1,15 @@ 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; @@ -13,318 +20,850 @@ 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> 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("photo1") MultipartFile photo1, - @RequestParam("sex_1") String sex_1, - @RequestParam("contraception_1") boolean contraception_1) { - - try { - Timestamp date_1 = Timestamp.valueOf(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") - .format(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(date1))); - - String step = userService.saveStep1(qr_id, userid_1, date_1, lat_1, long_1, location_1, photo1, sex_1, contraception_1, 1); - - Map 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_1: " + e.getMessage() - )); - } - } - - - @PostMapping("/step2") - public ResponseEntity> 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("photo2") MultipartFile photo2, - @RequestParam("sex_2") String sex_2, - @RequestParam("contraception_2") boolean contraception_2) { - - try { - 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, photo2, sex_2, contraception_2, 2); - - // Prepare and return the response - Map 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> 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> data = userService.getlogsrfid(rf_id); - - if (data != null && !data.isEmpty()) { - for (Map map : data) { - if (map.get("date_5") != null) { - int days = userService.getVaccineDue(qr_id, rf_id, formattedDate); - if (days <= 10) { - stage = 5; - } else { - stage = 6; - } - step = userService.updateStage(rf_id, qr_id, stage); - } - } - } 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 - Map response = new HashMap<>(); - 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> 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) { - try { - int stage = 5; // Assuming stage is hardcoded to 5 for Step 4 - - String qrid = userService.saveStep4(qr_id, rf_id, userid_4, surgery_complication_4, complication_type_4); - String step = userService.updateStage(rf_id, qr_id, stage); - - // Prepare response - Map 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> 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("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(qr_id, rf_id, date5.toString()); - - String qrid; - String step; - - if (days <= 10) { - qrid = userService.saveNewStep5(rf_id, qr_id, userid_5, arv_5, dhppi_5, photo_5, lat_5, long_5, location_5, date5); - } else { - qrid = userService.saveUpdateStep5(rf_id, qr_id, userid_5, arv_5, dhppi_5, photo_5, lat_5, long_5, location_5, date5); - } - step = userService.updateStage(rf_id, qr_id, stage); - - Map response = new HashMap<>(); - response.put("status", "OK"); - response.put("Qr_id", qrid); - 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 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> 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("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, date6, photo_6, stage); - - Map 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> getMasterData(@RequestParam String rf_id) { - try { - List> data = userService.getMasterData(rf_id); - Map response = new HashMap<>(); - - if (data.isEmpty()) { - //response.put("status", "Failed"); - //response.put("message", "No Data Found"); - } else { - response.put("status", "OK"); - response.put("data", data); - } - - 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> getLogData(@RequestParam String qr_id) { - try{ - List> data = userService.getLogData(qr_id); - Map response = new HashMap<>(); - if(data.size() != 0) { - response.put("status", "OK"); - response.put("data", data); - } else { - //response.put("status", "Failed"); - //response.put("data", "No Data Found"); - } - return ResponseEntity.ok(response); - }catch (Exception e) { - // Log the exception details for debugging - e.printStackTrace(); - - // Provide a user-friendly error message - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(Map.of( - "status", "Error", - "message", "Error getting data: " + e.getMessage() - )); - } - } - -} + + @Autowired + private UserService userService; + + @PostMapping("/step1") + public ResponseEntity> 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 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> 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 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> 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> data = userService.getlogsrfid(rf_id); + Map response = new HashMap<>(); + + if (data != null && !data.isEmpty()) { + for (Map 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> 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 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> 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 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> 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 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> getMasterData(@RequestParam String rf_id) { + try { + + List> data = userService.getMasterData(rf_id); + Map 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 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> getLogData(@RequestParam String qr_id) { + try { + List> data = userService.getLogData(qr_id); + Map response = new HashMap<>(); + if (data.size() != 0) { + response.put("status", "OK"); + response.put("data", data); + } else { + // response.put("status", "Failed"); + // response.put("data", "No Data Found"); + } + return ResponseEntity.ok(response); + } catch (Exception e) { + // Log the exception details for debugging + e.printStackTrace(); + + // Provide a user-friendly error message + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Map.of("status", "Error", "message", "Error getting data: " + e.getMessage())); + } + } + +// Get Overall Data + @GetMapping("getoveralldata") + public ResponseEntity> getOverallData(@RequestParam String fromDate, + @RequestParam String toDate) { + + Map response = new HashMap<>(); + List> 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> getoverallcatcheddata(@RequestParam String fromDate, @RequestParam String toDate) { + return userService.getoverallcatcheddata(fromDate, toDate); + } + +// Get Overall Released Data + @GetMapping("getoverallreleaseddata") + public List> getoverallreleaseddata(@RequestParam String fromDate, + @RequestParam String toDate) { + return userService.getoverallreleaseddata(fromDate, toDate); + } + +// Get AbcCenterwiseData + @GetMapping("getAbcCenterwiseData") + public ResponseEntity> getAbcCenterwiseData(@RequestParam String fromDate, + @RequestParam String toDate, @RequestParam String abcCenter) { + Map response = new HashMap<>(); + List> 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> getUnstrelizedZoneBreakup(@RequestParam String fromDate, + @RequestParam String toDate, @RequestParam String abcCenter) { + return userService.getUnstrelizedZoneBreakup(fromDate, toDate, abcCenter); + } + +// Get Unstrelized division breakup + @GetMapping("getUnstrelizedDivisionBreakup") + public List> 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> 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 getUnstrelizedDogsBreakup(@RequestParam String fromDate, @RequestParam String toDate, + @RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone, + @RequestParam String streetID, @RequestParam String sex) { + Map response = new LinkedHashMap<>(); + + try { + List> data = userService.getUnstrelizedDogsBreakup(ward, fromDate, toDate, abcCenter, + zone, streetID, sex); + + Map>> groupedData = new LinkedHashMap<>(); + for (Map record : data) { + String rfId = (String) record.get("rf_id"); + groupedData.putIfAbsent(rfId, new ArrayList<>()); + groupedData.get(rfId).add(record); + } + + List> list1 = new ArrayList<>(); + for (Map.Entry>> entry : groupedData.entrySet()) { + Map 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> geStrelizedZoneBreakup(@RequestParam String fromDate, @RequestParam String toDate, + @RequestParam String abcCenter) { + return userService.getStrelizedZoneBreakup(fromDate, toDate, abcCenter); + } + +// Get Strelized division breakup + @GetMapping("getStrelizedDivisionBreakup") + public List> 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> 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 getStrelizedDogsBreakup(@RequestParam String fromDate, @RequestParam String toDate, + @RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone, + @RequestParam String streetID, @RequestParam String sex) { + Map response = new LinkedHashMap<>(); + + try { + List> data = userService.getStrelizedDogsBreakup(ward, fromDate, toDate, abcCenter, + zone, streetID, sex); + + Map>> groupedData = new LinkedHashMap<>(); + for (Map record : data) { + String rfId = (String) record.get("rf_id"); + groupedData.putIfAbsent(rfId, new ArrayList<>()); + groupedData.get(rfId).add(record); + } + + List> list1 = new ArrayList<>(); + for (Map.Entry>> entry : groupedData.entrySet()) { + Map 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> getUnfitZoneBreakup(@RequestParam String fromDate, @RequestParam String toDate, + @RequestParam String abcCenter) { + return userService.getUnfitZoneBreakup(fromDate, toDate, abcCenter); + } + +// Get Unfit division breakup + @GetMapping("getUnfitDivisionBreakup") + public List> 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> 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 getUnfitDogsBreakup(@RequestParam String fromDate, @RequestParam String toDate, + @RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone, + @RequestParam String streetID, @RequestParam String sex) { + Map response = new LinkedHashMap<>(); + + try { + List> data = userService.getUnfitDogsBreakup(ward, fromDate, toDate, abcCenter, zone, + streetID, sex); + + Map>> groupedData = new LinkedHashMap<>(); + for (Map record : data) { + String rfId = (String) record.get("rf_id"); + groupedData.putIfAbsent(rfId, new ArrayList<>()); + groupedData.get(rfId).add(record); + } + + List> list1 = new ArrayList<>(); + for (Map.Entry>> entry : groupedData.entrySet()) { + Map 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> getSurgeryZoneBreakup(@RequestParam String fromDate, @RequestParam String toDate, + @RequestParam String abcCenter) { + return userService.getSurgeryZoneBreakup(fromDate, toDate, abcCenter); + } + +//Get Surgery division breakup + @GetMapping("getSurgeryDivisionBreakup") + public List> 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> 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 getSurgeryDogsBreakup(@RequestParam String fromDate, @RequestParam String toDate, + @RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone, + @RequestParam String streetID, @RequestParam String sex) { + Map response = new LinkedHashMap<>(); + + try { + List> data = userService.getSurgeryDogsBreakup(ward, fromDate, toDate, abcCenter, zone, + streetID, sex); + + Map>> groupedData = new LinkedHashMap<>(); + for (Map record : data) { + String rfId = (String) record.get("rf_id"); + groupedData.putIfAbsent(rfId, new ArrayList<>()); + groupedData.get(rfId).add(record); + } + + List> list1 = new ArrayList<>(); + for (Map.Entry>> entry : groupedData.entrySet()) { + Map 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> getDiedZoneBreakup(@RequestParam String fromDate, @RequestParam String toDate, + @RequestParam String abcCenter) { + return userService.getDiedZoneBreakup(fromDate, toDate, abcCenter); + } + +//Get Died division breakup + @GetMapping("getDiedDivisionBreakup") + public List> 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> 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 getDiedDogsBreakup(@RequestParam String fromDate, @RequestParam String toDate, + @RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone, + @RequestParam String streetID, @RequestParam String sex) { + Map response = new LinkedHashMap<>(); + + try { + List> data = userService.getDiedDogsBreakup(ward, fromDate, toDate, abcCenter, zone, + streetID, sex); + + Map>> groupedData = new LinkedHashMap<>(); + for (Map record : data) { + String rfId = (String) record.get("rf_id"); + groupedData.putIfAbsent(rfId, new ArrayList<>()); + groupedData.get(rfId).add(record); + } + + List> list1 = new ArrayList<>(); + for (Map.Entry>> entry : groupedData.entrySet()) { + Map 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> getReleasedZoneBreakup(@RequestParam String fromDate, @RequestParam String toDate, + @RequestParam String abcCenter) { + return userService.getReleasedZoneBreakup(fromDate, toDate, abcCenter); + } + +//Get Released division breakup + @GetMapping("getReleasedDivisionBreakup") + public List> 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> 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 getReleasedDogsBreakup(@RequestParam String fromDate, @RequestParam String toDate, + @RequestParam String abcCenter, @RequestParam String ward, @RequestParam String zone, + @RequestParam String streetID, @RequestParam String sex) { + Map response = new LinkedHashMap<>(); + + try { + List> data = userService.getReleasedDogsBreakup(ward, fromDate, toDate, abcCenter, zone, + streetID, sex); + + Map>> groupedData = new LinkedHashMap<>(); + for (Map record : data) { + String rfId = (String) record.get("rf_id"); + groupedData.putIfAbsent(rfId, new ArrayList<>()); + groupedData.get(rfId).add(record); + } + + List> list1 = new ArrayList<>(); + for (Map.Entry>> entry : groupedData.entrySet()) { + Map 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> getZoneList() { + Map response = new HashMap<>(); + List> 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 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 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> 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 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); + } + +} \ No newline at end of file diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/service/UserService.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/service/UserService.java index c966388..a424aca 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/service/UserService.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/gccstraydogs/service/UserService.java @@ -1,13 +1,21 @@ package in.gov.chennaicorporation.mobileservice.gccstraydogs.service; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; + import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.math.BigDecimal; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.sql.Timestamp; +import java.time.LocalDate; +import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -20,306 +28,1290 @@ 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.http.ResponseEntity; +import org.springframework.jdbc.BadSqlGrammarException; + +import java.util.ArrayList; +import java.util.Arrays; + import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import in.gov.chennaicorporation.mobileservice.gccactivity.service.DateTimeUtil; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; +import jakarta.persistence.Query; +import jakarta.servlet.http.HttpServletResponse; import jakarta.transaction.Transactional; @Service public class UserService { - + @PersistenceContext + private EntityManager entityManager; private JdbcTemplate jdbcStraydogsTemplate; private final Environment environment; private String fileBaseUrl; - + @Autowired public void setDataSource(@Qualifier("mysqlGccStraydogsDataSource") DataSource straydogsDataSource) { this.jdbcStraydogsTemplate = new JdbcTemplate(straydogsDataSource); } - + @Autowired public UserService(Environment environment) { this.environment = environment; - this.fileBaseUrl=environment.getProperty("fileBaseUrl"); + this.fileBaseUrl = environment.getProperty("fileBaseUrl"); } - + private byte[] compressImage(BufferedImage image, float quality) throws IOException { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(byteArrayOutputStream); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(byteArrayOutputStream); - ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next(); - writer.setOutput(imageOutputStream); + ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next(); + writer.setOutput(imageOutputStream); - ImageWriteParam param = writer.getDefaultWriteParam(); - if (param.canWriteCompressed()) { - param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); - param.setCompressionQuality(quality); - } + 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.write(null, new javax.imageio.IIOImage(image, null, null), param); - writer.dispose(); - imageOutputStream.close(); + writer.dispose(); + imageOutputStream.close(); + + return byteArrayOutputStream.toByteArray(); + } - 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("straydogs_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, bytes); - - System.out.println(filePath); - return filepath_txt; - - } catch (IOException e) { - e.printStackTrace(); - return "Failed to save file " + file.getOriginalFilename(); - } + String uploadDirectory = environment.getProperty("file.upload.directory"); + String serviceFolderName = environment.getProperty("straydogs_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, bytes); + + System.out.println(filePath); + return filepath_txt; + + } catch (IOException e) { + e.printStackTrace(); + return "Failed to save file " + file.getOriginalFilename(); + } + } + + @Transactional + public List> getABCCenter(String latitude, String longitude) { + String sqlQuery = ""; + + sqlQuery = "SELECT * " + "FROM abc_centers " + "WHERE (isactive=1 AND isdelete=0) AND " + + " ((6371008.8 * acos( ROUND(cos(radians(?)) * cos(radians(latitude)) * cos(radians(longitude) - radians(?)) + sin(radians(?)) * sin(radians(latitude)), 9) )) < 500)"; + List> result = jdbcStraydogsTemplate.queryForList(sqlQuery, + new Object[] { latitude, longitude, latitude }); + Map response = new HashMap<>(); + + response.put("status", "success"); + response.put("message", "Request Information"); + response.put("Data", result); + + return Collections.singletonList(response); } @Transactional - public String saveStep1(String qr_id, String userid_1, Timestamp date_1, String lat_1, String long_1, String location_1, MultipartFile file, String sex_1, boolean contraception_1, int stage) { + public List> getABCCenterList(){ + String sqlQuery =""; + + sqlQuery="SELECT * " + + "FROM abc_centers "; + List> result = jdbcStraydogsTemplate.queryForList(sqlQuery); + Map response = new HashMap<>(); + response.put("status", "success"); + response.put("message", "Request Information"); + response.put("Data", result); + + return Collections.singletonList(response); + } + + @Transactional + public String saveStep1(String qr_id, String userid_1, Timestamp date_1, String lat_1, String long_1, + String location_1, String zone_1, String ward_1, String streetid_1, String streetname_1, MultipartFile file, String sex_1, + boolean contraception_1, int stage, boolean flow_location) { + String filename = fileUpload("straydogs", "step1", file); - - String sql = "INSERT INTO stray_dog_logs (qr_id, userid_1, date_1, lat_1, long_1, location_1, photo_1, sex_1, contraception_1, stage) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; - try { - int rowsAffected = jdbcStraydogsTemplate.update(sql, qr_id, userid_1, date_1, lat_1, long_1, location_1, filename, sex_1, contraception_1, stage); - if (rowsAffected > 0) { - return Integer.toString(stage); - } else { - return "Error: No rows inserted"; - } - } catch (Exception e) { - e.printStackTrace(); - return "Error in Saving Step_1 give proper input"; - } + + String sql = "INSERT INTO stray_dog_logs (qr_id, userid_1, date_1, lat_1, long_1, location_1, zone_1, ward_1, streetid_1, streetname_1, photo_1, sex_1, contraception_1, stage, flow_location) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + try { + + int rowsAffected = jdbcStraydogsTemplate.update(sql, qr_id, userid_1, date_1, lat_1, long_1, location_1, + zone_1, ward_1, streetid_1, streetname_1, filename, sex_1, contraception_1, stage, flow_location); + + if (rowsAffected > 0) { + return Integer.toString(stage); + } else { + return "Error: No rows inserted"; + } + } catch (Exception e) { + e.printStackTrace(); + return "Error in Saving Step_1 give proper input"; + } } + @Transactional + public String saveStep2(String qr_id, String userid_2, Timestamp date_2, String lat_2, String long_2, + String location_2, String zone_2, String ward_2, String streetid_2, String streetname_2, String abc_center_2, MultipartFile file, + String sex_2, boolean contraception_2, int stage) { + try { + String filename = fileUpload("straydogs", "step2", file); + if (filename == null || filename.isEmpty()) { + throw new IllegalArgumentException("File upload failed"); + } + + String sql = "UPDATE stray_dog_logs SET userid_2 = ?, date_2 = ?, lat_2 = ?, long_2 = ?, location_2 = ?, zone_2 = ?, ward_2 = ?, streetid_2 = ?, streetname_2 = ?, abc_center_2 = ?, photo_2 = ?, sex_2 = ?, contraception_2 = ?, stage = ? WHERE qr_id = ?"; + + jdbcStraydogsTemplate.update(sql, userid_2, date_2, lat_2, long_2, location_2, zone_2, ward_2, streetid_2, streetname_2, + abc_center_2, filename, sex_2, contraception_2, stage, qr_id); + + return Integer.toString(stage); + + } catch (Exception e) { + e.printStackTrace(); + return "Database error while saving Step 2: " + e.getMessage(); + } + } @Transactional - public String saveStep2(String qr_id, String userid_2, Timestamp date_2, String lat_2, String long_2, String location_2, MultipartFile file, String sex_2, boolean contraception_2, int stage) { + public void saverfid(String qr_id, String rf_id) { + + String sql = "UPDATE stray_dog_logs SET rf_id = ? WHERE qr_id = ? "; + try { + jdbcStraydogsTemplate.update(sql, rf_id, qr_id); + + } catch (Exception e) { + e.printStackTrace(); + } + } - String filename = fileUpload("straydogs", "step2", file); - - String sql = "UPDATE stray_dog_logs SET userid_2 = ?, date_2 = ?, lat_2 = ?, long_2 = ?, location_2 = ?, photo_2 = ?, sex_2 = ?, contraception_2 = ?, stage = ? WHERE qr_id = ?"; - try { - System.out.println("----------------->"+userid_2); - jdbcStraydogsTemplate.update(sql, userid_2, date_2, lat_2, long_2, location_2, filename, sex_2, contraception_2, stage, qr_id); - - return Integer.toString(stage); - } catch (Exception e) { - e.printStackTrace(); - return "Error in Saving Step_2 give proper input"; - } - } - @Transactional - public void saverfid(String qr_id, String rf_id) { - System.out.println("Check 1"); - String sql = "UPDATE stray_dog_logs SET rf_id = ? WHERE qr_id = ? "; - try { - jdbcStraydogsTemplate.update(sql, rf_id, qr_id); - System.out.println("Check 1"); - } catch (Exception e) { - e.printStackTrace(); - } - } - + public String saveStep3(String qr_id, String rf_id, String userid_3, String sex_3, String body_weight_3, + String temperature_3, boolean surgery_fitness_3, String surgery_type_3, Timestamp surgery_date) { + + String sql = "INSERT INTO stray_dog_master (qr_id, rf_id, userid_3, sex_3, body_weight_3, temperature_3, surgery_fitness_3, surgery_type_3, surgery_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; + try { + jdbcStraydogsTemplate.update(sql, qr_id, rf_id, userid_3, sex_3, body_weight_3, temperature_3, + surgery_fitness_3, surgery_type_3, surgery_date); + + return qr_id; + } catch (Exception e) { + e.printStackTrace(); + } + return "Error in Saving Step_3 give proper input"; + } + @Transactional - public String saveStep3(String qr_id, String rf_id, String userid_3, String sex_3, String body_weight_3, String temperature_3, boolean surgery_fitness_3, String surgery_type_3, Timestamp surgery_date) { - System.out.println("repo 2 1"); - String sql = "INSERT INTO stray_dog_master (qr_id, rf_id, userid_3, sex_3, body_weight_3, temperature_3, surgery_fitness_3, surgery_type_3, surgery_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; - try { - jdbcStraydogsTemplate.update(sql, qr_id, rf_id, userid_3, sex_3, body_weight_3, temperature_3, surgery_fitness_3, surgery_type_3, surgery_date); -// System.out.println("repo 2 2 1"); - return qr_id; - } catch (Exception e) { - e.printStackTrace(); - } - return "Error in Saving Step_3 give proper input"; - } - - @Transactional - public String saveStep4(String qr_id, String rf_id, String userid_4, boolean surgery_complication_4, String complication_type_4) { - String sql = "UPDATE stray_dog_master SET userid_4 = ?, surgery_complication_4 = ?, complication_type_4 = ? WHERE qr_id = ? AND rf_id = ?"; - try { - jdbcStraydogsTemplate.update(sql, userid_4, surgery_complication_4, complication_type_4, qr_id, rf_id); - return qr_id; - } catch (Exception e) { - e.printStackTrace(); - } - return "Error in Saving Step_4 give proper input"; - } - - @Transactional - public String saveNewStep5(String rf_id, String qr_id, String userid_5, boolean arv_5, boolean dhppi_5, MultipartFile file, String lat_5, String long_5, String location_5, Timestamp date_5) { - - String filename = fileUpload("straydogs", "step5", file); - - String sql = "INSERT INTO stray_dog_master (rf_id, qr_id, userid_5, arv_5, dhppi_5, photo_5, lat_5, long_5, location_5, date_5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ? ,?)"; - try { - jdbcStraydogsTemplate.update(sql, rf_id, qr_id, userid_5, arv_5, dhppi_5, filename, lat_5, long_5, location_5, date_5); - return qr_id; - } catch (Exception e) { - e.printStackTrace(); - return "Error in Saving Step_5 give proper input"; - } - } - - - @Transactional - public String saveUpdateStep5(String rf_id, String qr_id, String userid_5, boolean arv_5, boolean dhppi_5, MultipartFile file, String lat_5, String long_5, String location_5, Timestamp date_5) { - + public String saveStep4(String qr_id, String rf_id, String userid_4, boolean surgery_complication_4, + String complication_type_4, boolean ready_to_release_4) { + String sql = "UPDATE stray_dog_master SET userid_4 = ?, surgery_complication_4 = ?, complication_type_4 = ?, ready_to_release_4 = ? WHERE qr_id = ? AND rf_id = ?"; + try { + jdbcStraydogsTemplate.update(sql, userid_4, surgery_complication_4, complication_type_4, ready_to_release_4, + qr_id, rf_id); + return qr_id; + } catch (Exception e) { + e.printStackTrace(); + } + return "Error in Saving Step_4 give proper input"; + } + + @Transactional + public String saveNewStep5(String rf_id, String qr_id, String userid_5, boolean arv_5, boolean dhppi_5, + MultipartFile file, String lat_5, String long_5, String location_5, String zone_5, String ward_5, + String streetid_5, Timestamp date_5) { + String filename = fileUpload("straydogs", "step5", file); - - String sql = "UPDATE stray_dog_master SET userid_5 = ?, arv_5 = ?, dhppi_5 = ?, photo_5 = ?, lat_5 = ?, long_5 = ?, location_5 = ?, date_5 = ? WHERE rf_id = ? AND qr_id = ?"; - try { - jdbcStraydogsTemplate.update(sql, userid_5, arv_5, dhppi_5, filename, lat_5, long_5, location_5, date_5, rf_id, qr_id); - return qr_id; - } catch (Exception e) { - e.printStackTrace(); - return "Error in Saving Step_5 give proper input"; - } - } - - + + String sql = "INSERT INTO stray_dog_master (rf_id, qr_id, userid_5, arv_5, dhppi_5, photo_5, lat_5, long_5, location_5, zone_5, ward_5, streetid_5, date_5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ? ,?, ?, ?, ?)"; + try { + jdbcStraydogsTemplate.update(sql, rf_id, qr_id, userid_5, arv_5, dhppi_5, filename, lat_5, long_5, + location_5, zone_5, ward_5, streetid_5, date_5); + return qr_id; + } catch (Exception e) { + e.printStackTrace(); + return "Error in Saving Step_5 give proper input"; + } + } + @Transactional - public String saveStep6(String qr_id, String userid_6, String lat_6, String long_6, String location_6, Timestamp date_6, MultipartFile file, int stage) { - + public String saveUpdateStep5(String rf_id, String qr_id, String userid_5, boolean arv_5, boolean dhppi_5, + MultipartFile file, String lat_5, String long_5, String location_5, String zone_5, String ward_5, + String streetid_5, String streetname_5, Timestamp date_5) { + + String filename = fileUpload("straydogs", "step5", file); + + String sql = "UPDATE stray_dog_master SET userid_5 = ?, arv_5 = ?, dhppi_5 = ?, photo_5 = ?, lat_5 = ?, long_5 = ?, location_5 = ?, zone_5 = ?, ward_5 = ?, streetid_5 = ?, streetname_5 = ?, date_5 = ? WHERE rf_id = ? AND qr_id = ?"; + try { + jdbcStraydogsTemplate.update(sql, userid_5, arv_5, dhppi_5, filename, lat_5, long_5, location_5, zone_5, + ward_5, streetid_5, streetname_5, date_5, rf_id, qr_id); + return qr_id; + } catch (Exception e) { + e.printStackTrace(); + return "Error in Saving Step_5 give proper input"; + } + } + + @Transactional + public String saveStep6(String qr_id, String userid_6, String lat_6, String long_6, String location_6, + String zone_6, String ward_6, String streetid_6, String streetname_6, Timestamp date_6, MultipartFile file, int stage) { + String filename = fileUpload("straydogs", "step6", file); - - String sql = "UPDATE stray_dog_logs SET userid_6 = ?, lat_6 = ?, long_6 = ?, location_6 = ?, date_6 = ?, photo_6 = ?, stage = ? WHERE qr_id = ?"; - try { - jdbcStraydogsTemplate.update(sql, userid_6, lat_6, long_6, location_6, date_6, filename, stage, qr_id); - return Integer.toString(stage); - - } catch (Exception e) { - e.printStackTrace(); - return "Error in Saving Step_6 give proper input"; - } - } - + + String sql = "UPDATE stray_dog_logs SET userid_6 = ?, lat_6 = ?, long_6 = ?, location_6 = ?, zone_6 = ?, ward_6 = ?, streetid_6 = ?, streetname_6 = ?, date_6 = ?, photo_6 = ?, stage = ? WHERE qr_id = ?"; + try { + jdbcStraydogsTemplate.update(sql, userid_6, lat_6, long_6, location_6, zone_6, ward_6, streetid_6, streetname_6, date_6, + filename, stage, qr_id); + return Integer.toString(stage); + + } catch (Exception e) { + e.printStackTrace(); + return "Error in Saving Step_6 give proper input"; + } + } + @Transactional public List> getMasterData(String rf_id) { - String sql = "SELECT *, " - + "CONCAT('"+fileBaseUrl+"/gccofficialapp/files', photo_5) AS step5_imageUrl, " - + String sql = "SELECT *, " + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_5) AS step5_imageUrl, " + + "CASE WHEN surgery_fitness_3 = 1 THEN DATE_FORMAT(surgery_date, '%d-%m-%Y %r') ELSE '-' END AS formatted_surgery_datetime, " + "CASE WHEN surgery_fitness_3 = 1 THEN DATE_FORMAT(surgery_date, '%d-%m-%Y') ELSE '-' END AS formatted_surgery_date, " + "CASE WHEN surgery_fitness_3 = 1 THEN DATE_FORMAT(surgery_date, '%r') ELSE '-' END AS formatted_surgery_time, " - + + "CASE WHEN arv_5 = 1 THEN DATE_FORMAT(date_5, '%d-%m-%Y %r') ELSE '-' END AS formatted_arv_datetime, " + "CASE WHEN arv_5 = 1 THEN DATE_FORMAT(date_5, '%d-%m-%Y') ELSE '-' END AS formatted_arv_date, " + "CASE WHEN arv_5 = 1 THEN DATE_FORMAT(date_5, '%r') ELSE '-' END AS formatted_arv_time " - + " FROM stray_dog_master WHERE rf_id = ?"; - return jdbcStraydogsTemplate.queryForList(sql, rf_id); - } + + " FROM stray_dog_master WHERE rf_id = ?"; + + // String sql = "SELECT * FROM stray_dog_master WHERE rf_id = ?"; + return jdbcStraydogsTemplate.queryForList(sql, rf_id); + } + @Transactional public List> getLogData(String qr_id) { - String sql = "SELECT *, " - + "CONCAT('"+fileBaseUrl+"/gccofficialapp/files', photo_1) AS step1_imageUrl, " - + "CONCAT('"+fileBaseUrl+"/gccofficialapp/files', photo_2) AS step2_imageUrl, " - + "CONCAT('"+fileBaseUrl+"/gccofficialapp/files', photo_6) AS step6_imageUrl, " - - + "CASE WHEN userid_1 IS NOT NULL THEN DATE_FORMAT(date_1, '%d-%m-%Y %r') ELSE '-' END AS formatted_stage_1_datetime, " + String sql = "SELECT *, " + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_1) AS step1_imageUrl, " + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_2) AS step2_imageUrl, " + "CONCAT('" + + fileBaseUrl + "/gccofficialapp/files', photo_6) AS step6_imageUrl, " + + + "CASE WHEN userid_1 IS NOT NULL THEN DATE_FORMAT(date_1, '%d-%m-%Y %r') ELSE '-' END AS formatted_stage_1_datetime, " + "CASE WHEN userid_1 IS NOT NULL THEN DATE_FORMAT(date_1, '%d-%m-%Y') ELSE '-' END AS formatted_stage_1_date, " + "CASE WHEN userid_1 IS NOT NULL THEN DATE_FORMAT(date_1, '%r') ELSE '-' END AS formatted_stage_1_time, " - + + "CASE WHEN userid_2 IS NOT NULL THEN DATE_FORMAT(date_2, '%d-%m-%Y %r') ELSE '-' END AS formatted_stage_2_datetime, " + "CASE WHEN userid_2 IS NOT NULL THEN DATE_FORMAT(date_2, '%d-%m-%Y') ELSE '-' END AS formatted_stage_2_date, " + "CASE WHEN userid_2 IS NOT NULL THEN DATE_FORMAT(date_2, '%r') ELSE '-' END AS formatted_stage_2_time, " - + + "CASE WHEN userid_6 IS NOT NULL THEN DATE_FORMAT(date_6, '%d-%m-%Y %r') ELSE '-' END AS formatted_stage_6_datetime, " + "CASE WHEN userid_6 IS NOT NULL THEN DATE_FORMAT(date_6, '%d-%m-%Y') ELSE '-' END AS formatted_stage_6_date, " + "CASE WHEN userid_6 IS NOT NULL THEN DATE_FORMAT(date_6, '%r') ELSE '-' END AS formatted_stage_6_time " - - + " FROM stray_dog_logs WHERE qr_id = ?"; - return jdbcStraydogsTemplate.queryForList(sql, qr_id); - } - + + + " FROM stray_dog_logs WHERE qr_id = ?"; + return jdbcStraydogsTemplate.queryForList(sql, qr_id); + } + @Transactional - public List> getlogsrfid(String rf_id) { - System.out.println("repo 1"); - String sql = "SELECT *, " - + "CONCAT('"+fileBaseUrl+"/gccofficialapp/files', photo_5) AS step5_imageUrl, " - + public List> getlogsrfid(String rf_id) { + + String sql = "SELECT *, " + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_5) AS step5_imageUrl, " + + "CASE WHEN surgery_fitness_3 = 1 THEN DATE_FORMAT(surgery_date, '%d-%m-%Y %r') ELSE '-' END AS formatted_surgery_datetime, " + "CASE WHEN surgery_fitness_3 = 1 THEN DATE_FORMAT(surgery_date, '%d-%m-%Y') ELSE '-' END AS formatted_surgery_date, " + "CASE WHEN surgery_fitness_3 = 1 THEN DATE_FORMAT(surgery_date, '%r') ELSE '-' END AS formatted_surgery_time, " - + + "CASE WHEN arv_5 = 1 THEN DATE_FORMAT(date_5, '%d-%m-%Y %r') ELSE '-' END AS formatted_arv_datetime, " + "CASE WHEN arv_5 = 1 THEN DATE_FORMAT(date_5, '%d-%m-%Y') ELSE '-' END AS formatted_arv_date, " + "CASE WHEN arv_5 = 1 THEN DATE_FORMAT(date_5, '%r') ELSE '-' END AS formatted_arv_time " - - + "FROM stray_dog_master WHERE rf_id = ? ORDER BY rf_id DESC LIMIT 1"; - System.out.println("repo 2"); - return jdbcStraydogsTemplate.queryForList(sql, rf_id); - } - + + + "FROM stray_dog_master WHERE rf_id = ? ORDER BY rf_id DESC LIMIT 1"; + + return jdbcStraydogsTemplate.queryForList(sql, rf_id); + } + @Transactional public String updateStage(String rf_id, String qr_id, int stage) { - System.out.println("update repo 1"); - String sql = "UPDATE stray_dog_logs SET stage = ?, rf_id = ? WHERE qr_id = ?"; - jdbcStraydogsTemplate.update(sql, stage, rf_id, qr_id); - System.out.println("update repo 2"); - return Integer.toString(stage); - } - + + String sql = "UPDATE stray_dog_logs SET stage = ?, rf_id = ? WHERE qr_id = ?"; + jdbcStraydogsTemplate.update(sql, stage, rf_id, qr_id); + + return Integer.toString(stage); + } + @Transactional - public int getVaccineDue(String qrId, String rfId, String formattedDate) { - System.out.println("vaccine repo 1"); - String sql = "SELECT COALESCE(DATEDIFF(DATE_ADD(date_5, INTERVAL 1 YEAR), ?), 365) AS remaining_days\n" + - "FROM stray_dog_master\n" + - "WHERE qr_id = ? AND rf_id = ? ORDER BY date_5 DESC LIMIT 1"; - - System.out.println("vaccine repo 2"); - List days = jdbcStraydogsTemplate.queryForList(sql, new Object[]{formattedDate, qrId, rfId}, Integer.class); - int day = days.get(0); - - System.out.println("day = "+day); - return day; - - } - -} + public int getVaccineDue(String rfId, String formattedDate) { + + String sql = "SELECT COALESCE(DATEDIFF(DATE_ADD(date_5, INTERVAL 1 YEAR), ?), 365) AS remaining_days\n" + + "FROM stray_dog_master\n" + "WHERE rf_id = ? ORDER BY date_5 DESC LIMIT 1"; + + List days = jdbcStraydogsTemplate.queryForList(sql, new Object[] { formattedDate, rfId }, + Integer.class); + if (days != null && !days.isEmpty()) { + int day = days.get(0); + + return day; + } + return 99999; + + } + + public String updateStage3(String rf_id, String qr_id) { + + String sql = "UPDATE stray_dog_master SET qr_id = ? WHERE rf_id = ?"; + + jdbcStraydogsTemplate.update(sql, qr_id, rf_id); + + return qr_id; + } + + public String checkQrId(String qr_id) { + + String sql = "SELECT CASE " + "WHEN EXISTS(SELECT 1 FROM stray_dog_logs WHERE qr_id = ?) " + "THEN 'true' " + + "ELSE 'false' " + "END AS result"; + + return jdbcStraydogsTemplate.queryForObject(sql, new Object[] { qr_id }, String.class); + + } + + public List> getOverallData(String fromDate, String toDate) { + String sql = "SELECT " + + "SUM(CASE WHEN date(date_1) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d') AND sex_1 = 'Male' THEN 1 ELSE 0 END) AS Male_Catched, " + + "SUM(CASE WHEN date(date_1) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d') AND sex_1 = 'Female' THEN 1 ELSE 0 END) AS Female_Catched, " + + "SUM(CASE WHEN date(date_1) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d') THEN 1 ELSE 0 END) AS Total_Catched, " + + "SUM(CASE WHEN date(date_6) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d') AND sex_2 = 'Male' THEN 1 ELSE 0 END) AS Male_Released, " + + "SUM(CASE WHEN date(date_6) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d') AND sex_2 = 'Female' THEN 1 ELSE 0 END) AS Female_Released, " + + "SUM(CASE WHEN date(date_6) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d') THEN 1 ELSE 0 END) AS Total_Released " + + "FROM stray_dog_logs"; + + Map resultMap = jdbcStraydogsTemplate.queryForMap(sql, fromDate, toDate, fromDate, toDate, + fromDate, toDate, fromDate, toDate, fromDate, toDate, fromDate, toDate); + + Map catchedData = new HashMap<>(); + Map releasedData = new HashMap<>(); + + resultMap.forEach((key, value) -> { + int intValue = (value instanceof BigDecimal) ? ((BigDecimal) value).intValue() : (Integer) value; + if (key.contains("Catched")) { + catchedData.put(key, intValue); + } else if (key.contains("Released")) { + releasedData.put(key, intValue); + } + }); + + Map catchedResult = new HashMap<>(); + catchedResult.put("flag", "Catched"); + catchedResult.put("data", catchedData); + + Map releasedResult = new HashMap<>(); + releasedResult.put("flag", "Released"); + releasedResult.put("data", releasedData); + + List> resultList = new ArrayList<>(); + resultList.add(catchedResult); + resultList.add(releasedResult); + + return resultList; + } + + public List> getoverallcatcheddata(String fromDate, String toDate) { + String sql = "SELECT \r\n" + " z.zone_name AS Zone,\r\n" + + " COALESCE(SUM(CASE WHEN s.sex_1 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Catched,\r\n" + + " COALESCE(SUM(CASE WHEN s.sex_1 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Catched,\r\n" + + " COALESCE(COUNT(s.sex_1), 0) AS Total_Catched\r\n" + "FROM \r\n" + " zone z\r\n" + + "LEFT JOIN \r\n" + " stray_dog_logs s ON z.zone_name = s.zone_1 \r\n" + + " AND date(s.date_1) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + "GROUP BY \r\n" + " z.zone_name"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate); + } + + public List> getoverallreleaseddata(String fromDate, String toDate) { + String sql = "SELECT \r\n" + " z.zone_name AS Zone,\r\n" + + " COALESCE(SUM(CASE WHEN s.sex_2 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Released,\r\n" + + " COALESCE(SUM(CASE WHEN s.sex_2 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Released,\r\n" + + " COALESCE(COUNT(s.sex_2), 0) AS Total_Released\r\n" + "FROM \r\n" + " zone z\r\n" + + "LEFT JOIN \r\n" + " stray_dog_logs s ON z.zone_name = s.zone_6 \r\n" + + " AND date(s.date_6) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + "GROUP BY \r\n" + " z.zone_name"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate); + } + + public List> getAbcCenterwiseData(String fromDate, String toDate, String abcCenter) { + + Map unsterilized = getunsterilizeddata(fromDate, toDate, abcCenter); + Map sterilized = getsterilizeddata(fromDate, toDate, abcCenter); + Map unfit = getunfitdata(fromDate, toDate, abcCenter); + Map surgery = getsurgerydata(fromDate, toDate, abcCenter); + Map died = getdieddata(fromDate, toDate, abcCenter); + Map released = getreleaseddata(fromDate, toDate, abcCenter); + + Map unsterilizedResult = new HashMap<>(); + unsterilizedResult.put("flag", "Unsterilized"); + unsterilizedResult.put("data", unsterilized); + + Map sterilizedResult = new HashMap<>(); + sterilizedResult.put("flag", "Sterilized"); + sterilizedResult.put("data", sterilized); + + Map unfitResult = new HashMap<>(); + unfitResult.put("flag", "Unfit"); + unfitResult.put("data", unfit); + + Map surgeryResult = new HashMap<>(); + surgeryResult.put("flag", "Surgery"); + surgeryResult.put("data", surgery); + + Map diedResult = new HashMap<>(); + diedResult.put("flag", "Died"); + diedResult.put("data", died); + + Map releasedResult = new HashMap<>(); + releasedResult.put("flag", "Released"); + releasedResult.put("data", released); + + List> resultList = new ArrayList<>(); + resultList.add(unsterilizedResult); + resultList.add(sterilizedResult); + resultList.add(unfitResult); + resultList.add(surgeryResult); + resultList.add(diedResult); + resultList.add(releasedResult); + + return resultList; + } + + private Map getreleaseddata(String fromDate, String toDate, String abcCenter) { + String sql = "SELECT \r\n" + + " IFNULL(SUM(CASE WHEN sl.sex_2 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_released,\r\n" + + " IFNULL(SUM(CASE WHEN sl.sex_2 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_released,\r\n" + + " COUNT(*) AS Total_released\r\n" + "FROM \r\n" + " stray_dog_logs sl\r\n" + "WHERE \r\n" + + " date(sl.date_6) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?"; + return jdbcStraydogsTemplate.queryForMap(sql, fromDate, toDate, abcCenter); + } + + private Map getdieddata(String fromDate, String toDate, String abcCenter) { + String sql = "SELECT \r\n" + + " IFNULL(SUM(CASE WHEN sm.sex_3 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Died,\r\n" + + " IFNULL(SUM(CASE WHEN sm.sex_3 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Died,\r\n" + + " COUNT(*) AS Total_Died\r\n" + "FROM \r\n" + " stray_dog_master sm\r\n" + + " Left join stray_dog_logs sl on sm.rf_id = sl.rf_id\r\n" + "WHERE \r\n" + + " date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sm.ready_to_release_4 = false\r\n" + " AND sl.abc_center_2 = ?"; + return jdbcStraydogsTemplate.queryForMap(sql, fromDate, toDate, abcCenter); + } + + private Map getsurgerydata(String fromDate, String toDate, String abcCenter) { + String sql = " SELECT \r\n" + + " IFNULL(SUM(CASE WHEN sm.sex_3 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Surgery,\r\n" + + " IFNULL(SUM(CASE WHEN sm.sex_3 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Surgery,\r\n" + + " COUNT(*) AS Total_Surgery\r\n" + "FROM \r\n" + " stray_dog_master sm\r\n" + + " Left join stray_dog_logs sl on sm.rf_id = sl.rf_id\r\n" + "WHERE \r\n" + + " date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sm.userid_4 is not null\r\n" + " AND sl.abc_center_2 = ?"; + return jdbcStraydogsTemplate.queryForMap(sql, fromDate, toDate, abcCenter); + } + + private Map getunfitdata(String fromDate, String toDate, String abcCenter) { + String sql = " SELECT \r\n" + + " IFNULL(SUM(CASE WHEN sm.sex_3 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Unfit,\r\n" + + " IFNULL(SUM(CASE WHEN sm.sex_3 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Unfit,\r\n" + + " COUNT(*) AS Total_Unfit\r\n" + "FROM \r\n" + " stray_dog_master sm\r\n" + + " Left join stray_dog_logs sl on sm.rf_id = sl.rf_id\r\n" + "WHERE \r\n" + + " date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sm.surgery_fitness_3 = false\r\n" + " AND sl.abc_center_2 = ?"; + return jdbcStraydogsTemplate.queryForMap(sql, fromDate, toDate, abcCenter); + } + + private Map getsterilizeddata(String fromDate, String toDate, String abcCenter) { + String sql = " SELECT \r\n" + + " IFNULL(SUM(CASE WHEN sl.sex_2 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Sterilized,\r\n" + + " IFNULL(SUM(CASE WHEN sl.sex_2 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Sterilized,\r\n" + + " COUNT(*) AS Total_Sterilized\r\n" + "FROM \r\n" + " stray_dog_logs sl\r\n" + "WHERE \r\n" + + " date(sl.date_2) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.contraception_2 = true\r\n" + " AND sl.abc_center_2 = ?"; + return jdbcStraydogsTemplate.queryForMap(sql, fromDate, toDate, abcCenter); + } + + private Map getunsterilizeddata(String fromDate, String toDate, String abcCenter) { + String sql = "SELECT \r\n" + + " IFNULL(SUM(CASE WHEN sl.sex_2 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Unsterilized,\r\n" + + " IFNULL(SUM(CASE WHEN sl.sex_2 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Unsterilized,\r\n" + + " COUNT(*) AS Total_Unsterilized\r\n" + "FROM \r\n" + " stray_dog_logs sl\r\n" + "WHERE \r\n" + + " date(sl.date_2) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.contraception_2 = false\r\n" + " AND sl.abc_center_2 = ?"; + return jdbcStraydogsTemplate.queryForMap(sql, fromDate, toDate, abcCenter); + } + + public List> getUnstrelizedZoneBreakup(String fromDate, String toDate, String abcCenter) { + String sql = "SELECT \r\n" + " z.zone_name AS Zone,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Unsterilized,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Unsterilized,\r\n" + + " COALESCE(COUNT(sl.sex_2), 0) AS Total_Unsterilized\r\n" + "FROM \r\n" + " zone z\r\n" + + "LEFT JOIN \r\n" + " stray_dog_logs sl ON sl.zone_1 = z.zone_name\r\n" + + " AND date(sl.date_2) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.contraception_2 = false\r\n" + " AND sl.abc_center_2 = ?\r\n" + "GROUP BY \r\n" + + " z.zone_name"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate, abcCenter); + } + + public List> getUnstrelizedDivisionBreakup(String fromDate, String toDate, String abcCenter, + String zone) { + String sql = "SELECT \r\n" + " d.div_name AS Division,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Unsterilized,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Unsterilized,\r\n" + + " COALESCE(COUNT(sl.sex_2), 0) AS Total_Unsterilized\r\n" + "FROM \r\n" + " division d \r\n" + + "LEFT JOIN \r\n" + " stray_dog_logs sl ON d.div_name = sl.ward_1 \r\n" + "LEFT JOIN \r\n" + + " zone z ON d.zone_id = z.zone_id \r\n" + + " where date(sl.date_2) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.contraception_2 = false\r\n" + " AND sl.abc_center_2 = ?\r\n" + + " AND z.zone_name = ?\r\n" + "GROUP BY \r\n" + " d.div_name"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate, abcCenter, zone); + } + + public List> getUnstrelizedStreetBreakup(String ward, String fromDate, String toDate, + String abcCenter, String zone) { + String sql = "SELECT \r\n" + " sl.streetid_1 as Street_ID, sl.streetname_1 as Street_Name,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Unsterilized,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Unsterilized,\r\n" + + " COALESCE(COUNT(sl.sex_2), 0) AS Total_Unsterilized\r\n" + "FROM \r\n" + + " stray_dog_logs sl\r\n" + " where\r\n" + " sl.ward_1 = ? \r\n" + + " AND date(sl.date_2) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + " AND sl.zone_1 = ?\r\n" + + " AND sl.contraception_2 = false\r\n" + "GROUP BY \r\n" + " sl.streetid_1, sl.streetname_1"; + return jdbcStraydogsTemplate.queryForList(sql, ward, fromDate, toDate, abcCenter, zone); + } + + public List> getStrelizedZoneBreakup(String fromDate, String toDate, String abcCenter) { + String sql = " SELECT \r\n" + " z.zone_name AS Zone,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Sterilized,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Sterilized,\r\n" + + " COALESCE(COUNT(sl.sex_2), 0) AS Total_sterilized\r\n" + "FROM \r\n" + " zone z\r\n" + + "LEFT JOIN \r\n" + " stray_dog_logs sl ON sl.zone_1 = z.zone_name\r\n" + + " AND date(sl.date_2) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.contraception_2 = true\r\n" + " AND sl.abc_center_2 = ?\r\n" + "GROUP BY \r\n" + + " z.zone_name"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate, abcCenter); + } + + public List> getStrelizedDivisionBreakup(String fromDate, String toDate, String abcCenter, + String zone) { + String sql = "SELECT \r\n" + " d.div_name AS Division,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Sterilized,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Sterilized,\r\n" + + " COALESCE(COUNT(sl.sex_2), 0) AS Total_Sterilized\r\n" + "FROM \r\n" + " division d \r\n" + + "LEFT JOIN \r\n" + " stray_dog_logs sl ON d.div_name = sl.ward_1 \r\n" + "LEFT JOIN \r\n" + + " zone z ON d.zone_id = z.zone_id \r\n" + + " where date(sl.date_2) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.contraception_2 = true\r\n" + " AND sl.abc_center_2 = ?\r\n" + + " AND z.zone_name = ?\r\n" + "GROUP BY \r\n" + " d.div_name"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate, abcCenter, zone); + } + + public List> getStrelizedStreetBreakup(String ward, String fromDate, String toDate, + String abcCenter, String zone) { + String sql = "SELECT \r\n" + " sl.streetid_1 as Street_ID, sl.streetname_1 as Street_Name,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Sterilized,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Sterilized,\r\n" + + " COALESCE(COUNT(sl.sex_2), 0) AS Total_Sterilized\r\n" + "FROM \r\n" + " stray_dog_logs sl\r\n" + + " where\r\n" + " sl.ward_1 = ? \r\n" + + " AND date(sl.date_2) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + " AND sl.zone_1 = ?\r\n" + + " AND sl.contraception_2 = true\r\n" + "GROUP BY \r\n" + " sl.streetid_1, sl.streetname_1"; + return jdbcStraydogsTemplate.queryForList(sql, ward, fromDate, toDate, abcCenter, zone); + } + + public List> getUnfitZoneBreakup(String fromDate, String toDate, String abcCenter) { + String sql = " SELECT \r\n" + " z.zone_name as Zone,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Unfit,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Unfit,\r\n" + + " COALESCE(COUNT(sm.sex_3), 0) AS Total_Unfit\r\n" + "FROM \r\n" + " zone z \r\n" + + "left JOIN stray_dog_logs sl ON z.zone_name = sl.zone_1\r\n" + + "LEFT JOIN stray_dog_master sm ON sl.rf_id = sm.rf_id\r\n" + + " AND date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sm.surgery_fitness_3 = false\r\n" + " AND sl.abc_center_2 = ?\r\n" + + "GROUP BY z.zone_name"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate, abcCenter); + } + + public List> getUnfitDivisionBreakup(String fromDate, String toDate, String abcCenter, + String zone) { + String sql = "SELECT \r\n" + " sl.ward_1 AS Division,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Unfit,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Unfit,\r\n" + + " COALESCE(COUNT(sm.sex_3), 0) AS Total_Unfit\r\n" + "FROM \r\n" + " division d \r\n" + + "left JOIN stray_dog_logs sl ON d.div_name = sl.ward_1 \r\n" + + "left JOIN stray_dog_master sm ON sl.rf_id = sm.rf_id\r\n" + + "left JOIN zone z ON d.zone_id = z.zone_id\r\n" + + " where date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sm.surgery_fitness_3 = false\r\n" + " AND sl.abc_center_2 = ?\r\n" + + " AND sl.zone_1 = ?\r\n" + "GROUP BY \r\n" + " sl.ward_1"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate, abcCenter, zone); + } + + public List> getUnfitStreetBreakup(String ward, String zone, String fromDate, String toDate, + String abcCenter) { + String sql = " SELECT \r\n" + " sl.streetid_1 as Street_ID, sl.streetname_1 as Street_Name,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Unfit,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Unfit,\r\n" + + " COALESCE(COUNT(sm.sex_3), 0) AS Total_Unfit\r\n" + "FROM \r\n" + " stray_dog_logs sl\r\n" + + " LEFT JOIN stray_dog_master sm ON sm.rf_id = sl.rf_id\r\n" + " where\r\n" + + " sl.ward_1 = ? \r\n" + " AND sl.zone_1 = ?\r\n" + + " AND date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + " AND sm.surgery_fitness_3 = false\r\n" + "GROUP BY \r\n" + + " sl.streetid_1, sl.streetname_1"; + return jdbcStraydogsTemplate.queryForList(sql, ward, zone, fromDate, toDate, abcCenter); + } + + public List> getSurgeryZoneBreakup(String fromDate, String toDate, String abcCenter) { + String sql = " SELECT \r\n" + " z.zone_name as Zone,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Surgery,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Surgery,\r\n" + + " COALESCE(COUNT(sm.sex_3), 0) AS Total_Surgery\r\n" + "FROM \r\n" + " zone z \r\n" + + "left JOIN stray_dog_logs sl ON z.zone_name = sl.zone_1\r\n" + + "LEFT JOIN stray_dog_master sm ON sl.rf_id = sm.rf_id\r\n" + + " AND date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sm.userid_4 is not null\r\n" + " AND sl.abc_center_2 = ?\r\n" + "GROUP BY z.zone_name"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate, abcCenter); + } + + public List> getSurgeryDivisionBreakup(String fromDate, String toDate, String abcCenter, + String zone) { + String sql = " SELECT \r\n" + " sl.ward_1 AS Division,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Surgery,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Female' THEN 1 ELSE 0 END), 0) AS female_Surgery,\r\n" + + " COALESCE(COUNT(sm.sex_3), 0) AS total_Surgery\r\n" + "FROM \r\n" + " division d \r\n" + + "left JOIN stray_dog_logs sl ON d.div_name = sl.ward_1 \r\n" + + "left JOIN stray_dog_master sm ON sl.rf_id = sm.rf_id\r\n" + + "left JOIN zone z ON d.zone_id = z.zone_id\r\n" + + " where date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sm.userid_4 is not null\r\n" + " AND sl.abc_center_2 = ?\r\n" + " AND sl.zone_1 = ?\r\n" + + "GROUP BY \r\n" + " sl.ward_1"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate, abcCenter, zone); + } + + public List> getSurgeryStreetBreakup(String ward, String zone, String fromDate, String toDate, + String abcCenter) { + String sql = " SELECT \r\n" + " sl.streetid_1 as Street_ID, sl.streetname_1 as Street_Name,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Surgery,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Surgery,\r\n" + + " COALESCE(COUNT(sm.sex_3), 0) AS Total_Surgery\r\n" + "FROM \r\n" + " stray_dog_logs sl\r\n" + + " LEFT JOIN stray_dog_master sm ON sl.rf_id = sm.rf_id\r\n" + " where\r\n" + + " sl.ward_1 = ? \r\n" + " AND sl.zone_1 = ?\r\n" + + " AND date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + " AND sm.userid_4 is not null\r\n" + "GROUP BY \r\n" + + " sl.streetid_1, sl.streetname_1"; + return jdbcStraydogsTemplate.queryForList(sql, ward, zone, fromDate, toDate, abcCenter); + } + + public List> getDiedZoneBreakup(String fromDate, String toDate, String abcCenter) { + String sql = " SELECT \r\n" + " z.zone_name as Zone,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Died,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Died,\r\n" + + " COALESCE(COUNT(sm.sex_3), 0) AS Total_Died\r\n" + "FROM \r\n" + " zone z \r\n" + + "left JOIN stray_dog_logs sl ON z.zone_name = sl.zone_1\r\n" + + "LEFT JOIN stray_dog_master sm ON sl.rf_id = sm.rf_id\r\n" + + " AND date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sm.ready_to_release_4 = false\r\n" + " AND sl.abc_center_2 = ?\r\n" + + "GROUP BY z.zone_name"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate, abcCenter); + } + + public List> getDiedDivisionBreakup(String fromDate, String toDate, String abcCenter, + String zone) { + String sql = " SELECT \r\n" + " sl.ward_1 AS Division,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Died,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Died,\r\n" + + " COALESCE(COUNT(sm.sex_3), 0) AS Total_Died\r\n" + "FROM \r\n" + " division d \r\n" + + "left JOIN stray_dog_logs sl ON d.div_name = sl.ward_1 \r\n" + + "left JOIN stray_dog_master sm ON sl.rf_id = sm.rf_id\r\n" + + "left JOIN zone z ON d.zone_id = z.zone_id\r\n" + + " where date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sm.ready_to_release_4 = false\r\n" + " AND sl.abc_center_2 = ?\r\n" + + " AND sl.zone_1 = ?\r\n" + "GROUP BY \r\n" + " sl.ward_1"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate, abcCenter, zone); + } + + public List> getDiedStreetBreakup(String ward, String zone, String fromDate, String toDate, + String abcCenter) { + String sql = " SELECT \r\n" + " sl.streetid_1 as Street_ID, sl.streetname_1 as Street_Name,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Died,\r\n" + + " COALESCE(SUM(CASE WHEN sm.sex_3 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Died,\r\n" + + " COALESCE(COUNT(sm.sex_3), 0) AS Total_Died\r\n" + "FROM \r\n" + " stray_dog_logs sl\r\n" + + " LEFT JOIN stray_dog_master sm ON sl.rf_id = sm.rf_id\r\n" + " where\r\n" + + " sl.ward_1 = ? \r\n" + " AND sl.zone_1 = ?\r\n" + + " AND date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + " AND sm.ready_to_release_4 = false\r\n" + "GROUP BY \r\n" + + " sl.streetid_1, sl.streetname_1"; + return jdbcStraydogsTemplate.queryForList(sql, ward, zone, fromDate, toDate, abcCenter); + } + + public List> getReleasedZoneBreakup(String fromDate, String toDate, String abcCenter) { + String sql = "SELECT \r\n" + " z.zone_name AS Zone,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Released,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Released,\r\n" + + " COALESCE(COUNT(sl.sex_2), 0) AS Total_Released\r\n" + "FROM \r\n" + " zone z\r\n" + + "LEFT JOIN \r\n" + " stray_dog_logs sl ON z.zone_name = sl.zone_6 \r\n" + + " AND date(sl.date_6) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + "GROUP BY \r\n" + "z.zone_name"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate, abcCenter); + } + + public List> getReleasedDivisionBreakup(String fromDate, String toDate, String abcCenter, + String zone) { + String sql = " SELECT \r\n" + " d.div_name AS Division,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Released,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Released,\r\n" + + " COALESCE(COUNT(sl.sex_2), 0) AS Total_Released\r\n" + "FROM \r\n" + " division d \r\n" + + "LEFT JOIN \r\n" + " stray_dog_logs sl ON d.div_name = sl.ward_6\r\n" + "LEFT JOIN \r\n" + + " zone z ON d.zone_id = z.zone_id \r\n" + + " where date(sl.date_6) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + " AND sl.zone_6 = ?\r\n" + "GROUP BY \r\n" + " d.div_name"; + return jdbcStraydogsTemplate.queryForList(sql, fromDate, toDate, abcCenter, zone); + } + + public List> getReleasedStreetBreakup(String ward, String zone, String fromDate, String toDate, + String abcCenter) { + String sql = " SELECT \r\n" + " sl.streetid_6 AS Street_ID, sl.streetname_6 as Street_Name,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Male' THEN 1 ELSE 0 END), 0) AS Male_Released,\r\n" + + " COALESCE(SUM(CASE WHEN sl.sex_2 = 'Female' THEN 1 ELSE 0 END), 0) AS Female_Released,\r\n" + + " COALESCE(COUNT(sl.sex_2), 0) AS Total_Released\r\n" + "FROM \r\n" + " stray_dog_logs sl\r\n" + + "WHERE\r\n" + " sl.ward_6 = ?\r\n" + " AND sl.zone_6 = ?\r\n" + + " AND DATE(sl.date_6) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + "GROUP BY \r\n" + " sl.streetid_6, sl.streetname_6"; + return jdbcStraydogsTemplate.queryForList(sql, ward, zone, fromDate, toDate, abcCenter); + } + + public ByteArrayInputStream overallExcelReport(String fromDate, String toDate) { + try (Workbook workbook = new XSSFWorkbook(); ByteArrayOutputStream out = new ByteArrayOutputStream()) { + + List> catchedData = getoverallcatcheddata(fromDate, toDate); + List> releasedData = getoverallreleaseddata(fromDate, toDate); + + + if (catchedData.isEmpty() || releasedData.isEmpty()) { + throw new RuntimeException("No data found for the report. Please check the database."); + } + + Sheet sheet = workbook.createSheet("Dog Catching Report"); + + // Define header and cell styles + CellStyle headerStyle = workbook.createCellStyle(); + Font headerFont = workbook.createFont(); + headerFont.setBold(true); + headerStyle.setFont(headerFont); + headerStyle.setAlignment(HorizontalAlignment.CENTER); + headerStyle.setVerticalAlignment(VerticalAlignment.CENTER); + headerStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); + headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headerStyle.setBorderBottom(BorderStyle.THIN); + headerStyle.setBorderTop(BorderStyle.THIN); + headerStyle.setBorderLeft(BorderStyle.THIN); + headerStyle.setBorderRight(BorderStyle.THIN); + + // First header row with the report title + Row titleRow = sheet.createRow(0); + Cell titleCell = titleRow.createCell(0); + titleCell.setCellValue("Zonewise Overall Report (From: " + fromDate + " to To: " + toDate + ")"); + titleCell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 7)); + + // Group header row + Row groupHeaderRow = sheet.createRow(1); + + // Merging cells (0,1) in groupHeaderRow with headerRow1 + sheet.addMergedRegion(new CellRangeAddress(1, 2, 0, 0)); // Merge Sl. No column + sheet.addMergedRegion(new CellRangeAddress(1, 2, 1, 1)); // Merge Zone column + + // Set merged header cells + Cell slNoHeader = groupHeaderRow.createCell(0); + slNoHeader.setCellValue("Sl. No"); + slNoHeader.setCellStyle(headerStyle); + + Cell zoneHeader = groupHeaderRow.createCell(1); + zoneHeader.setCellValue("Zone"); + zoneHeader.setCellStyle(headerStyle); + + // Create merged regions and set only the main cell style for catches and + // released headers + Cell catchesHeader = groupHeaderRow.createCell(2); + catchesHeader.setCellValue("No. of Dogs Cought"); + catchesHeader.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(1, 1, 2, 4)); + + Cell releasedHeader = groupHeaderRow.createCell(5); + releasedHeader.setCellValue("No. of Dogs Released"); + releasedHeader.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(1, 1, 5, 7)); + + // Column headers row (second row with individual column headers) + Row headerRow1 = sheet.createRow(2); + headerRow1.createCell(0).setCellValue("Sl. No"); + headerRow1.createCell(1).setCellValue("Zone"); + headerRow1.createCell(2).setCellValue("Male"); + headerRow1.createCell(3).setCellValue("Female"); + headerRow1.createCell(4).setCellValue("Total"); + headerRow1.createCell(5).setCellValue("Male"); + headerRow1.createCell(6).setCellValue("Female"); + headerRow1.createCell(7).setCellValue("Total"); + + // Apply header styles to the individual columns in headerRow1 + for (int i = 0; i <= 7; i++) { + headerRow1.getCell(i).setCellStyle(headerStyle); + } + + // Populate data rows + CellStyle regularStyle = workbook.createCellStyle(); + regularStyle.setBorderBottom(BorderStyle.THIN); + regularStyle.setBorderTop(BorderStyle.THIN); + regularStyle.setBorderLeft(BorderStyle.THIN); + regularStyle.setBorderRight(BorderStyle.THIN); + regularStyle.setAlignment(HorizontalAlignment.CENTER); + + int rowIndex = 3; // Start below the header rows + int slNo = 1; + for (Map catched : catchedData) { + + Row excelRow = sheet.createRow(rowIndex++); + excelRow.createCell(0).setCellValue(slNo++); // Sl. No + excelRow.createCell(1).setCellValue((String) catched.get("Zone")); // Zone + excelRow.createCell(2).setCellValue(((Number) catched.get("Male_Catched")).doubleValue()); // Male + // Catches + excelRow.createCell(3).setCellValue(((Number) catched.get("Female_Catched")).doubleValue()); // Female + // Catches + excelRow.createCell(4).setCellValue(((Number) catched.get("Total_Catched")).doubleValue()); // Total + // Catches + + for (Map released : releasedData) { + if ((((String) released.get("Zone")).equalsIgnoreCase((String) catched.get("Zone")))) { + excelRow.createCell(5).setCellValue(((Number) released.get("Male_Released")).doubleValue()); // Male + // Released + excelRow.createCell(6).setCellValue(((Number) released.get("Female_Released")).doubleValue()); // Female + // Released + excelRow.createCell(7).setCellValue(((Number) released.get("Total_Released")).doubleValue()); // Total + // Released + } + } + for (int col = 0; col <= 7; col++) { + excelRow.getCell(col).setCellStyle(regularStyle); + } + } + + // Auto-size columns + for (int i = 0; i < 8; i++) { + sheet.autoSizeColumn(i); + } + + workbook.write(out); + return new ByteArrayInputStream(out.toByteArray()); + } catch (IOException e) { + throw new RuntimeException("Failed to generate Excel report", e); + } catch (Exception e) { + throw new RuntimeException("An error occurred while generating the report: " + e.getMessage(), e); + } + } + + public ByteArrayInputStream abcCenterExcelReport(String fromDate, String toDate, String abcCenter) { + try (Workbook workbook = new XSSFWorkbook(); ByteArrayOutputStream out = new ByteArrayOutputStream()) { + + List> unsterilizedData = getUnstrelizedZoneBreakup(fromDate, toDate, abcCenter); + List> sterilizedData = getStrelizedZoneBreakup(fromDate, toDate, abcCenter); + List> unfitData = getUnfitZoneBreakup(fromDate, toDate, abcCenter); + List> surgeryData = getSurgeryZoneBreakup(fromDate, toDate, abcCenter); + List> diedData = getDiedZoneBreakup(fromDate, toDate, abcCenter); + List> releasedData = getReleasedZoneBreakup(fromDate, toDate, abcCenter); + + if (unsterilizedData.isEmpty() || sterilizedData.isEmpty() || unfitData.isEmpty() || surgeryData.isEmpty() + || diedData.isEmpty() || releasedData.isEmpty()) { + throw new RuntimeException("No data found for the report. Please check the database."); + } + + Sheet sheet = workbook.createSheet("Dog Catching Report"); + + // Define header and cell styles + CellStyle headerStyle = createHeaderStyle(workbook); + CellStyle regularStyle = createRegularCellStyle(workbook); + + // First header row with the report title + Row titleRow = sheet.createRow(0); + for (int col = 0; col <= 19; col++) { + Cell cell = titleRow.createCell(col); + cell.setCellStyle(headerStyle); + } + Cell titleCell = titleRow.createCell(0); + titleCell.setCellValue("Daily Report GCC " + abcCenter + " ABC Center Data (From: " + fromDate + " to To: " + + toDate + ")"); + titleCell.setCellStyle(headerStyle); + sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 19)); + + // Re-apply bottom border for merged title row + for (int col = 0; col <= 19; col++) { + Cell cell = titleRow.getCell(col); + CellStyle titleStyle = workbook.createCellStyle(); + titleStyle.cloneStyleFrom(headerStyle); + titleStyle.setBorderBottom(BorderStyle.THIN); + cell.setCellStyle(titleStyle); + } + + // Group header row + Row groupHeaderRow = sheet.createRow(1); + sheet.addMergedRegion(new CellRangeAddress(1, 2, 0, 0)); // Merge Sl. No column + sheet.addMergedRegion(new CellRangeAddress(1, 2, 1, 1)); // Merge Zone column + + // Set merged header cells + Cell slNoHeader = groupHeaderRow.createCell(0); + slNoHeader.setCellValue("Sl. No"); + slNoHeader.setCellStyle(headerStyle); + + Cell zoneHeader = groupHeaderRow.createCell(1); + zoneHeader.setCellValue("Zone"); + zoneHeader.setCellStyle(headerStyle); + + // Set merged header cells + createMergedHeaderCell(groupHeaderRow, 2, "No. of Unsterilized Dogs Received from each zone", headerStyle, + sheet, 2, 4); + createMergedHeaderCell(groupHeaderRow, 5, "No. of Sterilized Dogs Received from each zone", headerStyle, + sheet, 5, 7); + createMergedHeaderCell(groupHeaderRow, 8, "No. of Dogs Unfit for Surgery", headerStyle, sheet, 8, 10); + createMergedHeaderCell(groupHeaderRow, 11, "No. of ABC Surgery Conducted", headerStyle, sheet, 11, 13); + createMergedHeaderCell(groupHeaderRow, 14, "No. of Dogs Died", headerStyle, sheet, 14, 16); + createMergedHeaderCell(groupHeaderRow, 17, "No. of Dog Released", headerStyle, sheet, 17, 19); + + // Column headers row (second row with individual column headers) + Row headerRow1 = sheet.createRow(2); + String[] headers = { "Sl. No", "Zone", "Male", "Female", "Total", "Male", "Female", "Total", "Male", + "Female", "Total", "Male", "Female", "Total", "Male", "Female", "Total", "Male", "Female", + "Total" }; + + for (int col = 0; col < headers.length; col++) { + Cell cell = headerRow1.createCell(col); + cell.setCellValue(headers[col]); + cell.setCellStyle(headerStyle); + } + + // Populate data rows + int rowIndex = 3; // Start below the header rows + int slNo = 1; + for (Map unsterilized : unsterilizedData) { + Row excelRow = sheet.createRow(rowIndex++); + excelRow.createCell(0).setCellValue(slNo++); // Sl. No + excelRow.createCell(1).setCellValue((String) unsterilized.get("Zone")); // Zone + excelRow.createCell(2).setCellValue(((Number) unsterilized.get("Male_Unsterilized")).doubleValue()); + excelRow.createCell(3).setCellValue(((Number) unsterilized.get("Female_Unsterilized")).doubleValue()); + excelRow.createCell(4).setCellValue(((Number) unsterilized.get("Total_Unsterilized")).doubleValue()); + + for (Map sterilized : sterilizedData) { + if (((String) sterilized.get("Zone")).equalsIgnoreCase((String) unsterilized.get("Zone"))) { + excelRow.createCell(5).setCellValue(((Number) sterilized.get("Male_Sterilized")).doubleValue()); + excelRow.createCell(6) + .setCellValue(((Number) sterilized.get("Female_Sterilized")).doubleValue()); + excelRow.createCell(7) + .setCellValue(((Number) sterilized.get("Total_sterilized")).doubleValue()); + break; + } + } + + for (Map unfit : unfitData) { + if (((String) unfit.get("Zone")).equalsIgnoreCase((String) unsterilized.get("Zone"))) { + excelRow.createCell(8).setCellValue(((Number) unfit.get("Male_Unfit")).doubleValue()); + excelRow.createCell(9).setCellValue(((Number) unfit.get("Female_Unfit")).doubleValue()); + excelRow.createCell(10).setCellValue(((Number) unfit.get("Total_Unfit")).doubleValue()); + break; + } + } + + for (Map surgery : surgeryData) { + if (((String) surgery.get("Zone")).equalsIgnoreCase((String) unsterilized.get("Zone"))) { + excelRow.createCell(11).setCellValue(((Number) surgery.get("Male_Surgery")).doubleValue()); + excelRow.createCell(12).setCellValue(((Number) surgery.get("Female_Surgery")).doubleValue()); + excelRow.createCell(13).setCellValue(((Number) surgery.get("Total_Surgery")).doubleValue()); + break; + } + } + + for (Map died : diedData) { + if (((String) died.get("Zone")).equalsIgnoreCase((String) unsterilized.get("Zone"))) { + excelRow.createCell(14).setCellValue(((Number) died.get("Male_Died")).doubleValue()); + excelRow.createCell(15).setCellValue(((Number) died.get("Female_Died")).doubleValue()); + excelRow.createCell(16).setCellValue(((Number) died.get("Total_Died")).doubleValue()); + break; + } + } + + for (Map released : releasedData) { + if (((String) released.get("Zone")).equalsIgnoreCase((String) unsterilized.get("Zone"))) { + excelRow.createCell(17).setCellValue(((Number) released.get("Male_Released")).doubleValue()); + excelRow.createCell(18).setCellValue(((Number) released.get("Female_Released")).doubleValue()); + excelRow.createCell(19).setCellValue(((Number) released.get("Total_Released")).doubleValue()); + break; + } + } + + // Apply the regularStyle to all populated cells in the row + for (int col = 0; col <= 19; col++) { + excelRow.getCell(col).setCellStyle(regularStyle); + } + } + + // Auto-size columns + for (int i = 0; i < headers.length; i++) { + sheet.autoSizeColumn(i); + } + + workbook.write(out); + return new ByteArrayInputStream(out.toByteArray()); + } catch (IOException e) { + throw new RuntimeException("Failed to generate Excel report", e); + } catch (Exception e) { + throw new RuntimeException("An error occurred while generating the report: " + e.getMessage(), e); + } + } + + // Helper method for setting merged header cells with style and applying border + // to all cells in the range + private void createMergedHeaderCell(Row row, int colIndex, String value, CellStyle style, Sheet sheet, int fromCol, + int toCol) { + // Set value in the main cell and apply style + Cell mainCell = row.createCell(colIndex); + mainCell.setCellValue(value); + mainCell.setCellStyle(style); + + // Merge cells + sheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), fromCol, toCol)); + + // Apply style to each cell in the merged region to ensure borders are visible + for (int col = fromCol; col <= toCol; col++) { + Cell cell = row.getCell(col); + if (cell == null) { // Create cells if they don’t exist + cell = row.createCell(col); + } + cell.setCellStyle(style); + } + } + + // Define cell styles for headers and regular cells + private CellStyle createHeaderStyle(Workbook workbook) { + CellStyle style = workbook.createCellStyle(); + Font font = workbook.createFont(); + font.setBold(true); + style.setFont(font); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setBorderBottom(BorderStyle.THIN); + style.setBorderTop(BorderStyle.THIN); + style.setBorderRight(BorderStyle.THIN); + style.setBorderLeft(BorderStyle.THIN); + return style; + } + + private CellStyle createRegularCellStyle(Workbook workbook) { + CellStyle style = workbook.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setBorderBottom(BorderStyle.THIN); + style.setBorderTop(BorderStyle.THIN); + style.setBorderRight(BorderStyle.THIN); + style.setBorderLeft(BorderStyle.THIN); + return style; + } + + public List> getZoneList() { + String sql = "SELECT NAME FROM abc_centers as Name"; + List> resultMapList = jdbcStraydogsTemplate.queryForList(sql); + return resultMapList; + } + + public List> getUnstrelizedDogsBreakup(String ward, String fromDate, String toDate, + String abcCenter, String zone, String streetID, String sex) { + String sql = "SELECT *," + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_1) AS step1_imageUrl, " + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_2) AS step2_imageUrl, " + + "CONCAT('"+ fileBaseUrl + "/gccofficialapp/files', photo_5) AS step5_imageUrl, " + + "CONCAT('"+ fileBaseUrl + "/gccofficialapp/files', photo_6) AS step6_imageUrl " + +" FROM \r\n" + " stray_dog_master sm\r\n" + + " LEFT JOIN stray_dog_logs sl ON sm.rf_id = sl.rf_id\r\n" + " WHERE\r\n" + + " sl.ward_1 = ? \r\n" + + " AND date(sl.date_2) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + " AND sl.zone_1 = ? \r\n" + " AND sl.streetid_1 = ?\r\n" + + " AND sl.contraception_2 = false\r\n" + " AND sl.sex_2 = ?"; + + List> data = jdbcStraydogsTemplate.queryForList(sql, ward, fromDate, toDate, abcCenter, + zone, streetID, sex); + + return data; + } + + public List> getStrelizedDogsBreakup(String ward, String fromDate, String toDate, + String abcCenter, String zone, String streetID, String sex) { + + String sql = "SELECT *," + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_1) AS step1_imageUrl, " + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_2) AS step2_imageUrl, " + + "CONCAT('"+ fileBaseUrl + "/gccofficialapp/files', photo_5) AS step5_imageUrl, " + + "CONCAT('"+ fileBaseUrl + "/gccofficialapp/files', photo_6) AS step6_imageUrl " + + " FROM \r\n" + " stray_dog_master sm\r\n" + + " left join stray_dog_logs sl on sm.rf_id = sl.rf_id\r\n" + " where\r\n" + + " sl.ward_1 = ? \r\n" + + " AND date(sl.date_2) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + " AND sl.zone_1 = ? \r\n" + " and sl.streetid_1 = ?\r\n" + + " AND sl.contraception_2 = true\r\n" + " and sl.sex_2 = ?"; + + List> data = jdbcStraydogsTemplate.queryForList(sql, ward, fromDate, toDate, abcCenter, + zone, streetID, sex); + + return data; + + } + + public List> getUnfitDogsBreakup(String ward, String fromDate, String toDate, String abcCenter, + String zone, String streetID, String sex) { + + String sql = " SELECT *," + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_1) AS step1_imageUrl, " + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_2) AS step2_imageUrl, " + + "CONCAT('"+ fileBaseUrl + "/gccofficialapp/files', photo_5) AS step5_imageUrl, " + + "CONCAT('"+ fileBaseUrl + "/gccofficialapp/files', photo_6) AS step6_imageUrl " + + " FROM \r\n" + " stray_dog_master sm\r\n" + + " left join stray_dog_logs sl on sm.rf_id = sl.rf_id\r\n" + " where\r\n" + + " sl.ward_1 = ? \r\n" + + " AND date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + " AND sl.zone_1 = ? \r\n" + " and sl.streetid_1 = ?\r\n" + + " AND sm.surgery_fitness_3 = false\r\n" + " and sl.sex_2 = ?"; + List> data = jdbcStraydogsTemplate.queryForList(sql, ward, fromDate, toDate, abcCenter, + zone, streetID, sex); + + return data; + } + + public List> getSurgeryDogsBreakup(String ward, String fromDate, String toDate, + String abcCenter, String zone, String streetID, String sex) { + String sql = "SELECT *, " + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_1) AS step1_imageUrl, " + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_2) AS step2_imageUrl, " + + "CONCAT('"+ fileBaseUrl + "/gccofficialapp/files', photo_5) AS step5_imageUrl, " + + "CONCAT('"+ fileBaseUrl + "/gccofficialapp/files', photo_6) AS step6_imageUrl " + + " FROM \r\n" + " stray_dog_master sm\r\n" + + " left join stray_dog_logs sl on sm.rf_id = sl.rf_id\r\n" + " where\r\n" + + " sl.ward_1 = ? \r\n" + + " AND date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + " AND sl.zone_1 = ? \r\n" + " and sl.streetid_1 = ?\r\n" + + " AND sm.userid_4 is not null\r\n" + " and sl.sex_2 = ?"; + + List> data = jdbcStraydogsTemplate.queryForList(sql, ward, fromDate, toDate, abcCenter, + zone, streetID, sex); + + return data; + } + + public List> getDiedDogsBreakup(String ward, String fromDate, String toDate, String abcCenter, + String zone, String streetID, String sex) { + String sql = " SELECT *," + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_1) AS step1_imageUrl, " + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_2) AS step2_imageUrl, " + + "CONCAT('"+ fileBaseUrl + "/gccofficialapp/files', photo_5) AS step5_imageUrl, " + + "CONCAT('"+ fileBaseUrl + "/gccofficialapp/files', photo_6) AS step6_imageUrl " + + " FROM \r\n" + " stray_dog_master sm\r\n" + + " left join stray_dog_logs sl on sm.rf_id = sl.rf_id\r\n" + " where\r\n" + + " sl.ward_1 = ? \r\n" + + " AND date(sm.surgery_date) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + " AND sl.zone_1 = ? \r\n" + " and sl.streetid_1 = ?\r\n" + + " AND sm.ready_to_release_4 = false\r\n" + " and sl.sex_2 = ?"; + + List> data = jdbcStraydogsTemplate.queryForList(sql, ward, fromDate, toDate, abcCenter, + zone, streetID, sex); + + return data; + } + + public List> getReleasedDogsBreakup(String ward, String fromDate, String toDate, + String abcCenter, String zone, String streetID, String sex) { + String sql = "SELECT *," + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_1) AS step1_imageUrl, " + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', photo_2) AS step2_imageUrl, " + + "CONCAT('"+ fileBaseUrl + "/gccofficialapp/files', photo_5) AS step5_imageUrl, " + + "CONCAT('"+ fileBaseUrl + "/gccofficialapp/files', photo_6) AS step6_imageUrl " + + " FROM \r\n" + " stray_dog_master sm\r\n" + + " left join stray_dog_logs sl on sm.rf_id = sl.rf_id\r\n" + " where\r\n" + + " sl.ward_6 = ? \r\n" + + " AND date(sl.date_6) BETWEEN STR_TO_DATE(?, '%Y-%m-%d') AND STR_TO_DATE(?, '%Y-%m-%d')\r\n" + + " AND sl.abc_center_2 = ?\r\n" + " AND sl.zone_6 = ? \r\n" + " and sl.streetid_6 = ?\r\n" + + " and sl.sex_2 = ?"; + + List> data = jdbcStraydogsTemplate.queryForList(sql, ward, fromDate, toDate, abcCenter, + zone, streetID, sex); + + return data; + } + + @Transactional + public String saveBuildings(String location, String latitude, String longitude, String street_id, String street_name) { + + + String sql = "INSERT INTO buildings (location, latitude, longitude, street_id, street_name) VALUES (?, ?, ?, ?, ?)"; + try { + + int rowsAffected = jdbcStraydogsTemplate.update(sql, location, latitude, longitude, street_id, street_name); + return "Saved Sucessfuly"; + } catch (Exception e) { + e.printStackTrace(); + return "Error in Saving Step_1 give proper input"; + } + } + + @Transactional + public List> getBuildings(String latitude, String longitude) { + String sqlQuery = ""; + + sqlQuery = "SELECT * " + "FROM buildings " + "WHERE (is_active=1 AND is_delete=0) AND " + + " ((6371008.8 * acos( ROUND(cos(radians(?)) * cos(radians(latitude)) * cos(radians(longitude) - radians(?)) + sin(radians(?)) * sin(radians(latitude)), 9) )) < 500)"; + List> result = jdbcStraydogsTemplate.queryForList(sqlQuery, + new Object[] { latitude, longitude, latitude }); + Map response = new HashMap<>(); + + response.put("status", "success"); + response.put("message", "Request Information"); + response.put("Data", result); + + return Collections.singletonList(response); + } + + +} \ No newline at end of file diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/controller/APICattleCatchController.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/controller/APICattleCatchController.java index 543a312..4438617 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/controller/APICattleCatchController.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/controller/APICattleCatchController.java @@ -4,10 +4,14 @@ 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.CattleCatchService; @@ -17,8 +21,111 @@ public class APICattleCatchController { @Autowired private CattleCatchService cattleCatchService; - @GetMapping(value="/getpenaltytypes") - public List> getPenaltyTypes() { - return cattleCatchService.getPenaltyTypeList(); + @PostMapping(value="/step1") // Cattle Catch Step 1 + public List step1(@RequestParam MultiValueMap 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 = "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 = "isviolatorAvailable", required = false) String isviolatorAvailable, + //@RequestParam(value = "violatorName", required = false) String violatorName, + //@RequestParam(value = "violatorPhone", required = false) String violatorPhone, + //@RequestParam(value = "ton", required = false) String ton, + @RequestParam(value = "file", required = false) MultipartFile file + ) { + return cattleCatchService.step1(formData, categoryId, latitude, longitude, zone, ward, streeId, + streetName, loginId,remarks,file); + } + + @GetMapping("/step1list") + public List step1list(@RequestParam MultiValueMap formData, + @RequestParam(value = "orderid", required = false) String loginId) { + return cattleCatchService.step1list(formData,loginId); + } + + @PostMapping(value="/step2") // Move Catched cattle to depot + public List step2(@RequestParam MultiValueMap formData, + @RequestParam(value = "cinfoid", required = false) String cinfoid, + @RequestParam(value = "depotid", required = false) String depotid, + @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 + ) { + return cattleCatchService.step2(formData, cinfoid, depotid,latitude, longitude, zone, ward, streeId, + streetName, loginId,remarks,file); + } + + @GetMapping("/step2list") + public List step2list(@RequestParam MultiValueMap formData, + @RequestParam(value = "orderid", required = false) String orderid) { + return cattleCatchService.step2list(formData,orderid); + } + + @PostMapping(value="/step3") // Generate Fine Chellan when Violator is Available + public List generateChallan(@RequestParam MultiValueMap formData, + @RequestParam(value = "cinfoids", required = false) String cinfoids, + @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 = "isviolatorAvailable", required = false) String isviolatorAvailable, + @RequestParam(value = "violatorName", required = false) String violatorName, + @RequestParam(value = "violatorPhone", required = false) String violatorPhone, + @RequestParam(value = "fineAmount", required = false) String fineAmount, + @RequestParam(value = "file", required = false) MultipartFile file + ) { + return cattleCatchService.step3(formData, cinfoids, latitude, longitude, zone, ward, streeId, + streetName, loginId,remarks,violatorName,violatorPhone,fineAmount,file); + } + + @GetMapping("/getChallanPOSData") + public List getChallanPOSData(@RequestParam MultiValueMap formData, + @RequestParam(value = "orderid", required = false) String orderid, + @RequestParam(value = "loginid", required = true) String loginid) { + return cattleCatchService.getChallanPOSData(formData,orderid,loginid); } + + @PostMapping("/storeBankTransaction") + public List storeBankTransaction(@RequestBody Map transactionData) { + return cattleCatchService.storeBankTransaction(transactionData); + } + + @GetMapping("/step3list") + public List step3list(@RequestParam MultiValueMap formData, + @RequestParam(value = "loginid", required = true) String loginid) { + return cattleCatchService.step3list(formData,loginid); + } + + @PostMapping(value="/step4") // Cattle Catch Step 1 + public List generateChallan(@RequestParam MultiValueMap formData, + @RequestParam(value = "cinfoid", required = false) String cinfoid, + @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 + ) { + return cattleCatchService.step4(formData, cinfoid, latitude, longitude, zone, ward, streeId, + streetName, loginId,remarks,file); + } + } diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/controller/APIPenaltyControllerPOS.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/controller/APIPenaltyControllerPOS.java index a19d170..09946a5 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/controller/APIPenaltyControllerPOS.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/controller/APIPenaltyControllerPOS.java @@ -21,15 +21,25 @@ public class APIPenaltyControllerPOS { @Autowired private PenaltyServicePOS penaltyServicePOS; + @GetMapping(value="/getPenaltyDepartment") + public List> getPenaltyDepartment( + @RequestParam(value = "loginId", required = false) String loginId + ) { + return penaltyServicePOS.getPenaltyDepartment(); + } + @GetMapping(value="/getPenaltytypes") - public List> getPenaltyTypes(@RequestParam(value = "departmentId", required = false) String departmentId) { + public List> getPenaltyTypes( + @RequestParam(value = "departmentId", required = false) String departmentId, + @RequestParam(value = "loginId", required = false) String loginId) { return penaltyServicePOS.getPenaltyTypeList(departmentId); } @GetMapping(value="/getPenaltyAmount") - public List> getPenaltyTypes( + public List> getPenaltyAmount( @RequestParam(value = "categoryId", required = false) String categoryId, - @RequestParam(value = "ton", required = false) String ton + @RequestParam(value = "ton", required = false) String ton, + @RequestParam(value = "loginId", required = false) String loginId ) { return penaltyServicePOS.getPenaltyAmount(categoryId,ton); } @@ -39,6 +49,11 @@ public class APIPenaltyControllerPOS { return penaltyServicePOS.getOfflineModeTypes(); } + @GetMapping(value="/getBankList") + public List> getBankList() { + return penaltyServicePOS.getBankList(); + } + @PostMapping(value="/generateChallanPOS") public List generateChallan(@RequestParam MultiValueMap formData, @RequestParam(value = "categoryId", required = false) String categoryId, @@ -60,4 +75,22 @@ public class APIPenaltyControllerPOS { public List storeBankTransaction(@RequestBody Map transactionData) { return penaltyServicePOS.storeBankTransaction(transactionData); } + + @PostMapping(value="/storeOfflineTransaction") + public List generateChallan(@RequestParam MultiValueMap 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); + } } diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/CattleCatchService.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/CattleCatchService.java index 8542561..4be3265 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/CattleCatchService.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/CattleCatchService.java @@ -1,29 +1,800 @@ 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.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 CattleCatchService { 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) { + public void setDataSource(@Qualifier("mysqlCattleCatchDataSource") DataSource 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> step1( + MultiValueMap 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 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> step1list( + MultiValueMap 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> result = jdbcPenaltyTemplate.queryForList(sqlQuery); + Map response = new HashMap<>(); + response.put("status", 200); + response.put("message", "Challan Details"); + response.put("data", result); + + return result; + } + + @Transactional + public List> step2( + MultiValueMap formData, + String cinfoid, + String depotid, + String latitude, + String longitude, + String zone, + String ward, + String streeId, + String streetName, + String loginId, + String remarks, + MultipartFile file) { + + Map 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> step2list( + MultiValueMap 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> result = jdbcPenaltyTemplate.queryForList(sqlQuery); + Map response = new HashMap<>(); + response.put("status", 200); + response.put("message", "Challan Details"); + response.put("data", result); + + return result; + } + + @Transactional + public List> step3( + MultiValueMap 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 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> getChallanPOSData( + MultiValueMap 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> result = jdbcPenaltyTemplate.queryForList(sqlQuery); + Map response = new HashMap<>(); + response.put("status", 200); + response.put("message", "Challan Details"); + response.put("data", result); + + return result; + } + @Transactional - public List> getPenaltyTypeList() { - String SqlQuery = "SELECT `id`, `name`, `display_name` FROM `penalty_types` WHERE `isdelete`=0 AND `isactive`=1"; - List> result = jdbcPenaltyTemplate.queryForList(SqlQuery); - return result; + public List> storeBankTransaction(Map transactionData) { + + Map 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 txnResponseData = (Map) 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> 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> step3list( + MultiValueMap 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> result = jdbcPenaltyTemplate.queryForList(sqlQuery); + Map response = new HashMap<>(); + response.put("status", 200); + response.put("message", "Challan Details"); + response.put("data", result); + + return result; + } + + @Transactional + public List> step4( + MultiValueMap formData, + String cinfoid, + String latitude, + String longitude, + String zone, + String ward, + String streeId, + String streetName, + String loginId, + String remarks, + MultipartFile file) { + + Map 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> zoneReport( + MultiValueMap 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> result = jdbcPenaltyTemplate.queryForList(sqlQuery,fromDate,toDate); + Map response = new HashMap<>(); + response.put("status", 200); + response.put("message", "Challan Details"); + response.put("data", result); + + return result; + } + + @Transactional + public List> wardReport( + MultiValueMap 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> result = jdbcPenaltyTemplate.queryForList(sqlQuery,zone,fromDate,toDate); + Map response = new HashMap<>(); + response.put("status", 200); + response.put("message", "Challan Details"); + response.put("data", result); + + return result; + } } diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/PenaltyService.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/PenaltyService.java index e736018..eb6ad19 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/PenaltyService.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/PenaltyService.java @@ -147,7 +147,7 @@ public class PenaltyService { byte[] compressedBytes = compressImage(image, 0.5f); // Compress with 50% quality // Write the bytes to the file - Files.write(path, bytes); + Files.write(path, compressedBytes); System.out.println(filePath); return filepath_txt; diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/PenaltyServicePOS.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/PenaltyServicePOS.java index 0cfa66b..262ead8 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/PenaltyServicePOS.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/penalty/service/PenaltyServicePOS.java @@ -70,6 +70,7 @@ public class PenaltyServicePOS { } 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 @@ -172,6 +173,19 @@ public class PenaltyServicePOS { } //// POS //// + @Transactional + public List> getPenaltyDepartment() { + String sqlQuery = "SELECT * FROM `penalty_department` WHERE (`isactive`=1 AND `isdelete`=0) "; + sqlQuery = sqlQuery + " ORDER BY `display_order`, `name` ASC"; + List> result = jdbcPenaltyTemplate.queryForList(sqlQuery); + + Map response = new HashMap<>(); + response.put("status", 200); + response.put("message", "Department list"); + response.put("data", result); + + return Collections.singletonList(response); + } @Transactional public List> getPenaltyTypeList(String departmentId) { @@ -180,7 +194,9 @@ public class PenaltyServicePOS { 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`, `name` ASC"; + sqlQuery = sqlQuery + " ORDER BY `display_order` ASC"; List> result = jdbcPenaltyTemplate.queryForList(sqlQuery); Map response = new HashMap<>(); @@ -202,7 +218,7 @@ public class PenaltyServicePOS { sqlQuery= sqlQuery +" AND `ton`='"+ton+"'"; } - sqlQuery = sqlQuery + " LIMIT 1"; + sqlQuery = sqlQuery + ""; System.out.println(sqlQuery); List> result = jdbcPenaltyTemplate.queryForList(sqlQuery); @@ -215,6 +231,19 @@ public class PenaltyServicePOS { return Collections.singletonList(response); } + @Transactional + public List> getBankList() { + String sqlQuery = "SELECT `id`, `code`, `name`, `narration` FROM `bank_list` WHERE `isactive`=1 AND `isdelete`=0"; + List> result = jdbcPenaltyTemplate.queryForList(sqlQuery); + + Map response = new HashMap<>(); + response.put("status", 200); + response.put("message", "Bank list"); + response.put("data", result); + + return Collections.singletonList(response); + } + @Transactional public List> getOfflineModeTypes() { String sqlQuery = "SELECT `id`, `name` FROM `offline_mode_type` WHERE `isactive`=1 AND `isdelete`=0"; @@ -376,9 +405,9 @@ public class PenaltyServicePOS { return result; } */ + @Transactional - public List> storeBankTransaction( - Map transactionData) { + public List> storeBankTransaction(Map transactionData) { Map response = new HashMap<>(); int lastInsertId = 0; @@ -388,7 +417,7 @@ public class PenaltyServicePOS { // 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"); @@ -411,14 +440,15 @@ public class PenaltyServicePOS { 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) " + + "transactionTitle, txnAID, txnApprCode, txnCardNo, txnCardType, txnDate, txnInvoice, txnMode, txnRefNo, " + + "txnTC, txnTSI, txnTVR, txnTime) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; - + KeyHolder keyHolder = new GeneratedKeyHolder(); try { @@ -510,4 +540,110 @@ public class PenaltyServicePOS { jdbcPenaltyTemplate.update(sqlQuery, status, orderid); return "success"; } + + @Transactional + public List> storeOfflineTransaction( + MultiValueMap 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 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> 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); + } + } diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/service/OfficialAPIService.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/service/OfficialAPIService.java index 24fae79..fd4bb27 100644 --- a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/service/OfficialAPIService.java +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/service/OfficialAPIService.java @@ -50,6 +50,14 @@ public class OfficialAPIService { List> result = jdbcActivityTemplate.queryForList(sqlQuery); return result; } + + @Transactional + public List> nammaVersionCheck() { + String sqlQuery = "SELECT * FROM `nammachennai_app_version` WHERE `isactive`=1 LIMIT 1"; + List> result = jdbcActivityTemplate.queryForList(sqlQuery); + return result; + } + public List> sendOTP(HttpServletRequest request, @RequestParam("MobileNo") String MobileNo, @RequestParam("generatedToken") String OTP) { @@ -201,8 +209,8 @@ public class OfficialAPIService { SqlQuery="SELECT `groups` FROM `user_mapping_details` WHERE `userid`=?"; - System.out.println(SqlQuery); - System.out.println("loginId : "+loginId); + //System.out.println(SqlQuery); + //System.out.println("loginId : "+loginId); List> result = jdbcUserTemplate.queryForList(SqlQuery,loginId); return result; @@ -226,7 +234,7 @@ public class OfficialAPIService { groups = (String) firstEntry.get("groups"); // Do something with the groups value - System.out.println("Groups: " + groups); + //System.out.println("Groups: " + groups); } else { System.out.println("The 'groups' key is not present."); } @@ -260,7 +268,7 @@ public class OfficialAPIService { groups = (String) firstEntry.get("groups"); // Do something with the groups value - System.out.println("Groups: " + groups); + //System.out.println("Groups: " + groups); } else { System.out.println("The 'groups' key is not present."); } @@ -295,7 +303,7 @@ public class OfficialAPIService { menus = (String) firstEntry.get("module_ids"); // Do something with the groups value - System.out.println("Menus: " + menus); + //System.out.println("Menus: " + menus); } else { System.out.println("The 'module_ids' key is not present."); } @@ -331,7 +339,7 @@ public class OfficialAPIService { mainmenus = (String) firstEntry.get("department_ids"); // Do something with the groups value - System.out.println("MainMenus: " + mainmenus); + //System.out.println("MainMenus: " + mainmenus); } else { System.out.println("The 'department_ids' key is not present."); } @@ -367,7 +375,7 @@ public class OfficialAPIService { menus = (String) firstEntry.get("module_ids"); // Do something with the groups value - System.out.println("Menus: " + menus); + //System.out.println("Menus: " + menus); } else { System.out.println("The 'module_ids' key is not present."); } @@ -407,7 +415,7 @@ public class OfficialAPIService { menuitem = (String) firstEntry.get("menuitem_ids"); // Do something with the groups value - System.out.println("MenuItems: " + menuitem); + //System.out.println("MenuItems: " + menuitem); } else { System.out.println("The 'menuitem_ids' key is not present."); } diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/controller/APIController.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/controller/APIController.java new file mode 100644 index 0000000..1327ee0 --- /dev/null +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/controller/APIController.java @@ -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); + } + +} diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/controller/package-info.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/controller/package-info.java new file mode 100644 index 0000000..e64e810 --- /dev/null +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/controller/package-info.java @@ -0,0 +1 @@ +package in.gov.chennaicorporation.mobileservice.swmbwg.controller; \ No newline at end of file diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/package-info.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/package-info.java new file mode 100644 index 0000000..0599672 --- /dev/null +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/package-info.java @@ -0,0 +1 @@ +package in.gov.chennaicorporation.mobileservice.swmbwg; \ No newline at end of file diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/service/activity.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/service/activity.java new file mode 100644 index 0000000..4f1178a --- /dev/null +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/service/activity.java @@ -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> getAllClass(){ + + String sqlQuery = "SELECT `cid`, `name` " + + "FROM `swm_bwg_class` " + + "WHERE `isactive`=1 AND `isdelete`=0"; + + List> result = jdbcBWGTemplate.queryForList(sqlQuery); + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("message", "SWM - BWG Class List"); + response.put("data", result); + + return Collections.singletonList(response); + } + + public List> getBWGTypes(){ + + String sqlQuery = "SELECT `tid`, `name` " + + "FROM `swm_bwg_types` " + + "WHERE `isactive`=1 AND `isdelete`=0"; + + List> result = jdbcBWGTemplate.queryForList(sqlQuery); + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("message", "SWM - BWG Type List"); + response.put("data", result); + + return Collections.singletonList(response); + } + + public List> getServiceProviderList(){ + + String sqlQuery = "SELECT `splid`, `name` " + + "FROM `swm_bwg_service_provider_list` " + + "WHERE `isactive`=1 AND `isdelete`=0"; + + List> result = jdbcBWGTemplate.queryForList(sqlQuery); + Map 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> 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> result = null; + Map 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> 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> result = jdbcBWGTemplate.queryForList(sqlQuery); + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("message", "Zone wise count List"); + response.put("data", result); + + return Collections.singletonList(response); + } + + public List> 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> result = jdbcBWGTemplate.queryForList(sqlQuery,zone); + Map 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> 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> result = jdbcBWGTemplate.queryForList(sqlQuery,ward); + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("message", "SWM - BWG List"); + response.put("data", result); + + return Collections.singletonList(response); + } +} diff --git a/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/service/package-info.java b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/service/package-info.java new file mode 100644 index 0000000..8c5a015 --- /dev/null +++ b/mobileservice/src/main/java/in/gov/chennaicorporation/mobileservice/swmbwg/service/package-info.java @@ -0,0 +1 @@ +package in.gov.chennaicorporation.mobileservice.swmbwg.service; \ No newline at end of file diff --git a/mobileservice/src/main/resources/application.properties b/mobileservice/src/main/resources/application.properties index 550e6d8..eafaf20 100644 --- a/mobileservice/src/main/resources/application.properties +++ b/mobileservice/src/main/resources/application.properties @@ -39,4 +39,6 @@ penalty_foldername=penalty_activity/ straydogs_foldername=stray_dogs/ gccschools_foldername=schools_images/ parks_playground_foldername=parks_playground_images/ +swm_bwg_foldername=swm_bwg/ +cattlecatch_foldername=cattlecatch_activity/