first
This commit is contained in:
commit
9c69600a4c
|
@ -0,0 +1,25 @@
|
|||
/target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/build/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dbinfodefine>
|
||||
<info class="equipment" title="extinguisher" descript="灭火器(个)" type="int"/>
|
||||
<info class="equipment" title="fire_blanket" descript="灭火毯(个)" type="int"/>
|
||||
<info class="equipment" title="squirt_gun" descript="水枪(支)" type="int"/>
|
||||
<info class="equipment" title="separator" descript="分水器(个)" type="int"/>
|
||||
<info class="equipment" title="spanner" descript="消防栓扳手(把)" type="int"/>
|
||||
<info class="equipment" title="lifeline" descript="救生绳(根)" type="int"/>
|
||||
<info class="equipment" title="descent" descript="缓降器(个)" type="int"/>
|
||||
<info class="equipment" title="luminous_guide_rope" descript="发光导向绳(根)" type="int"/>
|
||||
<info class="equipment" title="luminous_guide_rod" descript="发光导向棒(个)" type="int"/>
|
||||
<info class="equipment" title="broke_tool" descript="简易破拆工具(套)" type="int"/>
|
||||
<info class="equipment" title="flat_axes" descript="消防平斧(把)" type="int"/>
|
||||
<info class="equipment" title="casque" descript="消防头盔(顶)" type="int"/>
|
||||
<info class="equipment" title="gloves" descript="消防手套(副)" type="int"/>
|
||||
<info class="equipment" title="boot" descript="灭火防护靴(双)" type="int"/>
|
||||
<info class="equipment" title="life_belt" descript="消防安全带(根)" type="int"/>
|
||||
<info class="equipment" title="water_belt" descript="水带(根)" type="int"/>
|
||||
<info class="equipment" title="respirator" descript="简易呼吸器(套)" type="int"/>
|
||||
<info class="equipment" title="light_lifeline" descript="轻型安全绳(根)" type="int"/>
|
||||
<info class="equipment" title="waist_axes" descript="消防腰斧(把)" type="int"/>
|
||||
<info class="equipment" title="protection_clothes" descript="灭火防护服(套)" type="int"/>
|
||||
<info class="equipment" title="training_clothes" descript="消防训练服(套)" type="int"/>
|
||||
<info class="equipment" title="flashlight" descript="手电筒(个)" type="int"/>
|
||||
<info class="equipment" title="transceiver" descript="对讲机或电台(台)" type="int"/>
|
||||
<info class="equipment" title="speaker" descript="扩音器(个)" type="int"/>
|
||||
|
||||
<info class="equipment" title="water_tanker" descript="水罐消防车(辆)" type="int"/>
|
||||
<info class="equipment" title="foam_tanker" descript="泡沫消防车(辆)" type="int"/>
|
||||
<info class="equipment" title="tricycle" descript="三轮简易消防车(辆)" type="int"/>
|
||||
<info class="equipment" title="motorcycle" descript="消防摩托车(辆)" type="int"/>
|
||||
<info class="equipment" title="electrombile" descript="消防电动车(辆)" type="int"/>
|
||||
<info class="equipment" title="pump" descript="机动消防泵(台)" type="int"/>
|
||||
<info class="equipment" title="air_respirator" descript="正压或消防空气呼吸器(套)" type="int"/>
|
||||
<info class="equipment" title="cmd_terminal" descript="指令终端(台)" type="int"/>
|
||||
|
||||
<info class="station" title="construction_funds" descript="建设资金(万元)" type="float"/>
|
||||
<info class="station" title="station_master" descript="站长" type="varchar"/>
|
||||
<info class="station" title="master_phone" descript="站长电话" type="varchar"/>
|
||||
<info class="station" title="member_count" descript="队员数" type="int"/>
|
||||
<info class="station" title="numberofgroup" descript="每班人数" type="int"/>
|
||||
<info class="station" title="office_area" descript="办公面积(平方米)" type="float"/>
|
||||
<info class="station" title="storeroom_area" descript="库房面积(平方米)" type="float"/>
|
||||
<info class="station" title="duty_house_area" descript="值班房面积(平方米)" type="float"/>
|
||||
</dbinfodefine>
|
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<defaultroledefine>
|
||||
|
||||
<role name="普通用户">
|
||||
<res type="interface" descript="查询单位组织信息" path="/firectrl/client/user/getorganization" />
|
||||
<res type="interface" descript="查询单位组织列表" path="/firectrl/client/user/getorganizationlist" />
|
||||
|
||||
<res type="interface" descript="更新微型站信息" path="/firectrl/client/updatestation" />
|
||||
<res type="interface" descript="查询微型站信息" path="/firectrl/client/getstation" />
|
||||
<res type="interface" descript="查询微型站总数" path="/firectrl/client/getstationcount" />
|
||||
<res type="interface" descript="查询微型站列表" path="/firectrl/client/getstationlist" />
|
||||
<res type="interface" descript="按范围查询微型站总数" path="/firectrl/client/getstationcountbyscope" />
|
||||
<res type="interface" descript="按范围查询微型站列表" path="/firectrl/client/getstationlistbyscope" />
|
||||
<res type="interface" descript="查询附近微型站列表" path="/firectrl/client/getneighbourstation" />
|
||||
|
||||
<res type="interface" descript="查询装备列表" path="/firectrl/client/getstationequipment" />
|
||||
<res type="interface" descript="更新装备列表" path="/firectrl/client/updatestationequipment" />
|
||||
<res type="interface" descript="查询装备审查列表" path="/firectrl/client/getequipmentverify"/>
|
||||
<res type="interface" descript="审查装备信息" path="/firectrl/client/equipmentverify"/>
|
||||
|
||||
<res type="interface" descript="创建组员" path="/firectrl/client/addstaff" />
|
||||
<res type="interface" descript="删除组员" path="/firectrl/client/deletestaff" />
|
||||
<res type="interface" descript="查询多微站组员列表" path="/firectrl/client/getmutilstationstaff" />
|
||||
<res type="interface" descript="查询组员列表" path="/firectrl/client/getstationstaff" />
|
||||
<res type="interface" descript="更新组员信息" path="/firectrl/client/updatestaff" />
|
||||
|
||||
<res type="interface" descript="查询中队信息" path="/firectrl/client/getdetachment" />
|
||||
<res type="interface" descript="查询大队信息" path="/firectrl/client/getborough" />
|
||||
<res type="interface" descript="查询支队信息" path="/firectrl/client/getbrigade" />
|
||||
|
||||
<res type="interface" descript="查询中队信息" path="/firectrl/client/user/getdetachment" />
|
||||
<res type="interface" descript="查询大队信息" path="/firectrl/client/user/getborough" />
|
||||
<res type="interface" descript="查询支队信息" path="/firectrl/client/user/getbrigade" />
|
||||
|
||||
<res type="interface" descript="查询微站在线时间" path="/firectrl/client/getonlinetime" />
|
||||
<res type="interface" descript="查询微站在岗时间" path="/firectrl/client/getonjobtime" />
|
||||
|
||||
<res type="interface" descript="创建微站视频通道" path="/firectrl/video/createchannel" />
|
||||
<res type="interface" descript="查询微站视频通道" path="/firectrl/video/getchannel" />
|
||||
<res type="interface" descript="启动视频通话" path="/firectrl/video/starttalk" />
|
||||
<res type="interface" descript="设置微站属性" path="/firectrl/client/station/property/add" />
|
||||
<res type="interface" descript="删除微站属性" path="/firectrl/client/station/property/delete"/>
|
||||
|
||||
<res type="interface" descript="获取两点间的最短距离" path="/firectrl/client/getdistance" />
|
||||
</role>
|
||||
|
||||
<role name="客户管理员">
|
||||
<res type="interface" descript="查询单位组织信息" path="/firectrl/client/user/getorganization" />
|
||||
<res type="interface" descript="查询单位组织列表" path="/firectrl/client/user/getorganizationlist" />
|
||||
|
||||
<res type="interface" descript="创建微型站" path="/firectrl/client/createstation" />
|
||||
<res type="interface" descript="删除微型站" path="/firectrl/client/deletestation" />
|
||||
|
||||
<res type="interface" descript="更新微型站信息" path="/firectrl/client/updatestation" />
|
||||
<res type="interface" descript="查询微型站信息" path="/firectrl/client/getstation" />
|
||||
<res type="interface" descript="查询微型站总数" path="/firectrl/client/getstationcount" />
|
||||
<res type="interface" descript="查询微型站列表" path="/firectrl/client/getstationlist" />
|
||||
<res type="interface" descript="按范围查询微型站总数" path="/firectrl/client/getstationcountbyscope" />
|
||||
<res type="interface" descript="按范围查询微型站列表" path="/firectrl/client/getstationlistbyscope" />
|
||||
|
||||
<res type="interface" descript="查询装备列表" path="/firectrl/client/getstationequipment" />
|
||||
<res type="interface" descript="更新装备列表" path="/firectrl/client/updatestationequipment" />
|
||||
<res type="interface" descript="查询装备审查列表" path="/firectrl/client/getequipmentverify"/>
|
||||
<res type="interface" descript="审查装备信息" path="/firectrl/client/equipmentverify"/>
|
||||
<res type="interface" descript="查询装备审查列表" path="/firectrl/client/getequipmentverifylist" />
|
||||
<res type="interface" descript="查询装备审查数量" path="/firectrl/client/getequipmentverifycount" />
|
||||
|
||||
<res type="interface" descript="创建组员" path="/firectrl/client/addstaff" />
|
||||
<res type="interface" descript="删除组员" path="/firectrl/client/deletestaff" />
|
||||
<res type="interface" descript="查询多微站组员列表" path="/firectrl/client/getmutilstationstaff" />
|
||||
<res type="interface" descript="查询组员列表" path="/firectrl/client/getstationstaff" />
|
||||
<res type="interface" descript="更新组员信息" path="/firectrl/client/updatestaff" />
|
||||
|
||||
<res type="interface" descript="查询中队信息" path="/firectrl/client/getdetachment" />
|
||||
<res type="interface" descript="查询大队信息" path="/firectrl/client/getborough" />
|
||||
<res type="interface" descript="查询支队信息" path="/firectrl/client/getbrigade" />
|
||||
|
||||
<res type="interface" descript="查询中队信息" path="/firectrl/client/user/getdetachment" />
|
||||
<res type="interface" descript="查询大队信息" path="/firectrl/client/user/getborough" />
|
||||
<res type="interface" descript="查询支队信息" path="/firectrl/client/user/getbrigade" />
|
||||
|
||||
<res type="interface" descript="查询微站在线时间" path="/firectrl/client/getonlinetime" />
|
||||
<res type="interface" descript="查询微站在岗时间" path="/firectrl/client/getonjobtime" />
|
||||
|
||||
<res type="interface" descript="创建微站视频通道" path="/firectrl/video/createchannel" />
|
||||
<res type="interface" descript="查询微站视频通道" path="/firectrl/video/getchannel" />
|
||||
<res type="interface" descript="启动视频通话" path="/firectrl/video/starttalk" />
|
||||
<res type="interface" descript="删除微站属性" path="/firectrl/client/station/property/delete"/>
|
||||
|
||||
<res type="interface" descript="设置微站属性" path="/firectrl/client/station/property/add" />
|
||||
<res type="interface" descript="获取两点间的最短距离" path="/firectrl/client/getdistance" />
|
||||
</role>
|
||||
</defaultroledefine>
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<equipmenttabdefine>
|
||||
<equipment title="extinguisher" descript="灭火器(个)" defaultval="0" type="necessary"/>
|
||||
<equipment title="fire_blanket" descript="灭火毯(个)" defaultval="0" type="necessary"/>
|
||||
<equipment title="squirt_gun" descript="水枪(支)" defaultval="0" type="necessary"/>
|
||||
<equipment title="separator" descript="分水器(个)" defaultval="0" type="necessary"/>
|
||||
<equipment title="spanner" descript="消防栓扳手(把)" type="necessary"/>
|
||||
<equipment title="lifeline" descript="救生绳(根)" type="necessary"/>
|
||||
<equipment title="descent" descript="缓降器(个)" type="necessary"/>
|
||||
<equipment title="luminous_guide_rope" descript="发光导向绳(根)" type="necessary"/>
|
||||
<equipment title="luminous_guide_rod" descript="发光导向棒(个)" type="necessary"/>
|
||||
<equipment title="broke_tool" descript="简易破拆工具(套)" type="necessary"/>
|
||||
<equipment title="flat_axes" descript="消防平斧(把)" type="necessary"/>
|
||||
<equipment title="casque" descript="消防头盔(顶)" type="necessary"/>
|
||||
<equipment title="gloves" descript="消防手套(副)" type="necessary"/>
|
||||
<equipment title="boot" descript="灭火防护靴(双)" type="necessary"/>
|
||||
<equipment title="life_belt" descript="消防安全带(根)" type="necessary"/>
|
||||
<equipment title="water_belt" descript="水带(根)" type="necessary"/>
|
||||
<equipment title="respirator" descript="简易呼吸器(套)" type="necessary"/>
|
||||
<equipment title="light_lifeline" descript="轻型安全绳(根)" type="necessary"/>
|
||||
<equipment title="waist_axes" descript="消防腰斧(把)" type="necessary"/>
|
||||
<equipment title="protection_clothes" descript="灭火防护服(套)" type="necessary"/>
|
||||
<equipment title="training_clothes" descript="消防训练服(套)" type="necessary"/>
|
||||
<equipment title="flashlight" descript="手电筒(个)" type="necessary"/>
|
||||
<equipment title="transceiver" descript="对讲机或电台(台)" type="necessary"/>
|
||||
<equipment title="speaker" descript="扩音器(个)" type="necessary"/>
|
||||
|
||||
<equipment title="water_tanker" descript="水罐消防车(辆)" type="optional"/>
|
||||
<equipment title="foam_tanker" descript="泡沫消防车(辆" type="optional"/>
|
||||
<equipment title="tricycle" descript="三轮简易消防车(辆)" type="optional"/>
|
||||
<equipment title="motorcycle" descript="消防摩托车(辆)" type="optional"/>
|
||||
<equipment title="electrombile" descript="消防电动车(辆)" type="optional"/>
|
||||
<equipment title="pump" descript="机动消防泵(台)" type="optional"/>
|
||||
<equipment title="air_respirator" descript="正压或消防空气呼吸器(套)" type="optional"/>
|
||||
<equipment title="cmd_terminal" descript="指令终端(台)" type="optional"/>
|
||||
</equipmenttabdefine>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
2022-01-17 21:33:06.633 [main] INFO c.j.i.f.FirestationportApplication - Starting FirestationportApplication on DESKTOP-MEEEFKF with PID 20696 (D:\javaee\projects\microstation\target\classes started by 86709 in D:\javaee\projects\microstation)
|
||||
2022-01-17 21:33:06.671 [main] DEBUG c.j.i.f.FirestationportApplication - Running with Spring Boot v2.0.3.RELEASE, Spring v5.0.7.RELEASE
|
||||
2022-01-17 21:33:06.674 [main] INFO c.j.i.f.FirestationportApplication - No active profile set, falling back to default profiles: default
|
|
@ -0,0 +1,225 @@
|
|||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# 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 /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
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Migwn, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
# TODO classpath?
|
||||
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="`which 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
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# 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/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
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 "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -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
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
|
@ -0,0 +1,143 @@
|
|||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@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 key stroke 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 enable echoing my 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 "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\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
|
||||
|
||||
%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 "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\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%
|
||||
|
||||
exit /B %ERROR_CODE%
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,237 @@
|
|||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.jingyi.iotserver</groupId>
|
||||
<artifactId>microstation</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>microstation</name>
|
||||
<description>micro station system http port</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.0.3.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web-services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>mssql-jdbc</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.13</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--阿里 Druid Spring Boot Starter依赖-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.1.10</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/dubbo -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>dubbo</artifactId>
|
||||
<version>2.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<!--MetaStuff dom4j-->
|
||||
<dependency>
|
||||
<groupId>dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>1.6.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>xml-apis</groupId>
|
||||
<artifactId>xml-apis</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.6</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-spring -->
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-spring</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-ehcache</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>2.0.4.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>4.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/cn.jpush.api/jpush-client -->
|
||||
<dependency>
|
||||
<groupId>cn.jpush.api</groupId>
|
||||
<artifactId>jpush-client</artifactId>
|
||||
<version>3.3.10</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/io.netty/netty-all -->
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.1.24.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
<version>2.0.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-quartz</artifactId>
|
||||
<version>2.7.8</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.hikvision.ga</groupId>
|
||||
<artifactId>artemis-http-client</artifactId>
|
||||
<version>1.1.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gavaghan</groupId>
|
||||
<artifactId>geodesy</artifactId>
|
||||
<version>1.1.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,275 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resinfodefine>
|
||||
<res type="interface" descript="创建用户" path="/common/client/user/create" scope="only-admin"/>
|
||||
<res type="interface" descript="创建用户带定位" path="/common/client/user/createwithlocate" scope="only-admin"/>
|
||||
<res type="interface" descript="删除用户" path="/common/client/user/delete" scope="only-admin"/>
|
||||
<res type="interface" descript="查询用户列表" path="/common/client/user/getuserlist" scope="only-admin"/>
|
||||
<res type="interface" descript="重置用户密码" path="/common/client/user/resetpwd" scope="only-admin"/>
|
||||
<res type="interface" descript="修改用户密码" path="/common/client/user/changepwd" scope="all"/>
|
||||
<res type="interface" descript="更新用户信息" path="/common/client/user/update" scope="only-admin"/>
|
||||
<res type="interface" descript="创建角色" path="/common/client/user/createrole" scope="only-admin"/>
|
||||
<res type="interface" descript="创建平台合作者" path="/common/client/partner/create" scope="only-admin"/>
|
||||
<res type="interface" descript="查询平台合作者" path="/common/client/partner/getlist" scope="only-admin"/>
|
||||
<res type="interface" descript="更新平台合作者信息" path="/common/client/partner/update" scope="only-admin"/>
|
||||
<res type="interface" descript="设置用户权限信息" path="/common/client/user/authordes/set" scope="only-admin"/>
|
||||
<res type="interface" descript="获取用户权限信息" path="/common/client/user/authordes/get" scope="all"/>
|
||||
|
||||
|
||||
<res type="interface" descript="删除角色" path="/common/client/user/deleterole" scope="only-admin"/>
|
||||
<res type="interface" descript="查询角色列表" path="/common/client/user/getroles" scope="only-admin"/>
|
||||
<res type="interface" descript="查询角色权限" path="/common/client/user/getroleauthority" scope="only-admin"/>
|
||||
<res type="interface" descript="修改角色权限" path="/common/client/user/updateroleauthority" scope="only-admin"/>
|
||||
<res type="interface" descript="查询所有权限" path="/common/client/user/getallauthority" scope="only-admin"/>
|
||||
<res type="interface" descript="查询发送任务权限" path="/common/client/user/hastaskauthor" scope="all"/>
|
||||
<res type="interface" descript="查询发送通知权限" path="/common/client/user/hasnotifyauthor" scope="all"/>
|
||||
<res type="interface" descript="查询操作列表数量" path="/common/client/user/getoperatecount" scope="all"/>
|
||||
<res type="interface" descript="查询操作列表" path="/common/client/user/getoperatelist" scope="all"/>
|
||||
<res type="interface" descript="获取用户列表" path="/common/client/user/getuser" scope="all"/>
|
||||
<res type="interface" descript="查询多个大队下的中队" path="/common/client/user/getdetachmentofmultiborough" scope="all"/>
|
||||
<res type="interface" descript="查询多个大队下的中队" path="/common/client/user/getboroughofmultibrigade" scope="all"/>
|
||||
|
||||
<res type="interface" descript="创建中队" path="/common/client/user/adddetachment" scope="only-admin"/>
|
||||
<res type="interface" descript="查询中队信息" path="/common/client/user/getdetachment" scope="all"/>
|
||||
<res type="interface" descript="删除中队" path="/common/client/user/deletedetachment" scope="only-admin"/>
|
||||
<res type="interface" descript="更新中队信息" path="/common/client/user/updatedetachment" scope="only-admin"/>
|
||||
|
||||
<res type="interface" descript="创建大队" path="/common/client/user/addborough" scope="only-admin"/>
|
||||
<res type="interface" descript="查询大队信息" path="/common/client/user/getborough" scope="all"/>
|
||||
<res type="interface" descript="删除大队" path="/common/client/user/deleteborough" scope="only-admin"/>
|
||||
<res type="interface" descript="更新大队信息" path="/common/client/user/updateborough" scope="only-admin"/>
|
||||
|
||||
<res type="interface" descript="创建支队" path="/common/client/user/addbrigade" scope="only-admin"/>
|
||||
<res type="interface" descript="查询支队信息" path="/common/client/user/getbrigade" scope="all"/>
|
||||
<res type="interface" descript="删除支队" path="/common/client/user/deletebrigade" scope="only-admin"/>
|
||||
<res type="interface" descript="更新支队信息" path="/common/client/user/updatebrigade" scope="only-admin"/>
|
||||
|
||||
<res type="interface" descript="创建单位组织" path="/common/client/user/addorganization" scope="all"/>
|
||||
<res type="interface" descript="删除单位组织" path="/common/client/user/deleteorganization" scope="all"/>
|
||||
<res type="interface" descript="更新单位组织信息" path="/common/client/user/updateorganization" scope="all"/>
|
||||
<res type="interface" descript="查询单位组织信息" path="/common/client/user/getorganization" scope="all"/>
|
||||
<res type="interface" descript="查询单位组织列表" path="/common/client/user/getorganizationlist" scope="all" />
|
||||
|
||||
<res type="interface" descript="创建微型站" path="/firectrl/client/createstation" scope="optional"/>
|
||||
<res type="interface" descript="删除微型站" path="/firectrl/client/deletestation" scope="optional"/>
|
||||
<res type="interface" descript="更新微型站信息" path="/firectrl/client/updatestation" scope="optional"/>
|
||||
<res type="interface" descript="查询微型站信息" path="/firectrl/client/getstation" scope="optional"/>
|
||||
<res type="interface" descript="查询微型站总数" path="/firectrl/client/getstationcount" scope="optional"/>
|
||||
<res type="interface" descript="查询微型站列表" path="/firectrl/client/getstationlist" scope="optional"/>
|
||||
<res type="interface" descript="按范围查询微型站总数" path="/firectrl/client/getstationcountbyscope" scope="optional"/>
|
||||
<res type="interface" descript="按范围查询微型站列表" path="/firectrl/client/getstationlistbyscope" scope="optional"/>
|
||||
<res type="interface" descript="查询附近微型站列表" path="/firectrl/client/getneighbourstation" scope="all"/>
|
||||
<res type="interface" descript="设置微型站服务范围" path="/firectrl/client/setstationbound" scope="all"/>
|
||||
<res type="interface" descript="查询微型站服务范围" path="/firectrl/client/getstationbound" scope="all"/>
|
||||
|
||||
<res type="interface" descript="查询装备列表" path="/firectrl/client/getstationequipment" scope="optional"/>
|
||||
<res type="interface" descript="更新装备列表" path="/firectrl/client/updatestationequipment" scope="optional"/>
|
||||
<res type="interface" descript="查询装备审查信息" path="/firectrl/client/getequipmentverify" scope="optional"/>
|
||||
<res type="interface" descript="审查装备信息" path="/firectrl/client/equipmentverify" scope="optional"/>
|
||||
<res type="interface" descript="查询装备审查列表" path="/firectrl/client/getequipmentverifylist" scope="optional"/>
|
||||
<res type="interface" descript="查询装备审查数量" path="/firectrl/client/getequipmentverifycount" scope="optional"/>
|
||||
|
||||
<res type="interface" descript="创建组员" path="/firectrl/client/addstaff" scope="optional"/>
|
||||
<res type="interface" descript="删除组员" path="/firectrl/client/deletestaff" scope="optional"/>
|
||||
<res type="interface" descript="查询多微站组员列表" path="/firectrl/client/getmutilstationstaff" scope="optional"/>
|
||||
<res type="interface" descript="查询组员列表" path="/firectrl/client/getstationstaff" scope="optional"/>
|
||||
<res type="interface" descript="更新组员信息" path="/firectrl/client/updatestaff" scope="optional"/>
|
||||
|
||||
<res type="interface" descript="创建中队" path="/firectrl/client/adddetachment" scope="only-admin"/>
|
||||
<res type="interface" descript="查询中队信息" path="/firectrl/client/getdetachment" scope="optional"/>
|
||||
<res type="interface" descript="删除中队" path="/firectrl/client/deletedetachment" scope="only-admin"/>
|
||||
<res type="interface" descript="删除中队" path="/firectrl/client/updatedetachment" scope="only-admin"/>
|
||||
|
||||
<res type="interface" descript="创建大队" path="/firectrl/client/addborough" scope="only-admin"/>
|
||||
<res type="interface" descript="查询大队信息" path="/firectrl/client/getborough" scope="optional"/>
|
||||
<res type="interface" descript="删除大队" path="/firectrl/client/deleteborough" scope="only-admin"/>
|
||||
<res type="interface" descript="删除大队" path="/firectrl/client/updateborough" scope="only-admin"/>
|
||||
|
||||
<res type="interface" descript="创建支队" path="/firectrl/client/addbrigade" scope="only-admin"/>
|
||||
<res type="interface" descript="查询支队信息" path="/firectrl/client/getbrigade" scope="optional"/>
|
||||
<res type="interface" descript="删除支队" path="/firectrl/client/deletebrigade" scope="only-admin"/>
|
||||
<res type="interface" descript="更新支队信息" path="/firectrl/client/updatebrigade" scope="only-admin"/>
|
||||
|
||||
<res type="interface" descript="查询微站在线时间" path="/firectrl/client/getonlinetime" scope="optional"/>
|
||||
<res type="interface" descript="查询微站在岗时间" path="/firectrl/client/getonjobtime" scope="optional"/>
|
||||
|
||||
<res type="interface" descript="创建微站视频通道" path="/firectrl/video/createchannel" scope="optional"/>
|
||||
<res type="interface" descript="查询微站视频通道" path="/firectrl/video/getchannel" scope="optional"/>
|
||||
<res type="interface" descript="启动视频通话" path="/firectrl/video/starttalk" scope="optional"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<res type="interface" descript="客户端心跳" path="/firectrl/client/user/active" scope="all"/>
|
||||
<res type="interface" descript="发起点名" path="/firectrl/client/startrollcall" scope="all"/>
|
||||
<res type="interface" descript="查询点名数量" path="/firectrl/client/getrollcallcount" scope="all"/>
|
||||
<res type="interface" descript="查询点名列表" path="/firectrl/client/getrollcalllist" scope="all"/>
|
||||
<res type="interface" descript="查询点名响应数量" path="/firectrl/client/getrollcallackcount" scope="all"/>
|
||||
<res type="interface" descript="查询点名响应列表" path="/firectrl/client/getrollcallacklist" scope="all"/>
|
||||
<res type="interface" descript="查询点名统计信息" path="/firectrl/client/getrollcallstatistics" scope="all"/>
|
||||
<res type="interface" descript="查询点名未响应列表" path="/firectrl/client/getrollcallnotacklist" scope="all"/>
|
||||
<res type="interface" descript="补点名回复" path="/firectrl/client/patchrollcallack" scope="all"/>
|
||||
<res type="interface" descript="获取点名报表" path="/firectrl/client/getrollcallreportform" scope="all"/>
|
||||
<res type="interface" descript="获取微站的点名报表" path="/firectrl/client/getstationrollcallreportform" scope="all"/>
|
||||
<res type="interface" descript="获取点名分析报表报表" path="/firectrl/client/analyze/rollcallreportform" scope="all"/>
|
||||
|
||||
<res type="interface" descript="设置定时事务" path="/firectrl/client/settimingjob" scope="all"/>
|
||||
<res type="interface" descript="删除定时事务" path="/firectrl/client/deletetimingjob" scope="all"/>
|
||||
<res type="interface" descript="查询定时事务" path="/firectrl/client/gettimingjob" scope="all"/>
|
||||
|
||||
<res type="operate" descript="发送任务权限" path="firectrl.client.user.sendtask" scope="optional"/>
|
||||
<res type="operate" descript="发送通知权限" path="firectrl.client.user.sendnotify" scope="optional"/>
|
||||
|
||||
<res type="interface" descript="添加传感器" path="/firectrl/client/addsensor" scope="all"/>
|
||||
<res type="interface" descript="删除传感器" path="/firectrl/client/deletesensor" scope="all"/>
|
||||
<res type="interface" descript="更新传感器信息" path="/firectrl/client/updatesensor" scope="all"/>
|
||||
<res type="interface" descript="启/停传感器" path="/firectrl/client/setsensor" scope="all"/>
|
||||
<res type="interface" descript="查询传感器信息" path="/firectrl/client/getsensor" scope="all"/>
|
||||
<res type="interface" descript="查询微站的传感器" path="/firectrl/client/getownersensor" scope="all"/>
|
||||
<res type="interface" descript="查询传感器类型列表" path="/firectrl/client/getsensortypes" scope="all"/>
|
||||
<res type="interface" descript="查询传感器数量" path="/firectrl/client/querysensorcount" scope="all"/>
|
||||
<res type="interface" descript="查询传感器列表" path="/firectrl/client/querysensorpage" scope="all"/>
|
||||
<res type="interface" descript="查询传感器在离线状态数量" path="/firectrl/client/querysensorstatecount" scope="all"/>
|
||||
<res type="interface" descript="查询传感器在离线状态列表" path="/firectrl/client/querysensostaterpage" scope="all"/>
|
||||
|
||||
<res type="interface" descript="查询气动开关状态数量" path="/firectrl/client/sensor/getacbstatuscount" scope="all"/>
|
||||
<res type="interface" descript="查询启动开关状态列表" path="/firectrl/client/sensor/getacbstatuslist" scope="all"/>
|
||||
<res type="interface" descript="查询启动开关报警数量" path="/firectrl/client/sensor/getacbalarmcount" scope="all"/>
|
||||
<res type="interface" descript="查询启动开关报警列表" path="/firectrl/client/sensor/getacbalarmlist" scope="all"/>
|
||||
<res type="interface" descript="查询启动开关状态信息数量" path="/firectrl/client/sensor/getacbstatusinfocount" scope="all"/>
|
||||
<res type="interface" descript="查询启动开关状态信息列表" path="/firectrl/client/sensor/getacbinfostatuslist" scope="all"/>
|
||||
<res type="interface" descript="计算气动开关参数信息" path="/firectrl/client/sensor/calacbparameter" scope="all"/>
|
||||
|
||||
<res type="interface" descript="查询液位计状态数量" path="/firectrl/client/sensor/liquidgage/getstatuscount" scope="all"/>
|
||||
<res type="interface" descript="查询液位计状态列表" path="/firectrl/client/sensor/liquidgage/getstatuslist" scope="all"/>
|
||||
<res type="interface" descript="查询水管水压状态数量" path="/firectrl/client/sensor/pipepressure/getstatuscount" scope="all"/>
|
||||
<res type="interface" descript="查询水管水压状态列表" path="/firectrl/client/sensor/pipepressure/getstatuslist" scope="all"/>
|
||||
<res type="interface" descript="设置液位计报警范围" path="/firectrl/client/sensor/liquidgage/setalarmrange" scope="all"/>
|
||||
<res type="interface" descript="设置水管水压报警范围" path="/firectrl/client/sensor/pipepressure/setalarmrange" scope="all"/>
|
||||
<res type="interface" descript="查询气体状态数量" path="/firectrl/client/sensor/gassensor/getstatuscount" scope="all"/>
|
||||
<res type="interface" descript="查询气体状态列表" path="/firectrl/client/sensor/gassensor/getstatuslist" scope="all"/>
|
||||
<res type="interface" descript="查询烟感事务事件数量" path="/firectrl/client/sensor/smoking/getbzeventcount" scope="all"/>
|
||||
<res type="interface" descript="查询烟感事务事件列表" path="/firectrl/client/sensor/smoking/getbzeventlist" scope="all"/>
|
||||
<res type="interface" descript="查询地磁事务事件数量" path="/firectrl/client/sensor/earthinductor/getbzeventcount" scope="all"/>
|
||||
<res type="interface" descript="查询地磁事务事件列表" path="/firectrl/client/sensor/earthinductor/getbzeventlist" scope="all"/>
|
||||
<res type="interface" descript="解除烟感报警事务" path="/firectrl/client/stopsmokingbuzevent" scope="all"/>
|
||||
<res type="interface" descript="关闭传感器报警功能" path="/firectrl/client/closesensoralarm" scope="all"/>
|
||||
<res type="interface" descript="打开传感器报警功能" path="/firectrl/client/opensensoralarm" scope="all"/>
|
||||
<res type="interface" descript="查询气体传感器最新状态" path="/firectrl/client/sensor/gassensor/getlaststatus" scope="all"/>
|
||||
<res type="interface" descript="查询报警主机事件数量" path="/firectrl/client/sensor/alarmhost/geteventcount" scope="all"/>
|
||||
<res type="interface" descript="查询报警主机事件列表" path="/firectrl/client/sensor/alarmhost/geteventlist" scope="all"/>
|
||||
<res type="interface" descript="查询多指定范围内多时段传感器报警数量" path="/firectrl/client/sensor/alarm/multi-querycount" scope="all"/>
|
||||
|
||||
<res type="interface" descript="删除气体传感器状态" path="/firectrl/client/sensor/gassensor/deleteevent" scope="only-admin"/>
|
||||
|
||||
<res type="interface" descript="查询智能IPC事件数量" path="/firectrl/client/sensor/aicamera/geteventcount" scope="all"/>
|
||||
<res type="interface" descript="查询智能IPC事件列表" path="/firectrl/client/sensor/aicamera/geteventlist" scope="all"/>
|
||||
|
||||
<res type="interface" descript="添加传感器子设备" path="/firectrl/client/sensor/addsubdev" scope="all"/>
|
||||
<res type="interface" descript="删除传感器子设备" path="/firectrl/client/sensor/delsubdev" scope="all"/>
|
||||
<res type="interface" descript="更新传感器子设备" path="/firectrl/client/sensor/updatesubdev" scope="all"/>
|
||||
<res type="interface" descript="查询传感器子设备列表" path="/firectrl/client/sensor/getsubdevlist" scope="all"/>
|
||||
|
||||
<res type="interface" descript="查询水表事件数量" path="/firectrl/client/sensor/watermeter/geteventcount" scope="all"/>
|
||||
<res type="interface" descript="查询水表事件列表" path="/firectrl/client/sensor/watermeter/geteventlist" scope="all"/>
|
||||
<res type="interface" descript="查询水表月统计" path="/firectrl/client/sensor/watermeter/getmonthcount" scope="all"/>
|
||||
<res type="interface" descript="查询水表日统计" path="/firectrl/client/sensor/watermeter/getdaycount" scope="all"/>
|
||||
<res type="interface" descript="查询水表小时统计" path="/firectrl/client/sensor/watermeter/gethourcount" scope="all"/>
|
||||
|
||||
<res type="interface" descript="查询AI IPC 入侵检测列表" path="/firectrl/client/sensor/aiipc/invade/getlist" scope="all"/>
|
||||
<res type="interface" descript="查询AI IPC 入侵检测数量" path="/firectrl/client/sensor/aiipc/invade/getcount" scope="all"/>
|
||||
|
||||
<res type="interface" descript="查询智能IPC人脸匹配事件数量" path="/firectrl/client/sensor/aiipc/getmatchfaceeventcount" scope="all"/>
|
||||
<res type="interface" descript="查询智能IPC人脸匹配事件列表" path="/firectrl/client/sensor/aiipc/getmatchfaceeventlist" scope="all"/>
|
||||
<res type="interface" descript="查询智能IPC车牌匹配事件数量" path="/firectrl/client/sensor/aiipc/getmatchcarplateeventcount" scope="all"/>
|
||||
<res type="interface" descript="查询智能IPC车牌匹配事件列表" path="/firectrl/client/sensor/aiipc/getmatchcarplateeventlist" scope="all"/>
|
||||
<res type="interface" descript="查询AIIPC配置信息" path="/firectrl/client/sensor/aiipc/getconfig" scope="all"/>
|
||||
<res type="interface" descript="配置AIIPC" path="/firectrl/client/sensor/aiipc/config" scope="all"/>
|
||||
|
||||
<res type="interface" descript="点名数据分析" path="/firectrl/client/analyze/rollcallack" scope="all"/>
|
||||
<res type="interface" descript="微站在离线数据分析" path="/firectrl/client/analyze/stationonline" scope="all"/>
|
||||
<res type="interface" descript="微站在离岗数据分析" path="/firectrl/client/analyze/stationonguard" scope="all"/>
|
||||
<res type="interface" descript="微站在线数量统计" path="/firectrl/client/analyze/stationonlinecount" scope="all"/>
|
||||
<res type="interface" descript="移动设备在线数量统计" path="/firectrl/client/analyze/mdevonlinecount" scope="all"/>
|
||||
<res type="interface" descript="移动设备在线时长分析" path="/firectrl/client/analyze/mdevonline" scope="all"/>
|
||||
<res type="interface" descript="传感器状态统计" path="/firectrl/client/analyze/sensorstatuscount" scope="all"/>
|
||||
<res type="interface" descript="发送通知" path="/firectrl/client/jpush" scope="all"/>
|
||||
|
||||
<res type="interface" descript="发送通知" path="/firectrl/client/notice/send" scope="all"/>
|
||||
<res type="interface" descript="查询通知总数" path="/firectrl/client/notice/getcount" scope="all"/>
|
||||
<res type="interface" descript="查询通知列表" path="/firectrl/client/notice/getlist" scope="all"/>
|
||||
<res type="interface" descript="查询通知状态" path="/firectrl/client/notice/getstatus" scope="all"/>
|
||||
<res type="interface" descript="获取通知分析数据" path="/firectrl/client/notice/analyze" scope="all"/>
|
||||
<res type="interface" descript="获取微站通知分析数据" path="/firectrl/client/notice/stationreport" scope="all"/>
|
||||
<res type="interface" descript="发送任务" path="/firectrl/client/assignment/send" scope="all"/>
|
||||
<res type="interface" descript="查询任务总数" path="/firectrl/client/assignment/getcount" scope="all"/>
|
||||
<res type="interface" descript="查询任务列表" path="/firectrl/client/assignment/getlist" scope="all"/>
|
||||
<res type="interface" descript="获取任务状态" path="/firectrl/client/assignment/getstatus" scope="all"/>
|
||||
<res type="interface" descript="查询任务分析数据" path="/firectrl/client/assignment/analyze" scope="all"/>
|
||||
<res type="interface" descript="查询多个时间段任务分析数据" path="/firectrl/client/notice/multi-analyze" scope="all"/>
|
||||
<res type="interface" descript="查询微站任务分析数据" path="/firectrl/client/assignment/stationreport" scope="all"/>
|
||||
<res type="interface" descript="查询微站任务处置信息" path="/firectrl/client/assignment/getprocessinfo" scope="all"/>
|
||||
<res type="interface" descript="按范围查询任务" path="/firectrl/client/assignment/getlistbyscope" scope="all"/>
|
||||
|
||||
<res type="interface" descript="微站查岗记录保存" path="/firectrl/client/inspect/save" scope="all"/>
|
||||
<res type="interface" descript="查询微站查岗记录总数" path="/firectrl/client/inspect/getcount" scope="all"/>
|
||||
<res type="interface" descript="查询微站查岗记录列表" path="/firectrl/client/inspect/getlist" scope="all"/>
|
||||
<res type="interface" descript="添加巡检设备" path="/firectrl/client/roundinspect/adddevice" scope="all"/>
|
||||
<res type="interface" descript="删除巡检设备" path="/firectrl/client/roundinspect/deldevice" scope="all"/>
|
||||
<res type="interface" descript="更新巡检设备信息" path="/firectrl/client/roundinspect/updatedevice" scope="all"/>
|
||||
<res type="interface" descript="查询巡检设备总数" path="/firectrl/client/roundinspect/getdevicecount" scope="all"/>
|
||||
<res type="interface" descript="查询巡检设备列表" path="/firectrl/client/roundinspect/getdevicelist" scope="all"/>
|
||||
<res type="interface" descript="添加巡检任务" path="/firectrl/client/roundinspect/addtask" scope="all"/>
|
||||
<res type="interface" descript="取消巡检任务" path="/firectrl/client/roundinspect/canceltask" scope="all"/>
|
||||
<res type="interface" descript="查询巡检任务数量" path="/firectrl/client/roundinspect/gettaskcount" scope="all"/>
|
||||
<res type="interface" descript="查询巡检任务列表" path="/firectrl/client/roundinspect/gettasklist" scope="all"/>
|
||||
<res type="interface" descript="查询巡检图片数量" path="/firectrl/client/roundinspect/getpictureount" scope="all"/>
|
||||
<res type="interface" descript="查询巡检图片列表" path="/firectrl/client/roundinspect/getpicturelist" scope="all"/>
|
||||
|
||||
<res type="interface" descript="给微站发送升级任务" path="/firectrl/client/swupdate/addtask" scope="only-admin"/>
|
||||
<res type="interface" descript="查询微站升级任务" path="/firectrl/client/swupdate/gettask" scope="all"/>
|
||||
<res type="interface" descript="关闭微站升级任务" path="/firectrl/client/swupdate/closetask" scope="only-admin"/>
|
||||
|
||||
<res type="interface" descript="设置微站属性" path="/firectrl/client/station/property/add" scope="optional"/>
|
||||
<res type="interface" descript="删除微站属性" path="/firectrl/client/station/property/delete" scope="optional"/>
|
||||
<res type="interface" descript="查询微站属性" path="/firectrl/client/station/property/get" scope="all"/>
|
||||
<res type="interface" descript="获取两点间的最短距离" path="/firectrl/client/getdistance" scope="all"/>
|
||||
|
||||
<res type="interface" descript="添加消防队" path="/firectrl/client/fireunit/add" scope="only-admin"/>
|
||||
<res type="interface" descript="删除消防队" path="/firectrl/client/fireunit/delete" scope="only-admin"/>
|
||||
<res type="interface" descript="更新消防队" path="/firectrl/client/fireunit/update" scope="only-admin"/>
|
||||
<res type="interface" descript="查询消防队" path="/firectrl/client/fireunit/getlist" scope="all"/>
|
||||
|
||||
<res type="interface" descript="添加媒体资源" path="/firectrl/client/media/add" scope="all"/>
|
||||
<res type="interface" descript="删除媒体资源" path="/firectrl/client/media/delete" scope="all"/>
|
||||
<res type="interface" descript="修改媒体资源" path="/firectrl/client/media/update" scope="all"/>
|
||||
<res type="interface" descript="查询媒体资源数量" path="/firectrl/client/media/getcount" scope="all"/>
|
||||
<res type="interface" descript="查询媒体资源列表" path="/firectrl/client/media/getlist" scope="all"/>
|
||||
|
||||
<res type="interface" descript="处理报警" path="/firectrl/client/alarm/process" scope="all"/>
|
||||
<res type="interface" descript="处理所有报警" path="/firectrl/client/alarm/processall" scope="all"/>
|
||||
<res type="interface" descript="查询报警数量" path="/firectrl/client/alarm/querycount" scope="all"/>
|
||||
<res type="interface" descript="查询多段报警数量" path="/firectrl/client/alarm/multi-querycount" scope="all"/>
|
||||
<res type="interface" descript="查询报警列表" path="/firectrl/client/alarm/querylist" scope="all"/>
|
||||
<res type="interface" descript="添加报警处理操作" path="/firectrl/client/alarm/operation/add" scope="all"/>
|
||||
<res type="interface" descript="查询报警处理操作数量" path="/firectrl/client/alarm/operation/getcount" scope="all"/>
|
||||
<res type="interface" descript="查询报警处理操作列表" path="/firectrl/client/alarm/operation/getlist" scope="all"/>
|
||||
|
||||
<res type="interface" descript="生成报告文件" path="/firectrl/client/reportfile/generate" scope="all"/>
|
||||
<res type="interface" descript="生成报告文件" path="/firectrl/client/reportfile/query" scope="all"/>
|
||||
|
||||
<res type="interface" descript="查询微站实时统计信息" path="/firectrl/client/station/runtimecache/query" scope="all"/>
|
||||
|
||||
<res type="interface" descript="添加对讲企业账号" path="/firectrl/client/talk/addplatformaccount" scope="only-admin"/>
|
||||
<res type="interface" descript="删除对讲企业账号" path="/firectrl/client/talk/updatetalkplatfomraccount" scope="only-admin"/>
|
||||
<res type="interface" descript="更新对讲企业账号" path="/firectrl/client/talk/deleteplatformaccount" scope="only-admin"/>
|
||||
<res type="interface" descript="查询对讲企业账号" path="/firectrl/client/talk/getplatformaccount" scope="all"/>
|
||||
<res type="interface" descript="查询对讲企业账号列表" path="/firectrl/client/talk/gettalkplatfomraccountlist" scope="all"/>
|
||||
|
||||
<res type="interface" descript="添加人员信息" path="/firectrl/client/person/add" scope="all"/>
|
||||
<res type="interface" descript="删除人员信息" path="/firectrl/client/person/delete" scope="all"/>
|
||||
<res type="interface" descript="更新人员信息" path="/firectrl/client/person/update" scope="all"/>
|
||||
<res type="interface" descript="查询人员列表" path="/firectrl/client/person/getlist" scope="all"/>
|
||||
|
||||
|
||||
</resinfodefine>
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,90 @@
|
|||
package com.jingyi.iotserver.clientmanage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ClientRuningInfo {
|
||||
private String name;
|
||||
private String usertype;
|
||||
private long mLastActTime;
|
||||
private long mTimeOut;
|
||||
private String sessionid;
|
||||
private String scopelevel;
|
||||
private String levelvalue;
|
||||
private List<String> roles = new ArrayList<String>();
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setUsertype(String usertype) {
|
||||
this.usertype = usertype;
|
||||
}
|
||||
|
||||
public String getUsertype() {
|
||||
return usertype;
|
||||
}
|
||||
|
||||
public long getmLastActTime() {
|
||||
return mLastActTime;
|
||||
}
|
||||
|
||||
public void setmLastActTime(long mLastActTime) {
|
||||
this.mLastActTime = mLastActTime;
|
||||
}
|
||||
|
||||
public String getSessionid() {
|
||||
return sessionid;
|
||||
}
|
||||
|
||||
public void setSessionid(String sessionid) {
|
||||
this.sessionid = sessionid;
|
||||
}
|
||||
|
||||
public void setmTimeOut(long mTimeOut) {
|
||||
this.mTimeOut = mTimeOut;
|
||||
}
|
||||
|
||||
public long getmTimeOut() {
|
||||
return mTimeOut;
|
||||
}
|
||||
|
||||
public void setScopelevel(String scopelevel) {
|
||||
this.scopelevel = scopelevel;
|
||||
}
|
||||
|
||||
public String getScopelevel() {
|
||||
return scopelevel;
|
||||
}
|
||||
|
||||
public void setLevelvalue(String levelvalue) {
|
||||
this.levelvalue = levelvalue;
|
||||
}
|
||||
|
||||
public String getLevelvalue() {
|
||||
return levelvalue;
|
||||
}
|
||||
|
||||
public void addRole(String rolename){
|
||||
roles.add(rolename);
|
||||
}
|
||||
|
||||
|
||||
public List<String>getRoles(){
|
||||
return roles;
|
||||
}
|
||||
public boolean CheckActive(){
|
||||
long cur = System.currentTimeMillis();
|
||||
if(cur-mLastActTime>=mTimeOut)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void UpdateActive(){
|
||||
mLastActTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.jingyi.iotserver.clientmanage;
|
||||
|
||||
import com.jingyi.iotserver.clientmanage.model.BoroughEntity;
|
||||
import com.jingyi.iotserver.clientmanage.model.BrigadeEntity;
|
||||
import com.jingyi.iotserver.clientmanage.model.DetachmentEntity;
|
||||
|
||||
public interface IOTCommonCallAppInf {
|
||||
public boolean PrepareDeleteBrigade(BrigadeEntity brigade);
|
||||
public boolean PrepareDeleteBorough(BoroughEntity borough);
|
||||
public boolean PrepareDeleteDetachment(DetachmentEntity detachment);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.jingyi.iotserver.clientmanage;
|
||||
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.clientmanage.model.OrganizationInfoEntity;
|
||||
|
||||
public interface IOrganizationOperate {
|
||||
public RespEntity ExecuteOperate(OrganizationInfoEntity org, Object param);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.jingyi.iotserver.clientmanage;
|
||||
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.clientmanage.model.UserInfoEntity;
|
||||
|
||||
public interface IUserOperate {
|
||||
public RespEntity ExecuteOperate(UserInfoEntity userinfo, Object param);
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.jingyi.iotserver.clientmanage;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class InterceptorConfig implements WebMvcConfigurer {
|
||||
@Autowired
|
||||
LoginInterceptor loginInterceptor;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
InterceptorRegistration registration = registry.addInterceptor(loginInterceptor);
|
||||
//addPathPatterns 用于添加拦截规则
|
||||
//excludePathPatterns用于排除拦截规则
|
||||
|
||||
registration.addPathPatterns("/common/client/**");
|
||||
registration.addPathPatterns("/firectrl/client/**");
|
||||
registration.addPathPatterns("/firectrl/partner/**");
|
||||
registration.addPathPatterns("/user/**");
|
||||
registration.excludePathPatterns("/common/client/user/login");
|
||||
registration.excludePathPatterns("/common/client/exit");
|
||||
registration.excludePathPatterns("/common/client/user/saveoperate");
|
||||
|
||||
registration.excludePathPatterns("/firectrl/file/**");
|
||||
registration.excludePathPatterns("/firectrl/partner/assign");
|
||||
registration.excludePathPatterns("/firectrl/partner/getsensorcount");
|
||||
registration.excludePathPatterns("/firectrl/partner/getsensorpage");
|
||||
registration.excludePathPatterns("/firectrl/client/isactive");
|
||||
registration.excludePathPatterns("/firectrl/client/user/login");
|
||||
registration.excludePathPatterns("/firectrl/client/user/agentlogin");
|
||||
registration.excludePathPatterns("/firectrl/client/test/db");
|
||||
registration.excludePathPatterns("/iotserver/sensor/huaxtent/earthinductor");
|
||||
registration.excludePathPatterns("/iotserver/sensor/**");
|
||||
registration.excludePathPatterns("/iotserver/alarmtask/**");
|
||||
registration.excludePathPatterns("/iotserver/pluginfo/**");
|
||||
registration.excludePathPatterns("/firectrl/client/notice/sendmqtt");
|
||||
registration.excludePathPatterns("/firectrl/client/map/**");
|
||||
|
||||
// registration.excludePathPatterns("/firectrl/client/getstationcount");
|
||||
// registration.excludePathPatterns("/firectrl/client/user/create");
|
||||
/* */
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins("*")
|
||||
.allowedMethods("GET", "POST", "OPTION", "PUT")
|
||||
.allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method",
|
||||
"Access-Control-Request-Headers","Authorization")
|
||||
.allowCredentials(true)
|
||||
.maxAge(3600);
|
||||
/*
|
||||
.exposedHeaders("Access-Control-Allow-Origin", "Access-Control-Allow-Credentials")
|
||||
.allowedHeaders("*")
|
||||
.exposedHeaders("Access-Control-Allow-Origin", "Access-Control-Allow-Credentials","sessionjy")
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,175 @@
|
|||
package com.jingyi.iotserver.clientmanage;
|
||||
|
||||
|
||||
import com.jingyi.iotserver.clientmanage.model.ThirdPlatformInfoEntity;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.sql.DataSource;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
//https://www.tianmaying.com/tutorial/spring-mvc-interceptor
|
||||
//https://www.jianshu.com/p/43c97352aa1e
|
||||
|
||||
@Service
|
||||
public class LoginInterceptor implements HandlerInterceptor {
|
||||
@Autowired
|
||||
UserAuthorManager userAuthorManager;
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(LoginInterceptor.class);
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
// System.out.println("preHandler");
|
||||
|
||||
// HttpSession session = request.getSession();
|
||||
Cookie[] cookies = request.getCookies();
|
||||
/* if(cookies==null)
|
||||
{
|
||||
return false;
|
||||
}else{
|
||||
for(Cookie cookie : cookies){
|
||||
if(cookie.getName().equals("session")){
|
||||
String val = cookie.getValue();
|
||||
String username = (String)session.getAttribute(val);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} */
|
||||
try{
|
||||
// Thread.sleep(20);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
String methodstr = request.getMethod();
|
||||
String uri = request.getRequestURI();
|
||||
if(methodstr.equals("OPTIONS"))
|
||||
return true;
|
||||
String sessionid = request.getHeader("authorization");
|
||||
|
||||
// String json = HttpTools.getBodyFromRequest(request);
|
||||
// JsonNode rootnode = JsonHelper.parseBodyLevel1(json);
|
||||
/* if(rootnode==null){
|
||||
//error request
|
||||
return false;
|
||||
}
|
||||
String sessionid = JsonHelper.getStringValue(rootnode,"session");*/
|
||||
// sessionid = MD5Tools.md5("firectrl"+"administrator"+sessionid)
|
||||
|
||||
if(uri.startsWith("/firectrl/partner/")){
|
||||
String appkey = request.getHeader("appkey");
|
||||
ThirdPlatformInfoEntity platform = null;
|
||||
if(appkey!=null)
|
||||
platform = ThirdPlatformInfoEntity.Query(dataSource,appkey);
|
||||
if(platform==null){
|
||||
platform = ThirdPlatformInfoEntity.Query(dataSource,sessionid);
|
||||
}else
|
||||
request.setAttribute("authorization",appkey);
|
||||
if(platform==null){
|
||||
responseOutWithJson(response,"{\"code\":-301,\"msg\":\"无权限\",\"request\":0}",request.getHeader("origin"));
|
||||
return false;
|
||||
}else
|
||||
return true;
|
||||
}
|
||||
|
||||
if(sessionid==null||!userAuthorManager.checkSessionActiveUpdate(sessionid)){
|
||||
responseOutWithJson(response,"{\"code\":-101,\"msg\":\"未登录\",\"request\":0}",request.getHeader("origin"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(userAuthorManager.IsAdmin(request)||userAuthorManager.IsSuper(request)) {
|
||||
logger.info(userAuthorManager.getUserName(sessionid));
|
||||
logger.info("==>"+uri);
|
||||
return true;
|
||||
}
|
||||
if(!userAuthorManager.checkUserAuthor(sessionid,uri)){
|
||||
responseOutWithJson(response,"{\"code\":-100,\"msg\":\"无权限\",\"request\":0}",request.getHeader("origin"));
|
||||
return false;
|
||||
}
|
||||
|
||||
logger.info(userAuthorManager.getUserName(sessionid));
|
||||
logger.info("==>"+uri);
|
||||
// request.setAttribute("req-json-str",json);
|
||||
// request.setAttribute("req-json-obj", rootnode);
|
||||
|
||||
/*
|
||||
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
||||
Method method = handlerMethod.getMethod();
|
||||
UserAccess access = method.getAnnotation(UserAccess.class);
|
||||
if(access!=null&&access.roles().length>0){
|
||||
String username = userAuthorManager.getUserName(sessionid);
|
||||
if(username==null)
|
||||
return false;
|
||||
boolean pass = false;
|
||||
String[] roles = access.roles();
|
||||
Set<String> roleSet = new HashSet<>();
|
||||
for (String role : roles) {
|
||||
// 将角色加入一个set集合中
|
||||
roleSet.add(role);
|
||||
}
|
||||
|
||||
|
||||
if(roleSet.contains("administrator")){
|
||||
if(username.equals("administrator"))
|
||||
pass = true;
|
||||
}
|
||||
|
||||
if(!pass)
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
return true;//true next handler process, false
|
||||
|
||||
}
|
||||
|
||||
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
|
||||
throws Exception {
|
||||
// System.out.println("postHandler");
|
||||
}
|
||||
|
||||
@Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||
throws Exception {
|
||||
// System.out.println("afterCompletion");
|
||||
}
|
||||
|
||||
protected void responseOutWithJson(HttpServletResponse response,
|
||||
String responseObject,String origin) {
|
||||
// JsonNode rootnode = null;
|
||||
// ObjectMapper mapper = new ObjectMapper();
|
||||
// mapper.
|
||||
//将实体对象转换为JSON Object转换
|
||||
// JSONObject responseJSONObject = JSONObject.fromObject(responseObject);
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/json; charset=utf-8");
|
||||
response.setStatus(200);
|
||||
response.setHeader("Access-Control-Allow-Credentials","true");
|
||||
response.setHeader("Access-Control-Allow-Origin",origin);
|
||||
// response.setHeader("Transfer-Encoding","chunked");
|
||||
response.setHeader("Vary","Origin, Access-Control-Request-Method, Access-Control-Request-Headers");
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
out = response.getWriter();
|
||||
// out.append(responseJSONObject.toString());
|
||||
out.append(responseObject);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,489 @@
|
|||
package com.jingyi.iotserver.clientmanage;
|
||||
|
||||
import com.jingyi.iotserver.clientmanage.model.AuthorityEntity;
|
||||
import com.jingyi.iotserver.clientmanage.model.OperatingRecordEntity;
|
||||
import com.jingyi.iotserver.clientmanage.model.OrganiztionUri;
|
||||
import com.jingyi.iotserver.clientmanage.model.RoleEntity;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class UserAuthorManager {
|
||||
public static final String USER_OPERATE_TYPE_CREATE = "create";
|
||||
public static final String USER_OPERATE_TYPE_DELETE = "delete";
|
||||
public static final String USER_OPERATE_TYPE_UPDATE = "update";
|
||||
public static final String USER_OPERATE_TYPE_RESET_PWD = "reset_password";
|
||||
public static final String USER_OPERATE_TYPE_CHANGE_PWD = "change_password";
|
||||
public static final String USER_OPERATE_TYPE_PATCH = "patch";
|
||||
public static final String USER_OPERATE_TYPE_RUN = "run";
|
||||
public static final String USER_OPERATE_TYPE_STOP = "stop";
|
||||
public static final String USER_OPERATE_TYPE_SET = "set";
|
||||
public static final String USER_OPERATE_TYPE_VERIFY = "verify";
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
private Object locker = new Object();
|
||||
private HashMap<String, ClientRuningInfo> mClientsMap = new HashMap<String,ClientRuningInfo>();
|
||||
private HashMap<String,ClientRuningInfo> mSessionsMap = new HashMap<String,ClientRuningInfo>();
|
||||
private HashMap<String,RoleEntity> mRoleAuthorMap = new HashMap<String,RoleEntity>();
|
||||
private HashMap<String,AuthorityEntity> mAnyRoleResMap = new HashMap<String,AuthorityEntity>();
|
||||
|
||||
private Thread scanservice = null;
|
||||
public void Init(){
|
||||
try {
|
||||
// Resource resource = new ClassPathResource("static\\dbinfodefine.xml");
|
||||
// File file = resource.getFile();
|
||||
InputStream stream = getClass().getClassLoader().getResourceAsStream("static/defaultroledefine.xml");
|
||||
File targetFile = new File("defaultroledefine.xml");
|
||||
// FileUtils.copyInputStreamToFile(stream, targetFile);
|
||||
|
||||
// BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(targetFile)));
|
||||
|
||||
SAXReader reader = new SAXReader();
|
||||
Document document = reader.read(new InputStreamReader(stream,"utf8"));
|
||||
Element root = document.getRootElement();
|
||||
if("defaultroledefine".equals(root.getName())) {
|
||||
List<Element> list = root.elements();
|
||||
for(Element el:list){
|
||||
if(el==null)
|
||||
continue;
|
||||
if(!"role".equals(el.getName()))
|
||||
continue;
|
||||
Attribute atr = el.attribute("name");
|
||||
String role = atr.getStringValue();
|
||||
RoleEntity roleEntity = new RoleEntity();
|
||||
roleEntity.setRolename(role);
|
||||
try{
|
||||
roleEntity = (RoleEntity)roleEntity.QueryIt(dataSource);
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
|
||||
if(roleEntity==null){
|
||||
roleEntity = new RoleEntity();
|
||||
roleEntity.setRolename(role);
|
||||
roleEntity.Insert(dataSource);
|
||||
|
||||
}
|
||||
|
||||
List<SQLDataObject> authors = null;
|
||||
try{
|
||||
AuthorityEntity aut = new AuthorityEntity();
|
||||
aut.extendName(""+roleEntity.getId());
|
||||
authors = aut.queryList(dataSource,null,null);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
List<Element> reses = el.elements();
|
||||
HashMap<String,AuthorityEntity> defautauth = new HashMap<String,AuthorityEntity>();
|
||||
for(Element res:reses){
|
||||
if(!"res".equals(res.getName()))
|
||||
continue;
|
||||
Attribute attr = res.attribute("type");
|
||||
String type = attr.getStringValue();
|
||||
attr = res.attribute("descript");
|
||||
String discript = attr.getStringValue();
|
||||
attr = res.attribute("path");
|
||||
String path = attr.getStringValue();
|
||||
if(type==null||type.length()<=0||path==null||path.length()<=0)
|
||||
continue;
|
||||
AuthorityEntity auth = new AuthorityEntity();
|
||||
auth.setDiscript(discript);
|
||||
auth.setPath(path);
|
||||
auth.setType(type);
|
||||
defautauth.put(path,auth);
|
||||
}
|
||||
if(authors!=null){
|
||||
for(SQLDataObject ob:authors) {
|
||||
AuthorityEntity auth = (AuthorityEntity) ob;
|
||||
if (defautauth.get(auth.getPath()) != null) {
|
||||
defautauth.remove(auth.getPath());
|
||||
} else {
|
||||
auth.extendName("" + roleEntity.getId());
|
||||
auth.Delete(dataSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(Map.Entry<String, AuthorityEntity> entry: defautauth.entrySet()){
|
||||
AuthorityEntity auth = entry.getValue();
|
||||
try {
|
||||
auth.extendName("" + roleEntity.getId());
|
||||
auth.Insert(dataSource);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
LoadRoleAuthority();
|
||||
LoadAnyRoleRes();
|
||||
scanservice = new Thread(){
|
||||
public void run(){
|
||||
while(true){
|
||||
try {
|
||||
CheckSessionTimeOut();
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
try{
|
||||
Thread.sleep(5*60*1000);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
scanservice.start();
|
||||
}
|
||||
|
||||
private void LoadAnyRoleRes(){
|
||||
try {
|
||||
// Resource resource = new ClassPathResource("static\\dbinfodefine.xml");
|
||||
// File file = resource.getFile();
|
||||
InputStream stream = getClass().getClassLoader().getResourceAsStream("static/resinfodefine.xml");
|
||||
File targetFile = new File("resinfodfine.xml");
|
||||
// FileUtils.copyInputStreamToFile(stream, targetFile);
|
||||
|
||||
// BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(targetFile)));
|
||||
|
||||
SAXReader reader = new SAXReader();
|
||||
Document document = reader.read(new InputStreamReader(stream,"utf8"));
|
||||
Element root = document.getRootElement();
|
||||
if("resinfodefine".equals(root.getName())) {
|
||||
List<Element> list = root.elements();
|
||||
for(Element el:list){
|
||||
if(el==null)
|
||||
continue;
|
||||
if(!"res".equals(el.getName()))
|
||||
continue;
|
||||
Attribute atr = el.attribute("scope");
|
||||
String scope = atr.getStringValue();
|
||||
|
||||
if(scope==null||!scope.equals("all"))
|
||||
continue;
|
||||
|
||||
atr = el.attribute("path");
|
||||
String path = atr.getStringValue();
|
||||
|
||||
atr = el.attribute("descript");
|
||||
String descript = atr.getStringValue();
|
||||
|
||||
atr = el.attribute("type");
|
||||
String type = atr.getStringValue();
|
||||
|
||||
AuthorityEntity authorityEntity = new AuthorityEntity();
|
||||
|
||||
authorityEntity.setType(type);
|
||||
authorityEntity.setPath(path);
|
||||
authorityEntity.setDiscript(descript);
|
||||
|
||||
mAnyRoleResMap.put(path,authorityEntity);
|
||||
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckSessionTimeOut(){
|
||||
synchronized (locker) {
|
||||
for (Map.Entry<String, ClientRuningInfo> entry : mSessionsMap.entrySet()) {
|
||||
ClientRuningInfo info = entry.getValue();
|
||||
if (info!=null&&!info.CheckActive()) {
|
||||
mClientsMap.remove(info.getName());
|
||||
mSessionsMap.remove(info.getSessionid());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadRoleAuthority(){
|
||||
try{
|
||||
RoleEntity r = new RoleEntity();
|
||||
List<SQLDataObject> rolelist = r.queryList(dataSource,null,null);
|
||||
for(SQLDataObject ob:rolelist){
|
||||
RoleEntity role = (RoleEntity)ob;
|
||||
if(role!=null){
|
||||
mRoleAuthorMap.put(role.getRolename(),role);
|
||||
AuthorityEntity aut = new AuthorityEntity();
|
||||
aut.extendName(""+role.getId());
|
||||
List<SQLDataObject> authors = aut.queryList(dataSource,null,null);
|
||||
if(authors!=null){
|
||||
for(SQLDataObject auth:authors){
|
||||
role.addAuthor((AuthorityEntity)auth);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
public String CheckUserLoginSession(String username){
|
||||
synchronized (locker) {
|
||||
ClientRuningInfo info = mClientsMap.get(username);
|
||||
if (info == null)
|
||||
return null;
|
||||
if(!info.CheckActive()){
|
||||
mClientsMap.remove(info.getName());
|
||||
mSessionsMap.remove(info.getSessionid());
|
||||
return null;
|
||||
}else{
|
||||
info.UpdateActive();
|
||||
return info.getSessionid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void KickOutUser(String username){
|
||||
synchronized (locker) {
|
||||
ClientRuningInfo info = mClientsMap.get(username);
|
||||
if (info == null)
|
||||
return ;
|
||||
mClientsMap.remove(info.getName());
|
||||
mSessionsMap.remove(info.getSessionid());
|
||||
|
||||
}
|
||||
}
|
||||
public boolean checkSessionActiveUpdate(String sessionid){
|
||||
synchronized (locker) {
|
||||
ClientRuningInfo info = mSessionsMap.get(sessionid);
|
||||
if(info==null)
|
||||
return false;
|
||||
if(!info.CheckActive()){
|
||||
mClientsMap.remove(info.getName());
|
||||
mSessionsMap.remove(sessionid);
|
||||
return false;
|
||||
}else{
|
||||
info.UpdateActive();
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addNewSession(String session,String username,String usertype,String role,String scopelevel ,String levelvalue){
|
||||
synchronized (locker) {
|
||||
ClientRuningInfo info = new ClientRuningInfo();
|
||||
info.setName(username);
|
||||
info.setUsertype(usertype);
|
||||
info.setSessionid(session);
|
||||
info.setScopelevel(scopelevel);
|
||||
info.setLevelvalue(levelvalue);
|
||||
info.setmLastActTime(System.currentTimeMillis());
|
||||
info.setmTimeOut(15*60*1000+2000);
|
||||
if(role!=null){
|
||||
String[] roles = role.split("#");
|
||||
if(roles!=null&&roles.length>0){
|
||||
for(int i=0;i<roles.length;i++){
|
||||
if(roles[i]!=null&&roles[i].length()>0){
|
||||
info.addRole(roles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mClientsMap.put(username,info);
|
||||
mSessionsMap.put(session,info);
|
||||
}
|
||||
}
|
||||
|
||||
public String getUserName(String session){
|
||||
String name = null;
|
||||
synchronized (locker) {
|
||||
ClientRuningInfo info = mSessionsMap.get(session);
|
||||
name = info.getName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public ClientRuningInfo getUserInfo(String session){
|
||||
ClientRuningInfo info = null;
|
||||
synchronized (locker) {
|
||||
info = mSessionsMap.get(session);
|
||||
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
public boolean checkUserAuthor(String session,String uri){
|
||||
|
||||
synchronized (locker) {
|
||||
|
||||
if(mAnyRoleResMap.get(uri)!=null)
|
||||
return true;
|
||||
|
||||
ClientRuningInfo info = mSessionsMap.get(session);
|
||||
List<String> roles = info.getRoles();
|
||||
for(String rolename:roles){
|
||||
RoleEntity role = mRoleAuthorMap.get(rolename);
|
||||
if(role.getAuthorlist().get(uri)!=null)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean IsAdmin(HttpServletRequest request){
|
||||
synchronized (locker) {
|
||||
String type = null;
|
||||
String session = request.getHeader("authorization");
|
||||
ClientRuningInfo info = mSessionsMap.get(session);
|
||||
type = info.getUsertype();
|
||||
if(type==null)
|
||||
return false;
|
||||
if(type.equals("admin"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean IsSuper(HttpServletRequest request){
|
||||
synchronized (locker) {
|
||||
String type = null;
|
||||
String session = request.getHeader("authorization");
|
||||
ClientRuningInfo info = mSessionsMap.get(session);
|
||||
type = info.getUsertype();
|
||||
if(type==null)
|
||||
return false;
|
||||
if(info.getName().equals("administrator"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean IsSelf(HttpServletRequest request,String name){
|
||||
if(name==null)
|
||||
return false;
|
||||
synchronized (locker) {
|
||||
String session = request.getHeader("authorization");
|
||||
ClientRuningInfo info = mSessionsMap.get(session);
|
||||
|
||||
if(info.getName().equals(name))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void NotifyDeleteRole(RoleEntity role){
|
||||
if(role==null)
|
||||
return;
|
||||
synchronized (locker) {
|
||||
mRoleAuthorMap.remove(role.getRolename());
|
||||
}
|
||||
}
|
||||
|
||||
public void NotifyUpdateRoleAuthority(RoleEntity role){
|
||||
if(role==null)
|
||||
return;
|
||||
RoleEntity ra = (RoleEntity)role.QueryIt(dataSource);
|
||||
if(ra==null)
|
||||
return;
|
||||
AuthorityEntity aut = new AuthorityEntity();
|
||||
aut.extendName(""+ra.getId());
|
||||
List<SQLDataObject> authors = aut.queryList(dataSource,null,null);
|
||||
if(authors!=null){
|
||||
for(SQLDataObject ob:authors){
|
||||
AuthorityEntity auth = (AuthorityEntity)ob;
|
||||
role.addAuthor(auth);
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (locker) {
|
||||
mRoleAuthorMap.remove(role.getRolename());
|
||||
mRoleAuthorMap.put(ra.getRolename(),ra);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddUserOperate(HttpServletRequest request,String operate,String objective,String conttent,String detail,int result){
|
||||
try {
|
||||
String sessionid = request.getHeader("authorization");
|
||||
|
||||
ClientRuningInfo info = mSessionsMap.get(sessionid);
|
||||
OperatingRecordEntity op = new OperatingRecordEntity();
|
||||
|
||||
op.setUsername(info.getName());
|
||||
op.setTimestamp(new Date());
|
||||
op.setOperate(operate);
|
||||
op.setObjective(objective);
|
||||
op.setContent(conttent);
|
||||
op.setDetail(detail);
|
||||
op.setResult(result);
|
||||
op.Insert(dataSource);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void AddUserOperate(String username,String operate,String objective,String content,String detail,int result){
|
||||
try {
|
||||
OperatingRecordEntity op = new OperatingRecordEntity();
|
||||
|
||||
op.setUsername(username);
|
||||
op.setTimestamp(new Date());
|
||||
op.setOperate(operate);
|
||||
op.setObjective(objective);
|
||||
op.setContent(content);
|
||||
op.setDetail(detail);
|
||||
op.setResult(result);
|
||||
op.Insert(dataSource);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public OrganiztionUri getUserScope(String sessionid){
|
||||
ClientRuningInfo info = mSessionsMap.get(sessionid);
|
||||
String type = info.getUsertype();
|
||||
if(type==null)
|
||||
return null;
|
||||
if(info.getName().equals("administrator"))
|
||||
return new OrganiztionUri();
|
||||
|
||||
OrganiztionUri uri = new OrganiztionUri();
|
||||
String level = info.getScopelevel();
|
||||
if(level==null)
|
||||
return null;
|
||||
if(level.equals("brigade"))
|
||||
uri.setBrigade(info.getLevelvalue());
|
||||
else if(level.equals("borough"))
|
||||
uri.setBorough(info.getLevelvalue());
|
||||
else if(level.equals("detachment"))
|
||||
uri.setDetachment(info.getLevelvalue());
|
||||
else if(level.equals("station"))
|
||||
uri.setStation(info.getLevelvalue());
|
||||
else
|
||||
return null;
|
||||
return uri;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,272 @@
|
|||
package com.jingyi.iotserver.clientmanage;
|
||||
|
||||
import com.jingyi.iotserver.clientmanage.model.*;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationBaseInfoEntity;
|
||||
import com.jingyi.iotserver.utils.MD5Tools;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.jingyi.iotserver.common.service.EnvConfigService;
|
||||
import javax.sql.DataSource;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
UserAuthorManager userAuthorManager;
|
||||
|
||||
@Autowired
|
||||
private EnvConfigService envConfigService;
|
||||
|
||||
private ArrayList<IOTCommonCallAppInf> appinfs = new ArrayList<IOTCommonCallAppInf>();
|
||||
public void InitService(){
|
||||
|
||||
try{
|
||||
UserInfoEntity user = new UserInfoEntity();
|
||||
user.setName("administrator");
|
||||
user = (UserInfoEntity)user.QueryIt(dataSource);
|
||||
if(user==null){
|
||||
user = new UserInfoEntity();
|
||||
user.setName("administrator");
|
||||
user.setUsertype("super");
|
||||
user.setScopelevel("master");
|
||||
user.setLevelvalue("");
|
||||
String adminpwd = MD5Tools.md5(envConfigService.getSuperPassword());
|
||||
String pwd = MD5Tools.md5("firectrl"+"administrator"+adminpwd);
|
||||
user.setPassword(pwd);
|
||||
user.Insert(dataSource);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterAppInf(IOTCommonCallAppInf inf){
|
||||
|
||||
if(appinfs!=null)
|
||||
appinfs.add(inf);
|
||||
}
|
||||
|
||||
public UserInfoEntity queryUserInfo(String name){
|
||||
try {
|
||||
UserInfoEntity user = new UserInfoEntity();
|
||||
user.setName(name);
|
||||
return (UserInfoEntity)user.QueryIt(dataSource);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public boolean createRole(RoleEntity role,List<AuthorityEntity>list){
|
||||
try {
|
||||
if(role==null||role.QueryIt(dataSource)!=null)
|
||||
return false;
|
||||
if(!role.Insert(dataSource))
|
||||
return false;
|
||||
if(list!=null&&list.size()>0)
|
||||
{
|
||||
for(AuthorityEntity auth:list){
|
||||
auth.extendName(""+role.getId());
|
||||
auth.Insert(dataSource);
|
||||
}
|
||||
}
|
||||
userAuthorManager.NotifyUpdateRoleAuthority(role);
|
||||
return true;
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public RespEntity deleteRole(RoleEntity role){
|
||||
try {
|
||||
UserInfoEntity user = new UserInfoEntity();
|
||||
user.setUserrole(role.getRolename());
|
||||
List<SQLDataObject> users = user.queryList(dataSource,null,null);
|
||||
if(users!=null&&users.size()>0)
|
||||
return new RespEntity(RespCode.NOTEMPTY);
|
||||
RoleEntity r = (RoleEntity)role.QueryIt(dataSource);
|
||||
if(r!=null&&r.getId()>0) {
|
||||
r.Delete(dataSource);
|
||||
AuthorityEntity aut = new AuthorityEntity();
|
||||
aut.extendName("" + r.getId());
|
||||
aut.dropTableSql(dataSource);
|
||||
userAuthorManager.NotifyDeleteRole(role);
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
|
||||
public boolean updateRoleAuthoriy(String rolename, List<AuthorityEntity> authors){
|
||||
RoleEntity role = new RoleEntity();
|
||||
role.setRolename(rolename);
|
||||
role = (RoleEntity)role.QueryIt(dataSource);
|
||||
try {
|
||||
AuthorityEntity aut = new AuthorityEntity();
|
||||
aut.extendName("" + role.getId());
|
||||
aut.DeleteAll(dataSource);
|
||||
for (AuthorityEntity auth : authors) {
|
||||
auth.extendName("" + role.getId());
|
||||
auth.Insert(dataSource);
|
||||
}
|
||||
userAuthorManager.NotifyUpdateRoleAuthority(role);
|
||||
}catch (Exception e){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
public List<AuthorityEntity> queryAllAuthoriy( ){
|
||||
|
||||
List<AuthorityEntity> authlist = new ArrayList<AuthorityEntity>();
|
||||
InputStream stream = null;
|
||||
try {
|
||||
// Resource resource = new ClassPathResource("static\\dbinfodefine.xml");
|
||||
// File file = resource.getFile();
|
||||
stream = getClass().getClassLoader().getResourceAsStream("static/resinfodefine.xml");
|
||||
File targetFile = new File("resinfodefine.xml");
|
||||
//FileUtils.copyInputStreamToFile(stream, targetFile);
|
||||
|
||||
// BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(targetFile)));
|
||||
|
||||
SAXReader reader = new SAXReader();
|
||||
Document document = reader.read(new InputStreamReader(stream,"utf8"));
|
||||
Element root = document.getRootElement();
|
||||
if("resinfodefine".equals(root.getName())) {
|
||||
List<Element> list = root.elements();
|
||||
for(Element res:list){
|
||||
if(!"res".equals(res.getName()))
|
||||
continue;
|
||||
try {
|
||||
Attribute attr = res.attribute("type");
|
||||
String type = attr.getStringValue();
|
||||
attr = res.attribute("scope");
|
||||
if (attr != null) {
|
||||
String useflag = attr.getStringValue();
|
||||
if (useflag != null && !useflag.equals("optional"))
|
||||
continue;
|
||||
}
|
||||
attr = res.attribute("descript");
|
||||
String discript = attr.getStringValue();
|
||||
attr = res.attribute("path");
|
||||
String path = attr.getStringValue();
|
||||
if (type == null || type.length() <= 0 || path == null || path.length() <= 0)
|
||||
continue;
|
||||
AuthorityEntity auth = new AuthorityEntity();
|
||||
auth.setDiscript(discript);
|
||||
auth.setPath(path);
|
||||
auth.setType(type);
|
||||
authlist.add(auth);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
if (stream != null)
|
||||
stream.close();
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
return authlist;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<UserInfoEntity> queryUserList(OrganiztionUri orguri) {
|
||||
ArrayList<UserInfoEntity> rel = new ArrayList<UserInfoEntity>();
|
||||
UserInfoEntity u = new UserInfoEntity();
|
||||
List<SQLDataObject> users = u.queryList(dataSource,null,null);
|
||||
for(SQLDataObject ob:users){
|
||||
UserInfoEntity user = (UserInfoEntity)ob;
|
||||
user.setPassword(null);
|
||||
if(user.getLevelvalue() != null){
|
||||
if(user.getLevelvalue().equals("master")){
|
||||
rel.add(user);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
OrganiztionUri userorg = new OrganiztionUri();
|
||||
|
||||
if(user.getScopelevel().equals("brigade")){
|
||||
userorg.setBrigade(user.getLevelvalue());
|
||||
}else if(user.getScopelevel().equals("borough")){
|
||||
userorg.setBorough(user.getLevelvalue());
|
||||
BoroughEntity b = new BoroughEntity();
|
||||
b.setBorough(user.getLevelvalue());
|
||||
b = (BoroughEntity)b.QueryIt(dataSource);
|
||||
if(b!=null)
|
||||
userorg.setBrigade(b.getBrigade());
|
||||
|
||||
}else if(user.getScopelevel().equals("detachment")){
|
||||
userorg.setDetachment(user.getLevelvalue());
|
||||
|
||||
DetachmentEntity d = new DetachmentEntity();
|
||||
d.setDetachment(user.getLevelvalue());
|
||||
d = (DetachmentEntity)d.QueryIt(dataSource);
|
||||
if(d!=null){
|
||||
userorg.setBorough(d.getBorough());
|
||||
userorg.setBrigade(d.getBrigade());
|
||||
|
||||
}
|
||||
}
|
||||
else if(user.getScopelevel().equals("station")){
|
||||
userorg.setStation(user.getLevelvalue());
|
||||
FireStationBaseInfoEntity s = new FireStationBaseInfoEntity();
|
||||
s.setName(user.getLevelvalue());
|
||||
s = (FireStationBaseInfoEntity)s.QueryIt(dataSource);
|
||||
if(s!=null){
|
||||
userorg.setBorough(s.getBorough());
|
||||
userorg.setBrigade(s.getBrigade());
|
||||
userorg.setDetachment(s.getDetachment());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(orguri.brigade!=null&&!orguri.brigade.equals(userorg.getBrigade()))
|
||||
continue;
|
||||
|
||||
if(orguri.borough!=null&&!orguri.borough.equals(userorg.getBorough()))
|
||||
continue;
|
||||
|
||||
if(orguri.detachment!=null&&!orguri.detachment.equals(userorg.getDetachment()))
|
||||
continue;
|
||||
|
||||
if(orguri.station!=null&&!orguri.station.equals(userorg.getStation()))
|
||||
continue;
|
||||
|
||||
rel.add(user);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
import com.jingyi.iotserver.utils.*;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
public class AuthorityEntity extends SQLDataObject {
|
||||
@JPos(index=1,primary = true,filter = true,orderkey = true)
|
||||
private String path;
|
||||
@JPos(index=2,filter = true)
|
||||
private String type;
|
||||
@JPos(index=3)
|
||||
private String discript;
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setDiscript(String discript) {
|
||||
this.discript = discript;
|
||||
}
|
||||
|
||||
public String getDiscript() {
|
||||
return discript;
|
||||
}
|
||||
|
||||
public String tableName(){
|
||||
return "firectrl_role_"+tableExtName+"_authority_table";
|
||||
}
|
||||
|
||||
public boolean dropTableSql(DataSource dataSource){
|
||||
String sql = "DROP TABLE ";
|
||||
sql += tableName();
|
||||
try{
|
||||
if(SQLTools.ExecuteSQL(dataSource, sql))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean DeleteAll(DataSource dataSource){
|
||||
String sql = "DELETE FROM "+tableName();
|
||||
try{
|
||||
SQLTools.ExecuteSQL(dataSource, sql);
|
||||
return true;
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
import com.jingyi.iotserver.utils.*;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
public class BoroughEntity extends SQLDataObject{
|
||||
@JPos(index=0,primary = true,filter = true,orderkey = true)
|
||||
private String borough;
|
||||
@JPos(index=1,primary = true,filter = true)
|
||||
private String brigade;
|
||||
@JPos(index=2)
|
||||
private String address;
|
||||
@JPos(index=3)
|
||||
private double longitude;
|
||||
@JPos(index=4)
|
||||
private double latitude;
|
||||
@JPos(index=5,filter = true)
|
||||
private String level;
|
||||
@JPos(index=6,filter = true)
|
||||
private String legal_person;
|
||||
@JPos(index=7,filter = true)
|
||||
private String phone;
|
||||
@JPos(index=8,strlen = 512)
|
||||
private String remark;
|
||||
|
||||
public void setBorough(String borough) {
|
||||
this.borough = borough;
|
||||
}
|
||||
|
||||
public String getBorough() {
|
||||
return borough;
|
||||
}
|
||||
|
||||
public void setBrigade(String brigade) {
|
||||
this.brigade = brigade;
|
||||
}
|
||||
|
||||
public String getBrigade() {
|
||||
return brigade;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLegal_person(String legal_person) {
|
||||
this.legal_person = legal_person;
|
||||
}
|
||||
|
||||
public String getLegal_person() {
|
||||
return legal_person;
|
||||
}
|
||||
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public String tableName( ){
|
||||
return "iotserver_borough_list_table";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.ACBEventEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.todev.AssignmentEntity;
|
||||
import com.jingyi.iotserver.utils.*;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
public class BrigadeEntity extends SQLDataObject{
|
||||
@JPos(index=0,primary = true,filter = true,orderkey = true)
|
||||
private String brigade;
|
||||
@JPos(index=1)
|
||||
private String address;
|
||||
@JPos(index=2)
|
||||
private double longitude;
|
||||
@JPos(index=3)
|
||||
private double latitude;
|
||||
@JPos(index=4,filter = true)
|
||||
private String level;
|
||||
@JPos(index=5,filter = true)
|
||||
private String legal_person;
|
||||
@JPos(index=6,filter = true)
|
||||
private String phone;
|
||||
@JPos(index=7,strlen = 512)
|
||||
private String remark;
|
||||
|
||||
public void setBrigade(String brigade) {
|
||||
this.brigade = brigade;
|
||||
}
|
||||
|
||||
public String getBrigade() {
|
||||
return brigade;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLegal_person(String legal_person) {
|
||||
this.legal_person = legal_person;
|
||||
}
|
||||
|
||||
public String getLegal_person() {
|
||||
return legal_person;
|
||||
}
|
||||
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public String tableName(){
|
||||
return "iotserver_brigade_list_table";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
import com.jingyi.iotserver.utils.*;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
public class DetachmentEntity extends SQLDataObject {
|
||||
@JPos(index=0,primary = true,filter = true,orderkey = true)
|
||||
private String detachment;
|
||||
@JPos(index=1,primary = true,filter = true)
|
||||
private String borough;
|
||||
@JPos(index=2,primary = true,filter = true)
|
||||
private String brigade;
|
||||
@JPos(index=3)
|
||||
private String address;
|
||||
@JPos(index=4)
|
||||
private double longitude;
|
||||
@JPos(index=5)
|
||||
private double latitude;
|
||||
@JPos(index=6,filter = true)
|
||||
private String level;
|
||||
@JPos(index=7,filter = true)
|
||||
private String legal_person;
|
||||
@JPos(index=8,filter = true)
|
||||
private String phone;
|
||||
@JPos(index=9,strlen = 512)
|
||||
private String remark;
|
||||
|
||||
public void setDetachment(String detachment) {
|
||||
this.detachment = detachment;
|
||||
}
|
||||
|
||||
public String getDetachment() {
|
||||
return detachment;
|
||||
}
|
||||
|
||||
public void setBorough(String borough) {
|
||||
this.borough = borough;
|
||||
}
|
||||
|
||||
public String getBorough() {
|
||||
return borough;
|
||||
}
|
||||
|
||||
public void setBrigade(String brigade) {
|
||||
this.brigade = brigade;
|
||||
}
|
||||
|
||||
public String getBrigade() {
|
||||
return brigade;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLegal_person(String legal_person) {
|
||||
this.legal_person = legal_person;
|
||||
}
|
||||
|
||||
public String getLegal_person() {
|
||||
return legal_person;
|
||||
}
|
||||
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public String tableName( ){
|
||||
return "iotserver_detachment_list_table";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
public class InfoChange {
|
||||
private Object oldinfo;
|
||||
private Object newinfo;
|
||||
|
||||
public void setOldinfo(Object oldinfo) {
|
||||
this.oldinfo = oldinfo;
|
||||
}
|
||||
|
||||
public Object getOldinfo() {
|
||||
return oldinfo;
|
||||
}
|
||||
|
||||
public void setNewinfo(Object newinfo) {
|
||||
this.newinfo = newinfo;
|
||||
}
|
||||
|
||||
public Object getNewinfo() {
|
||||
return newinfo;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
public class LoginResultEntity {
|
||||
private OrganizationInfoEntity organize;
|
||||
private String session;
|
||||
private String usertype;
|
||||
private String scopelevel;
|
||||
private String levelvalue;
|
||||
private double longitude;
|
||||
private double latitude;
|
||||
private String phone;
|
||||
private String theme;
|
||||
private String orgname;
|
||||
private String hidden;
|
||||
public void setOrganize(OrganizationInfoEntity organize) {
|
||||
this.organize = organize;
|
||||
}
|
||||
|
||||
public OrganizationInfoEntity getOrganize() {
|
||||
return organize;
|
||||
}
|
||||
|
||||
public void setSession(String session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
public String getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
public void setUsertype(String usertype) {
|
||||
this.usertype = usertype;
|
||||
}
|
||||
|
||||
public String getUsertype() {
|
||||
return usertype;
|
||||
}
|
||||
|
||||
public void setScopelevel(String scopelevel) {
|
||||
this.scopelevel = scopelevel;
|
||||
}
|
||||
|
||||
public String getScopelevel() {
|
||||
return scopelevel;
|
||||
}
|
||||
|
||||
public void setLevelvalue(String levelvalue) {
|
||||
this.levelvalue = levelvalue;
|
||||
}
|
||||
|
||||
public String getLevelvalue() {
|
||||
return levelvalue;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setTheme(String theme) {
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public String getTheme() {
|
||||
return theme;
|
||||
}
|
||||
|
||||
public String getOrgname() {
|
||||
return orgname;
|
||||
}
|
||||
|
||||
public void setOrgname(String orgname) {
|
||||
this.orgname = orgname;
|
||||
}
|
||||
|
||||
public String getHidden() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(String hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireMediaInfoEntity;
|
||||
import com.jingyi.iotserver.utils.*;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class OperatingRecordEntity extends SQLDataObject {
|
||||
@JPos(index=0,primary = true,filter = true)
|
||||
private String username;
|
||||
@JPos(index=1,filter = true)
|
||||
private String operate;
|
||||
@JPos(index=2,filter = true)
|
||||
private String objective;
|
||||
@JPos(index=3,primary = true,timekey = true,orderkey = true)
|
||||
private Date timestamp;
|
||||
@JPos(index=4,strlen = 512)
|
||||
private String content;
|
||||
@JPos(index=5,strlen = 4096)
|
||||
private String detail;
|
||||
@JPos(index=7)
|
||||
private int result;
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setOperate(String operate) {
|
||||
this.operate = operate;
|
||||
}
|
||||
|
||||
public String getOperate() {
|
||||
return operate;
|
||||
}
|
||||
|
||||
public void setObjective(String objective) {
|
||||
this.objective = objective;
|
||||
}
|
||||
|
||||
public String getObjective() {
|
||||
return objective;
|
||||
}
|
||||
|
||||
public void setTimestamp(Date timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public Date getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setDetail(String detail) {
|
||||
this.detail = detail;
|
||||
}
|
||||
|
||||
public String getDetail() {
|
||||
return detail;
|
||||
}
|
||||
|
||||
public void setResult(int result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public int getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public String tableName(){
|
||||
return "iotserver_operate_record_table";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
import com.jingyi.iotserver.utils.*;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
public class OrganizationInfoEntity extends SQLDataObject {
|
||||
@JPos(index=0,primary = true,filter = true,orderkey = true)
|
||||
private String orgname;
|
||||
@JPos(index=1,filter = true)
|
||||
private String brigade;
|
||||
@JPos(index=2,filter = true)
|
||||
private String borough;
|
||||
@JPos(index=3,filter = true)
|
||||
private String detachment;
|
||||
@JPos(index=4)
|
||||
private double longitude;
|
||||
@JPos(index=5)
|
||||
private double latitude;
|
||||
@JPos(index=6,filter = true)
|
||||
private String city;
|
||||
@JPos(index=7)
|
||||
private String address;
|
||||
@JPos(index=8)
|
||||
private String theme;
|
||||
@JPos(index=9)
|
||||
private String logo;
|
||||
|
||||
public void setOrgname(String orgname) {
|
||||
this.orgname = orgname;
|
||||
}
|
||||
|
||||
public String getOrgname() {
|
||||
return orgname;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setBrigade(String brigade) {
|
||||
this.brigade = brigade;
|
||||
}
|
||||
|
||||
public String getBrigade() {
|
||||
return brigade;
|
||||
}
|
||||
|
||||
public void setDetachment(String detachment) {
|
||||
this.detachment = detachment;
|
||||
}
|
||||
|
||||
public String getDetachment() {
|
||||
return detachment;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setBorough(String borough) {
|
||||
this.borough = borough;
|
||||
}
|
||||
|
||||
public String getBorough() {
|
||||
return borough;
|
||||
}
|
||||
|
||||
public String tableName(){
|
||||
return "firectrl_organization_info_table";
|
||||
}
|
||||
|
||||
public static OrganizationInfoEntity Query(DataSource dataSource,String name){
|
||||
OrganizationInfoEntity org = new OrganizationInfoEntity();
|
||||
org.setOrgname(name);
|
||||
return (OrganizationInfoEntity)org.QueryIt(dataSource);
|
||||
}
|
||||
|
||||
public String getTheme() {
|
||||
return theme;
|
||||
}
|
||||
|
||||
public void setTheme(String theme) {
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public String getLogo() {
|
||||
return logo;
|
||||
}
|
||||
|
||||
public void setLogo(String logo) {
|
||||
this.logo = logo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
public class OrganiztionUri {
|
||||
public String brigade;
|
||||
public String borough;
|
||||
public String detachment;
|
||||
public String station;
|
||||
|
||||
public void setBrigade(String brigade) {
|
||||
this.brigade = brigade;
|
||||
}
|
||||
|
||||
public String getBrigade() {
|
||||
return brigade;
|
||||
}
|
||||
|
||||
public void setBorough(String borough) {
|
||||
this.borough = borough;
|
||||
}
|
||||
|
||||
public String getBorough() {
|
||||
return borough;
|
||||
}
|
||||
|
||||
public void setDetachment(String detachment) {
|
||||
this.detachment = detachment;
|
||||
}
|
||||
|
||||
public String getDetachment() {
|
||||
return detachment;
|
||||
}
|
||||
|
||||
public void setStation(String station) {
|
||||
this.station = station;
|
||||
}
|
||||
|
||||
public String getStation() {
|
||||
return station;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
public class PropertyChange {
|
||||
private Object owner;
|
||||
private Object oldpro;
|
||||
private Object newpro;
|
||||
|
||||
public void setOwner(Object owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Object getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOldpro(Object oldpro) {
|
||||
this.oldpro = oldpro;
|
||||
}
|
||||
|
||||
public Object getOldpro() {
|
||||
return oldpro;
|
||||
}
|
||||
|
||||
public void setNewpro(Object newpro) {
|
||||
this.newpro = newpro;
|
||||
}
|
||||
|
||||
public Object getNewpro() {
|
||||
return newpro;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
import com.jingyi.iotserver.utils.*;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class RoleEntity extends SQLDataObject {
|
||||
@JPos(index=0,identify = true,orderkey = true)
|
||||
private int id;
|
||||
@JPos(index=1,primary = true,filter = true)
|
||||
private String rolename;
|
||||
private HashMap<String, AuthorityEntity> authorlist;
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setRolename(String rolename) {
|
||||
this.rolename = rolename;
|
||||
}
|
||||
|
||||
public String getRolename() {
|
||||
return rolename;
|
||||
}
|
||||
|
||||
public void setAuthorlist(HashMap<String, AuthorityEntity> authorlist) {
|
||||
this.authorlist = authorlist;
|
||||
}
|
||||
|
||||
public HashMap<String, AuthorityEntity> getAuthorlist() {
|
||||
return authorlist;
|
||||
}
|
||||
|
||||
public void addAuthor(AuthorityEntity auth){
|
||||
if(authorlist==null)
|
||||
authorlist = new HashMap<String,AuthorityEntity>();
|
||||
authorlist.put(auth.getPath(),auth);
|
||||
}
|
||||
|
||||
public boolean hasAuthor(String path){
|
||||
if(authorlist==null)
|
||||
return false;
|
||||
if(authorlist.get(path)!=null)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public String tableName( ){
|
||||
return "firectrl_user_role_table";
|
||||
}
|
||||
|
||||
public static RoleEntity Query(DataSource dataSource,String role){
|
||||
RoleEntity r = new RoleEntity();
|
||||
r.setRolename(role);
|
||||
return (RoleEntity)r.QueryIt(dataSource);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
import com.jingyi.iotserver.utils.*;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class ThirdPlatformInfoEntity extends SQLDataObject {
|
||||
@JPos(index=0,identify = true,orderkey = true)
|
||||
private int id;
|
||||
@JPos(index=1,filter = true)
|
||||
private String platform;
|
||||
@JPos(index=2,filter = true)
|
||||
private String company;
|
||||
@JPos(index=3,primary = true,filter = true)
|
||||
private String appkey;
|
||||
@JPos(index=4,timekey = true)
|
||||
private Date createtime;
|
||||
|
||||
@JPos(index=5,filter = true)
|
||||
public String brigade;
|
||||
@JPos(index=6,filter = true)
|
||||
public String borough;
|
||||
@JPos(index=7,filter = true)
|
||||
public String detachment;
|
||||
@JPos(index=8,filter = true)
|
||||
public String station;
|
||||
|
||||
@JPos(index=9,filter = true,strlen = 1024)
|
||||
private String msgurl;
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setPlatform(String platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
public void setCompany(String company) {
|
||||
this.company = company;
|
||||
}
|
||||
|
||||
public String getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
public void setAppkey(String appkey) {
|
||||
this.appkey = appkey;
|
||||
}
|
||||
|
||||
public String getAppkey() {
|
||||
return appkey;
|
||||
}
|
||||
|
||||
public void setCreatetime(Date createtime) {
|
||||
this.createtime = createtime;
|
||||
}
|
||||
|
||||
public Date getCreatetime() {
|
||||
return createtime;
|
||||
}
|
||||
|
||||
public String getMsgurl() {
|
||||
return msgurl;
|
||||
}
|
||||
|
||||
public void setMsgurl(String msgurl) {
|
||||
this.msgurl = msgurl;
|
||||
}
|
||||
|
||||
public void setBrigade(String brigade) {
|
||||
this.brigade = brigade;
|
||||
}
|
||||
|
||||
public String getBrigade() {
|
||||
return brigade;
|
||||
}
|
||||
|
||||
public void setBorough(String borough) {
|
||||
this.borough = borough;
|
||||
}
|
||||
|
||||
public String getBorough() {
|
||||
return borough;
|
||||
}
|
||||
|
||||
public void setDetachment(String detachment) {
|
||||
this.detachment = detachment;
|
||||
}
|
||||
|
||||
public String getDetachment() {
|
||||
return detachment;
|
||||
}
|
||||
|
||||
public void setStation(String station) {
|
||||
this.station = station;
|
||||
}
|
||||
|
||||
public String getStation() {
|
||||
return station;
|
||||
}
|
||||
|
||||
public String tableName(){
|
||||
return "firectrl_third_platform_info_table";
|
||||
}
|
||||
|
||||
public static ThirdPlatformInfoEntity Query(DataSource dataSource,String appkey){
|
||||
ThirdPlatformInfoEntity r = new ThirdPlatformInfoEntity();
|
||||
r.setAppkey(appkey);
|
||||
return (ThirdPlatformInfoEntity)r.QueryIt(dataSource);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
import com.jingyi.iotserver.utils.JPos;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
|
||||
public class UserAuthorDesEntity extends SQLDataObject {
|
||||
@JPos(index=0,primary = true,filter = true,orderkey = true)
|
||||
private String name;
|
||||
@JPos(index=1,strlen=4096)
|
||||
private String authordes;
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setAuthordes(String authordes) {
|
||||
this.authordes = authordes;
|
||||
}
|
||||
|
||||
public String getAuthordes() {
|
||||
return authordes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tableName() {
|
||||
return "firectrl_user_authordes_table";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
public class UserHelper {
|
||||
private UserInfoEntity userinfo;
|
||||
public UserHelper(UserInfoEntity userinfo){
|
||||
this.userinfo = userinfo;
|
||||
}
|
||||
|
||||
public UserHelper(){
|
||||
userinfo = null;
|
||||
}
|
||||
|
||||
public void setUserinfo(UserInfoEntity userinfo){
|
||||
this.userinfo = userinfo;
|
||||
}
|
||||
|
||||
boolean isAdministrator(){
|
||||
if(userinfo==null)
|
||||
return false;
|
||||
try {
|
||||
if (userinfo.getName().toLowerCase().equals("administrator")) {
|
||||
return true;
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
import com.jingyi.iotserver.utils.*;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
public class UserInfoEntity extends SQLDataObject {
|
||||
@JPos(index=0,primary = true,filter = true,orderkey = true)
|
||||
private String name;
|
||||
@JPos(index=1)
|
||||
private String password;
|
||||
@JPos(index=2)
|
||||
private String authority;
|
||||
@JPos(index=3,filter = true)
|
||||
private String orgname;
|
||||
@JPos(index=4,filter = true)
|
||||
private String usertype;
|
||||
@JPos(index=5,filter = true)
|
||||
private String userrole;
|
||||
|
||||
@JPos(index=6,filter = true)
|
||||
private String scopelevel;//master brigade borough detachment station
|
||||
@JPos(index=7,filter = true)
|
||||
private String levelvalue;
|
||||
@JPos(index=8,filter = true)
|
||||
private String phone;
|
||||
@JPos(index=9,filter = true)
|
||||
private String theme;
|
||||
@JPos(index=10)
|
||||
private double longitude;
|
||||
@JPos(index=11)
|
||||
private double latitude;
|
||||
@JPos(index=12)
|
||||
private String hidden;
|
||||
|
||||
public boolean IsSuper(){
|
||||
if(name!=null&&name.toLowerCase().equals("administrator")){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean IsAdmin(){
|
||||
if(usertype!=null&&usertype.equals("admin"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setAuthority(String authority) {
|
||||
this.authority = authority;
|
||||
}
|
||||
|
||||
public String getAuthority() {
|
||||
return authority;
|
||||
}
|
||||
|
||||
public void setOrgname(String orgname) {
|
||||
this.orgname = orgname;
|
||||
}
|
||||
|
||||
public String getOrgname() {
|
||||
return orgname;
|
||||
}
|
||||
|
||||
public void setUsertype(String usertype) {
|
||||
this.usertype = usertype;
|
||||
}
|
||||
|
||||
public String getUsertype() {
|
||||
return usertype;
|
||||
}
|
||||
|
||||
public void setUserrole(String userrole){
|
||||
this.userrole = userrole;
|
||||
}
|
||||
|
||||
public String getUserrole() {
|
||||
return userrole;
|
||||
}
|
||||
|
||||
public void setScopelevel(String scopelevel) {
|
||||
this.scopelevel = scopelevel;
|
||||
}
|
||||
|
||||
public String getScopelevel() {
|
||||
return scopelevel;
|
||||
}
|
||||
|
||||
public void setLevelvalue(String levelvalue) {
|
||||
this.levelvalue = levelvalue;
|
||||
}
|
||||
|
||||
public String getLevelvalue() {
|
||||
return levelvalue;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void addRole(String role){
|
||||
if(role==null||role.length()<=0)
|
||||
return ;
|
||||
if(userrole==null||userrole.length()<=0)
|
||||
userrole = role;
|
||||
else {
|
||||
userrole += "#";
|
||||
userrole += role;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setTheme(String theme) {
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public String getTheme() {
|
||||
return theme;
|
||||
}
|
||||
|
||||
public String tableName(){
|
||||
return "firectrl_user_info_table";
|
||||
}
|
||||
|
||||
public static UserInfoEntity QueryUser(DataSource dataSource,String name){
|
||||
UserInfoEntity user = new UserInfoEntity();
|
||||
user.setName(name);
|
||||
return (UserInfoEntity)user.QueryIt(dataSource);
|
||||
}
|
||||
|
||||
public String getHidden() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(String hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.jingyi.iotserver.clientmanage.model;
|
||||
|
||||
public class UserLoginRecord {
|
||||
public String username;
|
||||
public long lastLoginTime;
|
||||
public int loginCount;
|
||||
}
|
|
@ -0,0 +1,176 @@
|
|||
package com.jingyi.iotserver.common.configuration;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.support.http.StatViewServlet;
|
||||
import com.alibaba.druid.support.http.WebStatFilter;
|
||||
import com.alibaba.druid.support.spring.stat.DruidStatInterceptor;
|
||||
import org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Druid的DataResource配置类
|
||||
* 凡是被Spring管理的类,实现接口 EnvironmentAware 重写方法 setEnvironment 可以在工程启动时,
|
||||
* 获取到系统环境变量和application配置文件中的变量。 还有一种方式是采用注解的方式获取 @value("${变量的key值}")
|
||||
* 获取application配置文件中的变量。 这里采用第一种要方便些
|
||||
* Created by sun on 2017-1-20.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
public class DruidDataSourceConfig implements EnvironmentAware {
|
||||
// private RelaxedPropertyResolver propertyResolver;
|
||||
private Environment gEnv;
|
||||
private DruidDataSource gSqlServerData = null;
|
||||
private DruidDataSource gMySqlData = null;
|
||||
|
||||
private DruidDataSource gMDevData = null;
|
||||
public void setEnvironment(Environment env) {
|
||||
gEnv = env;
|
||||
// gEnv.acceptsProfiles();
|
||||
// this.propertyResolver = new RelaxedPropertyResolver(env, "spring.datasource.");
|
||||
}
|
||||
|
||||
public Environment getEnviroment(){
|
||||
return gEnv;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
DruidDataSource datasource = new DruidDataSource();
|
||||
|
||||
datasource.setUrl(gEnv.getProperty("spring.datasource.url"));
|
||||
datasource.setDriverClassName(gEnv.getProperty("spring.datasource.driver-class-name"));
|
||||
datasource.setUsername(gEnv.getProperty("spring.datasource.username"));
|
||||
datasource.setPassword(gEnv.getProperty("spring.datasource.password"));
|
||||
datasource.setInitialSize(Integer.valueOf(gEnv.getProperty("spring.datasource.initialSize")));
|
||||
datasource.setMinIdle(Integer.valueOf(gEnv.getProperty("spring.datasource.minIdle")));
|
||||
datasource.setMaxWait(Long.valueOf(gEnv.getProperty("spring.datasource.maxWait")));
|
||||
datasource.setMaxActive(Integer.valueOf(gEnv.getProperty("spring.datasource.maxActive")));
|
||||
datasource.setMinEvictableIdleTimeMillis(
|
||||
Long.valueOf(gEnv.getProperty("spring.datasource.minEvictableIdleTimeMillis")));
|
||||
try {
|
||||
datasource.setFilters("stat,wall");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return datasource;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServletRegistrationBean druidServlet() {
|
||||
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
|
||||
servletRegistrationBean.setServlet(new StatViewServlet());
|
||||
servletRegistrationBean.addUrlMappings("/druid/*");
|
||||
Map<String, String> initParameters = new HashMap<String, String>();
|
||||
// initParameters.put("loginUsername", "druid");// 用户名
|
||||
// initParameters.put("loginPassword", "druid");// 密码
|
||||
initParameters.put("resetEnable", "false");// 禁用HTML页面上的“Reset All”功能
|
||||
initParameters.put("allow", "127.0.0.1"); // IP白名单 (没有配置或者为空,则允许所有访问)
|
||||
// initParameters.put("deny", "192.168.20.38");// IP黑名单
|
||||
// (存在共同时,deny优先于allow)
|
||||
servletRegistrationBean.setInitParameters(initParameters);
|
||||
return servletRegistrationBean;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean filterRegistrationBean() {
|
||||
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
|
||||
filterRegistrationBean.setFilter(new WebStatFilter());
|
||||
filterRegistrationBean.addUrlPatterns("/*");
|
||||
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*");
|
||||
return filterRegistrationBean;
|
||||
}
|
||||
|
||||
// 按照BeanId来拦截配置 用来bean的监控
|
||||
@Bean(value = "druid-stat-interceptor")
|
||||
public DruidStatInterceptor DruidStatInterceptor() {
|
||||
DruidStatInterceptor druidStatInterceptor = new DruidStatInterceptor();
|
||||
return druidStatInterceptor;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BeanNameAutoProxyCreator beanNameAutoProxyCreator() {
|
||||
BeanNameAutoProxyCreator beanNameAutoProxyCreator = new BeanNameAutoProxyCreator();
|
||||
beanNameAutoProxyCreator.setProxyTargetClass(true);
|
||||
// 设置要监控的bean的id
|
||||
//beanNameAutoProxyCreator.setBeanNames("sysRoleMapper","loginController");
|
||||
beanNameAutoProxyCreator.setInterceptorNames("druid-stat-interceptor");
|
||||
return beanNameAutoProxyCreator;
|
||||
}
|
||||
|
||||
public DataSource getSqlServerDataSource() {
|
||||
if (gSqlServerData == null) {
|
||||
gSqlServerData = new DruidDataSource();
|
||||
|
||||
gSqlServerData.setUrl("jdbc:sqlserver://localhost:1433;database=firectrl_station;characterEncoding=UTF-8");
|
||||
gSqlServerData.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
|
||||
gSqlServerData.setUsername("sa");
|
||||
gSqlServerData.setPassword("?><M0okm");
|
||||
gSqlServerData.setInitialSize(5);
|
||||
gSqlServerData.setMinIdle(5);
|
||||
gSqlServerData.setMaxWait(60000);
|
||||
gSqlServerData.setMaxActive(20);
|
||||
gSqlServerData.setMinEvictableIdleTimeMillis(300000);
|
||||
try {
|
||||
gSqlServerData.setFilters("stat,wall");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return gSqlServerData;
|
||||
}
|
||||
|
||||
public DataSource getMySqlDataSource() {
|
||||
if (gMySqlData == null) {
|
||||
gMySqlData = new DruidDataSource();
|
||||
|
||||
gMySqlData.setUrl("jdbc:mysql://localhost:3316/firectrl_station?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai");
|
||||
gMySqlData.setDriverClassName("com.mysql.cj.jdbc.Driver");
|
||||
gMySqlData.setUsername("sa");
|
||||
gMySqlData.setPassword("?><M0okm");
|
||||
gMySqlData.setInitialSize(5);
|
||||
gMySqlData.setMinIdle(5);
|
||||
gMySqlData.setMaxWait(60000);
|
||||
gMySqlData.setMaxActive(20);
|
||||
gMySqlData.setMinEvictableIdleTimeMillis(300000);
|
||||
try {
|
||||
gMySqlData.setFilters("stat,wall");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return gMySqlData;
|
||||
}
|
||||
|
||||
public DataSource getMDevDataSource() {
|
||||
if (gMDevData == null) {
|
||||
gMDevData = new DruidDataSource();
|
||||
|
||||
gMDevData.setUrl("jdbc:mysql://localhost:3316/mdevsys?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai");
|
||||
gMDevData.setDriverClassName("com.mysql.cj.jdbc.Driver");
|
||||
gMDevData.setUsername("sa");
|
||||
gMDevData.setPassword("?><M0okm");
|
||||
gMDevData.setInitialSize(5);
|
||||
gMDevData.setMinIdle(5);
|
||||
gMDevData.setMaxWait(60000);
|
||||
gMDevData.setMaxActive(20);
|
||||
gMDevData.setMinEvictableIdleTimeMillis(300000);
|
||||
try {
|
||||
gMDevData.setFilters("stat,wall");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return gMDevData;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.jingyi.iotserver.common.configuration;
|
||||
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import okhttp3.ConnectionPool;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class OkHttpConfig {
|
||||
@Bean
|
||||
public X509TrustManager x509TrustManager() {
|
||||
return new X509TrustManager() {
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
||||
}
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
||||
}
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[0];
|
||||
}
|
||||
};
|
||||
}
|
||||
@Bean
|
||||
public SSLSocketFactory sslSocketFactory() {
|
||||
try {
|
||||
//信任任何链接
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, new TrustManager[]{x509TrustManager()}, new SecureRandom());
|
||||
return sslContext.getSocketFactory();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (KeyManagementException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Create a new connection pool with tuning parameters appropriate for a single-user application.
|
||||
* The tuning parameters in this pool are subject to change in future OkHttp releases. Currently
|
||||
*/
|
||||
@Bean
|
||||
public ConnectionPool pool() {
|
||||
return new ConnectionPool(200, 5, TimeUnit.MINUTES);
|
||||
}
|
||||
@Bean
|
||||
public OkHttpClient okHttpClient() {
|
||||
return new OkHttpClient.Builder()
|
||||
.sslSocketFactory(sslSocketFactory(), x509TrustManager())
|
||||
.retryOnConnectionFailure(false)//是否开启缓存
|
||||
.connectionPool(pool())//连接池
|
||||
.connectTimeout(60L, TimeUnit.SECONDS)
|
||||
.readTimeout(60L, TimeUnit.SECONDS)
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package com.jingyi.iotserver.common.configuration;
|
||||
|
||||
|
||||
import com.jingyi.iotserver.firestationport.shiro.ClientUserNameShiroRealm;
|
||||
import org.apache.shiro.cache.ehcache.EhCacheManager;
|
||||
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
|
||||
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
|
||||
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
||||
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
|
||||
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.filter.DelegatingFilterProxy;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
//@Configuration
|
||||
public class ShiroConfig {
|
||||
|
||||
@Bean
|
||||
public LifecycleBeanPostProcessor lifecycleBeanPostProcessor(){
|
||||
return new LifecycleBeanPostProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(){
|
||||
AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
|
||||
authorizationAttributeSourceAdvisor.setSecurityManager(defaultWebSecurityManager());
|
||||
return authorizationAttributeSourceAdvisor;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator(){
|
||||
DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
|
||||
defaultAdvisorAutoProxyCreator.setProxyTargetClass(true);
|
||||
return defaultAdvisorAutoProxyCreator;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public EhCacheManager ehCacheManager(){
|
||||
EhCacheManager ehCacheManager = new EhCacheManager();
|
||||
ehCacheManager.setCacheManagerConfigFile("classpath:config/ehcache.xml");
|
||||
return ehCacheManager;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientUserNameShiroRealm customUserNameShiroRealm(){
|
||||
ClientUserNameShiroRealm customUserNameShiroRealm = new ClientUserNameShiroRealm();
|
||||
customUserNameShiroRealm.setCacheManager(ehCacheManager());
|
||||
return customUserNameShiroRealm;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DefaultWebSecurityManager defaultWebSecurityManager(){
|
||||
DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
|
||||
defaultWebSecurityManager.setCacheManager(ehCacheManager());
|
||||
defaultWebSecurityManager.setRealm(customUserNameShiroRealm());
|
||||
// defaultWebSecurityManager.setAuthenticator(modularRealmAuthenticator());
|
||||
// defaultWebSecurityManager.setAuthorizer(modularRealmAuthorizer());
|
||||
return defaultWebSecurityManager;
|
||||
}
|
||||
|
||||
@Bean(name = "shiroFilter")
|
||||
public ShiroFilterFactoryBean shiroFilterFactoryBean(){
|
||||
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
|
||||
shiroFilterFactoryBean.setSecurityManager(defaultWebSecurityManager());
|
||||
shiroFilterFactoryBean.setLoginUrl("/firectrl/client/user/login");
|
||||
shiroFilterFactoryBean.setSuccessUrl("/admin/index");
|
||||
shiroFilterFactoryBean.setUnauthorizedUrl("/401");
|
||||
Map<String,String> filterChainDefinitionMap = new LinkedHashMap<>();
|
||||
filterChainDefinitionMap.put("/firectrl/client/user/login","anon");
|
||||
// filterChainDefinitionMap.put("/firectrl/client/getstationcount","anon");
|
||||
filterChainDefinitionMap.put("/logout","logout");
|
||||
filterChainDefinitionMap.put("/firectrl/client/*","authc");
|
||||
|
||||
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
|
||||
return shiroFilterFactoryBean;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean filterRegistrationBean(){
|
||||
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
|
||||
filterRegistrationBean.setFilter(new DelegatingFilterProxy("shiroFilter"));
|
||||
filterRegistrationBean.addInitParameter("targetFilterLifecycle","true");
|
||||
filterRegistrationBean.addUrlPatterns("/*");
|
||||
return filterRegistrationBean;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.jingyi.iotserver.common.service;
|
||||
|
||||
public class CountResult {
|
||||
private int count;
|
||||
|
||||
public CountResult(){
|
||||
|
||||
}
|
||||
|
||||
public CountResult(int c) {
|
||||
count = c;
|
||||
}
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.jingyi.iotserver.common.service;
|
||||
|
||||
import com.jingyi.iotserver.common.configuration.DruidDataSourceConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class EnvConfigService {
|
||||
@Autowired
|
||||
private DruidDataSourceConfig sourceConfig ;
|
||||
|
||||
private boolean blDataPortServer = false;
|
||||
|
||||
private String reportFilePath = null;
|
||||
public String getDataBaseName(){
|
||||
return sourceConfig.getEnviroment().getProperty("jy.database.name");
|
||||
}
|
||||
public String getSuperPassword(){return sourceConfig.getEnviroment().getProperty("jy.user.super.password");}
|
||||
|
||||
public String getDataBaseType(){return sourceConfig.getEnviroment().getProperty("spring.datasource.sqltype");}
|
||||
|
||||
public void LoadConfig(){
|
||||
String str = sourceConfig.getEnviroment().getProperty("jy.server.config.dataport");
|
||||
if(str!=null&&str.equals("true"))
|
||||
blDataPortServer = true;
|
||||
else
|
||||
blDataPortServer = false;
|
||||
|
||||
reportFilePath = sourceConfig.getEnviroment().getProperty("jy.station.report.html.path");
|
||||
|
||||
}
|
||||
|
||||
public boolean IsDataPortServer(){
|
||||
return blDataPortServer;
|
||||
}
|
||||
|
||||
public String getStationReportFilePath(){
|
||||
if(reportFilePath==null)
|
||||
return "e:\\web\\https\\fireStationEmePlan\\php\\html";
|
||||
return reportFilePath;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.jingyi.iotserver.common.service;
|
||||
|
||||
public enum RespCode {
|
||||
SUCCESS(0, "请求成功"),
|
||||
FAIL(-1,"请求失败"),
|
||||
WARN(-2, "网络异常,请稍后重试"),
|
||||
ERROR_CMD(-3,"错误的请求命令"),
|
||||
NOTEXIST(-4,"信息不存在"),
|
||||
ERROR_REQUEST(-5,"错误的请求"),
|
||||
EXCEPTION(-6,"请求异常"),
|
||||
EXIST(-7,"信息已存在"),
|
||||
DEVICE_BOUND(-8,"设备已绑定"),
|
||||
NOTEMPTY(-9,"列表不为空"),
|
||||
USER_PWD_ERROR(-10,"用户名或密码错误"),
|
||||
EMPTY(-11,"列表为空"),
|
||||
NOAUTHOR(-12,"无权限"),
|
||||
COMPLETED(-13,"已完成"),
|
||||
LOGIN_ERROR_DELAY_10MIN(-14,"请10分钟后重试登录");
|
||||
private int code;
|
||||
private String msg;
|
||||
|
||||
RespCode(int code, String msg) {
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
static public RespCode getResp(int code){
|
||||
switch(code){
|
||||
case 0:
|
||||
return SUCCESS;
|
||||
case -1:
|
||||
return FAIL;
|
||||
case -2:
|
||||
return WARN;
|
||||
case -3:
|
||||
return ERROR_CMD;
|
||||
case -4:
|
||||
return NOTEXIST;
|
||||
case -5:
|
||||
return ERROR_REQUEST;
|
||||
case -6:
|
||||
return EXCEPTION;
|
||||
case -7:
|
||||
return EXIST;
|
||||
case -8:
|
||||
return DEVICE_BOUND;
|
||||
case -9:
|
||||
return NOTEMPTY;
|
||||
case -10:
|
||||
return USER_PWD_ERROR;
|
||||
case -11:
|
||||
return EMPTY;
|
||||
case -12:
|
||||
return NOAUTHOR;
|
||||
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.jingyi.iotserver.common.service;
|
||||
|
||||
public class RespEntity {
|
||||
private int code;
|
||||
private String msg;
|
||||
private int request;
|
||||
private Object data;
|
||||
|
||||
public RespEntity(){
|
||||
|
||||
}
|
||||
|
||||
public RespEntity(RespCode respCode) {
|
||||
this.code = respCode.getCode();
|
||||
this.msg = respCode.getMsg();
|
||||
this.request = 0;
|
||||
}
|
||||
|
||||
public RespEntity(RespCode respCode, Object data) {
|
||||
this(respCode);
|
||||
this.data = data;
|
||||
this.request = 0;
|
||||
}
|
||||
|
||||
public RespEntity(RespCode respCode,int request){
|
||||
this(respCode);
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public RespEntity(RespCode respCode, Object data,int request) {
|
||||
this(respCode,data);
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public void setRequest(int request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public int getRequest() {
|
||||
return request;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
package com.jingyi.iotserver.firestationport;
|
||||
|
||||
import com.jingyi.iotserver.clientmanage.UserService;
|
||||
import com.jingyi.iotserver.common.service.EnvConfigService;
|
||||
import com.jingyi.iotserver.firestationport.model.update.SoftwareUpdateTaskEntity;
|
||||
import com.jingyi.iotserver.firestationport.services.*;
|
||||
import com.jingyi.iotserver.firestationport.services.eyeapp.SensorEventPusher;
|
||||
import com.jingyi.iotserver.firestationport.services.netease.NeteaseVideoManager;
|
||||
import com.jingyi.iotserver.firestationport.services.netease.NeteaseVideoService;
|
||||
import com.jingyi.iotserver.firestationport.services.sensor.ACBSystemAgent;
|
||||
import com.jingyi.iotserver.firestationport.services.sensor.DeShanAnService;
|
||||
import com.jingyi.iotserver.firestationport.services.sensor.SensorRunInfoManager;
|
||||
import com.jingyi.iotserver.firestationport.services.station.FireStationLiveManager;
|
||||
import com.jingyi.iotserver.clientmanage.UserAuthorManager;
|
||||
import com.jingyi.iotserver.firestationport.websocket.ClientWebsocketManager;
|
||||
import com.jingyi.iotserver.iotctrl.IoTCtrlServer;
|
||||
import com.jingyi.iotserver.mqtt.MessagePublisher;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Date;
|
||||
|
||||
@Order(value=1)
|
||||
@Component
|
||||
public class FireCtrlSystemInit implements CommandLineRunner {
|
||||
|
||||
public static final int netMode = 1; //0 内网,1外网
|
||||
@Autowired
|
||||
DatabaseDesInfoService dbinfoService;
|
||||
|
||||
@Autowired
|
||||
StationServices stationService;
|
||||
|
||||
@Autowired
|
||||
NeteaseVideoService neteaseVideoService;
|
||||
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@Autowired
|
||||
FireStationLiveManager fireStationLiveManager;
|
||||
|
||||
@Autowired
|
||||
UserAuthorManager userAuthorManager;
|
||||
|
||||
@Autowired
|
||||
ClientWebsocketManager clientWebsocketManager;
|
||||
|
||||
@Autowired
|
||||
TimingJobManager timingJobManager;
|
||||
|
||||
@Autowired
|
||||
SensorService sensorService;
|
||||
|
||||
@Autowired
|
||||
DataStatisticsService dataStatisticsService;
|
||||
|
||||
@Autowired
|
||||
NeteaseVideoManager neteaseVideoManager;
|
||||
|
||||
@Autowired
|
||||
SensorRunInfoManager sensorRunInfoManager;
|
||||
|
||||
@Autowired
|
||||
SensorEventPusher sensorEventPusher;
|
||||
|
||||
@Autowired
|
||||
EnvConfigService envConfigService;
|
||||
|
||||
@Autowired
|
||||
DatabaseTransfer databaseTransfer;
|
||||
|
||||
@Autowired
|
||||
private DeShanAnService deShanAnTCPService;
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private IoTCtrlServer ioTCtrlServer;
|
||||
|
||||
@Autowired
|
||||
private ACBSystemAgent acbSystemAgent;
|
||||
|
||||
@Autowired
|
||||
private MessagePublisher msgPublish;
|
||||
private final Logger logger = LoggerFactory.getLogger(FireCtrlSystemInit.class);
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
try{
|
||||
|
||||
logger.info("FireCtrlSystemInit ");
|
||||
envConfigService.LoadConfig();
|
||||
HttpTools.allowAllSSL();
|
||||
dbinfoService.LoadInfo();
|
||||
|
||||
userService.InitService();
|
||||
|
||||
fireStationLiveManager.Init();
|
||||
userAuthorManager.Init();
|
||||
sensorService.Init();
|
||||
|
||||
clientWebsocketManager.init();
|
||||
// timingJobManager.Init();
|
||||
|
||||
neteaseVideoManager.Init();
|
||||
|
||||
sensorRunInfoManager.Init();
|
||||
|
||||
sensorEventPusher.init();
|
||||
|
||||
databaseTransfer.Init();
|
||||
|
||||
ioTCtrlServer.startServer(6015);
|
||||
|
||||
if(netMode == 1){
|
||||
deShanAnTCPService.startServer();
|
||||
}
|
||||
|
||||
//acbSystemAgent.Init();
|
||||
|
||||
msgPublish.init();
|
||||
|
||||
dataStatisticsService.Init();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.jingyi.iotserver.firestationport;
|
||||
|
||||
import org.apache.catalina.connector.Connector;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@ComponentScan("com.jingyi.iotserver")
|
||||
@RestController
|
||||
@MapperScan("com.jingyi.iotserver")
|
||||
@EnableScheduling
|
||||
//@EnableAutoConfiguration
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||
public class FirestationportApplication {
|
||||
|
||||
@Bean
|
||||
public ServletWebServerFactory servletContainer() {
|
||||
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
|
||||
tomcat.addAdditionalTomcatConnectors(createStandardConnector());
|
||||
return tomcat;
|
||||
}
|
||||
|
||||
private Connector createStandardConnector() {
|
||||
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
|
||||
connector.setPort(8082);
|
||||
return connector;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(FirestationportApplication.class, args);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,76 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.jingyi.iotserver.firestationport.FireCtrlSystemInit;
|
||||
import com.jingyi.iotserver.firestationport.model.complexquery.RFIDResp;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.SensorDeviceEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.echarge.EChargeAlarmEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.echarge.EChargeRoomEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.event.SensorAlarmEventEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.voice.AiVoiceReport;
|
||||
import com.jingyi.iotserver.firestationport.model.station.MessageToStation;
|
||||
import com.jingyi.iotserver.firestationport.services.SensorService;
|
||||
import com.jingyi.iotserver.firestationport.websocket.ClientWebsocketManager;
|
||||
import com.jingyi.iotserver.firestationport.websocket.message.EChargeAlarmNotify;
|
||||
import com.jingyi.iotserver.firestationport.websocket.message.WebNotifyProperty;
|
||||
import com.jingyi.iotserver.iotctrl.IoTCtrlServer;
|
||||
import com.jingyi.iotserver.iotctrl.UDPAgentPackage;
|
||||
import com.jingyi.iotserver.mqtt.MessagePublisher;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class AiVoiceController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
@Autowired
|
||||
private SensorService sensorService;
|
||||
@Autowired
|
||||
private ClientWebsocketManager clientWebsocketManager;
|
||||
@Autowired
|
||||
private MessagePublisher messagePublisher;
|
||||
@Autowired
|
||||
private IoTCtrlServer ioTCtrlServer;
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/school/ai/asr/receiveEvent")
|
||||
public RFIDResp addEChargeReport(HttpServletRequest request) {
|
||||
RFIDResp res = new RFIDResp();
|
||||
res.setCode(0);
|
||||
res.setMsg("ok");
|
||||
try {
|
||||
String eventData = HttpTools.getBodyFromRequest(request);
|
||||
System.out.println("receiveEvent asr: "+ eventData);
|
||||
AiVoiceReport eChargeAlarm = JSON.parseObject(eventData, AiVoiceReport.class);
|
||||
|
||||
if(eChargeAlarm == null){
|
||||
return res;
|
||||
}
|
||||
if(eChargeAlarm.getTaskCode() == null || eChargeAlarm.getDeviceId() == null){
|
||||
return res;
|
||||
}
|
||||
// SensorDeviceEntity roomEntity = SensorDeviceEntity.Query(dataSource, eChargeAlarm.getDeviceId());
|
||||
|
||||
if(AiVoiceReport.ReportIndicate_Create.equalsIgnoreCase(eChargeAlarm.getReportIndicate())){
|
||||
SensorAlarmEventEntity alarmEvent = sensorService.addAlarmPointEvent(eChargeAlarm.getDeviceId());
|
||||
|
||||
if(FireCtrlSystemInit.netMode == 1){
|
||||
ioTCtrlServer.translateHttp2Skynet(UDPAgentPackage.TYPE_Http_Agent, JSON.toJSONString(alarmEvent), "/iotserver/sensor/alarm_event/agent");
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
res.setCode(20);
|
||||
res.setMsg("fail");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.services.SensorService;
|
||||
import com.jingyi.iotserver.firestationport.services.StationServices;
|
||||
import com.jingyi.iotserver.firestationport.websocket.ClientWebsocketManager;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class CitySensorController {
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
@Autowired
|
||||
private SensorService sensorService;
|
||||
|
||||
@Autowired
|
||||
private StationServices stationServices;
|
||||
|
||||
@Autowired
|
||||
private ClientWebsocketManager clientWebsocketManager;
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/citymgr/sensor/uav/state")
|
||||
public RespEntity addUAVStateInfo(HttpServletRequest request) {
|
||||
try {
|
||||
String json = HttpTools.getBodyFromRequest(request);
|
||||
System.out.println("UAV rec:" + json);
|
||||
|
||||
/*
|
||||
CityTruckOrderEntity info = (CityTruckOrderEntity) SQLTools.getEntityFromJson(rootnode, CityTruckOrderEntity.class);
|
||||
if(info==null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(info.getTaskid() == null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(info.QueryIt(dataSource)!=null) {
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
info.setReadstate("unread");
|
||||
info.setDeviceid("shpd12345");
|
||||
if(!info.Insert(dataSource)){
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
SensorDeviceEntity sensor = SensorDeviceEntity.Query(dataSource, info.getDeviceid());
|
||||
if (sensor == null)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
|
||||
CityTruckOrderNofity notify = new CityTruckOrderNofity(info);
|
||||
FireStationBaseInfoEntity from = FireStationBaseInfoEntity.Query(dataSource, sensor.getOwner());
|
||||
if (from != null) {
|
||||
WebNotifyProperty pro = new WebNotifyProperty();
|
||||
pro.setBrigade(from.getBrigade());
|
||||
pro.setBorough(from.getBorough());
|
||||
pro.setDetachment(from.getDetachment());
|
||||
pro.setStation(from.getName());
|
||||
pro.setDevice_id(notify.getDeviceid());
|
||||
pro.setDevice_type(sensor.getDevicetype());
|
||||
notify.attachProperty(pro);
|
||||
clientWebsocketManager.addWebNotify(notify);
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
} catch (Exception e) {
|
||||
new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,693 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.common.service.CountResult;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.FireCtrlSystemInit;
|
||||
import com.jingyi.iotserver.firestationport.model.complexquery.RFIDResp;
|
||||
import com.jingyi.iotserver.firestationport.model.person.PersonLogEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.person.SecurityPersonEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.school.PendingProcessItem;
|
||||
import com.jingyi.iotserver.firestationport.model.school.SchoolColorPoliceCheck;
|
||||
import com.jingyi.iotserver.firestationport.model.school.SchoolPendingItem;
|
||||
import com.jingyi.iotserver.firestationport.model.school.SchoolPendingProcessRecordEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.SensorDeviceEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.echarge.CommunityInfo;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.echarge.EChargeAlarmEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.echarge.EChargeBuildingEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.echarge.EChargeRoomEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationBaseInfoEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.MessageToStation;
|
||||
import com.jingyi.iotserver.firestationport.websocket.ClientWebsocketManager;
|
||||
import com.jingyi.iotserver.firestationport.websocket.message.EChargeAlarmNotify;
|
||||
import com.jingyi.iotserver.firestationport.websocket.message.WebNotifyProperty;
|
||||
import com.jingyi.iotserver.iotctrl.UDPAgentPackage;
|
||||
import com.jingyi.iotserver.mqtt.MessagePublisher;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class EChargeController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private ClientWebsocketManager clientWebsocketManager;
|
||||
@Autowired
|
||||
private MessagePublisher messagePublisher;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/houseDeviceEvent/receiveEvent")
|
||||
public RFIDResp addEChargeReport(HttpServletRequest request) {
|
||||
RFIDResp res = new RFIDResp();
|
||||
res.setCode(0);
|
||||
res.setMsg("ok");
|
||||
try {
|
||||
String eventData = HttpTools.getBodyFromRequest(request);
|
||||
|
||||
EChargeAlarmEntity eChargeAlarm = JSON.parseObject(eventData, EChargeAlarmEntity.class);
|
||||
|
||||
if(eChargeAlarm == null){
|
||||
return res;
|
||||
}
|
||||
if(eChargeAlarm.getSensorId() == null){
|
||||
return res;
|
||||
}
|
||||
|
||||
SensorDeviceEntity sensorDevice = new SensorDeviceEntity();
|
||||
sensorDevice.setDeviceid(eChargeAlarm.getSensorId());
|
||||
sensorDevice = (SensorDeviceEntity)sensorDevice.QueryIt(dataSource);
|
||||
if(sensorDevice == null){
|
||||
return res;
|
||||
}
|
||||
sensorDevice.setStatus(eChargeAlarm.getAlarm());
|
||||
sensorDevice.Update(dataSource);
|
||||
|
||||
EChargeRoomEntity roomEntity = new EChargeRoomEntity();
|
||||
roomEntity.setRoomId(sensorDevice.getHouseowner());
|
||||
roomEntity = (EChargeRoomEntity)roomEntity.QueryIt(dataSource);
|
||||
if(roomEntity==null){
|
||||
return res;
|
||||
}
|
||||
|
||||
if(EChargeAlarmEntity.ALARM_CHARGE_IN.equalsIgnoreCase(eChargeAlarm.getAlarm())){
|
||||
roomEntity.setChargeInCount(roomEntity.getChargeInCount()+1);
|
||||
roomEntity.setChargeStatus(eChargeAlarm.getAlarm());
|
||||
roomEntity.setChargeStatusTime(eChargeAlarm.getTimestamp());
|
||||
}else{
|
||||
SensorDeviceEntity sensorHouse = new SensorDeviceEntity();
|
||||
sensorHouse.setHouseowner(roomEntity.getRoomId());
|
||||
List<SQLDataObject> sensorList = sensorHouse.queryList(dataSource, null, null);
|
||||
boolean roomCharge= false;
|
||||
for(int iSen = 0; iSen < sensorList.size(); iSen++){
|
||||
SensorDeviceEntity chargeObj = (SensorDeviceEntity)sensorList.get(iSen);
|
||||
if(EChargeAlarmEntity.ALARM_CHARGE_IN.equalsIgnoreCase(chargeObj.getStatus())){
|
||||
roomCharge = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(roomCharge == false){
|
||||
roomEntity.setChargeStatus(EChargeAlarmEntity.ALARM_CHARGE_OUT);
|
||||
roomEntity.setChargeStatusTime(eChargeAlarm.getTimestamp());
|
||||
}
|
||||
}
|
||||
|
||||
roomEntity.Update(dataSource);
|
||||
|
||||
eChargeAlarm.setStation(roomEntity.getStation());
|
||||
eChargeAlarm.setDetachment(roomEntity.getDetachment());
|
||||
eChargeAlarm.setBorough(roomEntity.getBorough());
|
||||
eChargeAlarm.setBrigade(roomEntity.getBrigade());
|
||||
eChargeAlarm.setBuildingId(roomEntity.getBuildingId());
|
||||
eChargeAlarm.setBuildingName(roomEntity.getBuildingName());
|
||||
eChargeAlarm.setRoomId(roomEntity.getRoomId());
|
||||
eChargeAlarm.setRoomName(roomEntity.getRoomName());
|
||||
eChargeAlarm.setLatitude(roomEntity.getLatitude());
|
||||
eChargeAlarm.setLongitude(roomEntity.getLongitude());
|
||||
|
||||
eChargeAlarm.Insert(dataSource);
|
||||
|
||||
EChargeAlarmNotify notify = new EChargeAlarmNotify(eChargeAlarm);
|
||||
WebNotifyProperty pro = new WebNotifyProperty();
|
||||
pro.setBrigade(eChargeAlarm.getBrigade());
|
||||
pro.setBorough(eChargeAlarm.getBorough());
|
||||
pro.setDetachment(eChargeAlarm.getDetachment());
|
||||
pro.setStation(eChargeAlarm.getStation());
|
||||
pro.setDevice_id(eChargeAlarm.getSensorId());
|
||||
pro.setDevice_type("tpson");
|
||||
notify.attachProperty(pro);
|
||||
clientWebsocketManager.addWebNotify(notify);
|
||||
|
||||
MessageToStation msg = new MessageToStation();
|
||||
msg.setMessage("charge_event");
|
||||
msg.setData(JSON.toJSONString(eChargeAlarm));
|
||||
msg.setTitle("charge");
|
||||
String str = JsonHelper.convertObjectToStr(msg);
|
||||
messagePublisher.sendMessage(eChargeAlarm.getStation(),str);
|
||||
}catch (Exception e){
|
||||
res.setCode(20);
|
||||
res.setMsg("fail");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/chargeEvent/getlist")
|
||||
public RespEntity getEChargeEventList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
EChargeAlarmEntity eChargeAlarm = (EChargeAlarmEntity) SQLTools.getEntityFromJson(rootnode,EChargeAlarmEntity.class);
|
||||
|
||||
if(eChargeAlarm==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(eChargeAlarm.getBrigade() == null && eChargeAlarm.getBorough() == null && eChargeAlarm.getDetachment() == null && eChargeAlarm.getStation() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = eChargeAlarm.queryPage(dataSource, startstr, endstr, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/chargeEvent/count")
|
||||
public RespEntity countEChargeEventList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
EChargeAlarmEntity eChargeAlarm = (EChargeAlarmEntity) SQLTools.getEntityFromJson(rootnode,EChargeAlarmEntity.class);
|
||||
|
||||
if(eChargeAlarm==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(eChargeAlarm.getBrigade() == null && eChargeAlarm.getBorough() == null && eChargeAlarm.getDetachment() == null && eChargeAlarm.getStation() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
|
||||
int count = eChargeAlarm.queryCount(dataSource,startstr,endstr);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,reulst);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/chargeEvent/read")
|
||||
public RespEntity readEChargeEventList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
EChargeAlarmEntity eChargeAlarm = (EChargeAlarmEntity) SQLTools.getEntityFromJson(rootnode,EChargeAlarmEntity.class);
|
||||
|
||||
if(eChargeAlarm==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(eChargeAlarm.getAlarmId() == null ){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
EChargeAlarmEntity tgtAlarm = (EChargeAlarmEntity)eChargeAlarm.QueryIt(dataSource);
|
||||
if(tgtAlarm == null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(!EChargeAlarmEntity.ALARM_STATE_CLOSED.equalsIgnoreCase(tgtAlarm.getState())){
|
||||
tgtAlarm.setState(EChargeAlarmEntity.ALARM_STATE_READ);
|
||||
tgtAlarm.setReadTime(new Date());
|
||||
tgtAlarm.Update(dataSource);
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/chargeEvent/close")
|
||||
public RespEntity closeEChargeEventList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
EChargeAlarmEntity eChargeAlarm = (EChargeAlarmEntity) SQLTools.getEntityFromJson(rootnode,EChargeAlarmEntity.class);
|
||||
|
||||
if(eChargeAlarm==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(eChargeAlarm.getAlarmId() == null ){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
EChargeAlarmEntity tgtAlarm = (EChargeAlarmEntity)eChargeAlarm.QueryIt(dataSource);
|
||||
if(tgtAlarm == null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(!EChargeAlarmEntity.ALARM_STATE_CLOSED.equalsIgnoreCase(tgtAlarm.getState())){
|
||||
tgtAlarm.setState(EChargeAlarmEntity.ALARM_STATE_CLOSED);
|
||||
tgtAlarm.setCloseTime(new Date());
|
||||
tgtAlarm.Update(dataSource);
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
/*
|
||||
*community api
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/add",method = RequestMethod.POST)
|
||||
public RespEntity addCommunity(HttpServletRequest request) {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
CommunityInfo communityInfo = (CommunityInfo) SQLTools.getEntityFromJson(rootnode, CommunityInfo.class);
|
||||
|
||||
if(communityInfo==null||communityInfo.getStation()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(communityInfo.getCommunityName()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(communityInfo.getCommunityId() == null){
|
||||
communityInfo.setCommunityId(UUID.randomUUID().toString());
|
||||
}
|
||||
if(communityInfo.QueryIt(dataSource)!=null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
if (!communityInfo.Insert(dataSource)) {
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/update",method = RequestMethod.POST)
|
||||
public RespEntity updateCommunity(HttpServletRequest request) {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
CommunityInfo communityInfo = (CommunityInfo) SQLTools.getEntityFromJson(rootnode, CommunityInfo.class);
|
||||
if(communityInfo==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
CommunityInfo orgtask = (CommunityInfo)communityInfo.QueryIt(dataSource);
|
||||
if(orgtask==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if (communityInfo.Update(dataSource)) {
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/delete",method = RequestMethod.POST)
|
||||
public RespEntity deleteCommunity(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
CommunityInfo communityInfo = (CommunityInfo) SQLTools.getEntityFromJson(rootnode,CommunityInfo.class);
|
||||
if(communityInfo==null||communityInfo.getCommunityId()==null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
CommunityInfo tgtCommunity = (CommunityInfo)communityInfo.QueryIt(dataSource);
|
||||
if(tgtCommunity == null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(tgtCommunity.Delete(dataSource)){
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/count",method = RequestMethod.POST)
|
||||
public RespEntity getCommunityCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
CommunityInfo communityInfo = (CommunityInfo) SQLTools.getEntityFromJson(rootnode,CommunityInfo.class);
|
||||
|
||||
if(communityInfo==null)
|
||||
communityInfo = new CommunityInfo();
|
||||
int count = communityInfo.queryCount(dataSource,null,null);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS, reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getCommunityList(HttpServletRequest request) {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
CommunityInfo communityInfo = (CommunityInfo) SQLTools.getEntityFromJson(rootnode,CommunityInfo.class);
|
||||
|
||||
if(communityInfo==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(communityInfo.getBrigade()==null && communityInfo.getBorough()== null && communityInfo.getDetachment() == null && communityInfo.getStation()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
|
||||
List<SQLDataObject> list = communityInfo.queryPage(dataSource, startstr, endstr, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}
|
||||
|
||||
//building api
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/building/add",method = RequestMethod.POST)
|
||||
public RespEntity addCommunityBuilding(HttpServletRequest request) {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
EChargeBuildingEntity buildingEntity = (EChargeBuildingEntity) SQLTools.getEntityFromJson(rootnode, EChargeBuildingEntity.class);
|
||||
|
||||
if(buildingEntity==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(buildingEntity.getBuildingName()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(buildingEntity.getBuildingId() == null){
|
||||
buildingEntity.setBuildingId(UUID.randomUUID().toString());
|
||||
}
|
||||
if(buildingEntity.QueryIt(dataSource)!=null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
|
||||
if(buildingEntity.getCommunityId() != null){
|
||||
CommunityInfo tgtCommunity = new CommunityInfo();
|
||||
tgtCommunity.setCommunityId(buildingEntity.getCommunityId());
|
||||
tgtCommunity = (CommunityInfo)tgtCommunity.QueryIt(dataSource);
|
||||
if(tgtCommunity != null){
|
||||
buildingEntity.setCommunityName(tgtCommunity.getCommunityName());
|
||||
buildingEntity.setStation(tgtCommunity.getStation());
|
||||
buildingEntity.setDetachment(tgtCommunity.getDetachment());
|
||||
buildingEntity.setBorough(tgtCommunity.getBorough());
|
||||
buildingEntity.setBrigade(tgtCommunity.getBrigade());
|
||||
}
|
||||
}
|
||||
|
||||
if (!buildingEntity.Insert(dataSource)) {
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/building/update",method = RequestMethod.POST)
|
||||
public RespEntity updateCommunityBuilding(HttpServletRequest request) {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
EChargeBuildingEntity buildingEntity = (EChargeBuildingEntity) SQLTools.getEntityFromJson(rootnode, EChargeBuildingEntity.class);
|
||||
if(buildingEntity==null||buildingEntity.getBuildingId()==null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
EChargeBuildingEntity oldBuilding = (EChargeBuildingEntity)buildingEntity.QueryIt(dataSource);
|
||||
if(oldBuilding==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(buildingEntity.getCommunityId() != null){
|
||||
CommunityInfo tgtCommunity = new CommunityInfo();
|
||||
tgtCommunity.setCommunityId(buildingEntity.getCommunityId());
|
||||
tgtCommunity = (CommunityInfo)tgtCommunity.QueryIt(dataSource);
|
||||
if(tgtCommunity != null){
|
||||
buildingEntity.setCommunityName(tgtCommunity.getCommunityName());
|
||||
buildingEntity.setStation(tgtCommunity.getStation());
|
||||
buildingEntity.setDetachment(tgtCommunity.getDetachment());
|
||||
buildingEntity.setBorough(tgtCommunity.getBorough());
|
||||
buildingEntity.setBrigade(tgtCommunity.getBrigade());
|
||||
}
|
||||
}
|
||||
if (buildingEntity.Update(dataSource)) {
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/building/delete",method = RequestMethod.POST)
|
||||
public RespEntity deleteCommunityBuilding(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
EChargeBuildingEntity buildingEntity = (EChargeBuildingEntity) SQLTools.getEntityFromJson(rootnode,EChargeBuildingEntity.class);
|
||||
if(buildingEntity==null||buildingEntity.getBuildingId()==null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
EChargeBuildingEntity oldBuilding = (EChargeBuildingEntity)buildingEntity.QueryIt(dataSource);
|
||||
if(oldBuilding == null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(oldBuilding.Delete(dataSource)){
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/building/count",method = RequestMethod.POST)
|
||||
public RespEntity getCommunityBuildingCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
EChargeBuildingEntity buildingEntity = (EChargeBuildingEntity) SQLTools.getEntityFromJson(rootnode,EChargeBuildingEntity.class);
|
||||
|
||||
if(buildingEntity==null)
|
||||
buildingEntity = new EChargeBuildingEntity();
|
||||
int count = buildingEntity.queryCount(dataSource,null,null);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS, reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/building/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getCommunityBuildingList(HttpServletRequest request) {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
EChargeBuildingEntity buildingEntity = (EChargeBuildingEntity) SQLTools.getEntityFromJson(rootnode,EChargeBuildingEntity.class);
|
||||
|
||||
if(buildingEntity==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(buildingEntity.getBrigade()==null && buildingEntity.getBorough()== null && buildingEntity.getDetachment() == null && buildingEntity.getStation()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
|
||||
List<SQLDataObject> list = buildingEntity.queryPage(dataSource, startstr, endstr, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}
|
||||
|
||||
//room api
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/room/add",method = RequestMethod.POST)
|
||||
public RespEntity addCommunityRoom(HttpServletRequest request) {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
EChargeRoomEntity roomEntity = (EChargeRoomEntity) SQLTools.getEntityFromJson(rootnode, EChargeRoomEntity.class);
|
||||
|
||||
if(roomEntity==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(roomEntity.getRoomName()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(roomEntity.getRoomId() == null){
|
||||
roomEntity.setRoomId(UUID.randomUUID().toString());
|
||||
}
|
||||
if(roomEntity.QueryIt(dataSource)!=null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
|
||||
if(roomEntity.getBuildingId() != null){
|
||||
EChargeBuildingEntity tgtBuilding = new EChargeBuildingEntity();
|
||||
tgtBuilding.setBuildingId(roomEntity.getBuildingId());
|
||||
tgtBuilding = (EChargeBuildingEntity)tgtBuilding.QueryIt(dataSource);
|
||||
if(tgtBuilding != null){
|
||||
roomEntity.setCommunityName(tgtBuilding.getCommunityName());
|
||||
roomEntity.setCommunityId(tgtBuilding.getCommunityId());
|
||||
roomEntity.setBuildingName(tgtBuilding.getBuildingName());
|
||||
roomEntity.setStation(tgtBuilding.getStation());
|
||||
roomEntity.setDetachment(tgtBuilding.getDetachment());
|
||||
roomEntity.setBorough(tgtBuilding.getBorough());
|
||||
roomEntity.setBrigade(tgtBuilding.getBrigade());
|
||||
|
||||
if(roomEntity.getLatitude() == 0){
|
||||
roomEntity.setLatitude(tgtBuilding.getLatitude());
|
||||
}
|
||||
if(roomEntity.getLongitude() == 0){
|
||||
roomEntity.setLongitude(tgtBuilding.getLongitude());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!roomEntity.Insert(dataSource)) {
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/room/update",method = RequestMethod.POST)
|
||||
public RespEntity updateCommunityRoom(HttpServletRequest request) {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
EChargeRoomEntity roomEntity = (EChargeRoomEntity) SQLTools.getEntityFromJson(rootnode, EChargeRoomEntity.class);
|
||||
if(roomEntity==null||roomEntity.getRoomId()==null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
EChargeRoomEntity oldRoom = (EChargeRoomEntity)roomEntity.QueryIt(dataSource);
|
||||
if(oldRoom==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(roomEntity.getBuildingId() != null){
|
||||
CommunityInfo tgtCommunity = new CommunityInfo();
|
||||
tgtCommunity.setCommunityId(roomEntity.getCommunityId());
|
||||
tgtCommunity = (CommunityInfo)tgtCommunity.QueryIt(dataSource);
|
||||
if(tgtCommunity != null){
|
||||
roomEntity.setCommunityName(tgtCommunity.getCommunityName());
|
||||
roomEntity.setStation(tgtCommunity.getStation());
|
||||
roomEntity.setDetachment(tgtCommunity.getDetachment());
|
||||
roomEntity.setBorough(tgtCommunity.getBorough());
|
||||
roomEntity.setBrigade(tgtCommunity.getBrigade());
|
||||
}
|
||||
}
|
||||
roomEntity.setChargeStatus(null);
|
||||
roomEntity.setChargeStatusTime(null);
|
||||
if (roomEntity.Update(dataSource)) {
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/room/delete",method = RequestMethod.POST)
|
||||
public RespEntity deleteCommunityRoom(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
EChargeRoomEntity roomEntity = (EChargeRoomEntity) SQLTools.getEntityFromJson(rootnode,EChargeRoomEntity.class);
|
||||
if(roomEntity==null||roomEntity.getRoomId()==null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
EChargeRoomEntity oldRoom = (EChargeRoomEntity)roomEntity.QueryIt(dataSource);
|
||||
if(oldRoom == null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(oldRoom.Delete(dataSource)){
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/room/count",method = RequestMethod.POST)
|
||||
public RespEntity getCommunityRoomCount(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
EChargeRoomEntity roomEntity = (EChargeRoomEntity) SQLTools.getEntityFromJson(rootnode,EChargeRoomEntity.class);
|
||||
|
||||
if(roomEntity==null)
|
||||
roomEntity = new EChargeRoomEntity();
|
||||
int count = roomEntity.queryCount(dataSource,null,null);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS, reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/room/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getCommunityRoomList(HttpServletRequest request) {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
EChargeRoomEntity roomEntity = (EChargeRoomEntity) SQLTools.getEntityFromJson(rootnode,EChargeRoomEntity.class);
|
||||
|
||||
if(roomEntity==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(roomEntity.getBrigade()==null && roomEntity.getBorough()== null && roomEntity.getDetachment() == null && roomEntity.getStation()==null && roomEntity.getRoomId()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
|
||||
List<SQLDataObject> list = roomEntity.queryPage(dataSource, startstr, endstr, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/community/room/reset",method = RequestMethod.POST)
|
||||
public RespEntity resetRoomChargeState(HttpServletRequest request) {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
EChargeRoomEntity roomEntity = (EChargeRoomEntity) SQLTools.getEntityFromJson(rootnode, EChargeRoomEntity.class);
|
||||
if(roomEntity==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(roomEntity.getRoomId()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
EChargeRoomEntity oldRoom = (EChargeRoomEntity)roomEntity.QueryIt(dataSource);
|
||||
if(oldRoom==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
|
||||
roomEntity.setChargeStatus("charge.out");
|
||||
roomEntity.setChargeStatusTime(new Date());
|
||||
if (roomEntity.Update(dataSource)) {
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,306 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.common.service.CountResult;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.complexquery.AIIPCConfig;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.SensorDeviceEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.aiipc.*;
|
||||
import com.jingyi.iotserver.iotctrl.IoTCtrlMessage;
|
||||
import com.jingyi.iotserver.iotctrl.IoTCtrlServer;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FireCtrlAIIPCClientController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
@Autowired
|
||||
private IoTCtrlServer ioTCtrlServer;
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/aiipc/getmatchfaceeventcount",method = RequestMethod.POST)
|
||||
public RespEntity getAIIPCMatchFaceEventCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
|
||||
AIIPCMatchFaceEventEntity event = (AIIPCMatchFaceEventEntity) SQLTools.getEntityFromJson(rootnode, AIIPCMatchFaceEventEntity.class);
|
||||
if(event==null)
|
||||
event = new AIIPCMatchFaceEventEntity();
|
||||
|
||||
int count = event.queryCount(dataSource,startstr,endstr);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/aiipc/getmatchfaceeventlist",method = RequestMethod.POST)
|
||||
public RespEntity getAIIPCMatchFaceEventPage(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 100;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
AIIPCMatchFaceEventEntity event = (AIIPCMatchFaceEventEntity) SQLTools.getEntityFromJson(rootnode, AIIPCMatchFaceEventEntity.class);
|
||||
if(event==null)
|
||||
event = new AIIPCMatchFaceEventEntity();
|
||||
|
||||
List<SQLDataObject> list= event.queryPage(dataSource,startstr,endstr, pageindex, pagesize);
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/aiipc/getmatchcarplateeventcount",method = RequestMethod.POST)
|
||||
public RespEntity getAIIPCMatchCarplateEventCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
|
||||
|
||||
AIIPCMatchCarPlateEventEntity event = (AIIPCMatchCarPlateEventEntity) SQLTools.getEntityFromJson(rootnode, AIIPCMatchCarPlateEventEntity.class);
|
||||
if(event==null)
|
||||
event = new AIIPCMatchCarPlateEventEntity();
|
||||
|
||||
int count = event.queryCount(dataSource,startstr,endstr);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/aiipc/getmatchcarplateeventlist",method = RequestMethod.POST)
|
||||
public RespEntity getAIIPCMatchCarplateEventPage(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 100;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
AIIPCMatchCarPlateEventEntity event = (AIIPCMatchCarPlateEventEntity) SQLTools.getEntityFromJson(rootnode, AIIPCMatchCarPlateEventEntity.class);
|
||||
if(event==null)
|
||||
event = new AIIPCMatchCarPlateEventEntity();
|
||||
|
||||
List<SQLDataObject> list= event.queryPage(dataSource,startstr,endstr, pageindex, pagesize);
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/aiipc/getstatuscount",method = RequestMethod.POST)
|
||||
public RespEntity getAIIPCStatusCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
|
||||
|
||||
AIIPCStatusEntity event = (AIIPCStatusEntity) SQLTools.getEntityFromJson(rootnode, AIIPCStatusEntity.class);
|
||||
if(event==null)
|
||||
event = new AIIPCStatusEntity();
|
||||
|
||||
int count = event.queryCount(dataSource,startstr,endstr);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/aiipc/getstatuslist",method = RequestMethod.POST)
|
||||
public RespEntity getAIIPCStatusPage(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 100;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
AIIPCStatusEntity event = (AIIPCStatusEntity) SQLTools.getEntityFromJson(rootnode, AIIPCStatusEntity.class);
|
||||
if(event==null)
|
||||
event = new AIIPCStatusEntity();
|
||||
|
||||
List<SQLDataObject> list= event.queryPage(dataSource,startstr,endstr, pageindex, pagesize);
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/aiipc/config",method = RequestMethod.POST)
|
||||
public RespEntity AIIPCConfig(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
|
||||
AIIPCSettingEntity setting = (AIIPCSettingEntity) SQLTools.getEntityFromJson(rootnode, AIIPCSettingEntity.class);
|
||||
if(setting==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
SensorDeviceEntity sensor = SensorDeviceEntity.Query(dataSource,setting.getDeviceid());
|
||||
if(sensor == null)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
|
||||
JsonNode subobj = JsonHelper.getLevel2(rootnode,"eventsetting");
|
||||
if(subobj!=null&&subobj.isArray()){
|
||||
List<AIIPCEventSettingEntity> list = SQLTools.getEntityListFromJsonArray(subobj,AIIPCEventSettingEntity.class);
|
||||
if(list!=null&&list.size()>0) {
|
||||
for (AIIPCEventSettingEntity set : list) {
|
||||
if(set.QueryIt(dataSource)==null){
|
||||
set.Insert(dataSource);
|
||||
}else{
|
||||
set.Update(dataSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subobj = JsonHelper.getLevel2(rootnode,"textmatchsetting");
|
||||
if(subobj!=null&&subobj.isArray()){
|
||||
List<AIIPCTextMatchSettingEntity> list = SQLTools.getEntityListFromJsonArray(subobj,AIIPCTextMatchSettingEntity.class);
|
||||
if(list!=null&&list.size()>0) {
|
||||
for (AIIPCTextMatchSettingEntity set : list) {
|
||||
if(set.QueryIt(dataSource)==null){
|
||||
set.Insert(dataSource);
|
||||
}else{
|
||||
set.Update(dataSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IoTCtrlMessage iotmsg = new IoTCtrlMessage();
|
||||
iotmsg.setDeviceid(setting.getDeviceid());
|
||||
iotmsg.setDevicetype(sensor.getDevicetype());
|
||||
iotmsg.setTimestamp(System.currentTimeMillis()/1000);
|
||||
iotmsg.setMsgname("congfig-change");
|
||||
iotmsg.setMsgtype("request");
|
||||
iotmsg.setMessage("");
|
||||
String cmd = JsonHelper.convertObjectToStr(iotmsg);
|
||||
byte [] data = cmd.getBytes();
|
||||
|
||||
if(ioTCtrlServer.SendDataToIotCtrl(data))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/aiipc/getconfig",method = RequestMethod.POST)
|
||||
public RespEntity getAIIPCConfig(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
|
||||
String deviceid = JsonHelper.getStringValue(rootnode, "deviceid");
|
||||
SensorDeviceEntity sensor = SensorDeviceEntity.Query(dataSource,deviceid);
|
||||
if(sensor == null)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
|
||||
AIIPCConfig config = new AIIPCConfig();
|
||||
config.setDeviceid(deviceid);
|
||||
|
||||
AIIPCSettingEntity setting = new AIIPCSettingEntity();
|
||||
setting.setDeviceid(deviceid);
|
||||
setting = (AIIPCSettingEntity)setting.QueryIt(dataSource);
|
||||
if(setting==null){
|
||||
setting = new AIIPCSettingEntity();
|
||||
setting.setDeviceid(deviceid);
|
||||
setting.setHeartbeat(180);
|
||||
setting.setServeraddr("118.190.86.237");
|
||||
setting.setPort(9019);
|
||||
setting.setImageuploadaddr("https://www.genetek.cc:8083/firectrl/file/aiipc/upload");
|
||||
}
|
||||
config.setSetting(setting);
|
||||
|
||||
AIIPCEventSettingEntity eventset = new AIIPCEventSettingEntity();
|
||||
eventset.setDeviceid(deviceid);
|
||||
List<SQLDataObject> list = eventset.queryList(dataSource,null,null);
|
||||
config.setEventsetting(list);
|
||||
|
||||
AIIPCPictureMatchSettingEntity picset = new AIIPCPictureMatchSettingEntity();
|
||||
picset.setDeviceid(deviceid);
|
||||
list = picset.queryList(dataSource,null,null);
|
||||
config.setPicturematchsetting(list);
|
||||
|
||||
AIIPCTextMatchSettingEntity txtset = new AIIPCTextMatchSettingEntity();
|
||||
txtset.setDeviceid(deviceid);
|
||||
list = txtset.queryList(dataSource,null,null);
|
||||
config.setTextmatchsetting(list);
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS,config);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,218 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.clientmanage.IOrganizationOperate;
|
||||
import com.jingyi.iotserver.clientmanage.IUserOperate;
|
||||
import com.jingyi.iotserver.clientmanage.model.*;
|
||||
import com.jingyi.iotserver.common.configuration.DruidDataSourceConfig;
|
||||
import com.jingyi.iotserver.common.service.EnvConfigService;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.clientmanage.UserService;
|
||||
import com.jingyi.iotserver.firestationport.services.DatabaseTransfer;
|
||||
import com.jingyi.iotserver.firestationport.services.userman.UserAccess;
|
||||
import com.jingyi.iotserver.clientmanage.UserAuthorManager;
|
||||
import com.jingyi.iotserver.utils.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
//https://blog.csdn.net/huang906391/article/details/78376766
|
||||
//https://blog.csdn.net/likeyjs/article/details/80525042
|
||||
|
||||
//https://www.jianshu.com/p/43c97352aa1e
|
||||
|
||||
|
||||
//httpsession https://www.cnblogs.com/diewufeixian/p/4221747.html
|
||||
//httpsession https://www.cnblogs.com/zhaoYuQing-java2015/p/4621384.html
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FireCtrlClientLoginController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private UserAuthorManager userAuthorManager;
|
||||
|
||||
@Autowired
|
||||
private EnvConfigService envConfigService;
|
||||
|
||||
@Autowired
|
||||
private DatabaseTransfer databaseTransfer;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/user/login", method = RequestMethod.POST)
|
||||
public RespEntity appLogin(HttpServletRequest request, HttpServletResponse response, @CookieValue(value = "token", required = false) String token) {
|
||||
RespEntity rel = null;
|
||||
String user = "monsensora";
|
||||
String pwd = "9pt2qug7";
|
||||
String url = "http://125.74.48.82:8082/user/login";
|
||||
String appkey = "fbc8210c-2e59-4767-8c6c-5f013c85a137";
|
||||
String screct = "381dba50a848e60de2dbdd642e1e3956";
|
||||
/*
|
||||
GUIDUtil guid = new GUIDUtil();
|
||||
String appkey = guid.GeneralAppkey();
|
||||
String screct = guid.GenreralScerect(appkey);
|
||||
System.out.println(appkey+" "+scerect);
|
||||
*/
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/user/agentlogin",method = RequestMethod.POST)
|
||||
public RespEntity userAgentLogin(HttpServletRequest request, HttpServletResponse response, @CookieValue(value = "token", required = false) String token) {
|
||||
RespEntity rel = null;
|
||||
try{
|
||||
String json = HttpTools.getBodyFromRequest(request);
|
||||
JsonNode rootnode = JsonHelper.parseBodyLevel1(json);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
}
|
||||
String name = JsonHelper.getStringValue(rootnode,"name");
|
||||
String password = JsonHelper.getStringValue(rootnode,"password");
|
||||
if(name==null){
|
||||
return new RespEntity(RespCode.USER_PWD_ERROR);
|
||||
}
|
||||
|
||||
UserInfoEntity user = new UserInfoEntity();
|
||||
user.setName(name);
|
||||
user = (UserInfoEntity)user.QueryIt(dataSource);
|
||||
if(name.equals("administrator")){
|
||||
user = new UserInfoEntity();
|
||||
user.setUsertype("super");
|
||||
user.setName("administrator");
|
||||
user.setScopelevel("master");
|
||||
String adminpwd = MD5Tools.md5(envConfigService.getSuperPassword());
|
||||
user.setPassword(MD5Tools.md5("firectrl"+name+adminpwd));
|
||||
}
|
||||
if(user==null)
|
||||
return new RespEntity(RespCode.USER_PWD_ERROR);
|
||||
|
||||
String pwd = MD5Tools.md5("firectrl"+name+password);
|
||||
|
||||
if(!pwd.equals(user.getPassword())){
|
||||
return new RespEntity(RespCode.USER_PWD_ERROR);
|
||||
}
|
||||
|
||||
|
||||
LoginResultEntity result = new LoginResultEntity();
|
||||
result.setSession(user.getUserrole());
|
||||
|
||||
OrganizationInfoEntity org;
|
||||
if(user.IsSuper()) {
|
||||
org = new OrganizationInfoEntity();
|
||||
org.setOrgname("iotserver");
|
||||
org.setBrigade("all");
|
||||
org.setDetachment("all");
|
||||
org.setAddress("China");
|
||||
org.setCity("China");
|
||||
}else{
|
||||
org = new OrganizationInfoEntity();
|
||||
org.setOrgname(user.getOrgname());
|
||||
org = (OrganizationInfoEntity)org.QueryIt(dataSource);
|
||||
}
|
||||
result.setOrganize(org);
|
||||
result.setUsertype(user.getUsertype());
|
||||
result.setScopelevel(user.getScopelevel());
|
||||
result.setLevelvalue(user.getLevelvalue());
|
||||
// result.setUserinfo(user);
|
||||
return new RespEntity(RespCode.SUCCESS,result);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/user/active",method = RequestMethod.POST)
|
||||
public RespEntity userHeartBeat(HttpServletRequest request) {
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
private RespEntity executeOperateOnUser(HttpServletRequest request,IUserOperate op) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
UserInfoEntity userinfo = (UserInfoEntity)SQLTools.getEntityFromJson(rootnode,UserInfoEntity.class);
|
||||
if(userinfo==null||userinfo.getName()==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
return op.ExecuteOperate(userinfo,rootnode);
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/user/hastaskauthor",method = RequestMethod.POST)
|
||||
public RespEntity hasTaskAuthotity(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
|
||||
if(userAuthorManager.IsAdmin(request)||userAuthorManager.IsSuper(request))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
if(userAuthorManager.checkUserAuthor(request.getHeader("authorization"),"firectrl.client.user.sendtask"))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/user/hasnotifyauthor",method = RequestMethod.POST)
|
||||
public RespEntity hasNotifyAuthotity(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
if(userAuthorManager.IsAdmin(request)||userAuthorManager.IsSuper(request))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
if(userAuthorManager.checkUserAuthor(request.getHeader("authorization"),"firectrl.client.user.sendnotify"))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/test/db",method = RequestMethod.POST)
|
||||
public RespEntity dbtest(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
// DruidDataSourceConfig config = (DruidDataSourceConfig)SpringContextUtil.getBean(DruidDataSourceConfig.class);
|
||||
// DataSource ds = config.getMySqlDataSource();
|
||||
// UserInfoEntity user = UserInfoEntity.QueryUser(ds,"administrator");
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
String name = JsonHelper.getStringValue(rootnode,"name");
|
||||
if(databaseTransfer.startTrans(name))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,611 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.clientmanage.UserAuthorManager;
|
||||
import com.jingyi.iotserver.clientmanage.UserService;
|
||||
import com.jingyi.iotserver.common.service.EnvConfigService;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationBaseInfoEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.rollcall.FireStationRollCallAckEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.rollcall.FireStationRollCallEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.complexquery.*;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.SensorDeviceEntity;
|
||||
import com.jingyi.iotserver.firestationport.services.SensorService;
|
||||
import com.jingyi.iotserver.firestationport.services.StationServices;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FireCtrlDataAnalyzeController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private StationServices stationServices;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private UserAuthorManager userAuthorManager;
|
||||
|
||||
@Autowired
|
||||
private EnvConfigService envConfigService;
|
||||
|
||||
@Autowired
|
||||
private SensorService sensorService;
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/analyze/rollcallack",method = RequestMethod.POST)
|
||||
public RespEntity roolcallAckAnalyze(HttpServletRequest request) {
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/analyze/stationonline",method = RequestMethod.POST)
|
||||
public RespEntity stationOnlineAnalyze(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
ArrayList<TimeCountInfo> rellist = new ArrayList<TimeCountInfo>();
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
|
||||
if (rootnode != null) {
|
||||
FireStationBaseInfoEntity station = (FireStationBaseInfoEntity) SQLTools.getEntityFromJson(rootnode,FireStationBaseInfoEntity.class);
|
||||
if(station==null)
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
JsonNode timearray = JsonHelper.getLevel2(rootnode,"time");
|
||||
if(!timearray.isArray())
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
for(int i=0;i<timearray.size();i++) {
|
||||
try {
|
||||
JsonNode tim = timearray.get(i);
|
||||
String startstr = JsonHelper.getStringValue(tim, "start");
|
||||
String endstr = JsonHelper.getStringValue(tim, "end");
|
||||
String index = JsonHelper.getStringValue(tim, "index");
|
||||
Date start = SQLTools.StrToDateTime(startstr);
|
||||
Date end = SQLTools.StrToDateTime(endstr);
|
||||
|
||||
if (start == null || end == null)
|
||||
continue;
|
||||
TimeCountInfo tcount = stationServices.queryStationOnlineTimeCountInfo(station, start, end);
|
||||
if(tcount!=null){
|
||||
tcount.setIndex(index);
|
||||
rellist.add(tcount);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
rel = new RespEntity(RespCode.SUCCESS,rellist);
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/analyze/stationonguard",method = RequestMethod.POST)
|
||||
public RespEntity stationOnGuardAnalyze(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
ArrayList<TimeCountInfo> rellist = new ArrayList<TimeCountInfo>();
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode!=null) {
|
||||
FireStationBaseInfoEntity station = (FireStationBaseInfoEntity) SQLTools.getEntityFromJson(rootnode, FireStationBaseInfoEntity.class);
|
||||
if (station == null)
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
JsonNode timearray = JsonHelper.getLevel2(rootnode, "time");
|
||||
if (!timearray.isArray())
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
for(int i=0;i<timearray.size();i++) {
|
||||
try {
|
||||
JsonNode tim = timearray.get(i);
|
||||
String startstr = JsonHelper.getStringValue(tim, "start");
|
||||
String endstr = JsonHelper.getStringValue(tim, "end");
|
||||
String index = JsonHelper.getStringValue(tim, "index");
|
||||
Date start = SQLTools.StrToDateTime(startstr);
|
||||
Date end = SQLTools.StrToDateTime(endstr);
|
||||
if (start == null || end == null)
|
||||
continue;
|
||||
TimeCountInfo tcount = stationServices.queryStationOnSignTimeCountInfo(station, start, end);
|
||||
if(tcount!=null){
|
||||
rellist.add(tcount);
|
||||
tcount.setIndex(index);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
rel = new RespEntity(RespCode.SUCCESS,rellist);
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/analyze/rollcallreportform",method = RequestMethod.POST)
|
||||
public RespEntity getRollcallReportform(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
JsonNode timearray = JsonHelper.getLevel2(rootnode, "time");
|
||||
if (!timearray.isArray())
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
String username = JsonHelper.getStringValue(rootnode, "username");
|
||||
JsonNode scopenode = JsonHelper.getLevel2(rootnode, "scope");
|
||||
ArrayList<RollcallReportForm> reportlist = new ArrayList<RollcallReportForm>();
|
||||
FireStationRollCallEntity rollentity = null;
|
||||
if (username != null) {
|
||||
rollentity = new FireStationRollCallEntity();
|
||||
rollentity.setUsername(username);
|
||||
}
|
||||
for(int i=0;i<timearray.size();i++) {
|
||||
int stationcount = 0;
|
||||
|
||||
try {
|
||||
JsonNode tim = timearray.get(i);
|
||||
String startstr = JsonHelper.getStringValue(tim, "start");
|
||||
String endstr = JsonHelper.getStringValue(tim, "end");
|
||||
String index = JsonHelper.getStringValue(tim, "index");
|
||||
|
||||
List<SQLDataObject> rollcalllist = rollentity.queryPage(dataSource,startstr, endstr, 0, 1024);
|
||||
|
||||
if (scopenode != null && rollcalllist != null) {
|
||||
//remove rollcall out scope
|
||||
List<FireStationRollCallEntity> rmlist = new ArrayList<FireStationRollCallEntity>();
|
||||
List<FireStationBaseInfoEntity> list = SQLTools.getEntityListFromJsonArray(scopenode, FireStationBaseInfoEntity.class);
|
||||
if (list != null && list.size() > 0) {
|
||||
for (SQLDataObject ob : rollcalllist) {
|
||||
FireStationRollCallEntity rollcall = (FireStationRollCallEntity)ob;
|
||||
if (rollcall != null) {
|
||||
try {
|
||||
boolean rm = true;
|
||||
String scope = rollcall.getScope();
|
||||
JsonNode rollscopelist = JsonHelper.parseBodyLevel1(scope);
|
||||
List<FireStationBaseInfoEntity> rolllist = SQLTools.getEntityListFromJsonArray(rollscopelist, FireStationBaseInfoEntity.class);
|
||||
for (FireStationBaseInfoEntity userscope : list) {
|
||||
if (userscope != null) {
|
||||
for (FireStationBaseInfoEntity roll : rolllist) {
|
||||
if (roll != null) {
|
||||
if (userscope.checkScope(roll)) {
|
||||
rm = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!rm)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rm)
|
||||
rmlist.add(rollcall);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
for (FireStationRollCallEntity rollcall : rmlist) {
|
||||
if (rollcall != null)
|
||||
rollcalllist.remove(rollcall);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RollcallReportForm report = new RollcallReportForm();
|
||||
HashMap<String, StationRollcallCounter> stationrollcallmap = new HashMap<String, StationRollcallCounter>();
|
||||
if (rollcalllist == null || rollcalllist.size() <= 0) {
|
||||
report.setRollcall(0);
|
||||
report.setAck(0);
|
||||
report.setIgnore(0);
|
||||
report.setExpect(0);
|
||||
report.setRanking(null);
|
||||
report.setIndex(index);
|
||||
reportlist.add(report);
|
||||
continue;
|
||||
}
|
||||
report.setRollcall(rollcalllist.size());
|
||||
for (SQLDataObject ob : rollcalllist) {
|
||||
FireStationRollCallEntity rollcall = (FireStationRollCallEntity)ob;
|
||||
String scopejson = rollcall.getScope();
|
||||
|
||||
try {
|
||||
JsonNode scopelist = JsonHelper.parseBodyLevel1(scopejson);
|
||||
List<FireStationBaseInfoEntity> list = SQLTools.getEntityListFromJsonArray(scopelist, FireStationBaseInfoEntity.class);
|
||||
try {
|
||||
int count = stationServices.queryStationCountByScope(list);
|
||||
if (count > 0)
|
||||
stationcount += count;
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
FireStationRollCallAckEntity ackEntity = new FireStationRollCallAckEntity();
|
||||
int pageindex = 0;
|
||||
int pagesize = 512;
|
||||
ackEntity.setRollcallnumber(rollcall.getNumber());
|
||||
List<SQLDataObject> acklist = null;
|
||||
do {
|
||||
acklist = stationServices.queryRollCallAckList(ackEntity, null, null, pagesize, pageindex);
|
||||
pageindex++;
|
||||
if (acklist == null)
|
||||
break;
|
||||
for (SQLDataObject oback : acklist) {
|
||||
FireStationRollCallAckEntity ack = (FireStationRollCallAckEntity)oback;
|
||||
StationRollcallCounter counter = stationrollcallmap.get(ack.getStationname());
|
||||
if (counter == null) {
|
||||
counter = new StationRollcallCounter();
|
||||
counter.setName(ack.getStationname());
|
||||
if (ack.getState().equals("ack")) {
|
||||
counter.setAck(1);
|
||||
counter.setIgnore(0);
|
||||
} else {
|
||||
counter.setAck(0);
|
||||
counter.setIgnore(1);
|
||||
}
|
||||
stationrollcallmap.put(counter.getName(), counter);
|
||||
} else {
|
||||
if (ack.getState().equals("ack")) {
|
||||
counter.setAck(counter.getAck() + 1);
|
||||
} else {
|
||||
counter.setIgnore(counter.getIgnore() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (acklist != null && acklist.size() >= pagesize);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ArrayList<StationRollcallCounter> ranking = new ArrayList<StationRollcallCounter>();
|
||||
|
||||
for (Map.Entry<String, StationRollcallCounter> entry : stationrollcallmap.entrySet()) {
|
||||
StationRollcallCounter info = entry.getValue();
|
||||
if (info != null) {
|
||||
report.setAck(report.getAck() + info.getAck());
|
||||
report.setIgnore(report.getIgnore() + info.getIgnore());
|
||||
ranking.add(info);
|
||||
}
|
||||
}
|
||||
//Collections.sort(ranking, Collections.reverseOrder());
|
||||
Collections.sort(ranking);
|
||||
report.setRanking(ranking);
|
||||
report.setExpect(stationcount);
|
||||
report.setIndex(index);
|
||||
reportlist.add(report);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS, reportlist);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/analyze/stationonlinecount",method = RequestMethod.POST)
|
||||
public RespEntity stationOnlineCountAnalyze(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
ArrayList<CountInfo> rellist = new ArrayList<CountInfo>();
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
|
||||
if (rootnode != null) {
|
||||
FireStationBaseInfoEntity station = (FireStationBaseInfoEntity) SQLTools.getEntityFromJson(rootnode,FireStationBaseInfoEntity.class);
|
||||
if(station==null)
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
try {
|
||||
JsonNode times = JsonHelper.getLevel2(rootnode, "time");
|
||||
if(times==null||!times.isArray())
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
for(int i=0;i<times.size();i++) {
|
||||
try {
|
||||
JsonNode tnd = times.get(i);
|
||||
String time = JsonHelper.getStringValue(tnd,"time");
|
||||
Date ttt = SQLTools.StrToDateTime(time);
|
||||
|
||||
if (ttt == null)
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
CountInfo tcount = stationServices.queryStationCountOntime(station, ttt);
|
||||
tcount.setIndex(JsonHelper.getStringValue(tnd,"index"));
|
||||
rellist.add(tcount);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
rel = new RespEntity(RespCode.SUCCESS,rellist);
|
||||
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/analyze/mdevonline",method = RequestMethod.POST)
|
||||
public RespEntity mdevOnlineAnalyze(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
ArrayList<TimeCountInfo> rellist = new ArrayList<TimeCountInfo>();
|
||||
ArrayList<String> stationnamelist = new ArrayList<String>();
|
||||
ArrayList<TimeSegement> tslist = new ArrayList<TimeSegement>();
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
|
||||
if (rootnode != null) {
|
||||
FireStationBaseInfoEntity station = (FireStationBaseInfoEntity) SQLTools.getEntityFromJson(rootnode,FireStationBaseInfoEntity.class);
|
||||
if(station==null)
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
List<SQLDataObject> stationlist = null;
|
||||
int pageindex = 0;
|
||||
do {
|
||||
stationlist = stationServices.queryStationList(station, 1000, pageindex);
|
||||
if(stationlist!=null){
|
||||
for(SQLDataObject ob:stationlist) {
|
||||
FireStationBaseInfoEntity s = (FireStationBaseInfoEntity) ob;
|
||||
stationnamelist.add(s.getName());
|
||||
}
|
||||
}
|
||||
pageindex++;
|
||||
}while(stationlist!=null&&stationlist.size()>=1000);
|
||||
|
||||
|
||||
JsonNode timearray = JsonHelper.getLevel2(rootnode,"time");
|
||||
if(!timearray.isArray())
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
for(int i=0;i<timearray.size();i++) {
|
||||
try {
|
||||
JsonNode tim = timearray.get(i);
|
||||
String startstr = JsonHelper.getStringValue(tim, "start");
|
||||
String endstr = JsonHelper.getStringValue(tim, "end");
|
||||
String index = JsonHelper.getStringValue(tim, "index");
|
||||
TimeSegement ts = new TimeSegement();
|
||||
ts.setStart(startstr);
|
||||
ts.setEnd(endstr);
|
||||
ts.setIndex(index);
|
||||
tslist.add(ts);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// request mdev sys
|
||||
ComplexMutilObject multi = new ComplexMutilObject();
|
||||
multi.setObject0(stationnamelist);
|
||||
multi.setObject1(tslist);
|
||||
String mdevrel = HttpTools.getRespFromHttpServer("https://127.0.0.1:8086/mdev/analyze/deviceonline",JsonHelper.convertObjectToStr(multi));
|
||||
if(mdevrel==null)
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
|
||||
JsonNode resnode = JsonHelper.parseBodyLevel1(mdevrel);
|
||||
|
||||
if(resnode==null)
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
|
||||
int code = JsonHelper.getIntValue(resnode,"code");
|
||||
|
||||
JsonNode datanode = JsonHelper.getLevel2(resnode,"data");
|
||||
if(code!=0||datanode==null||!datanode.isArray())
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
for(int i=0;i<datanode.size();i++) {
|
||||
JsonNode rn = datanode.get(i);
|
||||
if(rn==null)
|
||||
continue;
|
||||
long seconds = JsonHelper.getLongValue(rn, "seconds");
|
||||
long total = JsonHelper.getLongValue(rn, "total");
|
||||
String index = JsonHelper.getStringValue(rn, "index");
|
||||
TimeCountInfo tc = new TimeCountInfo();
|
||||
tc.setSeconds((int) seconds);
|
||||
tc.setTotal((int) total);
|
||||
tc.setIndex(index);
|
||||
rellist.add(tc);
|
||||
}
|
||||
rel = new RespEntity(RespCode.SUCCESS,rellist);
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/analyze/mdevonlinecount",method = RequestMethod.POST)
|
||||
public RespEntity mdevOnlineCountAnalyze(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
ArrayList<String> stationnamelist = new ArrayList<String>();
|
||||
ArrayList<CountInfo> rellist = new ArrayList<CountInfo>();
|
||||
ArrayList<TimePoint> tplist = new ArrayList<TimePoint>();
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
|
||||
if (rootnode != null) {
|
||||
FireStationBaseInfoEntity station = (FireStationBaseInfoEntity) SQLTools.getEntityFromJson(rootnode,FireStationBaseInfoEntity.class);
|
||||
if(station==null)
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
List<SQLDataObject> stationlist = null;
|
||||
int pageindex = 0;
|
||||
do {
|
||||
stationlist = stationServices.queryStationList(station, 1000, pageindex);
|
||||
if(stationlist!=null){
|
||||
for(SQLDataObject ob:stationlist){
|
||||
FireStationBaseInfoEntity s = (FireStationBaseInfoEntity)ob;
|
||||
stationnamelist.add(s.getName());
|
||||
}
|
||||
|
||||
}
|
||||
pageindex++;
|
||||
}while(stationlist!=null&&stationlist.size()>=1000);
|
||||
|
||||
|
||||
JsonNode timearray = JsonHelper.getLevel2(rootnode,"time");
|
||||
if(!timearray.isArray())
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
for(int i=0;i<timearray.size();i++) {
|
||||
try {
|
||||
JsonNode tim = timearray.get(i);
|
||||
String timestr = JsonHelper.getStringValue(tim, "time");
|
||||
|
||||
String index = JsonHelper.getStringValue(tim, "index");
|
||||
TimePoint tp = new TimePoint();
|
||||
tp.setTime(timestr);
|
||||
tp.setIndex(index);
|
||||
tplist.add(tp);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// request mdev sys
|
||||
ComplexMutilObject multi = new ComplexMutilObject();
|
||||
multi.setObject0(stationnamelist);
|
||||
multi.setObject1(tplist);
|
||||
String mdevrel = HttpTools.getRespFromHttpServer("https://127.0.0.1:8086/mdev/analyze/deviceonlinecount",JsonHelper.convertObjectToStr(multi));
|
||||
if(mdevrel==null)
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
|
||||
JsonNode resnode = JsonHelper.parseBodyLevel1(mdevrel);
|
||||
|
||||
if(resnode==null)
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
|
||||
int code = JsonHelper.getIntValue(resnode,"code");
|
||||
|
||||
JsonNode datanode = JsonHelper.getLevel2(resnode,"data");
|
||||
if(code!=0||resnode==null||!datanode.isArray())
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
for(int j=0;j<datanode.size();j++) {
|
||||
try {
|
||||
JsonNode nd = datanode.get(j);
|
||||
int count = JsonHelper.getIntValue(nd, "count");
|
||||
int total = JsonHelper.getIntValue(nd, "total");
|
||||
String index = JsonHelper.getStringValue(nd, "index");
|
||||
CountInfo tc = new CountInfo();
|
||||
tc.setCount(count);
|
||||
tc.setTotal(total);
|
||||
tc.setIndex(index);
|
||||
rellist.add(tc);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
rel = new RespEntity(RespCode.SUCCESS,rellist);
|
||||
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/analyze/sensorstatuscount",method = RequestMethod.POST)
|
||||
public RespEntity sensorStatusCountAnalyze(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
ArrayList<String> stationnamelist = new ArrayList<String>();
|
||||
|
||||
HashMap<String ,SensorStatusCount> resultmap = new HashMap<String ,SensorStatusCount>();
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
|
||||
if (rootnode != null) {
|
||||
FireStationBaseInfoEntity station = (FireStationBaseInfoEntity) SQLTools.getEntityFromJson(rootnode, FireStationBaseInfoEntity.class);
|
||||
if (station == null)
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
|
||||
List<SQLDataObject> stationlist = null;
|
||||
int pageindex = 0;
|
||||
do {
|
||||
stationlist = stationServices.queryStationList(station, 1000, pageindex);
|
||||
if(stationlist!=null){
|
||||
for(SQLDataObject ob:stationlist) {
|
||||
FireStationBaseInfoEntity s = (FireStationBaseInfoEntity)ob;
|
||||
stationnamelist.add(s.getName());
|
||||
}
|
||||
}
|
||||
pageindex++;
|
||||
}while(stationlist!=null&&stationlist.size()>=1000);
|
||||
|
||||
for(String sn:stationnamelist){
|
||||
List<SensorDeviceEntity> list = SensorDeviceEntity.QueryByOwner(dataSource,sn);
|
||||
if(list==null||list.size()<=0)
|
||||
continue;
|
||||
|
||||
for(SensorDeviceEntity sensor:list){
|
||||
|
||||
if(sensor==null)
|
||||
continue;
|
||||
|
||||
SensorStatusCount statuscount = resultmap.get(sensor.getDevicetype());
|
||||
if(statuscount==null){
|
||||
statuscount = new SensorStatusCount();
|
||||
resultmap.put(sensor.getDevicetype(),statuscount);
|
||||
statuscount.setType(sensor.getDevicetype());
|
||||
}
|
||||
statuscount.total++;
|
||||
if(sensor.getEnableuse()!=null&&sensor.getEnableuse().equals("use")){
|
||||
String status = sensor.getStatus();
|
||||
if(status==null){
|
||||
statuscount.unknown++;
|
||||
}else if(status.equals("normal")){
|
||||
statuscount.normal++;
|
||||
}else if(status.equals("alarm")){
|
||||
statuscount.alarm++;
|
||||
}else if(status.equals("broken")){
|
||||
statuscount.broken++;
|
||||
}else {
|
||||
statuscount.unknown++;
|
||||
}
|
||||
}else{
|
||||
statuscount.unused++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<SensorStatusCount> rellist = new ArrayList<SensorStatusCount>();
|
||||
for(Map.Entry<String, SensorStatusCount> entry: resultmap.entrySet()){
|
||||
rellist.add(entry.getValue());
|
||||
}
|
||||
rel = new RespEntity(RespCode.SUCCESS,rellist);
|
||||
} catch (Exception e) {
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,379 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.SensorDeviceEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.aiipc.AIIPCPictureMatchSettingEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.aiipc.AIIPCTextMatchSettingEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationMapInfoEntity;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.sql.DataSource;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FireCtrlFileController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
///https://www.genetek.cc:8083/firectrl/file/download?fileName=log_jyiot.log
|
||||
@RequestMapping("/firectrl/file/download")
|
||||
public void download(String fileName, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
//获取文件的绝对路径
|
||||
String realPath = request.getSession().getServletContext().getRealPath("upload");
|
||||
//获取输入流对象(用于读文件)
|
||||
FileInputStream fis = new FileInputStream(new File("./logs", fileName));
|
||||
//获取文件后缀(.txt)
|
||||
String extendFileName = fileName.substring(fileName.lastIndexOf('.'));
|
||||
//动态设置响应类型,根据前台传递文件类型设置响应类型
|
||||
response.setContentType(request.getSession().getServletContext().getMimeType(extendFileName));
|
||||
//设置响应头,attachment表示以附件的形式下载,inline表示在线打开
|
||||
response.setHeader("content-disposition","attachment;fileName="+ URLEncoder.encode(fileName,"UTF-8"));
|
||||
//获取输出流对象(用于写文件)
|
||||
ServletOutputStream os = response.getOutputStream();
|
||||
//下载文件,使用spring框架中的FileCopyUtils工具
|
||||
FileCopyUtils.copy(fis,os);
|
||||
|
||||
}
|
||||
|
||||
///https://www.genetek.cc:8083/firectrl/file/aiipc/download?deviceid=t123456&channel=IPC0&fileName=test1.jpg
|
||||
@RequestMapping(value="/firectrl/file/aiipc/download")
|
||||
public void downloadAIIPC(String deviceid,String channel,String fileName,HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
String path = "./aiipc";
|
||||
|
||||
if(deviceid!=null&&deviceid.length()>0)
|
||||
path += "/"+deviceid;
|
||||
if(channel!=null&&channel.length()>0)
|
||||
path += "/"+channel;
|
||||
//获取输入流对象(用于读文件)
|
||||
FileInputStream fis = new FileInputStream(new File(path, fileName));
|
||||
//获取文件后缀(.txt)
|
||||
String extendFileName = fileName.substring(fileName.lastIndexOf('.'));
|
||||
//动态设置响应类型,根据前台传递文件类型设置响应类型
|
||||
response.setContentType(request.getSession().getServletContext().getMimeType(extendFileName));
|
||||
//设置响应头,attachment表示以附件的形式下载,inline表示在线打开
|
||||
response.setHeader("content-disposition","attachment;fileName="+ URLEncoder.encode(fileName,"UTF-8"));
|
||||
//获取输出流对象(用于写文件)
|
||||
ServletOutputStream os = response.getOutputStream();
|
||||
//下载文件,使用spring框架中的FileCopyUtils工具
|
||||
FileCopyUtils.copy(fis,os);
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value="/firectrl/file/aiipc/matchpicture")
|
||||
public void downloadAIIPCMatchPic(String deviceid,String channel,String fileName,HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
String path = "./aiipc";
|
||||
|
||||
if(deviceid!=null&&deviceid.length()>0)
|
||||
path += "/"+deviceid;
|
||||
if(channel!=null&&channel.length()>0)
|
||||
path += "/"+channel;
|
||||
path += "/match";
|
||||
//获取输入流对象(用于读文件)
|
||||
FileInputStream fis = new FileInputStream(new File(path, fileName));
|
||||
//获取文件后缀(.txt)
|
||||
String extendFileName = fileName.substring(fileName.lastIndexOf('.'));
|
||||
//动态设置响应类型,根据前台传递文件类型设置响应类型
|
||||
response.setContentType(request.getSession().getServletContext().getMimeType(extendFileName));
|
||||
//设置响应头,attachment表示以附件的形式下载,inline表示在线打开
|
||||
response.setHeader("content-disposition","attachment;fileName="+ URLEncoder.encode(fileName,"UTF-8"));
|
||||
//获取输出流对象(用于写文件)
|
||||
ServletOutputStream os = response.getOutputStream();
|
||||
//下载文件,使用spring框架中的FileCopyUtils工具
|
||||
FileCopyUtils.copy(fis,os);
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/firectrl/file/aiipc/upload", method = RequestMethod.POST)
|
||||
public RespEntity uploadFile(@RequestParam("jsondata") String jsondata,@RequestParam("file") MultipartFile file) {
|
||||
String path = "./aiipc";
|
||||
String fileName = file.getOriginalFilename();//获取文件名
|
||||
File dir = new File(path);
|
||||
if(!dir.exists()){
|
||||
dir.mkdir();
|
||||
}
|
||||
|
||||
// if (!jsondata.isEmpty())
|
||||
{
|
||||
try {
|
||||
JsonNode rootnode = JsonHelper.parseBodyLevel1( new String( jsondata.getBytes(),"UTF-8"));
|
||||
if (rootnode != null) {
|
||||
String deviceid = JsonHelper.getStringValue(rootnode,"id");
|
||||
if(deviceid!=null&&deviceid.length()>0)
|
||||
path += "/"+deviceid;
|
||||
dir = new File(path);
|
||||
if(!dir.exists()){
|
||||
dir.mkdir();
|
||||
}
|
||||
String channel = JsonHelper.getStringValue(rootnode,"channel");
|
||||
if(channel!=null&&channel.length()>0)
|
||||
path += "/"+channel;
|
||||
dir = new File(path);
|
||||
if(!dir.exists()){
|
||||
dir.mkdir();
|
||||
}
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
}/* else {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}*/
|
||||
|
||||
if (!file.isEmpty()) {
|
||||
|
||||
try {
|
||||
InputStream ins = file.getInputStream();
|
||||
|
||||
BufferedOutputStream out = new BufferedOutputStream(
|
||||
new FileOutputStream(new File(path + File.separator + fileName)));
|
||||
|
||||
byte[] buffer = new byte[128*1024];
|
||||
int len = 0;
|
||||
while((len = ins.read(buffer)) != -1) {
|
||||
out.write(buffer,0,len);
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
} catch (FileNotFoundException e) {
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
} catch (IOException e) {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
} else {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/firectrl/file/aiipc/uploadmatchpic", method = RequestMethod.POST)
|
||||
public RespEntity uploadMatchPicture(@RequestParam("jsondata") String jsondata,@RequestParam("file") MultipartFile file) {
|
||||
String path = "./aiipc";
|
||||
String fileName = file.getOriginalFilename();//获取文件名
|
||||
File dir = new File(path);
|
||||
if(!dir.exists()){
|
||||
dir.mkdir();
|
||||
}
|
||||
AIIPCPictureMatchSettingEntity setting = null ;
|
||||
// if (!jsondata.isEmpty())
|
||||
{
|
||||
try {
|
||||
JsonNode rootnode = JsonHelper.parseBodyLevel1( new String( jsondata.getBytes(),"UTF-8"));
|
||||
if (rootnode != null) {
|
||||
setting = (AIIPCPictureMatchSettingEntity) SQLTools.getEntityFromJson(rootnode, AIIPCPictureMatchSettingEntity.class);
|
||||
|
||||
if(setting.getDeviceid()==null||setting.getDeviceid().length()<=0||
|
||||
setting.getChannel()==null||setting.getChannel().length()<=0)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
SensorDeviceEntity sensor = SensorDeviceEntity.Query(dataSource,setting.getDeviceid());
|
||||
if(sensor == null)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
|
||||
path += "/"+setting.getDeviceid();
|
||||
dir = new File(path);
|
||||
if(!dir.exists())
|
||||
dir.mkdir();
|
||||
path += "/"+setting.getChannel();
|
||||
dir = new File(path);
|
||||
if(!dir.exists()){
|
||||
dir.mkdir();
|
||||
}
|
||||
path += "/match";
|
||||
dir = new File(path);
|
||||
if(!dir.exists()){
|
||||
dir.mkdir();
|
||||
}
|
||||
|
||||
setting.setImage(fileName);
|
||||
setting.setImage(path+"/"+fileName);
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
}/* else {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}*/
|
||||
|
||||
if(setting.QueryIt(dataSource)!=null)
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
|
||||
setting.setTimestamp(System.currentTimeMillis()/1000);
|
||||
if (!file.isEmpty()) {
|
||||
|
||||
try {
|
||||
InputStream ins = file.getInputStream();
|
||||
|
||||
BufferedOutputStream out = new BufferedOutputStream(
|
||||
new FileOutputStream(new File(path + File.separator + fileName)));
|
||||
|
||||
byte[] buffer = new byte[128*1024];
|
||||
int len = 0;
|
||||
while((len = ins.read(buffer)) != -1) {
|
||||
out.write(buffer,0,len);
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
setting.Insert(dataSource);
|
||||
return new RespEntity(RespCode.SUCCESS,setting);
|
||||
} catch (FileNotFoundException e) {
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
} catch (IOException e) {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
} else {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/firectrl/file/stationmap/upload", method = RequestMethod.POST)
|
||||
public RespEntity uploadStationMapFile(@RequestParam("jsondata") String jsondata,@RequestParam("file") MultipartFile file) {
|
||||
String path = "./stationmap";
|
||||
String fileName = file.getOriginalFilename();//获取文件名
|
||||
File dir = new File(path);
|
||||
if(!dir.exists()){
|
||||
dir.mkdir();
|
||||
}
|
||||
|
||||
// if (!jsondata.isEmpty())
|
||||
{
|
||||
try {
|
||||
JsonNode rootnode = JsonHelper.parseBodyLevel1( new String( jsondata.getBytes(),"UTF-8"));
|
||||
if (rootnode != null) {
|
||||
FireStationMapInfoEntity map = (FireStationMapInfoEntity)SQLTools.getEntityFromJson(rootnode,FireStationMapInfoEntity.class);
|
||||
if(map==null||map.getStation()==null||map.getMapid()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(map.QueryIt(dataSource)!=null)
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
|
||||
if(map.getStation()!=null&&map.getStation().length()>0)
|
||||
path += "/"+map.getStation();
|
||||
dir = new File(path);
|
||||
if(!dir.exists()){
|
||||
dir.mkdir();
|
||||
}
|
||||
fileName = map.getMapid()+".jpg";
|
||||
map.Insert(dataSource);
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
}/* else {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}*/
|
||||
|
||||
if (!file.isEmpty()) {
|
||||
|
||||
try {
|
||||
InputStream ins = file.getInputStream();
|
||||
|
||||
BufferedOutputStream out = new BufferedOutputStream(
|
||||
new FileOutputStream(new File(path + File.separator + fileName)));
|
||||
|
||||
byte[] buffer = new byte[128*1024];
|
||||
int len = 0;
|
||||
while((len = ins.read(buffer)) != -1) {
|
||||
out.write(buffer,0,len);
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
} catch (FileNotFoundException e) {
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
} catch (IOException e) {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
} else {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/firectrl/file/stationmap/upload2", method = RequestMethod.POST)
|
||||
public RespEntity uploadStationMapFileEx(FireStationMapInfoEntity mapinfo,@RequestParam("file") MultipartFile file) {
|
||||
if(mapinfo==null||mapinfo.getStation()==null||mapinfo.getMapid()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
if(mapinfo.QueryIt(dataSource)!=null)
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
|
||||
String path = "./stationmap";
|
||||
String fileName = file.getOriginalFilename();//获取文件名
|
||||
File dir = new File(path);
|
||||
if(!dir.exists()){
|
||||
dir.mkdir();
|
||||
}
|
||||
if(mapinfo.getStation()!=null&&mapinfo.getStation().length()>0)
|
||||
path += "/"+mapinfo.getStation();
|
||||
dir = new File(path);
|
||||
if(!dir.exists()){
|
||||
dir.mkdir();
|
||||
}
|
||||
fileName = mapinfo.getMapid()+".jpg";
|
||||
mapinfo.Insert(dataSource);
|
||||
|
||||
if (!file.isEmpty()) {
|
||||
|
||||
try {
|
||||
InputStream ins = file.getInputStream();
|
||||
|
||||
BufferedOutputStream out = new BufferedOutputStream(
|
||||
new FileOutputStream(new File(path + File.separator + fileName)));
|
||||
|
||||
byte[] buffer = new byte[128*1024];
|
||||
int len = 0;
|
||||
while((len = ins.read(buffer)) != -1) {
|
||||
out.write(buffer,0,len);
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
} catch (FileNotFoundException e) {
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
} catch (IOException e) {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
} else {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
///https://www.genetek.cc:8083/firectrl/file/stationmap/download?station=weizhan&mapid=12333
|
||||
@RequestMapping(value="/firectrl/file/stationmap/download")
|
||||
public void downloadMap(String station,String mapid,HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
String path = "./stationmap";
|
||||
|
||||
if(station!=null&&station.length()>0)
|
||||
path += "/"+station;
|
||||
|
||||
String fileName = mapid+".jpg";
|
||||
//获取输入流对象(用于读文件)
|
||||
FileInputStream fis = new FileInputStream(new File(path, fileName));
|
||||
//获取文件后缀(.txt)
|
||||
String extendFileName = fileName.substring(fileName.lastIndexOf('.'));
|
||||
//动态设置响应类型,根据前台传递文件类型设置响应类型
|
||||
response.setContentType(request.getSession().getServletContext().getMimeType(extendFileName));
|
||||
//设置响应头,attachment表示以附件的形式下载,inline表示在线打开
|
||||
response.setHeader("content-disposition","attachment;fileName="+ URLEncoder.encode(fileName,"UTF-8"));
|
||||
//获取输出流对象(用于写文件)
|
||||
ServletOutputStream os = response.getOutputStream();
|
||||
//下载文件,使用spring框架中的FileCopyUtils工具
|
||||
FileCopyUtils.copy(fis,os);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,500 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.clientmanage.UserAuthorManager;
|
||||
import com.jingyi.iotserver.clientmanage.UserService;
|
||||
import com.jingyi.iotserver.common.service.CountResult;
|
||||
import com.jingyi.iotserver.common.service.EnvConfigService;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.complexquery.RoundInspectTaskResult;
|
||||
import com.jingyi.iotserver.firestationport.model.inspection.InspectStationEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.inspection.RoundInspectionDeviceEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.inspection.RoundInspectionResultEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.inspection.RoundInspectionTaskEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.todev.NoticeEntity;
|
||||
import com.jingyi.iotserver.jpush.JpushClientUtil;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FireCtrlInspectionController {
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private UserAuthorManager userAuthorManager;
|
||||
|
||||
@Autowired
|
||||
private EnvConfigService envConfigService;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/inspect/save",method = RequestMethod.POST)
|
||||
public RespEntity addInspectionTask(HttpServletRequest request) {
|
||||
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
InspectStationEntity task = (InspectStationEntity) SQLTools.getEntityFromJson(rootnode, InspectStationEntity.class);
|
||||
|
||||
if(task==null||task.getNumber()==null||task.getNumber().length()<=0)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
if(InspectStationEntity.Query(dataSource,task.getNumber())!=null)
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
if(task.Insert(dataSource))
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
userAuthorManager.AddUserOperate(request,UserAuthorManager.USER_OPERATE_TYPE_CREATE,"INSPECT_STATION",
|
||||
"添加微站查岗",JsonHelper.convertObjectToStr(task),rel.getCode());
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/inspect/getcount",method = RequestMethod.POST)
|
||||
public RespEntity getInspectionTaskCount(HttpServletRequest request) {
|
||||
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
InspectStationEntity task = (InspectStationEntity) SQLTools.getEntityFromJson(rootnode, InspectStationEntity.class);
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
if(startstr==null||endstr==null)
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
if(task==null)
|
||||
task = new InspectStationEntity();
|
||||
int count = task.queryCount(dataSource,startstr,endstr);
|
||||
return new RespEntity(RespCode.SUCCESS, new CountResult(count));
|
||||
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/inspect/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getInspectionTaskList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
InspectStationEntity task = (InspectStationEntity) SQLTools.getEntityFromJson(rootnode, InspectStationEntity.class);
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 100;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
if(startstr==null||endstr==null)
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
if(task==null)
|
||||
task = new InspectStationEntity();
|
||||
List<SQLDataObject> list = task.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/roundinspect/adddevice",method = RequestMethod.POST)
|
||||
public RespEntity addRoundInspectDevice(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
RoundInspectionDeviceEntity dev = (RoundInspectionDeviceEntity) SQLTools.getEntityFromJson(rootnode, RoundInspectionDeviceEntity.class);
|
||||
|
||||
if(dev==null||dev.getDeviceid()==null||dev.getDeviceid().length()<=0)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
if(dev.QueryIt(dataSource)!=null)
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
if(dev.Insert(dataSource))
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
userAuthorManager.AddUserOperate(request,UserAuthorManager.USER_OPERATE_TYPE_CREATE,"ROUNDINSPECT_DEVICE",
|
||||
"添加巡检设备",JsonHelper.convertObjectToStr(dev),rel.getCode());
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/roundinspect/deldevice",method = RequestMethod.POST)
|
||||
public RespEntity delRoundInspectDevice(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
RoundInspectionDeviceEntity dev = (RoundInspectionDeviceEntity) SQLTools.getEntityFromJson(rootnode, RoundInspectionDeviceEntity.class);
|
||||
|
||||
if(dev==null||dev.getDeviceid()==null||dev.getDeviceid().length()<=0)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
if(dev.QueryIt(dataSource)==null)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
if(dev.Delete(dataSource))
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
userAuthorManager.AddUserOperate(request,UserAuthorManager.USER_OPERATE_TYPE_DELETE,"ROUNDINSPECT_DEVICE",
|
||||
"删除巡检设备",JsonHelper.convertObjectToStr(dev),rel.getCode());
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/roundinspect/updatedevice",method = RequestMethod.POST)
|
||||
public RespEntity updateRoundInspectDevice(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
RoundInspectionDeviceEntity dev = (RoundInspectionDeviceEntity) SQLTools.getEntityFromJson(rootnode, RoundInspectionDeviceEntity.class);
|
||||
|
||||
if(dev==null||dev.getDeviceid()==null||dev.getDeviceid().length()<=0)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
if(dev.QueryIt(dataSource)==null)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
if(dev.Update(dataSource))
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
userAuthorManager.AddUserOperate(request,UserAuthorManager.USER_OPERATE_TYPE_UPDATE,"ROUNDINSPECT_DEVICE",
|
||||
"更新巡检设备信息",JsonHelper.convertObjectToStr(dev),rel.getCode());
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/roundinspect/getdevicecount",method = RequestMethod.POST)
|
||||
public RespEntity getRoundInspectDeviceCount(HttpServletRequest request) {
|
||||
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
RoundInspectionDeviceEntity dev = (RoundInspectionDeviceEntity) SQLTools.getEntityFromJson(rootnode, RoundInspectionDeviceEntity.class);
|
||||
|
||||
if(dev==null)
|
||||
dev = new RoundInspectionDeviceEntity();
|
||||
int count = dev.queryCount(dataSource,null,null);
|
||||
return new RespEntity(RespCode.SUCCESS, new CountResult(count));
|
||||
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/roundinspect/getdevicelist",method = RequestMethod.POST)
|
||||
public RespEntity getRoundInspectDeviceList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
RoundInspectionDeviceEntity dev = (RoundInspectionDeviceEntity) SQLTools.getEntityFromJson(rootnode, RoundInspectionDeviceEntity.class);
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 100;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
if(dev==null)
|
||||
dev = new RoundInspectionDeviceEntity();
|
||||
List<SQLDataObject> list = dev.queryPage(dataSource,null,null,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/roundinspect/addtask",method = RequestMethod.POST)
|
||||
public RespEntity addRoundInspectTask(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
RoundInspectionTaskEntity task = (RoundInspectionTaskEntity) SQLTools.getEntityFromJson(rootnode, RoundInspectionTaskEntity.class);
|
||||
|
||||
if(task==null||task.getTaskid()==null||task.getTaskid().length()<=0)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
if(RoundInspectionTaskEntity.QueryRoundInspectionTask(dataSource,task.getTaskid())!=null)
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
|
||||
task.setTimestamp(new Date());
|
||||
task.setCompletedtime(null);
|
||||
task.setReceivedtime(null);
|
||||
task.setStatus("sent");
|
||||
if(task.Insert(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
try {
|
||||
NoticeEntity notice = new NoticeEntity();
|
||||
notice.setNoticeid("" + System.currentTimeMillis());
|
||||
notice.setTitle("巡检任务");
|
||||
notice.setContent("你站有新的任务,请登录移动设备获取任务,并尽快执行。");
|
||||
notice.setTimestamp(new Date());
|
||||
notice.setSender(task.getSender());
|
||||
String content = JsonHelper.convertObjectToStr(notice);
|
||||
JpushClientUtil.sendMessageToDevice("firectrl", task.getReceiver(), "notify", content, 0);
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}else
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
|
||||
userAuthorManager.AddUserOperate(request,UserAuthorManager.USER_OPERATE_TYPE_UPDATE,"ROUNDINSPECT_TASK",
|
||||
"添加巡检任务",JsonHelper.convertObjectToStr(task),rel.getCode());
|
||||
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/roundinspect/canceltask",method = RequestMethod.POST)
|
||||
public RespEntity cancelRoundInspectTask(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
RoundInspectionTaskEntity task = (RoundInspectionTaskEntity) SQLTools.getEntityFromJson(rootnode, RoundInspectionTaskEntity.class);
|
||||
|
||||
if(task==null||task.getTaskid()==null||task.getTaskid().length()<=0)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
task = RoundInspectionTaskEntity.QueryRoundInspectionTask(dataSource,task.getTaskid());
|
||||
if(task==null)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
if(task.getStatus()!=null&&task.getStatus().equals("completed"))
|
||||
return new RespEntity(RespCode.COMPLETED);
|
||||
|
||||
task.setTimestamp(null);
|
||||
task.setCompletedtime(null);
|
||||
task.setReceivedtime(null);
|
||||
task.setStatus("canceled");
|
||||
if(task.Update(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
try {
|
||||
NoticeEntity notice = new NoticeEntity();
|
||||
notice.setNoticeid("" + System.currentTimeMillis());
|
||||
notice.setTitle("巡检任务");
|
||||
notice.setContent("你站有巡检任务,已被取消。");
|
||||
notice.setTimestamp(new Date());
|
||||
notice.setSender(task.getSender());
|
||||
String content = JsonHelper.convertObjectToStr(notice);
|
||||
JpushClientUtil.sendMessageToDevice("firectrl", task.getReceiver(), "notify", content, 0);
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}else
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
|
||||
userAuthorManager.AddUserOperate(request,UserAuthorManager.USER_OPERATE_TYPE_UPDATE,"ROUNDINSPECT_TASK",
|
||||
"取消巡检任务",JsonHelper.convertObjectToStr(task),rel.getCode());
|
||||
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/roundinspect/gettaskcount",method = RequestMethod.POST)
|
||||
public RespEntity getRoundInspectTaskCount(HttpServletRequest request) {
|
||||
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
RoundInspectionTaskEntity task = (RoundInspectionTaskEntity) SQLTools.getEntityFromJson(rootnode, RoundInspectionTaskEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
if(task==null)
|
||||
task = new RoundInspectionTaskEntity();
|
||||
int count = task.queryCount(dataSource,startstr,endstr);
|
||||
return new RespEntity(RespCode.SUCCESS, new CountResult(count));
|
||||
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/roundinspect/gettasklist",method = RequestMethod.POST)
|
||||
public RespEntity getRoundInspectTaskList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
RoundInspectionTaskEntity task = (RoundInspectionTaskEntity) SQLTools.getEntityFromJson(rootnode, RoundInspectionTaskEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 100;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
if(task==null)
|
||||
task = new RoundInspectionTaskEntity();
|
||||
List<SQLDataObject> list = task.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/roundinspect/getpicturecount",method = RequestMethod.POST)
|
||||
public RespEntity getRoundInspectPictureCount(HttpServletRequest request) {
|
||||
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
RoundInspectionResultEntity task = (RoundInspectionResultEntity) SQLTools.getEntityFromJson(rootnode, RoundInspectionResultEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
if(task==null)
|
||||
task = new RoundInspectionResultEntity();
|
||||
int count = task.queryCount(dataSource,startstr,endstr);
|
||||
return new RespEntity(RespCode.SUCCESS, new CountResult(count));
|
||||
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/roundinspect/getpicturelist",method = RequestMethod.POST)
|
||||
public RespEntity getRoundInspectPictureList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
RoundInspectionResultEntity task = (RoundInspectionResultEntity) SQLTools.getEntityFromJson(rootnode, RoundInspectionResultEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 100;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
if(task==null)
|
||||
task = new RoundInspectionResultEntity();
|
||||
List<SQLDataObject> list = task.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/roundinspect/gettaskresult",method = RequestMethod.POST)
|
||||
public RespEntity getRoundInspectTaskResult(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
String taskid = JsonHelper.getStringValue(rootnode,"taskid");
|
||||
RoundInspectionTaskEntity task = RoundInspectionTaskEntity.QueryRoundInspectionTask(dataSource,taskid);
|
||||
List<RoundInspectionResultEntity> list = RoundInspectionResultEntity.queryTaskResult(dataSource,taskid);
|
||||
if(task==null)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
RoundInspectTaskResult result = new RoundInspectTaskResult();
|
||||
result.setResult(list);
|
||||
result.setTask(task);
|
||||
return new RespEntity(RespCode.SUCCESS, result);
|
||||
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.common.service.CountResult;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationBaseInfoEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireMediaInfoEntity;
|
||||
import com.jingyi.iotserver.firestationport.services.StationServices;
|
||||
import com.jingyi.iotserver.firestationport.services.station.FireStationLiveManager;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FireCtrlMediaController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private StationServices stationServices;
|
||||
|
||||
@Autowired
|
||||
private FireStationLiveManager fireStationLiveManager;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/media/add",method = RequestMethod.POST)
|
||||
public RespEntity addStationMedia(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode == null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
FireMediaInfoEntity mediainfo = (FireMediaInfoEntity) SQLTools.getEntityFromJson(rootnode, FireMediaInfoEntity.class);
|
||||
if(mediainfo==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
FireStationBaseInfoEntity st = FireStationBaseInfoEntity.Query(dataSource,mediainfo.getStation());
|
||||
|
||||
if(st!=null) {
|
||||
mediainfo.setStation(st.getName());
|
||||
}else{
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(mediainfo.Insert(dataSource))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
} catch (Exception e) {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/medida/delete",method = RequestMethod.POST)
|
||||
public RespEntity deleteStationMedia(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode == null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
FireMediaInfoEntity mediainfo = (FireMediaInfoEntity) SQLTools.getEntityFromJson(rootnode, FireMediaInfoEntity.class);
|
||||
if(mediainfo==null||mediainfo.getStation()==null||mediainfo.getCreatetime()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
if(mediainfo.Delete(dataSource))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
} catch (Exception e) {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/media/update",method = RequestMethod.POST)
|
||||
public RespEntity updateStationMedia(HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode == null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
FireMediaInfoEntity mediainfo = (FireMediaInfoEntity) SQLTools.getEntityFromJson(rootnode, FireMediaInfoEntity.class);
|
||||
if(mediainfo==null||mediainfo.getStation()==null||mediainfo.getCreatetime()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
FireStationBaseInfoEntity st = FireStationBaseInfoEntity.Query(dataSource,mediainfo.getStation());
|
||||
if(st!=null) {
|
||||
mediainfo.setStation(st.getName());
|
||||
}else{
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(mediainfo.Update(dataSource))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
} catch (Exception e) {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/media/getcount",method = RequestMethod.POST)
|
||||
public RespEntity getStationMediaCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode == null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
FireMediaInfoEntity mediainfo = (FireMediaInfoEntity) SQLTools.getEntityFromJson(rootnode, FireMediaInfoEntity.class);
|
||||
if(mediainfo==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
int count = mediainfo.queryCount(dataSource,startstr,endstr);
|
||||
CountResult result = new CountResult();
|
||||
result.setCount(count);
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS,result);
|
||||
} catch (Exception e) {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/media/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getStationMediaList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode == null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
FireMediaInfoEntity mediainfo = (FireMediaInfoEntity) SQLTools.getEntityFromJson(rootnode, FireMediaInfoEntity.class);
|
||||
if(mediainfo==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
List<SQLDataObject> list = mediainfo.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
} catch (Exception e) {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,568 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.clientmanage.UserAuthorManager;
|
||||
import com.jingyi.iotserver.clientmanage.UserService;
|
||||
import com.jingyi.iotserver.clientmanage.model.ThirdPlatformInfoEntity;
|
||||
import com.jingyi.iotserver.common.configuration.DruidDataSourceConfig;
|
||||
import com.jingyi.iotserver.common.service.CountResult;
|
||||
import com.jingyi.iotserver.common.service.EnvConfigService;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.mdev.MDevPartnerInfo;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.SensorDeviceEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationBaseInfoEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationStaffInfoEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.equipment.FireStationEquipmentInfoEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.partner.PartnerAlarm;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationAlarmEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.todev.AssignmentEntity;
|
||||
import com.jingyi.iotserver.firestationport.services.SensorService;
|
||||
import com.jingyi.iotserver.firestationport.services.StationServices;
|
||||
import com.jingyi.iotserver.jpush.JpushClientUtil;
|
||||
import com.jingyi.iotserver.mqtt.MessagePublisher;
|
||||
import com.jingyi.iotserver.utils.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.security.PrivateKey;
|
||||
//import java.util.Base64;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FireCtrlPartnerController {
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private UserAuthorManager userAuthorManager;
|
||||
|
||||
@Autowired
|
||||
private EnvConfigService envConfigService;
|
||||
|
||||
@Autowired
|
||||
private StationServices stationServices;
|
||||
|
||||
@Autowired
|
||||
private MessagePublisher messagePublisher;
|
||||
|
||||
@Autowired
|
||||
private SensorService sensorService;
|
||||
|
||||
private boolean checkScope(ThirdPlatformInfoEntity platform,FireStationBaseInfoEntity station){
|
||||
if(platform==null||station==null)
|
||||
return true;
|
||||
|
||||
if(platform.getBrigade()!=null&&platform.getBrigade().length()>1&&station.getBrigade()!=null&&station.getBrigade().length()>1){
|
||||
if(!platform.getBrigade().equals(station.getBrigade()))
|
||||
return false;
|
||||
}
|
||||
|
||||
if(platform.getBorough()!=null&&platform.getBorough().length()>1&&station.getBorough()!=null&&station.getBorough().length()>1){
|
||||
if(!platform.getBorough().equals(station.getBorough()))
|
||||
return false;
|
||||
}
|
||||
|
||||
if(platform.getDetachment()!=null&&platform.getDetachment().length()>1&&station.getDetachment()!=null&&station.getDetachment().length()>1){
|
||||
if(!platform.getDetachment().equals(station.getDetachment()))
|
||||
return false;
|
||||
}
|
||||
|
||||
if(platform.getStation()!=null&&platform.getStation().length()>1&&station.getName()!=null&&station.getName().length()>1){
|
||||
if(!platform.getStation().equals(station.getName()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean setScope(ThirdPlatformInfoEntity platform,FireStationBaseInfoEntity station){
|
||||
if(platform==null||station==null)
|
||||
return false;
|
||||
if(platform.getBrigade()!=null&&platform.getBrigade().length()>1)
|
||||
station.setBrigade(platform.getBrigade());
|
||||
|
||||
|
||||
if(platform.getBorough()!=null&&platform.getBorough().length()>1)
|
||||
station.setBorough(platform.getBorough());
|
||||
|
||||
|
||||
if(platform.getDetachment()!=null&&platform.getDetachment().length()>1)
|
||||
station.setDetachment(platform.getDetachment());
|
||||
|
||||
return true;
|
||||
}
|
||||
private boolean setScope(ThirdPlatformInfoEntity platform,FireStationAlarmEntity station){
|
||||
if(platform==null||station==null)
|
||||
return false;
|
||||
if(platform.getBrigade()!=null&&platform.getBrigade().length()>1)
|
||||
station.setBrigade(platform.getBrigade());
|
||||
|
||||
|
||||
if(platform.getBorough()!=null&&platform.getBorough().length()>1)
|
||||
station.setBorough(platform.getBorough());
|
||||
|
||||
|
||||
if(platform.getDetachment()!=null&&platform.getDetachment().length()>1)
|
||||
station.setDetachment(platform.getDetachment());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/partner/getstation",method = RequestMethod.POST)
|
||||
public RespEntity getStation(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
String sessionid = request.getHeader("authorization");
|
||||
ThirdPlatformInfoEntity platform = new ThirdPlatformInfoEntity();
|
||||
platform.setAppkey(sessionid);
|
||||
platform = (ThirdPlatformInfoEntity)platform.QueryIt(dataSource);
|
||||
if(platform==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
FireStationBaseInfoEntity station = (FireStationBaseInfoEntity) SQLTools.getEntityFromJson(rootnode,FireStationBaseInfoEntity.class);
|
||||
|
||||
if(station==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
try {
|
||||
FireStationBaseInfoEntity st = FireStationBaseInfoEntity.Query(dataSource,station.getName());
|
||||
if(st!=null&&checkScope(platform,st))
|
||||
rel = new RespEntity(RespCode.SUCCESS, st);
|
||||
else
|
||||
rel = new RespEntity(RespCode.NOTEXIST, null);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/partner/getstationcount",method = RequestMethod.POST)
|
||||
public RespEntity getStationCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
String sessionid = request.getHeader("authorization");
|
||||
ThirdPlatformInfoEntity platform = new ThirdPlatformInfoEntity();
|
||||
platform.setAppkey(sessionid);
|
||||
platform = (ThirdPlatformInfoEntity)platform.QueryIt(dataSource);
|
||||
if(platform==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
FireStationBaseInfoEntity station = (FireStationBaseInfoEntity)SQLTools.getEntityFromJson(rootnode,FireStationBaseInfoEntity.class);
|
||||
try {
|
||||
if(station==null)
|
||||
station = new FireStationBaseInfoEntity();
|
||||
setScope(platform,station);
|
||||
|
||||
int count = stationServices.queryStationCount(station);
|
||||
CountResult countobj = new CountResult();
|
||||
countobj.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,countobj);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/partner/getstationlist",method = RequestMethod.POST)
|
||||
public RespEntity getStationList(HttpServletRequest request) {
|
||||
long start = System.currentTimeMillis();
|
||||
RespEntity rel = null;
|
||||
String sessionid = request.getHeader("authorization");
|
||||
ThirdPlatformInfoEntity platform = new ThirdPlatformInfoEntity();
|
||||
platform.setAppkey(sessionid);
|
||||
platform = (ThirdPlatformInfoEntity)platform.QueryIt(dataSource);
|
||||
if(platform==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
FireStationBaseInfoEntity station = (FireStationBaseInfoEntity)SQLTools.getEntityFromJson(rootnode,FireStationBaseInfoEntity.class);
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
|
||||
try {
|
||||
if(station==null)
|
||||
station = new FireStationBaseInfoEntity();
|
||||
setScope(platform,station);
|
||||
List<SQLDataObject> list = stationServices.queryStationList(station,pagesize,pageindex);
|
||||
|
||||
rel = new RespEntity(RespCode.SUCCESS,list);
|
||||
System.out.println("query station use time: "+((System.currentTimeMillis()-start))+" milliseconds count="+list.size());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
System.out.println("query station fail use time: "+((System.currentTimeMillis()-start))+" milliseconds");
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/partner/getstationstaff",method = RequestMethod.POST)
|
||||
public RespEntity getStationStaff(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
String sessionid = request.getHeader("authorization");
|
||||
ThirdPlatformInfoEntity platform = new ThirdPlatformInfoEntity();
|
||||
platform.setAppkey(sessionid);
|
||||
platform = (ThirdPlatformInfoEntity)platform.QueryIt(dataSource);
|
||||
if(platform==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
FireStationBaseInfoEntity station = (FireStationBaseInfoEntity)SQLTools.getEntityFromJson(rootnode,FireStationBaseInfoEntity.class);
|
||||
|
||||
if(station==null||!checkScope(platform,station))
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
try {
|
||||
FireStationStaffInfoEntity st = new FireStationStaffInfoEntity();
|
||||
st.setStationName(station.getName());
|
||||
List<SQLDataObject> list = st.queryList(dataSource,null,null);
|
||||
for(SQLDataObject ob:list){
|
||||
FireStationStaffInfoEntity staff = (FireStationStaffInfoEntity)ob;
|
||||
if(staff!=null)
|
||||
staff.setPassword(null);
|
||||
}
|
||||
if(list!=null)
|
||||
rel = new RespEntity(RespCode.SUCCESS, list);
|
||||
else
|
||||
rel = new RespEntity(RespCode.FAIL, station);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/partner/getstationequipment",method = RequestMethod.POST)
|
||||
public RespEntity getStationEquipment(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
String sessionid = request.getHeader("authorization");
|
||||
ThirdPlatformInfoEntity platform = new ThirdPlatformInfoEntity();
|
||||
platform.setAppkey(sessionid);
|
||||
platform = (ThirdPlatformInfoEntity)platform.QueryIt(dataSource);
|
||||
if(platform==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
FireStationBaseInfoEntity station = (FireStationBaseInfoEntity)SQLTools.getEntityFromJson(rootnode,FireStationBaseInfoEntity.class);
|
||||
|
||||
if(station==null||!checkScope(platform,station))
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
try {
|
||||
List<FireStationEquipmentInfoEntity> equiplist = null;
|
||||
if(station.getName()!=null){
|
||||
equiplist = stationServices.queryStationEquipmentByName(station.getName());
|
||||
}
|
||||
else if(station.getDevice_id()!=null){
|
||||
equiplist = stationServices.queryStationEquipmentByDeviceID(station.getDevice_id());
|
||||
}else{
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(equiplist!=null)
|
||||
rel = new RespEntity(RespCode.SUCCESS, equiplist);
|
||||
else
|
||||
rel = new RespEntity(RespCode.FAIL, station);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/partner/alarm/querycount",method = RequestMethod.POST)
|
||||
public RespEntity queryStationAlarmCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
String sessionid = request.getHeader("authorization");
|
||||
ThirdPlatformInfoEntity platform = new ThirdPlatformInfoEntity();
|
||||
platform.setAppkey(sessionid);
|
||||
platform = (ThirdPlatformInfoEntity)platform.QueryIt(dataSource);
|
||||
if(platform==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
FireStationAlarmEntity alarm = (FireStationAlarmEntity)SQLTools.getEntityFromJson(rootnode,FireStationAlarmEntity.class);
|
||||
setScope(platform,alarm);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
int count = alarm.queryCount(dataSource,startstr,endstr);
|
||||
CountResult countobj = new CountResult();
|
||||
countobj.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,countobj);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/partner/alarm/querylist",method = RequestMethod.POST)
|
||||
public RespEntity queryStationAlarmList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
String sessionid = request.getHeader("authorization");
|
||||
ThirdPlatformInfoEntity platform = new ThirdPlatformInfoEntity();
|
||||
platform.setAppkey(sessionid);
|
||||
platform = (ThirdPlatformInfoEntity)platform.QueryIt(dataSource);
|
||||
if(platform==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
FireStationAlarmEntity alarm = (FireStationAlarmEntity)SQLTools.getEntityFromJson(rootnode,FireStationAlarmEntity.class);
|
||||
setScope(platform,alarm);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = alarm.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/partner/alarm/add",method = RequestMethod.POST)
|
||||
public RespEntity addPartnerAlarm(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
String sessionid = request.getHeader("authorization");
|
||||
ThirdPlatformInfoEntity platform = new ThirdPlatformInfoEntity();
|
||||
platform.setAppkey(sessionid);
|
||||
platform = (ThirdPlatformInfoEntity)platform.QueryIt(dataSource);
|
||||
if(platform==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
PartnerAlarm alarm = (PartnerAlarm)SQLTools.getEntityFromJson(rootnode,PartnerAlarm.class);
|
||||
alarm.setParterid(platform.getId());
|
||||
alarm.setTimestamp(new Date());
|
||||
|
||||
FireStationBaseInfoEntity st = FireStationBaseInfoEntity.Query(dataSource,alarm.getName());
|
||||
if(st!=null&&checkScope(platform,st)){
|
||||
if(alarm.Insert(dataSource)) {
|
||||
String content = JsonHelper.convertObjectToStr(alarm);
|
||||
JpushClientUtil.sendMessageToDevice("firectrl", alarm.getName(), "partneralarm", content, 0);
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
}else
|
||||
return new RespEntity(RespCode.NOTEXIST, null);
|
||||
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
String pubkey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCab9tZU7qVJsaVDFBOettyhi3Cxf9j9lYsp+VgXsPKcSWAVJq1fOyS2zCQjQrVxZbfXvub8ik93jTBXzXUhVCG+jXG202aNKC5uPgbo2IwAGU/8hr4o/Bj9fR1LCNr3uyYN/6GF+Fm/cEoKFWLkRl51EDxVorUirMNNwjLlbQ7vwIDAQAB";
|
||||
String prikey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJpv21lTupUmxpUMUE5623KGLcLF/2P2Viyn5WBew8pxJYBUmrV87JLbMJCNCtXFlt9e+5vyKT3eNMFfNdSFUIb6NcbbTZo0oLm4+BujYjAAZT/yGvij8GP19HUsI2ve7Jg3/oYX4Wb9wSgoVYuRGXnUQPFWitSKsw03CMuVtDu/AgMBAAECgYBh+44DgqficZOUhRd+c1w/sPnflZePaH8MHgndtsIp8teEMCln9DZ0hjStwY6aSp6KYczpCB86bXyzIyEYEO0hd87vQxrQH8wvLnQlXqBUGMG3IjEPUr25xhQFRVl8SNG3Bk5im0WUXcxQJxwS/514G5fADuKBpqIuspMS0XMYIQJBAOG7M5A84Oi4FdrO++u0U2WVOIl9RRPmY5c6rltFJ/XfihOgWz8ISaGhqO2PVZdh+hgZgZEI1D+iUcQ53kOVlV0CQQCvJUwIuz9Z3thCIG57oKUQTEYigEmE4GDWCJZ21rgi/I5TnmoHwwa7NF5t/1uO+sHzd7k34q8wUjuBYHDTskfLAkEAmzHbt7VDZHz7+Z4JMfqew96eKlkIHzBtFFJyAapAWRlBk1DSqzmFdizxObMsQ5JHIj6XCCIr2zw8P08R8yFquQJAWntZMXWSv9n5PQhGK4YNYEMXRIGj+Yp1XH1pRhGdZS22VYqUWlgtpQ7j7c2rPk1bX20teaqZOMxyw17QSv1iSwJAMTTq0frkipqCcz6zUSK5gShS4lsZirvEAlJUJ0vexi+wmIEohaXHGJRoy63tAUzU2pJCTTJG9bWhmYkueOf4nA==";
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/partner/assign",method = RequestMethod.POST)
|
||||
public String PartnerSendAssign(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
try {
|
||||
String body = HttpTools.getBodyFromRequest(request);
|
||||
String json = new String(Base64.decodeBase64(body),"UTF-8");
|
||||
JsonNode rootnode = JsonHelper.parseBodyLevel1(json);
|
||||
String reqSecret = JsonHelper.getStringValue(rootnode,"reqSecret");
|
||||
String reqInfo = JsonHelper.getStringValue(rootnode,"reqInfo");
|
||||
|
||||
if(reqSecret==null||reqInfo==null)
|
||||
return "{\"code\": \"fail\",\"message\": \"错误参数\"}";
|
||||
PrivateKey pkeyobj= RSAUtil.string2PrivateKey(prikey);
|
||||
|
||||
String deskey = new String(RSAUtil.privateDecrypt(Base64.decodeBase64(reqSecret),pkeyobj));
|
||||
|
||||
String src = TriDESEncryptUtil.Base64DESDecrypt2ByteString(deskey, reqInfo);
|
||||
|
||||
rootnode = JsonHelper.parseBodyLevel1(src);
|
||||
|
||||
String station = JsonHelper.getStringValue(rootnode,"id");
|
||||
String warnId = JsonHelper.getStringValue(rootnode,"warnId");
|
||||
String address = JsonHelper.getStringValue(rootnode,"address");
|
||||
String time = JsonHelper.getStringValue(rootnode,"time");
|
||||
String type = JsonHelper.getStringValue(rootnode,"type");
|
||||
String brigade = JsonHelper.getStringValue(rootnode,"brigade");
|
||||
String description = JsonHelper.getStringValue(rootnode,"description");
|
||||
double longitude = 0.0;
|
||||
String str = JsonHelper.getStringValue(rootnode,"longitude");
|
||||
if(str!=null)
|
||||
longitude = Double.parseDouble(str);
|
||||
double latitude = 0.0;
|
||||
str = JsonHelper.getStringValue(rootnode,"latitude");
|
||||
if(str!=null)
|
||||
latitude = Double.parseDouble(str);
|
||||
|
||||
FireStationBaseInfoEntity st = (FireStationBaseInfoEntity)FireStationBaseInfoEntity.QueryByDeviceID(dataSource,station);
|
||||
if(st==null)
|
||||
return "{\"code\": \"fail\",\"message\": \"微站不存在\"}";
|
||||
AssignmentEntity assignment = new AssignmentEntity();
|
||||
assignment.setReceiver(st.getName());
|
||||
assignment.setSendtype("toclient");
|
||||
assignment.setAssignmentid("ca-"+warnId);
|
||||
assignment.setTitle(warnId);
|
||||
assignment.setContent(description);
|
||||
assignment.setSender("CA-platform");
|
||||
assignment.setType(type);
|
||||
assignment.setTimestamp(new Date());
|
||||
assignment.setBrigade(brigade);
|
||||
assignment.setLongitude(longitude);
|
||||
assignment.setLatitude(latitude);
|
||||
assignment.setAddress(address);
|
||||
if(assignment.QueryIt(dataSource)!=null){
|
||||
return "{\"code\": \"fail\",\"message\": \"任务已经存在\"}";
|
||||
}
|
||||
if(!assignment.Insert(dataSource)){
|
||||
return "{\"code\": \"fail\",\"message\": \"写数据库失败\"}";
|
||||
}
|
||||
String content = JsonHelper.convertObjectToStr(assignment);
|
||||
JpushClientUtil.sendMessageToDevice("firectrl", st.getName(), "assignment", content, 24*60*60);
|
||||
|
||||
return "{\"code\": \"success\",\"message\": \"请求成功\"}";
|
||||
}catch (Exception e){
|
||||
return "{\"code\": \"fail\",\"message\": \"内部异常\"}";
|
||||
}
|
||||
//
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/rmttranfer/sendmessage", method = RequestMethod.POST)
|
||||
public RespEntity sendMQTT(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
String receiver = JsonHelper.getStringValue(rootnode, "receiver");
|
||||
String message = JsonHelper.getStringValue(rootnode, "message");
|
||||
|
||||
try {
|
||||
messagePublisher.sendMessage(receiver+"_rtmtranfer",message);
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/partner/getsensorcount",method = RequestMethod.POST)
|
||||
public RespEntity getMDevPartnerSensorCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode == null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
String appkey = JsonHelper.getStringValue(rootnode,"appkey");
|
||||
String station = JsonHelper.getStringValue(rootnode,"station");
|
||||
MDevPartnerInfo p = (MDevPartnerInfo) SQLTools.getEntityFromJson(rootnode, MDevPartnerInfo.class);
|
||||
if(p==null||p.getPartner()==null||station==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
DruidDataSourceConfig config = (DruidDataSourceConfig) SpringContextUtil.getBean(DruidDataSourceConfig.class);
|
||||
DataSource ds = config.getMDevDataSource();
|
||||
p = (MDevPartnerInfo)p.QueryIt(ds);
|
||||
if(p==null||!p.getStation().contains(station))
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
|
||||
if(!p.getAppkey().equals(appkey))
|
||||
return new RespEntity(RespCode.NOAUTHOR);
|
||||
|
||||
try {
|
||||
SensorDeviceEntity sensor = (SensorDeviceEntity) SQLTools.getEntityFromJson(rootnode,SensorDeviceEntity.class);
|
||||
if(sensor==null)
|
||||
sensor = new SensorDeviceEntity();
|
||||
if(sensor.getOwner()==null)
|
||||
sensor.setOwner(station);
|
||||
int count = sensorService.querySensorCount(sensor);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/partner/getsensorpage",method = RequestMethod.POST)
|
||||
public RespEntity getMDevPartnerSensorList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode == null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
String partner = JsonHelper.getStringValue(rootnode,"partner");
|
||||
|
||||
String appkey = JsonHelper.getStringValue(rootnode,"appkey");
|
||||
String station = JsonHelper.getStringValue(rootnode,"station");
|
||||
MDevPartnerInfo p = (MDevPartnerInfo) SQLTools.getEntityFromJson(rootnode, MDevPartnerInfo.class);
|
||||
if(p==null||p.getPartner()==null||station==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
DruidDataSourceConfig config = (DruidDataSourceConfig) SpringContextUtil.getBean(DruidDataSourceConfig.class);
|
||||
DataSource ds = config.getMDevDataSource();
|
||||
p = (MDevPartnerInfo)p.QueryIt(ds);
|
||||
if(p==null||!p.getStation().contains(station))
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
if(!p.getAppkey().equals(appkey))
|
||||
return new RespEntity(RespCode.NOAUTHOR);
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
SensorDeviceEntity sensor = (SensorDeviceEntity)SQLTools.getEntityFromJson(rootnode,SensorDeviceEntity.class);
|
||||
if(sensor==null)
|
||||
sensor = new SensorDeviceEntity();
|
||||
if(sensor.getOwner()==null)
|
||||
sensor.setOwner(station);
|
||||
List<SQLDataObject> list = sensorService.querySensorPage(pagesize,pageindex,sensor);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,247 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.clientmanage.ClientRuningInfo;
|
||||
import com.jingyi.iotserver.clientmanage.UserAuthorManager;
|
||||
import com.jingyi.iotserver.clientmanage.UserService;
|
||||
import com.jingyi.iotserver.clientmanage.model.BoroughEntity;
|
||||
import com.jingyi.iotserver.clientmanage.model.DetachmentEntity;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.talk.TalkPlatformAccountInfo;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FireCtrlTalkController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private UserAuthorManager userAuthorManager;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/talk/addplatformaccount",method = RequestMethod.POST)
|
||||
public RespEntity addPlatformAccount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
|
||||
try {
|
||||
TalkPlatformAccountInfo info = (TalkPlatformAccountInfo) SQLTools.getEntityFromJson(rootnode,TalkPlatformAccountInfo.class);
|
||||
if(info==null)
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
else{
|
||||
if(info.QueryIt(dataSource)!=null)
|
||||
rel = new RespEntity(RespCode.EXIST);
|
||||
else{
|
||||
if(info.Insert(dataSource))
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
userAuthorManager.AddUserOperate(request, UserAuthorManager.USER_OPERATE_TYPE_CREATE,"TALKACCOUNT",
|
||||
"添加对讲企业号", JsonHelper.convertObjectToStr(info),rel.getCode());
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/talk/getplatformaccount",method = RequestMethod.POST)
|
||||
public RespEntity getPlatformAccount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
String sessionid = request.getHeader("authorization");
|
||||
|
||||
ClientRuningInfo userinfo = userAuthorManager.getUserInfo(sessionid);
|
||||
if(userinfo==null)
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
|
||||
String level = userinfo.getScopelevel();
|
||||
String levelval = userinfo.getLevelvalue();
|
||||
if(level==null||levelval==null){
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
TalkPlatformAccountInfo account = new TalkPlatformAccountInfo();
|
||||
List<SQLDataObject> alist = null;
|
||||
|
||||
if(level.equals("detachment")){
|
||||
account.setScopelevel("detachment");
|
||||
account.setLevelvalue(levelval);
|
||||
alist = account.queryList(dataSource,null,null);
|
||||
|
||||
if(alist==null||alist.size()<=0)
|
||||
{
|
||||
DetachmentEntity detachment = new DetachmentEntity();
|
||||
detachment.setDetachment(levelval);
|
||||
detachment = (DetachmentEntity)detachment.QueryIt(dataSource);
|
||||
if(detachment!=null){
|
||||
account.setScopelevel("borough");
|
||||
account.setLevelvalue(detachment.getBorough());
|
||||
alist = account.queryList(dataSource,null,null);
|
||||
|
||||
if(alist==null||alist.size()<=0){
|
||||
if(detachment.getBrigade()==null){
|
||||
BoroughEntity b = new BoroughEntity();
|
||||
b.setBorough(detachment.getBorough());
|
||||
b = (BoroughEntity)b.QueryIt(dataSource);
|
||||
if(b!=null){
|
||||
detachment.setBrigade(b.getBrigade());
|
||||
}
|
||||
}
|
||||
account.setScopelevel("brigade");
|
||||
account.setLevelvalue(detachment.getBrigade());
|
||||
alist = account.queryList(dataSource,null,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if(level.equals("borough")){
|
||||
account.setScopelevel("borough");
|
||||
account.setLevelvalue(levelval);
|
||||
alist = account.queryList(dataSource,null,null);
|
||||
if(alist==null||alist.size()<=0){
|
||||
BoroughEntity b = new BoroughEntity();
|
||||
b.setBorough(account.getLevelvalue());
|
||||
b = (BoroughEntity)b.QueryIt(dataSource);
|
||||
if(b!=null){
|
||||
account.setScopelevel("brigade");
|
||||
account.setLevelvalue(b.getBrigade());
|
||||
alist = account.queryList(dataSource,null,null);
|
||||
}
|
||||
|
||||
}
|
||||
}else if(level.equals("brigade")){
|
||||
account.setScopelevel("brigade");
|
||||
account.setLevelvalue(account.getLevelvalue());
|
||||
alist = account.queryList(dataSource,null,null);
|
||||
}
|
||||
|
||||
if(alist!=null&&alist.size()>0)
|
||||
return new RespEntity(RespCode.SUCCESS,alist.get(0));
|
||||
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/talk/deleteplatformaccount",method = RequestMethod.POST)
|
||||
public RespEntity deletePlatformAccount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
|
||||
try {
|
||||
TalkPlatformAccountInfo info = (TalkPlatformAccountInfo)SQLTools.getEntityFromJson(rootnode,TalkPlatformAccountInfo.class);
|
||||
if(info==null)
|
||||
rel = new RespEntity(RespCode.NOTEXIST);
|
||||
else{
|
||||
if(info.QueryIt(dataSource)==null)
|
||||
rel = new RespEntity(RespCode.NOTEXIST);
|
||||
else{
|
||||
if(info.Delete(dataSource))
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
userAuthorManager.AddUserOperate(request,UserAuthorManager.USER_OPERATE_TYPE_DELETE,"TALKACCOUNT",
|
||||
"删除对讲企业账号",JsonHelper.convertObjectToStr(info),rel.getCode());
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/talk/updatetalkplatfomraccount",method = RequestMethod.POST)
|
||||
public RespEntity updatePlatformAccount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
|
||||
try {
|
||||
TalkPlatformAccountInfo info = (TalkPlatformAccountInfo)SQLTools.getEntityFromJson(rootnode,TalkPlatformAccountInfo.class);
|
||||
if(info==null)
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
else{
|
||||
if(info.QueryIt(dataSource)==null)
|
||||
rel = new RespEntity(RespCode.NOTEXIST);
|
||||
else{
|
||||
if(info.Update(dataSource))
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
userAuthorManager.AddUserOperate(request,UserAuthorManager.USER_OPERATE_TYPE_UPDATE,"TALKACCOUNT",
|
||||
"更新对讲企业账号信息",JsonHelper.convertObjectToStr(info),rel.getCode());
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/talk/gettalkplatfomraccountlist",method = RequestMethod.POST)
|
||||
public RespEntity getPlatformAccountList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
|
||||
try {
|
||||
TalkPlatformAccountInfo info = (TalkPlatformAccountInfo)SQLTools.getEntityFromJson(rootnode,TalkPlatformAccountInfo.class);
|
||||
if(info==null)
|
||||
info = new TalkPlatformAccountInfo();
|
||||
|
||||
List<SQLDataObject> list = info.queryList(dataSource,null,null);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,290 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.DeviceRequestEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationBaseInfoEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationVideoConfigEntity;
|
||||
import com.jingyi.iotserver.firestationport.services.StationServices;
|
||||
import com.jingyi.iotserver.firestationport.services.netease.NeteaseVideoManager;
|
||||
import com.jingyi.iotserver.firestationport.services.netease.NeteaseVideoService;
|
||||
import com.jingyi.iotserver.firestationport.services.station.FireStationLiveManager;
|
||||
import com.jingyi.iotserver.jpush.JpushClientUtil;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Date;
|
||||
|
||||
//http://dev.netease.im/docs/product/直播/服务端API文档
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FireCtrlVideoController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private StationServices stationServices;
|
||||
|
||||
@Autowired
|
||||
private NeteaseVideoService neteaseVideoService;
|
||||
|
||||
@Autowired
|
||||
private NeteaseVideoManager neteaseVideoManager;
|
||||
|
||||
@Autowired
|
||||
private FireStationLiveManager fireStationLiveManager;
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/video/createchannel",method = RequestMethod.POST)
|
||||
public RespEntity createChannel(HttpServletRequest request) {
|
||||
RespEntity rel = executeOperateOnStation(request,new IFireStationOperate(){
|
||||
@Override
|
||||
public RespEntity ExecuteOperate(FireStationBaseInfoEntity station,Object param) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
rel = neteaseVideoService.createVideoChannel(station);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
});
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/video/deletechannel",method = RequestMethod.POST)
|
||||
public RespEntity deleteChannel(HttpServletRequest request) {
|
||||
RespEntity rel = executeOperateOnStation(request,new IFireStationOperate(){
|
||||
@Override
|
||||
public RespEntity ExecuteOperate(FireStationBaseInfoEntity station,Object param) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
rel = neteaseVideoService.deleteVideoChannel(station);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
});
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/video/getchannel",method = RequestMethod.POST)
|
||||
public RespEntity getChannel(HttpServletRequest request) {
|
||||
RespEntity rel = executeOperateOnStation(request,new IFireStationOperate(){
|
||||
@Override
|
||||
public RespEntity ExecuteOperate(FireStationBaseInfoEntity station,Object param) {
|
||||
JsonNode jsonroot = (JsonNode)param;
|
||||
FireStationVideoConfigEntity videoconfig = FireStationVideoConfigEntity.Query(dataSource,station.getName(), "netease");
|
||||
if (videoconfig != null)
|
||||
return new RespEntity(RespCode.SUCCESS, videoconfig);
|
||||
else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
});
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/video/syncchannel")
|
||||
public RespEntity syncChannel(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
neteaseVideoService.syncVideoConfigList();
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
|
||||
private RespEntity executeOperateOnStation(HttpServletRequest request,IFireStationOperate op){
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
String json = HttpTools.getBodyFromRequest(request);
|
||||
if (json != null) {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
JsonNode rootnode = mapper.readTree(json);
|
||||
if (rootnode == null)
|
||||
return new RespEntity(RespCode.FAIL, null);
|
||||
JsonNode m = rootnode.findValue("stationname");
|
||||
if(m==null)
|
||||
m = rootnode.findValue("name");
|
||||
if(m==null){
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
return rel;
|
||||
}
|
||||
String stationname = m.asText();
|
||||
|
||||
FireStationBaseInfoEntity station = FireStationBaseInfoEntity.Query(dataSource,stationname);
|
||||
|
||||
if(station==null)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
|
||||
rel = op.ExecuteOperate(station,rootnode);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}else
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/video/reportvideostatus")
|
||||
public RespEntity reportVideoStatus(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
String json = HttpTools.getBodyFromRequest(request);
|
||||
if (json != null) {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
DeviceRequestEntity reqinfo = parseRequestCMD(json);
|
||||
|
||||
if(reqinfo!=null){
|
||||
FireStationBaseInfoEntity station = null;
|
||||
if(reqinfo.getDeviceId()!=null)
|
||||
station = FireStationBaseInfoEntity.QueryByDeviceID(dataSource,reqinfo.getDeviceId());
|
||||
else if(reqinfo.getUserName()!=null)
|
||||
station = FireStationBaseInfoEntity.Query(dataSource,reqinfo.getUserName());
|
||||
if(station!=null) {
|
||||
if(reqinfo.getCID()==2016){
|
||||
//open
|
||||
neteaseVideoManager.StationVideoStart(station.getName());
|
||||
fireStationLiveManager.setVideoState(station.getName(),"open");
|
||||
}else if(reqinfo.getCID()==2017){
|
||||
//close
|
||||
neteaseVideoManager.StationVideoStop(station.getName());
|
||||
fireStationLiveManager.setVideoState(station.getName(),"close");
|
||||
}
|
||||
rel = new RespEntity(RespCode.SUCCESS,reqinfo.getCID());
|
||||
}else
|
||||
rel = new RespEntity(RespCode.NOTEXIST,reqinfo.getCID());
|
||||
|
||||
}else{
|
||||
rel = new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
private DeviceRequestEntity parseRequestCMD(String json){
|
||||
DeviceRequestEntity rel = null;
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
JsonNode rootnode = mapper.readTree(json);
|
||||
if(rootnode==null)
|
||||
return null;
|
||||
JsonNode m = rootnode.findValue("Mark");
|
||||
String mark = m.asText();
|
||||
|
||||
JsonNode u = rootnode.findValue("UserName");
|
||||
String username = null;
|
||||
if(u!=null)
|
||||
username = u.asText();
|
||||
|
||||
JsonNode d = rootnode.findValue("DeviceId");
|
||||
String deviceid =null;
|
||||
if(d!=null)
|
||||
deviceid = d.asText();
|
||||
|
||||
JsonNode c = rootnode.findValue("CID");
|
||||
int cid = Integer.parseInt(c.asText());
|
||||
JsonNode p = rootnode.findValue("PTS");
|
||||
long pts = Long.parseLong(p.asText());
|
||||
|
||||
JsonNode data = rootnode.findValue("data");
|
||||
|
||||
rel = new DeviceRequestEntity();
|
||||
rel.setCID(cid);
|
||||
rel.setDeviceId(deviceid);
|
||||
rel.setMark(mark);
|
||||
rel.setPTS(pts);
|
||||
rel.setUserName(username);
|
||||
if(data!=null){
|
||||
rel.setData(data.asText());
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return rel;
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/video/openvideo",method = RequestMethod.POST)
|
||||
public RespEntity startVideoTalk(HttpServletRequest request) {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
|
||||
String brigade = JsonHelper.getStringValue(rootnode,"brigade");
|
||||
String borough = JsonHelper.getStringValue(rootnode,"borough");
|
||||
String detachment = JsonHelper.getStringValue(rootnode,"detachment");
|
||||
String name = JsonHelper.getStringValue(rootnode,"station");
|
||||
FireStationBaseInfoEntity station = null;
|
||||
station = FireStationBaseInfoEntity.Query(dataSource,name);
|
||||
if(station==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
String content = "{";
|
||||
|
||||
if(detachment!=null)
|
||||
content += "\"detachment\":\""+detachment+"\",\"timestamp\":\""+SQLTools.formatDate(new Date())+"\"}";
|
||||
else if(borough!=null)
|
||||
content += "\"borough\":\""+borough+"\",\"timestamp\":\""+SQLTools.formatDate(new Date())+"\"}";
|
||||
else if(brigade!=null)
|
||||
content += "\"brigade\":\""+brigade+"\",\"timestamp\":\""+SQLTools.formatDate(new Date())+"\"}";
|
||||
else
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
JpushClientUtil.sendMessageToDevice("firectrl", name, "openvideo", content, 0);
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/video/closevideo",method = RequestMethod.POST)
|
||||
public RespEntity stopVideoTalk(HttpServletRequest request) {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
|
||||
String brigade = JsonHelper.getStringValue(rootnode,"brigade");
|
||||
String borough = JsonHelper.getStringValue(rootnode,"borough");
|
||||
String detachment = JsonHelper.getStringValue(rootnode,"detachment");
|
||||
String name = JsonHelper.getStringValue(rootnode,"station");
|
||||
FireStationBaseInfoEntity station = null;
|
||||
station = FireStationBaseInfoEntity.Query(dataSource,name);
|
||||
if(station==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
String content = "{";
|
||||
|
||||
if(detachment!=null)
|
||||
content += "\"detachment\":\""+detachment+"\",\"timestamp\":\""+SQLTools.formatDate(new Date())+"\"}";
|
||||
else if(borough!=null)
|
||||
content += "\"borough\":\""+borough+"\",\"timestamp\":\""+SQLTools.formatDate(new Date())+"\"}";
|
||||
else if(brigade!=null)
|
||||
content += "\"brigade\":\""+brigade+"\",\"timestamp\":\""+SQLTools.formatDate(new Date())+"\"}";
|
||||
else
|
||||
content += "\"station\":\""+station+"\",\"timestamp\":\""+SQLTools.formatDate(new Date())+"\"}";
|
||||
JpushClientUtil.sendMessageToDevice("firectrl", name, "closevideo", content, 0);
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,240 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.clientmanage.ClientRuningInfo;
|
||||
import com.jingyi.iotserver.clientmanage.UserAuthorManager;
|
||||
import com.jingyi.iotserver.common.service.CountResult;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.complexquery.CountResultByIndex;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationBaseInfoEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationAlarmEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationAlarmProcessRecordEntity;
|
||||
import com.jingyi.iotserver.firestationport.services.*;
|
||||
import com.jingyi.iotserver.firestationport.services.station.FireStationLiveManager;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FireStationClientAlarmController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private StationServices stationServices;
|
||||
|
||||
@Autowired
|
||||
private FireStationLiveManager fireStationLiveManager;
|
||||
|
||||
@Autowired
|
||||
private UserAuthorManager userAuthorManager;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/alarm/process",method = RequestMethod.POST)
|
||||
public RespEntity processStationAlarm(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
String session = request.getHeader("authorization");
|
||||
ClientRuningInfo runinfo = userAuthorManager.getUserInfo(session);
|
||||
runinfo.getScopelevel();
|
||||
String sender = runinfo.getLevelvalue() ;
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
String name = JsonHelper.getStringValue(rootnode,"stationName");
|
||||
String alarmid = JsonHelper.getStringValue(rootnode,"alarmid");
|
||||
FireStationBaseInfoEntity station = FireStationBaseInfoEntity.Query(dataSource,name);
|
||||
if(station==null||alarmid==null)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
FireStationAlarmEntity alarm = new FireStationAlarmEntity();
|
||||
alarm.setStation(name);
|
||||
alarm.setAlarmid(alarmid);
|
||||
alarm.setState("processed");
|
||||
alarm.setProcesstime(new Date());
|
||||
stationServices.processStationAlarm(alarm,sender);
|
||||
if(!alarm.Update(dataSource))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/alarm/processall",method = RequestMethod.POST)
|
||||
public RespEntity processStationAllAlarm(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
String session = request.getHeader("authorization");
|
||||
ClientRuningInfo runinfo = userAuthorManager.getUserInfo(session);
|
||||
runinfo.getScopelevel();
|
||||
String sender = runinfo.getLevelvalue() ;
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
String name = JsonHelper.getStringValue(rootnode,"stationName");
|
||||
|
||||
FireStationBaseInfoEntity station = FireStationBaseInfoEntity.Query(dataSource,name);
|
||||
if(station==null)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
FireStationAlarmEntity alarm = new FireStationAlarmEntity();
|
||||
alarm.setStation(name);
|
||||
alarm.setState("processed");
|
||||
stationServices.processStationAlarm(alarm,sender);
|
||||
if(alarm.ProcessAllAlarm(dataSource)) {
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/alarm/querycount",method = RequestMethod.POST)
|
||||
public RespEntity queryStationAlarmCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
FireStationAlarmEntity alarm = (FireStationAlarmEntity)SQLTools.getEntityFromJson(rootnode,FireStationAlarmEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
int count = alarm.queryCount(dataSource,startstr,endstr);
|
||||
CountResult countobj = new CountResult();
|
||||
countobj.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,countobj);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/alarm/multi-querycount",method = RequestMethod.POST)
|
||||
public RespEntity queryStationMultiAlarmCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
FireStationAlarmEntity alarm = (FireStationAlarmEntity)SQLTools.getEntityFromJson(rootnode,FireStationAlarmEntity.class);
|
||||
JsonNode timesnode = JsonHelper.getLevel2(rootnode,"times");
|
||||
if(timesnode==null||!timesnode.isArray()||timesnode.size()<=0)
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
ArrayList<CountResultByIndex> infolist = new ArrayList<CountResultByIndex>();
|
||||
for(int i=0;i<timesnode.size();i++) {
|
||||
JsonNode time = timesnode.get(i);
|
||||
if (time == null)
|
||||
continue;
|
||||
try {
|
||||
String startstr = JsonHelper.getStringValue(time, "start");
|
||||
String endstr = JsonHelper.getStringValue(time, "end");
|
||||
int count = alarm.queryCount(dataSource, startstr, endstr);
|
||||
CountResultByIndex countobj = new CountResultByIndex();
|
||||
countobj.setCount(count);
|
||||
countobj.setIndex(JsonHelper.getIntValue(rootnode,"index"));
|
||||
infolist.add(countobj);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS,infolist);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/alarm/querylist",method = RequestMethod.POST)
|
||||
public RespEntity queryStationAlarmList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
FireStationAlarmEntity alarm = (FireStationAlarmEntity)SQLTools.getEntityFromJson(rootnode,FireStationAlarmEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = alarm.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/alarm/operation/add",method = RequestMethod.POST)
|
||||
public RespEntity addStationAlarmOperation(HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
FireStationAlarmProcessRecordEntity record = (FireStationAlarmProcessRecordEntity)SQLTools.getEntityFromJson(rootnode,FireStationAlarmProcessRecordEntity.class);
|
||||
FireStationAlarmEntity alarm = new FireStationAlarmEntity();
|
||||
alarm.setStation(record.getStation());
|
||||
alarm.setAlarmid(record.getAlarmid());
|
||||
if(alarm.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
record.setTimestamp(new Date());
|
||||
if(record.Insert(dataSource))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/alarm/operation/getcount",method = RequestMethod.POST)
|
||||
public RespEntity queryStationAlarmOperateCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
FireStationAlarmProcessRecordEntity alarm = (FireStationAlarmProcessRecordEntity)SQLTools.getEntityFromJson(rootnode,FireStationAlarmProcessRecordEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
|
||||
|
||||
int count = alarm.queryCount(dataSource,startstr,endstr);
|
||||
CountResult countobj = new CountResult();
|
||||
countobj.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,countobj);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/alarm/operation/getlist",method = RequestMethod.POST)
|
||||
public RespEntity queryStationAlarmOperateList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
FireStationAlarmProcessRecordEntity alarm = (FireStationAlarmProcessRecordEntity)SQLTools.getEntityFromJson(rootnode,FireStationAlarmProcessRecordEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = alarm.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,552 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.clientmanage.UserAuthorManager;
|
||||
import com.jingyi.iotserver.clientmanage.model.DetachmentEntity;
|
||||
import com.jingyi.iotserver.common.service.CountResult;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationBaseInfoEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.rollcall.FireStationRollCallAckEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.rollcall.FireStationRollCallEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.complexquery.*;
|
||||
import com.jingyi.iotserver.firestationport.services.*;
|
||||
import com.jingyi.iotserver.firestationport.services.station.FireStationLiveManager;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FireStationClientRollcallController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private StationServices stationServices;
|
||||
|
||||
@Autowired
|
||||
private DatabaseDesInfoService databaseDesInfoService;
|
||||
|
||||
@Autowired
|
||||
private FireStationLiveManager fireStationLiveManager;
|
||||
|
||||
@Autowired
|
||||
private UserAuthorManager userAuthorManager;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/startrollcall",method = RequestMethod.POST)
|
||||
public RespEntity startRollCall(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
try {
|
||||
FireStationRollCallEntity rollcall = (FireStationRollCallEntity) SQLTools.getEntityFromJson(rootnode,FireStationRollCallEntity.class);
|
||||
if(rollcall.getStarttime()==null)
|
||||
rollcall.setStarttime(new Date(System.currentTimeMillis()));
|
||||
JsonNode scope = rootnode.get("scope");
|
||||
if(scope!=null)
|
||||
rollcall.setScope(scope.toString());
|
||||
if(rollcall==null)
|
||||
rel = new RespEntity(RespCode.NOTEXIST);
|
||||
else
|
||||
rel = stationServices.addRollCall(rollcall);
|
||||
userAuthorManager.AddUserOperate(request, UserAuthorManager.USER_OPERATE_TYPE_CREATE,"ROLLCALL",
|
||||
"发起点名", JsonHelper.convertObjectToStr(rollcall),rel.getCode());
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/getrollcallcount",method = RequestMethod.POST)
|
||||
public RespEntity queryRollCallCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
FireStationRollCallEntity rollcall = (FireStationRollCallEntity)SQLTools.getEntityFromJson(rootnode,FireStationRollCallEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
try {
|
||||
if(rollcall==null)
|
||||
rollcall = new FireStationRollCallEntity();
|
||||
int count = rollcall.queryCount(dataSource,startstr,endstr);
|
||||
CountResult countobj = new CountResult();
|
||||
countobj.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,countobj);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/getrollcalllist",method = RequestMethod.POST)
|
||||
public RespEntity getRollCallList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
FireStationRollCallEntity rollcall = (FireStationRollCallEntity)SQLTools.getEntityFromJson(rootnode,FireStationRollCallEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
if(rollcall==null)
|
||||
rollcall = new FireStationRollCallEntity();
|
||||
try {
|
||||
List<SQLDataObject> list = rollcall.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/getrollcallstatistics",method = RequestMethod.POST)
|
||||
public RespEntity getRollCallStatistics(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
FireStationRollCallEntity rollcall = (FireStationRollCallEntity)SQLTools.getEntityFromJson(rootnode,FireStationRollCallEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
|
||||
if(rollcall==null)
|
||||
rollcall = new FireStationRollCallEntity();
|
||||
|
||||
try {
|
||||
List<SQLDataObject> list = rollcall.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
List<RollCallStatisticsInfo> statistics = new ArrayList<RollCallStatisticsInfo>();
|
||||
for(SQLDataObject ob:list){
|
||||
FireStationRollCallEntity entity = (FireStationRollCallEntity)ob;
|
||||
if(entity!=null){
|
||||
RollCallStatisticsInfo info = new RollCallStatisticsInfo();
|
||||
try {
|
||||
List<FireStationBaseInfoEntity> stationscope = SQLTools.getEntityListFromJson(entity.getScope(), FireStationBaseInfoEntity.class);
|
||||
int count = stationServices.queryStationCountByScope(stationscope);
|
||||
info.setRollcallnumber(entity.getNumber());
|
||||
info.setStationcount(count);
|
||||
info.setStarttime(entity.getStarttime());
|
||||
|
||||
FireStationRollCallAckEntity rollcallack = new FireStationRollCallAckEntity();
|
||||
rollcallack.setRollcallnumber(entity.getNumber());
|
||||
rollcallack.setState("ack");
|
||||
|
||||
count = rollcallack.queryCount(dataSource,null,null);
|
||||
info.setAckcount(count);
|
||||
rollcallack.setState("ignore");
|
||||
count = rollcallack.queryCount(dataSource,null,null);
|
||||
info.setIgnorecount(count);
|
||||
statistics.add(info);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS,statistics);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/getrollcallackcount",method = RequestMethod.POST)
|
||||
public RespEntity queryRollCallAckCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
FireStationRollCallAckEntity rollcallack = (FireStationRollCallAckEntity)SQLTools.getEntityFromJson(rootnode,FireStationRollCallAckEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
try {
|
||||
if(rollcallack==null)
|
||||
rollcallack = new FireStationRollCallAckEntity();
|
||||
int count = rollcallack.queryCount(dataSource,startstr,endstr);
|
||||
CountResult countobj = new CountResult();
|
||||
countobj.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,countobj);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/getrollcallacklist",method = RequestMethod.POST)
|
||||
public RespEntity getRollCallAckList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
FireStationRollCallAckEntity rollcallack = (FireStationRollCallAckEntity)SQLTools.getEntityFromJson(rootnode,FireStationRollCallAckEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
rollcallack.setState(null);
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
|
||||
try {
|
||||
if(rollcallack==null)
|
||||
rollcallack = new FireStationRollCallAckEntity();
|
||||
List<SQLDataObject> list = rollcallack.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/getrollcallnotacklist",method = RequestMethod.POST)
|
||||
public RespEntity getRollCallNotAckList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
FireStationRollCallEntity rollcall = (FireStationRollCallEntity)SQLTools.getEntityFromJson(rootnode,FireStationRollCallEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
|
||||
String brigade = JsonHelper.getStringValue(rootnode,"brigade");
|
||||
String borough = JsonHelper.getStringValue(rootnode,"borough");
|
||||
String detachment = JsonHelper.getStringValue(rootnode,"detachment");
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
ArrayList<FireStationRollCallAckEntity> notacklist = new ArrayList<FireStationRollCallAckEntity>();
|
||||
if(rollcall==null)
|
||||
rollcall = new FireStationRollCallEntity();
|
||||
try {
|
||||
|
||||
List<SQLDataObject> list = rollcall.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
List<RollCallStatisticsInfo> statistics = new ArrayList<RollCallStatisticsInfo>();
|
||||
for(SQLDataObject ob:list){
|
||||
FireStationRollCallEntity entity = (FireStationRollCallEntity)ob;
|
||||
if(entity!=null){
|
||||
RollCallStatisticsInfo info = new RollCallStatisticsInfo();
|
||||
try {
|
||||
/* List<FireStationBaseInfoEntity> stationscope = SQLTools.getEntityListFromJson(entity.getScope(), FireStationBaseInfoEntity.class);
|
||||
int count = stationServices.queryStationCountByScope(stationscope);
|
||||
info.setRollcallnumber(entity.getNumber());
|
||||
info.setStationcount(count);
|
||||
info.setStarttime(entity.getStarttime());
|
||||
*/
|
||||
FireStationRollCallAckEntity rollcallack = new FireStationRollCallAckEntity();
|
||||
rollcallack.setRollcallnumber(entity.getNumber());
|
||||
rollcallack.setState("ignore");
|
||||
// count = stationServices.queryRollCallAckCount(rollcallack,null,null);
|
||||
List<SQLDataObject> notack = rollcallack.queryPage(dataSource,null,null,0,1000);
|
||||
for(SQLDataObject oback:notack){
|
||||
FireStationRollCallAckEntity ack = (FireStationRollCallAckEntity)oback;
|
||||
if(fireStationLiveManager.matchScope(ack.getStationname(),brigade,borough,detachment))
|
||||
notacklist.add(ack);
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS,notacklist);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/patchrollcallack",method = RequestMethod.POST)
|
||||
public RespEntity patckRollCallAck(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try{
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
List<FireStationRollCallAckEntity> notack = SQLTools.getEntityListFromJsonArray(rootnode,FireStationRollCallAckEntity.class);
|
||||
for(FireStationRollCallAckEntity ack:notack){
|
||||
ack.setState("ack");
|
||||
ack.setAcktime(new Date());
|
||||
ack.Update(dataSource);
|
||||
}
|
||||
userAuthorManager.AddUserOperate(request,UserAuthorManager.USER_OPERATE_TYPE_PATCH,"ROLLCALL",
|
||||
"补点名",JsonHelper.convertObjectToStr(notack),0);
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/getrollcallreportform",method = RequestMethod.POST)
|
||||
public RespEntity getRollcallReportform(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
String username = JsonHelper.getStringValue(rootnode,"username");
|
||||
JsonNode scopenode = JsonHelper.getLevel2(rootnode,"scope");
|
||||
|
||||
FireStationRollCallEntity rollentity = null;
|
||||
if(username!=null){
|
||||
rollentity = new FireStationRollCallEntity();
|
||||
rollentity.setUsername(username);
|
||||
}
|
||||
int stationcount = 0;
|
||||
if(rollentity==null)
|
||||
rollentity = new FireStationRollCallEntity();
|
||||
try {
|
||||
|
||||
List<SQLDataObject> rollcalllist = rollentity.queryPage(dataSource,startstr,endstr,0,1024);
|
||||
|
||||
if(scopenode!=null&&rollcalllist!=null){
|
||||
//remove rollcall out scope
|
||||
List<FireStationRollCallEntity> rmlist = new ArrayList<FireStationRollCallEntity>();
|
||||
List<FireStationBaseInfoEntity> list = SQLTools.getEntityListFromJsonArray(scopenode,FireStationBaseInfoEntity.class);
|
||||
if(list!=null&&list.size()>0){
|
||||
for(SQLDataObject ob:rollcalllist){
|
||||
FireStationRollCallEntity rollcall = (FireStationRollCallEntity)ob;
|
||||
if(rollcall!=null){
|
||||
try {
|
||||
boolean rm = true;
|
||||
String scope = rollcall.getScope();
|
||||
JsonNode rollscopelist = JsonHelper.parseBodyLevel1(scope);
|
||||
List<FireStationBaseInfoEntity> rolllist = SQLTools.getEntityListFromJsonArray(rollscopelist, FireStationBaseInfoEntity.class);
|
||||
for (FireStationBaseInfoEntity userscope : list) {
|
||||
if (userscope != null) {
|
||||
for(FireStationBaseInfoEntity roll:rolllist){
|
||||
if(roll!=null){
|
||||
if(userscope.checkScope(roll)){
|
||||
rm = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(rm)
|
||||
rmlist.add(rollcall);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
for(FireStationRollCallEntity rollcall:rmlist){
|
||||
if(rollcall!=null)
|
||||
rollcalllist.remove(rollcall);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RollcallReportForm report = new RollcallReportForm();
|
||||
HashMap<String, StationRollcallCounter> stationrollcallmap = new HashMap<String,StationRollcallCounter>();
|
||||
if(rollcalllist==null||rollcalllist.size()<=0){
|
||||
report.setRollcall(0);
|
||||
report.setAck(0);
|
||||
report.setIgnore(0);
|
||||
report.setExpect(0);
|
||||
report.setRanking(null);
|
||||
return new RespEntity(RespCode.SUCCESS,report);
|
||||
}
|
||||
report.setRollcall(rollcalllist.size());
|
||||
for(SQLDataObject ob:rollcalllist){
|
||||
FireStationRollCallEntity rollcall = (FireStationRollCallEntity)ob;
|
||||
String scopejson = rollcall.getScope();
|
||||
|
||||
try{
|
||||
JsonNode scopelist = JsonHelper.parseBodyLevel1(scopejson);
|
||||
List<FireStationBaseInfoEntity> list = SQLTools.getEntityListFromJsonArray(scopelist,FireStationBaseInfoEntity.class);
|
||||
try {
|
||||
int count = stationServices.queryStationCountByScope(list);
|
||||
if(count>0)
|
||||
stationcount+=count;
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
FireStationRollCallAckEntity ackEntity = new FireStationRollCallAckEntity();
|
||||
int pageindex = 0;
|
||||
int pagesize = 512;
|
||||
ackEntity.setRollcallnumber(rollcall.getNumber());
|
||||
List<SQLDataObject> acklist = null;
|
||||
do {
|
||||
acklist = ackEntity.queryPage(dataSource, null, null, pageindex, pagesize);
|
||||
pageindex++;
|
||||
if (acklist == null)
|
||||
break;
|
||||
for (SQLDataObject oback : acklist) {
|
||||
FireStationRollCallAckEntity ack = (FireStationRollCallAckEntity)oback;
|
||||
StationRollcallCounter counter = stationrollcallmap.get(ack.getStationname());
|
||||
if (counter == null) {
|
||||
counter = new StationRollcallCounter();
|
||||
counter.setName(ack.getStationname());
|
||||
if (ack.getState().equals("ack")) {
|
||||
counter.setAck(1);
|
||||
counter.setIgnore(0);
|
||||
} else {
|
||||
counter.setAck(0);
|
||||
counter.setIgnore(1);
|
||||
}
|
||||
stationrollcallmap.put(counter.getName(), counter);
|
||||
} else {
|
||||
if (ack.getState().equals("ack")) {
|
||||
counter.setAck(counter.getAck() + 1);
|
||||
} else {
|
||||
counter.setIgnore(counter.getIgnore() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}while(acklist!=null&&acklist.size()>=pagesize);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ArrayList<StationRollcallCounter> ranking = new ArrayList<StationRollcallCounter>();
|
||||
|
||||
for(Map.Entry<String, StationRollcallCounter> entry: stationrollcallmap.entrySet()) {
|
||||
StationRollcallCounter info = entry.getValue();
|
||||
if(info!=null){
|
||||
report.setAck(report.getAck()+info.getAck());
|
||||
report.setIgnore(report.getIgnore()+info.getIgnore());
|
||||
ranking.add(info);
|
||||
}
|
||||
}
|
||||
//Collections.sort(ranking, Collections.reverseOrder());
|
||||
Collections.sort(ranking);
|
||||
report.setRanking(ranking);
|
||||
report.setExpect(stationcount);
|
||||
return new RespEntity(RespCode.SUCCESS,report);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/getstationrollcallreportform",method = RequestMethod.POST)
|
||||
public RespEntity getStationRollcallReportform(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
String stationname = JsonHelper.getStringValue(rootnode, "name");
|
||||
|
||||
if(startstr==null||endstr==null||stationname==null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
FireStationBaseInfoEntity station = FireStationBaseInfoEntity.Query(dataSource,stationname);
|
||||
if(station==null)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
|
||||
int ackcount = 0;
|
||||
int ignorecount = 0;
|
||||
FireStationRollCallAckEntity ackEntity = new FireStationRollCallAckEntity();
|
||||
int pageindex = 0;
|
||||
int pagesize = 1024;
|
||||
ackEntity.setStationname(stationname);
|
||||
List<SQLDataObject> acklist = null;
|
||||
acklist = ackEntity.queryPage(dataSource, startstr, endstr, pageindex, pagesize);
|
||||
|
||||
StationRollcallReportForm report = new StationRollcallReportForm();
|
||||
ArrayList<StationRollcallAckInfo> list = new ArrayList<StationRollcallAckInfo>();
|
||||
for(SQLDataObject ob : acklist){
|
||||
FireStationRollCallAckEntity ack = (FireStationRollCallAckEntity)ob;
|
||||
if(ack==null)
|
||||
continue;
|
||||
StationRollcallAckInfo info = new StationRollcallAckInfo();
|
||||
info.setNumber(ack.getRollcallnumber());
|
||||
FireStationRollCallEntity rollcall = FireStationRollCallEntity.Query(dataSource,ack.getRollcallnumber());
|
||||
if(rollcall==null)
|
||||
continue;
|
||||
info.setStarttime(rollcall.getStarttime());
|
||||
info.setState(ack.getState());
|
||||
info.setAcktime(ack.getAcktime());
|
||||
|
||||
try {
|
||||
if (ack.getState().equals("ack")) {
|
||||
ackcount++;
|
||||
} else {
|
||||
ignorecount++;
|
||||
}
|
||||
}catch (Exception e){
|
||||
continue;
|
||||
}
|
||||
list.add(info);
|
||||
}
|
||||
report.setAck(ackcount);
|
||||
report.setIgnore(ignorecount);
|
||||
report.setList(list);
|
||||
int rollcallcount = 0;
|
||||
try{
|
||||
FireStationRollCallEntity rollcal = new FireStationRollCallEntity();
|
||||
List<SQLDataObject> rollcalllist = rollcal.queryPage(dataSource,startstr,endstr,0,1024);
|
||||
for(SQLDataObject ob:rollcalllist){
|
||||
FireStationRollCallEntity rollcall = (FireStationRollCallEntity)ob;
|
||||
String scope = rollcall.getScope();
|
||||
try {
|
||||
List<DetachmentEntity> scopelist = SQLTools.getEntityListFromJson(scope, DetachmentEntity.class);
|
||||
for(DetachmentEntity detach:scopelist){
|
||||
String brigade = detach.getBrigade();
|
||||
String borough = detach.getBorough();
|
||||
String detachemnt = detach.getDetachment();
|
||||
if(brigade!=null&&!brigade.equals(station.getBrigade()))
|
||||
continue;
|
||||
if(borough!=null&&!borough.equals(station.getBorough()))
|
||||
continue;
|
||||
if(detachemnt!=null&&!detachemnt.equals(station.getDetachment()))
|
||||
continue;
|
||||
rollcallcount++;
|
||||
break;
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
report.setRollcall(rollcallcount);
|
||||
rel = new RespEntity(RespCode.SUCCESS,report);
|
||||
return rel;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,172 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.clientmanage.UserAuthorManager;
|
||||
import com.jingyi.iotserver.clientmanage.model.OrganiztionUri;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.update.SoftwareUpdateTaskEntity;
|
||||
import com.jingyi.iotserver.firestationport.services.StationServices;
|
||||
import com.jingyi.iotserver.firestationport.services.station.FireStationLiveManager;
|
||||
import com.jingyi.iotserver.jpush.JpushClientUtil;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FireStationSWUpdateController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private StationServices stationServices;
|
||||
|
||||
|
||||
@Autowired
|
||||
private FireStationLiveManager fireStationLiveManager;
|
||||
|
||||
@Autowired
|
||||
private UserAuthorManager userAuthorManager;
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/firectrl/client/swupdate/addtask", method = RequestMethod.POST)
|
||||
public RespEntity addSWUpdateTask(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
SoftwareUpdateTaskEntity task = (SoftwareUpdateTaskEntity) SQLTools.getEntityFromJson(rootnode, SoftwareUpdateTaskEntity.class);
|
||||
|
||||
if (task == null || task.getTaskid() == null || task.getTaskid().length() <= 0 )
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
|
||||
if (task.QueryTask(dataSource, task.getTaskid()) != null)
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
|
||||
if(task.getScope()==null||task.getScope().length()<5){
|
||||
JsonNode scope = JsonHelper.getLevel2(rootnode,"scope");
|
||||
task.setScope(scope.toString());
|
||||
}
|
||||
|
||||
try {
|
||||
task.setStatus("active");
|
||||
task.setTimestamp(new Date());
|
||||
|
||||
|
||||
if (!task.Insert(dataSource)) {
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
if(SendUpdateNotify(task))
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
userAuthorManager.AddUserOperate(request, UserAuthorManager.USER_OPERATE_TYPE_CREATE, "UPDATE",
|
||||
"发送通知给微站", JsonHelper.convertObjectToStr(task), rel.getCode());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
private boolean SendUpdateNotify(SoftwareUpdateTaskEntity task){
|
||||
try{
|
||||
String taskstr = JsonHelper.convertObjectToStr(task);
|
||||
if(taskstr==null)
|
||||
return false;
|
||||
List<OrganiztionUri> list = ( List<OrganiztionUri>)SQLTools.getEntityListFromJson(task.getScope(), OrganiztionUri.class);
|
||||
for(OrganiztionUri s:list){
|
||||
if(s!=null){
|
||||
String group = null;
|
||||
String station = null;
|
||||
if(s.getStation()!=null) {
|
||||
station = s.getStation();
|
||||
}else if(s.getDetachment()!=null){
|
||||
group = s.getDetachment();
|
||||
}else if(s.getBorough()!=null){
|
||||
group = s.getBorough();
|
||||
}else if(s.getBrigade()!=null){
|
||||
group = s.getBrigade();
|
||||
}
|
||||
try {
|
||||
if(station!=null) {
|
||||
JpushClientUtil.sendMessageToDevice("firectrl", station, "update", taskstr, 0);
|
||||
|
||||
}else if (group != null) {
|
||||
JpushClientUtil.sendMessageToGroup("firectrl", group, "update", taskstr, 0);
|
||||
}
|
||||
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/firectrl/client/swupdate/gettask", method = RequestMethod.POST)
|
||||
public RespEntity getSWUpdateTask(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
SoftwareUpdateTaskEntity task = (SoftwareUpdateTaskEntity) SQLTools.getEntityFromJson(rootnode, SoftwareUpdateTaskEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
if (task == null )
|
||||
task = new SoftwareUpdateTaskEntity();
|
||||
|
||||
List<SQLDataObject>list = task.queryPage(dataSource,startstr,endstr,0,1000);
|
||||
rel = new RespEntity(RespCode.SUCCESS,list);
|
||||
|
||||
} catch (Exception e) {
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/firectrl/client/swupdate/closetask", method = RequestMethod.POST)
|
||||
public RespEntity closeSWUpdateTask(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
|
||||
String taskid = JsonHelper.getStringValue(rootnode,"taskid");
|
||||
if (taskid == null || taskid.length()<=0)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
SoftwareUpdateTaskEntity task = new SoftwareUpdateTaskEntity();
|
||||
task = task.QueryTask(dataSource,taskid);
|
||||
if(task==null)
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
task.setStatus("close");
|
||||
if(task.UpdateStatus(dataSource))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
|
||||
} catch (Exception e) {
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationBaseInfoEntity;
|
||||
|
||||
|
||||
public interface IFireStationOperate {
|
||||
public RespEntity ExecuteOperate(FireStationBaseInfoEntity station, Object param);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.SensorDeviceEntity;
|
||||
|
||||
public interface ISensorOperate {
|
||||
public RespEntity ExecuteOperate(SensorDeviceEntity sensor, Object param);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.SensorSubDeviceEntity;
|
||||
|
||||
public interface ISensorSubdevOperate {
|
||||
public RespEntity ExecuteOperate(SensorSubDeviceEntity sensor, Object param);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationStaffInfoEntity;
|
||||
|
||||
public interface IStaffOperate {
|
||||
public RespEntity ExecuteOperate(FireStationStaffInfoEntity staff, Object param);
|
||||
}
|
|
@ -0,0 +1,394 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.clientmanage.model.BoroughEntity;
|
||||
import com.jingyi.iotserver.common.service.CountResult;
|
||||
import com.jingyi.iotserver.common.service.EnvConfigService;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.analyze.WeekCount;
|
||||
import com.jingyi.iotserver.firestationport.model.complexquery.SystemCountInfo;
|
||||
import com.jingyi.iotserver.firestationport.model.school.*;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.SensorDeviceEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.pushalarm.PushAlarmPointEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.ys.HikvisionIPCEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationBaseInfoEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.PolicemanInfo;
|
||||
import com.jingyi.iotserver.firestationport.model.statistics.BoroughMonthSummaryEntity;
|
||||
import com.jingyi.iotserver.firestationport.services.userman.HouseOwnerLoginResult;
|
||||
import com.jingyi.iotserver.firestationport.services.SensorService;
|
||||
import com.jingyi.iotserver.firestationport.services.userman.HouseOwnerManager;
|
||||
import com.jingyi.iotserver.firestationport.services.userman.HouseOwnerRunningInfo;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.sql.DataSource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class IntelEyeController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private EnvConfigService envConfigService;
|
||||
|
||||
@Autowired
|
||||
private SensorService sensorService;
|
||||
|
||||
@Autowired
|
||||
private HouseOwnerManager houseOwnerManager;
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/firectrl/eye/login", method = RequestMethod.POST)
|
||||
public RespEntity appLogin(HttpServletRequest request, HttpServletResponse response, @CookieValue(value = "token", required = false) String token) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
String json = HttpTools.getBodyFromRequest(request);
|
||||
JsonNode rootnode = JsonHelper.parseBodyLevel1(json);
|
||||
if (rootnode == null) {
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
}
|
||||
String phone = JsonHelper.getStringValue(rootnode, "phone");
|
||||
String password = JsonHelper.getStringValue(rootnode, "password");
|
||||
if (phone == null) {
|
||||
return new RespEntity(RespCode.USER_PWD_ERROR);
|
||||
}
|
||||
HouseOwnerRunningInfo info = houseOwnerManager.getHouseOwner(phone);
|
||||
if(info==null){
|
||||
HttpSession session = request.getSession();
|
||||
String sessionid = session.getId();
|
||||
session.setAttribute(session.getId(),phone);
|
||||
houseOwnerManager.addHouseOwner(phone,sessionid);
|
||||
info = houseOwnerManager.getHouseOwner(phone);
|
||||
}
|
||||
HouseOwnerLoginResult result = new HouseOwnerLoginResult();
|
||||
result.setSession(info.getSession());
|
||||
return new RespEntity(RespCode.SUCCESS,result);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value="/firectrl/eye/getsensorlist",method = RequestMethod.POST)
|
||||
public RespEntity getSensorList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
String devtype = JsonHelper.getStringValue(rootnode,"devicetype");
|
||||
String phone = JsonHelper.getStringValue(rootnode,"phone");
|
||||
SensorDeviceEntity sensor = new SensorDeviceEntity();
|
||||
|
||||
sensor.setHouseowner(phone);
|
||||
sensor.setDevicetype(devtype);
|
||||
List<SQLDataObject> list = sensorService.queryStationSensor(sensor);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value="/firectrl/eye/reportfault",method = RequestMethod.POST)
|
||||
public RespEntity reportFault(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
String json = HttpTools.getBodyFromRequest(request);
|
||||
System.out.println(json);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/firectrl/system/count",method = RequestMethod.POST)
|
||||
public RespEntity getSystemCountInfo(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
SystemCountInfo systemCountInfo = (SystemCountInfo) SQLTools.getEntityFromJson(rootnode,SystemCountInfo.class);
|
||||
|
||||
if(systemCountInfo== null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(systemCountInfo.getBrigade() == null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
|
||||
try {
|
||||
FireStationBaseInfoEntity station =new FireStationBaseInfoEntity();
|
||||
station.setBrigade(systemCountInfo.getBrigade());
|
||||
int count = station.queryCount(dataSource,null,null);
|
||||
// List<SQLDataObject> stations = station.queryPage(dataSource, null,null,0,1000);
|
||||
// int studentTotal = 0;
|
||||
// int count = stations.size();
|
||||
// for(int iSt = 0; iSt < stations.size(); iSt++){
|
||||
// FireStationBaseInfoEntity school = (FireStationBaseInfoEntity)stations.get(iSt);
|
||||
// studentTotal += school.getStudentCount();
|
||||
// }
|
||||
|
||||
systemCountInfo.setStation(count);
|
||||
//systemCountInfo.setStudent(studentTotal);
|
||||
}catch (Exception e){
|
||||
systemCountInfo.setStation(0);
|
||||
}
|
||||
|
||||
try {
|
||||
BoroughEntity borough =new BoroughEntity();
|
||||
borough.setBrigade(systemCountInfo.getBrigade());
|
||||
int count = borough.queryCount(dataSource,null,null);
|
||||
systemCountInfo.setBorough(count);
|
||||
}catch (Exception e){
|
||||
systemCountInfo.setBorough(0);
|
||||
}
|
||||
|
||||
try {
|
||||
PushAlarmPointEntity alarmPoint =new PushAlarmPointEntity();
|
||||
alarmPoint.setBrigade(systemCountInfo.getBrigade());
|
||||
int count = alarmPoint.queryCount(dataSource,null,null);
|
||||
systemCountInfo.setAlarmPoint(count);
|
||||
}catch (Exception e){
|
||||
systemCountInfo.setAlarmPoint(0);
|
||||
}
|
||||
|
||||
try {
|
||||
HikvisionIPCEntity hikvisionIPC =new HikvisionIPCEntity();
|
||||
hikvisionIPC.setBrigade(systemCountInfo.getBrigade());
|
||||
int count = hikvisionIPC.queryCount(dataSource,null,null);
|
||||
systemCountInfo.setIpc(count);
|
||||
}catch (Exception e){
|
||||
systemCountInfo.setIpc(0);
|
||||
}
|
||||
|
||||
try {
|
||||
BigDecimal count = FireStationBaseInfoEntity.querySumery(dataSource,systemCountInfo.getBrigade());
|
||||
systemCountInfo.setStudent(count.intValue());
|
||||
}catch (Exception e){
|
||||
systemCountInfo.setStudent(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
PolicemanInfo registerCount =new PolicemanInfo();
|
||||
registerCount.setBrigade(systemCountInfo.getBrigade());
|
||||
int count = registerCount.queryCount(dataSource,null,null);
|
||||
systemCountInfo.setSchoolGuardCount(count);
|
||||
}catch (Exception e){
|
||||
systemCountInfo.setSchoolGuardCount(0);
|
||||
}
|
||||
|
||||
try {
|
||||
SchoolNewsEntity schoolNews =new SchoolNewsEntity();
|
||||
schoolNews.setBrigade(systemCountInfo.getBrigade());
|
||||
int count = schoolNews.queryCount(dataSource,null,null);
|
||||
systemCountInfo.setSchoolNewsCount(count);
|
||||
}catch (Exception e){
|
||||
systemCountInfo.setSchoolNewsCount(0);
|
||||
}
|
||||
|
||||
try {
|
||||
SchoolNewsEntity schoolNews =new SchoolNewsEntity();
|
||||
schoolNews.setBrigade(systemCountInfo.getBrigade());
|
||||
int count = schoolNews.queryCount(dataSource,null,null);
|
||||
systemCountInfo.setSchoolNewsCount(count);
|
||||
}catch (Exception e){
|
||||
systemCountInfo.setSchoolNewsCount(0);
|
||||
}
|
||||
|
||||
try {
|
||||
GuardSignEventEntity signEvent =new GuardSignEventEntity();
|
||||
signEvent.setBrigade(systemCountInfo.getBrigade());
|
||||
signEvent.setDay(-1);
|
||||
signEvent.setYear(-1);
|
||||
signEvent.setMonth(-1);
|
||||
int count = signEvent.queryCount(dataSource,null,null);
|
||||
systemCountInfo.setSchoolSignCount(count);
|
||||
}catch (Exception e){
|
||||
systemCountInfo.setSchoolSignCount(0);
|
||||
}
|
||||
|
||||
try {
|
||||
SchoolSecurityCheckEntity checkRecord =new SchoolSecurityCheckEntity();
|
||||
checkRecord.setBrigade(systemCountInfo.getBrigade());
|
||||
int count = checkRecord.queryCount(dataSource,null,null);
|
||||
systemCountInfo.setSchoolCheckCount(count);
|
||||
}catch (Exception e){
|
||||
systemCountInfo.setSchoolCheckCount(0);
|
||||
}
|
||||
|
||||
try {
|
||||
SchoolStarRatingEntity starRating =new SchoolStarRatingEntity();
|
||||
starRating.setBrigade(systemCountInfo.getBrigade());
|
||||
starRating.setSchoolTime(systemCountInfo.getSchoolTime());
|
||||
int count = starRating.queryCount(dataSource,null,null);
|
||||
systemCountInfo.setSchoolStarCount(count);
|
||||
}catch (Exception e){
|
||||
systemCountInfo.setSchoolStarCount(0);
|
||||
}
|
||||
|
||||
try {
|
||||
SchoolColorRatingEntity colorRating =new SchoolColorRatingEntity();
|
||||
colorRating.setBrigade(systemCountInfo.getBrigade());
|
||||
colorRating.setSchoolTime(systemCountInfo.getSchoolTime());
|
||||
int count = colorRating.queryCount(dataSource,null,null);
|
||||
systemCountInfo.setSchoolColorCount(count);
|
||||
}catch (Exception e){
|
||||
systemCountInfo.setSchoolColorCount(0);
|
||||
}
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS, systemCountInfo);
|
||||
}catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@RequestMapping(value="/firectrl/schoolnews/weeks",method = RequestMethod.POST)
|
||||
public RespEntity getSchoolNewsWeeks(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
String json = HttpTools.getBodyFromRequest(request);
|
||||
SchoolNewsEntity schoolNewsFilter = JSON.parseObject(json, SchoolNewsEntity.class);
|
||||
if(schoolNewsFilter == null){
|
||||
schoolNewsFilter = new SchoolNewsEntity();
|
||||
}
|
||||
|
||||
List<WeekCount> newsWeekSummary = new ArrayList<>();
|
||||
|
||||
Calendar nowTime = Calendar.getInstance();
|
||||
int nDayofWeek = nowTime.get(Calendar.DAY_OF_WEEK);
|
||||
long dayOffsetMS = (nDayofWeek-1)*24*3600000;
|
||||
|
||||
long starMS = nowTime.getTimeInMillis() - dayOffsetMS;
|
||||
Date startDay = new Date(starMS);
|
||||
String strStartDay = SQLTools.formatDay(startDay);
|
||||
strStartDay += " 00:00:00";
|
||||
|
||||
String endStr = SQLTools.formatDate(new Date());
|
||||
|
||||
WeekCount weekNow = new WeekCount();
|
||||
weekNow.setStartTime(strStartDay);
|
||||
weekNow.setEndTime(endStr);
|
||||
int newsCount = schoolNewsFilter.queryCount(dataSource,strStartDay, endStr);
|
||||
weekNow.setCount(newsCount);
|
||||
newsWeekSummary.add(0,weekNow);
|
||||
|
||||
|
||||
Date week2Start = new Date(SQLTools.StrToDateTime(weekNow.getStartTime()).getTime() - 7*24*3600000);
|
||||
Date week3Start = new Date(SQLTools.StrToDateTime(weekNow.getStartTime()).getTime() - 14*24*3600000);
|
||||
Date week4Start = new Date(SQLTools.StrToDateTime(weekNow.getStartTime()).getTime() - 21*24*3600000);
|
||||
|
||||
WeekCount week2 = new WeekCount();
|
||||
week2.setStartTime(SQLTools.formatDate(week2Start));
|
||||
week2.setEndTime(weekNow.getStartTime());
|
||||
newsCount = schoolNewsFilter.queryCount(dataSource,week2.getStartTime(), week2.getEndTime());
|
||||
week2.setCount(newsCount);
|
||||
newsWeekSummary.add(0,week2);
|
||||
|
||||
WeekCount week3 = new WeekCount();
|
||||
week3.setStartTime(SQLTools.formatDate(week3Start));
|
||||
week3.setEndTime(week2.getStartTime());
|
||||
newsCount = schoolNewsFilter.queryCount(dataSource,week3.getStartTime(), week3.getEndTime());
|
||||
week3.setCount(newsCount);
|
||||
newsWeekSummary.add(0,week3);
|
||||
|
||||
WeekCount week4 = new WeekCount();
|
||||
week4.setStartTime(SQLTools.formatDate(week4Start));
|
||||
week4.setEndTime(week3.getStartTime());
|
||||
newsCount = schoolNewsFilter.queryCount(dataSource,week4.getStartTime(), week4.getEndTime());
|
||||
week4.setCount(newsCount);
|
||||
newsWeekSummary.add(0,week4);
|
||||
return new RespEntity(RespCode.SUCCESS, newsWeekSummary);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/firectrl/schoolsign/weeks",method = RequestMethod.POST)
|
||||
public RespEntity getSchoolSignWeeks(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
String json = HttpTools.getBodyFromRequest(request);
|
||||
GuardSignEventEntity signEvent = JSON.parseObject(json, GuardSignEventEntity.class);
|
||||
if(signEvent == null){
|
||||
signEvent = new GuardSignEventEntity();
|
||||
}
|
||||
signEvent.setMonth(-1);
|
||||
signEvent.setYear(-1);
|
||||
signEvent.setDay(-1);
|
||||
|
||||
List<WeekCount> newsWeekSummary = new ArrayList<>();
|
||||
|
||||
Calendar nowTime = Calendar.getInstance();
|
||||
int nDayofWeek = nowTime.get(Calendar.DAY_OF_WEEK);
|
||||
long dayOffsetMS = (nDayofWeek-1)*24*3600000;
|
||||
|
||||
long starMS = nowTime.getTimeInMillis() - dayOffsetMS;
|
||||
Date startDay = new Date(starMS);
|
||||
String strStartDay = SQLTools.formatDay(startDay);
|
||||
strStartDay += " 00:00:00";
|
||||
|
||||
String endStr = SQLTools.formatDate(new Date());
|
||||
|
||||
WeekCount weekNow = new WeekCount();
|
||||
weekNow.setStartTime(strStartDay);
|
||||
weekNow.setEndTime(endStr);
|
||||
int newsCount = signEvent.queryCount(dataSource,strStartDay, endStr);
|
||||
weekNow.setCount(newsCount);
|
||||
newsWeekSummary.add(0,weekNow);
|
||||
|
||||
|
||||
Date week2Start = new Date(SQLTools.StrToDateTime(weekNow.getStartTime()).getTime() - 7*24*3600000);
|
||||
Date week3Start = new Date(SQLTools.StrToDateTime(weekNow.getStartTime()).getTime() - 14*24*3600000);
|
||||
Date week4Start = new Date(SQLTools.StrToDateTime(weekNow.getStartTime()).getTime() - 21*24*3600000);
|
||||
|
||||
WeekCount week2 = new WeekCount();
|
||||
week2.setStartTime(SQLTools.formatDate(week2Start));
|
||||
week2.setEndTime(weekNow.getStartTime());
|
||||
newsCount = signEvent.queryCount(dataSource,week2.getStartTime(), week2.getEndTime());
|
||||
week2.setCount(newsCount);
|
||||
newsWeekSummary.add(0,week2);
|
||||
|
||||
WeekCount week3 = new WeekCount();
|
||||
week3.setStartTime(SQLTools.formatDate(week3Start));
|
||||
week3.setEndTime(week2.getStartTime());
|
||||
newsCount = signEvent.queryCount(dataSource,week3.getStartTime(), week3.getEndTime());
|
||||
week3.setCount(newsCount);
|
||||
newsWeekSummary.add(0,week3);
|
||||
|
||||
WeekCount week4 = new WeekCount();
|
||||
week4.setStartTime(SQLTools.formatDate(week4Start));
|
||||
week4.setEndTime(week3.getStartTime());
|
||||
newsCount = signEvent.queryCount(dataSource,week4.getStartTime(), week4.getEndTime());
|
||||
week4.setCount(newsCount);
|
||||
newsWeekSummary.add(0,week4);
|
||||
return new RespEntity(RespCode.SUCCESS, newsWeekSummary);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.common.service.CountResult;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.pluginfo.PlugInfoEntity;
|
||||
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class IoTPlugInfoController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/pluginfo/add",method = RequestMethod.POST)
|
||||
public RespEntity addPlugInfo(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
PlugInfoEntity info = (PlugInfoEntity) SQLTools.getEntityFromJson(rootnode, PlugInfoEntity.class);
|
||||
if(info==null||info.getId()==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
if(info.QueryIt(dataSource)!=null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
|
||||
if(info.Insert(dataSource)){
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}else{
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/pluginfo/delete",method = RequestMethod.POST)
|
||||
public RespEntity deletePlugInfo(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
PlugInfoEntity info = (PlugInfoEntity) SQLTools.getEntityFromJson(rootnode, PlugInfoEntity.class);
|
||||
if(info==null||info.getId()==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
if(info.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
|
||||
if(info.Delete(dataSource)){
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}else{
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/pluginfo/update",method = RequestMethod.POST)
|
||||
public RespEntity updatePlugInfo(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
PlugInfoEntity info = (PlugInfoEntity) SQLTools.getEntityFromJson(rootnode, PlugInfoEntity.class);
|
||||
if(info==null||info.getId()==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
if(info.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
|
||||
if(info.Update(dataSource)){
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}else{
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/pluginfo/get",method = RequestMethod.POST)
|
||||
public RespEntity getPlugInfo(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
PlugInfoEntity info = (PlugInfoEntity) SQLTools.getEntityFromJson(rootnode, PlugInfoEntity.class);
|
||||
if(info==null||info.getId()==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
info = (PlugInfoEntity)info.QueryIt(dataSource);
|
||||
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS,info);
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/pluginfo/getcount",method = RequestMethod.POST)
|
||||
public RespEntity getPlugInfoCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
PlugInfoEntity info = (PlugInfoEntity) SQLTools.getEntityFromJson(rootnode, PlugInfoEntity.class);
|
||||
if(info==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
|
||||
int count = info.queryCount(dataSource,startstr,endstr);
|
||||
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/pluginfo/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getPlugInfoList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
PlugInfoEntity info = (PlugInfoEntity) SQLTools.getEntityFromJson(rootnode, PlugInfoEntity.class);
|
||||
if(info==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 100;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = info.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,362 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.common.service.CountResult;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.FireCtrlSystemInit;
|
||||
import com.jingyi.iotserver.firestationport.model.school.StudentVipEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.GasSensorEventEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.SensorDeviceEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.WaterCheckDataEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.WaterCheckReportEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.gas.DataDescriptionEntity;
|
||||
import com.jingyi.iotserver.firestationport.services.SensorService;
|
||||
import com.jingyi.iotserver.iotctrl.UDPAgentPackage;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class IotSensorDataController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private SensorService sensorService;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iot/sensor/data/desc/list",method = RequestMethod.POST)
|
||||
public RespEntity getSensorDataDesc(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
DataDescriptionEntity sensorDesc = (DataDescriptionEntity) SQLTools.getEntityFromJson(rootnode,DataDescriptionEntity.class);
|
||||
if(sensorDesc == null){
|
||||
sensorDesc = new DataDescriptionEntity();
|
||||
}
|
||||
|
||||
List<SQLDataObject> dataList = sensorDesc.queryPage(dataSource,null,null,0, 1000);
|
||||
return new RespEntity(RespCode.SUCCESS,dataList);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iot/sensor/data/desc/add",method = RequestMethod.POST)
|
||||
public RespEntity addSensorDataDesc(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
DataDescriptionEntity sensorDesc = (DataDescriptionEntity) SQLTools.getEntityFromJson(rootnode,DataDescriptionEntity.class);
|
||||
if(sensorDesc == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(sensorDesc.getName() == null || sensorDesc.getType() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(sensorDesc.QueryIt(dataSource) != null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
if(sensorDesc.Insert(dataSource)){
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}else{
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iot/sensor/count",method = RequestMethod.POST)
|
||||
public RespEntity getSensorCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
SensorDeviceEntity sensor = (SensorDeviceEntity) SQLTools.getEntityFromJson(rootnode,SensorDeviceEntity.class);
|
||||
int count = sensorService.querySensorCount(sensor);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iot/sensor/list",method = RequestMethod.POST)
|
||||
public RespEntity getSensorPage(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
SensorDeviceEntity sensor = (SensorDeviceEntity)SQLTools.getEntityFromJson(rootnode,SensorDeviceEntity.class);
|
||||
List<SQLDataObject> list = sensorService.querySensorPage(pagesize,pageindex,sensor);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iot/sensor/water/getinfo/qrcode",method = RequestMethod.POST)
|
||||
public RespEntity getSensorWithQicode(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
String qrcode = JsonHelper.getStringValue(rootnode,"qrcode");
|
||||
|
||||
SensorDeviceEntity sensor = SensorDeviceEntity.QueryQrcode(dataSource,qrcode);
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS,sensor);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iot/sensor/clean_water/last",method = RequestMethod.POST)
|
||||
public RespEntity getWaterDeviceLastData(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
WaterCheckDataEntity sensorData = (WaterCheckDataEntity)SQLTools.getEntityFromJson(rootnode,WaterCheckDataEntity.class);
|
||||
if(sensorData == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(sensorData.getDeviceid() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
WaterCheckDataEntity lastData = (WaterCheckDataEntity)sensorData.QueryLast(dataSource);
|
||||
if(lastData == null){
|
||||
lastData = new WaterCheckDataEntity();
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS,lastData);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iot/sensor/clean_water/data_list",method = RequestMethod.POST)
|
||||
public RespEntity getWaterDeviceDataList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
WaterCheckDataEntity sensorData = (WaterCheckDataEntity)SQLTools.getEntityFromJson(rootnode,WaterCheckDataEntity.class);
|
||||
if(sensorData == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(sensorData.getDeviceid() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> dataList = sensorData.queryPage(dataSource,startstr,endstr,pageindex, pagesize);
|
||||
if(dataList == null){
|
||||
dataList = new ArrayList<>();
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS, dataList);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iot/sensor/air/last",method = RequestMethod.POST)
|
||||
public RespEntity getGasDeviceLastData(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
GasSensorEventEntity sensorData = (GasSensorEventEntity)SQLTools.getEntityFromJson(rootnode,GasSensorEventEntity.class);
|
||||
if(sensorData == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(sensorData.getDeviceid() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
GasSensorEventEntity lastData = (GasSensorEventEntity)sensorData.QueryLast(dataSource);
|
||||
if(lastData == null){
|
||||
lastData = new GasSensorEventEntity();
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS,lastData);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iot/sensor/air/data_list",method = RequestMethod.POST)
|
||||
public RespEntity getGasDeviceDataList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
GasSensorEventEntity sensorData = (GasSensorEventEntity)SQLTools.getEntityFromJson(rootnode,GasSensorEventEntity.class);
|
||||
if(sensorData == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(sensorData.getDeviceid() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> dataList = sensorData.queryPage(dataSource,startstr,endstr,pageindex, pagesize);
|
||||
if(dataList == null){
|
||||
dataList = new ArrayList<>();
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS, dataList);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iot/sensor/clean_water/fly/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getStudentList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
WaterCheckReportEntity waterCheckReport = (WaterCheckReportEntity)SQLTools.getEntityFromJson(rootnode,WaterCheckReportEntity.class);
|
||||
|
||||
if(waterCheckReport==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(waterCheckReport.getBrigade()==null && waterCheckReport.getBorough()==null && waterCheckReport.getDetachment()==null && waterCheckReport.getOwner()==null && waterCheckReport.getTargetDeviceid()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = waterCheckReport.queryPage(dataSource, startstr, endstr, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iot/sensor/clean_water/fly/add",method = RequestMethod.POST)
|
||||
public RespEntity addStudentInfo(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
WaterCheckReportEntity waterCheckReport = (WaterCheckReportEntity) SQLTools.getEntityFromJson(rootnode, WaterCheckReportEntity.class);
|
||||
if (waterCheckReport == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (waterCheckReport.getRecordId() == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if(waterCheckReport.QueryIt(dataSource)!=null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
|
||||
if (waterCheckReport.Insert(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iot/sensor/clean_water/fly/delete",method = RequestMethod.POST)
|
||||
public RespEntity deleteStudentInfo(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
WaterCheckReportEntity waterCheckReport = (WaterCheckReportEntity) SQLTools.getEntityFromJson(rootnode, WaterCheckReportEntity.class);
|
||||
if (waterCheckReport == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (waterCheckReport.getRecordId() == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if(waterCheckReport.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if (waterCheckReport.Delete(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.multiPlatform.MultiAlarmPoint;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.pushalarm.PushAlarmPointEntity;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class MultiAlarmPlatformController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/platform/alarm_point/sync",method = RequestMethod.POST)
|
||||
public RespEntity getPushAlarmPointList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
PushAlarmPointEntity alarmPointEntity = new PushAlarmPointEntity();
|
||||
List<SQLDataObject> list = alarmPointEntity.queryPage(dataSource, null, null, 0, 100000);
|
||||
|
||||
if(list == null || list.isEmpty()){
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
List<MultiAlarmPoint> multiAlarmPointList = new ArrayList<>();
|
||||
for(int iP = 0; iP < list.size(); iP++){
|
||||
PushAlarmPointEntity alarmPoint = (PushAlarmPointEntity)list.get(iP);
|
||||
MultiAlarmPoint tmpPoint = MultiAlarmPoint.copyFromPushPoint(alarmPoint);
|
||||
multiAlarmPointList.add(tmpPoint);
|
||||
}
|
||||
|
||||
HttpURLConnection connLogin;
|
||||
try {
|
||||
String agentUrlLong = "http://175.6.124.250:8082/multialarm/alarm_points/sync" ;
|
||||
System.out.println("process http into inner: url = " + agentUrlLong);
|
||||
connLogin = HttpTools.createHttpConnection(agentUrlLong);
|
||||
connLogin.setRequestMethod("POST");
|
||||
connLogin.setRequestProperty("platKey", "LS0001");
|
||||
connLogin.setRequestProperty("platToken", "LS0001");
|
||||
connLogin.setRequestProperty("Content-Type", "application/json;charset=utf-8");
|
||||
connLogin.connect();
|
||||
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(connLogin.getOutputStream(), "UTF-8"));
|
||||
writer.write(JSON.toJSONString(multiAlarmPointList));
|
||||
writer.close();
|
||||
|
||||
int responseCode = connLogin.getResponseCode();
|
||||
if(responseCode != HttpURLConnection.HTTP_OK){
|
||||
System.out.println("alarm_point sync: fail = " + responseCode);
|
||||
}else{
|
||||
System.out.println("alarm_point sync: ok = " + responseCode);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
System.out.println("alarm_point sync: fail = " + e.getMessage());
|
||||
}finally {
|
||||
|
||||
}
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,388 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.common.service.CountResult;
|
||||
import com.jingyi.iotserver.common.service.EnvConfigService;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.complexquery.AlarmTaskNewResult;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.event.ProcessAlarmEventOpRecord;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.event.SensorAlarmEventEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.ProcessAlarmTaskEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.ProcessAlarmTaskOpRecord;
|
||||
import com.jingyi.iotserver.firestationport.services.SensorService;
|
||||
import com.jingyi.iotserver.firestationport.services.StationServices;
|
||||
import com.jingyi.iotserver.firestationport.websocket.ClientWebsocketManager;
|
||||
import com.jingyi.iotserver.mqtt.MessagePublisher;
|
||||
import com.jingyi.iotserver.utils.*;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class ProcessAlarmTaskController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
@Autowired
|
||||
private SensorService sensorService;
|
||||
|
||||
@Autowired
|
||||
private StationServices stationServices;
|
||||
|
||||
@Autowired
|
||||
private ClientWebsocketManager clientWebsocketManager;
|
||||
|
||||
@Autowired
|
||||
EnvConfigService envConfigService;
|
||||
|
||||
@Autowired
|
||||
private MessagePublisher messagePublisher;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ProcessAlarmTaskController.class);
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/alarmtask/add",method = RequestMethod.POST)
|
||||
public RespEntity createAlarmTask(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
ProcessAlarmTaskEntity task = (ProcessAlarmTaskEntity) SQLTools.getEntityFromJson(rootnode,ProcessAlarmTaskEntity.class);
|
||||
JsonNode opnode = JsonHelper.getLevel2(rootnode,"operator");
|
||||
|
||||
if(task==null||task.getReceiver()==null||task.getRelatealarmid()==null||opnode==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
String [] rvcs = task.getReceiver().split("##");
|
||||
if(rvcs==null||rvcs.length<=0||rvcs[0].length()<=0)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
ArrayList<AlarmTaskNewResult> results = new ArrayList<AlarmTaskNewResult>();
|
||||
for(int i=0;i<rvcs.length;i++) {
|
||||
String alarmid = GUIDUtil.GeneralAppkey();
|
||||
task.setTaskid(alarmid);
|
||||
task.setClosetime(null);
|
||||
task.setCreatetime(new Date());
|
||||
task.setStatus("created");
|
||||
task.setReceiver(rvcs[i]);
|
||||
int count = 0;
|
||||
while (task.QueryIt(dataSource) != null) {
|
||||
if (count > 10) {
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
count++;
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
task.setTaskid(GUIDUtil.GeneralAppkey());
|
||||
}
|
||||
if (!task.Insert(dataSource)) {
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
ProcessAlarmTaskOpRecord op = (ProcessAlarmTaskOpRecord) SQLTools.getEntityFromJson(opnode, ProcessAlarmTaskOpRecord.class);
|
||||
if (op != null) {
|
||||
op.setOperation("create");
|
||||
op.setTaskid(task.getTaskid());
|
||||
op.setRelatealarmid(task.getRelatealarmid());
|
||||
op.setTimestamp(new Date());
|
||||
op.setReceiver(task.getReceiver());
|
||||
try {
|
||||
op.setResult(Base64.encodeBase64String(rootnode.toString().getBytes("UTF8")));
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
op.Insert(dataSource);
|
||||
}
|
||||
AlarmTaskNewResult r = new AlarmTaskNewResult();
|
||||
r.setReceiver(task.getReceiver());
|
||||
r.setTaskid(task.getTaskid());
|
||||
results.add(r);
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS,results);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/alarmtask/update",method = RequestMethod.POST)
|
||||
public RespEntity updateAlarmTask(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
ProcessAlarmTaskEntity task = new ProcessAlarmTaskEntity();
|
||||
JsonNode opnode = JsonHelper.getLevel2(rootnode,"operator");
|
||||
|
||||
task.setTaskid(JsonHelper.getStringValue(rootnode,"taskid"));
|
||||
task.setLongitude(JsonHelper.getDoubleValue(rootnode,"longitude"));
|
||||
task.setLatitude(JsonHelper.getDoubleValue(rootnode,"latitude"));
|
||||
task.setContent(JsonHelper.getStringValue(rootnode,"content"));
|
||||
task.setType(JsonHelper.getStringValue(rootnode,"type"));
|
||||
task.setAddress(JsonHelper.getStringValue(rootnode,"address"));
|
||||
task.setTitle(JsonHelper.getStringValue(rootnode,"title"));
|
||||
if(task.getTaskid()==null||opnode==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
ProcessAlarmTaskEntity orgtask = (ProcessAlarmTaskEntity)task.QueryIt(dataSource);
|
||||
if(orgtask==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
|
||||
if (task.Update(dataSource)) {
|
||||
ProcessAlarmTaskOpRecord op = (ProcessAlarmTaskOpRecord) SQLTools.getEntityFromJson(opnode,ProcessAlarmTaskOpRecord.class);
|
||||
if(op!=null){
|
||||
op.setOperation("updateinfo");
|
||||
try {
|
||||
op.setResult(Base64.encodeBase64String(rootnode.toString().getBytes("UTF8")));
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
op.setTaskid(orgtask.getTaskid());
|
||||
op.setRelatealarmid(orgtask.getRelatealarmid());
|
||||
op.setTimestamp(new Date());
|
||||
op.setReceiver(orgtask.getReceiver());
|
||||
op.Insert(dataSource);
|
||||
}
|
||||
}else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/alarmtask/setstatus",method = RequestMethod.POST)
|
||||
public RespEntity setAlarmTaskStatus(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
ProcessAlarmTaskEntity task = new ProcessAlarmTaskEntity();
|
||||
JsonNode opnode = JsonHelper.getLevel2(rootnode,"operator");
|
||||
|
||||
task.setTaskid(JsonHelper.getStringValue(rootnode,"taskid"));
|
||||
task.setStatus(JsonHelper.getStringValue(rootnode,"status"));
|
||||
if(task.getStatus()!=null&&task.getStatus().equals("closed")){
|
||||
task.setClosetime(new Date());
|
||||
}
|
||||
if(task.getTaskid()==null||opnode==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
ProcessAlarmTaskEntity orgtask = (ProcessAlarmTaskEntity)task.QueryIt(dataSource);
|
||||
if(orgtask==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
|
||||
if (task.Update(dataSource)) {
|
||||
ProcessAlarmTaskOpRecord op = (ProcessAlarmTaskOpRecord) SQLTools.getEntityFromJson(opnode,ProcessAlarmTaskOpRecord.class);
|
||||
if(op!=null){
|
||||
op.setOperation("updatestatus");
|
||||
try {
|
||||
op.setResult(Base64.encodeBase64String(task.getStatus().getBytes("UTF8")));
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
op.setTaskid(orgtask.getTaskid());
|
||||
op.setRelatealarmid(orgtask.getRelatealarmid());
|
||||
op.setTimestamp(new Date());
|
||||
op.setReceiver(orgtask.getReceiver());
|
||||
op.Insert(dataSource);
|
||||
}
|
||||
}else
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/alarmtask/gettaskcount",method = RequestMethod.POST)
|
||||
public RespEntity getAlarmTaskCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
ProcessAlarmTaskEntity task = (ProcessAlarmTaskEntity) SQLTools.getEntityFromJson(rootnode,ProcessAlarmTaskEntity.class);
|
||||
|
||||
if(task==null)
|
||||
task = new ProcessAlarmTaskEntity();
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
|
||||
int count = task.queryCount(dataSource, startstr, endstr);
|
||||
return new RespEntity(RespCode.SUCCESS, new CountResult(count));
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/alarmtask/gettasklist",method = RequestMethod.POST)
|
||||
public RespEntity getAlarmTaskList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
ProcessAlarmTaskEntity task = (ProcessAlarmTaskEntity) SQLTools.getEntityFromJson(rootnode,ProcessAlarmTaskEntity.class);
|
||||
|
||||
if(task==null)
|
||||
task = new ProcessAlarmTaskEntity();
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 100;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = task.queryPage(dataSource, startstr, endstr, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/alarmtask/gettaskcount_diffstatus",method = RequestMethod.POST)
|
||||
public RespEntity getAlarmTaskCountDiffstatus(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
ProcessAlarmTaskEntity task = (ProcessAlarmTaskEntity) SQLTools.getEntityFromJson(rootnode,ProcessAlarmTaskEntity.class);
|
||||
task.addDiffCond("status");
|
||||
if(task.getStatus()==null)
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
if(task==null)
|
||||
task = new ProcessAlarmTaskEntity();
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
|
||||
int count = task.queryCount(dataSource, startstr, endstr);
|
||||
return new RespEntity(RespCode.SUCCESS, new CountResult(count));
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/alarmtask/gettasklist_diffstatus",method = RequestMethod.POST)
|
||||
public RespEntity getAlarmTaskListDiffstatus(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
ProcessAlarmTaskEntity task = (ProcessAlarmTaskEntity) SQLTools.getEntityFromJson(rootnode,ProcessAlarmTaskEntity.class);
|
||||
if(task.getStatus()==null)
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
if(task==null)
|
||||
task = new ProcessAlarmTaskEntity();
|
||||
task.addDiffCond("status");
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 100;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = task.queryPage(dataSource, startstr, endstr, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/alarmtask/gettaskopcount",method = RequestMethod.POST)
|
||||
public RespEntity getAlarmTaskOPCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
ProcessAlarmTaskOpRecord task = (ProcessAlarmTaskOpRecord) SQLTools.getEntityFromJson(rootnode,ProcessAlarmTaskOpRecord.class);
|
||||
|
||||
if(task==null)
|
||||
task = new ProcessAlarmTaskOpRecord();
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
|
||||
int count = task.queryCount(dataSource, startstr, endstr);
|
||||
return new RespEntity(RespCode.SUCCESS, new CountResult(count));
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/alarmtask/gettaskoplist",method = RequestMethod.POST)
|
||||
public RespEntity getAlarmTaskOPList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
ProcessAlarmTaskOpRecord op = (ProcessAlarmTaskOpRecord) SQLTools.getEntityFromJson(rootnode,ProcessAlarmTaskOpRecord.class);
|
||||
|
||||
if(op==null)
|
||||
op = new ProcessAlarmTaskOpRecord();
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 100;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = op.queryPage(dataSource, startstr, endstr, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/alarm_event/changestate",method = RequestMethod.POST)
|
||||
public RespEntity changeSensorAlarmEvent(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
|
||||
ProcessAlarmEventOpRecord eventOpRecord = (ProcessAlarmEventOpRecord) SQLTools.getEntityFromJson(rootnode, ProcessAlarmEventOpRecord.class);
|
||||
if(eventOpRecord==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(eventOpRecord.getEventId() == null || eventOpRecord.getNewState() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
SensorAlarmEventEntity eventDB = new SensorAlarmEventEntity();
|
||||
eventDB.setEventId(eventOpRecord.getEventId());
|
||||
eventDB = (SensorAlarmEventEntity)eventDB.QueryIt(dataSource);
|
||||
if(eventDB != null) {
|
||||
Date recordTime = new Date();
|
||||
eventOpRecord.setPreviousState(eventDB.getState());
|
||||
eventDB.setState(eventOpRecord.getNewState());
|
||||
eventDB.setStateTime(recordTime);
|
||||
if(eventDB.Update(dataSource)) {
|
||||
eventOpRecord.setRecordId(eventDB.getEventId() + "_" + recordTime.getTime());
|
||||
eventOpRecord.setTimestamp(recordTime);
|
||||
|
||||
eventOpRecord.Insert(dataSource);
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
}else
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/alarm_event/getlog",method = RequestMethod.POST)
|
||||
public RespEntity getSensorAlarmEventOpList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
|
||||
ProcessAlarmEventOpRecord eventOpRecord = (ProcessAlarmEventOpRecord) SQLTools.getEntityFromJson(rootnode, ProcessAlarmEventOpRecord.class);
|
||||
if(eventOpRecord==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(eventOpRecord.getEventId() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
List<SQLDataObject> list = eventOpRecord.queryPage(dataSource, null, null, 0, 2000);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.FireCtrlSystemInit;
|
||||
import com.jingyi.iotserver.firestationport.model.publicsafe.PublicAlarmEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.school.PendingProcessItem;
|
||||
import com.jingyi.iotserver.firestationport.model.school.SchoolPendingItem;
|
||||
import com.jingyi.iotserver.firestationport.model.school.SchoolPendingProcessRecordEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.school.SchoolSecurityCheckEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.pushalarm.PushAlarmPointEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationBaseInfoEntity;
|
||||
import com.jingyi.iotserver.firestationport.services.SensorService;
|
||||
import com.jingyi.iotserver.firestationport.websocket.ClientWebsocketManager;
|
||||
import com.jingyi.iotserver.iotctrl.IoTCtrlServer;
|
||||
import com.jingyi.iotserver.iotctrl.UDPAgentPackage;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class PublicAlarmController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private IoTCtrlServer ioTCtrlServer;
|
||||
|
||||
@Autowired
|
||||
private ClientWebsocketManager clientWebsocketManager;
|
||||
|
||||
@Autowired
|
||||
private SensorService sensorService;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/public/alarm/add",method = RequestMethod.POST)
|
||||
public RespEntity addPublicAlarmInfo(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
PublicAlarmEntity publicAlarm = (PublicAlarmEntity) SQLTools.getEntityFromJson(rootnode,PublicAlarmEntity.class);
|
||||
|
||||
if(publicAlarm==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
publicAlarm.setAlarmId(UUID.randomUUID().toString());
|
||||
publicAlarm.setReportTime(new Date());
|
||||
publicAlarm.setStatus(PublicAlarmEntity.STATE_OPEN);
|
||||
publicAlarm.setCheckResult(PublicAlarmEntity.RESULT_NO);
|
||||
if(FireCtrlSystemInit.netMode == 1){
|
||||
sensorService.addWechatAlarmEvent(publicAlarm);
|
||||
ioTCtrlServer.translateHttp2Skynet(UDPAgentPackage.TYPE_School_Check, JSON.toJSONString(publicAlarm), "/iotserver/school/check/add");
|
||||
}
|
||||
|
||||
if (!publicAlarm.Insert(dataSource)) {
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/iotserver/public/alarm/getlist",method = RequestMethod.POST)
|
||||
public RespEntity get(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
PublicAlarmEntity publicAlarm = (PublicAlarmEntity) SQLTools.getEntityFromJson(rootnode,PublicAlarmEntity.class);
|
||||
|
||||
if(publicAlarm==null)
|
||||
publicAlarm = new PublicAlarmEntity();
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
String startstr = JsonHelper.getStringValue(rootnode,"start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode,"end");
|
||||
|
||||
List<SQLDataObject> list = publicAlarm.queryPage(dataSource, startstr, endstr, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,689 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.clientmanage.UserAuthorManager;
|
||||
import com.jingyi.iotserver.common.service.CountResult;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.FireCtrlSystemInit;
|
||||
import com.jingyi.iotserver.firestationport.model.school.SchoolNewsEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.SensorDeviceEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.gas.DataDescriptionEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.pushalarm.PushAlarmPointEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.rfid.RfidAntDetectorEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.rfid.RfidBuzEventEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.rfid.RfidEventEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.rfid.RfidStateEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationBaseInfoEntity;
|
||||
import com.jingyi.iotserver.firestationport.services.StationServices;
|
||||
import com.jingyi.iotserver.iotctrl.IoTCtrlServer;
|
||||
import com.jingyi.iotserver.iotctrl.UDPAgentPackage;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class RfidController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private StationServices stationServices;
|
||||
|
||||
@Autowired
|
||||
private IoTCtrlServer ioTCtrlServer;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(RfidController.class);
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/detectant/add",method = RequestMethod.POST)
|
||||
public RespEntity addRfidDetect(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
RfidAntDetectorEntity detector = (RfidAntDetectorEntity) SQLTools.getEntityFromJson(rootnode,RfidAntDetectorEntity.class);
|
||||
if(detector==null||detector.getRfidreader()==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(detector.QueryIt(dataSource)!=null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
if(detector.Insert(dataSource))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/detectant/delete",method = RequestMethod.POST)
|
||||
public RespEntity deleteRfidDetect(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
RfidAntDetectorEntity detector = (RfidAntDetectorEntity) SQLTools.getEntityFromJson(rootnode,RfidAntDetectorEntity.class);
|
||||
if(detector==null||detector.getRfidreader()==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(detector.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(detector.Delete(dataSource))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/detectant/update",method = RequestMethod.POST)
|
||||
public RespEntity updateRfidDetect(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
RfidAntDetectorEntity detector = (RfidAntDetectorEntity) SQLTools.getEntityFromJson(rootnode,RfidAntDetectorEntity.class);
|
||||
if(detector==null||detector.getRfidreader()==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(detector.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(detector.Update(dataSource))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/detectant/getcount",method = RequestMethod.POST)
|
||||
public RespEntity getDetectorCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
RfidAntDetectorEntity detector = (RfidAntDetectorEntity) SQLTools.getEntityFromJson(rootnode,RfidAntDetectorEntity.class);
|
||||
|
||||
if(detector==null)
|
||||
detector = new RfidAntDetectorEntity();
|
||||
int count = detector.queryCount(dataSource,null,null);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/detectant/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getDetectorList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
|
||||
RfidAntDetectorEntity detector = (RfidAntDetectorEntity) SQLTools.getEntityFromJson(rootnode,RfidAntDetectorEntity.class);
|
||||
|
||||
if(detector==null)
|
||||
detector = new RfidAntDetectorEntity();
|
||||
List<SQLDataObject> list = detector.queryPage(dataSource,null,null,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/add",method = RequestMethod.POST)
|
||||
public RespEntity addRfid(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
RfidStateEntity rfid = (RfidStateEntity) SQLTools.getEntityFromJson(rootnode,RfidStateEntity.class);
|
||||
if(rfid==null||rfid.getRfid()==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(rfid.QueryIt(dataSource)!=null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
if(rfid.Insert(dataSource))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/delete",method = RequestMethod.POST)
|
||||
public RespEntity deleteRfid(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
RfidStateEntity rfid = (RfidStateEntity) SQLTools.getEntityFromJson(rootnode,RfidStateEntity.class);
|
||||
if(rfid==null||rfid.getRfid()==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(rfid.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(rfid.Delete(dataSource))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/update",method = RequestMethod.POST)
|
||||
public RespEntity updateRfid(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
RfidStateEntity rfid = (RfidStateEntity) SQLTools.getEntityFromJson(rootnode,RfidStateEntity.class);
|
||||
if(rfid==null||rfid.getRfid()==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(rfid.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(rfid.Update(dataSource))
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/getcount",method = RequestMethod.POST)
|
||||
public RespEntity getRfidCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
RfidStateEntity rfid = (RfidStateEntity) SQLTools.getEntityFromJson(rootnode,RfidStateEntity.class);
|
||||
|
||||
if(rfid==null)
|
||||
rfid = new RfidStateEntity();
|
||||
int count = rfid.queryCount(dataSource,null,null);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getRfidList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
|
||||
RfidStateEntity rfid = (RfidStateEntity) SQLTools.getEntityFromJson(rootnode,RfidStateEntity.class);
|
||||
|
||||
if(rfid==null)
|
||||
rfid = new RfidStateEntity();
|
||||
List<SQLDataObject> list = rfid.queryPage(dataSource,null,null,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/buzevent/getcount",method = RequestMethod.POST)
|
||||
public RespEntity getRfidBuzEventCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
RfidBuzEventEntity event = (RfidBuzEventEntity) SQLTools.getEntityFromJson(rootnode,RfidBuzEventEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
if(event==null)
|
||||
event = new RfidBuzEventEntity();
|
||||
int count = event.queryCount(dataSource,startstr,endstr);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/buzevent/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getRfidBuzEventList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
|
||||
RfidBuzEventEntity event = (RfidBuzEventEntity) SQLTools.getEntityFromJson(rootnode,RfidBuzEventEntity.class);
|
||||
|
||||
if(event==null)
|
||||
event = new RfidBuzEventEntity();
|
||||
List<SQLDataObject> list = event.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/event/getcount",method = RequestMethod.POST)
|
||||
public RespEntity getRfidEventCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
RfidEventEntity event = (RfidEventEntity) SQLTools.getEntityFromJson(rootnode, RfidEventEntity.class);
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
if(event==null)
|
||||
event = new RfidEventEntity();
|
||||
int count = event.queryCount(dataSource,startstr,endstr);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/sensor/rfid/event/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getRfidEventList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
String startstr = JsonHelper.getStringValue(rootnode, "start");
|
||||
String endstr = JsonHelper.getStringValue(rootnode, "end");
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
|
||||
RfidEventEntity event = (RfidEventEntity) SQLTools.getEntityFromJson(rootnode,RfidEventEntity.class);
|
||||
|
||||
if(event==null)
|
||||
event = new RfidEventEntity();
|
||||
List<SQLDataObject> list = event.queryPage(dataSource,startstr,endstr,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/push_alarm_point/add",method = RequestMethod.POST)
|
||||
public RespEntity addPushAlarmPoint(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
String bodyData = HttpTools.getBodyFromRequest(request);
|
||||
if (bodyData != null) {
|
||||
if(FireCtrlSystemInit.netMode == 1){
|
||||
ioTCtrlServer.translateHttp2Skynet(UDPAgentPackage.TYPE_Http_Agent, bodyData, "/firectrl/push_alarm_point/add");
|
||||
}
|
||||
PushAlarmPointEntity alarmPointEntity = JSON.parseObject(bodyData, PushAlarmPointEntity.class);// SQLTools.getEntityFromJson(rootnode, PushAlarmPointEntity.class);
|
||||
|
||||
if (alarmPointEntity == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (alarmPointEntity.getPointCode() == null || alarmPointEntity.getBrigade() == null || alarmPointEntity.getAccount() == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
|
||||
alarmPointEntity.setPointId(alarmPointEntity.getAccount() + "_" + alarmPointEntity.getPointCode());
|
||||
if(alarmPointEntity.QueryIt(dataSource)!=null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
if (alarmPointEntity.Insert(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/push_alarm_point/update",method = RequestMethod.POST)
|
||||
public RespEntity updatePushAlarmPoint(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
String bodyData = HttpTools.getBodyFromRequest(request);
|
||||
System.out.println("updatePushAlarmPoint: 0 " + bodyData);
|
||||
if (bodyData != null) {
|
||||
PushAlarmPointEntity pointEntity = JSON.parseObject(bodyData, PushAlarmPointEntity.class);
|
||||
|
||||
if(FireCtrlSystemInit.netMode == 1){
|
||||
ioTCtrlServer.translateHttp2Skynet(UDPAgentPackage.TYPE_Http_Agent, bodyData, "/firectrl/push_alarm_point/update");
|
||||
}
|
||||
System.out.println("updatePushAlarmPoint: 1");
|
||||
if (pointEntity == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
|
||||
System.out.println("updatePushAlarmPoint: 2");
|
||||
if (pointEntity.getPointId() == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
|
||||
System.out.println("updatePushAlarmPoint: 3");
|
||||
if(pointEntity.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
|
||||
if (pointEntity.Update(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/push_alarm_point/delete",method = RequestMethod.POST)
|
||||
public RespEntity deletePushAlarmPoint(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
String bodyData = HttpTools.getBodyFromRequest(request);
|
||||
if (bodyData != null) {
|
||||
PushAlarmPointEntity pointEntity = JSON.parseObject(bodyData, PushAlarmPointEntity.class);
|
||||
|
||||
if(FireCtrlSystemInit.netMode == 1){
|
||||
ioTCtrlServer.translateHttp2Skynet(UDPAgentPackage.TYPE_Http_Agent, bodyData, "/firectrl/push_alarm_point/delete");
|
||||
}
|
||||
|
||||
if (pointEntity == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (pointEntity.getPointId() == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if(pointEntity.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if (pointEntity.Delete(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/push_alarm_point/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getPushAlarmPoint(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
PushAlarmPointEntity pointEntity = (PushAlarmPointEntity)SQLTools.getEntityFromJson(rootnode,PushAlarmPointEntity.class);
|
||||
|
||||
if(pointEntity==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(pointEntity.getBrigade()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = pointEntity.queryPage(dataSource, null, null, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/push_alarm_point/dwmc",method = RequestMethod.POST)
|
||||
public RespEntity getPushAlarmPointInfo(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
PushAlarmPointEntity pointEntity = (PushAlarmPointEntity)SQLTools.getEntityFromJson(rootnode,PushAlarmPointEntity.class);
|
||||
|
||||
if(pointEntity==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
if(pointEntity.getDwmc()==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
PushAlarmPointEntity list = PushAlarmPointEntity.QueryStationName(dataSource, pointEntity.getDwmc());
|
||||
if(list == null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
/*
|
||||
传感器数值描述表
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/data_description/add",method = RequestMethod.POST)
|
||||
public RespEntity addDataDescription(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
String bodyData = HttpTools.getBodyFromRequest(request);
|
||||
if (bodyData != null) {
|
||||
|
||||
DataDescriptionEntity alarmPointEntity = JSON.parseObject(bodyData, DataDescriptionEntity.class);
|
||||
if (alarmPointEntity == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (alarmPointEntity.getName() == null || alarmPointEntity.getType() == null )
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
|
||||
if(alarmPointEntity.QueryIt(dataSource)!=null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
if (alarmPointEntity.Insert(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/data_description/update",method = RequestMethod.POST)
|
||||
public RespEntity updateDataDescription(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
String bodyData = HttpTools.getBodyFromRequest(request);
|
||||
if (bodyData != null) {
|
||||
DataDescriptionEntity pointEntity = JSON.parseObject(bodyData, DataDescriptionEntity.class);
|
||||
|
||||
if (pointEntity == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (pointEntity.getName() == null || pointEntity.getType() == null )
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
|
||||
if(pointEntity.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if (pointEntity.Update(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/data_description/delete",method = RequestMethod.POST)
|
||||
public RespEntity deleteDataDescription(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
String bodyData = HttpTools.getBodyFromRequest(request);
|
||||
if (bodyData != null) {
|
||||
DataDescriptionEntity pointEntity = JSON.parseObject(bodyData, DataDescriptionEntity.class);
|
||||
|
||||
if (pointEntity == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (pointEntity.getName() == null || pointEntity.getType() == null )
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if(pointEntity.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if (pointEntity.Delete(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/data_description/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getDataDescriptionList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
DataDescriptionEntity pointEntity = (DataDescriptionEntity)SQLTools.getEntityFromJson(rootnode,PushAlarmPointEntity.class);
|
||||
|
||||
if(pointEntity==null)
|
||||
pointEntity = new DataDescriptionEntity();
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = pointEntity.queryPage(dataSource, null, null, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,236 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.common.service.CountResult;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.person.PersonLogEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.person.SecurityPersonEntity;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class SecurityPersonController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/security/person/add",method = RequestMethod.POST)
|
||||
public RespEntity addSecurityPerson(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
SecurityPersonEntity securityPerson = (SecurityPersonEntity) SQLTools.getEntityFromJson(rootnode,SecurityPersonEntity.class);
|
||||
if(securityPerson==null||securityPerson.getName()==null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(securityPerson.getStaffId() == null){
|
||||
securityPerson.setStaffId(UUID.randomUUID().toString());
|
||||
}
|
||||
if(securityPerson.QueryIt(dataSource)!=null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
if(securityPerson.Insert(dataSource)){
|
||||
PersonLogEntity personLog = new PersonLogEntity(securityPerson);
|
||||
personLog.setOperationType(PersonLogEntity.Operation_Type_Info_Add);
|
||||
personLog.setPreviousData("");
|
||||
personLog.setNowData(JSON.toJSONString(securityPerson));
|
||||
personLog.Insert(dataSource);
|
||||
return new RespEntity(RespCode.SUCCESS, securityPerson);
|
||||
}
|
||||
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/security/person/delete",method = RequestMethod.POST)
|
||||
public RespEntity deleteSecurityPerson(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
SecurityPersonEntity securityPerson = (SecurityPersonEntity) SQLTools.getEntityFromJson(rootnode,SecurityPersonEntity.class);
|
||||
if(securityPerson==null||securityPerson.getStaffId()==null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
SecurityPersonEntity tgtPerson = (SecurityPersonEntity)securityPerson.QueryIt(dataSource);
|
||||
if(tgtPerson == null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if(securityPerson.Delete(dataSource)){
|
||||
PersonLogEntity personLog = new PersonLogEntity(tgtPerson);
|
||||
personLog.setOperationType(PersonLogEntity.Operation_Type_Info_Delete);
|
||||
personLog.setNowData("");
|
||||
personLog.setPreviousData(JSON.toJSONString(securityPerson));
|
||||
personLog.Insert(dataSource);
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/security/person/update",method = RequestMethod.POST)
|
||||
public RespEntity updateSecurityPerson(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
SecurityPersonEntity securityPerson = (SecurityPersonEntity) SQLTools.getEntityFromJson(rootnode,SecurityPersonEntity.class);
|
||||
if(securityPerson==null||securityPerson.getStaffId()==null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
SecurityPersonEntity tgtPerson = (SecurityPersonEntity)securityPerson.QueryIt(dataSource);
|
||||
if(tgtPerson == null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
|
||||
if(securityPerson.Update(dataSource)) {
|
||||
PersonLogEntity personLog = new PersonLogEntity(tgtPerson);
|
||||
personLog.setOperationType(PersonLogEntity.Operation_Type_Info_Modify);
|
||||
personLog.Insert(dataSource);
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/security/person/move",method = RequestMethod.POST)
|
||||
public RespEntity moveSecurityPerson(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
SecurityPersonEntity securityPerson = (SecurityPersonEntity) SQLTools.getEntityFromJson(rootnode,SecurityPersonEntity.class);
|
||||
if(securityPerson==null||securityPerson.getStaffId()==null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
SecurityPersonEntity tgtPerson = (SecurityPersonEntity)securityPerson.QueryIt(dataSource);
|
||||
if(tgtPerson == null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
|
||||
if(securityPerson.Update(dataSource)) {
|
||||
PersonLogEntity personLog = new PersonLogEntity(tgtPerson);
|
||||
personLog.setOperationType(PersonLogEntity.Operation_Type_Org_Modify);
|
||||
personLog.Insert(dataSource);
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/security/person/change_device",method = RequestMethod.POST)
|
||||
public RespEntity changePersonDevice(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
SecurityPersonEntity securityPerson = (SecurityPersonEntity) SQLTools.getEntityFromJson(rootnode,SecurityPersonEntity.class);
|
||||
if(securityPerson==null||securityPerson.getStaffId()==null||securityPerson.getDeviceId()==null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
SecurityPersonEntity tgtPerson = (SecurityPersonEntity)securityPerson.QueryIt(dataSource);
|
||||
if(tgtPerson == null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
|
||||
if(securityPerson.Update(dataSource)) {
|
||||
PersonLogEntity personLog = new PersonLogEntity(tgtPerson);
|
||||
personLog.setOperationType(PersonLogEntity.Operation_Type_Device_Change);
|
||||
personLog.setPreviousData(tgtPerson.getDeviceId());
|
||||
personLog.setNowData(securityPerson.getDeviceId());
|
||||
personLog.Insert(dataSource);
|
||||
return new RespEntity(RespCode.SUCCESS);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/security/person/count",method = RequestMethod.POST)
|
||||
public RespEntity getSecurityPersonCount(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
SecurityPersonEntity securityPerson = (SecurityPersonEntity) SQLTools.getEntityFromJson(rootnode,SecurityPersonEntity.class);
|
||||
|
||||
if(securityPerson==null)
|
||||
securityPerson = new SecurityPersonEntity();
|
||||
int count = securityPerson.queryCount(dataSource,null,null);
|
||||
CountResult reulst = new CountResult();
|
||||
reulst.setCount(count);
|
||||
return new RespEntity(RespCode.SUCCESS,reulst);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/client/security/person/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getSecurityPersonList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if(rootnode==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
int pagesize = JsonHelper.getIntValue(rootnode,"pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode,"pageindex");
|
||||
if(pagesize<=0)
|
||||
pagesize = 100;
|
||||
if(pageindex<0)
|
||||
pageindex = 0;
|
||||
|
||||
SecurityPersonEntity securityPerson = (SecurityPersonEntity) SQLTools.getEntityFromJson(rootnode,SecurityPersonEntity.class);
|
||||
|
||||
if(securityPerson==null)
|
||||
securityPerson = new SecurityPersonEntity();
|
||||
List<SQLDataObject> list = securityPerson.queryPage(dataSource,null,null,pageindex,pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.mdev.MDevPictureEntity;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.sql.DataSource;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class StationPictureController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/mdev/picture/upload", method = RequestMethod.POST)
|
||||
public RespEntity uploadFile(@RequestParam("jsondata") String jsondata, @RequestParam("file") MultipartFile file) {
|
||||
String path = "./pic";
|
||||
String filename ;//获取文件名
|
||||
File dir = new File(path);
|
||||
if(!dir.exists()){
|
||||
dir.mkdir();
|
||||
}
|
||||
MDevPictureEntity p = null;
|
||||
{
|
||||
try {
|
||||
JsonNode rootnode = JsonHelper.parseBodyLevel1( jsondata);
|
||||
if (rootnode != null) {
|
||||
p = (MDevPictureEntity) SQLTools.getEntityFromJson(rootnode, MDevPictureEntity.class);
|
||||
if(p==null)
|
||||
{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
String uri = "/mdev/pic/download?creator=";
|
||||
if(p.getCreator()!=null&&p.getCreator().length()>0) {
|
||||
uri += p.getCreator();
|
||||
path += "/"+p.getCreator();
|
||||
dir = new File(path);
|
||||
if(!dir.exists()){
|
||||
dir.mkdir();
|
||||
}
|
||||
}
|
||||
if(p.getId() == null){
|
||||
p.setId(UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
p.setUploadtime(new Date());
|
||||
if(!p.Insert(dataSource))
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
|
||||
MDevPictureEntity pupdate = new MDevPictureEntity();
|
||||
pupdate.setId(p.getId());
|
||||
filename = p.getId()+".jpg";
|
||||
pupdate.setFilename(filename);
|
||||
uri += "&file="+filename;
|
||||
pupdate.setUri(uri);
|
||||
p.setFilename(filename);
|
||||
p.setUri(uri);
|
||||
if(!pupdate.Update(dataSource))
|
||||
{
|
||||
return new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}else{
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
}
|
||||
|
||||
if (!file.isEmpty()) {
|
||||
|
||||
try {
|
||||
InputStream ins = file.getInputStream();
|
||||
|
||||
BufferedOutputStream out = new BufferedOutputStream(
|
||||
new FileOutputStream(new File(path + File.separator + filename)));
|
||||
|
||||
byte[] buffer = new byte[128*1024];
|
||||
int len = 0;
|
||||
while((len = ins.read(buffer)) != -1) {
|
||||
out.write(buffer,0,len);
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
return new RespEntity(RespCode.SUCCESS,p);
|
||||
} catch (FileNotFoundException e) {
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
} catch (IOException e) {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
} else {
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/mdev/pic/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getStationMobleList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode = HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode == null) {
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
MDevPictureEntity p = (MDevPictureEntity) SQLTools.getEntityFromJson(rootnode, MDevPictureEntity.class);
|
||||
if(p==null)
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
|
||||
List<SQLDataObject> list = p.queryList(dataSource,null,null);
|
||||
rel = new RespEntity(RespCode.SUCCESS,list);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
///https://www.genetek.cc:8086/medev/pic/download?creator=weizhan&file=12333
|
||||
@RequestMapping(value="/mdev/pic/download")
|
||||
public void downloadMap(String creator,String file,HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
String path = "./pic";
|
||||
|
||||
if(creator!=null&&creator.length()>0)
|
||||
path += "/"+creator;
|
||||
if(file==null||file.length()<=0)
|
||||
{
|
||||
response.sendError(707);
|
||||
return;
|
||||
}
|
||||
String fileName = file;
|
||||
//获取输入流对象(用于读文件)
|
||||
FileInputStream fis = new FileInputStream(new File(path, fileName));
|
||||
//获取文件后缀(.txt)
|
||||
String extendFileName = fileName.substring(fileName.lastIndexOf('.'));
|
||||
//动态设置响应类型,根据前台传递文件类型设置响应类型
|
||||
response.setContentType(request.getSession().getServletContext().getMimeType(extendFileName));
|
||||
//设置响应头,attachment表示以附件的形式下载,inline表示在线打开
|
||||
response.setHeader("content-disposition","attachment;fileName="+ URLEncoder.encode(fileName,"UTF-8"));
|
||||
//获取输出流对象(用于写文件)
|
||||
ServletOutputStream os = response.getOutputStream();
|
||||
//下载文件,使用spring框架中的FileCopyUtils工具
|
||||
FileCopyUtils.copy(fis,os);
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value="/mdev/pic/downloadId")
|
||||
public void downloadPictureById(String id,HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
String path = "./pic";
|
||||
if(id == null){
|
||||
return;
|
||||
}
|
||||
MDevPictureEntity pictureEntity = new MDevPictureEntity();
|
||||
pictureEntity.setId(id);
|
||||
MDevPictureEntity pictureInDB = (MDevPictureEntity)pictureEntity.QueryIt(dataSource);
|
||||
if(pictureInDB == null){
|
||||
response.sendError(707);
|
||||
return;
|
||||
}
|
||||
String creator = pictureInDB.getCreator();
|
||||
String file = pictureInDB.getFilename();
|
||||
|
||||
if(creator!=null&&creator.length()>0)
|
||||
path += "/"+creator;
|
||||
if(file==null||file.length()<=0) {
|
||||
response.sendError(707);
|
||||
return;
|
||||
}
|
||||
String fileName = file;
|
||||
//获取输入流对象(用于读文件)
|
||||
FileInputStream fis = new FileInputStream(new File(path, fileName));
|
||||
//获取文件后缀(.txt)
|
||||
String extendFileName = fileName.substring(fileName.lastIndexOf('.'));
|
||||
//动态设置响应类型,根据前台传递文件类型设置响应类型
|
||||
response.setContentType(request.getSession().getServletContext().getMimeType(extendFileName));
|
||||
//设置响应头,attachment表示以附件的形式下载,inline表示在线打开
|
||||
response.setHeader("content-disposition","attachment;fileName="+ URLEncoder.encode(fileName,"UTF-8"));
|
||||
//获取输出流对象(用于写文件)
|
||||
ServletOutputStream os = response.getOutputStream();
|
||||
//下载文件,使用spring框架中的FileCopyUtils工具
|
||||
FileCopyUtils.copy(fis,os);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,632 @@
|
|||
package com.jingyi.iotserver.firestationport.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.jingyi.iotserver.common.service.RespCode;
|
||||
import com.jingyi.iotserver.common.service.RespEntity;
|
||||
import com.jingyi.iotserver.firestationport.model.school.ImportantStation;
|
||||
import com.jingyi.iotserver.firestationport.model.sensor.water.*;
|
||||
import com.jingyi.iotserver.firestationport.model.station.FireStationBaseInfoEntity;
|
||||
import com.jingyi.iotserver.utils.HttpTools;
|
||||
import com.jingyi.iotserver.utils.JsonHelper;
|
||||
import com.jingyi.iotserver.utils.SQLDataObject;
|
||||
import com.jingyi.iotserver.utils.SQLTools;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class WaterDeviceController {
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/waterfilter/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getWaterFilterList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
WaterFilterEntity waterFilter = (WaterFilterEntity) SQLTools.getEntityFromJson(rootnode,WaterFilterEntity.class);
|
||||
|
||||
if(waterFilter==null)
|
||||
waterFilter = new WaterFilterEntity();
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = waterFilter.queryPage(dataSource, null, null, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/waterfilter/add",method = RequestMethod.POST)
|
||||
public RespEntity addWaterFilterInfo(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
WaterFilterEntity waterFilter = (WaterFilterEntity) SQLTools.getEntityFromJson(rootnode, WaterFilterEntity.class);
|
||||
if (waterFilter == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (waterFilter.getFilterId() == null || waterFilter.getWaterDeviceId() == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if(waterFilter.QueryIt(dataSource)!=null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
if (waterFilter.Insert(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/waterfilter/update",method = RequestMethod.POST)
|
||||
public RespEntity updateWaterFilterInfo(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
WaterFilterEntity waterFilter = (WaterFilterEntity) SQLTools.getEntityFromJson(rootnode, WaterFilterEntity.class);
|
||||
if (waterFilter == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (waterFilter.getFilterId() == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if(waterFilter.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if (waterFilter.Update(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/waterfilter/delete",method = RequestMethod.POST)
|
||||
public RespEntity deleteWaterFilterInfo(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
WaterFilterEntity waterFilter = (WaterFilterEntity) SQLTools.getEntityFromJson(rootnode, WaterFilterEntity.class);
|
||||
if (waterFilter == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (waterFilter.getFilterId() == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if(waterFilter.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if (waterFilter.Delete(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/maintain_staff/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getMaintainStaffList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
MaintainStaffEntity maintainStaff = (MaintainStaffEntity) SQLTools.getEntityFromJson(rootnode,MaintainStaffEntity.class);
|
||||
|
||||
if(maintainStaff==null)
|
||||
maintainStaff = new MaintainStaffEntity();
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = maintainStaff.queryPage(dataSource, null, null, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/maintain_staff/add",method = RequestMethod.POST)
|
||||
public RespEntity addMaintainStaff(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
MaintainStaffEntity maintainStaff = (MaintainStaffEntity) SQLTools.getEntityFromJson(rootnode, MaintainStaffEntity.class);
|
||||
if (maintainStaff == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (maintainStaff.getStaffName() == null )
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
|
||||
if(maintainStaff.getIdCode() != null){
|
||||
maintainStaff.setStaffId(maintainStaff.getIdCode());
|
||||
}else{
|
||||
maintainStaff.setStaffId(UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
if(maintainStaff.QueryIt(dataSource)!=null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
if (maintainStaff.Insert(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/maintain_staff/update",method = RequestMethod.POST)
|
||||
public RespEntity updateMaintainStaff(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
MaintainStaffEntity maintainStaff = (MaintainStaffEntity) SQLTools.getEntityFromJson(rootnode, MaintainStaffEntity.class);
|
||||
if (maintainStaff == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (maintainStaff.getStaffId() == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if(maintainStaff.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if (maintainStaff.Update(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/maintain_staff/delete",method = RequestMethod.POST)
|
||||
public RespEntity deleteWaterMaintainStaff(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
MaintainStaffEntity maintainStaff = (MaintainStaffEntity) SQLTools.getEntityFromJson(rootnode, MaintainStaffEntity.class);
|
||||
if (maintainStaff == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (maintainStaff.getStaffId() == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if(maintainStaff.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if (maintainStaff.Delete(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/maintain_staff/bind",method = RequestMethod.POST)
|
||||
public RespEntity bindMaintainStaff(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
MaintainStaffBindEntity maintainStaff = (MaintainStaffBindEntity) SQLTools.getEntityFromJson(rootnode, MaintainStaffBindEntity.class);
|
||||
if (maintainStaff == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (maintainStaff.getStaffId() == null || maintainStaff.getStation() == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
|
||||
maintainStaff.setBindId(maintainStaff.getStation() + "_" + maintainStaff.getStaffId());
|
||||
if(maintainStaff.QueryIt(dataSource) != null){
|
||||
return new RespEntity(RespCode.EXIST);
|
||||
}
|
||||
if (maintainStaff.Insert(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/maintain_staff/unbind",method = RequestMethod.POST)
|
||||
public RespEntity unbindMaintainStaff(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
MaintainStaffBindEntity maintainStaff = (MaintainStaffBindEntity) SQLTools.getEntityFromJson(rootnode, MaintainStaffBindEntity.class);
|
||||
if (maintainStaff == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if(maintainStaff.QueryIt(dataSource)==null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
if (maintainStaff.Delete(dataSource)) {
|
||||
rel = new RespEntity(RespCode.SUCCESS);
|
||||
}else {
|
||||
rel = new RespEntity(RespCode.FAIL);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/maintain_staff/bind_stations",method = RequestMethod.POST)
|
||||
public RespEntity getBindStations(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
MaintainStaffBindEntity maintainStaff = (MaintainStaffBindEntity) SQLTools.getEntityFromJson(rootnode, MaintainStaffBindEntity.class);
|
||||
if (maintainStaff == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
if (maintainStaff.getStaffId() == null )
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = maintainStaff.queryPage(dataSource, null, null, pageindex, pagesize);
|
||||
rel = new RespEntity(RespCode.SUCCESS, list);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/maintain_staff/bind_staffs",method = RequestMethod.POST)
|
||||
public RespEntity getBindStaffes(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode=HttpTools.getJsonFromRequest(request);
|
||||
if (rootnode != null) {
|
||||
MaintainStaffBindEntity maintainStaff = (MaintainStaffBindEntity) SQLTools.getEntityFromJson(rootnode, MaintainStaffBindEntity.class);
|
||||
if (maintainStaff == null)
|
||||
return new RespEntity(RespCode.ERROR_CMD);
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = maintainStaff.queryPage(dataSource, null, null, pageindex, pagesize);
|
||||
|
||||
List<MaintainStaffEntity> bindStaffs = new ArrayList<>();
|
||||
if(list != null){
|
||||
for(int iStaff = 0; iStaff < list.size(); iStaff++){
|
||||
MaintainStaffBindEntity bindStaff = (MaintainStaffBindEntity)list.get(iStaff);
|
||||
MaintainStaffEntity tgtStaff = new MaintainStaffEntity();
|
||||
tgtStaff.setStaffId(bindStaff.getStaffId());
|
||||
tgtStaff = (MaintainStaffEntity)tgtStaff.QueryIt(dataSource);
|
||||
if(tgtStaff != null){
|
||||
bindStaffs.add(tgtStaff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rel = new RespEntity(RespCode.SUCCESS, bindStaffs);
|
||||
}
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/waterflow/hour/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getWaterFlowHourList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
WaterFlowHourEntity flowHourEntity = (WaterFlowHourEntity) SQLTools.getEntityFromJson(rootnode,WaterFlowHourEntity.class);
|
||||
|
||||
if(flowHourEntity==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(flowHourEntity.getBrigade() == null && flowHourEntity.getBorough() == null && flowHourEntity.getDetachment() == null && flowHourEntity.getStation() == null && flowHourEntity.getWaterDeviceId() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = flowHourEntity.queryPage(dataSource, null, null, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/waterflow/day/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getWaterFlowDayList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
WaterFlowDayEntity flowDayEntity = (WaterFlowDayEntity) SQLTools.getEntityFromJson(rootnode,WaterFlowDayEntity.class);
|
||||
|
||||
if(flowDayEntity==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(flowDayEntity.getBrigade() == null && flowDayEntity.getBorough() == null && flowDayEntity.getDetachment() == null && flowDayEntity.getStation() == null && flowDayEntity.getWaterDeviceId() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = flowDayEntity.queryPage(dataSource, null, null, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/waterflow/month/getlist",method = RequestMethod.POST)
|
||||
public RespEntity getWaterFlowMonthList(HttpServletRequest request) {
|
||||
RespEntity rel = null;
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
WaterFlowMonthEntity flowMonthEntity = (WaterFlowMonthEntity) SQLTools.getEntityFromJson(rootnode,WaterFlowMonthEntity.class);
|
||||
|
||||
if(flowMonthEntity==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(flowMonthEntity.getBrigade() == null && flowMonthEntity.getBorough() == null && flowMonthEntity.getDetachment() == null && flowMonthEntity.getStation() == null && flowMonthEntity.getWaterDeviceId() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
int pagesize = JsonHelper.getIntValue(rootnode, "pagesize");
|
||||
int pageindex = JsonHelper.getIntValue(rootnode, "pageindex");
|
||||
if (pagesize <= 0)
|
||||
pagesize = 1000;
|
||||
if (pageindex < 0)
|
||||
pageindex = 0;
|
||||
|
||||
List<SQLDataObject> list = flowMonthEntity.queryPage(dataSource, null, null, pageindex, pagesize);
|
||||
return new RespEntity(RespCode.SUCCESS, list);
|
||||
}catch (Exception e){
|
||||
rel = new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/waterflow/station/flowsum",method = RequestMethod.POST)
|
||||
public RespEntity getStationWaterFlowSum(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
WaterFlowMonthEntity flowMonthEntity = (WaterFlowMonthEntity) SQLTools.getEntityFromJson(rootnode,WaterFlowMonthEntity.class);
|
||||
|
||||
if(flowMonthEntity==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
|
||||
if(flowMonthEntity.getBrigade() == null && flowMonthEntity.getBorough() == null && flowMonthEntity.getDetachment() == null && flowMonthEntity.getStation() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
flowMonthEntity.setWaterDeviceId(null);
|
||||
|
||||
WaterFlowSum flowSum = new WaterFlowSum();
|
||||
flowSum.setStation(flowMonthEntity.getStation());
|
||||
flowSum.setBorough(flowMonthEntity.getBorough());
|
||||
flowSum.setDetachment(flowMonthEntity.getDetachment());
|
||||
flowSum.setBrigade(flowMonthEntity.getBrigade());
|
||||
|
||||
Calendar signDayTime = Calendar.getInstance();
|
||||
String nYear = String.valueOf(signDayTime.get(Calendar.YEAR));
|
||||
String nMonth = String.valueOf(signDayTime.get(Calendar.MONTH)+1);
|
||||
String nDay = String.valueOf(signDayTime.get(Calendar.DAY_OF_MONTH));
|
||||
|
||||
flowMonthEntity.setYear(nYear);
|
||||
|
||||
WaterFlowDayEntity dayFlow = new WaterFlowDayEntity();
|
||||
dayFlow.setStation(flowMonthEntity.getStation());
|
||||
dayFlow.setBorough(flowMonthEntity.getBorough());
|
||||
dayFlow.setDetachment(flowMonthEntity.getDetachment());
|
||||
dayFlow.setBrigade(flowMonthEntity.getBrigade());
|
||||
dayFlow.setDay(nDay);
|
||||
dayFlow.setMonth(nMonth);
|
||||
dayFlow.setYear(nYear);
|
||||
List<SQLDataObject> listDay= dayFlow.queryPage(dataSource, null, null, 0, 50000);
|
||||
if(listDay != null){
|
||||
WaterFlowDayEntity tgtDayFlow = (WaterFlowDayEntity)listDay.get(0);
|
||||
flowSum.setFlowCurDay(tgtDayFlow.getFlow());
|
||||
}else{
|
||||
flowSum.setFlowCurDay(0);
|
||||
}
|
||||
|
||||
List<SQLDataObject> listMonth = flowMonthEntity.queryPage(dataSource, null, null, 0, 50000);
|
||||
if(listMonth == null){
|
||||
return new RespEntity(RespCode.SUCCESS, flowSum);
|
||||
}
|
||||
if(listMonth.isEmpty()){
|
||||
return new RespEntity(RespCode.SUCCESS, flowSum);
|
||||
}
|
||||
|
||||
long yearFlow = 0;
|
||||
long monthFlow = 0;
|
||||
for(int iMon = 0; iMon < listMonth.size(); iMon++){
|
||||
WaterFlowMonthEntity tgtMonth = (WaterFlowMonthEntity)listMonth.get(iMon);
|
||||
yearFlow += tgtMonth.getFlow();
|
||||
|
||||
if(iMon == listMonth.size()-1){
|
||||
monthFlow = tgtMonth.getFlow();;
|
||||
}
|
||||
}
|
||||
flowSum.setFlowCurYear(yearFlow);
|
||||
flowSum.setFlowCurMonth(monthFlow);
|
||||
|
||||
|
||||
return new RespEntity(RespCode.SUCCESS, flowSum);
|
||||
}catch (Exception e){
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/firectrl/foodsafe/waterflow/stations/flowsum",method = RequestMethod.POST)
|
||||
public RespEntity getStationsWaterFlowSum(HttpServletRequest request) {
|
||||
try {
|
||||
JsonNode rootnode= HttpTools.getJsonFromRequest(request);
|
||||
WaterFlowMonthEntity flowMonthEntity = (WaterFlowMonthEntity) SQLTools.getEntityFromJson(rootnode,WaterFlowMonthEntity.class);
|
||||
|
||||
if(flowMonthEntity==null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
if(flowMonthEntity.getBrigade() == null && flowMonthEntity.getBorough() == null && flowMonthEntity.getDetachment() == null && flowMonthEntity.getStation() == null){
|
||||
return new RespEntity(RespCode.ERROR_REQUEST);
|
||||
}
|
||||
flowMonthEntity.setWaterDeviceId(null);
|
||||
|
||||
FireStationBaseInfoEntity tgtStation = new FireStationBaseInfoEntity();
|
||||
tgtStation.setBrigade(flowMonthEntity.getBrigade());
|
||||
tgtStation.setBorough(flowMonthEntity.getBorough());
|
||||
tgtStation.setDetachment(flowMonthEntity.getDetachment());
|
||||
tgtStation.setName(flowMonthEntity.getStation());
|
||||
|
||||
List<SQLDataObject> stationList = tgtStation.queryPage(dataSource,null,null,0,10000);
|
||||
if(stationList == null){
|
||||
return new RespEntity(RespCode.NOTEXIST);
|
||||
}
|
||||
|
||||
List<WaterFlowSum> retWfList = new ArrayList<>();
|
||||
for(int iSt = 0; iSt < stationList.size(); iSt++){
|
||||
FireStationBaseInfoEntity stationInfo = (FireStationBaseInfoEntity)stationList.get(iSt);
|
||||
|
||||
WaterFlowSum flowSum = new WaterFlowSum();
|
||||
flowSum.setStation(stationInfo.getName());
|
||||
flowSum.setBorough(stationInfo.getBorough());
|
||||
flowSum.setDetachment(stationInfo.getDetachment());
|
||||
flowSum.setBrigade(stationInfo.getBrigade());
|
||||
|
||||
Calendar signDayTime = Calendar.getInstance();
|
||||
String nYear = String.valueOf(signDayTime.get(Calendar.YEAR));
|
||||
String nMonth = String.valueOf(signDayTime.get(Calendar.MONTH)+1);
|
||||
String nDay = String.valueOf(signDayTime.get(Calendar.DAY_OF_MONTH));
|
||||
|
||||
flowMonthEntity.setYear(nYear);
|
||||
flowMonthEntity.setStation(stationInfo.getName());
|
||||
flowMonthEntity.setBorough(stationInfo.getBorough());
|
||||
flowMonthEntity.setDetachment(stationInfo.getDetachment());
|
||||
flowMonthEntity.setBrigade(stationInfo.getBrigade());
|
||||
|
||||
WaterFlowDayEntity dayFlow = new WaterFlowDayEntity();
|
||||
dayFlow.setStation(stationInfo.getName());
|
||||
dayFlow.setBorough(stationInfo.getBorough());
|
||||
dayFlow.setDetachment(stationInfo.getDetachment());
|
||||
dayFlow.setBrigade(stationInfo.getBrigade());
|
||||
dayFlow.setDay(nDay);
|
||||
dayFlow.setMonth(nMonth);
|
||||
dayFlow.setYear(nYear);
|
||||
List<SQLDataObject> listDay= dayFlow.queryPage(dataSource, null, null, 0, 50000);
|
||||
if(listDay != null && listDay.size() > 0){
|
||||
WaterFlowDayEntity tgtDayFlow = (WaterFlowDayEntity)listDay.get(0);
|
||||
flowSum.setFlowCurDay(tgtDayFlow.getFlow());
|
||||
}else{
|
||||
flowSum.setFlowCurDay(0);
|
||||
}
|
||||
long yearFlow = 0;
|
||||
long monthFlow = 0;
|
||||
List<SQLDataObject> listMonth = flowMonthEntity.queryPage(dataSource, null, null, 0, 50000);
|
||||
if(listMonth != null){
|
||||
for(int iMon = 0; iMon < listMonth.size(); iMon++){
|
||||
WaterFlowMonthEntity tgtMonth = (WaterFlowMonthEntity)listMonth.get(iMon);
|
||||
yearFlow += tgtMonth.getFlow();
|
||||
|
||||
if(iMon == listMonth.size()-1){
|
||||
monthFlow = tgtMonth.getFlow();;
|
||||
}
|
||||
}
|
||||
}
|
||||
flowSum.setFlowCurYear(yearFlow);
|
||||
flowSum.setFlowCurMonth(monthFlow);
|
||||
|
||||
retWfList.add(flowSum);
|
||||
}
|
||||
return new RespEntity(RespCode.SUCCESS, retWfList);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
// System.out.println("getStationsWaterFlowSum: "+ e);
|
||||
return new RespEntity(RespCode.EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue