ソースを参照

贸易对账 数据权限过滤 判空处理

xucaiqin 2 年 前
コミット
7f952ded52

+ 139 - 129
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerLogisticsMapper.xml

@@ -147,31 +147,33 @@
                         or kllu.contacts like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
                     )
             </if>
-            and (
-            case
-                when kll.status = 2 then
-                    true
-            when kll.status in (3, 4, 5) then
-            (
+            <if test="authList != null and authList.size() != 0">
+                and (
+                case
+                    when kll.status = 2 then
+                        true
+                when kll.status in (3, 4, 5) then
+                (
+                (
+                    kllu2.contacts_id in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>)
+                or
             (
-                kllu2.contacts_id in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>)
-            or
-        (
-        select kllt.id
-        from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
-                                               and kllt.l_ledger_id = kll.id
-                                               and kllt.status in (3, 5)
-                                               and kllt.create_by in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            )
-                )
-                end
+            select kllt.id
+            from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
+                                                   and kllt.l_ledger_id = kll.id
+                                                   and kllt.status in (3, 5)
+                                                   and kllt.create_by in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
                 )
+                    )
+                    end
+                    )
+            </if>
         </where>
         order by kll.generate_time desc
     </select>
@@ -384,26 +386,28 @@
                         or kllu.contacts like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
                     )
             </if>
-            and (
-            case when kll.status in (1, 6)
-                then
-                kll.create_by in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            when kll.status in (2, 3, 4, 5) then
-            (
-                kll.create_by in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            or kllu2.contacts_id in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            )
-                end
+            <if test="authList != null and authList.size() != 0">
+                and (
+                case when kll.status in (1, 6)
+                    then
+                    kll.create_by in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
+                when kll.status in (2, 3, 4, 5) then
+                (
+                    kll.create_by in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
+                or kllu2.contacts_id in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
                 )
+                    end
+                    )
+            </if>
         </where>
         order by kll.generate_time desc
     </select>
@@ -440,26 +444,28 @@
                         or kllu.contacts like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
                     )
             </if>
-            and (
-            case when kll.status in (1, 6)
-                then
-                kll.create_by in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            when kll.status in (2, 3, 4, 5) then
-            (
-                kll.create_by in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            or kllu2.contacts_id in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            )
-                end
+            <if test="authList != null and authList.size() != 0">
+                and (
+                case when kll.status in (1, 6)
+                    then
+                    kll.create_by in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
+                when kll.status in (2, 3, 4, 5) then
+                (
+                    kll.create_by in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
+                or kllu2.contacts_id in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
                 )
+                    end
+                    )
+            </if>
         </where>
     </select>
     <!--对账审核方-->
@@ -496,31 +502,33 @@
                         or kllu.contacts like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
                     )
             </if>
-            and (
-            case
-                when kll.status = 2 then
-                    true
-            when kll.status in (3, 4, 5) then
-            (
+            <if test="authList != null and authList.size() != 0">
+                and (
+                case
+                    when kll.status = 2 then
+                        true
+                when kll.status in (3, 4, 5) then
+                (
+                (
+                    kllu2.contacts_id in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>)
+                or
             (
-                kllu2.contacts_id in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>)
-            or
-        (
-        select kllt.id
-        from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
-                                               and kllt.l_ledger_id = kll.id
-                                               and kllt.status in (3, 5)
-                                               and kllt.create_by in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            )
-                )
-                end
+            select kllt.id
+            from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
+                                                   and kllt.l_ledger_id = kll.id
+                                                   and kllt.status in (3, 5)
+                                                   and kllt.create_by in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
                 )
+                    )
+                    end
+                    )
+            </if>
         </where>
     </select>
     <select id="countOrder" resultType="java.util.Map">
@@ -727,54 +735,56 @@
                                 or kllu.contacts like concat('%', #{logisticsReq.keywords,jdbcType=VARCHAR}, '%')
                             )
                     </if>
-                    <if test="logisticsReq.unitType == 1">
-                        and (
-                        case when kll.status in (1, 6)
-                            then
-                            kll.create_by in
-                        <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                            #{item,jdbcType=BIGINT}
-                        </foreach>
-                        when kll.status in (2, 3, 4, 5) then
-                        (
-                            kll.create_by in
-                        <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                            #{item,jdbcType=BIGINT}
-                        </foreach>
-                        or kllu2.contacts_id in
-                        <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                            #{item,jdbcType=BIGINT}
-                        </foreach>
-                        )
-                            end
+                    <if test="authList != null and authList.size() != 0">
+                        <if test="logisticsReq.unitType == 1">
+                            and (
+                            case when kll.status in (1, 6)
+                                then
+                                kll.create_by in
+                            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                                #{item,jdbcType=BIGINT}
+                            </foreach>
+                            when kll.status in (2, 3, 4, 5) then
+                            (
+                                kll.create_by in
+                            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                                #{item,jdbcType=BIGINT}
+                            </foreach>
+                            or kllu2.contacts_id in
+                            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                                #{item,jdbcType=BIGINT}
+                            </foreach>
                             )
-                    </if>
-                    <if test="logisticsReq.unitType == 2">
-                        and (
-                        case
-                            when kll.status = 2 then
-                                true
-                        when kll.status in (3, 4, 5) then
+                                end
+                                )
+                        </if>
+                        <if test="logisticsReq.unitType == 2">
+                            and (
+                            case
+                                when kll.status = 2 then
+                                    true
+                            when kll.status in (3, 4, 5) then
+                            (
+                            (
+                                kllu2.contacts_id in
+                            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                                #{item,jdbcType=BIGINT}
+                            </foreach>)
+                            or
                         (
-                        (
-                            kllu2.contacts_id in
-                        <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                            #{item,jdbcType=BIGINT}
-                        </foreach>)
-                        or
-                    (
-                    select kllt.id
-                    from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
-                                                           and kllt.l_ledger_id = kll.id
-                                                           and kllt.status in (3, 5)
-                                                           and kllt.create_by in
-                        <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                            #{item,jdbcType=BIGINT}
-                        </foreach>
-                        )
-                            )
-                            end
+                        select kllt.id
+                        from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
+                                                               and kllt.l_ledger_id = kll.id
+                                                               and kllt.status in (3, 5)
+                                                               and kllt.create_by in
+                            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                                #{item,jdbcType=BIGINT}
+                            </foreach>
                             )
+                                )
+                                end
+                                )
+                        </if>
                     </if>
                 </otherwise>
             </choose>

+ 152 - 142
sckw-modules/sckw-payment/src/main/resources/mapper/KwpLedgerTradeMapper.xml

@@ -149,26 +149,28 @@
                         , '%')
                     )
             </if>
-            and (
-            case when klt.status in (1, 6)
-            then
-            klt.create_by in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            when klt.status in (2, 3, 4, 5) then
-            (
-            klt.create_by in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            or kltu2.contacts_id in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            )
-            end
-            )
+            <if test="authList != null and authList.size() != 0">
+                and (
+                case when klt.status in (1, 6)
+                    then
+                    klt.create_by in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
+                when klt.status in (2, 3, 4, 5) then
+                (
+                    klt.create_by in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
+                or kltu2.contacts_id in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
+                )
+                    end
+                    )
+            </if>
         </where>
         order by klt.generate_time desc
     </select>
@@ -319,31 +321,33 @@
                         , '%')
                     )
             </if>
-            and (
-            case
-                when klt.status = 2 then
-                    true
-            when klt.status in (3, 4, 5) then
-            (
+            <if test="authList != null and authList.size() != 0">
+                and (
+                case
+                    when klt.status = 2 then
+                        true
+                when klt.status in (3, 4, 5) then
+                (
+                (
+                    kltu2.contacts_id in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>)
+                or
             (
-                kltu2.contacts_id in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>)
-            or
-        (
-        select kllt.id
-        from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
-                                               and kllt.l_ledger_id = klt.id
-                                               and kllt.status in (3, 5)
-                                               and kllt.create_by in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            )
-                )
-                end
+            select kllt.id
+            from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
+                                                   and kllt.l_ledger_id = klt.id
+                                                   and kllt.status in (3, 5)
+                                                   and kllt.create_by in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
                 )
+                    )
+                    end
+                    )
+            </if>
         </where>
         order by klt.generate_time desc
     </select>
@@ -524,26 +528,28 @@
                         , '%')
                     )
             </if>
-            and (
-            case when klt.status in (1, 6)
-            then
-            klt.create_by in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            when klt.status in (2, 3, 4, 5) then
-            (
-            klt.create_by in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            or kltu2.contacts_id in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            )
-            end
-            )
+            <if test="authList != null and authList.size() != 0">
+                and (
+                case when klt.status in (1, 6)
+                    then
+                    klt.create_by in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
+                when klt.status in (2, 3, 4, 5) then
+                (
+                    klt.create_by in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
+                or kltu2.contacts_id in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
+                )
+                    end
+                    )
+            </if>
         </where>
     </select>
     <select id="countPurchaseOrder" resultType="java.util.Map">
@@ -587,31 +593,33 @@
                         , '%')
                     )
             </if>
