335 lines
12 KiB
XML
335 lines
12 KiB
XML
<?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.zcloud.mapper.datasource.map.GateMachineMapper">
|
|
<sql id="table"> mk_gate_machine </sql>
|
|
|
|
<sql id="filed">
|
|
f
|
|
.
|
|
GATE_MACHINE_ID
|
|
,
|
|
f.GATE_MACHINE_TYPE,
|
|
f.EQUIPMENTID,
|
|
f.GATE_MACHINE_MODEL,
|
|
f.GATE_MACHINE_NAME,
|
|
f.STATE,
|
|
f.DESCR,
|
|
f.LATITUDE,
|
|
f.LONGITUDE,
|
|
f.CORPINFO_ID,
|
|
f.CREATOR,
|
|
f.CREATTIME,
|
|
f.OPERATOR,
|
|
f.OPERATTIME,
|
|
f.REMAKE
|
|
</sql>
|
|
<insert id="save">
|
|
INSERT INTO mk_gate_machine
|
|
(
|
|
GATE_MACHINE_ID,
|
|
GATE_AREA_ID,
|
|
GATE_MACHINE_NAME,
|
|
GATE_MACHINE_TYPE,
|
|
EQUIPMENTID,
|
|
GATE_MACHINE_MODEL,
|
|
STATE,
|
|
DESCR,
|
|
LONGITUDE,
|
|
LATITUDE,
|
|
CORPINFO_ID,
|
|
CREATOR,
|
|
CREATTIME,
|
|
OPERATOR,
|
|
OPERATTIME)
|
|
VALUES (#{GATE_MACHINE_ID},
|
|
#{GATE_AREA_ID},
|
|
#{GATE_MACHINE_NAME},
|
|
#{GATE_MACHINE_TYPE},
|
|
#{EQUIPMENTID},
|
|
#{GATE_MACHINE_MODEL},
|
|
#{STATE},
|
|
#{DESCR},
|
|
#{LONGITUDE},
|
|
#{LATITUDE},
|
|
#{CORPINFO_ID},
|
|
#{CREATOR},
|
|
#{CREATTIME},
|
|
#{OPERATOR},
|
|
#{OPERATTIME})
|
|
</insert>
|
|
<select id="getDatalistPage" resultType="com.zcloud.entity.PageData">
|
|
select <include refid="filed"></include>, CONCAT_WS('--', f.LATITUDE,f.LONGITUDE) LONGTITUDEANDLATITUDE
|
|
from
|
|
mk_gate_machine f where ISDELETE = 0
|
|
<if test="pd.GATE_MACHINE_NAME != null and pd.GATE_MACHINE_NAME != ''">
|
|
and f.GATE_MACHINE_NAME like CONCAT(CONCAT('%', #{pd.GATE_MACHINE_NAME}),'%')
|
|
</if>
|
|
<if test="pd.GATE_AREA_ID != null and pd.GATE_AREA_ID != ''">
|
|
and f.GATE_AREA_ID = #{pd.GATE_AREA_ID}
|
|
</if>
|
|
<if test="pd.GATE_MACHINE_TYPE != null and pd.GATE_MACHINE_TYPE != ''">
|
|
and f.GATE_MACHINE_TYPE = #{pd.GATE_MACHINE_TYPE}
|
|
</if>
|
|
<if test="pd.GATE_MACHINE_MODEL != null and pd.GATE_MACHINE_MODEL != ''">
|
|
and f.GATE_MACHINE_MODEL like CONCAT(CONCAT('%', #{pd.GATE_MACHINE_MODEL}),'%')
|
|
</if>
|
|
</select>
|
|
<select id="getOnlineGateMachine" resultType="com.zcloud.entity.PageData">
|
|
SELECT
|
|
'PERSON_OUT' TYPE,
|
|
COUNT( 1 ) COUNT
|
|
FROM
|
|
`bus_carduser` f
|
|
WHERE
|
|
f.TIME BETWEEN CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 00:00:00' )
|
|
AND CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 23:59:59' )
|
|
AND STATE = 1
|
|
<if test="AREA != null and AREA != ''">
|
|
and CORPINFO_ID in (select CORPINFO_ID from bus_corp_info where AREA = #{AREA} and ISDELETE = 0)
|
|
</if>
|
|
<if test="CORP_INFO_ID != null and CORP_INFO_ID != ''">
|
|
and CORPINFO_ID = #{CORP_INFO_ID}
|
|
</if>
|
|
UNION ALL
|
|
SELECT
|
|
'PERSON_IN' TYPE,
|
|
COUNT( 1 ) count
|
|
FROM
|
|
`bus_carduser` f
|
|
WHERE
|
|
f.TIME BETWEEN CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 00:00:00' )
|
|
AND CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 23:59:59' )
|
|
AND STATE = 0
|
|
<if test="AREA != null and AREA != ''">
|
|
and CORPINFO_ID in (select CORPINFO_ID from bus_corp_info where AREA = #{AREA} and ISDELETE = 0)
|
|
</if>
|
|
<if test="CORP_INFO_ID != null and CORP_INFO_ID != ''">
|
|
and CORPINFO_ID = #{CORP_INFO_ID}
|
|
</if>
|
|
UNION ALL
|
|
SELECT
|
|
'CAR_IN' TYPE,
|
|
IFNULL( COUNT( 1 ), 0 ) COUNT
|
|
FROM
|
|
bus_foreigncar c
|
|
WHERE
|
|
c.ISDELETE = 0 and
|
|
c.TIME_IN BETWEEN CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 00:00:00' )
|
|
AND CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 23:59:59' )
|
|
<if test="AREA != null and AREA != ''">
|
|
and CORPINFO_ID in (select CORPINFO_ID from bus_corp_info where AREA = #{AREA} and ISDELETE = 0)
|
|
</if>
|
|
<if test="CORP_INFO_ID != null and CORP_INFO_ID != ''">
|
|
and CORPINFO_ID = #{CORP_INFO_ID}
|
|
</if>
|
|
UNION ALL
|
|
SELECT
|
|
'CAR_OUT' TYPE,
|
|
IFNULL( COUNT( 1 ), 0 ) COUNT
|
|
FROM
|
|
bus_foreigncar c
|
|
WHERE
|
|
c.ISDELETE = 0 and
|
|
c.TIME_OUT BETWEEN CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 00:00:00' )
|
|
AND CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 23:59:59' )
|
|
<if test="AREA != null and AREA != ''">
|
|
and CORPINFO_ID in (select CORPINFO_ID from bus_corp_info where AREA = #{AREA} and ISDELETE = 0)
|
|
</if>
|
|
<if test="CORP_INFO_ID != null and CORP_INFO_ID != ''">
|
|
and CORPINFO_ID = #{CORP_INFO_ID}
|
|
</if>
|
|
UNION ALL
|
|
SELECT
|
|
'CAMERA' TYPE,
|
|
IFNULL( COUNT( 1 ), 0 ) COUNT
|
|
FROM
|
|
bus_gatevideo v
|
|
LEFT JOIN mk_gate_area o on v.GATE_AREA_ID = o.GATE_AREA_ID
|
|
WHERE
|
|
v.isdelete = 0 and v.LATITUDE IS NOT NULL and v.LONGITUDE IS NOT NULL
|
|
<if test="AREA != null and AREA != ''">
|
|
and o.CORPINFO_ID in (select CORPINFO_ID from bus_corp_info where AREA = #{AREA} and ISDELETE = 0)
|
|
</if>
|
|
<if test="CORP_INFO_ID != null and CORP_INFO_ID != ''">
|
|
and o.CORPINFO_ID = #{CORP_INFO_ID}
|
|
</if>
|
|
group by
|
|
v.GATEVIDEO_ID
|
|
</select>
|
|
<select id="getTodayInOutCount" resultType="com.zcloud.entity.PageData">
|
|
SELECT
|
|
f.EQUIPMENTID,
|
|
COUNT( 1 ) COUNT,
|
|
m.GATE_MACHINE_NAME
|
|
FROM
|
|
bus_carduser f
|
|
LEFT JOIN mk_gate_machine m ON f.EQUIPMENTID = m.EQUIPMENTID
|
|
WHERE
|
|
f.TIME > CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 00:00:00' )
|
|
<if test="AREA != null and AREA != ''">
|
|
and m.CORPINFO_ID in (select CORPINFO_ID from bus_corp_info where AREA = #{AREA} and ISDELETE = 0)
|
|
</if>
|
|
<if test="CORP_INFO_ID != null and CORP_INFO_ID != ''">
|
|
and m.CORPINFO_ID = #{CORP_INFO_ID}
|
|
</if>
|
|
<if test="CORPINFO_ID != null and CORPINFO_ID != ''">
|
|
and m.CORPINFO_ID = #{CORPINFO_ID}
|
|
</if>
|
|
|
|
GROUP BY
|
|
f.EQUIPMENTID
|
|
ORDER BY
|
|
GATE_MACHINE_NAME DESC
|
|
</select>
|
|
<select id="getGatePosition" resultType="com.zcloud.entity.PageData">
|
|
select LONGITUDE,
|
|
LATITUDE,
|
|
GATE_MACHINE_NAME,
|
|
'${TYPE}' TYPE,
|
|
GATE_MACHINE_ID id
|
|
FROM
|
|
mk_gate_machine
|
|
WHERE
|
|
isdelete = 0
|
|
and GATE_MACHINE_TYPE = #{GATE_MACHINE_TYPE}
|
|
<if test="AREA != null and AREA != ''">
|
|
and CORPINFO_ID in (select CORPINFO_ID from bus_corp_info where AREA = #{AREA} and ISDELETE = 0)
|
|
</if>
|
|
<if test="CORP_INFO_ID != null and CORP_INFO_ID != ''">
|
|
and CORPINFO_ID = #{CORP_INFO_ID}
|
|
</if>
|
|
</select>
|
|
<select id="getGateMachineInfoById" resultType="com.zcloud.entity.PageData">
|
|
SELECT
|
|
r.GATE_AREA_NAME,
|
|
GROUP_CONCAT( f.GATE_MACHINE_NAME ) GATE_MACHINE_NAME,
|
|
GROUP_CONCAT( DISTINCT f.GATE_MACHINE_MODEL ) GATE_MACHINE_MODEL,
|
|
GROUP_CONCAT( DISTINCT r.CORPINFO_ID ) CORPINFO_ID,
|
|
GROUP_CONCAT( f.EQUIPMENTID ) EQUIPMENTID
|
|
FROM
|
|
mk_gate_machine f
|
|
LEFT JOIN mk_gate_area r ON r.GATE_AREA_ID = f.GATE_AREA_ID
|
|
|
|
left join bus_gatevideo v on v.GATE_AREA_ID = f.GATE_AREA_ID
|
|
WHERE
|
|
f.ISDELETE = 0
|
|
<if test="GATE_AREA_ID != null and GATE_AREA_ID != ''" >
|
|
and f.GATE_AREA_ID = #{GATE_AREA_ID}
|
|
</if>
|
|
<if test="GATEVIDEO_ID != null and GATEVIDEO_ID != ''" >
|
|
AND v.GATEVIDEO_ID = #{GATEVIDEO_ID}
|
|
</if>
|
|
|
|
GROUP BY
|
|
f.GATE_AREA_ID
|
|
</select>
|
|
<select id="getPersonRecordCountByEId" resultType="com.zcloud.entity.PageData">
|
|
SELECT
|
|
COUNT( 1 ) COUNT,
|
|
CASE
|
|
STATE
|
|
WHEN 0 THEN
|
|
'PERSON_IN' ELSE 'PERSON_OUT'
|
|
END TYPE
|
|
FROM
|
|
bus_carduser
|
|
WHERE
|
|
EQUIPMENTID in <foreach collection="array" item="item" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
AND TIME BETWEEN CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 00:00:00' )
|
|
AND CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 23:59:59' )
|
|
GROUP BY
|
|
STATE
|
|
</select>
|
|
<select id="getCarRecordCountByEId" resultType="com.zcloud.entity.PageData">
|
|
SELECT
|
|
COUNT( 1 ) COUNT,
|
|
'CAR_IN' TYPE
|
|
FROM
|
|
bus_foreigncar
|
|
WHERE
|
|
EQUIPMENTID in
|
|
<foreach collection="array" item="item" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
AND TIME_IN BETWEEN CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 00:00:00' )
|
|
AND CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 23:59:59' ) UNION ALL
|
|
SELECT
|
|
COUNT( 1 ) COUNT,
|
|
'CAR_OUT' TYPE
|
|
FROM
|
|
bus_foreigncar
|
|
WHERE
|
|
EQUIPMENTID in
|
|
<foreach collection="array" item="item" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
AND TIME_OUT BETWEEN CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 00:00:00' )
|
|
AND CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 23:59:59' )
|
|
</select>
|
|
<select id="getCarRecordCountByCorpId" resultType="com.zcloud.entity.PageData">
|
|
SELECT
|
|
COUNT( 1 ) COUNT,
|
|
'CAR_IN' TYPE
|
|
FROM
|
|
bus_foreigncar
|
|
WHERE
|
|
ISDELETE = 0
|
|
and CORPINFO_ID = #{CORPINFO_ID}
|
|
AND TIME_IN BETWEEN CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 00:00:00' )
|
|
AND CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 23:59:59' ) UNION ALL
|
|
SELECT
|
|
COUNT( 1 ) COUNT,
|
|
'CAR_OUT' TYPE
|
|
FROM
|
|
bus_foreigncar
|
|
WHERE
|
|
ISDELETE = 0
|
|
and CORPINFO_ID = #{CORPINFO_ID}
|
|
AND TIME_OUT BETWEEN CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 00:00:00' )
|
|
AND CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 23:59:59' )
|
|
</select>
|
|
|
|
<update id="edit">
|
|
update
|
|
<include refid="table"></include>
|
|
set
|
|
GATE_MACHINE_TYPE = #{GATE_MACHINE_TYPE},
|
|
GATE_MACHINE_MODEL = #{GATE_MACHINE_MODEL},
|
|
GATE_MACHINE_NAME = #{GATE_MACHINE_NAME},
|
|
STATE = #{STATE},
|
|
DESCR = #{DESCR},
|
|
LONGITUDE = #{LONGITUDE},
|
|
LATITUDE = #{LATITUDE},
|
|
CORPINFO_ID = #{CORPINFO_ID},
|
|
OPERATOR = #{OPERATOR},
|
|
OPERATTIME = #{OPERATTIME},
|
|
REMAKE = #{REMAKE}
|
|
where
|
|
GATE_MACHINE_ID = #{GATE_MACHINE_ID}
|
|
</update>
|
|
|
|
<update id="removeByIds">
|
|
update mk_gate_machine
|
|
set ISDELETE = 1
|
|
where GATE_MACHINE_ID in
|
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</update>
|
|
|
|
|
|
<select id="getPersonRecordListAllByIdlistPage" resultType="com.zcloud.entity.PageData">
|
|
SELECT
|
|
f.*
|
|
from bus_carduser f
|
|
WHERE
|
|
1=1
|
|
and f.EQUIPMENTID in (select EQUIPMENTID from mk_gate_machine where GATE_AREA_ID = #{pd.GATE_AREA_ID})
|
|
AND f.TIME BETWEEN CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 00:00:00' )
|
|
AND CONCAT( DATE_FORMAT( now(), '%Y-%m-%d' ), ' 23:59:59' )
|
|
order by f.time desc
|
|
</select>
|
|
</mapper>
|