commit
e654eb1e7b
25 changed files with 1780 additions and 0 deletions
-
2.gitattributes
-
33.gitignore
-
259mvnw
-
149mvnw.cmd
-
81pom.xml
-
16src/main/java/com/gcc/erppostdata/ErppostdataApplication.java
-
275src/main/java/com/gcc/erppostdata/communityhall/CHPostData.java
-
88src/main/java/com/gcc/erppostdata/communityhall/CmhQueryBank.java
-
49src/main/java/com/gcc/erppostdata/communityhall/CmhScheduler.java
-
17src/main/java/com/gcc/erppostdata/config/AppConfig.java
-
139src/main/java/com/gcc/erppostdata/config/DatabaseConfig.java
-
49src/main/java/com/gcc/erppostdata/controller/APIController.java
-
58src/main/java/com/gcc/erppostdata/model/ErpCHPostData.java
-
59src/main/java/com/gcc/erppostdata/model/ErpPetPostData.java
-
21src/main/java/com/gcc/erppostdata/mudhalvarpadaipagam/MPPostData.java
-
224src/main/java/com/gcc/erppostdata/petregistration/PRPostData.java
-
86src/main/java/com/gcc/erppostdata/petregistration/PetQueryBank.java
-
51src/main/java/com/gcc/erppostdata/petregistration/PetScheduler.java
-
40src/main/java/com/gcc/erppostdata/repo/CommunityHallLogRepo.java
-
39src/main/java/com/gcc/erppostdata/repo/PetLogRepo.java
-
20src/main/java/com/gcc/erppostdata/swimmingpool/SPPostData.java
-
2src/main/resources/application-dev.properties
-
1src/main/resources/application-prod.properties
-
9src/main/resources/application.properties
-
13src/test/java/com/gcc/erppostdata/ErppostdataApplicationTests.java
@ -0,0 +1,2 @@ |
|||
/mvnw text eol=lf |
|||
*.cmd text eol=crlf |
|||
@ -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/ |
|||
@ -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-<version>,maven-mvnd-<version>-<platform>}/<hash> |
|||
[ -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 "$@" |
|||
@ -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-<version>,maven-mvnd-<version>-<platform>}/<hash> |
|||
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" |
|||
@ -0,0 +1,81 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
<parent> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-parent</artifactId> |
|||
<version>3.4.3</version> |
|||
<relativePath/> <!-- lookup parent from repository --> |
|||
</parent> |
|||
<groupId>com.gcc</groupId> |
|||
<artifactId>erppostdata</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
<name>erppostdata</name> |
|||
<description>Demo project for Spring Boot</description> |
|||
<url/> |
|||
<licenses> |
|||
<license/> |
|||
</licenses> |
|||
<developers> |
|||
<developer/> |
|||
</developers> |
|||
<scm> |
|||
<connection/> |
|||
<developerConnection/> |
|||
<tag/> |
|||
<url/> |
|||
</scm> |
|||
<properties> |
|||
<java.version>17</java.version> |
|||
</properties> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-data-jdbc</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-data-jpa</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-jdbc</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-thymeleaf</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-web</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-devtools</artifactId> |
|||
<scope>runtime</scope> |
|||
<optional>true</optional> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.mysql</groupId> |
|||
<artifactId>mysql-connector-j</artifactId> |
|||
<scope>runtime</scope> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-test</artifactId> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
<build> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-maven-plugin</artifactId> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
|
|||
</project> |
|||
@ -0,0 +1,16 @@ |
|||
package com.gcc.erppostdata; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import org.springframework.context.annotation.ComponentScan; |
|||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; |
|||
|
|||
@SpringBootApplication |
|||
public class ErppostdataApplication { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(ErppostdataApplication.class, args); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,275 @@ |
|||
package com.gcc.erppostdata.communityhall; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import com.gcc.erppostdata.config.AppConfig; |
|||
import com.gcc.erppostdata.model.ErpCHPostData; |
|||
import com.gcc.erppostdata.repo.CommunityHallLogRepo; |
|||
import jakarta.persistence.EntityManager; |
|||
import jakarta.persistence.Query; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.sql.DataSource; |
|||
import java.io.BufferedReader; |
|||
import java.io.InputStreamReader; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.net.URLEncoder; |
|||
import java.text.SimpleDateFormat; |
|||
import java.time.LocalDate; |
|||
import java.util.*; |
|||
|
|||
@Component |
|||
public class CHPostData { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
@Autowired |
|||
private AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
private CommunityHallLogRepo cmhRepo; |
|||
|
|||
private List<Map<String, Object>> chDataList; |
|||
|
|||
@Autowired |
|||
@Qualifier("chEntityManagerFactory") |
|||
private EntityManager entityManager; |
|||
|
|||
@Autowired |
|||
public void setDataSource (@Qualifier("mysqlCommunityHallDataSource")DataSource dataSource){ |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
public void fetchChData(String sql,String transactionId,String id) { |
|||
Query query = null; |
|||
|
|||
|
|||
System.out.println("sql:" + sql); |
|||
|
|||
// Create query |
|||
query = entityManager.createNativeQuery(sql); |
|||
List<Object[]> results = query.getResultList(); |
|||
|
|||
chDataList = new ArrayList<>(); |
|||
|
|||
for (Object[] row : results) { |
|||
Map<String, Object> data = new TreeMap<>(); |
|||
String assesNo = ""; |
|||
String splitAmtOne ="0";/*hallamount*/ |
|||
String splitAmtTwo = "0"; /*depositamount*/ |
|||
String splitAmtThree ="0";/*gst*/ |
|||
|
|||
if (row[0].toString().startsWith("CHBED")){ |
|||
// Generate ASSESSMENTNO dynamically |
|||
assesNo = LocalDate.now().getYear() + "/COMM/ED/" + row[11].toString(); // row[11] -> booking_id |
|||
splitAmtTwo = String.valueOf(row[2]); |
|||
|
|||
|
|||
}else { |
|||
// Generate ASSESSMENTNO dynamically |
|||
assesNo = LocalDate.now().getYear() + "/COMM/" + row[11].toString(); // row[11] -> booking_id |
|||
splitAmtTwo = String.valueOf(row[6]); |
|||
splitAmtOne = String.valueOf(row[5]); |
|||
splitAmtThree = String.valueOf(row[7]); |
|||
} |
|||
|
|||
|
|||
|
|||
// Static mandatory input |
|||
data.put("serviceId", "getOtherCollection"); |
|||
data.put("COLLECTION_TYPE", "Community Hall"); |
|||
data.put("TOTALTRANSACTIONCODE", "450310000"); |
|||
|
|||
// Unique data |
|||
data.put("ASSESSMENTNO", assesNo); // Use generated assessment number |
|||
data.put("UNIQUERECEIPTID", row[11]); // transaction_id |
|||
data.put("TRANSACTIONNO", row[0]); // transaction_id (order_id) |
|||
data.put("TRANSACTIONREFNO", row[1]); // tpsl_txn_id |
|||
data.put("TRANSACTIONDATE", row[3]); // paymentdate |
|||
|
|||
// Corrected numeric fields |
|||
data.put("TOTALTRANSACTIONAMOUNT", Double.parseDouble(String.valueOf(row[2]))); // amount |
|||
|
|||
data.put("HALLAMOUNT", Double.parseDouble(String.valueOf(row[5]))); // hall_amount |
|||
data.put("DEPOSITAMOUNT", Double.parseDouble(String.valueOf(row[6]))); // deposit_amount |
|||
data.put("GST", Double.parseDouble(String.valueOf(row[7]))); // gst |
|||
data.put("bookingId", String.valueOf(row[11])); // gst |
|||
|
|||
|
|||
// Amount breakdown |
|||
data.put("MSTRCODEONE", "411"); |
|||
data.put("MSTRCODETWO", "412"); |
|||
data.put("MSTRCODETHREE", "413"); |
|||
data.put("SPLITAMOUNTONE", splitAmtOne); |
|||
data.put("SPLITAMOUNTTWO", splitAmtTwo); |
|||
data.put("SPLITAMOUNTTHREE", splitAmtThree); |
|||
|
|||
// Party details (no parsing required) |
|||
data.put("PARTYNAME", row[8]); // us.name (String) |
|||
data.put("PARTYMOBILE", row[9]); // us.mobile_no (String) |
|||
data.put("PARTYADDRESS", row[10]); // full_address (String) |
|||
|
|||
chDataList.add(data); |
|||
} |
|||
|
|||
|
|||
// Call the method with the fetched data |
|||
postDataToERP(chDataList,id); |
|||
} |
|||
|
|||
public void postDataToERP(List<Map<String, Object>> chlist,String id) { |
|||
System.out.println("ERP URL before request: " + appConfig.getErpUrl()); |
|||
|
|||
String erpBaseUrl = "http://coc-staging.egovernments.org:9980/pgr/external/mobileservice?"; |
|||
for (Map<String, Object> data : chlist) { |
|||
StringBuilder response = new StringBuilder(); |
|||
|
|||
System.out.println("Sending Data: " + data); |
|||
|
|||
StringBuilder encodedUrl = new StringBuilder(erpBaseUrl); |
|||
|
|||
try { |
|||
boolean firstParam = true; |
|||
SimpleDateFormat inputFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); // Correct format |
|||
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); // Expected format |
|||
outputFormat.setTimeZone(TimeZone.getTimeZone("Asia/Kolkata")); // Adjust timezone if needed |
|||
|
|||
for (Map.Entry<String, Object> entry : data.entrySet()) { |
|||
if (!firstParam) { |
|||
encodedUrl.append("&"); |
|||
} |
|||
firstParam = false; |
|||
|
|||
String key = URLEncoder.encode(entry.getKey(), "UTF-8"); |
|||
String value = ""; |
|||
|
|||
if (entry.getValue() == null) { |
|||
System.out.println("Missing value for key: " + key); |
|||
value = ""; // Ensure empty values are sent correctly |
|||
} else { |
|||
value = entry.getValue().toString(); |
|||
|
|||
// ✅ Fix Date Formatting |
|||
if (entry.getKey().equals("TRANSACTIONDATE")) { |
|||
try { |
|||
Date date = inputFormat.parse(value); |
|||
value = outputFormat.format(date); |
|||
} catch (Exception e) { |
|||
System.out.println(" Error parsing TRANSACTIONDATE: " + value); |
|||
} |
|||
} |
|||
} |
|||
|
|||
encodedUrl.append(key).append("=").append(URLEncoder.encode(value, "UTF-8")); |
|||
} |
|||
|
|||
String finalUrl = encodedUrl.toString(); |
|||
System.out.println("Final Encoded URL: " + finalUrl); |
|||
|
|||
HttpURLConnection connection = (HttpURLConnection) new URL(finalUrl).openConnection(); |
|||
connection.setRequestMethod("GET"); |
|||
|
|||
int responseCode = connection.getResponseCode(); |
|||
System.out.println("Response Code: " + responseCode); |
|||
|
|||
if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK |
|||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); |
|||
String inputLine; |
|||
while ((inputLine = in.readLine()) != null) { |
|||
response.append(inputLine); |
|||
} |
|||
in.close(); |
|||
|
|||
|
|||
} else { |
|||
System.out.println("GET request failed."); |
|||
} |
|||
if(id!=null){ |
|||
updateTheLog(data,response,id); |
|||
}else { |
|||
saveTheLog(data, response); |
|||
} |
|||
} catch (Exception e) { |
|||
try { |
|||
if(id!=null){ |
|||
updateTheLog(data,response,id); |
|||
}else { |
|||
saveTheLog(data, response); |
|||
} |
|||
}catch (Exception e1) { |
|||
e.printStackTrace(); |
|||
} |
|||
e.printStackTrace(); |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
|
|||
public void saveTheLog(Map<String, Object> map,StringBuilder response) throws JsonProcessingException { |
|||
System.out.println(response); |
|||
String status =""; |
|||
String msgStatus =""; |
|||
if(response != null) { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
Map<String, Object> res = objectMapper.readValue(response.toString(), Map.class); |
|||
status = res.get("ResultStatus").toString(); |
|||
msgStatus = res.get("Message").toString(); |
|||
} |
|||
|
|||
System.out.println("ResultStatus: " + status); |
|||
String msg = "Already Updated this collection"; |
|||
|
|||
ErpCHPostData com = new ErpCHPostData(); |
|||
com.setBookingId(map.get("bookingId").toString()); |
|||
com.setTransactionId(map.get("TRANSACTIONNO").toString()); |
|||
if(status.equals("true")){ |
|||
com.setStatus(1); |
|||
}else if(msg.equals(msgStatus) && status.equals("false")) { |
|||
com.setStatus(1); |
|||
} else if ("Failure".equals(msgStatus) && status.equals("false")) { |
|||
com.setStatus(2); |
|||
} else { |
|||
com.setStatus(0); |
|||
} |
|||
com.setResponse(response.toString()); |
|||
cmhRepo.insert(com.getTransactionId(),com.getBookingId(),com.getStatus()+"",com.getResponse()); |
|||
} |
|||
|
|||
|
|||
public void updateTheLog(Map<String, Object> map,StringBuilder response,String id) throws JsonProcessingException{ |
|||
System.out.println(response); |
|||
String status =""; |
|||
String msgStatus =""; |
|||
if(response != null) { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
Map<String, Object> res = objectMapper.readValue(response.toString(), Map.class); |
|||
status = res.get("ResultStatus").toString(); |
|||
msgStatus = res.get("Message").toString(); |
|||
} |
|||
|
|||
System.out.println("ResultStatus: " + status); |
|||
String msg = "Already Updated this collection"; |
|||
|
|||
ErpCHPostData com = new ErpCHPostData(); |
|||
com.setBookingId(map.get("bookingId").toString()); |
|||
com.setTransactionId(map.get("TRANSACTIONNO").toString()); |
|||
|
|||
if(msg.equals(msgStatus) && status.equals("false")) { |
|||
com.setStatus(1); |
|||
} else if ("Failure".equals(msgStatus) && status.equals("false")) { |
|||
com.setStatus(2); |
|||
} else { |
|||
com.setStatus(0); |
|||
} |
|||
com.setResponse(response.toString()); |
|||
cmhRepo.updateLog(com.getStatus()+"",com.getResponse(),id); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,88 @@ |
|||
package com.gcc.erppostdata.communityhall; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
@Component |
|||
public class CmhQueryBank { |
|||
@Autowired |
|||
CHPostData chPostData; |
|||
|
|||
public void hourlyPushData() { |
|||
String hourlysql = "SELECT " + |
|||
" tr.txansaction_id, " + |
|||
" tr.tpsl_txn_id, " + |
|||
" tr.amount, " + |
|||
" tr.date, " + |
|||
" bk.booking_status, " + |
|||
" bk.hall_amount, " + |
|||
" bk.deposit_amount, " + |
|||
" bk.gst, " + |
|||
" us.name, " + |
|||
" us.mobile_no, " + |
|||
" CONCAT(us.street, ', ', us.location) AS full_address, " + |
|||
" bk.booking_id " + |
|||
"FROM transaction_response tr " + |
|||
"INNER JOIN users us ON tr.user_id = us.user_id " + |
|||
"INNER JOIN booking_details bk ON bk.booking_id = tr.booking_id " + |
|||
"WHERE tr.status_code = '0300' " + |
|||
// "AND bk.booking_status IN ('APPROVED', 'CANCELED', 'COMPLETED', 'GCC_BLOCKED') " + |
|||
"AND STR_TO_DATE(tr.date, '%d-%m-%Y %H:%i:%s') >= NOW() - INTERVAL 2 HOUR" |
|||
+ " AND STR_TO_DATE(tr.date, '%d-%m-%Y %H:%i:%s') >= NOW() - INTERVAL 1 HOUR" |
|||
; |
|||
|
|||
chPostData.fetchChData(hourlysql,null,null); |
|||
} |
|||
|
|||
public void PushAllData() { |
|||
String sql = "SELECT " + |
|||
" tr.txansaction_id, " + |
|||
" tr.tpsl_txn_id, " + |
|||
" tr.amount, " + |
|||
" tr.date, " + |
|||
" bk.booking_status, " + |
|||
" bk.hall_amount, " + |
|||
" bk.deposit_amount, " + |
|||
" bk.gst, " + |
|||
" us.name, " + |
|||
" us.mobile_no, " + |
|||
" CONCAT(us.street, ', ', us.location) AS full_address, " + |
|||
" bk.booking_id " + |
|||
"FROM transaction_response tr " + |
|||
"INNER JOIN users us ON tr.user_id = us.user_id " + |
|||
"INNER JOIN booking_details bk ON bk.booking_id = tr.booking_id " + |
|||
"WHERE tr.status_code = '0300' " + |
|||
// "AND bk.booking_status IN ('APPROVED', 'CANCELED', 'COMPLETED', 'GCC_BLOCKED') " + |
|||
"AND tr.date < NOW() - INTERVAL 1 HOUR;"; |
|||
|
|||
chPostData.fetchChData(sql,null,null); |
|||
} |
|||
|
|||
public void resendPushData(String transactionId,String id) { |
|||
|
|||
String sql = "SELECT " + |
|||
" tr.txansaction_id, " + |
|||
" tr.tpsl_txn_id, " + |
|||
" tr.amount, " + |
|||
" tr.date, " + |
|||
" bk.booking_status, " + |
|||
" bk.hall_amount, " + |
|||
" bk.deposit_amount, " + |
|||
" bk.gst, " + |
|||
" us.name, " + |
|||
" us.mobile_no, " + |
|||
" CONCAT(us.street, ', ', us.location) AS full_address, " + |
|||
" bk.booking_id " + |
|||
"FROM transaction_response tr " + |
|||
"INNER JOIN users us ON tr.user_id = us.user_id " + |
|||
"INNER JOIN booking_details bk ON bk.booking_id = tr.booking_id " + |
|||
"WHERE tr.txansaction_id = '" +transactionId+"' "+ |
|||
// "AND bk.booking_status IN ('APPROVED', 'CANCELED', 'COMPLETED', 'GCC_BLOCKED') " + |
|||
// "AND STR_TO_DATE(tr.date, '%d-%m-%Y %H:%i:%s') <= NOW() - INTERVAL 2 HOUR" |
|||
// " AND STR_TO_DATE(tr.date, '%d-%m-%Y %H:%i:%s') >= NOW() - INTERVAL 1 HOUR" |
|||
" AND tr.status_code = '0300' " |
|||
; |
|||
chPostData.fetchChData(sql,transactionId,id); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
package com.gcc.erppostdata.communityhall; |
|||
|
|||
|
|||
import com.gcc.erppostdata.repo.CommunityHallLogRepo; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.scheduling.annotation.EnableScheduling; |
|||
import org.springframework.scheduling.annotation.Scheduled; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Configuration |
|||
@EnableScheduling // Enable scheduling |
|||
public class CmhScheduler { |
|||
|
|||
@Autowired |
|||
CmhQueryBank queryBank; |
|||
|
|||
@Autowired |
|||
CommunityHallLogRepo communityHallLogRepo; |
|||
|
|||
@Scheduled(fixedRate = 3600000) // Runs every 1 hour (3600000 milliseconds) |
|||
public void oneHouseScheduledMethod() { |
|||
queryBank.hourlyPushData(); |
|||
|
|||
} |
|||
@Scheduled(fixedRate = 10800000) |
|||
public void threeHouseScheduledMethod() { |
|||
System.out.println("im for ERP post data"); |
|||
List<Map<String, Object>> dataByStatus = communityHallLogRepo.getDataByStatus(String.valueOf(0)); |
|||
for (Map<String, Object> data : dataByStatus) { |
|||
queryBank.resendPushData(data.get("transactionId").toString(), |
|||
data.get("id").toString() |
|||
); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
@Scheduled(fixedRate = 10000) |
|||
public void tensecScheduledMethod(){ |
|||
|
|||
// System.out.print("hello"); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
package com.gcc.erppostdata.config; |
|||
|
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
@Configuration |
|||
public class AppConfig { |
|||
private String erpUrl; |
|||
|
|||
public String getErpUrl() { |
|||
return erpUrl; |
|||
} |
|||
|
|||
public void setErpUrl(String erpUrl) { |
|||
this.erpUrl = erpUrl; |
|||
} |
|||
} |
|||
@ -0,0 +1,139 @@ |
|||
package com.gcc.erppostdata.config; |
|||
|
|||
import jakarta.persistence.EntityManagerFactory; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.boot.jdbc.DataSourceBuilder; |
|||
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.context.annotation.Primary; |
|||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; |
|||
import org.springframework.jdbc.datasource.DriverManagerDataSource; |
|||
import org.springframework.orm.jpa.JpaTransactionManager; |
|||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; |
|||
import org.springframework.transaction.PlatformTransactionManager; |
|||
import org.springframework.transaction.annotation.EnableTransactionManagement; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
@Configuration |
|||
@EnableTransactionManagement |
|||
public class DatabaseConfig { |
|||
|
|||
String chDb="communityhalldemo"; |
|||
String petDb="gcc_pets"; |
|||
|
|||
String userName="root"; |
|||
String password="root"; |
|||
|
|||
@Configuration |
|||
@EnableTransactionManagement |
|||
@EnableJpaRepositories( |
|||
basePackages = "com.gcc.erppostdata.petregistration", |
|||
entityManagerFactoryRef = "petEntityManagerFactory", |
|||
transactionManagerRef = "petTransactionManager" |
|||
) |
|||
public class MysqlpetDataSourceConfig { |
|||
|
|||
String petDb="gcc_pets"; |
|||
|
|||
@Primary |
|||
@Bean(name = "mysqlPetRegistrationDataSource") |
|||
public DataSource mysqlPetRegistrationDataSource() { |
|||
return DataSourceBuilder.create() |
|||
.url("jdbc:mysql://localhost:3306/"+DatabaseConfig.this.petDb) |
|||
.username(DatabaseConfig.this.userName) |
|||
.password(DatabaseConfig.this.password) |
|||
.driverClassName("com.mysql.cj.jdbc.Driver") |
|||
.build(); |
|||
} |
|||
|
|||
@Primary |
|||
@Bean(name = "petEntityManagerFactory") |
|||
public LocalContainerEntityManagerFactoryBean petEntityManagerFactory( |
|||
EntityManagerFactoryBuilder builder, |
|||
DataSource mysqlPetRegistrationDataSource) { |
|||
return builder |
|||
.dataSource(mysqlPetRegistrationDataSource) |
|||
.packages("com.gcc.erppostdata.petregistration") |
|||
.persistenceUnit("petPU") |
|||
.build(); |
|||
} |
|||
|
|||
@Primary |
|||
@Bean(name = "petTransactionManager") |
|||
public PlatformTransactionManager petTransactionManager( |
|||
EntityManagerFactory petEntityManagerFactory) { |
|||
return new JpaTransactionManager(petEntityManagerFactory); |
|||
} |
|||
} |
|||
@Configuration |
|||
@EnableTransactionManagement |
|||
@EnableJpaRepositories( |
|||
basePackages = "com.gcc.erppostdata.communityhall", |
|||
entityManagerFactoryRef = "chEntityManagerFactory", |
|||
transactionManagerRef = "chTransactionManager" |
|||
) |
|||
public class MysqlchDataSourceConfig { |
|||
|
|||
|
|||
|
|||
@Bean(name = "mysqlCommunityHallDataSource") |
|||
public DataSource mysqlCommunityHallDataSource() { |
|||
return DataSourceBuilder.create() |
|||
.url("jdbc:mysql://localhost:3306/"+DatabaseConfig.this.chDb) |
|||
.username(DatabaseConfig.this.userName) |
|||
.password(DatabaseConfig.this.password) |
|||
.driverClassName("com.mysql.cj.jdbc.Driver") |
|||
.build(); |
|||
} |
|||
|
|||
@Bean(name = "chEntityManagerFactory") |
|||
public LocalContainerEntityManagerFactoryBean chEntityManagerFactory( |
|||
EntityManagerFactoryBuilder builder, |
|||
@Qualifier("mysqlCommunityHallDataSource") DataSource dataSource) { |
|||
return builder |
|||
.dataSource(dataSource) |
|||
.packages("com.gcc.erppostdata.communityhall") // Package containing Community Hall entities |
|||
.persistenceUnit("chPU") |
|||
.build(); |
|||
} |
|||
|
|||
@Bean(name = "chTransactionManager") |
|||
public PlatformTransactionManager chTransactionManager( |
|||
@Qualifier("chEntityManagerFactory") EntityManagerFactory chEntityManagerFactory) { |
|||
return new JpaTransactionManager(chEntityManagerFactory); |
|||
} |
|||
|
|||
} |
|||
@Bean(name = "mysqlSwimmingPoolDataSource") |
|||
public DataSource mysqlSwimmingPoolDataSource() { |
|||
DriverManagerDataSource dataSource = new DriverManagerDataSource(); |
|||
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); |
|||
dataSource.setUrl("jdbc:mysql://localhost:3306/swimtesting"); |
|||
dataSource.setUsername("root"); |
|||
dataSource.setPassword("root"); |
|||
return dataSource; |
|||
} |
|||
|
|||
@Bean(name = "mysqlmudhalvarpadaipagamDataSource") |
|||
public DataSource mysqlmudhalvarpadaipagamDataSource() { |
|||
DriverManagerDataSource dataSource = new DriverManagerDataSource(); |
|||
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); |
|||
dataSource.setUrl("jdbc:mysql://localhost:3306/mudhalavarpadaipagam"); |
|||
dataSource.setUsername("root"); |
|||
dataSource.setPassword("root"); |
|||
return dataSource; |
|||
} |
|||
|
|||
@Bean(name = "mysqlerpPostData") |
|||
public DataSource mysqlerpPostData() { |
|||
DriverManagerDataSource dataSource = new DriverManagerDataSource(); |
|||
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); |
|||
dataSource.setUrl("jdbc:mysql://localhost:3306/erppostdata"); |
|||
dataSource.setUsername("root"); |
|||
dataSource.setPassword("root"); |
|||
return dataSource; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
package com.gcc.erppostdata.controller; |
|||
|
|||
|
|||
import com.gcc.erppostdata.communityhall.CHPostData; |
|||
import com.gcc.erppostdata.communityhall.CmhQueryBank; |
|||
import com.gcc.erppostdata.petregistration.PRPostData; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
|
|||
@Controller |
|||
public class APIController { |
|||
|
|||
@Autowired |
|||
private PRPostData prPostData; |
|||
|
|||
@Autowired |
|||
private CmhQueryBank chPostData; |
|||
|
|||
|
|||
@GetMapping("/peterpdata") |
|||
public ResponseEntity<String> peterpdata() { |
|||
try { |
|||
// prPostData.fetpetData(); |
|||
return ResponseEntity.ok("Pet data fetched and sent successfully."); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Error fetching pet data: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/cherpdata") |
|||
public ResponseEntity<String> cherpdata() { |
|||
try { |
|||
|
|||
chPostData.hourlyPushData(); |
|||
|
|||
return ResponseEntity.ok("Communityhall data fetched and sent successfully."); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Error fetching community hall data: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
package com.gcc.erppostdata.model; |
|||
|
|||
import jakarta.persistence.Entity; |
|||
import jakarta.persistence.GeneratedValue; |
|||
import jakarta.persistence.GenerationType; |
|||
import jakarta.persistence.Id; |
|||
|
|||
//@Entity |
|||
public class ErpCHPostData { |
|||
|
|||
// @Id |
|||
// @GeneratedValue(strategy = GenerationType.IDENTITY) |
|||
private int id; |
|||
private String transactionId; |
|||
private String bookingId; |
|||
private int status =1; |
|||
private String response; |
|||
|
|||
public int getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(int id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getTransactionId() { |
|||
return transactionId; |
|||
} |
|||
|
|||
public void setTransactionId(String transactionId) { |
|||
this.transactionId = transactionId; |
|||
} |
|||
|
|||
public String getBookingId() { |
|||
return bookingId; |
|||
} |
|||
|
|||
public void setBookingId(String bookingId) { |
|||
this.bookingId = bookingId; |
|||
} |
|||
|
|||
public int getStatus() { |
|||
return status; |
|||
} |
|||
|
|||
public void setStatus(int status) { |
|||
this.status = status; |
|||
} |
|||
|
|||
public String getResponse() { |
|||
return response; |
|||
} |
|||
|
|||
public void setResponse(String response) { |
|||
this.response = response; |
|||
} |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
package com.gcc.erppostdata.model; |
|||
|
|||
import jakarta.persistence.Entity; |
|||
import jakarta.persistence.GeneratedValue; |
|||
import jakarta.persistence.GenerationType; |
|||
import jakarta.persistence.Id; |
|||
|
|||
//@Entity |
|||
public class ErpPetPostData { |
|||
|
|||
// @Id |
|||
// @GeneratedValue(strategy = GenerationType.IDENTITY) |
|||
private int id; |
|||
|
|||
private int uniqueId; |
|||
private String orderId; |
|||
private String paymentId; |
|||
private int status =1 ; |
|||
|
|||
public int getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(int id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public int getUniqueId() { |
|||
return uniqueId; |
|||
} |
|||
|
|||
public void setUniqueId(int uniqueId) { |
|||
this.uniqueId = uniqueId; |
|||
} |
|||
|
|||
public String getOrderId() { |
|||
return orderId; |
|||
} |
|||
|
|||
public void setOrderId(String orderId) { |
|||
this.orderId = orderId; |
|||
} |
|||
|
|||
public String getPaymentId() { |
|||
return paymentId; |
|||
} |
|||
|
|||
public void setPaymentId(String paymentId) { |
|||
this.paymentId = paymentId; |
|||
} |
|||
|
|||
public int getStatus() { |
|||
return status; |
|||
} |
|||
|
|||
public void setStatus(int status) { |
|||
this.status = status; |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
package com.gcc.erppostdata.mudhalvarpadaipagam; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
@Component |
|||
public class MPPostData { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource (@Qualifier("mysqlmudhalvarpadaipagamDataSource") DataSource dataSource){ |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,224 @@ |
|||
package com.gcc.erppostdata.petregistration; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import com.gcc.erppostdata.config.AppConfig; |
|||
import com.gcc.erppostdata.model.ErpCHPostData; |
|||
import com.gcc.erppostdata.repo.PetLogRepo; |
|||
import jakarta.persistence.EntityManager; |
|||
import jakarta.persistence.Query; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.util.UriComponentsBuilder; |
|||
|
|||
import javax.sql.DataSource; |
|||
import java.io.BufferedReader; |
|||
import java.io.InputStreamReader; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.net.URLEncoder; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.*; |
|||
|
|||
@Component |
|||
public class PRPostData { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
@Autowired |
|||
private AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
private PetLogRepo petLogRepo; |
|||
|
|||
private List<Map<String, Object>> petDataList; |
|||
|
|||
@Autowired |
|||
@Qualifier("petEntityManagerFactory") |
|||
private EntityManager entityManager; |
|||
|
|||
|
|||
@Autowired |
|||
public void setDataSource (@Qualifier("mysqlPetRegistrationDataSource") DataSource dataSource){ |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
public void fetpetData(String sql) { |
|||
|
|||
|
|||
System.out.println("sql:" + sql); |
|||
// Create query |
|||
Query query = entityManager.createNativeQuery(sql); |
|||
List<Object[]> results = query.getResultList(); |
|||
|
|||
petDataList = new ArrayList<>(); |
|||
|
|||
for (Object[] row : results) { |
|||
Map<String, Object> data = new TreeMap<>(); |
|||
|
|||
// Static mandatory input |
|||
data.put("serviceId", "getOtherCollection"); |
|||
data.put("COLLECTION_TYPE", "Pet License"); |
|||
data.put("TOTALTRANSACTIONCODE", "450310000"); |
|||
|
|||
// Unique data |
|||
data.put("ASSESSMENTNO", row[10].toString()); |
|||
data.put("UNIQUERECEIPTID", row[1].toString()); // uniqueid |
|||
data.put("TRANSACTIONNO", row[9].toString()); // order_id |
|||
data.put("TRANSACTIONREFNO", row[6].toString()); // payment_id |
|||
data.put("TRANSACTIONDATE", row[8].toString()); // paymentdate |
|||
data.put("TOTALTRANSACTIONAMOUNT", Double.parseDouble(row[5].toString())); // amount |
|||
|
|||
// Amount breakdown |
|||
data.put("MSTRCODEONE", "401"); |
|||
data.put("SPLITAMOUNTONE", row[5].toString()); // amount |
|||
|
|||
// Party details |
|||
data.put("PARTYNAME", row[3].toString()); // fname |
|||
data.put("PARTYADDRESS", row[4].toString()); // partyaddress |
|||
data.put("PARTYMOBILE", row[2].toString()); // phone |
|||
|
|||
petDataList.add(data); |
|||
} |
|||
|
|||
// Call the method with the fetched data |
|||
postDataToERP(petDataList); |
|||
} |
|||
|
|||
public void postDataToERP(List<Map<String, Object>> petlist) { |
|||
for (Map<String, Object> data : petlist) { |
|||
System.out.println("Sending Data: " + data); |
|||
System.out.println("ERP URL before request: " + appConfig.getErpUrl()); |
|||
|
|||
String erpBaseUrl = "http://coc-staging.egovernments.org:9980/pgr/external/mobileservice?"; |
|||
StringBuilder encodedUrl = new StringBuilder(erpBaseUrl); |
|||
|
|||
try { |
|||
boolean firstParam = true; |
|||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); // Original format |
|||
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); // Expected format |
|||
outputFormat.setTimeZone(TimeZone.getTimeZone("Asia/Kolkata")); // Adjust timezone if needed |
|||
|
|||
for (Map.Entry<String, Object> entry : data.entrySet()) { |
|||
if (!firstParam) { |
|||
encodedUrl.append("&"); |
|||
} |
|||
firstParam = false; |
|||
|
|||
String key = URLEncoder.encode(entry.getKey(), "UTF-8"); |
|||
String value = ""; |
|||
|
|||
if (entry.getValue() == null) { |
|||
System.out.println("Missing value for key: " + key); |
|||
value = ""; // Ensure empty values are sent correctly |
|||
} else { |
|||
value = entry.getValue().toString(); |
|||
|
|||
// ✅ Fix Date Formatting |
|||
if (entry.getKey().equals("TRANSACTIONDATE")) { |
|||
try { |
|||
Date date = inputFormat.parse(value); |
|||
value = outputFormat.format(date); |
|||
} catch (Exception e) { |
|||
System.out.println(" Error parsing TRANSACTIONDATE: " + value); |
|||
} |
|||
} |
|||
} |
|||
|
|||
encodedUrl.append(key).append("=").append(URLEncoder.encode(value, "UTF-8")); |
|||
} |
|||
|
|||
String finalUrl = encodedUrl.toString(); |
|||
System.out.println("Final Encoded URL: " + finalUrl); |
|||
|
|||
HttpURLConnection connection = (HttpURLConnection) new URL(finalUrl).openConnection(); |
|||
connection.setRequestMethod("GET"); |
|||
|
|||
int responseCode = connection.getResponseCode(); |
|||
System.out.println("Response Code: " + responseCode); |
|||
|
|||
if (responseCode == HttpURLConnection.HTTP_OK) { // 200 OK |
|||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); |
|||
StringBuilder response = new StringBuilder(); |
|||
String inputLine; |
|||
while ((inputLine = in.readLine()) != null) { |
|||
response.append(inputLine); |
|||
} |
|||
in.close(); |
|||
System.out.println("Response: " + response.toString()); |
|||
saveTheLog(data,response); |
|||
} else { |
|||
System.out.println("GET request failed."); |
|||
saveTheLog(data,null); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public void saveTheLog(Map<String, Object> map,StringBuilder response) throws JsonProcessingException { |
|||
System.out.println(response); |
|||
String status =""; |
|||
String statusCode = ""; |
|||
String msgStatus =""; |
|||
if(response != null) { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
Map<String, Object> res = objectMapper.readValue(response.toString(), Map.class); |
|||
status = res.get("ResultStatus").toString(); |
|||
msgStatus = res.get("Message").toString(); |
|||
} |
|||
|
|||
System.out.println("ResultStatus: " + status); |
|||
String msg = "Already Updated this collection"; |
|||
|
|||
|
|||
if(msg.equals(msgStatus) && status.equals("false")) { |
|||
statusCode="1"; |
|||
} else if ("Failure".equals(msgStatus) && status.equals("false")) { |
|||
statusCode="2"; |
|||
} else { |
|||
statusCode="0"; |
|||
} |
|||
petLogRepo.insert( |
|||
map.get("UNIQUERECEIPTID")+"", |
|||
map.get("TRANSACTIONNO")+"", |
|||
map.get("TRANSACTIONREFNO")+"", |
|||
statusCode, |
|||
response.toString()); |
|||
} |
|||
|
|||
public void updateTheLog(Map<String, Object> data,StringBuilder response,String id) throws JsonProcessingException { |
|||
|
|||
System.out.println(response); |
|||
String status =""; |
|||
String msgStatus =""; |
|||
String statusCode = ""; |
|||
if(response != null) { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
Map<String, Object> res = objectMapper.readValue(response.toString(), Map.class); |
|||
status = res.get("ResultStatus").toString(); |
|||
msgStatus = res.get("Message").toString(); |
|||
} |
|||
|
|||
System.out.println("ResultStatus: " + status); |
|||
String msg = "Already Updated this collection"; |
|||
if(status.equals("true")){ |
|||
statusCode ="1"; |
|||
}else if(msg.equals(msgStatus) && status.equals("false")) { |
|||
statusCode ="1"; |
|||
} else if ("Failure".equals(msgStatus) && status.equals("false")) { |
|||
statusCode ="2"; |
|||
} else { |
|||
statusCode ="0"; |
|||
} |
|||
petLogRepo.updateLog(statusCode,response.toString(),id); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,86 @@ |
|||
package com.gcc.erppostdata.petregistration; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class PetQueryBank { |
|||
|
|||
@Autowired |
|||
PRPostData prPostData; |
|||
|
|||
public void PushAllData() { |
|||
String sql = "SELECT " + |
|||
" p.uniqueid, " + |
|||
" p.status, " + |
|||
" o.phone, " + |
|||
" o.fname, " + |
|||
" CONCAT(o.doornumber, ', ', o.street, ', ', o.area) AS partyaddress, " + |
|||
" pay.amount, " + |
|||
" pay.payment_id, " + |
|||
" pay.payment_status, " + |
|||
" pay.paymentdate, " + |
|||
" pay.order_id, " + |
|||
" l.license_no, " + |
|||
" l.validity " + |
|||
"FROM petdetails p " + |
|||
"INNER JOIN payment pay ON p.uniqueid = pay.uniqueid " + |
|||
"INNER JOIN pet_license l ON p.uniqueid = l.uniqueid " + |
|||
"INNER JOIN pet_owner o ON p.mobilenum = o.phone " + |
|||
"WHERE p.status = 2;"; |
|||
|
|||
prPostData.fetpetData(sql); |
|||
} |
|||
|
|||
public void hourlyPushData() { |
|||
String sql = "SELECT " + |
|||
" p.uniqueid, " + |
|||
" p.status, " + |
|||
" o.phone, " + |
|||
" o.fname, " + |
|||
" CONCAT(o.doornumber, ', ', o.street, ', ', o.area) AS partyaddress, " + |
|||
" pay.amount, " + |
|||
" pay.payment_id, " + |
|||
" pay.payment_status, " + |
|||
" pay.paymentdate, " + |
|||
" pay.order_id, " + |
|||
" l.license_no, " + |
|||
" l.validity " + |
|||
"FROM petdetails p " + |
|||
"INNER JOIN payment pay ON p.uniqueid = pay.uniqueid " + |
|||
"INNER JOIN pet_license l ON p.uniqueid = l.uniqueid " + |
|||
"INNER JOIN pet_owner o ON p.mobilenum = o.phone " + |
|||
"WHERE p.status = 2 AND pay.paymentdate >= NOW() - INTERVAL 2 HOUR" |
|||
+ " AND pay.paymentdate >= NOW() - INTERVAL 1 HOUR" |
|||
; |
|||
prPostData.fetpetData(sql); |
|||
|
|||
} |
|||
|
|||
public void resendPushData(String uniqueId,String id) { |
|||
|
|||
String sql = "SELECT " + |
|||
" p.uniqueid, " + |
|||
" p.status, " + |
|||
" o.phone, " + |
|||
" o.fname, " + |
|||
" CONCAT(o.doornumber, ', ', o.street, ', ', o.area) AS partyaddress, " + |
|||
" pay.amount, " + |
|||
" pay.payment_id, " + |
|||
" pay.payment_status, " + |
|||
" pay.paymentdate, " + |
|||
" pay.order_id, " + |
|||
" l.license_no, " + |
|||
" l.validity " + |
|||
"FROM petdetails p " + |
|||
"INNER JOIN payment pay ON p.uniqueid = pay.uniqueid " + |
|||
"INNER JOIN pet_license l ON p.uniqueid = l.uniqueid " + |
|||
"INNER JOIN pet_owner o ON p.mobilenum = o.phone " + |
|||
"WHERE p.status = 2 AND p.uniqueid = '" + uniqueId + "'"; |
|||
|
|||
prPostData.fetpetData(sql); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
package com.gcc.erppostdata.petregistration; |
|||
|
|||
|
|||
import com.gcc.erppostdata.repo.PetLogRepo; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.scheduling.annotation.EnableScheduling; |
|||
import org.springframework.scheduling.annotation.Scheduled; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
//@Configuration |
|||
//@EnableScheduling |
|||
@Service |
|||
public class PetScheduler { |
|||
|
|||
@Autowired |
|||
PetQueryBank petQueryBank; |
|||
|
|||
@Autowired |
|||
PetLogRepo petLogRepo; |
|||
|
|||
@Scheduled(fixedRate = 3600000) // Runs every 1 hour (3600000 milliseconds) |
|||
public void oneHouseScheduledMethod() { |
|||
System.out.println("Executing one house scheduled method"); |
|||
petQueryBank.hourlyPushData(); |
|||
|
|||
} |
|||
@Scheduled(fixedRate = 10800000) |
|||
public void threeHouseScheduledMethod() { |
|||
System.out.println("im for ERP pet post data test"); |
|||
List<Map<String, Object>> dataByStatus = petLogRepo.getDataByStatus(String.valueOf(0)); |
|||
for (Map<String, Object> data : dataByStatus) { |
|||
petQueryBank.resendPushData(data.get("uniqueId").toString(), |
|||
data.get("id").toString() |
|||
); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
@Scheduled(fixedRate = 10000) |
|||
public void tensecScheduledMethod(){ |
|||
|
|||
// System.out.print("hello"); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
package com.gcc.erppostdata.repo; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.sql.DataSource; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
//@Repository |
|||
@Service |
|||
public class CommunityHallLogRepo { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource (@Qualifier("mysqlerpPostData") DataSource dataSource){ |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
public int insert(String transactionId, String bookingId, String status, String response) { |
|||
String sql = "INSERT INTO comm_post_data (transactionId, bookingId, status, response) VALUES (?, ?, ?, ?)"; |
|||
|
|||
return jdbcTemplate.update(sql, transactionId, bookingId, status, response); |
|||
|
|||
} |
|||
|
|||
public List<Map<String,Object>> getDataByStatus(String status) { |
|||
String sql = "SELECT * FROM comm_post_data WHERE status = ?"; |
|||
return jdbcTemplate.queryForList(sql, status); |
|||
} |
|||
|
|||
public int updateLog(String status,String response,String id){ |
|||
String sql = "UPDATE comm_post_data SET status = ?, response = ? WHERE id = ?"; |
|||
return jdbcTemplate.update(sql, status,response,id); |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
package com.gcc.erppostdata.repo; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.sql.DataSource; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class PetLogRepo { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource (@Qualifier("mysqlerpPostData") DataSource dataSource){ |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
public int insert(String uniqueId, String orderId,String paymentId, String status, String response) { |
|||
String sql = "INSERT INTO pet_post_data (uniqueId, orderId,paymentId, status, response) VALUES (?,?, ?, ?, ?)"; |
|||
|
|||
return jdbcTemplate.update(sql, uniqueId, orderId,paymentId, status, response); |
|||
|
|||
} |
|||
|
|||
public List<Map<String,Object>> getDataByStatus(String status) { |
|||
String sql = "SELECT * FROM pet_post_data WHERE status = ?"; |
|||
return jdbcTemplate.queryForList(sql, status); |
|||
} |
|||
|
|||
public int updateLog(String status,String response,String id){ |
|||
String sql = "UPDATE pet_post_data SET status = ?, response = ? WHERE id = ?"; |
|||
return jdbcTemplate.update(sql, status,response,id); |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package com.gcc.erppostdata.swimmingpool; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
@Component |
|||
public class SPPostData { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource (@Qualifier("mysqlSwimmingPoolDataSource") DataSource dataSource){ |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
} |
|||
@ -0,0 +1,2 @@ |
|||
app.erpUrl=http://coc-staging.egovernments.org:9980/pgr/external/mobileservice? |
|||
|
|||
@ -0,0 +1 @@ |
|||
app.erpUrl=https://erp.chennaicorporation.gov.in/pgr/external/mobileservice? |
|||
@ -0,0 +1,9 @@ |
|||
spring.application.name=erppostdata |
|||
|
|||
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/erppostdata |
|||
spring.datasource.username=root |
|||
spring.datasource.password=root |
|||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver |
|||
|
|||
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect |
|||
spring.jpa.hibernate.ddl-auto=update |
|||
@ -0,0 +1,13 @@ |
|||
package com.gcc.erppostdata; |
|||
|
|||
import org.junit.jupiter.api.Test; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
|
|||
@SpringBootTest |
|||
class ErppostdataApplicationTests { |
|||
|
|||
@Test |
|||
void contextLoads() { |
|||
} |
|||
|
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue