随便从项目里面摘出来一个代码片段记录一下
mapper 接口
/**
* @param: queryStatus 查询状态 0 是查询生日 1 是成交纪念日 2是查询其它类型定时任务
* @Author: 张俊杰 2020年09月09日 11:08
*/
List<CustInfoDTO> selectCustListByCustomerGroupCode(
@Param("customerGroupCodeArray") String[] customerGroupCodeArray,
@Param("queryStatus") String queryStatus
);
xml文件
<!--
查询条件我先注释掉了, 为了模拟参数用的,等正式数据到位了再给查询条件放开.
需求:根据二级群组id去查询 目标用户数量 , 根据身份证号码去重,我在代码里面去做.
-->
<select id="selectCustListByCustomerGroupCode"
resultType="com.datangwealth.datazt.entity.dto.CustInfoDTO">
SELECT a.CUST_CODE as custCode,
b.TAG_L2_ID,
c.STATEDATE,
ORDERID,
a.CUST_NAME,
a.CERTNO,
CERTNAME,
MOBILE,
PRO_CODE,
PRO_NAME,
STATE_TIME,
INPUT_TIME,
(SELECT WM_CONCAT(b.TAG_L2_ID)
FROM DMA_TAG_CUST_LABEL a1
LEFT JOIN DMA_TAG_SUBJECT_SPLIT b1
ON a1.tag_id = b1.tag_id
WHERE a1.CUST_CODE = a.CUST_CODE
and b1.TAG_L2_ID is not null
) as tagIdArrayStr
FROM DMA_CUST_INFO c
inner join
DMA_TAG_CUST_LABEL a
on c.CUST_CODE = a.CUST_CODE
inner JOIN DMA_TAG_SUBJECT_SPLIT b
ON a.tag_id = b.tag_id
where 1=1
and c.STATE_TIME is not null
<if test="queryStatus =0">
and to_char(sysdate, 'mmdd') = substr( a.CERTNO, 11, 4)
</if>
<if test="queryStatus =1">
and to_char(sysdate, 'mmdd') = substr(c.STATE_TIME, 5, 8)
</if>
and b.TAG_L2_ID IN
<foreach collection="customerGroupCodeArray" item="customerGroupCode" separator="," open="(" close=")">
#{customerGroupCode}
</foreach>
</select>