MsgInfoMapper.xml 6.45 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~
  ~      Copyright (c) 2018-2025, lengleng All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the yifu4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: lengleng (wangiegie@gmail.com)
  ~
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.yifu.cloud.plus.v1.msg.mapper.MsgInfoMapper">

  <resultMap id="msgInfoMap" type="com.yifu.cloud.plus.v1.msg.entity.MsgInfo">
    <id property="id" column="ID"/>
    <result property="orderId" column="ORDER_ID"/>
    <result property="url" column="URL"/>
    <result property="orderNo" column="ORDER_NO"/>
    <result property="alertType" column="ALERT_TYPE"/>
    <result property="createTime" column="CREATE_TIME"/>
fangxinjiang's avatar
fangxinjiang committed
33
    <result property="readStatus" column="READ_STATUS"/>
34
    <result property="alertUser" column="ALERT_USER"/>
fangxinjiang's avatar
fangxinjiang committed
35
	<result property="domainName" column="DOMAIN_NAME"/>
36 37 38 39 40 41 42 43
  </resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.ORDER_ID,
                a.URL,
                a.ORDER_NO,
                a.ALERT_TYPE,
                a.CREATE_TIME,
fangxinjiang's avatar
fangxinjiang committed
44
                a.READ_STATUS,
fangxinjiang's avatar
fangxinjiang committed
45 46
                a.ALERT_USER,
				a.DOMAIN_NAME
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
    </sql>
    <sql id="msgInfo_where">
        <if test="msgInfo != null">
                    <if test="msgInfo.id != null and msgInfo.id.trim() != ''">
                        AND a.ID = #{msgInfo.id}
                    </if>
                    <if test="msgInfo.orderId != null and msgInfo.orderId.trim() != ''">
                        AND a.ORDER_ID = #{msgInfo.orderId}
                    </if>
                    <if test="msgInfo.url != null and msgInfo.url.trim() != ''">
                        AND a.URL = #{msgInfo.url}
                    </if>
                    <if test="msgInfo.orderNo != null and msgInfo.orderNo.trim() != ''">
                        AND a.ORDER_NO = #{msgInfo.orderNo}
                    </if>
                    <if test="msgInfo.alertType != null and msgInfo.alertType.trim() != ''">
                        AND a.ALERT_TYPE = #{msgInfo.alertType}
                    </if>
                    <if test="msgInfo.createTime != null">
                        AND a.CREATE_TIME = #{msgInfo.createTime}
                    </if>
fangxinjiang's avatar
fangxinjiang committed
68 69
                    <if test="msgInfo.readStatus != null and msgInfo.readStatus.trim() != ''">
                        AND a.READ_STATUS = #{msgInfo.readStatus}
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
                    </if>
                    <if test="msgInfo.alertUser != null and msgInfo.alertUser.trim() != ''">
                        AND a.ALERT_USER = #{msgInfo.alertUser}
                    </if>
        </if>
    </sql>
    <!--msgInfo简单分页查询-->
    <select id="getMsgInfoPage" resultMap="msgInfoMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM msg_info a
        <where>
            1=1
            <include refid="msgInfo_where"/>
        </where>
    </select>
fangxinjiang's avatar
fangxinjiang committed
86 87 88 89 90 91 92 93 94
	<select id="getMsgInfo" resultMap="msgInfoMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM msg_info a
		<where>
			1=1
			<include refid="msgInfo_where"/>
		</where>
	</select>
95

fangxinjiang's avatar
fangxinjiang committed
96
	<select id="getMsgByOrderId" resultMap="msgInfoMap">
97
		SELECT
fangxinjiang's avatar
fangxinjiang committed
98
			a.fd_3ac901ba3b9d3e domain_name,
fangxinjiang's avatar
fangxinjiang committed
99 100 101 102
			p.fd_name ALERT_USER,
			a.fd_3ac901c5184274  ORDER_NO,
			a.fd_id  ORDER_ID,
			'0' as ALERT_TYPE
103 104
		FROM
			ekp_ea33075576149bb8a4f5 a
105
				LEFT JOIN sys_org_element p on a.fd_3bb0dd2400b154 = p.fd_id
106
		WHERE
fangxinjiang's avatar
fangxinjiang committed
107
			a.fd_id = #{orderId} limit 1
108
	</select>
fangxinjiang's avatar
fangxinjiang committed
109
	<!--  加急(2-3小时)|1  紧急(3-5小时)|4  常规(5-8小时)|7  -->
fangxinjiang's avatar
fangxinjiang committed
110
	<select id="getMsgByTask"  resultMap="msgInfoMap">
fangxinjiang's avatar
fangxinjiang committed
111 112
		SELECT * from (
		SELECT
fangxinjiang's avatar
fangxinjiang committed
113
			b1.fd_3ac901ba3b9d3e domain_name,
fangxinjiang's avatar
fangxinjiang committed
114 115 116 117 118
			o.fd_no ALERT_USER,
			b1.fd_3ac901c5184274 ORDER_NO,
			b1.fd_id ORDER_ID,
			'1' AS ALERT_TYPE,
			DATE_ADD(NOW(), INTERVAL 30 MINUTE)  as  'date1',
119 120 121 122 123 124 125
			IF(b1.fd_3b779ba2168eea = 1,
				DATE_ADD(a.fd_start_date,INTERVAL 3 HOUR),
				IF(b1.fd_3b779ba2168eea = 4,
				   DATE_ADD(a.fd_start_date,INTERVAL 5 HOUR),
				   IF(b1.fd_3b779ba2168eea = 7,
					  DATE_ADD(a.fd_start_date,INTERVAL 8 HOUR),
					  DATE_ADD(a.fd_start_date,INTERVAL 2 MONTH)))) as 'date2'
fangxinjiang's avatar
fangxinjiang committed
126 127 128 129 130 131 132 133 134 135
		FROM
			lbpm_workitem a
		LEFT JOIN lbpm_node e ON e.fd_id = a.fd_node_id
		LEFT JOIN lbpm_process p ON p.fd_id = e.fd_process_id
		LEFT JOIN ekp_ea33075576149bb8a4f5 b1 ON p.fd_model_id = b1.fd_id
		LEFT JOIN sys_org_element o ON o.fd_id = fd_expected_id
		WHERE
			e.fd_fact_node_id = 'N5'
		AND b1.fd_id IS NOT NULL
		) x
136
		where x.date1 >= date2 GROUP BY x.ORDER_NO
fangxinjiang's avatar
fangxinjiang committed
137
	</select>
138 139 140 141 142 143 144

	<select id="getMsgByTaskOne"  resultMap="msgInfoMap">
		SELECT
			b1.fd_3ac901ba3b9d3e domain_name,
			o.fd_no ALERT_USER,
			b1.fd_3ac901c5184274 ORDER_NO,
			b1.fd_id ORDER_ID,
145 146
			'3' AS ALERT_TYPE,
			b1.fd_3bddc3d6c8a734
147
		FROM
148 149
			ekp_ea33075576149bb8a4f5 b1
				LEFT JOIN sys_org_element o ON o.fd_id = b1.fd_3bf1511f1d618e
150 151
		WHERE
			b1.fd_3bddc3d6c8a734 = '待支出'
152
		  AND b1.fd_id IS NOT NULL and o.fd_id is not null
153
	</select>
154 155

	<delete id="deleteHandledMsg">
fangxinjiang's avatar
fangxinjiang committed
156 157 158 159 160 161 162
		DELETE FROM msg_info where ALERT_TYPE ='0'
		<if test="nos != null and nos.size > 0">
			and ORDER_NO not in
			<foreach item="items" index="index" collection="nos" open="(" separator="," close=")">
				#{items}
			</foreach>
		</if>
163
	</delete>
fangxinjiang's avatar
fangxinjiang committed
164 165 166 167 168 169 170 171 172 173 174 175
	<select id="getOrderNos" resultType="java.lang.String">
		SELECT
			b1.fd_3ac901c5184274 ORDER_NO
		FROM
			lbpm_workitem a
				LEFT JOIN lbpm_node e ON e.fd_id = a.fd_node_id
				LEFT JOIN lbpm_process p ON p.fd_id = e.fd_process_id
				LEFT JOIN ekp_ea33075576149bb8a4f5 b1 ON p.fd_model_id = b1.fd_id
		WHERE
			e.fd_fact_node_id = 'N5'
		  AND b1.fd_id IS NOT NULL
	</select>
176 177

	<insert id="insertMsg">
178 179
		insert into msg_info (ID,URL,ORDER_ID,ALERT_USER,DOMAIN_NAME,CREATE_TIME,ALERT_TYPE,ORDER_NO)
			value (REPLACE(UUID(),"-",""),#{vo.urlInfo},#{vo.orderId},#{vo.userName},#{vo.domainName},now(),'0',#{vo.dingdanNo})
180
	</insert>
181
</mapper>