Kaynağa Gözat

1、4.2托运订单和物流订单查询及统计接口调整;

zk 1 yıl önce
ebeveyn
işleme
e804745975

+ 8 - 24
sckw-modules/sckw-order/src/main/resources/mapper/KwoTradeOrderMapper.xml

@@ -575,26 +575,14 @@
     <select id="appStatistic" resultType="com.sckw.order.model.vo.res.TradeOrderAppStatisticVO">
         SELECT a.status AS `value`, COUNT(a.status) AS total
         FROM kwo_trade_order a
-        LEFT JOIN kwo_trade_order_unit d ON a.id = d.t_order_id
-        AND d.unit_type = "1" AND d.del_flag = 0
-        LEFT JOIN kwo_trade_order_unit e ON a.id = e.t_order_id
-        AND e.unit_type = "2" AND e.del_flag = 0
+        LEFT JOIN kwo_trade_order_unit d ON a.id = d.t_order_id AND d.unit_type = "1" AND d.del_flag = 0
+        LEFT JOIN kwo_trade_order_unit e ON a.id = e.t_order_id AND e.unit_type = "2" AND e.del_flag = 0
         <where>
             a.del_flag = 0
 --             数据权限匹配
             <if test="query.isMain == 0">
-                and ((
-                <if test="query.entId != null">
-                    a.ent_id = #{query.entId}
-                </if>
-                <if test="authUserIds != null and authUserIds.size() > 0">
-                    and a.create_by in
-                    <foreach collection="authUserIds" item="authUserId" open="(" close=")" separator=",">
-                        #{authUserId}
-                    </foreach>
-                </if>
-                )or
-                (<if test="query.orderType == 1">
+                and (
+                <if test="query.orderType == 1">
                     <if test="query.entId != null">
                         d.top_ent_id = #{query.entId}
                     </if>
@@ -615,16 +603,12 @@
                             #{authUserId}
                         </foreach>
                     </if>
-                </if>)
+                </if>
                 )
             </if>
             <if test="query.isMain == 1">
-                and ((
-                <if test="query.entId != null">
-                    a.ent_id = #{query.entId}
-                </if>)
-                or
-                (<if test="query.orderType == 1">
+                and (
+                <if test="query.orderType == 1">
                     <if test="query.entId != null">
                         d.top_ent_id = #{query.entId}
                     </if>
@@ -633,7 +617,7 @@
                     <if test="query.entId != null">
                         e.top_ent_id = #{query.entId}
                     </if>
-                </if>)
+                </if>
                 )
             </if>
             <if test="query.orderType == 1">

+ 2 - 28
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/AcceptCarriageOrderVO.java

@@ -96,24 +96,6 @@ public class AcceptCarriageOrderVO /*extends PageRequest*/ {
      */
     private String goodsName;
 
-    /**
-     * 装货名称
-     */
-    private String loadName;
-
-    /**
-     * 装货名称
-     */
-    private String unloadName;
-
-    /**
-     * 装货地点
-     */
-    private String loadAddress;
-    /**
-     * 装货区域名称
-     */
-    private String loadCityName;
     /**
      * 数据库id
      */
@@ -209,14 +191,7 @@ public class AcceptCarriageOrderVO /*extends PageRequest*/ {
      * 状态
      */
     private String statusLabel;
-    /**
-     * 卸货地点
-     */
-    private String unloadAddress;
-    /**
-     * 卸货区域名称
-     */
-    private String unloadCityName;
+
 //    /**
 //     * 关联承运订单号
 //     */
@@ -352,10 +327,9 @@ public class AcceptCarriageOrderVO /*extends PageRequest*/ {
 
     /**
      * 多装货地4.2
-     */
     private List<LoadAddressVo> loading;
 
-    private List<UnLoadAddressVo> unloading;
+    private List<UnLoadAddressVo> unloading;*/
 
 
 }

+ 16 - 26
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtAcceptCarriageOrderService.java

@@ -2520,11 +2520,9 @@ public class KwtAcceptCarriageOrderService {
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(pageInfo, list);
         }
-//        List<AcceptCarriageOrderVO> detailRes = new ArrayList<>();
         /**计量单位*/
         Map<String, String> unitTypeDictData = getDictData(DictTypeEnum.UNIT_TYPE.getType());
         /**运价方式*/
-//        Map<String, String> priceDictData = getDictData(DictTypeEnum.PRICE_TYPE.getType());
         /**计费方式*/
         Map<String, String> chargingDictData = getDictData(DictTypeEnum.CHARGING_TYPE.getType());
         /**结算周期*/
@@ -2532,7 +2530,6 @@ public class KwtAcceptCarriageOrderService {
         /**签约方式*/
         Map<String, String> signingWay = getDictData(DictTypeEnum.SIGNING_TYPE.getType());
         /**合理损耗*/
-//        Map<String, String> taxRateTypeDictData = getDictData(DictTypeEnum.TAX_RATE_TYPE.getType());
         /**订单来源*/
         Map<String, String> orderSource = getDictData(DictTypeEnum.ORDER_SOURCE.getType());
         Map<Long, UserCacheResDto> longUserMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
@@ -2542,6 +2539,7 @@ public class KwtAcceptCarriageOrderService {
                 longUserMap = remoteSystemService.queryUserCacheMapByIds(collect);
             }
         }
+
         for (AcceptCarriageOrderVO vo : list) {
             vo.setAccountsCycleLabel(settlementDictData.get(vo.getAccountsCycle()));
             vo.setAppointor(longUserMap.get(vo.getCreateBy()) == null ? null : longUserMap.get(vo.getCreateBy()).getName());
@@ -2549,11 +2547,7 @@ public class KwtAcceptCarriageOrderService {
             vo.setSigningLabel(signingWay.get(vo.getSigning()));
             vo.setOrderSourceLabel(orderSource == null ? null : orderSource.get(vo.getOrderSource()));
             vo.setStatusLabel(LogisticsOrderEnum.getName(vo.getStatus()));
-            vo.setLoadAddress(vo.getLoadCityName() + vo.getLoadAddress());
-            vo.setUnloadAddress(vo.getUnloadCityName() + vo.getUnloadAddress());
-            vo.setLoadCityName(vo.getLoadName());
             vo.setUnitLabel(unitTypeDictData == null ? vo.getUnit() : (unitTypeDictData.get(vo.getUnit()) == null ? vo.getUnit() : unitTypeDictData.get(vo.getUnit())));
-            vo.setUnloadCityName(vo.getUnloadName());
             vo.setWaitDistributionAmount(vo.getCarryingCapacity().subtract(vo.getSubcontractAmount()).subtract(vo.getEntrustAmount()));
             String tOrderId = vo.getTOrderId();
             if (StringUtils.isNotBlank(tOrderId)) {
@@ -2579,37 +2573,33 @@ public class KwtAcceptCarriageOrderService {
                 }
             }
             String lOrderId = vo.getLOrderId();
-            List<String> loadName = new ArrayList<String>();
-            List<String> loadAddressList = new ArrayList<String>();
-            List<KwtLogisticsOrderAddress> loadAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+            List<KwtLogisticsOrderAddress> loadAddresses = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
                     .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.ONE)
                     .eq(KwtLogisticsOrderAddress::getDelFlag, NumberConstant.ZERO)
                     .eq(KwtLogisticsOrderAddress::getLOrderId, Long.parseLong(lOrderId))
             );
-            loadAddress.forEach(address -> {
-                loadName.add(address.getName());
-                loadAddressList.add(address.getDetailAddress());
-            });
-
-            List<String> unloadName = new ArrayList<String>();
-            List<String> unloadAddressList = new ArrayList<String>();
-            List<KwtLogisticsOrderAddress> unloadAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+            List<KwtLogisticsOrderAddress> unloadAddresses = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
                     .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.TWO)
                     .eq(KwtLogisticsOrderAddress::getDelFlag, NumberConstant.ZERO)
                     .eq(KwtLogisticsOrderAddress::getLOrderId, Long.parseLong(lOrderId))
             );
-            unloadAddress.forEach(address -> {
-                unloadName.add(address.getName());
-                unloadAddressList.add(address.getDetailAddress());
-            });
+            //装货地点名称
+            List<String> loadName = loadAddresses.stream().map(KwtLogisticsOrderAddress::getCityName).toList();
+            //装货地点
+            List<String> loadAddress = loadAddresses.stream().map(KwtLogisticsOrderAddress::getDetailAddress).toList();
+            //卸货地点点名称
+            List<String> unloadName = unloadAddresses.stream().map(KwtLogisticsOrderAddress::getCityName).toList();
+            //卸货地点
+            List<String> unloadAddress = unloadAddresses.stream().map(KwtLogisticsOrderAddress::getDetailAddress).toList();
+
             vo.setLoadNames(loadName);
-            vo.setLoadAddresses(loadAddressList);
+            vo.setLoadAddresses(loadAddress);
             vo.setUnloadNames(unloadName);
-            vo.setUnloadAddresses(unloadAddressList);
-            List<LoadAddressVo> loadAddressAmount = logisticsOrderAddressMapper.findByAddressAndLoadAmount(Long.parseLong(lOrderId), NumberConstant.ONE);
+            vo.setUnloadAddresses(unloadAddress);
+            /*List<LoadAddressVo> loadAddressAmount = logisticsOrderAddressMapper.findByAddressAndLoadAmount(Long.parseLong(lOrderId), NumberConstant.ONE);
             vo.setLoading(loadAddressAmount);
             List<UnLoadAddressVo> unloadAddressAmount = logisticsOrderAddressMapper.findByAddressAndUnLoadAmount(Long.parseLong(lOrderId), NumberConstant.TWO);
-            vo.setUnloading(unloadAddressAmount);
+            vo.setUnloading(unloadAddressAmount);*/
         }
         return PageRes.build(pageInfo, list);
     }

