123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467 |
- <?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.lemon.lifecenter.mapper.PushMapper">
- <select id="selectPushResultTableCount" parameterType="PushDTO" resultType="int">
- <![CDATA[
- SELECT COUNT(*) total
- FROM db_class
- WHERE class_name LIKE '%push_result_${ym}%'
- ]]>
- </select>
-
- <select id="selectPushListTotal" parameterType="PushDTO" resultType="int">
- <![CDATA[
- SELECT SUM( A.total ) total
- FROM (
- SELECT COUNT(*) total
- FROM push_log PL
- LEFT JOIN member M
- ON M.id = PL.sender
- WHERE 1 = 1
- AND DATE_FORMAT( PL.start_date, '%Y%m' ) = #{ym}
-
- ]]>
-
- <if test='centerCode != null and centerCode != "0"'>
- <![CDATA[
- AND M.CENTER_CODE = #{centerCode}
- ]]>
- </if>
-
- <if test='sendType != null and sendType != ""'>
- <![CDATA[
- AND PL.send_type = #{sendType}
- ]]>
- </if>
-
- <if test='targetType != null and targetType != ""'>
- <![CDATA[
- AND PL.target_type = #{targetType}
- ]]>
- </if>
-
- <if test='startDate != null and startDate != ""'>
- <![CDATA[
- AND DATE_FORMAT( PL.start_date, '%Y-%m-%d') >= #{startDate}
- ]]>
- </if>
-
- <if test='endDate != null and endDate != ""'>
- <![CDATA[
- AND DATE_FORMAT( PL.start_date, '%Y-%m-%d') <= #{endDate}
- ]]>
- </if>
-
- <if test='searchType != null and searchType != ""'>
- <if test='searchType == "title" and q != null and q !=""'>
- <![CDATA[
- AND PL.push_title LIKE CONCAT('%', #{q}, '%')
- ]]>
- </if>
-
- <if test='searchType == "name" and q != null and q !=""'>
- <![CDATA[
- AND M.name LIKE CONCAT('%', #{q}, '%')
- ]]>
- </if>
-
- <if test='searchType == "id" and q != null and q !=""'>
- <![CDATA[
- AND PL.sender LIKE CONCAT('%', #{q}, '%')
- ]]>
- </if>
- </if>
-
- <![CDATA[
- UNION
- SELECT COUNT(*) total
- FROM push_schedule
- WHERE send_type = 'D'
- AND send_state = 'W'
- ) A
- ]]>
- </select>
-
- <select id="selectPushListData" parameterType="PushDTO" resultType="PushDTO">
- <![CDATA[
- SELECT PL.idx AS idx,
- PL.push_idx AS pushIdx,
- PL.send_type AS sendType,
- PL.send_state AS sendState,
- PL.target_type AS targetType,
- PL.center_code AS centerCode,
- PL.sender_ip AS senderIp,
- PL.sender AS sender,
- PL.push_title AS pushTitle,
- PL.push_content AS pushContent,
- M.name AS name,
-
- DATE_FORMAT( PL.create_date, '%Y-%m-%d %H:%i' ) AS createDate,
- DATE_FORMAT( PL.start_date, '%Y-%m-%d %H:%i' ) AS startDate,
- DATE_FORMAT( PL.end_date, '%Y-%m-%d %H:%i' ) AS endDate,
-
- PR.total_count AS totalCount,
- PR.success_count AS successCount,
- PR.fail_count AS failCount,
- PR.wait_count AS waitCount,
-
- ( SELECT center_name FROM center_info WHERE center_code = PL.center_code ) AS centerName
- FROM push_log PL
- LEFT JOIN member M
- ON M.id = PL.sender
- LEFT JOIN ( SELECT A.push_idx,
- COUNT( push_idx ) total_count,
- COUNT( IF(success_yn='Y', 1, null) ) success_count,
- COUNT( IF(success_yn='N', 1, null) ) fail_count,
- COUNT( IF(state='W', 1, null) ) wait_count
- FROM push_result_${ym} A
- WHERE push_idx = PL.push_idx
- AND log_idx = PL.idx
- GROUP BY A.push_idx ) PR
- ON PR.push_idx = PL.push_idx
- WHERE 1 = 1
- AND DATE_FORMAT( PL.start_date, '%Y%m' ) = #{ym}
- ]]>
- <if test='centerCode != null and centerCode != "0"'>
- <![CDATA[
- AND M.CENTER_CODE = #{centerCode}
- ]]>
- </if>
-
- <if test='sendType != null and sendType != ""'>
- <![CDATA[
- AND PL.send_type = #{sendType}
- ]]>
- </if>
-
- <if test='targetType != null and targetType != ""'>
- <![CDATA[
- AND PL.target_type = #{targetType}
- ]]>
- </if>
-
- <if test='startDate != null and startDate != ""'>
- <![CDATA[
- AND DATE_FORMAT( PL.start_date, '%Y-%m-%d') >= #{startDate}
- ]]>
- </if>
-
- <if test='endDate != null and endDate != ""'>
- <![CDATA[
- AND DATE_FORMAT( PL.start_date, '%Y-%m-%d') <= #{endDate}
- ]]>
- </if>
-
- <if test='searchType != null and searchType != ""'>
- <if test='searchType == "title" and q != null and q !=""'>
- <![CDATA[
- AND PL.push_title LIKE CONCAT('%', #{q}, '%')
- ]]>
- </if>
-
- <if test='searchType == "name" and q != null and q !=""'>
- <![CDATA[
- AND M.name LIKE CONCAT('%', #{q}, '%')
- ]]>
- </if>
-
- <if test='searchType == "id" and q != null and q !=""'>
- <![CDATA[
- AND PL.sender LIKE CONCAT('%', #{q}, '%')
- ]]>
- </if>
- </if>
-
- <![CDATA[
- UNION
-
- SELECT 0 idx,
- push_idx AS pushIdx,
- send_type AS sendType,
- send_state AS sendState,
- target_type AS targetType,
- center_code AS centerCode,
- sender_ip AS senderIp,
- sender AS sender,
- push_title AS pushTitle,
- push_content AS pushContent,
- ( SELECT `name` FROM member WHERE id= sender ) AS `name`,
- DATE_FORMAT( create_date, '%Y-%m-%d %H:%i' ) AS createDate,
- DATE_FORMAT( create_date, '%Y-%m-%d %H:%i' ) AS startDate,
- null AS endDate,
- 0 AS totalCount,
- 0 AS successCount,
- 0 AS failCount,
- 0 AS waitCount,
-
- ( SELECT center_name FROM center_info WHERE center_code = push_schedule.center_code ) AS centerName
- FROM push_schedule
- WHERE send_type = 'D'
- AND send_state = 'W'
-
- ORDER BY startDate desc
- LIMIT ${limit}, ${limitMax}
- ]]>
- </select>
-
- <select id="selectPushResultTotal" parameterType="PushDTO" resultType="int">
- <![CDATA[
- SELECT COUNT(*) total
- FROM push_result_${ym} PR
- WHERE 1=1
- AND PR.push_idx = #{pushIdx}
- AND PR.log_idx = #{logIdx}
- ]]>
-
- <if test='state != null and state !=""'>
- <![CDATA[
- AND PR.state = #{state}
- ]]>
- </if>
-
- <if test='successYn != null and successYn !=""'>
- <![CDATA[
- AND PR.success_yn = #{successYn}
- ]]>
- </if>
- </select>
-
- <select id="selectPushResultList" parameterType="PushDTO" resultType="PushDTO">
- <![CDATA[
- SELECT PR.idx AS idx,
- PR.push_idx AS pushIdx,
- PR.patient_idx AS patientIdx,
- PR.device_key AS deviceKey,
- PR.state AS state,
- PR.success_yn AS successYn,
- PR.fail_code AS failCode,
- PR.note AS note,
- DATE_FORMAT( PR.create_date, '%Y-%m-%d %H:%i:%s' ) AS createDate,
- DATE_FORMAT( PR.update_date, '%Y-%m-%d %H:%i:%s' ) AS updateDate,
- PC.patient_name AS patientName,
- PC.ward_number AS wardNumber,
- PC.room_number AS roomNumber,
- PC.gender AS gender,
- PC.jumin AS jumin
- FROM push_result_${ym} PR
- LEFT JOIN patient_care PC
- ON PR.patient_idx = PC.patient_idx
- WHERE 1=1
- AND PC.USE_YN = 'Y'
- AND PR.push_idx = #{pushIdx}
- AND PR.log_idx = #{logIdx}
- ]]>
-
- <if test='state != null and state !=""'>
- <![CDATA[
- AND PR.state = #{state}
- ]]>
- </if>
-
- <if test='successYn != null and successYn !=""'>
- <![CDATA[
- AND PR.success_yn = #{successYn}
- ]]>
- </if>
- </select>
-
- <insert id="insertPushData" parameterType="PushDTO" useGeneratedKeys="true">
- <selectKey keyProperty="pushIdx" resultType="int" order="AFTER">
- <![CDATA[
- SELECT CURRENT_VAL AS pushIdx FROM db_serial WHERE NAME = 'push_schedule_ai_push_idx';
- ]]>
- </selectKey>
- <![CDATA[
- INSERT
- INTO push_schedule
- ( send_type, send_state, target_type, center_code, sender_ip, sender,
- push_title, push_content, push_payload1, send_date, send_time, create_date )
- VALUES ( #{sendType}, #{sendState}, #{targetType}, #{centerCode}, #{senderIp}, #{sender},
- #{pushTitle}, #{pushContent}, #{pushPayLoad1}, #{sendDate}, #{sendTime}, NOW() );
- ]]>
- </insert>
-
- <update id="updatePushData" parameterType="PushDTO">
- <![CDATA[
- UPDATE push_schedule
- SET send_type = #{sendType},
- target_type = #{targetType},
- push_title = #{pushTitle},
- push_content = #{pushContent},
- send_date = #{sendDate},
- send_time = #{sendTime},
- update_date = NOW(),
- update_by = #{updateBy}
- WHERE push_idx = #{pushIdx}
- ]]>
- </update>
-
- <delete id="deletePushData" parameterType="PushDTO">
- <![CDATA[
- DELETE
- FROM push_schedule
- WHERE push_idx = #{pushIdx}
- ]]>
- </delete>
-
- <insert id="insertPushTargetTemp" parameterType="PushDTO">
- <![CDATA[
- INSERT
- INTO push_target_temp
- ( push_idx, patient_idx )
- VALUES ( #{pushIdx}, #{patientIdx} )
- ]]>
- </insert>
-
- <delete id="deletePushTargetTemp" parameterType="PushDTO">
- <![CDATA[
- DELETE
- FROM push_target_temp
- WHERE push_idx = #{pushIdx}
- ]]>
- </delete>
-
- <select id="selectPushTargetTempCount" parameterType="PushDTO" resultType="int">
- <![CDATA[
- SELECT COUNT(*) total
- FROM push_target_temp
- WHERE push_idx = #{pushIdx}
- ]]>
- </select>
-
- <select id="selectPushTargetTempList" parameterType="PushDTO" resultType="PushDTO">
- <![CDATA[
- SELECT PT.push_idx AS pushIdx,
- PT.patient_idx AS patientIdx,
- PC.patient_name AS patientName,
- CASE WHEN PC.GENDER = 'M' THEN '남'
- WHEN PC.GENDER = 'F' THEN '여'
- ELSE ''
- END AS gender,
- (SELECT TRUNC((SYSDATE-TO_DATE(PC.JUMIN, 'YYYYMMDD'))/365) + 1) AS age,
- PC.ward_number AS wardNumber,
- PC.room_number AS roomNumber,
- DATE_FORMAT(PC.JUMIN, '%Y-%m-%d') AS jumin,
- DATE_FORMAT(PC.HOSPITALIZATION_DATE, '%Y-%m-%d') AS hospitalizationDate
- FROM push_target_temp PT
- LEFT JOIN patient_care PC
- ON PC.patient_idx = PT.patient_idx
- WHERE push_idx = #{pushIdx}
- AND PC.USE_YN = 'Y'
- ]]>
- </select>
-
- <select id="selectPushScheduleCount" parameterType="PushDTO" resultType="int">
- <![CDATA[
- SELECT COUNT(*) total
- FROM push_schedule
- WHERE send_type != 'D'
- ]]>
-
- <if test='centerCode != null and centerCode !=""'>
- <![CDATA[
- AND center_code = #{centerCode}
- ]]>
- </if>
- </select>
-
- <select id="selectPushScheduleList" parameterType="PushDTO" resultType="PushDTO">
- <![CDATA[
- SELECT PS.push_idx AS pushIdx,
- PS.send_type AS sendType,
- PS.send_state AS sendState,
- PS.target_type AS targetType,
- PS.center_code AS centerCode,
- PS.sender_ip AS senderIp,
- PS.sender AS sender,
- PS.push_title AS pushTitle,
- PS.push_content AS pushContent,
- PS.send_date AS sendDate,
- TIME_FORMAT( PS.send_time, '%H:%i' ) AS sendTime,
- DATE_FORMAT( PS.create_date, '%Y-%m-%d %H:%i' ) AS createDate,
- M.name AS name
- FROM push_schedule PS
- LEFT JOIN member M
- ON PS.sender = M.id
- WHERE PS.send_type != 'D'
- ]]>
-
- <if test='centerCode != null and centerCode !=""'>
- <![CDATA[
- AND PS.center_code = #{centerCode}
- ]]>
- </if>
-
- <![CDATA[
- ORDER BY PS.push_idx DESC
- ]]>
- </select>
-
-
- <select id="selectPushScheduleOneCount" parameterType="PushDTO" resultType="int">
- <![CDATA[
- SELECT COUNT(*) total
- FROM push_schedule
- WHERE push_idx = #{pushIdx}
- ]]>
- </select>
-
- <select id="selectPushScheduleOneData" parameterType="PushDTO" resultType="PushDTO">
- <![CDATA[
- SELECT PS.push_idx AS pushIdx,
- PS.send_type AS sendType,
- PS.send_state AS sendState,
- PS.target_type AS targetType,
- PS.center_code AS centerCode,
- PS.sender_ip AS senderIp,
- PS.sender AS sender,
- PS.push_title AS pushTitle,
- PS.push_content AS pushContent,
- PS.send_date AS sendDate,
- TIME_FORMAT( PS.send_time, '%H:%i' ) AS sendTime,
- DATE_FORMAT( PS.create_date, '%Y-%m-%d %H:%i' ) AS createDate,
- M.name AS name,
- ( SELECT center_name FROM center_info WHERE center_code = PS.center_code ) AS centerName
- FROM push_schedule PS
- LEFT JOIN member M
- ON PS.sender = M.id
- WHERE PS.push_idx = #{pushIdx}
- ]]>
- </select>
-
- <select id="mobilePushMessageBoxCount" parameterType="PushDTO" resultType="int">
- <![CDATA[
- SELECT COUNT(*) AS cnt
- FROM PUSH_RESULT_${ym} PR
- LEFT JOIN (SELECT PUSH_IDX,
- PUSH_TITLE,
- PUSH_CONTENT
- FROM PUSH_LOG) PL
- ON PR.PUSH_IDX = PL.PUSH_IDX
- WHERE 1 = 1
- AND PR.PATIENT_IDX = #{patientIdx}
- AND PR.SUCCESS_YN = 'Y'
- AND PR.STATE = 'C'
- ]]>
- </select>
-
- <select id="mobilePushMessageBox" parameterType="PushDTO" resultType="PushDTO">
- <![CDATA[
- SELECT PL.PUSH_TITLE AS pushTitle,
- PL.PUSH_CONTENT AS pushContent,
- DATE_FORMAT(PR.UPDATE_DATE, '%Y-%m-%d %H:%i') AS updateDate
- FROM PUSH_RESULT_${ym} PR
- LEFT JOIN (SELECT PUSH_IDX,
- PUSH_TITLE,
- PUSH_CONTENT
- FROM PUSH_LOG) PL
- ON PR.PUSH_IDX = PL.PUSH_IDX
- WHERE 1 = 1
- AND PR.PATIENT_IDX = #{patientIdx}
- AND PR.SUCCESS_YN = 'Y'
- AND PR.STATE = 'C'
- ORDER BY PR.UPDATE_DATE DESC
- ]]>
- </select>
- </mapper>
|