随便从项目里面摘出来一个代码片段记录一下
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 a1LEFT JOIN DMA_TAG_SUBJECT_SPLIT b1ON a1.tag_id = b1.tag_idWHERE a1.CUST_CODE = a.CUST_CODEand b1.TAG_L2_ID is not null) as tagIdArrayStrFROM DMA_CUST_INFO cinner joinDMA_TAG_CUST_LABEL aon c.CUST_CODE = a.CUST_CODEinner JOIN DMA_TAG_SUBJECT_SPLIT bON a.tag_id = b.tag_idwhere 1=1and 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>
