| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- <?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="cn.com.goldenwater.dcproj.dao.PersPositionDao">
- <resultMap type="cn.com.goldenwater.dcproj.model.PersPosition" id="persPositionResultMap">
- <result property="latitude" column="LATITUDE"/>
- <result property="operateTime" column="OPERATE_TIME"/>
- <result property="adCode" column="AD_CODE"/>
- <result property="longitude" column="LONGITUDE"/>
- <result property="id" column="ID"/>
- <result property="persId" column="PERS_ID"/>
- <result property="orgId" column="ORG_ID"/>
- <result property="groupId" column="GROUP_ID"/>
- <result property="persName" column="PERS_NAME"/>
- <result property="mobile" column="MOBILE"/>
- <result property="lon" column="LON"/>
- <result property="lat" column="LAT"/>
- <result property="status" column="STATUS"/>
- </resultMap>
- <sql id="table_columns">
- LATITUDE,
- OPERATE_TIME,
- AD_CODE,
- LONGITUDE,
- ID,
- PERS_ID,
- ORG_ID,
- GROUP_ID,
- PERS_NAME,
- MOBILE,
- LON,
- LAT
- </sql>
- <sql id="entity_properties">
- #{latitude},
- #{operateTime},
- #{adCode},
- #{longitude},
- #{id},
- #{persId},
- #{orgId},
- #{groupId},
- #{persName},
- #{mobile},
- #{lon},
- #{lat}
- </sql>
- <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
- <sql id="page_where">
- <trim prefix="where" prefixOverrides="and | or ">
- <if test="operateTime != null">and OPERATE_TIME = #{operateTime}</if>
- <if test="operateTimeFrom != null">and OPERATE_TIME >= #{operateTimeFrom}</if>
- <if test="operateTimeTo != null">and OPERATE_TIME <= #{operateTimeTo}</if>
- <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
- <if test="id != null and id != ''">and ID = #{id}</if>
- <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
- <if test="orgId != null and orgId != ''">and ORG_ID = #{orgId}</if>
- <if test="groupId != null and groupId != ''">and GROUP_ID = #{groupId}</if>
- <if test="persName != null and persName != ''">and PERS_NAME = #{persName}</if>
- <if test="mobile != null and mobile != ''">and MOBILE = #{mobile}</if>
- <if test="lon != null and lon != ''">and LON = #{lon}</if>
- <if test="lat != null and lat != ''">and LAT = #{lat}</if>
- </trim>
- </sql>
- <select id="get" resultMap="persPositionResultMap" parameterType="String">
- select
- <include refid="table_columns"/>
- from pers_position where ID = #{id}
- </select>
- <select id="getPersPosition" resultMap="persPositionResultMap" parameterType="String">
- select
- LATITUDE,
- OPERATE_TIME,
- AD_CODE,
- LONGITUDE,
- PERS_ID,
- ORG_ID,
- GROUP_ID,
- PERS_NAME,
- MOBILE,
- LON,
- LAT
- from pers_position_latest t1
- where t1.PERS_ID = #{persId}
- </select>
- <select id="getBy" resultMap="persPositionResultMap">
- select
- <include refid="table_columns"/>
- from pers_position
- <include refid="page_where"/>
- </select>
- <select id="findAll" resultMap="persPositionResultMap">
- select
- <include refid="table_columns"/>
- from pers_position
- </select>
- <select id="findList" resultMap="persPositionResultMap">
- select
- LATITUDE,
- OPERATE_TIME,
- AD_CODE,
- LONGITUDE,
- PERS_ID,
- t2.ORG_ID,
- GROUP_ID,
- t2.PERS_NAME,
- MOBILE,
- LON,
- LAT,
- case when OPERATE_TIME >= #{operateTime} then '1'
- else '0' end as status
- from
- <if test="persId != null and persId != ''">
- bis_insp_all_rlation t
- left join bis_insp_all_rlation t1 on t1.id like concat(t.id,'%')
- left join pers_position_latest t2 on t2.pers_id = t1.persid
- where t.persid=#{persId} and t2.pers_id is not null
- </if>
- <if test="id != null and id != ''">
- bis_insp_all_rlation t1
- left join pers_position_latest t2 on t2.pers_id = t1.persid
- where
- <foreach item="item" index="index" collection="id.split(',')" open="(" separator="OR" close=")">
- t1.id LIKE concat(#{item}, '%')
- </foreach>
- and t2.pers_id is not null
- </if>
- <if test="orgId != null and orgId != ''">
- BIS_INSP_ALL_RLATION_PERS t1
- left join pers_position_latest t2 on t2.pers_id = t1.guid
- where t1.ORG_ID like concat(#{orgId},'%') and t2.pers_id is not null
- </if>
- <if test="(persId == null or persId == '') and (id == null or id == '') and (orgId == null or orgId == '')">
- pers_position_latest t2
- </if>
- <if test="adCode != null and adCode != ''">t2.ad_code like concat(#{adCode},'%')</if>
- </select>
- <select id="findListByPersId" resultMap="persPositionResultMap">
- select
- <include refid="table_columns"/>
- from pers_position
- <include refid="page_where"/>
- order by OPERATE_TIME
- </select>
- <select id="selectCountByClassfyId" resultType="int">
- select count(distinct t4.pers_id) from bis_insp_all t1
- LEFT JOIN BIS_INSP_ALL_RLATION t2 ON t2.id = t1.id
- left join BIS_INSP_ALL_RLATION_PERS t3 ON t3.guid = t2.persid
- left join pers_position_latest t4 on t4.pers_id = t3.guid
- where t4.pers_id is not null
- and t1.id like concat(#{id}, '%')
- and t4.OPERATE_TIME >= #{operateTime}
- </select>
- <select id="selectCountByOrgId" resultType="int">
- select count(distinct t2.pers_id) from BIS_INSP_ALL_RLATION_PERS t1
- left join pers_position_latest t2 on t2.pers_id = t1.guid
- where t2.pers_id is not null
- and t1.ORG_ID IN (${orgId})
- and t2.OPERATE_TIME >= #{operateTime}
- </select>
- <select id="selectCount" resultType="int">
- select count(ID) from pers_position
- <include refid="page_where"/>
- </select>
- <select id="selectOnlineCount" resultType="int">
- select count(0) from pers_position_latest
- where OPERATE_TIME >= #{operateTime}
- </select>
- <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.PersPosition">
- insert into pers_position(
- <include refid="table_columns"/>
- )
- values (
- <include refid="entity_properties"/>
- )
- </insert>
- <insert id="insertList" parameterType="cn.com.goldenwater.dcproj.model.PersPosition">
- insert all into pers_position(
- <include refid="table_columns"/>
- )
- select
- <foreach collection="list" item="item" index="index" separator="UNION select">
- #{item.latitude},#{item.operateTime}, #{item.adCode},#{item.longitude}, #{item.id},
- #{item.persId}, #{item.orgId}, #{item.groupId}, #{item.persName}, #{item.mobile},
- #{item.lon}, #{item.lat} from dual
- </foreach>
- </insert>
- <delete id="delete" parameterType="java.lang.String">
- delete from pers_position where ID = #{id}
- </delete>
- <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.PersPosition">
- delete from pers_position
- <include refid="page_where"/>
- </delete>
- <update id="deleteInFlag" parameterType="java.lang.String">
- update pers_position set flag_valid = 0 where ID = #{id}
- </update>
- <update id="update" parameterType="cn.com.goldenwater.dcproj.model.PersPosition">
- update pers_position
- <trim prefix="set" suffixOverrides=",">
- <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
- <if test="id != null and id != ''">ID = #{id},</if>
- <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
- <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
- <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
- <if test="persName != null and persName != ''">PERS_NAME = #{persName},</if>
- <if test="mobile != null and mobile != ''">MOBILE = #{mobile},</if>
- <if test="lon != null and lon != ''">LON = #{lon},</if>
- <if test="lat != null and lat != ''">LAT = #{lat},</if>
- </trim>
- <where>ID = #{id}</where>
- </update>
- <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.PersPosition">
- update pers_position
- <trim prefix="set" suffixOverrides=",">
- <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
- <if test="id != null and id != ''">ID = #{id},</if>
- <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
- <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
- <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
- <if test="persName != null and persName != ''">PERS_NAME = #{persName},</if>
- <if test="mobile != null and mobile != ''">MOBILE = #{mobile},</if>
- <if test="lon != null and lon != ''">LON = #{lon},</if>
- <if test="lat != null and lat != ''">LAT = #{lat},</if>
- </trim>
- <include refid="page_where"/>
- </update>
- <!-- 其他自定义SQL -->
- <!--根据人员id获取轨迹路线-->
- <select id="fingPositionByPersid" resultType="cn.com.goldenwater.dcproj.model.PersPosition">
- SELECT LATITUDE,
- to_char(OPERATE_TIME,'YYYY-MM-DD HH24:MI:SS') OPERATE_TIME,
- AD_CODE,
- LONGITUDE,
- ID,
- PERS_ID,
- ORG_ID,
- GROUP_ID,
- PERS_NAME,
- MOBILE,
- LON,
- LAT FROM pers_position WHERE PERS_ID = #{persid}
- <if test="sttm != null and sttm != ''">
- AND OPERATE_TIME BETWEEN to_date(#{sttm},'YYYY-MM-DD HH24:MI:SS') AND to_date(#{entm},'YYYY-MM-DD
- HH24:MI:SS')
- </if>
- order by operate_time
- </select>
- <select id="fingPositionByPersidSimple" resultType="cn.com.goldenwater.dcproj.dto.LonLat">
- SELECT
- LON,
- LAT FROM pers_position WHERE PERS_ID = #{persid}
- <if test="sttm != null and sttm != ''">
- AND OPERATE_TIME BETWEEN to_date(#{sttm},'YYYY-MM-DD HH24:MI:SS') AND to_date(#{entm},'YYYY-MM-DD
- HH24:MI:SS')
- </if>
- order by operate_time
- </select>
- <!--获取轨迹列表-->
- <select id="fingPositionList" parameterType="cn.com.goldenwater.dcproj.param.PersPositionBaseParam"
- resultType="cn.com.goldenwater.dcproj.model.PersPosition">
- SELECT LATITUDE,
- to_char(OPERATE_TIME,'YYYY-MM-DD HH24:MI:SS') OPERATE_TIME,
- AD_CODE,
- LONGITUDE,
- ID,
- PERS_ID,
- ORG_ID,
- GROUP_ID,
- PERS_NAME,
- MOBILE,
- LON,
- LAT FROM pers_position WHERE 1 = 1
- <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
- <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
- <if test="orgId != null and orgId != ''">and ORG_ID = #{orgId}</if>
- <if test="groupId != null and groupId != ''">and GROUP_ID = #{groupId}</if>
- <if test="persName != null and persName != ''">and PERS_NAME = #{persName}</if>
- <if test="mobile != null and mobile != ''">and MOBILE = #{mobile}</if>
- <if test="sttm != null and sttm != '' and entm != null and entm != ''">
- and OPERATE_TIME BETWEEN to_date(#{sttm},'YYYY-MM-DD HH24:MI:SS') AND to_date(#{entm},'YYYY-MM-DD
- HH24:MI:SS')
- </if>
- </select>
- <select id="getOrgByPid" parameterType="String" resultType="cn.com.goldenwater.dcproj.model.BisInspOrg">
- SELECT * FROM BIS_INSP_ORG WHERE ORG_PID = #{orgPid}
- </select>
- <select id="countGroupOnline" parameterType="String" resultType="Integer">
- SELECT COUNT(*) FROM (
- SELECT DISTINCT rl.id FROM (
- SELECT DISTINCT USER_ID FROM
- BIS_INSP_LOG
- WHERE INTM >= TO_DATE(#{sttm}, 'yyyy-mm-dd hh24:mi:ss')
- AND INTM <= TO_DATE(#{entm}, 'yyyy-mm-dd hh24:mi:ss')
- <include refid="orgIdsql"/>
- GROUP BY USER_ID
- ) a LEFT JOIN BIS_INSP_ALL_RLATION rl
- ON a.USER_ID = rl.PERSID AND LENGTH(rl.id)=12
- LEFT JOIN BIS_INSP_ALL B ON RL.ID = B.ID
- WHERE B.STTM <= TO_DATE(#{sttm}, 'yyyy-mm-dd hh24:mi:ss')
- AND B.ENTM >= TO_DATE(#{entm}, 'yyyy-mm-dd hh24:mi:ss')
- GROUP BY rl.ID
- )
- </select>
- <sql id="orgIdsql">
- <choose>
- <when test="orgId !=null and orgId !=''">
- AND ORG_ID=#{orgId}
- </when>
- <otherwise>
- AND ORG_ID is null
- </otherwise>
- </choose>
- </sql>
- <select id="getAllPersId" resultType="String">
- SELECT DISTINCT PERS_ID FROM pers_position
- </select>
- <select id="getDateList" resultType="String">
- SELECT DISTINCT TO_CHAR(OPERATE_TIME,'YYYY-MM-DD') OP_TIME
- FROM pers_position WHERE PERS_ID=#{persId} ORDER BY OP_TIME
- </select>
- </mapper>
|