随便从项目里面摘出来一个代码片段记录一下

    mapper 接口

    1. /**
    2. * @param: queryStatus 查询状态 0 是查询生日 1 是成交纪念日 2是查询其它类型定时任务
    3. * @Author: 张俊杰 2020年09月09日 11:08
    4. */
    5. List<CustInfoDTO> selectCustListByCustomerGroupCode(
    6. @Param("customerGroupCodeArray") String[] customerGroupCodeArray,
    7. @Param("queryStatus") String queryStatus
    8. );

    xml文件

    1. <!--
    2. 查询条件我先注释掉了, 为了模拟参数用的,等正式数据到位了再给查询条件放开.
    3. 需求:根据二级群组id去查询 目标用户数量 , 根据身份证号码去重,我在代码里面去做.
    4. -->
    5. <select id="selectCustListByCustomerGroupCode"
    6. resultType="com.datangwealth.datazt.entity.dto.CustInfoDTO">
    7. SELECT a.CUST_CODE as custCode,
    8. b.TAG_L2_ID,
    9. c.STATEDATE,
    10. ORDERID,
    11. a.CUST_NAME,
    12. a.CERTNO,
    13. CERTNAME,
    14. MOBILE,
    15. PRO_CODE,
    16. PRO_NAME,
    17. STATE_TIME,
    18. INPUT_TIME,
    19. (SELECT WM_CONCAT(b.TAG_L2_ID)
    20. FROM DMA_TAG_CUST_LABEL a1
    21. LEFT JOIN DMA_TAG_SUBJECT_SPLIT b1
    22. ON a1.tag_id = b1.tag_id
    23. WHERE a1.CUST_CODE = a.CUST_CODE
    24. and b1.TAG_L2_ID is not null
    25. ) as tagIdArrayStr
    26. FROM DMA_CUST_INFO c
    27. inner join
    28. DMA_TAG_CUST_LABEL a
    29. on c.CUST_CODE = a.CUST_CODE
    30. inner JOIN DMA_TAG_SUBJECT_SPLIT b
    31. ON a.tag_id = b.tag_id
    32. where 1=1
    33. and c.STATE_TIME is not null
    34. <if test="queryStatus =0">
    35. and to_char(sysdate, 'mmdd') = substr( a.CERTNO, 11, 4)
    36. </if>
    37. <if test="queryStatus =1">
    38. and to_char(sysdate, 'mmdd') = substr(c.STATE_TIME, 5, 8)
    39. </if>
    40. and b.TAG_L2_ID IN
    41. <foreach collection="customerGroupCodeArray" item="customerGroupCode" separator="," open="(" close=")">
    42. #{customerGroupCode}
    43. </foreach>
    44. </select>