Browse Source

fix:查重sql错误

master
buaixuexideshitongxue 4 weeks ago
parent
commit
435127e3f5
  1. 59
      src/main/resources/mapper/ComplaintCollectionMapper.xml

59
src/main/resources/mapper/ComplaintCollectionMapper.xml

@ -341,31 +341,33 @@
<select id="selectForRepeatCheck" resultType="com.biutag.supervision.pojo.dto.complaintCollection.ComplaintCollectionPageDTO">
SELECT
cc.id,
cc.source_table AS sourceTable,
cc.source_table_sub_one AS sourceTableSubOne,
cc.negative_id AS negativeId,
cc.responder_id_code AS responderIdCode,
cc.repeatt AS repeatt,
cc.tag AS tag,
cc.handle_method AS handleMethod,
cc.second_depart_id AS secondDepartId,
cc.second_depart_name AS secondDepartName,
cc.merge_history AS mergeHistory,
n.originId,
n.discoveryTime,
n.responderName,
n.contactPhone AS responderPhone,
n.businessTypeCode,
n.businessTypeName,
n.thingDesc,
n.involveProblem
cc.id,
cc.source_table AS sourceTable,
cc.source_table_sub_one AS sourceTableSubOne,
cc.negative_id AS negativeId,
cc.responder_id_code AS responderIdCode,
cc.repeatt AS repeatt,
cc.tag AS tag,
cc.handle_method AS handleMethod,
cc.second_depart_id AS secondDepartId,
cc.second_depart_name AS secondDepartName,
cc.merge_history AS mergeHistory,
n.originId,
n.discoveryTime,
n.responderName,
n.contactPhone AS responderPhone,
n.businessTypeCode,
n.businessTypeName,
n.thingDesc,
n.involveProblem
FROM complaint_collection cc
LEFT JOIN negative n ON n.id = cc.negative_id
<where>
<choose>
<when test="(param.responderIdCode != null and param.responderIdCode != '') or (param.responderName != null and param.responderName != '') or (param.responderPhone != null and param.responderPhone != '')">
1=1
<!-- 至少有一个参数非空时,生成括号包裹的 OR 条件 -->
<if test="(param.responderIdCode != null and param.responderIdCode != '')
or (param.responderName != null and param.responderName != '')
or (param.responderPhone != null and param.responderPhone != '')">
<trim prefix="(" suffix=")" prefixOverrides="OR">
<if test="param.responderIdCode != null and param.responderIdCode != ''">
OR cc.responder_id_code = #{param.responderIdCode}
</if>
@ -375,11 +377,14 @@
<if test="param.responderPhone != null and param.responderPhone != ''">
OR n.contactPhone = #{param.responderPhone}
</if>
</when>
<otherwise>
1=0
</otherwise>
</choose>
</trim>
</if>
<!-- 三个参数全为空时,强制无结果 -->
<if test="(param.responderIdCode == null or param.responderIdCode == '')
and (param.responderName == null or param.responderName == '')
and (param.responderPhone == null or param.responderPhone == '')">
1=0
</if>
</where>
ORDER BY cc.create_time DESC
LIMIT 100

Loading…
Cancel
Save