| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- <?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="platform.modules.government.dao.NotifyDao">
- <select id="findAllNotify" resultType="platform.modules.government.entity.Notify">
- select temp.* from
- (
- select n.*,
- getPushDate(n.id,'0') as push_date,
- '' as receive_date,
- getCodeByValue('notify_type',n.type) as type_code,
- '1' as is_read,
- '' as notify_detail_id,
- zUser.user_type as source,
-
- case zUser.user_type
- when '0' then '高新区政府'
- when '1' then zUser.build_name
- when '4' then zUser.street_name
- else '' end as source_name,
-
- n.archive_date as archive_date_detail
- from z_notify n
- left join z_user zUser on zUser.id = n.create_by
- WHERE n.del_flag='0'
- <choose>
- <when test="!isArchive">
- and n.status=0
- </when>
- <otherwise>
- and n.status=1
- </otherwise>
- </choose>
- <!-- and zUser.user_type = #{condition.user_type} 政府,街道也能看到下级发送的通知 -->
- <if test="condition.street_id!=null and condition.street_id!=''">
- and zUser.street_id=#{condition.street_id}
- </if>
- <if test="condition.build_id!=null and condition.build_id!='' ">
- and zUser.build_id=#{condition.build_id}
- </if>
- <if test="condition.company_id!=null and condition.company_id!='' ">
- and zUser.company_id=#{condition.company_id}
- </if>
- <!-- <if test="condition.keyword!=null and condition.keyword!=''">
- and n.title like CONCAT('%',#{condition.keyword},'%')
- </if> -->
- <if test="condition.type!=null and condition.type!=''">
- and n.type = #{condition.type}
- </if>
- <!-- 政府不能看到接到园区还没推送的消息,只能看到已经推送的消息 -->
- <if test="condition.user_type == 0">
- and (zUser.user_type = 0 or n.is_push = 1 )
- </if>
- <if test="(condition.street_id!=null and condition.street_id!='')
- or (condition.build_id!=null and condition.build_id!='' )
- or (condition.company_id!=null and condition.company_id!='' )">
- UNION
- select
- a.*,
- getPushDate(a.id,b.id) as push_date,
- b.create_time as receive_date,
- getCodeByValue('notify_type',a.type) as type_code,
- b.is_read as is_read,
- b.id as notify_detail_id,
- zUser.user_type as source,
-
- case zUser.user_type
- when '0' then '高新区政府'
- when '1' then zUser.build_name
- when '4' then zUser.street_name
- else '' end as source_name,
-
- b.archive_date as archive_date_detail
- from z_notify a
- LEFT JOIN z_notify_detail b on b.z_notify_id=a.id
- left join z_user zUser on zUser.id = b.create_by
- WHERE
- b.push_type = #{condition.user_type}
- <if test="condition.street_id!=null and condition.street_id!=''">
- and b.push_id=#{condition.street_id}
- </if>
- <if test="condition.build_id!=null and condition.build_id!='' ">
- and b.push_id=#{condition.build_id}
- </if>
- <if test="condition.company_id!=null and condition.company_id!='' ">
- and b.push_id=#{condition.company_id}
- </if>
- and ( DATE(a.expiry_date) > NOW() or a.expiry_date=null or a.expiry_date='' )
- and a.del_flag='0' and b.del_flag='0'
- <choose>
- <when test="!isArchive">
- and b.status=0
- </when>
- <otherwise>
- and b.status=1
- </otherwise>
- </choose>
- <!-- <if test="condition.keyword!=null and condition.keyword!=''">
- and a.title like CONCAT('%',#{condition.keyword},'%')
- </if> -->
- <if test="condition.type!=null and condition.type!=''">
- and a.type = #{condition.type}
- </if>
- </if>
- ) temp where 1=1
- <if test="condition.begin_date != null and condition.begin_date !='' ">
- <![CDATA[ and DATE_FORMAT(temp.create_time, '%Y-%m-%d')>= DATE_FORMAT(#{condition.begin_date}, '%Y-%m-%d') ]]>
- </if>
- <if test="condition.end_date != null and condition.end_date !='' ">
- <![CDATA[ and DATE_FORMAT(temp.create_time, '%Y-%m-%d')<= DATE_FORMAT(#{condition.end_date}, '%Y-%m-%d') ]]>
- </if>
- <if test="condition.keyword!=null and condition.keyword!=''">
- and (
- temp.title like CONCAT('%',#{condition.keyword},'%')
- or temp.source_name like CONCAT('%',#{condition.keyword},'%')
- )
- </if>
- order by temp.create_time desc
- </select>
- <select id="findPushNotify" resultType="platform.modules.government.entity.Notify">
- select
- a.*,
- getCodeByValue('notify_type',a.type) as type_code,
- b.is_read as is_read,
- b.id as notify_detail_id,
- zUser.user_type as source
- from z_notify a
- LEFT JOIN z_notify_detail b on b.z_notify_id=a.id
- left join z_user zUser on zUser.id = a.create_by
- WHERE
- a.del_flag='0'
- <if test="condition.street_id!=null and condition.street_id!=''">
- and b.push_id=#{condition.street_id}
- </if>
- <if test="condition.build_id!=null and condition.build_id!='' ">
- b.push_id=#{condition.build_id}
- </if>
- and a.del_flag='0' and b.del_flag='0'
- <if test="condition.keyword!=null and condition.keyword!=''">
- and a.title like CONCAT('%',#{condition.keyword},'%')
- </if>
- order by create_time desc
- </select>
- <select id="findNotifyList" resultType="platform.modules.government.entity.Notify">
- select temp.* from
- (
- select n.*,
- getPushDate(n.id,'0') as push_date,
- getCodeByValue('notify_type',n.type) as type_code,
- '1' as is_read,
- '' as notify_detail_id,
- zUser.user_type as source,
- case zUser.user_type
- when '0' then '高新区政府'
- when '1' then zUser.build_name
- when '4' then zUser.street_name
- else '' end as source_name
- from z_notify n
- left join z_user zUser on zUser.id = n.create_by
- WHERE n.del_flag='0' and n.status='0'
- and zUser.user_type = #{currUser.user_type}
- <if test="notifyDto.street_id!=null and notifyDto.street_id!=''">
- and zUser.street_id=#{notifyDto.street_id}
- </if>
- <if test="notifyDto.build_id!=null and notifyDto.build_id!='' ">
- and zUser.build_id=#{notifyDto.build_id}
- </if>
- <if test="notifyDto.company_id!=null and notifyDto.company_id!='' ">
- and zUser.company_id=#{notifyDto.company_id}
- </if>
- <if test="(notifyDto.street_id!=null and notifyDto.street_id!='')
- or (notifyDto.build_id!=null and notifyDto.build_id!='' )
- or (notifyDto.company_id!=null and notifyDto.company_id!='' )">
- UNION
- select
- a.*,
- getPushDate(a.id,b.id) as push_date,
- getCodeByValue('notify_type',a.type) as type_code,
- b.is_read as is_read,
- b.id as notify_detail_id,
- zUser.user_type as source,
- case zUser.user_type
- when '0' then '高新区政府'
- when '1' then zUser.build_name
- when '4' then zUser.street_name
- else '' end as source_name
- from z_notify a
- LEFT JOIN z_notify_detail b on b.z_notify_id=a.id
- left join z_user zUser on zUser.id = a.create_by
- WHERE
- b.push_type = #{currUser.user_type}
- <if test="notifyDto.street_id!=null and notifyDto.street_id!=''">
- and b.push_id=#{notifyDto.street_id}
- </if>
- <if test="notifyDto.build_id!=null and notifyDto.build_id!='' ">
- and b.push_id=#{notifyDto.build_id}
- </if>
- <if test="notifyDto.company_id!=null and notifyDto.company_id!=''">
- and b.push_id=#{notifyDto.company_id}
- </if>
- and a.del_flag='0' and a.status='0' and b.del_flag='0' and b.status='0'
- <if test="notifyDto.is_read!=null">
- and b.is_read = #{notifyDto.is_read}
- </if>
- and ( DATE(a.expiry_date) > NOW() or a.expiry_date=null or a.expiry_date='' )
- </if>
- ) temp
- order by temp.create_time desc limit #{notifyDto.count}
- </select>
- <!-- 获取上级推送过来的通知 -->
- <select id="findReceivedNotifyList" resultType="platform.modules.government.entity.Notify">
- select temp.* from
- (
- select
- a.*,
- getPushDate(a.id,b.id) as push_date,
- getCodeByValue('notify_type',a.type) as type_code,
- b.is_read as is_read,
- b.id as notify_detail_id,
- zUser.user_type as source,
- case zUser.user_type
- when '0' then '高新区政府'
- when '1' then zUser.build_name
- when '4' then zUser.street_name
- else '' end as source_name
- from z_notify a
- LEFT JOIN z_notify_detail b on b.z_notify_id=a.id
- left join z_user zUser on zUser.id = a.create_by
- WHERE
- b.push_type = #{currUser.user_type}
- <if test="notifyDto.street_id!=null and notifyDto.street_id!=''">
- and b.push_id=#{notifyDto.street_id}
- </if>
- <if test="notifyDto.build_id!=null and notifyDto.build_id!='' ">
- and b.push_id=#{notifyDto.build_id}
- </if>
- <if test="notifyDto.company_id!=null and notifyDto.company_id!=''">
- and b.push_id=#{notifyDto.company_id}
- </if>
- and a.del_flag='0' and a.status='0' and b.del_flag='0' and b.status='0'
- and ( DATE(a.expiry_date) > NOW() or a.expiry_date=null or a.expiry_date='' )
- <if test="notifyDto.is_read!=null">
- and b.is_read = #{notifyDto.is_read}
- </if>
- ) temp
- order by temp.create_time desc limit #{notifyDto.count}
- </select>
- <select id="findCompanyNotifyList" resultType="platform.modules.government.entity.Notify">
-
- select
- a.*,
- getPushDate(a.id,b.id) as push_date,
- getCodeByValue('notify_type',a.type) as type_code,
- b.is_read as is_read,
- b.id as notify_detail_id,
- zUser.user_type as source
- from z_notify a
- LEFT JOIN z_notify_detail b on b.z_notify_id=a.id
- left join z_user zUser on zUser.id = a.create_by
- WHERE
- b.push_type = #{currUser.user_type} and a.is_read = 0
- and b.push_id=#{notifyDto.company_id}
- and a.del_flag='0' and a.status='0' and b.del_flag='0' and b.status='0'
-
- order by temp.create_time desc limit #{notifyDto.count}
-
- </select>
- <select id="findStreetReadNum" resultType="Integer">
- select count(d.id) from z_notify_detail d
- inner join z_notify n on n.id=d.z_notify_id
- where d.user_type=4 and d.push_street_id=#{streetId} and d.del_flag=0
- <![CDATA[ and DATE_FORMAT(n.`create_time`, '%Y-%m-%d')<= DATE_FORMAT(#{dateTo}, '%Y-%m-%d') ]]>
- <![CDATA[ and DATE_FORMAT(n.`create_time`, '%Y-%m-%d')>= DATE_FORMAT(#{dateFrom}, '%Y-%m-%d')
- ]]> and d.is_read=true
- </select>
- <select id="findStreetPushNum" resultType="Integer">
- select count(d.id) from z_notify_detail d
- left join z_notify n on n.id=d.z_notify_id
- where d.user_type=4 and d.push_street_id=#{streetId} and d.del_flag=0
- <![CDATA[ and DATE_FORMAT(n.`create_time`, '%Y-%m-%d')<= DATE_FORMAT(#{dateTo}, '%Y-%m-%d') ]]>
- <![CDATA[ and DATE_FORMAT(n.`create_time`, '%Y-%m-%d')>= DATE_FORMAT(#{dateFrom}, '%Y-%m-%d')
- ]]>
- </select>
- <select id="findGovernmentReadNum" resultType="Integer">
- select count(id) from z_notify_detail where user_type=0 and del_flag=0
- <![CDATA[ and DATE_FORMAT(`create_time`, '%Y-%m-%d')<= DATE_FORMAT(#{dateTo}, '%Y-%m-%d') ]]>
- <![CDATA[ and DATE_FORMAT(`create_time`, '%Y-%m-%d')>= DATE_FORMAT(#{dateFrom}, '%Y-%m-%d')
- ]]> and is_read=true
- </select>
- <select id="findGovernmentPushNum" resultType="Integer">
- select count(id) from z_notify_detail where user_type=0 and del_flag=0
- <![CDATA[ and DATE_FORMAT(`create_time`, '%Y-%m-%d')<= DATE_FORMAT(#{dateTo}, '%Y-%m-%d') ]]>
- <![CDATA[ and DATE_FORMAT(`create_time`, '%Y-%m-%d')>= DATE_FORMAT(#{dateFrom}, '%Y-%m-%d')
- ]]>
- </select>
- <select id="findPublishNum" resultType="Integer">
- select count(n.id) from z_notify n
- left join z_user u on u.id = n.create_by
- where <![CDATA[ DATE_FORMAT(n.`create_time`, '%Y-%m-%d')<= DATE_FORMAT(#{dateTo}, '%Y-%m-%d') ]]>
- <![CDATA[ and DATE_FORMAT(n.`create_time`, '%Y-%m-%d')>= DATE_FORMAT(#{dateFrom}, '%Y-%m-%d')]]>
- and u.user_type=${userType}
- <if test="streetId!=null and streetId!=''">
- and u.street_id=#{streetId}
- </if>
- </select>
- <select id="findGovernmentExportPushStreet" resultType="Integer">
- select count(id) from z_notify_detail where push_type=4 and user_type=0 and del_flag=0 and z_notify_id=#{notifyId}
- </select>
- <select id="findGovernmentExportPushStreetNum" resultType="Integer">
- select count(id) from z_notify_detail where push_type=4 and user_type=0 and del_flag=0 and z_notify_id=#{notifyId} and is_read=0
- </select>
- <select id="findGovernmentExportPushBuild" resultType="Integer">
- select count(id) from z_notify_detail where push_type=1 and user_type=0 and del_flag=0 and z_notify_id=#{notifyId}
- </select>
- <select id="findGovernmentExportPushBuildNum" resultType="Integer">
- select count(id) from z_notify_detail where push_type=1 and user_type=0 and del_flag=0 and z_notify_id=#{notifyId} and is_read=0
- </select>
- <select id="findGovernmentExportPushCompany" resultType="Integer">
- select count(id) from z_notify_detail where push_type=3 and user_type=0 and del_flag=0 and z_notify_id=#{notifyId}
- </select>
- <select id="findGovernmentExportPushCompanyNum" resultType="Integer">
- select count(id) from z_notify_detail where push_type=3 and user_type=0 and del_flag=0 and z_notify_id=#{notifyId} and is_read=0
- </select>
- <select id="findStreetExportPushBuild" resultType="Integer">
- select count(id) from z_notify_detail where push_type=1 and del_flag=0 and z_notify_id=#{notifyId} and push_street_id=#{streetId}
- </select>
- <select id="findStreetExportPushBuildNum" resultType="Integer">
- select count(id) from z_notify_detail where push_type=1 and del_flag=0 and z_notify_id=#{notifyId} and is_read=0 and push_street_id=#{streetId}
- </select>
- <select id="findStreetExportPushCompany" resultType="Integer">
- select count(id) from z_notify_detail where push_type=3 and del_flag=0 and z_notify_id=#{notifyId} and push_street_id=#{streetId}
- </select>
- <select id="findStreetExportPushCompanyNum" resultType="Integer">
- select count(id) from z_notify_detail where push_type=3 and del_flag=0 and z_notify_id=#{notifyId} and is_read=0 and push_street_id=#{streetId}
- </select>
- <select id="findBuildExportPushCompany" resultType="Integer">
- select count(id) from z_notify_detail where push_type=3 and del_flag=0 and z_notify_id=#{notifyId} and push_build_id=#{buildId}
- </select>
- <select id="findBuildExportPushCompanyNum" resultType="Integer">
- select count(id) from z_notify_detail where push_type=3 and del_flag=0 and z_notify_id=#{notifyId} and is_read=0 and push_build_id=#{buildId}
- </select>
-
-
- <select id="getFullNotifyById" resultType="platform.modules.government.entity.Notify">
-
- select
- a.*,
- zUser.user_type as source
- from z_notify a
- left join z_user zUser on zUser.id = a.create_by
- WHERE a.id = #{notifyId}
-
- </select>
-
- </mapper>
|