Procházet zdrojové kódy

对账模块数据查询增加数据过滤

lengfaqiang před 2 roky
rodič
revize
11c9212c16

+ 9 - 2
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java

@@ -33,9 +33,13 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
      *
      * @param logisticsOrderParam 查询参数
      * @param dictValue           字典id
+     * @param entId           托运角色
+     * @param dictValue           承运角色
      * @return
      */
-    List<LogisticsOrderVO> selectLogisticOrderData(@Param("logisticsOrderParam") LogisticsOrderParam logisticsOrderParam, @Param("dictValue") String dictValue, @Param("entId") Long entId);
+    List<LogisticsOrderVO> selectLogisticOrderData(@Param("logisticsOrderParam") LogisticsOrderParam logisticsOrderParam,
+                                                   @Param("dictValue") String dictValue, @Param("entId") Long entId,
+                                                   @Param("ids") List<Long> ids);
 
 
     /**
@@ -90,7 +94,10 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
      * @param dictValue
      * @return
      */
-    Long selectLogisticOrderCount(@Param("logisticsOrderParam") LogisticsOrderParam logisticsOrderParam, @Param("dictValue") String dictValue, @Param("entId") Long entId);
+    Long selectLogisticOrderCount(@Param("logisticsOrderParam") LogisticsOrderParam logisticsOrderParam,
+                                  @Param("dictValue") String dictValue, @Param("entId") Long entId,
+                                  @Param("ids") List<Long> ids
+    );
 
     Map<String, String> getRejectReason(@Param("id") String id, @Param("status") Integer status);
 

+ 14 - 6
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/TransportCommonService.java

@@ -447,15 +447,15 @@ public class TransportCommonService {
         //托运
         KwtLogisticsOrderUnit consignUnit = logisticsOrderUnitMapper.selectOne(
                 new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
-                        .eq(KwtLogisticsOrderUnit::getLOrderId,id)
+                        .eq(KwtLogisticsOrderUnit::getLOrderId, id)
                         .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.ONE));
         //承运
         KwtLogisticsOrderUnit carriageUnit = logisticsOrderUnitMapper.selectOne(
                 new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
-                        .eq(KwtLogisticsOrderUnit::getLOrderId,id)
+                        .eq(KwtLogisticsOrderUnit::getLOrderId, id)
                         .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.TWO));
-        commonService.cancelLogisticsConsignment(consignUnit,carriageUnit,logisticsOrder.getLOrderNo(),logisticsOrder.getCreateBy(),
-                logisticsOrder.getEntId(),MessageEnum.CANCELLATION_LOGISTICS,MessageEnum.CARRIAGE_CANCELLATION_LOGISTICS);
+        commonService.cancelLogisticsConsignment(consignUnit, carriageUnit, logisticsOrder.getLOrderNo(), logisticsOrder.getCreateBy(),
+                logisticsOrder.getEntId(), MessageEnum.CANCELLATION_LOGISTICS, MessageEnum.CARRIAGE_CANCELLATION_LOGISTICS);
         return result;
     }
 
@@ -507,9 +507,17 @@ public class TransportCommonService {
             logisticsOrderParam.setEndTime(logisticsOrderParam.getEndTime() + " 23:59:59");
         }
         Integer page = logisticsOrderParam.getPage();
+        Long entId = LoginUserHolder.getEntId();
+        List<Long> ids = new ArrayList<>();
+        ids.add(entId);
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(entId);
+        if (entCacheResDto != null) {
+            ids.add(entCacheResDto.getId());
+        }
+        ids = ids.stream().distinct().collect(Collectors.toList());
         logisticsOrderParam.setPage((logisticsOrderParam.getPage() - 1) * logisticsOrderParam.getPageSize());
-        List<LogisticsOrderVO> list = logisticsOrderMapper.selectLogisticOrderData(logisticsOrderParam, dictValue, LoginUserHolder.getEntId());
-        Long count = logisticsOrderMapper.selectLogisticOrderCount(logisticsOrderParam, dictValue, LoginUserHolder.getEntId());
+        List<LogisticsOrderVO> list = logisticsOrderMapper.selectLogisticOrderData(logisticsOrderParam, dictValue, LoginUserHolder.getEntId(),ids);
+        Long count = logisticsOrderMapper.selectLogisticOrderCount(logisticsOrderParam, dictValue, LoginUserHolder.getEntId(),ids);
         /**计量单位*/
         Map<String, String> unitTypeDictData = getDictData(DictTypeEnum.UNIT_TYPE.getType());
         /**运价方式*/

+ 200 - 173
sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

@@ -165,12 +165,12 @@
         AND f.del_flag = 0
         <where>
             a.del_flag = 0
-<!--            <if test="type == 1">-->
-<!--                and (d.top_ent_id = #{entId} or d.ent_id = #{entId})-->
-<!--            </if>-->
-<!--            <if test="type == 2">-->
-<!--                and (e.top_ent_id = #{entId} or e.ent_id = #{entId})-->
-<!--            </if>-->
+            <!--            <if test="type == 1">-->
+            <!--                and (d.top_ent_id = #{entId} or d.ent_id = #{entId})-->
+            <!--            </if>-->
+            <!--            <if test="type == 2">-->
+            <!--                and (e.top_ent_id = #{entId} or e.ent_id = #{entId})-->
+            <!--            </if>-->
             <if test="contractIds != null and contractIds.size() > 0">
                 and f.contract_id in
                 <foreach collection="contractIds" item="item" separator="," open="(" close=")">
@@ -228,7 +228,8 @@
         LEFT JOIN kwt_logistics_order_contract c ON a.id = c.l_order_id
         <!--        LEFT JOIN ( SELECT l_order_id FROM kwt_logistics_order_unit WHERE unit_type = 1 AND ent_id = #{entId} ) g ON a.id = g.l_order_id-->
         <!--        LEFT JOIN ( SELECT ent_id FROM kwt_logistics_order_unit WHERE unit_type = 1 AND ent_id = #{entId} ) g ON a.id = g.l_order_id-->
-        LEFT JOIN kwt_logistics_order_unit g on a.id =g.l_order_id and g.unit_type=1
+        LEFT JOIN kwt_logistics_order_unit g on a.id = g.l_order_id and g.unit_type= 1
+        LEFT JOIN kwt_logistics_order_unit h on a.id = h.l_order_id and h.unit_type= 2
         <where>
             a.del_flag = 0 and a.bind_status = '0' <!--and d.unit_type = 1-->
             <if test="dictValue != null and dictValue != ''">
@@ -238,6 +239,17 @@
                 <!--                AND d.ent_id = #{logisticsOrderParam.companyId}-->
                 AND g.ent_id = #{logisticsOrderParam.companyId}
             </if>
+            <if test="ids !=null and ids.size() > 0 ">
+                AND ( h.ent_id in
+                <foreach collection="ids" open="(" close=")" separator="," item="item">
+                    #{item}
+                </foreach>
+                or h.top_ent_id in
+                <foreach collection="ids" item="item" separator="," close=")" open="(">
+                    #{item}
+                </foreach>
+                )
+            </if>
             <if test="logisticsOrderParam.taxRate != null and logisticsOrderParam.taxRate != ''">
                 AND a.tax_rate = #{logisticsOrderParam.taxRate}
             </if>
@@ -263,15 +275,27 @@
         kwt_logistics_order a
         LEFT JOIN kwt_logistics_order_goods b ON a.id = b.l_order_id
         LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
+        LEFT JOIN kwt_logistics_order_unit h ON a.id = h.l_order_id
         LEFT JOIN kwt_logistics_order_contract c ON a.id=c.l_order_id
         <where>
-            a.del_flag = 0 and d.unit_type = 1 and a.bind_status='0'
+            a.del_flag = 0 and d.unit_type = 1 and h.unit_type = 2 and a.bind_status='0'
             <if test="dictValue != null and dictValue != ''">
                 AND a.payment = #{dictValue}
             </if>
             <if test="logisticsOrderParam.companyId !=null and logisticsOrderParam.companyId != ''">
                 AND d.ent_id = #{logisticsOrderParam.companyId}
             </if>
+            <if test="ids !=null and ids.size() > 0 ">
+                AND ( h.ent_id in
+                <foreach collection="ids" open="(" close=")" separator="," item="item">
+                    #{item}
+                </foreach>
+                or h.top_ent_id in
+                <foreach collection="ids" item="item" separator="," close=")" open="(">
+                    #{item}
+                </foreach>
+                )
+            </if>
             <if test="logisticsOrderParam.taxRate != null and logisticsOrderParam.taxRate != ''">
                 AND a.tax_rate = #{logisticsOrderParam.taxRate}
             </if>
@@ -355,60 +379,60 @@
 
     <select id="getSubcontractConsignmentNotPage" resultType="com.sckw.transport.model.vo.SubcontractConsignmentVO">
         SELECT a.id,
-               a.pid,
-               a.`status`         as status,
-               a.l_order_no       as consignOrderNo,
-<!--               a.l_order_no       as carrierOrderNo,-->
-               c.firm_name        as carrierCompany,
-               d.goods_name       as goodsName,
-               a.amount           as carryingCapacity,
-               a.price,
-               a.price_type       as priceType,
-               e.detail_address   as loadAddress,
-               f.detail_address   as unloadAddress,
-               a.billing_mode     as billingMode,
-               a.loss,
-               a.loss_unit        as lossUnit,
-               a.goods_price      as goodsPrice,
-               a.goods_price_unit as goodsPriceUnit,
-               a.settlement_cycle as settlementCycle,
-               c.contacts         as carrierContacts,
-               c.phone            as carrierPhone,
-               b.firm_name        as consignCompany,
-               b.contacts         as consignContacts,
-               b.phone            as consignPhone,
-               e.contacts         as loadContacts,
-               e.phone            as loadPhone,
-               f.contacts         as unloadContacts,
-               f.phone            as unloadPhone,
-               a.start_time       as shipmentsDate,
-               a.end_time         as receiveGoodsDate,
-               a.remark,
-               a.create_by        as createBy,
-               a.create_time      as createTime,
-               g.contract_id      as contractId,
-               g.contract_no      as contractNo,
-               g.contract_name    as contractName,
-               g.signing_way      as signing,
-               e.city_name        as loadCityName,
-               f.city_name        as unloadCityName
+        a.pid,
+        a.`status` as status,
+        a.l_order_no as consignOrderNo,
+        <!--               a.l_order_no       as carrierOrderNo,-->
+        c.firm_name as carrierCompany,
+        d.goods_name as goodsName,
+        a.amount as carryingCapacity,
+        a.price,
+        a.price_type as priceType,
+        e.detail_address as loadAddress,
+        f.detail_address as unloadAddress,
+        a.billing_mode as billingMode,
+        a.loss,
+        a.loss_unit as lossUnit,
+        a.goods_price as goodsPrice,
+        a.goods_price_unit as goodsPriceUnit,
+        a.settlement_cycle as settlementCycle,
+        c.contacts as carrierContacts,
+        c.phone as carrierPhone,
+        b.firm_name as consignCompany,
+        b.contacts as consignContacts,
+        b.phone as consignPhone,
+        e.contacts as loadContacts,
+        e.phone as loadPhone,
+        f.contacts as unloadContacts,
+        f.phone as unloadPhone,
+        a.start_time as shipmentsDate,
+        a.end_time as receiveGoodsDate,
+        a.remark,
+        a.create_by as createBy,
+        a.create_time as createTime,
+        g.contract_id as contractId,
+        g.contract_no as contractNo,
+        g.contract_name as contractName,
+        g.signing_way as signing,
+        e.city_name as loadCityName,
+        f.city_name as unloadCityName
         FROM kwt_logistics_order a
-                 LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
-            AND b.unit_type = 1
-                 LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
-            AND c.unit_type = 2
-                 LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
-                 LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
-            AND e.address_type = 1
-                 LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
-            AND f.address_type = 2
-                 LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
+        LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
+        AND b.unit_type = 1
+        LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
+        AND c.unit_type = 2
+        LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
+        LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
+        AND e.address_type = 1
+        LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
+        AND f.address_type = 2
+        LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
         WHERE a.del_flag = 0
-          AND b.del_flag = 0
-          AND c.del_flag = 0
-          AND e.del_flag = 0
-          AND f.del_flag = 0
-          and a.pid = #{lOrderId}
+        AND b.del_flag = 0
+        AND c.del_flag = 0
+        AND e.del_flag = 0
+        AND f.del_flag = 0
+        and a.pid = #{lOrderId}
         ORDER BY a.create_time desc
     </select>
 
@@ -491,9 +515,9 @@
         <!--        b.truck_no AS truckNo-->
         <!--        ,-->
         <!--        COUNT( b.id ) AS count-->
-<!--        FROM-->
-<!--        kwt_waybill_order b,-->
-<!--        kwt_logistics_order a-->
+        <!--        FROM-->
+        <!--        kwt_waybill_order b,-->
+        <!--        kwt_logistics_order a-->
         <where>
             a.id = b.l_order_id
             AND a.del_flag = 0
@@ -853,45 +877,45 @@
             a.del_flag = 0
             <if test="type == 1">
                 and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
-<!--                AND (-->
-<!--                a.ent_id = #{entId}-->
-<!--                <if test="userIds != null and userIds.size()>0">-->
-<!--                    AND a.create_by IN-->
-<!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                </if>-->
-<!--                )-->
-<!--                OR (-->
-<!--                d.top_ent_id = #{entId}-->
-<!--                <if test="contactsIds != null and contactsIds.size()>0">-->
-<!--                    AND d.contacts_id IN-->
-<!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                </if>-->
-<!--                 )-->
+                <!--                AND (-->
+                <!--                a.ent_id = #{entId}-->
+                <!--                <if test="userIds != null and userIds.size()>0">-->
+                <!--                    AND a.create_by IN-->
+                <!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
+                <!--                        #{item}-->
+                <!--                    </foreach>-->
+                <!--                </if>-->
+                <!--                )-->
+                <!--                OR (-->
+                <!--                d.top_ent_id = #{entId}-->
+                <!--                <if test="contactsIds != null and contactsIds.size()>0">-->
+                <!--                    AND d.contacts_id IN-->
+                <!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
+                <!--                        #{item}-->
+                <!--                    </foreach>-->
+                <!--                </if>-->
+                <!--                 )-->
             </if>
             <if test="type == 2">
                 and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
-<!--                AND (-->
-<!--                a.ent_id = #{entId}-->
-<!--                <if test="userIds != null and userIds.size()>0">-->
-<!--                    AND a.create_by IN-->
-<!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                </if>-->
-<!--                )-->
-<!--                OR (-->
-<!--                d.top_ent_id = #{entId}-->
-<!--                <if test="contactsIds != null and contactsIds.size()>0">-->
-<!--                    AND d.contacts_id IN-->
-<!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                </if>-->
-<!--                )-->
+                <!--                AND (-->
+                <!--                a.ent_id = #{entId}-->
+                <!--                <if test="userIds != null and userIds.size()>0">-->
+                <!--                    AND a.create_by IN-->
+                <!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
+                <!--                        #{item}-->
+                <!--                    </foreach>-->
+                <!--                </if>-->
+                <!--                )-->
+                <!--                OR (-->
+                <!--                d.top_ent_id = #{entId}-->
+                <!--                <if test="contactsIds != null and contactsIds.size()>0">-->
+                <!--                    AND d.contacts_id IN-->
+                <!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
+                <!--                        #{item}-->
+                <!--                    </foreach>-->
+                <!--                </if>-->
+                <!--                )-->
             </if>
             <if test="query.keywords != null and query.keywords != ''">
                 and (
@@ -958,45 +982,45 @@
             a.del_flag = 0
             <if test="type == 1">
                 and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
-<!--                AND (-->
-<!--                a.ent_id = #{entId}-->
-<!--                <if test="userIds != null and userIds.size()>0">-->
-<!--                    AND a.create_by IN-->
-<!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                </if>-->
-<!--                )-->
-<!--                OR (-->
-<!--                d.top_ent_id = #{entId}-->
-<!--                <if test="contactsIds != null and contactsIds.size()>0">-->
-<!--                    AND d.contacts_id IN-->
-<!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                </if>-->
-<!--                )-->
+                <!--                AND (-->
+                <!--                a.ent_id = #{entId}-->
+                <!--                <if test="userIds != null and userIds.size()>0">-->
+                <!--                    AND a.create_by IN-->
+                <!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
+                <!--                        #{item}-->
+                <!--                    </foreach>-->
+                <!--                </if>-->
+                <!--                )-->
+                <!--                OR (-->
+                <!--                d.top_ent_id = #{entId}-->
+                <!--                <if test="contactsIds != null and contactsIds.size()>0">-->
+                <!--                    AND d.contacts_id IN-->
+                <!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
+                <!--                        #{item}-->
+                <!--                    </foreach>-->
+                <!--                </if>-->
+                <!--                )-->
             </if>
             <if test="type == 2">
                 and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
-<!--                AND (-->
-<!--                a.ent_id = #{entId}-->
-<!--                <if test="userIds != null and userIds.size()>0">-->
-<!--                    AND a.create_by IN-->
-<!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                </if>-->
-<!--                )-->
-<!--                OR (-->
-<!--                d.top_ent_id = #{entId}-->
-<!--                <if test="contactsIds != null and contactsIds.size()>0">-->
-<!--                    AND d.contacts_id IN-->
-<!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                </if>-->
-<!--                )-->
+                <!--                AND (-->
+                <!--                a.ent_id = #{entId}-->
+                <!--                <if test="userIds != null and userIds.size()>0">-->
+                <!--                    AND a.create_by IN-->
+                <!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
+                <!--                        #{item}-->
+                <!--                    </foreach>-->
+                <!--                </if>-->
+                <!--                )-->
+                <!--                OR (-->
+                <!--                d.top_ent_id = #{entId}-->
+                <!--                <if test="contactsIds != null and contactsIds.size()>0">-->
+                <!--                    AND d.contacts_id IN-->
+                <!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
+                <!--                        #{item}-->
+                <!--                    </foreach>-->
+                <!--                </if>-->
+                <!--                )-->
             </if>
             <if test="query.keywords != null and query.keywords != ''">
                 and (
@@ -1052,7 +1076,9 @@
         </if>
     </select>
     <select id="getMaxOrderNoByDate" resultType="java.lang.String">
-        SELECT MAX(l_order_no) FROM kwt_logistics_order WHERE create_time &gt;= #{date};
+        SELECT MAX(l_order_no)
+        FROM kwt_logistics_order
+        WHERE create_time &gt;= #{date};
     </select>
     <select id="checkLogisticsOrderIsFinishByEntId" resultType="java.lang.String">
         SELECT
@@ -1083,7 +1109,8 @@
         </where>
     </select>
 
-    <select id="selectLogisticsOrderListExport" resultType="com.sckw.transport.model.vo.execlvo.AcceptCarriageOrderExcelVo">
+    <select id="selectLogisticsOrderListExport"
+            resultType="com.sckw.transport.model.vo.execlvo.AcceptCarriageOrderExcelVo">
         SELECT
         <include refid="Query_Column_List">
         </include>
@@ -1173,45 +1200,45 @@
             a.del_flag = 0
             <if test="type == 1">
                 and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
-<!--                AND (-->
-<!--                a.ent_id = #{entId}-->
-<!--                <if test="userIds != null and userIds.size()>0">-->
-<!--                    AND a.create_by IN-->
-<!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                </if>-->
-<!--                )-->
-<!--                OR (-->
-<!--                d.top_ent_id = #{entId}-->
-<!--                <if test="contactsIds != null and contactsIds.size()>0">-->
-<!--                    AND d.contacts_id IN-->
-<!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                </if>-->
-<!--                )-->
+                <!--                AND (-->
+                <!--                a.ent_id = #{entId}-->
+                <!--                <if test="userIds != null and userIds.size()>0">-->
+                <!--                    AND a.create_by IN-->
+                <!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
+                <!--                        #{item}-->
+                <!--                    </foreach>-->
+                <!--                </if>-->
+                <!--                )-->
+                <!--                OR (-->
+                <!--                d.top_ent_id = #{entId}-->
+                <!--                <if test="contactsIds != null and contactsIds.size()>0">-->
+                <!--                    AND d.contacts_id IN-->
+                <!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
+                <!--                        #{item}-->
+                <!--                    </foreach>-->
+                <!--                </if>-->
+                <!--                )-->
             </if>
             <if test="type == 2">
                 and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
-<!--                AND (-->
-<!--                a.ent_id = #{entId}-->
-<!--                <if test="userIds != null and userIds.size()>0">-->
-<!--                    AND a.create_by IN-->
-<!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                </if>-->
-<!--                )-->
-<!--                OR (-->
-<!--                d.top_ent_id = #{entId}-->
-<!--                <if test="contactsIds != null and contactsIds.size()>0">-->
-<!--                    AND d.contacts_id IN-->
-<!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                </if>-->
-<!--                )-->
+                <!--                AND (-->
+                <!--                a.ent_id = #{entId}-->
+                <!--                <if test="userIds != null and userIds.size()>0">-->
+                <!--                    AND a.create_by IN-->
+                <!--                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">-->
+                <!--                        #{item}-->
+                <!--                    </foreach>-->
+                <!--                </if>-->
+                <!--                )-->
+                <!--                OR (-->
+                <!--                d.top_ent_id = #{entId}-->
+                <!--                <if test="contactsIds != null and contactsIds.size()>0">-->
+                <!--                    AND d.contacts_id IN-->
+                <!--                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">-->
+                <!--                        #{item}-->
+                <!--                    </foreach>-->
+                <!--                </if>-->
+                <!--                )-->
             </if>
             <if test="query.keywords != null and query.keywords != ''">
                 and (