commit
a8945ea91d
9387 changed files with 1719695 additions and 0 deletions
-
308mvnw
-
205mvnw.cmd
-
156pom.xml
-
BINsrc/.DS_Store
-
BINsrc/main/.DS_Store
-
BINsrc/main/java/.DS_Store
-
BINsrc/main/java/in/.DS_Store
-
BINsrc/main/java/in/gov/.DS_Store
-
BINsrc/main/java/in/gov/chennaicorporation/.DS_Store
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/.DS_Store
-
26src/main/java/in/gov/chennaicorporation/gccoffice/GccOfficeApplication.java
-
151src/main/java/in/gov/chennaicorporation/gccoffice/c_petition/controller/APIController.java
-
130src/main/java/in/gov/chennaicorporation/gccoffice/c_petition/controller/MainController.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/c_petition/controller/package-info.java
-
21src/main/java/in/gov/chennaicorporation/gccoffice/c_petition/data/ComplaintType.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/c_petition/data/package-info.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/c_petition/entity/package-info.java
-
7src/main/java/in/gov/chennaicorporation/gccoffice/c_petition/package-info.java
-
709src/main/java/in/gov/chennaicorporation/gccoffice/c_petition/service/Petition.java
-
58src/main/java/in/gov/chennaicorporation/gccoffice/c_petition/service/PetitionMaster.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/c_petition/service/package-info.java
-
112src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/AgentAssignAPIController.java
-
320src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/AgentsAPIController.java
-
36src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/AttendanceAPIController.java
-
643src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/CampaignAPIController.java
-
29src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/CampaignDropdownApiController.java
-
100src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/CampaignReportAPIController.java
-
281src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/CategoryAPIController.java
-
219src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/MainController.java
-
26src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/controller/WhatsappController.java
-
303src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/AddcategoryServices.java
-
214src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/AgentAssignService.java
-
665src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/AgentsService.java
-
116src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/AttendanceService.java
-
29src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/CampaignDropdownApiService.java
-
533src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/CampaignReportService.java
-
715src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/CampaignService.java
-
40src/main/java/in/gov/chennaicorporation/gccoffice/callcenter/service/WhatsappMsgService.java
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/.DS_Store
-
36src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/AttendanceApiController.java
-
71src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/AttendanceMainController.java
-
672src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/ComplaintController.java
-
31src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/ComplaintStatusMainController.java
-
278src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/DomesticWasteApiController.java
-
73src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/DomesticWasteMainController.java
-
85src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/FollowUpController.java
-
96src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/InprogresscallController.java
-
370src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/MainController.java
-
89src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/PublicFollowUpController.java
-
391src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcAPIController.java
-
208src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcAdminSettingsApiController.java
-
47src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcAdminSettingsMainController.java
-
234src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcAgentAssignAPIController.java
-
161src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcAgentsAPIController.java
-
519src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcCallsController.java
-
38src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcPgrComplaintsMainController.java
-
68src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/QaqcTaskListAPIController.java
-
58src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/ReportsMainController.java
-
563src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/ScpApiController.java
-
55src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/ScpMaincontroller.java
-
464src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/SocialMediaApiController.java
-
50src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/SocialMediaMainController.java
-
82src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/StatusCountController.java
-
147src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/WhatsappController.java
-
95src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/ComplaintService.java
-
308src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/DomesticWasteService.java
-
224src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/FollowUpService.java
-
102src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/InprogresscallService.java
-
52src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/PublicFollowUpService.java
-
123src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcAdminSettingService.java
-
1166src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcAgentAssignService.java
-
686src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcAgentsService.java
-
391src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcCallsService.java
-
357src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcService.java
-
291src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcTaskListService.java
-
361src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/ScpService.java
-
822src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/SocialMediaService.java
-
274src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/StatusCountService.java
-
234src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/WhatsappqaqcMsgService.java
-
174src/main/java/in/gov/chennaicorporation/gccoffice/cdwaste/controller/DumpRegistrationAPIController.java
-
75src/main/java/in/gov/chennaicorporation/gccoffice/cdwaste/controller/MainController.java
-
195src/main/java/in/gov/chennaicorporation/gccoffice/cdwaste/service/OfficerService.java
-
40src/main/java/in/gov/chennaicorporation/gccoffice/cdwaste/service/SMSService.java
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/cdwastecollectorregistrations/.DS_Store
-
111src/main/java/in/gov/chennaicorporation/gccoffice/cdwastecollectorregistrations/controller/ApiController.java
-
142src/main/java/in/gov/chennaicorporation/gccoffice/cdwastecollectorregistrations/controller/MainController.java
-
29src/main/java/in/gov/chennaicorporation/gccoffice/cdwastecollectorregistrations/controller/WhatsappControllerCD.java
-
33src/main/java/in/gov/chennaicorporation/gccoffice/cdwastecollectorregistrations/service/RegistrationService.java
-
41src/main/java/in/gov/chennaicorporation/gccoffice/cdwastecollectorregistrations/service/WhatsappMsgService.java
-
428src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Controller/ChildrenSurveyController.java
-
102src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Controller/MainController.java
-
3375src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java
-
58src/main/java/in/gov/chennaicorporation/gccoffice/circular/controller/APIController.java
-
61src/main/java/in/gov/chennaicorporation/gccoffice/circular/controller/MainController.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/circular/controller/package-info.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/circular/package-info.java
-
223src/main/java/in/gov/chennaicorporation/gccoffice/circular/service/CircularMaster.java
-
1src/main/java/in/gov/chennaicorporation/gccoffice/circular/service/package-info.java
-
BINsrc/main/java/in/gov/chennaicorporation/gccoffice/com_petition/.DS_Store
-
219src/main/java/in/gov/chennaicorporation/gccoffice/com_petition/controller/APIController.java
@ -0,0 +1,308 @@ |
|||
#!/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 |
|||
# |
|||
# https://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.2.0 |
|||
# |
|||
# Required ENV vars: |
|||
# ------------------ |
|||
# JAVA_HOME - location of a JDK home dir |
|||
# |
|||
# Optional ENV vars |
|||
# ----------------- |
|||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven |
|||
# e.g. to debug Maven itself, use |
|||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 |
|||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files |
|||
# ---------------------------------------------------------------------------- |
|||
|
|||
if [ -z "$MAVEN_SKIP_RC" ] ; then |
|||
|
|||
if [ -f /usr/local/etc/mavenrc ] ; then |
|||
. /usr/local/etc/mavenrc |
|||
fi |
|||
|
|||
if [ -f /etc/mavenrc ] ; then |
|||
. /etc/mavenrc |
|||
fi |
|||
|
|||
if [ -f "$HOME/.mavenrc" ] ; then |
|||
. "$HOME/.mavenrc" |
|||
fi |
|||
|
|||
fi |
|||
|
|||
# OS specific support. $var _must_ be set to either true or false. |
|||
cygwin=false; |
|||
darwin=false; |
|||
mingw=false |
|||
case "$(uname)" in |
|||
CYGWIN*) cygwin=true ;; |
|||
MINGW*) mingw=true;; |
|||
Darwin*) darwin=true |
|||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home |
|||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html |
|||
if [ -z "$JAVA_HOME" ]; then |
|||
if [ -x "/usr/libexec/java_home" ]; then |
|||
JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME |
|||
else |
|||
JAVA_HOME="/Library/Java/Home"; export JAVA_HOME |
|||
fi |
|||
fi |
|||
;; |
|||
esac |
|||
|
|||
if [ -z "$JAVA_HOME" ] ; then |
|||
if [ -r /etc/gentoo-release ] ; then |
|||
JAVA_HOME=$(java-config --jre-home) |
|||
fi |
|||
fi |
|||
|
|||
# For Cygwin, ensure paths are in UNIX format before anything is touched |
|||
if $cygwin ; then |
|||
[ -n "$JAVA_HOME" ] && |
|||
JAVA_HOME=$(cygpath --unix "$JAVA_HOME") |
|||
[ -n "$CLASSPATH" ] && |
|||
CLASSPATH=$(cygpath --path --unix "$CLASSPATH") |
|||
fi |
|||
|
|||
# For Mingw, ensure paths are in UNIX format before anything is touched |
|||
if $mingw ; then |
|||
[ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && |
|||
JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" |
|||
fi |
|||
|
|||
if [ -z "$JAVA_HOME" ]; then |
|||
javaExecutable="$(which javac)" |
|||
if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then |
|||
# readlink(1) is not available as standard on Solaris 10. |
|||
readLink=$(which readlink) |
|||
if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then |
|||
if $darwin ; then |
|||
javaHome="$(dirname "\"$javaExecutable\"")" |
|||
javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" |
|||
else |
|||
javaExecutable="$(readlink -f "\"$javaExecutable\"")" |
|||
fi |
|||
javaHome="$(dirname "\"$javaExecutable\"")" |
|||
javaHome=$(expr "$javaHome" : '\(.*\)/bin') |
|||
JAVA_HOME="$javaHome" |
|||
export JAVA_HOME |
|||
fi |
|||
fi |
|||
fi |
|||
|
|||
if [ -z "$JAVACMD" ] ; then |
|||
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" |
|||
else |
|||
JAVACMD="$JAVA_HOME/bin/java" |
|||
fi |
|||
else |
|||
JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" |
|||
fi |
|||
fi |
|||
|
|||
if [ ! -x "$JAVACMD" ] ; then |
|||
echo "Error: JAVA_HOME is not defined correctly." >&2 |
|||
echo " We cannot execute $JAVACMD" >&2 |
|||
exit 1 |
|||
fi |
|||
|
|||
if [ -z "$JAVA_HOME" ] ; then |
|||
echo "Warning: JAVA_HOME environment variable is not set." |
|||
fi |
|||
|
|||
# traverses directory structure from process work directory to filesystem root |
|||
# first directory with .mvn subdirectory is considered project base directory |
|||
find_maven_basedir() { |
|||
if [ -z "$1" ] |
|||
then |
|||
echo "Path not specified to find_maven_basedir" |
|||
return 1 |
|||
fi |
|||
|
|||
basedir="$1" |
|||
wdir="$1" |
|||
while [ "$wdir" != '/' ] ; do |
|||
if [ -d "$wdir"/.mvn ] ; then |
|||
basedir=$wdir |
|||
break |
|||
fi |
|||
# workaround for JBEAP-8937 (on Solaris 10/Sparc) |
|||
if [ -d "${wdir}" ]; then |
|||
wdir=$(cd "$wdir/.." || exit 1; pwd) |
|||
fi |
|||
# end of workaround |
|||
done |
|||
printf '%s' "$(cd "$basedir" || exit 1; pwd)" |
|||
} |
|||
|
|||
# concatenates all lines of a file |
|||
concat_lines() { |
|||
if [ -f "$1" ]; then |
|||
# Remove \r in case we run on Windows within Git Bash |
|||
# and check out the repository with auto CRLF management |
|||
# enabled. Otherwise, we may read lines that are delimited with |
|||
# \r\n and produce $'-Xarg\r' rather than -Xarg due to word |
|||
# splitting rules. |
|||
tr -s '\r\n' ' ' < "$1" |
|||
fi |
|||
} |
|||
|
|||
log() { |
|||
if [ "$MVNW_VERBOSE" = true ]; then |
|||
printf '%s\n' "$1" |
|||
fi |
|||
} |
|||
|
|||
BASE_DIR=$(find_maven_basedir "$(dirname "$0")") |
|||
if [ -z "$BASE_DIR" ]; then |
|||
exit 1; |
|||
fi |
|||
|
|||
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR |
|||
log "$MAVEN_PROJECTBASEDIR" |
|||
|
|||
########################################################################################## |
|||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central |
|||
# This allows using the maven wrapper in projects that prohibit checking in binary data. |
|||
########################################################################################## |
|||
wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" |
|||
if [ -r "$wrapperJarPath" ]; then |
|||
log "Found $wrapperJarPath" |
|||
else |
|||
log "Couldn't find $wrapperJarPath, downloading it ..." |
|||
|
|||
if [ -n "$MVNW_REPOURL" ]; then |
|||
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" |
|||
else |
|||
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" |
|||
fi |
|||
while IFS="=" read -r key value; do |
|||
# Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) |
|||
safeValue=$(echo "$value" | tr -d '\r') |
|||
case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; |
|||
esac |
|||
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" |
|||
log "Downloading from: $wrapperUrl" |
|||
|
|||
if $cygwin; then |
|||
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") |
|||
fi |
|||
|
|||
if command -v wget > /dev/null; then |
|||
log "Found wget ... using wget" |
|||
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" |
|||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then |
|||
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" |
|||
else |
|||
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" |
|||
fi |
|||
elif command -v curl > /dev/null; then |
|||
log "Found curl ... using curl" |
|||
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" |
|||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then |
|||
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" |
|||
else |
|||
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" |
|||
fi |
|||
else |
|||
log "Falling back to using Java to download" |
|||
javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" |
|||
javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" |
|||
# For Cygwin, switch paths to Windows format before running javac |
|||
if $cygwin; then |
|||
javaSource=$(cygpath --path --windows "$javaSource") |
|||
javaClass=$(cygpath --path --windows "$javaClass") |
|||
fi |
|||
if [ -e "$javaSource" ]; then |
|||
if [ ! -e "$javaClass" ]; then |
|||
log " - Compiling MavenWrapperDownloader.java ..." |
|||
("$JAVA_HOME/bin/javac" "$javaSource") |
|||
fi |
|||
if [ -e "$javaClass" ]; then |
|||
log " - Running MavenWrapperDownloader.java ..." |
|||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" |
|||
fi |
|||
fi |
|||
fi |
|||
fi |
|||
########################################################################################## |
|||
# End of extension |
|||
########################################################################################## |
|||
|
|||
# If specified, validate the SHA-256 sum of the Maven wrapper jar file |
|||
wrapperSha256Sum="" |
|||
while IFS="=" read -r key value; do |
|||
case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; |
|||
esac |
|||
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" |
|||
if [ -n "$wrapperSha256Sum" ]; then |
|||
wrapperSha256Result=false |
|||
if command -v sha256sum > /dev/null; then |
|||
if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then |
|||
wrapperSha256Result=true |
|||
fi |
|||
elif command -v shasum > /dev/null; then |
|||
if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then |
|||
wrapperSha256Result=true |
|||
fi |
|||
else |
|||
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." |
|||
echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." |
|||
exit 1 |
|||
fi |
|||
if [ $wrapperSha256Result = false ]; then |
|||
echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 |
|||
echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 |
|||
echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 |
|||
exit 1 |
|||
fi |
|||
fi |
|||
|
|||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" |
|||
|
|||
# For Cygwin, switch paths to Windows format before running java |
|||
if $cygwin; then |
|||
[ -n "$JAVA_HOME" ] && |
|||
JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") |
|||
[ -n "$CLASSPATH" ] && |
|||
CLASSPATH=$(cygpath --path --windows "$CLASSPATH") |
|||
[ -n "$MAVEN_PROJECTBASEDIR" ] && |
|||
MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") |
|||
fi |
|||
|
|||
# Provide a "standardized" way to retrieve the CLI args that will |
|||
# work with both Windows and non-Windows executions. |
|||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" |
|||
export MAVEN_CMD_LINE_ARGS |
|||
|
|||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain |
|||
|
|||
# shellcheck disable=SC2086 # safe args |
|||
exec "$JAVACMD" \ |
|||
$MAVEN_OPTS \ |
|||
$MAVEN_DEBUG_OPTS \ |
|||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ |
|||
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ |
|||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" |
|||
@ -0,0 +1,205 @@ |
|||
@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 https://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.2.0 |
|||
@REM |
|||
@REM Required ENV vars: |
|||
@REM JAVA_HOME - location of a JDK home dir |
|||
@REM |
|||
@REM Optional ENV vars |
|||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands |
|||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending |
|||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven |
|||
@REM e.g. to debug Maven itself, use |
|||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 |
|||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files |
|||
@REM ---------------------------------------------------------------------------- |
|||
|
|||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' |
|||
@echo off |
|||
@REM set title of command window |
|||
title %0 |
|||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' |
|||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% |
|||
|
|||
@REM set %HOME% to equivalent of $HOME |
|||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") |
|||
|
|||
@REM Execute a user defined script before this one |
|||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre |
|||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending |
|||
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* |
|||
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* |
|||
:skipRcPre |
|||
|
|||
@setlocal |
|||
|
|||
set ERROR_CODE=0 |
|||
|
|||
@REM To isolate internal variables from possible post scripts, we use another setlocal |
|||
@setlocal |
|||
|
|||
@REM ==== START VALIDATION ==== |
|||
if not "%JAVA_HOME%" == "" goto OkJHome |
|||
|
|||
echo. |
|||
echo Error: JAVA_HOME not found in your environment. >&2 |
|||
echo Please set the JAVA_HOME variable in your environment to match the >&2 |
|||
echo location of your Java installation. >&2 |
|||
echo. |
|||
goto error |
|||
|
|||
:OkJHome |
|||
if exist "%JAVA_HOME%\bin\java.exe" goto init |
|||
|
|||
echo. |
|||
echo Error: JAVA_HOME is set to an invalid directory. >&2 |
|||
echo JAVA_HOME = "%JAVA_HOME%" >&2 |
|||
echo Please set the JAVA_HOME variable in your environment to match the >&2 |
|||
echo location of your Java installation. >&2 |
|||
echo. |
|||
goto error |
|||
|
|||
@REM ==== END VALIDATION ==== |
|||
|
|||
:init |
|||
|
|||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". |
|||
@REM Fallback to current working directory if not found. |
|||
|
|||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% |
|||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir |
|||
|
|||
set EXEC_DIR=%CD% |
|||
set WDIR=%EXEC_DIR% |
|||
:findBaseDir |
|||
IF EXIST "%WDIR%"\.mvn goto baseDirFound |
|||
cd .. |
|||
IF "%WDIR%"=="%CD%" goto baseDirNotFound |
|||
set WDIR=%CD% |
|||
goto findBaseDir |
|||
|
|||
:baseDirFound |
|||
set MAVEN_PROJECTBASEDIR=%WDIR% |
|||
cd "%EXEC_DIR%" |
|||
goto endDetectBaseDir |
|||
|
|||
:baseDirNotFound |
|||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR% |
|||
cd "%EXEC_DIR%" |
|||
|
|||
:endDetectBaseDir |
|||
|
|||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig |
|||
|
|||
@setlocal EnableExtensions EnableDelayedExpansion |
|||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a |
|||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% |
|||
|
|||
:endReadAdditionalConfig |
|||
|
|||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" |
|||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" |
|||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain |
|||
|
|||
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" |
|||
|
|||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( |
|||
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B |
|||
) |
|||
|
|||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central |
|||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data. |
|||
if exist %WRAPPER_JAR% ( |
|||
if "%MVNW_VERBOSE%" == "true" ( |
|||
echo Found %WRAPPER_JAR% |
|||
) |
|||
) else ( |
|||
if not "%MVNW_REPOURL%" == "" ( |
|||
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" |
|||
) |
|||
if "%MVNW_VERBOSE%" == "true" ( |
|||
echo Couldn't find %WRAPPER_JAR%, downloading it ... |
|||
echo Downloading from: %WRAPPER_URL% |
|||
) |
|||
|
|||
powershell -Command "&{"^ |
|||
"$webclient = new-object System.Net.WebClient;"^ |
|||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ |
|||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ |
|||
"}"^ |
|||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ |
|||
"}" |
|||
if "%MVNW_VERBOSE%" == "true" ( |
|||
echo Finished downloading %WRAPPER_JAR% |
|||
) |
|||
) |
|||
@REM End of extension |
|||
|
|||
@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file |
|||
SET WRAPPER_SHA_256_SUM="" |
|||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( |
|||
IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B |
|||
) |
|||
IF NOT %WRAPPER_SHA_256_SUM%=="" ( |
|||
powershell -Command "&{"^ |
|||
"$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ |
|||
"If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ |
|||
" Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ |
|||
" Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ |
|||
" Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ |
|||
" exit 1;"^ |
|||
"}"^ |
|||
"}" |
|||
if ERRORLEVEL 1 goto error |
|||
) |
|||
|
|||
@REM Provide a "standardized" way to retrieve the CLI args that will |
|||
@REM work with both Windows and non-Windows executions. |
|||
set MAVEN_CMD_LINE_ARGS=%* |
|||
|
|||
%MAVEN_JAVA_EXE% ^ |
|||
%JVM_CONFIG_MAVEN_PROPS% ^ |
|||
%MAVEN_OPTS% ^ |
|||
%MAVEN_DEBUG_OPTS% ^ |
|||
-classpath %WRAPPER_JAR% ^ |
|||
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ |
|||
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* |
|||
if ERRORLEVEL 1 goto error |
|||
goto end |
|||
|
|||
:error |
|||
set ERROR_CODE=1 |
|||
|
|||
:end |
|||
@endlocal & set ERROR_CODE=%ERROR_CODE% |
|||
|
|||
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost |
|||
@REM check for post script, once with legacy .bat ending and once with .cmd ending |
|||
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" |
|||
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" |
|||
:skipRcPost |
|||
|
|||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' |
|||
if "%MAVEN_BATCH_PAUSE%"=="on" pause |
|||
|
|||
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% |
|||
|
|||
cmd /C exit /B %ERROR_CODE% |
|||
@ -0,0 +1,156 @@ |
|||
<?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>2.5.4</version>--> |
|||
<version>2.5.4</version> <!-- or the latest 3.x version --> |
|||
<relativePath/> <!-- lookup parent from repository --> |
|||
</parent> |
|||
<!--<packaging>war</packaging>--> |
|||
<groupId>in.gov.chennaicorporation</groupId> |
|||
<artifactId>gccoffice</artifactId> |
|||
<version>0.0.1</version> |
|||
<name>GCC OFFICE</name> |
|||
<description>GCC Applications and Dashboard</description> |
|||
<properties> |
|||
<java.version>17</java.version> |
|||
<bootstrap.version>4.0.0-2</bootstrap.version> |
|||
<webjars-locator.version>0.30</webjars-locator.version> |
|||
<lombok.version>1.18.2</lombok.version> |
|||
<maven.compiler.source>17</maven.compiler.source> |
|||
<maven.compiler.target>17</maven.compiler.target> |
|||
</properties> |
|||
<dependencies> |
|||
|
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-security</artifactId> |
|||
</dependency> |
|||
<!-- |
|||
<dependency> |
|||
<groupId>org.springframework.cloud</groupId> |
|||
<artifactId>spring-cloud-starter-netflix-eureka-client</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.thymeleaf.extras</groupId> |
|||
<artifactId>thymeleaf-extras-springsecurity6</artifactId> |
|||
<version>3.1.1.RELEASE</version> <!-- Replace with the appropriate version --> |
|||
</dependency> |
|||
|
|||
<!-- Spring Boot Starter Data JPA --> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-data-jpa</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.mysql</groupId> |
|||
<artifactId>mysql-connector-j</artifactId> |
|||
<version>8.0.33</version> <!-- Replace with the appropriate version --> |
|||
<scope>runtime</scope> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>com.oracle.database.jdbc</groupId> |
|||
<artifactId>ojdbc8</artifactId> |
|||
<scope>runtime</scope> |
|||
</dependency> |
|||
<!-- Use jakarta.persistence --> |
|||
<dependency> |
|||
<groupId>jakarta.persistence</groupId> |
|||
<artifactId>jakarta.persistence-api</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.fasterxml.jackson.datatype</groupId> |
|||
<artifactId>jackson-datatype-jsr310</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>org.hibernate</groupId> |
|||
<artifactId>hibernate-core</artifactId> |
|||
</dependency> |
|||
|
|||
|
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-tomcat</artifactId> |
|||
<scope>provided</scope> |
|||
</dependency> |
|||
|
|||
<!-- |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-test</artifactId> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.security</groupId> |
|||
<artifactId>spring-security-test</artifactId> |
|||
<scope>test</scope> |
|||
</dependency> |
|||
--> |
|||
|
|||
<dependency> |
|||
<groupId>org.apache.poi</groupId> |
|||
<artifactId>poi-ooxml</artifactId> |
|||
<version>5.2.2</version> |
|||
</dependency> |
|||
|
|||
|
|||
<dependency> |
|||
<groupId>org.apache.poi</groupId> |
|||
<artifactId>poi</artifactId> |
|||
<version>5.2.2</version> |
|||
</dependency> |
|||
|
|||
<!-- <dependency> |
|||
<groupId>in.gov.chennaicorporation</groupId> |
|||
<artifactId>Community-Hall-Booking</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
</dependency> --> |
|||
<!-- |
|||
<dependency> |
|||
<groupId>org.jsoup</groupId> |
|||
<artifactId>jsoup</artifactId> |
|||
<version>1.14.3</version> |
|||
</dependency> |
|||
--> |
|||
</dependencies> |
|||
|
|||
<!-- Spring Cloud dependencies --> |
|||
<!-- |
|||
<dependencyManagement> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>org.springframework.cloud</groupId> |
|||
<artifactId>spring-cloud-dependencies</artifactId> |
|||
<version>2020.0.4</version> |
|||
<type>pom</type> |
|||
<scope>import</scope> |
|||
</dependency> |
|||
</dependencies> |
|||
</dependencyManagement> |
|||
--> |
|||
<build> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-maven-plugin</artifactId> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
|
|||
</project> |
|||
@ -0,0 +1,26 @@ |
|||
package in.gov.chennaicorporation.gccoffice; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import org.springframework.boot.autoconfigure.domain.EntityScan; |
|||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
|||
//import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
|||
import org.springframework.context.annotation.ComponentScan; |
|||
|
|||
@EntityScan(basePackages = { |
|||
"in.gov.chennaicorporation.gccoffice", |
|||
"in.gov.chennaicorporation.gccoffice.taxcollection.entity" |
|||
}) |
|||
@ComponentScan(basePackages = { |
|||
"in.gov.chennaicorporation.gccoffice", |
|||
"in.gov.chennaicorporation.gccoffice.taxcollection", |
|||
"in.gov.chennaicorporation.gccoffice.garbagecollection" |
|||
}) |
|||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class) |
|||
//@EnableDiscoveryClient |
|||
public class GccOfficeApplication { |
|||
public static void main(String[] args) { |
|||
//System.setProperty("spring.config.name", "gcc-portal"); |
|||
SpringApplication.run(GccOfficeApplication.class, args); |
|||
} |
|||
} |
|||
@ -0,0 +1,151 @@ |
|||
package in.gov.chennaicorporation.gccoffice.c_petition.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.c_petition.service.Petition; |
|||
import in.gov.chennaicorporation.gccoffice.c_petition.service.PetitionMaster; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("gcc/api/c_petition") |
|||
@RestController("cpRest") // Mayor Petition Rest |
|||
public class APIController { |
|||
private PetitionMaster petitionMaster; |
|||
private Petition petition; |
|||
|
|||
@Autowired |
|||
public APIController(PetitionMaster petitionMaster,Petition petition) { |
|||
this.petitionMaster = petitionMaster; |
|||
this.petition = petition; |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintTypes") |
|||
public List getComplaintTypeList() { |
|||
return petitionMaster.getComplaintType(); |
|||
} |
|||
|
|||
@GetMapping(value="/getOfficerList") |
|||
public List getOfficerList() { |
|||
return petitionMaster.getOfficerList(); |
|||
} |
|||
|
|||
@GetMapping(value="/getPetitionList") |
|||
public List getPetitionList() { |
|||
return petition.getPetitionList(); |
|||
} |
|||
|
|||
@GetMapping(value="/getUnmapPetitionList") |
|||
public List getUnmapPetitionList() { |
|||
return petition.getUnmapPetitionList(); |
|||
} |
|||
|
|||
@GetMapping(value="/getPetitionDetails") |
|||
public List getPetitionDetails(@RequestParam("petitionNo") String petitionNo) { |
|||
return petition.getPetitionDetails(petitionNo); |
|||
} |
|||
|
|||
@PostMapping(value="/savePetition") |
|||
public String savePetition( |
|||
@RequestParam("createdBy") String createdBy, |
|||
@RequestParam("petition_type") String petitionType, |
|||
@RequestParam("petitionerName") String petitionerName, |
|||
@RequestParam("petitionerMobile") String petitionerMobile, |
|||
@RequestParam("complaintType") String petitionerComplaint, |
|||
@RequestParam("san_page1") MultipartFile page1, |
|||
@RequestParam("san_page2") MultipartFile page2, |
|||
@RequestParam("san_page3") MultipartFile page3, |
|||
@RequestParam("san_page4") MultipartFile page4) { |
|||
|
|||
return petition.savePetition(petitionType,createdBy, petitionerName, petitionerMobile, petitionerComplaint, page1, page2, page3, page4); |
|||
} |
|||
|
|||
@PostMapping(value="/updatePetition") |
|||
public Boolean updatePetition( |
|||
@RequestParam("petitionType") String petitionType, |
|||
@RequestParam("petitionNo") String petitionNo, |
|||
@RequestParam("createdBy") String createdBy, |
|||
@RequestParam("petitionerName") String petitionerName, |
|||
@RequestParam("petitionerMobile") String petitionerMobile, |
|||
@RequestParam("petitionerAddress") String petitionerAddress, |
|||
@RequestParam("petitionerPincode") String petitionerPincode, |
|||
@RequestParam("complaintType") String petitionerComplaint, |
|||
@RequestParam("complaintNature") String complaintNature) { |
|||
|
|||
return petition.updatePetition(petitionNo, petitionType, createdBy, petitionerName, petitionerMobile, petitionerAddress, petitionerPincode, petitionerComplaint, complaintNature); |
|||
} |
|||
|
|||
@PostMapping(value="/mapComplientToOfficer") |
|||
public Boolean updatePetition( |
|||
@RequestParam("petitionId") String petitionId, |
|||
@RequestParam("petitionNo") String petitionNo, |
|||
@RequestParam("createdBy") String createdBy, |
|||
@RequestParam(value = "", required = false) String mapOfficers) { |
|||
|
|||
String com_mapping = mapOfficers; |
|||
|
|||
// First before Mapping need to unmaps old list |
|||
petition.unmapComplient(petitionId, petitionNo); |
|||
|
|||
if(com_mapping!=null) { |
|||
String[] com_mapping_parts = com_mapping.split(","); |
|||
for (String values : com_mapping_parts) { |
|||
String[] com_mapping_val = values.split("_"); |
|||
if (com_mapping_val.length > 0) { |
|||
String complientId = com_mapping_val[0]; |
|||
String offcierId = com_mapping_val[1]; |
|||
petition.mapComplientToOfficer(createdBy, petitionId, petitionNo, complientId, offcierId); |
|||
} |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
|
|||
@GetMapping(value="/getComplaintMappingDetails") |
|||
public List getComplaintMappingDetails( |
|||
@RequestParam("petitionId") String petitionId, |
|||
@RequestParam("petitionNo") String petitionNo, |
|||
@RequestParam("complaintTypeId") String complaintTypeId) { |
|||
return petition.getComplaintMappingDetails(petitionNo,petitionId,complaintTypeId); |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintList") |
|||
public List getComplaintList() { |
|||
return petition.getComplaintList(); |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintListByPetitionId") |
|||
public List getComplaintList(@RequestParam("petitionId") String petitionId) { |
|||
return petition.getComplaintListByPetitionId(petitionId); |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintDetails") |
|||
public List<?> getComplaintDetails(@RequestParam("mapId") String mapId) { |
|||
return petition.getComplaintDetails(mapId); |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintActionDetails") |
|||
public List<?> getComplaintActionDetails(@RequestParam("mapId") String mapId) { |
|||
return petition.getComplaintActionDetails(mapId); |
|||
} |
|||
|
|||
@PostMapping(value="/saveComplanitStatus") |
|||
public String saveComplanitStatus( |
|||
@RequestParam("createdBy") String createdBy, |
|||
@RequestParam("mapId") String mapId, |
|||
@RequestParam("complaintStatus") String complaintStatus, |
|||
@RequestParam("complaintActionText") String complaintActionText, |
|||
@RequestParam("action_san_page1") MultipartFile actionPage1, |
|||
@RequestParam("petitionId") String petitionId, |
|||
@RequestParam("petitionNo") String petitionNo) { |
|||
|
|||
return petition.saveComplanitStatus(createdBy, mapId, complaintStatus, complaintActionText, actionPage1, petitionId, petitionNo); |
|||
} |
|||
} |
|||
@ -0,0 +1,130 @@ |
|||
package in.gov.chennaicorporation.gccoffice.c_petition.controller; |
|||
|
|||
import org.hibernate.hql.internal.ast.tree.RestrictableStatement; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.service.Base64Util; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/c_petition") |
|||
@Controller("CouncillorPetitionController") |
|||
public class MainController { |
|||
private final RestTemplate restTemplate; |
|||
private String BasePath = "modules/c_petition/"; |
|||
@Autowired |
|||
public MainController(RestTemplate restTemplate) { |
|||
this.restTemplate = restTemplate; |
|||
} |
|||
|
|||
@GetMapping({"", "/", "/index", "/dashboard"}) |
|||
public String dashboard(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"index"; |
|||
} |
|||
|
|||
@GetMapping({"/new_petition"}) |
|||
public String newPetition(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"new_petition"; |
|||
} |
|||
|
|||
@GetMapping("/petition-ack/{petitionNo}") |
|||
public String petitionAck(Model model,@PathVariable("petitionNo") String petitionNo) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
model.addAttribute("petitionNo",petitionNo); |
|||
return BasePath+"petition_ack"; |
|||
} |
|||
|
|||
@GetMapping("/petition-list") |
|||
public String petitionList(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"petition_list"; |
|||
} |
|||
|
|||
@GetMapping("/unmapped-petition-list") |
|||
public String unMappedPetitionList(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"petition_not_mapped_list"; |
|||
} |
|||
|
|||
@GetMapping("/update-petition") |
|||
public String petitionUpadte(Model model,@RequestParam(value="petitionNo", required = false) String petitionNo) { |
|||
|
|||
if (petitionNo != null && !petitionNo.isEmpty()) { |
|||
// Decrypt the encrypted value |
|||
petitionNo = Base64Util.decodeBase64(petitionNo); |
|||
} |
|||
else { |
|||
petitionNo = null; |
|||
} |
|||
|
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
model.addAttribute("petitionNo",petitionNo); |
|||
return BasePath+"petition_update"; |
|||
} |
|||
|
|||
@GetMapping("/view-petition") |
|||
public String petitionView(Model model,@RequestParam(value="petitionNo", required = false) String petitionNo) { |
|||
|
|||
if (petitionNo != null && !petitionNo.isEmpty()) { |
|||
// Decrypt the encrypted value |
|||
petitionNo = Base64Util.decodeBase64(petitionNo); |
|||
} |
|||
else { |
|||
petitionNo = null; |
|||
} |
|||
|
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
model.addAttribute("petitionNo",petitionNo); |
|||
return BasePath+"petition_view"; |
|||
} |
|||
|
|||
@GetMapping("/view-petition-modal") |
|||
public String petitionViewModal(Model model,@RequestParam(value="petitionNo", required = false) String petitionNo) { |
|||
|
|||
if (petitionNo != null && !petitionNo.isEmpty()) { |
|||
// Decrypt the encrypted value |
|||
petitionNo = Base64Util.decodeBase64(petitionNo); |
|||
} |
|||
else { |
|||
petitionNo = null; |
|||
} |
|||
|
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
model.addAttribute("petitionNo",petitionNo); |
|||
return BasePath+"petition_view_modal_page"; |
|||
} |
|||
|
|||
@GetMapping("/search-petition") |
|||
public String petitionSearch(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
//model.addAttribute("petitionNo",petitionNo); |
|||
return BasePath+"petition_update"; |
|||
} |
|||
|
|||
@GetMapping("/complaint-list") |
|||
public String complaintList(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"complaint_list"; |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.c_petition.controller; |
|||
@ -0,0 +1,21 @@ |
|||
package in.gov.chennaicorporation.gccoffice.c_petition.data; |
|||
|
|||
import java.util.Map; |
|||
|
|||
public class ComplaintType { |
|||
private int complaintTypeId; |
|||
private String complaintType; |
|||
|
|||
public ComplaintType(Map<String, Object> map) { |
|||
this.complaintTypeId = (int) map.get("complaint_typeid"); |
|||
this.complaintType = (String) map.get("complaint_type"); |
|||
} |
|||
|
|||
public int getComplaintTypeId() { |
|||
return complaintTypeId; |
|||
} |
|||
|
|||
public String getComplaintType() { |
|||
return complaintType; |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.c_petition.data; |
|||
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.c_petition.entity; |
|||
@ -0,0 +1,7 @@ |
|||
/** |
|||
* |
|||
*/ |
|||
/** |
|||
* |
|||
*/ |
|||
package in.gov.chennaicorporation.gccoffice.c_petition; |
|||
@ -0,0 +1,709 @@ |
|||
package in.gov.chennaicorporation.gccoffice.c_petition.service; |
|||
|
|||
import java.io.IOException; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.Statement; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.core.env.Environment; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.m_petition.data.ComplaintType; |
|||
import in.gov.chennaicorporation.gccoffice.service.Base64Util; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
import org.springframework.jdbc.core.PreparedStatementCreator; |
|||
import org.springframework.jdbc.support.GeneratedKeyHolder; |
|||
import org.springframework.jdbc.support.KeyHolder; |
|||
|
|||
@Service("cPetitionService") |
|||
public class Petition { |
|||
private JdbcTemplate jdbcTemplate; |
|||
private final Environment environment; |
|||
private PetitionMaster petitionMaster; |
|||
|
|||
@Autowired |
|||
public Petition(Environment environment,PetitionMaster petitionMaster) { |
|||
this.environment = environment; |
|||
this.petitionMaster = petitionMaster; |
|||
} |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysqlCouncillorPetitionDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List getComplaintTypeList() { |
|||
return petitionMaster.getComplaintType(); |
|||
} |
|||
/* |
|||
@Transactional(readOnly = true) |
|||
public static List<ComplaintType> convertToComplaintTypes(List<Map<String, Object>> complaintTypeMaps) { |
|||
return complaintTypeMaps.stream() |
|||
.map(ComplaintType::new) |
|||
.collect(Collectors.toList()); |
|||
} |
|||
*/ |
|||
@Transactional(readOnly = true) |
|||
public static List<ComplaintType> convertToComplaintTypes(List<Map<String, Object>> complaintTypeMaps) { |
|||
List<ComplaintType> complaintTypes = new ArrayList<>(); |
|||
for (Map<String, Object> complaintTypeMap : complaintTypeMaps) { |
|||
complaintTypes.add(new ComplaintType(complaintTypeMap)); |
|||
} |
|||
return complaintTypes; |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
// Method to map complaint type IDs to their respective complaint types |
|||
public static String mapComplaintTypes(List<ComplaintType> complaintTypes, String complaint) { |
|||
String[] complaintIds = complaint.split(","); |
|||
StringBuilder complaintTxtBuilder = new StringBuilder(); |
|||
|
|||
for (String complaintId : complaintIds) { |
|||
int id = Integer.parseInt(complaintId); |
|||
for (ComplaintType type : complaintTypes) { |
|||
if (type.getComplaintTypeId() == id) { |
|||
if (complaintTxtBuilder.length() > 0) { |
|||
complaintTxtBuilder.append(","); |
|||
} |
|||
complaintTxtBuilder.append(type.getComplaintType()); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return complaintTxtBuilder.toString(); |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getPetitionList() { |
|||
try { |
|||
String sqlQuery = "SELECT * FROM petition WHERE (`isactive`=1 AND `isdelete`=0)"; |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery); |
|||
Base64Util.encodeBase64(sqlQuery); |
|||
|
|||
// Iterate over the list of maps |
|||
for (Map<String, Object> map : result) { |
|||
// Get the value of the 'petitionNo' field from the map |
|||
String petitionNo = (String) map.get("petition_no"); |
|||
|
|||
// Encode the 'petitionNo' value using Base64Util |
|||
String petitionNoEncoded = Base64Util.encodeBase64(petitionNo); |
|||
|
|||
// Add the encoded value as 'petitionNoEncode' to the map |
|||
map.put("petitionNoEncode", petitionNoEncoded); |
|||
} |
|||
|
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getUnmapPetitionList() { |
|||
try { |
|||
String sqlQuery = "SELECT " |
|||
+ " p.* " |
|||
+ "FROM " |
|||
+ " `petition` p " |
|||
+ "WHERE " |
|||
+ " p.`isactive` = 1 AND p.`isdelete` = 0 " |
|||
+ " AND NOT EXISTS (" |
|||
+ " SELECT 1 " |
|||
+ " FROM `petition_mapping` pm " |
|||
+ " WHERE (p.`petition_id` = pm.`petition_id`) AND (pm.`isactive` = 1 AND pm.`isdelete` = 0 ) " |
|||
+ " )"; |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery); |
|||
|
|||
// Iterate over the list of maps |
|||
for (Map<String, Object> map : result) { |
|||
// Get the value of the 'petitionNo' field from the map |
|||
String petitionNo = (String) map.get("petition_no"); |
|||
|
|||
// Encode the 'petitionNo' value using Base64Util |
|||
String petitionNoEncoded = Base64Util.encodeBase64(petitionNo); |
|||
|
|||
// Add the encoded value as 'petitionNoEncode' to the map |
|||
map.put("petitionNoEncode", petitionNoEncoded); |
|||
} |
|||
|
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getPetitionDetails(String petitionNo) { |
|||
// String petitionNoEncoded = Base64Util.encodeBase64(petitionNo); |
|||
try { |
|||
String sqlQuery = "SELECT * FROM petition WHERE petition_no = ? AND (`isactive`=1 AND `isdelete`=0) LIMIT 1"; |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery, petitionNo); |
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public String savePetition( |
|||
String petitionType, |
|||
String createdBy, |
|||
String petitionerName, |
|||
String petitionerMobile, |
|||
String petitionerComplaint, |
|||
MultipartFile page1, |
|||
MultipartFile page2, |
|||
MultipartFile page3, |
|||
MultipartFile page4) { |
|||
|
|||
//System.out.println("I am from Service Page "+petitionerName); |
|||
|
|||
//String complaintNature = ""; |
|||
int lastInsertId = 0; |
|||
String sqlQuery = "INSERT INTO `petition` " |
|||
+ "(`petition_type`,`created_by`, `petitioner_name`, `petitioner_mobile`, " |
|||
+ "`petitioner_complaint`, `petitioner_complaint_txt`) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?)"; |
|||
|
|||
try { |
|||
// Complaint Type List |
|||
List complaintTypelist = getComplaintTypeList(); |
|||
// Convert the list of maps to a list of ComplaintType objects |
|||
List<ComplaintType> complaintTypes = convertToComplaintTypes(complaintTypelist); |
|||
|
|||
// Map complaint types |
|||
String petitionerComplaint_txt = mapComplaintTypes(complaintTypes, petitionerComplaint); |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
// Use JdbcTemplate's update method to execute the query with parameters |
|||
jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(sqlQuery, Statement.RETURN_GENERATED_KEYS); |
|||
ps.setString(1, petitionType); |
|||
ps.setString(2, createdBy); |
|||
ps.setString(3, petitionerName); |
|||
ps.setString(4, petitionerMobile); |
|||
ps.setString(5, petitionerComplaint); |
|||
ps.setString(6, petitionerComplaint_txt); |
|||
return ps; |
|||
}, keyHolder); |
|||
|
|||
// Get the last insert ID |
|||
lastInsertId = (int) keyHolder.getKey().longValue(); |
|||
|
|||
// Get the value of cp_ackno from application.properties |
|||
String ackno = environment.getProperty("cp_ackno"); |
|||
String ackno_prefix = environment.getProperty("cp_ackno_prefix"); |
|||
|
|||
// Convert ackno to int if needed |
|||
int acknoInt = Integer.parseInt(ackno); |
|||
|
|||
// Calculate the petition number |
|||
int petitionNo = (int) (lastInsertId + acknoInt); |
|||
|
|||
// Construct the petition number string |
|||
String petitionNoString = ackno_prefix + petitionNo; |
|||
|
|||
// Update the petition number in the database |
|||
updatePetitionNumber(lastInsertId, petitionNoString); |
|||
|
|||
// Add Petition Scan File in the database |
|||
addPetitionFile(createdBy,lastInsertId, petitionNoString, page1, page2, page3, page4); |
|||
|
|||
return petitionNoString; // If no exception, query executed successfully |
|||
} catch (DataAccessException e) { |
|||
// Handle exception (e.g., log error) |
|||
e.printStackTrace(); |
|||
return "error"; // Query execution failed |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean updatePetitionNumber(int petitionId,String petitionNoString) { |
|||
String sqlQuery = "UPDATE `petition` SET `petition_no`='"+petitionNoString+"' WHERE `petition_id`='"+petitionId+"'"; |
|||
jdbcTemplate.update(sqlQuery); |
|||
return true; |
|||
} |
|||
|
|||
@Transactional |
|||
public String addPetitionFile(String createdBy, |
|||
int petitionId, |
|||
String petitionNoString, |
|||
MultipartFile page1, |
|||
MultipartFile page2, |
|||
MultipartFile page3, |
|||
MultipartFile page4) { |
|||
|
|||
String fileName=""; |
|||
for (int i = 1; i <= 4; i++) { |
|||
MultipartFile file = null; |
|||
switch (i) { |
|||
case 1: |
|||
file = page1; |
|||
fileName = "Scan1"; |
|||
break; |
|||
case 2: |
|||
file = page2; |
|||
fileName = "Scan2"; |
|||
break; |
|||
case 3: |
|||
file = page3; |
|||
fileName = "Scan3"; |
|||
break; |
|||
case 4: |
|||
file = page4; |
|||
fileName = "Scan4"; |
|||
break; |
|||
} |
|||
if (file != null && !file.isEmpty()) { |
|||
try { |
|||
// Get the bytes of the file |
|||
byte[] bytes = file.getBytes(); |
|||
|
|||
// Set the file path where you want to save it |
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
String serviceFolderName = environment.getProperty("cp_foldername"); |
|||
uploadDirectory = uploadDirectory + serviceFolderName; |
|||
|
|||
// File name |
|||
fileName = petitionId + "_" + fileName + "_" + petitionNoString + "_" + file.getOriginalFilename(); |
|||
|
|||
//File Size |
|||
Long fileSize = file.getSize(); |
|||
|
|||
// File Type |
|||
String fileType = file.getContentType(); |
|||
|
|||
// Create directory if it doesn't exist |
|||
Path directoryPath = Paths.get(uploadDirectory); |
|||
if (!Files.exists(directoryPath)) { |
|||
Files.createDirectories(directoryPath); |
|||
} |
|||
|
|||
String filePath = uploadDirectory + "/" + fileName; |
|||
|
|||
// Create a new Path object |
|||
Path path = Paths.get(filePath); |
|||
|
|||
// Write the bytes to the file |
|||
Files.write(path, bytes); |
|||
|
|||
// Save the file path to a database |
|||
String sqlQuery = "INSERT INTO `pentition_files`(`created_by`, `file_name`, `file_size`, `file_type`, `petition_no`, `petition_id`) " |
|||
+ "VALUES ('"+createdBy+"','"+fileName+"','"+fileSize+"','"+fileType+"','"+petitionNoString+"','"+petitionId+"')"; |
|||
jdbcTemplate.update(sqlQuery); |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return "Failed to save file " + file.getOriginalFilename(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
return "success"; |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean updatePetition( |
|||
String petitionType, |
|||
String petitionNo, |
|||
String createdBy, |
|||
String petitionerName, |
|||
String petitionerMobile, |
|||
String petitionerAddress, |
|||
String petitionerPincode, |
|||
String petitionerComplaint, |
|||
String complaintNature) { |
|||
|
|||
try { |
|||
// Complaint Type List |
|||
List complaintTypelist = getComplaintTypeList(); |
|||
// Convert the list of maps to a list of ComplaintType objects |
|||
List<ComplaintType> complaintTypes = convertToComplaintTypes(complaintTypelist); |
|||
|
|||
// Map complaint types |
|||
String petitionerComplaint_txt = mapComplaintTypes(complaintTypes, petitionerComplaint); |
|||
/* |
|||
String sqlQuery = "UPDATE `petition` SET " |
|||
+ "`petition_type`='"+petitionType+"', `created_by`='"+createdBy+"', `petitioner_name`='"+petitionerName+"', `petitioner_mobile`='"+petitionerMobile+"', " |
|||
+ "`petitioner_address`='"+petitionerAddress+"', `petitioner_pincode`='"+petitionerPincode+"'," |
|||
+ "`petitioner_complaint`='"+petitionerComplaint+"', `petitioner_complaint_txt`='"+petitionerComplaint_txt+"', `complaint_nature`='"+complaintNature+"' " |
|||
+ "WHERE (`petition_no`='"+petitionNo+"') LIMIT 1"; |
|||
|
|||
// Use JdbcTemplate's update method to execute the query with parameters |
|||
jdbcTemplate.update(sqlQuery); |
|||
*/ |
|||
String sqlQuery = "UPDATE `petition` SET " |
|||
+ "`petition_type` = ?, `created_by` = ?, `petitioner_name` = ?, `petitioner_mobile` = ?, " |
|||
+ "`petitioner_address` = ?, `petitioner_pincode` = ?, `petitioner_complaint` = ?, " |
|||
+ "`petitioner_complaint_txt` = ?, `complaint_nature` = ? " |
|||
+ "WHERE `petition_no` = ? LIMIT 1"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(sqlQuery, |
|||
petitionType, |
|||
createdBy, |
|||
petitionerName, |
|||
petitionerMobile, |
|||
petitionerAddress, |
|||
petitionerPincode, |
|||
petitionerComplaint, |
|||
petitionerComplaint_txt, // Safely includes single quotes |
|||
complaintNature, |
|||
petitionNo |
|||
); |
|||
|
|||
// Add Petition Scan File in the database |
|||
//addPetitionFile(createdBy,lastInsertId, petitionNoString, page1, page2, page3, page4); |
|||
|
|||
return true; // If no exception, query executed successfully |
|||
} catch (DataAccessException e) { |
|||
// Handle exception (e.g., log error) |
|||
e.printStackTrace(); |
|||
return false; // Query execution failed |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean updatePetitionStatus(String petitionId,String petitionNo) { |
|||
String status_value = "close"; |
|||
List<Map<String, Object>> petitionMappingDetails = getPetitionMappingDetails(petitionNo, petitionId); |
|||
|
|||
for (Map<String, Object> mapping : petitionMappingDetails) { |
|||
// Access values from the map using keys |
|||
Object status = mapping.get("status"); |
|||
// Check if status is "close" |
|||
if (!"close".equals(status)) { |
|||
status_value = "partial"; |
|||
} |
|||
|
|||
} |
|||
|
|||
String sqlQuery = "UPDATE `petition` SET `status`='"+status_value+"' WHERE `petition_no`='"+petitionNo+"' AND `petition_id`='"+petitionId+"' LIMIT 1"; |
|||
jdbcTemplate.update(sqlQuery); |
|||
System.out.println(sqlQuery); |
|||
return true; |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getPetitionMappingDetails(String petitionNo, String petitionId) { |
|||
try { |
|||
String sqlQuery = "SELECT * FROM petition_mapping WHERE (`petition_id`= ? AND petition_no = ?) AND (`isactive`=1 AND `isdelete`=0)"; |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery, petitionId, petitionNo); |
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean unmapComplient(String petitionId, String petitionNo) { |
|||
String sqlQuery = "UPDATE `petition_mapping` SET `isactive`='0',`isdelete`='1' WHERE `petition_id`='"+petitionId+"' AND `petition_no`='"+petitionNo+"'"; |
|||
jdbcTemplate.update(sqlQuery); |
|||
return true; |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean mapComplientToOfficer( |
|||
String createdBy, String petitionId, String petitionNo, String complaintId, String officerId) { |
|||
String sqlQuery = "INSERT INTO `petition_mapping`" |
|||
+ "(`created_by`, `off_id`, `petition_no`, `complaint_typeid`, `petition_id`) " |
|||
+ "VALUES (?, ?, ?, ?, ?)"; |
|||
jdbcTemplate.update(sqlQuery, createdBy, officerId, petitionNo, complaintId, petitionId); |
|||
return true; |
|||
} |
|||
|
|||
@Transactional |
|||
public boolean updateMapComplientStatus(String mapId,String status) { |
|||
String sqlQuery = "UPDATE `petition_mapping` SET `status`=? WHERE `mapid`=? LIMIT 1"; |
|||
jdbcTemplate.update(sqlQuery, status, mapId); |
|||
System.out.println(sqlQuery); |
|||
return true; |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getComplaintMappingDetails(String petitionNo, String petitionId, String complaintTypeId) { |
|||
try { |
|||
String sqlQuery = "SELECT * FROM petition_mapping WHERE (`petition_id`= ? AND petition_no = ?) AND `complaint_typeid`= ? AND (`isactive`=1 AND `isdelete`=0) LIMIT 1"; |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery, petitionId, petitionNo,complaintTypeId); |
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getComplaintList() { |
|||
try { |
|||
String sqlQuery = "SELECT " |
|||
+ " p.`petition_id`, p.`cdate`, p.`created_by`, p.`isactive`, p.`isdelete`, p.`petition_no`, " |
|||
+ " p.`petitioner_address`, p.`petitioner_complaint`, p.`petitioner_complaint_txt`, " |
|||
+ " p.`petitioner_mobile`, p.`petitioner_name`, p.`complaint_nature`, p.`petitioner_pincode`, " |
|||
+ " pm.`mapid`, pm.`complaint_typeid`, pm.`off_id`, pm.`status`, om.`off_nm`, ctype.`complaint_type` " |
|||
+ " FROM " |
|||
+ " `petition` p, `petition_mapping` pm, `petition_master`.`officer_master` om, `petition_master`.`complaint_types` ctype " |
|||
+ " WHERE " |
|||
+ " (p.`isactive` = 1 AND p.`isdelete` = 0) " |
|||
+ " AND (pm.`isactive` = 1 AND pm.`isdelete` = 0) " |
|||
+ " AND (om.`isactive` = 1 AND om.`isdelete` = 0) " |
|||
+ " AND (om.`off_id` = pm.`off_id`) " |
|||
+ " AND (ctype.`complaint_typeid` = pm.`complaint_typeid`) " |
|||
+ " AND (p.`petition_id` = pm.`petition_id`)" |
|||
+ " "; |
|||
System.out.println(sqlQuery); |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery); |
|||
|
|||
// Iterate over the list of maps |
|||
for (Map<String, Object> map : result) { |
|||
// Get the value of the 'petitionNo' field from the map |
|||
String petitionNo = (String) map.get("petition_no"); |
|||
|
|||
// Encode the 'petitionNo' value using Base64Util |
|||
String petitionNoEncoded = Base64Util.encodeBase64(petitionNo); |
|||
|
|||
// Add the encoded value as 'petitionNoEncode' to the map |
|||
map.put("petitionNoEncode", petitionNoEncoded); |
|||
} |
|||
|
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getComplaintListByPetitionId(String petitionId) { |
|||
try { |
|||
String sqlQuery = "SELECT " |
|||
+ " p.`petition_id`, p.`cdate`, p.`created_by`, p.`isactive`, p.`isdelete`, p.`petition_no`, " |
|||
+ " p.`petitioner_address`, p.`petitioner_complaint`, p.`petitioner_complaint_txt`, " |
|||
+ " p.`petitioner_mobile`, p.`petitioner_name`, p.`complaint_nature`, p.`petitioner_pincode`, p.`status` petition_status, " |
|||
+ " pm.`mapid`, pm.`complaint_typeid`, pm.`off_id`, pm.`status` complaint_status, pm.`cdate` mappedOn, om.`off_nm`, ctype.`complaint_type` " |
|||
+ " FROM " |
|||
+ " `mayor_petition`.`petition` p,`mayor_petition`.`petition_mapping` pm, `petition_master`.`officer_master` om, `petition_master`.`complaint_types` ctype " |
|||
+ " WHERE " |
|||
+ " (p.`petition_id` = '"+petitionId+"' AND p.`isactive` = 1 AND p.`isdelete` = 0) " |
|||
+ " AND (pm.`isactive` = 1 AND pm.`isdelete` = 0) " |
|||
+ " AND (om.`isactive` = 1 AND om.`isdelete` = 0) " |
|||
+ " AND (om.`off_id` = pm.`off_id`) " |
|||
+ " AND (ctype.`complaint_typeid` = pm.`complaint_typeid`) " |
|||
+ " AND (p.`petition_id` = pm.`petition_id`)" |
|||
+ " "; |
|||
System.out.println(sqlQuery); |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery); |
|||
|
|||
// Iterate over the list of maps |
|||
for (Map<String, Object> map : result) { |
|||
// Get the value of the 'petitionNo' field from the map |
|||
String petitionNo = (String) map.get("petition_no"); |
|||
|
|||
// Encode the 'petitionNo' value using Base64Util |
|||
String petitionNoEncoded = Base64Util.encodeBase64(petitionNo); |
|||
|
|||
// Add the encoded value as 'petitionNoEncode' to the map |
|||
map.put("petitionNoEncode", petitionNoEncoded); |
|||
} |
|||
|
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String, Object>> getComplaintDetails(String mapid) { |
|||
try { |
|||
String sqlQuery = "SELECT " |
|||
+ " p.`petition_id`, p.`cdate`, p.`created_by`, p.`isactive`, p.`isdelete`, p.`petition_no`, " |
|||
+ " p.`petitioner_address`, p.`petitioner_complaint`, p.`petitioner_complaint_txt`, " |
|||
+ " p.`petitioner_mobile`, p.`petitioner_name`, p.`complaint_nature`, p.`petitioner_pincode`, " |
|||
+ " pm.`mapid`, pm.`complaint_typeid`, pm.`off_id`, pm.`status`, om.`off_nm`, ctype.`complaint_type`, " |
|||
+ " COALESCE(pf.`mtm_pet_file_id`, 'No file available') AS mtm_pet_file_id, " |
|||
+ " COALESCE(pf.`cdate`, '') AS file_cdate, " |
|||
+ " COALESCE(pf.`created_by`, 'N/A') AS file_created_by, " |
|||
+ " COALESCE(pf.`file_name`, 'No file available') AS file_name, " |
|||
+ " COALESCE(pf.`file_size`, 0) AS file_size, " |
|||
+ " COALESCE(pf.`file_type`, 'Unknown') AS file_type, " |
|||
+ " COALESCE(pf.`isactive`, 0) AS file_isactive, " |
|||
+ " COALESCE(pf.`isdelete`, 0) AS file_isdelete " |
|||
+ " FROM " |
|||
+ " `petition` p " |
|||
+ " JOIN `petition_mapping` pm ON p.`petition_id` = pm.`petition_id` " |
|||
+ " JOIN `petition_master`.`officer_master` om ON om.`off_id` = pm.`off_id` " |
|||
+ " JOIN `petition_master`.`complaint_types` ctype ON ctype.`complaint_typeid` = pm.`complaint_typeid` " |
|||
+ " LEFT JOIN `pentition_files` pf ON p.`petition_id` = pf.`petition_id` " |
|||
+ " WHERE " |
|||
+ " pm.`mapid` = '" + mapid + "' " |
|||
+ " AND p.`isactive` = 1 AND p.`isdelete` = 0 " |
|||
+ " AND pm.`isactive` = 1 AND pm.`isdelete` = 0 " |
|||
+ " AND om.`isactive` = 1 AND om.`isdelete` = 0 "; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery); |
|||
|
|||
// Iterate over the list of maps |
|||
for (Map<String, Object> map : result) { |
|||
// Get the value of the 'petitionNo' field from the map |
|||
String petitionNo = (String) map.get("petition_no"); |
|||
|
|||
// Encode the 'petitionNo' value using Base64Util |
|||
String petitionNoEncoded = Base64Util.encodeBase64(petitionNo); |
|||
|
|||
// Add the encoded value as 'petitionNoEncode' to the map |
|||
map.put("petitionNoEncode", petitionNoEncoded); |
|||
} |
|||
|
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getComplaintActionDetails(String mapId) { |
|||
try { |
|||
String sqlQuery = "SELECT * FROM `petition_action_taken` WHERE (`mapid`= ? AND `isactive`=1 AND `isdelete`=0) LIMIT 1"; |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sqlQuery, mapId); |
|||
return result; |
|||
} catch (DataAccessException e) { |
|||
e.printStackTrace(); |
|||
return null; // Return null or handle error appropriately |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public String saveComplanitStatus( |
|||
String createdBy, |
|||
String mapId, |
|||
String complaintStatus, |
|||
String complaintActionText, |
|||
MultipartFile actionPage1, |
|||
String petitionId, |
|||
String petitionNo) { |
|||
|
|||
//System.out.println("I am from Service Page "+petitionerName); |
|||
|
|||
//String complaintNature = ""; |
|||
int lastInsertId = 0; |
|||
String sqlQuery = "INSERT INTO `petition_action_taken` " |
|||
+ "(`created_by`, `off_id`, `mapid`, `status`, " |
|||
+ "`comments`) " |
|||
+ "VALUES (?, ?, ?, ?, ?)"; |
|||
|
|||
try { |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
// Use JdbcTemplate's update method to execute the query with parameters |
|||
jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(sqlQuery, Statement.RETURN_GENERATED_KEYS); |
|||
ps.setString(1, createdBy); |
|||
ps.setString(2, createdBy); |
|||
ps.setString(3, mapId); |
|||
ps.setString(4, complaintStatus); |
|||
ps.setString(5, complaintActionText); |
|||
return ps; |
|||
}, keyHolder); |
|||
|
|||
// Get the last insert ID |
|||
lastInsertId = (int)keyHolder.getKey().longValue(); |
|||
String actionID = "error"; |
|||
if(lastInsertId>0) { |
|||
// Update Complaint Status |
|||
updateMapComplientStatus(mapId,"close"); |
|||
// Update Petition Status |
|||
updatePetitionStatus(petitionId,petitionNo); |
|||
// Add Action Scan File in the database |
|||
addActionFile(mapId,lastInsertId, actionPage1); |
|||
actionID = ""+lastInsertId; |
|||
} |
|||
|
|||
return actionID; // If no exception, query executed successfully |
|||
} catch (DataAccessException e) { |
|||
// Handle exception (e.g., log error) |
|||
e.printStackTrace(); |
|||
return "error"; // Query execution failed |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public String addActionFile( String mapId, int solmapid, |
|||
MultipartFile page1) { |
|||
|
|||
MultipartFile file = page1; |
|||
String fileName = "Scan1_"+solmapid; |
|||
|
|||
if (file != null && !file.isEmpty()) { |
|||
try { |
|||
// Get the bytes of the file |
|||
byte[] bytes = file.getBytes(); |
|||
|
|||
// Set the file path where you want to save it |
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
String serviceFolderName = environment.getProperty("cp_foldername"); |
|||
String serviceActionFolderName = environment.getProperty("cp_action_Foldername"); |
|||
|
|||
uploadDirectory = uploadDirectory + serviceFolderName +"/"+ serviceActionFolderName; |
|||
|
|||
// File name |
|||
fileName = mapId + "_" + fileName + "_" + file.getOriginalFilename(); |
|||
|
|||
//File Size |
|||
Long fileSize = file.getSize(); |
|||
|
|||
// File Type |
|||
String fileType = file.getContentType(); |
|||
|
|||
// Create directory if it doesn't exist |
|||
Path directoryPath = Paths.get(uploadDirectory); |
|||
if (!Files.exists(directoryPath)) { |
|||
Files.createDirectories(directoryPath); |
|||
} |
|||
|
|||
String filePath = uploadDirectory + "/" + fileName; |
|||
|
|||
// Create a new Path object |
|||
Path path = Paths.get(filePath); |
|||
|
|||
// Write the bytes to the file |
|||
Files.write(path, bytes); |
|||
|
|||
// Save the file path to a database |
|||
String sqlQuery = "UPDATE `petition_action_taken` SET " |
|||
+ "`file_name`='"+fileName+"', " |
|||
+ "`file_size`='"+fileSize+"', " |
|||
+ "`file_type`='"+fileType+"' " |
|||
+ "WHERE `solmapid`='"+solmapid+"' LIMIT 1"; |
|||
jdbcTemplate.update(sqlQuery); |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return "Failed to save file " + file.getOriginalFilename(); |
|||
} |
|||
} |
|||
return "success"; |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
package in.gov.chennaicorporation.gccoffice.c_petition.service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
@Service("CPetitionMaster") |
|||
public class PetitionMaster { |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysqlPetitionMasterDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getComplaintType(){ |
|||
String SqlQuery = ""; |
|||
|
|||
SqlQuery = "SELECT * FROM `complaint_types` WHERE `isactive`=1 AND `isdelete`=0"; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(SqlQuery); |
|||
|
|||
return result; |
|||
|
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getOfficerList(){ |
|||
String SqlQuery = ""; |
|||
|
|||
SqlQuery = "SELECT * FROM `officer_master` WHERE `isactive`=1 AND `isdelete`=0"; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(SqlQuery); |
|||
|
|||
return result; |
|||
|
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getPetitionTypes(){ |
|||
String SqlQuery = ""; |
|||
|
|||
SqlQuery = "SELECT * FROM `petition_types` WHERE `isactive`=1 AND `isdelete`=0 ORDER BY `orderby` ASC"; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(SqlQuery); |
|||
|
|||
return result; |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.c_petition.service; |
|||
@ -0,0 +1,112 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AgentAssignService; |
|||
|
|||
|
|||
@RequestMapping("/gcc/api/callcenter/admin") |
|||
@RestController("callcentercontroller") |
|||
public class AgentAssignAPIController |
|||
{ |
|||
private AgentAssignService campaignmaster; |
|||
|
|||
@Autowired |
|||
public AgentAssignAPIController(AgentAssignService campaignmaster) { |
|||
this.campaignmaster = campaignmaster; |
|||
} |
|||
|
|||
@GetMapping("/getcategory") |
|||
public List<Map<String, Object>> getcategory() |
|||
{ |
|||
return campaignmaster.getcategory(); |
|||
} |
|||
|
|||
@GetMapping("/getcampaignbycategory") |
|||
public List<Map<String, Object>> getcampaignbycategory(@RequestParam int id) |
|||
{ |
|||
return campaignmaster.getcampaignbycategory(id); |
|||
} |
|||
|
|||
// @GetMapping("/getcampaignbyid") |
|||
// public List<Map<String, Object>> getcampaignbyid(@RequestParam int id) |
|||
// { |
|||
// return campaignmaster.getcampaignbyid(id); |
|||
// } |
|||
|
|||
@GetMapping("/getagentsfortask") |
|||
public List<Map<String, Object>> getagentsfortask(@RequestParam int id) |
|||
{ |
|||
return campaignmaster.getagentsfortask(id); |
|||
} |
|||
|
|||
@PostMapping("/addagentsfortask") |
|||
public ResponseEntity<List<Map<String, Object>>> addagentsfortask(@RequestBody List<Map<String, Object>> requestList) { |
|||
//System.out.println("Received POST request with data: " + requestList); |
|||
|
|||
List<Map<String, Object>> insertedAgents = new ArrayList<>(); // To store successfully inserted agents |
|||
|
|||
try { |
|||
for (Map<String, Object> request : requestList) { |
|||
int agentId = (int) request.get("agentId"); |
|||
int categoryId = (int) request.get("categoryId"); |
|||
int campaignId = (int) request.get("campaignId"); |
|||
|
|||
// Call the service method to insert the agent details |
|||
int rowsAffected = campaignmaster.addagentsfortask(agentId, categoryId, campaignId); |
|||
|
|||
if (rowsAffected > 0) { |
|||
// If the insert was successful, add the agent data to the response list |
|||
Map<String, Object> insertedAgent = new HashMap<>(); |
|||
insertedAgent.put("categoryId", categoryId); |
|||
insertedAgent.put("campaignId", campaignId); |
|||
insertedAgent.put("agentId", agentId); |
|||
|
|||
insertedAgents.add(insertedAgent); // Add the successfully inserted agent to the list |
|||
} else { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Collections.singletonList(Collections.singletonMap("error", "Failed to add agent for campaignId: " + campaignId))); |
|||
} |
|||
} |
|||
|
|||
// Return the list of successfully inserted agents |
|||
return ResponseEntity.status(HttpStatus.CREATED).body(insertedAgents); |
|||
|
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) |
|||
.body(Collections.singletonList(Collections.singletonMap("error", "Invalid request data: " + e.getMessage()))); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getassignedcampaign") |
|||
public List<Map<String, Object>> checkcampaigninassignedtable(@RequestParam int id) |
|||
{ |
|||
return campaignmaster.checkcampaigninassignedtable(id); |
|||
} |
|||
|
|||
@GetMapping("/deleteassignedbyid") |
|||
public int editagentsfortask(@RequestParam int id) |
|||
{ |
|||
return campaignmaster.editagentsfortask(id); |
|||
} |
|||
|
|||
@GetMapping("/getcampaignbyid") |
|||
public List<Map<String, Object>> getcampaignquestionbyid(@RequestParam int id){ |
|||
return campaignmaster.getcampaignquestionbyid(id); |
|||
} |
|||
} |
|||
@ -0,0 +1,320 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.servlet.http.HttpSession; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AgentsService; |
|||
|
|||
@RequestMapping("/gcc/api/agents") |
|||
@RestController |
|||
public class AgentsAPIController { |
|||
|
|||
@Autowired |
|||
private AgentsService agentsService; |
|||
|
|||
@GetMapping("/excel") |
|||
public List<Map<String, Object>> fetchDataFromExcel(@RequestParam int categoryId,@RequestParam Long campaignId) { |
|||
try { |
|||
return agentsService.fetchDataFromExcel(categoryId,campaignId); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return null; // Handle the exception as needed |
|||
} |
|||
} |
|||
|
|||
|
|||
@PostMapping("/saveExcelData") |
|||
public String saveExcelData( @RequestParam int categoryId,@RequestParam Long campaignId,@RequestParam String filePath) { |
|||
|
|||
try { |
|||
// Fetch data from Excel |
|||
List<Map<String, Object>> excelData = agentsService.getExcelData(categoryId,campaignId, filePath); |
|||
// Save data into the database |
|||
agentsService.saveExcelData(excelData); |
|||
return "Data saved successfully"; |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return "Failed to save data"; |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getdataByIds") |
|||
public List<Map<String, Object>> getdataByIds(@RequestParam List<Integer> ids) { |
|||
return agentsService.getdataByIds(ids); |
|||
} |
|||
|
|||
@GetMapping("/getPendingDataByIds") |
|||
public List<Map<String, Object>> getPendingDataByIds(@RequestParam List<Integer> ids) { |
|||
return agentsService.getPendingDataByIds(ids); |
|||
} |
|||
|
|||
|
|||
|
|||
// @PostMapping("/updatecall") |
|||
// public ResponseEntity<String> updatecall(@RequestBody Map<String, Object> callData) |
|||
// { |
|||
// String call_status = (String) callData.get("call_status"); |
|||
// int data_id = (int) callData.get("data_id"); |
|||
// int agent_id=(int) callData.get("agent_id"); |
|||
// int campaign_id=(int) callData.get("campaign_id"); |
|||
// |
|||
// if (call_status == null || call_status.isEmpty()) { |
|||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Call status is required."); |
|||
// } |
|||
// |
|||
// agentsService.saveInLogsTable(campaign_id, agent_id, data_id,call_status); |
|||
// |
|||
// return ResponseEntity.ok("Data Inserted successfully."); |
|||
// } |
|||
|
|||
@GetMapping("/getAgentNames") |
|||
public List<Map<String, Object>> getAgentsNameById(@RequestParam List<Integer> agentIds){ |
|||
return agentsService.getAgentsNameById(agentIds); |
|||
} |
|||
|
|||
@GetMapping("/getDataFields") |
|||
public List<Map<String, Object>> getDataDetailsById( |
|||
@RequestParam String originalDataIds) throws JsonProcessingException { |
|||
|
|||
// Parse originalDataIds from JSON string |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
List<List<Integer>> originalDataIdsList = objectMapper.readValue(originalDataIds, new TypeReference<List<List<Integer>>>() {}); |
|||
|
|||
// Prepare a list to hold the results for each sub-array |
|||
List<Map<String, Object>> groupedResults = new ArrayList<>(); |
|||
|
|||
// Iterate through each sub-array of originalDataIds |
|||
for (List<Integer> dataIds : originalDataIdsList) { |
|||
List<Map<String, Object>> results = agentsService.getDataDetailsById(dataIds); |
|||
// Group results according to your business logic |
|||
Map<String, Object> combinedResult = new HashMap<>(); |
|||
for (Map<String, Object> result : results) { |
|||
combinedResult.putAll(result); |
|||
} |
|||
groupedResults.add(combinedResult); |
|||
} |
|||
|
|||
return groupedResults; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getCompletedDataFields") |
|||
public Map<String, Object> getCompletedDataDetailsById( |
|||
@RequestParam String originalCDataIds) throws JsonProcessingException { |
|||
|
|||
// Parse originalDataIds from JSON string |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
List<Integer> originalCDataIdsList = objectMapper.readValue(originalCDataIds, new TypeReference<List<Integer>>() {}); |
|||
|
|||
// Prepare a list to hold the results for each sub-array |
|||
//List<Map<String, Object>> groupedCompletedResults = new ArrayList<>(); |
|||
List<Integer> completedDataIds = new ArrayList<>(); // List to hold data_ids with Complete_count > 0 |
|||
|
|||
// Iterate through each sub-array of originalDataIds |
|||
|
|||
List<Map<String, Object>> results = agentsService.getCompletedDataDetailsById(originalCDataIdsList); |
|||
// Group results according to your business logic |
|||
//Map<String, Object> CompletedcombinedResult = new HashMap<>(); |
|||
for (Map<String, Object> result : results) { |
|||
|
|||
if (result.get("Complete_count") != null && ((Number) result.get("Complete_count")).intValue() > 0) { |
|||
completedDataIds.add((Integer) result.get("data_id")); |
|||
} |
|||
//groupedCompletedResults.add(result); |
|||
} |
|||
|
|||
|
|||
|
|||
// Prepare the final response containing grouped results and completed dataIds |
|||
Map<String, Object> response = new HashMap<>(); |
|||
//response.put("groupedCompletedResults", groupedCompletedResults); |
|||
response.put("completedDataIds", completedDataIds); |
|||
return response; |
|||
} |
|||
|
|||
@GetMapping("/getCompletedDataById") |
|||
public List<Map<String, Object>> getCompletedDataById(@RequestParam List<Integer> completedDataIds){ |
|||
return agentsService.getCompletedDataById(completedDataIds); |
|||
} |
|||
|
|||
|
|||
@PostMapping("/furtherAssignedAgents") |
|||
public ResponseEntity<Map<String, String>> updateAgentAssigndata( |
|||
@RequestBody Map<String, Object> requestData) { |
|||
|
|||
String campaign_id = (String) requestData.get("campaign_id"); |
|||
String category_id = (String) requestData.get("category_id"); |
|||
String call_per_agent = (String) requestData.get("call_per_agent"); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
// Correct key name for selected agents |
|||
List<String> selectedAgentsList = (List<String>) requestData.get("selected_agents"); |
|||
|
|||
//System.out.println("campaign_id=" + campaign_id); |
|||
//System.out.println("category_id=" + category_id); |
|||
//System.out.println("call_per_agent=" + call_per_agent); |
|||
//System.out.println("selectedAgentsList=" + selectedAgentsList); |
|||
|
|||
int campaignId = Integer.parseInt(campaign_id); |
|||
int categoryId = Integer.parseInt(category_id); |
|||
int callperagent = Integer.parseInt(call_per_agent); |
|||
|
|||
agentsService.resetAgentAssignmentForNextDay(categoryId,campaignId); |
|||
|
|||
int calls_assign = callperagent * selectedAgentsList.size(); |
|||
//System.out.println("calls_assign== " + calls_assign); |
|||
|
|||
List<Integer> DataIds=agentsService.getDataIdForFurtherAssign(categoryId, campaignId); |
|||
//System.out.println("dataids=== " + DataIds); |
|||
|
|||
if (!DataIds.isEmpty()) { |
|||
int dataIndex = 0; // Initialize data index pointer |
|||
|
|||
for (String agentId : selectedAgentsList) { |
|||
int selectedAgentId = Integer.parseInt(agentId); |
|||
|
|||
agentsService.addAgentsForCampaign(selectedAgentId, categoryId, campaignId); |
|||
|
|||
// Iterate for noOfCalls times and assign data IDs to the current agent |
|||
for (int i = 0; i < callperagent && dataIndex < DataIds.size(); i++, dataIndex++) { |
|||
int DataId = DataIds.get(dataIndex); |
|||
|
|||
agentsService.updateAgentForCampaign( |
|||
selectedAgentId, |
|||
categoryId, |
|||
campaignId, |
|||
DataId |
|||
); |
|||
} |
|||
} |
|||
|
|||
} |
|||
else { |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND) |
|||
.body(Map.of("status", "error", "message", "No data available for Further assign.")); |
|||
} |
|||
|
|||
return ResponseEntity.ok(Map.of("status", "success", "message", "Campaign details saved successfully")); |
|||
} |
|||
|
|||
|
|||
|
|||
////////////////////Ajith code////////////////////// |
|||
|
|||
@GetMapping("/Campaignview") |
|||
public ResponseEntity<?> getCampaignview(@RequestParam int categoryId, @RequestParam int agentId, @RequestParam int dataId) { |
|||
try { |
|||
List<Map<String, Object>> response = agentsService.getFilteredFields(categoryId, agentId, dataId); |
|||
|
|||
if (response.isEmpty()) { |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("No matching data found."); |
|||
} |
|||
|
|||
return ResponseEntity.ok(response); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/questions") |
|||
public List<Map<String, Object>> getCampaignQuestions( |
|||
@RequestParam int categoryId, |
|||
@RequestParam int campaignId) { |
|||
|
|||
return agentsService.getCampaignQuestions(categoryId, campaignId); |
|||
} |
|||
|
|||
@GetMapping("/fetchAnswer") |
|||
public List<Map<String, Object>> fetchAnswer( |
|||
@RequestParam int campaignId, |
|||
@RequestParam int agentId, |
|||
@RequestParam int questionId, |
|||
@RequestParam int dataId) { |
|||
|
|||
return agentsService.FetchAnswer(campaignId,agentId,questionId,dataId); |
|||
} |
|||
|
|||
|
|||
@PostMapping("/submitAnswers") |
|||
public ResponseEntity<String> submitAnswers(@RequestBody Map<String, List<Map<String, Object>>> requestData) { |
|||
List<Map<String, Object>> answers = requestData.get("answers"); |
|||
|
|||
if (answers == null || answers.isEmpty()) { |
|||
return ResponseEntity.badRequest().body("No answers provided."); |
|||
} |
|||
|
|||
agentsService.saveAnswers(answers); |
|||
return ResponseEntity.ok("Answers submitted successfully"); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/callstatus") |
|||
public List<Map<String, Object>> getCallStatus() { |
|||
//System.out.println("dropdown"); |
|||
return agentsService.getCallStatus(); |
|||
} |
|||
|
|||
@GetMapping("/checkCounts") |
|||
public List<Map<String, Object>> checkCounts( |
|||
@RequestParam int campaignId, |
|||
@RequestParam int dataId) { |
|||
|
|||
return agentsService.checkCounts(campaignId,dataId); |
|||
} |
|||
|
|||
@PostMapping("/savecall") |
|||
public ResponseEntity<String> savecall(@RequestBody Map<String, Object> callData) { |
|||
String call_status = (String) callData.get("call_status"); |
|||
String remarks = (String) callData.get("remarks"); |
|||
int data_id = Integer.parseInt(callData.get("data_id").toString()); |
|||
int agent_id = Integer.parseInt(callData.get("agent_id").toString()); |
|||
int campaign_id = Integer.parseInt(callData.get("campaign_id").toString()); |
|||
|
|||
// System.out.println("controler"); |
|||
//System.out.println(call_status); |
|||
|
|||
// Add a debug statement to check the received values |
|||
// System.out.println("Received call_status: " + call_status); |
|||
|
|||
if (call_status == null || call_status.isEmpty()) { |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Call status is required."); |
|||
} |
|||
|
|||
|
|||
agentsService.saveCallLogs(call_status, remarks,data_id,agent_id); |
|||
|
|||
agentsService.saveInLogsTable(campaign_id, agent_id, data_id,call_status,remarks); |
|||
|
|||
return ResponseEntity.ok("Data Inserted successfully."); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.ResponseEntity; |
|||
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 org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
@RequestMapping("/gcc/api/attendance") |
|||
@RestController |
|||
public class AttendanceAPIController { |
|||
|
|||
private AppConfig appConfig; |
|||
private final RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
public AttendanceAPIController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/getAttendancedetails") |
|||
public String getAttendancedetails(@RequestParam String fromDate,@RequestParam String toDate){ |
|||
String apiUrl = appConfig.attendanceReport + "/callcenter/api/attendance/getattendancereport"+"?fromDate="+ fromDate + "&toDate="+ toDate; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return responseEntity.getBody(); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,643 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
import org.apache.poi.ss.usermodel.*; |
|||
|
|||
|
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import java.io.*; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.text.SimpleDateFormat; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.*; |
|||
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.core.env.Environment; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
|
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
|
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
|
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RequestPart; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AddcategoryServices; |
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AgentAssignService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.CampaignService; |
|||
|
|||
@RestController("callcenterapicontroller") |
|||
@RequestMapping("gcc/api/campaign") |
|||
public class CampaignAPIController { |
|||
|
|||
@Autowired |
|||
private CampaignService campaignService; |
|||
|
|||
@Autowired |
|||
private AddcategoryServices addCategoryServices; // Injecting the service |
|||
|
|||
@Autowired |
|||
private AgentAssignService agentsAssignService; |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
private Environment environment; |
|||
|
|||
@GetMapping("/getCampaignDetails") |
|||
public ResponseEntity<Map<String, Object>> getCampaignDetails() { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
List<Map<String, Object>> data = campaignService.getCampaignDetails(); |
|||
|
|||
response.put("data", data); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
|
|||
// Endpoint to get campaign details by ID |
|||
@GetMapping("/getCampaignDetailsById") |
|||
public @ResponseBody List<Map<String, Object>> getCampaignDetailsById(@RequestParam("campaign_id") Long campaignId) { |
|||
return campaignService.getCampaignDetailsById(campaignId); |
|||
} |
|||
|
|||
|
|||
@PostMapping("/updateCampaign") |
|||
public ResponseEntity<String> updateCampaign( |
|||
@RequestBody Map<String, Object> requestData) { |
|||
|
|||
Long campaign_id = ((Number) requestData.get("campaign_id")).longValue(); |
|||
String end_date = (String) requestData.get("end_date"); |
|||
List<Map<String, Object>> questionsData = |
|||
(List<Map<String, Object>>) requestData.get("questionsData"); |
|||
|
|||
if (campaign_id == null) { |
|||
return ResponseEntity.badRequest().body("Campaign ID is required."); |
|||
} |
|||
|
|||
try { |
|||
// Update campaign details |
|||
campaignService.updateCampaign(campaign_id, end_date); |
|||
|
|||
// Save questions and answers |
|||
for (Map<String, Object> questionMap : questionsData) { |
|||
String category = (String) questionMap.get("category"); |
|||
String question = (String) questionMap.get("question"); |
|||
String answerType = (String) questionMap.get("answerType"); |
|||
List<String> answers = (List<String>) questionMap.get("answers"); |
|||
|
|||
if (category != null && question != null && answerType != null) { |
|||
campaignService.saveQuestionsAndAnswers( |
|||
category, |
|||
String.valueOf(campaign_id), // Corrected data type |
|||
question, |
|||
answerType, |
|||
answers |
|||
); |
|||
} |
|||
} |
|||
|
|||
return ResponseEntity.ok("Campaign updated successfully."); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Error updating campaign: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
//save question and ansewers for campaign |
|||
@PostMapping("/saveQuestionsAndAnswers") |
|||
public ResponseEntity<String> saveQuestions(@RequestBody List<Map<String, Object>> requestData) { |
|||
String response = campaignService.saveQuestionsAnswers(requestData); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
//save file and get path |
|||
private String saveFile(MultipartFile file) throws IOException { |
|||
|
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
|
|||
String folderName = environment.getProperty("campaign.foldername"); |
|||
|
|||
String fileName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")) + "_" + file.getOriginalFilename(); |
|||
|
|||
String folderPath = uploadDirectory + "/" + folderName + "/excel/"; |
|||
|
|||
|
|||
Path dirPath = Paths.get(folderPath); |
|||
if (!Files.exists(dirPath)) { |
|||
Files.createDirectories(dirPath); |
|||
} |
|||
|
|||
Path filePath = dirPath.resolve(fileName); |
|||
|
|||
Files.write(filePath, file.getBytes()); |
|||
|
|||
return filePath.toAbsolutePath().toString(); |
|||
} |
|||
|
|||
|
|||
//read uploaded excel data and make condition for each category uploading same excel columns are other some other? |
|||
private List<Map<String, Object>> readExcelData(InputStream inputStream, List<String> categoryColumns) throws IOException { |
|||
List<Map<String, Object>> dataList = new ArrayList<>(); |
|||
|
|||
try (Workbook workbook = new XSSFWorkbook(inputStream)) { |
|||
Sheet sheet = workbook.getSheetAt(0); |
|||
FormulaEvaluator formulaEvaluator = workbook.getCreationHelper().createFormulaEvaluator(); |
|||
|
|||
// Read header row from Excel |
|||
Row headerRow = sheet.getRow(0); |
|||
List<String> excelHeaders = new ArrayList<>(); |
|||
for (Cell cell : headerRow) { |
|||
excelHeaders.add(cell.getStringCellValue().trim()); |
|||
} |
|||
|
|||
// Compare Excel headers with category columns |
|||
if (!excelHeaders.containsAll(categoryColumns)) { |
|||
// throw new IllegalArgumentException("Excel data does not match the category columns."); |
|||
|
|||
} |
|||
|
|||
// Proceed with reading data only if headers match |
|||
for (Row row : sheet) { |
|||
if (row.getRowNum() == 0) continue; // Skip header row |
|||
|
|||
Map<String, Object> dataMap = new HashMap<>(); |
|||
for (Cell cell : row) { |
|||
String cellValue = ""; |
|||
switch (formulaEvaluator.evaluateInCell(cell).getCellType()) { |
|||
case STRING: |
|||
cellValue = cell.getStringCellValue(); |
|||
break; |
|||
case NUMERIC: |
|||
if (DateUtil.isCellDateFormatted(cell)) { |
|||
cellValue = new SimpleDateFormat("yyyy-MM-dd").format(cell.getDateCellValue()); |
|||
} else { |
|||
// Check if value is an integer (whole number) |
|||
if (cell.getNumericCellValue() % 1 == 0) { |
|||
cellValue = String.valueOf((long) cell.getNumericCellValue()); // Format as integer |
|||
} else { |
|||
cellValue = String.valueOf(cell.getNumericCellValue()); // Keep decimal values as they are |
|||
} |
|||
} |
|||
break; |
|||
case BOOLEAN: |
|||
cellValue = String.valueOf(cell.getBooleanCellValue()); |
|||
break; |
|||
default: |
|||
cellValue = "Unknown"; |
|||
break; |
|||
} |
|||
// Map cell data to correct column name |
|||
dataMap.put(excelHeaders.get(cell.getColumnIndex()), cellValue); |
|||
} |
|||
|
|||
if (!dataMap.isEmpty()) { |
|||
dataList.add(dataMap); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return dataList; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@GetMapping("/getExcelData") |
|||
public ResponseEntity<List<Map<String, Object>>> getExcelData(@RequestParam("filePath") String filePath) { |
|||
try { |
|||
// Read data from the uploaded Excel file |
|||
List<Map<String, Object>> excelData = readExcelData(new FileInputStream(filePath), null); |
|||
|
|||
// Return data as JSON |
|||
return ResponseEntity.ok(excelData); |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); |
|||
} |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getlastCampaignid") |
|||
public List<Map<String, Object>> getLastRow() |
|||
{ |
|||
return campaignService.getLastRow(); |
|||
} |
|||
|
|||
@GetMapping("/startcampaign") |
|||
public List<Map<String, Object>> getDataforAgents(@RequestParam int campaign_id,@RequestParam int calls_per_agent) |
|||
{ |
|||
return campaignService.getDataforAgents(campaign_id, calls_per_agent); |
|||
} |
|||
|
|||
@GetMapping("/viewcampaignstatus") |
|||
public List<Map<String, Object>> viewcampaignstatus(@RequestParam int campaign_id) |
|||
{ |
|||
return campaignService.viewcampaignstatus(campaign_id); |
|||
} |
|||
|
|||
@GetMapping("/viewcompletedby") |
|||
public List<Map<String, Object>> viewcompletedby(@RequestParam int campaign_id,@RequestParam int agent_id) |
|||
{ |
|||
return campaignService.viewcompletedby(campaign_id,agent_id); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@PostMapping(value = "/savecampaign", consumes = {"multipart/form-data"}) |
|||
public ResponseEntity<Map<String, String>> saveCampaign( |
|||
@RequestParam String campaignId, |
|||
@RequestParam String categoryId, |
|||
@RequestParam String eventStartDate, |
|||
@RequestParam String eventEndDate, |
|||
@RequestParam int noOfCalls, |
|||
@RequestParam String description, |
|||
@RequestParam(required = false) String questionsData, // JSON as String |
|||
@RequestParam(required = false) String selectedAgents // JSON string |
|||
) { |
|||
|
|||
|
|||
// Convert JSON strings to List objects |
|||
List<Map<String, Object>> questionsDataList = new ArrayList<>(); |
|||
List<String> selectedAgentsList = new ArrayList<>(); |
|||
|
|||
try { |
|||
if (questionsData != null) { |
|||
questionsDataList = new ObjectMapper().readValue(questionsData, new TypeReference<List<Map<String, Object>>>() {}); |
|||
} |
|||
|
|||
if (selectedAgents != null) { |
|||
selectedAgentsList = new ObjectMapper().readValue(selectedAgents, new TypeReference<List<String>>() {}); |
|||
} |
|||
} catch (JsonProcessingException e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) |
|||
.body(Map.of("status", "error", "message", "Invalid JSON format in request data")); |
|||
} |
|||
|
|||
// Campaign Details Mapping |
|||
Map<String, Object> campaignDetails = new HashMap<>(); |
|||
campaignDetails.put("campaign_id", campaignId); |
|||
campaignDetails.put("category_id", categoryId); |
|||
campaignDetails.put("start_date", eventStartDate); |
|||
campaignDetails.put("end_date", eventEndDate); |
|||
campaignDetails.put("calls_per_agent", noOfCalls); |
|||
campaignDetails.put("description", description); |
|||
|
|||
try { |
|||
campaignService.saveCampaignDetails(campaignDetails); |
|||
|
|||
// Step 3: Assign Agents for the Campaign |
|||
if (!selectedAgentsList.isEmpty()) { |
|||
int parsedCampaignId = Integer.parseInt(campaignId); |
|||
int parsedCategoryId = Integer.parseInt(categoryId); |
|||
|
|||
System.out.println("selectedAgentsList====== " + selectedAgentsList); |
|||
|
|||
int calls_assign = noOfCalls * selectedAgentsList.size(); |
|||
System.out.println("calls_assign== " + calls_assign); |
|||
|
|||
List<Integer> DataIds=agentsAssignService.getDataIdForInitialAssign(parsedCategoryId, parsedCampaignId); |
|||
|
|||
for (String agentId : selectedAgentsList) { |
|||
int selectedAgentId = Integer.parseInt(agentId); |
|||
|
|||
agentsAssignService.addAgentsForCampaign(selectedAgentId, parsedCategoryId, parsedCampaignId); |
|||
} |
|||
//System.out.println("dataids=== " + DataIds); |
|||
if (!DataIds.isEmpty()) { |
|||
int dataIndex = 0; // Initialize data index pointer |
|||
|
|||
for (String agentId : selectedAgentsList) { |
|||
int selectedAgentId = Integer.parseInt(agentId); |
|||
|
|||
// Iterate for noOfCalls times and assign data IDs to the current agent |
|||
for (int i = 0; i < noOfCalls && dataIndex < DataIds.size(); i++, dataIndex++) { |
|||
int DataId = DataIds.get(dataIndex); |
|||
|
|||
agentsAssignService.updateAgentForCampaign( |
|||
selectedAgentId, |
|||
parsedCategoryId, |
|||
parsedCampaignId, |
|||
DataId |
|||
); |
|||
} |
|||
} |
|||
|
|||
// Update campaign status to 'ONGOING' after successful assignment |
|||
campaignService.updateCampaignStatus(parsedCampaignId, parsedCategoryId); |
|||
} |
|||
|
|||
else { |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND) |
|||
.body(Map.of("status", "error", "message", "No data available for initial assignment.")); |
|||
} |
|||
|
|||
} |
|||
|
|||
// Step 4: Save Questions and Answers |
|||
if (!questionsDataList.isEmpty()) { |
|||
for (Map<String, Object> questionMap : questionsDataList) { |
|||
String question = (String) questionMap.get("question"); |
|||
String answerType = (String) questionMap.get("answerType"); |
|||
List<String> answers = (List<String>) questionMap.get("answers"); |
|||
|
|||
if (question != null && answerType != null) { |
|||
campaignService.saveQuestionsAndAnswers( |
|||
categoryId, |
|||
campaignId, |
|||
question, |
|||
answerType, |
|||
answers |
|||
); |
|||
} else { |
|||
System.out.println("Skipping invalid question data: " + questionMap); |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Map.of("status", "error", "message", "Failed to save campaign details: " + e.getMessage())); |
|||
} |
|||
|
|||
return ResponseEntity.ok(Map.of("status", "success", "message", "Campaign details saved successfully")); |
|||
} |
|||
|
|||
|
|||
//save excel data separate method |
|||
|
|||
@PostMapping(value = "/saveexcelcampaign" ,consumes = {"multipart/form-data"}) |
|||
public Map<String, String> saveExcelCampaign( |
|||
@RequestParam String name, |
|||
@RequestParam String category, |
|||
@RequestPart MultipartFile file) { |
|||
|
|||
//System.out.println("Received campaign data:"); |
|||
//System.out.println("Name: " + name); |
|||
//System.out.println("Category: " + category); |
|||
|
|||
//System.out.println("File Name: " + file.getOriginalFilename()); |
|||
|
|||
Map<String, Object> campaignDetails = new HashMap<>(); |
|||
campaignDetails.put("campaign_name", name); |
|||
campaignDetails.put("category_id", category); |
|||
|
|||
|
|||
try { |
|||
// Get category-specific columns |
|||
List<Map<String, Object>> categoryColumns = addCategoryServices.getCategoryColumns(Integer.parseInt(category)); |
|||
/* |
|||
//System.out.println("categorycolmns: " + categoryColumns); |
|||
List<String> expectedHeaders = categoryColumns.stream() |
|||
.map(column -> column.get("column_name").toString()) |
|||
.collect(Collectors.toList()); |
|||
*/ |
|||
List<String> expectedHeaders = new ArrayList<String>(); |
|||
|
|||
for (Map<String, Object> column : categoryColumns) { |
|||
Object columnNameObj = column.get("column_name"); |
|||
if (columnNameObj != null) { |
|||
expectedHeaders.add(columnNameObj.toString()); |
|||
} |
|||
} |
|||
// Fetch field_ columns from upload_data table |
|||
List<String> fieldColumns = campaignService.getUploadDataFieldColumns(); |
|||
//System.out.println("fieldColumns: " + fieldColumns); |
|||
|
|||
|
|||
// Read uploaded Excel data and extract headers |
|||
List<Map<String, Object>> excelData = readExcelData(file.getInputStream(), expectedHeaders); |
|||
|
|||
// System.out.println("excedata: " + excelData ); |
|||
List<String> uploadedHeaders = new ArrayList<>(excelData.get(0).keySet()); // Extract headers from first row |
|||
|
|||
//System.out.println("uploadeddata : " + uploadedHeaders); |
|||
|
|||
// Check column count mismatch with field_ columns |
|||
if (uploadedHeaders.size() > fieldColumns.size()) { |
|||
Map<String, String> response = new HashMap<>(); |
|||
response.put("status", "column_mismatch"); // Changed status to differentiate |
|||
response.put("message", "Extend the columns in Database, Inform Admin."); |
|||
return response; |
|||
} |
|||
|
|||
// Validate headers |
|||
if (!new HashSet<>(expectedHeaders).equals(new HashSet<>(uploadedHeaders))) { |
|||
Map<String, String> response = new HashMap<>(); |
|||
response.put("status", "header_mismatch"); // Changed status to differentiate |
|||
response.put("message", "Excel data does not match the category columns."); |
|||
return response; |
|||
} |
|||
|
|||
|
|||
String fileUrl = saveFile(file); |
|||
campaignDetails.put("excel_url", fileUrl); |
|||
|
|||
//System.out.println("Campaign Details: " + campaignDetails); |
|||
//System.out.println("Excel Data: " + excelData); |
|||
|
|||
campaignService.saveCampaignDetailsExcel(campaignDetails); |
|||
int lastId = campaignService.getLastInsertedCampaignId(); |
|||
|
|||
String excelUrl = campaignService.getExcelUrlByCampaignId(lastId); |
|||
//List<Map<String, Object>> excelDatas = readExcelDataupdated(new FileInputStream(excelUrl)); |
|||
List<Map<String, Object>> excelDatas = readExcelData(new FileInputStream(excelUrl), uploadedHeaders); |
|||
//System.out.println("excelDatas:" + excelDatas); |
|||
|
|||
for (Map<String, Object> row : excelDatas) { |
|||
campaignService.saveUploadData(category, lastId, row,expectedHeaders); |
|||
//System.out.println("exceldatas:" + excelDatas); |
|||
} |
|||
|
|||
Map<String, String> response = new HashMap<>(); |
|||
response.put("status", "success"); |
|||
response.put("message", "Campaign and Excel saved successfully"); |
|||
return response; |
|||
|
|||
} |
|||
catch (IOException e) { |
|||
e.printStackTrace(); |
|||
Map<String, String> response = new HashMap<>(); |
|||
response.put("status", "error"); |
|||
response.put("message", "Failed to save campaign details: "+ e.getMessage()); |
|||
return response; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@GetMapping("/availableAgents") |
|||
public ResponseEntity<List<Map<String, Object>>> getAvailableAgents() { |
|||
// Query 1: Fetch OUTBOUND agents |
|||
String outboundAgentsQuery = "SELECT agent_name, agent_id, calling_type " + |
|||
"FROM gcc_1913_qaqc.agents_list " + |
|||
"WHERE calling_type='OUTBOUND'"; |
|||
|
|||
List<Map<String, Object>> outboundAgents = jdbcTemplate.queryForList(outboundAgentsQuery); |
|||
|
|||
//System.out.println("outboundagents" + outboundAgents); |
|||
// Query 2: Fetch agents from ongoing campaigns |
|||
String ongoingCampaignAgentsQuery = "SELECT ca.agent_id " + |
|||
"FROM gcc_1913_campaign.campaign_request cr " + |
|||
"JOIN gcc_1913_campaign.agent_assign ca " + |
|||
"ON ca.campaign_id = cr.campaign_id " + |
|||
"WHERE cr.campaign_status = 'ONGOING'"; |
|||
|
|||
List<Map<String, Object>> ongoingAgents = jdbcTemplate.queryForList(ongoingCampaignAgentsQuery); |
|||
|
|||
//System.out.println("ongoingAgents" + ongoingAgents); |
|||
// Extract agent IDs from both lists |
|||
/* |
|||
Set<Integer> ongoingAgentIds = ongoingAgents.stream() |
|||
.map(agent -> (Integer) agent.get("agent_id")) |
|||
.collect(Collectors.toSet()); |
|||
|
|||
// Filter OUTBOUND agents who are NOT in ongoing agents |
|||
List<Map<String, Object>> availableAgents = outboundAgents.stream() |
|||
.filter(agent -> !ongoingAgentIds.contains(agent.get("agent_id"))) |
|||
.collect(Collectors.toList()); |
|||
|
|||
*/ |
|||
Set<Integer> ongoingAgentIds = new HashSet<>(); |
|||
|
|||
for (Map<String, Object> agent : ongoingAgents) { |
|||
Object idObj = agent.get("agent_id"); |
|||
if (idObj != null) { |
|||
ongoingAgentIds.add(Integer.parseInt(idObj.toString())); |
|||
} |
|||
} |
|||
|
|||
// Filter OUTBOUND agents who are NOT in ongoing agents |
|||
List<Map<String, Object>> availableAgents = new ArrayList<>(); |
|||
|
|||
for (Map<String, Object> agent : outboundAgents) { |
|||
Object idObj = agent.get("agent_id"); |
|||
if (idObj != null) { |
|||
Integer agentId = Integer.parseInt(idObj.toString()); |
|||
if (!ongoingAgentIds.contains(agentId)) { |
|||
availableAgents.add(agent); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return ResponseEntity.ok(availableAgents); |
|||
} |
|||
|
|||
|
|||
|
|||
private Object getCellValue(Cell cell) { |
|||
switch (cell.getCellType()) { |
|||
case STRING: |
|||
return cell.getStringCellValue().trim(); |
|||
case NUMERIC: |
|||
if (DateUtil.isCellDateFormatted(cell)) { |
|||
return cell.getDateCellValue(); // Return Date for date-formatted cells |
|||
} |
|||
double numericValue = cell.getNumericCellValue(); |
|||
|
|||
// ✅ Convert numeric values that are likely mobile numbers to string |
|||
if (String.valueOf((long) numericValue).length() >= 10) { // Assuming mobile numbers are at least 10 digits |
|||
return String.valueOf((long) numericValue); |
|||
} |
|||
|
|||
// ✅ Convert to int if no decimal part, else keep as double |
|||
return (numericValue % 1 == 0) ? (int) numericValue : numericValue; |
|||
case BOOLEAN: |
|||
return cell.getBooleanCellValue(); |
|||
case FORMULA: |
|||
return cell.getCellFormula(); // Return formula as string |
|||
case BLANK: |
|||
return ""; |
|||
default: |
|||
return ""; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
//question and answers report page api |
|||
@GetMapping("/question-answers") |
|||
public ResponseEntity<?> getQuestionAnswers(@RequestParam int campaignId) { |
|||
List<Map<String, Object>> response = campaignService.getQuestionAnswers(campaignId); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
|
|||
//dizo campaignlist apicontroller |
|||
// Query Parameter Approach |
|||
@GetMapping("/statistics") |
|||
public ResponseEntity<Map<String, Object>> getCampaignStatisticsByQuery(@RequestParam int campaignId) { |
|||
Map<String, Object> statistics = campaignService.getCampaignStatistics(campaignId); |
|||
return ResponseEntity.ok(statistics); |
|||
} |
|||
|
|||
@GetMapping("/assignagentid") |
|||
public ResponseEntity<List<Map<String, Object>>> getAllAgents() { |
|||
List<Map<String, Object>> assignAgentId = campaignService.getAllAgents(); |
|||
return ResponseEntity.ok(assignAgentId); |
|||
} |
|||
|
|||
@PostMapping("/close") |
|||
public ResponseEntity<String> closeCampaign(@RequestParam("campaignId") int campaignId) { |
|||
if (campaignId <= 0) { |
|||
return ResponseEntity.badRequest().body("Invalid Campaign ID"); |
|||
} |
|||
|
|||
System.out.println("Received request to close campaign ID: " + campaignId); // Debugging log |
|||
|
|||
int rowsUpdated = campaignService.closeCampaign(campaignId); |
|||
if (rowsUpdated > 0) { |
|||
return ResponseEntity.ok("Campaign closed successfully"); |
|||
} else { |
|||
return ResponseEntity.status(400).body("Failed to close campaign. Campaign ID " + campaignId + " may not exist."); |
|||
} |
|||
} |
|||
|
|||
@PostMapping("/auto-close") |
|||
public ResponseEntity<String> autoCloseExpiredCampaigns() { |
|||
|
|||
int rowsUpdated = campaignService.autoCloseExpiredCampaigns(); |
|||
|
|||
if (rowsUpdated > 0) { |
|||
return ResponseEntity.ok(rowsUpdated + " expired campaigns closed successfully."); |
|||
} else { |
|||
return ResponseEntity.ok("No expired campaigns found."); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.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.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.CampaignDropdownApiService; |
|||
|
|||
@RequestMapping("gcc/api") |
|||
@RestController |
|||
public class CampaignDropdownApiController { |
|||
|
|||
|
|||
@Autowired |
|||
private CampaignDropdownApiService dropdownApiService; |
|||
|
|||
@GetMapping("/getAnswerTypes") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> getAnswerTypes() { |
|||
return dropdownApiService.getAnswerTypes(); |
|||
} |
|||
} |
|||
@ -0,0 +1,100 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.PrintWriter; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.ResponseEntity; |
|||
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 in.gov.chennaicorporation.gccoffice.callcenter.service.CampaignReportService; |
|||
|
|||
@RestController |
|||
@RequestMapping("gcc/api/campaignreport") |
|||
public class CampaignReportAPIController { |
|||
|
|||
@Autowired |
|||
private CampaignReportService campaignReportService; |
|||
|
|||
@GetMapping("/getcampaignData") |
|||
public List<Map<String, Object>> getCampaignData( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
|
|||
List<Map<String, Object>> campaignData = campaignReportService.getCampaignData(startDate, endDate); |
|||
//System.out.println("Campaign Data: " + campaignData); // Debugging log |
|||
return campaignData; |
|||
} |
|||
|
|||
@GetMapping("/getagentdatacount") |
|||
public List<Map<String, Object>> getAgentwiseData(@RequestParam String campaign_id) { |
|||
List<Map<String, Object>> agentData = campaignReportService.getAgentwiseData(campaign_id); |
|||
//System.out.println("Agent Data: " + agentData); |
|||
return agentData; |
|||
} |
|||
|
|||
@GetMapping("/getReportCampaignid") |
|||
public ResponseEntity<?> getAgentReportCampaignId(@RequestParam String campaign_id) { |
|||
|
|||
List<Map<String, Object>> agentData = campaignReportService.getAgentReportCampaignId(campaign_id); |
|||
//System.out.println("Agent Data: " + agentData); |
|||
return ResponseEntity.ok(agentData); |
|||
} |
|||
|
|||
//question and answers report page api |
|||
@GetMapping("/question-answers") |
|||
public ResponseEntity<?> getQuestionAnswers(@RequestParam int campaign_id) { |
|||
List<Map<String, Object>> response = campaignReportService.getQuestionAnswers(campaign_id); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
// @GetMapping("/download-excel") |
|||
// public void downloadFilteredCSV( |
|||
// @RequestParam int categoryId, |
|||
// @RequestParam int campaignId, |
|||
// |
|||
// |
|||
// |
|||
// HttpServletResponse response) throws IOException { |
|||
// |
|||
// // Set response headers |
|||
// response.setContentType("text/csv"); |
|||
// response.setHeader("Content-Disposition", "attachment; filename=filtered_data.csv"); |
|||
// |
|||
// // Generate CSV and write to response |
|||
// PrintWriter writer = response.getWriter(); |
|||
// campaignReportService.generateCSV(categoryId, campaignId, writer); |
|||
// writer.flush(); |
|||
// writer.close(); |
|||
// } |
|||
|
|||
|
|||
@GetMapping("/download-excel") |
|||
public void downloadFilteredCSV( |
|||
@RequestParam int categoryId, |
|||
@RequestParam int campaignId, |
|||
HttpServletResponse response) throws IOException { |
|||
|
|||
String filename = campaignReportService.getCampaignName(campaignId); |
|||
// Format campaign name for file safety (remove spaces/special characters) |
|||
//String safeCampaignName = filename.replaceAll("[^a-zA-Z0-9]", "_"); |
|||
|
|||
// Set response headers |
|||
response.setContentType("text/csv"); |
|||
response.setHeader("Content-Disposition", "attachment; filename=" + filename + ".csv"); |
|||
|
|||
// Generate CSV and write to response |
|||
PrintWriter writer = response.getWriter(); |
|||
campaignReportService.generateCSV(categoryId, campaignId, writer); |
|||
writer.flush(); |
|||
writer.close(); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,281 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.PutMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AddcategoryServices; |
|||
|
|||
|
|||
@RequestMapping("/gcc/api/category") |
|||
@RestController |
|||
public class CategoryAPIController { |
|||
|
|||
@Autowired |
|||
private AddcategoryServices addCategoryServices; // Injecting the service |
|||
|
|||
@PostMapping("/save") |
|||
public ResponseEntity<String> saveCategoryDetails(@RequestBody Map<String, Object> payload) { |
|||
try { |
|||
addCategoryServices.saveCategoryDetails(payload); |
|||
return ResponseEntity.ok("Category and columns saved successfully."); |
|||
} catch (IllegalArgumentException e) { |
|||
return ResponseEntity.badRequest().body("Validation Error: " + e.getMessage()); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(500).body("Internal Server Error: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
// Endpoint to save category details |
|||
// @PostMapping("/save") |
|||
// public ResponseEntity<String> saveCategoryDetails(@RequestBody Map<String, Object> payload) { |
|||
// try { |
|||
// addCategoryServices.saveCategoryDetails(payload); // Call the service method to save category details |
|||
// return ResponseEntity.ok("Category details saved successfully."); |
|||
// } catch (IllegalArgumentException e) { |
|||
// return ResponseEntity.badRequest().body("Error: " + e.getMessage()); |
|||
// } catch (Exception e) { |
|||
// return ResponseEntity.status(500).body("Error saving category details: " + e.getMessage()); |
|||
// } |
|||
// } |
|||
|
|||
// Endpoint to get all categories |
|||
@GetMapping("/list") |
|||
public List<Map<String, Object>> getAllCategories() { |
|||
return addCategoryServices.getAllCategories(); |
|||
} |
|||
|
|||
@GetMapping("/showcategoryId") |
|||
public ResponseEntity<?> getCategoryById(@RequestParam("category_id") int categoryId) { |
|||
Map<String, Object> category = addCategoryServices.showCategory(categoryId); |
|||
if (category.isEmpty()) { |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Category not found"); |
|||
} |
|||
return ResponseEntity.ok(category); |
|||
} |
|||
|
|||
@PostMapping("/deleteColumnById") |
|||
public ResponseEntity<Map<String, Object>> deleteCategoryColumnById(@RequestParam("columnId") int columnId) { |
|||
boolean updated = addCategoryServices.removeColumnById(columnId); |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
response.put("success", updated); |
|||
|
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
@PostMapping("/updateCategoryColumns") |
|||
public ResponseEntity<Map<String, Object>> updateCategoryColumnsById(@RequestBody Map<String, Object> requestData) { |
|||
try { |
|||
int categoryId = (int) requestData.get("categoryId"); |
|||
List<Map<String, Object>> columns = (List<Map<String, Object>>) requestData.get("columns"); |
|||
|
|||
|
|||
boolean allUpdated = true; |
|||
|
|||
for (Map<String, Object> column : columns) { |
|||
int columnId = (int) column.get("id"); |
|||
String columnName = (String) column.get("name"); |
|||
|
|||
|
|||
boolean updated = addCategoryServices.updateColumnById(categoryId,columnId, columnName); |
|||
|
|||
if (!updated) { |
|||
allUpdated = false; |
|||
} |
|||
} |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
response.put("success", allUpdated); |
|||
return ResponseEntity.ok(response); |
|||
|
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(Map.of("error", "Invalid data format")); |
|||
} |
|||
} |
|||
|
|||
@PostMapping("/addNewColumns") |
|||
public ResponseEntity<Map<String, Object>> addNewCategoryColumnsById(@RequestBody Map<String, Object> requestData) { |
|||
|
|||
try { |
|||
int categoryId = (int) requestData.get("categoryId"); |
|||
List<Map<String, Object>> columns = (List<Map<String, Object>>) requestData.get("columns"); |
|||
|
|||
|
|||
boolean allUpdated = true; |
|||
|
|||
for (Map<String, Object> column : columns) { |
|||
|
|||
String columnName = (String) column.get("name"); |
|||
|
|||
|
|||
boolean updated = addCategoryServices.addnewupdateColumn(categoryId, columnName); |
|||
|
|||
if (!updated) { |
|||
allUpdated = false; |
|||
} |
|||
} |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
response.put("success", allUpdated); |
|||
return ResponseEntity.ok(response); |
|||
|
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(Map.of("error", "Invalid data format")); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
@PutMapping("/update/{categoryId}") |
|||
public ResponseEntity<String> updateCategoryWithColumns( |
|||
@PathVariable("categoryId") int categoryId, |
|||
@RequestBody Map<String, Object> payload) { |
|||
|
|||
String categoryName = (String) payload.get("categoryName"); |
|||
List<String> columns = (List<String>) payload.get("columns"); |
|||
|
|||
try { |
|||
int rowsAffected = addCategoryServices.updateCategoryWithColumns(categoryId, categoryName, columns); |
|||
return rowsAffected > 0 |
|||
? ResponseEntity.ok("Category and columns updated successfully") |
|||
: ResponseEntity.status(HttpStatus.NOT_FOUND).body("Category not found or update failed"); |
|||
|
|||
} catch (IllegalArgumentException e) { |
|||
return ResponseEntity.badRequest().body("Validation Error: " + e.getMessage()); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Error updating category: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
// // Endpoint to get a category by its ID |
|||
// @GetMapping("/showcategoryId") |
|||
// public ResponseEntity<?> getCategoryById(@RequestParam("category_id") int categoryId) { |
|||
// Map<String, Object> category = addCategoryServices.showCategory(categoryId); |
|||
// |
|||
// if (category == null) { |
|||
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Category not found"); |
|||
// } |
|||
// |
|||
// return ResponseEntity.ok(category); |
|||
// } |
|||
// |
|||
// @PutMapping("/update/{categoryId}") |
|||
// public ResponseEntity<String> updateCategoryWithColumns( |
|||
// @PathVariable("categoryId") int categoryId, |
|||
// @RequestBody Map<String, Object> payload) { |
|||
// |
|||
// String categoryName = (String) payload.get("categoryName"); |
|||
// List<String> columns = (List<String>) payload.get("columns"); |
|||
// |
|||
// try { |
|||
// int rowsAffected = addCategoryServices.updateCategoryWithColumns(categoryId, categoryName, columns); |
|||
// if (rowsAffected > 0) { |
|||
// return ResponseEntity.ok("Category and columns updated successfully"); |
|||
// } else { |
|||
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Category not found or update failed"); |
|||
// } |
|||
// } catch (IllegalArgumentException e) { |
|||
// return ResponseEntity.badRequest().body("Validation Error: " + e.getMessage()); |
|||
// } catch (Exception e) { |
|||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
// .body("Error updating category: " + e.getMessage()); |
|||
// } |
|||
// } |
|||
|
|||
// @GetMapping("/showcategoryId") |
|||
// public ResponseEntity<?> showCategoryId(@RequestParam("category_id") int categoryId) { |
|||
// try { |
|||
// Map<String, Object> category = addCategoryServices.showCategory(categoryId); |
|||
// if (category != null && !category.isEmpty()) { |
|||
// return ResponseEntity.ok(category); |
|||
// } else { |
|||
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Category not found"); |
|||
// } |
|||
// } catch (Exception e) { |
|||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
// .body("Error retrieving category: " + e.getMessage()); |
|||
// } |
|||
// } |
|||
|
|||
// @PutMapping("/update/{categoryId}") |
|||
// public ResponseEntity<String> updateCategory( |
|||
// @PathVariable("categoryId") int categoryId, |
|||
// @RequestParam String categoryName) { |
|||
// |
|||
// // Validate input |
|||
// if (categoryName == null || categoryName.trim().isEmpty()) { |
|||
// return ResponseEntity.badRequest().body("Category name cannot be empty"); |
|||
// } |
|||
// |
|||
// try { |
|||
// // Call the service method to update the category |
|||
// int rowsAffected = addCategoryServices.updateCategory(categoryId, categoryName); |
|||
// if (rowsAffected > 0) { |
|||
// return ResponseEntity.ok("Category updated successfully"); |
|||
// } else { |
|||
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Category not found or update failed"); |
|||
// } |
|||
// } catch (Exception e) { |
|||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
// .body("Error updating category: " + e.getMessage()); |
|||
// } |
|||
// } |
|||
|
|||
|
|||
// Endpoint to delete a category by its ID |
|||
@DeleteMapping("/delete/{categoryId}") |
|||
public ResponseEntity<String> deleteCategory( |
|||
@PathVariable("categoryId") int categoryId) { |
|||
|
|||
try { |
|||
// Call the service method to delete the category |
|||
addCategoryServices.deleteCategory(categoryId); |
|||
return ResponseEntity.ok("Category deleted successfully"); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Error deleting category: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
//hari category api populate |
|||
|
|||
@GetMapping("/getcategory") |
|||
public List<Map<String, Object>> getcategory(){ |
|||
return addCategoryServices.getcategory(); |
|||
} |
|||
|
|||
// Get category-specific columns based on category_id |
|||
@GetMapping("/getCategoryColumns") |
|||
public List<Map<String, Object>> getCategoryColumns(@RequestParam int category_id) { |
|||
return addCategoryServices.getCategoryColumns(category_id); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getcampaignbycategory") |
|||
public List<Map<String, Object>> getcampaignbycategory(@RequestParam int id) |
|||
{ |
|||
return addCategoryServices.getcampaignbycategory(id); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,219 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.servlet.http.HttpSession; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AddcategoryServices; |
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AgentsService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AttendanceService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.AgentAssignService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.CampaignService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
|
|||
@RequestMapping("/gcc/callcenter") |
|||
@Controller("callCenterCampaignMainController") |
|||
public class MainController { |
|||
|
|||
|
|||
|
|||
@Autowired |
|||
private AgentAssignService campaignmaster; |
|||
|
|||
@Autowired |
|||
private CampaignService campaignService; |
|||
|
|||
@Autowired |
|||
private AddcategoryServices addCategoryServices; |
|||
|
|||
@Autowired |
|||
private AgentsService agentsService; |
|||
|
|||
@Autowired |
|||
private AttendanceService attendanceSerivce; |
|||
|
|||
private AppConfig appConfig; |
|||
private RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
public MainController(AgentAssignService campaignmaster,AgentsService agentsService,CampaignService campaignService,AddcategoryServices addCategoryServices,RestTemplate restTemplate, AppConfig appConfig) |
|||
{ |
|||
this.campaignmaster=campaignmaster; |
|||
this.campaignService=campaignService; |
|||
this.addCategoryServices=addCategoryServices; |
|||
this.agentsService=agentsService; |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
|
|||
} |
|||
|
|||
|
|||
@GetMapping("/admin/addcategory") |
|||
|
|||
public String addcategory(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
List<Map<String, Object>> categories = addCategoryServices.getAllCategories(); |
|||
|
|||
//System.out.println(categories); |
|||
|
|||
model.addAttribute("categories", categories); |
|||
|
|||
return "modules/callcenter/addcategory"; |
|||
|
|||
} |
|||
|
|||
@GetMapping("/admin/createcampaign") |
|||
|
|||
public String createcampaign(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
/* |
|||
* List<Map<String, Object>> campaigns = campaignService.getCampaignDetails(); |
|||
* |
|||
* |
|||
* System.out.println("campaignlist:"+campaigns); |
|||
* |
|||
* model.addAttribute("campaigns", campaigns); |
|||
*/ |
|||
|
|||
return "modules/callcenter/createcampaign"; // Name of the Thymeleaf template (e.g., campaignList.html) |
|||
|
|||
} |
|||
|
|||
@GetMapping("/admin/campaignlist") |
|||
public String viewCampaignList(Model model) |
|||
{ |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
List<Map<String, Object>> campaigns = campaignService.getDetailsForStart(); |
|||
|
|||
model.addAttribute("campaigns", campaigns); |
|||
|
|||
List<Map<String, Object>> activeCampaigns =campaignService.getActiveCampaigns(); |
|||
model.addAttribute("activeCampaigns", activeCampaigns); |
|||
|
|||
return "modules/callcenter/campaignlist"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/agentscampaign") |
|||
public String targetPage(Model model) |
|||
{ |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
List<Map<String, Object>> agentsCampaigns=agentsService.getAgentsALLCampaigns(userId); |
|||
|
|||
List<Map<String, Object>> agentsCampaignsList=agentsService.getAgentsALLCampaignsList(userId); |
|||
|
|||
List<Map<String, Object>> agentsCampaignsList1=agentsService.getAgentsALLCampaignsList1(userId); |
|||
|
|||
//List<Map<String, Object>> CampActions=agentsService.getCallCategories(); |
|||
//model.addAttribute("CampActions", CampActions); |
|||
|
|||
model.addAttribute("agentsCampaignsList", agentsCampaignsList); |
|||
model.addAttribute("agentsCampaigns", agentsCampaigns); |
|||
model.addAttribute("agentsCampaignsList1", agentsCampaignsList1); |
|||
//System.out.println("Agents Campaigns List: " + agentsCampaignsList); |
|||
//System.out.println("Agents Campaigns : " + agentsCampaigns); |
|||
|
|||
return "modules/callcenter/agentscampaign"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/admin/campaignreport") |
|||
public String campaignreport(Model model) |
|||
{ |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
return "modules/callcenter/campaignreport"; |
|||
} |
|||
|
|||
@GetMapping("/attendancereport") |
|||
public String AttendanceList( |
|||
@RequestParam(required = false) String fromDate, |
|||
@RequestParam(required = false) String toDate, |
|||
Model model) { |
|||
List<Map<String, Object>> attendanceData = Collections.emptyList(); |
|||
|
|||
if (fromDate != null && !fromDate.isEmpty() && toDate != null && !toDate.isEmpty()) { |
|||
String apiUrl = appConfig.attendanceReport + "/callcenter/api/attendance/getattendancereport?fromDate=" + fromDate + "&toDate=" + toDate; |
|||
|
|||
try { |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
String responseBody = responseEntity.getBody(); |
|||
|
|||
if (responseBody != null && !responseBody.isEmpty()) { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
if (responseBody.trim().startsWith("{")) { |
|||
// Single object response |
|||
Map<String, Object> singleData = objectMapper.readValue(responseBody, new TypeReference<>() {}); |
|||
attendanceData = List.of(singleData); |
|||
} else { |
|||
// Array response |
|||
attendanceData = objectMapper.readValue(responseBody, new TypeReference<>() {}); |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
System.err.println("Error fetching attendance data: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
model.addAttribute("attendanceData", attendanceData); |
|||
model.addAttribute("fromDate", fromDate); |
|||
model.addAttribute("toDate", toDate); |
|||
model.addAttribute("LoginUserId", LoginUserInfo.getLoginUserId()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
return "modules/callcenter/attendancereport"; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.controller; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenter.service.WhatsappMsgService; |
|||
|
|||
@RestController |
|||
@RequestMapping("/gcc/api/whatsapp") |
|||
public class WhatsappController { |
|||
|
|||
@Autowired |
|||
private WhatsappMsgService whatsappMsgService; |
|||
|
|||
@PostMapping("/send-whatsapp-message") |
|||
public ResponseEntity<String> sendWhatsAppMessage(@RequestParam String msgUrl) { |
|||
String response = whatsappMsgService.sendMsg(msgUrl); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,303 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.service; |
|||
|
|||
import java.sql.ResultSet; |
|||
|
|||
import java.sql.SQLException; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
import java.util.Locale.Category; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.dao.EmptyResultDataAccessException; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import org.springframework.jdbc.support.GeneratedKeyHolder; |
|||
import org.springframework.jdbc.support.KeyHolder; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.Statement; |
|||
|
|||
|
|||
@Service |
|||
public class AddcategoryServices { |
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913CampaignDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
|
|||
// public void saveCategoryDetails(Map<String, Object> categoryData) { |
|||
// String sql = "INSERT INTO category (category_name, isactive, isdelete, created_date) VALUES (?, 1, 0, CURRENT_TIMESTAMP)"; |
|||
// |
|||
// // Ensure that the key "categoryname" matches exactly what is being sent from the frontend |
|||
// String categoryName = (String) categoryData.get("categoryname"); |
|||
// |
|||
// // Check if categoryName is null or empty and handle it properly |
|||
// if (categoryName == null || categoryName.trim().isEmpty()) { |
|||
// throw new IllegalArgumentException("Category name cannot be null or empty"); |
|||
// } |
|||
// |
|||
// jdbcTemplate.update(sql, categoryName); |
|||
// } |
|||
|
|||
|
|||
@Transactional |
|||
public void saveCategoryDetails(Map<String, Object> categoryData) { |
|||
String categoryName = (String) categoryData.get("categoryname"); |
|||
List<String> columns = (List<String>) categoryData.get("columns"); |
|||
|
|||
if (categoryName == null || categoryName.trim().isEmpty()) { |
|||
throw new IllegalArgumentException("Category name cannot be null or empty"); |
|||
} |
|||
|
|||
if (columns == null || columns.isEmpty() || columns.contains("")) { |
|||
throw new IllegalArgumentException("At least one column name is required"); |
|||
} |
|||
|
|||
// Insert into category table and get the generated category_id |
|||
String categorySql = "INSERT INTO category (category_name, isactive, isdelete, created_date) VALUES (?, 1, 0, CURRENT_TIMESTAMP)"; |
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
|
|||
jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(categorySql, Statement.RETURN_GENERATED_KEYS); |
|||
ps.setString(1, categoryName); |
|||
return ps; |
|||
}, keyHolder); |
|||
|
|||
Integer categoryId = keyHolder.getKey().intValue(); // Extract generated category_id |
|||
|
|||
// Insert columns into category_columns table |
|||
String columnSql = "INSERT INTO category_columns (category_id, column_name, isactive, isdelete, created_date) VALUES (?, ?, 1, 0, CURRENT_TIMESTAMP)"; |
|||
jdbcTemplate.batchUpdate(columnSql, columns, columns.size(), |
|||
(PreparedStatement ps, String column) -> { |
|||
ps.setInt(1, categoryId); |
|||
ps.setString(2, column); |
|||
}); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAllCategories() { |
|||
|
|||
String SqlQuery = "SELECT category_id,category_name FROM category where isactive=1 and isdelete=0"; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(SqlQuery); |
|||
return result; |
|||
} |
|||
|
|||
public Map<String, Object> showCategory(int categoryId) { |
|||
String categorySql = "SELECT category_id, category_name FROM category WHERE category_id = ? AND isactive = 1 AND isdelete = 0"; |
|||
Map<String, Object> category; |
|||
try { |
|||
category = jdbcTemplate.queryForMap(categorySql, categoryId); |
|||
} catch (EmptyResultDataAccessException e) { |
|||
return Collections.emptyMap(); |
|||
} |
|||
|
|||
String columnsSql = "SELECT id,column_name FROM category_columns WHERE category_id = ? AND isactive = 1 AND isdelete = 0"; |
|||
List<Map<String,Object>> columns = jdbcTemplate.queryForList(columnsSql,categoryId); |
|||
category.put("columns", columns); |
|||
return category; |
|||
} |
|||
|
|||
@Transactional |
|||
public int updateCategoryWithColumns(int categoryId, String categoryName, List<String> columns) { |
|||
if (categoryName == null || categoryName.trim().isEmpty()) { |
|||
throw new IllegalArgumentException("Category name cannot be empty"); |
|||
} |
|||
if (columns == null || columns.size() < 2 || columns.contains("")) { |
|||
throw new IllegalArgumentException("At least two column names are required"); |
|||
} |
|||
|
|||
String updateCategorySql = "UPDATE category SET category_name = ? WHERE category_id = ? AND isactive = 1 AND isdelete = 0"; |
|||
int categoryUpdateCount = jdbcTemplate.update(updateCategorySql, categoryName, categoryId); |
|||
|
|||
if (categoryUpdateCount == 0) { |
|||
throw new IllegalArgumentException("Category not found or update failed."); |
|||
} |
|||
|
|||
String deleteColumnsSql = "DELETE FROM category_columns WHERE category_id = ? AND isactive = 1 AND isdelete = 0"; |
|||
jdbcTemplate.update(deleteColumnsSql, categoryId); |
|||
|
|||
String insertColumnsSql = "INSERT INTO category_columns (category_id, column_name, isactive, isdelete, created_date) VALUES (?, ?, 1, 0, CURRENT_TIMESTAMP)"; |
|||
jdbcTemplate.batchUpdate(insertColumnsSql, columns, columns.size(), (PreparedStatement ps, String column) -> { |
|||
ps.setInt(1, categoryId); |
|||
ps.setString(2, column); |
|||
}); |
|||
|
|||
return categoryUpdateCount; |
|||
} |
|||
|
|||
|
|||
// @Transactional |
|||
// public int updateCategoryWithColumns(int categoryId, String categoryName, List<String> columns) { |
|||
// if (categoryName == null || categoryName.trim().isEmpty()) { |
|||
// throw new IllegalArgumentException("Category name cannot be empty"); |
|||
// } |
|||
// if (columns == null || columns.isEmpty() || columns.contains("")) { |
|||
// throw new IllegalArgumentException("At least one column name is required"); |
|||
// } |
|||
// |
|||
// String updateCategorySql = "UPDATE category SET category_name = ? WHERE category_id = ? AND isactive = 1 AND isdelete = 0"; |
|||
// int categoryUpdateCount = jdbcTemplate.update(updateCategorySql, categoryName, categoryId); |
|||
// |
|||
// if (categoryUpdateCount == 0) { |
|||
// throw new IllegalArgumentException("Category not found or update failed."); |
|||
// } |
|||
// |
|||
// String deleteColumnsSql = "DELETE FROM category_columns WHERE category_id = ? AND isactive = 1 AND isdelete = 0"; |
|||
// jdbcTemplate.update(deleteColumnsSql, categoryId); |
|||
// |
|||
// String insertColumnsSql = "INSERT INTO category_columns (category_id, column_name, isactive, isdelete, created_date) VALUES (?, ?, 1, 0, CURRENT_TIMESTAMP)"; |
|||
// jdbcTemplate.batchUpdate(insertColumnsSql, columns, columns.size(), (PreparedStatement ps, String column) -> { |
|||
// ps.setInt(1, categoryId); |
|||
// ps.setString(2, column); |
|||
// }); |
|||
// |
|||
// return categoryUpdateCount; |
|||
// } |
|||
|
|||
|
|||
|
|||
|
|||
// // Method to show a category by its ID |
|||
// public Map<String, Object> showCategory(int categoryId) { |
|||
// // Fetch category details |
|||
// String categorySql = "SELECT category_id, category_name FROM category WHERE category_id = ? AND isactive = 1 AND isdelete = 0"; |
|||
// Map<String, Object> category; |
|||
// try { |
|||
// category = jdbcTemplate.queryForMap(categorySql, categoryId); |
|||
// } catch (EmptyResultDataAccessException e) { |
|||
// return null; // If no category found |
|||
// } |
|||
// |
|||
// // Fetch category columns |
|||
// String columnsSql = "SELECT column_name FROM category_columns WHERE category_id = ? AND isactive = 1 AND isdelete = 0"; |
|||
// List<String> columns = jdbcTemplate.queryForList(columnsSql, String.class, categoryId); |
|||
// |
|||
// // Add columns to response |
|||
// category.put("columns", columns); |
|||
// return category; |
|||
// } |
|||
// |
|||
// |
|||
|
|||
// @Transactional |
|||
// public int updateCategoryWithColumns(int categoryId, String categoryName, List<String> columns) { |
|||
// // Validate input |
|||
// if (categoryName == null || categoryName.trim().isEmpty()) { |
|||
// throw new IllegalArgumentException("Category name cannot be empty"); |
|||
// } |
|||
// if (columns == null || columns.isEmpty() || columns.contains("")) { |
|||
// throw new IllegalArgumentException("At least one column name is required"); |
|||
// } |
|||
// |
|||
// // Update category name |
|||
// String updateCategorySql = "UPDATE category SET category_name = ? WHERE category_id = ? AND isactive = 1 AND isdelete = 0"; |
|||
// int categoryUpdateCount = jdbcTemplate.update(updateCategorySql, categoryName, categoryId); |
|||
// |
|||
// if (categoryUpdateCount == 0) { |
|||
// throw new IllegalArgumentException("Category not found or update failed."); |
|||
// } |
|||
// |
|||
// // Remove existing category columns before inserting new ones |
|||
// String deleteColumnsSql = "DELETE FROM category_columns WHERE category_id = ?"; |
|||
// jdbcTemplate.update(deleteColumnsSql, categoryId); |
|||
// |
|||
// // Insert updated columns |
|||
// String insertColumnsSql = "INSERT INTO category_columns (category_id, column_name, isactive, isdelete, created_date) VALUES (?, ?, 1, 0, CURRENT_TIMESTAMP)"; |
|||
// jdbcTemplate.batchUpdate(insertColumnsSql, columns, columns.size(), |
|||
// (PreparedStatement ps, String column) -> { |
|||
// ps.setInt(1, categoryId); |
|||
// ps.setString(2, column); |
|||
// }); |
|||
// |
|||
// return categoryUpdateCount; |
|||
// } |
|||
|
|||
|
|||
// // Method to update a category's name by its ID |
|||
// public int updateCategory(int categoryId, String categoryName) { |
|||
// String sql = "UPDATE category SET category_name = ? WHERE category_id = ? AND isactive = 1 AND isdelete = 0"; |
|||
// return jdbcTemplate.update(sql, categoryName, categoryId); |
|||
// } |
|||
|
|||
|
|||
|
|||
|
|||
// Method to delete a category by its name |
|||
public void deleteCategory(int categoryId) { |
|||
// String sql = "DELETE FROM category WHERE category_id = ?"; |
|||
|
|||
String sql = "UPDATE category SET isactive=0 , isdelete=1 WHERE category_id = ?"; |
|||
jdbcTemplate.update(sql, categoryId); |
|||
} |
|||
|
|||
|
|||
//hari populate category services |
|||
@Transactional |
|||
public List<Map<String, Object>> getcategory() { |
|||
String sqlQuery = "SELECT category_id,category_name FROM category where isactive='1' and isdelete='0'"; |
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getCategoryColumns(int categoryId) { |
|||
String sqlQuery = "SELECT column_name FROM category_columns WHERE category_id = ? AND isactive = 1"; |
|||
return jdbcTemplate.queryForList(sqlQuery, categoryId); |
|||
} |
|||
|
|||
// Fetch category with columns |
|||
public List<Map<String, Object>> getCategoriesWithColumns() { |
|||
String sqlQuery = "SELECT c.category_id, c.category_name, cc.column " + |
|||
"FROM gcc_1913_campaign.category c " + |
|||
"INNER JOIN gcc_1913_campaign.category_columns cc ON c.category_id = cc.category_id " + |
|||
"WHERE c.isactive = 1 AND c.isdelete = 0 " + |
|||
"AND cc.isactive = 1 AND cc.isdelete = 0"; |
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
@Transactional |
|||
|
|||
public List<Map<String, Object>> getcampaignbycategory(int id) { |
|||
|
|||
String sqlQuery = "SELECT cr.campaign_id,cr.campaign_name FROM campaign_request cr JOIN category c ON cr.category_id=c.category_id where cr.category_id=? and cr.isactive='1'"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery,id); |
|||
|
|||
} |
|||
|
|||
|
|||
public boolean removeColumnById(int columnId) { |
|||
String sql = "UPDATE category_columns SET isactive = 0, isdelete = 1 WHERE id = ?"; |
|||
|
|||
int rowsAffected = jdbcTemplate.update(sql, columnId); |
|||
|
|||
return rowsAffected > 0; // Returns true if at least one row was updated, otherwise false |
|||
} |
|||
|
|||
public boolean updateColumnById(int categoryId,int columnId, String columnName) { |
|||
String sql = "UPDATE category_columns SET column_name = ? WHERE id = ? and category_id=?"; |
|||
int rowsAffected = jdbcTemplate.update(sql, columnName, columnId,categoryId); |
|||
return rowsAffected > 0; |
|||
} |
|||
|
|||
|
|||
public boolean addnewupdateColumn(int categoryId, String columnName) { |
|||
|
|||
//String sql = "UPDATE category_columns SET column_name = ? WHERE id = ? and category_id=?"; |
|||
String sql = "INSERT INTO category_columns (category_id, column_name) VALUES (?, ?)"; |
|||
|
|||
int rowsAffected = jdbcTemplate.update(sql, categoryId,columnName); |
|||
return rowsAffected > 0; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,214 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.service; |
|||
|
|||
import java.util.ArrayList; |
|||
|
|||
import java.util.LinkedHashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
|
|||
@Service |
|||
public class AgentAssignService |
|||
{ |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913CampaignDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
public void setDataSource2(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate2; |
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getcategory() { |
|||
String sqlQuery = "SELECT category_id,category_name FROM gcc_1913_campaign.category where isactive='1' and isdelete='0'"; |
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getcampaignbycategory(int id) { |
|||
String sqlQuery = "SELECT cr.campaign_id, cr.campaign_name " + |
|||
"FROM gcc_1913_campaign.campaign_request cr " + |
|||
"JOIN gcc_1913_campaign.category c ON cr.category_id = c.category_id " + |
|||
"WHERE cr.category_id = ? AND campaign_status='PENDING' " + |
|||
"AND cr.isactive = '1' "; |
|||
return jdbcTemplate.queryForList(sqlQuery,id); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getcampaignbyid(int id) { |
|||
String sqlQuery = "SELECT * FROM gcc_1913_campaign.campaign_request where isactive='1' and campaign_id=?"; |
|||
return jdbcTemplate.queryForList(sqlQuery,id); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getagentsfortask(int id) { |
|||
String sqlQuery = "SELECT al.agent_id,al.agent_name\r\n" |
|||
+ "FROM gcc_1913_qaqc.agents_list al\r\n" |
|||
+ "LEFT JOIN gcc_1913_campaign.agent_assign aa ON al.agent_id = aa.agent_id AND aa.isactive = '1' AND aa.campaign_id = ?\r\n" |
|||
+ "WHERE aa.agent_id IS NULL AND al.calling_type='OUTBOUND'AND al.isactive='1' AND al.isdelete='0'"; |
|||
return jdbcTemplate.queryForList(sqlQuery,id); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public int addagentsfortask(int agent_id, int category_id, int campaign_id) { |
|||
String insertSql = "INSERT INTO gcc_1913_campaign.agent_assign (agent_id, category_id, campaign_id) VALUES (?, ?, ?)"; |
|||
int rowsInserted = jdbcTemplate.update(insertSql, agent_id, category_id, campaign_id); |
|||
|
|||
return rowsInserted; |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public void addAgentsForCampaign(int selectedAgentId, int categoryId, int campaignId) { |
|||
String insertSql = "INSERT INTO gcc_1913_campaign.agent_assign (agent_id, category_id, campaign_id) VALUES (?, ?, ?)"; |
|||
|
|||
try { |
|||
|
|||
int rowsInserted = jdbcTemplate.update(insertSql, selectedAgentId, categoryId, campaignId); |
|||
|
|||
if (rowsInserted > 0) { |
|||
System.out.println("Successfully inserted agent ID in agent_assign== " + selectedAgentId + " into campaign ID " + campaignId); |
|||
} else { |
|||
System.out.println("No rows inserted for agent ID " + selectedAgentId); |
|||
} |
|||
|
|||
} catch (DataAccessException | NumberFormatException ex) { |
|||
System.err.println("Error inserting data: " + ex.getMessage()); |
|||
throw new RuntimeException("Failed to insert agents for campaign. Please try again.", ex); |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public void updateAgentForCampaign(int selectedAgentId, int categoryId, int campaignId,int DataId) { |
|||
String updateSql = "UPDATE gcc_1913_campaign.upload_data SET agent_id = ? WHERE campaign_id = ? AND category_id = ? AND data_id=?"; |
|||
|
|||
try { |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(updateSql, selectedAgentId,campaignId,categoryId,DataId); |
|||
|
|||
/* if (rowsUpdated > 0) { |
|||
System.out.println("Successfully updated agent ID in upload_data== " + selectedAgentId + " for campaign ID " + campaignId); |
|||
} else { |
|||
System.out.println("No rows updated for agent ID " + selectedAgentId); |
|||
}*/ |
|||
|
|||
} catch (DataAccessException | NumberFormatException ex) { |
|||
System.err.println("Error updating data: " + ex.getMessage()); |
|||
throw new RuntimeException("Failed to update agents for campaign. Please try again.", ex); |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Integer> getDataIdForInitialAssign(int categoryId, int campaignId) { |
|||
|
|||
String sql = "SELECT data_id FROM gcc_1913_campaign.upload_data " |
|||
+ "WHERE category_id = ? AND campaign_id = ? " |
|||
+ "AND agent_id IS NULL AND is_processed = 0 ORDER BY data_id"; |
|||
|
|||
// Correctly specify the return type for jdbcTemplate.queryForList |
|||
return jdbcTemplate.queryForList(sql, Integer.class, categoryId, campaignId); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> checkcampaigninassignedtable(int id) |
|||
{ |
|||
String sqlQuery = "SELECT al.agent_id,al.agent_name,aa.assigned_id\r\n" |
|||
+ "FROM gcc_1913_qaqc.agents_list al\r\n" |
|||
+ "JOIN gcc_1913_campaign.agent_assign aa ON al.agent_id = aa.agent_id\r\n" |
|||
+ "JOIN gcc_1913_campaign.campaign_request c ON aa.campaign_id=c.campaign_id\r\n" |
|||
+ "WHERE aa.campaign_id = ? AND aa.isactive = '1' AND al.calling_type='OUTBOUND'AND al.isactive='1' AND al.isdelete='0'"; |
|||
return jdbcTemplate.queryForList(sqlQuery,id); |
|||
} |
|||
|
|||
@Transactional |
|||
public int editagentsfortask(int assigned_id) { |
|||
String updateSql = "UPDATE gcc_1913_campaign.agent_assign SET isactive='0', isdelete='1',status='NOT_ASSIGNED' WHERE assigned_id=?"; |
|||
int rowsInserted = jdbcTemplate.update(updateSql,assigned_id); |
|||
|
|||
return rowsInserted; |
|||
} |
|||
|
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getcampaignquestionbyid(int id) { |
|||
String sqlQuery = " SELECT " + |
|||
" cr.campaign_id, " + |
|||
" cr.campaign_name, " + |
|||
" cr.category_id, " + |
|||
" cr.start_date, " + |
|||
" cr.end_date, " + |
|||
" cr.no_of_agents, " + |
|||
" cr.calls_per_agent, " + |
|||
" cr.description, " + |
|||
" cr.created_date, " + |
|||
" cr.excel_url, " + |
|||
" cr.isactive, " + |
|||
" cr.campaign_status, " + |
|||
" cq.questions, " + |
|||
" cq.question_id, " + |
|||
" cq.answer_type_id, " + |
|||
" cat.type_name, " + |
|||
" ca.campaign_answer " + // Campaign Answer can be NULL |
|||
"FROM gcc_1913_campaign.campaign_request cr " + |
|||
"JOIN gcc_1913_campaign.campaign_questions cq " + |
|||
" ON cr.campaign_id = cq.campaign_id " + |
|||
"LEFT JOIN gcc_1913_campaign.campaign_answers ca " + // LEFT JOIN to include questions with no answers |
|||
" ON cq.question_id = ca.question_id " + |
|||
"JOIN gcc_1913_campaign.answer_type cat " + |
|||
" ON cat.answer_type_id = cq.answer_type_id " + |
|||
"WHERE cr.isactive = 1 AND cr.campaign_id = ?"; |
|||
|
|||
List<Map<String, Object>> queryResult = jdbcTemplate.queryForList(sqlQuery, id); |
|||
|
|||
// Map to group answers by question_id |
|||
Map<Integer, Map<String, Object>> groupedData = new LinkedHashMap(); |
|||
|
|||
for (Map<String, Object> row : queryResult) { |
|||
Integer questionId = (Integer) row.get("question_id"); |
|||
String campaignAnswer = (String) row.get("campaign_answer"); // Can be null |
|||
|
|||
// Check if this question_id already exists in the map |
|||
if (!groupedData.containsKey(questionId)) { |
|||
// Copy the row data (excluding campaign_answer) and initialize answers list |
|||
Map<String, Object> newRow = new LinkedHashMap<>(row); |
|||
newRow.remove("campaign_answer"); // Remove individual answer |
|||
newRow.put("campaign_answers", new ArrayList<String>()); // Initialize answer list |
|||
|
|||
groupedData.put(questionId, newRow); |
|||
} |
|||
|
|||
// Only add answers if they are not null |
|||
if (campaignAnswer != null) { |
|||
((List<String>) groupedData.get(questionId).get("campaign_answers")).add(campaignAnswer); |
|||
} |
|||
} |
|||
|
|||
// Convert grouped data to a list |
|||
return new ArrayList<>(groupedData.values()); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,665 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.service; |
|||
|
|||
import java.io.File; |
|||
import java.io.FileInputStream; |
|||
import java.io.IOException; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.apache.poi.ss.usermodel.Cell; |
|||
import org.apache.poi.ss.usermodel.DateUtil; |
|||
import org.apache.poi.ss.usermodel.Row; |
|||
import org.apache.poi.ss.usermodel.Sheet; |
|||
import org.apache.poi.ss.usermodel.Workbook; |
|||
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class AgentsService { |
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913CampaignDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
public void setDataSource2(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate2; |
|||
|
|||
|
|||
// Utility method to get cell value based on type |
|||
private String getCellValue(Cell cell) { |
|||
if (cell == null) { |
|||
return ""; |
|||
} |
|||
switch (cell.getCellType()) { |
|||
case STRING: |
|||
return cell.getStringCellValue(); |
|||
case NUMERIC: |
|||
// Check if the numeric cell contains a date |
|||
if (DateUtil.isCellDateFormatted(cell)) { |
|||
return new SimpleDateFormat("yyyy-MM-dd").format(cell.getDateCellValue()); |
|||
} |
|||
return String.valueOf((long) cell.getNumericCellValue()); // Cast to long to avoid scientific notation |
|||
case BOOLEAN: |
|||
return String.valueOf(cell.getBooleanCellValue()); |
|||
case FORMULA: |
|||
return cell.getCellFormula(); |
|||
default: |
|||
return ""; |
|||
} |
|||
} |
|||
|
|||
// Parse integer values (for ID) |
|||
private Integer parseInteger(String value) { |
|||
try { |
|||
return Integer.parseInt(value); |
|||
} catch (NumberFormatException e) { |
|||
return null; // return null if parsing fails |
|||
} |
|||
} |
|||
|
|||
// Parse long values (for Mobile number) |
|||
private Long parseLong(String value) { |
|||
try { |
|||
return Long.parseLong(value); |
|||
} catch (NumberFormatException e) { |
|||
return null; // return null if parsing fails |
|||
} |
|||
} |
|||
|
|||
// Example fetch method |
|||
public List<Map<String, Object>> fetchDataFromExcel(int categoryId,Long campaignId) throws IOException { |
|||
String excelUrl = getExcelUrlByCampaignId(campaignId); |
|||
List<Map<String, Object>>data=getExcelData(categoryId,campaignId, excelUrl); |
|||
return saveExcelData(data); |
|||
} |
|||
|
|||
public String getExcelUrlByCampaignId(Long campaignId) { |
|||
String sql = "SELECT excel_url\r\n" |
|||
+ "FROM gcc_1913_campaign.campaign_request\r\n" |
|||
+ "WHERE campaign_id = ?"; |
|||
return jdbcTemplate.queryForObject(sql, String.class, campaignId); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getExcelData(int categoryId,Long campaignId,String filePath) throws IOException { |
|||
List<Map<String, Object>> data = new ArrayList<>(); |
|||
File file = new File(filePath); |
|||
|
|||
try (FileInputStream fis = new FileInputStream(file); |
|||
Workbook workbook = new XSSFWorkbook(fis)) { |
|||
|
|||
Sheet sheet = workbook.getSheetAt(0); |
|||
for (Row row : sheet) { |
|||
if (row.getRowNum() == 0) continue; // skip header row |
|||
|
|||
Map<String, Object> rowData = new HashMap<>(); |
|||
|
|||
// Add the campaign_id and category_id to each row |
|||
|
|||
rowData.put("category_id", categoryId); |
|||
|
|||
rowData.put("campaign_id", campaignId); |
|||
|
|||
// Convert ID to Integer |
|||
rowData.put("ID", getCellValue(row.getCell(0))); |
|||
|
|||
// Name remains String |
|||
rowData.put("Name", getCellValue(row.getCell(1))); |
|||
|
|||
// Address remains String |
|||
rowData.put("Address", getCellValue(row.getCell(2))); |
|||
|
|||
// Dues remains String (you can convert if necessary) |
|||
rowData.put("Balance amount", parseLong(getCellValue(row.getCell(3)))); |
|||
|
|||
// Convert Mobile number to Long |
|||
rowData.put("Mobile number", parseLong(getCellValue(row.getCell(4)))); |
|||
|
|||
rowData.put("Tiny url", getCellValue(row.getCell(5))); |
|||
|
|||
data.add(rowData); |
|||
} |
|||
} |
|||
return data; |
|||
} |
|||
|
|||
public List<Map<String, Object>> saveExcelData(List<Map<String, Object>> data) { |
|||
|
|||
// Prepare SQL query for inserting the specified columns |
|||
String sql = "INSERT INTO gcc_1913_campaign.upload_data (category_id, campaign_id, field_1, field_2, field_3, field_4, field_5,field_6) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?, ?,?)"; |
|||
|
|||
// Loop through the data list and insert each row into the database |
|||
for (Map<String, Object> row : data) { |
|||
jdbcTemplate.update(sql, |
|||
row.get("category_id"), // Category ID |
|||
row.get("campaign_id"), // Campaign ID |
|||
row.get("ID"), // ID (String) |
|||
row.get("Name"), // Name (String) |
|||
row.get("Address"), // Address (String) |
|||
row.get("Balance amount"), // Dues if any (String) |
|||
row.get("Mobile number"), // Mobile number (Long) |
|||
row.get("Tiny url") |
|||
); |
|||
} |
|||
|
|||
// Return the inserted data (if needed) |
|||
return data; // Optionally return the inserted data or change the return type as per your use case |
|||
} |
|||
|
|||
|
|||
|
|||
//For Assigned tasks |
|||
// @Transactional |
|||
// public List<Map<String, Object>> getAgentsALLCampaigns(int agent_id) { |
|||
// String SqlQuery = "SELECT \r\n" |
|||
// + " c.category_name,\r\n" |
|||
// + " cr.campaign_name,\r\n" |
|||
// + " cr.calls_per_agent,\r\n" |
|||
// + " aa.campaign_id,\r\n" |
|||
// + " aa.agent_id,\r\n" |
|||
// + " (SELECT COUNT(data_id) \r\n" |
|||
// + " FROM gcc_1913_campaign.upload_data up \r\n" |
|||
// + " WHERE up.agent_id = aa.agent_id \r\n" |
|||
// + " AND up.campaign_id = cr.campaign_id\r\n" |
|||
// + " ) AS calls_assigned,\r\n" |
|||
// + " (SELECT COUNT(CASE WHEN up.field_14 IS NULL THEN 1 END) \r\n" |
|||
// + " FROM gcc_1913_campaign.upload_data up \r\n" |
|||
// + " WHERE up.agent_id = aa.agent_id \r\n" |
|||
// + " AND up.campaign_id = cr.campaign_id\r\n" |
|||
// + " ) AS pending_count,\r\n" |
|||
// + " (SELECT COUNT(CASE WHEN up.field_14 IS NOT NULL THEN 1 END) \r\n" |
|||
// + " FROM gcc_1913_campaign.upload_data up \r\n" |
|||
// + " WHERE up.agent_id = aa.agent_id \r\n" |
|||
// + " AND up.campaign_id = cr.campaign_id\r\n" |
|||
// + " ) AS complete_count,\r\n" |
|||
// + " (SELECT COUNT(CASE WHEN up.field_14 ='CALL_BACK_LATER' OR up.field_14 = 'UNATTENDED' THEN 1 END) \r\n" |
|||
// + " FROM gcc_1913_campaign.upload_data up \r\n" |
|||
// + " WHERE up.agent_id = aa.agent_id \r\n" |
|||
// + " AND up.campaign_id = cr.campaign_id\r\n" |
|||
// + " ) AS followup_count\r\n" |
|||
// + " \r\n" |
|||
// + "FROM \r\n" |
|||
// + " gcc_1913_campaign.agent_assign aa\r\n" |
|||
// + "JOIN \r\n" |
|||
// + " gcc_1913_qaqc.agents_list al ON aa.agent_id = al.agent_id\r\n" |
|||
// + "JOIN \r\n" |
|||
// + " gcc_1913_campaign.campaign_request cr ON cr.campaign_id = aa.campaign_id\r\n" |
|||
// + "JOIN \r\n" |
|||
// + " gcc_1913_campaign.category c ON cr.category_id = c.category_id\r\n" |
|||
// + "WHERE \r\n" |
|||
// + " aa.agent_id = ? \r\n" |
|||
// + " AND aa.isactive = '1'\r\n" |
|||
// + " AND cr.isactive = '0'"; |
|||
// |
|||
// return jdbcTemplate.queryForList(SqlQuery,agent_id); |
|||
// } |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getdataByIds(List<Integer> ids) { |
|||
// Construct the SQL query with placeholders for the number of IDs |
|||
String inSql = String.join(",", Collections.nCopies(ids.size(), "?")); |
|||
String SqlQuery = "SELECT data_id, field_1 as id, field_2 as name, field_3 as address, field_4 as dues, field_5 as cellnumber,field_6 as viewdetails,field_14 as call_status,field_15 as remarks " + |
|||
"FROM gcc_1913_campaign.upload_data " + |
|||
"WHERE data_id IN (" + inSql + ")"; |
|||
|
|||
// Convert the list of ids to an Object array |
|||
return jdbcTemplate.queryForList(SqlQuery, ids.toArray()); |
|||
} |
|||
|
|||
@Transactional |
|||
public void saveCallLogs(String call_status,String remarks ,int data_id,int agent_id) |
|||
{ |
|||
String SqlQuery = "UPDATE gcc_1913_campaign.upload_data SET call_status = ?, remarks=?, updated_date = NOW() ,updated_agent_id=?, is_processed=1 WHERE (data_id = ? )"; |
|||
|
|||
jdbcTemplate.update(SqlQuery,call_status, remarks,agent_id,data_id); |
|||
} |
|||
|
|||
@Transactional |
|||
public int saveInLogsTable(int campaignId, int agentId, int dataId, String call_status,String remarks) { |
|||
String sqlQuery = "INSERT INTO gcc_1913_campaign.call_logs (campaign_id,agent_id,data_id,call_status,remarks) VALUES (?, ?, ?,?,?)"; |
|||
int rowsAffected = 0; |
|||
try { |
|||
rowsAffected = jdbcTemplate.update(sqlQuery, campaignId, agentId, dataId,call_status,remarks); |
|||
//System.out.println("Inserted into call_logs successfully. Rows affected: " + rowsAffected); |
|||
} catch (Exception e) { |
|||
System.err.println("Error inserting into call_logs: " + e.getMessage()); |
|||
// Log the exception or rethrow it based on your error-handling strategy |
|||
} |
|||
return rowsAffected; |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getPendingDataByIds(List<Integer> ids) { |
|||
// Construct the SQL query with placeholders for the number of IDs |
|||
String inSql = String.join(",", Collections.nCopies(ids.size(), "?")); |
|||
String SqlQuery = "SELECT data_id, field_1 as id, field_2 as name, field_3 as address, field_4 as dues, field_5 as cellnumber,field_6 as viewdetails,field_14 as call_status,field_15 as remarks " + |
|||
"FROM gcc_1913_campaign.upload_data " + |
|||
"WHERE data_id IN (" + inSql + ") " + |
|||
"AND field_14 IN ('UNATTENDED', 'CALL_BACK_LATER')"; |
|||
|
|||
// Convert the list of ids to an Object array |
|||
return jdbcTemplate.queryForList(SqlQuery, ids.toArray()); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAgentsNameById(List<Integer> agentIds) |
|||
{ |
|||
String inSql = String.join(",", Collections.nCopies(agentIds.size(), "?")); |
|||
String SqlQuery ="select agent_name,agent_id from gcc_1913_qaqc.agents_list where agent_id IN (" + inSql + ")"; |
|||
|
|||
return jdbcTemplate.queryForList(SqlQuery, agentIds.toArray()); |
|||
|
|||
} |
|||
//agents performance |
|||
@Transactional |
|||
public List<Map<String, Object>> getDataDetailsById(List<Integer> dataIds) |
|||
{ |
|||
if (dataIds.isEmpty()) { |
|||
// Handle the case where dataIds is empty to avoid SQL syntax error. |
|||
throw new IllegalArgumentException("The dataIds list is empty, cannot execute query."); |
|||
} |
|||
|
|||
String inSql = String.join(",", Collections.nCopies(dataIds.size(), "?")); |
|||
String SqlQuery ="SELECT\r\n" |
|||
+ " COUNT(*) AS Assigned_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 IS NOT NULL THEN 1 END) AS Complete_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 IS NULL THEN 1 END) AS Pending_count ,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'INFORMATION_GIVEN' THEN 1 END) AS Information_Given_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'UNATTENDED' THEN 1 END) AS Unattended_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'CALL_BACK_LATER' THEN 1 END) AS Call_back_later_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'SWITCH_OFF' THEN 1 END) AS Switch_off_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'WRONG_NUMBER' THEN 1 END) AS Wrong_number_count,\r\n" |
|||
+ " CASE WHEN COUNT(*) = 0 THEN 0 ELSE ROUND((COUNT(CASE WHEN field_14 IS NOT NULL THEN 1 END) * 100.0 / COUNT(*)), 0)END AS Percentage\r\n" |
|||
+ "FROM gcc_1913_campaign.upload_data\r\n" |
|||
+ "WHERE data_id IN (" + inSql + ")"; |
|||
|
|||
|
|||
|
|||
List<Map<String, Object>> results = jdbcTemplate.queryForList(SqlQuery, dataIds.toArray()); |
|||
return results; |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getCompletedDataDetailsById(List<Integer> CdataIds) |
|||
{ |
|||
if (CdataIds.isEmpty()) { |
|||
// Handle the case where dataIds is empty to avoid SQL syntax error. |
|||
throw new IllegalArgumentException("The CdataIds list is empty, cannot execute query."); |
|||
} |
|||
|
|||
String inSql = String.join(",", Collections.nCopies(CdataIds.size(), "?")); |
|||
String SqlQuery ="SELECT\r\n" |
|||
+ " data_id,\r\n" // Add data_id to the result |
|||
+ " COUNT(*) AS Assigned_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 IS NOT NULL THEN 1 END) AS Complete_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 IS NULL THEN 1 END) AS Pending_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'INFORMATION_GIVEN' THEN 1 END) AS Information_Given_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'UNATTENDED' THEN 1 END) AS Unattended_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'CALL_BACK_LATER' THEN 1 END) AS Call_back_later_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'SWITCH_OFF' THEN 1 END) AS Switch_off_count,\r\n" |
|||
+ " COUNT(CASE WHEN field_14 = 'WRONG_NUMBER' THEN 1 END) AS Wrong_number_count,\r\n" |
|||
+ " CASE WHEN COUNT(*) = 0 THEN 0 ELSE ROUND((COUNT(CASE WHEN field_14 IS NOT NULL THEN 1 END) * 100.0 / COUNT(*)), 0) END AS Percentage\r\n" |
|||
+ "FROM gcc_1913_campaign.upload_data\r\n" |
|||
+ "WHERE data_id IN (" + inSql + ")\r\n" |
|||
+ "GROUP BY data_id"; // Group by data_id |
|||
|
|||
return jdbcTemplate.queryForList(SqlQuery, CdataIds.toArray()); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String,Object>> getCompletedDataById(List<Integer> completedDataIds) |
|||
{ |
|||
if (completedDataIds.isEmpty()) { |
|||
// Handle the case where dataIds is empty to avoid SQL syntax error. |
|||
throw new IllegalArgumentException("The completedDataIds list is empty, cannot execute query."); |
|||
} |
|||
|
|||
String inSql = String.join(",", Collections.nCopies(completedDataIds.size(), "?")); |
|||
String SqlQuery = "SELECT field_1 as id, field_2 as name, field_3 as address, " + |
|||
"field_5 as cellnumber, field_14 as call_status, updated_date as updated_date,field_15 as remarks, " + |
|||
"(SELECT COUNT(data_id) FROM call_logs WHERE data_id = upload_data.data_id) as call_count " + |
|||
"FROM gcc_1913_campaign.upload_data " + |
|||
"WHERE data_id IN (" + inSql + ")"; |
|||
|
|||
|
|||
return jdbcTemplate.queryForList(SqlQuery, completedDataIds.toArray()); |
|||
|
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public void addAgentsForCampaign(int selectedAgentId, int categoryId, int campaignId) { |
|||
String checkSql = "SELECT COUNT(*) FROM gcc_1913_campaign.agent_assign " |
|||
+ "WHERE agent_id = ? AND category_id = ? AND campaign_id = ?"; |
|||
|
|||
String insertSql = "INSERT INTO gcc_1913_campaign.agent_assign (agent_id, category_id, campaign_id) VALUES (?, ?, ?)"; |
|||
|
|||
try { |
|||
// Check if the record already exists |
|||
int count = jdbcTemplate.queryForObject(checkSql, Integer.class, selectedAgentId, categoryId, campaignId); |
|||
|
|||
if (count == 0) { |
|||
// Insert only if no existing record found |
|||
int rowsInserted = jdbcTemplate.update(insertSql, selectedAgentId, categoryId, campaignId); |
|||
|
|||
if (rowsInserted > 0) { |
|||
System.out.println("Successfully inserted agent ID " + selectedAgentId + " into campaign ID " + campaignId); |
|||
} else { |
|||
System.out.println("No rows inserted for agent ID " + selectedAgentId); |
|||
} |
|||
} else { |
|||
System.out.println("Agent ID " + selectedAgentId + " is already assigned to campaign ID " + campaignId); |
|||
} |
|||
|
|||
} catch (DataAccessException | NumberFormatException ex) { |
|||
System.err.println("Error inserting data: " + ex.getMessage()); |
|||
throw new RuntimeException("Failed to insert agents for campaign. Please try again.", ex); |
|||
} |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public void updateAgentForCampaign(int selectedAgentId, int categoryId, int campaignId,int DataId) { |
|||
String updateSql = "UPDATE gcc_1913_campaign.upload_data SET agent_id = ? WHERE campaign_id = ? AND category_id = ? AND data_id=?"; |
|||
|
|||
try { |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(updateSql, selectedAgentId,campaignId,categoryId,DataId); |
|||
|
|||
/* if (rowsUpdated > 0) { |
|||
System.out.println("Successfully updated agent ID in upload_data== " + selectedAgentId + " for campaign ID " + campaignId); |
|||
} else { |
|||
System.out.println("No rows updated for agent ID " + selectedAgentId); |
|||
}*/ |
|||
|
|||
} catch (DataAccessException | NumberFormatException ex) { |
|||
System.err.println("Error updating data: " + ex.getMessage()); |
|||
throw new RuntimeException("Failed to update agents for campaign. Please try again.", ex); |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Integer> getDataIdForFurtherAssign(int categoryId, int campaignId) { |
|||
|
|||
String sql = "SELECT data_id FROM gcc_1913_campaign.upload_data " |
|||
+ "WHERE category_id = ? " |
|||
+ "AND campaign_id = ? " |
|||
+ "AND is_processed = 0 " |
|||
+ "ORDER BY data_id"; |
|||
|
|||
return jdbcTemplate.queryForList(sql, Integer.class, categoryId, campaignId); |
|||
} |
|||
|
|||
@Transactional |
|||
public void resetAgentAssignmentForNextDay(int categoryId, int campaignId) { |
|||
String sql = "UPDATE gcc_1913_campaign.upload_data " |
|||
+ "SET agent_id = NULL, " |
|||
+ " call_status = NULL, " |
|||
+ " remarks = NULL, " |
|||
+ " updated_agent_id = NULL, " |
|||
+ " updated_date = NULL, " |
|||
+ " is_processed = 0 " |
|||
+ "WHERE category_id = ? " |
|||
+ " AND campaign_id = ? " |
|||
+ " AND call_status IN ('CALL BACK LATER', 'UNATTENDED')"; |
|||
|
|||
jdbcTemplate.update(sql, categoryId, campaignId); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
//////////////////////Ajith code/////////////////// |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getFilteredFields(int categoryId, int agentId, int dataId) { |
|||
List<Map<String, Object>> resultList = new ArrayList<>(); |
|||
|
|||
// Fetch ordered field column names |
|||
String fetchColumnsSQL = "SELECT COLUMN_NAME " + |
|||
"FROM INFORMATION_SCHEMA.COLUMNS " + |
|||
"WHERE TABLE_SCHEMA = 'gcc_1913_campaign' " + |
|||
"AND TABLE_NAME = 'upload_data' " + |
|||
"AND COLUMN_NAME LIKE 'field_%' " + |
|||
"ORDER BY CAST(SUBSTRING(COLUMN_NAME, 7) AS UNSIGNED)"; |
|||
|
|||
List<String> fieldColumns = jdbcTemplate.queryForList(fetchColumnsSQL, String.class); |
|||
|
|||
if (fieldColumns.isEmpty()) { |
|||
throw new RuntimeException("No matching columns found"); |
|||
} |
|||
|
|||
// Fetch ordered fields data |
|||
String query1 = "SELECT " + String.join(", ", fieldColumns) + " FROM gcc_1913_campaign.upload_data WHERE data_id = ?"; |
|||
List<Map<String, Object>> orderedFieldsList = jdbcTemplate.queryForList(query1, dataId); |
|||
|
|||
if (orderedFieldsList.isEmpty()) { |
|||
throw new RuntimeException("No data found for data_id: " + dataId); |
|||
} |
|||
|
|||
Map<String, Object> orderedFields = orderedFieldsList.get(0); |
|||
|
|||
// Fetch category columns |
|||
String query2 = "SELECT column_name FROM gcc_1913_campaign.category_columns WHERE category_id = ? and isactive=1 "; |
|||
List<String> categoryColumns = new ArrayList<>(jdbcTemplate.queryForList(query2, String.class, categoryId)); |
|||
//System.out.println("service===="+categoryColumns); |
|||
|
|||
if (categoryColumns.isEmpty()) { |
|||
throw new RuntimeException("No category columns found for category_id: " + categoryId); |
|||
} |
|||
|
|||
int categoryCount = categoryColumns.size(); |
|||
|
|||
// Collect first 'categoryCount' non-null values from orderedFields |
|||
List<Object> nonNullValues = new ArrayList<>(); |
|||
for (String field : fieldColumns) { |
|||
Object value = orderedFields.get(field); |
|||
if (value != null) { |
|||
nonNullValues.add(value); |
|||
if (nonNullValues.size() == categoryCount) { |
|||
break; // Stop after collecting required count |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (nonNullValues.size() < categoryCount) { |
|||
throw new RuntimeException("Not enough non-null values to match category columns"); |
|||
} |
|||
|
|||
// Map category columns to non-null ordered field values |
|||
Map<String, Object> finalMapping = new HashMap<>(); |
|||
for (int i = 0; i < categoryCount; i++) { |
|||
finalMapping.put(categoryColumns.get(i), nonNullValues.get(i)); |
|||
} |
|||
|
|||
resultList.add(finalMapping); |
|||
return resultList; |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getCampaignQuestions(int categoryId, int campaignId) { |
|||
// Fetch questions along with answer type |
|||
// String questionQuery = "SELECT cq.*, at.type_name " + |
|||
// "FROM gcc_1913_campaign.campaign_questions cq " + |
|||
// "JOIN gcc_1913_campaign.answer_type at " + |
|||
// "ON cq.answer_type_id = at.answer_type_id " + |
|||
// |
|||
// "WHERE cq.category_id = ? AND cq.campaign_id = ? "; |
|||
|
|||
String questionQuery="SELECT cq.questions AS questions, \r\n" |
|||
+ " MIN(cq.question_id) AS question_id, \r\n" |
|||
+ " MIN(cq.category_id) AS category_id, \r\n" |
|||
+ " MIN(cq.campaign_id) AS campaign_id, \r\n" |
|||
+ " MIN(cq.answer_type_id) AS answer_type_id, \r\n" |
|||
+ " MIN(cat.type_name) AS type_name \r\n" |
|||
+ "FROM gcc_1913_campaign.campaign_questions cq \r\n" |
|||
+ "JOIN gcc_1913_campaign.answer_type cat \r\n" |
|||
+ " ON cq.answer_type_id = cat.answer_type_id \r\n" |
|||
+ "WHERE cq.category_id = ? \r\n" |
|||
+ "AND cq.campaign_id = ? \r\n" |
|||
+ "AND cq.isactive = 1\r\n" |
|||
+ "GROUP BY cq.questions\r\n" |
|||
+ "ORDER BY MIN(cq.question_id)"; |
|||
|
|||
List<Map<String, Object>> questions = jdbcTemplate.queryForList(questionQuery, categoryId, campaignId); |
|||
|
|||
// Iterate over each question and fetch answers |
|||
for (Map<String, Object> question : questions) { |
|||
int questionId = (int) question.get("question_id"); |
|||
|
|||
// String answerQuery = "SELECT campaign_answer FROM gcc_1913_campaign.campaign_answers " + |
|||
// "WHERE question_id = ?"; |
|||
|
|||
String answerQuery="SELECT distinct(question_id) as qid, campaign_answer, created_date FROM gcc_1913_campaign.campaign_answers\r\n" |
|||
+ "WHERE question_id = ?"; |
|||
|
|||
List<Map<String, Object>> answers = jdbcTemplate.queryForList(answerQuery, questionId); |
|||
/* |
|||
// Extract answer values and add to the question map |
|||
List<String> answerList = answers.stream() |
|||
.map(a -> (String) a.get("campaign_answer")) |
|||
.collect(Collectors.toList()); |
|||
*/ |
|||
List<String> answerList = new ArrayList<String>(); |
|||
|
|||
for (Map<String, Object> a : answers) { |
|||
Object ansObj = a.get("campaign_answer"); |
|||
if (ansObj != null) { |
|||
answerList.add(ansObj.toString()); |
|||
} |
|||
} |
|||
|
|||
question.put("answers", answerList); |
|||
} |
|||
|
|||
return questions; |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> FetchAnswer(int campaignId,int agentId,int questionId,int dataId) { |
|||
String sqlQuery = "SELECT distinct(campaign_answer) FROM gcc_1913_campaign.questions_answers where campaign_id=? and agent_id=? and question_id=? and data_id=?; "; |
|||
//System.out.println("dropdown l"); |
|||
return jdbcTemplate.queryForList(sqlQuery,campaignId,agentId,questionId,dataId); |
|||
} |
|||
|
|||
@Transactional |
|||
public void saveAnswers(List<Map<String, Object>> answers) { |
|||
String sql = "INSERT INTO gcc_1913_campaign.questions_answers " + |
|||
"(campaign_id, data_id, agent_id, question_id, campaign_answer, created_date) " + |
|||
"VALUES (?, ?, ?, ?, ?, NOW())"; |
|||
|
|||
for (Map<String, Object> answer : answers) { |
|||
jdbcTemplate.update(sql, |
|||
answer.get("campaign_id"), |
|||
answer.get("data_id"), |
|||
answer.get("agent_id"), |
|||
answer.get("question_id"), |
|||
answer.get("campaign_answer") |
|||
); |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getCallStatus() { |
|||
String sqlQuery = "SELECT * FROM gcc_1913_campaign.calls_status "; |
|||
//System.out.println("dropdown l"); |
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> checkCounts(int campaignId, int dataId) { |
|||
// Query to get the count of answered questions for a given dataId |
|||
String answersCountQuery = "SELECT COUNT(distinct(question_id)) AS answersCount FROM gcc_1913_campaign.questions_answers WHERE data_id = ?"; |
|||
|
|||
// Query to get the count of required questions for a given campaignId |
|||
String questionsCountQuery = "SELECT COUNT(distinct(questions)) AS questionsCount FROM gcc_1913_campaign.campaign_questions WHERE campaign_id = ?"; |
|||
|
|||
// Execute queries |
|||
int answersCount = jdbcTemplate.queryForObject(answersCountQuery, Integer.class, dataId); |
|||
int questionsCount = jdbcTemplate.queryForObject(questionsCountQuery, Integer.class, campaignId); |
|||
|
|||
// Construct response as a list of maps |
|||
return List.of(Map.of( |
|||
"answersCount", answersCount, |
|||
"questionsCount", questionsCount |
|||
)); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAgentsALLCampaignsList(int agent_id) { |
|||
String SqlQuery = "SELECT * FROM gcc_1913_campaign.upload_data ud inner join gcc_1913_campaign.campaign_request cr on ud.campaign_id=cr.campaign_id where cr.campaign_status='ONGOING'"+ |
|||
" and ud.agent_id = ? and ud.is_processed=0 "; |
|||
//System.out.println("text"); |
|||
return jdbcTemplate.queryForList(SqlQuery,agent_id); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAgentsALLCampaignsList1(int agent_id) { |
|||
String SqlQuery = "SELECT * FROM gcc_1913_campaign.upload_data ud inner join gcc_1913_campaign.campaign_request cr on ud.campaign_id=cr.campaign_id where cr.campaign_status='ONGOING'"+ |
|||
" and ud.agent_id = ? and ud.is_processed=1"; |
|||
// System.out.println("text"); |
|||
return jdbcTemplate.queryForList(SqlQuery,agent_id); |
|||
} |
|||
|
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAgentsALLCampaigns(int agent_id) { |
|||
String SqlQuery = "SELECT c.category_name,cr.*,\r\n" |
|||
+ "(SELECT COUNT(data_id)\r\n" |
|||
+ "FROM gcc_1913_campaign.upload_data up\r\n" |
|||
+ "WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ "AND up.campaign_id = cr.campaign_id\r\n" |
|||
+ ") AS calls_assigned,\r\n" |
|||
+ "(SELECT COUNT(CASE WHEN up.call_status IS NOT NULL THEN 1 END) \r\n" |
|||
+ "FROM gcc_1913_campaign.upload_data up \r\n" |
|||
+ "WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ "AND up.campaign_id = cr.campaign_id\r\n" |
|||
+ ") AS complete_count,\r\n" |
|||
+ "(SELECT COUNT(CASE WHEN up.call_status IS NULL THEN 1 END) \r\n" |
|||
+ "FROM gcc_1913_campaign.upload_data up \r\n" |
|||
+ "WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ "AND up.campaign_id = cr.campaign_id\r\n" |
|||
+ ") AS pending_count\r\n" |
|||
+ "FROM gcc_1913_campaign.agent_assign aa\r\n" |
|||
+ "JOIN gcc_1913_campaign.campaign_request cr ON cr.campaign_id=aa.campaign_id\r\n" |
|||
+ "JOIN gcc_1913_campaign.category c ON c.category_id=cr.category_id\r\n" |
|||
+ "WHERE cr.campaign_status='ONGOING' AND aa.isactive=1 AND cr.isactive=1 AND aa.agent_id=?"; |
|||
|
|||
return jdbcTemplate.queryForList(SqlQuery,agent_id); |
|||
} |
|||
|
|||
// public List<Map<String, Object>> getCallCategories() |
|||
// { |
|||
// String query = "SELECT id,call_status FROM gcc_1913_campaign.calls_status WHERE isactive=1 AND isdelete=0"; |
|||
// return jdbcTemplate.queryForList(query); |
|||
// } |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,116 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.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 AttendanceService { |
|||
|
|||
|
|||
// private JdbcTemplate jdbcTemplate; |
|||
// |
|||
// |
|||
// @Autowired |
|||
// public void setDataSource(@Qualifier("BiometricDataSource") DataSource dataSource) { |
|||
// this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
// } |
|||
// |
|||
// |
|||
// public List<Map<String, Object>> getAttendanceReport(String fromDate, String toDate) { |
|||
// String reportQuery; |
|||
// |
|||
// if (fromDate != null && toDate != null) { |
|||
// // Query with date filter if dates are provided |
|||
// reportQuery = "SELECT d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, " + |
|||
// "c.device_name, CAST(a.officepunch AS DATE) AS punch_date, MIN(a.OFFICEPUNCH) AS PUNCHIN, " + |
|||
// "CASE WHEN MAX(a.OFFICEPUNCH) = MIN(a.OFFICEPUNCH) THEN NULL ELSE MAX(a.OFFICEPUNCH) END AS PUNCHOUT " + |
|||
// "FROM machinerawpunch a, tbl_realtime_userinfo b, tbl_fkdevice_status c, zone_div_mast d, " + |
|||
// "tblemployee e, tbldepartment f " + |
|||
// "WHERE a.paycode = b.user_id AND a.deviceid = c.device_id AND c.device_name = d.devname " + |
|||
// "AND a.paycode = e.paycode AND e.departmentcode = f.departmentcode " + |
|||
// "AND CAST(a.officepunch AS DATE) BETWEEN ? AND ? " + |
|||
// "AND a.paycode LIKE '%19130%' " + |
|||
// "GROUP BY d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, " + |
|||
// "c.device_name, CAST(a.officepunch AS DATE) " + |
|||
// "ORDER BY d.zone, d.division, b.user_id, CAST(a.officepunch AS DATE)"; |
|||
// |
|||
// // Execute query with date parameters |
|||
// return jdbcTemplate.queryForList(reportQuery, fromDate, toDate); |
|||
// |
|||
// } else { |
|||
// // Query without date filter |
|||
// reportQuery = "SELECT d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, " + |
|||
// "c.device_name, CAST(a.officepunch AS DATE) AS punch_date, MIN(a.OFFICEPUNCH) AS PUNCHIN, " + |
|||
// "CASE WHEN MAX(a.OFFICEPUNCH) = MIN(a.OFFICEPUNCH) THEN NULL ELSE MAX(a.OFFICEPUNCH) END AS PUNCHOUT " + |
|||
// "FROM machinerawpunch a, tbl_realtime_userinfo b, tbl_fkdevice_status c, zone_div_mast d, " + |
|||
// "tblemployee e, tbldepartment f " + |
|||
// "WHERE a.paycode = b.user_id AND a.deviceid = c.device_id AND c.device_name = d.devname " + |
|||
// "AND a.paycode = e.paycode AND e.departmentcode = f.departmentcode " + |
|||
// "AND a.paycode LIKE '%19130%' " + |
|||
// "GROUP BY d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, " + |
|||
// "c.device_name, CAST(a.officepunch AS DATE) " + |
|||
// "ORDER BY d.zone, d.division, b.user_id, CAST(a.officepunch AS DATE)"; |
|||
// |
|||
// // Execute query without date parameters |
|||
// return jdbcTemplate.queryForList(reportQuery); |
|||
// } |
|||
// } |
|||
// |
|||
// |
|||
// |
|||
//// public List<Map<String, Object>> getAttendanceReport(String fromDate, String toDate) { |
|||
//// System.out.println("Service Layer: Generating attendance report"); |
|||
//// |
|||
//// String reportQuery = "SELECT d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, c.device_name, " + |
|||
//// "CAST(a.officepunch AS DATE) AS punch_date, MIN(a.OFFICEPUNCH) AS PUNCHIN, " + |
|||
//// "CASE WHEN MAX(a.OFFICEPUNCH) = MIN(a.OFFICEPUNCH) THEN NULL ELSE MAX(a.OFFICEPUNCH) END AS PUNCHOUT " + |
|||
//// "FROM machinerawpunch a, tbl_realtime_userinfo b, tbl_fkdevice_status c, zone_div_mast d, " + |
|||
//// "tblemployee e, tbldepartment f " + |
|||
//// "WHERE a.paycode = b.user_id AND a.deviceid = c.device_id AND c.device_name = d.devname " + |
|||
//// "AND a.paycode = e.paycode AND e.departmentcode = f.departmentcode "; |
|||
//// |
|||
//// // Dynamic date filter |
|||
//// if (fromDate != null && toDate != null) { |
|||
//// reportQuery += "AND CAST(a.officepunch AS DATE) BETWEEN ? AND ? "; |
|||
//// } else if (fromDate != null) { |
|||
//// reportQuery += "AND CAST(a.officepunch AS DATE) = ? "; |
|||
//// } else { |
|||
//// throw new IllegalArgumentException("fromDate or toDate must be provided"); |
|||
//// } |
|||
//// |
|||
//// reportQuery += "AND a.paycode LIKE '%19130%' " + |
|||
//// "GROUP BY d.zone, d.division, b.user_id, b.user_name, f.departmentname, e.designation, c.device_name, " + |
|||
//// "CAST(a.officepunch AS DATE) " + |
|||
//// "ORDER BY d.zone, d.division, b.user_id, CAST(a.officepunch AS DATE)"; |
|||
//// |
|||
//// // Execute query based on dates |
|||
//// if (fromDate != null && toDate != null) { |
|||
//// return jdbcTemplate.queryForList(reportQuery, fromDate, toDate); |
|||
//// } else { |
|||
//// return jdbcTemplate.queryForList(reportQuery, fromDate); |
|||
//// } |
|||
//// } |
|||
// |
|||
//// public List<Map<String, Object>> getAttendanceReport() { |
|||
//// System.out.println("check 2"); |
|||
//// String reportQuery ="SELECT d.zone,d.division,b.user_id,b.user_name,f.departmentname,e.designation,c.device_name,CAST(a.officepunch AS DATE) as punch_date,MIN(a.OFFICEPUNCH) AS PUNCHIN,\r\n" |
|||
//// + "CASE WHEN MAX(a.OFFICEPUNCH) = MIN(a.OFFICEPUNCH) THEN NULL ELSE MAX(a.OFFICEPUNCH) END AS PUNCHOUT FROM machinerawpunch a,tbl_realtime_userinfo b,tbl_fkdevice_status c,\r\n" |
|||
//// + "zone_div_mast d,tblemployee e,tbldepartment f WHERE a.paycode = b.user_id AND a.deviceid = c.device_id AND c.device_name = d.devname AND a.paycode = e.paycode AND \r\n" |
|||
//// + "e.departmentcode = f.departmentcode AND CAST(officepunch AS DATE) BETWEEN '2024-10-01' AND '2024-10-10'\r\n" |
|||
//// + "AND a.paycode LIKE '%19130%' \r\n" |
|||
//// + "GROUP BY d.zone,d.division,b.user_id,b.user_name,f.departmentname,e.designation,c.device_name,CAST(a.officepunch AS DATE)\r\n" |
|||
//// + "ORDER BY d.zone,d.division,b.user_id,CAST(a.officepunch AS DATE)"; |
|||
//// System.out.println("check 3"); |
|||
//// List<Map<String,Object>> reports = jdbcTemplate.queryForList(reportQuery); |
|||
//// System.out.println("check 4"); |
|||
//// return reports; |
|||
//// } |
|||
|
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.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 CampaignDropdownApiService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913CampaignDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
public List<Map<String,Object>> getAnswerTypes(){ |
|||
String sql = "SELECT answer_type_id,type_name FROM answer_type"; |
|||
return jdbcTemplate.queryForList(sql); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,533 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.service; |
|||
|
|||
import java.io.PrintWriter; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.LinkedHashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
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 CampaignReportService { |
|||
|
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSourcemysql(@Qualifier("mysql1913CampaignDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
public void setDataSource2(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getCampaignData(String startDate, String endDate) { |
|||
StringBuilder query = new StringBuilder( |
|||
"SELECT " + |
|||
" cr.campaign_id, " + |
|||
" cr.category_id, " + |
|||
" cr.campaign_name, " + |
|||
" cc.category_name, " + |
|||
" cr.start_date, " + |
|||
" cr.end_date, " + |
|||
" COUNT(ud.campaign_id) AS total_count, " + |
|||
" COUNT(ud.agent_id) AS assigned_count, " + |
|||
" COUNT(ud.campaign_id) - COUNT(ud.agent_id) AS not_assigned_count, " + |
|||
" COUNT(CASE WHEN ud.call_status = 'INFORMATION GIVEN' THEN 1 ELSE NULL END) AS informationgiven_count, " + |
|||
" COUNT(CASE WHEN ud.call_status = 'CALL BACK LATER' THEN 1 ELSE NULL END) AS callback_count, " + |
|||
" COUNT(CASE WHEN ud.call_status = 'UNATTENDED' THEN 1 ELSE NULL END) AS unattended_count, " + |
|||
" COUNT(CASE WHEN ud.call_status = 'SWITCH OFF' THEN 1 ELSE NULL END) AS switchoff_count, " + |
|||
" COUNT(CASE WHEN ud.call_status = 'WRONG NUMBER' THEN 1 ELSE NULL END) AS wrongnumber_count " + |
|||
"FROM gcc_1913_campaign.campaign_request cr " + |
|||
"JOIN gcc_1913_campaign.upload_data ud ON cr.campaign_id = ud.campaign_id " + |
|||
"JOIN gcc_1913_campaign.category cc ON cr.category_id = cc.category_id " + |
|||
"WHERE cr.campaign_status IN ('ONGOING', 'CLOSED') " + |
|||
"AND ud.agent_id IS NOT NULL " |
|||
); |
|||
|
|||
// Apply date filter dynamically if dates are provided |
|||
if (startDate != null && endDate != null) { |
|||
query.append("AND DATE(cr.created_date) BETWEEN ? AND ? "); |
|||
} |
|||
|
|||
query.append("GROUP BY cr.campaign_id "); |
|||
query.append("ORDER BY cr.campaign_id DESC"); |
|||
|
|||
// Execute query with or without parameters |
|||
if (startDate != null && endDate != null) { |
|||
return jdbcTemplate.queryForList(query.toString(), startDate, endDate); |
|||
} else { |
|||
return jdbcTemplate.queryForList(query.toString()); |
|||
} |
|||
} |
|||
|
|||
public List<Map<String, Object>> getAgentwiseData(String campaignId) { |
|||
String query = "SELECT aa.agent_id, al.agent_name, \r\n" |
|||
+ " COUNT(ud.agent_id) AS assigned_count, \r\n" |
|||
+ " COUNT(CASE WHEN ud.is_processed = 1 THEN 1 ELSE NULL END) AS completed_count, \r\n" |
|||
+ " COUNT(ud.agent_id) - COUNT(CASE WHEN ud.is_processed = 1 THEN 1 ELSE NULL END) AS pending_count, \r\n" |
|||
+ " COUNT(CASE WHEN ud.call_status = 'INFORMATION GIVEN' THEN 1 ELSE NULL END) AS informationgiven_count, \r\n" |
|||
+ " COUNT(CASE WHEN ud.call_status = 'CALL BACK LATER' THEN 1 ELSE NULL END) AS callback_count, \r\n" |
|||
+ " COUNT(CASE WHEN ud.call_status = 'UNATTENDED' THEN 1 ELSE NULL END) AS unattended_count, \r\n" |
|||
+ " COUNT(CASE WHEN ud.call_status = 'SWITCH OFF' THEN 1 ELSE NULL END) AS switchoff_count, \r\n" |
|||
+ " COUNT(CASE WHEN ud.call_status = 'WRONG NUMBER' THEN 1 ELSE NULL END) AS wrongnumber_count, \r\n" |
|||
+ " CASE \r\n" |
|||
+ " WHEN COUNT(ud.agent_id) = 0 THEN 0 \r\n" |
|||
+ " ELSE FLOOR((COUNT(CASE WHEN ud.is_processed = 1 THEN 1 ELSE NULL END) * 100) / COUNT(ud.agent_id))\r\n" |
|||
+ " END AS completed_percentage\r\n" |
|||
+ "FROM gcc_1913_campaign.agent_assign aa \r\n" |
|||
+ "JOIN gcc_1913_qaqc.agents_list al ON al.agent_id = aa.agent_id \r\n" |
|||
+ "JOIN gcc_1913_campaign.upload_data ud ON ud.agent_id = aa.agent_id AND ud.campaign_id = aa.campaign_id\r\n" |
|||
+ "WHERE aa.campaign_id = ? AND aa.isactive = 1 AND aa.isdelete = 0 AND ud.agent_id IS NOT NULL \r\n" |
|||
+ "GROUP BY aa.agent_id, al.agent_name \r\n" |
|||
+ "ORDER BY aa.agent_id"; |
|||
|
|||
return jdbcTemplate.queryForList(query, campaignId); |
|||
} |
|||
|
|||
//report for campaign details |
|||
public List<Map<String, Object>> getAgentReportCampaignId(String campaignId) { |
|||
String query = "SELECT cr.category_id,cr.campaign_id, cc.category_name, \r\n" |
|||
+ " cr.start_date, cr.end_date, \r\n" |
|||
+ " cr.description, date (cr.created_date) as created_date \r\n" |
|||
+ " FROM gcc_1913_campaign.category cc \r\n" |
|||
+ " join gcc_1913_campaign.campaign_request cr on cr.category_id = cc.category_id \r\n" |
|||
+ " where cr.campaign_id = ?;"; |
|||
|
|||
return jdbcTemplate.queryForList(query, campaignId); |
|||
} |
|||
|
|||
|
|||
|
|||
//get campaignname |
|||
public String getCampaignName(int campaignId) { |
|||
String query = "SELECT campaign_name FROM gcc_1913_campaign.campaign_request WHERE campaign_id = ?"; |
|||
|
|||
return jdbcTemplate.queryForObject(query, String.class, campaignId); |
|||
} |
|||
|
|||
|
|||
|
|||
//question and answers counts with percentage in report page method |
|||
|
|||
public List<Map<String, Object>> getQuestionAnswers(int campaignId) { |
|||
String sql = "SELECT cq.question_id, cq.questions, ca.campaign_answer," |
|||
+ " COUNT(qa.campaign_answer) AS answer_count," |
|||
+ " FLOOR(" |
|||
+ " IFNULL((COUNT(qa.campaign_answer) / NULLIF(total_info.total_information_given, 0)) * 100, 0)" |
|||
+ " ) AS answer_percentage" |
|||
+ " FROM " |
|||
+ " gcc_1913_campaign.campaign_questions cq" |
|||
+ " JOIN " |
|||
+ " gcc_1913_campaign.campaign_answers ca " |
|||
+ " ON cq.question_id = ca.question_id AND cq.campaign_id = ca.campaign_id" |
|||
+ " LEFT JOIN " |
|||
+ " gcc_1913_campaign.questions_answers qa " |
|||
+ " ON cq.question_id = qa.question_id " |
|||
+ " AND ca.campaign_answer = qa.campaign_answer " |
|||
+ " AND cq.campaign_id = qa.campaign_id" |
|||
+ " LEFT JOIN (" |
|||
+ " SELECT campaign_id, COUNT(*) AS total_information_given" |
|||
+ " FROM gcc_1913_campaign.upload_data " |
|||
+ " WHERE call_status = 'INFORMATION GIVEN'" |
|||
+ " GROUP BY campaign_id" |
|||
+ " ) AS total_info ON total_info.campaign_id = cq.campaign_id" |
|||
+ " WHERE " |
|||
+ " cq.campaign_id = ? " |
|||
+ " AND cq.isactive = 1 " |
|||
+ " AND cq.isdelete = 0" |
|||
+ " GROUP BY " |
|||
+ " cq.question_id, cq.questions, ca.campaign_answer, total_info.total_information_given" |
|||
+ " ORDER BY " |
|||
+ " cq.question_id"; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, campaignId); |
|||
Map<Integer, Map<String, Object>> responseMap = new LinkedHashMap<>(); |
|||
|
|||
for (Map<String, Object> row : result) { |
|||
int questionId = (int) row.get("question_id"); |
|||
if (!responseMap.containsKey(questionId)) { |
|||
Map<String, Object> questionData = new HashMap<>(); |
|||
questionData.put("question_id", questionId); |
|||
questionData.put("questions", row.get("questions")); |
|||
questionData.put("answers", new ArrayList<>()); |
|||
responseMap.put(questionId, questionData); |
|||
} |
|||
|
|||
Map<String, Object> answerData = new HashMap<>(); |
|||
answerData.put("campaign_answer", row.get("campaign_answer")); |
|||
answerData.put("answer_count", row.get("answer_count")); |
|||
answerData.put("answer_percentage", row.get("answer_percentage")); |
|||
|
|||
((List<Map<String, Object>>) responseMap.get(questionId).get("answers")).add(answerData); |
|||
} |
|||
|
|||
return new ArrayList<>(responseMap.values()); |
|||
} |
|||
|
|||
// |
|||
|
|||
|
|||
|
|||
|
|||
// public void generateCSV(int categoryId, int campaignId, PrintWriter writer) { |
|||
// List<Map<String, Object>> resultList = new ArrayList<>(); |
|||
// |
|||
// // Fetch ordered field column names |
|||
// String fetchColumnsSQL = "SELECT COLUMN_NAME " + |
|||
// "FROM INFORMATION_SCHEMA.COLUMNS " + |
|||
// "WHERE TABLE_SCHEMA = 'gcc_1913_campaign' " + |
|||
// "AND TABLE_NAME = 'upload_data' " + |
|||
// "AND COLUMN_NAME LIKE 'field_%' " + |
|||
// "ORDER BY CAST(SUBSTRING(COLUMN_NAME, 7) AS UNSIGNED)"; |
|||
// |
|||
// List<String> fieldColumns = jdbcTemplate.queryForList(fetchColumnsSQL, String.class); |
|||
// |
|||
// if (fieldColumns.isEmpty()) { |
|||
// writer.println("No matching columns found"); |
|||
// return; |
|||
// } |
|||
// |
|||
// // Fetch ordered fields data based on campaign_id, including data_id, agent_id, and call_status |
|||
// String query1 = "SELECT data_id, " + String.join(", ", fieldColumns) + ", agent_id, call_status,remarks " + |
|||
// "FROM gcc_1913_campaign.upload_data WHERE campaign_id = ?"; |
|||
// |
|||
// List<Map<String, Object>> orderedFieldsList = jdbcTemplate.queryForList(query1, campaignId); |
|||
// |
|||
// if (orderedFieldsList.isEmpty()) { |
|||
// writer.println("No data found for campaign_id: " + campaignId); |
|||
// return; |
|||
// } |
|||
// |
|||
// // Fetch category columns |
|||
// String query2 = "SELECT column_name FROM gcc_1913_campaign.category_columns WHERE category_id = ? AND isactive=1"; |
|||
// List<String> categoryColumns = jdbcTemplate.queryForList(query2, String.class, categoryId); |
|||
// |
|||
// if (categoryColumns.isEmpty()) { |
|||
// writer.println("No category columns found for category_id: " + categoryId); |
|||
// return; |
|||
// } |
|||
// |
|||
// int categoryCount = categoryColumns.size(); |
|||
// |
|||
// // Fetch Agent Names from agent_id |
|||
// String fetchAgentSQL = "SELECT agent_id, agent_name FROM gcc_1913_qaqc.agents_list"; |
|||
// Map<Integer, String> agentMap = jdbcTemplate.query(fetchAgentSQL, rs -> { |
|||
// Map<Integer, String> map = new HashMap<>(); |
|||
// while (rs.next()) { |
|||
// map.put(rs.getInt("agent_id"), rs.getString("agent_name")); |
|||
// } |
|||
// return map; |
|||
// }); |
|||
// |
|||
// // Fetch Questions for given campaign_id |
|||
// String fetchQuestionsQuery = "SELECT question_id, questions FROM gcc_1913_campaign.campaign_questions WHERE campaign_id = ?"; |
|||
// Map<Integer, String> questionsMap = jdbcTemplate.query(fetchQuestionsQuery, rs -> { |
|||
// Map<Integer, String> map = new LinkedHashMap<>(); |
|||
// while (rs.next()) { |
|||
// map.put(rs.getInt("question_id"), rs.getString("questions")); |
|||
// } |
|||
// return map; |
|||
// }, campaignId); |
|||
// |
|||
// // Fetch Answers mapped to questions and grouped by data_id |
|||
// String fetchAnswersQuery = "SELECT data_id, question_id, campaign_answer FROM gcc_1913_campaign.questions_answers " + |
|||
// "WHERE campaign_id = ?"; |
|||
// Map<Integer, Map<Integer, String>> answersMap = jdbcTemplate.query(fetchAnswersQuery, rs -> { |
|||
// Map<Integer, Map<Integer, String>> map = new HashMap<>(); |
|||
// while (rs.next()) { |
|||
// int dataId = rs.getInt("data_id"); |
|||
// int questionId = rs.getInt("question_id"); |
|||
// String answer = rs.getString("campaign_answer"); |
|||
// |
|||
// map.computeIfAbsent(dataId, k -> new HashMap<>()).put(questionId, answer); |
|||
// } |
|||
// return map; |
|||
// }, campaignId); |
|||
// |
|||
// // Process each row and collect data |
|||
// for (Map<String, Object> orderedFields : orderedFieldsList) { |
|||
// List<Object> nonNullValues = new ArrayList<>(); |
|||
// for (String field : fieldColumns) { |
|||
// Object value = orderedFields.get(field); |
|||
// if (value != null) { |
|||
// nonNullValues.add(value); |
|||
// if (nonNullValues.size() == categoryCount) { |
|||
// break; // Stop after collecting required count |
|||
// } |
|||
// } |
|||
// } |
|||
// |
|||
// if (nonNullValues.size() < categoryCount) { |
|||
// continue; // Skip if not enough non-null values |
|||
// } |
|||
// |
|||
// Integer dataId = orderedFields.get("data_id") != null ? ((Number) orderedFields.get("data_id")).intValue() : null; |
|||
// |
|||
// // Map category columns to non-null ordered field values |
|||
// Map<String, Object> finalMapping = new LinkedHashMap<>(); |
|||
// |
|||
// // Add category columns |
|||
// for (int i = 0; i < categoryCount; i++) { |
|||
// finalMapping.put(categoryColumns.get(i), nonNullValues.get(i)); |
|||
// } |
|||
// |
|||
// // Add Questions and Corresponding Answers for this specific data_id |
|||
// Map<Integer, String> currentAnswers = answersMap.getOrDefault(dataId, new HashMap<>()); |
|||
// for (Map.Entry<Integer, String> entry : questionsMap.entrySet()) { |
|||
// Integer questionId = entry.getKey(); |
|||
// String questionText = entry.getValue(); |
|||
// String answer = currentAnswers.getOrDefault(questionId, "-"); // Default to "-" |
|||
// |
|||
// finalMapping.put(questionText, answer); |
|||
// } |
|||
// |
|||
// //Integer agentId = ((Number) orderedFields.get("agent_id")).intValue(); |
|||
// |
|||
// Integer agentId = orderedFields.get("agent_id") != null ? ((Number) orderedFields.get("agent_id")).intValue() : null; |
|||
// String agentName = agentMap.getOrDefault(agentId, "Not Assigned"); |
|||
// finalMapping.put("Agent Name", agentName); |
|||
// |
|||
// String callstatus = orderedFields.get("call_status") != null ? orderedFields.get("call_status").toString() : "-"; |
|||
// finalMapping.put("Call Status", callstatus); |
|||
// |
|||
// // Add Remarks |
|||
// String remarks = orderedFields.get("remarks") != null ? orderedFields.get("remarks").toString() : "-"; |
|||
// |
|||
// finalMapping.put("Remarks", remarks); |
|||
// |
|||
// resultList.add(finalMapping); |
|||
// } |
|||
// |
|||
// // Write CSV data |
|||
// if (resultList.isEmpty()) { |
|||
// writer.println("No Data Available"); |
|||
// return; |
|||
// } |
|||
// |
|||
// // Extract headers from the first row |
|||
// String headers = String.join(",", resultList.get(0).keySet()); |
|||
// writer.println(headers); |
|||
// |
|||
// // Write data rows |
|||
// for (Map<String, Object> rowData : resultList) { |
|||
// List<String> values = rowData.values().stream() |
|||
// .map(value -> value != null ? value.toString() : "") |
|||
// .collect(Collectors.toList()); |
|||
// writer.println(String.join(",", values)); |
|||
// } |
|||
// } |
|||
|
|||
|
|||
// Method to escape CSV values |
|||
private String escapeCsvValue(String value) { |
|||
if (value == null) return ""; |
|||
|
|||
// If the value contains commas, double quotes, or newlines, wrap it in quotes and escape inner quotes |
|||
if (value.contains(",") || value.contains("\"") || value.contains("\n")) { |
|||
value = "\"" + value.replace("\"", "\"\"") + "\""; |
|||
} |
|||
return value; |
|||
} |
|||
|
|||
public void generateCSV(int categoryId, int campaignId, PrintWriter writer) { |
|||
List<Map<String, Object>> resultList = new ArrayList<>(); |
|||
|
|||
// Fetch ordered field column names |
|||
String fetchColumnsSQL = "SELECT COLUMN_NAME " + |
|||
"FROM INFORMATION_SCHEMA.COLUMNS " + |
|||
"WHERE TABLE_SCHEMA = 'gcc_1913_campaign' " + |
|||
"AND TABLE_NAME = 'upload_data' " + |
|||
"AND COLUMN_NAME LIKE 'field_%' " + |
|||
"ORDER BY CAST(SUBSTRING(COLUMN_NAME, 7) AS UNSIGNED)"; |
|||
|
|||
List<String> fieldColumns = jdbcTemplate.queryForList(fetchColumnsSQL, String.class); |
|||
|
|||
if (fieldColumns.isEmpty()) { |
|||
writer.println("No matching columns found"); |
|||
return; |
|||
} |
|||
|
|||
// Fetch ordered fields data based on campaign_id, including data_id, agent_id, and call_status |
|||
String query1 = "SELECT data_id, " + String.join(", ", fieldColumns) + ", agent_id, call_status,remarks,DATE(updated_date) as updated_date " + |
|||
"FROM gcc_1913_campaign.upload_data WHERE campaign_id = ?"; |
|||
|
|||
List<Map<String, Object>> orderedFieldsList = jdbcTemplate.queryForList(query1, campaignId); |
|||
|
|||
if (orderedFieldsList.isEmpty()) { |
|||
writer.println("No data found for campaign_id: " + campaignId); |
|||
return; |
|||
} |
|||
|
|||
// Fetch category columns |
|||
String query2 = "SELECT column_name FROM gcc_1913_campaign.category_columns WHERE category_id = ? AND isactive=1"; |
|||
List<String> categoryColumns = jdbcTemplate.queryForList(query2, String.class, categoryId); |
|||
|
|||
if (categoryColumns.isEmpty()) { |
|||
writer.println("No category columns found for category_id: " + categoryId); |
|||
return; |
|||
} |
|||
|
|||
int categoryCount = categoryColumns.size(); |
|||
|
|||
// Fetch Agent Names from agent_id |
|||
String fetchAgentSQL = "SELECT agent_id, agent_name FROM gcc_1913_qaqc.agents_list"; |
|||
Map<Integer, String> agentMap = jdbcTemplate.query(fetchAgentSQL, rs -> { |
|||
Map<Integer, String> map = new HashMap<>(); |
|||
while (rs.next()) { |
|||
map.put(rs.getInt("agent_id"), rs.getString("agent_name")); |
|||
} |
|||
return map; |
|||
}); |
|||
|
|||
// Fetch Questions for given campaign_id |
|||
String fetchQuestionsQuery = "SELECT question_id, questions FROM gcc_1913_campaign.campaign_questions WHERE campaign_id = ?"; |
|||
Map<Integer, String> questionsMap = jdbcTemplate.query(fetchQuestionsQuery, rs -> { |
|||
Map<Integer, String> map = new LinkedHashMap<>(); |
|||
while (rs.next()) { |
|||
map.put(rs.getInt("question_id"), rs.getString("questions")); |
|||
} |
|||
return map; |
|||
}, campaignId); |
|||
|
|||
// Fetch Answers mapped to questions and grouped by data_id |
|||
String fetchAnswersQuery = "SELECT data_id, question_id, campaign_answer FROM gcc_1913_campaign.questions_answers " + |
|||
"WHERE campaign_id = ?"; |
|||
Map<Integer, Map<Integer, String>> answersMap = jdbcTemplate.query(fetchAnswersQuery, rs -> { |
|||
Map<Integer, Map<Integer, String>> map = new HashMap<>(); |
|||
while (rs.next()) { |
|||
int dataId = rs.getInt("data_id"); |
|||
int questionId = rs.getInt("question_id"); |
|||
String answer = rs.getString("campaign_answer"); |
|||
|
|||
map.computeIfAbsent(dataId, k -> new HashMap<>()).put(questionId, answer); |
|||
} |
|||
return map; |
|||
}, campaignId); |
|||
|
|||
// Process each row and collect data |
|||
for (Map<String, Object> orderedFields : orderedFieldsList) { |
|||
List<Object> nonNullValues = new ArrayList<>(); |
|||
for (String field : fieldColumns) { |
|||
Object value = orderedFields.get(field); |
|||
if (value != null) { |
|||
nonNullValues.add(value); |
|||
if (nonNullValues.size() == categoryCount) { |
|||
break; // Stop after collecting required count |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (nonNullValues.size() < categoryCount) { |
|||
continue; // Skip if not enough non-null values |
|||
} |
|||
|
|||
Integer dataId = orderedFields.get("data_id") != null ? ((Number) orderedFields.get("data_id")).intValue() : null; |
|||
|
|||
// Map category columns to non-null ordered field values |
|||
Map<String, Object> finalMapping = new LinkedHashMap<>(); |
|||
|
|||
// Add category columns |
|||
for (int i = 0; i < categoryCount; i++) { |
|||
finalMapping.put(categoryColumns.get(i), nonNullValues.get(i)); |
|||
} |
|||
|
|||
// Add Questions and Corresponding Answers for this specific data_id |
|||
Map<Integer, String> currentAnswers = answersMap.getOrDefault(dataId, new HashMap<>()); |
|||
for (Map.Entry<Integer, String> entry : questionsMap.entrySet()) { |
|||
Integer questionId = entry.getKey(); |
|||
String questionText = entry.getValue(); |
|||
String answer = currentAnswers.getOrDefault(questionId, "-"); // Default to "-" |
|||
|
|||
finalMapping.put(questionText, answer); |
|||
} |
|||
|
|||
Integer agentId = orderedFields.get("agent_id") != null ? ((Number) orderedFields.get("agent_id")).intValue() : null; |
|||
String agentName = agentMap.getOrDefault(agentId, "Not Assigned"); |
|||
finalMapping.put("Agent Name", agentName); |
|||
|
|||
String callstatus = orderedFields.get("call_status") != null ? orderedFields.get("call_status").toString() : "-"; |
|||
finalMapping.put("Call Status", callstatus); |
|||
|
|||
// Add Remarks |
|||
String remarks = orderedFields.get("remarks") != null ? orderedFields.get("remarks").toString() : "-"; |
|||
finalMapping.put("Remarks", remarks); |
|||
|
|||
String up_date = orderedFields.get("updated_date") != null ? orderedFields.get("updated_date").toString() : "-"; |
|||
finalMapping.put("Updated_Date", up_date); |
|||
|
|||
resultList.add(finalMapping); |
|||
} |
|||
|
|||
// Write CSV data |
|||
if (resultList.isEmpty()) { |
|||
writer.println("No Data Available"); |
|||
return; |
|||
} |
|||
/* |
|||
// Extract headers from the first row and escape them |
|||
String headers = resultList.get(0).keySet().stream() |
|||
.map(this::escapeCsvValue) // Escape each header value |
|||
.collect(Collectors.joining(",")); |
|||
writer.println(headers); |
|||
|
|||
// Write data rows |
|||
for (Map<String, Object> rowData : resultList) { |
|||
List<String> values = rowData.values().stream() |
|||
.map(value -> escapeCsvValue(value != null ? value.toString() : "")) |
|||
.collect(Collectors.toList()); |
|||
writer.println(String.join(",", values)); |
|||
} |
|||
*/ |
|||
// Extract headers from the first row and escape them |
|||
Map<String, Object> firstRow = resultList.get(0); |
|||
|
|||
StringBuilder headerBuilder = new StringBuilder(); |
|||
int headerIndex = 0; |
|||
|
|||
for (String key : firstRow.keySet()) { |
|||
if (headerIndex > 0) { |
|||
headerBuilder.append(","); |
|||
} |
|||
headerBuilder.append(escapeCsvValue(key)); |
|||
headerIndex++; |
|||
} |
|||
|
|||
writer.println(headerBuilder.toString()); |
|||
|
|||
// Write data rows |
|||
for (Map<String, Object> rowData : resultList) { |
|||
|
|||
StringBuilder rowBuilder = new StringBuilder(); |
|||
int valueIndex = 0; |
|||
|
|||
for (Object value : rowData.values()) { |
|||
if (valueIndex > 0) { |
|||
rowBuilder.append(","); |
|||
} |
|||
rowBuilder.append( |
|||
escapeCsvValue(value != null ? value.toString() : "") |
|||
); |
|||
valueIndex++; |
|||
} |
|||
|
|||
writer.println(rowBuilder.toString()); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,715 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.service; |
|||
|
|||
import java.io.File; |
|||
import java.io.IOException; |
|||
import java.sql.Date; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.Statement; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.LinkedHashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Set; |
|||
import java.util.stream.Collectors; |
|||
|
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|||
import org.springframework.jdbc.core.simple.SimpleJdbcInsert; |
|||
import org.springframework.jdbc.support.GeneratedKeyHolder; |
|||
import org.springframework.jdbc.support.KeyHolder; |
|||
import org.springframework.scheduling.annotation.Scheduled; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
@Service |
|||
public class CampaignService { |
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSourcemysql(@Qualifier("mysql1913CampaignDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
public void setDataSource2(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate2; |
|||
|
|||
|
|||
//Method to save file and return its URL |
|||
public String saveFile(MultipartFile file) { |
|||
String fileName = file.getOriginalFilename(); |
|||
String filePath = "/uploads/" + fileName; // Path to save the file |
|||
try { |
|||
File destinationFile = new File(filePath); |
|||
file.transferTo(destinationFile); // Save the file locally |
|||
} catch (IOException e) { |
|||
throw new RuntimeException("Failed to store file " + fileName, e); |
|||
} |
|||
return filePath; // Return the file path (URL) for saving to the database |
|||
} |
|||
|
|||
|
|||
//Method to save campaign details into the database |
|||
public void saveCampaignDetails(Map<String, Object> campaignDetails) { |
|||
String sql = "UPDATE gcc_1913_campaign.campaign_request " + |
|||
"SET start_date = :start_date, " + |
|||
"end_date = :end_date, " + |
|||
"calls_per_agent = :calls_per_agent, " + |
|||
"description = :description " + |
|||
"WHERE campaign_id = :campaign_id"; |
|||
|
|||
// Using NamedParameterJdbcTemplate for mapping campaignDetails into query |
|||
NamedParameterJdbcTemplate namedJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate); |
|||
namedJdbcTemplate.update(sql, campaignDetails); |
|||
} |
|||
|
|||
|
|||
// Method to save campaign details into the database |
|||
public String saveCampaignDetailsExcel(Map<String, Object> campaignDetailsExcel) { |
|||
|
|||
campaignDetailsExcel.putIfAbsent("campaign_status", "PENDING"); |
|||
|
|||
String sql = "INSERT INTO gcc_1913_campaign.campaign_request (campaign_name, category_id, excel_url,campaign_status) " + |
|||
"VALUES (:campaign_name, :category_id, :excel_url ,:campaign_status)"; |
|||
|
|||
// Using NamedParameterJdbcTemplate for mapping campaignDetails into query |
|||
NamedParameterJdbcTemplate namedJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate); |
|||
namedJdbcTemplate.update(sql, campaignDetailsExcel); |
|||
|
|||
// Return the category to use in the next step |
|||
return campaignDetailsExcel.get("category_id").toString(); |
|||
|
|||
} |
|||
|
|||
|
|||
// campaign_status change as ongoing in campaign_request table |
|||
@Transactional |
|||
public void updateCampaignStatus(int campaignId, int categoryId) { |
|||
String checkSql = "SELECT COUNT(*) FROM gcc_1913_campaign.agent_assign " |
|||
+ "WHERE campaign_id = ? AND category_id = ? AND status = 'ASSIGNED'"; |
|||
|
|||
int assignedCount = jdbcTemplate.queryForObject(checkSql, Integer.class, campaignId, categoryId); |
|||
|
|||
if (assignedCount > 0) { |
|||
String updateSql = "UPDATE gcc_1913_campaign.campaign_request " |
|||
+ "SET campaign_status = 'ONGOING' WHERE campaign_id = ? AND category_id = ?"; |
|||
jdbcTemplate.update(updateSql, campaignId, categoryId); |
|||
|
|||
System.out.println("Campaign status updated to ONGOING for campaign ID: " + campaignId); |
|||
} else { |
|||
System.out.println("No agents assigned yet. Campaign status remains PENDING."); |
|||
} |
|||
} |
|||
|
|||
|
|||
//Validated uploaded excel column count with field column in our DB |
|||
public List<String> getUploadDataFieldColumns() { |
|||
String query = "SELECT column_name FROM information_schema.columns " |
|||
+ "WHERE table_schema = 'gcc_1913_campaign' " |
|||
+ "AND table_name = 'upload_data' " |
|||
+ "AND column_name LIKE 'field_%'"; |
|||
return jdbcTemplate.queryForList(query, String.class); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public String saveQuestionsAnswers(List<Map<String, Object>> questionsData) { |
|||
for (Map<String, Object> question : questionsData) { |
|||
String questionText = (String) question.get("question"); |
|||
String answerType = (String) question.get("answerType"); |
|||
|
|||
// Validate and parse categoryId and campaignId |
|||
Integer categoryId = Integer.parseInt(question.get("categoryId").toString()); |
|||
Integer campaignId = Integer.parseInt(question.get("campaignId").toString()); |
|||
|
|||
List<String> answers = (List<String>) question.get("answers"); |
|||
|
|||
// Insert question and get generated question_id |
|||
String questionInsertQuery = "INSERT INTO gcc_1913_campaign.campaign_questions (category_id, campaign_id, questions, answer_type_id) VALUES (?, ?, ?, ?)"; |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(questionInsertQuery, Statement.RETURN_GENERATED_KEYS); |
|||
ps.setInt(1, categoryId); |
|||
ps.setInt(2, campaignId); |
|||
ps.setString(3, questionText); |
|||
ps.setString(4, answerType); |
|||
return ps; |
|||
}, keyHolder); |
|||
|
|||
Integer questionId = keyHolder.getKey().intValue(); |
|||
|
|||
// Insert answers if available |
|||
if (answers != null && !answers.isEmpty()) { |
|||
String answerInsertQuery = "INSERT INTO gcc_1913_campaign.campaign_answers (category_id, campaign_id, question_id, campaign_answer) VALUES (?, ?, ?, ?)"; |
|||
for (String answer : answers) { |
|||
jdbcTemplate.update(answerInsertQuery, categoryId, campaignId, questionId, answer); |
|||
} |
|||
} |
|||
} |
|||
return "Questions and Answers saved successfully!"; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public void saveQuestionsAndAnswers(String category, String campaignId, String question, String answerType, List<String> answers) { |
|||
// Convert category and answerType to integers once to avoid redundant parsing |
|||
int categoryId = Integer.parseInt(category); |
|||
int answerTypeId = Integer.parseInt(answerType); |
|||
int campaignIdd = Integer.parseInt(campaignId); |
|||
|
|||
// Query to insert question into campaign_questions and retrieve generated question_id |
|||
String query1 = "INSERT INTO gcc_1913_campaign.campaign_questions (category_id, campaign_id, questions, answer_type_id) VALUES (?, ?, ?, ?)"; |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
|
|||
jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(query1, Statement.RETURN_GENERATED_KEYS); |
|||
ps.setInt(1, categoryId); |
|||
ps.setInt(2, campaignIdd); |
|||
ps.setString(3, question); |
|||
ps.setInt(4, answerTypeId); |
|||
return ps; |
|||
}, keyHolder); |
|||
|
|||
int questionId = keyHolder.getKey().intValue(); |
|||
|
|||
// If answerType is NOT "Text" (ID = 1), save answers |
|||
if (answerTypeId != 1 && answers != null && !answers.isEmpty()) { |
|||
String query2 = "INSERT INTO gcc_1913_campaign.campaign_answers (category_id, campaign_id, question_id, campaign_answer) VALUES (?, ?, ?, ?)"; |
|||
|
|||
for (String answer : answers) { |
|||
jdbcTemplate.update(query2, categoryId, campaignId, questionId, answer); |
|||
} |
|||
} |
|||
|
|||
System.out.println("Inserted Question ID: " + questionId + " with Answers: " + (answers != null ? answers : "None")); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
// |
|||
// public Map<String, Object> getCampaignDetailsById(Long campaign_id) { |
|||
// String sql = "SELECT * FROM gcc_1913_campaign.campaign_request WHERE campaign_id = ?"; |
|||
// return jdbcTemplate.queryForMap(sql, campaign_id); |
|||
// } |
|||
|
|||
|
|||
|
|||
|
|||
public void updateCampaign(Long campaign_id, String end_date) { |
|||
String sql = "UPDATE gcc_1913_campaign.campaign_request SET end_date = ? WHERE campaign_id = ?"; |
|||
jdbcTemplate.update(sql, end_date,campaign_id); |
|||
} |
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getCampaignDetails() { |
|||
String sql = "SELECT campaign_id, " + |
|||
" campaign_name, " + |
|||
" CONCAT(" + |
|||
" DATE_FORMAT(start_date, '%d/%m/%Y'), " + |
|||
" ' to ', " + |
|||
" DATE_FORMAT(end_date, '%d/%m/%Y')" + |
|||
" ) AS event_dates, " + |
|||
" no_of_agents, " + |
|||
" calls_per_agent, " + |
|||
" (no_of_agents)*(calls_per_agent) as total_calls, " + |
|||
" description " + |
|||
"FROM gcc_1913_campaign.campaign_request;"; |
|||
|
|||
List<Map<String, Object>> campaigns = jdbcTemplate.queryForList(sql); |
|||
|
|||
|
|||
return campaigns; |
|||
} |
|||
|
|||
public List<Map<String, Object>> getLastRow() |
|||
{ |
|||
String sqlQuery ="SELECT campaign_id\r\n" |
|||
+ "FROM gcc_1913_campaign.campaign_request\r\n" |
|||
+ "ORDER BY campaign_id DESC\r\n" |
|||
+ "LIMIT 1"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public String getLastInsertedCategoryId() { |
|||
String sqlQuery = "SELECT category_id " + |
|||
"FROM gcc_1913_campaign.campaign_request " + |
|||
"ORDER BY campaign_id DESC " + |
|||
"LIMIT 1"; |
|||
|
|||
return jdbcTemplate.queryForObject(sqlQuery, String.class); |
|||
} |
|||
|
|||
|
|||
public Integer getLastInsertedCampaignId() |
|||
{ |
|||
String sqlQuery ="SELECT campaign_id\r\n" |
|||
+ "FROM gcc_1913_campaign.campaign_request\r\n" |
|||
+ "ORDER BY campaign_id DESC\r\n" |
|||
+ "LIMIT 1"; |
|||
|
|||
return jdbcTemplate.queryForObject(sqlQuery,Integer.class); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getDetailsForStart() |
|||
{ |
|||
String sqlQuery ="SELECT cr.campaign_id,cr.category_id,ca.category_name,cr.campaign_name,start_date\r\n" |
|||
+ "FROM gcc_1913_campaign.campaign_request cr \r\n" |
|||
+ "join gcc_1913_campaign.category ca ON cr.category_id = ca.category_id \r\n" |
|||
+ "where cr.campaign_status='ONGOING' AND cr.isactive='1' and cr.isdelete='0' \r\n" |
|||
+ "order by cr.campaign_id desc"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getDataforAgents(int campaign_id, int calls_per_agent) |
|||
{ |
|||
List<Map<String, Object>> assignedAgent_list =getAssignedAgentId(campaign_id); |
|||
List<Map<String, Object>> data_list =getDataId(campaign_id); |
|||
|
|||
List<Map<String, Object>> task = getTask(assignedAgent_list,data_list,calls_per_agent,campaign_id); |
|||
|
|||
// Perform the update query here |
|||
if (task != null && !task.isEmpty()) { |
|||
assignAgentIds(task); |
|||
updateAgentStatus(campaign_id); |
|||
} |
|||
|
|||
|
|||
return task; |
|||
} |
|||
|
|||
//Method to update agent_id for each data_id in upload_data table |
|||
public void assignAgentIds(List<Map<String, Object>> taskList) { |
|||
String updateQuery = "UPDATE gcc_1913_campaign.upload_data SET agent_id = ? WHERE data_id = ? AND campaign_id = ?"; |
|||
|
|||
// Loop through each agent's task list |
|||
for (Map<String, Object> task : taskList) { |
|||
Integer agentId = (Integer) task.get("agent_id"); |
|||
Integer campaignId = (Integer) task.get("campaign_id"); |
|||
List<Integer> dataIds = (List<Integer>) task.get("data_ids"); |
|||
|
|||
// Update each data_id with the respective agent_id |
|||
for (Integer dataId : dataIds) { |
|||
jdbcTemplate.update(updateQuery, agentId, dataId, campaignId); |
|||
} |
|||
} |
|||
} |
|||
|
|||
//Example update method |
|||
private void updateAgentStatus(int campaign_id) { |
|||
String updateQuery = "UPDATE gcc_1913_campaign.campaign_request SET isactive = '0', isdelete='1' WHERE campaign_id = ?"; |
|||
jdbcTemplate.update(updateQuery, campaign_id); |
|||
} |
|||
|
|||
|
|||
private List<Map<String, Object>> getTask(List<Map<String, Object>> assignedAgent_list, List<Map<String, Object>> data_list, |
|||
int calls_per_agent,int campaign_id) { |
|||
|
|||
List<Map<String, Object>> result = new ArrayList<>(); |
|||
int dataIndex = 0; |
|||
|
|||
// Loop through each assigned ID |
|||
for (Map<String, Object> assigned : assignedAgent_list) { |
|||
// Create a map to store the assigned_id and corresponding data_ids |
|||
Map<String, Object> assignedTaskMap = new HashMap<>(); |
|||
List<Integer> assignedDataIds = new ArrayList<>(); |
|||
|
|||
// Get assigned_id |
|||
Integer agent_id = (Integer) assigned.get("agent_id"); |
|||
|
|||
// Loop to assign the appropriate number of data IDs (calls_per_agent) |
|||
for (int i = 0; i < calls_per_agent; i++) { |
|||
if (dataIndex >= data_list.size()) { |
|||
// Exit if we run out of data IDs |
|||
break; |
|||
} |
|||
Map<String, Object> data = data_list.get(dataIndex); |
|||
Integer data_id = (Integer) data.get("data_id"); |
|||
assignedDataIds.add(data_id); |
|||
dataIndex++; |
|||
} |
|||
|
|||
// Put the agent_id and the corresponding data_ids in the map |
|||
assignedTaskMap.put("agent_id", agent_id); |
|||
assignedTaskMap.put("data_ids", assignedDataIds); |
|||
assignedTaskMap.put("campaign_id", campaign_id); |
|||
|
|||
// Add the map to the result list |
|||
result.add(assignedTaskMap); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
private List<Map<String, Object>> getDataId(int campaign_id) { |
|||
|
|||
String sqlQuery ="SELECT data_id\r\n" |
|||
+ "from gcc_1913_campaign.upload_data\r\n" |
|||
+ "where campaign_id=?"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery, new Object[]{campaign_id}); |
|||
} |
|||
|
|||
|
|||
private List<Map<String, Object>> getAssignedAgentId(int campaign_id) { |
|||
|
|||
String sqlQuery ="SELECT agent_id\r\n" |
|||
+ "FROM gcc_1913_campaign.agent_assign \r\n" |
|||
+ "where campaign_id=? and isactive='1'"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery, new Object[]{campaign_id}); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getActiveCampaigns() |
|||
{ |
|||
String sqlQuery ="SELECT cr.campaign_id,cr.calls_per_agent,cr.category_id,cr.campaign_name,c.category_name,cr.start_date,cr.end_date,cr.description,cr.campaign_status\r\n" |
|||
+ "FROM gcc_1913_campaign.campaign_request cr\r\n" |
|||
+ "JOIN gcc_1913_campaign.category c ON cr.category_id=c.category_id\r\n" |
|||
+ "where cr.isactive='1' and cr.campaign_status IN ('ONGOING', 'CLOSED') Order by cr.campaign_id desc"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> viewcampaignstatus(int campaign_id) { |
|||
|
|||
String sqlQuery ="SELECT \r\n" |
|||
+ "aa.campaign_id as campaign_id,\r\n" |
|||
+ " al.agent_id as agent_id,\r\n" |
|||
+ " al.agent_name as agent_name,\r\n" |
|||
+ " COUNT(up.agent_id) AS Assigned_count,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 IS NOT NULL THEN 1 END) AS Complete_count,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 IS NULL THEN 1 END) AS Pending_count,\r\n" |
|||
+ " ROUND(\r\n" |
|||
+ " (COUNT(CASE WHEN up.field_14 IS NOT NULL THEN 1 END) * 100) / \r\n" |
|||
+ " COUNT(up.agent_id)\r\n" |
|||
+ " ) as Percentage,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 = 'INFORMATION_GIVEN' THEN 1 END) AS Information_Given_count,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 = 'UNATTENDED' THEN 1 END) AS Unattended_count,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 = 'CALL_BACK_LATER' THEN 1 END) AS Call_back_later_count,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 = 'SWITCH_OFF' THEN 1 END) AS Switch_off_count,\r\n" |
|||
+ " COUNT(CASE WHEN up.field_14 = 'WRONG_NUMBER' THEN 1 END) AS Wrong_number_count\r\n" |
|||
+ "FROM gcc_1913_campaign.agent_assign aa\r\n" |
|||
+ "JOIN gcc_1913_qaqc.agents_list al ON al.agent_id = aa.agent_id\r\n" |
|||
+ "JOIN gcc_1913_campaign.upload_data up ON up.agent_id = al.agent_id AND up.campaign_id = ?\r\n" |
|||
+ "WHERE aa.campaign_id = ? AND aa.isactive = '1'\r\n" |
|||
+ "GROUP BY aa.campaign_id,al.agent_id, al.agent_name"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery,campaign_id,campaign_id); |
|||
} |
|||
|
|||
public List<Map<String, Object>> viewcompletedby(int campaign_id, int agent_id) { |
|||
|
|||
String sqlQuery ="SELECT \r\n" |
|||
+ "up.data_id as data_id,up.field_1 as id, up.field_2 as name, up.field_3 as address,field_5 as cellnumber, field_14 as call_status, \r\n" |
|||
+ "count(cl.data_id) as call_count,updated_date as updated_date,field_15 as remarks\r\n" |
|||
+ "FROM gcc_1913_campaign.agent_assign aa\r\n" |
|||
+ "JOIN gcc_1913_campaign.upload_data up ON up.agent_id = aa.agent_id AND up.campaign_id = ?\r\n" |
|||
+ "JOIN gcc_1913_campaign.call_logs cl ON cl.data_id=up.data_id\r\n" |
|||
+ "WHERE aa.campaign_id = ? AND aa.isactive = '1' AND aa.agent_id=? AND up.field_14 IS NOT NULL\r\n" |
|||
+ "group by up.data_id,up.field_1, up.field_2"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery,campaign_id,campaign_id,agent_id); |
|||
} |
|||
|
|||
public String getExcelUrlByCampaignId(int lastId) { |
|||
String sqlQuery = "SELECT excel_url FROM gcc_1913_campaign.campaign_request WHERE campaign_id = ?"; |
|||
return jdbcTemplate.queryForObject(sqlQuery, String.class, lastId); |
|||
} |
|||
|
|||
|
|||
|
|||
public void saveUploadData(String category, int campaignId, Map<String, Object> rowData, List<String> expectedHeaders) { |
|||
int fieldCount = rowData.size(); |
|||
|
|||
List<String> columnNames = new ArrayList<>(); |
|||
for (int i = 1; i <= fieldCount; i++) { |
|||
columnNames.add("field_" + i); |
|||
} |
|||
|
|||
String columnNamesString = String.join(", ", columnNames); |
|||
//String placeholders = columnNames.stream().map(col -> "?").collect(Collectors.joining(", ")); |
|||
|
|||
StringBuilder placeholdersBuilder = new StringBuilder(); |
|||
|
|||
for (int i = 0; i < columnNames.size(); i++) { |
|||
if (i > 0) { |
|||
placeholdersBuilder.append(", "); |
|||
} |
|||
placeholdersBuilder.append("?"); |
|||
} |
|||
|
|||
String placeholders = placeholdersBuilder.toString(); |
|||
|
|||
String sql = "INSERT INTO gcc_1913_campaign.upload_data (category_id, campaign_id, " + columnNamesString + ") VALUES (?, ?, " + placeholders + ")"; |
|||
|
|||
//System.out.println("SQL Query========= " + sql); |
|||
|
|||
List<Object> values = new ArrayList<>(); |
|||
values.add(category); |
|||
values.add(campaignId); |
|||
|
|||
// Ensure rowData values are ordered based on expected headers |
|||
for (String header : expectedHeaders) { |
|||
values.add(rowData.getOrDefault(header, "")); // Ensures the correct mapping |
|||
} |
|||
|
|||
final Logger logger = LoggerFactory.getLogger(CampaignService.class); |
|||
try { |
|||
jdbcTemplate.update(sql, values.toArray()); |
|||
} catch (Exception e) { |
|||
logger.error("Error inserting upload data for campaign {}: {}", campaignId, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
// public void saveUploadData(String category, int campaignId, Map<String, Object> rowData) { |
|||
// // Get total number of fields in the row |
|||
// int fieldCount = rowData.size(); |
|||
// |
|||
// // Generate dynamic column names as field_1, field_2, ..., field_N |
|||
// List<String> columnNames = new ArrayList<>(); |
|||
// for (int i = 1; i <= fieldCount; i++) { |
|||
// columnNames.add("field_" + i); |
|||
// } |
|||
// |
|||
// // Build dynamic SQL query |
|||
// String columnNamesString = String.join(", ", columnNames); |
|||
// String placeholders = columnNames.stream().map(col -> "?").collect(Collectors.joining(", ")); |
|||
// |
|||
// String sql = "INSERT INTO upload_data (category_id, campaign_id, " + columnNamesString + ") VALUES (?, ?, " + placeholders + ")"; |
|||
// |
|||
// System.out.println("SQL Query========= " + sql); |
|||
// |
|||
// // Prepare values list |
|||
// List<Object> values = new ArrayList<>(); |
|||
// values.add(category); |
|||
// values.add(campaignId); |
|||
// values.addAll(rowData.values()); // Add row data values dynamically |
|||
// |
|||
// |
|||
// |
|||
// final Logger logger = LoggerFactory.getLogger(CampaignService.class); |
|||
// try { |
|||
// jdbcTemplate.update(sql, values.toArray()); |
|||
// } catch (Exception e) { |
|||
// logger.error("Error inserting upload data for campaign {}: {}", campaignId, e.getMessage()); |
|||
// } |
|||
// } |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
//Agent List |
|||
public List<Map<String, Object>> getAllAgents() { |
|||
String sql = "SELECT agent_id, agent_name FROM gcc_1913_qaqc.agents_list WHERE calling_type = 'OUTBOUND' AND isactive = '1'"; |
|||
return jdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
//count based on total, completed and pending |
|||
public Map<String, Object> getCampaignStatistics(int campaignId) { |
|||
Map<String, Object> result = new HashMap<>(); |
|||
|
|||
// Total Count |
|||
String totalQuery = "SELECT COUNT(*) AS total FROM gcc_1913_campaign.upload_data WHERE campaign_id = ?"; |
|||
int totalCount = jdbcTemplate.queryForObject(totalQuery, Integer.class, campaignId); |
|||
result.put("totalCount", totalCount); |
|||
|
|||
// Completed Count (agent_id is not null and call_status is null) |
|||
String completedQuery = "SELECT COUNT(*) AS completed FROM gcc_1913_campaign.upload_data ud\r\n" |
|||
+ "JOIN gcc_1913_campaign.campaign_request cr ON ud.campaign_id = cr.campaign_id\r\n" |
|||
+ "WHERE ud.campaign_id = ? AND cr.campaign_status = 'ONGOING' AND ud.agent_id IS NOT NULL AND\r\n" |
|||
+ "( ud.call_status NOT IN ('CALL BACK LATER','UNATTENDED'))"; |
|||
int completedCount = jdbcTemplate.queryForObject(completedQuery, Integer.class, campaignId); |
|||
result.put("completedCount", completedCount); |
|||
|
|||
// Pending Count (agent_id is not null and call_status is not null) |
|||
String pendingQuery = "SELECT COUNT(*) AS pending FROM gcc_1913_campaign.upload_data ud\r\n" |
|||
+ "JOIN gcc_1913_campaign.campaign_request cr ON ud.campaign_id = cr.campaign_id\r\n" |
|||
+ "WHERE ud.campaign_id = ? AND ud.agent_id IS NOT NULL \r\n" |
|||
+ "AND (ud.call_status IS NULL OR ud.call_status IN ('CALL BACK LATER','UNATTENDED'))"; |
|||
int pendingCount = jdbcTemplate.queryForObject(pendingQuery, Integer.class, campaignId); |
|||
result.put("pendingCount", pendingCount); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getCampaignDetailsById(Long campaign_id) { |
|||
String sql = "SELECT \r\n" |
|||
+ " cr.campaign_id, \r\n" |
|||
+ " cr.campaign_name, \r\n" |
|||
+ " cr.category_id, \r\n" |
|||
+ " cr.start_date, \r\n" |
|||
+ " cr.end_date, \r\n" |
|||
+ " cr.calls_per_agent, \r\n" |
|||
+ " cr.description, \r\n" |
|||
+ " cr.created_date, \r\n" |
|||
+ " cr.excel_url, \r\n" |
|||
+ " cr.isactive, \r\n" |
|||
+ " cr.isdelete, \r\n" |
|||
+ " cr.campaign_status, \r\n" |
|||
+ " cq.question_id, \r\n" |
|||
+ " cq.questions, \r\n" |
|||
+ " cq.answer_type_id, \r\n" |
|||
+ " at.type_name, \r\n" |
|||
+ " ca.id AS answer_id, \r\n" |
|||
+ " ca.campaign_answer\r\n" |
|||
+ "FROM gcc_1913_campaign.campaign_request cr\r\n" |
|||
+ "JOIN gcc_1913_campaign.campaign_questions cq \r\n" |
|||
+ " ON cr.campaign_id = cq.campaign_id\r\n" |
|||
+ "LEFT JOIN gcc_1913_campaign.answer_type at\r\n" |
|||
+ " ON cq.answer_type_id = at.answer_type_id \r\n" |
|||
+ "LEFT JOIN gcc_1913_campaign.campaign_answers ca\r\n" |
|||
+ " ON cq.question_id = ca.question_id\r\n" |
|||
+ "WHERE cr.campaign_id = ?"; |
|||
|
|||
List<Map<String, Object>> results = jdbcTemplate.queryForList(sql, campaign_id); |
|||
|
|||
// Group answers by question_id |
|||
Map<Long, Map<String, Object>> groupedData = new LinkedHashMap(); |
|||
|
|||
for (Map<String, Object> row : results) { |
|||
Object questionIdObj = row.get("question_id"); |
|||
Long questionId = null; |
|||
|
|||
// Convert Integer to Long if needed |
|||
if (questionIdObj instanceof Integer) { |
|||
questionId = ((Integer) questionIdObj).longValue(); |
|||
} else if (questionIdObj instanceof Long) { |
|||
questionId = (Long) questionIdObj; |
|||
} |
|||
|
|||
if (questionId == null) continue; |
|||
|
|||
if (!groupedData.containsKey(questionId)) { |
|||
// Ensure `campaign_answer` is initialized correctly |
|||
List<String> answers = new ArrayList<>(); |
|||
if (row.get("campaign_answer") != null) { |
|||
answers.add(row.get("campaign_answer").toString()); |
|||
} |
|||
row.put("campaign_answer", answers); |
|||
groupedData.put(questionId, row); |
|||
} else { |
|||
// Append the answer to the existing question |
|||
List<String> answers = (List<String>) groupedData.get(questionId).get("campaign_answer"); |
|||
if (row.get("campaign_answer") != null) { |
|||
answers.add(row.get("campaign_answer").toString()); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return new ArrayList<>(groupedData.values()); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
//question and answers counts with percentage in report page method |
|||
public List<Map<String, Object>> getQuestionAnswers(int campaignId) { |
|||
String sql = "SELECT cq.question_id, cq.questions, ca.campaign_answer, " + |
|||
"COUNT(qa.campaign_answer) AS answer_count, " + |
|||
"FLOOR(IFNULL((COUNT(qa.campaign_answer) / " + |
|||
"(SELECT COUNT(*) FROM gcc_1913_campaign.upload_data " + |
|||
"WHERE campaign_id = cq.campaign_id AND call_status = 'INFORMATION GIVEN') * 100), 0)) AS answer_percentage " + |
|||
"FROM campaign_questions cq " + |
|||
"JOIN campaign_answers ca ON cq.question_id = ca.question_id AND cq.campaign_id = ca.campaign_id " + |
|||
"LEFT JOIN questions_answers qa ON cq.question_id = qa.question_id AND ca.campaign_answer = qa.campaign_answer AND cq.campaign_id = qa.campaign_id " + |
|||
"WHERE cq.campaign_id = ? AND cq.isactive = 1 AND cq.isdelete = 0 " + |
|||
"GROUP BY cq.question_id, cq.questions, ca.campaign_answer " + |
|||
"ORDER BY cq.question_id;"; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, campaignId); |
|||
Map<Integer, Map<String, Object>> responseMap = new LinkedHashMap<>(); |
|||
|
|||
for (Map<String, Object> row : result) { |
|||
int questionId = (int) row.get("question_id"); |
|||
if (!responseMap.containsKey(questionId)) { |
|||
Map<String, Object> questionData = new HashMap<>(); |
|||
questionData.put("question_id", questionId); |
|||
questionData.put("questions", row.get("questions")); |
|||
questionData.put("answers", new ArrayList<>()); |
|||
responseMap.put(questionId, questionData); |
|||
} |
|||
|
|||
Map<String, Object> answerData = new HashMap<>(); |
|||
answerData.put("campaign_answer", row.get("campaign_answer")); |
|||
answerData.put("answer_count", row.get("answer_count")); |
|||
answerData.put("answer_percentage", row.get("answer_percentage")); |
|||
|
|||
((List<Map<String, Object>>) responseMap.get(questionId).get("answers")).add(answerData); |
|||
} |
|||
|
|||
return new ArrayList<>(responseMap.values()); |
|||
} |
|||
|
|||
|
|||
//////////////dizo////////////// |
|||
|
|||
public int closeCampaign(int campaignId) { |
|||
String sql = "UPDATE gcc_1913_campaign.campaign_request SET campaign_status = 'CLOSED' WHERE campaign_id = ?"; |
|||
int rowsAffected = jdbcTemplate.update(sql, campaignId); |
|||
|
|||
if (rowsAffected == 0) { |
|||
System.out.println("Failed to update. Check if campaignId exists: " + campaignId); |
|||
} else { |
|||
System.out.println("Campaign ID " + campaignId + " successfully updated to CLOSED."); |
|||
} |
|||
|
|||
return rowsAffected; |
|||
} |
|||
|
|||
public int autoCloseExpiredCampaigns() { |
|||
String sql = "UPDATE gcc_1913_campaign.campaign_request " + |
|||
"SET campaign_status = 'CLOSED' " + |
|||
"WHERE campaign_status = 'ONGOING' AND end_date < CURRENT_DATE"; |
|||
|
|||
int rowsAffected = jdbcTemplate.update(sql); |
|||
|
|||
if (rowsAffected == 0) { |
|||
System.out.println("No expired campaigns found to close."); |
|||
} else { |
|||
System.out.println(rowsAffected + " campaigns successfully updated to CLOSED."); |
|||
} |
|||
|
|||
return rowsAffected; |
|||
} |
|||
|
|||
// Scheduled job to run daily at midnight |
|||
/* |
|||
* @Scheduled(cron = "0 0 0 * * ?") public void scheduledAutoClose() { |
|||
* System.out.println("Running scheduled auto-close for expired campaigns..."); |
|||
* autoCloseExpiredCampaigns(); } |
|||
*/ |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenter.service; |
|||
|
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
|
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
@Service |
|||
public class WhatsappMsgService { |
|||
|
|||
|
|||
public String sendMsg(String msgUrl) { |
|||
|
|||
String response =""; |
|||
try{ |
|||
HttpURLConnection connection =null; |
|||
|
|||
URL url = new URL(msgUrl); |
|||
connection = (HttpURLConnection) url.openConnection(); |
|||
connection.setRequestMethod("GET"); |
|||
|
|||
int responseCode = connection.getResponseCode(); |
|||
response=responseCode+""; |
|||
System.out.println("Response Code: " + responseCode); |
|||
|
|||
}catch (Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
|
|||
public String sendSMS(String SMS_Url) { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String response =restTemplate.getForObject(SMS_Url,String.class); |
|||
return response; |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.ResponseEntity; |
|||
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 org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
|
|||
@RequestMapping("/gcc/api/callenter/attendance") |
|||
@RestController |
|||
public class AttendanceApiController { |
|||
|
|||
private AppConfig appConfig; |
|||
private final RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
public AttendanceApiController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/getAttendancedetails") |
|||
public String getAttendancedetails(@RequestParam String fromDate,@RequestParam String toDate){ |
|||
String apiUrl = appConfig.attendanceReport + "/callcenter/api/attendance/getattendancereport"+"?fromDate="+ fromDate + "&toDate="+ toDate; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return responseEntity.getBody(); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,71 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
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.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/callcenterattendance") |
|||
@Controller("callCenterAttendanceController") |
|||
public class AttendanceMainController { |
|||
|
|||
@Autowired |
|||
private AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
private RestTemplate restTemplate; |
|||
|
|||
@GetMapping("/attendancereport") |
|||
public String AttendanceList( |
|||
@RequestParam(required = false) String fromDate, |
|||
@RequestParam(required = false) String toDate, |
|||
Model model) { |
|||
List<Map<String, Object>> attendanceData = Collections.emptyList(); |
|||
|
|||
if (fromDate != null && !fromDate.isEmpty() && toDate != null && !toDate.isEmpty()) { |
|||
String apiUrl = appConfig.attendanceReport + "/callcenter/api/attendance/getattendancereport?fromDate=" + fromDate + "&toDate=" + toDate; |
|||
|
|||
try { |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
String responseBody = responseEntity.getBody(); |
|||
|
|||
if (responseBody != null && !responseBody.isEmpty()) { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
if (responseBody.trim().startsWith("{")) { |
|||
// Single object response |
|||
Map<String, Object> singleData = objectMapper.readValue(responseBody, new TypeReference<>() {}); |
|||
attendanceData = List.of(singleData); |
|||
} else { |
|||
// Array response |
|||
attendanceData = objectMapper.readValue(responseBody, new TypeReference<>() {}); |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
System.err.println("Error fetching attendance data: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
model.addAttribute("attendanceData", attendanceData); |
|||
model.addAttribute("fromDate", fromDate); |
|||
model.addAttribute("toDate", toDate); |
|||
model.addAttribute("LoginUserId", LoginUserInfo.getLoginUserId()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
return "modules/callcenter/attendancereport"; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,672 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
|
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
|
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.ComplaintService; |
|||
|
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.util.LinkedMultiValueMap; |
|||
import org.springframework.util.MultiValueMap; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.io.BufferedReader; |
|||
import java.io.IOException; |
|||
import java.io.InputStreamReader; |
|||
import java.io.OutputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.net.URLEncoder; |
|||
import java.time.LocalDate; |
|||
import java.time.format.DateTimeFormatter; |
|||
|
|||
import org.springframework.http.*; |
|||
|
|||
import java.util.Base64; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
import java.awt.Graphics2D; |
|||
import java.awt.image.BufferedImage; |
|||
import java.io.ByteArrayOutputStream; |
|||
import java.io.IOException; |
|||
import javax.imageio.ImageIO; |
|||
import java.util.Base64; |
|||
|
|||
@CrossOrigin |
|||
@RestController |
|||
@RequestMapping("gcc/api/callcenterqaqc/pgrcomplaint") |
|||
public class ComplaintController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
|
|||
public ComplaintController(RestTemplate restTemplate) { |
|||
this.restTemplate = restTemplate; |
|||
} |
|||
|
|||
@Autowired |
|||
private ComplaintService complaintService; |
|||
|
|||
@GetMapping("/getComplaintCategories") |
|||
public @ResponseBody String getComplaintCategories() { |
|||
return complaintService.fetchComplaintCategories(); |
|||
} |
|||
|
|||
@GetMapping("/getComplaintSubTypes") |
|||
public @ResponseBody String getComplaintSubTypes(@RequestParam String groupId) { |
|||
return complaintService.fetchComplaintSubTypes(groupId); |
|||
} |
|||
|
|||
@GetMapping("/getComplaintDetailsbyId") |
|||
public List<Map<String, Object>> getComplaintDetailsById(@RequestParam String complaintid) { |
|||
return complaintService.fetchComplaintDetailsById(complaintid); |
|||
} |
|||
|
|||
@GetMapping("/getComplaintDetailsByMobile") |
|||
public List<Map<String, Object>> getComplaintDetailsByMobile(@RequestParam String mobileNo) { |
|||
return complaintService.fetchComplaintDetailsByMobile(mobileNo); |
|||
} |
|||
|
|||
@PostMapping("/register") |
|||
public ResponseEntity<?> registerComplaint( |
|||
@RequestParam(value = "ComplainantName", required = false) String complainantName, |
|||
@RequestParam(value = "ComplainantAddr", required = false) String complainantAddr, |
|||
@RequestParam(value = "MobileNo", required = false) String mobileNo, |
|||
@RequestParam(value = "Email", required = false) String email, |
|||
@RequestParam(value = "ComplaintType", required = false) String complaintType, |
|||
@RequestParam(value = "ComplaintTitle", required = false) String complaintTitle, |
|||
@RequestParam(value = "ComplaintDetails", required = false) String complaintDetails, |
|||
@RequestParam(value = "StreetId", required = false) String streetId, |
|||
@RequestParam(value = "Comp_Image", required = false) String compImage, |
|||
@RequestParam(value = "latitude", required = false) String latitude, |
|||
@RequestParam(value = "longtitude", required = false) String longtitude, |
|||
@RequestParam(value = "Landmark", required = false) String landmark, |
|||
@RequestParam(value = "gender", required = false) String gender) { |
|||
|
|||
String externalUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; |
|||
|
|||
try { |
|||
// Create the URL object |
|||
URL url = new URL(externalUrl); |
|||
|
|||
// Create the HttpURLConnection object |
|||
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
|||
conn.setRequestMethod("POST"); |
|||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); |
|||
conn.setDoOutput(true); |
|||
|
|||
// Create the parameters string, handling null values |
|||
String params = "serviceId=RegComplaint" + "&ComplainantName=" |
|||
+ URLEncoder.encode(complainantName != null ? complainantName : "", "UTF-8") + "&ComplainantAddr=" |
|||
+ URLEncoder.encode(complainantAddr != null ? complainantAddr : "", "UTF-8") + "&MobileNo=" |
|||
+ URLEncoder.encode(mobileNo != null ? mobileNo : "", "UTF-8") + "&Email=" |
|||
+ URLEncoder.encode(email != null ? email : "", "UTF-8") + "&ComplaintType=" |
|||
+ URLEncoder.encode(complaintType != null ? complaintType : "", "UTF-8") + "&ComplaintTitle=" |
|||
+ URLEncoder.encode(complaintTitle != null ? complaintTitle : "", "UTF-8") + "&ComplaintDetails=" |
|||
+ URLEncoder.encode(complaintDetails != null ? complaintDetails : "", "UTF-8") + "&StreetId=" |
|||
+ URLEncoder.encode(streetId != null ? streetId : "", "UTF-8") + "&Comp_Image=" |
|||
+ URLEncoder.encode(compImage != null ? compImage : "", "UTF-8") + "&latitude=" |
|||
+ URLEncoder.encode(latitude != null ? latitude : "", "UTF-8") + "&longtitude=" |
|||
+ URLEncoder.encode(longtitude != null ? longtitude : "", "UTF-8") + "&Landmark=" |
|||
+ URLEncoder.encode(landmark != null ? landmark : "", "UTF-8") + "&gender=" |
|||
+ URLEncoder.encode(gender != null ? gender : "", "UTF-8") + "&compmode=2"; |
|||
// Write parameters to request body |
|||
try (OutputStream os = conn.getOutputStream()) { |
|||
byte[] input = params.getBytes("UTF-8"); |
|||
os.write(input, 0, input.length); |
|||
} |
|||
|
|||
// Read the response |
|||
int responseCode = conn.getResponseCode(); |
|||
BufferedReader reader; |
|||
if (responseCode == HttpURLConnection.HTTP_OK) { |
|||
reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); |
|||
} else { |
|||
reader = new BufferedReader(new InputStreamReader(conn.getErrorStream())); |
|||
} |
|||
|
|||
StringBuilder response = new StringBuilder(); |
|||
String line; |
|||
while ((line = reader.readLine()) != null) { |
|||
response.append(line); |
|||
} |
|||
reader.close(); |
|||
|
|||
// Return the response from the external API |
|||
//return ResponseEntity.status(responseCode).body(response.toString()); |
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
Map<String, String> responseMap = mapper.readValue(response.toString(), Map.class); |
|||
|
|||
String complaintNo = responseMap.getOrDefault("Complaint Number", "N/A"); |
|||
//System.out.println("complaintNo===="+complaintNo); |
|||
|
|||
return ResponseEntity.ok() |
|||
.contentType(MediaType.APPLICATION_JSON) |
|||
.body(Map.of("complaintNumber", complaintNo)); |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("An error occurred while processing the request."); |
|||
} |
|||
} |
|||
|
|||
@PostMapping("/updateComplaint") |
|||
public ResponseEntity<String> updateComplaint(@RequestParam("ComplaintId") String complaintId, |
|||
@RequestParam(value = "Message", required = false) String message, |
|||
@RequestParam(value = "Status") String status, |
|||
@RequestPart(value = "Comp_Image", required = false) MultipartFile compImage) { |
|||
|
|||
String userType = "Public"; |
|||
|
|||
//System.out.println("message:-" + message + "\n UserType:-" + userType + "\n Status:-" + status); |
|||
//System.out.println(compImage == null); |
|||
String externalUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; |
|||
|
|||
try { |
|||
// Convert and compress the image to base64 if provided |
|||
String base64Image = null; |
|||
if (compImage != null && !compImage.isEmpty()) { |
|||
base64Image = compressAndEncodeToBase64(compImage); |
|||
//System.out.println("imageee" + base64Image); |
|||
} |
|||
|
|||
// Construct the POST body with parameters |
|||
String params = "serviceId=UpdateComplaint" + "&ComplaintId=" |
|||
+ URLEncoder.encode(complaintId != null ? complaintId : "", "UTF-8") + "&Message=" |
|||
+ URLEncoder.encode(message != null ? message : "", "UTF-8") + "&UserType=" |
|||
+ URLEncoder.encode(userType, "UTF-8") + "&Status=" |
|||
+ URLEncoder.encode(status != null ? status : "", "UTF-8") + "&Comp_Image=" |
|||
+ URLEncoder.encode(compImage != null ? base64Image : "", "UTF-8") |
|||
+ "&Token=718333469976265947044293"; |
|||
// Open connection and send POST request |
|||
URL url = new URL(externalUrl); |
|||
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
|||
conn.setRequestMethod("POST"); |
|||
conn.setDoOutput(true); |
|||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); |
|||
|
|||
// Send parameters |
|||
OutputStream os = conn.getOutputStream(); |
|||
os.write(params.getBytes()); |
|||
os.flush(); |
|||
os.close(); |
|||
|
|||
// Handle the response |
|||
int responseCode = conn.getResponseCode(); |
|||
BufferedReader reader; |
|||
if (responseCode == HttpURLConnection.HTTP_OK) { |
|||
reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); |
|||
} else { |
|||
reader = new BufferedReader(new InputStreamReader(conn.getErrorStream())); |
|||
} |
|||
|
|||
StringBuilder response = new StringBuilder(); |
|||
String line; |
|||
while ((line = reader.readLine()) != null) { |
|||
response.append(line); |
|||
} |
|||
reader.close(); |
|||
|
|||
return ResponseEntity.status(responseCode).body(response.toString()); |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("An error occurred while processing the request."); |
|||
} |
|||
} |
|||
|
|||
private String compressAndEncodeToBase64(MultipartFile file) throws IOException { |
|||
// Convert MultipartFile to BufferedImage |
|||
BufferedImage originalImage = ImageIO.read(file.getInputStream()); |
|||
|
|||
// Resize/Compress the image |
|||
int targetWidth = 800; // You can adjust the width as needed |
|||
int targetHeight = (int) (originalImage.getHeight() * (800.0 / originalImage.getWidth())); // Preserve aspect |
|||
// ratio |
|||
|
|||
BufferedImage resizedImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB); |
|||
Graphics2D g = resizedImage.createGraphics(); |
|||
g.drawImage(originalImage, 0, 0, targetWidth, targetHeight, null); |
|||
g.dispose(); |
|||
|
|||
// Compress the image by writing it to a ByteArrayOutputStream in JPEG format |
|||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
|||
ImageIO.write(resizedImage, "jpg", baos); // You can change the format to "png" or "jpg" |
|||
byte[] compressedBytes = baos.toByteArray(); |
|||
|
|||
// Convert the compressed image to base64 |
|||
return Base64.getEncoder().encodeToString(compressedBytes); |
|||
} |
|||
|
|||
////////////////////////////////////// PGR Check ////////////////////////////////////////// |
|||
|
|||
|
|||
@GetMapping("/checktypeforduplicate") |
|||
public ResponseEntity<?> getComplaintMatch( |
|||
@RequestParam("mobileNo") String mobileNo, |
|||
@RequestParam("complaintId") String complaintId, |
|||
@RequestParam("streetName") String streetName |
|||
) { |
|||
try { |
|||
// 1. Map complaintId to complaint title |
|||
Map<String, String> complaintIdToTitle = new HashMap<>(); |
|||
complaintIdToTitle.put("97", "Removal of Garbage"); |
|||
complaintIdToTitle.put("98", "Overflowing of Garbage Bin"); |
|||
complaintIdToTitle.put("99", "Removal of Debris"); |
|||
complaintIdToTitle.put("100", "Absenteeism of Sweepers"); |
|||
complaintIdToTitle.put("101", "Absenteeism of Door to door garbage Collector"); |
|||
complaintIdToTitle.put("102", "Improper Sweeping"); |
|||
complaintIdToTitle.put("103", "Provison of Garbage Bin"); |
|||
complaintIdToTitle.put("104", "Broken Bin"); |
|||
complaintIdToTitle.put("105", "Shifting of Garbage Bin"); |
|||
complaintIdToTitle.put("106", "Cleaning of Water Table"); |
|||
complaintIdToTitle.put("107", "Nuisance by Garbage Tractor/Truck"); |
|||
complaintIdToTitle.put("108", "Burning of Garbage"); |
|||
complaintIdToTitle.put("109", "Garbage Lorry without Net"); |
|||
complaintIdToTitle.put("110", "Spilling of Garbage from Lorry"); |
|||
complaintIdToTitle.put("111", "Burning of Garbage at Dumping Ground"); |
|||
complaintIdToTitle.put("112", "Pot hole fill up / Repairs to the damaged surface"); |
|||
complaintIdToTitle.put("113", "Relaying of Road"); |
|||
complaintIdToTitle.put("114", "Formation of New Road"); |
|||
complaintIdToTitle.put("115", "Repairs to existing Footpath"); |
|||
complaintIdToTitle.put("116", "Request to provide Footpath"); |
|||
complaintIdToTitle.put("117", "Removal of Shops in the Footpath"); |
|||
complaintIdToTitle.put("118", "Mosquito Menace"); |
|||
complaintIdToTitle.put("119", "Street Dogs"); |
|||
complaintIdToTitle.put("120", "Stray Cattle"); |
|||
complaintIdToTitle.put("121", "Stray Pigs"); |
|||
complaintIdToTitle.put("122", "Death of Stray Animals"); |
|||
complaintIdToTitle.put("123", "Public Health / Dengue / Malaria / Gastro Enteritis"); |
|||
complaintIdToTitle.put("124", "Transfer Station Smell"); |
|||
complaintIdToTitle.put("125", "Flies Menace from Dumping Ground"); |
|||
complaintIdToTitle.put("126", "Open Defecation"); |
|||
complaintIdToTitle.put("127", "Illegal Draining of Sewage to SWD / Open Site"); |
|||
complaintIdToTitle.put("128", "Complaints regarding unhygenic Restaurants"); |
|||
complaintIdToTitle.put("129", "Complaints regarding quality of food in hotels"); |
|||
complaintIdToTitle.put("130", "Road Side Eateries"); |
|||
complaintIdToTitle.put("131", "Slaughter House related complaints"); |
|||
complaintIdToTitle.put("132", "Unauthorized Sale of Meat and Meat products"); |
|||
complaintIdToTitle.put("133", "Illegal Slaughtering"); |
|||
complaintIdToTitle.put("134", "Unhygenic and Improper Transport of Meat and Livestock"); |
|||
complaintIdToTitle.put("135", "Biomedical waste / Health hazard waste removal"); |
|||
complaintIdToTitle.put("136", "Complaints regarding Corporation Hospitals"); |
|||
complaintIdToTitle.put("137", "Complaints regarding CDH"); |
|||
complaintIdToTitle.put("138", "Stagnation of Water"); |
|||
complaintIdToTitle.put("139", "Obstruction of Water Flow"); |
|||
complaintIdToTitle.put("140", "Desilting of Drain"); |
|||
complaintIdToTitle.put("141", "Desilting of Canal"); |
|||
complaintIdToTitle.put("142", "Repairs to Storm Water Drain"); |
|||
complaintIdToTitle.put("143", "Covering Manholes of Storm Water Drain"); |
|||
complaintIdToTitle.put("144", "New Drain Construction"); |
|||
complaintIdToTitle.put("145", "Disposal of Removed Silt on the Road"); |
|||
complaintIdToTitle.put("146", "Non burning of Street lights"); |
|||
complaintIdToTitle.put("147", "Electric shock due to street light"); |
|||
complaintIdToTitle.put("148", "Damage to the Electric pole"); |
|||
complaintIdToTitle.put("149", "New Street lights"); |
|||
complaintIdToTitle.put("150", "Shifting of Street light pole"); |
|||
complaintIdToTitle.put("151", "Overhead cable wires running in a haphazard manner"); |
|||
complaintIdToTitle.put("152", "Removal of Fallen Trees"); |
|||
complaintIdToTitle.put("153", "Complaints regarding Park"); |
|||
complaintIdToTitle.put("154", "Complaints regarding Playground"); |
|||
complaintIdToTitle.put("155", "Complaints regarding Centre Median"); |
|||
complaintIdToTitle.put("156", "Complaints regarding Traffic Island"); |
|||
complaintIdToTitle.put("157", "Unauthorized Tree Cutting"); |
|||
complaintIdToTitle.put("158", "Obstruction of Trees"); |
|||
complaintIdToTitle.put("159", "Complaints regarding Public Toilets"); |
|||
complaintIdToTitle.put("160", "Complaints regarding Free Usage of Public Toilets"); |
|||
complaintIdToTitle.put("161", "Complaints regarding Cleanliness of Toilets in Theatre"); |
|||
complaintIdToTitle.put("162", "Complaints regarding Cleanliness of Toilets in Shopping Complex"); |
|||
complaintIdToTitle.put("163", "Building Plan Sanction"); |
|||
complaintIdToTitle.put("164", "Violation of DCR/Building By laws"); |
|||
complaintIdToTitle.put("165", "Unauthorized / Illegal Construction"); |
|||
complaintIdToTitle.put("166", "Complaints related to Property Tax"); |
|||
complaintIdToTitle.put("167", "Complaints related to Professional Tax"); |
|||
complaintIdToTitle.put("168", "Complaints related to Trade Licence"); |
|||
complaintIdToTitle.put("174", "Name Error (Spelling Related)"); |
|||
complaintIdToTitle.put("175", "Change of Address in Electoral Roll"); |
|||
complaintIdToTitle.put("176", "Issue of Voter ID"); |
|||
complaintIdToTitle.put("177", "Inclusion, Deletion, Correction in Voter List"); |
|||
complaintIdToTitle.put("178", "Complaints regarding Voter List"); |
|||
complaintIdToTitle.put("179", "Name not found in the Electoral Roll"); |
|||
complaintIdToTitle.put("180", "Issue of Birth and Death Certificate"); |
|||
complaintIdToTitle.put("181", "Encroachment on the Public Property"); |
|||
complaintIdToTitle.put("182", " Complaints related to Schools"); |
|||
complaintIdToTitle.put("183", "Sanction of Financial Assistance under Moovalaur Thirumana Thittam"); |
|||
complaintIdToTitle.put("184", "Complaints related to issue of all types of Registration Certificate"); |
|||
complaintIdToTitle.put("185", "Slow Progress of Work"); |
|||
complaintIdToTitle.put("186", "Poor Quality of Work"); |
|||
complaintIdToTitle.put("187", "Unauthorized Advertisement Boards"); |
|||
complaintIdToTitle.put("188", "Complaints regarding Bridges / Flyovers / Subways"); |
|||
complaintIdToTitle.put("189", "Complaints related Shopping Complex"); |
|||
complaintIdToTitle.put("190", "Complaints regarding Community Hall"); |
|||
complaintIdToTitle.put("191", "Complaints regarding Burial Ground"); |
|||
complaintIdToTitle.put("192", "Complaints regarding any other CoC building"); |
|||
complaintIdToTitle.put("193", "Parking Issue"); |
|||
complaintIdToTitle.put("195", "Complaints Regarding Plastics"); |
|||
complaintIdToTitle.put("196", "No electricity in public toilet"); |
|||
complaintIdToTitle.put("197", "No water supply in public toilet"); |
|||
complaintIdToTitle.put("198", "Public toilet blockage"); |
|||
complaintIdToTitle.put("199", "Public toilet cleaning"); |
|||
complaintIdToTitle.put("200", "Burning of street light in daytime"); |
|||
complaintIdToTitle.put("201", "Illegal Parking on foot path"); |
|||
complaintIdToTitle.put("202", "Complaints regarding non availability of Doctors"); |
|||
complaintIdToTitle.put("203", "Complaints regarding non availability of medicines"); |
|||
complaintIdToTitle.put("204", "Complaints regarding laboratory issues"); |
|||
complaintIdToTitle.put("205", "Issues regarding amma baby care kits (After Delivery)"); |
|||
complaintIdToTitle.put("206", "Issues regarding Amma nutrition kit for pregnant woman"); |
|||
complaintIdToTitle.put("207", "Issues regarding Muthulakshmi Reddy Maternity Benefit Scheme (MRMBS)"); |
|||
complaintIdToTitle.put("208", "Issues regarding janani suraksha yojana scheme (JSY)"); |
|||
complaintIdToTitle.put("209", "Travel pass related complaints"); |
|||
complaintIdToTitle.put("210", "Food related complaints"); |
|||
complaintIdToTitle.put("212", "Covid Health Related Queries"); |
|||
complaintIdToTitle.put("213", "Hospital and Covid care centre(CCC) Related Queries"); |
|||
complaintIdToTitle.put("214", "Medical Emergencies"); |
|||
complaintIdToTitle.put("215", "Essentials and Medicines"); |
|||
complaintIdToTitle.put("216", "PSYCHO-SOCIO support"); |
|||
complaintIdToTitle.put("218", "Quarantine and isolation Related Queries"); |
|||
complaintIdToTitle.put("219", "General Health Queries"); |
|||
complaintIdToTitle.put("220", "Disinfection request"); |
|||
complaintIdToTitle.put("221", "Non Covid Health Related Queries"); |
|||
complaintIdToTitle.put("222", "Milling/Scraping of Road before Relaying of Road"); |
|||
complaintIdToTitle.put("226", "Food Requirement"); |
|||
complaintIdToTitle.put("227", "Relief Center Requirement"); |
|||
complaintIdToTitle.put("228", "Covid19 Ambulance Service"); |
|||
complaintIdToTitle.put("229", "Air Quality"); |
|||
complaintIdToTitle.put("230", "Online Payment Issue"); |
|||
complaintIdToTitle.put("231", "General Revision Objection"); |
|||
complaintIdToTitle.put("232", "Water Mixed with Sewarage"); |
|||
complaintIdToTitle.put("233", "Sewerage Overflow"); |
|||
complaintIdToTitle.put("234", "Drinking water supply"); |
|||
complaintIdToTitle.put("235", "Electricity Shock"); |
|||
complaintIdToTitle.put("236", "Electricity Unavailability"); |
|||
complaintIdToTitle.put("237", "Insufficient Barricading"); |
|||
complaintIdToTitle.put("238", "Fallen poles/towers/hoardings/other infra"); |
|||
complaintIdToTitle.put("239", "Fallen EB cables"); |
|||
complaintIdToTitle.put("240", "Project information not provided (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("241", "Project information not provided (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("242", "Project information not provided (MC Road)"); |
|||
complaintIdToTitle.put("243", "Project information not provided (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("244", "Project information not provided (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("245", "Project information not provided (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("246", "Advance information on consultation not provided (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("247", "Advance information on consultation not provided (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("248", "Advance information on consultation not provided (MC Road)"); |
|||
complaintIdToTitle.put("249", "Advance information on consultation not provided (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("250", "Advance information on consultation not provided (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("251", "Advance information on consultation not provided (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("252", "Location and area of consultation not provided (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("253", "Location and area of consultation not provided (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("254", "Location and area of consultation not provided (MC Road)"); |
|||
complaintIdToTitle.put("255", "Location and area of consultation not provided (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("256", "Location and area of consultation not provided (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("257", "Location and area of consultation not provided (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("258", "Information on detailed work plan not provided (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("259", "Information on detailed work plan not provided (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("260", "Information on detailed work plan not provided (MC Road)"); |
|||
complaintIdToTitle.put("261", "Information on detailed work plan not provided (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("262", "Information on detailed work plan not provided (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("263", "Information on detailed work plan not provided (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("264", "Others (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("265", "Others (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("266", "Others (MC Road)"); |
|||
complaintIdToTitle.put("267", "Others (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("268", "Others (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("269", "Others (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("270", "No information in advance provided on the date and time of civil works (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("271", "No information in advance provided on the date and time of civil works (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("272", "No information in advance provided on the date and time of civil works (MC Road)"); |
|||
complaintIdToTitle.put("273", "No information in advance provided on the date and time of civil works (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("274", "No information in advance provided on the date and time of civil works (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("275", "No information in advance provided on the date and time of civil works (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("276", "No information provided on the nature and schedule of civil work (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("277", "No information provided on the nature and schedule of civil work (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("278", "No information provided on the nature and schedule of civil work (MC Road)"); |
|||
complaintIdToTitle.put("279", "No information provided on the nature and schedule of civil work (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("280", "No information provided on the nature and schedule of civil work (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("281", "No information provided on the nature and schedule of civil work (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("282", "No consultation carried out with the people affected by the civil works (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("283", "No consultation carried out with the people affected by the civil works (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("284", "No consultation carried out with the people affected by the civil works (MC Road)"); |
|||
complaintIdToTitle.put("285", "No consultation carried out with the people affected by the civil works (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("286", "No consultation carried out with the people affected by the civil works (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("287", "No consultation carried out with the people affected by the civil works (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("288", "No arrangement made for temporary displacement (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("289", "No arrangement made for temporary displacement (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("290", "No arrangement made for temporary displacement (MC Road)"); |
|||
complaintIdToTitle.put("291", "No arrangement made for temporary displacement (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("292", "No arrangement made for temporary displacement (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("293", "No arrangement made for temporary displacement (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("294", "No display board on the project installed at work site (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("295", "No display board on the project installed at work site (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("296", "No display board on the project installed at work site (MC Road)"); |
|||
complaintIdToTitle.put("297", "No display board on the project installed at work site (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("298", "No display board on the project installed at work site (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("299", "No display board on the project installed at work site (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("300", "Temporary access to structures not provided and or not adequate (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("301", "Temporary access to structures not provided and or not adequate (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("302", "Temporary access to structures not provided and or not adequate (MC Road)"); |
|||
complaintIdToTitle.put("303", "Temporary access to structures not provided and or not adequate (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("304", "Temporary access to structures not provided and or not adequate (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("305", "Temporary access to structures not provided and or not adequate (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("306", "No safety measures taken at worksite (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("307", "No safety measures taken at worksite (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("308", "No safety measures taken at worksite (MC Road)"); |
|||
complaintIdToTitle.put("309", "No safety measures taken at worksite (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("310", "No safety measures taken at worksite (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("311", "No safety measures taken at worksite (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("312", "Water supply disrupted and alternate arrangement not provided (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("313", "Water supply disrupted and alternate arrangement not provided (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("314", "Water supply disrupted and alternate arrangement not provided (MC Road)"); |
|||
complaintIdToTitle.put("315", "Water supply disrupted and alternate arrangement not provided (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("316", "Water supply disrupted and alternate arrangement not provided (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("317", "Water supply disrupted and alternate arrangement not provided (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("318", "Electricity supply disrupted and alternate arrangement not provided (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("319", "Electricity supply disrupted and alternate arrangement not provided (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("320", "Electricity supply disrupted and alternate arrangement not provided (MC Road)"); |
|||
complaintIdToTitle.put("321", "Electricity supply disrupted and alternate arrangement not provided (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("322", "Electricity supply disrupted and alternate arrangement not provided (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("323", "Electricity supply disrupted and alternate arrangement not provided (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("324", "Disposal of debris not appropriately managed (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("325", "Disposal of debris not appropriately managed (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("326", "Disposal of debris not appropriately managed (MC Road)"); |
|||
complaintIdToTitle.put("327", "Disposal of debris not appropriately managed (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("328", "Disposal of debris not appropriately managed (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("329", "Disposal of debris not appropriately managed (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("330", " Temporary arrangement for parking not provided (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("331", " Temporary arrangement for parking not provided (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("332", " Temporary arrangement for parking not provided (MC Road)"); |
|||
complaintIdToTitle.put("333", " Temporary arrangement for parking not provided (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("334", " Temporary arrangement for parking not provided (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("335", " Temporary arrangement for parking not provided (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("336", "GRM and helpline numbers not displayed at worksite (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("337", "GRM and helpline numbers not displayed at worksite (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("338", "GRM and helpline numbers not displayed at worksite (MC Road)"); |
|||
complaintIdToTitle.put("339", "GRM and helpline numbers not displayed at worksite (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("340", "GRM and helpline numbers not displayed at worksite (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("341", "GRM and helpline numbers not displayed at worksite (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("342", "Drinking water/ other basic needs for Labour not available at worksite (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("343", "Drinking water/ other basic needs for Labour not available at worksite (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("344", "Drinking water/ other basic needs for Labour not available at worksite (MC Road)"); |
|||
complaintIdToTitle.put("345", "Drinking water/ other basic needs for Labour not available at worksite (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("346", "Drinking water/ other basic needs for Labour not available at worksite (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("347", "Drinking water/ other basic needs for Labour not available at worksite (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("348", "Noise levels are very high (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("349", "Noise levels are very high (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("350", "Noise levels are very high (MC Road)"); |
|||
complaintIdToTitle.put("351", "Noise levels are very high (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("352", "Noise levels are very high (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("353", "Noise levels are very high (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("354", " Sprinkling of water at worksite not carried out (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("355", " Sprinkling of water at worksite not carried out (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("356", " Sprinkling of water at worksite not carried out (MC Road)"); |
|||
complaintIdToTitle.put("357", " Sprinkling of water at worksite not carried out (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("358", " Sprinkling of water at worksite not carried out (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("359", " Sprinkling of water at worksite not carried out (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("360", "The worksite is not barricaded; (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("361", "The worksite is not barricaded; (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("362", "The worksite is not barricaded; (MC Road)"); |
|||
complaintIdToTitle.put("363", "The worksite is not barricaded; (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("364", "The worksite is not barricaded; (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("365", "The worksite is not barricaded; (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("366", " No information on number of labour working at the site (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("367", " No information on number of labour working at the site (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("368", " No information on number of labour working at the site (MC Road)"); |
|||
complaintIdToTitle.put("369", " No information on number of labour working at the site (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("370", " No information on number of labour working at the site (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("371", " No information on number of labour working at the site (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("372", "Labourer not using the safety equipment (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("373", "Labourer not using the safety equipment (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("374", "Labourer not using the safety equipment (MC Road)"); |
|||
complaintIdToTitle.put("375", "Labourer not using the safety equipment (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("376", "Labourer not using the safety equipment (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("377", "Labourer not using the safety equipment (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("378", "Sewerage pipe is damaged (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("379", "Sewerage pipe is damaged (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("380", "Sewerage pipe is damaged (MC Road)"); |
|||
complaintIdToTitle.put("381", "Sewerage pipe is damaged (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("382", "Sewerage pipe is damaged (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("383", "Sewerage pipe is damaged (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("384", "Others (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("385", "Others (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("386", "Others (MC Road)"); |
|||
complaintIdToTitle.put("387", "Others (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("388", "Others (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("389", "Others (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("390", "Insufficient Barricading (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("391", "Insufficient Barricading (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("392", "Insufficient Barricading (MC Road)"); |
|||
complaintIdToTitle.put("393", "Insufficient Barricading (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("394", "Insufficient Barricading (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("395", "Insufficient Barricading (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("396", "Non Removal of Debris (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("397", "Non Removal of Debris (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("398", "Non Removal of Debris (MC Road)"); |
|||
complaintIdToTitle.put("399", "Non Removal of Debris (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("400", "Non Removal of Debris (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("401", "Non Removal of Debris (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("402", "Potholes fill up (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("403", "Potholes fill up (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("404", "Potholes fill up (MC Road)"); |
|||
complaintIdToTitle.put("405", "Potholes fill up (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("406", "Potholes fill up (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("407", "Potholes fill up (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("408", "Damage to utilities (TNEB, CMWSSB, BSNL) (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("409", "Damage to utilities (TNEB, CMWSSB, BSNL) (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("410", "Damage to utilities (TNEB, CMWSSB, BSNL) (MC Road)"); |
|||
complaintIdToTitle.put("411", "Damage to utilities (TNEB, CMWSSB, BSNL) (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("412", "Damage to utilities (TNEB, CMWSSB, BSNL) (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("413", "Damage to utilities (TNEB, CMWSSB, BSNL) (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("414", "Encroaching Public Space (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("415", "Encroaching Public Space (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("416", "Encroaching Public Space (MC Road)"); |
|||
complaintIdToTitle.put("417", "Encroaching Public Space (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("418", "Encroaching Public Space (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("419", "Encroaching Public Space (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("420", "Need Pathway ramp (Thiruvotriyur High Road)"); |
|||
complaintIdToTitle.put("421", "Need Pathway ramp (Arunachaleshwar Road)"); |
|||
complaintIdToTitle.put("422", "Need Pathway ramp (MC Road)"); |
|||
complaintIdToTitle.put("423", "Need Pathway ramp (Washermenpet Metro)"); |
|||
complaintIdToTitle.put("424", "Need Pathway ramp (Khadar Nawas Khan Road)"); |
|||
complaintIdToTitle.put("425", "Need Pathway ramp (Race Course road + Guindy MMI)"); |
|||
complaintIdToTitle.put("426", "Cleanliness in Parks"); |
|||
complaintIdToTitle.put("427", "Greenary in Parks"); |
|||
complaintIdToTitle.put("428", "Play Equipment"); |
|||
complaintIdToTitle.put("429", "Opening and closing hours"); |
|||
complaintIdToTitle.put("430", "Toilets in parks"); |
|||
complaintIdToTitle.put("431", "Non functional lights/ no lights in parks"); |
|||
complaintIdToTitle.put("432", "Safety in parks/playgrounds"); |
|||
complaintIdToTitle.put("433", "Women related safety issues in parks"); |
|||
complaintIdToTitle.put("434", "Availability or cleanliness of dustbins in public toilets"); |
|||
complaintIdToTitle.put("435", "Cleanliness/ water supply in toilets"); |
|||
complaintIdToTitle.put("436", "Broken sinks, toilets or urinals and doors"); |
|||
complaintIdToTitle.put("437", "Request for new toilet"); |
|||
complaintIdToTitle.put("438", "Illegal activities in toilet"); |
|||
complaintIdToTitle.put("439", "Toilets not in use/ closed"); |
|||
complaintIdToTitle.put("440", "Inadequate lighting in and around the toilet"); |
|||
complaintIdToTitle.put("441", "Safety in public toilets"); |
|||
complaintIdToTitle.put("442", "Cleanliness in footpath"); |
|||
complaintIdToTitle.put("443", "Electrical wires/obstruction on footpath"); |
|||
complaintIdToTitle.put("444", "Unsafe dark spots/ corners"); |
|||
complaintIdToTitle.put("445", "Public defecation/urination"); |
|||
complaintIdToTitle.put("446", "Women related safety issues"); |
|||
complaintIdToTitle.put("447", "Inadequate light in a particular location or spot/ dark spots"); |
|||
|
|||
String expectedType; |
|||
if (complaintIdToTitle.containsKey(complaintId)) { |
|||
expectedType = complaintIdToTitle.get(complaintId).trim().toLowerCase(); |
|||
} else { |
|||
// Fallback: Use sub-type text directly if not found in map (i.e. for "Others") |
|||
expectedType = complaintId.trim().toLowerCase(); |
|||
} |
|||
|
|||
// 2. Date range: last 7 days |
|||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); |
|||
LocalDate today = LocalDate.now(); |
|||
String endDate = today.format(formatter); |
|||
String startDate = today.minusDays(7).format(formatter); |
|||
int repYear = today.getYear(); |
|||
|
|||
// 3. Construct external URL |
|||
String externalUrl = String.format( |
|||
"https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=getComplaintListWithImg" + |
|||
"&From_date=%s&To_date=%s&jsonResp=Yes&UserType=Public&Token=&PageIndex=null&Status=null&repYear=%d&MobileNo=%s", |
|||
startDate, endDate, repYear, mobileNo |
|||
); |
|||
|
|||
System.out.println("External API URL: " + externalUrl); |
|||
|
|||
// 4. Fetch and parse response |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String json = restTemplate.getForObject(externalUrl, String.class); |
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JsonNode rootArray = mapper.readTree(json); |
|||
|
|||
boolean found = false; |
|||
|
|||
if (rootArray.isArray() && rootArray.size() > 0) { |
|||
JsonNode complaintList = rootArray.get(0).path("ComplaintListHistory"); |
|||
|
|||
if (complaintList.isArray()) { |
|||
for (JsonNode item : complaintList) { |
|||
String type = item.path("complainttype").asText("").trim().toLowerCase(); |
|||
String street = item.path("Street").asText("").trim().toLowerCase(); |
|||
|
|||
if (type.equals(expectedType) && |
|||
street.equals(streetName.trim().toLowerCase())) { |
|||
found = true; |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
// 5. Return response |
|||
Map<String, Object> response = new HashMap<>(); |
|||
response.put("duplicate", found); |
|||
return ResponseEntity.ok(response); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Collections.singletonMap("error", "Failed to process the request")); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.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; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/callcenterqaqccomplaintstatus") |
|||
@Controller("callCenterQaQcComplaintStatusController") |
|||
public class ComplaintStatusMainController { |
|||
|
|||
@GetMapping("/complaintstatus") |
|||
public String viewstatuscheck(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
|
|||
return "modules/callcenterqaqc/complaintstatus"; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,278 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.HttpClientErrorException; |
|||
import org.springframework.web.client.HttpServerErrorException; |
|||
import org.springframework.web.client.ResourceAccessException; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
|
|||
|
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.DomesticWasteService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
@RestController |
|||
@RequestMapping("/gcc/api/domestic_waste") |
|||
public class DomesticWasteApiController { |
|||
|
|||
@Autowired |
|||
private AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
private RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
private DomesticWasteService domesticWasteService; |
|||
|
|||
|
|||
|
|||
|
|||
@GetMapping("/getitems") |
|||
public ResponseEntity<Map<String, Object>> getItemsList() { |
|||
String apiUrl = appConfig.domesticurl + "/get-all-masters"; |
|||
Map<String, Object> responseMap = new HashMap<>(); |
|||
|
|||
try { |
|||
String response = restTemplate.getForObject(apiUrl, String.class); |
|||
|
|||
responseMap.put("status", "success"); |
|||
responseMap.put("data", new ObjectMapper().readValue(response, Object.class)); // parse JSON array into list |
|||
return ResponseEntity.ok(responseMap); |
|||
|
|||
} catch (HttpClientErrorException | HttpServerErrorException ex) { |
|||
responseMap.put("status", "error"); |
|||
responseMap.put("code", ex.getStatusCode().value()); |
|||
responseMap.put("message", ex.getStatusText()); |
|||
responseMap.put("details", ex.getResponseBodyAsString()); |
|||
return ResponseEntity.status(ex.getStatusCode()).body(responseMap); |
|||
|
|||
} catch (ResourceAccessException ex) { |
|||
responseMap.put("status", "error"); |
|||
responseMap.put("code", HttpStatus.SERVICE_UNAVAILABLE.value()); |
|||
responseMap.put("message", "Service unavailable"); |
|||
responseMap.put("details", ex.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).body(responseMap); |
|||
|
|||
} catch (Exception ex) { |
|||
responseMap.put("status", "error"); |
|||
responseMap.put("code", HttpStatus.INTERNAL_SERVER_ERROR.value()); |
|||
responseMap.put("message", "Unexpected error"); |
|||
responseMap.put("details", ex.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseMap); |
|||
} |
|||
} |
|||
|
|||
@PostMapping("/saverequest") |
|||
public ResponseEntity<?> saveRequest( |
|||
@RequestParam String user_name, |
|||
@RequestParam String mobile, |
|||
@RequestParam String address, |
|||
@RequestParam String latitude, |
|||
@RequestParam String longitude, |
|||
@RequestParam String street_name, |
|||
@RequestParam String street_id, |
|||
@RequestParam String remarks, |
|||
@RequestParam("items") String itemsJson, |
|||
@RequestParam String userId,@RequestParam String zone,@RequestParam String ward) { |
|||
|
|||
try { |
|||
Map<String, Object> result = domesticWasteService.saveMultipleWasteRequests( |
|||
user_name, mobile, address, |
|||
latitude, longitude, |
|||
street_name, street_id, remarks, |
|||
itemsJson,userId,zone,ward |
|||
); |
|||
|
|||
return ResponseEntity.ok(result); |
|||
|
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(500).body(Map.of("status", false, "message", e.getMessage())); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getalldomesticwastelist") |
|||
public Map<String, Object> getFilterReports( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate, |
|||
@RequestParam(required = false) String mobile, |
|||
@RequestParam(required = false) String requestId) { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
System.out.println("startDate="+startDate); |
|||
System.out.println("endDate="+endDate); |
|||
System.out.println("mobile="+mobile); |
|||
System.out.println("requestId="+requestId); |
|||
|
|||
List<Map<String, Object>> details =domesticWasteService.getAllComplaintsList(startDate,endDate,mobile,requestId) ; |
|||
System.out.println(details); |
|||
if (details == null || details.isEmpty()) { |
|||
response.put("status", "nodata"); |
|||
response.put("message", "No Data"); |
|||
} |
|||
else { |
|||
response.put("status", "success"); |
|||
response.put("details", details); |
|||
} |
|||
|
|||
} |
|||
catch (Exception e) { |
|||
response.put("status", "error"); |
|||
response.put("message", "An error occurred while fetching data."); |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/checkstatusbymobile") |
|||
public Map<String, Object> getStatusByMobileNumber( |
|||
@RequestParam(required = false) String mobile) { |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
try { |
|||
System.out.println("mobile=" + mobile); |
|||
|
|||
// Construct external API URL |
|||
String url = appConfig.domesticurl + "/get-user-bymobile?mobile=" + mobile; |
|||
|
|||
// Call the external API |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
ResponseEntity<String> apiResponse = restTemplate.getForEntity(url, String.class); |
|||
|
|||
if (apiResponse.getStatusCode().is2xxSuccessful() && apiResponse.getBody() != null) { |
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
|
|||
// Convert JSON string to List of Maps |
|||
List<Map<String, Object>> itemsList = mapper.readValue(apiResponse.getBody(), |
|||
new TypeReference<List<Map<String, Object>>>() {}); |
|||
|
|||
if (itemsList.isEmpty()) { |
|||
response.put("status", "no data"); |
|||
response.put("data", Collections.emptyList()); |
|||
} else { |
|||
response.put("status", "success"); |
|||
response.put("data", itemsList); |
|||
} |
|||
} else { |
|||
response.put("status", "no data"); |
|||
response.put("data", Collections.emptyList()); |
|||
} |
|||
|
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response.put("status", "error"); |
|||
response.put("message", e.getMessage()); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/getpendingcomplaints") |
|||
public Map<String, Object> getpendingcomplaints( |
|||
@RequestParam String startDate, |
|||
@RequestParam String endDate, |
|||
@RequestParam (required = false) String mobile) { |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
try { |
|||
|
|||
List<Map<String,Object>> list = domesticWasteService.getpendingcomplaints(startDate,endDate,mobile); |
|||
|
|||
if (!list.isEmpty()) { |
|||
|
|||
response.put("status", "success"); |
|||
response.put("data", list); |
|||
|
|||
} 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; |
|||
} |
|||
|
|||
@GetMapping("/getDetailsByReqId") |
|||
public Map<String, Object> getDetailsByReqId( |
|||
@RequestParam String requestId) { |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
try { |
|||
|
|||
List<Map<String,Object>> list = domesticWasteService.getDetailsByReqId(requestId); |
|||
|
|||
if (!list.isEmpty()) { |
|||
|
|||
response.put("status", "success"); |
|||
response.put("data", list); |
|||
|
|||
} 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; |
|||
} |
|||
|
|||
@PostMapping("/cancelbyagents") |
|||
public ResponseEntity<Map<String, Object>> saveAnswer(@RequestParam String requestId,@RequestParam String remarks,@RequestParam String userId) { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
boolean success = domesticWasteService.changeStatus(requestId,remarks,userId); |
|||
if (success) { |
|||
response.put("status", "success"); |
|||
response.put("message", "Complaint cancelled successfully!"); |
|||
return ResponseEntity.ok(response); |
|||
} else { |
|||
response.put("status", "error"); |
|||
response.put("message", "Fail to Update."); |
|||
return ResponseEntity.status(500).body(response); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response.put("status", "error"); |
|||
response.put("message", "Exception: " + e.getMessage()); |
|||
return ResponseEntity.status(500).body(response); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAgentsService; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/domestic_waste") |
|||
@Controller("callCenterDomesticWasteController") |
|||
public class DomesticWasteMainController { |
|||
|
|||
@Autowired |
|||
private QaqcAgentsService agentsService; |
|||
|
|||
@GetMapping("/registerpage") |
|||
public String viewDomesticWastepage(Model model) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
return "modules/callcenterqaqc/domesticwastecomplaints"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/checkstatus") |
|||
public String viewComplaintspage(Model model) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
return "modules/callcenterqaqc/domesticwastecheckstatus"; |
|||
} |
|||
|
|||
@GetMapping("/cancelpage") |
|||
public String viewpendingpage(Model model) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
return "modules/callcenterqaqc/domesticwastecancel"; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.FollowUpService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcCallsService; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/agent/followupcalls") |
|||
@RestController |
|||
public class FollowUpController { |
|||
|
|||
@Autowired |
|||
RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
private QaqcCallsService qaqcCallsService; |
|||
|
|||
@Autowired |
|||
private FollowUpService followService; |
|||
|
|||
@PostMapping("/update") |
|||
@ResponseBody |
|||
public ResponseEntity<String> updateCallDetails(@RequestParam("complaintNumber") String complaintNumber, |
|||
@RequestParam("dataId") int dataId, |
|||
@RequestParam("userId") String userId, |
|||
@RequestParam("action") String action, |
|||
@RequestParam(value = "remainderDate", required = false,defaultValue = "-") String remainderDate, |
|||
@RequestParam("remarks") String remarks) { |
|||
try { |
|||
// System.out.println("Updating Complaint Number: " + complaintNumber); |
|||
// System.out.println("Updating Data ID: " + dataId); |
|||
// System.out.println("Action: " + action); |
|||
// System.out.println("Remarks: " + remarks); |
|||
int updated_agent = Integer.parseInt(userId); |
|||
// System.out.println("updated_agent: " + updated_agent); |
|||
|
|||
Map<String, Object> complaintDetails = qaqcCallsService.getComplaintDetails(dataId); |
|||
|
|||
Integer agentId = (Integer) complaintDetails.get("agent_id"); |
|||
Map<String, Object> erp_username=qaqcCallsService.getErpnameById(agentId); |
|||
String Erpname=(String) erp_username.get("erp_username"); |
|||
|
|||
if ("WRONG_ASSIGN".equals(action)) { |
|||
|
|||
boolean statusUpdated = qaqcCallsService.ChangeStatusInErp(complaintNumber, remarks, action, Erpname); |
|||
|
|||
if (!statusUpdated) { |
|||
return ResponseEntity.ok("error"); |
|||
} |
|||
} |
|||
|
|||
// Update complaint details |
|||
followService.updateFollowupComplaintDetails(complaintNumber, dataId, action, remarks,updated_agent); |
|||
followService.updateComplaintHistoryDetails(complaintNumber, dataId, action, remarks,updated_agent, remainderDate); |
|||
|
|||
Map<String, Object> logDetails = qaqcCallsService.getComplaintDetails(dataId); |
|||
// Upload to logs |
|||
followService.uploadComplaintDetailsInLogs(logDetails, action, complaintNumber,remainderDate); |
|||
|
|||
return ResponseEntity.ok("Success"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error"); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getoffsubmittedcalls") |
|||
public List<Map<String, Object>> getFollowupSubmitDetails(@RequestParam int userId) |
|||
{ |
|||
return followService.getFollowupSubmitDetails(userId); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,96 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.InprogresscallService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcCallsService; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/agent/inprogresscalls") |
|||
@RestController |
|||
|
|||
public class InprogresscallController { |
|||
|
|||
@Autowired |
|||
InprogresscallService inprogresscallService; |
|||
|
|||
@Autowired |
|||
RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
private QaqcCallsService qaqcCallsService; |
|||
|
|||
@PostMapping("/update") |
|||
@ResponseBody |
|||
public ResponseEntity<String> updateCallDetails(@RequestParam("complaintNumber") String complaintNumber, |
|||
@RequestParam("dataId") int dataId, |
|||
@RequestParam("userId") String userId, |
|||
@RequestParam("action") String action, |
|||
@RequestParam(value = "remainderDate", required = false,defaultValue = "-") String remainderDate, |
|||
@RequestParam("remarks") String remarks) { |
|||
try { |
|||
// System.out.println("Updating Complaint Number: " + complaintNumber); |
|||
// System.out.println("Updating Data ID: " + dataId); |
|||
// System.out.println("Action: " + action); |
|||
// System.out.println("Remarks: " + remarks); |
|||
int updated_agent = Integer.parseInt(userId); |
|||
// System.out.println("updated_agent: " + updated_agent); |
|||
|
|||
//to insert incorrect office mobile number details in table |
|||
if (action.equals("MOBILE_NUM")) { |
|||
inprogresscallService.saveMobileNumDetails(complaintNumber, remarks); |
|||
} |
|||
|
|||
Map<String, Object> complaintDetails = qaqcCallsService.getComplaintDetails(dataId); |
|||
|
|||
Integer agentId = (Integer) complaintDetails.get("agent_id"); |
|||
Map<String, Object> erp_username=qaqcCallsService.getErpnameById(agentId); |
|||
String Erpname=(String) erp_username.get("erp_username"); |
|||
|
|||
if ("WRONG_ASSIGN".equals(action)) { |
|||
|
|||
boolean statusUpdated = qaqcCallsService.ChangeStatusInErp(complaintNumber, remarks, action, Erpname); |
|||
|
|||
if (!statusUpdated) { |
|||
return ResponseEntity.ok("error"); |
|||
} |
|||
} |
|||
|
|||
// Update complaint details |
|||
inprogresscallService.updateInprogressComplaintDetails(complaintNumber, dataId, action, remarks,updated_agent); |
|||
inprogresscallService.updateComplaintHistoryDetails(complaintNumber, dataId, action, remarks,updated_agent, remainderDate); |
|||
Map<String, Object> logDetails = qaqcCallsService.getComplaintDetails(dataId); |
|||
// Upload to logs |
|||
qaqcCallsService.uploadComplaintDetailsInLogs(logDetails, action, complaintNumber,remainderDate); |
|||
|
|||
return ResponseEntity.ok("Success"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error"); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getinprogresssubmittedcalls") |
|||
public List<Map<String, Object>> getInprogressSubmitDetails(@RequestParam int userId) |
|||
{ |
|||
return inprogresscallService.getInprogressSubmitDetails(userId); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,370 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.FollowUpService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.InprogresscallService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.PublicFollowUpService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAdminSettingService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAgentsService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcCallsService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcService; |
|||
import in.gov.chennaicorporation.gccoffice.entity.AppUserEntity; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
|
|||
@RequestMapping("/gcc/callcenterqaqc") |
|||
@Controller("callCenterQaQcMainController") |
|||
public class MainController { |
|||
|
|||
@Autowired |
|||
private QaqcService qaqcService; |
|||
|
|||
@Autowired |
|||
private QaqcAgentsService agentsService; |
|||
|
|||
@Autowired |
|||
private QaqcAdminSettingService adminService; |
|||
|
|||
@Autowired |
|||
private InprogresscallService inprogresscallService; |
|||
|
|||
@Autowired |
|||
private QaqcCallsService qaqcCallsService; |
|||
|
|||
@Autowired |
|||
private FollowUpService followUpService; |
|||
|
|||
@Autowired |
|||
private PublicFollowUpService publicService; |
|||
|
|||
|
|||
@GetMapping("/admin/qaqcgrievancedashboard") |
|||
public String viewqaqcdashboard(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
List<Map<String,Object>> previousday=agentsService.getPreviousDayDashboardCounts(); |
|||
model.addAttribute("previousday", previousday); |
|||
//System.out.println(previousday); |
|||
|
|||
List<Map<String,Object>> agentcount=agentsService.getAgentPreviousDayCount(); |
|||
model.addAttribute("agentcount", agentcount); |
|||
|
|||
return "modules/callcenterqaqc/qaqcgrievancedashboard"; |
|||
} |
|||
|
|||
@GetMapping("/admin/qaqcassigntaskagents") |
|||
public String viewAgentAssign(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
return "modules/callcenterqaqc/qaqctaskagentassign"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/admin/qaqcfollowuplist") |
|||
public String viewAdminFollowuplist(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
return "modules/callcenterqaqc/qaqcfollowuplist"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/admin/unattendedcomplaints") |
|||
public String viewAdminUnattendedClose(Model model) { |
|||
|
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("userId", userId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
return "modules/callcenterqaqc/unattendedclosing"; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@GetMapping("/agent/agentgrievancedashboard") |
|||
public String viewAgentGrievenceDashboardpage( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate, |
|||
Model model |
|||
) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
|
|||
|
|||
// Default dates if not provided |
|||
if (startDate == null || endDate == null) { |
|||
LocalDate today = LocalDate.now(); |
|||
startDate = today.toString(); |
|||
endDate = today.toString(); |
|||
} |
|||
|
|||
List<Map<String, Object>> details = agentsService.getAgentDashboard(userId, startDate, endDate); |
|||
model.addAttribute("details", details); |
|||
|
|||
List<Map<String, Object>> details2 = agentsService.getAgentPerformanceData(userId, startDate, endDate); |
|||
model.addAttribute("details2", details2); |
|||
|
|||
List<Map<String, Object>> tasks = agentsService.getAgentTaskDetails(userId, startDate, endDate); |
|||
model.addAttribute("tasks", tasks); |
|||
//System.out.println("tasks: "+tasks); |
|||
return "modules/callcenterqaqc/agentgrievancedashboard"; |
|||
} |
|||
|
|||
|
|||
|
|||
@PostMapping("/agent/agentgrievancedashboard") |
|||
public String viewAgentGrievenceDashboard( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate, |
|||
Model model |
|||
) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
// Default dates if not provided |
|||
if (startDate == null || endDate == null) { |
|||
LocalDate today = LocalDate.now(); |
|||
startDate = today.toString(); |
|||
endDate = today.toString(); |
|||
} |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
// System.out.println("startdate: "+startDate ); |
|||
// System.out.println("enddate:" + endDate); |
|||
|
|||
List<Map<String, Object>> details = agentsService.getAgentDashboard(userId, startDate, endDate); |
|||
model.addAttribute("details", details); |
|||
|
|||
List<Map<String, Object>> details2 = agentsService.getAgentPerformanceData(userId, startDate, endDate); |
|||
model.addAttribute("details2", details2); |
|||
|
|||
List<Map<String, Object>> tasks = agentsService.getAgentTaskDetails(userId, startDate, endDate); |
|||
model.addAttribute("tasks", tasks); |
|||
|
|||
return "modules/callcenterqaqc/agentgrievancedashboard"; |
|||
|
|||
} |
|||
|
|||
@GetMapping("/agent/qaqccalls") |
|||
public String viewAgentQaqcCalls( @RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate,Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
// Default dates if not provided |
|||
if (startDate == null || endDate == null) { |
|||
LocalDate today = LocalDate.now(); |
|||
startDate = today.toString(); |
|||
endDate = today.toString(); |
|||
} |
|||
|
|||
List<Map<String, Object>> details = agentsService.getAgentDashboard(userId, startDate, endDate); |
|||
model.addAttribute("details", details); |
|||
|
|||
List<Map<String, Object>> qaqcCallslists=qaqcCallsService.getClosedComplaints(userId); |
|||
model.addAttribute("qaqcCallsLists",qaqcCallslists); |
|||
|
|||
List<Map<String, Object>> qaqcCallsAction=qaqcCallsService.getCallCategories(); |
|||
model.addAttribute("qaqcCallsActioin",qaqcCallsAction); |
|||
|
|||
List<Map<String, Object>> qaqcSubmitDetails=qaqcCallsService.getSubmitDetails(userId); |
|||
model.addAttribute("qaqcSubmitDetails",qaqcSubmitDetails); |
|||
|
|||
return "modules/callcenterqaqc/agentqaqccalls"; |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("agent/qaqcinprogresscall") |
|||
public String viewqaqcin_progress_call( @RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate,Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
// Default dates if not provided |
|||
if (startDate == null || endDate == null) { |
|||
LocalDate today = LocalDate.now(); |
|||
startDate = today.toString(); |
|||
endDate = today.toString(); |
|||
} |
|||
|
|||
List<Map<String, Object>> details = agentsService.getAgentDashboard(userId, startDate, endDate); |
|||
model.addAttribute("details", details); |
|||
|
|||
List<Map<String, Object>> inprogresslists=inprogresscallService.getInProgressCalls(userId); |
|||
model.addAttribute("inprogresslists", inprogresslists); |
|||
|
|||
List<Map<String, Object>> qaqcactionlists=inprogresscallService.getActionsCatergory(); |
|||
model.addAttribute("qaqcactionlists", qaqcactionlists); |
|||
|
|||
List<Map<String, Object>> inSubmitDetails=inprogresscallService.getInprogressSubmitDetails(userId); |
|||
model.addAttribute("inSubmitDetails",inSubmitDetails); |
|||
|
|||
return "modules/callcenterqaqc/agentqaqcinprogresscalls"; |
|||
} |
|||
|
|||
@GetMapping("/agent/qaqcfollowupcalls") |
|||
public String viewAgentQaqcFollowupCalls(@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate,Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
// Default dates if not provided |
|||
if (startDate == null || endDate == null) { |
|||
LocalDate today = LocalDate.now(); |
|||
startDate = today.toString(); |
|||
endDate = today.toString(); |
|||
} |
|||
|
|||
|
|||
List<Map<String, Object>> details = agentsService.getAgentDashboard(userId, startDate, endDate); |
|||
model.addAttribute("details", details); |
|||
|
|||
List<Map<String, Object>> qaqcfollowuplists=followUpService.getFollowUpCalls(userId); |
|||
model.addAttribute("qaqcfollowuplists",qaqcfollowuplists); |
|||
|
|||
List<Map<String, Object>> qaqccategorylists=followUpService.getFollowUpCatergory(); |
|||
|
|||
model.addAttribute("qaqccategorylists",qaqccategorylists); |
|||
|
|||
List<Map<String, Object>> fcSubmitDetails=followUpService.getFollowupSubmitDetails(userId); |
|||
model.addAttribute("fcSubmitDetails",fcSubmitDetails); |
|||
|
|||
return "modules/callcenterqaqc/agentqaqcfollowupcalls"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/agent/qaqcpublicfollowupcalls") |
|||
public String viewAgentQaqcPublicFollowupCalls(@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate,Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
// Default dates if not provided |
|||
if (startDate == null || endDate == null) { |
|||
LocalDate today = LocalDate.now(); |
|||
startDate = today.toString(); |
|||
endDate = today.toString(); |
|||
} |
|||
|
|||
|
|||
List<Map<String, Object>> details = agentsService.getAgentDashboard(userId, startDate, endDate); |
|||
model.addAttribute("details", details); |
|||
|
|||
List<Map<String, Object>> qaqcfollowuplists=publicService.getFollowUpCalls(userId); |
|||
model.addAttribute("qaqcfollowuplists",qaqcfollowuplists); |
|||
|
|||
List<Map<String, Object>> qaqccategorylists=publicService.getFollowUpCatergory(); |
|||
|
|||
model.addAttribute("qaqccategorylists",qaqccategorylists); |
|||
|
|||
List<Map<String, Object>> fcSubmitDetails=publicService.getFollowupSubmitDetails(userId); |
|||
model.addAttribute("fcSubmitDetails",fcSubmitDetails); |
|||
|
|||
return "modules/callcenterqaqc/agentqaqcpublicfollowupcalls"; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,89 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.FollowUpService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.PublicFollowUpService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcCallsService; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/agent/publicfollowupcalls") |
|||
@RestController |
|||
public class PublicFollowUpController { |
|||
|
|||
@Autowired |
|||
RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
private QaqcCallsService qaqcCallsService; |
|||
|
|||
@Autowired |
|||
private FollowUpService followService; |
|||
|
|||
@Autowired |
|||
private PublicFollowUpService publicService; |
|||
|
|||
@PostMapping("/update") |
|||
@ResponseBody |
|||
public ResponseEntity<String> updateCallDetails(@RequestParam("complaintNumber") String complaintNumber, |
|||
@RequestParam("dataId") int dataId, |
|||
@RequestParam("userId") String userId, |
|||
@RequestParam("action") String action, |
|||
@RequestParam(value = "remainderDate", required = false,defaultValue = "-") String remainderDate, |
|||
@RequestParam("remarks") String remarks) { |
|||
try { |
|||
// System.out.println("Updating Complaint Number: " + complaintNumber); |
|||
// System.out.println("Updating Data ID: " + dataId); |
|||
// System.out.println("Action: " + action); |
|||
// System.out.println("Remarks: " + remarks); |
|||
int updated_agent = Integer.parseInt(userId); |
|||
// System.out.println("updated_agent: " + updated_agent); |
|||
|
|||
Map<String, Object> complaintDetails = qaqcCallsService.getComplaintDetails(dataId); |
|||
|
|||
Integer agentId = (Integer) complaintDetails.get("agent_id"); |
|||
Map<String, Object> erp_username=qaqcCallsService.getErpnameById(agentId); |
|||
String Erpname=(String) erp_username.get("erp_username"); |
|||
|
|||
if ("COMPLETED".equals(action) || "REOPEN".equals(action) ||"WRONG_ASSIGN".equals(action)) |
|||
{ |
|||
boolean statusUpdated =qaqcCallsService.ChangeStatusInErp(complaintNumber, remarks, action,Erpname); |
|||
System.out.println("statusUpdated="+statusUpdated); |
|||
if (!statusUpdated) |
|||
{ |
|||
return ResponseEntity.ok("error"); |
|||
} |
|||
} |
|||
|
|||
// Update complaint details |
|||
followService.updateFollowupComplaintDetails(complaintNumber, dataId, action, remarks,updated_agent); |
|||
followService.updateComplaintHistoryDetails(complaintNumber, dataId, action, remarks,updated_agent, remainderDate); |
|||
|
|||
Map<String, Object> logDetails = qaqcCallsService.getComplaintDetails(dataId); |
|||
// Upload to logs |
|||
followService.uploadComplaintDetailsInLogs(logDetails, action, complaintNumber,remainderDate); |
|||
|
|||
return ResponseEntity.ok("Success"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error"); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getpubsubmittedcalls") |
|||
public List<Map<String, Object>> getFollowupSubmitDetails(@RequestParam int userId) |
|||
{ |
|||
return publicService.getFollowupSubmitDetails(userId); |
|||
} |
|||
} |
|||
@ -0,0 +1,391 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.security.SecureRandom; |
|||
import java.sql.Connection; |
|||
import java.text.SimpleDateFormat; |
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.time.format.DateTimeParseException; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.logging.Level; |
|||
import java.util.logging.Logger; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.databind.JsonMappingException; |
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.FollowUpService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
|
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc") |
|||
@RestController("GrivanceQCapiController") |
|||
|
|||
public class QaqcAPIController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
|
|||
@Autowired |
|||
public QaqcAPIController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@Autowired |
|||
private QaqcService qaqcService; |
|||
|
|||
@Autowired |
|||
private FollowUpService followUpService; |
|||
|
|||
|
|||
|
|||
@GetMapping("/getComplaintDetails/{complaintNumber}") |
|||
public Map<String, Object> getComplaintDetails( |
|||
@PathVariable String complaintNumber, |
|||
@RequestParam(required = false) String gender, |
|||
@RequestParam(required = false) String compmode, |
|||
@RequestParam(required = false) String deptname) { |
|||
|
|||
Map<String, Object> resultMap = new HashMap<>(); |
|||
|
|||
try { |
|||
String url = "https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=getComplaintByID&ComplaintId=" |
|||
+ complaintNumber + "&imgUrlonly=yes"; |
|||
System.out.println("Request URL: " + url); |
|||
|
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); |
|||
|
|||
if (responseEntity.getStatusCode().is2xxSuccessful()) { |
|||
String responseBody = responseEntity.getBody(); |
|||
//System.out.println("Response Body: " + responseBody); |
|||
|
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JsonNode rootNode = mapper.readTree(responseBody); |
|||
|
|||
JsonNode complaintDetails = rootNode.path(0).path("ComplaintListHistory").path(0); |
|||
|
|||
String registerDate=complaintDetails.path("complaintopendate").asText("N/A"); |
|||
//System.out.println("registerdate====="+registerDate); |
|||
|
|||
String formattedDate = "N/A"; // Default value if parsing fails |
|||
|
|||
if (!registerDate.equals("N/A") && !registerDate.isEmpty()) { |
|||
try { |
|||
// Parse the input date string |
|||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); |
|||
Date date = inputFormat.parse(registerDate); |
|||
|
|||
// Format the date to dd-MM-yyyy |
|||
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); |
|||
formattedDate = outputFormat.format(date); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Log exception for debugging |
|||
} |
|||
} |
|||
|
|||
if (!complaintDetails.isMissingNode()) { |
|||
// Existing fields |
|||
resultMap.put("complaintid", complaintDetails.path("complaintid").asText("N/A")); |
|||
resultMap.put("complaintdate", formattedDate); |
|||
resultMap.put("complainantName", complaintDetails.path("CustomerName").asText("N/A")); |
|||
resultMap.put("mobileNumber", complaintDetails.path("CustomerMobile").asText("N/A")); |
|||
resultMap.put("complaintType", complaintDetails.path("complainttype").asText("N/A")); |
|||
resultMap.put("description", complaintDetails.path("complaintdetails").asText("N/A")); |
|||
resultMap.put("currentStatus", complaintDetails.path("complaintcurrentstatus").asText("N/A")); |
|||
resultMap.put("Street", complaintDetails.path("Street").asText("N/A")); |
|||
resultMap.put("Area", complaintDetails.path("Area").asText("N/A")); |
|||
resultMap.put("Landmark", complaintDetails.path("Landmark").asText("N/A")); |
|||
resultMap.put("Location", complaintDetails.path("Location").asText("N/A")); |
|||
resultMap.put("Zone", complaintDetails.path("Zone").asText("N/A")); |
|||
resultMap.put("Division", complaintDetails.path("Division").asText("N/A")); |
|||
resultMap.put("OfficialMobile", complaintDetails.path("OfficialMobile").asText("N/A")); |
|||
resultMap.put("gender", gender != null ? gender : complaintDetails.path("GENDER").asText("N/A")); |
|||
resultMap.put("deptname", deptname != null ? deptname : complaintDetails.path("DEPT_NAME").asText("N/A")); |
|||
resultMap.put("compmode", compmode != null ? compmode : complaintDetails.path("COMP_MODE").asText("N/A")); |
|||
|
|||
// Comments section |
|||
JsonNode comments = complaintDetails.path("Comments"); |
|||
if (!comments.isMissingNode()) { |
|||
List<Map<String, Object>> commentList = new ArrayList<>(); |
|||
for (JsonNode commentNode : comments) { |
|||
Map<String, Object> commentData = new HashMap<>(); |
|||
|
|||
// Extracting comment details |
|||
commentData.put("user", commentNode.path("user").asText("N/A")); |
|||
commentData.put("message", commentNode.path("message").asText("N/A")); |
|||
commentData.put("comment_date", commentNode.path("comment_date").asText("N/A")); |
|||
|
|||
// Handling media link (Image) as part of userimages array for each comment |
|||
JsonNode userImages = commentNode.path("userimages"); |
|||
if (!userImages.isMissingNode() && userImages.isArray() && userImages.size() > 0) { |
|||
String mediaLink = userImages.get(0).path("Comp_Image").asText(null); |
|||
// If media link is valid, add it to the comment data |
|||
if (mediaLink != null && !mediaLink.equals("null") && !mediaLink.isEmpty()) { |
|||
commentData.put("Comp_Image", mediaLink); |
|||
} else { |
|||
commentData.put("Comp_Image", "No image available"); |
|||
} |
|||
} else { |
|||
commentData.put("Comp_Image", "No image available"); |
|||
} |
|||
|
|||
// Add the comment data to the list |
|||
commentList.add(commentData); |
|||
} |
|||
resultMap.put("comments", commentList); |
|||
} |
|||
|
|||
|
|||
// Handling media link (Image) as part of userimages array |
|||
String mediaLink = complaintDetails.path("mediaLink").asText(null); |
|||
List<Map<String, String>> userImagesList = new ArrayList<>(); |
|||
Map<String, String> imageMap = new HashMap<>(); |
|||
imageMap.put("Comp_Image", mediaLink != null && !mediaLink.equals("null") ? mediaLink : null); |
|||
userImagesList.add(imageMap); |
|||
resultMap.put("userimages", userImagesList); |
|||
|
|||
|
|||
// System.out.println("Image URL from API: " + mediaLink); |
|||
} |
|||
} else { |
|||
resultMap.put("error", "Failed to retrieve complaint details."); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
resultMap.put("error", "Error processing request"); |
|||
} |
|||
|
|||
return resultMap; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/followuplist") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> getFollowUpList( |
|||
@RequestParam(value = "callStatus", required = false) String callStatus, |
|||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate, |
|||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate) { |
|||
|
|||
// Set default 'toDate' to a future date (1 year ahead) if not provided |
|||
if (toDate == null) { |
|||
toDate = LocalDate.now().plusMonths(1); // Set to one year ahead or any other future date |
|||
//toDate= qaqcService.getMaxRemainderdate(); |
|||
} |
|||
|
|||
// Set default 'fromDate' to the start of the current month if not provided |
|||
if (fromDate == null) { |
|||
fromDate = LocalDate.now().withDayOfMonth(1); // Start from the first day of the current month |
|||
} |
|||
|
|||
// Print debug info |
|||
// System.out.println("Received callStatus: " + callStatus); |
|||
// System.out.println("From Date: " + fromDate); |
|||
// System.out.println("To Date: " + toDate); |
|||
|
|||
// Call the service to fetch the filtered data based on the status and date range |
|||
return qaqcService.getFollowUpDetailsByStatus(callStatus, fromDate, toDate); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/followup/todayCount") |
|||
public ResponseEntity<Map<String, Long>> getTodayFollowUpCount(@RequestParam String followupStatus) { |
|||
LocalDate today = LocalDate.now(); // Get the current date |
|||
Map<String, Long> counts = qaqcService.countFollowUpsByDateAndStatus(today, followupStatus); |
|||
|
|||
return ResponseEntity.ok(counts); // Return the count in the response |
|||
} |
|||
|
|||
@GetMapping("/callhistory") |
|||
public ResponseEntity<List<Map<String, Object>>> getCallHistory(@RequestParam String complaintNumber) { |
|||
List<Map<String, Object>> callHistory = followUpService.getCallHistory(complaintNumber); |
|||
if (callHistory.isEmpty()) { |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND) |
|||
.body(Collections.emptyList()); |
|||
} |
|||
return ResponseEntity.ok(callHistory); |
|||
} |
|||
|
|||
@GetMapping("/getfilterreport") |
|||
public Map<String, Object> getFilterReports( |
|||
@RequestParam String startDate, |
|||
@RequestParam String endDate, |
|||
@RequestParam String status, |
|||
@RequestParam String group, |
|||
@RequestParam String type, |
|||
@RequestParam String mode, |
|||
@RequestParam String zone, |
|||
@RequestParam String region) { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
LocalDate fromLocalDate = LocalDate.parse(startDate, DateTimeFormatter.ISO_DATE); |
|||
LocalDate toLocalDate = LocalDate.parse(endDate, DateTimeFormatter.ISO_DATE); |
|||
String formattedFromDate = fromLocalDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")); |
|||
String formattedToDate = toLocalDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")); |
|||
|
|||
String url="https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=ms_dashboard_details&From_date="+formattedFromDate+"&To_date="+formattedToDate+"&jsonResp=Yes&Status="+status+"&isQcuser=Yes"+"&ComplaintType="+type+"&ComplaintGroupId="+group+"&compmode="+mode+"&Zoneid="+zone+"&RegionId="+region; |
|||
System.out.println(url); |
|||
|
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
|
|||
// Fetch response as String |
|||
ResponseEntity<String> responses = restTemplate.getForEntity(url, String.class); |
|||
String rawResponse = responses.getBody(); |
|||
|
|||
// Preprocess response to remove invalid characters if needed |
|||
if (rawResponse != null) { |
|||
//rawResponse = rawResponse.replaceAll("\"\"", "\""); // Replace double-double quotes |
|||
//rawResponse = rawResponse.replaceAll("(?<![,{])\"R", "\"R"); // Example: Fix missing commas |
|||
} |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
Map<String, Object> responseMap = objectMapper.readValue(rawResponse, Map.class); |
|||
List<Map<String, Object>> details = (List<Map<String, Object>>) responseMap.get("Details"); |
|||
//System.out.println(details); |
|||
if (details == null) { |
|||
response.put("status", "nodata"); |
|||
response.put("message", "No Data, please change criteria"); |
|||
} |
|||
else { |
|||
response.put("status", "success"); |
|||
response.put("details", details); |
|||
} |
|||
|
|||
} |
|||
catch (Exception e) { |
|||
response.put("status", "error"); |
|||
response.put("message", "An error occurred while fetching data."); |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
@GetMapping("/getunattendedcount") |
|||
public Map<String, Object> GetUnattendedComplaints(@RequestParam int ucount) |
|||
{ |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
// Logging input parameters |
|||
//System.out.println("Received Data: " + ucount); |
|||
|
|||
// Fetch unattended complaints |
|||
List<Map<String, Object>> details = qaqcService.getUnattendedlist(ucount); |
|||
|
|||
if (details != null && !details.isEmpty()) { |
|||
response.put("status", "success"); |
|||
response.put("details", details); |
|||
} else { |
|||
response.put("status", "nodata"); |
|||
response.put("message", "No unattended complaints found for the given criteria."); |
|||
} |
|||
} catch (Exception e) { |
|||
System.err.println("Error while fetching unattended complaints: " + e.getMessage()); |
|||
e.printStackTrace(); // Log the complete stack trace for debugging |
|||
|
|||
response.put("status", "error"); |
|||
response.put("message", "An error occurred while fetching unattended complaints. Please try again."); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
@PostMapping("/closingunattendedcomplaints") |
|||
public ResponseEntity<Map<String, Object>> closeUnattendedComplaints(@RequestBody Map<String, Object> request) { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
// Extract values from request map |
|||
String userId = (String) request.get("userId"); |
|||
String remarks = (String) request.get("remarks"); |
|||
List<String> complaintNumbers = (List<String>) request.get("complaintNumbers"); |
|||
|
|||
if (userId == null || remarks == null || complaintNumbers == null || complaintNumbers.isEmpty()) { |
|||
response.put("status", "error"); |
|||
response.put("message", "Invalid request data."); |
|||
return ResponseEntity.badRequest().body(response); |
|||
} |
|||
|
|||
// Get ERP Username |
|||
String erp_name = qaqcService.getErpusernamebyId(userId); |
|||
//System.out.println("ERP Name: " + erp_name); |
|||
|
|||
List<String> completedComplaints = new ArrayList<>(); |
|||
List<String> failedComplaints = new ArrayList<>(); |
|||
|
|||
// Process each complaint number |
|||
for (String complaintNumber : complaintNumbers) { |
|||
boolean isSuccess = qaqcService.ChangeStatusInErp(complaintNumber, erp_name, remarks); |
|||
if (isSuccess) { |
|||
completedComplaints.add(complaintNumber); |
|||
} else { |
|||
failedComplaints.add(complaintNumber); |
|||
} |
|||
} |
|||
|
|||
int updated=qaqcService.UpdateInHistoryTable(completedComplaints); |
|||
//System.out.println("Updated rows in history table: " + updated); |
|||
|
|||
int updateInlogs=qaqcService.insertInLogs(completedComplaints,remarks,userId); |
|||
//System.out.println("Updated rows in logs table: " + updateInlogs); |
|||
|
|||
//System.out.println("failedComplaints===="+failedComplaints); |
|||
|
|||
// Response handling |
|||
if (complaintNumbers.size() == completedComplaints.size()) { |
|||
response.put("status", "success"); |
|||
response.put("message", "All complaints Completed successfully."); |
|||
response.put("completedCount", completedComplaints.size()); |
|||
} else if (!completedComplaints.isEmpty()) { |
|||
response.put("status", "partial_success"); |
|||
response.put("message", "Some complaints failed to process."); |
|||
response.put("completedCount", completedComplaints.size()); |
|||
response.put("failedCount", failedComplaints.size()); |
|||
response.put("failedComplaints", failedComplaints); |
|||
} else { |
|||
response.put("status", "error"); |
|||
response.put("message", "Failed to process all complaints."); |
|||
} |
|||
|
|||
return ResponseEntity.ok(response); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response.put("status", "error"); |
|||
response.put("message", "An internal server error occurred."); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,208 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.logging.Level; |
|||
import java.util.logging.Logger; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAdminSettingService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/adminsettings") |
|||
@RestController |
|||
public class QaqcAdminSettingsApiController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
|
|||
@Autowired |
|||
public QaqcAdminSettingsApiController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@Autowired |
|||
private QaqcAdminSettingService adminService; |
|||
|
|||
@PostMapping("/saveproductivity") |
|||
public ResponseEntity<Map<String, String>> saveproductivity(@RequestParam int productivity_count) |
|||
{ |
|||
Map<String, String> response = new HashMap<>(); |
|||
try { |
|||
|
|||
// Save task ID |
|||
int rowsInserted = adminService.saveProductivity(productivity_count); |
|||
|
|||
if (rowsInserted > 0) { |
|||
response.put("status", "success"); |
|||
response.put("message", "Productivity inserted successfully"); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
response.put("status", "fail"); |
|||
response.put("message", "Productivity not saved"); |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); // Change to BAD_REQUEST for failure |
|||
|
|||
} catch (Exception e) { |
|||
// Logging the error |
|||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "Error saving task", e); |
|||
|
|||
response.put("status", "error"); |
|||
response.put("message", "Failed to save productivity"); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} |
|||
|
|||
|
|||
@PostMapping("/updateproductivity") |
|||
public ResponseEntity<Map<String, String>> updateProductivityById(@RequestBody Map<String, Integer> requestData) |
|||
{ Map<String, String> response = new HashMap<>(); |
|||
try { |
|||
|
|||
// Save task ID |
|||
int productivityCount = requestData.getOrDefault("productivity_count", 0); // Default to 0 if not provided |
|||
int rowsUpdated = adminService.updateProductivity(productivityCount); |
|||
|
|||
|
|||
if (rowsUpdated > 0) { |
|||
response.put("status", "success"); |
|||
response.put("message", "Productivity saved successfully"); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
response.put("status", "fail"); |
|||
response.put("message", "Productivity not saved"); |
|||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); // Change to BAD_REQUEST for failure |
|||
|
|||
} catch (Exception e) { |
|||
// Logging the error |
|||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "Error saving task", e); |
|||
|
|||
response.put("status", "error"); |
|||
response.put("message", "Failed to save productivity"); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getproductivity") |
|||
public Integer getProductivity() |
|||
{ |
|||
return adminService.getProductivity(); |
|||
} |
|||
|
|||
@GetMapping("/getadminsettingcounts") |
|||
public List<Map<String, Object>> getadminsettingcounts() |
|||
{ |
|||
return adminService.getAdminSettingCounts(); |
|||
|
|||
} |
|||
|
|||
@GetMapping("/assigncallingtype") |
|||
public List<Map<String, Object>> assigncallingtype() |
|||
{ |
|||
return adminService.getAgentsForCallingtype(); |
|||
|
|||
} |
|||
|
|||
@PostMapping("/updateCallType") // Bulk update endpoint |
|||
public ResponseEntity<Map<String, String>> updateCallType(@RequestBody List<Map<String, Object>> selectedAgents) { |
|||
|
|||
Map<String, String> response = new HashMap<>(); |
|||
|
|||
try { |
|||
int rowsUpdated = 0; |
|||
|
|||
// Loop through each selected agent and update their calling_type |
|||
for (Map<String, Object> agent : selectedAgents) { |
|||
String callingType = (String) agent.get("calling_type"); |
|||
|
|||
// Parse agent_id to Integer if it's passed as a String |
|||
int agentId = Integer.parseInt(agent.get("agent_id").toString()); // Ensure it's parsed as Integer |
|||
|
|||
// Update calling type for the agent |
|||
rowsUpdated += adminService.updateCallType(callingType, agentId); |
|||
|
|||
|
|||
} |
|||
adminService.saveCallingTypeInSettings(); |
|||
|
|||
if (rowsUpdated > 0) { |
|||
response.put("status", "success"); |
|||
response.put("message", "Agents Assigned successfully"); |
|||
return ResponseEntity.ok(response); |
|||
} else { |
|||
response.put("status", "error"); |
|||
response.put("message", "No agents updated"); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} catch (Exception e) { |
|||
response.put("status", "error"); |
|||
response.put("message", "Error occurred while updating calling types: " + e.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} |
|||
|
|||
@PostMapping("/updateagentname") |
|||
public ResponseEntity<Map<String, String>> updateAgentnameById(@RequestBody Map<String, String> requestData){ |
|||
Map<String, String> response = new HashMap<>(); |
|||
|
|||
try { |
|||
// Extract and convert agent_id to int |
|||
String agentIdStr = requestData.get("agent_id"); |
|||
String updatedName = requestData.get("agent_name"); |
|||
|
|||
// Validate input |
|||
if (agentIdStr == null || updatedName == null || updatedName.trim().isEmpty()) { |
|||
response.put("status", "error"); |
|||
response.put("message", "Agent ID and name are required!"); |
|||
return ResponseEntity.badRequest().body(response); |
|||
} |
|||
|
|||
int agentId; |
|||
try { |
|||
agentId = Integer.parseInt(agentIdStr); |
|||
} catch (NumberFormatException e) { |
|||
response.put("status", "error"); |
|||
response.put("message", "Invalid Agent ID format!"); |
|||
return ResponseEntity.badRequest().body(response); |
|||
} |
|||
|
|||
// Call service layer to update the agent name |
|||
int updatedRows = adminService.updateAgentName(agentId, updatedName); // Now agentId is an int |
|||
|
|||
if (updatedRows == -1) { // If name already exists |
|||
response.put("status", "error"); |
|||
response.put("message", "Agent name already exists!"); |
|||
return ResponseEntity.status(HttpStatus.CONFLICT).body(response); |
|||
} else if (updatedRows > 0) { |
|||
response.put("status", "success"); |
|||
response.put("message", "Agent name updated successfully!"); |
|||
return ResponseEntity.ok(response); |
|||
} else { |
|||
response.put("status", "error"); |
|||
response.put("message", "Agent not found or update failed."); |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); |
|||
} |
|||
|
|||
} |
|||
catch (Exception e) { |
|||
response.put("status", "error"); |
|||
response.put("message", "Error occurred while updating Agent name " + e.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAdminSettingService; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/callcenterqaqcadminsettings") |
|||
@Controller("callCenterQaQcAdminSettingsController") |
|||
public class QaqcAdminSettingsMainController { |
|||
|
|||
@Autowired |
|||
private QaqcAdminSettingService adminService; |
|||
|
|||
@GetMapping("/adminsettings") |
|||
public String viewAdminSettings(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
|
|||
|
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
List<Map<String, Object>> Counts=adminService.getAdminSettingCounts(); |
|||
model.addAttribute("Counts", Counts); |
|||
|
|||
List<Map<String, Object>> agents=adminService.getAgentsForCallingtype(); |
|||
model.addAttribute("Agents", agents); |
|||
|
|||
|
|||
return "modules/callcenterqaqc/qaqcadminsettings"; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,234 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.security.SecureRandom; |
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.time.format.DateTimeParseException; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.Comparator; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.logging.Level; |
|||
import java.util.logging.Logger; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAdminSettingService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAgentAssignService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
|
|||
@RestController |
|||
@RequestMapping("gcc/api/callcenterqaqc/agentassign") |
|||
public class QaqcAgentAssignAPIController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
public QaqcAgentAssignAPIController(RestTemplate restTemplate) { |
|||
this.restTemplate = restTemplate; |
|||
} |
|||
|
|||
@Autowired |
|||
private QaqcAgentAssignService agentAssignService; |
|||
|
|||
@Autowired |
|||
private QaqcAdminSettingService adminService; |
|||
|
|||
|
|||
|
|||
@GetMapping("/getavailableagents") |
|||
public ResponseEntity<Map<String, Object>> getAvailableAgents(@RequestParam int totalDataCount) { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
try { |
|||
// Fetch available agents |
|||
List<Map<String, Object>> availableAgents = agentAssignService.getAvailableOutboundAgents(); |
|||
Integer productivity_count = adminService.getProductivity(); |
|||
|
|||
if (availableAgents.isEmpty() || totalDataCount == 0) { |
|||
response.put("status", "error"); |
|||
response.put("message", "No available agents or totalDataCount must be greater than 0."); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
|
|||
// Process and filter agents based on productivity_count |
|||
List<Map<String, Object>> filteredAgents = new ArrayList<>(); |
|||
for (Map<String, Object> agent : availableAgents) { |
|||
Integer agentId = (Integer) agent.get("agent_id"); |
|||
String agentName = (String) agent.get("agent_name"); |
|||
Integer todayCount=agentAssignService.getTodayCountForAgent(agentId); |
|||
Integer campaignPendingCount = agentAssignService.getCampaignPendingCountForAgent(agentId); |
|||
Integer pendingCounts=todayCount+campaignPendingCount; |
|||
// Log the details of each agent |
|||
//System.out.println("Agent ID: " + agentId + ", Today Count: " + todayCount +", Campaign Pending Count: " + campaignPendingCount + ", Pending Counts: " + pendingCounts); |
|||
|
|||
if(pendingCounts<productivity_count) { |
|||
filteredAgents.add(Map.of( |
|||
"agent_id", agentId, |
|||
"agent_name", agentName, |
|||
"campaignPendingCount", campaignPendingCount, |
|||
"todayCount",todayCount |
|||
)); |
|||
//System.out.println("Agent added to filteredAgents: " + agentName); |
|||
|
|||
} |
|||
|
|||
} |
|||
//System.out.println("Filtered Agents Size: " + filteredAgents.size()); |
|||
|
|||
|
|||
if (filteredAgents.isEmpty()) { |
|||
response.put("status", "error"); |
|||
response.put("message", "No Available Agents,To continue Increase the Productivity"); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
// Calculate agent_available_count based on filtered agents |
|||
int agent_available_count = filteredAgents.size(); |
|||
|
|||
// Calculate calls per agent using filtered agent count |
|||
int calls_per_agent = totalDataCount / agent_available_count; |
|||
int remainder = totalDataCount % agent_available_count; |
|||
|
|||
// Distribute calls_per_agent and remainder |
|||
List<Map<String, Object>> finalFilteredAgents = new ArrayList<>(); |
|||
filteredAgents.sort(Comparator.comparingInt(agent -> (Integer) agent.get("campaignPendingCount"))); |
|||
|
|||
for (int i = 0; i < filteredAgents.size(); i++) { |
|||
Map<String, Object> agent = filteredAgents.get(i); |
|||
Integer agentId = (Integer) agent.get("agent_id"); |
|||
String agentName = (String) agent.get("agent_name"); |
|||
Integer todayCount = (Integer) agent.get("todayCount"); |
|||
Integer campaignPendingCount = (Integer) agent.get("campaignPendingCount"); |
|||
// Add 1 extra call for agents handling the remainder, starting from the first agent |
|||
int additionalCalls = (i < remainder) ? 1 : 0; |
|||
int totalCallsCount = todayCount+campaignPendingCount + calls_per_agent + additionalCalls; |
|||
|
|||
if (totalCallsCount < productivity_count) { |
|||
finalFilteredAgents.add(Map.of( |
|||
"agent_id", agentId, |
|||
"agent_name", agentName, |
|||
"totalCallsCount", totalCallsCount, |
|||
"todayCount",todayCount, |
|||
"campaignPendingCount", campaignPendingCount, |
|||
"calls_per_agent", calls_per_agent + additionalCalls |
|||
)); |
|||
// System.out.println("Agent added to final======filteredAgents: " + agentName); |
|||
} |
|||
} |
|||
//System.out.println("Final Filtered Agents Size: " + finalFilteredAgents.size()); |
|||
|
|||
if (finalFilteredAgents.isEmpty()) { |
|||
response.put("status", "error"); |
|||
response.put("message", "No Available Agents,To continue Increase the Productivity"); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
|
|||
int agent_available_count2 = finalFilteredAgents.size(); |
|||
|
|||
// Calculate calls per agent using filtered agent count |
|||
int calls_per_agent2 = totalDataCount / agent_available_count2; |
|||
int remainder2 = totalDataCount % agent_available_count2; |
|||
|
|||
// Distribute calls_per_agent and remainder |
|||
List<Map<String, Object>> LastfinalFilteredAgents = new ArrayList<>(); |
|||
finalFilteredAgents.sort(Comparator.comparingInt(agent -> (Integer) agent.get("campaignPendingCount"))); |
|||
|
|||
for (int i = 0; i < finalFilteredAgents.size(); i++) { |
|||
Map<String, Object> agent = finalFilteredAgents.get(i); |
|||
Integer agentId = (Integer) agent.get("agent_id"); |
|||
String agentName = (String) agent.get("agent_name"); |
|||
Integer todayCount1 = (Integer) agent.get("todayCount"); |
|||
Integer campaignPendingCount = (Integer) agent.get("campaignPendingCount"); |
|||
// Add 1 extra call for agents handling the remainder, starting from the first agent |
|||
int additionalCalls1 = (i < remainder2) ? 1 : 0; |
|||
int totalCallsCount1 = todayCount1+campaignPendingCount + calls_per_agent2 + additionalCalls1; |
|||
|
|||
if (totalCallsCount1 < productivity_count) { |
|||
LastfinalFilteredAgents.add(Map.of( |
|||
"agent_id", agentId, |
|||
"agent_name", agentName, |
|||
"totalCallsCount", totalCallsCount1, |
|||
"todayCount1",todayCount1, |
|||
"campaignPendingCount", campaignPendingCount, |
|||
"calls_per_agent", calls_per_agent2 + additionalCalls1 |
|||
)); |
|||
// System.out.println("Agent added to Lastfinal======LastfinalFilteredAgents: " + agentName); |
|||
} |
|||
} |
|||
//System.out.println("Filtered Agents Size: " + LastfinalFilteredAgents.size()); |
|||
|
|||
if (LastfinalFilteredAgents.isEmpty()) { |
|||
response.put("status", "error"); |
|||
response.put("message", "No Available Agents,To continue Increase the Productivity"); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
// Build response |
|||
response.put("status", "success"); |
|||
response.put("message", "Available agents fetched successfully"); |
|||
response.put("available_agents", LastfinalFilteredAgents); |
|||
response.put("productivity_count", productivity_count); |
|||
response.put("agent_available_count", LastfinalFilteredAgents.size()); |
|||
|
|||
return ResponseEntity.ok(response); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
|
|||
// Return error response in case of failure |
|||
response.put("status", "error"); |
|||
response.put("message", "Failed to fetch available agents"); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} |
|||
|
|||
|
|||
@PostMapping("/taskassign") |
|||
public ResponseEntity<Map<String, Object>> assignTasks(@RequestBody Map<String, Object> requestData) { |
|||
Map<String, Object> response; |
|||
try { |
|||
// Delegate transactional work to the service |
|||
response = agentAssignService.assignTasksTransactionally(requestData); |
|||
return ResponseEntity.ok(response); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response = new HashMap<>(); |
|||
response.put("status", "error"); |
|||
response.put("message", "An error occurred: " + e.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/deleteRecords") |
|||
public ResponseEntity<String> deleteRecordsInUploadData() { |
|||
try { |
|||
int rowsAffected = agentAssignService.deleteUploadDataTable(); |
|||
if (rowsAffected > 0) { |
|||
return ResponseEntity.ok("success"); |
|||
} else { |
|||
return ResponseEntity.ok("No records to delete"); |
|||
} |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error deleting records"); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,161 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.io.InputStream; |
|||
import java.net.URL; |
|||
import java.net.URLConnection; |
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.time.LocalDate; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Required; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAgentsService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/agent") |
|||
@RestController |
|||
public class QaqcAgentsAPIController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
|
|||
@Autowired |
|||
public QaqcAgentsAPIController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@Autowired |
|||
private QaqcAgentsService agentsService; |
|||
|
|||
|
|||
@GetMapping("/getdataforagents") |
|||
public ResponseEntity<Map<String, Object>> getdataforagents(@RequestParam int agent_id,@RequestParam int qaqc_id) |
|||
{ |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
List<Map<String, Object>> tasks = agentsService.getdataforagents(agent_id,qaqc_id); |
|||
|
|||
if (tasks.isEmpty()) { |
|||
|
|||
response.put("status", "no_data"); |
|||
response.put("message", "No data found for the given agent_id and qaqc_id."); |
|||
} else { |
|||
// Success case |
|||
response.put("status", "success"); |
|||
response.put("message", "Data retrieved successfully."); |
|||
response.put("tasks", tasks); |
|||
} |
|||
return ResponseEntity.ok(response); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response.put("status", "error"); |
|||
response.put("message", "An error occurred: " + e.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); |
|||
} |
|||
|
|||
} |
|||
|
|||
@PostMapping("/savecallstatus") |
|||
public ResponseEntity<String> savecallstatus(@RequestParam String call_status,@RequestParam String remarks,@RequestParam String complaintNumber)//get full body data |
|||
{ |
|||
|
|||
agentsService.savecallstatus(call_status, remarks,complaintNumber);//get all dbdata and save here and service also |
|||
agentsService.savecallstatusinlogs(call_status, remarks,complaintNumber);//get all dbdata and save here and service also |
|||
|
|||
return ResponseEntity.ok("Data Inserted successfully."); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/getagentperformancecount") |
|||
public List<Map<String, Object>> getAgentPerformanceCount( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
|
|||
List<Map<String, Object>> counts = agentsService.getAgentPerformanceCount(startDate, endDate); |
|||
// System.out.println("fromdates: " + startDate); |
|||
// System.out.println("todate: " + endDate); |
|||
// System.out.println("overallcounts: " + counts ); |
|||
return counts; |
|||
} |
|||
|
|||
@GetMapping("/getagentperformancelist") |
|||
public List<Map<String, Object>> getAgentPerformanceList( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
|
|||
// Fetch agent performance data from service |
|||
List<Map<String, Object>> agentPerformanceData = agentsService.getAgentPerformanceList(startDate, endDate); |
|||
|
|||
// Log or return the data |
|||
//System.out.println("Agent Performance Data: " + agentPerformanceData); |
|||
return agentPerformanceData; |
|||
} |
|||
|
|||
@GetMapping("/agenttaskwise") |
|||
public List<Map<String, Object>> getAgentTaskwiseData(@RequestParam String agentId,@RequestParam String startDate,@RequestParam String endDate) { |
|||
// Call the service to fetch agent task-wise data |
|||
List<Map<String, Object>> agentTaskwiseData = agentsService.getAgentTaskwiseData(agentId, startDate, endDate); |
|||
//System.out.println("Agent Task Wise Data: " + agentTaskwiseData); |
|||
return agentTaskwiseData; |
|||
} |
|||
|
|||
@GetMapping("/agentattendedcomplaints") |
|||
public List<Map<String,Object>> getAttendedComplaintStatus( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate, |
|||
@RequestParam(required = false) String complaintNumber, |
|||
@RequestParam(required = false) String complaintMobileNumber){ |
|||
|
|||
List<Map<String, Object>> agentAttendedData = agentsService.getAttendedComplaintStatus(startDate, endDate, complaintNumber, complaintMobileNumber); |
|||
//System.out.println("Agent attended Data: " + agentAttendedData); |
|||
return agentAttendedData; |
|||
} |
|||
|
|||
@GetMapping("/attendedcomplaintshistory") |
|||
public List<Map<String,Object>> getAttendedComplainthistory( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate, |
|||
@RequestParam(required = false) String complaintNumber, |
|||
@RequestParam(required = false) String complaintMobileNumber){ |
|||
|
|||
List<Map<String, Object>> agentAttendedData = agentsService.getAttendedComplainthistory(startDate, endDate, complaintNumber, complaintMobileNumber); |
|||
//System.out.println("Agent attended Data: " + agentAttendedData); |
|||
return agentAttendedData; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/agenttaskassign") |
|||
public List<Map<String, Object>> getAgentTaskwiseAssign(@RequestParam String agentId) { |
|||
// Call the service to fetch agent task-wise data |
|||
List<Map<String, Object>> agentTaskwiseAssign = agentsService.getAgentTaskwiseAssign(agentId); |
|||
//System.out.println("Agent Task Wise Assign: " + agentTaskwiseAssign); |
|||
return agentTaskwiseAssign; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,519 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.text.SimpleDateFormat; |
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.time.format.DateTimeParseException; |
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Objects; |
|||
//import java.util.stream.Stream; |
|||
import java.text.ParseException; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcCallsService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/agent/qaqccalls") |
|||
@RestController |
|||
public class QaqcCallsController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
public QaqcCallsController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@Autowired |
|||
private QaqcCallsService qaqcCallsService; |
|||
|
|||
@PostMapping("/update") |
|||
@ResponseBody |
|||
public ResponseEntity<String> updateCallDetails(@RequestParam("complaintNumber") String complaintNumber, |
|||
@RequestParam("dataId") int dataId, @RequestParam("action") String action, |
|||
@RequestParam("userId") String userId, |
|||
@RequestParam(value = "remainderDate", required = false, defaultValue = "-") String remainderDate, |
|||
@RequestParam("remarks") String remarks) { |
|||
try { |
|||
// System.out.println("Updating Complaint Number: " + complaintNumber); |
|||
// System.out.println("Updating Data ID: " + dataId); |
|||
// System.out.println("Action: " + action); |
|||
// System.out.println("Remarks: " + remarks); |
|||
int updated_agent = Integer.parseInt(userId); |
|||
// System.out.println("updated_agent: " + updated_agent); |
|||
|
|||
|
|||
// Map<String,Object> followUpComplaint = |
|||
// qaqcCallsService.checkComplaintDetail(complaintNumber); |
|||
// |
|||
// try { |
|||
// int followupid = (int) followUpComplaint.get("id"); |
|||
// // update complaintstaus if exist in followup call logs table |
|||
// if (followUpComplaint != null &&!followUpComplaint.isEmpty()) |
|||
// { |
|||
// qaqcCallsService.updateFollowupCallLogs(complaintNumber, action, remarks,followupid); |
|||
// } |
|||
// |
|||
// } |
|||
// catch(Exception e) |
|||
// { |
|||
// System.out.println("Exception:"+e); |
|||
// } |
|||
|
|||
//to insert incorrect office mobile number details in table |
|||
if(action.equals("MOBILE_NUM")) { |
|||
qaqcCallsService.saveMobileNumDetails(complaintNumber, remarks); } |
|||
|
|||
// Get complaint details |
|||
Map<String, Object> complaintDetails =qaqcCallsService.getComplaintDetails(dataId); |
|||
|
|||
Integer agentId = (Integer) complaintDetails.get("agent_id"); |
|||
Map<String,Object> erp_username=qaqcCallsService.getErpnameById(agentId); |
|||
String Erpname=(String) erp_username.get("erp_username"); |
|||
|
|||
// Handle COMPLETED and REOPEN actions |
|||
|
|||
if ("COMPLETED".equals(action) || "REOPEN".equals(action) ||"WRONG_ASSIGN".equals(action)) |
|||
{ |
|||
boolean statusUpdated =qaqcCallsService.ChangeStatusInErp(complaintNumber, remarks, action,Erpname); |
|||
System.out.println("statusUpdated="+statusUpdated); |
|||
if (!statusUpdated) |
|||
{ |
|||
return ResponseEntity.ok("error"); |
|||
} |
|||
} |
|||
|
|||
if("FOLLOWUP".equals(action)) { |
|||
|
|||
String pname = (String) complaintDetails.get("complaint_person_name"); |
|||
String mob_no = (String) complaintDetails.get("complaint_mobilenumber"); |
|||
String cat = (String) complaintDetails.get("complaint_type"); |
|||
|
|||
String result = sendWhatsappMsg(pname, cat, mob_no, complaintNumber); |
|||
if(result.equals("200")) { |
|||
System.out.println("Followup Whatsapp Message Triggered for "+complaintNumber); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
// Execute common update methods |
|||
qaqcCallsService.updateComplaintDetails(complaintNumber, dataId, action,remarks,updated_agent); |
|||
qaqcCallsService.updateComplaintHistoryDetails(complaintNumber,dataId, action, remarks,updated_agent, remainderDate); |
|||
Map<String, Object> logDetails =qaqcCallsService.getComplaintDetails(dataId); |
|||
qaqcCallsService.uploadComplaintDetailsInLogs(logDetails, action,complaintNumber, remainderDate); |
|||
|
|||
|
|||
return ResponseEntity.ok("Success"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error"); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getComplaintDetails") |
|||
public Map<String, Object> getComplaintDetails(@RequestParam String complaintNumber) { |
|||
|
|||
Map<String, Object> resultMap = new HashMap<>(); |
|||
|
|||
try { |
|||
String url = "https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=getComplaintByID&ComplaintId=" |
|||
+ complaintNumber + "&imgUrlonly=yes&isQcuser=Yes&jsonResp=Yes"; |
|||
System.out.println("Request URL: " + url); |
|||
|
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); |
|||
|
|||
if (responseEntity.getStatusCode().is2xxSuccessful()) { |
|||
String responseBody = responseEntity.getBody(); |
|||
//System.out.println("Response Body: " + responseBody); |
|||
|
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JsonNode rootNode = mapper.readTree(responseBody); |
|||
|
|||
JsonNode complaintDetails = rootNode.path(0).path("ComplaintListHistory").path(0); |
|||
|
|||
String registerDate = complaintDetails.path("complaintopendate").asText("N/A"); |
|||
String ClosedDate = complaintDetails.path("complaintcloseddate").asText("N/A"); |
|||
String ReopenDate = complaintDetails.path("REOPENDDATE").asText("N/A"); |
|||
String FinalcloseDate = complaintDetails.path("FINALCLOSEDDATE").asText("N/A"); |
|||
|
|||
//System.out.println("registerdate=====" + registerDate); |
|||
|
|||
String formattedDate = "N/A"; // Default value if parsing fails |
|||
|
|||
if (!registerDate.equals("N/A") && !registerDate.isEmpty()) { |
|||
try { |
|||
// Parse the input date string |
|||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); |
|||
Date date = inputFormat.parse(registerDate); |
|||
|
|||
// Format the date to dd-MM-yyyy |
|||
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); |
|||
formattedDate = outputFormat.format(date); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Log exception for debugging |
|||
} |
|||
} |
|||
|
|||
/* |
|||
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S"); |
|||
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
|||
|
|||
LocalDateTime maxDate = Stream.of(registerDate, ClosedDate, ReopenDate, FinalcloseDate) |
|||
.filter(date -> date != null && !date.equalsIgnoreCase("null")) |
|||
.map(date -> { |
|||
try { |
|||
return LocalDateTime.parse(date, inputFormatter); |
|||
} catch (DateTimeParseException e) { |
|||
return null; // Skip invalid date formats |
|||
} |
|||
}) |
|||
.filter(Objects::nonNull) |
|||
.max(LocalDateTime::compareTo) // Find the greatest date |
|||
.orElse(null); // Default to null if no valid dates are found |
|||
|
|||
String greatestDateFormatted = (maxDate != null) ? maxDate.format(outputFormatter) : "N/A"; |
|||
*/ |
|||
|
|||
SimpleDateFormat inputFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); |
|||
SimpleDateFormat outputFormatter = new SimpleDateFormat("dd-MM-yyyy"); |
|||
|
|||
Date maxDate = null; |
|||
|
|||
// Put all date strings into array |
|||
String[] dates = { registerDate, ClosedDate, ReopenDate, FinalcloseDate }; |
|||
|
|||
for (int i = 0; i < dates.length; i++) { |
|||
|
|||
String dateStr = dates[i]; |
|||
|
|||
if (dateStr == null || "null".equalsIgnoreCase(dateStr)) { |
|||
continue; |
|||
} |
|||
|
|||
try { |
|||
Date parsedDate = inputFormatter.parse(dateStr); |
|||
|
|||
if (maxDate == null || parsedDate.after(maxDate)) { |
|||
maxDate = parsedDate; |
|||
} |
|||
|
|||
} catch (ParseException e) { |
|||
// Ignore invalid date formats |
|||
} |
|||
} |
|||
|
|||
String greatestDateFormatted = |
|||
(maxDate != null) ? outputFormatter.format(maxDate) : "N/A"; |
|||
|
|||
if (!complaintDetails.isMissingNode()) { |
|||
// Existing fields |
|||
resultMap.put("complaintid", complaintDetails.path("complaintid").asText("N/A")); |
|||
resultMap.put("complaintdate", formattedDate); |
|||
resultMap.put("complainantName", complaintDetails.path("CustomerName").asText("N/A")); |
|||
resultMap.put("mobileNumber", complaintDetails.path("CustomerMobile").asText("N/A")); |
|||
resultMap.put("complaintType", complaintDetails.path("complainttype").asText("N/A")); |
|||
resultMap.put("description", complaintDetails.path("complaintdetails").asText("N/A")); |
|||
resultMap.put("currentStatus", complaintDetails.path("complaintcurrentstatus").asText("N/A")); |
|||
resultMap.put("OfficialMobile", complaintDetails.path("OfficialMobile").asText("N/A")); |
|||
resultMap.put("Street", complaintDetails.path("Street").asText("N/A")); |
|||
resultMap.put("Area", complaintDetails.path("Area").asText("N/A")); |
|||
resultMap.put("Landmark", complaintDetails.path("Landmark").asText("N/A")); |
|||
resultMap.put("Location", complaintDetails.path("Location").asText("N/A")); |
|||
resultMap.put("Zone", complaintDetails.path("Zone").asText("N/A")); |
|||
resultMap.put("Division", complaintDetails.path("Division").asText("N/A")); |
|||
resultMap.put("gender", complaintDetails.path("GENDER").asText("N/A")); |
|||
resultMap.put("deptname", complaintDetails.path("DEPT_NAME").asText("N/A")); |
|||
resultMap.put("compmode", complaintDetails.path("COMP_MODE").asText("N/A")); |
|||
resultMap.put("greatestDate", greatestDateFormatted); |
|||
|
|||
// Comments section |
|||
JsonNode comments = complaintDetails.path("Comments"); |
|||
if (!comments.isMissingNode()) { |
|||
List<Map<String, Object>> commentList = new ArrayList<>(); |
|||
for (JsonNode commentNode : comments) { |
|||
Map<String, Object> commentData = new HashMap<>(); |
|||
|
|||
// Extracting comment details |
|||
commentData.put("user", commentNode.path("user").asText("N/A")); |
|||
commentData.put("message", commentNode.path("message").asText("N/A")); |
|||
commentData.put("comment_date", commentNode.path("comment_date").asText("N/A")); |
|||
|
|||
// Handling media link (Image) as part of userimages array for each comment |
|||
JsonNode userImages = commentNode.path("userimages"); |
|||
if (!userImages.isMissingNode() && userImages.isArray() && userImages.size() > 0) { |
|||
String mediaLink = userImages.get(0).path("Comp_Image").asText(null); |
|||
// If media link is valid, add it to the comment data |
|||
if (mediaLink != null && !mediaLink.equals("null") && !mediaLink.isEmpty()) { |
|||
commentData.put("Comp_Image", mediaLink); |
|||
} else { |
|||
commentData.put("Comp_Image", "No image available"); |
|||
} |
|||
} else { |
|||
commentData.put("Comp_Image", "No image available"); |
|||
} |
|||
|
|||
// Add the comment data to the list |
|||
commentList.add(commentData); |
|||
} |
|||
resultMap.put("comments", commentList); |
|||
} |
|||
|
|||
// Handling media link (Image) as part of userimages array |
|||
String mediaLink = complaintDetails.path("mediaLink").asText(null); |
|||
List<Map<String, String>> userImagesList = new ArrayList<>(); |
|||
Map<String, String> imageMap = new HashMap<>(); |
|||
imageMap.put("Comp_Image", mediaLink != null && !mediaLink.equals("null") ? mediaLink : null); |
|||
userImagesList.add(imageMap); |
|||
resultMap.put("userimages", userImagesList); |
|||
|
|||
//System.out.println("Image URL from API: " + mediaLink); |
|||
} |
|||
} else { |
|||
resultMap.put("error", "Failed to retrieve complaint details."); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
resultMap.put("error", "Error processing request"); |
|||
} |
|||
|
|||
return resultMap; |
|||
} |
|||
|
|||
@GetMapping("/getComplaintDetailsByMobileNumber") |
|||
public Map<String, Object> getComplaintDetailsByMobileNumber(@RequestParam String complaintMobileNumber, |
|||
@RequestParam(required = false) String startDate, @RequestParam(required = false) String endDate, |
|||
@RequestParam String complaintYear) { |
|||
|
|||
// System.out.println("Computed Start Date: " + startDate); |
|||
// System.out.println("Computed End Date: " + endDate); |
|||
// System.out.println("Computed Year: " + complaintYear); |
|||
// System.out.println("Computed MobileNumber: " + complaintMobileNumber); |
|||
|
|||
Map<String, Object> resultMap = new HashMap<>(); |
|||
List<Map<String, Object>> complaintsList = new ArrayList<>(); |
|||
|
|||
try { |
|||
// Determine current year's starting date and today's date |
|||
LocalDate currentDate = LocalDate.now(); |
|||
LocalDate yearStartDate = currentDate.withDayOfYear(1); |
|||
|
|||
// Set default dates if startDate or endDate are empty |
|||
if (startDate == null || startDate.isEmpty()) { |
|||
startDate = yearStartDate.toString(); // Set to current year's start date |
|||
} |
|||
if (endDate == null || endDate.isEmpty()) { |
|||
endDate = currentDate.toString(); // Set to today's date |
|||
} |
|||
|
|||
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|||
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); |
|||
|
|||
startDate = LocalDate.parse(startDate, inputFormatter).format(outputFormatter); |
|||
endDate = LocalDate.parse(endDate, inputFormatter).format(outputFormatter); |
|||
|
|||
// Debug logs (optional) |
|||
// System.out.println("Formatted Start Date: " + startDate); |
|||
// System.out.println("Formatted End Date: " + endDate); |
|||
|
|||
String url = "https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=getComplaintListWithImg&From_date=" |
|||
+ startDate + "&To_date=" + endDate |
|||
+ "&jsonResp=Yes&UserType=Public&Token=&PageIndex=null&Status=null&repYear=" + complaintYear |
|||
+ "&MobileNo=" + complaintMobileNumber; |
|||
|
|||
System.out.println("Request URL: " + url); |
|||
|
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); |
|||
|
|||
if (responseEntity.getStatusCode().is2xxSuccessful()) { |
|||
String responseBody = responseEntity.getBody(); |
|||
// System.out.println("Response Body: " + responseBody); |
|||
|
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JsonNode rootNode = mapper.readTree(responseBody); |
|||
|
|||
JsonNode complaintListHistory = rootNode.path(0).path("ComplaintListHistory"); |
|||
|
|||
if (complaintListHistory.isArray()) { |
|||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); |
|||
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy"); |
|||
for (JsonNode complaintDetails : complaintListHistory) { |
|||
Map<String, Object> complaintMap = new HashMap<>(); |
|||
|
|||
String registerDate = complaintDetails.path("complaintopendate").asText("N/A"); |
|||
Date parsedDate = null; |
|||
|
|||
if (!registerDate.equals("N/A") && !registerDate.isEmpty() && !"null".equalsIgnoreCase(registerDate)) { |
|||
try { |
|||
parsedDate = inputFormat.parse(registerDate); |
|||
String formattedDate = outputFormat.format(parsedDate); |
|||
complaintMap.put("complaintdate", formattedDate); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
complaintMap.put("complaintdate", "N/A"); |
|||
} |
|||
} else { |
|||
complaintMap.put("complaintdate", "N/A"); |
|||
} |
|||
|
|||
// Add complaint details to the map |
|||
complaintMap.put("complaintid", complaintDetails.path("complaintid").asText("N/A")); |
|||
complaintMap.put("complainantName", complaintDetails.path("CustomerName").asText("N/A")); |
|||
complaintMap.put("mobileNumber", complaintDetails.path("CustomerMobile").asText("N/A")); |
|||
complaintMap.put("complaintType", complaintDetails.path("complainttype").asText("N/A")); |
|||
complaintMap.put("currentStatus",complaintDetails.path("complaintcurrentstatus").asText("N/A")); |
|||
complaintMap.put("OfficialMobile", complaintDetails.path("OfficialMobile").asText("N/A")); |
|||
complaintMap.put("Street", complaintDetails.path("Street").asText("N/A")); |
|||
complaintMap.put("Area", complaintDetails.path("Area").asText("N/A")); |
|||
complaintMap.put("Landmark", complaintDetails.path("Landmark").asText("N/A")); |
|||
complaintMap.put("Location", complaintDetails.path("Location").asText("N/A")); |
|||
complaintMap.put("Zone", complaintDetails.path("Zone").asText("N/A")); |
|||
complaintMap.put("Division", complaintDetails.path("Division").asText("N/A")); |
|||
String closedDate = complaintDetails.path("complaintcloseddate").asText("N/A"); |
|||
|
|||
// Check if the value is explicitly "null" (as a string) |
|||
if ("null".equalsIgnoreCase(closedDate)) { |
|||
closedDate = "N/A"; |
|||
} |
|||
|
|||
complaintMap.put("complaintcloseddate", closedDate); |
|||
complaintMap.put("parsedComplaintDate", parsedDate); |
|||
|
|||
// Add the complaint to the list |
|||
complaintsList.add(complaintMap); |
|||
} |
|||
|
|||
// Sort complaintsList by parsedComplaintDate in descending order |
|||
complaintsList.sort((a, b) -> { |
|||
Date dateA = (Date) a.get("parsedComplaintDate"); |
|||
Date dateB = (Date) b.get("parsedComplaintDate"); |
|||
if (dateA == null && dateB == null) return 0; |
|||
if (dateA == null) return 1; |
|||
if (dateB == null) return -1; |
|||
return dateB.compareTo(dateA); |
|||
}); |
|||
|
|||
for (Map<String, Object> complaint : complaintsList) { |
|||
complaint.remove("parsedComplaintDate"); |
|||
} |
|||
} |
|||
resultMap.put("status", "success"); |
|||
resultMap.put("complaints", complaintsList); |
|||
} else { |
|||
resultMap.put("status", "error"); |
|||
resultMap.put("message", "Failed to retrieve complaint details."); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
resultMap.put("status", "error"); |
|||
resultMap.put("message", "Error processing request"); |
|||
} |
|||
|
|||
return resultMap; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getqcsubmittedcalls") |
|||
public List<Map<String, Object>> getSubmittedList(@RequestParam int userId) |
|||
{ |
|||
return qaqcCallsService.getSubmitDetails(userId); |
|||
} |
|||
|
|||
/* |
|||
* System.out.println("Computed Start Date: " + startDate); |
|||
* System.out.println("Computed End Date: " + endDate); |
|||
* System.out.println("Computed Year: " + complaintYear); |
|||
* System.out.println("Computed MobileNumber: " + complaintMobileNumber); |
|||
* |
|||
* String url |
|||
* ="https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=getComplaintListWithImg&From_date=" |
|||
* +startDate+"&To_date="+endDate+ |
|||
* "&jsonResp=Yes&UserType=Public&Token=&PageIndex=null&Status=null&repYear="+ |
|||
* complaintYear+"&MobileNo="+complaintMobileNumber; |
|||
* |
|||
* System.out.println("Request URL: " + url); |
|||
* |
|||
*/ |
|||
|
|||
|
|||
private String sendWhatsappMsg(String pname,String cat,String mob_no, String complaintNumber) { |
|||
String urlString = ""; |
|||
|
|||
//urlString="https://sendapiv1.pinbot.ai/pinwa/sendMessage?apikey=5c995535-6244-11f0-98fc-02c8a5e042bd&from=919445061913&to="+mob_no+"&templateid=3285616&type=template&placeholders="+pname+"||"+cat+"||"+complaintNumber+"&button_placeholder="+complaintNumber; |
|||
|
|||
try { |
|||
|
|||
String placeholders = |
|||
URLEncoder.encode( |
|||
pname + "|~|" + cat + "|~|" + complaintNumber, |
|||
StandardCharsets.UTF_8.toString()); |
|||
|
|||
String buttonPlaceholder = |
|||
URLEncoder.encode( |
|||
complaintNumber, |
|||
StandardCharsets.UTF_8.toString()); |
|||
|
|||
String mobile = |
|||
URLEncoder.encode( |
|||
mob_no, |
|||
StandardCharsets.UTF_8.toString()); |
|||
|
|||
|
|||
urlString="https://sendapiv1.pinbot.ai/pinwa/sendMessage?apikey=5c995535-6244-11f0-98fc-02c8a5e042bd&from=919445061913&to="+mobile+"&templateid=3285616&type=template&placeholders="+placeholders+"&button_placeholder="+buttonPlaceholder; |
|||
|
|||
String res = hitURL(urlString); |
|||
return res; |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ""; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
private String hitURL(String urlString) { |
|||
String response = ""; |
|||
try { |
|||
URL url = new URL(urlString); |
|||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
|||
connection.setRequestMethod("GET"); |
|||
|
|||
int responseCode = connection.getResponseCode(); |
|||
response = String.valueOf(responseCode); |
|||
//System.out.println("Response Code for URL: " + urlString + " is " + responseCode); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
System.out.println("response=" + response); |
|||
return response; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAgentsService; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/callcenterqaqccomplaintsregistration") |
|||
@Controller("callCenterQaQcComplaintsRegistrationController") |
|||
public class QaqcPgrComplaintsMainController { |
|||
|
|||
@Autowired |
|||
private QaqcAgentsService agentsService; |
|||
|
|||
@GetMapping("/pgrcomplaint") |
|||
public String viewPGRpage(Model model) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
return "modules/callcenterqaqc/pgrcomplaints"; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.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 org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAdminSettingService; |
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcTaskListService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/qaqctasklist") |
|||
@RestController |
|||
public class QaqcTaskListAPIController { |
|||
|
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
|
|||
@Autowired |
|||
public QaqcTaskListAPIController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@Autowired |
|||
private QaqcTaskListService tasklist; |
|||
|
|||
@GetMapping("/overalltaskcount") |
|||
public List<Map<String, Object>> getComplaintAndCallStatusCounts( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
|
|||
List<Map<String, Object>> counts = tasklist.getComplaintAndCallStatusCounts(startDate, endDate); |
|||
//System.out.println("overallcounts:" + counts); |
|||
return counts; |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/taskdatacount") |
|||
public List<Map<String, Object>> getTaskwiseData( |
|||
@RequestParam(required = false) String startDate, |
|||
@RequestParam(required = false) String endDate) { |
|||
List<Map<String, Object>> taskdata = tasklist.getTaskwiseData(startDate, endDate); |
|||
//System.out.println("taskdata "+ taskdata); |
|||
return taskdata; |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/agentdatacount") |
|||
public List<Map<String, Object>> getAgentwiseData(@RequestParam String qaqc_id) |
|||
{ |
|||
List<Map<String, Object>> agentwisedata = tasklist.getAgentwiseData(qaqc_id); |
|||
//System.out.println("agentdata "+agentwisedata); |
|||
return agentwisedata; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.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; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
|
|||
@RequestMapping("/gcc/callcenterqaqcreports") |
|||
@Controller("callCenterQaQcReportsController") |
|||
public class ReportsMainController { |
|||
|
|||
|
|||
@GetMapping("/overallreport") |
|||
public String viewOverallReports(Model model) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
return "modules/callcenterqaqc/overallreport"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/qaqctasklist") |
|||
public String viewqaqctasklist(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
|
|||
return "modules/callcenterqaqc/qaqctasklist"; |
|||
} |
|||
|
|||
@GetMapping("/qaqcagentperformance") |
|||
public String viewAgentPerformance(Model model) { |
|||
|
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(LoginUserId); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String agent_name=LoginUserInfo.getCurrentUserDetails().getUsername(); |
|||
model.addAttribute("agent_name", agent_name); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
return "modules/callcenterqaqc/qaqcagentperformance"; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,563 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.HttpClientErrorException; |
|||
import org.springframework.web.client.HttpServerErrorException; |
|||
import org.springframework.web.client.ResourceAccessException; |
|||
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; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.ScpService; |
|||
|
|||
@RestController |
|||
@RequestMapping("/gcc/api/scp") |
|||
public class ScpApiController { |
|||
|
|||
|
|||
@Autowired |
|||
private RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
private ObjectMapper objectMapper; |
|||
|
|||
@Autowired |
|||
private ScpService scpservice; |
|||
|
|||
@GetMapping("/getdatabyfilters") |
|||
public Map<String, Object> getdatabyfilters( |
|||
@RequestParam String startDate, |
|||
@RequestParam String endDate, |
|||
@RequestParam String zone, |
|||
@RequestParam String ward) { |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|||
DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
|||
|
|||
String formattedStartDate = LocalDate.parse(startDate, inputFormat).format(outputFormat); |
|||
String formattedEndDate = LocalDate.parse(endDate, inputFormat).format(outputFormat); |
|||
|
|||
// Build API URL |
|||
String apiUrl = "https://gccservices.in/gccofficialapp/api/asset/scpfilterReports" |
|||
+ "?assetTypeId=2" |
|||
+ "&fromDate=" + formattedStartDate |
|||
+ "&toDate=" + formattedEndDate |
|||
+ "&loginId=5662"; |
|||
|
|||
if (!zone.isEmpty()) { |
|||
apiUrl += "&zone=" + zone; |
|||
} |
|||
if (!ward.isEmpty()) { |
|||
apiUrl += "&ward=" + ward; |
|||
} |
|||
|
|||
System.out.println("apiUrl=" + apiUrl); |
|||
|
|||
// Call the external API |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
ResponseEntity<String> 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()); |
|||
|
|||
// Extract "scpreport" array |
|||
JsonNode reportNode = rootNode.path("scpreport"); |
|||
|
|||
if (reportNode.isMissingNode() || !reportNode.isArray() || reportNode.size() == 0) { |
|||
response.put("status", "nodata"); |
|||
response.put("data", Collections.emptyList()); |
|||
} else { |
|||
// Convert JSON array → List<Map<String, Object>> |
|||
List<Map<String, Object>> reportList = mapper.convertValue( |
|||
reportNode, |
|||
new TypeReference<List<Map<String, Object>>>() {} |
|||
); |
|||
|
|||
response.put("status", "success"); |
|||
response.put("data", reportList); |
|||
if(zone.isEmpty() && ward.isEmpty()) { |
|||
response.put("table", "table1"); |
|||
} |
|||
else if(ward.isEmpty() && !zone.isEmpty()) { |
|||
response.put("table", "table2"); |
|||
} |
|||
else if(!ward.isEmpty() && !zone.isEmpty()) { |
|||
response.put("table", "table3"); |
|||
} |
|||
|
|||
} |
|||
} 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; |
|||
} |
|||
|
|||
@GetMapping("/getzones") |
|||
public ResponseEntity<Map<String, Object>> getzones() { |
|||
String apiUrl = "https://gccservices.in/gccrestservices/dropdown/api/zone"; |
|||
Map<String, Object> responseMap = new HashMap<>(); |
|||
|
|||
try { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String response = restTemplate.getForObject(apiUrl, String.class); |
|||
|
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
JsonNode rootArray = objectMapper.readTree(response); |
|||
|
|||
// ✅ The response is an array, so get the first element |
|||
if (rootArray.isArray() && rootArray.size() > 0) { |
|||
JsonNode firstObject = rootArray.get(0); |
|||
|
|||
boolean status = firstObject.path("status").asBoolean(false); |
|||
|
|||
if (status) { |
|||
JsonNode dataArray = firstObject.path("data"); |
|||
responseMap.put("status", "success"); |
|||
responseMap.put("code", 200); |
|||
responseMap.put("message", "Data found"); |
|||
responseMap.put("data", objectMapper.convertValue( |
|||
dataArray, new TypeReference<List<Map<String, Object>>>() {})); |
|||
return ResponseEntity.ok(responseMap); |
|||
} else { |
|||
responseMap.put("status", "failure"); |
|||
responseMap.put("code", 404); |
|||
responseMap.put("message", "No Zones found"); |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(responseMap); |
|||
} |
|||
} else { |
|||
responseMap.put("status", "failure"); |
|||
responseMap.put("code", 404); |
|||
responseMap.put("message", "Invalid response format"); |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(responseMap); |
|||
} |
|||
|
|||
} catch (Exception ex) { |
|||
responseMap.put("status", "error"); |
|||
responseMap.put("code", HttpStatus.INTERNAL_SERVER_ERROR.value()); |
|||
responseMap.put("message", "Unexpected error occurred"); |
|||
responseMap.put("details", ex.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseMap); |
|||
} |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getwardbyzone") |
|||
public ResponseEntity<Map<String, Object>> getwardbyzone( @RequestParam String zone) { |
|||
String apiUrl = "https://gccservices.in/gccrestservices/dropdown/api/wardbyzone?zoneId="+zone; |
|||
Map<String, Object> responseMap = new HashMap<>(); |
|||
|
|||
try { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String response = restTemplate.getForObject(apiUrl, String.class); |
|||
|
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
JsonNode rootArray = objectMapper.readTree(response); |
|||
|
|||
// ✅ The response is an array, so get the first element |
|||
if (rootArray.isArray() && rootArray.size() > 0) { |
|||
JsonNode firstObject = rootArray.get(0); |
|||
|
|||
boolean status = firstObject.path("status").asBoolean(false); |
|||
|
|||
if (status) { |
|||
JsonNode dataArray = firstObject.path("data"); |
|||
responseMap.put("status", "success"); |
|||
responseMap.put("code", 200); |
|||
responseMap.put("message", "Data found"); |
|||
responseMap.put("data", objectMapper.convertValue( |
|||
dataArray, new TypeReference<List<Map<String, Object>>>() {})); |
|||
return ResponseEntity.ok(responseMap); |
|||
} else { |
|||
responseMap.put("status", "failure"); |
|||
responseMap.put("code", 404); |
|||
responseMap.put("message", "No Zones found"); |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(responseMap); |
|||
} |
|||
} else { |
|||
responseMap.put("status", "failure"); |
|||
responseMap.put("code", 404); |
|||
responseMap.put("message", "Invalid response format"); |
|||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(responseMap); |
|||
} |
|||
|
|||
} catch (Exception ex) { |
|||
responseMap.put("status", "error"); |
|||
responseMap.put("code", HttpStatus.INTERNAL_SERVER_ERROR.value()); |
|||
responseMap.put("message", "Unexpected error occurred"); |
|||
responseMap.put("details", ex.getMessage()); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(responseMap); |
|||
} |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getstreetdetails") |
|||
public Map<String, Object> getstreetdetails( |
|||
@RequestParam String startDate, |
|||
@RequestParam String endDate, |
|||
@RequestParam String variable) { |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|||
DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
|||
|
|||
String formattedStartDate = LocalDate.parse(startDate, inputFormat).format(outputFormat); |
|||
String formattedEndDate = LocalDate.parse(endDate, inputFormat).format(outputFormat); |
|||
|
|||
// 🔹 Call external API |
|||
String apiUrl = "https://gccservices.in/gccofficialapp/api/asset/scpReportAssetList" |
|||
+ "?assetTypeId=2" |
|||
+ "&fromDate=" + formattedStartDate |
|||
+ "&toDate=" + formattedEndDate |
|||
+ "&loginId=5662" |
|||
+ "&status=Cleaned" |
|||
+ "&streetid=" + variable; |
|||
|
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
ResponseEntity<String> apiResponse = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
List<Map<String, Object>> reportData = new ArrayList<>(); |
|||
|
|||
if (apiResponse.getStatusCode().is2xxSuccessful() && apiResponse.getBody() != null) { |
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JsonNode rootNode = mapper.readTree(apiResponse.getBody()); |
|||
JsonNode reportNode = rootNode.path("scpreport"); |
|||
|
|||
if (reportNode.isArray() && reportNode.size() > 0) { |
|||
reportData = mapper.convertValue( |
|||
reportNode, |
|||
new TypeReference<List<Map<String, Object>>>() {} |
|||
); |
|||
} |
|||
} |
|||
|
|||
if (reportData.isEmpty()) { |
|||
response.put("status", "nodata"); |
|||
response.put("data", Collections.emptyList()); |
|||
} else { |
|||
// 🔹 Enrich each data item with questions_part |
|||
List<Map<String, Object>> enrichedData = scpservice.enrichScpReportWithQuestions(reportData); |
|||
|
|||
response.put("status", "success"); |
|||
response.put("data", enrichedData); |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response.put("status", "error"); |
|||
response.put("message", e.getMessage()); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
|
|||
// @PostMapping("/saveanswer") |
|||
// public ResponseEntity<Map<String, Object>> saveAnswer(@RequestBody List<Map<String, Object>> answers) { |
|||
// Map<String, Object> response = new HashMap<>(); |
|||
// |
|||
// try { |
|||
// boolean success = scpservice.saveAnswers(answers); |
|||
// if (success) { |
|||
// response.put("status", "success"); |
|||
// response.put("message", "Feedback submitted successfully!"); |
|||
// return ResponseEntity.ok(response); |
|||
// } else { |
|||
// response.put("status", "error"); |
|||
// response.put("message", "Fail to Save."); |
|||
// return ResponseEntity.status(500).body(response); |
|||
// } |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// response.put("status", "error"); |
|||
// response.put("message", "Exception: " + e.getMessage()); |
|||
// return ResponseEntity.status(500).body(response); |
|||
// } |
|||
// } |
|||
|
|||
|
|||
@PostMapping("/saveanswer") |
|||
public ResponseEntity<Map<String, Object>> saveAnswer(@RequestBody List<Map<String, Object>> answers) { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
String result = scpservice.saveAnswers(answers); |
|||
|
|||
if ("success".equals(result)) { |
|||
response.put("status", "success"); |
|||
response.put("message", "Feedback submitted successfully!"); |
|||
return ResponseEntity.ok(response); |
|||
|
|||
} else if ("duplicate".equals(result)) { |
|||
response.put("status", "duplicate"); |
|||
response.put("message", "Already submitted by another one, So refresh the page"); |
|||
return ResponseEntity.ok(response); |
|||
|
|||
} else { |
|||
response.put("status", "error"); |
|||
response.put("message", "Fail to Save."); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response.put("status", "error"); |
|||
response.put("message", "Exception: " + e.getMessage()); |
|||
return ResponseEntity.status(500).body(response); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/getreportdatabyfilters") |
|||
public Map<String, Object> getreportdatabyfilters( |
|||
@RequestParam String startDate, |
|||
@RequestParam String endDate, |
|||
@RequestParam String zone, |
|||
@RequestParam String ward) { |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|||
DateTimeFormatter outputFormat = DateTimeFormatter.ofPattern("dd-MM-yyyy"); |
|||
|
|||
String formattedStartDate = LocalDate.parse(startDate, inputFormat).format(outputFormat); |
|||
String formattedEndDate = LocalDate.parse(endDate, inputFormat).format(outputFormat); |
|||
|
|||
// Build API URL |
|||
String apiUrl = "https://gccservices.in/gccofficialapp/api/asset/scpfilterReports" |
|||
+ "?assetTypeId=2" |
|||
+ "&fromDate=" + formattedStartDate |
|||
+ "&toDate=" + formattedEndDate |
|||
+ "&loginId=5662"; |
|||
|
|||
if (!zone.isEmpty()) { |
|||
apiUrl += "&zone=" + zone; |
|||
} |
|||
if (!ward.isEmpty()) { |
|||
apiUrl += "&ward=" + ward; |
|||
} |
|||
|
|||
System.out.println("apiUrl=" + apiUrl); |
|||
|
|||
// Call the external API |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
ResponseEntity<String> 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()); |
|||
|
|||
// Extract "scpreport" array |
|||
JsonNode reportNode = rootNode.path("scpreport"); |
|||
|
|||
if (reportNode.isMissingNode() || !reportNode.isArray() || reportNode.size() == 0) { |
|||
response.put("status", "nodata"); |
|||
response.put("data", Collections.emptyList()); |
|||
} else { |
|||
// Convert JSON array → List<Map<String, Object>> |
|||
List<Map<String, Object>> reportList = mapper.convertValue( |
|||
reportNode, |
|||
new TypeReference<List<Map<String, Object>>>() {} |
|||
); |
|||
|
|||
|
|||
// Declare dbMap outside conditional blocks |
|||
Map<String, Map<String, Object>> dbMap = new HashMap<>(); |
|||
List<Map<String, Object>> dbList = new ArrayList<>(); |
|||
/* |
|||
// Fetch DB data based on filters |
|||
if (zone.isEmpty() && ward.isEmpty()) { |
|||
dbList = scpservice.getZoneWiseReportData(); |
|||
dbMap = dbList.stream().collect(Collectors.toMap( |
|||
row -> String.valueOf(row.get("zone")), |
|||
row -> row |
|||
)); |
|||
} else if (ward.isEmpty() && !zone.isEmpty()) { |
|||
dbList = scpservice.getWardWiseReportData(zone); |
|||
dbMap = dbList.stream().collect(Collectors.toMap( |
|||
row -> String.valueOf(row.get("ward")), |
|||
row -> row |
|||
)); |
|||
} else if (!ward.isEmpty() && !zone.isEmpty()) { |
|||
dbList = scpservice.getStreetWiseReportData(zone, ward); |
|||
dbMap = dbList.stream().collect(Collectors.toMap( |
|||
row -> String.valueOf(row.get("streetid")), |
|||
row -> row |
|||
)); |
|||
} |
|||
*/ |
|||
// Fetch DB data based on filters |
|||
if (zone.isEmpty() && ward.isEmpty()) { |
|||
|
|||
dbList = scpservice.getZoneWiseReportData(); |
|||
|
|||
for (Map<String, Object> row : dbList) { |
|||
String key = String.valueOf(row.get("zone")); |
|||
dbMap.put(key, row); |
|||
} |
|||
|
|||
} else if (ward.isEmpty() && !zone.isEmpty()) { |
|||
|
|||
dbList = scpservice.getWardWiseReportData(zone); |
|||
|
|||
for (Map<String, Object> row : dbList) { |
|||
String key = String.valueOf(row.get("ward")); |
|||
dbMap.put(key, row); |
|||
} |
|||
|
|||
} else if (!ward.isEmpty() && !zone.isEmpty()) { |
|||
|
|||
dbList = scpservice.getStreetWiseReportData(zone, ward); |
|||
|
|||
for (Map<String, Object> row : dbList) { |
|||
String key = String.valueOf(row.get("streetid")); |
|||
dbMap.put(key, row); |
|||
} |
|||
} |
|||
|
|||
|
|||
// Merge API data with DB data |
|||
// Merge API data with DB data |
|||
for (int i = 0; i < reportList.size(); i++) { |
|||
Map<String, Object> apiRow = reportList.get(i); |
|||
String variableValue = String.valueOf(apiRow.get("VARIABLE")); |
|||
boolean isLast = (i == reportList.size() - 1); // check if it's the last element |
|||
|
|||
if (dbMap.containsKey(variableValue)) { |
|||
Map<String, Object> dbRow = dbMap.get(variableValue); |
|||
apiRow.put("Completed", dbRow.get("Completed")); |
|||
apiRow.put("Yes", dbRow.get("YesCount")); |
|||
apiRow.put("No", dbRow.get("NoCount")); |
|||
apiRow.put("Available", dbRow.get("AvailableCount")); |
|||
apiRow.put("Not Available", dbRow.get("NotAvailableCount")); |
|||
apiRow.put("Image Not Clear", dbRow.get("ImageNotClearCount")); |
|||
apiRow.put("LidGoodYesCount", dbRow.get("LidGoodYesCount")); |
|||
apiRow.put("LidGoodNoCount", dbRow.get("LidGoodNoCount")); |
|||
} else { |
|||
// If last list → use "-" |
|||
if (isLast) { |
|||
apiRow.put("Completed", "-"); |
|||
apiRow.put("Yes", "-"); |
|||
apiRow.put("No", "-"); |
|||
apiRow.put("Available", "-"); |
|||
apiRow.put("Not Available", "-"); |
|||
apiRow.put("Image Not Clear", "-"); |
|||
apiRow.put("LidGoodYesCount", "-"); |
|||
apiRow.put("LidGoodNoCount", "-"); |
|||
} else { |
|||
// For all others → use 0 |
|||
apiRow.put("Completed", 0); |
|||
apiRow.put("Yes", 0); |
|||
apiRow.put("No", 0); |
|||
apiRow.put("Available", 0); |
|||
apiRow.put("Not Available", 0); |
|||
apiRow.put("Image Not Clear", 0); |
|||
apiRow.put("LidGoodYesCount", 0); |
|||
apiRow.put("LidGoodNoCount", 0); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
response.put("status", "success"); |
|||
response.put("data", reportList); |
|||
if(zone.isEmpty() && ward.isEmpty()) { |
|||
response.put("table", "table1"); |
|||
} |
|||
else if(ward.isEmpty() && !zone.isEmpty()) { |
|||
response.put("table", "table2"); |
|||
} |
|||
else if(!ward.isEmpty() && !zone.isEmpty()) { |
|||
response.put("table", "table3"); |
|||
} |
|||
|
|||
} |
|||
} 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; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getdetailreportdata") |
|||
public Map<String, Object> getDetailreportdatabyfilters( |
|||
@RequestParam String startDate, |
|||
@RequestParam String endDate) { |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
List<Map<String,Object>> list=scpservice.getdetailreport(startDate,endDate); |
|||
|
|||
if(list.isEmpty()) { |
|||
response.put("status", "nodata"); |
|||
response.put("message", "No Data"); |
|||
} |
|||
else { |
|||
response.put("status", "success"); |
|||
response.put("data", list); |
|||
response.put("message", "Fetched Data Successfully"); |
|||
} |
|||
} |
|||
catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response.put("status", "error"); |
|||
response.put("message", e.getMessage()); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.QaqcAgentsService; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/callcenterqaqcscp") |
|||
@Controller("callCenterQaQcScpController") |
|||
public class ScpMaincontroller { |
|||
|
|||
@Autowired |
|||
private QaqcAgentsService agentsService; |
|||
|
|||
@GetMapping("/scpverification") |
|||
public String viewDomesticWastepage(Model model) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
return "modules/callcenterqaqc/scpverification"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/scpreport") |
|||
public String viewReportPage(Model model) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("userId",userId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
List<Map<String, Object>> agent=agentsService.getAgentName(userId); |
|||
model.addAttribute("agent", agent); |
|||
|
|||
return "modules/callcenterqaqc/scpreport"; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,464 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.io.InputStream; |
|||
import java.net.URL; |
|||
import java.net.URLConnection; |
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.text.SimpleDateFormat; |
|||
import java.time.LocalDate; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.time.format.DateTimeParseException; |
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.SocialMediaService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc/socialmedia") |
|||
@RestController |
|||
public class SocialMediaApiController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
public SocialMediaService socialservice; |
|||
|
|||
@Autowired |
|||
public SocialMediaApiController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@PostMapping("/update") |
|||
@ResponseBody |
|||
public ResponseEntity<String> updateCallDetails(@RequestParam("complaintNumber") String complaintNumber, |
|||
@RequestParam("userId") String userId,@RequestParam("action") String action,@RequestParam("remarks") String remarks, |
|||
@RequestParam(value = "remainderDate", required = false) String remainderDate |
|||
) { |
|||
try { |
|||
// System.out.println("Updating Complaint Number: " + complaintNumber); |
|||
// System.out.println("userId= " + userId); |
|||
// System.out.println("action= " + action); |
|||
// System.out.println("remarks="+remarks); |
|||
int updated_agent = Integer.parseInt(userId); |
|||
// System.out.println("remainderDate: " + remainderDate); |
|||
if(remarks.isEmpty()) |
|||
{ |
|||
remarks="N/A"; |
|||
} |
|||
|
|||
String erp_name=socialservice.getErpusernamebyId(userId); |
|||
// System.out.println("erp_name=="+erp_name); |
|||
if (erp_name.isEmpty()) { |
|||
return ResponseEntity.ok("erpname"); |
|||
} |
|||
|
|||
if ("COMPLETED".equals(action) || "REOPEN".equals(action)) |
|||
{ |
|||
boolean statusUpdated =ChangeStatusInErp(complaintNumber,action,remarks,erp_name); |
|||
//System.out.println("statusUpdated="+statusUpdated); |
|||
|
|||
if (!statusUpdated) |
|||
{ |
|||
return ResponseEntity.ok("error"); |
|||
} |
|||
} |
|||
|
|||
|
|||
Map<String, Object> details =getDetailsByComplaintNumber(complaintNumber); |
|||
int rowInserted=socialservice.uploadComplaintDetailsInLogs(details,action,remarks,updated_agent,remainderDate); |
|||
if(rowInserted!=1) |
|||
{ |
|||
return ResponseEntity.ok("save"); |
|||
} |
|||
return ResponseEntity.ok("Success"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error"); |
|||
} |
|||
} |
|||
|
|||
public Map<String, Object> getDetailsByComplaintNumber(String complaintNumber) { |
|||
|
|||
Map<String, Object> resultMap = new HashMap<>(); |
|||
|
|||
try { |
|||
String url = "https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=getComplaintByID&ComplaintId=" |
|||
+ complaintNumber + "&imgUrlonly=yes&isQcuser=Yes&jsonResp=Yes"; |
|||
//System.out.println("Request URL: " + url); |
|||
|
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); |
|||
|
|||
if (responseEntity.getStatusCode().is2xxSuccessful()) { |
|||
String responseBody = responseEntity.getBody(); |
|||
//System.out.println("Response Body: " + responseBody); |
|||
|
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JsonNode rootNode = mapper.readTree(responseBody); |
|||
|
|||
JsonNode complaintDetails = rootNode.path(0).path("ComplaintListHistory").path(0); |
|||
|
|||
String registerDate=complaintDetails.path("complaintopendate").asText("N/A"); |
|||
//System.out.println("registerdate====="+registerDate); |
|||
|
|||
String formattedDate = "N/A"; // Default value if parsing fails |
|||
|
|||
if (!registerDate.equals("N/A") && !registerDate.isEmpty()) { |
|||
try { |
|||
// Parse the input date string |
|||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); |
|||
Date date = inputFormat.parse(registerDate); |
|||
|
|||
// Format the date to dd-MM-yyyy |
|||
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy"); |
|||
formattedDate = outputFormat.format(date); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Log exception for debugging |
|||
} |
|||
} |
|||
|
|||
if (!complaintDetails.isMissingNode()) { |
|||
// Existing fields |
|||
resultMap.put("complaintid", complaintDetails.path("complaintid").asText("N/A")); |
|||
resultMap.put("complaintdate", formattedDate); |
|||
resultMap.put("complainantName", complaintDetails.path("CustomerName").asText("N/A")); |
|||
resultMap.put("mobileNumber", complaintDetails.path("CustomerMobile").asText("N/A")); |
|||
resultMap.put("complaintType", complaintDetails.path("complainttype").asText("N/A")); |
|||
resultMap.put("description", complaintDetails.path("complaintdetails").asText("N/A")); |
|||
resultMap.put("currentStatus", complaintDetails.path("complaintcurrentstatus").asText("N/A")); |
|||
resultMap.put("Street", complaintDetails.path("Street").asText("N/A")); |
|||
resultMap.put("Area", complaintDetails.path("Area").asText("N/A")); |
|||
resultMap.put("Landmark", complaintDetails.path("Landmark").asText("N/A")); |
|||
resultMap.put("Location", complaintDetails.path("Location").asText("N/A")); |
|||
resultMap.put("Zone", complaintDetails.path("Zone").asText("N/A")); |
|||
resultMap.put("Division", complaintDetails.path("Division").asText("N/A")); |
|||
resultMap.put("OfficialMobile", complaintDetails.path("OfficialMobile").asText("N/A")); |
|||
resultMap.put("gender", complaintDetails.path("GENDER").asText("N/A")); |
|||
resultMap.put("deptname",complaintDetails.path("DEPT_NAME").asText("N/A")); |
|||
resultMap.put("compmode", complaintDetails.path("COMP_MODE").asText("N/A")); |
|||
resultMap.put("Officialname", complaintDetails.path("Officialname").asText("N/A")); |
|||
|
|||
|
|||
} |
|||
} else { |
|||
resultMap.put("error", "Failed to retrieve complaint details."); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
resultMap.put("error", "Error processing request"); |
|||
} |
|||
|
|||
return resultMap; |
|||
} |
|||
|
|||
|
|||
public boolean ChangeStatusInErp(String complaintNumber,String action ,String remarks,String erp_name) { |
|||
String baseUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?"; |
|||
String status = ""; |
|||
|
|||
|
|||
//String Erpname ="QAops1"; |
|||
|
|||
try { |
|||
// Encode parameters |
|||
String encodedComplaintNumber = URLEncoder.encode(complaintNumber, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
String encodedRemarks = URLEncoder.encode(remarks, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
String encodedErpname = URLEncoder.encode(erp_name, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
|
|||
// Determine status based on action |
|||
if ("COMPLETED".equals(action)) { |
|||
status = "11"; |
|||
} else if ("REOPEN".equals(action)) { |
|||
status = "9"; |
|||
} else { |
|||
return false; // Invalid action, return false |
|||
} |
|||
|
|||
// Construct the URL |
|||
String urlString = baseUrl |
|||
+ "serviceId=UpdateComplaint" |
|||
+ "&ComplaintId=" + encodedComplaintNumber |
|||
+ "&Message=" + encodedRemarks |
|||
+ "&UserType=Official" |
|||
+ "&Status=" + status |
|||
+ "&Comp_Image=" |
|||
+ "&erp_username=" + encodedErpname; |
|||
|
|||
System.out.println("ERP Hitting URL="+urlString); |
|||
|
|||
// Send the request |
|||
return sendRequest(urlString); |
|||
// return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
|
|||
private boolean sendRequest(String urlString) { |
|||
try { |
|||
URL url = new URL(urlString); |
|||
URLConnection urlcon = url.openConnection(); |
|||
InputStream stream = urlcon.getInputStream(); |
|||
StringBuilder responseBuilder = new StringBuilder(); |
|||
int i; |
|||
while ((i = stream.read()) != -1) { |
|||
responseBuilder.append((char) i); |
|||
} |
|||
stream.close(); |
|||
|
|||
// Parse the response |
|||
String response = responseBuilder.toString(); |
|||
//System.out.println("Raw Response: " + response); |
|||
|
|||
// Check ResultStatus in the response |
|||
if (response.contains("\"ResultStatus\": true")) { |
|||
//System.out.println("ResultStatus is true in the response."); |
|||
return true; |
|||
} else { |
|||
System.out.println("ResultStatus is false or not present in the response."); |
|||
return false; |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getsocialmediacomps") |
|||
public Map<String, Object> viewSocialMediaData( |
|||
@RequestParam String startDate, |
|||
@RequestParam String endDate, |
|||
@RequestParam String status, |
|||
@RequestParam String group, |
|||
@RequestParam String type, |
|||
@RequestParam String zone, |
|||
@RequestParam String region) { |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
LocalDate fromLocalDate = LocalDate.parse(startDate, DateTimeFormatter.ISO_DATE); |
|||
LocalDate toLocalDate = LocalDate.parse(endDate, DateTimeFormatter.ISO_DATE); |
|||
String formattedFromDate = fromLocalDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")); |
|||
String formattedToDate = toLocalDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")); |
|||
|
|||
String mode="SOCIAL MEDIA"; |
|||
|
|||
String encoded_mode=URLEncoder.encode(mode, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
|
|||
//String url="https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=ms_dashboard_details&From_date="+formattedFromDate+"&To_date="+formattedToDate+"&jsonResp=Yes&Status="+status+"&isQcuser=Yes"+"&ComplaintType="+type+"&ComplaintGroupId="+group+"&compmode="+encoded_mode+"&Zoneid="+zone; |
|||
|
|||
//String url="https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=ms_dashboard_details&From_date="+formattedFromDate+"&To_date="+formattedToDate+"&jsonResp=Yes&Status="+status+"&isQcuser=Yes"+"&ComplaintType="+type+"&ComplaintGroupId="+group+"&compmode="+mode+"&Zoneid="+zone; |
|||
|
|||
String url="https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=ms_dashboard_details&From_date="+formattedFromDate+"&To_date="+formattedToDate+"&jsonResp=Yes&Status="+status+"&isQcuser=Yes"+"&ComplaintType="+type+"&ComplaintGroupId="+group+"&compmode="+mode+"&Zoneid="+zone+"&RegionId="+region; |
|||
|
|||
//System.out.println("url==="+url); |
|||
|
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
|
|||
// Fetch response as String |
|||
ResponseEntity<String> responses = restTemplate.getForEntity(url, String.class); |
|||
String rawResponse = responses.getBody(); |
|||
|
|||
// Preprocess response to remove invalid characters if needed |
|||
if (rawResponse != null) { |
|||
//rawResponse = rawResponse.replaceAll("\"\"", "\""); // Replace double-double quotes |
|||
//rawResponse = rawResponse.replaceAll("(?<![,{])\"R", "\"R"); // Example: Fix missing commas |
|||
} |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
Map<String, Object> responseMap = objectMapper.readValue(rawResponse, Map.class); |
|||
List<Map<String, Object>> details; |
|||
details = (List<Map<String, Object>>) responseMap.get("Details"); |
|||
//System.out.println("details="+details); |
|||
|
|||
|
|||
if (details != null) { |
|||
if(status.equals("redressed") || status.equals("closed")) { |
|||
|
|||
details=socialservice.getfiltreddetails(details); |
|||
} |
|||
} |
|||
|
|||
if (details == null) { |
|||
response.put("status", "nodata"); |
|||
response.put("message", "No Data, please change criteria"); |
|||
} |
|||
else { |
|||
response.put("status", "success"); |
|||
response.put("details", details); |
|||
} |
|||
|
|||
} |
|||
catch (Exception e) { |
|||
response.put("status", "error"); |
|||
response.put("message", "An error occurred while fetching data."); |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
@GetMapping("/socialmediacompletedlist") |
|||
public Map<String, Object> viewSocialMediaCompletedData( |
|||
@RequestParam String startDate, |
|||
@RequestParam String endDate, @RequestParam String status, |
|||
@RequestParam String zone) { |
|||
|
|||
//System.out.printf("==================="+startDate,endDate,zone); |
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
LocalDate fromLocalDate = LocalDate.parse(startDate, DateTimeFormatter.ISO_DATE); |
|||
LocalDate toLocalDate = LocalDate.parse(endDate, DateTimeFormatter.ISO_DATE); |
|||
String formattedFromDate = fromLocalDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
|||
String formattedToDate = toLocalDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
|||
|
|||
List<Map<String, Object>> details= socialservice.getdetails(formattedFromDate,formattedToDate,status,zone); |
|||
if(details==null) |
|||
{ |
|||
response.put("status", "nodata"); |
|||
response.put("message", "No data for Selected filter"); |
|||
} |
|||
else { |
|||
response.put("status", "success"); |
|||
response.put("details", details); |
|||
} |
|||
} |
|||
catch (DateTimeParseException e) { |
|||
response.put("status", "error"); |
|||
response.put("message", "Invalid date format. Please use 'yyyy-MM-dd'."); |
|||
e.printStackTrace(); |
|||
} |
|||
catch (Exception e) { |
|||
response.put("status", "error"); |
|||
response.put("message", "An error occurred while fetching data."); |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
@GetMapping("/getA1dropdowns") |
|||
public ResponseEntity<?> getA1dropdowns(){ |
|||
try { |
|||
List<Map<String, Object>> list = socialservice.getA1dropdowns(); |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
response.put("status", "success"); |
|||
response.put("data", list); |
|||
|
|||
return ResponseEntity.ok(response); |
|||
|
|||
} catch (Exception ex) { |
|||
ex.printStackTrace(); |
|||
|
|||
Map<String, Object> error = new HashMap<>(); |
|||
error.put("status", "error"); |
|||
error.put("message", ex.getMessage()); |
|||
|
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getA2dropdowns") |
|||
public ResponseEntity<?> getA2dropdowns(){ |
|||
try { |
|||
List<Map<String, Object>> list = socialservice.getA2dropdowns(); |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
response.put("status", "success"); |
|||
response.put("data", list); |
|||
|
|||
return ResponseEntity.ok(response); |
|||
|
|||
} catch (Exception ex) { |
|||
ex.printStackTrace(); |
|||
|
|||
Map<String, Object> error = new HashMap<>(); |
|||
error.put("status", "error"); |
|||
error.put("message", ex.getMessage()); |
|||
|
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/checkregisteredcomplaint") |
|||
public Map<String, Object> checkRegisteredComplaint( |
|||
@RequestParam String complaintNumber) { |
|||
|
|||
return socialservice.checkRegisteredComplaint(complaintNumber); |
|||
} |
|||
|
|||
@PostMapping("/submitRegClosingComplaint") |
|||
public Map<String, Object> submitRegClosingComplaint( |
|||
@RequestParam String complaintNumber, |
|||
@RequestParam String remarks, |
|||
@RequestParam MultipartFile resolvedImage, |
|||
@RequestParam String cby) { |
|||
|
|||
|
|||
return socialservice.submitRegClosingComplaint( |
|||
complaintNumber, |
|||
remarks, |
|||
resolvedImage, |
|||
cby); |
|||
} |
|||
|
|||
@GetMapping("/getfilteredregcomps") |
|||
public Map<String, Object> getFilteredRegComps() { |
|||
|
|||
return socialservice.getFilteredRegComps(); |
|||
} |
|||
|
|||
@PostMapping("/approveComplaint") |
|||
@ResponseBody |
|||
public Map<String, Object> approveComplaint( |
|||
@RequestParam String complaintId, |
|||
@RequestParam String remarks, |
|||
@RequestParam String imgFullPath, |
|||
@RequestParam String userid |
|||
) { |
|||
|
|||
|
|||
return socialservice.approveComplaint( |
|||
complaintId, |
|||
remarks, |
|||
imgFullPath, |
|||
userid); |
|||
} |
|||
|
|||
@PostMapping("/rejectComplaint") |
|||
public Map<String, Object> rejectComplaint( |
|||
@RequestParam String complaintId, |
|||
@RequestParam String userid |
|||
) { |
|||
|
|||
return socialservice.rejectComplaint( |
|||
complaintId, |
|||
userid); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.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; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/callcenterqaqcsocialmedia") |
|||
@Controller("callCenterQaQcSocialMediaController") |
|||
public class SocialMediaMainController { |
|||
|
|||
@GetMapping("/socialmediacomplaints") |
|||
public String viewSocialMediaComplaints(Model model) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("userId", userId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
return "modules/callcenterqaqc/socialmediacomplaints"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/smfinishedcomplaints") |
|||
public String viewSocialMediaCompletedComplaints(Model model) { |
|||
String loginUserId = LoginUserInfo.getLoginUserId(); |
|||
int userId = Integer.parseInt(loginUserId); |
|||
|
|||
model.addAttribute("LoginUserId", loginUserId); |
|||
model.addAttribute("userId", userId); |
|||
model.addAttribute("agent_name", LoginUserInfo.getCurrentUserDetails().getUsername()); |
|||
model.addAttribute("UserRole", LoginUserInfo.getUserRole()); |
|||
|
|||
return "modules/callcenterqaqc/socialmediacompletedlist"; |
|||
} |
|||
|
|||
@GetMapping("/regcompclosing") |
|||
public String viewregCompClosing(Model model) { |
|||
|
|||
String userId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("userId", userId); |
|||
|
|||
return "modules/callcenterqaqc/socialmediaregcompclosing"; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,82 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.ResponseEntity; |
|||
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 in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.StatusCountService; |
|||
|
|||
@RequestMapping("gcc/api/callcenterqaqc") |
|||
@RestController |
|||
public class StatusCountController { |
|||
|
|||
@Autowired |
|||
private StatusCountService statusCountService; |
|||
|
|||
|
|||
@Autowired |
|||
public StatusCountController(StatusCountService statusCountService) { |
|||
this.statusCountService = statusCountService; |
|||
} |
|||
|
|||
@GetMapping("/dashboard") |
|||
public ResponseEntity<Map<String, Object>> getDashboardData( |
|||
@RequestParam(value = "startDate", required = false, defaultValue = "") String fromDate, |
|||
@RequestParam(value = "endDate", required = false, defaultValue = "") String toDate, |
|||
@RequestParam(value = "dropdown1", required = false, defaultValue = "") String compType, |
|||
@RequestParam(value = "dropdown2", required = false, defaultValue = "") String zoneName, |
|||
@RequestParam(value = "dropdown3", required = false,defaultValue = "") String compMode, |
|||
@RequestParam(value = "dropdown4", required = false, defaultValue = "") String compGroup, |
|||
@RequestParam(value = "regiondropdown", required = false, defaultValue = "") String region) { |
|||
|
|||
|
|||
Map<String, Object> counts = statusCountService.fetchComplaintCounts(fromDate, toDate, compType, zoneName, compMode, compGroup,region); |
|||
//System.out.println("counts:" + counts); |
|||
//System.out.println("group:" + compGroup); |
|||
return ResponseEntity.ok(counts); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getComplaintTypesByGroup") |
|||
public ResponseEntity<List<String>> getComplaintTypesByGroup(@RequestParam String group) { |
|||
List<String> complaintTypes = statusCountService.fetchComplaintTypes(group); |
|||
return ResponseEntity.ok(complaintTypes); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getComplaintGroup") |
|||
public ResponseEntity<List<String>> getComplaintGroup() { |
|||
List<String> complaintGroup= statusCountService.fetchComplaintGroup(); |
|||
//System.out.println("types:"+complaintTypes); |
|||
return ResponseEntity.ok(complaintGroup); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getModes") |
|||
public ResponseEntity<List<String>> getModes() { |
|||
List<String> modes= statusCountService.fetchModes(); |
|||
//System.out.println("types:"+modes); |
|||
return ResponseEntity.ok(modes); |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getZones") |
|||
public ResponseEntity<List<String>> getZones() { |
|||
List<String> zones= statusCountService.fetchZones(); |
|||
//System.out.println("types:"+zones); |
|||
return ResponseEntity.ok(zones); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,147 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.controller; |
|||
|
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
|
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.callcenterqaqc.service.WhatsappqaqcMsgService; |
|||
|
|||
@RestController("callcenterqaqcwhatsapp") |
|||
@RequestMapping("/gcc/api/qaqc/whatsapp") |
|||
public class WhatsappController { |
|||
|
|||
@Autowired |
|||
private WhatsappqaqcMsgService whatsappqaqcMsgService; |
|||
|
|||
@PostMapping("/send-whatsapp-message") |
|||
public ResponseEntity<String> sendWhatsAppMessage(@RequestParam String msgUrl,@RequestParam String tamilmsgUrl) { |
|||
String response = whatsappqaqcMsgService.sendMsg(msgUrl,tamilmsgUrl); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
@GetMapping("/checkforwhatsappmsg") |
|||
public boolean checkforwhatsappmsg( |
|||
@RequestParam String complaintNumber, |
|||
@RequestParam String action, |
|||
@RequestParam String complaintTypeName, |
|||
@RequestParam String mobnumber, |
|||
@RequestParam String pname) { |
|||
|
|||
Map<String, Object> ismsg = |
|||
whatsappqaqcMsgService.checkforwhatsappmsg( |
|||
complaintNumber, |
|||
action); |
|||
|
|||
String returnedAction = |
|||
String.valueOf(ismsg.get("action")); |
|||
|
|||
boolean status = |
|||
Boolean.TRUE.equals(ismsg.get("status")); |
|||
|
|||
System.out.println("Action = " + returnedAction); |
|||
System.out.println("Status = " + status); |
|||
|
|||
if (status) { |
|||
|
|||
String result = sendWhatsappMsg(pname, complaintTypeName, mobnumber, complaintNumber,returnedAction); |
|||
if(result.equals("200")) { |
|||
System.out.println("Whatsapp Message Triggered for "+complaintNumber); |
|||
return true; |
|||
} |
|||
else { |
|||
System.out.println("Whatsapp Message Failed for "+complaintNumber); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
private String sendWhatsappMsg(String pname,String cat,String mob_no, String complaintNumber,String returnedAction) { |
|||
String urlString = ""; |
|||
|
|||
try { |
|||
|
|||
|
|||
if("COMPLETED".equalsIgnoreCase(returnedAction)) { |
|||
|
|||
} |
|||
|
|||
if("UNATTENDED".equalsIgnoreCase(returnedAction)) { |
|||
|
|||
} |
|||
|
|||
String placeholders = |
|||
URLEncoder.encode( |
|||
pname + "|~|" + cat + "|~|" + complaintNumber, |
|||
StandardCharsets.UTF_8.toString()); |
|||
|
|||
String buttonPlaceholder = |
|||
URLEncoder.encode( |
|||
complaintNumber, |
|||
StandardCharsets.UTF_8.toString()); |
|||
|
|||
String mobile = |
|||
URLEncoder.encode( |
|||
mob_no, |
|||
StandardCharsets.UTF_8.toString()); |
|||
|
|||
|
|||
urlString=""; |
|||
|
|||
String res = hitURL(urlString); |
|||
return res; |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ""; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
private String hitURL(String urlString) { |
|||
String response = ""; |
|||
try { |
|||
URL url = new URL(urlString); |
|||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
|||
connection.setRequestMethod("GET"); |
|||
|
|||
int responseCode = connection.getResponseCode(); |
|||
response = String.valueOf(responseCode); |
|||
//System.out.println("Response Code for URL: " + urlString + " is " + responseCode); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
System.out.println("response=" + response); |
|||
return response; |
|||
} |
|||
|
|||
@GetMapping("/getclosefromuser") |
|||
public String getclosefromuser(@RequestParam String complaintNumber) { |
|||
|
|||
return whatsappqaqcMsgService.getclosefromuser(complaintNumber); |
|||
|
|||
} |
|||
|
|||
@GetMapping("/getreopenfromuser") |
|||
public String getreopenfromuser(@RequestParam String complaintNumber) { |
|||
|
|||
return whatsappqaqcMsgService.getreopenfromuser(complaintNumber); |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,95 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Random; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import org.apache.naming.java.javaURLContextFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
@Service |
|||
public class ComplaintService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
private final String baseUrl = "https://erp.chennaicorporation.gov.in/pgr/newmobileservice"; |
|||
|
|||
public String fetchComplaintCategories() { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String url = baseUrl + "?serviceId=getComplCategory&ComplaintGroupId=null"; |
|||
return restTemplate.getForObject(url, String.class); |
|||
} |
|||
|
|||
public String fetchComplaintSubTypes(String groupId) { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String url = baseUrl + "?serviceId=getComplCategory&ComplaintGroupId=" + groupId; |
|||
return restTemplate.getForObject(url, String.class); |
|||
} |
|||
|
|||
public List<Map<String, Object>> fetchComplaintDetailsById(String complaintId) { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String url = baseUrl + "?serviceId=getComplaintByID&ComplaintId=" + complaintId; |
|||
String response = restTemplate.getForObject(url, String.class); |
|||
|
|||
try { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
return objectMapper.readValue(response, new TypeReference<List<Map<String, Object>>>() { |
|||
}); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public List<Map<String, Object>> fetchComplaintDetailsByMobile(String mobileNo) { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String url = baseUrl |
|||
+ "?serviceId=getComplaintListWithImg&From_date=01/01/2024&To_date=20/08/2024&jsonResp=Yes&UserType=Public&MobileNo=" |
|||
+ mobileNo + "&PageIndex=null&Status=null&repYear=2024"; |
|||
String response = restTemplate.getForObject(url, String.class); |
|||
|
|||
try { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
return objectMapper.readValue(response, new TypeReference<List<Map<String, Object>>>() { |
|||
}); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public int saveInLogs(String mobileNo, String complaintNo,String userId) { |
|||
|
|||
int agent_id; |
|||
try { |
|||
agent_id = Integer.parseInt(userId); |
|||
} catch (NumberFormatException e) { |
|||
return 0; |
|||
} |
|||
|
|||
String sql = "INSERT INTO pgr_complaint_reg (user_mobile_num, complaint_number, agent_id) VALUES (?, ?, ?)"; |
|||
return jdbcTemplate.update(sql, mobileNo, complaintNo, agent_id); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,308 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.sql.PreparedStatement; |
|||
import java.sql.Statement; |
|||
import java.time.LocalDate; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.ArrayList; |
|||
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.beans.factory.annotation.Value; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.support.GeneratedKeyHolder; |
|||
import org.springframework.jdbc.support.KeyHolder; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
|
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
@Service |
|||
public class DomesticWasteService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Value("${fileBaseUrl}") |
|||
private String fileBaseUrl; |
|||
|
|||
@Autowired |
|||
public void setDatasource(@Qualifier("mysqlDomesticWasteDataSource") DataSource datasource) { |
|||
this.jdbcTemplate=new JdbcTemplate(datasource); |
|||
} |
|||
|
|||
|
|||
|
|||
public Map<String, Object> saveMultipleWasteRequests(String user_name, String mobile, String address, |
|||
String latitude, String longitude, |
|||
String street_name, String street_id, String remarks, |
|||
String itemsJson,String userId,String zone, String ward) { |
|||
|
|||
|
|||
int agent_id=Integer.parseInt(userId); |
|||
int is_app=3; |
|||
String remarks1; |
|||
if (remarks == null || remarks.trim().isEmpty()) { |
|||
remarks1 = "-"; |
|||
} else { |
|||
remarks1 = remarks; |
|||
} |
|||
|
|||
try { |
|||
|
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
List<Map<String, Object>> items = objectMapper.readValue(itemsJson, new TypeReference<>() {}); |
|||
|
|||
String sofaSize = null; // declare before lambda |
|||
for (Map<String, Object> item : items) { |
|||
if ("2".equals(item.get("item_id").toString())) { // Sofa id = 2 |
|||
Object sizeObj = item.get("sofa_size"); // match your JS payload key |
|||
if (sizeObj != null && !sizeObj.toString().isEmpty()) { |
|||
sofaSize = sizeObj.toString(); |
|||
} |
|||
break; // found sofa, no need to loop further |
|||
} |
|||
} |
|||
|
|||
final String finalSofaSize = sofaSize; |
|||
|
|||
|
|||
// Step 1: Insert main request (one time) |
|||
String insertMainSql = "INSERT INTO user_request_table " + |
|||
"(request_id, user_name, mobile, address, latitude, longitude, street_name, street_id, remarks,agent_id,is_app,zone,division,sofa_type) " + |
|||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?)"; |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
jdbcTemplate.update(con -> { |
|||
PreparedStatement ps = con.prepareStatement(insertMainSql, Statement.RETURN_GENERATED_KEYS); |
|||
ps.setString(1, "TEMP"); // placeholder |
|||
ps.setString(2, user_name); |
|||
ps.setString(3, mobile); |
|||
ps.setString(4, address); |
|||
ps.setString(5, latitude); |
|||
ps.setString(6, longitude); |
|||
ps.setString(7, street_name); |
|||
ps.setString(8, street_id); |
|||
ps.setString(9, remarks1); |
|||
ps.setInt(10, agent_id); |
|||
ps.setInt(11, is_app); |
|||
ps.setString(12, zone); |
|||
ps.setString(13, ward); |
|||
ps.setString(14, finalSofaSize); |
|||
return ps; |
|||
}, keyHolder); |
|||
|
|||
int generatedId = keyHolder.getKey().intValue(); |
|||
String requestId = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + generatedId; |
|||
|
|||
// Update request_id in user_request_table |
|||
jdbcTemplate.update("UPDATE user_request_table SET request_id = ? WHERE id = ?", requestId, generatedId); |
|||
|
|||
|
|||
String insertItemSql = "INSERT INTO items (iteam_id, quantity, req_table_id, requedt_id) VALUES (?, ?, ?, ?)"; |
|||
|
|||
for (Map<String, Object> item : items) { |
|||
Object itemIdObj = item.get("item_id"); |
|||
Object quantityObj = item.get("quantity"); |
|||
|
|||
if (itemIdObj == null || quantityObj == null) { |
|||
continue; |
|||
} |
|||
|
|||
int itemId = Integer.parseInt(itemIdObj.toString()); |
|||
int quantity = Integer.parseInt(quantityObj.toString()); |
|||
|
|||
jdbcTemplate.update(insertItemSql, itemId, quantity, generatedId, requestId); |
|||
} |
|||
|
|||
return Map.of("status", true,"message", "Request saved successfully","requestId", requestId); |
|||
|
|||
} |
|||
catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return Map.of("status", false, "message", "Error: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getAllComplaintsList(String startDate, String endDate, String mobile, String requestId) { |
|||
StringBuilder sql = new StringBuilder( |
|||
"SELECT u.*, sm.status_master AS status_name, DATE(u.cdate) AS created_date " + |
|||
"FROM user_request_table u " + |
|||
"JOIN status_master sm ON sm.id = u.status_id " + |
|||
"WHERE u.is_active = 1 AND u.is_delete = 0 AND sm.is_active = 1 AND sm.is_delete = 0 " |
|||
); |
|||
|
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
if (startDate != null && !startDate.isEmpty() && endDate != null && !endDate.isEmpty()) { |
|||
sql.append(" AND DATE(u.cdate) BETWEEN ? AND ? "); |
|||
params.add(startDate); |
|||
params.add(endDate); |
|||
} |
|||
|
|||
if (mobile != null && !mobile.isEmpty()) { |
|||
sql.append(" AND u.mobile = ? "); |
|||
params.add(mobile); |
|||
} |
|||
|
|||
if (requestId != null && !requestId.isEmpty()) { |
|||
sql.append(" AND u.request_id = ? "); |
|||
params.add(requestId); |
|||
} |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
|
|||
for (Map<String, Object> complaint : result) { |
|||
Number reqTableId = (Number) complaint.get("id"); |
|||
List<Map<String, Object>> itemList = getItemsByRequestId(reqTableId.intValue()); |
|||
complaint.put("items", itemList); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getpendingcomplaints(String startDate, String endDate, String mobile) { |
|||
|
|||
StringBuilder sql = new StringBuilder("SELECT u.*, sm.status_master AS status_name, DATE(u.cdate) AS created_date" |
|||
+ " FROM user_request_table u " |
|||
+ " JOIN status_master sm ON sm.id = u.status" |
|||
+ " WHERE u.is_active = 1 AND u.is_delete = 0 AND u.status IN (1,3) " |
|||
); |
|||
|
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
if (startDate != null && !startDate.isEmpty() && endDate != null && !endDate.isEmpty()) { |
|||
sql.append(" AND DATE(u.cdate) BETWEEN ? AND ? "); |
|||
params.add(startDate); |
|||
params.add(endDate); |
|||
} |
|||
|
|||
if (mobile != null && !mobile.isEmpty()) { |
|||
sql.append(" AND u.mobile = ? "); |
|||
params.add(mobile); |
|||
} |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
|
|||
for (Map<String, Object> complaint : result) { |
|||
Number reqTableId = (Number) complaint.get("id"); |
|||
List<Map<String, Object>> itemList = getItemsByRequestId(reqTableId.intValue()); |
|||
complaint.put("items", itemList); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
public List<Map<String, Object>> getItemsByRequestId(int reqTableId) { |
|||
String itemSql = "SELECT i.iteam_id, im.item_name, i.quantity " + |
|||
"FROM items i " + |
|||
"LEFT JOIN item_master im ON i.iteam_id = im.id " + |
|||
"WHERE i.is_active = 1 AND i.is_delete = 0 AND i.req_table_id = ?"; |
|||
return jdbcTemplate.queryForList(itemSql, reqTableId); |
|||
} |
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getDetailsByReqId(String requestId) { |
|||
|
|||
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, " + |
|||
"u.is_active, u.is_delete, u.street_id, sm.status_master AS status, u.is_app, " + |
|||
"DATE_FORMAT(u.close_date, '%d-%m-%Y') AS close_date, " + |
|||
"CONCAT('" + fileBaseUrl + "/gccofficialapp/files', u.officer_upload_url) AS officer_upload_url, " + |
|||
"itm.iteam_id, itm.quantity, im.item_name " + |
|||
"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.request_id = ? AND u.is_active = 1"; |
|||
|
|||
List<Map<String, Object>> rawList = jdbcTemplate.queryForList(sql, requestId); |
|||
|
|||
Map<Integer, Map<String, Object>> groupedMap = new LinkedHashMap<>(); |
|||
|
|||
for (Map<String, Object> row : rawList) { |
|||
Integer id = (Integer) row.get("id"); |
|||
|
|||
Map<String, Object> 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<Map<String, Object>>) groupedMap.get(id).get("items")).add(item); |
|||
} |
|||
} else { |
|||
Map<String, Object> 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<Map<String, Object>> items = new ArrayList<>(); |
|||
if (item != null) { |
|||
items.add(item); |
|||
} |
|||
newEntry.put("items", items); |
|||
|
|||
groupedMap.put(id, newEntry); |
|||
} |
|||
} |
|||
|
|||
return new ArrayList<>(groupedMap.values()); |
|||
} |
|||
|
|||
|
|||
|
|||
public boolean changeStatus(String requestId, String remarks, String userId) { |
|||
String sql = "UPDATE user_request_table " + |
|||
"SET status = 5, " + |
|||
"officer_remark = ?, " + |
|||
"cancelled_by = ?, " + |
|||
"rejecttype = 'Without Location', " + |
|||
"reject_latitude = 0.0, " + |
|||
"reject_longitude = 0.0 " + |
|||
"WHERE request_id = ?"; |
|||
|
|||
int result = jdbcTemplate.update(sql, remarks, userId, requestId); |
|||
return result > 0; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,224 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
@Service |
|||
public class FollowUpService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getFollowUpCalls(int agent_id) { |
|||
String query = "SELECT data_id, complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber, " + |
|||
"complaint_type, official_name, official_mobilenum, call_category, complaint_mode, department " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE call_category = 'OFFICIALFOLLOWUP' AND agent_id = ? AND is_processed = FALSE"; |
|||
|
|||
return jdbcTemplate.queryForList(query, agent_id); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getFollowUpCatergory() |
|||
{ |
|||
String query = "SELECT call_status " + |
|||
"FROM gcc_1913_qaqc.call_status WHERE call_category_id = 2 and isactive='1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query); |
|||
} |
|||
|
|||
//public List<Map<String, Object>> getAgentCallStatus(int agentId) { |
|||
// |
|||
// String query = "SELECT " + |
|||
// " (SELECT SUM(aa.data_count) " + |
|||
// " FROM agent_assigned aa " + |
|||
// " WHERE aa.agent_id = ?) AS total_data_count, " + |
|||
// " COUNT(CASE WHEN cl.call_status = 'COMPLETED' THEN 1 END) AS completed_count, " + |
|||
// " COUNT(CASE WHEN cl.call_status != 'COMPLETED' THEN 1 END) AS pending_count " + |
|||
// "FROM " + |
|||
// " qaqc_call_logs cl " + |
|||
// "WHERE " + |
|||
// " cl.agent_id = ?"; |
|||
// return jdbcTemplate.queryForList(query,agentId); |
|||
// |
|||
// } |
|||
|
|||
public void updateFollowupComplaintDetails(String complaintNumber,int dataId, String action, String remarks,int updated_agent) |
|||
{ |
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_upload_data " + |
|||
"SET call_status = ?, " + " remarks = ?, updated_agent=?," + |
|||
" updated_date = CURRENT_TIMESTAMP, " + " is_processed = TRUE " + |
|||
"WHERE data_id = ? " +" AND complaint_number = ? "; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks,updated_agent, dataId,complaintNumber); |
|||
|
|||
//System.out.println("Rows Updated in upload data: " + rowsUpdated); |
|||
} |
|||
|
|||
@Transactional |
|||
public int uploadComplaintDetailsInLogs(Map<String, Object> logDetails, String action, String complaintNumber, String remainderDate) { |
|||
//System.out.println("Complaint Details: " + logDetails); |
|||
// Extract other field values from complaintDetails |
|||
int qaqcid = (int) logDetails.get("qaqc_id"); |
|||
String ccategory = logDetails.get("call_category").toString(); |
|||
String personName = logDetails.get("complaint_person_name").toString(); |
|||
String personMobNo = logDetails.get("complaint_mobilenumber").toString(); |
|||
String complaintDate = logDetails.get("complaint_date").toString(); |
|||
String cType = logDetails.get("complaint_type").toString(); |
|||
String cMode = logDetails.get("complaint_mode").toString(); |
|||
String department = logDetails.get("department").toString(); |
|||
String cGroup = logDetails.get("complaint_group").toString(); |
|||
String officialName = logDetails.get("official_name").toString(); |
|||
String officialMobileNum = logDetails.get("official_mobilenum").toString(); |
|||
String callStatus = logDetails.get("call_status").toString(); |
|||
String remarks = logDetails.get("remarks").toString(); |
|||
int agentId = (int) logDetails.get("agent_id"); |
|||
int updated_agent=(int)logDetails.get("updated_agent"); |
|||
boolean isProcessed = (boolean)logDetails.get("is_processed"); |
|||
LocalDateTime currentDate = LocalDateTime.now(); |
|||
|
|||
// Determine which table to insert into based on the action |
|||
if (action.equals("FOLLOWUP")) { |
|||
|
|||
|
|||
String query ="INSERT INTO gcc_1913_qaqc.qaqc_followup_call_logs (qaqc_id, call_category, agent_id, complaint_number, complaint_date,complaint_person_name, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name,remainder_date, official_mobilenum, call_status, remarks,updated_agent) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)"; |
|||
|
|||
|
|||
int rowsAffected = jdbcTemplate.update(query, qaqcid, ccategory, agentId, complaintNumber, complaintDate,personName, |
|||
personMobNo, cType, cMode, department, cGroup, officialName,remainderDate, officialMobileNum, callStatus, remarks, |
|||
updated_agent); |
|||
//System.out.println("Rows Updated in qaqc_followup_call_logs : " + rowsAffected); |
|||
} |
|||
|
|||
String query1 = "INSERT INTO gcc_1913_qaqc.qaqc_call_logs (qaqc_id, call_category, agent_id, complaint_number,complaint_date, complaint_person_name, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, call_status, remarks, is_processed,updated_agent) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)"; |
|||
|
|||
int rowsAffected1 = jdbcTemplate.update(query1, qaqcid, ccategory, agentId, complaintNumber,complaintDate, personName, |
|||
personMobNo, cType, cMode, department, cGroup, officialName, officialMobileNum, callStatus, remarks, |
|||
isProcessed,updated_agent); |
|||
|
|||
//System.out.println("Rows Updated in qaqc_call_logs: " + rowsAffected1); |
|||
|
|||
return rowsAffected1; |
|||
|
|||
} |
|||
|
|||
/* |
|||
@Transactional |
|||
public int uploadComplaintDetailsInLogs(Map<String, Object> logDetails, String action, String complaintNumber, String remainderDate) { |
|||
//System.out.println("Complaint Details: " + logDetails); |
|||
// Extract other field values from complaintDetails |
|||
int qaqcid = (int) logDetails.get("qaqc_id"); |
|||
String ccategory = logDetails.get("call_category").toString(); |
|||
String personName = logDetails.get("complaint_person_name").toString(); |
|||
String personMobNo = logDetails.get("complaint_mobilenumber").toString(); |
|||
String complaintDate = logDetails.get("complaint_date").toString(); |
|||
String cType = logDetails.get("complaint_type").toString(); |
|||
String cMode = logDetails.get("complaint_mode").toString(); |
|||
String department = logDetails.get("department").toString(); |
|||
String cGroup = logDetails.get("complaint_group").toString(); |
|||
String officialName = logDetails.get("official_name").toString(); |
|||
String officialMobileNum = logDetails.get("official_mobilenum").toString(); |
|||
String callStatus = logDetails.get("call_status").toString(); |
|||
String remarks = logDetails.get("remarks").toString(); |
|||
int agentId = (int) logDetails.get("agent_id"); |
|||
int updated_agent=(int)logDetails.get("updated_agent"); |
|||
boolean isProcessed = (boolean)logDetails.get("is_processed"); |
|||
LocalDateTime currentDate = LocalDateTime.now(); |
|||
|
|||
// Determine which table to insert into based on the action |
|||
if (action.equals("FOLLOWUP")) { |
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_followup_call_logs " |
|||
+ "SET qaqc_id = ?, call_category = ?, agent_id = ?, remainder_date = ?, call_status = ?, remarks = ?, updated_agent = ?, updated_date = CURRENT_TIMESTAMP " |
|||
+ "WHERE complaint_number = ? " |
|||
+ "AND id = (SELECT max_id FROM (SELECT MAX(id) AS max_id FROM gcc_1913_qaqc.qaqc_followup_call_logs WHERE complaint_number = ?) AS temp)"; |
|||
|
|||
int rowsAffected = jdbcTemplate.update(query,qaqcid, ccategory,agentId,remainderDate, callStatus, remarks,updated_agent,complaintNumber,complaintNumber); |
|||
//System.out.println("Rows Updated in qaqc_followup_call_logs : " + rowsAffected); |
|||
|
|||
|
|||
String query1 = "INSERT INTO gcc_1913_qaqc.qaqc_call_logs (qaqc_id, call_category, agent_id, complaint_number, complaint_date,complaint_person_name, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name,remainder_date, official_mobilenum, call_status, remarks, is_processed,updated_agent) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?)"; |
|||
|
|||
int rowsAffected1 = jdbcTemplate.update(query1, qaqcid, ccategory, agentId, complaintNumber, complaintDate,personName, |
|||
personMobNo, cType, cMode, department, cGroup, officialName,remainderDate, officialMobileNum, callStatus, remarks, |
|||
isProcessed,updated_agent); |
|||
//System.out.println("Rows Updated in qaqc_call_logs : " + rowsAffected1); |
|||
|
|||
return rowsAffected + rowsAffected1; |
|||
|
|||
} else { |
|||
|
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_followup_call_logs " |
|||
+ "SET qaqc_id = ?, call_category = ?, agent_id = ?, call_status = ?, remarks = ?, updated_agent = ?, updated_date = CURRENT_TIMESTAMP " |
|||
+ "WHERE complaint_number = ? " |
|||
+ "AND id = (SELECT max_id FROM (SELECT MAX(id) AS max_id FROM gcc_1913_qaqc.qaqc_followup_call_logs WHERE complaint_number = ?) AS temp)"; |
|||
|
|||
int rowsAffected = jdbcTemplate.update(query,qaqcid, ccategory,agentId, callStatus, remarks,updated_agent,complaintNumber,complaintNumber); |
|||
//System.out.println("Rows Updated in qaqc_followup_call_logs : " + rowsAffected); |
|||
|
|||
String query1 = "INSERT INTO gcc_1913_qaqc.qaqc_call_logs (qaqc_id, call_category, agent_id, complaint_number,complaint_date, complaint_person_name, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, call_status, remarks, is_processed,updated_agent) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)"; |
|||
|
|||
int rowsAffected1 = jdbcTemplate.update(query1, qaqcid, ccategory, agentId, complaintNumber,complaintDate, personName, |
|||
personMobNo, cType, cMode, department, cGroup, officialName, officialMobileNum, callStatus, remarks, |
|||
isProcessed,updated_agent); |
|||
|
|||
//System.out.println("Rows Updated in qaqc_call_logs: " + rowsAffected1); |
|||
|
|||
return rowsAffected + rowsAffected1; |
|||
} |
|||
} |
|||
*/ |
|||
|
|||
public List<Map<String, Object>> getCallHistory(String complaintNumber) |
|||
{ |
|||
String query = "SELECT complaint_number, agent_id, remainder_date, remarks, created_date " + |
|||
"FROM gcc_1913_qaqc.qaqc_call_logs " + |
|||
"WHERE complaint_number = ? and call_status='FOLLOWUP'"; |
|||
return jdbcTemplate.queryForList(query, complaintNumber); |
|||
|
|||
} |
|||
|
|||
public List<Map<String, Object>> getFollowupSubmitDetails(int userId) { |
|||
|
|||
String query = "SELECT complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber,official_name,official_mobilenum, " + |
|||
"complaint_type, call_status, remarks " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE call_category = 'OFFICIALFOLLOWUP' AND agent_id = ? AND is_processed = '1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query,userId); |
|||
|
|||
} |
|||
|
|||
public void updateComplaintHistoryDetails(String complaintNumber, int dataId, String action, String remarks,int updated_agent, |
|||
String remainderDate) { |
|||
|
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_upload_data_history \r\n" |
|||
+ "SET call_status = ?, remarks = ?, updated_date = CURRENT_TIMESTAMP, remainder_date = ?,updated_agent=?\r\n" |
|||
+ "WHERE data_id = ? AND complaint_number = ?"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks, remainderDate, updated_agent,dataId, complaintNumber); |
|||
|
|||
//System.out.println("Rows Updated in upload history: " + rowsUpdated); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,102 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
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 java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
@Service |
|||
public class InprogresscallService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getActionsCatergory() |
|||
{ |
|||
String query = "SELECT call_status " + |
|||
"FROM gcc_1913_qaqc.call_status WHERE call_category_id = 3 and isactive='1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query); |
|||
} |
|||
|
|||
// public List<Map<String, Object>> getInProgressCalls(int agent_id) { |
|||
// String sql = "SELECT complaint_number, " + |
|||
// " official_name , " + |
|||
// " official_mobilenum , " + |
|||
// " complaint_type, " + |
|||
// " call_category, " + |
|||
// " complaint_mode, " + |
|||
// " department " + |
|||
// |
|||
// "FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
// "WHERE call_category ='inprogress' and agent_id= ?"; |
|||
// |
|||
// |
|||
// return jdbcTemplate.queryForList(sql, agent_id); |
|||
// } |
|||
|
|||
public List<Map<String, Object>> getInProgressCalls(int agent_id) { |
|||
String query = "SELECT data_id, complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber, " + |
|||
"complaint_type, official_name, official_mobilenum, call_category, complaint_mode, department " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE (call_category = 'PROCESSING' OR call_category = 'REOPENED' OR call_category = 'REDRESSED' OR call_category = 'INPROGRESS') " + |
|||
" AND is_processed = FALSE " + |
|||
" AND agent_id = ?"; |
|||
return jdbcTemplate.queryForList(query, agent_id); |
|||
} |
|||
|
|||
public void updateInprogressComplaintDetails(String complaintNumber,int dataId, String action, String remarks,int updated_agent) |
|||
{ |
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_upload_data " + |
|||
"SET call_status = ?, " + " remarks = ?,updated_agent=?, " + |
|||
" updated_date = CURRENT_TIMESTAMP, " + " is_processed = TRUE " + |
|||
"WHERE data_id = ? " +" AND complaint_number = ?"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks,updated_agent, dataId,complaintNumber); |
|||
|
|||
//System.out.println("Rows Updated in upload data: " + rowsUpdated); |
|||
} |
|||
|
|||
public void saveMobileNumDetails(String complaintNumber, String remarks) { |
|||
String query = "insert into officer_mobileno (complaint_number,remarks) values(?,?)"; |
|||
int rowsUpdated = jdbcTemplate.update(query, complaintNumber, remarks); |
|||
//System.out.println("Rows Updated: " + rowsUpdated); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getInprogressSubmitDetails(int userId) { |
|||
|
|||
String query = "SELECT complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber,official_name,official_mobilenum, " + |
|||
"complaint_type, call_status, remarks " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE (call_category = 'PROCESSING' OR call_category = 'REOPENED' OR call_category = 'REDRESSED' OR call_category = 'INPROGRESS') AND agent_id = ? AND is_processed = '1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query,userId); |
|||
|
|||
} |
|||
|
|||
|
|||
public void updateComplaintHistoryDetails(String complaintNumber, int dataId, String action, String remarks,int updated_agent, |
|||
String remainderDate) { |
|||
|
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_upload_data_history \r\n" |
|||
+ "SET call_status = ?, remarks = ?, updated_date = CURRENT_TIMESTAMP, remainder_date = ?,updated_agent=?\r\n" |
|||
+ "WHERE data_id = ? AND complaint_number = ?"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks, remainderDate,updated_agent, dataId, complaintNumber); |
|||
|
|||
//System.out.println("Rows Updated in upload data history: " + rowsUpdated); |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.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 PublicFollowUpService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getFollowUpCalls(int agent_id) { |
|||
String query = "SELECT data_id, complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber, " + |
|||
"complaint_type, official_name, official_mobilenum, call_category, complaint_mode, department " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE call_category = 'PUBLICFOLLOWUP' AND agent_id = ? AND is_processed = FALSE"; |
|||
|
|||
return jdbcTemplate.queryForList(query, agent_id); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getFollowUpCatergory() |
|||
{ |
|||
String query = "SELECT call_status " + |
|||
"FROM gcc_1913_qaqc.call_status WHERE call_category_id = 4 and isactive='1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getFollowupSubmitDetails(int userId) { |
|||
|
|||
String query = "SELECT complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber,official_name,official_mobilenum, " + |
|||
"complaint_type, call_status, remarks " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE call_category = 'PUBLICFOLLOWUP' AND agent_id = ? AND is_processed = '1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query,userId); |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,123 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
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 QaqcAdminSettingService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Transactional |
|||
public int updateProductivity(int productivity_count) { |
|||
String updateSql = "UPDATE productivity SET productivity_count=? where isactive='1' and isdelete='0'"; |
|||
return jdbcTemplate.update(updateSql,productivity_count); |
|||
|
|||
} |
|||
|
|||
@Transactional |
|||
public int saveProductivity(int productivity_count) { |
|||
String insertSql = "INSERT INTO productivity (productivity_count) VALUES (?)"; |
|||
return jdbcTemplate.update(insertSql, productivity_count); |
|||
|
|||
} |
|||
|
|||
@Transactional |
|||
public Integer getProductivity() { |
|||
String insertSql = "select productivity_count\r\n" |
|||
+ "from productivity\r\n" |
|||
+ "where isactive='1' and isdelete='0'" |
|||
+ "LIMIT 1"; |
|||
return jdbcTemplate.queryForObject(insertSql, Integer.class); |
|||
|
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAdminSettingCounts() { |
|||
|
|||
String sqlQuery = "SELECT " + |
|||
"COALESCE(p.productivity_count, 0) AS productivity_count, " + |
|||
"COUNT(al.agent_id) AS total_count, " + |
|||
"COALESCE(p.inbound_count, 0) AS inbound_count, " + |
|||
"COALESCE(p.outbound_count, 0) AS outbound_count, " + |
|||
"COALESCE(p.inbound_count, 0) + COALESCE(p.outbound_count, 0) As assigned, " + |
|||
"(COUNT(al.agent_id) - (COALESCE(p.inbound_count, 0) + COALESCE(p.outbound_count, 0))) AS notassigned " + |
|||
"FROM productivity p " + |
|||
"JOIN agents_list al " + |
|||
"WHERE p.isactive = '1' AND p.isdelete = '0' AND al.isactive = '1' AND al.isdelete = '0' " + |
|||
"GROUP BY p.productivity_count, p.inbound_count, p.outbound_count"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public int saveCallingTypeInSettings() { |
|||
// Query to get inbound and outbound counts |
|||
String selectSql = "SELECT\r\n" |
|||
+ "SUM(CASE WHEN calling_type = 'INBOUND' THEN 1 ELSE 0 END) AS inbound, \r\n" |
|||
+ "SUM(CASE WHEN calling_type = 'OUTBOUND' THEN 1 ELSE 0 END) AS outbound \r\n" |
|||
+ "FROM agents_list \r\n" |
|||
+ "WHERE isactive = '1' AND isdelete = '0'"; |
|||
|
|||
// Fetch the counts |
|||
Map<String, Object> result = jdbcTemplate.queryForMap(selectSql); |
|||
int inbound = ((Number) result.get("inbound")).intValue(); // Convert to int |
|||
int outbound = ((Number) result.get("outbound")).intValue(); // Convert to int |
|||
|
|||
//Corrected SQL syntax for updating multiple columns |
|||
String updateSql = "UPDATE productivity SET inbound_count = ?, outbound_count = ? WHERE isactive = '1' AND isdelete = '0'"; |
|||
return jdbcTemplate.update(updateSql, inbound, outbound); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public int updateCallType(String calling_type,int agent_id) { |
|||
String updateSql = "UPDATE agents_list SET calling_type=? WHERE agent_id=? AND isactive='1'"; |
|||
|
|||
return jdbcTemplate.update(updateSql,calling_type,agent_id); |
|||
} |
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAgentsForCallingtype() |
|||
{ |
|||
String sqlQuery = "select al.agent_id as agent_id,ap.username as username,al.agent_name as agent_name,al.mobile_number as mobile_number,\r\n" |
|||
+ "al.calling_type as calling_type\r\n" |
|||
+ "from gcc_1913_qaqc.agents_list al\r\n" |
|||
+ "LEFT join gcc_apps.appusers ap on ap.userid=al.agent_id\r\n" |
|||
+ "where al.isactive='1' and al.isdelete='0'"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
public int updateAgentName(int agentId, String updatedName) { |
|||
// Query to check if the name exists for another agent |
|||
String checkSql = "SELECT COUNT(*) FROM agents_list WHERE agent_name = ? AND agent_id <> ? AND isactive = '1'"; |
|||
|
|||
int count = jdbcTemplate.queryForObject(checkSql, Integer.class, updatedName, agentId); |
|||
|
|||
if (count > 0) { |
|||
return -1; // Indicate that the name already exists |
|||
} |
|||
|
|||
// Proceed with the update if the name is unique |
|||
String updateSql = "UPDATE agents_list SET agent_name = ? WHERE agent_id = ? AND isactive = '1'"; |
|||
return jdbcTemplate.update(updateSql, updatedName, agentId); |
|||
} |
|||
|
|||
|
|||
} |
|||
1166
src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/QaqcAgentAssignService.java
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,686 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
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 QaqcAgentsService { |
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public List<Map<String, Object>> getAgentsAllTasksCounts(int agent_id) { |
|||
String SqlQuery = "SELECT \r\n" |
|||
+ " cr.taskid,\r\n" |
|||
+ " cr.call_category,\r\n" |
|||
+ " cr.description,\r\n" |
|||
+ " aa.qaqc_id,\r\n" |
|||
+ " aa.agent_id,\r\n" |
|||
+ " aa.created_date,\r\n" |
|||
+ " (SELECT COUNT(data_id) \r\n" |
|||
+ " FROM qaqc_upload_data up \r\n" |
|||
+ " WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ " AND up.qaqc_id = cr.qaqc_id\r\n" |
|||
+ " ) AS calls_assigned,\r\n" |
|||
+ " (SELECT COUNT(CASE WHEN up.call_status IS NULL THEN 1 END) \r\n" |
|||
+ " FROM qaqc_upload_data up \r\n" |
|||
+ " WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ " AND up.qaqc_id = cr.qaqc_id\r\n" |
|||
+ " ) AS pending_count,\r\n" |
|||
+ " (SELECT COUNT(CASE WHEN up.call_status IS NOT NULL THEN 1 END) \r\n" |
|||
+ " FROM qaqc_upload_data up \r\n" |
|||
+ " WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ " AND up.qaqc_id = cr.qaqc_id\r\n" |
|||
+ " ) AS complete_count,\r\n" |
|||
+ " (SELECT COUNT(CASE WHEN up.call_status ='CALL_BACK_LATER' OR up.field_9 = 'UNATTENDED' THEN 1 END) \r\n" |
|||
+ " FROM qaqc_upload_data up \r\n" |
|||
+ " WHERE up.agent_id = aa.agent_id \r\n" |
|||
+ " AND up.qaqc_id = cr.qaqc_id\r\n" |
|||
+ " ) AS followup_count\r\n" |
|||
+ " \r\n" |
|||
+ "FROM \r\n" |
|||
+ " agent_assigned aa\r\n" |
|||
+ "JOIN \r\n" |
|||
+ " agents_list al ON aa.agent_id = al.agent_id\r\n" |
|||
+ "JOIN \r\n" |
|||
+ " qaqc_request cr ON cr.qaqc_id = aa.qaqc_id\r\n" |
|||
+ "WHERE \r\n" |
|||
+ " aa.agent_id = ? \r\n" |
|||
+ " AND aa.isactive = '1'"; |
|||
|
|||
return jdbcTemplate.queryForList(SqlQuery,agent_id); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getdataforagents(int agent_id,int qaqc_id) { |
|||
String sqlQuery = "select *\r\n" |
|||
+ "from qaqc_upload_data\r\n" |
|||
+ "where agent_id=? and qaqc_id=?"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery,agent_id,qaqc_id); |
|||
} |
|||
|
|||
@Transactional |
|||
public void savecallstatus(String call_status, String remarks,String complaintNumber) |
|||
{ |
|||
|
|||
|
|||
String SqlQuery = "UPDATE qaqc_upload_data SET call_status = ?,remarks=?, updated_date = NOW() WHERE (complaint_number = ? )"; |
|||
|
|||
jdbcTemplate.update(SqlQuery,call_status, remarks,complaintNumber); |
|||
} |
|||
|
|||
@Transactional |
|||
public void savecallstatusinlogs(String call_status, String remarks,String complaintNumber) { |
|||
|
|||
// Step 1: Fetch details from the source table using the complaintNumber |
|||
String selectQuery = "SELECT * FROM qaqc_upload_data WHERE complaint_number = ?"; |
|||
Map<String, Object> details = jdbcTemplate.queryForMap(selectQuery, complaintNumber); |
|||
|
|||
// Extract the required fields from the result (modify based on your table structure) |
|||
String detailField1 = (String) details.get("qaqc_id"); |
|||
String detailField2 = (String) details.get("agent_id"); |
|||
String detailField3 = (String) details.get("complaint_number"); |
|||
String detailField4 = (String) details.get("complaint_person_name"); |
|||
String detailField5 = (String) details.get("complaint_mobilenumber"); |
|||
String detailField6 = (String) details.get("complaint_type"); |
|||
String detailField7 = (String) details.get("complaint_mode"); |
|||
String detailField8 = (String) details.get("department"); |
|||
String detailField9 = (String) details.get("complaint_group"); |
|||
String detailField10 = (String) details.get("official_name"); |
|||
String detailField11 = (String) details.get("official_mobilenum"); |
|||
|
|||
// Step 2: Insert the fetched details along with call_status and remarks into qaqc_call_logs |
|||
String insertQuery = "INSERT INTO qaqc_call_logs (qaqc_id, agent_id, complaint_number, complaint_person_name, complaint_mobilenumber,complaint_type,complaint_mode,department,complaint_group,official_name,official_mobilenum) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
|||
jdbcTemplate.update(insertQuery,detailField1, detailField2,detailField3,detailField4,detailField5,detailField6,detailField7,detailField8,detailField9,detailField10,detailField11,call_status,remarks); |
|||
|
|||
} |
|||
|
|||
|
|||
public List<Map<String,Object>> getPreviousDayDashboardCounts() |
|||
{ |
|||
String sqlQuery = "SELECT \r\n" |
|||
+ " COUNT(DISTINCT assigned_stats.agent_id) AS TotalAgents, \r\n" |
|||
+ " SUM(COALESCE(assigned_stats.Assigned, 0)) AS TotalAssigned, \r\n" |
|||
+ " SUM(COALESCE(completed_stats.TotalCompleted, 0)) AS TotalCompleted, \r\n" |
|||
+ " SUM(COALESCE(assigned_stats.Assigned, 0) - COALESCE(completed_stats.TotalCompleted, 0)) AS TotalPending \r\n" |
|||
+ "FROM \r\n" |
|||
+ " (SELECT al.agent_id AS agent_id, SUM(aa.data_count) AS Assigned \r\n" |
|||
+ " FROM agent_assigned aa \r\n" |
|||
+ " JOIN agents_list al ON aa.agent_id = al.agent_id \r\n" |
|||
+ " WHERE DATE(aa.created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
+ " GROUP BY al.agent_id) AS assigned_stats \r\n" |
|||
+ "LEFT JOIN \r\n" |
|||
+ " (SELECT agent_id, COUNT(DISTINCT (complaint_number)) AS TotalCompleted \r\n" |
|||
+ " FROM qaqc_call_logs \r\n" |
|||
+ " WHERE DATE(created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
+ " GROUP BY agent_id) AS completed_stats \r\n" |
|||
+ "ON assigned_stats.agent_id = completed_stats.agent_id;"; |
|||
|
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
// public List<Map<String,Object>> getAgentPreviousDayCount() |
|||
// { |
|||
// String sqlQuery = "SELECT DISTINCT \r\n" |
|||
// + " assigned_stats.agent_id, \r\n" |
|||
// + " assigned_stats.agent_name as agent_name, -- Use the alias assigned_stats here instead of aa\r\n" |
|||
// + " COALESCE(assigned_stats.Assigned, 0) AS Assigned, \r\n" |
|||
// + " COALESCE(completed_stats.TotalCompleted, 0) AS TotalCompleted, \r\n" |
|||
// + " COALESCE(assigned_stats.Assigned, 0) - COALESCE(completed_stats.TotalCompleted, 0) AS Pending, \r\n" |
|||
// + " CASE \r\n" |
|||
// + " WHEN COALESCE(assigned_stats.Assigned, 0) = 0 THEN 0 \r\n" |
|||
// + " ELSE ROUND(COALESCE(completed_stats.TotalCompleted, 0) * 100.0 / COALESCE(assigned_stats.Assigned, 1)) \r\n" |
|||
// + " END AS CompletionPercentage, \r\n" |
|||
// + " COALESCE(call_stats.Completed_count, 0) AS Completed_count, \r\n" |
|||
// + " COALESCE(call_stats.Reopened_count, 0) AS Reopened_count, \r\n" |
|||
// + " COALESCE(call_stats.Followup_count, 0) AS Followup_count, \r\n" |
|||
// + " COALESCE(call_stats.Other_count, 0) AS Other_count \r\n" |
|||
// + "FROM \r\n" |
|||
// + " (SELECT al.agent_id AS agent_id, al.agent_name AS agent_name, SUM(aa.data_count) AS Assigned \r\n" |
|||
// + " FROM agent_assigned aa \r\n" |
|||
// + " JOIN agents_list al ON aa.agent_id = al.agent_id \r\n" |
|||
// + " WHERE DATE(aa.created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
// + " GROUP BY al.agent_id,al.agent_name) AS assigned_stats -- The alias 'assigned_stats' is used here\r\n" |
|||
// + "LEFT JOIN \r\n" |
|||
// + " (SELECT agent_id, COUNT(qaqc_id) AS TotalCompleted \r\n" |
|||
// + " FROM qaqc_call_logs \r\n" |
|||
// + " WHERE DATE(created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
// + " GROUP BY agent_id) AS completed_stats ON assigned_stats.agent_id = completed_stats.agent_id \r\n" |
|||
// + "LEFT JOIN \r\n" |
|||
// + " (SELECT agent_id, \r\n" |
|||
// + " SUM(CASE WHEN call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 ELSE 0 END) AS Completed_count, \r\n" |
|||
// + " SUM(CASE WHEN call_status = 'REOPEN' THEN 1 ELSE 0 END) AS Reopened_count, \r\n" |
|||
// + " SUM(CASE WHEN call_status = 'FOLLOWUP' THEN 1 ELSE 0 END) AS Followup_count, \r\n" |
|||
// + " SUM(CASE WHEN call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 ELSE 0 END) AS Other_count \r\n" |
|||
// + " FROM qaqc_call_logs \r\n" |
|||
// + " WHERE DATE(created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
// + " GROUP BY agent_id) AS call_stats ON assigned_stats.agent_id = call_stats.agent_id;\r\n"; |
|||
// |
|||
// return jdbcTemplate.queryForList(sqlQuery); |
|||
// } |
|||
|
|||
|
|||
public List<Map<String,Object>> getAgentPreviousDayCount() |
|||
{ |
|||
String sqlQuery = "SELECT DISTINCT \r\n" |
|||
+ " assigned_stats.agent_id, \r\n" |
|||
+ " assigned_stats.agent_name as agent_name, -- Use the alias assigned_stats here instead of aa\r\n" |
|||
+ " COALESCE(assigned_stats.Assigned, 0) AS Assigned, \r\n" |
|||
+ " COALESCE(completed_stats.TotalCompleted, 0) AS TotalCompleted, \r\n" |
|||
+ " COALESCE(assigned_stats.Assigned, 0) - COALESCE(completed_stats.TotalCompleted, 0) AS Pending, \r\n" |
|||
+ " CASE \r\n" |
|||
+ " WHEN COALESCE(assigned_stats.Assigned, 0) = 0 THEN 0 \r\n" |
|||
+ " ELSE ROUND(COALESCE(completed_stats.TotalCompleted, 0) * 100.0 / COALESCE(assigned_stats.Assigned, 1)) \r\n" |
|||
+ " END AS CompletionPercentage, \r\n" |
|||
+ " COALESCE(call_stats.Completed_count, 0) AS Completed_count, \r\n" |
|||
+ " COALESCE(call_stats.Reopened_count, 0) AS Reopened_count, \r\n" |
|||
+ " COALESCE(call_stats.Followup_count, 0) AS Followup_count, \r\n" |
|||
+ " COALESCE(call_stats.Other_count, 0) AS Other_count \r\n" |
|||
+ "FROM \r\n" |
|||
+ " (SELECT al.agent_id AS agent_id, al.agent_name AS agent_name, SUM(aa.data_count) AS Assigned \r\n" |
|||
+ " FROM agent_assigned aa \r\n" |
|||
+ " JOIN agents_list al ON aa.agent_id = al.agent_id \r\n" |
|||
+ " WHERE DATE(aa.created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
+ " GROUP BY al.agent_id,al.agent_name) AS assigned_stats -- The alias 'assigned_stats' is used here\r\n" |
|||
+ "LEFT JOIN \r\n" |
|||
+ " (SELECT agent_id, count(DISTINCT (complaint_number)) AS TotalCompleted \r\n" |
|||
+ " FROM qaqc_call_logs \r\n" |
|||
+ " WHERE DATE(created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
+ " GROUP BY agent_id) AS completed_stats ON assigned_stats.agent_id = completed_stats.agent_id \r\n" |
|||
+ "LEFT JOIN \r\n" |
|||
+ " (SELECT agent_id, \r\n" |
|||
+ " SUM(CASE WHEN call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 ELSE 0 END) AS Completed_count, \r\n" |
|||
+ " SUM(CASE WHEN call_status = 'REOPEN' THEN 1 ELSE 0 END) AS Reopened_count, \r\n" |
|||
+ " SUM(CASE WHEN call_status = 'FOLLOWUP' THEN 1 ELSE 0 END) AS Followup_count, \r\n" |
|||
+ " SUM(CASE WHEN call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 ELSE 0 END) AS Other_count \r\n" |
|||
+ " FROM qaqc_call_logs \r\n" |
|||
+ " WHERE DATE(created_date) = DATE(SUBDATE(CURDATE(), 1)) \r\n" |
|||
+ " GROUP BY agent_id) AS call_stats ON assigned_stats.agent_id = call_stats.agent_id \r\n" |
|||
+ " ORDER BY agent_name \r\n;"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getAgentDashboard(int userId, String startDate, String endDate) { |
|||
String sql = "SELECT " + |
|||
" COALESCE(SUM(aa.data_count), 0) AS Total_Calls_assigned, " + |
|||
" COALESCE(SUM(CASE WHEN qr.call_category = 'closed' THEN aa.data_count ELSE 0 END), 0) AS Closed_Call_count, " + |
|||
" COALESCE(SUM(CASE WHEN qr.call_category IN ('inprogress', 'redressed', 'reopened','processing') THEN aa.data_count ELSE 0 END), 0) AS Inprogress_Call_count, " + |
|||
" COALESCE(SUM(CASE WHEN qr.call_category = 'officialfollowup' THEN aa.data_count ELSE 0 END), 0) AS Followup_Call_count, " + |
|||
" COALESCE(SUM(CASE WHEN qr.call_category = 'publicfollowup' THEN aa.data_count ELSE 0 END), 0) AS PublicFollowup_Call_count " + |
|||
"FROM agent_assigned aa " + |
|||
"LEFT JOIN qaqc_request qr ON aa.qaqc_id = qr.qaqc_id " + |
|||
"WHERE aa.agent_id = ? " + |
|||
"AND DATE(qr.created_date) BETWEEN ? AND ?"; |
|||
|
|||
return jdbcTemplate.queryForList(sql, userId, startDate, endDate); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getAgentPerformanceData(int agentId, String startDate, String endDate) { |
|||
// String sql = "SELECT \n" |
|||
// + " COALESCE(total_data_count, 0) AS total_data_count,\n" // Ensure total_data_count is 0 if null |
|||
// + " COALESCE(completed_count, 0) AS completed_count,\n" // Ensure completed_count is 0 if null |
|||
// + " COALESCE((total_data_count - completed_count), 0) AS pending_count,\n" // Ensure pending_count is 0 |
|||
// + " CASE \n" |
|||
// + " WHEN COALESCE(total_data_count, 0) > 0 THEN ROUND((COALESCE(completed_count, 0) / total_data_count) * 100, 1)\n" |
|||
// + " ELSE 0\n" |
|||
// + " END AS completed_percentage\n" |
|||
// + "FROM \n" |
|||
// + " (\n" |
|||
// + " SELECT \n" |
|||
// + " (SELECT COALESCE(SUM(aa.data_count), 0) \n" |
|||
// + " FROM agent_assigned aa \n" |
|||
// + " WHERE aa.agent_id = ? AND DATE(aa.created_date) BETWEEN ? AND ?) AS total_data_count,\n" |
|||
// + " \n" |
|||
// + " (SELECT COALESCE(COUNT(*), 0) \n" |
|||
// + " FROM qaqc_call_logs cl \n" |
|||
// + " WHERE cl.agent_id = ?\n" |
|||
// + " AND DATE(cl.created_date) BETWEEN ? AND ? \n" |
|||
// + " AND cl.call_status IS NOT NULL) AS completed_count\n" |
|||
// + " ) AS combined"; |
|||
|
|||
// return jdbcTemplate.queryForList(sql, agentId, startDate, endDate, agentId, startDate, endDate); |
|||
|
|||
String sql="SELECT " |
|||
+ " total_data_count," |
|||
+ " completed_count," |
|||
+ " (total_data_count - completed_count) AS pending_count," |
|||
+ " CASE " |
|||
+ " WHEN total_data_count > 0 " |
|||
+ " THEN ROUND((completed_count / total_data_count) * 100, 1)" |
|||
+ " ELSE 0" |
|||
+ " END AS completed_percentage" |
|||
+ " FROM (" |
|||
+ " SELECT " |
|||
+ " COUNT(*) AS total_data_count," |
|||
+ " COUNT(call_status) AS completed_count" |
|||
+ " FROM qaqc_upload_data_history" |
|||
+ " WHERE created_date >= ? " |
|||
+ " AND created_date < DATE_ADD( ? , INTERVAL 1 DAY)" |
|||
+ " AND agent_id = ? " |
|||
+ ") t"; |
|||
|
|||
return jdbcTemplate.queryForList(sql, startDate, endDate, agentId); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getAgentTaskDetails(int userId, String startDate, String endDate) { |
|||
String sql = "WITH LatestCallLogs AS ( " + |
|||
" SELECT " + |
|||
" cl.qaqc_id, " + |
|||
" cl.agent_id, " + |
|||
" cl.complaint_number, " + |
|||
" cl.call_status, " + |
|||
" cl.created_date, " + |
|||
" ROW_NUMBER() OVER (PARTITION BY cl.qaqc_id, cl.agent_id, cl.complaint_number ORDER BY cl.created_date DESC) AS row_num " + |
|||
" FROM " + |
|||
" qaqc_call_logs cl " + |
|||
") " + |
|||
"SELECT DISTINCT " + |
|||
" qr.taskid AS taskid, " + |
|||
" qr.call_category AS call_category, " + |
|||
" DATE(aa.created_date) AS cdate, " + |
|||
" aa.data_count AS assigned, " + |
|||
" COUNT(lcl.agent_id) AS callstaken, " + |
|||
" (aa.data_count - COUNT(lcl.agent_id)) AS pending, " + |
|||
" ROUND((CASE WHEN aa.data_count > 0 THEN (COUNT(lcl.agent_id) / aa.data_count) * 100 ELSE 0 END), 2) AS percentage, " + |
|||
" COUNT(CASE WHEN lcl.call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 END) AS Completed, " + |
|||
" COUNT(CASE WHEN lcl.call_status = 'REOPEN' THEN 1 END) AS Reopened, " + |
|||
" COUNT(CASE WHEN lcl.call_status = 'FOLLOWUP' THEN 1 END) AS Followup, " + |
|||
" COUNT(CASE WHEN lcl.call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 END) AS Others " + |
|||
"FROM " + |
|||
" qaqc_request qr " + |
|||
"JOIN " + |
|||
" agent_assigned aa ON aa.qaqc_id = qr.qaqc_id " + |
|||
"JOIN " + |
|||
" agents_list al ON al.agent_id = aa.agent_id " + |
|||
"LEFT JOIN " + |
|||
" LatestCallLogs lcl ON qr.qaqc_id = lcl.qaqc_id AND al.agent_id = lcl.agent_id AND lcl.row_num = 1 " + |
|||
"WHERE " + |
|||
" al.agent_id = ? AND aa.data_count != 0 " + |
|||
" AND DATE(aa.created_date) BETWEEN ? AND ? " + |
|||
"GROUP BY " + |
|||
" taskid, cdate, assigned, call_category"; |
|||
|
|||
return jdbcTemplate.queryForList(sql, userId, startDate, endDate); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getAgentPerformanceCount(String startDate, String endDate) { |
|||
String sql = "SELECT " + |
|||
"t2.total_calls, " + |
|||
"t3.completed_calls, " + |
|||
"t2.total_calls - t3.completed_calls AS pending_calls, " + |
|||
"t4.no_of_agents " + |
|||
"FROM " + |
|||
"( " + |
|||
" SELECT " + |
|||
" SUM(aa.data_count) AS total_calls " + |
|||
" FROM " + |
|||
" agent_assigned aa " + |
|||
" INNER JOIN " + |
|||
" qaqc_request qr " + |
|||
" ON " + |
|||
" aa.qaqc_id = qr.qaqc_id " + |
|||
" WHERE " + |
|||
" (? IS NULL OR date(qr.created_date) BETWEEN ? AND ?) " + |
|||
") AS t2, " + |
|||
"( " + |
|||
" SELECT " + |
|||
" SUM(qr.total_data) AS total_data, " + |
|||
" COUNT(CASE WHEN qcl.call_status IS NOT NULL THEN qcl.qaqc_id END) AS completed_calls" + |
|||
" FROM " + |
|||
" qaqc_request qr " + |
|||
" LEFT JOIN " + |
|||
" qaqc_upload_data_history qcl " + |
|||
" ON " + |
|||
" qr.qaqc_id = qcl.qaqc_id " + |
|||
" WHERE " + |
|||
" (? IS NULL OR date(qr.created_date) BETWEEN ? AND ?) " + |
|||
") AS t3, " + |
|||
"( " + |
|||
" SELECT " + |
|||
" COUNT(DISTINCT aa.agent_id) AS no_of_agents " + |
|||
" FROM " + |
|||
" agent_assigned aa " + |
|||
" WHERE " + |
|||
" (? IS NULL OR date(aa.created_date) BETWEEN ? AND ?) " + |
|||
") AS t4"; |
|||
|
|||
// Prepare the parameters for the query |
|||
Object[] params = new Object[] { |
|||
startDate, startDate, endDate, // For t2 |
|||
startDate, startDate, endDate, // For t3 |
|||
startDate, startDate, endDate // For t4 |
|||
}; |
|||
|
|||
// Execute the query and return the results as a List of Maps |
|||
return jdbcTemplate.queryForList(sql, params); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getAgentPerformanceList(String startDate, String endDate) { |
|||
// Base query with subqueries for Assigned, Completed, and Pending |
|||
StringBuilder query = new StringBuilder( |
|||
"SELECT DISTINCT " + |
|||
" assigned_stats.agent_id, " + |
|||
" assigned_stats.agent_name, " + |
|||
" COALESCE(assigned_stats.Assigned, 0) AS Assigned, " + |
|||
" COALESCE(completed_stats.TotalCompleted, 0) AS TotalCompleted, " + |
|||
" COALESCE(assigned_stats.Assigned, 0) - COALESCE(completed_stats.TotalCompleted, 0) AS Pending, " + |
|||
" CASE WHEN COALESCE(assigned_stats.Assigned, 0) = 0 THEN 0 ELSE " + |
|||
" ROUND(COALESCE(completed_stats.TotalCompleted, 0) * 100.0 / COALESCE(assigned_stats.Assigned, 1), 2) " + |
|||
" END AS CompletionPercentage, " + |
|||
" COALESCE(call_stats.Completed_count, 0) AS Completed_count, " + |
|||
" COALESCE(call_stats.Reopened_count, 0) AS Reopened_count, " + |
|||
" COALESCE(call_stats.Followup_count, 0) AS Followup_count, " + |
|||
" COALESCE(call_stats.Other_count, 0) AS Other_count " + |
|||
"FROM " + |
|||
" (SELECT al.agent_id as agent_id, al.agent_name as agent_name,SUM(aa.data_count) AS Assigned " + |
|||
" FROM agent_assigned aa JOIN agents_list al ON aa.agent_id=al.agent_id " + |
|||
" WHERE (? IS NULL OR DATE(aa.created_date) >= STR_TO_DATE(?, '%Y-%m-%d')) " + // Conditional date filtering |
|||
" AND (? IS NULL OR DATE(aa.created_date) <= STR_TO_DATE(?, '%Y-%m-%d')) " + |
|||
" GROUP BY al.agent_id,al.agent_name) AS assigned_stats " + // The alias 'assigned_stats' is used here |
|||
"LEFT JOIN " + |
|||
" (SELECT agent_id, COUNT(call_status) AS TotalCompleted " + |
|||
" FROM qaqc_upload_data_history " + |
|||
" WHERE (? IS NULL OR DATE(created_date) >= STR_TO_DATE(?, '%Y-%m-%d')) " + // Conditional date filtering |
|||
" AND (? IS NULL OR DATE(created_date) <= STR_TO_DATE(?, '%Y-%m-%d')) " + |
|||
" GROUP BY agent_id) AS completed_stats ON assigned_stats.agent_id = completed_stats.agent_id " + |
|||
"LEFT JOIN " + |
|||
" (SELECT agent_id, " + |
|||
" SUM(CASE WHEN call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 ELSE 0 END) AS Completed_count, " + |
|||
" SUM(CASE WHEN call_status = 'REOPEN' THEN 1 ELSE 0 END) AS Reopened_count, " + |
|||
" SUM(CASE WHEN call_status = 'FOLLOWUP' THEN 1 ELSE 0 END) AS Followup_count, " + |
|||
" SUM(CASE WHEN call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 ELSE 0 END) AS Other_count " + |
|||
" FROM qaqc_upload_data_history " + |
|||
" WHERE (? IS NULL OR DATE(created_date) >= STR_TO_DATE(?, '%Y-%m-%d')) " + // Conditional date filtering |
|||
" AND (? IS NULL OR DATE(created_date) <= STR_TO_DATE(?, '%Y-%m-%d')) " + |
|||
" GROUP BY agent_id) AS call_stats ON assigned_stats.agent_id = call_stats.agent_id" |
|||
); |
|||
|
|||
// Execute query with date range parameters |
|||
return jdbcTemplate.queryForList( |
|||
query.toString(), |
|||
startDate, startDate, endDate, endDate, // Parameters for assigned_stats |
|||
startDate, startDate, endDate, endDate, // Parameters for completed_stats |
|||
startDate, startDate, endDate, endDate // Parameters for call_stats |
|||
); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getAgentTaskwiseData(String agentId,String startDate, String endDate) { |
|||
|
|||
String query="WITH LatestCallLogs AS (\r\n" |
|||
+ " SELECT \r\n" |
|||
+ " cl.qaqc_id,\r\n" |
|||
+ " cl.agent_id,\r\n" |
|||
+ " cl.complaint_number,\r\n" |
|||
+ " cl.call_status,\r\n" |
|||
+ " cl.created_date,\r\n" |
|||
+ " ROW_NUMBER() OVER (PARTITION BY cl.qaqc_id, cl.agent_id, cl.complaint_number ORDER BY cl.created_date DESC) AS row_num\r\n" |
|||
+ " FROM \r\n" |
|||
+ " qaqc_call_logs cl\r\n" |
|||
+ ")\r\n" |
|||
+ "SELECT DISTINCT \r\n" |
|||
+ " qr.taskid as taskid,\r\n" |
|||
+ " date(aa.created_date) as cdate,\r\n" |
|||
+ " aa.data_count AS assigned,\r\n" |
|||
+ " COUNT(lcl.agent_id) AS callstaken,\r\n" |
|||
+ " (aa.data_count - COUNT(lcl.agent_id)) AS pending,\r\n" |
|||
+ " ROUND((COUNT(lcl.agent_id) / aa.data_count) * 100, 2) AS percentage,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 END) AS Completed,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status = 'REOPEN' THEN 1 END) AS Reopened,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status = 'FOLLOWUP' THEN 1 END) AS Followup,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 END) AS Others\r\n" |
|||
+ "FROM \r\n" |
|||
+ " qaqc_request qr\r\n" |
|||
+ "JOIN \r\n" |
|||
+ " agent_assigned aa ON aa.qaqc_id = qr.qaqc_id\r\n" |
|||
+ "JOIN \r\n" |
|||
+ " agents_list al ON al.agent_id = aa.agent_id\r\n" |
|||
+ "LEFT JOIN \r\n" |
|||
+ " LatestCallLogs lcl ON qr.qaqc_id = lcl.qaqc_id AND al.agent_id = lcl.agent_id AND lcl.row_num = 1\r\n" |
|||
+ "WHERE \r\n" |
|||
+ " al.agent_id = ? AND DATE(qr.created_date) >= ? AND DATE(qr.created_date) <= ? \r\n" |
|||
+ "GROUP BY \r\n" |
|||
+ " taskid, cdate, assigned"; |
|||
|
|||
|
|||
return jdbcTemplate.queryForList(query, agentId,startDate,endDate); |
|||
|
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getAttendedComplaintStatus( |
|||
String startDate, String endDate, String complaintNumber, String complaintMobileNumber) { |
|||
|
|||
// Base query with JOIN to include agent_name |
|||
StringBuilder query = new StringBuilder( |
|||
"SELECT qcl.*,date(qcl.created_date) as updated_date, al.agent_name " + |
|||
"FROM qaqc_call_logs qcl " + |
|||
"LEFT JOIN agents_list al ON qcl.agent_id = al.agent_id " + |
|||
"WHERE 1=1 "); |
|||
|
|||
// List to store query parameters |
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
// Add date range condition if provided |
|||
if (startDate != null && !startDate.isEmpty()) { |
|||
query.append("AND DATE(qcl.created_date) >= ? "); |
|||
params.add(startDate); |
|||
} |
|||
if (endDate != null && !endDate.isEmpty()) { |
|||
query.append("AND DATE(qcl.created_date) <= ? "); |
|||
params.add(endDate); |
|||
} |
|||
|
|||
// Add complaint number condition if provided |
|||
if (complaintNumber != null && !complaintNumber.isEmpty()) { |
|||
query.append("AND qcl.complaint_number = ? "); |
|||
params.add(complaintNumber); |
|||
} |
|||
|
|||
// Add complaint mobile number condition if provided |
|||
if (complaintMobileNumber != null && !complaintMobileNumber.isEmpty()) { |
|||
query.append("AND qcl.complaint_mobilenumber = ? "); |
|||
params.add(complaintMobileNumber); |
|||
} |
|||
|
|||
// Add ORDER BY clause |
|||
query.append("ORDER BY qcl.created_date DESC "); |
|||
|
|||
// Add LIMIT clause only if complaintNumber is provided |
|||
if (complaintNumber != null && !complaintNumber.isEmpty()) { |
|||
query.append("LIMIT 1 "); |
|||
} |
|||
|
|||
// Execute the query with dynamic parameters |
|||
return jdbcTemplate.queryForList(query.toString(), params.toArray()); |
|||
} |
|||
|
|||
|
|||
// public List<Map<String, Object>> getAttendedComplainthistory( |
|||
// String startDate, String endDate, String complaintNumber, String complaintMobileNumber) { |
|||
// |
|||
// // Base query with JOIN to include agent_name |
|||
// StringBuilder query = new StringBuilder( |
|||
// "SELECT qcl.*, al.agent_name " + |
|||
// "FROM qaqc_call_logs qcl " + |
|||
// "LEFT JOIN agents_list al ON qcl.agent_id = al.agent_id " + |
|||
// "WHERE 1=1 "); |
|||
// |
|||
// // List to store query parameters |
|||
// List<Object> params = new ArrayList<>(); |
|||
// |
|||
// // Add date range condition if provided |
|||
// if (startDate != null && !startDate.isEmpty()) { |
|||
// query.append("AND DATE(qcl.created_date) >= ? "); |
|||
// params.add(startDate); |
|||
// } |
|||
// if (endDate != null && !endDate.isEmpty()) { |
|||
// query.append("AND DATE(qcl.created_date) <= ? "); |
|||
// params.add(endDate); |
|||
// } |
|||
// |
|||
// // Add complaint number condition if provided |
|||
// if (complaintNumber != null && !complaintNumber.isEmpty()) { |
|||
// query.append("AND qcl.complaint_number = ? "); |
|||
// params.add(complaintNumber); |
|||
// } |
|||
// |
|||
// // Add complaint mobile number condition if provided |
|||
// if (complaintMobileNumber != null && !complaintMobileNumber.isEmpty()) { |
|||
// query.append("AND qcl.complaint_mobilenumber = ? "); |
|||
// params.add(complaintMobileNumber); |
|||
// } |
|||
// |
|||
// // Group by qcl.id and agent_name to avoid SQL error |
|||
// query.append("GROUP BY qcl.id, al.agent_name "); |
|||
// |
|||
// // Add ordering clause |
|||
// query.append("ORDER BY qcl.created_date DESC"); |
|||
// |
|||
// // Execute the query with dynamic parameters |
|||
// return jdbcTemplate.queryForList(query.toString(), params.toArray()); |
|||
// } |
|||
|
|||
public List<Map<String, Object>> getAttendedComplainthistory( |
|||
String startDate, |
|||
String endDate, |
|||
String complaintNumber, |
|||
String complaintMobileNumber) { |
|||
|
|||
StringBuilder query = new StringBuilder( |
|||
|
|||
"SELECT * FROM ( " + |
|||
|
|||
// ================= QAQC CALL LOGS ================= |
|||
"SELECT " + |
|||
"qcl.id, " + |
|||
"qcl.qaqc_id, " + |
|||
"qcl.call_category, " + |
|||
"qcl.agent_id, " + |
|||
"qcl.complaint_number, " + |
|||
"qcl.complaint_date, " + |
|||
"qcl.complaint_person_name, " + |
|||
"qcl.complaint_mobilenumber, " + |
|||
"qcl.complaint_type, " + |
|||
"qcl.complaint_mode, " + |
|||
"qcl.department, " + |
|||
"qcl.complaint_group, " + |
|||
"qcl.official_name, " + |
|||
"qcl.official_mobilenum, " + |
|||
"qcl.call_status, " + |
|||
"qcl.remainder_date, " + |
|||
"qcl.remarks, " + |
|||
"qcl.created_date, " + |
|||
"qcl.is_processed, " + |
|||
"qcl.updated_agent, " + |
|||
"al.agent_name, " + |
|||
"'QAQC' AS source_table " + |
|||
|
|||
"FROM qaqc_call_logs qcl " + |
|||
"LEFT JOIN agents_list al ON qcl.agent_id = al.agent_id " + |
|||
|
|||
"UNION ALL " + |
|||
|
|||
// ================= SOCIAL MEDIA ================= |
|||
"SELECT " + |
|||
"smc.id, " + |
|||
"NULL AS qaqc_id, " + |
|||
"NULL AS call_category, " + |
|||
"smc.updated_by AS agent_id, " + |
|||
"smc.complaint_number, " + |
|||
"smc.complaint_date, " + |
|||
"smc.complaint_person_name, " + |
|||
"smc.complaint_mobilenumber, " + |
|||
"smc.complaint_type, " + |
|||
"smc.complaint_mode, " + |
|||
"smc.department, " + |
|||
"NULL AS complaint_group, " + |
|||
"smc.official_name, " + |
|||
"smc.official_mobilenum, " + |
|||
"smc.call_status, " + |
|||
"smc.remainder_date AS remainder_date, " + |
|||
"smc.remarks, " + |
|||
"smc.created_date, " + |
|||
"smc.is_processed AS is_processed, " + |
|||
"smc.updated_by AS updated_agent, " + |
|||
"al.agent_name, " + |
|||
"'SOCIAL_MEDIA' AS source_table " + |
|||
|
|||
"FROM social_media_completed smc " + |
|||
"LEFT JOIN agents_list al ON smc.updated_by = al.agent_id " + |
|||
|
|||
") x WHERE 1=1 " |
|||
); |
|||
|
|||
List<Object> params = new ArrayList<>(); |
|||
|
|||
// ================= DATE FILTER ================= |
|||
if (startDate != null && !startDate.isEmpty()) { |
|||
query.append("AND DATE(x.created_date) >= ? "); |
|||
params.add(startDate); |
|||
} |
|||
|
|||
if (endDate != null && !endDate.isEmpty()) { |
|||
query.append("AND DATE(x.created_date) <= ? "); |
|||
params.add(endDate); |
|||
} |
|||
|
|||
// ================= COMPLAINT NUMBER ================= |
|||
if (complaintNumber != null && !complaintNumber.isEmpty()) { |
|||
query.append("AND x.complaint_number = ? "); |
|||
params.add(complaintNumber); |
|||
} |
|||
|
|||
// ================= MOBILE NUMBER ================= |
|||
if (complaintMobileNumber != null && !complaintMobileNumber.isEmpty()) { |
|||
query.append("AND x.complaint_mobilenumber = ? "); |
|||
params.add(complaintMobileNumber); |
|||
} |
|||
|
|||
// ================= ORDER ================= |
|||
query.append("ORDER BY x.created_date DESC"); |
|||
|
|||
return jdbcTemplate.queryForList(query.toString(), params.toArray()); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getAgentTaskwiseAssign(String agentId) { |
|||
String query="SELECT * FROM qaqc_upload_data_history where agent_id=? "; |
|||
return jdbcTemplate.queryForList(query, agentId); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getAgentName(int userId) { |
|||
String query="SELECT agent_name \r\n" |
|||
+ "FROM agents_list\r\n" |
|||
+ "where agent_id=?"; |
|||
return jdbcTemplate.queryForList(query, userId); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,391 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import java.io.InputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.net.URLConnection; |
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
|
|||
@Service |
|||
@Transactional |
|||
public class QaqcCallsService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getClosedComplaints(int agent_id) { |
|||
String query = "SELECT data_id, complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber, complaint_type,official_name, official_mobilenum,complaint_mode, department,call_category " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE call_category = 'CLOSED' " + |
|||
" AND is_processed = FALSE " + // Fetch only unprocessed entries |
|||
" AND agent_id = ?"; |
|||
return jdbcTemplate.queryForList(query, agent_id); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getCallCategories() |
|||
{ |
|||
String query = "SELECT call_status " + |
|||
"FROM gcc_1913_qaqc.call_status WHERE call_category_id ='1' and isactive='1'"; |
|||
return jdbcTemplate.queryForList(query); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public int uploadComplaintDetailsInLogs(Map<String, Object> logDetails, String action, String complaintNumber, String remainderDate) { |
|||
//System.out.println("Complaint Details: " + logDetails); |
|||
// Extract other field values from complaintDetails |
|||
int qaqcid = (int) logDetails.get("qaqc_id"); |
|||
String ccategory = logDetails.get("call_category").toString(); |
|||
String complaintDate = logDetails.get("complaint_date").toString(); |
|||
String personName = logDetails.get("complaint_person_name").toString(); |
|||
String personMobNo = logDetails.get("complaint_mobilenumber").toString(); |
|||
String cType = logDetails.get("complaint_type").toString(); |
|||
String cMode = logDetails.get("complaint_mode").toString(); |
|||
String department = logDetails.get("department").toString(); |
|||
String cGroup = logDetails.get("complaint_group").toString(); |
|||
String officialName = logDetails.get("official_name").toString(); |
|||
String officialMobileNum = logDetails.get("official_mobilenum").toString(); |
|||
String callStatus = logDetails.get("call_status").toString(); |
|||
String remarks = logDetails.get("remarks").toString(); |
|||
int agentId = (int) logDetails.get("agent_id"); |
|||
int updated_agent=(int)logDetails.get("updated_agent"); |
|||
boolean isProcessed = (boolean)logDetails.get("is_processed"); |
|||
LocalDateTime currentDate = LocalDateTime.now(); |
|||
|
|||
// Determine which table to insert into based on the action |
|||
if (action.equals("FOLLOWUP")) { |
|||
String query = "INSERT INTO gcc_1913_qaqc.qaqc_followup_call_logs (qaqc_id, call_category, agent_id, complaint_number,complaint_date, complaint_person_name, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, remainder_date,official_mobilenum, call_status, remarks,created_date,updated_agent) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?)"; |
|||
|
|||
int rowsAffected = jdbcTemplate.update(query, qaqcid, ccategory, agentId, complaintNumber, complaintDate,personName, |
|||
personMobNo, cType, cMode, department, cGroup, officialName,remainderDate, officialMobileNum,callStatus, |
|||
remarks,currentDate,updated_agent); |
|||
//System.out.println("Rows Inserted in qaqc_followup_call_logs : " + rowsAffected); |
|||
|
|||
String query1 = "INSERT INTO gcc_1913_qaqc.qaqc_call_logs (qaqc_id, call_category, agent_id, complaint_number,complaint_date, complaint_person_name, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name,remainder_date, official_mobilenum, call_status, remarks, is_processed,updated_agent) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?)"; |
|||
|
|||
int rowsAffected1 = jdbcTemplate.update(query1, qaqcid, ccategory, agentId, complaintNumber, complaintDate,personName, |
|||
personMobNo, cType, cMode, department, cGroup, officialName,remainderDate, officialMobileNum, callStatus, remarks, |
|||
isProcessed,updated_agent); |
|||
//System.out.println("Rows Inserted in qaqc_call_logs : " + rowsAffected1); |
|||
|
|||
|
|||
return rowsAffected + rowsAffected1; |
|||
|
|||
} else { |
|||
String query = "INSERT INTO gcc_1913_qaqc.qaqc_call_logs (qaqc_id, call_category, agent_id, complaint_number, complaint_date,complaint_person_name, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, call_status, remarks, is_processed,updated_agent) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)"; |
|||
|
|||
int rowsAffected = jdbcTemplate.update(query, qaqcid, ccategory, agentId, complaintNumber,complaintDate, personName, |
|||
personMobNo, cType, cMode, department, cGroup, officialName, officialMobileNum, callStatus, remarks, |
|||
isProcessed,updated_agent); |
|||
|
|||
//System.out.println("Rows Inserted in qaqc_call_logs: " + rowsAffected); |
|||
|
|||
return rowsAffected; |
|||
} |
|||
} |
|||
|
|||
public void updateComplaintDetails(String complaintNumber,int dataId, String action, String remarks,int updated_agent) |
|||
{ |
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_upload_data " + |
|||
"SET call_status = ?, " + " remarks = ?,updated_agent=?, " + |
|||
" updated_date = CURRENT_TIMESTAMP, " + " is_processed = TRUE " + |
|||
"WHERE data_id = ? " +" AND complaint_number = ? " +" AND call_category = 'CLOSED'"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks,updated_agent, dataId,complaintNumber); |
|||
|
|||
//System.out.println("Rows Updated in upload data: " + rowsUpdated); |
|||
} |
|||
|
|||
public Map<String, Object> getComplaintDetails(int dataId) { |
|||
String query = "Select * from gcc_1913_qaqc.qaqc_upload_data where data_id = ?"; |
|||
return jdbcTemplate.queryForMap(query, dataId); |
|||
} |
|||
|
|||
public Map<String, Object> getErpnameById(Integer agentId) { |
|||
String query = "Select erp_username from agents_list where agent_id = ?"; |
|||
return jdbcTemplate.queryForMap(query, agentId); |
|||
} |
|||
|
|||
// public boolean ChangeStatusInErp(String complaintNumber, String remarks, String action,String Erpname) { |
|||
// String urlString = ""; |
|||
// |
|||
// if(remarks.isEmpty()) { |
|||
// remarks="N/A"; |
|||
// } |
|||
// |
|||
// if("COMPLETED".equals(action) || "WRONG_ASSIGN".equals(action)) { |
|||
// |
|||
// urlString="https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=UpdateComplaint&ComplaintId="+complaintNumber+"&Message="+remarks+"&UserType=Official&Status=11&erp_username="+Erpname; |
|||
// System.out.println(urlString); |
|||
// //urlencode |
|||
// try { |
|||
// |
|||
// URL url = new URL(urlString); |
|||
// URLConnection urlcon=url.openConnection(); |
|||
// InputStream stream=urlcon.getInputStream(); |
|||
// StringBuilder responseBuilder = new StringBuilder(); |
|||
// int i; |
|||
// while((i=stream.read())!=-1){ |
|||
// responseBuilder.append((char) i); |
|||
// } |
|||
// stream.close(); |
|||
// |
|||
// // Parse the response |
|||
// String response = responseBuilder.toString(); |
|||
// System.out.println("Raw Response from ERP if Completed: " + response); // Debug: Print the raw response |
|||
// |
|||
// // Check ResultStatus in the response |
|||
// if (response.contains("\"ResultStatus\": true")) { |
|||
// System.out.println("ResultStatus is true in the response."); // Debug: Positive ResultStatus |
|||
// return true; |
|||
// } |
|||
// else { |
|||
// System.out.println("ResultStatus is false or not present in the response."); // Debug: Negative or missing ResultStatus |
|||
// return false; |
|||
// } |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// return false; |
|||
// } |
|||
// } |
|||
// |
|||
// if("REOPEN".equals(action)) { |
|||
// urlString="https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=UpdateComplaint&ComplaintId="+complaintNumber+"&Message="+remarks+"&UserType=Official&Status=9&Comp_Image=64baseString&erp_username="+Erpname; |
|||
// System.out.println(urlString); |
|||
// try { |
|||
// URL url = new URL(urlString); |
|||
// URLConnection urlcon=url.openConnection(); |
|||
// InputStream stream=urlcon.getInputStream(); |
|||
// StringBuilder responseBuilder = new StringBuilder(); |
|||
// int i; |
|||
// while((i=stream.read())!=-1){ |
|||
// responseBuilder.append((char) i); |
|||
// } |
|||
// stream.close(); |
|||
// |
|||
// // Parse the response |
|||
// String response = responseBuilder.toString(); |
|||
// System.out.println("Raw Response from ERP if Reopen: " + response); |
|||
// |
|||
// // Check ResultStatus in the response |
|||
// if (response.contains("\"ResultStatus\": true")) { |
|||
// System.out.println("ResultStatus is true in the response."); // Debug: Positive ResultStatus |
|||
// return true; |
|||
// } |
|||
// else { |
|||
// System.out.println("ResultStatus is false or not present in the response."); // Debug: Negative or missing ResultStatus |
|||
// return false; |
|||
// } |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// return false; |
|||
// } |
|||
// } |
|||
// return false; |
|||
// |
|||
// } |
|||
|
|||
// public boolean ChangeStatusInErp(String complaintNumber, String remarks, String action, String Erpname) { |
|||
// String urlString = ""; |
|||
// |
|||
// if (remarks.isEmpty()) { |
|||
// remarks = "N/A"; |
|||
// } |
|||
// |
|||
// try { |
|||
// // Encode parameters |
|||
// String encodedComplaintNumber = URLEncoder.encode(complaintNumber, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
// String encodedRemarks = URLEncoder.encode(remarks, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
// String encodedErpname = URLEncoder.encode(Erpname, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
// |
|||
// if ("COMPLETED".equals(action) || "WRONG_ASSIGN".equals(action)) { |
|||
// urlString = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?" |
|||
// + "serviceId=UpdateComplaint" |
|||
// + "&ComplaintId=" + encodedComplaintNumber |
|||
// + "&Message=" + encodedRemarks |
|||
// + "&UserType=Official" |
|||
// + "&Status=11" |
|||
// + "&erp_username=" + encodedErpname; |
|||
// |
|||
// System.out.println(urlString); |
|||
// |
|||
// return sendRequest(urlString); |
|||
// } |
|||
// |
|||
// if ("REOPEN".equals(action)) { |
|||
// urlString = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?" |
|||
// + "serviceId=UpdateComplaint" |
|||
// + "&ComplaintId=" + encodedComplaintNumber |
|||
// + "&Message=" + encodedRemarks |
|||
// + "&UserType=Official" |
|||
// + "&Status=9" |
|||
// + "&Comp_Image=64baseString" |
|||
// + "&erp_username=" + encodedErpname; |
|||
// |
|||
// System.out.println(urlString); |
|||
// |
|||
// return sendRequest(urlString); |
|||
// } |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// return false; |
|||
// } |
|||
// |
|||
// return false; |
|||
// } |
|||
|
|||
public boolean ChangeStatusInErp(String complaintNumber, String remarks, String action, String Erpname) { |
|||
String baseUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?"; |
|||
String status = ""; |
|||
|
|||
if (remarks.isEmpty()) { |
|||
remarks = "N/A"; |
|||
} |
|||
|
|||
try { |
|||
// Encode parameters |
|||
String encodedComplaintNumber = URLEncoder.encode(complaintNumber, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
String encodedRemarks = URLEncoder.encode(remarks, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
String encodedErpname = URLEncoder.encode(Erpname, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
|
|||
// Determine status based on action |
|||
if ("COMPLETED".equals(action) || "WRONG_ASSIGN".equals(action)) { |
|||
status = "11"; |
|||
} else if ("REOPEN".equals(action)) { |
|||
status = "9"; |
|||
} else { |
|||
return false; // Invalid action, return false |
|||
} |
|||
|
|||
// Construct the URL |
|||
String urlString = baseUrl |
|||
+ "serviceId=UpdateComplaint" |
|||
+ "&ComplaintId=" + encodedComplaintNumber |
|||
+ "&Message=" + encodedRemarks |
|||
+ "&UserType=Official" |
|||
+ "&Status=" + status |
|||
+ "&Comp_Image=" |
|||
+ "&erp_username=" + encodedErpname; |
|||
|
|||
System.out.println(urlString); |
|||
|
|||
// Send the request |
|||
return sendRequest(urlString); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
|
|||
private boolean sendRequest(String urlString) { |
|||
try { |
|||
URL url = new URL(urlString); |
|||
URLConnection urlcon = url.openConnection(); |
|||
InputStream stream = urlcon.getInputStream(); |
|||
StringBuilder responseBuilder = new StringBuilder(); |
|||
int i; |
|||
while ((i = stream.read()) != -1) { |
|||
responseBuilder.append((char) i); |
|||
} |
|||
stream.close(); |
|||
|
|||
// Parse the response |
|||
String response = responseBuilder.toString(); |
|||
//System.out.println("Raw Response: " + response); |
|||
|
|||
// Check ResultStatus in the response |
|||
if (response.contains("\"ResultStatus\": true")) { |
|||
//System.out.println("ResultStatus is true in the response."); |
|||
return true; |
|||
} else { |
|||
System.out.println("ResultStatus is false or not present in the response."); |
|||
return false; |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
|
|||
public void saveMobileNumDetails(String complaintNumber, String remarks) { |
|||
String query = "insert into officer_mobileno (complaint_number,remarks) values(?,?)"; |
|||
int rowsUpdated = jdbcTemplate.update(query, complaintNumber, remarks); |
|||
//System.out.println("Rows Updated: " + rowsUpdated); |
|||
} |
|||
|
|||
public Map<String,Object> checkComplaintDetail(String complaintNumber) { |
|||
String query = "select id,complaint_number from qaqc_followup_call_logs where complaint_number = ?"; |
|||
try { |
|||
return jdbcTemplate.queryForMap(query, complaintNumber); |
|||
} catch (Exception e) { |
|||
System.out.println("Complaint number not found"); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public void updateFollowupCallLogs(String complaintNumber, String action, String remarks, int followupid) { |
|||
//System.out.println(complaintNumber+action+remarks); |
|||
|
|||
String query = "update gcc_1913_qaqc.qaqc_followup_call_logs set call_status = ?,remarks = ? where complaint_number= ? and id =?"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks, complaintNumber, followupid); |
|||
//System.out.println("Rows Updated in followup: " + rowsUpdated); |
|||
|
|||
} |
|||
|
|||
public List<Map<String, Object>> getSubmitDetails(int userId) { |
|||
|
|||
String query = "SELECT complaint_number, complaint_date,complaint_person_name, complaint_mobilenumber, " + |
|||
"complaint_type, call_status, remarks " + |
|||
"FROM gcc_1913_qaqc.qaqc_upload_data " + |
|||
"WHERE agent_id = ? AND call_category = 'CLOSED' AND is_processed = '1'"; |
|||
|
|||
return jdbcTemplate.queryForList(query,userId); |
|||
|
|||
} |
|||
|
|||
public void updateComplaintHistoryDetails(String complaintNumber, int dataId, String action, String remarks,int updated_agent, |
|||
String remainderDate) { |
|||
|
|||
String query = "UPDATE gcc_1913_qaqc.qaqc_upload_data_history \r\n" |
|||
+ "SET call_status = ?, remarks = ?, updated_date = CURRENT_TIMESTAMP, remainder_date = ?,updated_agent=?\r\n" |
|||
+ "WHERE data_id = ? AND complaint_number = ? AND call_category = 'CLOSED'"; |
|||
|
|||
int rowsUpdated = jdbcTemplate.update(query, action, remarks, remainderDate,updated_agent, dataId, complaintNumber); |
|||
|
|||
//System.out.println("Rows Updated in upload history: " + rowsUpdated); |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,357 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.io.InputStream; |
|||
import java.net.URL; |
|||
import java.net.URLConnection; |
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.sql.Connection; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.SQLException; |
|||
import java.time.LocalDate; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
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.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class QaqcService { |
|||
|
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getFollowUpDetailsByStatus(String callStatus, LocalDate fromDate, LocalDate toDate) { |
|||
// Start the SQL query |
|||
String sql = "SELECT " + |
|||
"f.id, " + |
|||
"f.qaqc_id, " + |
|||
"f.call_category, " + |
|||
"f.complaint_number, " + |
|||
"f.agent_id, " + |
|||
"f.complaint_person_name, " + |
|||
"f.complaint_mobilenumber, " + |
|||
"f.complaint_type, " + |
|||
"f.complaint_mode, " + |
|||
"f.department, " + |
|||
"f.complaint_group, " + |
|||
"f.official_name, " + |
|||
"f.official_mobilenum, " + |
|||
"f.call_status, " + |
|||
"f.remainder_date, " + |
|||
"f.remarks, " + |
|||
"f.created_date, " + |
|||
"r.taskid " + |
|||
"FROM qaqc_followup_call_logs f " + |
|||
"LEFT JOIN qaqc_request r ON f.qaqc_id = r.qaqc_id "; |
|||
|
|||
// List to hold the query parameters |
|||
List<Object> params = new ArrayList<>(); |
|||
boolean hasCondition = false; |
|||
|
|||
// Filter by callStatus if provided |
|||
if (callStatus != null && !callStatus.isEmpty()) { |
|||
sql += " WHERE f.call_status = ?"; |
|||
params.add(callStatus); |
|||
hasCondition = true; |
|||
} |
|||
|
|||
// Filter by date range (fromDate to toDate) if both are provided |
|||
if (fromDate != null && toDate != null) { |
|||
if (hasCondition) { |
|||
sql += " AND f.remainder_date BETWEEN ? AND ?"; |
|||
} else { |
|||
sql += " WHERE f.remainder_date BETWEEN ? AND ?"; |
|||
hasCondition = true; |
|||
} |
|||
params.add(fromDate); |
|||
params.add(toDate); |
|||
} |
|||
// If only fromDate is provided |
|||
else if (fromDate != null) { |
|||
if (hasCondition) { |
|||
sql += " AND f.remainder_date >= ?"; |
|||
} else { |
|||
sql += " WHERE f.remainder_date >= ?"; |
|||
hasCondition = true; |
|||
} |
|||
params.add(fromDate); |
|||
} |
|||
// If only toDate is provided (include records with remainder_date greater than toDate) |
|||
else if (toDate != null) { |
|||
if (hasCondition) { |
|||
sql += " AND (f.remainder_date <= ? OR f.remainder_date > ?)"; |
|||
} else { |
|||
sql += " WHERE (f.remainder_date <= ? OR f.remainder_date > ?)"; |
|||
hasCondition = true; |
|||
} |
|||
params.add(toDate); // <= toDate condition |
|||
params.add(toDate); // > toDate condition |
|||
} |
|||
|
|||
// Final debugging: print the query and parameters |
|||
//System.out.println("Final SQL Query: " + sql); |
|||
//System.out.println("Query Parameters: " + params); |
|||
|
|||
// Execute the query with the dynamically added parameters |
|||
return jdbcTemplate.queryForList(sql, params.toArray()); |
|||
} |
|||
|
|||
/* |
|||
|
|||
public Map<String, Long> countFollowUpsByDateAndStatus(LocalDate today, String followupStatus) { |
|||
String sqlNotClosed = "SELECT COUNT(*) FROM qaqc_followup_call_logs " + |
|||
"WHERE call_status = ? AND DATE(remainder_date) = ? AND call_category NOT IN ('CLOSED')"; |
|||
|
|||
String sqlClosed = "SELECT COUNT(*) FROM qaqc_followup_call_logs " + |
|||
"WHERE call_status = ? AND DATE(remainder_date) = ? AND call_category IN ('CLOSED')"; |
|||
|
|||
long countNotClosed = jdbcTemplate.queryForObject(sqlNotClosed, new Object[]{followupStatus, today}, Long.class); |
|||
long countClosed = jdbcTemplate.queryForObject(sqlClosed, new Object[]{followupStatus, today}, Long.class); |
|||
|
|||
Map<String, Long> result = new HashMap<>(); |
|||
result.put("officialfollowup", countNotClosed); |
|||
result.put("publicfollowup", countClosed); |
|||
|
|||
return result; |
|||
} |
|||
*/ |
|||
public Map<String, Long> countFollowUpsByDateAndStatus(LocalDate today, String followupStatus) { |
|||
String sqlNotClosed = "SELECT COUNT(*) FROM qaqc_followup_call_logs " + |
|||
"WHERE call_status = ? AND DATE(remainder_date) = ? AND call_category NOT IN ('CLOSED','PUBLICFOLLOWUP')"; |
|||
|
|||
String sqlClosed = "SELECT COUNT(*) FROM qaqc_followup_call_logs " + |
|||
"WHERE call_status = ? AND DATE(remainder_date) = ? AND call_category IN ('CLOSED','PUBLICFOLLOWUP')"; |
|||
|
|||
long countNotClosed = jdbcTemplate.queryForObject(sqlNotClosed, new Object[]{followupStatus, today}, Long.class); |
|||
long countClosed = jdbcTemplate.queryForObject(sqlClosed, new Object[]{followupStatus, today}, Long.class); |
|||
|
|||
Map<String, Long> result = new HashMap<>(); |
|||
result.put("officialfollowup", countNotClosed); |
|||
result.put("publicfollowup", countClosed); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getUnattendedlist(Integer ucount) { |
|||
|
|||
String query1="SELECT \r\n" |
|||
+ " MIN(complaint_date) AS complaint_date, \r\n" |
|||
+ " MIN(call_category) AS call_category, \r\n" |
|||
+ " MIN(complaint_person_name) AS complaint_person_name, \r\n" |
|||
+ " MIN(complaint_mobilenumber) AS complaint_mobilenumber, \r\n" |
|||
+ " complaint_number AS complaint_number, \r\n" |
|||
+ " MIN(complaint_group) AS complaint_group, \r\n" |
|||
+ " MIN(complaint_type) AS complaint_type, \r\n" |
|||
+ " MIN(complaint_mode) AS complaint_mode \r\n" |
|||
+ " FROM qaqc_upload_data_history \r\n" |
|||
+ " WHERE unattended_msg = 0 \r\n" |
|||
+ " AND call_status = 'UNATTENDED' \r\n" |
|||
+ " AND call_category IN ('CLOSED', 'PUBLICFOLLOWUP') \r\n" |
|||
+ " GROUP BY complaint_number \r\n" |
|||
+ " HAVING COUNT(*) >= ? \r\n" |
|||
+ " LIMIT 100"; |
|||
|
|||
|
|||
// Log query and parameters for debugging |
|||
//System.out.println("Executing query: " + query1); |
|||
//System.out.println("With parameters: " + ucount); |
|||
|
|||
List<Map<String, Object>> results = jdbcTemplate.queryForList(query1, ucount); |
|||
|
|||
// Log results for debugging |
|||
//System.out.println("Query results: " + results); |
|||
|
|||
return results.isEmpty() ? Collections.emptyList() : results; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public boolean ChangeStatusInErp(String complaintNumber,String erp_name,String remarks) { |
|||
String baseUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?"; |
|||
String status = "11"; |
|||
|
|||
//String Erpname ="QAops1"; |
|||
|
|||
try { |
|||
// Encode parameters |
|||
String encodedComplaintNumber = URLEncoder.encode(complaintNumber, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
String encodedRemarks = URLEncoder.encode(remarks, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
String encodedErpname = URLEncoder.encode(erp_name, StandardCharsets.UTF_8.toString()).replace("+", "%20"); |
|||
|
|||
//System.out.println("encodedComplaintNumber===="+encodedComplaintNumber); |
|||
//System.out.println("encodedErpname===="+encodedErpname); |
|||
//System.out.println("encodedRemarks===="+encodedRemarks); |
|||
|
|||
// Construct the URL |
|||
String urlString = baseUrl |
|||
+ "serviceId=UpdateComplaint" |
|||
+ "&ComplaintId=" + encodedComplaintNumber |
|||
+ "&Message=" + encodedRemarks |
|||
+ "&UserType=Official" |
|||
+ "&Status=" + status |
|||
+ "&Comp_Image=" |
|||
+ "&erp_username=" + encodedErpname; |
|||
|
|||
System.out.println("ERP Hitting URL="+urlString); |
|||
|
|||
// Send the request |
|||
return sendRequest(urlString); |
|||
|
|||
//return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
|
|||
private boolean sendRequest(String urlString) { |
|||
try { |
|||
URL url = new URL(urlString); |
|||
URLConnection urlcon = url.openConnection(); |
|||
InputStream stream = urlcon.getInputStream(); |
|||
StringBuilder responseBuilder = new StringBuilder(); |
|||
int i; |
|||
while ((i = stream.read()) != -1) { |
|||
responseBuilder.append((char) i); |
|||
} |
|||
stream.close(); |
|||
|
|||
// Parse the response |
|||
String response = responseBuilder.toString(); |
|||
//System.out.println("Raw Response: " + response); |
|||
|
|||
// Check ResultStatus in the response |
|||
if (response.contains("\"ResultStatus\": true")) { |
|||
//System.out.println("ResultStatus is true in the response."); |
|||
return true; |
|||
} else { |
|||
System.out.println("ResultStatus is false or not present in the response."); |
|||
return false; |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
|
|||
public String getErpusernamebyId(String userId) { |
|||
|
|||
String query="SELECT erp_username FROM gcc_1913_qaqc.agents_list\r\n" |
|||
+ "where calling_type='1913ADMIN' and agent_id=?"; |
|||
|
|||
//System.out.println("query"+query); |
|||
|
|||
//String erpUsername = jdbcTemplate.queryForObject(query,new Object[]{userId},String.class); |
|||
String erpUsername = jdbcTemplate.queryForObject(query,String.class,userId); |
|||
|
|||
return erpUsername; |
|||
} |
|||
|
|||
|
|||
|
|||
public int UpdateInHistoryTable(List<String> completedComplaints) { |
|||
int totalUpdated = 0; |
|||
|
|||
for (String cnum : completedComplaints) { |
|||
String query = "UPDATE qaqc_upload_data_history SET unattended_msg = 1 WHERE complaint_number = ?"; |
|||
|
|||
// Update using JdbcTemplate and accumulate the count |
|||
int rowsUpdated = jdbcTemplate.update(query, cnum); |
|||
|
|||
// Accumulate the number of successfully updated rows |
|||
totalUpdated += rowsUpdated; |
|||
} |
|||
|
|||
return totalUpdated; // Return the total number of updated rows |
|||
} |
|||
|
|||
|
|||
|
|||
public int insertInLogs(List<String> completedComplaints,String remarks,String userId) { |
|||
|
|||
int totalUpdated = 0; |
|||
int rowsUpdated=0; |
|||
|
|||
for (String cnum : completedComplaints) { |
|||
|
|||
List<Map<String,Object>>details=getComplaintsLatestDetails(cnum); |
|||
|
|||
if(!details.isEmpty()) { |
|||
|
|||
for (Map<String, Object> detail : details) { |
|||
int qaqc_id = Integer.parseInt(detail.get("qaqc_id").toString()); |
|||
String call_category = "UNATTENDED"; |
|||
int agent_id = Integer.parseInt(detail.get("agent_id").toString()); |
|||
|
|||
// # id, qaqc_id, call_category, agent_id, complaint_number, complaint_date, complaint_person_name, |
|||
// complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, |
|||
// call_status, remainder_date, remarks, created_date, is_processed, updated_agent |
|||
String complaint_number = detail.get("complaint_number").toString(); |
|||
String complaint_date = detail.get("complaint_date").toString(); |
|||
String complaint_person_name = detail.get("complaint_person_name").toString(); |
|||
String complaint_mobilenumber = detail.get("complaint_mobilenumber").toString(); |
|||
String complaint_type = detail.get("complaint_type").toString(); |
|||
String complaint_mode = detail.get("complaint_mode").toString(); |
|||
String department = detail.get("department").toString(); |
|||
String complaint_group = detail.get("complaint_group").toString(); |
|||
String official_name = detail.get("official_name").toString(); |
|||
String official_mobilenum = detail.get("official_mobilenum").toString(); |
|||
String call_status = "COMPLETED"; |
|||
String upremarks=remarks; |
|||
int is_processed=1; |
|||
int updated_agent = Integer.parseInt(userId); |
|||
|
|||
String query = "INSERT INTO gcc_1913_qaqc.qaqc_call_logs (qaqc_id, call_category, agent_id, complaint_number, complaint_date,complaint_person_name, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, call_status, remarks, is_processed,updated_agent) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?)"; |
|||
|
|||
rowsUpdated = jdbcTemplate.update(query, qaqc_id, call_category, agent_id, complaint_number,complaint_date, complaint_person_name, |
|||
complaint_mobilenumber, complaint_type, complaint_mode, department, complaint_group, official_name, official_mobilenum, call_status, upremarks, |
|||
is_processed,updated_agent); |
|||
|
|||
totalUpdated += rowsUpdated; |
|||
|
|||
} |
|||
|
|||
} |
|||
else { |
|||
return 0; |
|||
} |
|||
|
|||
} |
|||
|
|||
return totalUpdated; |
|||
} |
|||
|
|||
|
|||
public List<Map<String,Object>> getComplaintsLatestDetails(String complaint_number){ |
|||
|
|||
String query = "SELECT * FROM qaqc_upload_data_history WHERE complaint_number = ? ORDER BY created_date DESC LIMIT 1"; |
|||
|
|||
List<Map<String,Object>> getCompNumber = jdbcTemplate.queryForList(query, complaint_number); |
|||
|
|||
return getCompNumber; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,291 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.util.ArrayList; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
import javax.transaction.Transactional; |
|||
|
|||
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 QaqcTaskListService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
// old overalltaskcount wise method |
|||
|
|||
// public List<Map<String, Object>> getComplaintAndCallStatusCounts(String startDate, String endDate) { |
|||
// String sql = "SELECT " + |
|||
// "t1.total_tasks, " + |
|||
// "t2.total_calls, " + |
|||
// "t3.completed_calls, " + |
|||
// "t2.total_calls - t3.completed_calls AS pending_calls " + |
|||
// "FROM " + |
|||
// "( " + |
|||
// " SELECT " + |
|||
// " COUNT(qaqc_id) AS total_tasks " + |
|||
// " FROM " + |
|||
// " qaqc_request " + |
|||
// " WHERE " + |
|||
// " (? IS NULL OR created_date BETWEEN ? AND ?) " + |
|||
// ") AS t1, " + |
|||
// "( " + |
|||
// " SELECT " + |
|||
// " SUM(total_data) AS total_calls " + |
|||
// " FROM " + |
|||
// " qaqc_request " + |
|||
// " WHERE " + |
|||
// " (? IS NULL OR created_date BETWEEN ? AND ?) " + |
|||
// ") AS t2, " + |
|||
// "( " + |
|||
// " SELECT " + |
|||
// " SUM(qr.total_data) AS total_data, " + |
|||
// " COUNT(CASE WHEN qcl.qaqc_id IS NOT NULL THEN qcl.qaqc_id END) AS completed_calls " + |
|||
// " FROM " + |
|||
// " qaqc_request qr " + |
|||
// " LEFT JOIN " + |
|||
// " qaqc_call_logs qcl " + |
|||
// " ON " + |
|||
// " qr.qaqc_id = qcl.qaqc_id " + |
|||
// " WHERE " + |
|||
// " (? IS NULL OR qcl.created_date BETWEEN ? AND ?) " + |
|||
// ") AS t3;"; |
|||
// |
|||
// // Prepare the parameters for the query |
|||
// Object[] params = new Object[] { |
|||
// startDate, startDate, endDate, |
|||
// startDate, startDate, endDate, |
|||
// startDate, startDate, endDate |
|||
// }; |
|||
// |
|||
// // Execute the query and return the results as a List of Maps |
|||
// return jdbcTemplate.queryForList(sql, params); |
|||
// } |
|||
|
|||
|
|||
|
|||
//updated overalltaskcount method |
|||
public List<Map<String, Object>> getComplaintAndCallStatusCounts(String startDate, String endDate) { |
|||
// Start constructing the SQL query dynamically |
|||
StringBuilder sql = new StringBuilder(); |
|||
sql.append("SELECT ") |
|||
.append("t1.total_tasks, ") |
|||
.append("t2.total_calls, ") |
|||
.append("t3.completed_calls, ") |
|||
.append("t2.total_calls - t3.completed_calls AS pending_calls, ") |
|||
.append("t4.no_of_agents ") |
|||
.append("FROM ") |
|||
.append("( ") |
|||
.append(" SELECT ") |
|||
.append(" COUNT(qaqc_id) AS total_tasks ") |
|||
.append(" FROM ") |
|||
.append(" qaqc_request qr "); |
|||
|
|||
// Adding dynamic WHERE conditions for date range if provided |
|||
if (startDate != null && endDate != null) { |
|||
sql.append("WHERE DATE(qr.created_date) >= ? AND DATE(qr.created_date) <= ? "); |
|||
} |
|||
|
|||
sql.append(") AS t1, ") |
|||
.append("( ") |
|||
.append(" SELECT ") |
|||
.append(" SUM(aa.data_count) AS total_calls ") |
|||
.append(" FROM ") |
|||
.append(" agent_assigned aa ") |
|||
.append(" INNER JOIN ") |
|||
.append(" qaqc_request qr ") |
|||
.append(" ON ") |
|||
.append(" aa.qaqc_id = qr.qaqc_id "); |
|||
|
|||
if (startDate != null && endDate != null) { |
|||
sql.append("WHERE DATE(qr.created_date) >= ? AND DATE(qr.created_date) <= ? "); |
|||
} |
|||
|
|||
sql.append(") AS t2, ") |
|||
.append("( ") |
|||
.append(" SELECT ") |
|||
.append(" SUM(qr.total_data) AS total_data, ") |
|||
.append(" COUNT(CASE WHEN qcl.call_status IS NOT NULL THEN qcl.qaqc_id END) AS completed_calls ") |
|||
.append(" FROM ") |
|||
.append(" qaqc_request qr ") |
|||
.append(" LEFT JOIN ") |
|||
.append(" qaqc_upload_data_history qcl ") |
|||
.append(" ON ") |
|||
.append(" qr.qaqc_id = qcl.qaqc_id "); |
|||
|
|||
if (startDate != null && endDate != null) { |
|||
sql.append("WHERE DATE(qcl.created_date) >= ? AND DATE(qcl.created_date) <= ? "); |
|||
} |
|||
|
|||
sql.append(") AS t3, ") |
|||
.append("( ") |
|||
.append(" SELECT ") |
|||
.append(" COUNT(DISTINCT aa.agent_id) AS no_of_agents ") |
|||
.append(" FROM ") |
|||
.append(" agent_assigned aa "); |
|||
|
|||
if (startDate != null && endDate != null) { |
|||
sql.append("WHERE DATE(aa.created_date) >= ? AND DATE(aa.created_date) <= ? "); |
|||
} |
|||
|
|||
sql.append(") AS t4;"); |
|||
|
|||
// Prepare the parameters dynamically based on the presence of the date range |
|||
List<Object> params = new ArrayList<>(); |
|||
if (startDate != null && endDate != null) { |
|||
params.add(startDate); |
|||
params.add(endDate); |
|||
params.add(startDate); |
|||
params.add(endDate); |
|||
params.add(startDate); |
|||
params.add(endDate); |
|||
params.add(startDate); |
|||
params.add(endDate); |
|||
} |
|||
|
|||
// Execute the query and return the results as a List of Maps |
|||
return jdbcTemplate.queryForList(sql.toString(), params.toArray()); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
//old taskwise querymethod |
|||
|
|||
// public List<Map<String, Object>> getTaskwiseData(String startDate, String endDate) { |
|||
// // Base query |
|||
// StringBuilder query = new StringBuilder( |
|||
// "SELECT " + |
|||
// " qr.taskid, " + |
|||
// " MAX(qr.total_data) AS Assigned, " + |
|||
// " MAX(qr.created_date) AS TaskCreatedDate, " + |
|||
// " COUNT(CASE WHEN acl.qaqc_id IS NOT NULL THEN qr.qaqc_id END) AS TotalCompleted, " + |
|||
// " MAX(qr.total_data) - COUNT(CASE WHEN acl.qaqc_id IS NOT NULL THEN qr.qaqc_id END) AS Pending, " + // Pending calculated as Assigned - TotalCompleted |
|||
// " COUNT(CASE WHEN acl.call_status = 'COMPLETED' THEN 1 END) AS Completed, " + |
|||
// " COUNT(CASE WHEN acl.call_status = 'REOPENED' THEN 1 END) AS Reopened, " + |
|||
// " COUNT(CASE WHEN acl.call_status = 'FOLLOWUP' THEN 1 END) AS Followup " + |
|||
// "FROM qaqc_request qr " + |
|||
// "LEFT JOIN qaqc_call_logs acl " + |
|||
// "ON qr.qaqc_id = acl.qaqc_id " |
|||
// ); |
|||
// |
|||
// // Adding dynamic WHERE conditions for date range |
|||
// if (startDate != null && endDate != null) { |
|||
// query.append("WHERE qr.created_date BETWEEN ? AND ? "); |
|||
// } |
|||
// |
|||
// // Grouping by taskid |
|||
// query.append("GROUP BY qr.taskid"); |
|||
// |
|||
// // Query Execution |
|||
// if (startDate != null && endDate != null) { |
|||
// return jdbcTemplate.queryForList(query.toString(), startDate, endDate); |
|||
// } else { |
|||
// return jdbcTemplate.queryForList(query.toString()); |
|||
// } |
|||
// } |
|||
|
|||
|
|||
//updated taskwisedata query method |
|||
|
|||
public List<Map<String, Object>> getTaskwiseData(String startDate, String endDate) { |
|||
// Base query with subqueries for Assigned and Pending calculations |
|||
StringBuilder query = new StringBuilder( |
|||
"SELECT " + |
|||
" qr.qaqc_id, " + |
|||
" qr.taskid, " + |
|||
" qr.call_category, " + |
|||
" qr.description, " + |
|||
" (" + |
|||
" SELECT SUM(aa.data_count) " + |
|||
" FROM agent_assigned aa " + |
|||
" WHERE aa.qaqc_id = qr.qaqc_id" + |
|||
" ) AS Assigned, " + |
|||
" MAX(DATE(qr.created_date)) AS TaskCreatedDate, " + |
|||
" COUNT(CASE WHEN acl.call_status IS NOT NULL THEN acl.qaqc_id END) AS TotalCompleted, " + |
|||
" (" + |
|||
" SELECT SUM(aa.data_count) " + |
|||
" FROM agent_assigned aa " + |
|||
" WHERE aa.qaqc_id = qr.qaqc_id" + |
|||
" ) - COUNT(CASE WHEN acl.call_status IS NOT NULL THEN acl.qaqc_id END) AS Pending, " + |
|||
" COUNT(CASE WHEN acl.call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 END) AS Completed, " + |
|||
" COUNT(CASE WHEN acl.call_status = 'REOPEN' THEN 1 END) AS Reopened, " + |
|||
" COUNT(CASE WHEN acl.call_status = 'FOLLOWUP' THEN 1 END) AS Followup, " + |
|||
" COUNT(CASE WHEN acl.call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 ELSE NULL END) AS Others " + |
|||
"FROM qaqc_request qr " + |
|||
"LEFT JOIN qaqc_upload_data_history acl " + |
|||
"ON qr.qaqc_id = acl.qaqc_id " |
|||
); |
|||
|
|||
// Adding dynamic WHERE conditions for date range if provided |
|||
if (startDate != null && endDate != null) { |
|||
query.append("WHERE DATE(qr.created_date) >= ? AND DATE(qr.created_date) <= ? "); |
|||
} |
|||
|
|||
// Grouping by taskid and qaqc_id to calculate Assigned and Pending |
|||
query.append("GROUP BY qr.taskid, qr.qaqc_id "); |
|||
|
|||
// Adding ORDER BY clause for descending order of created_date |
|||
query.append("ORDER BY TaskCreatedDate DESC, qr.qaqc_id DESC"); |
|||
|
|||
// Query execution with parameters for start and end dates if available |
|||
if (startDate != null && endDate != null) { |
|||
return jdbcTemplate.queryForList(query.toString(), startDate, endDate); |
|||
} else { |
|||
return jdbcTemplate.queryForList(query.toString()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getAgentwiseData(String qaqc_id) { |
|||
|
|||
String query= "SELECT DISTINCT \r\n" |
|||
+ " al.agent_id,\r\n" |
|||
+ " al.agent_name AS agentName,\r\n" |
|||
+ " qr.taskid AS taskId,\r\n" |
|||
+ " qr.fromdate AS fromdate,\r\n" |
|||
+ " qr.todate AS todate,\r\n" |
|||
+ " qr.description AS description,\r\n" |
|||
+ " qr.call_category AS call_category,\r\n" |
|||
+ " qr.complaint_region AS complaint_region,\r\n" |
|||
+ " qr.complaint_group AS complaint_group,\r\n" |
|||
+ " qr.complaint_type AS complaint_type,\r\n" |
|||
+ " qr.complaint_mode AS complaint_mode,\r\n" |
|||
+ " qr.complaint_zone AS complaint_zone,\r\n" |
|||
+ " DATE(qr.created_date) AS TaskCreatedDate,\r\n" |
|||
+ " aa.data_count AS assigned,\r\n" |
|||
+ " COUNT(lcl.call_status) AS callstaken,\r\n" |
|||
+ " (aa.data_count - COUNT(lcl.call_status)) AS pending,\r\n" |
|||
+ " ROUND((COUNT(lcl.call_status) / aa.data_count) * 100, 2) AS percentage,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status IN ('COMPLETED', 'FOLLOWUP_COMPLETED') THEN 1 END) AS Completed,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status = 'REOPEN' THEN 1 END) AS Reopened,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status = 'FOLLOWUP' THEN 1 END) AS Followup,\r\n" |
|||
+ " COUNT(CASE WHEN lcl.call_status NOT IN ('COMPLETED', 'FOLLOWUP_COMPLETED', 'REOPEN', 'FOLLOWUP') THEN 1 END) AS Others\r\n" |
|||
+ "FROM qaqc_request qr\r\n" |
|||
+ "JOIN agent_assigned aa ON aa.qaqc_id = qr.qaqc_id\r\n" |
|||
+ "JOIN agents_list al ON al.agent_id = aa.agent_id\r\n" |
|||
+ "LEFT JOIN qaqc_upload_data_history lcl ON qr.qaqc_id = lcl.qaqc_id AND al.agent_id = lcl.agent_id \r\n" |
|||
+ "WHERE qr.qaqc_id = ?\r\n" |
|||
+ "GROUP BY al.agent_id, al.agent_name, aa.data_count"; |
|||
|
|||
return jdbcTemplate.queryForList(query, qaqc_id); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,361 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
import java.util.HashSet; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Objects; |
|||
import java.util.Set; |
|||
import java.util.stream.Collectors; |
|||
|
|||
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.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class ScpService { |
|||
|
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysqlScpDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
|
|||
// Method to enrich report data with questions_part |
|||
public List<Map<String, Object>> enrichScpReportWithQuestions(List<Map<String, Object>> reportData) { |
|||
|
|||
// Step 1: Fetch all questions |
|||
String questionSql = "SELECT id AS question_id, questions AS question, answer_type, isactive, isdelete FROM questions WHERE isactive=1 AND isdelete=0"; |
|||
List<Map<String, Object>> questionList = jdbcTemplate.queryForList(questionSql); |
|||
|
|||
// Step 2: Fetch all answers (master answers) |
|||
String answerSql = "SELECT question_id, answer FROM answers WHERE isactive=1 AND isdelete=0"; |
|||
List<Map<String, Object>> answerList = jdbcTemplate.queryForList(answerSql); |
|||
|
|||
// Convert answerList to Map<question_id, List<String>> for easy mapping |
|||
Map<Integer, List<String>> answerMasterMap = new HashMap<>(); |
|||
for (Map<String, Object> ans : answerList) { |
|||
Integer qid = (Integer) ans.get("question_id"); |
|||
String answerVal = (String) ans.get("answer"); |
|||
answerMasterMap.computeIfAbsent(qid, k -> new ArrayList<>()).add(answerVal); |
|||
} |
|||
/* |
|||
// Step 3: Fetch all scp_report entries for these scp_ids |
|||
List<Long> scpIds = reportData.stream() |
|||
.map(d -> ((Number) d.get("id")).longValue()) |
|||
.collect(Collectors.toList()); |
|||
|
|||
// Step 4: Get existing scp_ids from scp_report |
|||
Set<Long> existingScpIds = new HashSet<>(); |
|||
if (!scpIds.isEmpty()) { |
|||
String inClause = scpIds.stream().map(id -> "?").collect(Collectors.joining(",")); |
|||
String sql = "SELECT DISTINCT scp_id FROM scp_report WHERE isactive=1 AND isdelete=0 AND scp_id IN (" + inClause + ")"; |
|||
List<Map<String, Object>> existingList = jdbcTemplate.queryForList(sql, scpIds.toArray()); |
|||
for (Map<String, Object> row : existingList) { |
|||
existingScpIds.add(((Number) row.get("scp_id")).longValue()); |
|||
} |
|||
} |
|||
|
|||
// Step 5: Filter out already answered scp_ids |
|||
List<Map<String, Object>> filteredReportData = reportData.stream() |
|||
.filter(d -> !existingScpIds.contains(((Number) d.get("id")).longValue())) |
|||
.collect(Collectors.toList()); |
|||
*/ |
|||
// Step 3: Fetch all scp_report entries for these scp_ids |
|||
List<Long> scpIds = new ArrayList<Long>(); |
|||
for (Map<String, Object> d : reportData) { |
|||
Object idObj = d.get("id"); |
|||
if (idObj instanceof Number) { |
|||
scpIds.add(((Number) idObj).longValue()); |
|||
} |
|||
} |
|||
|
|||
// Step 4: Get existing scp_ids from scp_report |
|||
Set<Long> existingScpIds = new HashSet<Long>(); |
|||
if (!scpIds.isEmpty()) { |
|||
// Build the IN clause placeholders |
|||
StringBuilder inClause = new StringBuilder(); |
|||
for (int i = 0; i < scpIds.size(); i++) { |
|||
if (i > 0) inClause.append(","); |
|||
inClause.append("?"); |
|||
} |
|||
|
|||
String sql = "SELECT DISTINCT scp_id FROM scp_report WHERE isactive=1 AND isdelete=0 AND scp_id IN (" |
|||
+ inClause.toString() + ")"; |
|||
List<Map<String, Object>> existingList = jdbcTemplate.queryForList(sql, scpIds.toArray()); |
|||
for (Map<String, Object> row : existingList) { |
|||
Object scpIdObj = row.get("scp_id"); |
|||
if (scpIdObj instanceof Number) { |
|||
existingScpIds.add(((Number) scpIdObj).longValue()); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// Step 5: Filter out already answered scp_ids |
|||
List<Map<String, Object>> filteredReportData = new ArrayList<Map<String, Object>>(); |
|||
for (Map<String, Object> d : reportData) { |
|||
Object idObj = d.get("id"); |
|||
if (idObj instanceof Number) { |
|||
Long id = ((Number) idObj).longValue(); |
|||
if (!existingScpIds.contains(id)) { |
|||
filteredReportData.add(d); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// Step 6: Attach questions only to the filtered list |
|||
for (Map<String, Object> report : filteredReportData) { |
|||
Long scpId = ((Number) report.get("id")).longValue(); |
|||
List<Map<String, Object>> questionsPart = new ArrayList<>(); |
|||
|
|||
for (Map<String, Object> question : questionList) { |
|||
Integer qid = (Integer) question.get("question_id"); |
|||
|
|||
Map<String, Object> questionPart = new HashMap<>(); |
|||
questionPart.put("question_id", qid); |
|||
questionPart.put("question", question.get("question")); |
|||
questionPart.put("answer_type", question.get("answer_type")); |
|||
questionPart.put("answer_master", answerMasterMap.getOrDefault(qid, Collections.emptyList())); |
|||
|
|||
// Empty answers since these scp_ids don’t exist yet |
|||
Map<String, Object> answersMap = new HashMap<>(); |
|||
answersMap.put("scp_id", scpId); |
|||
answersMap.put("question_id", qid); |
|||
answersMap.put("answer", null); |
|||
answersMap.put("agent_id", null); |
|||
|
|||
questionPart.put("answers", answersMap); |
|||
questionsPart.add(questionPart); |
|||
} |
|||
|
|||
report.put("questions_part", questionsPart); |
|||
} |
|||
|
|||
return filteredReportData; |
|||
} |
|||
|
|||
|
|||
// public boolean saveAnswers(List<Map<String, Object>> answers) { |
|||
// if (answers == null || answers.isEmpty()) return false; |
|||
// |
|||
// String sql = "INSERT INTO scp_report (scp_id, question_id, answer, agent_id, zone, ward, streetid, street_name, last_feedback_date) " |
|||
// + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
|||
// |
|||
// int[][] result = jdbcTemplate.batchUpdate(sql, answers, answers.size(), (ps, answer) -> { |
|||
// |
|||
// // Convert safely to String or Integer |
|||
// String scpIdStr = getSafeString(answer.get("scp_id")); |
|||
// String questionIdStr = getSafeString(answer.get("question_id")); |
|||
// String answerStr = getSafeString(answer.get("answer")); |
|||
// String agentIdStr = getSafeString(answer.get("agent_id")); |
|||
// String zone = getSafeString(answer.get("zone")); |
|||
// String ward = getSafeString(answer.get("ward")); |
|||
// String streetId = getSafeString(answer.get("street_id")); |
|||
// String streetName = getSafeString(answer.get("street_name")); |
|||
// String lastFeedback = getSafeString(answer.get("lastfeedback")); |
|||
// |
|||
// // Parse integers only if not null |
|||
// Integer scpId = (scpIdStr != null) ? Integer.parseInt(scpIdStr) : null; |
|||
// Integer questionId = (questionIdStr != null) ? Integer.parseInt(questionIdStr) : null; |
|||
// Integer agentId = (agentIdStr != null) ? Integer.parseInt(agentIdStr) : null; |
|||
// |
|||
// // Set parameters |
|||
// ps.setObject(1, scpId); |
|||
// ps.setObject(2, questionId); |
|||
// ps.setObject(3, answerStr); |
|||
// ps.setObject(4, agentId); |
|||
// ps.setObject(5, zone); |
|||
// ps.setObject(6, ward); |
|||
// ps.setObject(7, streetId); |
|||
// ps.setObject(8, streetName); |
|||
// ps.setObject(9, lastFeedback); |
|||
// }); |
|||
// |
|||
// return result.length > 0; |
|||
// } |
|||
|
|||
public String saveAnswers(List<Map<String, Object>> answers) { |
|||
if (answers == null || answers.isEmpty()) return "error"; |
|||
/* |
|||
// Step 1: Extract unique scp_ids from the list |
|||
List<Integer> scpIds = answers.stream() |
|||
.map(a -> { |
|||
String idStr = getSafeString(a.get("scp_id")); |
|||
return (idStr != null) ? Integer.parseInt(idStr) : null; |
|||
}) |
|||
.filter(Objects::nonNull) |
|||
.distinct() |
|||
.toList(); |
|||
*/ |
|||
// Step 1: Extract unique scp_ids from the list |
|||
List<Integer> scpIds = new ArrayList<Integer>(); |
|||
Set<Integer> uniqueIds = new HashSet<Integer>(); |
|||
|
|||
for (Map<String, Object> a : answers) { |
|||
Object scpIdObj = a.get("scp_id"); |
|||
String idStr = getSafeString(scpIdObj); |
|||
if (idStr != null) { |
|||
try { |
|||
Integer id = Integer.parseInt(idStr); |
|||
if (!uniqueIds.contains(id)) { |
|||
uniqueIds.add(id); |
|||
scpIds.add(id); |
|||
} |
|||
} catch (NumberFormatException e) { |
|||
// Skip invalid numbers |
|||
} |
|||
} |
|||
} |
|||
|
|||
// Step 2: Check if any of these scp_ids already exist in DB |
|||
String checkSql = "SELECT COUNT(*) FROM scp_report WHERE scp_id IN (:ids)"; |
|||
Map<String, Object> params = new HashMap<>(); |
|||
params.put("ids", scpIds); |
|||
|
|||
NamedParameterJdbcTemplate namedJdbc = new NamedParameterJdbcTemplate(jdbcTemplate); |
|||
Integer count = namedJdbc.queryForObject(checkSql, params, Integer.class); |
|||
|
|||
if (count != null && count > 0) { |
|||
// Duplicate found — stop processing |
|||
return "duplicate"; |
|||
} |
|||
|
|||
// Step 3: Insert new answers |
|||
String insertSql = "INSERT INTO scp_report (scp_id, question_id, answer, agent_id, zone, ward, streetid, street_name, last_feedback_date) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
|||
|
|||
int[][] result = jdbcTemplate.batchUpdate(insertSql, answers, answers.size(), (ps, answer) -> { |
|||
String scpIdStr = getSafeString(answer.get("scp_id")); |
|||
String questionIdStr = getSafeString(answer.get("question_id")); |
|||
String answerStr = getSafeString(answer.get("answer")); |
|||
String agentIdStr = getSafeString(answer.get("agent_id")); |
|||
String zone = getSafeString(answer.get("zone")); |
|||
String ward = getSafeString(answer.get("ward")); |
|||
String streetId = getSafeString(answer.get("street_id")); |
|||
String streetName = getSafeString(answer.get("street_name")); |
|||
String lastFeedback = getSafeString(answer.get("lastfeedback")); |
|||
|
|||
Integer scpId = (scpIdStr != null) ? Integer.parseInt(scpIdStr) : null; |
|||
Integer questionId = (questionIdStr != null) ? Integer.parseInt(questionIdStr) : null; |
|||
Integer agentId = (agentIdStr != null) ? Integer.parseInt(agentIdStr) : null; |
|||
|
|||
ps.setObject(1, scpId); |
|||
ps.setObject(2, questionId); |
|||
ps.setObject(3, answerStr); |
|||
ps.setObject(4, agentId); |
|||
ps.setObject(5, zone); |
|||
ps.setObject(6, ward); |
|||
ps.setObject(7, streetId); |
|||
ps.setObject(8, streetName); |
|||
ps.setObject(9, lastFeedback); |
|||
}); |
|||
|
|||
return (result.length > 0) ? "success" : "error"; |
|||
} |
|||
|
|||
|
|||
// Helper method |
|||
private String getSafeString(Object val) { |
|||
if (val == null) return null; |
|||
String s = val.toString().trim(); |
|||
return s.isEmpty() ? null : s; |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getZoneWiseReportData() { |
|||
String sql = "SELECT " |
|||
+ "sr.zone," |
|||
+ " COALESCE(COUNT(DISTINCT sr.scp_id), 0) AS Completed," |
|||
+ " SUM(CASE WHEN sr.answer = 'Yes' THEN 1 ELSE 0 END) AS YesCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'No' THEN 1 ELSE 0 END) AS NoCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Available' THEN 1 ELSE 0 END) AS AvailableCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Not Available' THEN 1 ELSE 0 END) AS NotAvailableCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Image Not Clear' THEN 1 ELSE 0 END) AS ImageNotClearCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Yes,it is in good condition' THEN 1 ELSE 0 END) AS LidGoodYesCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'No,it is not in good condition' THEN 1 ELSE 0 END) AS LidGoodNoCount" |
|||
+ " FROM scp_report sr" |
|||
+ " WHERE sr.isactive = 1 AND sr.isdelete = 0" |
|||
+ " GROUP BY sr.zone" |
|||
+ " ORDER BY sr.zone"; |
|||
|
|||
return jdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getWardWiseReportData(String zone) { |
|||
String sql = "SELECT " |
|||
+ "sr.zone," |
|||
+ "sr.ward," |
|||
+ " COALESCE(COUNT(DISTINCT sr.scp_id), 0) AS Completed," |
|||
+ " SUM(CASE WHEN sr.answer = 'Yes' THEN 1 ELSE 0 END) AS YesCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'No' THEN 1 ELSE 0 END) AS NoCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Available' THEN 1 ELSE 0 END) AS AvailableCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Not Available' THEN 1 ELSE 0 END) AS NotAvailableCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Image Not Clear' THEN 1 ELSE 0 END) AS ImageNotClearCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Yes,it is in good condition' THEN 1 ELSE 0 END) AS LidGoodYesCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'No,it is not in good condition' THEN 1 ELSE 0 END) AS LidGoodNoCount" |
|||
+ " FROM scp_report sr" |
|||
+ " WHERE sr.isactive = 1 AND sr.isdelete = 0 AND sr.zone= ?" |
|||
+ " GROUP BY sr.zone,sr.ward" |
|||
+ " ORDER BY sr.zone,sr.ward"; |
|||
|
|||
return jdbcTemplate.queryForList(sql,zone); |
|||
} |
|||
|
|||
public List<Map<String, Object>> getStreetWiseReportData(String zone,String ward) { |
|||
String sql = "SELECT " |
|||
+ "sr.zone," |
|||
+ "sr.ward," |
|||
+ "sr.streetid," |
|||
+ " COALESCE(COUNT(DISTINCT sr.scp_id), 0) AS Completed," |
|||
+ " SUM(CASE WHEN sr.answer = 'Yes' THEN 1 ELSE 0 END) AS YesCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'No' THEN 1 ELSE 0 END) AS NoCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Available' THEN 1 ELSE 0 END) AS AvailableCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Not Available' THEN 1 ELSE 0 END) AS NotAvailableCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Image Not Clear' THEN 1 ELSE 0 END) AS ImageNotClearCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Yes,it is in good condition' THEN 1 ELSE 0 END) AS LidGoodYesCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'No,it is not in good condition' THEN 1 ELSE 0 END) AS LidGoodNoCount" |
|||
+ " FROM scp_report sr" |
|||
+ " WHERE sr.isactive = 1 AND sr.isdelete = 0 AND sr.zone=? AND sr.ward=?" |
|||
+ " GROUP BY sr.streetid, sr.street_name,sr.zone,sr.ward" |
|||
+ " ORDER BY sr.zone,sr.ward,sr.streetid"; |
|||
|
|||
return jdbcTemplate.queryForList(sql,zone,ward); |
|||
} |
|||
|
|||
|
|||
public List<Map<String,Object>> getdetailreport(String startDate, String endDate) { |
|||
|
|||
|
|||
String sql = "SELECT " |
|||
+ "sr.zone," |
|||
+ "sr.ward," |
|||
+ "sr.street_name," |
|||
+ " COALESCE(COUNT(DISTINCT sr.scp_id), 0) AS Completed," |
|||
+ " SUM(CASE WHEN sr.answer = 'Yes' THEN 1 ELSE 0 END) AS YesCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'No' THEN 1 ELSE 0 END) AS NoCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Available' THEN 1 ELSE 0 END) AS AvailableCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Not Available' THEN 1 ELSE 0 END) AS NotAvailableCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Image Not Clear' THEN 1 ELSE 0 END) AS ImageNotClearCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'Yes,it is in good condition' THEN 1 ELSE 0 END) AS LidGoodYesCount," |
|||
+ " SUM(CASE WHEN sr.answer = 'No,it is not in good condition' THEN 1 ELSE 0 END) AS LidGoodNoCount" |
|||
+ " FROM scp_report sr" |
|||
+ " WHERE sr.isactive = 1 AND sr.isdelete = 0 AND DATE(sr.created_date) BETWEEN ? AND ?" |
|||
+ " GROUP BY sr.streetid, sr.street_name,sr.zone,sr.ward" |
|||
+ " ORDER BY sr.zone,sr.ward,sr.streetid"; |
|||
|
|||
return jdbcTemplate.queryForList(sql,startDate,endDate); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,822 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.ArrayList; |
|||
import java.util.Base64; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.awt.image.BufferedImage; |
|||
import java.io.BufferedReader; |
|||
import java.io.ByteArrayInputStream; |
|||
import java.io.ByteArrayOutputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.io.InputStreamReader; |
|||
import java.io.OutputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.net.URLConnection; |
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.sql.Timestamp; |
|||
import java.text.SimpleDateFormat; |
|||
import java.time.LocalDate; |
|||
import java.util.HashMap; |
|||
|
|||
import javax.imageio.ImageIO; |
|||
import javax.imageio.ImageWriteParam; |
|||
import javax.imageio.ImageWriter; |
|||
import javax.imageio.stream.ImageOutputStream; |
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.core.env.Environment; |
|||
import org.springframework.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 org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.vendor.service.DateTimeUtil; |
|||
|
|||
@Service |
|||
@Transactional |
|||
public class SocialMediaService { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
@Autowired |
|||
@Qualifier("vendorDateTimeUtil") |
|||
private DateTimeUtil dateTimeUtil; |
|||
|
|||
private final Environment environment; |
|||
|
|||
private String fileBaseUrl; |
|||
|
|||
public SocialMediaService(Environment environment,RestTemplate restTemplate) { |
|||
this.restTemplate=restTemplate; |
|||
this.environment = environment; |
|||
this.fileBaseUrl = environment.getProperty("fileBaseUrl"); |
|||
} |
|||
|
|||
@Transactional |
|||
public int uploadComplaintDetailsInLogs(Map<String, Object> details,String action,String remarks,int updated_agent,String remainderDate) { |
|||
//System.out.println("Complaint Details: " + details); |
|||
// Extract other field values from complaintDetails |
|||
String complaintNumber = details.get("complaintid").toString(); |
|||
String complaintDate = details.get("complaintdate").toString(); |
|||
String personName = details.get("complainantName").toString(); |
|||
String personMobNo = details.get("mobileNumber").toString(); |
|||
String cType = details.get("complaintType").toString(); |
|||
String cMode = details.get("compmode").toString(); |
|||
String department = details.get("deptname").toString(); |
|||
String officialName = details.get("Officialname").toString(); |
|||
String officialMobileNum = details.get("OfficialMobile").toString(); |
|||
String callStatus = action; |
|||
String remarksfield = remarks; |
|||
String zone = details.get("Zone").toString(); |
|||
int updated_by=updated_agent; |
|||
String cur_status = details.get("currentStatus").toString(); |
|||
|
|||
String finalremainderDate=null; |
|||
if(!remainderDate.isEmpty()) { |
|||
finalremainderDate=remainderDate; |
|||
} |
|||
|
|||
LocalDateTime currentDate = LocalDateTime.now(); |
|||
|
|||
String query = "INSERT INTO gcc_1913_qaqc.social_media_completed (complaint_number,zone,complaint_date, complaint_person_name,remarks, " |
|||
+ "complaint_mobilenumber, complaint_type, complaint_mode, department, official_name,official_mobilenum, call_status,created_date,updated_by,cur_status,remainder_date) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?)"; |
|||
|
|||
int rowsAffected = jdbcTemplate.update(query, complaintNumber,zone, complaintDate,personName,remarksfield, |
|||
personMobNo, cType, cMode, department, officialName, officialMobileNum,callStatus, |
|||
currentDate,updated_by,cur_status,finalremainderDate); |
|||
//System.out.println("Rows Inserted in table : " + rowsAffected); |
|||
|
|||
return rowsAffected; |
|||
|
|||
} |
|||
|
|||
public List<Map<String, Object>> getdetails(String formattedFromDate, String formattedToDate, String status, String zone) { |
|||
StringBuilder query = new StringBuilder("SELECT *,DATE_FORMAT(remainder_date, '%d/%m/%Y') as formatted_fdate FROM gcc_1913_qaqc.social_media_completed WHERE DATE(created_date) BETWEEN ? AND ? "); |
|||
List<Object> params = new ArrayList<>(); |
|||
params.add(formattedFromDate); |
|||
params.add(formattedToDate); |
|||
|
|||
if (zone != null && !zone.isEmpty()) { |
|||
query.append(" AND zone = ?"); |
|||
params.add(zone); |
|||
} |
|||
|
|||
if (status != null && !status.equals("ALL")) { |
|||
query.append(" AND call_status = ?"); |
|||
params.add(status); |
|||
} |
|||
|
|||
// Execute the query |
|||
List<Map<String, Object>> results = jdbcTemplate.queryForList(query.toString(), params.toArray()); |
|||
|
|||
|
|||
return results.isEmpty() ? null : results; |
|||
} |
|||
|
|||
public String getErpusernamebyId(String userId) { |
|||
|
|||
String query="SELECT erp_username FROM gcc_1913_qaqc.agents_list " |
|||
+ "where calling_type='SOCIALMEDIA' and agent_id=?"; |
|||
|
|||
//System.out.println("query====="+query); |
|||
|
|||
//String erpUsername = jdbcTemplate.queryForObject(query,new Object[]{userId},String.class); |
|||
String erpUsername = jdbcTemplate.queryForObject(query,String.class,userId); |
|||
|
|||
return erpUsername; |
|||
} |
|||
|
|||
public String get1913AdminErpusernamebyId(String userId) { |
|||
|
|||
String query="SELECT erp_username FROM gcc_1913_qaqc.agents_list " |
|||
+ "where agent_id=?"; |
|||
|
|||
//System.out.println("query====="+query); |
|||
|
|||
//String erpUsername = jdbcTemplate.queryForObject(query,new Object[]{userId},String.class); |
|||
String erpUsername = jdbcTemplate.queryForObject(query,String.class,userId); |
|||
|
|||
return erpUsername; |
|||
} |
|||
|
|||
public List<Map<String, Object>> getA1dropdowns() { |
|||
String sql="SELECT * FROM call_status WHERE isactive=1 AND isdelete=0 AND call_category_id=5"; |
|||
try { |
|||
return jdbcTemplate.queryForList(sql); |
|||
} catch (Exception ex) { |
|||
ex.printStackTrace(); |
|||
return new ArrayList<>(); // return empty list on error |
|||
} |
|||
} |
|||
|
|||
public List<Map<String, Object>> getA2dropdowns() { |
|||
String sql="SELECT * FROM call_status WHERE isactive=1 AND isdelete=0 AND call_category_id=6"; |
|||
try { |
|||
return jdbcTemplate.queryForList(sql); |
|||
} catch (Exception ex) { |
|||
ex.printStackTrace(); |
|||
return new ArrayList<>(); // return empty list on error |
|||
} |
|||
} |
|||
|
|||
public List<Map<String, Object>> getfiltreddetails(List<Map<String, Object>> details) { |
|||
|
|||
List<Map<String, Object>> followupData = getFollowupData(); |
|||
|
|||
if (followupData == null || followupData.isEmpty()) { |
|||
return details; |
|||
} |
|||
|
|||
// if(details.isEmpty()) { |
|||
// return details; |
|||
// } |
|||
|
|||
LocalDate currentDate = LocalDate.now(); |
|||
|
|||
// Store complaint_number -> followup row |
|||
Map<String, Map<String, Object>> followupMap = new HashMap<>(); |
|||
|
|||
for (Map<String, Object> followup : followupData) { |
|||
|
|||
String complaintNumber = String.valueOf(followup.get("complaint_number")); |
|||
|
|||
followupMap.put(complaintNumber, followup); |
|||
} |
|||
|
|||
List<Map<String, Object>> filteredDetails = new ArrayList<>(); |
|||
|
|||
for (Map<String, Object> detail : details) { |
|||
|
|||
String complaintNumber =String.valueOf(detail.get("Complaint Number")); |
|||
|
|||
// If complaint not in followup table |
|||
if (!followupMap.containsKey(complaintNumber)) { |
|||
|
|||
filteredDetails.add(detail); |
|||
continue; |
|||
} |
|||
|
|||
Map<String, Object> followupRow =followupMap.get(complaintNumber); |
|||
|
|||
String remainderDateStr =String.valueOf(followupRow.get("remainder_date")); |
|||
|
|||
LocalDate remainderDate = LocalDate.parse(remainderDateStr); |
|||
|
|||
// remainder_date <= current date |
|||
if (!remainderDate.isAfter(currentDate)) { |
|||
|
|||
// UPDATE is_processed = 0 |
|||
Integer id = (Integer) followupRow.get("id"); |
|||
|
|||
updateFollowupProcessed(id); |
|||
|
|||
filteredDetails.add(detail); |
|||
} |
|||
|
|||
// ELSE: |
|||
// remainder_date > currentDate |
|||
// skip / eliminate from frontend |
|||
} |
|||
|
|||
return filteredDetails; |
|||
} |
|||
|
|||
private void updateFollowupProcessed(Integer id) { |
|||
|
|||
String sql = |
|||
"UPDATE social_media_completed " + |
|||
"SET is_processed = 0 " + |
|||
"WHERE id = ?"; |
|||
|
|||
jdbcTemplate.update(sql, id); |
|||
} |
|||
|
|||
private List<Map<String, Object>> getFollowupData() { |
|||
String sqlQuery = "select id, complaint_number,call_status, remainder_date from social_media_completed where is_processed=1 AND call_status='FOLLOWUP'"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
public Map<String, Object> checkRegisteredComplaint(String complaintNumber) { |
|||
|
|||
Map<String, Object> result = new HashMap<>(); |
|||
|
|||
String sql = "SELECT is_processed " |
|||
+ " FROM socialmedia_reg_completed " |
|||
+ " WHERE complaint_number = ? AND isactive=1 AND isdelete=0 " |
|||
+ " LIMIT 1"; |
|||
|
|||
List<Map<String, Object>> list = |
|||
jdbcTemplate.queryForList(sql, complaintNumber); |
|||
|
|||
// Case 1 |
|||
if (list.isEmpty()) { |
|||
result.put("status", "NOT_FOUND"); |
|||
return result; |
|||
} |
|||
|
|||
Boolean isProcessed = (Boolean) list.get(0).get("is_processed"); |
|||
|
|||
if (!isProcessed) { |
|||
result.put("status", "PENDING_APPROVAL"); |
|||
} else { |
|||
result.put("status", "PROCESSED"); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
public Map<String, Object> submitRegClosingComplaint( |
|||
String complaintNumber, |
|||
String remarks, |
|||
MultipartFile resolvedImage, |
|||
String cby) { |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
Integer loginId = Integer.parseInt(cby); |
|||
|
|||
String imagePath = fileUpload(resolvedImage, "resolved_img"); |
|||
|
|||
String sql = "INSERT INTO socialmedia_reg_completed " |
|||
+ "(complaint_number, resolved_img, remarks, cby) " |
|||
+ "VALUES (?, ?, ?, ?)"; |
|||
|
|||
int rows = jdbcTemplate.update( |
|||
sql, |
|||
complaintNumber, |
|||
imagePath, |
|||
remarks, |
|||
loginId |
|||
); |
|||
|
|||
if (rows > 0) { |
|||
response.put("status", "SUCCESS"); |
|||
response.put("message", "Complaint submitted successfully for admin approval."); |
|||
} else { |
|||
response.put("status", "FAILED"); |
|||
response.put("message", "Unable to submit complaint."); |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
|
|||
e.printStackTrace(); |
|||
|
|||
response.put("status", "error"); |
|||
response.put("message", e.getMessage() != null |
|||
? e.getMessage() |
|||
: "Something went wrong while submitting complaint."); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
public String fileUpload(MultipartFile file, String name) { |
|||
|
|||
// Set the file path where you want to save it |
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
String serviceFolderName = environment.getProperty("socialmedia_1913_regcomp_foldername"); |
|||
var year = DateTimeUtil.getCurrentYear(); |
|||
var month = DateTimeUtil.getCurrentMonth(); |
|||
|
|||
uploadDirectory = uploadDirectory + serviceFolderName + "/" + year + "/" + month; |
|||
|
|||
try { |
|||
// Create directory if it doesn't exist |
|||
Path directoryPath = Paths.get(uploadDirectory); |
|||
if (!Files.exists(directoryPath)) { |
|||
Files.createDirectories(directoryPath); |
|||
} |
|||
|
|||
// Datetime string |
|||
String datetimetxt = DateTimeUtil.getCurrentDateTime(); |
|||
|
|||
// File name |
|||
String fileName = name + "_" + datetimetxt + "_" + file.getOriginalFilename(); |
|||
fileName = fileName.replaceAll("\\s+", ""); // Remove space on filename |
|||
|
|||
String filePath = uploadDirectory + "/" + fileName; |
|||
|
|||
String filepath_txt = "/" + serviceFolderName + "/" + year + "/" + month + "/" + fileName; |
|||
|
|||
// Create a new Path object |
|||
Path path = Paths.get(filePath); |
|||
|
|||
// Get the bytes of the file |
|||
byte[] bytes = file.getBytes(); |
|||
|
|||
|
|||
BufferedImage image = ImageIO.read(new ByteArrayInputStream(bytes)); |
|||
byte[] compressedBytes = compressImage(image, 0.5f); // Compress with 50%quality |
|||
|
|||
// Write the bytes to the file |
|||
Files.write(path, bytes); |
|||
|
|||
// Write the bytes to the file |
|||
Files.write(path, compressedBytes); |
|||
|
|||
|
|||
//System.out.println(filePath); |
|||
return filepath_txt; |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return "Failed to save file " + file.getOriginalFilename(); |
|||
} |
|||
} |
|||
|
|||
private byte[] compressImage(BufferedImage image, float quality) throws IOException { |
|||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
|||
ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(byteArrayOutputStream); |
|||
|
|||
ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next(); |
|||
writer.setOutput(imageOutputStream); |
|||
|
|||
ImageWriteParam param = writer.getDefaultWriteParam(); |
|||
if (param.canWriteCompressed()) { |
|||
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
|||
param.setCompressionQuality(quality); |
|||
} |
|||
|
|||
writer.write(null, new javax.imageio.IIOImage(image, null, null), param); |
|||
|
|||
writer.dispose(); |
|||
imageOutputStream.close(); |
|||
|
|||
return byteArrayOutputStream.toByteArray(); |
|||
} |
|||
|
|||
|
|||
public Map<String, Object> getDetailsByComplaintNumber(String complaintNumber) { |
|||
|
|||
Map<String, Object> resultMap = new HashMap<>(); |
|||
|
|||
try { |
|||
String url = "https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=getComplaintByID&ComplaintId=" |
|||
+ complaintNumber + "&imgUrlonly=yes&isQcuser=Yes&jsonResp=Yes"; |
|||
//System.out.println("Request URL: " + url); |
|||
|
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); |
|||
|
|||
if (responseEntity.getStatusCode().is2xxSuccessful()) { |
|||
String responseBody = responseEntity.getBody(); |
|||
//System.out.println("Response Body: " + responseBody); |
|||
|
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JsonNode rootNode = mapper.readTree(responseBody); |
|||
|
|||
JsonNode complaintDetails = rootNode.path(0).path("ComplaintListHistory").path(0); |
|||
|
|||
String registerDate=complaintDetails.path("complaintopendate").asText("N/A"); |
|||
//System.out.println("registerdate====="+registerDate); |
|||
|
|||
String formattedDate = "N/A"; // Default value if parsing fails |
|||
|
|||
if (!registerDate.equals("N/A") && !registerDate.isEmpty()) { |
|||
try { |
|||
// Parse the input date string |
|||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); |
|||
Date date = inputFormat.parse(registerDate); |
|||
|
|||
// Format the date to dd-MM-yyyy |
|||
SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy"); |
|||
formattedDate = outputFormat.format(date); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); // Log exception for debugging |
|||
} |
|||
} |
|||
|
|||
if (!complaintDetails.isMissingNode()) { |
|||
// Existing fields |
|||
resultMap.put("complaintid", complaintDetails.path("complaintid").asText("N/A")); |
|||
resultMap.put("complaintdate", formattedDate); |
|||
resultMap.put("complainantName", complaintDetails.path("CustomerName").asText("N/A")); |
|||
resultMap.put("mobileNumber", complaintDetails.path("CustomerMobile").asText("N/A")); |
|||
resultMap.put("complaintType", complaintDetails.path("complainttype").asText("N/A")); |
|||
resultMap.put("description", complaintDetails.path("complaintdetails").asText("N/A")); |
|||
resultMap.put("currentStatus", complaintDetails.path("complaintcurrentstatus").asText("N/A")); |
|||
resultMap.put("Street", complaintDetails.path("Street").asText("N/A")); |
|||
resultMap.put("Area", complaintDetails.path("Area").asText("N/A")); |
|||
resultMap.put("Landmark", complaintDetails.path("Landmark").asText("N/A")); |
|||
resultMap.put("Location", complaintDetails.path("Location").asText("N/A")); |
|||
resultMap.put("Zone", complaintDetails.path("Zone").asText("N/A")); |
|||
resultMap.put("Division", complaintDetails.path("Division").asText("N/A")); |
|||
resultMap.put("OfficialMobile", complaintDetails.path("OfficialMobile").asText("N/A")); |
|||
resultMap.put("gender", complaintDetails.path("GENDER").asText("N/A")); |
|||
resultMap.put("deptname",complaintDetails.path("DEPT_NAME").asText("N/A")); |
|||
resultMap.put("compmode", complaintDetails.path("COMP_MODE").asText("N/A")); |
|||
resultMap.put("Officialname", complaintDetails.path("Officialname").asText("N/A")); |
|||
|
|||
|
|||
} |
|||
} else { |
|||
resultMap.put("error", "Failed to retrieve complaint details."); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
resultMap.put("error", "Error processing request"); |
|||
} |
|||
|
|||
return resultMap; |
|||
} |
|||
|
|||
public Map<String, Object> getFilteredRegComps() { |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
String sql = |
|||
"SELECT src.complaint_number, src.created_date,CONCAT('" + fileBaseUrl + "/gcc/files',src.resolved_img) AS img_full_path,al.agent_name as agent_name,src.remarks as remarks" + |
|||
" FROM socialmedia_reg_completed src " |
|||
+ " LEFT JOIN agents_list al ON al.agent_id=src.cby " + |
|||
"WHERE src.is_processed = 0 " + |
|||
"AND src.isactive = 1 " + |
|||
"AND src.isdelete = 0"; |
|||
|
|||
List<Map<String, Object>> dbList = jdbcTemplate.queryForList(sql); |
|||
|
|||
List<Map<String, Object>> finalList = new ArrayList<>(); |
|||
|
|||
for (Map<String, Object> row : dbList) { |
|||
|
|||
String complaintNumber = |
|||
String.valueOf(row.get("complaint_number")); |
|||
|
|||
Map<String, Object> complaintDetails = |
|||
getDetailsByComplaintNumber(complaintNumber); |
|||
|
|||
String currentStatus = |
|||
String.valueOf( |
|||
complaintDetails.getOrDefault( |
|||
"currentStatus", |
|||
"" |
|||
) |
|||
); |
|||
|
|||
//System.out.println("currentStatus==="+currentStatus); |
|||
|
|||
if ("REGISTERED".equalsIgnoreCase(currentStatus) |
|||
|| "FORWARDED".equalsIgnoreCase(currentStatus)) { |
|||
|
|||
Map<String, Object> resultRow = new HashMap<>(); |
|||
|
|||
resultRow.put("complaintnumber", complaintNumber); |
|||
//resultRow.put("submitted_date", row.get("created_date")); |
|||
Timestamp ts = (Timestamp) row.get("created_date"); |
|||
|
|||
SimpleDateFormat sdf = |
|||
new SimpleDateFormat("dd/MM/yyyy HH:mm"); |
|||
|
|||
resultRow.put("submitted_date", sdf.format(ts)); |
|||
|
|||
String img = (String) row.get("img_full_path"); |
|||
resultRow.put("img_full_path", img); |
|||
|
|||
String agent_name = (String) row.get("agent_name"); |
|||
resultRow.put("agent_name", agent_name); |
|||
|
|||
String remarks = (String) row.get("remarks"); |
|||
resultRow.put("remarks", remarks); |
|||
|
|||
finalList.add(resultRow); |
|||
|
|||
} else { |
|||
|
|||
String updateSql = |
|||
"UPDATE socialmedia_reg_completed " + |
|||
"SET updated_by = ?, " + |
|||
"updated_date = NOW(), " + |
|||
"isactive = 0, " + |
|||
"isdelete = 1 " + |
|||
"WHERE complaint_number = ?"; |
|||
|
|||
jdbcTemplate.update( |
|||
updateSql, |
|||
0, |
|||
complaintNumber |
|||
); |
|||
} |
|||
} |
|||
|
|||
if (finalList.isEmpty()) { |
|||
|
|||
response.put("status", "nodata"); |
|||
response.put("message", "No registered complaints found."); |
|||
|
|||
} else { |
|||
|
|||
response.put("status", "success"); |
|||
response.put("details", finalList); |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
|
|||
e.printStackTrace(); |
|||
|
|||
response.put("status", "error"); |
|||
response.put("message", e.getMessage()); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
public Map<String, Object> approveComplaint(String complaintId, String remarks, String imgFullPath, String userid) { |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
|
|||
Integer updated_by = Integer.parseInt(userid); |
|||
|
|||
String erp_name=get1913AdminErpusernamebyId(userid); |
|||
|
|||
boolean statusUpdated = |
|||
ChangeStatusInErp( |
|||
complaintId, |
|||
"ActionLevel1", |
|||
remarks, |
|||
erp_name, |
|||
imgFullPath); |
|||
|
|||
if (!statusUpdated) { |
|||
response.put("status", "FAILED"); |
|||
response.put("message", "Unable to move complaint to Action Level 1."); |
|||
return response; |
|||
} |
|||
|
|||
boolean statusUpdated1 = |
|||
ChangeStatusInErp( |
|||
complaintId, |
|||
"Close", |
|||
remarks, |
|||
erp_name, |
|||
""); |
|||
|
|||
if (!statusUpdated1) { |
|||
response.put("status", "FAILED"); |
|||
response.put("message", "Unable to move complaint to Close."); |
|||
return response; |
|||
} |
|||
|
|||
String sql="UPDATE socialmedia_reg_completed " |
|||
+ "SET is_processed = 1, " |
|||
+ " updated_by = ?, " |
|||
+ " updated_date = NOW() " |
|||
+ "WHERE complaint_number = ? AND isactive=1 AND isdelete=0"; |
|||
|
|||
int rows=jdbcTemplate.update(sql,updated_by,complaintId); |
|||
|
|||
if (rows > 0) { |
|||
response.put("status", "SUCCESS"); |
|||
response.put("message", "Complaint Closed successfully."); |
|||
} else { |
|||
response.put("status", "FAILED"); |
|||
response.put("message", "Complaint Closed,Unable to insert in logs."); |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
|
|||
e.printStackTrace(); |
|||
|
|||
response.put("status", "error"); |
|||
response.put("message", e.getMessage() != null |
|||
? e.getMessage() |
|||
: "Something went wrong while submitting complaint."); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
public boolean ChangeStatusInErp(String complaintNumber,String action ,String remarks,String erp_name,String imgFullPath) { |
|||
String baseUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; |
|||
String status = ""; |
|||
|
|||
|
|||
try { |
|||
|
|||
// Determine status based on action |
|||
if ("ActionLevel1".equals(action)) { |
|||
status = "5"; |
|||
} else if ("Close".equals(action)) { |
|||
status = "11"; |
|||
} else { |
|||
return false; // Invalid action, return false |
|||
} |
|||
|
|||
//String img="https://gccservices.in/gccofficialapp/files/app_icon/menu/gcc_survey_icons/Cow.png"; |
|||
|
|||
// Convert image to Base64 |
|||
String base64Image = ""; |
|||
|
|||
if (imgFullPath != null && !imgFullPath.trim().isEmpty()) { |
|||
|
|||
URL imageUrl = new URL(imgFullPath); |
|||
|
|||
try (InputStream inputStream = imageUrl.openStream()) { |
|||
|
|||
byte[] imageBytes = inputStream.readAllBytes(); |
|||
|
|||
base64Image = |
|||
Base64.getEncoder().encodeToString(imageBytes); |
|||
} |
|||
} |
|||
|
|||
String postData = |
|||
"serviceId=" + URLEncoder.encode("UpdateComplaint", "UTF-8") |
|||
+ "&ComplaintId=" + URLEncoder.encode(complaintNumber, "UTF-8") |
|||
+ "&Message=" + URLEncoder.encode(remarks, "UTF-8") |
|||
+ "&UserType=Official" |
|||
+ "&Status=" + status |
|||
+ "&Comp_Image=" + URLEncoder.encode(base64Image, "UTF-8") |
|||
+ "&erp_username=" + URLEncoder.encode(erp_name, "UTF-8"); |
|||
|
|||
|
|||
System.out.println("Complaint = " + complaintNumber); |
|||
System.out.println("Action = " + action); |
|||
System.out.println("Base64 Length = " + base64Image.length()); |
|||
System.out.println("Post Data Length = " + postData.length()); |
|||
|
|||
return sendRequest(baseUrl, postData); |
|||
// return true; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
|
|||
private boolean sendRequest(String urlString, String postData) { |
|||
|
|||
try { |
|||
URL url = new URL(urlString); |
|||
|
|||
HttpURLConnection connection = |
|||
(HttpURLConnection) url.openConnection(); |
|||
|
|||
|
|||
connection.setRequestMethod("POST"); |
|||
connection.setDoOutput(true); |
|||
|
|||
connection.setRequestProperty( |
|||
"Content-Type", |
|||
"application/x-www-form-urlencoded" |
|||
); |
|||
|
|||
//System.out.println("Method = " + connection.getRequestMethod()); |
|||
try (OutputStream os = connection.getOutputStream()) { |
|||
|
|||
byte[] input = postData.getBytes(StandardCharsets.UTF_8); |
|||
|
|||
os.write(input, 0, input.length); |
|||
} |
|||
|
|||
int responseCode = connection.getResponseCode(); |
|||
|
|||
System.out.println("Response Code = " + responseCode); |
|||
System.out.println("Response Message = " + connection.getResponseMessage()); |
|||
|
|||
InputStream stream; |
|||
|
|||
if (responseCode >= 200 && responseCode < 300) { |
|||
stream = connection.getInputStream(); |
|||
} else { |
|||
stream = connection.getErrorStream(); |
|||
} |
|||
|
|||
StringBuilder responseBuilder = new StringBuilder(); |
|||
|
|||
if (stream != null) { |
|||
|
|||
BufferedReader reader = |
|||
new BufferedReader( |
|||
new InputStreamReader(stream)); |
|||
|
|||
String line; |
|||
|
|||
while ((line = reader.readLine()) != null) { |
|||
responseBuilder.append(line); |
|||
} |
|||
|
|||
reader.close(); |
|||
} |
|||
|
|||
String response = responseBuilder.toString(); |
|||
|
|||
System.out.println("ERP Response = " + response); |
|||
|
|||
return response.contains("\"ResultStatus\": true"); |
|||
|
|||
} catch (Exception e) { |
|||
|
|||
e.printStackTrace(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public Map<String, Object> rejectComplaint(String complaintId, String userid) { |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
try { |
|||
Integer updated_by = Integer.parseInt(userid); |
|||
|
|||
String sql="UPDATE socialmedia_reg_completed " |
|||
+ "SET isactive=0,isdelete=1, " |
|||
+ " updated_by = ?, " |
|||
+ " updated_date = NOW() " |
|||
+ "WHERE complaint_number = ? AND isactive=1 AND isdelete=0"; |
|||
|
|||
int rows=jdbcTemplate.update(sql,updated_by,complaintId); |
|||
|
|||
|
|||
if (rows > 0) { |
|||
response.put("status", "SUCCESS"); |
|||
response.put("message", "Complaint Rejected successfully."); |
|||
} else { |
|||
response.put("status", "FAILED"); |
|||
response.put("message", "Unable to Reject the Complaint."); |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
|
|||
e.printStackTrace(); |
|||
|
|||
response.put("status", "error"); |
|||
response.put("message", e.getMessage() != null |
|||
? e.getMessage() |
|||
: "Something went wrong while submitting complaint."); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,274 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
@Service |
|||
public class StatusCountService { |
|||
|
|||
private RestTemplate restTemplate; |
|||
private ObjectMapper objectMapper; |
|||
@Autowired |
|||
private AppConfig appconfig; |
|||
|
|||
public StatusCountService(RestTemplate restTemplate, ObjectMapper objectMapper) { |
|||
this.restTemplate = restTemplate; |
|||
this.objectMapper = objectMapper; |
|||
} |
|||
|
|||
public Map<String, Object> fetchComplaintCounts(String fromDate, String toDate, String compType, String zoneName, String compMode, String compGroup, String region) { |
|||
//https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=common_api&jsonResp=Yes&subService=dashboardAbs&fromDate=&toDate=&compType=&zoneName=&compMode=&compGroup= |
|||
String apiUrl; |
|||
if ("SOCIAL MEDIA".equalsIgnoreCase(compMode)) { |
|||
|
|||
apiUrl = appconfig.qaqcurl+"serviceId=common_api&jsonResp=Yes" |
|||
+ "&subService=dashboardAbs" |
|||
+ "&fromDate=" + fromDate |
|||
+ "&toDate=" + toDate; |
|||
} |
|||
|
|||
else { |
|||
apiUrl = appconfig.qaqcurl+"serviceId=common_api&jsonResp=Yes" |
|||
+ "&subService=dashboardAbs" |
|||
+ "&fromDate=" + fromDate |
|||
+ "&toDate=" + toDate |
|||
+"&excludeMode=7"; |
|||
|
|||
} |
|||
|
|||
// Append parameters based on their availability |
|||
if (!compType.isEmpty()) { |
|||
apiUrl += "&compType=" + compType; |
|||
} |
|||
|
|||
if (!zoneName.isEmpty()) { |
|||
apiUrl += "&zoneName=" + zoneName; |
|||
} |
|||
|
|||
if (!compMode.isEmpty()) { |
|||
apiUrl += "&compMode=" + compMode; |
|||
} |
|||
|
|||
if (!compGroup.isEmpty()) { |
|||
apiUrl += "&compGroup=" + compGroup; |
|||
} |
|||
|
|||
if (!region.isEmpty()) { |
|||
apiUrl += "®ion=" + region; |
|||
} |
|||
|
|||
Map<String, Object> counts = new HashMap<>(); |
|||
System.out.println("url: " + apiUrl); |
|||
|
|||
try { |
|||
// Get the raw response |
|||
String response = restTemplate.getForObject(apiUrl, String.class); |
|||
//System.out.println("API Response: " + response); // Log the response for debugging |
|||
|
|||
JsonNode jsonResponse = objectMapper.readTree(response); |
|||
|
|||
// Check if "ListResult" exists and is an array |
|||
JsonNode listResult = jsonResponse.path("ListResult"); |
|||
|
|||
if (listResult.isArray() && !listResult.isEmpty()) { |
|||
JsonNode resultNode = listResult.get(0); |
|||
if (resultNode != null && !resultNode.isNull()) { |
|||
counts.put("Total Complaints", resultNode.path("RECEIVED").asText("")); |
|||
counts.put("In Progress", resultNode.path("PENDING").asText("")); |
|||
counts.put("Redressed", resultNode.path("REDRESSED").asText("")); |
|||
counts.put("Reopened", resultNode.path("REOPEN").asText("")); |
|||
counts.put("Closed", resultNode.path("CLOSED").asText("")); |
|||
} |
|||
} |
|||
|
|||
//System.out.println(fromDate); |
|||
//System.out.println(toDate); |
|||
|
|||
String url="https://erp.chennaicorporation.gov.in/pgr/newmobileservice?serviceId=ms_dashboard_details&From_date="+fromDate+"&To_date="+toDate+"&jsonResp=Yes&Status=closed&isQcuser=Yes&ComplaintType="+compType+"&ComplaintGroupId="+compGroup+"&compmode="+compMode+"&Zoneid="+zoneName+"&RegionId="+region; |
|||
System.out.println("url==="+url); |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
ResponseEntity<String> response1 = restTemplate.getForEntity(url, String.class); |
|||
String rawResponse = response1.getBody(); |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
Map<String, Object> responseMap = objectMapper.readValue(rawResponse, Map.class); |
|||
List<Map<String, Object>> details = (List<Map<String, Object>>) responseMap.get("Details"); |
|||
/* |
|||
long completedCount = (details == null || details.isEmpty()) ? 0 : |
|||
details.stream().filter(entry -> "Completed".equals(entry.get("Current Status"))).count(); |
|||
*/ |
|||
long completedCount = 0; |
|||
|
|||
if (details != null && !details.isEmpty()) { |
|||
for (Map<String, Object> entry : details) { |
|||
Object statusObj = entry.get("Current Status"); |
|||
if ("Completed".equals(statusObj)) { |
|||
completedCount++; |
|||
} |
|||
} |
|||
} |
|||
|
|||
counts.put("Withdraw", String.valueOf(completedCount)); |
|||
|
|||
int closedCount = Integer.parseInt(String.valueOf(counts.getOrDefault("Closed", "0"))); |
|||
closedCount -= completedCount; // Adjust closed count |
|||
counts.put("Closed", String.valueOf(closedCount)); |
|||
|
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return counts; |
|||
|
|||
} |
|||
|
|||
|
|||
public List<String> fetchComplaintTypes(String compGroup) { |
|||
// Construct the API URL with the compGroup parameter |
|||
String apiUrl = appconfig.qaqcurl + |
|||
"serviceId=common_api&jsonResp=Yes&subService=compTypelist&compGroup=" + compGroup; |
|||
List<String> complaintTypes = new ArrayList<>(); |
|||
|
|||
try { |
|||
// Call the external API |
|||
ResponseEntity<String> response = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
if (response.getStatusCode() == HttpStatus.OK) { |
|||
// Parse the response JSON |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
JsonNode rootNode = objectMapper.readTree(response.getBody()); |
|||
|
|||
// Navigate to "ListResult" and extract "COMPLAINTTYPENAME" |
|||
JsonNode listResultNode = rootNode.path("ListResult"); |
|||
if (listResultNode.isArray()) { |
|||
for (JsonNode item : listResultNode) { |
|||
String complaintTypeName = item.path("COMPLAINTTYPENAME").asText().trim(); |
|||
complaintTypes.add(complaintTypeName); |
|||
} |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
System.err.println("Error fetching complaint types for compGroup " + compGroup + ": " + e.getMessage()); |
|||
} |
|||
|
|||
return complaintTypes; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
//for complaintgroup api |
|||
public List<String> fetchComplaintGroup() { |
|||
String apiUrl = appconfig.qaqcurl+"serviceId=common_api&jsonResp=Yes&subService=compGrouplist"; |
|||
List<String> complaintGroup = new ArrayList(); |
|||
|
|||
try { |
|||
// Call the external API |
|||
ResponseEntity<String> response = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
if (response.getStatusCode() == HttpStatus.OK) { |
|||
// Parse the response JSON |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
JsonNode rootNode = objectMapper.readTree(response.getBody()); |
|||
|
|||
// Navigate to "ListResult" and extract "COMPLAINTTYPENAME" |
|||
JsonNode listResultNode = rootNode.path("ListResult"); |
|||
if (listResultNode.isArray()) { |
|||
for (JsonNode item : listResultNode) { |
|||
String complaintTypeName = item.path("COMPLAINTGROUPNAME").asText().trim(); |
|||
complaintGroup.add(complaintTypeName); |
|||
} |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
System.err.println("Error fetching complaint types: " + e.getMessage()); |
|||
} |
|||
|
|||
return complaintGroup; |
|||
} |
|||
|
|||
|
|||
|
|||
//for modes api |
|||
public List<String> fetchModes() { |
|||
String apiUrl = appconfig.qaqcurl+"serviceId=common_api&jsonResp=Yes&subService=compModelist"; |
|||
List<String> modes = new ArrayList(); |
|||
|
|||
try { |
|||
// Call the external API |
|||
ResponseEntity<String> response = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
if (response.getStatusCode() == HttpStatus.OK) { |
|||
// Parse the response JSON |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
JsonNode rootNode = objectMapper.readTree(response.getBody()); |
|||
|
|||
// Navigate to "ListResult" and extract "COMPLAINTTYPENAME" |
|||
JsonNode listResultNode = rootNode.path("ListResult"); |
|||
if (listResultNode.isArray()) { |
|||
for (JsonNode item : listResultNode) { |
|||
String complaintModeName = item.path("COMP_MODE").asText().trim(); |
|||
modes.add(complaintModeName); |
|||
} |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
System.err.println("Error fetching complaint types: " + e.getMessage()); |
|||
} |
|||
|
|||
return modes; |
|||
} |
|||
|
|||
|
|||
// for zones api |
|||
public List<String> fetchZones() { |
|||
String apiUrl = appconfig.qaqcurl+"serviceId=common_api&jsonResp=Yes&subService=zoneNamelist"; |
|||
List<String> zones = new ArrayList(); |
|||
|
|||
try { |
|||
// Call the external API |
|||
ResponseEntity<String> response = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
if (response.getStatusCode() == HttpStatus.OK) { |
|||
// Parse the response JSON |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
JsonNode rootNode = objectMapper.readTree(response.getBody()); |
|||
|
|||
// Navigate to "ListResult" and extract "COMPLAINTTYPENAME" |
|||
JsonNode listResultNode = rootNode.path("ListResult"); |
|||
if (listResultNode.isArray()) { |
|||
for (JsonNode item : listResultNode) { |
|||
String complaintzone = item.path("NAME").asText().trim(); |
|||
zones.add(complaintzone); |
|||
} |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
System.err.println("Error fetching complaint types: " + e.getMessage()); |
|||
} |
|||
|
|||
return zones; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,234 @@ |
|||
package in.gov.chennaicorporation.gccoffice.callcenterqaqc.service; |
|||
|
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.util.HashMap; |
|||
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.core.env.Environment; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
@Service |
|||
public class WhatsappqaqcMsgService { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
private SocialMediaService socialMediaService; |
|||
|
|||
@Autowired |
|||
private QaqcCallsService qaqcCallsService; |
|||
|
|||
|
|||
@Autowired |
|||
public void setDataSource(@Qualifier("mysql1913QAQCDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
public WhatsappqaqcMsgService(RestTemplate restTemplate) { |
|||
this.restTemplate=restTemplate; |
|||
} |
|||
|
|||
public String sendMsg(String msgUrl, String tamilmsgUrl) { |
|||
StringBuilder response = new StringBuilder(); |
|||
|
|||
|
|||
response.append("English Message Response: ").append(sendWhatsAppMessage(msgUrl)).append("\n"); |
|||
|
|||
|
|||
response.append("Tamil Message Response: ").append(sendWhatsAppMessage(tamilmsgUrl)); |
|||
|
|||
return response.toString(); |
|||
} |
|||
|
|||
private String sendWhatsAppMessage(String urlString) { |
|||
String response = ""; |
|||
try { |
|||
URL url = new URL(urlString); |
|||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
|||
connection.setRequestMethod("GET"); |
|||
|
|||
int responseCode = connection.getResponseCode(); |
|||
response = String.valueOf(responseCode); |
|||
System.out.println("Response Code for URL: " + urlString + " is " + responseCode); |
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return response; |
|||
} |
|||
|
|||
|
|||
|
|||
public String sendSMS(String SMS_Url) { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String response =restTemplate.getForObject(SMS_Url,String.class); |
|||
return response; |
|||
} |
|||
|
|||
public Map<String, Object> checkforwhatsappmsg(String complaintNumber, String action) { |
|||
|
|||
Map<String, Object> response = new HashMap<>(); |
|||
|
|||
boolean result = false; |
|||
|
|||
if ("COMPLETED".equalsIgnoreCase(action)) { |
|||
|
|||
String sql = |
|||
"SELECT call_status " + |
|||
"FROM qaqc_upload_data_history " + |
|||
"WHERE complaint_number=? " + |
|||
"ORDER BY id DESC " + |
|||
"LIMIT 20"; |
|||
|
|||
List<String> statuses = |
|||
jdbcTemplate.queryForList( |
|||
sql, |
|||
String.class, |
|||
complaintNumber); |
|||
|
|||
if (!statuses.isEmpty() |
|||
&& "COMPLETED".equalsIgnoreCase(statuses.get(0))) { |
|||
|
|||
int unattendedCount = 0; |
|||
|
|||
for (int i = 1; i < statuses.size(); i++) { |
|||
|
|||
if ("UNATTENDED".equalsIgnoreCase(statuses.get(i))) { |
|||
unattendedCount++; |
|||
} else { |
|||
break; |
|||
} |
|||
} |
|||
|
|||
result = unattendedCount >= 5; |
|||
} |
|||
} |
|||
|
|||
else if ("UNATTENDED".equalsIgnoreCase(action)) { |
|||
|
|||
String sql = |
|||
"SELECT call_status " + |
|||
"FROM qaqc_upload_data_history " + |
|||
"WHERE complaint_number=? " + |
|||
"ORDER BY id DESC " + |
|||
"LIMIT 5"; |
|||
|
|||
List<String> statuses = |
|||
jdbcTemplate.queryForList( |
|||
sql, |
|||
String.class, |
|||
complaintNumber); |
|||
|
|||
int unattendedCount = 0; |
|||
|
|||
for (String status : statuses) { |
|||
|
|||
if ("UNATTENDED".equalsIgnoreCase(status)) { |
|||
unattendedCount++; |
|||
} else { |
|||
break; |
|||
} |
|||
} |
|||
|
|||
result = unattendedCount >= 3; |
|||
} |
|||
|
|||
response.put("action", action); |
|||
response.put("status", result); |
|||
|
|||
return response; |
|||
} |
|||
|
|||
public String getclosefromuser(String complaintNumber) { |
|||
|
|||
try { |
|||
|
|||
Map<String, Object> complaintDetails =socialMediaService.getDetailsByComplaintNumber(complaintNumber); |
|||
String currentStatus = |
|||
String.valueOf( |
|||
complaintDetails.getOrDefault( |
|||
"currentStatus", |
|||
"" |
|||
) |
|||
); |
|||
|
|||
String Erpname="QAops72"; |
|||
|
|||
if ("Action Taken - Level 2".equalsIgnoreCase(currentStatus)) { |
|||
|
|||
boolean statusUpdated=qaqcCallsService.ChangeStatusInErp(complaintNumber, "", "COMPLETED",Erpname); |
|||
if (statusUpdated) |
|||
{ |
|||
return complaintNumber+ " PGR Complaint closed Successfully"; |
|||
} |
|||
else { |
|||
return "Unable to close "+complaintNumber+" PGR Complaint"; |
|||
} |
|||
} |
|||
else { |
|||
return "Unable to close PGR "+complaintNumber+" Complaint,Because the complaint status is "+currentStatus; |
|||
} |
|||
|
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return "Error in closing PGR complaint from user "+complaintNumber; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
public String getreopenfromuser(String complaintNumber) { |
|||
|
|||
try { |
|||
|
|||
Map<String, Object> complaintDetails =socialMediaService.getDetailsByComplaintNumber(complaintNumber); |
|||
String currentStatus = |
|||
String.valueOf( |
|||
complaintDetails.getOrDefault( |
|||
"currentStatus", |
|||
"" |
|||
) |
|||
); |
|||
|
|||
String Erpname="QAops72"; |
|||
|
|||
if ("Action Taken - Level 2".equalsIgnoreCase(currentStatus)) { |
|||
|
|||
boolean statusUpdated=qaqcCallsService.ChangeStatusInErp(complaintNumber, "", "REOPEN",Erpname); |
|||
if (statusUpdated) |
|||
{ |
|||
return complaintNumber+ " Complaint Reopened Successfully"; |
|||
} |
|||
else { |
|||
return "Unable to Reopen "+complaintNumber+" Complaint"; |
|||
} |
|||
} |
|||
else { |
|||
return "Unable to Reopen "+complaintNumber+" Complaint,Because the complaint status is "+currentStatus; |
|||
} |
|||
|
|||
|
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return "Error in Reopen complaint from user "+complaintNumber; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,174 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwaste.controller; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.cdwaste.service.OfficerService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
|
|||
@RestController |
|||
@RequestMapping("/gcc/api/dumpregistration") |
|||
public class DumpRegistrationAPIController { |
|||
|
|||
|
|||
@Autowired |
|||
private OfficerService officerService; |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
public DumpRegistrationAPIController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/wastecollectorlist") |
|||
public ResponseEntity<String> getWasteCollectorList( |
|||
@RequestParam(required = false) Long mobileNo, |
|||
@RequestParam(required = false) Long refId) { |
|||
|
|||
StringBuilder apiUrl = new StringBuilder(appConfig.dumpregister + "/dumpregistration/api/wastecollectorlist"); |
|||
|
|||
// If at least one param is present, append '?' |
|||
if (mobileNo != null || refId != null) { |
|||
apiUrl.append("?"); |
|||
} |
|||
|
|||
// Append parameters |
|||
List<String> params = new ArrayList<>(); |
|||
if (mobileNo != null) { |
|||
params.add("mobileNo=" + mobileNo); |
|||
} |
|||
if (refId != null) { |
|||
params.add("refId=" + refId); |
|||
} |
|||
|
|||
apiUrl.append(String.join("&", params)); |
|||
|
|||
try { |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl.toString(), String.class); |
|||
return ResponseEntity.ok(responseEntity.getBody()); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Failed to fetch data: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getallcharges") |
|||
public ResponseEntity<String> getpaymentcharges() { |
|||
String apiUrl = appConfig.dumpregister + "/dumpregistration/dropdown/api/getallcharges"; |
|||
|
|||
try { |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return ResponseEntity.ok(responseEntity.getBody()); // Return the real response, not a fixed string |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Failed to fetch data: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
@PostMapping("/saveWasteRequest") |
|||
public ResponseEntity<String> saveWasteRequest(@RequestBody Map<String, Object> payload) { |
|||
try { |
|||
officerService.saveRequestDetails(payload); |
|||
return ResponseEntity.ok("Saved successfully"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error saving request"); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@GetMapping("/getless1tonlist") |
|||
public ResponseEntity<String> getWasteCollectorLess1TonList() { |
|||
StringBuilder apiUrl = new StringBuilder(appConfig.dumpregister + "/dumpregistration/api/getless1tonlist"); |
|||
|
|||
try { |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl.toString(), String.class); |
|||
return ResponseEntity.ok(responseEntity.getBody()); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Failed to fetch data: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@GetMapping("/getless1tonlistbyId") |
|||
public ResponseEntity<String> getWasteCollectorLess1TonListbyId(@RequestParam(required = true) Long refId) { |
|||
if (refId == null) { |
|||
return ResponseEntity.badRequest().body("refId is required"); |
|||
} |
|||
|
|||
try { |
|||
String apiUrl = appConfig.dumpregister + "/dumpregistration/api/getless1tonlistbyid?refId=" + refId; |
|||
|
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return ResponseEntity.ok(responseEntity.getBody()); |
|||
|
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body("Failed to fetch data: " + e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/getAllDetails") |
|||
public ResponseEntity<?> getAllRequestDetails( |
|||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate, |
|||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate, |
|||
@RequestParam(required = false) String wastequantity, |
|||
@RequestParam(required = false) String zone) { |
|||
try { |
|||
|
|||
List<Map<String, Object>> response = officerService.getAllRequestDetails(fromDate, toDate, wastequantity, zone); |
|||
return ResponseEntity.ok(response); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Collections.singletonMap("error", "Failed to fetch data: " + e.getMessage())); |
|||
} |
|||
} |
|||
|
|||
|
|||
@GetMapping("/getquantity") |
|||
public List<Map<String, Object>> getwastequantity() { |
|||
return officerService.getAllwastequantity(); |
|||
} |
|||
|
|||
//fetch all zones |
|||
|
|||
@GetMapping("/getzones") |
|||
public ResponseEntity<?> getAllZones() { |
|||
try { |
|||
List<Map<String, Object>> response = officerService.getZonesList(); |
|||
return ResponseEntity.ok(response); |
|||
} catch (Exception e) { |
|||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) |
|||
.body(Collections.singletonMap("error", "Failed to fetch data: " + e.getMessage())); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,75 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwaste.controller; |
|||
|
|||
|
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
|
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/dumpregistration") |
|||
@Controller("dumpregistrationMainController") |
|||
public class MainController { |
|||
|
|||
private final LoginUserInfo loginUserInfo; |
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
public MainController(RestTemplate restTemplate,LoginUserInfo loginUserInfo, |
|||
AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
this.loginUserInfo = loginUserInfo; |
|||
} |
|||
|
|||
@GetMapping("/officer") |
|||
public String viewOfficer(Model model) |
|||
{ |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
|
|||
return "modules/cdwastecollect/officer"; |
|||
} |
|||
|
|||
|
|||
|
|||
@GetMapping("/lessthanoneton") |
|||
public String viewLessoneTonList(Model model) |
|||
{ |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
|
|||
return "modules/cdwastecollect/lessoneton"; |
|||
} |
|||
|
|||
|
|||
@GetMapping("/overallreport") |
|||
public String wasteCollectionReports(Model model) |
|||
{ |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
|
|||
String UserRole = LoginUserInfo.getUserRole(); |
|||
model.addAttribute("UserRole", UserRole); |
|||
return "modules/cdwastecollect/reports"; |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,195 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwaste.service; |
|||
|
|||
import java.net.URLEncoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.time.LocalDate; |
|||
import java.time.LocalDateTime; |
|||
import java.time.LocalTime; |
|||
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.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
@Service |
|||
public class OfficerService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
@Autowired |
|||
private RestTemplate restTemplate; |
|||
|
|||
@Autowired |
|||
private SMSService smsService; |
|||
|
|||
@Autowired |
|||
public void setDataSourcemysql(@Qualifier("mysqlCDManagerSystemDataSource") DataSource dataSource) { |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
} |
|||
|
|||
|
|||
@Transactional |
|||
public void saveRequestDetails(Map<String, Object> payload) { |
|||
double actualWeight = Double.parseDouble(payload.get("actualWeight").toString()); |
|||
String paymentType = payload.get("paymentType").toString(); |
|||
/* |
|||
* double processingCharge = |
|||
* Double.parseDouble(payload.get("processingCharge").toString()); double |
|||
* wasteCharge = Double.parseDouble(payload.get("wasteCharge").toString()); |
|||
*/ |
|||
|
|||
double processingCharge = payload.get("processingCharge") != null |
|||
? Double.parseDouble(payload.get("processingCharge").toString()) |
|||
: 0.0; |
|||
|
|||
double wasteCharge = payload.get("wasteCharge") != null |
|||
? Double.parseDouble(payload.get("wasteCharge").toString()) |
|||
: 0.0; |
|||
double totalCharge = Double.parseDouble(payload.get("totalCharge").toString()); |
|||
String paymentMobNo = payload.get("paymentMobileNo") != null ? payload.get("paymentMobileNo").toString() : null; |
|||
String refId = payload.get("refId") != null ? payload.get("refId").toString() : null; |
|||
|
|||
// ✅ Check if record exists |
|||
String checkSql = "SELECT COUNT(*) FROM waste_collectors_request WHERE refid = ?"; |
|||
Integer count = jdbcTemplate.queryForObject(checkSql, new Object[]{refId}, Integer.class); |
|||
|
|||
if (count != null && count > 0) { |
|||
// ✅ Update the existing record |
|||
String updateSql = "UPDATE waste_collectors_request SET actual_weight = ?, payment_type = ?, processing_charge = ?, waste_collection_charge = ?, total_charge = ?, payment_mobile_no = ? WHERE refid = ?"; |
|||
jdbcTemplate.update(updateSql, actualWeight, paymentType, processingCharge, wasteCharge, totalCharge, paymentMobNo, refId); |
|||
|
|||
// ✅ Send WhatsApp message if payment type is 'generateLink' and mobile number is provided |
|||
if ("generateLink".equalsIgnoreCase(paymentType) && paymentMobNo != null && !paymentMobNo.isBlank()) { |
|||
sendWhatsappMessage(refId, actualWeight, totalCharge, paymentMobNo); |
|||
} |
|||
} else { |
|||
throw new RuntimeException("No request found for Ref ID: " + refId); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
// public void sendWhatsappMessage(String refId, double actualWeight, double totalCharge, String mobileNumber) { |
|||
// try { |
|||
// String message = String.format( |
|||
// "Your request (Request ID: *%s*) has been processed. Please proceed with the payment.\n\nActual Weight: *%.0f kg*\nAmount Payable: *%.0f*", |
|||
// refId, actualWeight, totalCharge |
|||
// ); |
|||
// |
|||
// String encodedMessage = URLEncoder.encode(message, StandardCharsets.UTF_8); |
|||
// String encodedHeader = URLEncoder.encode("C&D Waste Collection – Payment Request", StandardCharsets.UTF_8); |
|||
// String encodedFooter = URLEncoder.encode("Greater Chennai Corporation", StandardCharsets.UTF_8); |
|||
// |
|||
// String redirectUrlParam = URLEncoder.encode("dumpregistration/paymentform?requestId=" + refId, StandardCharsets.UTF_8); |
|||
// |
|||
// String apiUrl = "https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507" + |
|||
// "&password=h2YjFNcJ" + |
|||
// "&send_to=" + mobileNumber + |
|||
// "&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE" + |
|||
// "&msg=" + encodedMessage + |
|||
// "&isTemplate=true" + |
|||
// "&header=" + encodedHeader + |
|||
// "&footer=" + encodedFooter + |
|||
// "&buttonUrlParam=" + redirectUrlParam; |
|||
// |
|||
// // Optional: log URL before hitting for debugging |
|||
// System.out.println("WhatsApp API URL: " + apiUrl); |
|||
// |
|||
// // Make API call |
|||
// // restTemplate.getForObject(apiUrl, String.class); |
|||
// smsService.sendMsg(apiUrl); |
|||
// } catch (Exception e) { |
|||
// e.printStackTrace(); |
|||
// // Optionally log or alert failure |
|||
// } |
|||
// } |
|||
|
|||
|
|||
public void sendWhatsappMessage(String refId, double actualWeight, double totalCharge, String mobileNumber) { |
|||
try { |
|||
|
|||
String apikey = "5c995535-6244-11f0-98fc-02c8a5e042bd"; |
|||
String from = "919445061913"; |
|||
String placeholders = ""; |
|||
String button_placeholder=""; |
|||
|
|||
// String apiUrl ="https://media.smsgupshup.com/GatewayAPI/rest?userid=2000233507&password=h2YjFNcJ&send_to="+mobileNumber+"&v=1.1&format=json&msg_type=TEXT&method=SENDMESSAGE&msg=Thank+you%21+Your+request+has+been+successfully+submitted.%0ARequest+Id+%3A+"+refId+"&isTemplate=true&header=C%26D+Waste+Collection+Request+Registered&footer=Greater+Chennai+Corporation"; |
|||
|
|||
// placeholders = URLEncoder.encode(refId, "UTF-8"); |
|||
|
|||
placeholders = URLEncoder.encode(refId + "|~|" + actualWeight + "|~|" + totalCharge, "UTF-8"); |
|||
|
|||
button_placeholder=URLEncoder.encode(refId, "UTF-8"); |
|||
|
|||
String whatsappMsg = "https://sendapiv1.pinbot.ai/pinwa/sendMessage?apikey=" + apikey + "&from=" |
|||
+ from + "&to=91" + mobileNumber + "" |
|||
+ "&type=template&templateid=3037264&placeholders=" + placeholders + "" |
|||
+ "&button_placeholder=dumpregistration/paymentform?requestId=" +button_placeholder + "" ; |
|||
|
|||
|
|||
|
|||
System.out.println("WhatsApp API URL: " + whatsappMsg); |
|||
smsService.sendMsg(whatsappMsg); |
|||
|
|||
|
|||
}catch (Exception e) { |
|||
|
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getAllRequestDetails(LocalDate fromDate, LocalDate toDate, String wastequantity, String zone) { |
|||
StringBuilder query = new StringBuilder( |
|||
"SELECT wcr.id, wcr.name, wcr.mobile_no, wcr.area, wcr.zone, qm.quantity, " + |
|||
"wtm.waste_type, dl.location, wcr.actual_weight, wcr.payment_status,wcr.waste_collection_charge, " + |
|||
"wcr.processing_charge, wcr.total_charge, DATE_FORMAT(wcr.cdate, '%d-%m-%Y') AS request_date, wcr.refid " + |
|||
"FROM waste_collectors_request wcr " + |
|||
"JOIN dumping_location dl ON wcr.dump_location_id = dl.id " + |
|||
"JOIN waste_type_master wtm ON wcr.waste_type_id = wtm.id " + |
|||
"JOIN quantity_master qm ON wcr.waste_quantity_id = qm.id " + |
|||
"WHERE wcr.cdate BETWEEN ? AND ?"); |
|||
|
|||
LocalDateTime fromDateTime = fromDate.atStartOfDay(); |
|||
LocalDateTime toDateTime = toDate.atTime(LocalTime.MAX); |
|||
|
|||
List<Object> params = new ArrayList<>(); |
|||
params.add(fromDateTime); |
|||
params.add(toDateTime); |
|||
|
|||
if (wastequantity != null && !wastequantity.isEmpty()) { |
|||
query.append(" AND qm.quantity = ?"); |
|||
params.add(wastequantity); |
|||
} |
|||
|
|||
if (zone != null && !zone.isEmpty()) { |
|||
query.append(" AND wcr.zone = ?"); |
|||
params.add(zone); |
|||
} |
|||
|
|||
return jdbcTemplate.queryForList(query.toString(), params.toArray()); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public List<Map<String, Object>> getAllwastequantity() { |
|||
String sql = " SELECT id,quantity FROM quantity_master where is_active = 1 "; |
|||
return jdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
|
|||
public List<Map<String, Object>> getZonesList() { |
|||
String sql = " SELECT id,zone_name from zones where is_active = 1 "; |
|||
return jdbcTemplate.queryForList(sql); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwaste.service; |
|||
|
|||
|
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
|
|||
@Service |
|||
public class SMSService { |
|||
public String sendMsg(String msgUrl) { |
|||
System.out.println("Whatsapp URL :-"+msgUrl); |
|||
|
|||
String response =""; |
|||
try{ |
|||
HttpURLConnection connection =null; |
|||
|
|||
URL url = new URL(msgUrl); |
|||
connection = (HttpURLConnection) url.openConnection(); |
|||
connection.setRequestMethod("GET"); |
|||
|
|||
int responseCode = connection.getResponseCode(); |
|||
response=responseCode+""; |
|||
System.out.println("Response Code: " + responseCode); |
|||
|
|||
}catch (Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
public String sendSMS(String SMS_Url) { |
|||
System.out.println("SMS URL:- "+ SMS_Url); |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String response =restTemplate.getForObject(SMS_Url,String.class); |
|||
return response; |
|||
} |
|||
} |
|||
@ -0,0 +1,111 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.controller; |
|||
|
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.core.env.Environment; |
|||
|
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.client.RestTemplate; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.service.RegistrationService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
|
|||
import java.io.IOException; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
@RestController("cdapiController") |
|||
@RequestMapping("/gcc/api/registration") |
|||
public class ApiController { |
|||
|
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
public ApiController(RestTemplate restTemplate, AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
} |
|||
|
|||
@Autowired |
|||
private Environment environment; |
|||
|
|||
@GetMapping("/pending") |
|||
public String getUserDetails(){ |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/getuserdetails"; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return responseEntity.getBody(); |
|||
} |
|||
|
|||
@GetMapping("/pendingbyid") |
|||
public String getUserDetailsById(@RequestParam("registerId") Long registerId){ |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/getuserbyid"+"?registerId="+ registerId; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return responseEntity.getBody(); |
|||
} |
|||
|
|||
|
|||
// @PostMapping("/acceptbyid") |
|||
// public String acceptRegistration(@RequestParam("registerId") Long registerId) { |
|||
// // Your logic to accept the registration |
|||
// String apiUrl = appConfig.cdwastecollectors +"/volunteer/wastecollector/api/accept"+"?registerId="+ registerId; |
|||
// ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
// return responseEntity.getBody(); |
|||
// } |
|||
|
|||
@PostMapping("/acceptbyid") |
|||
public ResponseEntity<String> acceptRegistration(@RequestParam("registerId") Long registerId) { |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/accept?registerId=" + registerId; |
|||
ResponseEntity<String> responseEntity = restTemplate.postForEntity(apiUrl, null, String.class); |
|||
return ResponseEntity.ok("Registration Accepted for ID: " + registerId); |
|||
} |
|||
|
|||
|
|||
|
|||
@PostMapping("/rejectbyid") |
|||
public ResponseEntity<String> rejectRegistration( |
|||
@RequestParam("registerId") Long registerId, |
|||
@RequestParam("reason") String reason) { |
|||
|
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/reject?registerId=" + registerId + "&reason=" + reason; |
|||
ResponseEntity<String> responseEntity = restTemplate.postForEntity(apiUrl, null, String.class); |
|||
return ResponseEntity.ok("Registration Rejected for ID: " + registerId); |
|||
} |
|||
|
|||
@GetMapping("/approvallist") |
|||
public String getApprovalDetails(){ |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/approvedlist"; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return responseEntity.getBody(); |
|||
} |
|||
|
|||
@GetMapping("/rejectedlist") |
|||
public String getRejectedDetails(){ |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/rejectedlist"; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
return responseEntity.getBody(); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@ -0,0 +1,142 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.controller; |
|||
|
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.core.ParameterizedTypeReference; |
|||
import org.springframework.http.HttpEntity; |
|||
import org.springframework.http.HttpHeaders; |
|||
import org.springframework.http.HttpMethod; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.security.core.userdetails.UserDetails; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonMappingException; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.service.RegistrationService; |
|||
import in.gov.chennaicorporation.gccoffice.configuration.AppConfig; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
import org.springframework.http.MediaType; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
|
|||
|
|||
|
|||
@RequestMapping("/gcc/cdwaste") |
|||
@Controller("cdcontroller") |
|||
public class MainController { |
|||
|
|||
private final LoginUserInfo loginUserInfo; |
|||
private final RestTemplate restTemplate; |
|||
private final AppConfig appConfig; |
|||
|
|||
@Autowired |
|||
public MainController(RestTemplate restTemplate,LoginUserInfo loginUserInfo, |
|||
AppConfig appConfig) { |
|||
this.restTemplate = restTemplate; |
|||
this.appConfig = appConfig; |
|||
this.loginUserInfo = loginUserInfo; |
|||
} |
|||
|
|||
@Autowired |
|||
private RegistrationService registrationservice; |
|||
|
|||
@GetMapping("/registration") |
|||
public String SavecdRegistraion(Model model){ |
|||
return "modules/cdwaste/registration"; |
|||
} |
|||
|
|||
@GetMapping("/pending") |
|||
public String Pendinglist(Model model) throws JsonMappingException, JsonProcessingException { |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/getuserdetails"; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
// Get the response body |
|||
String responseBody = responseEntity.getBody(); |
|||
|
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
|
|||
if (responseBody != null && !responseBody.isEmpty()) { |
|||
// Check if the response is an object or an array |
|||
if (responseBody.trim().startsWith("{")) { // Single object case |
|||
Map<String, Object> userDetails = objectMapper.readValue(responseBody, new TypeReference<Map<String, Object>>() {}); |
|||
model.addAttribute("userDetails", List.of(userDetails)); // Convert to a list for consistency |
|||
} else { // It's expected to be an array |
|||
List<Map<String, Object>> userDetails = objectMapper.readValue(responseBody, new TypeReference<List<Map<String, Object>>>() {}); |
|||
model.addAttribute("userDetails", userDetails); // Add the list directly |
|||
} |
|||
} else { |
|||
// If response is null or empty, pass an empty list to the model |
|||
model.addAttribute("userDetails", Collections.emptyList()); |
|||
} |
|||
|
|||
return "modules/cdwaste/pending"; // Return the view |
|||
} |
|||
|
|||
|
|||
@GetMapping("/approval") |
|||
public String approvalList(Model model) throws JsonMappingException, JsonProcessingException { |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/approvedlist"; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
// Get the response body |
|||
String responseBody = responseEntity.getBody(); |
|||
|
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
|
|||
if (responseBody != null && !responseBody.isEmpty()) { |
|||
// Check if the response is an object or an array |
|||
if (responseBody.trim().startsWith("{")) { // Single object case |
|||
Map<String, Object> approvalDetails = objectMapper.readValue(responseBody, new TypeReference<Map<String, Object>>() {}); |
|||
model.addAttribute("approvalDetails", List.of(approvalDetails)); // Convert to list |
|||
} else { // It's an array |
|||
List<Map<String, Object>> approvalDetails = objectMapper.readValue(responseBody, new TypeReference<List<Map<String, Object>>>() {}); |
|||
model.addAttribute("approvalDetails", approvalDetails); |
|||
} |
|||
} else { |
|||
model.addAttribute("approvalDetails", Collections.emptyList()); |
|||
} |
|||
|
|||
return "modules/cdwaste/approval"; // Return the appropriate view |
|||
} |
|||
|
|||
@GetMapping("/rejected") |
|||
public String rejectedList(Model model) throws JsonMappingException, JsonProcessingException { |
|||
String apiUrl = appConfig.cdwastecollectors + "/volunteer/wastecollectors/api/rejectedlist"; |
|||
ResponseEntity<String> responseEntity = restTemplate.getForEntity(apiUrl, String.class); |
|||
|
|||
// Get the response body |
|||
String responseBody = responseEntity.getBody(); |
|||
|
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
|
|||
if (responseBody != null && !responseBody.isEmpty()) { |
|||
// Check if the response is an object or an array |
|||
if (responseBody.trim().startsWith("{")) { // Single object case |
|||
Map<String, Object> rejectedDetails = objectMapper.readValue(responseBody, new TypeReference<Map<String, Object>>() {}); |
|||
model.addAttribute("rejectedDetails", List.of(rejectedDetails)); // Convert to list |
|||
} else { // It's an array |
|||
List<Map<String, Object>> rejectedDetails = objectMapper.readValue(responseBody, new TypeReference<List<Map<String, Object>>>() {}); |
|||
model.addAttribute("rejectedDetails", rejectedDetails); |
|||
} |
|||
} else { |
|||
model.addAttribute("rejectedDetails", Collections.emptyList()); |
|||
} |
|||
|
|||
return "modules/cdwaste/rejected"; // Return the appropriate view |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.controller; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
|
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.service.WhatsappMsgService; |
|||
|
|||
|
|||
|
|||
@RestController("whatsappconCD") |
|||
@RequestMapping("/gcc/api/cd/whatsapp") |
|||
public class WhatsappControllerCD { |
|||
|
|||
@Autowired |
|||
private WhatsappMsgService whatsappMsgService; |
|||
|
|||
@PostMapping("/send-whatsapp-message") |
|||
public ResponseEntity<String> sendWhatsAppMessage(@RequestParam String msgUrl) { |
|||
String response = whatsappMsgService.sendMsg(msgUrl); |
|||
return ResponseEntity.ok(response); |
|||
} |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,33 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.service; |
|||
|
|||
import java.io.File; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.UUID; |
|||
|
|||
import javax.sql.DataSource; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Qualifier; |
|||
import org.springframework.core.env.Environment; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
@Service |
|||
public class RegistrationService { |
|||
|
|||
@Autowired |
|||
private JdbcTemplate jdbcTemplate; |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@ -0,0 +1,41 @@ |
|||
package in.gov.chennaicorporation.gccoffice.cdwastecollectorregistrations.service; |
|||
|
|||
import java.net.HttpURLConnection; |
|||
|
|||
import java.net.URL; |
|||
|
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
@Service("whatsappServiceCD") |
|||
public class WhatsappMsgService { |
|||
|
|||
|
|||
public String sendMsg(String msgUrl) { |
|||
|
|||
String response =""; |
|||
try{ |
|||
HttpURLConnection connection =null; |
|||
|
|||
URL url = new URL(msgUrl); |
|||
connection = (HttpURLConnection) url.openConnection(); |
|||
connection.setRequestMethod("GET"); |
|||
|
|||
int responseCode = connection.getResponseCode(); |
|||
response=responseCode+""; |
|||
System.out.println("Response Code: " + responseCode); |
|||
|
|||
}catch (Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return response; |
|||
} |
|||
|
|||
|
|||
public String sendSMS(String SMS_Url) { |
|||
RestTemplate restTemplate = new RestTemplate(); |
|||
String response =restTemplate.getForObject(SMS_Url,String.class); |
|||
return response; |
|||
} |
|||
} |
|||
@ -0,0 +1,428 @@ |
|||
package in.gov.chennaicorporation.gccoffice.childrensurvey.Controller; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.childrensurvey.Service.ChildrenSurveyService; |
|||
|
|||
@RestController |
|||
@RequestMapping("/gcc/api/children-survey") |
|||
public class ChildrenSurveyController { |
|||
|
|||
@Autowired |
|||
private ChildrenSurveyService service; |
|||
|
|||
@GetMapping("/gender") |
|||
public List<Map<String, Object>> getGender() { |
|||
return service.getGender(); |
|||
} |
|||
|
|||
@GetMapping("/location") |
|||
public List<Map<String, Object>> getLocation() { |
|||
return service.getLocation(); |
|||
} |
|||
|
|||
@GetMapping("/education") |
|||
public List<Map<String, Object>> getEducation() { |
|||
return service.getEducation(); |
|||
} |
|||
|
|||
@GetMapping("/list") |
|||
public List<Map<String, Object>> getSurveyList( |
|||
@RequestParam(required = false) String name, |
|||
@RequestParam(required = false) String gender, |
|||
@RequestParam(required = false) String age, |
|||
@RequestParam(required = false) String area, |
|||
@RequestParam(required = false) String education, |
|||
@RequestParam(required = false) String fromDate, |
|||
@RequestParam(required = false) String toDate) { |
|||
return service.getSurveyList(name, gender, age, area, education, fromDate, toDate); |
|||
} |
|||
|
|||
@GetMapping("/details") |
|||
public Map<String, Object> getSurveyDetails( |
|||
@RequestParam String surveyId) { |
|||
return service.getSurveyDetails(surveyId); |
|||
} |
|||
|
|||
@GetMapping("/getSurveyorsList") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> getSurveyorsList( |
|||
|
|||
@RequestParam(required = false) String name, |
|||
@RequestParam(required = false) String area, |
|||
@RequestParam(required = false) String fromDate, |
|||
@RequestParam(required = false) String toDate) { |
|||
|
|||
return service.getSurveyorsList( |
|||
name, |
|||
area, |
|||
fromDate, |
|||
toDate); |
|||
} |
|||
|
|||
@GetMapping("/survey-breakup") |
|||
@ResponseBody |
|||
public List<Map<String, Object>> getSurveyBreakup( |
|||
|
|||
@RequestParam(required = false) String loginId, |
|||
@RequestParam(required = false) String locationId, |
|||
@RequestParam(required = false) String surveyDate) { |
|||
|
|||
return service.getSurveyBreakup(loginId, locationId, surveyDate); |
|||
} |
|||
|
|||
@GetMapping("/dashboard") |
|||
public Map<String, Object> dashboard() { |
|||
|
|||
return service.getDashboardData(); |
|||
} |
|||
|
|||
@GetMapping("/educationmasterlist") |
|||
public List<Map<String, Object>> list() { |
|||
|
|||
return service.getEducationList(); |
|||
} |
|||
|
|||
@PostMapping("/save") |
|||
public String save( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveEducation(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/status") |
|||
public String updateStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/locationmasterlist") |
|||
public List<Map<String, Object>> getLocationList() { |
|||
return service.getLocationList(); |
|||
} |
|||
|
|||
@PostMapping("/locationsave") |
|||
public String saveLocation( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveLocation(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/location-status") |
|||
public String updateLocationStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateLocationStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/gendermasterlist") |
|||
public List<Map<String, Object>> getGenderList() { |
|||
return service.getGenderList(); |
|||
} |
|||
|
|||
@PostMapping("/gendersave") |
|||
public String saveGender( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveGender(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/gender-status") |
|||
public String updateGenderStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateGenderStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/castemasterlist") |
|||
public List<Map<String, Object>> getCasteList() { |
|||
return service.getCasteList(); |
|||
} |
|||
|
|||
@PostMapping("/savecaste") |
|||
public String saveCaste( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveCaste(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/caste-status") |
|||
public String updateCasteStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateCasteStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/livingmasterlist") |
|||
public List<Map<String, Object>> getLivingList() { |
|||
return service.getLivingList(); |
|||
} |
|||
|
|||
@PostMapping("/livingsave") |
|||
public String saveLiving( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveLiving(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/living-status") |
|||
public String updateLivingStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateLivingStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/documentcreationmasterlist") |
|||
public List<Map<String, Object>> getDocumentCreationList() { |
|||
return service.getDocumentCreationList(); |
|||
} |
|||
|
|||
@PostMapping("/documentcreationsave") |
|||
public String saveDocumentCreation( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveDocumentCreation(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/documentcreationstatus") |
|||
public String updateDocumentCreationStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateDocumentCreationStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/dropoutreasonmasterlist") |
|||
public List<Map<String, Object>> getDropoutReasonList() { |
|||
return service.getDropoutReasonList(); |
|||
} |
|||
|
|||
@PostMapping("/dropoutreasonsave") |
|||
public String saveDropoutReason( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveDropoutReason(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/dropoutreasonstatus") |
|||
public String updateDropoutReasonStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateDropoutReasonStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/incomemasterlist") |
|||
public List<Map<String, Object>> getIncomeList() { |
|||
return service.getIncomeList(); |
|||
} |
|||
|
|||
@PostMapping("/incomesave") |
|||
public String saveIncome( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveIncome(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/incomemasterstatus") |
|||
public String updateIncomeStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateIncomeStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/interestfieldmasterlist") |
|||
public List<Map<String, Object>> getInterestFieldList() { |
|||
return service.getInterestFieldList(); |
|||
} |
|||
|
|||
@PostMapping("/interestfieldsave") |
|||
public String saveInterestField( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveInterestField(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/interestfieldmaster-status") |
|||
public String updateInterestFieldStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateInterestFieldStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/ownermasterlist") |
|||
public List<Map<String, Object>> getOwnerList() { |
|||
return service.getOwnerList(); |
|||
} |
|||
|
|||
@PostMapping("/ownermastersave") |
|||
public String saveOwner( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveOwner(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/ownermasterstatus") |
|||
public String updateOwnerStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateOwnerStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/religionmasterlist") |
|||
public List<Map<String, Object>> getReligionList() { |
|||
return service.getReligionList(); |
|||
} |
|||
|
|||
@PostMapping("/religionsave") |
|||
public String saveReligion( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveReligion(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/religion-status") |
|||
public String updateReligionStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateReligionStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/vulnerabilitymasterlist") |
|||
public List<Map<String, Object>> getVulnerabilityList() { |
|||
return service.getVulnerabilityList(); |
|||
} |
|||
|
|||
@PostMapping("/vulnerabilitysave") |
|||
public String saveVulnerability( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveVulnerability(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/vulnerabilitymasterstatus") |
|||
public String updateVulnerabilityStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateVulnerabilityStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/whereaboutmasterlist") |
|||
public List<Map<String, Object>> getWhereaboutList() { |
|||
return service.getWhereaboutList(); |
|||
} |
|||
|
|||
@PostMapping("/whereaboutsave") |
|||
public String saveWhereabout( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveWhereabout(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/whereaboutstatus") |
|||
public String updateWhereaboutStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateWhereaboutStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/documentreasonmasterlist") |
|||
public List<Map<String, Object>> getDocumentReasonList() { |
|||
return service.getDocumentReasonList(); |
|||
} |
|||
|
|||
@PostMapping("/documentreasonmaster") |
|||
public String saveDocumentReason( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.saveDocumentReason(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@PostMapping("/documentreasonmasterstatus") |
|||
public String updateDocumentReasonStatus( |
|||
@RequestBody Map<String, Object> req) { |
|||
|
|||
service.updateDocumentReasonStatus(req); |
|||
|
|||
return "SUCCESS"; |
|||
} |
|||
|
|||
@GetMapping("/nonsurveyed/list") |
|||
public ResponseEntity<List<Map<String, Object>>> getNonSurveyedChildList( |
|||
|
|||
@RequestParam(required = false) String area, |
|||
@RequestParam(required = false) String fromDate, |
|||
@RequestParam(required = false) String toDate) { |
|||
|
|||
return ResponseEntity.ok( |
|||
service.getNonSurveyedChildList( |
|||
area, |
|||
fromDate, |
|||
toDate)); |
|||
} |
|||
} |
|||
@ -0,0 +1,102 @@ |
|||
package in.gov.chennaicorporation.gccoffice.childrensurvey.Controller; |
|||
|
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
|
|||
@Controller("ChildrenSurveyController") |
|||
@RequestMapping("/gcc/childrensurvey") |
|||
public class MainController { |
|||
|
|||
@GetMapping("/surveylist") |
|||
public String surveylist() { |
|||
return "modules/childrensurvey/surveylist"; |
|||
} |
|||
|
|||
@GetMapping("/childlist/surveyedlist") |
|||
public String surveyedlist() { |
|||
return "modules/childrensurvey/childlist"; |
|||
} |
|||
|
|||
@GetMapping("/childlist/nonsurveyedlist") |
|||
public String nonsurveyedlist() { |
|||
return "modules/childrensurvey/nonchildlist"; |
|||
} |
|||
|
|||
@GetMapping("/surveyorsreports") |
|||
public String surveyorsreports() { |
|||
return "modules/childrensurvey/surveyorsreports"; |
|||
} |
|||
|
|||
@GetMapping("/mastersubmenu/educationmaster") |
|||
public String educationmaster() { |
|||
return "modules/childrensurvey/educationmaster"; |
|||
} |
|||
|
|||
@GetMapping("/mastersubmenu/locationmaster") |
|||
public String locationmaster() { |
|||
return "modules/childrensurvey/locationmaster"; |
|||
} |
|||
|
|||
@GetMapping("/mastersubmenu/gendermaster") |
|||
public String gendermaster() { |
|||
return "modules/childrensurvey/gendermaster"; |
|||
} |
|||
|
|||
@GetMapping("/mastersubmenu/castemaster") |
|||
public String castemaster() { |
|||
return "modules/childrensurvey/castemaster"; |
|||
} |
|||
|
|||
@GetMapping("/mastersubmenu/livingmaster") |
|||
public String livingmaster() { |
|||
return "modules/childrensurvey/livingmaster"; |
|||
} |
|||
|
|||
// documentation |
|||
@GetMapping("/mastersubmenu/documentcorrectionmaster") |
|||
public String documentcorrectionmaster() { |
|||
return "modules/childrensurvey/documentcorrectionmaster"; |
|||
} |
|||
|
|||
@GetMapping("/mastersubmenu/dropoutreasonmaster") |
|||
public String dropoutreasonmaster() { |
|||
return "modules/childrensurvey/dropoutreasonmaster"; |
|||
} |
|||
|
|||
@GetMapping("/mastersubmenu/incomemaster") |
|||
public String incomemaster() { |
|||
return "modules/childrensurvey/incomemaster"; |
|||
} |
|||
|
|||
@GetMapping("/mastersubmenu/religionmaster") |
|||
public String religionmaster() { |
|||
return "modules/childrensurvey/religionmaster"; |
|||
} |
|||
|
|||
@GetMapping("/mastersubmenu/interestfieldmaster") |
|||
public String interestfieldmaster() { |
|||
return "modules/childrensurvey/interestfieldmaster"; |
|||
} |
|||
|
|||
@GetMapping("/mastersubmenu/ownershipmaster") |
|||
public String ownermaster() { |
|||
return "modules/childrensurvey/ownermaster"; |
|||
} |
|||
|
|||
@GetMapping("/mastersubmenu/vulnerabilitymaster") |
|||
public String vulnerabilitymaster() { |
|||
return "modules/childrensurvey/vulnerabilitymaster"; |
|||
} |
|||
|
|||
@GetMapping("/mastersubmenu/whereaboutmaster") |
|||
public String whereaboutmaster() { |
|||
return "modules/childrensurvey/whereaboutmaster"; |
|||
} |
|||
|
|||
@GetMapping("/mastersubmenu/documentreasonmaster") |
|||
public String documentreasonmaster() { |
|||
return "modules/childrensurvey/documentreasonmaster"; |
|||
} |
|||
|
|||
} |
|||
3375
src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,58 @@ |
|||
package in.gov.chennaicorporation.gccoffice.circular.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.circular.service.CircularMaster; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("gcc/api/circular") |
|||
@RestController("circularRest") // Circular Rest |
|||
public class APIController { |
|||
private CircularMaster circularMaster; |
|||
|
|||
@Autowired |
|||
public APIController(CircularMaster circularMaster) { |
|||
this.circularMaster = circularMaster; |
|||
} |
|||
|
|||
@GetMapping(value="/getCircularTypes") |
|||
public List getCircularTypeList() { |
|||
return circularMaster.getCircularType(); |
|||
} |
|||
|
|||
@GetMapping(value="/getDeprtmentList") |
|||
public List getDepartmentList() { |
|||
return circularMaster.getDepartment(); |
|||
} |
|||
|
|||
@GetMapping(value="/getCircularList") |
|||
public List getCircularList() { |
|||
return circularMaster.getCircular(); |
|||
} |
|||
|
|||
@PostMapping(value="/saveCircular") |
|||
public String savePetition( |
|||
@RequestParam("createdBy") String createdBy, |
|||
@RequestParam("doc_cat") String circularCategory, |
|||
@RequestParam("circularType") String circularType, |
|||
@RequestParam("department") String department, |
|||
@RequestParam("Date") String Date, |
|||
@RequestParam("subject") String subject, |
|||
@RequestParam("scan_page1") MultipartFile scan_file1) { |
|||
|
|||
return circularMaster.saveCircular(createdBy,circularCategory,circularType,department,Date,subject,scan_file1); |
|||
} |
|||
|
|||
@GetMapping(value="/getReport") |
|||
public List getReport() { |
|||
return circularMaster.getReport(); |
|||
} |
|||
} |
|||
@ -0,0 +1,61 @@ |
|||
package in.gov.chennaicorporation.gccoffice.circular.controller; |
|||
|
|||
import org.hibernate.hql.internal.ast.tree.RestrictableStatement; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.core.env.Environment; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.Model; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.service.Base64Util; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("/gcc/circular") |
|||
@Controller("CircularController") |
|||
public class MainController { |
|||
private final RestTemplate restTemplate; |
|||
private Environment environment; |
|||
private String BasePath = "modules/circular/"; |
|||
|
|||
@Autowired |
|||
public MainController(RestTemplate restTemplate,Environment environment) { |
|||
this.restTemplate = restTemplate; |
|||
this.environment = environment; |
|||
} |
|||
|
|||
@GetMapping({"", "/", "/index", "/dashboard"}) |
|||
public String dashboard(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"index"; |
|||
} |
|||
|
|||
@GetMapping({"/new"}) |
|||
public String newCircular(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"new_circular"; |
|||
} |
|||
|
|||
@GetMapping("/list") |
|||
public String inbox(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
String serviceFolderName = environment.getProperty("cir_foldername"); |
|||
uploadDirectory = uploadDirectory + serviceFolderName; |
|||
model.addAttribute("uploadDirectory",uploadDirectory); |
|||
return BasePath+"inbox"; |
|||
} |
|||
|
|||
@GetMapping("/report") |
|||
public String report(Model model) { |
|||
String LoginUserId = LoginUserInfo.getLoginUserId(); |
|||
model.addAttribute("LoginUserId",LoginUserId); |
|||
return BasePath+"report"; |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.circular.controller; |
|||
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.circular; |
|||
@ -0,0 +1,223 @@ |
|||
package in.gov.chennaicorporation.gccoffice.circular.service; |
|||
|
|||
import java.io.IOException; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.Statement; |
|||
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.core.env.Environment; |
|||
import org.springframework.dao.DataAccessException; |
|||
import org.springframework.jdbc.core.JdbcTemplate; |
|||
import org.springframework.jdbc.support.GeneratedKeyHolder; |
|||
import org.springframework.jdbc.support.KeyHolder; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.m_petition.data.ComplaintType; |
|||
|
|||
@Service("CircularMaster") |
|||
public class CircularMaster { |
|||
private JdbcTemplate jdbcTemplate; |
|||
private Environment environment; |
|||
private JdbcTemplate appjdbcTemplate; |
|||
|
|||
@Autowired |
|||
public void setDataSource(Environment environment, |
|||
@Qualifier("mysqlCircularDataSource") DataSource dataSource, |
|||
@Qualifier("mysqlAppDataSource") DataSource appdataSource) { |
|||
this.environment = environment; |
|||
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|||
this.appjdbcTemplate = new JdbcTemplate(appdataSource); |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getCircularType(){ |
|||
String SqlQuery = ""; |
|||
|
|||
SqlQuery = "SELECT * FROM `circular_types` WHERE `isactive`=1 AND `isdelete`=0"; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(SqlQuery); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getDepartment(){ |
|||
String SqlQuery = ""; |
|||
|
|||
SqlQuery = "SELECT * FROM `departments` WHERE `isactive`=1 AND `isdelete`=0 Order By name"; |
|||
|
|||
List<Map<String, Object>> result = appjdbcTemplate.queryForList(SqlQuery); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getCircular(){ |
|||
String SqlQuery = ""; |
|||
|
|||
SqlQuery = "SELECT cd.*, cf.*, CASE WHEN cf.cid IS NOT NULL THEN 'true' ELSE 'false' END AS file_exits, gcc_apps.departments.name as department_name, circular_types.name as circular_type_name FROM circular_data cd LEFT JOIN circular_files cf ON cd.cid = cf.cid, gcc_apps.departments, circular_types where gcc_apps.departments.did=department AND circular_types.tid=circular_type ORDER BY cd.cid Desc"; |
|||
|
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(SqlQuery); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
@Transactional |
|||
public String saveCircular( |
|||
String createdBy, |
|||
String circularCategory, |
|||
String circularType, |
|||
String department, |
|||
String Date, |
|||
String subject, |
|||
MultipartFile scan_file1) { |
|||
|
|||
//System.out.println("I am from Service Page "+petitionerName); |
|||
|
|||
//String complaintNature = ""; |
|||
int lastInsertId = 0; |
|||
String sqlQuery = "INSERT INTO `circular_data` " |
|||
+ "(`createdBy`,`category`, `circular_type`, `department`, " |
|||
+ "`Date`, `subject`) " |
|||
+ "VALUES (?, ?, ?, ?, ?, ?)"; |
|||
|
|||
try { |
|||
|
|||
KeyHolder keyHolder = new GeneratedKeyHolder(); |
|||
// Use JdbcTemplate's update method to execute the query with parameters |
|||
jdbcTemplate.update(connection -> { |
|||
PreparedStatement ps = connection.prepareStatement(sqlQuery, Statement.RETURN_GENERATED_KEYS); |
|||
ps.setString(1, createdBy); |
|||
ps.setString(2, circularCategory); |
|||
ps.setString(3, circularType); |
|||
ps.setString(4, department); |
|||
ps.setString(5, Date); |
|||
ps.setString(6, subject); |
|||
return ps; |
|||
}, keyHolder); |
|||
|
|||
// Get the last insert ID |
|||
lastInsertId = (int) keyHolder.getKey().longValue(); |
|||
String lastInsertId_txt = String.valueOf(lastInsertId); |
|||
|
|||
// Add Petition Scan File in the database |
|||
addCircularFile(createdBy, lastInsertId, scan_file1); |
|||
|
|||
return lastInsertId_txt; // If no exception, query executed successfully |
|||
|
|||
} catch (DataAccessException e) { |
|||
// Handle exception (e.g., log error) |
|||
String sqlQuery2 = "UPDATE `circular_data` SET `isactive`=0, `isdelete`=1 WHERE `cid`="+lastInsertId+" LIMIT 1"; |
|||
jdbcTemplate.update(sqlQuery2); |
|||
e.printStackTrace(); |
|||
return "error"; // Query execution failed |
|||
} |
|||
} |
|||
|
|||
@Transactional |
|||
public String addCircularFile(String createdBy, |
|||
int cid, |
|||
MultipartFile page1) { |
|||
|
|||
String fileName=""; |
|||
for (int i = 1; i <= 4; i++) { |
|||
MultipartFile file = null; |
|||
switch (i) { |
|||
case 1: |
|||
file = page1; |
|||
fileName = "Scan1"; |
|||
break; |
|||
} |
|||
if (file != null && !file.isEmpty()) { |
|||
try { |
|||
// Get the bytes of the file |
|||
byte[] bytes = file.getBytes(); |
|||
|
|||
// Set the file path where you want to save it |
|||
String uploadDirectory = environment.getProperty("file.upload.directory"); |
|||
String serviceFolderName = environment.getProperty("cir_foldername"); |
|||
uploadDirectory = uploadDirectory + serviceFolderName; |
|||
|
|||
// File name |
|||
fileName = cid + "_" + fileName + "_" + file.getOriginalFilename(); |
|||
|
|||
//File Size |
|||
Long fileSize = file.getSize(); |
|||
|
|||
// File Type |
|||
String fileType = file.getContentType(); |
|||
|
|||
// Create directory if it doesn't exist |
|||
Path directoryPath = Paths.get(uploadDirectory); |
|||
if (!Files.exists(directoryPath)) { |
|||
Files.createDirectories(directoryPath); |
|||
} |
|||
|
|||
String filePath = uploadDirectory + "/" + fileName; |
|||
|
|||
// Create a new Path object |
|||
Path path = Paths.get(filePath); |
|||
|
|||
// Write the bytes to the file |
|||
Files.write(path, bytes); |
|||
|
|||
// Save the file path to a database |
|||
String sqlQuery = "INSERT INTO `circular_files` ( `cid`, `created_by`, `file_name`, `file_size`, `file_type`) " |
|||
+ "VALUES ('"+cid+"', '"+createdBy+"','"+fileName+"','"+fileSize+"','"+fileType+"')"; |
|||
jdbcTemplate.update(sqlQuery); |
|||
|
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
return "Failed to save file " + file.getOriginalFilename(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
return "success"; |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String,Object>> getReport(){ |
|||
String SqlQuery = ""; |
|||
String dynamic_query =""; |
|||
SqlQuery = "SELECT * FROM `circular_types` WHERE `isactive`=1 AND `isdelete`=0 ORDER BY `tid`"; |
|||
|
|||
List<Map<String, Object>> circular_types_result = jdbcTemplate.queryForList(SqlQuery); |
|||
|
|||
for(Map<String, Object> type : circular_types_result) { |
|||
String typeId = type.get("tid").toString(); |
|||
String typeName = type.get("name").toString(); |
|||
dynamic_query += "SUM(CASE WHEN ct.tid = '" + typeId + "' THEN 1 ELSE 0 END) AS `dynamic_" + typeName + "`, "; |
|||
} |
|||
|
|||
// Remove the trailing comma and space from dynamic_query |
|||
dynamic_query = dynamic_query.substring(0, dynamic_query.length() - 2); |
|||
|
|||
// Construct the SQL query with the dynamic part |
|||
SqlQuery = "SELECT " |
|||
+ " d.name, " |
|||
+ "SUM(CASE WHEN ct.tid != '0' THEN 1 ELSE 0 END) as total, " |
|||
+ dynamic_query + " " |
|||
+ "FROM " |
|||
+ "gcc_apps.departments d " |
|||
+ "LEFT JOIN circular.circular_data cd ON cd.department = d.did " |
|||
+ "LEFT JOIN circular.circular_types ct ON cd.circular_type = ct.tid " |
|||
+ "GROUP BY d.name"; |
|||
System.out.println(SqlQuery); |
|||
List<Map<String, Object>> result = jdbcTemplate.queryForList(SqlQuery); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1 @@ |
|||
package in.gov.chennaicorporation.gccoffice.circular.service; |
|||
@ -0,0 +1,219 @@ |
|||
package in.gov.chennaicorporation.gccoffice.com_petition.controller; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.springframework.security.core.Authentication; |
|||
|
|||
import org.springframework.security.core.context.SecurityContextHolder; |
|||
import org.springframework.security.core.userdetails.UserDetails; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import in.gov.chennaicorporation.gccoffice.com_petition.service.Petition; |
|||
import in.gov.chennaicorporation.gccoffice.com_petition.service.PetitionMaster; |
|||
import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; |
|||
|
|||
@RequestMapping("gcc/api/com_petition") |
|||
@RestController("commpRest") // Mayor Petition Rest |
|||
public class APIController { |
|||
private PetitionMaster petitionMaster; |
|||
private Petition petition; |
|||
|
|||
@Autowired |
|||
public APIController(PetitionMaster petitionMaster,Petition petition) { |
|||
this.petitionMaster = petitionMaster; |
|||
this.petition = petition; |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintTypes") |
|||
public List getComplaintTypeList() { |
|||
return petitionMaster.getComplaintType(); |
|||
} |
|||
|
|||
@GetMapping(value="/getOfficerList") |
|||
public List getOfficerList() { |
|||
return petitionMaster.getOfficerList(); |
|||
} |
|||
|
|||
@GetMapping(value="/getPetitionTypes") |
|||
public List getPetitionTypes() { |
|||
return petitionMaster.getPetitionTypes(); |
|||
} |
|||
|
|||
@GetMapping(value="/getPetitionList") |
|||
public List getPetitionList() { |
|||
return petition.getPetitionList(); |
|||
} |
|||
|
|||
@GetMapping(value="/getUnmapPetitionList") |
|||
public List getUnmapPetitionList() { |
|||
return petition.getUnmapPetitionList(); |
|||
} |
|||
|
|||
@GetMapping(value="/getPetitionDetails") |
|||
public List getPetitionDetails(@RequestParam("petitionNo") String petitionNo) { |
|||
return petition.getPetitionDetails(petitionNo); |
|||
} |
|||
|
|||
@PostMapping(value="/savePetition") |
|||
public String savePetition( |
|||
@RequestParam("createdBy") String createdBy, |
|||
@RequestParam("petitionType") String petitionType, |
|||
@RequestParam("petitionerName") String petitionerName, |
|||
@RequestParam("petitionerMobile") String petitionerMobile, |
|||
@RequestParam("complaintType") String petitionerComplaint, |
|||
@RequestParam("san_page1") MultipartFile page1, |
|||
@RequestParam("san_page2") MultipartFile page2, |
|||
@RequestParam("san_page3") MultipartFile page3, |
|||
@RequestParam("san_page4") MultipartFile page4) { |
|||
|
|||
return petition.savePetition(petitionType, createdBy, petitionerName, petitionerMobile, petitionerComplaint, page1, page2, page3, page4); |
|||
} |
|||
|
|||
@PostMapping(value="/updatePetition") |
|||
public Boolean updatePetition( |
|||
@RequestParam("petitionType") String petitionType, |
|||
@RequestParam("petitionNo") String petitionNo, |
|||
@RequestParam("createdBy") String createdBy, |
|||
@RequestParam("petitionerName") String petitionerName, |
|||
@RequestParam("petitionerMobile") String petitionerMobile, |
|||
@RequestParam("petitionerAddress") String petitionerAddress, |
|||
@RequestParam("petitionerPincode") String petitionerPincode, |
|||
@RequestParam("complaintType") String petitionerComplaint, |
|||
@RequestParam("complaintNature") String complaintNature, |
|||
@RequestParam("remarks") String remarks) { |
|||
|
|||
return petition.updatePetition(petitionNo, petitionType, createdBy, petitionerName, petitionerMobile, petitionerAddress, petitionerPincode, petitionerComplaint, complaintNature, remarks); |
|||
} |
|||
|
|||
@PostMapping(value="/mapComplientToOfficer") |
|||
public Boolean updatePetition( |
|||
@RequestParam("petitionId") String petitionId, |
|||
@RequestParam("petitionNo") String petitionNo, |
|||
@RequestParam("createdBy") String createdBy, |
|||
@RequestParam(value = "", required = false) String mapOfficers) { |
|||
|
|||
String com_mapping = mapOfficers; |
|||
|
|||
// First before Mapping need to unmaps old list |
|||
petition.unmapComplient(petitionId, petitionNo); |
|||
|
|||
if(com_mapping!=null) { |
|||
String[] com_mapping_parts = com_mapping.split(","); |
|||
for (String values : com_mapping_parts) { |
|||
String[] com_mapping_val = values.split("_"); |
|||
if (com_mapping_val.length > 0) { |
|||
String complientId = com_mapping_val[0]; |
|||
String offcierId = com_mapping_val[1]; |
|||
petition.mapComplientToOfficer(createdBy, petitionId, petitionNo, complientId, offcierId); |
|||
} |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
|
|||
@GetMapping(value="/getComplaintMappingDetails") |
|||
public List getComplaintMappingDetails( |
|||
@RequestParam("petitionId") String petitionId, |
|||
@RequestParam("petitionNo") String petitionNo, |
|||
@RequestParam("complaintTypeId") String complaintTypeId) { |
|||
return petition.getComplaintMappingDetails(petitionNo,petitionId,complaintTypeId); |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintList") |
|||
public List getComplaintList(@RequestParam("loginId") String loginId) { |
|||
return petition.getComplaintList(loginId); |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintListByPetitionId") |
|||
public List getComplaintListByPetitionId(@RequestParam("petitionId") String petitionId) { |
|||
return petition.getComplaintListByPetitionId(petitionId); |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintDetails") |
|||
public List<?> getComplaintDetails(@RequestParam("mapId") String mapId) { |
|||
return petition.getComplaintDetails(mapId); |
|||
} |
|||
|
|||
@GetMapping(value="/getComplaintActionDetails") |
|||
public List<?> getComplaintActionDetails(@RequestParam("mapId") String mapId) { |
|||
return petition.getComplaintActionDetails(mapId); |
|||
} |
|||
|
|||
@PostMapping(value="/saveComplanitStatus") |
|||
public String saveComplanitStatus( |
|||
@RequestParam("createdBy") String createdBy, |
|||
@RequestParam("mapId") String mapId, |
|||
@RequestParam("complaintStatus") String complaintStatus, |
|||
@RequestParam("complaintActionText") String complaintActionText, |
|||
@RequestParam("action_san_page1") MultipartFile actionPage1, |
|||
@RequestParam("petitionId") String petitionId, |
|||
@RequestParam("petitionNo") String petitionNo) { |
|||
|
|||
return petition.saveComplanitStatus(createdBy, mapId, complaintStatus, complaintActionText, actionPage1, petitionId, petitionNo); |
|||
} |
|||
|
|||
@PostMapping(value="/insertForwardLog") |
|||
public String insertForwardLog( |
|||
@RequestParam("offidto") String offidto, |
|||
@RequestParam("comments") String comments, |
|||
@RequestParam("mapid") String mapid) { |
|||
|
|||
// Get the petition details from the database |
|||
List<Map<String, Object>> eventsPetitionMappingList = petition.getComplaintDetails(mapid); |
|||
|
|||
// Check if the list is not empty and contains only one item |
|||
if (!eventsPetitionMappingList.isEmpty()) { |
|||
if (eventsPetitionMappingList.size() == 1) { |
|||
// Get the first element from the list (it’s a Map) |
|||
Map<String, Object> petitionMapping = eventsPetitionMappingList.get(0); |
|||
|
|||
// Extract values from the map using the correct keys |
|||
String offId = ""+petitionMapping.get("off_id"); |
|||
String petitionNumber = ""+petitionMapping.get("petition_no"); |
|||
String petitionId = ""+petitionMapping.get("petition_id"); |
|||
String complaintTypeId = ""+petitionMapping.get("complaint_typeid"); |
|||
|
|||
String[] com_mapping_val = offidto.split("_"); |
|||
if (com_mapping_val.length > 0) { |
|||
String complientId = com_mapping_val[0]; |
|||
String offcierId = com_mapping_val[1]; |
|||
|
|||
// Insert the forward log with the extracted data |
|||
petition.insertForwardLog( |
|||
offId, |
|||
offcierId, |
|||
petitionNumber, |
|||
petitionId, |
|||
complaintTypeId, |
|||
mapid, |
|||
comments |
|||
); |
|||
} |
|||
} |
|||
} |
|||
return "success"; // Return success when completed |
|||
} |
|||
|
|||
@GetMapping("/getReportList") |
|||
public List<Map<String, Object>> getReportList( |
|||
@RequestParam(value = "fromDate", required = false) |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date fromDate, |
|||
|
|||
@RequestParam(value = "toDate", required = false) |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date toDate, |
|||
|
|||
@RequestParam(value = "petitionType", required = false) String petitionType) { |
|||
|
|||
return petition.getReportList(fromDate, toDate, petitionType); |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue