From fc1b2be09b2449439d109ce696fbb4ad727f7d59 Mon Sep 17 00:00:00 2001 From: Hariprasath S <113695067+Hariprasath4022@users.noreply.github.com> Date: Wed, 15 Oct 2025 11:23:35 +0530 Subject: [PATCH] first commit --- .gitattributes | 2 + .gitignore | 33 + .mvn/wrapper/maven-wrapper.properties | 19 + mvnw | 259 +++++ mvnw.cmd | 149 +++ pom.xml | 83 ++ .../CommissionerreviewIiApplication.java | 13 + .../configuration/DataSourceConfig.java | 53 + .../controller/EnforcementApiController.java | 55 ++ .../EnforcementPendencyApiController.java | 101 ++ .../controller/MainController.java | 38 + .../SofaBedCollectionApiController.java | 77 ++ .../service/EnforcementPendencyService.java | 769 +++++++++++++++ .../service/EnforcementService.java | 304 ++++++ .../service/SofaBedCollectionService.java | 621 ++++++++++++ src/main/resources/application.properties | 3 + .../modules/enforcement/Zonewise.html | 919 ++++++++++++++++++ .../modules/enforcement/form2pendency.html | 857 ++++++++++++++++ .../modules/enforcement/form3Pendency.html | 857 ++++++++++++++++ .../modules/enforcement/form7pendency.html | 796 +++++++++++++++ .../templates/modules/sofa_bed/zonewise.html | 662 +++++++++++++ .../templates/modules/sofa_bed/zonewise1.html | 687 +++++++++++++ .../CommissionerreviewIiApplicationTests.java | 13 + 23 files changed, 7370 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .mvn/wrapper/maven-wrapper.properties create mode 100644 mvnw create mode 100644 mvnw.cmd create mode 100644 pom.xml create mode 100644 src/main/java/com/gcc/commissionerreviewII/CommissionerreviewIiApplication.java create mode 100644 src/main/java/com/gcc/commissionerreviewII/configuration/DataSourceConfig.java create mode 100644 src/main/java/com/gcc/commissionerreviewII/controller/EnforcementApiController.java create mode 100644 src/main/java/com/gcc/commissionerreviewII/controller/EnforcementPendencyApiController.java create mode 100644 src/main/java/com/gcc/commissionerreviewII/controller/MainController.java create mode 100644 src/main/java/com/gcc/commissionerreviewII/controller/SofaBedCollectionApiController.java create mode 100644 src/main/java/com/gcc/commissionerreviewII/service/EnforcementPendencyService.java create mode 100644 src/main/java/com/gcc/commissionerreviewII/service/EnforcementService.java create mode 100644 src/main/java/com/gcc/commissionerreviewII/service/SofaBedCollectionService.java create mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/templates/modules/enforcement/Zonewise.html create mode 100644 src/main/resources/templates/modules/enforcement/form2pendency.html create mode 100644 src/main/resources/templates/modules/enforcement/form3Pendency.html create mode 100644 src/main/resources/templates/modules/enforcement/form7pendency.html create mode 100644 src/main/resources/templates/modules/sofa_bed/zonewise.html create mode 100644 src/main/resources/templates/modules/sofa_bed/zonewise1.html create mode 100644 src/test/java/com/gcc/commissionerreviewII/CommissionerreviewIiApplicationTests.java diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3b41682 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +/mvnw text eol=lf +*.cmd text eol=crlf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..667aaef --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..d58dfb7 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +wrapperVersion=3.3.2 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/mvnw b/mvnw new file mode 100644 index 0000000..19529dd --- /dev/null +++ b/mvnw @@ -0,0 +1,259 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.3.2 +# +# Optional ENV vars +# ----------------- +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output +# ---------------------------------------------------------------------------- + +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x + +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac + +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" + + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 + fi + fi + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi + fi +} + +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" + done + printf %x\\n $h +} + +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } + +die() { + printf %s\\n "$1" >&2 + exit 1 +} + +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} + +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" +fi + +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac + +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" +fi + +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" +fi + +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 + fi +fi + +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" + +clean || : +exec_maven "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..249bdf3 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,149 @@ +<# : batch portion +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.2 +@REM +@REM Optional ENV vars +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output +@REM ---------------------------------------------------------------------------- + +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' +$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" +if ($env:MAVEN_USER_HOME) { + $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" +} +$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..8c74077 --- /dev/null +++ b/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.5.0 + + + com.gcc + commissionerreviewII + 0.0.1-SNAPSHOT + commissionerreviewII + Demo project for Spring Boot + + + + + + + + + + + + + + + 17 + + + + + org.springframework.boot + spring-boot-starter-data-jdbc + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.oracle.database.jdbc + ojdbc8 + runtime + + + com.mysql + mysql-connector-j + 8.4.0 + runtime + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/src/main/java/com/gcc/commissionerreviewII/CommissionerreviewIiApplication.java b/src/main/java/com/gcc/commissionerreviewII/CommissionerreviewIiApplication.java new file mode 100644 index 0000000..e942e96 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreviewII/CommissionerreviewIiApplication.java @@ -0,0 +1,13 @@ +package com.gcc.commissionerreviewII; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class CommissionerreviewIiApplication { + + public static void main(String[] args) { + SpringApplication.run(CommissionerreviewIiApplication.class, args); + } + +} diff --git a/src/main/java/com/gcc/commissionerreviewII/configuration/DataSourceConfig.java b/src/main/java/com/gcc/commissionerreviewII/configuration/DataSourceConfig.java new file mode 100644 index 0000000..65b1412 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreviewII/configuration/DataSourceConfig.java @@ -0,0 +1,53 @@ +package com.gcc.commissionerreviewII.configuration; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.datasource.DriverManagerDataSource; + +@Configuration +public class DataSourceConfig { + + + + @Configuration + public static class MyDataSourceConfig { + + private static final String host = "localhost"; + private static final String dbpassword = "root"; + @Primary + @Bean(name = "oracleDataSource") + public DataSource oracleDataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("oracle.jdbc.OracleDriver"); + dataSource.setUrl("jdbc:oracle:thin:@10.1.0.14:1521:chncorp"); + dataSource.setUsername("FAS"); + dataSource.setPassword("FAS"); + return dataSource; + } + + @Bean(name = "mySqlDataSourceSofaBed") + public DataSource mySqlDataSourceSofaBed() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://" + host + "/domestic_waste_management"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); + return dataSource; + } + + @Bean(name = "jdbcDomesticWasteTemplate") + public JdbcTemplate jdbcDomesticWasteTemplate(@Qualifier("mySqlDataSourceSofaBed") DataSource ds) { + return new JdbcTemplate(ds); + } + } + + + + + +} diff --git a/src/main/java/com/gcc/commissionerreviewII/controller/EnforcementApiController.java b/src/main/java/com/gcc/commissionerreviewII/controller/EnforcementApiController.java new file mode 100644 index 0000000..3d4276a --- /dev/null +++ b/src/main/java/com/gcc/commissionerreviewII/controller/EnforcementApiController.java @@ -0,0 +1,55 @@ +package com.gcc.commissionerreviewII.controller; + +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.gcc.commissionerreviewII.service.EnforcementService; + + +@RestController +@RequestMapping("/commissionerreview/api/enforcement") +public class EnforcementApiController { + + @Autowired + private EnforcementService enforcementService; + + + @GetMapping("/getZoneWiseDetails") + public List> getZonewisedetails() + { + return enforcementService.getzonewisedetails(); + } + + @GetMapping("/getWardWiseDetails") + public List> getWardwisedetails(@RequestParam String zone) + { + return enforcementService.getwardwisedetails(zone); + } + + @GetMapping("/getFormDetails") + public List> getFormdetails(@RequestParam String ward,@RequestParam String zone,@RequestParam String formtype,@RequestParam String status) + { + return enforcementService.getformdetailswithzone(zone,ward,formtype,status); + } + + @GetMapping("/getFormDetailsWithoutWard") + public List> getFormdetailsWithoutWard(@RequestParam String zone,@RequestParam String formtype,@RequestParam String status) + { + return enforcementService.getformdetailswithoutward(zone,formtype,status); + } + + + @GetMapping("/getFormId") + public List> getFormIddetails(@RequestParam String formid) + { + return enforcementService.getformiddetails(formid); + } + + +} diff --git a/src/main/java/com/gcc/commissionerreviewII/controller/EnforcementPendencyApiController.java b/src/main/java/com/gcc/commissionerreviewII/controller/EnforcementPendencyApiController.java new file mode 100644 index 0000000..d01b3f6 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreviewII/controller/EnforcementPendencyApiController.java @@ -0,0 +1,101 @@ +package com.gcc.commissionerreviewII.controller; + +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.gcc.commissionerreviewII.service.EnforcementPendencyService; + +@RestController +@RequestMapping("/commissionerreview/api/pendency") +public class EnforcementPendencyApiController { + + @Autowired + private EnforcementPendencyService enforcementPendencyService; + + + + @GetMapping("/getZoneWisePendencyDetails") + public List> getZoneWisePendencyDetails() + { + return enforcementPendencyService.getzonewisependencydetails(); + } + + + @GetMapping("/getWardWisePendencyDetails") + public List> getWardWisePendencyDetails(@RequestParam String zone) + { + return enforcementPendencyService.getwardwisependencydetails(zone); + } + + + @GetMapping("/getPendencyDetailReport") + public List> getPendencyDetailReport(@RequestParam String zone,@RequestParam String status) + { + return enforcementPendencyService.getpendencydetailreport(zone,status); + } + + @GetMapping("/getPendencyDetailReportByWard") + public List> getPendencyDetailReportByWard(@RequestParam String zone,@RequestParam String status,@RequestParam String ward) + { + return enforcementPendencyService.getpendencydetailreportbyward(zone,status,ward); + } + + + // for form 3 + + @GetMapping("/getZoneWiseForm3PendencyDetails") + public List> getZoneWiseForm3PendencyDetails() + { + return enforcementPendencyService.getZoneWiseForm3PendencyDetails(); + } + + + @GetMapping("/getWardWiseForm3PendencyDetails") + public List> getWardWiseForm3PendencyDetails(@RequestParam String zone) + { + return enforcementPendencyService.getWardWiseForm3PendencyDetails(zone); + } + + + @GetMapping("/getForm3PendencyDetailReport") + public List> getForm3PendencyDetailReport(@RequestParam String zone,@RequestParam String status) + { + return enforcementPendencyService.getForm3PendencyDetailReport(zone,status); + } + + @GetMapping("/getForm3PendencyDetailReportByWard") + public List> getForm3PendencyDetailReportByWard(@RequestParam String zone,@RequestParam String status,@RequestParam String ward) + { + return enforcementPendencyService.getForm3PendencyDetailReportByWard(zone,status,ward); + } + + // for form 7 + + @GetMapping("/getZoneWiseForm7PendencyDetails") + public List> getZoneWiseForm7PendencyDetails() { + return enforcementPendencyService.getZoneWiseForm7PendencyDetails(); + } + + + @GetMapping("/getWardWiseForm7PendencyDetails") + public List> getWardWiseForm7PendencyDetails(@RequestParam String zone) { + return enforcementPendencyService.getWardWiseForm7PendencyDetails(zone); + } + + + @GetMapping("/getForm7PendencyDetailReportByZone") + public List> getForm7PendencyDetailReportByZone(@RequestParam String zone, @RequestParam String status) { + return enforcementPendencyService.getForm7PendencyDetailReportByZone(zone, status); + } + + @GetMapping("/getForm7PendencyDetailReportByWard") + public List> getForm7PendencyDetailReportByWard(@RequestParam String zone, @RequestParam String status, @RequestParam String ward) { + return enforcementPendencyService.getForm7PendencyDetailReportByWard(zone, status, ward); + } +} diff --git a/src/main/java/com/gcc/commissionerreviewII/controller/MainController.java b/src/main/java/com/gcc/commissionerreviewII/controller/MainController.java new file mode 100644 index 0000000..efa3e28 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreviewII/controller/MainController.java @@ -0,0 +1,38 @@ +package com.gcc.commissionerreviewII.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping(value = {"/commissionerreview"}) +public class MainController { + + @GetMapping("/enforcement") + public String viewenforcementpage(Model model) { + return "modules/enforcement/Zonewise"; + } + + @GetMapping("/pendency") + public String viewpendencypage(Model model) { + return "modules/enforcement/form2pendency"; + } + + @GetMapping("/pendencyform3") + public String viewpendencypage2(Model model) { + return "modules/enforcement/form3Pendency"; + } + + @GetMapping("/pendencyform7") + public String viewform7pendencypage(Model model) { + return "modules/enforcement/form7pendency"; + } + + + @GetMapping("/sofacollection") + public String sofaZoneReport(Model model) { + return "modules/sofa_bed/zonewise1"; + } + +} diff --git a/src/main/java/com/gcc/commissionerreviewII/controller/SofaBedCollectionApiController.java b/src/main/java/com/gcc/commissionerreviewII/controller/SofaBedCollectionApiController.java new file mode 100644 index 0000000..90f0cdf --- /dev/null +++ b/src/main/java/com/gcc/commissionerreviewII/controller/SofaBedCollectionApiController.java @@ -0,0 +1,77 @@ +package com.gcc.commissionerreviewII.controller; + +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.gcc.commissionerreviewII.service.SofaBedCollectionService; + +@RestController +@RequestMapping("/commissionerreview/api/sofabedcollection") +public class SofaBedCollectionApiController { + + @Autowired + private SofaBedCollectionService sofaBedCollectionService; + + @GetMapping("/getZoneWiseDetails") + public Map getZonewisedetails() + { + return sofaBedCollectionService.getzonewisedetails(); + } + + @GetMapping("/getWardDetails") + public Map getWardDetails(@RequestParam String zone) + { + return sofaBedCollectionService.getwarddetails(zone); + } + + @GetMapping("/getWardStatusDetails") + public Map getWardStatusDetails(@RequestParam String ward,@RequestParam String status) + { + return sofaBedCollectionService.getwardstatusdetails(ward,status); + } + + // @GetMapping("/getZoneReport") + // public List> getZoneReport(@RequestParam String fromDate,@RequestParam String toDate) + // { + // return sofaBedCollectionService.getZoneReport(fromDate,toDate); + // } + + @GetMapping("/getZoneReport") + public List> getZoneReport() + { + return sofaBedCollectionService.getZoneReport(); + } + + + // @GetMapping("/getWardReport") + // public List> getWardReport(@RequestParam String fromDate,@RequestParam String toDate,@RequestParam String zone) + // { + // return sofaBedCollectionService.getWardReport(fromDate,toDate,zone); + // } + + @GetMapping("/getWardReport") + public List> getWardReport(@RequestParam String zone) + { + return sofaBedCollectionService.getWardReport(zone); + } + + // @GetMapping("/getWardStatusReport") + // public List> getWardStatusDetails(@RequestParam String fromDate,@RequestParam String toDate,@RequestParam String ward,@RequestParam String status) + // { + // return sofaBedCollectionService.getWardStatusDetails(fromDate,toDate,ward,status); + // } + + + + @GetMapping("/getWardStatusReport") + public List> getWardStatusDetail(@RequestParam String ward,@RequestParam String status) + { + return sofaBedCollectionService.getWardStatusDetails(ward,status); + } +} diff --git a/src/main/java/com/gcc/commissionerreviewII/service/EnforcementPendencyService.java b/src/main/java/com/gcc/commissionerreviewII/service/EnforcementPendencyService.java new file mode 100644 index 0000000..b6bf991 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreviewII/service/EnforcementPendencyService.java @@ -0,0 +1,769 @@ +package com.gcc.commissionerreviewII.service; + +import java.util.List; +import java.util.Map; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; + +@Service +public class EnforcementPendencyService { + + @Autowired + private JdbcTemplate jdbcTemplate; + + @Autowired + public void setDataSource(@Qualifier("oracleDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + + public List> getzonewisependencydetails() { + String sql = + "WITH latest_form1 AS (\r\n" + + " SELECT \r\n" + + " form_parentid,\r\n" + + " MAX(id) AS max_id\r\n" + + " FROM \r\n" + + " EGBPA_FORM_RULES@erp\r\n" + + " WHERE \r\n" + + " formtype = 'Form 1'\r\n" + + " GROUP BY \r\n" + + " form_parentid\r\n" + + "),\r\n" + + "form1_data AS (\r\n" + + " SELECT \r\n" + + " a.form_parentid,\r\n" + + " a.approveddate AS form1_date,\r\n" + + " zone.name AS zone\r\n" + + " FROM \r\n" + + " EGBPA_FORM_RULES@erp a\r\n" + + " JOIN latest_form1 lf ON a.id = lf.max_id\r\n" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid\r\n" + + "),\r\n" + + "form2_data AS (\r\n" + + " SELECT \r\n" + + " form_parentid,\r\n" + + " MIN(approveddate) AS form2_date\r\n" + + " FROM \r\n" + + " EGBPA_FORM_RULES@erp\r\n" + + " WHERE \r\n" + + " formtype = 'Form 2'\r\n" + + " GROUP BY \r\n" + + " form_parentid\r\n" + + ")\r\n" + + "SELECT \r\n" + + " f1.zone,\r\n" + + " \r\n" + + " COUNT(CASE \r\n" + + " WHEN f2.form2_date IS NULL AND f1.form1_date <= SYSDATE - 7 \r\n" + + " THEN 1 \r\n" + + " END) AS \"Form 2 Not Initiated\",\r\n" + + " \r\n" + + " COUNT(CASE \r\n" + + " WHEN f2.form2_date is not null and f2.form2_date > f1.form1_date + INTERVAL '7' DAY \r\n" + + " THEN 1 \r\n" + + " END) AS \"Form 2 Initiated After 7 Days\",\r\n" + + " \r\n" + + " COUNT(CASE \r\n" + + " WHEN f2.form2_date is not null and f2.form2_date <= f1.form1_date + INTERVAL '7' DAY \r\n" + + " THEN 1 \r\n" + + " END) AS \"Form 2 Initiated Within 7 Days\"\r\n" + + "\r\n" + + "FROM \r\n" + + " form1_data f1\r\n" + + "LEFT JOIN \r\n" + + " form2_data f2 ON f1.form_parentid = f2.form_parentid\r\n" + + "GROUP BY \r\n" + + " f1.zone\r\n" + + "ORDER BY \r\n" + + " f1.zone"; + + return jdbcTemplate.queryForList(sql); + } + + + + public List> getwardwisependencydetails(String zone) { + System.out.println("openZoneModal.."+zone); + String sql = + "WITH latest_form1 AS (\r\n" + + " SELECT \r\n" + + " form_parentid,\r\n" + + " MAX(id) AS max_id\r\n" + + " FROM \r\n" + + " EGBPA_FORM_RULES@erp\r\n" + + " WHERE \r\n" + + " formtype = 'Form 1'\r\n" + + " GROUP BY \r\n" + + " form_parentid\r\n" + + "),\r\n" + + "form1_data AS (\r\n" + + " SELECT \r\n" + + " a.form_parentid,\r\n" + + " a.approveddate AS form1_date,\r\n" + + " zone.name AS zone,\r\n" + + " ward.name AS ward\r\n" + + " FROM \r\n" + + " EGBPA_FORM_RULES@erp a\r\n" + + " JOIN latest_form1 lf ON a.id = lf.max_id\r\n" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid\r\n" + + " JOIN eg_boundary@erp ward ON ward.id_bndry = a.wardid\r\n" + + " WHERE zone.name = ? \r\n" + + "),\r\n" + + "form2_data AS (\r\n" + + " SELECT \r\n" + + " form_parentid,\r\n" + + " MIN(approveddate) AS form2_date\r\n" + + " FROM \r\n" + + " EGBPA_FORM_RULES@erp\r\n" + + " WHERE \r\n" + + " formtype = 'Form 2'\r\n" + + " GROUP BY \r\n" + + " form_parentid\r\n" + + ")\r\n" + + "SELECT \r\n" + + " f1.ward,\r\n" + + " \r\n" + + " COUNT(CASE \r\n" + + " WHEN f2.form2_date IS NULL AND f1.form1_date <= SYSDATE - 7 \r\n" + + " THEN 1 \r\n" + + " END) AS \"Form 2 Not Initiated\",\r\n" + + " \r\n" + + " COUNT(CASE \r\n" + + " WHEN f2.form2_date > f1.form1_date + INTERVAL '7' DAY \r\n" + + " THEN 1 \r\n" + + " END) AS \"Form 2 Initiated After 7 Days\",\r\n" + + " \r\n" + + " COUNT(CASE \r\n" + + " WHEN f2.form2_date <= f1.form1_date + INTERVAL '7' DAY \r\n" + + " THEN 1 \r\n" + + " END) AS \"Form 2 Initiated Within 7 Days\"\r\n" + + "\r\n" + + "FROM \r\n" + + " form1_data f1\r\n" + + "LEFT JOIN \r\n" + + " form2_data f2 ON f1.form_parentid = f2.form_parentid\r\n" + + "GROUP BY \r\n" + + " f1.ward\r\n" + + "ORDER BY \r\n" + + " f1.ward"; + + return jdbcTemplate.queryForList(sql, zone ); + } + + + + public List> getpendencydetailreport(String zone,String status) { + String sql = "SELECT * FROM \r\n" + + "(SELECT \r\n" + + " zone.name AS zone,\r\n" + + " ward.name AS ward,\r\n" + + " addr.formid,\r\n" + + " addr.applicant_name,\r\n" + + " addr.area,\r\n" + + " addr.address,\r\n" + + " addr.pincode,\r\n" + + " CASE \r\n" + + " WHEN f2.form2_date IS NULL AND f1.form1_date <= SYSDATE - 7 THEN 'Form 2 Not Initiated'\r\n" + + " WHEN f2.form2_date IS NULL AND f1.form1_date > SYSDATE - 7 THEN 'Form 2 Not Yet Due'\r\n" + + " WHEN f2.form2_date > f1.form1_date + INTERVAL '7' DAY THEN 'Form 2 Initiated After 7 Days'\r\n" + + " WHEN f2.form2_date <= f1.form1_date + INTERVAL '7' DAY THEN 'Form 2 Initiated Within 7 Days'\r\n" + + " END AS form2_status\r\n" + + "FROM \r\n" + + " (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form1_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype = 'Form 1'\r\n" + + " GROUP BY form_parentid\r\n" + + " ) f1\r\n" + + "LEFT JOIN \r\n" + + " (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form2_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype = 'Form 2'\r\n" + + " GROUP BY form_parentid\r\n" + + " ) f2 ON f2.form_parentid = f1.form_parentid\r\n" + + "JOIN \r\n" + + " EGBPA_FORM_RULES@erp a ON a.form_parentid = f1.form_parentid\r\n" + + "JOIN \r\n" + + " eg_wf_states@erp b ON a.state_id = b.id\r\n" + + "JOIN \r\n" + + " eg_boundary@erp zone ON zone.id_bndry = a.zoneid\r\n" + + "JOIN \r\n" + + " eg_boundary@erp ward ON ward.id_bndry = a.wardid\r\n" + + "LEFT JOIN \r\n" + + " EGBPA_ENF_APP_ADDRESS@erp addr ON addr.formid = f1.form_parentid\r\n" + + "WHERE \r\n" + + " a.id = (\r\n" + + " SELECT MAX(id) \r\n" + + " FROM EGBPA_FORM_RULES@erp \r\n" + + " WHERE form_parentid = a.form_parentid AND formtype = 'Form 1'\r\n" + + " )" + + " AND a.formtype = 'Form 1' " + + " AND zone.name = ? " + + " ORDER BY CASE " + + " WHEN f2.form2_date IS NULL AND f1.form1_date <= SYSDATE - 7 THEN 1 " + + " WHEN f2.form2_date IS NULL AND f1.form1_date > SYSDATE - 7 THEN 2 " + + " WHEN f2.form2_date > f1.form1_date + INTERVAL '7' DAY THEN 3 " + + " WHEN f2.form2_date <= f1.form1_date + INTERVAL '7' DAY THEN 4 " + + " ELSE 5 " + + " END " + + ") " + + "WHERE FORM2_STATUS = ? "; + + return jdbcTemplate.queryForList(sql,zone,status); + } + + + public List> getpendencydetailreportbyward(String zone, String status, String ward) { + + String sql = "SELECT * FROM \r\n" + + "(SELECT \r\n" + + " zone.name AS zone,\r\n" + + " ward.name AS ward,\r\n" + + " addr.formid,\r\n" + + " addr.applicant_name,\r\n" + + " addr.area,\r\n" + + " addr.address,\r\n" + + " addr.pincode,\r\n" + + " CASE \r\n" + + " WHEN f2.form2_date IS NULL AND f1.form1_date <= SYSDATE - 7 THEN 'Form 2 Not Initiated'\r\n" + + " WHEN f2.form2_date IS NULL AND f1.form1_date > SYSDATE - 7 THEN 'Form 2 Not Yet Due'\r\n" + + " WHEN f2.form2_date > f1.form1_date + INTERVAL '7' DAY THEN 'Form 2 Initiated After 7 Days'\r\n" + + " WHEN f2.form2_date <= f1.form1_date + INTERVAL '7' DAY THEN 'Form 2 Initiated Within 7 Days'\r\n" + + " END AS form2_status\r\n" + + "FROM \r\n" + + " (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form1_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype = 'Form 1'\r\n" + + " GROUP BY form_parentid\r\n" + + " ) f1\r\n" + + "LEFT JOIN \r\n" + + " (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form2_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype = 'Form 2'\r\n" + + " GROUP BY form_parentid\r\n" + + " ) f2 ON f2.form_parentid = f1.form_parentid\r\n" + + "JOIN \r\n" + + " EGBPA_FORM_RULES@erp a ON a.form_parentid = f1.form_parentid\r\n" + + "JOIN \r\n" + + " eg_wf_states@erp b ON a.state_id = b.id\r\n" + + "JOIN \r\n" + + " eg_boundary@erp zone ON zone.id_bndry = a.zoneid\r\n" + + "JOIN \r\n" + + " eg_boundary@erp ward ON ward.id_bndry = a.wardid\r\n" + + "LEFT JOIN \r\n" + + " EGBPA_ENF_APP_ADDRESS@erp addr ON addr.formid = f1.form_parentid\r\n" + + "WHERE \r\n" + + " a.id = (\r\n" + + " SELECT MAX(id) \r\n" + + " FROM EGBPA_FORM_RULES@erp \r\n" + + " WHERE form_parentid = a.form_parentid AND formtype = 'Form 1'\r\n" + + " )" + + " AND a.formtype = 'Form 1' " + + " AND zone.name = ? " + + " AND ward.name = ? " + + " ORDER BY CASE " + + " WHEN f2.form2_date IS NULL AND f1.form1_date <= SYSDATE - 7 THEN 1 " + + " WHEN f2.form2_date IS NULL AND f1.form1_date > SYSDATE - 7 THEN 2 " + + " WHEN f2.form2_date > f1.form1_date + INTERVAL '7' DAY THEN 3 " + + " WHEN f2.form2_date <= f1.form1_date + INTERVAL '7' DAY THEN 4 " + + " ELSE 5 " + + " END " + + ") " + + "WHERE FORM2_STATUS = ? "; + + return jdbcTemplate.queryForList(sql,zone,ward,status); + } + + + ////////////////////////////////////////////////////////////////////// + + public List> getZoneWiseForm3PendencyDetails() { + + String sql = "WITH latest_form2 AS (\r\n" + + " SELECT \r\n" + + " form_parentid,\r\n" + + " MAX(id) AS max_id\r\n" + + " FROM \r\n" + + " EGBPA_FORM_RULES@erp\r\n" + + " WHERE \r\n" + + " formtype = 'Form 2'\r\n" + + " GROUP BY \r\n" + + " form_parentid\r\n" + + "),\r\n" + + "form2_data AS (\r\n" + + " SELECT \r\n" + + " a.form_parentid,\r\n" + + " a.approveddate AS form2_date,\r\n" + + " zone.name AS zone\r\n" + + " FROM \r\n" + + " EGBPA_FORM_RULES@erp a\r\n" + + " JOIN latest_form2 lf ON a.id = lf.max_id\r\n" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid\r\n" + + "),\r\n" + + "form3_4_data AS (\r\n" + + " SELECT \r\n" + + " form_parentid,\r\n" + + " MIN(approveddate) AS form3_4_date\r\n" + + " FROM \r\n" + + " EGBPA_FORM_RULES@erp\r\n" + + " WHERE \r\n" + + " formtype IN ('Form 3', 'Form 4')\r\n" + + " GROUP BY \r\n" + + " form_parentid\r\n" + + ")\r\n" + + "\r\n" + + "SELECT \r\n" + + " f2.zone,\r\n" + + " \r\n" + + " COUNT(CASE \r\n" + + " WHEN f34.form3_4_date IS NULL AND f2.form2_date <= SYSDATE - 15 \r\n" + + " THEN 1 \r\n" + + " END) AS \"Not Initiated\",\r\n" + + " \r\n" + + " COUNT(CASE \r\n" + + " WHEN f34.form3_4_date > f2.form2_date + INTERVAL '15' DAY \r\n" + + " THEN 1 \r\n" + + " END) AS \"After 15 Days\",\r\n" + + " \r\n" + + " COUNT(CASE \r\n" + + " WHEN f34.form3_4_date <= f2.form2_date + INTERVAL '15' DAY \r\n" + + " THEN 1 \r\n" + + " END) AS \"Within 15 Days\"\r\n" + + "\r\n" + + "FROM \r\n" + + " form2_data f2\r\n" + + "LEFT JOIN \r\n" + + " form3_4_data f34 ON f2.form_parentid = f34.form_parentid\r\n" + + "GROUP BY \r\n" + + " f2.zone\r\n" + + "ORDER BY \r\n" + + " f2.zone"; + + + return jdbcTemplate.queryForList(sql); + } + + + public List> getWardWiseForm3PendencyDetails(String zone) { + String sql="WITH latest_form2 AS (\r\n" + + " SELECT \r\n" + + " form_parentid,\r\n" + + " MAX(id) AS max_id\r\n" + + " FROM \r\n" + + " EGBPA_FORM_RULES@erp\r\n" + + " WHERE \r\n" + + " formtype = 'Form 2'\r\n" + + " GROUP BY \r\n" + + " form_parentid\r\n" + + "),\r\n" + + "form2_data AS (\r\n" + + " SELECT \r\n" + + " a.form_parentid,\r\n" + + " a.approveddate AS form2_date,\r\n" + + " zone.name AS zone,\r\n" + + " ward.name AS ward\r\n" + + " FROM \r\n" + + " EGBPA_FORM_RULES@erp a\r\n" + + " JOIN latest_form2 lf ON a.id = lf.max_id\r\n" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid\r\n" + + " JOIN eg_boundary@erp ward ON ward.id_bndry = a.wardid\r\n" + + "),\r\n" + + "form3_4_data AS (\r\n" + + " SELECT \r\n" + + " form_parentid,\r\n" + + " MIN(approveddate) AS form3_4_date\r\n" + + " FROM \r\n" + + " EGBPA_FORM_RULES@erp\r\n" + + " WHERE \r\n" + + " formtype IN ('Form 3', 'Form 4')\r\n" + + " GROUP BY \r\n" + + " form_parentid\r\n" + + ")\r\n" + + "\r\n" + + "SELECT \r\n" + + " f2.zone,\r\n" + + " f2.ward,\r\n" + + " \r\n" + + " COUNT(CASE \r\n" + + " WHEN f34.form3_4_date IS NULL AND f2.form2_date <= SYSDATE - 15 \r\n" + + " THEN 1 \r\n" + + " END) AS \"Not Initiated\",\r\n" + + " \r\n" + + " COUNT(CASE \r\n" + + " WHEN f34.form3_4_date > f2.form2_date + INTERVAL '15' DAY \r\n" + + " THEN 1 \r\n" + + " END) AS \"After 15 Days\",\r\n" + + " \r\n" + + " COUNT(CASE \r\n" + + " WHEN f34.form3_4_date <= f2.form2_date + INTERVAL '15' DAY \r\n" + + " THEN 1 \r\n" + + " END) AS \"Within 15 Days\"\r\n" + + "\r\n" + + "FROM \r\n" + + " form2_data f2\r\n" + + "LEFT JOIN \r\n" + + " form3_4_data f34 ON f2.form_parentid = f34.form_parentid\r\n" + + "WHERE \r\n" + + " f2.zone = ? \r\n" + + "GROUP BY \r\n" + + " f2.zone, f2.ward\r\n" + + "ORDER BY \r\n" + + " f2.zone, f2.ward"; + + return jdbcTemplate.queryForList(sql,zone); + } + + + public List> getForm3PendencyDetailReport(String zone, String status) { + + String sql="SELECT * FROM \r\n" + + "(\r\n" + + " SELECT \r\n" + + " zone.name AS zone,\r\n" + + " ward.name AS ward,\r\n" + + " addr.formid,\r\n" + + " addr.applicant_name,\r\n" + + " addr.area,\r\n" + + " addr.address,\r\n" + + " addr.pincode,\r\n" + + " \r\n" + + " CASE \r\n" + + " WHEN f34.form3_4_date IS NULL AND f2.form2_date <= SYSDATE - 15 THEN 'Form 3/4 Not Initiated'\r\n" + + " WHEN f34.form3_4_date IS NULL AND f2.form2_date > SYSDATE - 15 THEN 'Form 3/4 Not Yet Due'\r\n" + + " WHEN f34.form3_4_date > f2.form2_date + INTERVAL '15' DAY THEN 'Form 3/4 Initiated After 15 Days'\r\n" + + " WHEN f34.form3_4_date <= f2.form2_date + INTERVAL '15' DAY THEN 'Form 3/4 Initiated Within 15 Days'\r\n" + + " ELSE 'Unknown Status'\r\n" + + " END AS form3_4_status\r\n" + + "\r\n" + + " FROM \r\n" + + " (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form2_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype = 'Form 2'\r\n" + + " GROUP BY form_parentid\r\n" + + " ) f2\r\n" + + " LEFT JOIN \r\n" + + " (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form3_4_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype IN ('Form 3', 'Form 4')\r\n" + + " GROUP BY form_parentid\r\n" + + " ) f34 ON f34.form_parentid = f2.form_parentid\r\n" + + "\r\n" + + " JOIN \r\n" + + " EGBPA_FORM_RULES@erp a ON a.form_parentid = f2.form_parentid\r\n" + + " JOIN \r\n" + + " eg_wf_states@erp b ON a.state_id = b.id\r\n" + + " JOIN \r\n" + + " eg_boundary@erp zone ON zone.id_bndry = a.zoneid\r\n" + + " JOIN \r\n" + + " eg_boundary@erp ward ON ward.id_bndry = a.wardid\r\n" + + " LEFT JOIN \r\n" + + " EGBPA_ENF_APP_ADDRESS@erp addr ON addr.formid = f2.form_parentid\r\n" + + "\r\n" + + " WHERE \r\n" + + " a.id = (\r\n" + + " SELECT MAX(id) \r\n" + + " FROM EGBPA_FORM_RULES@erp \r\n" + + " WHERE form_parentid = a.form_parentid AND formtype = 'Form 2'\r\n" + + " )\r\n" + + " AND a.formtype = 'Form 2'\r\n" + + " AND zone.name = ? -- Change to your required zone\r\n" + + "\r\n" + + " ORDER BY \r\n" + + " CASE \r\n" + + " WHEN f34.form3_4_date IS NULL AND f2.form2_date <= SYSDATE - 15 THEN 1\r\n" + + " WHEN f34.form3_4_date IS NULL AND f2.form2_date > SYSDATE - 15 THEN 2\r\n" + + " WHEN f34.form3_4_date > f2.form2_date + INTERVAL '15' DAY THEN 3\r\n" + + " WHEN f34.form3_4_date <= f2.form2_date + INTERVAL '15' DAY THEN 4\r\n" + + " ELSE 5\r\n" + + " END\r\n" + + ")\r\n" + + "WHERE form3_4_status = ? "; + + return jdbcTemplate.queryForList(sql,zone,status); + } + + + public List> getForm3PendencyDetailReportByWard(String zone, String status, String ward) { + + String sql="SELECT * FROM \r\n" + + "(\r\n" + + " SELECT \r\n" + + " zone.name AS zone,\r\n" + + " ward.name AS ward,\r\n" + + " addr.formid,\r\n" + + " addr.applicant_name,\r\n" + + " addr.area,\r\n" + + " addr.address,\r\n" + + " addr.pincode,\r\n" + + " \r\n" + + " CASE \r\n" + + " WHEN f34.form3_4_date IS NULL AND f2.form2_date <= SYSDATE - 15 THEN 'Form 3/4 Not Initiated'\r\n" + + " WHEN f34.form3_4_date IS NULL AND f2.form2_date > SYSDATE - 15 THEN 'Form 3/4 Not Yet Due'\r\n" + + " WHEN f34.form3_4_date > f2.form2_date + INTERVAL '15' DAY THEN 'Form 3/4 Initiated After 15 Days'\r\n" + + " WHEN f34.form3_4_date <= f2.form2_date + INTERVAL '15' DAY THEN 'Form 3/4 Initiated Within 15 Days'\r\n" + + " ELSE 'Unknown Status'\r\n" + + " END AS form3_4_status\r\n" + + "\r\n" + + " FROM \r\n" + + " (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form2_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype = 'Form 2'\r\n" + + " GROUP BY form_parentid\r\n" + + " ) f2\r\n" + + " LEFT JOIN \r\n" + + " (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form3_4_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype IN ('Form 3', 'Form 4')\r\n" + + " GROUP BY form_parentid\r\n" + + " ) f34 ON f34.form_parentid = f2.form_parentid\r\n" + + "\r\n" + + " JOIN \r\n" + + " EGBPA_FORM_RULES@erp a ON a.form_parentid = f2.form_parentid\r\n" + + " JOIN \r\n" + + " eg_wf_states@erp b ON a.state_id = b.id\r\n" + + " JOIN \r\n" + + " eg_boundary@erp zone ON zone.id_bndry = a.zoneid\r\n" + + " JOIN \r\n" + + " eg_boundary@erp ward ON ward.id_bndry = a.wardid\r\n" + + " LEFT JOIN \r\n" + + " EGBPA_ENF_APP_ADDRESS@erp addr ON addr.formid = f2.form_parentid\r\n" + + "\r\n" + + " WHERE \r\n" + + " a.id = (\r\n" + + " SELECT MAX(id) \r\n" + + " FROM EGBPA_FORM_RULES@erp \r\n" + + " WHERE form_parentid = a.form_parentid AND formtype = 'Form 2'\r\n" + + " )\r\n" + + " AND a.formtype = 'Form 2'\r\n" + + " AND zone.name = ? -- Change to your required zone\r\n" + + " AND ward.name = ? \r\n" + + "\r\n" + + " ORDER BY \r\n" + + " CASE \r\n" + + " WHEN f34.form3_4_date IS NULL AND f2.form2_date <= SYSDATE - 15 THEN 1\r\n" + + " WHEN f34.form3_4_date IS NULL AND f2.form2_date > SYSDATE - 15 THEN 2\r\n" + + " WHEN f34.form3_4_date > f2.form2_date + INTERVAL '15' DAY THEN 3\r\n" + + " WHEN f34.form3_4_date <= f2.form2_date + INTERVAL '15' DAY THEN 4\r\n" + + " ELSE 5\r\n" + + " END\r\n" + + ")\r\n" + + "WHERE form3_4_status = ?"; + + return jdbcTemplate.queryForList(sql,zone,ward,status); + } + + ////////////////////////////////////////////////////////////////////////////////// + + + public List> getZoneWiseForm7PendencyDetails() { + String sql = "WITH latest_form3_4 AS (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form3_4_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype IN ('Form 3', 'Form 4')\r\n" + + " GROUP BY form_parentid\r\n" + + "),\r\n" + + "latest_form7 AS (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form7_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype = 'Form 7'\r\n" + + " GROUP BY form_parentid\r\n" + + "),\r\n" + + "combined_data AS (\r\n" + + " SELECT\r\n" + + " f3_4.form_parentid,\r\n" + + " f3_4.form3_4_date,\r\n" + + " f7.form7_date\r\n" + + " FROM latest_form3_4 f3_4\r\n" + + " LEFT JOIN latest_form7 f7 ON f3_4.form_parentid = f7.form_parentid\r\n" + + "),\r\n" + + "zone_data AS (\r\n" + + " SELECT\r\n" + + " a.zoneid,\r\n" + + " zone.name AS zone,\r\n" + + " cd.form3_4_date,\r\n" + + " cd.form7_date\r\n" + + " FROM combined_data cd\r\n" + + " JOIN EGBPA_FORM_RULES@erp a ON a.form_parentid = cd.form_parentid AND a.formtype IN ('Form 3', 'Form 4')\r\n" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid\r\n" + + " WHERE a.id = (\r\n" + + " SELECT MAX(id) \r\n" + + " FROM EGBPA_FORM_RULES@erp \r\n" + + " WHERE form_parentid = a.form_parentid AND formtype IN ('Form 3', 'Form 4')\r\n" + + " )\r\n" + + ")\r\n" + + "SELECT\r\n" + + " zone,\r\n" + + " COUNT(CASE WHEN form7_date IS NULL AND form3_4_date <= SYSDATE - 30 THEN 1 END) AS \"F7 Not Initiated After 30 Days\",\r\n" + + " COUNT(CASE WHEN form7_date > form3_4_date + INTERVAL '30' DAY THEN 1 END) AS \"F7 Initiated After 30 Days\",\r\n" + + " COUNT(CASE WHEN form7_date IS NOT NULL AND form7_date <= form3_4_date + INTERVAL '30' DAY THEN 1 END) AS \"F7 Initiated Within 30 Days\"\r\n" + + "FROM zone_data\r\n" + + "GROUP BY zone\r\n" + + "ORDER BY zone"; + return jdbcTemplate.queryForList(sql); + } + + public List> getWardWiseForm7PendencyDetails(String zone) { + String sql = "WITH form3_4 AS (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form3_4_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype IN ('Form 3', 'Form 4')\r\n" + + " GROUP BY form_parentid\r\n" + + "),\r\n" + + "form7 AS (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form7_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype = 'Form 7'\r\n" + + " GROUP BY form_parentid\r\n" + + "),\r\n" + + "combined AS (\r\n" + + " SELECT\r\n" + + " f34.form_parentid,\r\n" + + " f34.form3_4_date,\r\n" + + " f7.form7_date\r\n" + + " FROM form3_4 f34\r\n" + + " LEFT JOIN form7 f7 ON f34.form_parentid = f7.form_parentid\r\n" + + "),\r\n" + + "ward_data AS (\r\n" + + " SELECT\r\n" + + " ward.name AS ward,\r\n" + + " zone.name AS zone,\r\n" + + " c.form3_4_date,\r\n" + + " c.form7_date\r\n" + + " FROM combined c\r\n" + + " JOIN EGBPA_FORM_RULES@erp a ON a.form_parentid = c.form_parentid\r\n" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid\r\n" + + " JOIN eg_boundary@erp ward ON ward.id_bndry = a.wardid\r\n" + + " WHERE a.id = (\r\n" + + " SELECT MAX(id) FROM EGBPA_FORM_RULES@erp \r\n" + + " WHERE form_parentid = a.form_parentid AND formtype IN ('Form 3', 'Form 4')\r\n" + + " )\r\n" + + " AND a.formtype IN ('Form 3', 'Form 4')\r\n" + + " AND zone.name = ? \r\n" + + ")\r\n" + + "SELECT\r\n" + + " ward,\r\n" + + " COUNT(CASE WHEN form7_date IS NULL AND form3_4_date <= SYSDATE - 30 THEN 1 END) AS \"F7 Not Initiated After 30 Days\",\r\n" + + " COUNT(CASE WHEN form7_date > form3_4_date + INTERVAL '30' DAY THEN 1 END) AS \"F7 Initiated After 30 Days\",\r\n" + + " COUNT(CASE WHEN form7_date IS NOT NULL AND form7_date <= form3_4_date + INTERVAL '30' DAY THEN 1 END) AS \"F7 Initiated Within 30 Days\"\r\n" + + "FROM ward_data\r\n" + + "GROUP BY ward\r\n" + + "ORDER BY ward"; + return jdbcTemplate.queryForList(sql, zone); + } + + public List> getForm7PendencyDetailReportByZone(String zone, String status) { + String sql = "SELECT *\r\n" + + "FROM (\r\n" + + " SELECT \r\n" + + " zone.name AS zone,\r\n" + + " ward.name AS ward,\r\n" + + " addr.formid,\r\n" + + " addr.applicant_name,\r\n" + + " addr.area,\r\n" + + " addr.address,\r\n" + + " addr.pincode,\r\n" + + " f34.form3_4_date,\r\n" + + " f7.form7_date,\r\n" + + " CASE \r\n" + + " WHEN f7.form7_date IS NULL AND f34.form3_4_date <= SYSDATE - 30 THEN 'Form 7 Not Initiated After 30 Days'\r\n" + + " WHEN f7.form7_date IS NULL AND f34.form3_4_date > SYSDATE - 30 THEN 'Form 7 Not Yet Due'\r\n" + + " WHEN f7.form7_date > f34.form3_4_date + INTERVAL '30' DAY THEN 'Form 7 Initiated After 30 Days'\r\n" + + " WHEN f7.form7_date <= f34.form3_4_date + INTERVAL '30' DAY THEN 'Form 7 Initiated Within 30 Days'\r\n" + + " ELSE 'Unknown'\r\n" + + " END AS form7_status\r\n" + + " FROM (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form3_4_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype IN ('Form 3', 'Form 4')\r\n" + + " GROUP BY form_parentid\r\n" + + " ) f34\r\n" + + " LEFT JOIN (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form7_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype = 'Form 7'\r\n" + + " GROUP BY form_parentid\r\n" + + " ) f7 ON f34.form_parentid = f7.form_parentid\r\n" + + " JOIN EGBPA_FORM_RULES@erp a ON a.form_parentid = f34.form_parentid\r\n" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid\r\n" + + " JOIN eg_boundary@erp ward ON ward.id_bndry = a.wardid\r\n" + + " LEFT JOIN EGBPA_ENF_APP_ADDRESS@erp addr ON addr.formid = f34.form_parentid\r\n" + + " WHERE a.id = (\r\n" + + " SELECT MAX(id)\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE form_parentid = a.form_parentid AND formtype IN ('Form 3', 'Form 4')\r\n" + + " )\r\n" + + " AND a.formtype IN ('Form 3', 'Form 4')" + + " AND zone.name = ? " + + " ) " + + "WHERE form7_status = ? "+ + " ORDER BY form7_status, form3_4_date" ; + return jdbcTemplate.queryForList(sql, zone, status); + } + + public List> getForm7PendencyDetailReportByWard(String zone, String status, String ward) { + String sql = "SELECT *\r\n" + + "FROM (\r\n" + + " SELECT \r\n" + + " zone.name AS zone,\r\n" + + " ward.name AS ward,\r\n" + + " addr.formid,\r\n" + + " addr.applicant_name,\r\n" + + " addr.area,\r\n" + + " addr.address,\r\n" + + " addr.pincode,\r\n" + + " f34.form3_4_date,\r\n" + + " f7.form7_date,\r\n" + + " CASE \r\n" + + " WHEN f7.form7_date IS NULL AND f34.form3_4_date <= SYSDATE - 30 THEN 'Form 7 Not Initiated After 30 Days'\r\n" + + " WHEN f7.form7_date IS NULL AND f34.form3_4_date > SYSDATE - 30 THEN 'Form 7 Not Yet Due'\r\n" + + " WHEN f7.form7_date > f34.form3_4_date + INTERVAL '30' DAY THEN 'Form 7 Initiated After 30 Days'\r\n" + + " WHEN f7.form7_date <= f34.form3_4_date + INTERVAL '30' DAY THEN 'Form 7 Initiated Within 30 Days'\r\n" + + " ELSE 'Unknown'\r\n" + + " END AS form7_status\r\n" + + " FROM (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form3_4_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype IN ('Form 3', 'Form 4')\r\n" + + " GROUP BY form_parentid\r\n" + + " ) f34\r\n" + + " LEFT JOIN (\r\n" + + " SELECT form_parentid, MIN(approveddate) AS form7_date\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE formtype = 'Form 7'\r\n" + + " GROUP BY form_parentid\r\n" + + " ) f7 ON f34.form_parentid = f7.form_parentid\r\n" + + " JOIN EGBPA_FORM_RULES@erp a ON a.form_parentid = f34.form_parentid\r\n" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid\r\n" + + " JOIN eg_boundary@erp ward ON ward.id_bndry = a.wardid\r\n" + + " LEFT JOIN EGBPA_ENF_APP_ADDRESS@erp addr ON addr.formid = f34.form_parentid\r\n" + + " WHERE a.id = (\r\n" + + " SELECT MAX(id)\r\n" + + " FROM EGBPA_FORM_RULES@erp\r\n" + + " WHERE form_parentid = a.form_parentid AND formtype IN ('Form 3', 'Form 4')\r\n" + + " )\r\n" + + " AND a.formtype IN ('Form 3', 'Form 4')" + + " AND zone.name = ? " + + " AND ward.name = ? " + + ") " + + "WHERE form7_status = ? "+ + "ORDER BY form7_status, form3_4_date "; + ; + return jdbcTemplate.queryForList(sql, zone, ward, status); + } + + + +} diff --git a/src/main/java/com/gcc/commissionerreviewII/service/EnforcementService.java b/src/main/java/com/gcc/commissionerreviewII/service/EnforcementService.java new file mode 100644 index 0000000..dc8ca06 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreviewII/service/EnforcementService.java @@ -0,0 +1,304 @@ +package com.gcc.commissionerreviewII.service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.ResponseEntity; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; + +@Service +public class EnforcementService { + + @Autowired + private JdbcTemplate jdbcTemplate; + + @Autowired + public void setDataSource(@Qualifier("oracleDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + public List> getzonewisedetails() + { + + String sql="select zone.name zone,\r\n" + + "sum(case when formtype='Form 1' then 1 else 0 end) form1_recieved,\r\n" + + "sum(case when formtype='Form 1' and b.value!='END' then 1 else 0 end) form1_inprogress,\r\n" + + "sum(case when formtype='Form 1' and b.value='END' then 1 else 0 end) form1_completed,\r\n" + + "sum(case when formtype='Form 2' then 1 else 0 end) form2_recieved,\r\n" + + "sum(case when formtype='Form 2' and b.value!='END' then 1 else 0 end) form2_inprogress,\r\n" + + "sum(case when formtype='Form 2' and b.value='END' then 1 else 0 end) form2_completed,\r\n" + + "sum(case when formtype='Form 3' then 1 else 0 end) form3_recieved,\r\n" + + "sum(case when formtype='Form 3' and b.value!='END' then 1 else 0 end) form3_inprogress,\r\n" + + "sum(case when formtype='Form 3' and b.value='END' then 1 else 0 end) form3_completed,\r\n" + + "sum(case when formtype='Form 4' then 1 else 0 end) form4_recieved,\r\n" + + "sum(case when formtype='Form 4' and b.value!='END' then 1 else 0 end) form4_inprogress,\r\n" + + "sum(case when formtype='Form 4' and b.value='END' then 1 else 0 end) form4_completed,\r\n" + + "sum(case when formtype='Form 5' then 1 else 0 end) form5_recieved,\r\n" + + "sum(case when formtype='Form 5' and b.value!='END' then 1 else 0 end) form5_inprogress,\r\n" + + "sum(case when formtype='Form 5' and b.value='END' then 1 else 0 end) form5_completed,\r\n" + + "sum(case when formtype='Form 6' then 1 else 0 end) form6_recieved,\r\n" + + "sum(case when formtype='Form 6' and b.value!='END' then 1 else 0 end) form6_inprogress,\r\n" + + "sum(case when formtype='Form 6' and b.value='END' then 1 else 0 end) form6_completed,\r\n" + + "sum(case when formtype='Form 7' then 1 else 0 end) form7_recieved,\r\n" + + "sum(case when formtype='Form 7' and b.value!='END' then 1 else 0 end) form7_inprogress,\r\n" + + "sum(case when formtype='Form 7' and b.value='END' then 1 else 0 end) form7_completed\r\n" + + "from EGBPA_FORM_RULES@erp a,eg_wf_states@erp b,eg_boundary@erp zone\r\n" + + "where a.state_id=b.id and zone.id_bndry=a.zoneid and\r\n" + + " a.id = (SELECT MAX(id) FROM EGBPA_FORM_RULES@erp WHERE form_parentid = a.form_parentid)\r\n" + + "group by zone.name order by name"; + + + + return jdbcTemplate.queryForList(sql); + + } + + + public List> getwardwisedetails(String zone) + { + String sql="select zone.name zone,ward.name ward,\r\n" + + "sum(case when formtype='Form 1' then 1 else 0 end) form1_recieved,\r\n" + + "sum(case when formtype='Form 1' and b.value!='END' then 1 else 0 end) form1_inprogress,\r\n" + + "sum(case when formtype='Form 1' and b.value='END' then 1 else 0 end) form1_completed,\r\n" + + "sum(case when formtype='Form 2' then 1 else 0 end) form2_recieved,\r\n" + + "sum(case when formtype='Form 2' and b.value!='END' then 1 else 0 end) form2_inprogress,\r\n" + + "sum(case when formtype='Form 2' and b.value='END' then 1 else 0 end) form2_completed,\r\n" + + "sum(case when formtype='Form 3' then 1 else 0 end) form3_recieved,\r\n" + + "sum(case when formtype='Form 3' and b.value!='END' then 1 else 0 end) form3_inprogress,\r\n" + + "sum(case when formtype='Form 3' and b.value='END' then 1 else 0 end) form3_completed,\r\n" + + "sum(case when formtype='Form 4' then 1 else 0 end) form4_recieved,\r\n" + + "sum(case when formtype='Form 4' and b.value!='END' then 1 else 0 end) form4_inprogress,\r\n" + + "sum(case when formtype='Form 4' and b.value='END' then 1 else 0 end) form4_completed,\r\n" + + "sum(case when formtype='Form 5' then 1 else 0 end) form5_recieved,\r\n" + + "sum(case when formtype='Form 5' and b.value!='END' then 1 else 0 end) form5_inprogress,\r\n" + + "sum(case when formtype='Form 5' and b.value='END' then 1 else 0 end) form5_completed,\r\n" + + "sum(case when formtype='Form 6' then 1 else 0 end) form6_recieved,\r\n" + + "sum(case when formtype='Form 6' and b.value!='END' then 1 else 0 end) form6_inprogress,\r\n" + + "sum(case when formtype='Form 6' and b.value='END' then 1 else 0 end) form6_completed,\r\n" + + "sum(case when formtype='Form 7' then 1 else 0 end) form7_recieved,\r\n" + + "sum(case when formtype='Form 7' and b.value!='END' then 1 else 0 end) form7_inprogress,\r\n" + + "sum(case when formtype='Form 7' and b.value='END' then 1 else 0 end) form7_completed\r\n" + + "from EGBPA_FORM_RULES@erp a,eg_wf_states@erp b,eg_boundary@erp zone,eg_boundary@erp ward\r\n" + + "where a.state_id=b.id and zone.id_bndry=a.zoneid and ward.id_bndry=a.wardid and\r\n" + + " a.id = (SELECT MAX(id) FROM EGBPA_FORM_RULES@erp WHERE form_parentid = a.form_parentid) and zone.name=? \r\n" + + "group by zone.name,ward.name order by zone.name,ward.name"; + + return jdbcTemplate.queryForList(sql,zone); + } + + public List> getformdetailswithzone(String zone, String ward, String formtype, String status) { + + String sql=""; + List> result = new ArrayList<>();; + + if("Received".equalsIgnoreCase(status)) { + sql="SELECT " + + " zone.name zone,ward.name ward," + + " addr.applicant_name," + + " addr.formid," + + " addr.area," + + " addr.address," + + " addr.pincode " + + "FROM" + + " EGBPA_FORM_RULES@erp a" + + " JOIN eg_wf_states@erp b ON a.state_id = b.id" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid" + + " JOIN eg_boundary@erp ward ON ward.id_bndry = a.wardid" + + " LEFT JOIN EGBPA_ENF_APP_ADDRESS@erp addr ON addr.formid = a.form_parentid " + + "WHERE" + + " a.id = (" + + " SELECT MAX(id)" + + " FROM EGBPA_FORM_RULES@erp" + + " WHERE form_parentid = a.form_parentid" + + " )" + + " AND a.formtype = ? " + + " AND zone.name = ? " + + " AND ward.name = ? "; + + result = jdbcTemplate.queryForList(sql, formtype, zone, ward); + } + + if("Inprogress".equalsIgnoreCase(status)) { + + sql="SELECT" + + " zone.name zone,ward.name ward," + + " addr.applicant_name," + + " addr.formid," + + " addr.area," + + " addr.address," + + " addr.pincode " + + "FROM" + + " EGBPA_FORM_RULES@erp a" + + " JOIN eg_wf_states@erp b ON a.state_id = b.id" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid" + + " JOIN eg_boundary@erp ward ON ward.id_bndry = a.wardid" + + " LEFT JOIN EGBPA_ENF_APP_ADDRESS@erp addr ON addr.formid = a.form_parentid" + + " WHERE" + + " a.id = (" + + " SELECT MAX(id)" + + " FROM EGBPA_FORM_RULES@erp" + + " WHERE form_parentid = a.form_parentid" + + " )" + + " AND a.formtype = ?" + + " AND zone.name = ?" + + " AND ward.name = ?" + + " and formtype=? and b.value!='END'"; + + result=jdbcTemplate.queryForList(sql,formtype,zone,ward,formtype); + } + + if("Completed".equalsIgnoreCase(status)) { + + sql="SELECT" + + " zone.name zone,ward.name ward," + + " addr.applicant_name," + + " addr.formid," + + " addr.area," + + " addr.address," + + " addr.pincode " + + "FROM " + + " EGBPA_FORM_RULES@erp a" + + " JOIN eg_wf_states@erp b ON a.state_id = b.id" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid" + + " JOIN eg_boundary@erp ward ON ward.id_bndry = a.wardid" + + " LEFT JOIN EGBPA_ENF_APP_ADDRESS@erp addr ON addr.formid = a.form_parentid " + + "WHERE" + + " a.id = (" + + " SELECT MAX(id)" + + " FROM EGBPA_FORM_RULES@erp" + + " WHERE form_parentid = a.form_parentid" + + " )" + + " AND a.formtype = ? " + + " AND zone.name = ? " + + " AND ward.name = ? " + + " and formtype=? and b.value='END'"; + + result=jdbcTemplate.queryForList(sql,formtype,zone,ward,formtype); + } + + return result; + } + + public List> getformiddetails(String formid) { + + String sql="SELECT" + + " m.ENCLOSEMENTNAME," + + " TO_CHAR(f.CREATEDDATE, 'YYYY/MM/DD HH24:MI') || ' 00:00:00.0' AS cdate," + + " 'https://erp.chennaicorporation.gov.in/bpa/search/registrationForm!viewFile.action?formParentId=' || d.FORMID ||" + + " CHR(38) || 'fileName=' || d.DOCNAME ||" + + " CHR(38) || 'contentType=' || d.DOCTYPE ||" + + " CHR(38) || 'fileCreatedDate=' || TO_CHAR(f.CREATEDDATE, 'YYYY-MM-DD') || ' 00:00:00.0' AS fileUrl" + + " FROM" + + " EGBPA_FORM_ENCLOSEMENT_DET@erp d " + + "INNER JOIN " + + " EGBPA_FORM_ENCLOSEMENT@erp m ON d.TYPEID = m.ID " + + "INNER JOIN" + + " EGBPA_FORM_RULES@erp f ON f.ID = d.APPID " + + "WHERE" + + " d.FORMID = ? " + + "ORDER BY" + + " m.FORMTYPE DESC"; + + return jdbcTemplate.queryForList(sql,formid); + } + + public List> getformdetailswithoutward(String zone, String formtype, String status) { + String sql=""; + List> result = new ArrayList<>();; + + if("Received".equalsIgnoreCase(status)) { + sql="SELECT " + + " zone.name zone,ward.name ward," + + " addr.applicant_name," + + " addr.formid," + + " addr.area," + + " addr.address," + + " addr.pincode " + + "FROM" + + " EGBPA_FORM_RULES@erp a" + + " JOIN eg_wf_states@erp b ON a.state_id = b.id" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid" + + " JOIN eg_boundary@erp ward ON ward.id_bndry = a.wardid" + + " LEFT JOIN EGBPA_ENF_APP_ADDRESS@erp addr ON addr.formid = a.form_parentid " + + "WHERE" + + " a.id = (" + + " SELECT MAX(id)" + + " FROM EGBPA_FORM_RULES@erp" + + " WHERE form_parentid = a.form_parentid" + + " )" + + " AND a.formtype = ? " + + " AND zone.name = ? " + +" ORDER BY ward.name"; + + result = jdbcTemplate.queryForList(sql, formtype, zone); + } + + if("Inprogress".equalsIgnoreCase(status)) { + + sql="SELECT" + + " zone.name zone,ward.name ward," + + " addr.applicant_name," + + " addr.formid," + + " addr.area," + + " addr.address," + + " addr.pincode, " + + "FROM" + + " EGBPA_FORM_RULES@erp a" + + " JOIN eg_wf_states@erp b ON a.state_id = b.id" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid" + + " JOIN eg_boundary@erp ward ON ward.id_bndry = a.wardid" + + " LEFT JOIN EGBPA_ENF_APP_ADDRESS@erp addr ON addr.formid = a.form_parentid" + + " WHERE" + + " a.id = (" + + " SELECT MAX(id)" + + " FROM EGBPA_FORM_RULES@erp" + + " WHERE form_parentid = a.form_parentid" + + " )" + + " AND a.formtype = ?" + + " AND zone.name = ?" + + " and formtype=? and b.value!='END'" + +" ORDER BY ward.name"; + + result=jdbcTemplate.queryForList(sql,formtype,zone,formtype); + } + + if("Completed".equalsIgnoreCase(status)) { + + sql="SELECT" + + " zone.name zone,ward.name ward," + + " addr.applicant_name," + + " addr.formid," + + " addr.area," + + " addr.address," + + " addr.pincode, " + + "'https://erp.chennaicorporation.gov.in/bpa/search/registrationForm!printRule.action?appId='||id as notice_url" + + " FROM " + + " EGBPA_FORM_RULES@erp a" + + " JOIN eg_wf_states@erp b ON a.state_id = b.id" + + " JOIN eg_boundary@erp zone ON zone.id_bndry = a.zoneid" + + " JOIN eg_boundary@erp ward ON ward.id_bndry = a.wardid" + + " LEFT JOIN EGBPA_ENF_APP_ADDRESS@erp addr ON addr.formid = a.form_parentid " + + "WHERE" + + " a.id = (" + + " SELECT MAX(id)" + + " FROM EGBPA_FORM_RULES@erp" + + " WHERE form_parentid = a.form_parentid" + + " )" + + " AND a.formtype = ? " + + " AND zone.name = ? " + + " and formtype=? and b.value='END'" + +" ORDER BY ward.name"; + + result=jdbcTemplate.queryForList(sql,formtype,zone,formtype); + } + + return result; + } + +} diff --git a/src/main/java/com/gcc/commissionerreviewII/service/SofaBedCollectionService.java b/src/main/java/com/gcc/commissionerreviewII/service/SofaBedCollectionService.java new file mode 100644 index 0000000..efe2079 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreviewII/service/SofaBedCollectionService.java @@ -0,0 +1,621 @@ +package com.gcc.commissionerreviewII.service; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.http.ResponseEntity; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.client.RestTemplate; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Service +public class SofaBedCollectionService { + + @Autowired + @Qualifier("jdbcDomesticWasteTemplate") + private JdbcTemplate jdbcDomesticWasteTemplate; + + + public Map getzonewisedetails() { + + Map response = new HashMap<>(); + + try { + + // Formatter for output + DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + // Fixed start date + String formattedStartDate = "03-10-2025"; + + // Current date as end date + String formattedEndDate = LocalDate.now().format(outputFormat); + + String apiUrl ="https://gccservices.in/gccofficialapp/api/domesticwaste/getZoneReport?fromDate="+formattedStartDate+"&toDate="+formattedEndDate; + + System.out.println("apiUrl=" + apiUrl); + + // Call the external API + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity apiResponse = restTemplate.getForEntity(apiUrl, String.class); + + if (apiResponse.getStatusCode().is2xxSuccessful() && apiResponse.getBody() != null) { + + ObjectMapper mapper = new ObjectMapper(); + + // Parse full JSON + JsonNode rootNode = mapper.readTree(apiResponse.getBody()); + + if (rootNode.isArray() && rootNode.size() > 0) { + JsonNode firstObject = rootNode.get(0); // Get first object + JsonNode reportNode = firstObject.path("data"); + + if (reportNode.isMissingNode() || !reportNode.isArray() || reportNode.size() == 0) { + response.put("status", "nodata"); + response.put("data", Collections.emptyList()); + } else { + // Convert JSON array → List> + List> reportList = mapper.convertValue( + reportNode, + new TypeReference>>() {} + ); + + response.put("status", "success"); + response.put("data", reportList); + + } + + } else { + response.put("status", "nodata"); + response.put("data", Collections.emptyList()); + } + } else { + response.put("status", "nodata"); + response.put("data", Collections.emptyList()); + + } + + } catch (Exception e) { + e.printStackTrace(); + response.put("status", "error"); + response.put("message", e.getMessage()); + } + + return response; + } + + + + + + public Map getwarddetails(String zone) { + + Map response = new HashMap<>(); + + try { + + // Formatter for output + DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + // Fixed start date + String formattedStartDate = "03-10-2025"; + + // Current date as end date + String formattedEndDate = LocalDate.now().format(outputFormat); + + String apiUrl ="https://gccservices.in/gccofficialapp/api/domesticwaste/getWardReport?fromDate="+formattedStartDate+"&toDate="+formattedEndDate+"&zone="+zone; + + System.out.println("apiUrl=" + apiUrl); + + // Call the external API + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity apiResponse = restTemplate.getForEntity(apiUrl, String.class); + + if (apiResponse.getStatusCode().is2xxSuccessful() && apiResponse.getBody() != null) { + + ObjectMapper mapper = new ObjectMapper(); + + // Parse full JSON + JsonNode rootNode = mapper.readTree(apiResponse.getBody()); + + if (rootNode.isArray() && rootNode.size() > 0) { + JsonNode firstObject = rootNode.get(0); // Get first object + JsonNode reportNode = firstObject.path("data"); + + if (reportNode.isMissingNode() || !reportNode.isArray() || reportNode.size() == 0) { + response.put("status", "nodata"); + response.put("data", Collections.emptyList()); + } else { + // Convert JSON array → List> + List> reportList = mapper.convertValue( + reportNode, + new TypeReference>>() {} + ); + + response.put("status", "success"); + response.put("data", reportList); + + } + + } else { + response.put("status", "nodata"); + response.put("data", Collections.emptyList()); + } + } else { + response.put("status", "nodata"); + response.put("data", Collections.emptyList()); + + } + + } catch (Exception e) { + e.printStackTrace(); + response.put("status", "error"); + response.put("message", e.getMessage()); + } + + return response; + + } + + public Map getwardstatusdetails(String ward, String status) { + + Map response = new HashMap<>(); + + try { + + // Formatter for output + DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + // Fixed start date + String formattedStartDate = "03-10-2025"; + + // Current date as end date + String formattedEndDate = LocalDate.now().format(outputFormat); + + String apiUrl="https://gccservices.in/gccofficialapp/api/domesticwaste/getWardStatusDetails?fromDate="+formattedStartDate+"&toDate="+formattedEndDate+"&ward="+ward+"&status="+status; + + System.out.println("apiUrl=" + apiUrl); + + // Call the external API + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity apiResponse = restTemplate.getForEntity(apiUrl, String.class); + + if (apiResponse.getStatusCode().is2xxSuccessful() && apiResponse.getBody() != null) { + + ObjectMapper mapper = new ObjectMapper(); + + // Parse full JSON + JsonNode rootNode = mapper.readTree(apiResponse.getBody()); + + if (rootNode.isArray() && rootNode.size() > 0) { + JsonNode firstObject = rootNode.get(0); // Get first object + JsonNode reportNode = firstObject.path("data"); + + if (reportNode.isMissingNode() || !reportNode.isArray() || reportNode.size() == 0) { + response.put("status", "nodata"); + response.put("data", Collections.emptyList()); + } else { + // Convert JSON array → List> + List> reportList = mapper.convertValue( + reportNode, + new TypeReference>>() {} + ); + + response.put("status", "success"); + response.put("data", reportList); + + } + + } else { + response.put("status", "nodata"); + response.put("data", Collections.emptyList()); + } + } else { + response.put("status", "nodata"); + response.put("data", Collections.emptyList()); + + } + + } catch (Exception e) { + e.printStackTrace(); + response.put("status", "error"); + response.put("message", e.getMessage()); + } + + return response; + } + + + + + //yogi + + + @Transactional(readOnly = true) +public List> getZoneReport() { + + String sql = """ + WITH date_limits AS ( + SELECT + DATE_SUB(CURDATE(), INTERVAL (DAYOFWEEK(CURDATE()) - 1) DAY) AS week_start, + DATE_ADD(DATE_SUB(CURDATE(), INTERVAL (DAYOFWEEK(CURDATE()) - 1) DAY), INTERVAL 7 DAY) AS week_end + ) + SELECT + COALESCE(ur.zone, 'TOTAL') AS zone, + COUNT(*) AS total_request, + + -- Requests created this week + SUM(CASE WHEN ur.cdate >= d.week_start AND ur.cdate < d.week_end THEN 1 ELSE 0 END) AS this_week_requests, + + -- Older requests + SUM(CASE WHEN ur.cdate < d.week_start THEN 1 ELSE 0 END) AS older_requests, + + -- Status-based counts + SUM(CASE WHEN ur.status = 2 THEN 1 ELSE 0 END) AS completed, + SUM(CASE WHEN ur.status = 4 THEN 1 ELSE 0 END) AS user_cancel, + SUM(CASE WHEN ur.status = 5 THEN 1 ELSE 0 END) AS officer_cancel, + + -- Pending = older_requests - (completed + cancels) + ( + SUM(CASE WHEN ur.cdate < d.week_start THEN 1 ELSE 0 END) + - SUM(CASE WHEN ur.status IN (2,4,5) THEN 1 ELSE 0 END) + ) AS pending + + FROM + user_request_table ur + CROSS JOIN date_limits d + WHERE + ur.is_active = 1 + AND ur.is_delete = 0 + GROUP BY + ur.zone WITH ROLLUP + ORDER BY + CASE WHEN ur.zone IS NULL THEN 999 ELSE ur.zone END; + """; + + List> reportList = jdbcDomesticWasteTemplate.queryForList(sql); + + Map response = new LinkedHashMap<>(); + response.put("status", "Success"); + response.put("message", "Zone-wise Report (All Dates)"); + response.put("data", reportList); + + return Collections.singletonList(response); +} + + + +// @Transactional +// public List> getZoneReport(String fromDate, String toDate) { + +// String sql = """ +// WITH date_limits AS ( +// SELECT +// STR_TO_DATE(?, '%d-%m-%Y') AS start_date, +// STR_TO_DATE(?, '%d-%m-%Y') AS end_date, +// DATE_SUB(CURDATE(), INTERVAL (DAYOFWEEK(CURDATE()) - 1) DAY) AS week_start, +// DATE_ADD(DATE_SUB(CURDATE(), INTERVAL (DAYOFWEEK(CURDATE()) - 1) DAY), INTERVAL 7 DAY) AS week_end +// ) +// SELECT +// COALESCE(ur.zone, 'TOTAL') AS zone, +// COUNT(*) AS total_request, + +// -- Requests created this week +// SUM(CASE WHEN ur.cdate >= d.week_start AND ur.cdate < d.week_end THEN 1 ELSE 0 END) AS this_week_requests, + +// -- Older requests +// SUM(CASE WHEN ur.cdate < d.week_start THEN 1 ELSE 0 END) AS older_requests, + +// -- Status-based counts +// SUM(CASE WHEN ur.status = 2 THEN 1 ELSE 0 END) AS completed, +// SUM(CASE WHEN ur.status = 4 THEN 1 ELSE 0 END) AS user_cancel, +// SUM(CASE WHEN ur.status = 5 THEN 1 ELSE 0 END) AS officer_cancel, + +// -- Pending = older_requests - (completed + cancels) +// ( +// SUM(CASE WHEN ur.cdate < d.week_start THEN 1 ELSE 0 END) +// - SUM(CASE WHEN ur.status IN (2,4,5) THEN 1 ELSE 0 END) +// ) AS pending + +// FROM +// user_request_table ur +// CROSS JOIN date_limits d +// WHERE +// ur.is_active = 1 +// AND ur.is_delete = 0 +// AND ur.cdate BETWEEN d.start_date AND d.end_date +// GROUP BY +// ur.zone WITH ROLLUP +// ORDER BY +// CASE WHEN ur.zone IS NULL THEN 999 ELSE ur.zone END; +// """; + +// List> reportList = jdbcDomesticWasteTemplate.queryForList(sql, fromDate, toDate); + +// Map response = new LinkedHashMap<>(); +// response.put("status", "Success"); +// response.put("message", "Zone-wise Report"); +// response.put("data", reportList); + +// return Collections.singletonList(response); +// } + + + + // @Transactional(readOnly = true) + // public List> getWardReport(String fromDate, String toDate, String zone) { + // String sql = + // "(" + // + " SELECT " + // + " ur.division AS division, " + // + " COUNT(*) AS total_request, " + // + " SUM(CASE WHEN ur.status = 1 THEN 1 ELSE 0 END) AS open, " + // + " SUM(CASE WHEN ur.status = 2 THEN 1 ELSE 0 END) AS completed, " + // + " SUM(CASE WHEN ur.status = 3 THEN 1 ELSE 0 END) AS pending, " + // + " SUM(CASE WHEN ur.status = 4 THEN 1 ELSE 0 END) AS user_cancel, " + // + " SUM(CASE WHEN ur.status = 5 THEN 1 ELSE 0 END) AS officer_cancel " + // + " FROM user_request_table ur " + // + " WHERE ur.is_active = 1 AND ur.is_delete = 0 AND ur.zone = ? " + // + " GROUP BY ur.division " + // + ") " + // + "UNION ALL " + // + "(" + // + " SELECT " + // + " 'TOTAL' AS division, " + // + " COUNT(*) AS total_request, " + // + " SUM(CASE WHEN ur.status = 1 THEN 1 ELSE 0 END) AS open, " + // + " SUM(CASE WHEN ur.status = 2 THEN 1 ELSE 0 END) AS completed, " + // + " SUM(CASE WHEN ur.status = 3 THEN 1 ELSE 0 END) AS pending, " + // + " SUM(CASE WHEN ur.status = 4 THEN 1 ELSE 0 END) AS user_cancel, " + // + " SUM(CASE WHEN ur.status = 5 THEN 1 ELSE 0 END) AS officer_cancel " + // + " FROM user_request_table ur " + // + " WHERE ur.is_active = 1 AND ur.is_delete = 0 AND ur.zone = ? " + // + ") " + // + "ORDER BY " + // + " CASE WHEN division = 'TOTAL' THEN 999 ELSE CAST(division AS UNSIGNED) END"; + + // List> reportList = jdbcDomesticWasteTemplate.queryForList(sql, zone, zone); + + // Map response = new LinkedHashMap<>(); + // response.put("status", "Success"); + // response.put("message", "Ward-wise Report"); + // response.put("data", reportList); + + // return Collections.singletonList(response); + // } + + + + @Transactional(readOnly = true) +public List> getWardReport(String zone) { + + String sql = """ + WITH date_limits AS ( + SELECT + DATE_SUB(CURDATE(), INTERVAL (DAYOFWEEK(CURDATE()) - 1) DAY) AS week_start, + DATE_ADD(DATE_SUB(CURDATE(), INTERVAL (DAYOFWEEK(CURDATE()) - 1) DAY), INTERVAL 7 DAY) AS week_end + ) + SELECT + COALESCE(ur.division, 'TOTAL') AS division, + COUNT(*) AS total_request, + + -- Requests created this week + SUM(CASE WHEN ur.cdate >= d.week_start AND ur.cdate < d.week_end THEN 1 ELSE 0 END) AS this_week_requests, + + -- Older requests + SUM(CASE WHEN ur.cdate < d.week_start THEN 1 ELSE 0 END) AS older_requests, + + -- Status-based counts + SUM(CASE WHEN ur.status = 2 THEN 1 ELSE 0 END) AS completed, + SUM(CASE WHEN ur.status = 4 THEN 1 ELSE 0 END) AS user_cancel, + SUM(CASE WHEN ur.status = 5 THEN 1 ELSE 0 END) AS officer_cancel, + + -- Pending = older_requests - (completed + cancels) + ( + SUM(CASE WHEN ur.cdate < d.week_start THEN 1 ELSE 0 END) + - SUM(CASE WHEN ur.status IN (2,4,5) THEN 1 ELSE 0 END) + ) AS pending + + FROM + user_request_table ur + CROSS JOIN date_limits d + WHERE + ur.is_active = 1 + AND ur.is_delete = 0 + AND ur.zone = ? + GROUP BY + ur.division WITH ROLLUP + ORDER BY + CASE WHEN ur.division IS NULL THEN 999 ELSE CAST(ur.division AS UNSIGNED) END; + """; + + List> reportList = jdbcDomesticWasteTemplate.queryForList(sql, zone); + + Map response = new LinkedHashMap<>(); + response.put("status", "Success"); + response.put("message", "Ward-wise Report with Weekly and Pending Breakdown"); + response.put("data", reportList); + + return Collections.singletonList(response); +} + + + + // @Transactional(readOnly = true) + // public List> getWardStatusDetails( + // String fromDate, String toDate, + // String ward, String status) { + + // // ✅ Base URL for images + // String fileBaseUrl = "https://gccservices.in"; // or your configured value + + // // ✅ SQL query with ward + status filters + // String sql = + // "SELECT " + + // " u.id, u.request_id, u.user_name, u.mobile, u.address, " + + // " u.latitude, u.longitude, u.zone, u.division, u.street_name, " + + // " u.quantity AS main_quantity, u.remarks, " + + // " CONCAT('" + fileBaseUrl + "/gccofficialapp/files', u.image_url) AS image_url, " + + // " DATE_FORMAT(u.cdate, '%d-%m-%Y') AS cdate, " + + // " sm.status_master AS status, " + + // " DATE_FORMAT(u.close_date, '%d-%m-%Y') AS close_date, " + + // " CONCAT('" + fileBaseUrl + "/gccofficialapp/files', u.officer_upload_url) AS officer_upload_url, " + + // " im.item_name, itm.quantity " + + // "FROM user_request_table u " + + // "LEFT JOIN items itm ON u.id = itm.req_table_id " + + // "LEFT JOIN item_master im ON itm.iteam_id = im.id AND im.is_active = 1 " + + // "LEFT JOIN status_master sm ON sm.id = u.status AND sm.is_active = 1 AND sm.is_delete = 0 " + + // "WHERE u.is_active = 1 AND u.is_delete = 0 " + + // " AND u.division = ? " + + // " AND u.status = ? " + + // "ORDER BY u.cdate DESC"; + + // // ✅ Execute query + // List> reportList = jdbcDomesticWasteTemplate.queryForList(sql, ward, status); + + + // Map response = new LinkedHashMap<>(); + // response.put("status", "Success"); + // response.put("message", "Ward-status-wise - Report"); + // response.put("data", reportList); + + // return Collections.singletonList(response); + + // //return groupRequestsWithItems(reportList); + + // } + + + + @Transactional(readOnly = true) +public List> getWardStatusDetails(String ward, String status) { + + // ✅ Base URL for images (you can move to application.properties later) + String fileBaseUrl = "https://gccservices.in"; + + // ✅ SQL query using only ward + status + String sql = """ + SELECT + u.id, + u.request_id, + u.user_name, + u.mobile, + u.address, + u.latitude, + u.longitude, + u.zone, + u.division, + u.street_name, + u.quantity AS main_quantity, + u.remarks, + CONCAT(?, u.image_url) AS image_url, + DATE_FORMAT(u.cdate, '%d-%m-%Y') AS cdate, + sm.status_master AS status, + DATE_FORMAT(u.close_date, '%d-%m-%Y') AS close_date, + CONCAT(?, u.officer_upload_url) AS officer_upload_url, + itm.iteam_id, + im.item_name, + itm.quantity + FROM user_request_table u + LEFT JOIN items itm ON u.id = itm.req_table_id + LEFT JOIN item_master im ON itm.iteam_id = im.id AND im.is_active = 1 + LEFT JOIN status_master sm ON sm.id = u.status AND sm.is_active = 1 AND sm.is_delete = 0 + WHERE + u.is_active = 1 + AND u.is_delete = 0 + AND u.division = ? + AND u.status = ? + ORDER BY u.cdate DESC + """; + + // ✅ Execute query + List> reportList = jdbcDomesticWasteTemplate.queryForList( + sql, + fileBaseUrl + "/gccofficialapp/files", + fileBaseUrl + "/gccofficialapp/files", + ward, + status + ); + + Map> groupedMap = new LinkedHashMap<>(); + + for (Map row : reportList) { + Integer id = (Integer) row.get("id"); + + Map item = null; + if (row.get("item_name") != null) { + item = new LinkedHashMap<>(); + item.put("item_name", row.get("item_name")); + item.put("quantity", row.get("quantity")); + } + + if (groupedMap.containsKey(id)) { + if (item != null) { + ((List>) groupedMap.get(id).get("items")).add(item); + } + } else { + Map newEntry = new LinkedHashMap<>(); + newEntry.put("id", id); + newEntry.put("request_id", row.get("request_id")); + newEntry.put("user_name", row.get("user_name")); + newEntry.put("mobile", row.get("mobile")); + newEntry.put("address", row.get("address")); + newEntry.put("latitude", row.get("latitude")); + newEntry.put("longitude", row.get("longitude")); + newEntry.put("zone", row.get("zone")); + newEntry.put("division", row.get("division")); + newEntry.put("street_name", row.get("street_name")); + newEntry.put("main_quantity", row.get("main_quantity")); + newEntry.put("remarks", row.get("remarks")); + newEntry.put("image_url", row.get("image_url")); + newEntry.put("cdate", row.get("cdate")); + newEntry.put("is_active", row.get("is_active")); + newEntry.put("is_delete", row.get("is_delete")); + newEntry.put("street_id", row.get("street_id")); + newEntry.put("status", row.get("status")); // Now this is human-readable + newEntry.put("is_app", row.get("is_app")); + newEntry.put("close_date", row.get("close_date")); + newEntry.put("officer_upload_url", row.get("officer_upload_url")); + + List> items = new ArrayList<>(); + if (item != null) { + items.add(item); + } + newEntry.put("items", items); + + groupedMap.put(id, newEntry); + } + } + + + // ✅ Wrap response + Map response = new LinkedHashMap<>(); + response.put("status", "Success"); + response.put("message", "Ward-status-wise Report"); + response.put("data", groupedMap.values()); + + return Collections.singletonList(response); +} + + + + + + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..b9cac4b --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,3 @@ +spring.application.name=commissionerreviewII + +server.port=8075 diff --git a/src/main/resources/templates/modules/enforcement/Zonewise.html b/src/main/resources/templates/modules/enforcement/Zonewise.html new file mode 100644 index 0000000..1c1bd74 --- /dev/null +++ b/src/main/resources/templates/modules/enforcement/Zonewise.html @@ -0,0 +1,919 @@ + + + + Enforcement Zonewise Report Summary + + + + + + + + + + + + +
+

Enforcement - Zonewise Report

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ZONENOTICE 1NOTICE 2NOTICE 3NOTICE 4NOTICE 5NOTICE 6NOTICE 7
Generated InprogressIssued Generated InprogressIssued Generated InprogressIssued Generated InprogressIssued Generated InprogressIssued Generated InprogressIssued Generated InprogressIssued
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/templates/modules/enforcement/form2pendency.html b/src/main/resources/templates/modules/enforcement/form2pendency.html new file mode 100644 index 0000000..2de1a2f --- /dev/null +++ b/src/main/resources/templates/modules/enforcement/form2pendency.html @@ -0,0 +1,857 @@ + + + +Enforcement Zonewise Report Summary + + + + + + + + + + + + +
+

Pendency - Notice 2 Zonewise Report

+
+ +
+ + + + + + + + + + +
ZONENotice 2 Not InitiatedNotice 2 Initiated After 7 DaysNotice 2 Initiated Within 7 Days
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/templates/modules/enforcement/form3Pendency.html b/src/main/resources/templates/modules/enforcement/form3Pendency.html new file mode 100644 index 0000000..e21abde --- /dev/null +++ b/src/main/resources/templates/modules/enforcement/form3Pendency.html @@ -0,0 +1,857 @@ + + + +Enforcement Pendency Zone wise Report Summary + + + + + + + + + + + + +
+

Pendency - Notice 3 and 4 Zone wise Report

+
+ +
+ + + + + + + + + + +
ZONENotice 3 Not InitiatedNotice 3 Initiated After 7 DaysNotice 3 Initiated Within 7 Days
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/templates/modules/enforcement/form7pendency.html b/src/main/resources/templates/modules/enforcement/form7pendency.html new file mode 100644 index 0000000..fafb7d3 --- /dev/null +++ b/src/main/resources/templates/modules/enforcement/form7pendency.html @@ -0,0 +1,796 @@ + + + + Enforcement Pendency Zone wise Report Summary + + + + + + + + + + + + +
+

Pendency - Notice 7 Zone wise Report

+
+ +
+ + + + + + + + + + +
ZONENotice 7 Not Initiated After 30 DaysNotice 7 Initiated After 30 DaysNotice 7 Initiated Within 30 Days
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/templates/modules/sofa_bed/zonewise.html b/src/main/resources/templates/modules/sofa_bed/zonewise.html new file mode 100644 index 0000000..148a4a5 --- /dev/null +++ b/src/main/resources/templates/modules/sofa_bed/zonewise.html @@ -0,0 +1,662 @@ + + + + Sofa Bed collection Zonewise Report Summary + + + + + + + + + + + + +
+

Sofa and Bed Collection - Zonewise Report

+
+ +
+ + + + + + + + + + + + + + + + + + +
ZoneTotal RequestThis weekCompletedUser Cancelled Officer CancelledOver The week
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/sofa_bed/zonewise1.html b/src/main/resources/templates/modules/sofa_bed/zonewise1.html new file mode 100644 index 0000000..05fe897 --- /dev/null +++ b/src/main/resources/templates/modules/sofa_bed/zonewise1.html @@ -0,0 +1,687 @@ + + + + Sofa Bed collection Zonewise Report Summary + + + + + + + + + + + + +
+

Sofa and Bed Collection - Zonewise Report

+
+ +
+ + + + + + + + + + + + + + + + + + +
ZoneTotal RequestThis week RequestsOlder RequestsCompletedUser Cancelled Officer CancelledPending
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/java/com/gcc/commissionerreviewII/CommissionerreviewIiApplicationTests.java b/src/test/java/com/gcc/commissionerreviewII/CommissionerreviewIiApplicationTests.java new file mode 100644 index 0000000..050179b --- /dev/null +++ b/src/test/java/com/gcc/commissionerreviewII/CommissionerreviewIiApplicationTests.java @@ -0,0 +1,13 @@ +package com.gcc.commissionerreviewII; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class CommissionerreviewIiApplicationTests { + + @Test + void contextLoads() { + } + +}