mybatis动态循环拼接SQL,动态拼接字段 和动态拼接 LEFT JOIN

mybatis动态循环拼接SQL,动态拼接字段 和动态拼接 LEFT JOIN

 select T.BUSINESS_KEY_ "businessKey",
        D.JHBM "jhbm",
        D.JHBM || DO.DOC_NAME AS "designDoc",
        T.PROC_INST_ID_ "lcId",
        TO_CHAR( T.END_TIME_, 'yyyy-MM-dd hh24:mi:ss') "cjsj"
        <foreach collection="mapList" item="join">
            ,decode(${join.tablename}.f_count, '', '未结构化', '已结构化') as "${join.tablename}",
            (SELECT TABLECHINESE FROM DOC_STRUCTURED_QUERY_CONFIG WHERE TABLENAME = '${join.tablename}')
            "${join.tablename}MC"
        foreach>
        FROM ACT_HI_PROCINST T
        <foreach collection="mapList" item="join" separator="">
            LEFT JOIN (select lcid, count(1) as f_count
            from ${join.tablename}
            group by lcid) ${join.tablename} ON T.PROC_INST_ID_ = ${join.tablename}.LCID
        foreach>
        LEFT JOIN V_DJJCXX D
        ON D.JHDM = T.BUSINESS_KEY_
        LEFT JOIN DOC_FLOW_INSTANCE_INFO DI
        ON DI.PROCESS_INSTANCE_ID = T.PROC_INST_ID_
        LEFT JOIN DOC_INFO DO
        ON DO.DOC_KEY = DI.DOC_KEY
        <where>
            D.JHBM IS NOT NULL
            <if test="jhbm != null and jhbm != ''">
                AND D.JHBM LIKE '%' || #{jhbm} || '%'
            if>
        where>
        ORDER BY T.END_TIME_ 

你可能感兴趣的:(SQL记录,mybatis,sql,java)