<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.skyline.electricity.mapper.DetectMapper">
|
|
<select id="judge" resultType="string" parameterType="map">
|
|
SELECT
|
st_intersects(
|
(st_geomfromtext (#{point}, 4326 )),
|
(st_geomfromtext (#{polygon}, 4326 )))
|
|
</select>
|
|
<insert id="insertPoint" parameterType="personposition">
|
|
INSERT INTO "position"(userid,username,latitude,longitude,satellitenum,userindex,altitude,time,course)
|
VALUES (#{userId},#{userName},#{latitude},#{longitude},#{satelliteNum},#{userIndex},#{altitude},#{time},#{course})
|
|
</insert>
|
|
<select id="getPositionById" parameterType="String" resultType="personposition">
|
|
|
select distinct * from position where userid=#{userId}
|
|
</select>
|
|
<select id="getRoute" resultType="String" parameterType="String">
|
|
select point from coordinate where username=#{username} ORDER BY
|
createtime asc
|
|
|
</select>
|
|
<select id="getWifiInfo" resultType="wifi">
|
|
select "gid", "te_type", "te_desc", "te_fname", "te_yaw", "te_pitch", "te_roll",
|
"te_width", "te_length", "te_height", "te_scale", substr(rtrim(ST_AsText("geom"), ')'), 11) as gemo
|
from wifi_jz
|
|
</select>
|
|
<select id="getMonitorInfo" resultType="monitor">
|
|
select "gid", "te_type", "te_desc", "te_fname", "te_yaw", "te_pitch", "te_roll",
|
"te_width", "te_length", "te_height", "te_scale", substr(rtrim(ST_AsText("geom"), ')'), 11) as gemo,regionpath,transptz,
|
cameraname,cameraindex,status
|
from video
|
|
</select>
|
|
<select id="getDoorAccessInfo" resultType="dooraccess">
|
|
select * from dooraccess
|
|
</select>
|
|
<insert id="insertPolygon" parameterType="fenceposition" >
|
|
insert into fence(workid, fname, fenceposition, startaltitude, endaltitude, createtime, starttime, disabledtime,
|
status, type, level)
|
values (#{workId}, #{fname}, ST_GeomFromText(#{fenceposition}), #{startaltitude}, #{endaltitude}, #{createtime},
|
#{starttime}, #{disabledtime}, #{status}, #{type}, #{level})
|
|
</insert>
|
|
<select id="selectPolygon" parameterType="fenceposition" resultType="fenceposition">
|
|
select * from fence where workid = #{workId}
|
|
</select>
|
|
<insert id="insertHp" parameterType="historyposition">
|
|
insert into historyposition(timestamp,altitude,satellitenum,latitude,course,entityid,time,longitude,username)
|
values (#{timestamp},#{altitude},#{satelliteNum},#{latitude},#{course},#{entityId},#{time},#{longitude},#{userName})
|
|
</insert>
|
|
<select id="getRouteByUserId" resultType="historyposition">
|
|
select distinct timestamp,altitude,satellitenum,latitude,course,entityid,time,longitude,username
|
from historyposition where entityid=#{entityId} and to_timestamp(timestamp, 'yyyy-MM-dd HH24:MI:SS')
|
between to_timestamp(#{starttime}, 'yyyy-MM-dd HH24:MI:SS') and to_timestamp( #{endtime}, 'yyyy-MM-dd HH24:MI:SS')
|
ORDER BY "timestamp" asc
|
|
</select>
|
|
|
<select id="getFenceInfo" resultType="fenceposition">
|
|
SELECT fid,fname,workid,substr(rtrim(ST_AsText(fenceposition), ')'), 10) as fenceposition,starttime,disabledtime,createtime,startaltitude,
|
endaltitude,personcount,alarmcount
|
from fence where status='enabled' and workid not in(#{workId})
|
|
|
</select>
|
|
<select id="getFenceInfoByStatus" resultType="fenceposition">
|
|
SELECT fid,fname,workid,substr(rtrim(ST_AsText(fenceposition), ')'), 10) as fenceposition,starttime,disabledtime,createtime,startaltitude,endaltitude,status,type,level,personcount,alarmcount from fence
|
where status='enabled'
|
|
</select>
|
|
<select id="getFixedFenceInfo" resultType="fenceposition">
|
|
SELECT fid,fname,workid,substr(rtrim(ST_AsText(fenceposition), ')'), 10) as fenceposition,starttime,disabledtime,createtime,startaltitude,endaltitude,status,type,level,personcount,alarmcount from fence
|
where type='fixed'
|
|
</select>
|
|
<select id="getTempFenceInfo" resultType="fenceposition">
|
|
SELECT fid,fname,workid,substr(rtrim(ST_AsText(fenceposition), ')'), 10) as fenceposition,
|
starttime,disabledtime,createtime,personcount,alarmcount from fence where type='temp'
|
|
</select>
|
|
|
<update id="updateFenceInfo" parameterType="FencePosition">
|
|
|
update fence
|
<set >
|
<if test="fname != null" >
|
fname = #{fname},
|
</if>
|
<if test="endaltitude != null and endaltitude != -9999" >
|
endaltitude = #{endaltitude},
|
</if>
|
<if test="startaltitude !=null and startaltitude != -9999" >
|
startaltitude = #{startaltitude},
|
</if>
|
<if test="starttime != null" >
|
starttime = #{starttime},
|
</if>
|
<if test="disabledtime != null" >
|
disabledtime = #{disabledtime},
|
</if>
|
<if test="personcount != null " >
|
personcount = #{personcount},
|
</if>
|
</set>
|
where workid = #{workId}
|
|
</update>
|
|
<update id="updateFenceById" parameterType="fenceposition">
|
|
update fence
|
<set >
|
<if test="fname != null" >
|
fname = #{fname},
|
</if>
|
<if test="fenceposition != null" >
|
fenceposition = ST_GeomFromText(#{fenceposition}),
|
</if>
|
<if test="createtime != null" >
|
createtime = #{createtime},
|
</if>
|
<if test="startaltitude !=null and startaltitude != -9999" >
|
startaltitude = #{startaltitude},
|
</if>
|
<if test="endaltitude != null and endaltitude != -9999" >
|
endaltitude = #{endaltitude},
|
</if>
|
|
</set>
|
where workid = #{workId}
|
|
</update>
|
|
<select id="intersects" parameterType="map" resultType="String">
|
|
select st_intersects(
|
(st_geomfromtext (#{polygon}, 4326 )),
|
(st_geomfromtext (#{py}, 4326 )))
|
|
</select>
|
|
|
<delete id="deleteFenceById" parameterType="String">
|
|
delete from fence where workid = #{workId}
|
|
</delete>
|
|
<delete id="deleteFence">
|
|
delete from fence
|
|
</delete>
|
|
<update id="changeFenceStatus" parameterType="string">
|
|
update fence set status='enabled' where workid = #{workId}
|
|
</update>
|
|
<delete id="deleteDisabledFence">
|
|
delete from fence
|
where NOW() > to_timestamp(disabledtime, 'yyyy-MM-dd HH24:MI')
|
|
</delete>
|
|
<select id="selectPosition" parameterType="string" resultType="information">
|
|
select * from information where userid=#{userId} and status='in' and wtid=#{workId}
|
|
</select>
|
|
|
<select id="selectPositionDelay" parameterType="string" resultType="information">
|
|
select * from information where userid=#{userId} and (status='in' or status='not in') and wtid=#{workId} order by starttime desc limit 1
|
|
</select>
|
|
<insert id="insertInfo" parameterType="information">
|
|
insert into information(userId,userName,wtid,name,starttime,status,fence_type)
|
values (#{userId},#{userName},#{wtId},#{name},#{startTime},#{status},#{fence_type})
|
|
</insert>
|
|
<update id="changeStatus" parameterType="string">
|
|
update information set status='not in' where userid=#{userId} and status='in' and wtid=#{workId}
|
|
</update>
|
|
<select id="getFenceInfoById" resultType="fenceposition" parameterType="String">
|
|
select fid,fname,workid,substr(rtrim(ST_AsText(fenceposition), ')'), 10) as fenceposition,starttime,disabledtime,createtime,startaltitude,
|
endaltitude,status,type,level
|
from fence where workid=#{workId}
|
|
</select>
|
|
<update id="setFenceEnabled">
|
|
update fence set status='enabled' where workid=#{workId}
|
|
</update>
|
|
<update id="setFenceEnabledByStartTime">
|
|
update fence set status='enabled'
|
where workid=#{workId}
|
|
</update>
|
|
<update id="setFenceDisabled">
|
|
update fence set status='disabled' where workid=#{workId}
|
|
</update>
|
|
<update id="setEnabled" parameterType="int">
|
|
update fence set status='enabled'
|
|
</update>
|
|
<update id="setDisabled" parameterType="int">
|
|
update fence set status='disabled'
|
|
</update>
|
|
<select id="transLocation" parameterType="String" resultType="String">
|
|
select substr(rtrim(ST_AsText(ST_Transform(st_geometryfromtext('point(${point})',2436),4326)), ')'), 7)
|
|
</select>
|
|
<select id="getDeviceInfo" resultType="DeviceInfo">
|
|
select "gid", "filename", "x", "y", "z", "xpl2id", "设备名" as device_name, "台账名" as account, "设备id" as device_id, "测点" as testpoint,
|
"编码" as code, "kks类型" as kkstype, substr(rtrim(ST_AsText("geom"), ')'), 11) as gemo
|
from kks_equip where "设备id"!=''
|
|
</select>
|
|
<select id="getDeviceInfoById" parameterType="String" resultType="DeviceInfo">
|
|
select "gid", "filename", "x", "y", "z", "xpl2id", "设备名" as device_name, "台账名" as account, "设备id" as device_id, "测点" as testpoint,
|
"编码" as code, "kks类型" as kkstype, substr(rtrim(ST_AsText("geom"), ')'), 11) as gemo
|
from kks_equip where 设备id=#{device_id}
|
|
</select>
|
|
|
<select id="getDeviceId" resultType="String">
|
|
select distinct device_id from devicekks where device_id!=''
|
|
</select>
|
|
<select id="getDeviceKKSInfo" resultType="DeviceKKS">
|
|
select * from devicekks where device_id=#{device_id}
|
|
</select>
|
|
|
<select id="getMonitorDeviceInfo" resultType="MonitorInfo">
|
|
select gid,"monitor_name", "monitor_type", "belong_device", "aisle_no", "aisle_type", "video_ip", "monitor_id", "belong_area", "monitor_index",
|
"desc", "x", "y", "z", "hk_rtsp", substr(rtrim(ST_AsText("geom"), ')'), 11) as geom
|
from monitor
|
|
</select>
|
|
<select id="getMonitorDeviceInfoById" resultType="MonitorInfo">
|
|
select gid,"monitor_name", "monitor_type", "belong_device", "aisle_no", "aisle_type", "video_ip", "monitor_id", "belong_area", "monitor_index",
|
"desc", "x", "y", "z", "hk_rtsp", substr(rtrim(ST_AsText("geom"), ')'), 11) as geom
|
from monitor where monitor_index=#{monitor_index}
|
|
</select>
|
<insert id="insertFencePersonRel" parameterType="map" useGeneratedKeys="true" keyColumn="id" keyProperty="id" >
|
INSERT INTO "fence_person_rel"(
|
fname,
|
workid,
|
userid,
|
personcount,
|
type
|
)
|
VALUES
|
<foreach collection="list" item="item" index="index" separator=",">(
|
#{ item.fname},
|
#{ item.workid },
|
#{ item.userid },
|
#{ item.personcount },
|
'fence'
|
)
|
</foreach>
|
|
</insert>
|
|
|
<insert id="insertfixareaPersonRel" parameterType="map" useGeneratedKeys="true" keyColumn="id" keyProperty="id" >
|
INSERT INTO "fence_person_rel"(
|
workid,
|
userid,
|
personcount,
|
type
|
)
|
VALUES
|
<foreach collection="list" item="item" index="index" separator=",">(
|
#{ item.workid },
|
#{ item.userid },
|
#{ item.personcount },
|
'fixedArea'
|
)
|
</foreach>
|
|
</insert>
|
<delete id="delFencePersonRel" flushCache="true" parameterType="String" >
|
delete from "fence_person_rel" where "workid" = #{_parameter}
|
</delete>
|
|
<update id="delAllFencePersonRel" flushCache="true" >
|
truncate table "fence_person_rel"
|
</update>
|
|
<select id="selectFencePersonRelByworkid" resultType="map">
|
|
select a.workid,a.userid,b.name,b,mobile,b.no,b.login_name,b.email
|
from fence_person_rel a
|
left join sys_user b on a.userid=b.id where a.workid=#{_parameter}
|
|
</select>
|
<select id="selectAllfixedareaPerson" resultType="map">
|
|
select distinct a.workid,a.personcount
|
from fence_person_rel a where a.type='fixedArea'
|
|
|
</select>
|
|
<select id="selectAllfencePerson" resultType="map">
|
|
select distinct a.fname, a.workid,a.personcount
|
from fence_person_rel a where a.type='fence'
|
|
|
</select>
|
|
<select id="selectFenceAndfixedYQArea" resultType="fenceposition">
|
|
SELECT gid as fid,substr(rtrim(ST_AsText(geom), ')'), 20) as fenceposition from fence_yq
|
|
</select>
|
|
<insert id="insertPolygon_yq" parameterType="fenceposition" >
|
|
insert into fence_yq(te_type,te_desc,te_height,geom)
|
values (#{type},#{fname},#{height},ST_GeomFromText(#{fenceposition}))
|
|
</insert>
|
|
<select id="selectInformation" parameterType="string" resultType="information">
|
select im.starttime,ft.userid as userId,ft.workid as workId from fence_temp ft
|
left join information im on im.wtid = ft.workid
|
where ft.userid=#{userId} and im.status='out' and ft.workid=#{workId} order by im.starttime desc limit 1
|
</select>
|
|
<select id="selectFenceTemp" parameterType="string" resultType="FenceTemp">
|
select * from fence_temp ft
|
where type='temp'
|
<if test="userId !=null and userId!=''">and userid=#{userId}</if>
|
and ft.workid=#{workId}
|
</select>
|
<insert id="insetFenceTemp" parameterType="FenceTemp">
|
insert into fence_temp(workid,userid,type) values (#{workId},#{userId},#{type})
|
</insert>
|
|
<update id="updateFenceTemp" parameterType="string">
|
update fence_temp set userid=#{newUserId} where type='temp' and workid=#{workId}
|
</update>
|
|
<delete id="deleteFenceTemps" parameterType="string">
|
delete fence_temp where type='temp' and workid=#{workId}
|
</delete>
|
|
<select id="selectPeopleInSecureCircle" parameterType="string" resultType="map">
|
SELECT id ,company_id, org_id, login_name, no, name, email, phone, mobile, user_type, photo, login_ip, login_date, login_flag, create_by, create_date, update_by, update_date, remarks, del_flag, sort, pos_code, token, party_cost, gender, birthday, education, residence, nation
|
FROM public.sys_user where org_id='2015';
|
</select>
|
|
<select id="selectDepartDeputyDirectorByStaffid" parameterType="string" resultType="map">
|
SELECT b.user_id as id, b.user_name, a.orgid,b.pos_name
|
FROM public.pg_pos a left join public.pg_pos_user b on a.id=b.pos_id
|
where b.pos_name like '%主任' and a.orgid in (select c.org_id from sys_user c where c.id=#{_parameter})
|
</select>
|
<select id="selectWorkLeader" parameterType="string" resultType="map">
|
select b.* from fence_temp a left join sys_user b on a.userid=b.id
|
where type='temp'
|
and a.workid=#{workId}
|
</select>
|
|
|
<update id="updateFenceAlarmCount" parameterType="string">
|
update fence set alarmcount=alarmcount+1 where workid=#{_parameter}
|
</update>
|
|
</mapper>
|