mybatis 根据参数不同来拼接不同的sql

    xiaoxiao2023-10-04  34

    <select id="selectLocationStockHeadForDisplayFromDb" parameterType="jp.co.mazdalogi.aggi.vo.LocationStockSearchConditionVO" resultType="jp.co.mazdalogi.aggi.vo.LocationStockVO"> SELECT part_no as partNo, part_name as partName, SUM(quantity) as quantity FROM stock st WHERE 1=1 <if test="'' != partNo and partNo !=null"> and st.part_no like '%' || #{partNo} || '%' </if> <if test="'' != otherProgram and otherProgram !=null and '' != otherProgramValue and otherProgramValue !=null"> <if test="otherProgram == 1"> and other_part_no = #{otherProgramValue} </if> <if test="otherProgram == 2"> and other_part_no = #{otherProgramValue} </if> <if test="otherProgram == 3"> and lot_no = #{otherProgramValue} </if> <if test="otherProgram == 4"> and other_part_no = #{otherProgramValue} </if> </if> <if test="'' != importerCode and importerCode !=null"> AND EXISTS ( select 1 from SHIPPING_HEAD sh_head where sh_head.shipping_head_id = st.shipping_head_id and sh_head.importer_code = #{importerCode} ) </if> Group BY part_no, part_name </select>
    最新回复(0)