150 lines
5.8 KiB
XML
150 lines
5.8 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.bonus.hnrn.rnama.own.dao.NotifyDao">
|
|
<insert id="addDelNotify">
|
|
insert into bns_smz_own_read(worker_id, ann_id, is_read, create_time, update_time, is_active)
|
|
VALUES (#{workerId}, #{notifyId}, '0', NOW(), NOW(), '0')
|
|
</insert>
|
|
<insert id="addNotifyRecord">
|
|
insert into bns_smz_own_read(worker_id, ann_id, is_read, create_time, update_time, is_active)
|
|
VALUES (#{workerId}, #{notifyId}, '1', NOW(), NOW(), '1')
|
|
</insert>
|
|
<update id="delNotify">
|
|
UPDATE bns_smz_own_read
|
|
set is_active='0',
|
|
update_time=NOW()
|
|
WHERE worker_id = #{workerId}
|
|
and ann_id = #{notifyId}
|
|
</update>
|
|
|
|
<select id="getNotifyData" resultType="com.bonus.hnrn.rnama.own.entity.NotifyBean">
|
|
SELECT *
|
|
FROM (
|
|
SELECT a.id as notifyId,
|
|
a.notify_type as notifyType,
|
|
a.type,
|
|
a.ggbt as title,
|
|
a.ggnr as content,
|
|
a.create_data as createTime,
|
|
IFNULL(GROUP_CONCAT(f.file_path SEPARATOR ';'), '') AS photoFilePath,
|
|
owo1.rzzm_path as rzzmPath,
|
|
owo2.srzm_path as srzmPath,
|
|
off.notice_path as noticePath,
|
|
a.worker_id as workerId,
|
|
CASE
|
|
WHEN EXISTS(SELECT 1 FROM bns_smz_own_read re WHERE re.ann_id = a.id AND re.worker_id = #{workerId})
|
|
THEN
|
|
'Yes'
|
|
ELSE 'No'
|
|
END AS isRead,
|
|
(SELECT is_active
|
|
FROM bns_smz_own_read re
|
|
WHERE re.ann_id = a.id AND re.worker_id = #{workerId}) is_active
|
|
FROM bns_smz_own_announcement AS a
|
|
LEFT JOIN bns_smz_own_announcement_file AS f ON a.id = f.pid
|
|
AND f.is_active = '1'
|
|
LEFT JOIN bns_smz_own_worker_on owo1
|
|
on owo1.worker_id = a.worker_id and a.notify_type = '2' and a.type = '1' and
|
|
owo1.is_active = '1'
|
|
LEFT JOIN bns_smz_own_worker_on owo2
|
|
on owo2.worker_id = a.worker_id and a.notify_type = '2' and a.type = '2' and
|
|
owo2.is_active = '1'
|
|
LEFT JOIN bns_smz_own_worker_off off on a.worker_id=off.worker_id and a.notify_type='2' and a.type='3' and off.is_active='1'
|
|
WHERE a.is_active = '1'
|
|
GROUP BY a.id
|
|
) b
|
|
WHERE 1 = 1
|
|
AND (
|
|
b.is_active <> '0'
|
|
OR b.is_active IS NULL
|
|
)
|
|
AND (
|
|
b.workerId = #{workerId}
|
|
OR b.workerId IS NULL
|
|
)
|
|
ORDER BY createTime DESC
|
|
</select>
|
|
<select id="selectNotify" resultType="java.lang.Integer">
|
|
SELECT
|
|
COUNT(*)
|
|
FROM bns_smz_own_read
|
|
WHERE
|
|
worker_id = #{workerId}
|
|
AND ann_id = #{notifyId}
|
|
</select>
|
|
|
|
<select id="getNewMessage" resultType="com.bonus.hnrn.rnama.own.entity.NotifyBean">
|
|
SELECT *
|
|
FROM (
|
|
SELECT a.id as notifyId,
|
|
a.notify_type as notifyType,
|
|
a.type,
|
|
a.ggbt as title,
|
|
a.ggnr as content,
|
|
a.create_data as createTime,
|
|
IFNULL(GROUP_CONCAT(f.file_path SEPARATOR ';'), '') AS photoFilePath,
|
|
owo1.rzzm_path as rzzmPath,
|
|
owo2.srzm_path as srzmPath,
|
|
off.notice_path as noticePath,
|
|
a.worker_id as workerId,
|
|
CASE
|
|
WHEN EXISTS(SELECT 1 FROM bns_smz_own_read re WHERE re.ann_id = a.id AND re.worker_id = #{workerId})
|
|
THEN
|
|
'Yes'
|
|
ELSE 'No'
|
|
END AS isRead,
|
|
(SELECT is_active
|
|
FROM bns_smz_own_read re
|
|
WHERE re.ann_id = a.id
|
|
AND re.worker_id = #{workerId}) is_active
|
|
FROM bns_smz_own_announcement AS a
|
|
LEFT JOIN bns_smz_own_announcement_file AS f ON a.id = f.pid
|
|
AND f.is_active = '1'
|
|
LEFT JOIN bns_smz_own_worker_on owo1
|
|
on owo1.worker_id = a.worker_id and a.notify_type = '2' and a.type = '1' and
|
|
owo1.is_active = '1'
|
|
LEFT JOIN bns_smz_own_worker_on owo2
|
|
on owo2.worker_id = a.worker_id and a.notify_type = '2' and a.type = '2' and
|
|
owo2.is_active = '1'
|
|
LEFT JOIN bns_smz_own_worker_off off on a.worker_id=off.worker_id and a.notify_type='2' and a.type='3' and off.is_active='1'
|
|
WHERE a.is_active = '1'
|
|
GROUP BY a.id
|
|
) b
|
|
WHERE 1 = 1
|
|
AND (
|
|
b.is_active
|
|
<>
|
|
'0'
|
|
OR b.is_active IS NULL
|
|
)
|
|
AND (
|
|
b.workerId = #{workerId}
|
|
OR b.workerId IS NULL
|
|
)
|
|
and isRead = 'No'
|
|
ORDER BY createTime DESC
|
|
LIMIT 1
|
|
</select>
|
|
|
|
<select id="getVersionList" resultType="com.bonus.hnrn.rnama.core.entity.VersionNoticeBean">
|
|
SELECT ann.id,
|
|
ann.version AS versionCode,
|
|
ann.content AS versionContent,
|
|
SUBSTRING(ann.create_time, 1, 10) AS createDate,
|
|
ann.create_time AS createTime
|
|
FROM bns_smz_own_sys_announcement ann
|
|
WHERE ann.is_active = 1
|
|
ORDER BY ann.create_time DESC
|
|
</select>
|
|
|
|
<select id="getVersionContent" resultType="com.bonus.hnrn.rnama.core.entity.VersionNoticeBean">
|
|
SELECT id,
|
|
version as versionCode,
|
|
content as versionContent,
|
|
SUBSTRING(create_time, 1, 10) as createDate,
|
|
create_time as createTime
|
|
FROM bns_smz_own_sys_announcement
|
|
WHERE is_active = 1
|
|
and id = #{id}
|
|
</select>
|
|
</mapper> |