活动sql
This commit is contained in:
parent
1cdf15b934
commit
467d70e0c7
|
|
@ -0,0 +1,331 @@
|
||||||
|
<?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.dkl.large.mapper.DklActivityMapper">
|
||||||
|
|
||||||
|
<resultMap type="DklActivity" id="DklActivityResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="activityName" column="activity_name" />
|
||||||
|
<result property="holidayName" column="holiday_name" />
|
||||||
|
<result property="address" column="address" />
|
||||||
|
<result property="region" column="region" />
|
||||||
|
<result property="isKeyDay" column="is_key_day" />
|
||||||
|
<result property="startTime" column="start_time" />
|
||||||
|
<result property="endTime" column="end_time" />
|
||||||
|
<result property="dutyPeople" column="duty_people" />
|
||||||
|
<result property="dutyPhone" column="duty_phone" />
|
||||||
|
<result property="lng" column="lng" />
|
||||||
|
<result property="lat" column="lat" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="delFlag" column="del_flag" />
|
||||||
|
<result property="loadBearingMax" column="load_bearing_max" />
|
||||||
|
<result property="activityText" column="activity_text" />
|
||||||
|
<result property="sigenCode" column="sigen_code" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectDklActivityVo">
|
||||||
|
select da.id, da.activity_name, da.holiday_name, da.address, da.region, da.is_key_day, da.start_time, da.end_time,
|
||||||
|
da.duty_people, da.duty_phone, da.lng, da.lat, da.create_by, da.create_time, da.update_by, da.update_time,
|
||||||
|
da.del_flag,da.load_bearing_max,da.activity_text,sdd.dict_label as regionname,da.sigen_code from dkl_activity da
|
||||||
|
left join sys_dept d on da.dept_id = d.dept_id
|
||||||
|
LEFT JOIN sys_dict_data sdd ON sdd.dict_value = da.region
|
||||||
|
AND sdd.dict_type = 'activity_area'
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectDklActivityList" parameterType="DklActivity" resultMap="DklActivityResult">
|
||||||
|
<include refid="selectDklActivityVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="activityName != null and activityName != ''"> and da.activity_name like concat('%', #{activityName}, '%')</if>
|
||||||
|
<if test="holidayName != null and holidayName != ''"> and da.holiday_name like concat('%', #{holidayName}, '%')</if>
|
||||||
|
<if test="address != null and address != ''"> and da.address = #{address}</if>
|
||||||
|
<if test="region != null and region != ''"> and da.region = #{region}</if>
|
||||||
|
<if test="isKeyDay != null and isKeyDay != ''"> and da.is_key_day = #{isKeyDay}</if>
|
||||||
|
<if test="dutyPeople != null and dutyPeople != ''"> and da.duty_people = #{dutyPeople}</if>
|
||||||
|
<if test="dutyPhone != null and dutyPhone != ''"> and da.duty_phone = #{dutyPhone}</if>
|
||||||
|
<if test="lng != null and lng != ''"> and da.lng = #{lng}</if>
|
||||||
|
<if test="lat != null and lat != ''"> and da.lat = #{lat}</if>
|
||||||
|
<if test="delFlag != null and delFlag != ''"> and da.del_flag = #{delFlag}</if>
|
||||||
|
<if test="deptId != null "> and da.dept_id = #{deptId}</if>
|
||||||
|
<if test="loadBearingMax != null and loadBearingMax != ''"> and da.load_bearing_max = #{loadBearingMax}</if>
|
||||||
|
<if test="activityText != null and activityText != ''"> and da.activity_text = #{activityText}</if>
|
||||||
|
<if test="startTime != null and endTime != null ">
|
||||||
|
AND da.start_time BETWEEN #{startTime} and #{endTime}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
|
||||||
|
<!-- 数据范围过滤 -->
|
||||||
|
${params.dataScope}
|
||||||
|
order by da.create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectDklActivityById" parameterType="int" resultMap="DklActivityResult">
|
||||||
|
<include refid="selectDklActivityVo"/>
|
||||||
|
where da.id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertDklActivity" parameterType="DklActivity" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into dkl_activity
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="activityName != null">activity_name,</if>
|
||||||
|
<if test="holidayName != null">holiday_name,</if>
|
||||||
|
<if test="address != null">address,</if>
|
||||||
|
<if test="region != null">region,</if>
|
||||||
|
<if test="isKeyDay != null">is_key_day,</if>
|
||||||
|
<if test="startTime != null">start_time,</if>
|
||||||
|
<if test="endTime != null">end_time,</if>
|
||||||
|
<if test="dutyPeople != null">duty_people,</if>
|
||||||
|
<if test="dutyPhone != null">duty_phone,</if>
|
||||||
|
<if test="lng != null">lng,</if>
|
||||||
|
<if test="lat != null">lat,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
<if test="delFlag != null">del_flag,</if>
|
||||||
|
<if test="loadBearingMax != null">load_bearing_max,</if>
|
||||||
|
<if test="deptId != null">dept_id,</if>
|
||||||
|
<if test="activityText != null">activity_text,</if>
|
||||||
|
<if test="sigenCode != null">sigen_code,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="activityName != null">#{activityName},</if>
|
||||||
|
<if test="holidayName != null">#{holidayName},</if>
|
||||||
|
<if test="address != null">#{address},</if>
|
||||||
|
<if test="region != null">#{region},</if>
|
||||||
|
<if test="isKeyDay != null">#{isKeyDay},</if>
|
||||||
|
<if test="startTime != null">#{startTime},</if>
|
||||||
|
<if test="endTime != null">#{endTime},</if>
|
||||||
|
<if test="dutyPeople != null">#{dutyPeople},</if>
|
||||||
|
<if test="dutyPhone != null">#{dutyPhone},</if>
|
||||||
|
<if test="lng != null">#{lng},</if>
|
||||||
|
<if test="lat != null">#{lat},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
<if test="delFlag != null">#{delFlag},</if>
|
||||||
|
<if test="loadBearingMax != null">#{loadBearingMax},</if>
|
||||||
|
<if test="deptId != null">#{deptId},</if>
|
||||||
|
<if test="activityText != null">#{activityText},</if>
|
||||||
|
<if test="sigenCode != null">#{sigenCode},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateDklActivity" parameterType="DklActivity">
|
||||||
|
update dkl_activity
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="activityName != null">activity_name = #{activityName},</if>
|
||||||
|
<if test="holidayName != null">holiday_name = #{holidayName},</if>
|
||||||
|
<if test="address != null">address = #{address},</if>
|
||||||
|
<if test="region != null">region = #{region},</if>
|
||||||
|
<if test="isKeyDay != null">is_key_day = #{isKeyDay},</if>
|
||||||
|
<if test="startTime != null">start_time = #{startTime},</if>
|
||||||
|
<if test="endTime != null">end_time = #{endTime},</if>
|
||||||
|
<if test="dutyPeople != null">duty_people = #{dutyPeople},</if>
|
||||||
|
<if test="dutyPhone != null">duty_phone = #{dutyPhone},</if>
|
||||||
|
<if test="lng != null">lng = #{lng},</if>
|
||||||
|
<if test="lat != null">lat = #{lat},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||||
|
<if test="loadBearingMax != null">load_bearing_max = #{loadBearingMax},</if>
|
||||||
|
<if test="activityText != null">activity_text = #{activityText},</if>
|
||||||
|
<if test="sigenCode != null">sigen_code = #{sigenCode},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteDklActivityById" parameterType="int">
|
||||||
|
update dkl_activity set del_flag = 2 where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<update id="deleteDklActivityByIds" parameterType="int">
|
||||||
|
update dkl_activity set del_flag = 2 where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
<!-- delete from dkl_activity where id in-->
|
||||||
|
<!-- <foreach item="id" collection="array" open="(" separator="," close=")">-->
|
||||||
|
<!-- #{id}-->
|
||||||
|
<!-- </foreach>-->
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="ativityEarlyWarning" parameterType="DklActivity" resultMap="DklActivityResult">
|
||||||
|
SELECT
|
||||||
|
da.ID,
|
||||||
|
da.load_bearing_max ,
|
||||||
|
da.activity_name,
|
||||||
|
SUM ( T.numberPeople ) AS numberPeople,
|
||||||
|
CAST ( SUM ( T.numberPeople ) / da.load_bearing_max AS DECIMAL ( 10, 3 ) )*100 AS capacityFactor,
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
icon
|
||||||
|
FROM
|
||||||
|
dkl_warning_threshold
|
||||||
|
WHERE
|
||||||
|
CAST ( SUM ( T.numberPeople ) / da.load_bearing_max AS DECIMAL ( 10, 3 ) ) >= max_capacity
|
||||||
|
AND CAST ( SUM ( T.numberPeople ) / da.load_bearing_max AS DECIMAL ( 10, 3 ) ) <= min_capacity
|
||||||
|
) as icon
|
||||||
|
FROM
|
||||||
|
dkl_activity AS da
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
dv.activity_id AS activityId,
|
||||||
|
dvd.video_id AS videoId,
|
||||||
|
SUM ( dvd.number_people ) AS numberPeople
|
||||||
|
FROM
|
||||||
|
dkl_video_data AS dvd
|
||||||
|
LEFT JOIN dkl_video AS dv ON dv."id" = dvd.video_id
|
||||||
|
AND dv.del_flag = '0'
|
||||||
|
WHERE
|
||||||
|
dvd.del_flag = '0'
|
||||||
|
<if test="filterTime != null">
|
||||||
|
AND dvd.acquisition_time >= DATE_TRUNC( 'day', #{filterTime} :: DATE )
|
||||||
|
AND dvd.acquisition_time < DATE_TRUNC( 'day', #{filterTime} :: DATE + INTERVAL '1 day' )
|
||||||
|
</if>
|
||||||
|
GROUP BY
|
||||||
|
dv.activity_id,
|
||||||
|
dvd.video_id
|
||||||
|
) AS T ON da.ID = T.activityId
|
||||||
|
WHERE
|
||||||
|
da.del_flag = '0'
|
||||||
|
GROUP BY
|
||||||
|
da.ID
|
||||||
|
ORDER BY numberPeople
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="thermogramStatistics" parameterType="DklActivity" resultMap="DklActivityResult">
|
||||||
|
SELECT
|
||||||
|
da.ID,
|
||||||
|
da.load_bearing_max ,
|
||||||
|
da.activity_name ,
|
||||||
|
da.lng,
|
||||||
|
da.lat,
|
||||||
|
SUM ( T.numberPeople ) AS numberPeople,
|
||||||
|
CAST ( SUM ( T.numberPeople ) / da.load_bearing_max AS DECIMAL ( 10, 3 ) )*100 AS capacityFactor
|
||||||
|
FROM
|
||||||
|
dkl_activity AS da
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
dv.activity_id AS activityId,
|
||||||
|
dvd.video_id AS videoId,
|
||||||
|
SUM ( dvd.number_people ) AS numberPeople
|
||||||
|
FROM
|
||||||
|
dkl_video_data AS dvd
|
||||||
|
LEFT JOIN dkl_video AS dv ON dv."id" = dvd.video_id
|
||||||
|
AND dv.del_flag = '0'
|
||||||
|
WHERE
|
||||||
|
dvd.del_flag = '0'
|
||||||
|
<if test="filterTime != null">
|
||||||
|
AND dvd.acquisition_time >= DATE_TRUNC( 'day', #{filterTime} :: DATE )
|
||||||
|
AND dvd.acquisition_time < DATE_TRUNC( 'day', #{filterTime} :: DATE + INTERVAL '1 day' )
|
||||||
|
</if>
|
||||||
|
GROUP BY
|
||||||
|
dv.activity_id,
|
||||||
|
dvd.video_id
|
||||||
|
) AS T ON da.ID = T.activityId
|
||||||
|
WHERE
|
||||||
|
da.del_flag = '0'
|
||||||
|
<if test="isKeyDay==1">
|
||||||
|
AND da.is_key_day=#{isKeyDay}
|
||||||
|
</if>
|
||||||
|
GROUP BY
|
||||||
|
da.ID
|
||||||
|
ORDER BY numberPeople
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="regionalStatistics" parameterType="DklActivity" resultMap="DklActivityResult">
|
||||||
|
SELECT
|
||||||
|
da.region,
|
||||||
|
sdd.dict_label as regionname,
|
||||||
|
SUM ( T.numberPeople ) AS numberPeople
|
||||||
|
FROM
|
||||||
|
dkl_activity AS da
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
dv.activity_id AS activityId,
|
||||||
|
dvd.video_id AS videoId,
|
||||||
|
SUM ( dvd.number_people ) AS numberPeople
|
||||||
|
FROM
|
||||||
|
dkl_video_data AS dvd
|
||||||
|
LEFT JOIN dkl_video AS dv ON dv."id" = dvd.video_id
|
||||||
|
AND dv.del_flag = '0'
|
||||||
|
WHERE
|
||||||
|
dvd.del_flag = '0'
|
||||||
|
<if test="filterTime != null">
|
||||||
|
AND dvd.acquisition_time >= DATE_TRUNC( 'day', #{filterTime} :: DATE )
|
||||||
|
AND dvd.acquisition_time < DATE_TRUNC( 'day', #{filterTime} :: DATE + INTERVAL '1 day' )
|
||||||
|
</if>
|
||||||
|
GROUP BY
|
||||||
|
dv.activity_id,
|
||||||
|
dvd.video_id
|
||||||
|
) AS T ON da.ID = T.activityId
|
||||||
|
LEFT JOIN sys_dict_data sdd ON sdd.dict_value = da.region
|
||||||
|
AND sdd.dict_type = 'activity_area'
|
||||||
|
WHERE
|
||||||
|
da.del_flag = '0'
|
||||||
|
GROUP BY
|
||||||
|
da.region,
|
||||||
|
sdd.dict_label
|
||||||
|
ORDER BY
|
||||||
|
numberPeople
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getActivityCount" parameterType="string">
|
||||||
|
SELECT COUNT(*) FROM dkl_activity WHERE del_flag = '0'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="homeActivityStatistics" parameterType="DklActivity" resultMap="DklActivityResult" >
|
||||||
|
SELECT
|
||||||
|
da.region,
|
||||||
|
count( da.region) AS numberPeople,
|
||||||
|
sdd.dict_label AS regionname
|
||||||
|
FROM
|
||||||
|
dkl_activity AS da
|
||||||
|
LEFT JOIN sys_dict_data sdd ON sdd.dict_value = da.region
|
||||||
|
AND sdd.dict_type = 'activity_area'
|
||||||
|
WHERE
|
||||||
|
da.del_flag = '0'
|
||||||
|
<if test="startTime != null and endTime != null ">
|
||||||
|
AND da.start_time BETWEEN #{startTime} and #{endTime}
|
||||||
|
</if>
|
||||||
|
GROUP BY
|
||||||
|
da.region,
|
||||||
|
sdd.dict_label
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="homeActivityStatisticsPeople" parameterType="DklActivity" resultMap="DklActivityResult" >
|
||||||
|
SELECT
|
||||||
|
da.region,
|
||||||
|
sdd.dict_label as regionname,
|
||||||
|
SUM ( da.load_bearing_max ) AS numberPeople
|
||||||
|
FROM
|
||||||
|
dkl_activity AS da
|
||||||
|
LEFT JOIN sys_dict_data sdd ON sdd.dict_value = da.region
|
||||||
|
AND sdd.dict_type = 'activity_area'
|
||||||
|
WHERE
|
||||||
|
da.del_flag = '0'
|
||||||
|
<if test="startTime != null and endTime != null ">
|
||||||
|
AND da.start_time BETWEEN #{startTime} and #{endTime}
|
||||||
|
</if>
|
||||||
|
|
||||||
|
GROUP BY
|
||||||
|
da.region,
|
||||||
|
sdd.dict_label
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="checkActivityNameUnique" resultMap="DklActivityResult">
|
||||||
|
<include refid="selectDklActivityVo"/>
|
||||||
|
where da.activity_name=#{activityName} and da.del_flag = '0' limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue