liusheng
9 天以前 a1e256f64930865ae2d170e333ee3f1a773c6c49
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package com.ruoyi.satisfaction.mapper;
 
import com.ruoyi.satisfaction.domain.row.SatisfactionCategoryRow;
import com.ruoyi.satisfaction.domain.row.SatisfactionIvrScriptRow;
import com.ruoyi.satisfaction.domain.row.SatisfactionOptionScoreRow;
import com.ruoyi.satisfaction.domain.row.SatisfactionScriptQuery;
import com.ruoyi.satisfaction.domain.row.SatisfactionSvyScriptRow;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
 
import java.util.List;
import java.util.Map;
 
/**
 * 满意度统计取「满意度分类 / 模板问题 / 选项分值」的只读 Mapper。
 * <p>
 * <b>为什么不复用 smartor 的模板/分类 Mapper:</b>
 * <ul>
 *   <li>{@code com.ruoyi.template.domain.IvrLibaScriptAssort} / {@code IvrLibaTemplateScript} /
 *       {@code SvyLibScriptCategory} / {@code SvyLibTemplateScript} 这 4 个实体属于
 *       smartor 的**模板与分类管理**业务(分别被 11/9/12/13 个文件使用,含增删改查),
 *       不能搬进本模块;</li>
 *   <li>本模块要求「不依赖 smartor,其它模块要用只能调本模块 api」,所以不能 import 它们;</li>
 *   <li>原文这些查询依赖 `resultMap` + 共享 `<sql>` 片段,而片段被同文件里其它
 *       <b>非满意度</b>查询共用。直接复制片段会造成「同一份 SQL 两处维护」的隐患,
 *       因此这里<b>改写为显式列清单</b>,只取满意度真正用到的字段。</li>
 * </ul>
 * <p>
 * ⚠️ 本 Mapper 全部是<b>只读查询</b>,不会对 {@code ivr_liba_*} / {@code svy_lib_*} 做任何写操作。
 * <p>
 * 对应 XML:{@code mapper/satisfaction/SatisfactionScriptMapper.xml}
 */
@Mapper
public interface SatisfactionScriptMapper {
 
    // ================================================================ 满意度分类
 
    /**
     * 查询指定机构下的满意度分类(语音侧)。
     * <p>
     * 原实现:{@code IvrLibaScriptAssortMapper.selectIvrLibaScriptAssortList}
     * <pre>
     * select id, index_assort_name, type from ivr_liba_script_assort
     * where del_flag = 0 and orgid = ? and type like '%myd%' order by seqno asc
     * </pre>
     * 调用方再按 {@code type.contains("myd")} 过滤出满意度分类 id。
     *
     * @param query orgid 与 type(type 传 "myd")
     * @return 每行含 id、index_assort_name、type
     */
    List<SatisfactionCategoryRow> selectIvrCategoryList(@Param("q") SatisfactionScriptQuery query);
 
    /**
     * 查询指定机构下的满意度分类(问卷侧)。
     * <p>
     * 原实现:{@code SvyLibScriptCategoryMapper.selectSvyLibScriptCategoryList}
     * (注意:该 statement 定义在 {@code SvyLibTopicCategoryMapper.xml} 里,namespace 与文件名不一致)
     * <pre>
     * select id, name, type from svy_lib_script_category
     * where del_flag = 0 and orgid = ? and type like '%myd%' order by seqno asc
     * </pre>
     *
     * @param query orgid 与 type(type 传 "myd")
     * @return 每行含 id、name、type
     */
    List<SatisfactionCategoryRow> selectSvyCategoryList(@Param("q") SatisfactionScriptQuery query);
 
    // ================================================================ 模板问题(按分类)
 
    /**
     * 按语音分类 id 取问题。
     * <p>
     * 原实现:{@code IvrLibaTemplateScriptMapper.queryLibTemplateIds}
     * <pre>
     * select templateid, scriptid, script_content, script_assortname, dimension
     * from ivr_liba_template_script
     * where del_flag = 0 [and script_assortid in (...)]
     * </pre>
     * <b>口径注意</b>:{@code scriptAssortids} 为空时不再拼该条件(原实现是
     * {@code if test="scriptAssortids != null and scriptAssortids.size > 0"})。
     */
    List<SatisfactionIvrScriptRow> queryIvrScriptByAssort(@Param("q") SatisfactionScriptQuery query);
 
    /**
     * 按问卷分类 id 取问题。
     * <p>
     * 原实现:{@code SvyLibTemplateScriptMapper.querySvyLibTemplateIds}
     * <pre>
     * select id, svyid, script_content, categoryName, dimension
     * from svy_lib_template_script
     * where del_flag = 0 [and categoryid in (...)]
     * </pre>
     * <b>口径注意</b>:原实现取选项分值时用的是 {@code id}(主键),
     * 而聚合统计的模板 id 用的是 {@code svyid}——两者都保留在结果行里。
     */
    List<SatisfactionSvyScriptRow> querySvyScriptByCategory(@Param("q") SatisfactionScriptQuery query);
 
    // ================================================================ 模板问题(按维度)
 
    /**
     * 按维度取问题(语音侧)。
     * <p>
     * 原实现:{@code IvrLibaTemplateScriptMapper.selectILTSBydimension}
     * <pre>
     * ... where del_flag = 0
     *     [and dimension in (...)]
     *     [dimension IS NOT NULL]   ← dimensionList 为空时拼这个
     * </pre>
     * <b>口径注意</b>:{@code dimensionList} 为空时,语音侧会拼
     * {@code dimension IS NOT NULL}(问卷侧不会)——这是原实现的行为,必须保留。
     * 同时原实现还支持 duty/report 相关过滤,满意度调用时不传,故不再暴露。
     */
    List<SatisfactionIvrScriptRow> selectIvrScriptByDimension(@Param("q") SatisfactionScriptQuery query);
 
    /**
     * 按维度取问题(问卷侧)。
     * <p>
     * 原实现:{@code SvyLibTemplateScriptMapper.selectSLTScriptListBydimension}
     * <pre>
     * ... where del_flag = 0 [and dimension in (...)]
     * </pre>
     * <b>口径注意</b>:与语音侧不同,{@code dimensionList} 为空时<b>不拼</b>
     * {@code dimension IS NOT NULL}(等于取该表全部 del_flag=0 的问题)。
     * 另外此处聚合统计用的模板 id 与取选项分值用的关联 id <b>都是 {@code svyid}</b>。
     */
    List<SatisfactionSvyScriptRow> selectSvyScriptByDimension(@Param("q") SatisfactionScriptQuery query);
 
    // ================================================================ 选项分值
 
    /**
     * 按问题 id 批量取语音选项分值(只取 scriptid、score 两列)。
     * <p>
     * 原实现:{@code IvrLibaTemplateTargetoptionMapper.selectIvrLibaTargetoptionScores}
     * <p>
     * <b>口径注意</b>:{@code scriptIds} 为 null 时原实现不拼 scriptid 条件
     * (等于取该表全部分值),调用方用 null 作 key 存这一份。
     */
    List<SatisfactionOptionScoreRow> selectIvrTargetOptionScores(@Param("scriptIds") List<Long> scriptIds);
 
    /**
     * 按问题 id 批量取问卷选项分值(只取 scriptid、score 两列)。
     * <p>
     * 原实现:{@code SvyLibTemplateTargetoptionMapper.selectSvyLibTargetoptionScores}
     */
    List<SatisfactionOptionScoreRow> selectSvyTargetOptionScores(@Param("scriptIds") List<Long> scriptIds);
}