liusheng
4 天以前 0bbbd746e8c39d91ad7b47a4e36e29ab972dc98c
ruoyi-satisfaction/src/main/resources/mapper/satisfaction/SatisfactionScriptMapper.xml
@@ -16,7 +16,7 @@
      口径要点(必须与原文逐字一致):
      - queryIvrScriptByAssort / querySvyScriptByCategory:ids 为空时不拼 IN 条件;
      - selectIvrScriptByDimension:dimensionList 为空时拼 `dimension IS NOT NULL`;
      - selectSvyScriptByDimension:dimensionList 为空时【不拼】该条件(两侧不一致是原文行为);
      - selectSvyScriptByDimension:dimensionList 为空时【同样】拼该条件(原文写在 <where> 最后一行,极易看漏;早期迁移曾误判为不拼,已修正);
      - selectIvr/SvyTargetOptionScores:scriptIds 为 null 时不拼过滤,等于取全部分值。
    -->
@@ -45,7 +45,11 @@
    <!-- ================================================ 满意度分类(问卷侧)
         原:SvyLibScriptCategoryMapper.selectSvyLibScriptCategoryList
             (该 statement 实际定义在 SvyLibTopicCategoryMapper.xml,namespace 与文件名不一致)
         注意:问卷侧原文就是直接取【全部行】(不拼树、不筛顶层),与语音侧不同。 -->
         注意:问卷侧原文就是直接取【全部行】(不拼树、不筛顶层),与语音侧不同。
         ⚠️ orgid 的条件与原文逐字一致:原文问卷侧是 `<if test="orgid != null">`(**没有** != ''),
            语音侧才是 `orgid != null and orgid != ''`。两侧不一致是原文行为,必须保留:
            若给问卷侧也加上 `!= ''`,当入参 orgid 为空串时,原实现按 `orgid = ''` 查(无数据),
            加了 != '' 则变成不带 orgid 条件(返回全部机构数据)—— 结果会变。 -->
    <select id="selectSvyCategoryList"
            resultType="com.ruoyi.satisfaction.domain.row.SatisfactionCategoryRow">
        select id,
@@ -57,7 +61,7 @@
        <if test="q.type != null and q.type != ''">
            and type like concat('%', #{q.type}, '%')
        </if>
        <if test="q.orgid != null and q.orgid != ''">
        <if test="q.orgid != null">
            and orgid = #{q.orgid}
        </if>
        order by seqno asc
@@ -75,11 +79,11 @@
        select id,
               templateid,
               scriptid,
               script_content,
               script_assortname,
               script_assortid,
               script_topic,
               script_type,
               script_content as scriptContent,
               script_assortname as scriptAssortname,
               script_assortid as scriptAssortid,
               script_topic as scriptTopic,
               script_type as scriptType,
               dimension
        from ivr_liba_template_script
        where del_flag = 0
@@ -102,11 +106,11 @@
            resultType="com.ruoyi.satisfaction.domain.row.SatisfactionSvyScriptRow">
        select id,
               svyid,
               script_content,
               script_content as scriptContent,
               categoryName,
               categoryid,
               script_topic,
               script_type,
               script_topic as scriptTopic,
               script_type as scriptType,
               dimension
        from svy_lib_template_script
        where del_flag = 0
@@ -120,13 +124,13 @@
    <!-- ================================================ 按维度取问题(语音侧)
         原:IvrLibaTemplateScriptMapper.selectILTSBydimension
         口径要点:dimensionList 为空时拼 `dimension IS NOT NULL`(问卷侧不拼,两侧不同是原文行为) -->
         口径要点:dimensionList 为空时拼 `dimension IS NOT NULL`(问卷侧原文也有,见 selectSvyScriptByDimension) -->
    <select id="selectIvrScriptByDimension"
            resultType="com.ruoyi.satisfaction.domain.row.SatisfactionIvrScriptRow">
        select templateid,
               scriptid,
               script_content,
               script_assortname,
               script_content as scriptContent,
               script_assortname as scriptAssortname,
               dimension
        from ivr_liba_template_script
        <where>
@@ -145,13 +149,19 @@
    <!-- ================================================ 按维度取问题(问卷侧)
         原:SvyLibTemplateScriptMapper.selectSLTScriptListBydimension
         口径要点:dimensionList 为空时【不拼】dimension IS NOT NULL(等于全表 del_flag=0);
                   聚合用的模板 id 与选项关联 id 都是 svyid -->
         ⚠️ 两侧其实【都要】拼 dimension IS NOT NULL:
            - 语音侧(selectIvrScriptByDimension)该条件紧跟在 dimensionList 分支之后;
            - 问卷侧原文把它写在 <where> 的**最后一行**(在 duty/report/circulation 那些
              满意度用不到的条件之后),容易看漏 —— 早期迁移时曾误判为"问卷侧不拼",已修正。
         ⚠️ 必须同时取 id 与 svyid 两个【不同】的列(原文的 <include> 片段就是这样):
            聚合统计(发送量/填报量)按 svyid 分组,而取「选项分值」时用的是 id(主键),
            对应 svy_lib_template_targetoption.scriptid。早期迁移时曾误写成 `svyid as id`,
            导致选项分值匹配不上 -> 最高分/最低分恒为 0.0。 -->
    <select id="selectSvyScriptByDimension"
            resultType="com.ruoyi.satisfaction.domain.row.SatisfactionSvyScriptRow">
        select svyid,
               svyid as id,
               script_content,
        select id,
               svyid,
               script_content as scriptContent,
               categoryName,
               dimension
        from svy_lib_template_script
@@ -163,6 +173,9 @@
                    #{dimension}
                </foreach>
            </if>
            <if test="q.dimensionList == null or q.dimensionList.size() == 0">
                and dimension IS NOT NULL
            </if>
        </where>
    </select>