+ 21 - 36
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtConsignOrderService.java

@@ -1814,20 +1814,19 @@ public class KwtConsignOrderService {
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(pageInfo, list);
         }
-//        List<AcceptCarriageOrderVO> detailRes = new ArrayList<>();
-        /**计量单位*/
+
+        /*计量单位*/
         Map<String, String> unitTypeDictData = commonService.getDictData(DictTypeEnum.UNIT_TYPE.getType());
-        /**运价方式*/
+        /*运价方式*/
         Map<String, String> priceDictData = commonService.getDictData(DictTypeEnum.PRICE_TYPE.getType());
-        /**计费方式*/
+        /*计费方式*/
         Map<String, String> chargingDictData = commonService.getDictData(DictTypeEnum.CHARGING_TYPE.getType());
-        /**结算周期*/
+        /*结算周期*/
         Map<String, String> settlementDictData = commonService.getDictData(DictTypeEnum.SETTLEMENT_CYCLE.getType());
-        /**签约方式*/
+        /*签约方式*/
         Map<String, String> signingWay = commonService.getDictData(DictTypeEnum.SIGNING_TYPE.getType());
         Map<String, String> orderSource = commonService.getDictData(DictTypeEnum.ORDER_SOURCE.getType());
-        /**合理损耗*/
-//        Map<String, String> taxRateTypeDictData = getDictData(DictTypeEnum.TAX_RATE_TYPE.getType());
+        /*合理损耗*/
         Map<Long, UserCacheResDto> longUserMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
         if (CollectionUtils.isNotEmpty(list)) {
             List<Long> collect = list.stream().map(AcceptCarriageOrderVO::getCreateBy).collect(Collectors.toList());
@@ -1842,10 +1841,6 @@ public class KwtConsignOrderService {
             vo.setBillingModeLabel(chargingDictData.get(vo.getBillingMode()));
             vo.setSigningLabel(signingWay.get(vo.getSigning()));
             vo.setStatusLabel(LogisticsOrderEnum.getName(vo.getStatus()));
-            vo.setLoadAddress(vo.getLoadCityName() + vo.getLoadAddress());
-            vo.setUnloadAddress(vo.getUnloadCityName() + vo.getUnloadAddress());
-            vo.setLoadCityName(vo.getLoadName());
-            vo.setUnloadCityName(vo.getUnloadName());
             vo.setPriceLabel(vo.getPriceType() == null ? null : priceDictData.get(vo.getPriceType()));
             vo.setUnitLabel(unitTypeDictData == null ? vo.getUnit() : (unitTypeDictData.get(vo.getUnit()) == null ? vo.getUnit() : unitTypeDictData.get(vo.getUnit())));
             vo.setWaitDistributionAmount(vo.getCarryingCapacity().subtract(vo.getSubcontractAmount()).subtract(vo.getEntrustAmount()));
@@ -1873,37 +1868,28 @@ public class KwtConsignOrderService {
                 }
             }
             String lOrderId = vo.getLOrderId();
-            List<String> loadName = new ArrayList<String>();
-            List<String> loadAddressList = new ArrayList<String>();
-            List<KwtLogisticsOrderAddress> loadAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+            List<KwtLogisticsOrderAddress> loadAddresses = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
                     .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.ONE)
                     .eq(KwtLogisticsOrderAddress::getDelFlag, NumberConstant.ZERO)
-                    .eq(KwtLogisticsOrderAddress::getLOrderId, lOrderId)
+                    .eq(KwtLogisticsOrderAddress::getLOrderId, Long.parseLong(lOrderId))
             );
-            loadAddress.forEach(address -> {
-                loadName.add(address.getName());
-                loadAddressList.add(address.getDetailAddress());
-            });
-
-            List<String> unloadName = new ArrayList<String>();
-            List<String> unloadAddressList = new ArrayList<String>();
-            List<KwtLogisticsOrderAddress> unloadAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+            List<KwtLogisticsOrderAddress> unloadAddresses = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
                     .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.TWO)
                     .eq(KwtLogisticsOrderAddress::getDelFlag, NumberConstant.ZERO)
-                    .eq(KwtLogisticsOrderAddress::getLOrderId, lOrderId)
+                    .eq(KwtLogisticsOrderAddress::getLOrderId, Long.parseLong(lOrderId))
             );
-            unloadAddress.forEach(address -> {
-                unloadName.add(address.getName());
-                unloadAddressList.add(address.getDetailAddress());
-            });
+            //装货地点名称
+            List<String> loadName = loadAddresses.stream().map(KwtLogisticsOrderAddress::getCityName).toList();
+            //装货地点
+            List<String> loadAddress = loadAddresses.stream().map(KwtLogisticsOrderAddress::getDetailAddress).toList();
+            //卸货地点点名称
+            List<String> unloadName = unloadAddresses.stream().map(KwtLogisticsOrderAddress::getCityName).toList();
+            //卸货地点
+            List<String> unloadAddress = unloadAddresses.stream().map(KwtLogisticsOrderAddress::getDetailAddress).toList();
             vo.setLoadNames(loadName);
-            vo.setLoadAddresses(loadAddressList);
+            vo.setLoadAddresses(loadAddress);
             vo.setUnloadNames(unloadName);
-            vo.setUnloadAddresses(unloadAddressList);
-            List<LoadAddressVo> loadAddressAmount = logisticsOrderAddressMapper.findByAddressAndLoadAmount(Long.parseLong(lOrderId), NumberConstant.ONE);
-            vo.setLoading(loadAddressAmount);
-            List<UnLoadAddressVo> unloadAddressAmount = logisticsOrderAddressMapper.findByAddressAndUnLoadAmount(Long.parseLong(lOrderId), NumberConstant.TWO);
-            vo.setUnloading(unloadAddressAmount);
+            vo.setUnloadAddresses(unloadAddress);
         }
         return PageRes.build(pageInfo, list);
     }
@@ -1944,7 +1930,6 @@ public class KwtConsignOrderService {
         longs.add(LoginUserHolder.getUserId());
         List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
         List<Long> idsList = StringUtils.splitStrToList(query.getIds(), Long.class);
-//        List<TableTops> list = kwtLogisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId, longList, longList,idsList);
         List<TableTops> list = kwtLogisticsOrderMapper.countLogisticsOrderListByConsignStatus(query, orderList, type, entId, longList, longList, idsList);
         List<TableTops> arrayList = new ArrayList<>();
         arrayList.addAll(list);

+ 4 - 3
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtTransportCommonService.java

@@ -248,12 +248,13 @@ public class KwtTransportCommonService {
             vo.setLoadContacts(loadAddress.getContacts());
             vo.setLoadPhone(loadAddress.getPhone());
             vo.setLoadAddressDetail(loadAddress.getDetailAddress());
-            KwtLogisticsOrderAmount orderAmount = logisticsOrderAmountMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAmount>()
+            KwtLogisticsOrderAmount orderAmount = logisticsOrderAmountMapper.selectOne(
+                    new LambdaQueryWrapper<KwtLogisticsOrderAmount>()
                     .eq(KwtLogisticsOrderAmount::getLOrderId, loadAddress.getLOrderId())
                     .eq(KwtLogisticsOrderAmount::getLAddressId, loadAddress.getId())
                     .eq(KwtLogisticsOrderAmount::getDelFlag, 0)
             );
-            vo.setLoadAmount(orderAmount != null ? orderAmount.getLoadAmount() : new BigDecimal("0.00"));
+            vo.setLoadAmount(orderAmount != null ? orderAmount.getAmount() : new BigDecimal("0.00"));
             loadAddressList.add(vo);
 
         });
@@ -272,7 +273,7 @@ public class KwtTransportCommonService {
                     .eq(KwtLogisticsOrderAmount::getLAddressId, unloadAddress.getId())
                     .eq(KwtLogisticsOrderAmount::getDelFlag, 0)
             );
-            vo.setUnloadAmount(orderAmount != null ? orderAmount.getUnloadAmount() : new BigDecimal("0.00"));
+            vo.setUnloadAmount(orderAmount != null ? orderAmount.getAmount() : new BigDecimal("0.00"));
             unloadAddressList.add(vo);
 
         });

+ 265 - 325
sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

@@ -1267,26 +1267,7 @@
         e.top_ent_id                                        AS carrierTopEntId,
         e.contacts                                          AS carrierContacts,
         e.phone                                             AS carrierPhone,
-        b.`name`                                            AS loadName,
-        b.address_type                                      AS loadType,
-        b.city_name                                         AS loadCityName,
-        b.city_code                                         AS loadCityCode,
-        b.detail_address                                    AS loadAddress,
-        b.contacts                                          AS shipmentsContacts,
-        b.phone                                             AS shipmentsPhone,
-        b.lat                                               AS loadLat,
-        b.lng                                               AS loadLng,
-        c.`name`                                            AS unloadName,
-        c.address_type                                      AS unloadType,
-        c.contacts                                          AS receiveGoodsContacts,
-        c.phone                                             AS receiveGoodsPhone,
-        c.city_name                                         AS unloadCityName,
-        c.city_code                                         AS unloadCityCode,
-        c.detail_address                                    AS unloadAddress,
-        c.lat                                               AS unloadLat,
-        c.lng                                               AS unloadLng,
-        f.contract_name                                     as contract
-                ,
+        f.contract_name                                     as contract,
         a.del_flag                                          as delFlag,
         case when a.ent_id = e.top_ent_id then 1 ELSE 2 end as createType
     </sql>