-            and (
-            case
-                when klt.status = 2 then
-                    true
-            when klt.status in (3, 4, 5) then
-            (
+            <if test="authList != null and authList.size() != 0">
+                and (
+                case
+                    when klt.status = 2 then
+                        true
+                when klt.status in (3, 4, 5) then
+                (
+                (
+                    kltu2.contacts_id in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>)
+                or
             (
-                kltu2.contacts_id in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>)
-            or
-        (
-        select kllt.id
-        from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
-                                               and kllt.l_ledger_id = klt.id
-                                               and kllt.status in (3, 5)
-                                               and kllt.create_by in
-            <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                #{item,jdbcType=BIGINT}
-            </foreach>
-            )
-                )
-                end
+            select kllt.id
+            from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
+                                                   and kllt.l_ledger_id = klt.id
+                                                   and kllt.status in (3, 5)
+                                                   and kllt.create_by in
+                <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
                 )
+                    )
+                    end
+                    )
+            </if>
         </where>
     </select>
 
@@ -838,69 +846,71 @@
                     </if>
                     <if test="tradeReq.endCreateTime != null and tradeReq.endCreateTime != '' and tradeReq.startCreateTime != null and tradeReq.startCreateTime != ''">
                         and klt.generate_time between #{tradeReq.startCreateTime,jdbcType=TIMESTAMP}
-                        and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
+                            and #{tradeReq.endCreateTime,jdbcType=TIMESTAMP}
                     </if>
                     <if test="tradeReq.keywords != null and tradeReq.keywords != ''">
                         and (
-                        klt.t_ledger_no like concat('%'
-                        , #{tradeReq.keywords,jdbcType=VARCHAR}
-                        , '%')
-                        or kltu.firm_name like concat('%'
-                        , #{tradeReq.keywords,jdbcType=VARCHAR}
-                        , '%')
-                        or kltu.contacts like concat('%'
-                        , #{tradeReq.keywords,jdbcType=VARCHAR}
-                        , '%')
-                        )
+                                    klt.t_ledger_no like concat('%'
+                                    , #{tradeReq.keywords,jdbcType=VARCHAR}
+                                    , '%')
+                                or kltu.firm_name like concat('%'
+                                , #{tradeReq.keywords,jdbcType=VARCHAR}
+                                , '%')
+                                or kltu.contacts like concat('%'
+                                , #{tradeReq.keywords,jdbcType=VARCHAR}
+                                , '%')
+                            )
                     </if>
-                    <if test="tradeReq.unitType == 1">
-                        and (
-                        case when klt.status in (1, 6)
-                        then
-                        klt.create_by in
-                        <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                            #{item,jdbcType=BIGINT}
-                        </foreach>
-                        when klt.status in (2, 3, 4, 5) then
-                        (
-                        klt.create_by in
-                        <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                            #{item,jdbcType=BIGINT}
-                        </foreach>
-                        or kltu2.contacts_id in
-                        <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                            #{item,jdbcType=BIGINT}
-                        </foreach>
-                        )
-                        end
-                        )
-                    </if>
-                    <if test="tradeReq.unitType == 2">
-                        and (
-                        case
-                        when klt.status = 2 then
-                        true
-                        when klt.status in (3, 4, 5) then
-                        (
-                        (
-                        kltu2.contacts_id in
-                        <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                            #{item,jdbcType=BIGINT}
-                        </foreach>)
-                        or
+                    <if test="authList != null and authList.size() != 0">
+                        <if test="tradeReq.unitType == 1">
+                            and (
+                            case when klt.status in (1, 6)
+                                then
+                                klt.create_by in
+                            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                                #{item,jdbcType=BIGINT}
+                            </foreach>
+                            when klt.status in (2, 3, 4, 5) then
+                            (
+                                klt.create_by in
+                            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                                #{item,jdbcType=BIGINT}
+                            </foreach>
+                            or kltu2.contacts_id in
+                            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                                #{item,jdbcType=BIGINT}
+                            </foreach>
+                            )
+                                end
+                                )
+                        </if>
+                        <if test="tradeReq.unitType == 2">
+                            and (
+                            case
+                                when klt.status = 2 then
+                                    true
+                            when klt.status in (3, 4, 5) then
+                            (
+                            (
+                                kltu2.contacts_id in
+                            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                                #{item,jdbcType=BIGINT}
+                            </foreach>)
+                            or
                         (
                         select kllt.id
                         from kwp_ledger_logistics_track kllt where kllt.del_flag = 0
-                        and kllt.l_ledger_id = klt.id
-                        and kllt.status in (3, 5)
-                        and kllt.create_by in
-                        <foreach collection="authList" item="item" open="(" close=")" separator=",">
-                            #{item,jdbcType=BIGINT}
-                        </foreach>
-                        )
-                        )
-                        end
-                        )
+                                                               and kllt.l_ledger_id = klt.id
+                                                               and kllt.status in (3, 5)
+                                                               and kllt.create_by in
+                            <foreach collection="authList" item="item" open="(" close=")" separator=",">
+                                #{item,jdbcType=BIGINT}
+                            </foreach>
+                            )
+                                )
+                                end
+                                )
+                        </if>
                     </if>
                 </otherwise>
             </choose>