| | |
| | | COALESCE(NULLIF(TRIM(current_preachform), ''), TRIM(SUBSTRING_INDEX(preachform, ',', 1))) |
| | | </sql> |
| | | |
| | | <!-- 累计发送方式统计用:归一化 preachform 顺序(去空格、统一中文逗号) --> |
| | | <sql id="normalizedPreachformExpr"> |
| | | REPLACE(REPLACE(IFNULL(preachform, ''), ' ', ''), ',', ',') |
| | | </sql> |
| | | |
| | | <!-- 累计发送方式统计用:归一化后的有效 current_preachform(为空时取 preachform 第一个) --> |
| | | <sql id="normalizedEffectiveCurrentPreachformExpr"> |
| | | COALESCE(NULLIF(TRIM(current_preachform), ''), |
| | | TRIM(SUBSTRING_INDEX(<include refid="normalizedPreachformExpr"/>, ',', 1))) |
| | | </sql> |
| | | |
| | | <select id="selectServiceSubtaskBySendstate" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity" |
| | | resultMap="ServiceSubtaskResult"> |
| | | <include refid="selectServiceSubtaskVo"/> |
| | |
| | | </if> |
| | | <if test="currentPreachform != null and currentPreachform != '' "> |
| | | AND <include refid="effectiveCurrentPreachformExpr"/> = #{currentPreachform} |
| | | <if test="followUpCountStyle != null and followUpCountStyle = '1'"> |
| | | <!-- 注意:OGNL 里单引号 '1' 是 Character,String 与之用 = 比较会得到非 0 数字(恒真),必须用 =="1" --> |
| | | <if test='followUpCountStyle != null and followUpCountStyle == "1"'> |
| | | AND sendstate != 4 |
| | | </if> |
| | | <if test='followUpCountStyle != null and followUpCountStyle == "3"'> |
| | | AND sendstate = 6 |
| | | </if> |
| | | </if> |
| | | <!-- |
| | | 累计发送方式下钻: |
| | | preachform 是执行顺序(如 3,5,4,1),current_preachform 是当前执行到的位置。 |
| | | 若要在“语音”下钻,则 current 位于语音及之后的所有行都要返回。 |
| | | 以下条件与 ServiceSubtaskServiceImpl#applyFirstCumulativePreachformStatistics 口径一致: |
| | | current 为空 -> 按 preachform 第一个方式 |
| | | current = -1 -> 按最后一个位置(全部方式都进入过) |
| | | current 不在顺序中 -> 只做精确匹配兜底 |
| | | --> |
| | | <if test="cumulativePreachform != null and cumulativePreachform != ''"> |
| | | AND ( |
| | | CASE |
| | | WHEN <include refid="normalizedPreachformExpr"/> = '' THEN |
| | | <include refid="normalizedEffectiveCurrentPreachformExpr"/> = #{cumulativePreachform} |
| | | |
| | | WHEN <include refid="normalizedEffectiveCurrentPreachformExpr"/> = '-1' THEN |
| | | FIND_IN_SET(#{cumulativePreachform}, |
| | | <include refid="normalizedPreachformExpr"/>) > 0 |
| | | |
| | | WHEN FIND_IN_SET(<include refid="normalizedEffectiveCurrentPreachformExpr"/>, |
| | | <include refid="normalizedPreachformExpr"/>) = 0 THEN |
| | | <include refid="normalizedEffectiveCurrentPreachformExpr"/> = #{cumulativePreachform} |
| | | |
| | | ELSE |
| | | FIND_IN_SET(#{cumulativePreachform}, |
| | | <include refid="normalizedPreachformExpr"/>) > 0 |
| | | AND FIND_IN_SET(#{cumulativePreachform}, |
| | | <include refid="normalizedPreachformExpr"/>) |
| | | <= FIND_IN_SET(<include refid="normalizedEffectiveCurrentPreachformExpr"/>, |
| | | <include refid="normalizedPreachformExpr"/>) |
| | | END |
| | | ) |
| | | <if test='followUpCountStyle != null and followUpCountStyle == "1"'> |
| | | AND sendstate != 4 |
| | | </if> |
| | | <if test='followUpCountStyle != null and followUpCountStyle == "3"'> |
| | | AND sendstate = 6 |
| | | </if> |
| | | </if> |
| | | <if test="excep != null and excep != ''"> |
| | | AND excep = #{excep} |