@@ -1346,26 +1327,7 @@
         e.top_ent_id                                        AS carrierTopEntId,
         e.contacts                                          AS carrierContacts,
         e.phone                                             AS carrierPhone,
-<!--        b.`name`                                            AS loadName,-->
-<!--        b.address_type                                      AS loadType,-->
-<!--        b.city_name                                         AS loadCityName,-->
-<!--        b.city_code                                         AS loadCityCode,-->
-<!--        b.detail_address                                    AS loadAddress,-->
-<!--        b.contacts                                          AS shipmentsContacts,-->
-<!--        b.phone                                             AS shipmentsPhone,-->
-<!--        b.lat                                               AS loadLat,-->
-<!--        b.lng                                               AS loadLng,-->
-<!--        c.`name`                                            AS unloadName,-->
-<!--        c.address_type                                      AS unloadType,-->
-<!--        c.contacts                                          AS receiveGoodsContacts,-->
-<!--        c.phone                                             AS receiveGoodsPhone,-->
-<!--        c.city_name                                         AS unloadCityName,-->
-<!--        c.city_code                                         AS unloadCityCode,-->
-<!--        c.detail_address                                    AS unloadAddress,-->
-<!--        c.lat                                               AS unloadLat,-->
-<!--        c.lng                                               AS unloadLng,-->
-        f.contract_name                                     as contract
-                ,
+        f.contract_name                                     as contract,
         a.del_flag                                          as delFlag,
         case when a.ent_id = e.top_ent_id then 1 ELSE 2 end as createType
     </sql>
@@ -1425,26 +1387,7 @@
         e.top_ent_id                                        AS carrierTopEntId,
         e.contacts                                          AS carrierContacts,
         e.phone                                             AS carrierPhone,
-        b.`name`                                            AS loadName,
-        b.address_type                                      AS loadType,
-        b.city_name                                         AS loadCityName,
-        b.city_code                                         AS loadCityCode,
-        b.detail_address                                    AS loadAddress,
-        b.contacts                                          AS shipmentsContacts,
-        b.phone                                             AS shipmentsPhone,
-        b.lat                                               AS loadLat,
-        b.lng                                               AS loadLng,
-        c.`name`                                            AS unloadName,
-        c.address_type                                      AS unloadType,
-        c.contacts                                          AS receiveGoodsContacts,
-        c.phone                                             AS receiveGoodsPhone,
-        c.city_name                                         AS unloadCityName,
-        c.city_code                                         AS unloadCityCode,
-        c.detail_address                                    AS unloadAddress,
-        c.lat                                               AS unloadLat,
-        c.lng                                               AS unloadLng,
-        f.contract_name                                     as contract
-                ,
+        f.contract_name                                     as contract,
         a.del_flag                                          as delFlag,
         case when a.ent_id = d.top_ent_id then 1 ELSE 2 end as createType
     </sql>
@@ -2361,8 +2304,7 @@
         ) t1
     </select>
 
-    <select id="workbenchLogisticsOrderStatisticsByMonth"
-            resultType="com.sckw.transport.model.vo.LogisticsOrderStatisticsVO">
+    <select id="workbenchLogisticsOrderStatisticsByMonth" resultType="com.sckw.transport.model.vo.LogisticsOrderStatisticsVO">
         SELECT A.date_time as dateTime,
         COALESCE(B.num, 0) as num,
         IFNULL(B.typeOne, 0) AS typeOne,
@@ -2414,8 +2356,7 @@
         ON A.date_time = B.date_time
     </select>
 
-    <select id="workbenchLogisticsOrderStatisticsByDays"
-            resultType="com.sckw.transport.model.vo.LogisticsOrderStatisticsVO">
+    <select id="workbenchLogisticsOrderStatisticsByDays" resultType="com.sckw.transport.model.vo.LogisticsOrderStatisticsVO">
         SELECT A.date               as dateTime,
                COALESCE(B.num, 0)   as num,
                IFNULL(B.typeOne, 0) AS typeOne,
@@ -2466,83 +2407,79 @@
         ) B
         ON A.date = B.date_time;
     </select>
-    <select id="selectLogisticsOrderListByAcceptCarriage"
-            resultType="com.sckw.transport.model.vo.AcceptCarriageOrderVO">
+
+    <select id="selectLogisticsOrderListByAcceptCarriage" resultType="com.sckw.transport.model.vo.AcceptCarriageOrderVO">
         SELECT
-<!--        <include refid="New_Query_Column_List">-->
-<!--        </include>-->
         <include refid="New_Query_Column_List_v42">
         </include>
         FROM (
-        SELECT
-<!--        <include refid="Query_Column_List_Accept_Carriage">-->
-<!--        </include>-->
-        <include refid="Query_Column_List_Accept_Carriage_v42">
-        </include>
-        FROM kwt_logistics_order a
-                 LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
-            AND b.address_type = 1 AND b.del_flag = 0
-                 LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
-            AND c.address_type = 2 AND c.del_flag = 0
-                 LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
-            AND d.unit_type = 1 AND d.del_flag = 0
-                 LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
-            AND e.unit_type = 2
-                 LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
-                 LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
-        <where>
-            a.del_flag = 0 and  f.del_flag = 0
-            <if test="query.keywords != null and query.keywords != ''">
-                and (
+                SELECT
+                <include refid="Query_Column_List_Accept_Carriage_v42">
+                </include>
+                FROM kwt_logistics_order a
+                LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id AND d.unit_type = 1 AND d.del_flag = 0
+                LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id AND e.unit_type = 2
+                LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
+                LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
+                <where>
+                    a.del_flag = 0 and  f.del_flag = 0
+                    <if test="query.keywords != null and query.keywords != ''">
+                        and (
                             a.t_order_no like concat('%', #{query.keywords}, '%')
-                        or a.l_order_no like concat('%', #{query.keywords}, '%')
-                        or d.firm_name like concat('%', #{query.keywords}, '%')
-                        or e.firm_name like concat('%', #{query.keywords}, '%')
-                        or g.goods_name like concat('%', #{query.keywords}, '%'))
-            </if>
-            <if test="orderList != null and orderList.size() > 0">
-                and a.status in
-                <foreach collection="orderList" item="status" open="(" close=")" separator=",">
-                    #{status}
-                </foreach>
-            </if>
-            <if test="idsList != null and idsList.size() > 0">
-                and a.id in
-                <foreach collection="idsList" close=")" open="(" separator="," item="item">
-                    #{item}
-                </foreach>
-            </if>
-            <if test="query.endBeginDateTime != null and query.endBeginDateTime != ''">
-                and DATE ( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
-            </if>
-            <if test="query.endOverDateTime != null and query.endOverDateTime != ''">
-                and DATE ( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
-            </if>
-            <if test="query.startBeginDateTime != null and query.startBeginDateTime != ''">
-                and DATE ( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
-            </if>
-            <if test="query.startOverDateTime != null and query.startOverDateTime != ''">
-                and DATE ( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
-            </if>
-            <if test="query.createStartTime != null and query.createStartTime != ''">
-                and a.create_time &gt;=#{query.createStartTime}
-            </if>
-            <if test="query.createEndTime != null and query.createEndTime != ''">
-                and a.create_time &lt;=#{query.createEndTime}
-            </if>
-            <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
-                and b.city_code LIKE CONCAT(#{query.loadAddressCode}
-                                           , '%')
-            </if>
-            <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
-                and c.city_code LIKE CONCAT(#{query.unloadAddressCode}
-                                           , '%')
-            </if>
-            <if test="query.billingMode != null and query.billingMode != ''">
-                and a.billing_mode =#{query.billingMode}
-            </if>
-        </where>
-        ORDER BY a.create_time DESC
+                            or a.l_order_no like concat('%', #{query.keywords}, '%')
+                            or d.firm_name like concat('%', #{query.keywords}, '%')
+                            or e.firm_name like concat('%', #{query.keywords}, '%')
+                            or g.goods_name like concat('%', #{query.keywords}, '%')
+                        )
+                    </if>
+                    <if test="orderList != null and orderList.size() > 0">
+                        and a.status in
+                        <foreach collection="orderList" item="status" open="(" close=")" separator=",">
+                            #{status}
+                        </foreach>
+                    </if>
+                    <if test="idsList != null and idsList.size() > 0">
+                        and a.id in
+                        <foreach collection="idsList" close=")" open="(" separator="," item="item">
+                            #{item}
+                        </foreach>
+                    </if>
+                    <if test="query.endBeginDateTime != null and query.endBeginDateTime != ''">
+                        and DATE ( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
+                    </if>
+                    <if test="query.endOverDateTime != null and query.endOverDateTime != ''">
+                        and DATE ( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
+                    </if>
+                    <if test="query.startBeginDateTime != null and query.startBeginDateTime != ''">
+                        and DATE ( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
+                    </if>
+                    <if test="query.startOverDateTime != null and query.startOverDateTime != ''">
+                        and DATE ( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
+                    </if>
+                    <if test="query.createStartTime != null and query.createStartTime != ''">
+                        and a.create_time &gt;=#{query.createStartTime}
+                    </if>
+                    <if test="query.createEndTime != null and query.createEndTime != ''">
+                        and a.create_time &lt;=#{query.createEndTime}
+                    </if>
+                    <if test="(query.loadAddressCode != null and query.loadAddressCode != '') or (query.unloadAddressCode != null and query.unloadAddressCode != '')">
+                        and a.id in (
+                        SELECT DISTINCT l_order_id from kwt_logistics_order_address where del_flag = 0
+                        <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
+                            and address_type = 1
+                            and left(city_code, #{query.loadAddressLevel, jdbcType=INTEGER}) = left( #{query.loadAddressCode, jdbcType=INTEGER}, #{query.loadAddressLevel, jdbcType=INTEGER} )
+                        </if>
+                        <if test="unloadAddressCode != null and unloadAddressCode != ''">
+                            and address_type = 2
+                            and left(city_code, #{query.unloadAddressLevel, jdbcType=INTEGER}) = left( #{query.unloadAddressCode, jdbcType=INTEGER}, #{query.unloadAddressLevel, jdbcType=INTEGER} )
+                        </if>
+                        )
+                    </if>
+                    <if test="query.billingMode != null and query.billingMode != ''">
+                        and a.billing_mode =#{query.billingMode}
+                    </if>
+                </where>
+                ORDER BY a.create_time DESC
             ) tab
         <where>
             tab.delFlag = 0
@@ -2569,36 +2506,29 @@
             ))
         </where>
     </select>
+
     <select id="selectLogisticsOrderListByConsign" resultType="com.sckw.transport.model.vo.AcceptCarriageOrderVO">
         SELECT
-<!--        <include refid="New_Query_Column_List">-->
-<!--        </include>-->
         <include refid="New_Query_Column_List_v42">
         </include>
         FROM (
             SELECT
             <include refid="Query_Column_List_Cogsign">
             </include>
-            FROM kwt_logistics_order a
-                     LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
-                AND b.address_type = 1 AND b.del_flag = 0
-                     LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
-                AND c.address_type = 2 AND c.del_flag = 0
-                     LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
-                AND d.unit_type = 1 AND d.del_flag = 0
-                     LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
-                AND e.unit_type = 2
-                     LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
-                     LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
+                FROM kwt_logistics_order a
+                LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id AND d.unit_type = 1 AND d.del_flag = 0
+                LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id AND e.unit_type = 2
+                LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
+                LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
             <where>
                 a.del_flag = 0
                 <if test="query.keywords != null and query.keywords != ''">
                     and (
-                                a.t_order_no like concat('%', #{query.keywords}, '%')
-                            or a.l_order_no like concat('%', #{query.keywords}, '%')
-                            or d.firm_name like concat('%', #{query.keywords}, '%')
-                            or e.firm_name like concat('%', #{query.keywords}, '%')
-                            or g.goods_name like concat('%', #{query.keywords}, '%'))
+                        a.t_order_no like concat('%', #{query.keywords}, '%')
+                        or a.l_order_no like concat('%', #{query.keywords}, '%')
+                        or d.firm_name like concat('%', #{query.keywords}, '%')
+                        or e.firm_name like concat('%', #{query.keywords}, '%')
+                        or g.goods_name like concat('%', #{query.keywords}, '%'))
                 </if>
                 <if test="orderList != null and orderList.size() > 0">
                     and a.status in
@@ -2630,14 +2560,18 @@
                 <if test="query.createEndTime != null and query.createEndTime != ''">
                     and a.create_time &lt;=#{query.createEndTime}
                 </if>
-                <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
-                    <!--                and b.city_code = #{query.loadAddressCode}-->
-                    and b.city_code LIKE CONCAT(#{query.loadAddressCode}
-                                               , '%')
-                </if>
-                <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
-                    and c.city_code LIKE CONCAT(#{query.unloadAddressCode}
-                                               , '%')
+                <if test="(query.loadAddressCode != null and query.loadAddressCode != '') or (query.unloadAddressCode != null and query.unloadAddressCode != '')">
+                    and a.id in (
+                    SELECT DISTINCT l_order_id from kwt_logistics_order_address where del_flag = 0
+                    <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
+                        and address_type = 1
+                        and left(city_code, #{query.loadAddressLevel, jdbcType=INTEGER}) = left( #{query.loadAddressCode, jdbcType=INTEGER}, #{query.loadAddressLevel, jdbcType=INTEGER} )
+                    </if>
+                    <if test="unloadAddressCode != null and unloadAddressCode != ''">
+                        and address_type = 2
+                        and left(city_code, #{query.unloadAddressLevel, jdbcType=INTEGER}) = left( #{query.unloadAddressCode, jdbcType=INTEGER}, #{query.unloadAddressLevel, jdbcType=INTEGER} )
+                    </if>
+                    )
                 </if>
                 <if test="query.billingMode != null and query.billingMode != ''">
                     and a.billing_mode =#{query.billingMode}
@@ -2672,195 +2606,201 @@
     </select>
 
     <select id="countLogisticsOrderListByConsignStatus" resultType="com.sckw.mongo.model.TableTops">
-        select status AS value ,
-        COUNT(status) AS total FROM (
+        select
+        status AS value ,
+        COUNT(status) AS total
+        FROM (
             SELECT
-        <include refid="Query_Column_List_Cogsign">
-        </include>
-        FROM
-            kwt_logistics_order a
-            LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
-            AND b.address_type = 1 AND b.del_flag = 0
-            LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
-            AND c.address_type = 2 AND c.del_flag = 0
-            LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
-            AND d.unit_type = 1 AND d.del_flag = 0
-            LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
-            AND e.unit_type = 2
-            LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
-            LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
-        <where>
-            a.del_flag = 0
-            <if test="query.keywords != null and query.keywords != ''">
-                and (
-                    a.t_order_no like concat('%', #{query.keywords}, '%')
-                    or a.l_order_no like concat('%', #{query.keywords}, '%')
-                    or d.firm_name like concat('%', #{query.keywords}, '%')
-                    or e.firm_name like concat('%', #{query.keywords}, '%')
-                    or g.goods_name like concat('%', #{query.keywords}, '%'))
-            </if>
-            <if test="orderList != null and orderList.size() > 0">
-                and a.status in
-                <foreach collection="orderList" item="status" open="(" close=")" separator=",">
-                    #{status}
-                </foreach>
-            </if>
-            <if test="idsList != null and idsList.size() > 0">
-                and a.id in
-                <foreach collection="idsList" close=")" open="(" separator="," item="item">
-                    #{item}
-                </foreach>
-            </if>
-            <if test="query.endBeginDateTime != null and query.endBeginDateTime != ''">
-                and DATE ( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
-            </if>
-            <if test="query.endOverDateTime != null and query.endOverDateTime != ''">
-                and DATE ( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
-            </if>
-            <if test="query.startBeginDateTime != null and query.startBeginDateTime != ''">
-                and DATE ( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
-            </if>
-            <if test="query.startOverDateTime != null and query.startOverDateTime != ''">
-                and DATE ( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
-            </if>
-            <if test="query.createStartTime != null and query.createStartTime != ''">
-                and a.create_time &gt;=#{query.createStartTime}
-            </if>
-            <if test="query.createEndTime != null and query.createEndTime != ''">
-                and a.create_time &lt;=#{query.createEndTime}
-            </if>
-            <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
-                <!--                and b.city_code = #{query.loadAddressCode}-->
-                and b.city_code LIKE CONCAT(#{query.loadAddressCode}, '%')
-            </if>
-            <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
-                <!--                and c.city_code = #{query.unloadAddressCode}-->
-                and c.city_code LIKE CONCAT(#{query.unloadAddressCode}, '%')
-            </if>
-            <if test="query.billingMode != null and query.billingMode != ''">
-                and a.billing_mode =#{query.billingMode}
-            </if>
-        </where>
-        ORDER BY a.create_time DESC
+                <include refid="Query_Column_List_Cogsign">
+                </include>
+                FROM
+                    kwt_logistics_order a
+                    LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id AND d.unit_type = 1 AND d.del_flag = 0
+                    LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id AND e.unit_type = 2
+                    LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
+                    LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
+                <where>
+                    a.del_flag = 0
+                    <if test="query.keywords != null and query.keywords != ''">
+                        and (
+                            a.t_order_no like concat('%', #{query.keywords}, '%')
+                            or a.l_order_no like concat('%', #{query.keywords}, '%')
+                            or d.firm_name like concat('%', #{query.keywords}, '%')
+                            or e.firm_name like concat('%', #{query.keywords}, '%')
+                            or g.goods_name like concat('%', #{query.keywords}, '%'))
+                    </if>
+                    <if test="orderList != null and orderList.size() > 0">
+                        and a.status in
+                        <foreach collection="orderList" item="status" open="(" close=")" separator=",">
+                            #{status}
+                        </foreach>
+                    </if>
+                    <if test="idsList != null and idsList.size() > 0">
+                        and a.id in
+                        <foreach collection="idsList" close=")" open="(" separator="," item="item">
+                            #{item}
+                        </foreach>
+                    </if>
+                    <if test="query.endBeginDateTime != null and query.endBeginDateTime != ''">
+                        and DATE ( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
+                    </if>
+                    <if test="query.endOverDateTime != null and query.endOverDateTime != ''">
+                        and DATE ( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
+                    </if>
+                    <if test="query.startBeginDateTime != null and query.startBeginDateTime != ''">
+                        and DATE ( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
+                    </if>
+                    <if test="query.startOverDateTime != null and query.startOverDateTime != ''">
+                        and DATE ( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
+                    </if>
+                    <if test="query.createStartTime != null and query.createStartTime != ''">
+                        and a.create_time &gt;=#{query.createStartTime}
+                    </if>
+                    <if test="query.createEndTime != null and query.createEndTime != ''">
+                        and a.create_time &lt;=#{query.createEndTime}
+                    </if>
+                    <if test="(query.loadAddressCode != null and query.loadAddressCode != '') or (query.unloadAddressCode != null and query.unloadAddressCode != '')">
+                        and a.id in (
+                        SELECT DISTINCT l_order_id from kwt_logistics_order_address where del_flag = 0
+                        <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
+                            and address_type = 1
+                            and left(city_code, #{query.loadAddressLevel, jdbcType=INTEGER}) = left( #{query.loadAddressCode, jdbcType=INTEGER}, #{query.loadAddressLevel, jdbcType=INTEGER} )
+                        </if>
+                        <if test="unloadAddressCode != null and unloadAddressCode != ''">
+                            and address_type = 2
+                            and left(city_code, #{query.unloadAddressLevel, jdbcType=INTEGER}) = left( #{query.unloadAddressCode, jdbcType=INTEGER}, #{query.unloadAddressLevel, jdbcType=INTEGER} )
+                        </if>
+                        )
+                    </if>
+                    <if test="query.billingMode != null and query.billingMode != ''">
+                        and a.billing_mode =#{query.billingMode}
+                    </if>
+                </where>
+                ORDER BY a.create_time DESC
             ) tab
         <where>
             tab.delFlag = 0
             AND ((
                 tab.createType = 1
-            and tab.entId = #{entId}
-            <if test="userIds != null and userIds.size() > 0">
-                AND tab.createBy IN
-                <foreach collection="userIds" open="(" close=")" item="item" separator=",">
-                    #{item}
-                </foreach>
-            </if>
-            )
+                and tab.entId = #{entId}
+                <if test="userIds != null and userIds.size() > 0">
+                    AND tab.createBy IN
+                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">
+                        #{item}
+                    </foreach>
+                </if>
+                )
             OR (
                 tab.consignTopEntId = #{entId}
-            <if test="contactsIds != null and contactsIds.size() > 0">
-                AND tab.consignContactsId IN
-                <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
-                    #{item}
-                </foreach>
-            </if>
+                <if test="contactsIds != null and contactsIds.size() > 0">
+                    AND tab.consignContactsId IN
+                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
+                        #{item}
+                    </foreach>
+                </if>
             ))
         </where>
         group by status
     </select>
+
     <select id="countLogisticsOrderListByAcceptCarriageStatus" resultType="com.sckw.mongo.model.TableTops">
-        SELECT status as value,
-        COUNT( status ) AS total FROM (
+        SELECT
+        status as value,
+        COUNT( status ) AS total
+        FROM (
             SELECT
-        <include refid="Query_Column_List_Accept_Carriage">
-        </include>
-        FROM
-            kwt_logistics_order a
-            LEFT JOIN kwt_logistics_order_address b ON a.id = b.l_order_id
-            AND b.address_type = 1 AND b.del_flag = 0
-            LEFT JOIN kwt_logistics_order_address c ON a.id = c.l_order_id
-            AND c.address_type = 2 AND c.del_flag = 0
-            LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
-            AND d.unit_type = 1 AND d.del_flag = 0
-            LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
-            AND e.unit_type = 2
-            LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
-            LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
-        <where>
-            a.del_flag = 0
-            <if test="query.keywords != null and query.keywords != ''">
-                and (
-                    a.t_order_no like concat('%', #{query.keywords}, '%')
-                    or a.l_order_no like concat('%', #{query.keywords}, '%')
-                    or d.firm_name like concat('%', #{query.keywords}, '%')
-                    or e.firm_name like concat('%', #{query.keywords}, '%')
-                    or g.goods_name like concat('%', #{query.keywords}, '%'))
-            </if>
-            <if test="orderList != null and orderList.size() > 0">
-                and a.status in
-                <foreach collection="orderList" item="status" open="(" close=")" separator=",">
-                    #{status}
-                </foreach>
-            </if>
-            <if test="idsList != null and idsList.size() > 0">
-                and a.id in
-                <foreach collection="idsList" close=")" open="(" separator="," item="item">
-                    #{item}
-                </foreach>
-            </if>
-            <if test="query.endBeginDateTime != null and query.endBeginDateTime != ''">
-                and DATE ( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
-            </if>
-            <if test="query.endOverDateTime != null and query.endOverDateTime != ''">
-                and DATE ( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
-            </if>
-            <if test="query.startBeginDateTime != null and query.startBeginDateTime != ''">
-                and DATE ( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
-            </if>
-            <if test="query.startOverDateTime != null and query.startOverDateTime != ''">
-                and DATE ( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
-            </if>
-            <if test="query.createStartTime != null and query.createStartTime != ''">
-                and a.create_time &gt;=#{query.createStartTime}
-            </if>
-            <if test="query.createEndTime != null and query.createEndTime != ''">
-                and a.create_time &lt;=#{query.createEndTime}
-            </if>
-            <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
-                and b.city_code LIKE CONCAT(#{query.loadAddressCode}, '%')
-            </if>
-            <if test="query.unloadAddressCode != null and query.unloadAddressCode != ''">
-                and c.city_code LIKE CONCAT(#{query.unloadAddressCode}, '%')
-            </if>
-            <if test="query.billingMode != null and query.billingMode != ''">
-                and a.billing_mode =#{query.billingMode}
-            </if>
-        </where>
-        ORDER BY a.create_time DESC
+                <include refid="Query_Column_List_Accept_Carriage">
+                </include>
+                FROM
+                    kwt_logistics_order a
+                    LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id AND d.unit_type = 1 AND d.del_flag = 0
+                    LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id AND e.unit_type = 2
+                    LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
+                    LEFT JOIN kwt_logistics_order_contract f ON a.id = f.l_order_id AND f.del_flag = 0
+                <where>
+                    a.del_flag = 0
+                    <if test="query.keywords != null and query.keywords != ''">
+                        and (
+                            a.t_order_no like concat('%', #{query.keywords}, '%')
+                            or a.l_order_no like concat('%', #{query.keywords}, '%')
+                            or d.firm_name like concat('%', #{query.keywords}, '%')
+                            or e.firm_name like concat('%', #{query.keywords}, '%')
+                            or g.goods_name like concat('%', #{query.keywords}, '%'))
+                    </if>
+                    <if test="orderList != null and orderList.size() > 0">
+                        and a.status in
+                        <foreach collection="orderList" item="status" open="(" close=")" separator=",">
+                            #{status}
+                        </foreach>
+                    </if>
+                    <if test="idsList != null and idsList.size() > 0">
+                        and a.id in
+                        <foreach collection="idsList" close=")" open="(" separator="," item="item">
+                            #{item}
+                        </foreach>
+                    </if>
+                    <if test="query.endBeginDateTime != null and query.endBeginDateTime != ''">
+                        and DATE ( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
+                    </if>
+                    <if test="query.endOverDateTime != null and query.endOverDateTime != ''">
+                        and DATE ( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
+                    </if>
+                    <if test="query.startBeginDateTime != null and query.startBeginDateTime != ''">
+                        and DATE ( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
+                    </if>
+                    <if test="query.startOverDateTime != null and query.startOverDateTime != ''">
+                        and DATE ( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
+                    </if>
+                    <if test="query.createStartTime != null and query.createStartTime != ''">
+                        and a.create_time &gt;=#{query.createStartTime}
+                    </if>
+                    <if test="query.createEndTime != null and query.createEndTime != ''">
+                        and a.create_time &lt;=#{query.createEndTime}
+                    </if>
+                    <if test="(query.loadAddressCode != null and query.loadAddressCode != '') or (query.unloadAddressCode != null and query.unloadAddressCode != '')">
+                        and a.id in (
+                        SELECT DISTINCT l_order_id from kwt_logistics_order_address where del_flag = 0
+                        <if test="query.loadAddressCode != null and query.loadAddressCode != ''">
+                            and address_type = 1
+                            and left(city_code, #{query.loadAddressLevel, jdbcType=INTEGER}) = left( #{query.loadAddressCode, jdbcType=INTEGER}, #{query.loadAddressLevel, jdbcType=INTEGER} )
+                        </if>
+                        <if test="unloadAddressCode != null and unloadAddressCode != ''">
+                            and address_type = 2
+                            and left(city_code, #{query.unloadAddressLevel, jdbcType=INTEGER}) = left( #{query.unloadAddressCode, jdbcType=INTEGER}, #{query.unloadAddressLevel, jdbcType=INTEGER} )
+                        </if>
+                        )
+                    </if>
+                    <if test="query.billingMode != null and query.billingMode != ''">
+                        and a.billing_mode =#{query.billingMode}
+                    </if>
+                </where>
+                ORDER BY a.create_time DESC
             ) tab
         <where>
             tab.delFlag = 0
             AND ((
                 tab.createType = 1
-            and tab.entId = #{entId}
-            <if test="userIds != null and userIds.size() > 0">
-                AND tab.createBy IN
-                <foreach collection="userIds" open="(" close=")" item="item" separator=",">
-                    #{item}
-                </foreach>
-            </if>
+                and tab.entId = #{entId}
+                <if test="userIds != null and userIds.size() > 0">
+                    AND tab.createBy IN
+                    <foreach collection="userIds" open="(" close=")" item="item" separator=",">
+                        #{item}
+                    </foreach>
+                </if>
             )
             OR (
                 tab.carrierTopEntId = #{entId}
-            <if test="contactsIds != null and contactsIds.size() > 0">
-                AND tab.carrierContactsId IN
-                <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
-                    #{item}
-                </foreach>
-            </if>
+                <if test="contactsIds != null and contactsIds.size() > 0">
+                    AND tab.carrierContactsId IN
+                    <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
+                        #{item}
+                    </foreach>
+                </if>
             ))
         </where>
         group by status
     </select>
+
     <select id="selectConsignLogisticsOrderListByConsign" resultType="com.sckw.transport.model.vo.ConsignOrderVO">
         SELECT
         <include refid="New_Query_Column_List">

+ 9 - 9
sckw-modules/sckw-transport/src/main/resources/mapper/KwtWaybillOrderV1Mapper.xml

@@ -20,13 +20,13 @@
         </if>
         <if test="(loadCityCode != null and loadCityCode != '') or (unloadCityCode != null and unloadCityCode != '')">
             and wo.id in (
-            SELECT w_order_id from kwt_waybill_order_address where del_flag = 0
+            SELECT DISTINCT w_order_id from kwt_waybill_order_address where del_flag = 0
             <if test="loadCityCode != null and loadCityCode != ''">
-                address_type = 1
+                and address_type = 1
                 and left(city_code, #{loadCityCodeLevel, jdbcType=INTEGER}) = left( #{loadCityCode, jdbcType=INTEGER}, #{loadCityCodeLevel, jdbcType=INTEGER} )
             </if>
             <if test="unloadCityCode != null and unloadCityCode != ''">
-                address_type = 2
+                and address_type = 2
                 and left(city_code, #{loadCityCodeLevel, jdbcType=INTEGER}) = left( #{unloadCityCode, jdbcType=INTEGER}, #{loadCityCodeLevel, jdbcType=INTEGER} )
             </if>
             )
@@ -34,7 +34,7 @@
         <if test="(startLoadTime != null and startLoadTime != '') or (endLoadTime != null and endLoadTime != '')
                or (startUnloadTime != null and startUnloadTime != '') or (endUnloadTime != null and endUnloadTime != '')">
             and wo.id in (
-                SELECT w_order_id from kwt_waybill_order_subtask where del_flag = 0
+                SELECT DISTINCT w_order_id from kwt_waybill_order_subtask where del_flag = 0
             <if test="startLoadTime != null and startLoadTime != ''">
                     and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
             </if>
@@ -87,21 +87,21 @@
         </if>
         <if test="(loadCityCode != null and loadCityCode != '') or (unloadCityCode != null and unloadCityCode != '')">
             and wo.id in (
-            SELECT w_order_id from kwt_waybill_order_address where del_flag = 0
+            SELECT DISTINCT w_order_id from kwt_waybill_order_address where del_flag = 0
             <if test="loadCityCode != null and loadCityCode != ''">
-                address_type = 1
+                and address_type = 1
                 and left(city_code, #{loadCityCodeLevel, jdbcType=INTEGER}) = left( #{loadCityCode, jdbcType=INTEGER}, #{loadCityCodeLevel, jdbcType=INTEGER} )
             </if>
             <if test="unloadCityCode != null and unloadCityCode != ''">
-                address_type = 2
-                and left(city_code, #{loadCityCodeLevel, jdbcType=INTEGER}) = left( #{unloadCityCode, jdbcType=INTEGER}, #{loadCityCodeLevel, jdbcType=INTEGER} )
+                and address_type = 2
+                and left(city_code, #{unloadCityCodeLevel, jdbcType=INTEGER}) = left( #{unloadCityCode, jdbcType=INTEGER}, #{unloadCityCodeLevel, jdbcType=INTEGER} )
             </if>
             )
         </if>
         <if test="(startLoadTime != null and startLoadTime != '') or (endLoadTime != null and endLoadTime != '')
                or (startUnloadTime != null and startUnloadTime != '') or (endUnloadTime != null and endUnloadTime != '')">
             and wo.id in (
-            SELECT w_order_id from kwt_waybill_order_subtask where del_flag = 0
+            SELECT DISTINCT w_order_id from kwt_waybill_order_subtask where del_flag = 0
             <if test="startLoadTime != null and startLoadTime != ''">
                 and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
             </if>