Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/dev' into dev

xucaiqin 2 anni fa
parent
commit
4bfc8ff61f
31 ha cambiato i file con 1444 aggiunte e 176 eliminazioni
  1. 9 1
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/CarWaybillEnum.java
  2. 124 1
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/DateUtils.java
  3. 344 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/request/HttpClientUtil.java
  4. 5 0
      sckw-common/sckw-common-mongo/src/main/java/com/sckw/mongo/model/TableTops.java
  5. 2 15
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfTruckController.java
  6. 15 1
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfTruckMapper.java
  7. 49 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfTruckGpsVo.java
  8. 38 0
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfTruckMonitorVo.java
  9. 0 1
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfFleetService.java
  10. 160 8
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckService.java
  11. 16 0
      sckw-modules/sckw-fleet/src/main/resources/mapper/KwfTruckMapper.xml
  12. 10 0
      sckw-modules/sckw-message/src/main/java/com/sckw/message/dao/KwmMessageMapper.java
  13. 5 0
      sckw-modules/sckw-message/src/main/java/com/sckw/message/model/dto/SelectMessagesDTO.java
  14. 6 0
      sckw-modules/sckw-message/src/main/java/com/sckw/message/model/vo/req/SelectMessagesReqVO.java
  15. 3 0
      sckw-modules/sckw-message/src/main/java/com/sckw/message/model/vo/req/StatisticsMessagesReqVO.java
  16. 12 0
      sckw-modules/sckw-message/src/main/java/com/sckw/message/service/KwmMessageService.java
  17. 21 11
      sckw-modules/sckw-message/src/main/java/com/sckw/message/service/MessageService.java
  18. 62 27
      sckw-modules/sckw-message/src/main/resources/mapper/KwmMessageMapper.xml
  19. 7 7
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderService.java
  20. 120 42
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwTransportService.java
  21. 11 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/KwtWaybillOrderController.java
  22. 13 6
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java
  23. 16 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/LogisticsOrderDTO.java
  24. 83 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/WaybillOrderTicketV1Dto.java
  25. 4 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/AcceptCarriageOrderVO.java
  26. 17 7
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/AcceptCarriageOrderService.java
  27. 16 7
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java
  28. 74 7
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtWaybillOrderService.java
  29. 25 5
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/LogisticsConsignmentService.java
  30. 56 14
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java
  31. 121 16
      sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

+ 9 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/CarWaybillEnum.java

@@ -52,7 +52,7 @@ public enum CarWaybillEnum {
     /**
     /**
      * 已撤销
      * 已撤销
      */
      */
-    REVOKED(11, "revoked", "11", "已撤销"),
+    REVOKED(11, "revoked", "11", "单趟撤回"),
     /**
     /**
      * 已核单-不通过
      * 已核单-不通过
      */
      */
@@ -122,6 +122,14 @@ public enum CarWaybillEnum {
         return codes;
         return codes;
     }
     }
 
 
+    public static List<String> getStringCodes() {
+        List<String> codes = new ArrayList<>();
+        for (CarWaybillEnum waybillEnum : CarWaybillEnum.values()) {
+            codes.add(waybillEnum.getStatus());
+        }
+        return codes;
+    }
+
     /**
     /**
      * @param code 状态码
      * @param code 状态码
      * @desc 是否可以变更司机/车辆
      * @desc 是否可以变更司机/车辆

+ 124 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/DateUtils.java

@@ -106,6 +106,25 @@ public class DateUtils extends DateUtil {
     }
     }
 
 
 
 
+    /**
+     * 日期格式化 日期格式为:yyyy-MM-dd
+     *
+     * @param date    日期
+     * @return 返回yyMMdd格式日期
+     */
+    public static Date formatDate(String date) {
+        try {
+            if (date != null) {
+                SimpleDateFormat df = new SimpleDateFormat(DATE_TIME_PATTERN);
+                return df.parse(date);
+            }
+        } catch (Exception e){
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+
     /**
     /**
      * 日期格式化 日期格式为:yyyy-MM-dd
      * 日期格式化 日期格式为:yyyy-MM-dd
      *
      *
@@ -365,9 +384,113 @@ public class DateUtils extends DateUtil {
         return Duration.between(now, nextDay).getSeconds();
         return Duration.between(now, nextDay).getSeconds();
     }
     }
 
 
+    /**
+     * 对日期的【秒】进行加/减
+     *
+     * @param date    日期
+     * @param seconds 秒数,负数为减
+     * @return 加/减几秒后的日期
+     */
+    public static Date addDateSeconds(Date date, int seconds) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.MINUTE, seconds);
+        return cal.getTime();
+    }
+
+    /**
+     * 对日期的【分钟】进行加/减
+     * @param date    日期
+     * @param minutes 分钟数,负数为减
+     * @return 加/减几分钟后的日期
+     */
+    public static Date addDateMinutes(Date date, int minutes) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.MINUTE, minutes);
+        return cal.getTime();
+    }
 
 
-    public static void main(String[] ager) throws InterruptedException {
+    /**
+     * 对日期的【小时】进行加/减
+     * @param date  日期
+     * @param hours 小时数,负数为减
+     * @return 加/减几小时后的日期
+     */
+    public static Date addDateHours(Date date, int hours) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.HOUR, hours);
+        return cal.getTime();
+    }
 
 
+    /**
+     * 对日期的【天】进行加/减
+     * @param date 日期
+     * @param days 天数,负数为减
+     * @return 加/减几天后的日期
+     */
+    public static Date addDateDays(Date date, int days) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.DATE, days);
+        return cal.getTime();
+    }
+
+    /**
+     * 对日期的【周】进行加/减
+     * @param date  日期
+     * @param weeks 周数,负数为减
+     * @return 加/减几周后的日期
+     */
+    public static Date addDateWeeks(Date date, int weeks) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.DATE, weeks * 7);
+        return cal.getTime();
+    }
+
+    /**
+     * 对日期的【月】进行加/减
+     * @param date   日期
+     * @param months 月数,负数为减
+     * @return 加/减几月后的日期
+     */
+    public static Date addDateMonths(Date date, int months) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.MONTH, months);
+        return cal.getTime();
+    }
+
+    /**
+     * 对日期的【年】进行加/减
+     * @param date  日期
+     * @param years 年数,负数为减
+     * @return 加/减几年后的日期
+     */
+    public static Date addDateYears(Date date, int years) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.YEAR, years);
+        return cal.getTime();
+    }
+
+    /**
+     * 时间比较大小
+     * @param date1  日期
+     * @param date2 年数,负数为减
+     * @return -1 date1小于date2、0 date1等于date2、1 date1大于date2
+     */
+    public static int compareTo(Date date1, Date date2) {
+        return date1.compareTo(date2);
+    }
+
+    public static void main(String[] ager) throws InterruptedException {
+        Date newTime = new Date();
+        Date time = addDateMinutes(new Date(), 10);
+        int result = newTime.compareTo(time);
+        System.out.println(result);
     }
     }
 
 
     /**
     /**

+ 344 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/request/HttpClientUtil.java

@@ -0,0 +1,344 @@
+package com.sckw.core.web.request;
+
+import com.alibaba.fastjson.JSON;
+import com.sckw.core.model.constant.Global;
+import com.sckw.core.utils.StringUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.conn.HttpHostConnectException;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @desc http请求工具类
+ * @Author dengyinghui
+ * @Date 2018年02月03日
+ */
+@Slf4j
+public class HttpClientUtil {
+
+    private static final String UTF_8 = "UTF-8";
+
+    /**
+     * POST请求
+     *
+     * @param url 请求地址
+     * @return 返回结果
+     * @Date 2018年02月03日
+     */
+    public static String post(String url) throws ClientProtocolException, IOException {
+        return post(url, Global.EMPTY_STRING);
+    }
+
+    /**
+     * POST请求
+     * @param url    请求地址
+     * @param params 请求参数
+     * @return 返回结果
+     * @Date 2018年02月03日
+     */
+    public static String post(String url, Map<String, Object> params) throws ClientProtocolException, IOException {
+        HttpPost httpPost = new HttpPost(url);
+        List<NameValuePair> pairs = null;
+        if (params != null && params.size() > 0) {
+            pairs = covertParams2Nvps(params);
+            try {
+                httpPost.setEntity(new UrlEncodedFormEntity(pairs, UTF_8));
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return handlerRequest(httpPost);
+    }
+
+    /**
+     * POST请求
+     * @param url    请求地址
+     * @param body 请求参数
+     * @param headsMap 请求参数
+     * @return 返回结果
+     * @Date 2018年02月03日
+     */
+    public static String postBody(String url, String body, Map<String, Object> headsMap) {
+        int successCode = 200;
+        log.debug("start:");
+        // 实例化httpClient
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        // 实例化post方法
+        HttpPost httpPost = new HttpPost(url);
+        //头
+        httpPost.setHeader("Content-Type", "application/json");
+        if (headsMap != null && !headsMap.isEmpty()) {
+            for (String key : headsMap.keySet()) {
+                httpPost.setHeader(key, (String) headsMap.get(key));
+            }
+        }
+        log.debug("initheader");
+        // 结果
+        CloseableHttpResponse response = null;
+        String content = null;
+        try {
+            log.debug("initbody");
+            // 将参数给post方法
+            if (body != null) {
+                StringEntity stringEntity = new StringEntity(body, "UTF-8");
+                httpPost.setEntity(stringEntity);
+            }
+            log.info(httpPost.toString());
+            // 执行post方法
+            response = httpclient.execute(httpPost);
+            log.info(response.getEntity().toString());
+            try {
+                content = EntityUtils.toString(response.getEntity(), "UTF-8");
+            } catch (Exception e) {
+                e.printStackTrace();
+                log.error("HttpClientUtil.postBody:", e.getMessage());
+            } finally {
+                response.close();
+            }
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return content;
+    }
+
+    /**
+     * POST请求
+     * @param url  请求地址
+     * @param data 字符参数参数
+     * @return 返回结果
+     * @Date 2018年02月03日
+     */
+    public static String post(String url, String data) {
+        HttpPost httpPost = new HttpPost(url);
+        httpPost.setHeader("Content-Type", "application/json");
+        try {
+            if (!StringUtils.validatorEmpty(data)) {
+                httpPost.setEntity(new StringEntity(data, UTF_8));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        CloseableHttpResponse response = null;
+        String content = null;
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        try {
+            response = httpclient.execute(httpPost);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        try {
+            try {
+                content = EntityUtils.toString(response.getEntity(), "UTF-8");
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        } finally {
+            try {
+                response.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return content;
+    }
+
+
+    /**
+     * GET请求
+     * @param url 请求地址
+     * @return 返回结果
+     * @Date 2018年02月03日
+     */
+    public static String get(String url) throws ClientProtocolException, IOException {
+        return get(url, null);
+    }
+
+    /**
+     * GET请求
+     * @param url    请求地址
+     * @param params 请求参数
+     * @return 返回结果
+     * @Date 2018年02月03日
+     */
+    public static String get(String url, Map<String, Object> params) throws ClientProtocolException, HttpHostConnectException, IOException {
+        URIBuilder ub = new URIBuilder();
+        ub.setPath(url);
+        if (params != null && params.size() > 0) {
+            List<NameValuePair> pairs = covertParams2Nvps(params);
+            ub.setParameters(pairs);
+        }
+        HttpGet httpGet = null;
+        try {
+            httpGet = new HttpGet(ub.build());
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return handlerRequest(httpGet);
+    }
+
+    /**
+     * 封装请求参数
+     * @param params 请求参数
+     * @return 返回结果
+     * @Date 2018年02月03日
+     */
+    private static List<NameValuePair> covertParams2Nvps(Map<String, Object> params) {
+        List<NameValuePair> pairs = new ArrayList<NameValuePair>();
+        for (Map.Entry<String, Object> param : params.entrySet()) {
+            pairs.add(new BasicNameValuePair(param.getKey(), String.valueOf(param.getValue())));
+        }
+        return pairs;
+    }
+
+    /**
+     * 处理Http请求
+     * @param httpRequestBase
+     * @return 返回结果
+     * @Date 2018年02月03日
+     */
+    private static String handlerRequest(HttpRequestBase httpRequestBase) throws ClientProtocolException, IOException {
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = httpClient.execute(httpRequestBase);
+        HttpEntity entity = response.getEntity();
+        if (entity != null) {
+            String result = EntityUtils.toString(entity, UTF_8);
+            response.close();
+            return result;
+        }
+        return null;
+    }
+
+    public static String postBody(String url, String body) {
+        int successCode = 200;
+        // 实例化httpClient
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        // 实例化post方法
+        HttpPost httpPost = new HttpPost(url);
+        // 结果
+        CloseableHttpResponse response = null;
+        String content = null;
+        httpPost.setHeader("Content-Type", "application/json");
+        httpPost.setHeader("token", null);
+        httpPost.setHeader("type", "pc");
+        httpPost.setHeader("version", "5");
+        try {
+            // 将参数给post方法
+            if (body != null) {
+                StringEntity stringEntity = new StringEntity(body, "UTF-8");
+                httpPost.setEntity(stringEntity);
+            }
+            // 执行post方法
+            response = httpclient.execute(httpPost);
+            try {
+                content = EntityUtils.toString(response.getEntity(), "UTF-8");
+            } catch (Exception e) {
+                e.printStackTrace();
+                log.error("HttpClientUtil.postBody:", e.getMessage());
+            } finally {
+                response.close();
+            }
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return content;
+    }
+
+    /**
+     * GET请求
+     * @param url    请求地址
+     * @return 返回结果
+     * @Date 2018年02月03日
+     */
+    public static String getBody(String url) {
+        // 实例化httpClient
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        // 实例化post方法
+        //HttpPost httpPost = new HttpPost(url);
+        HttpGet httpGet = new HttpGet(url);
+        // 结果
+        CloseableHttpResponse response = null;
+        String content = null;
+        httpGet.setHeader("Content-Type", "application/json");
+        try {
+            // 执行post方法
+            int successCode = 200;
+            response = httpclient.execute(httpGet);
+            try {
+                content = EntityUtils.toString(response.getEntity(), "UTF-8");
+            } finally {
+                response.close();
+            }
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return content;
+    }
+
+    /**
+     * POST请求
+     * @param url    请求地址
+     * @param params 请求参数
+     * @return 返回结果
+     * @Date 2018年02月03日
+     */
+    public static String postByMapString(String url, Map<String, String> params) throws ClientProtocolException, IOException {
+        HttpPost httpPost = new HttpPost(url);
+        List<NameValuePair> pairs = null;
+        if (params != null && params.size() > 0) {
+            pairs = new ArrayList<>();
+            for (Map.Entry<String, String> param : params.entrySet()) {
+                pairs.add(new BasicNameValuePair(param.getKey(), param.getValue()));
+            }
+            try {
+                httpPost.setEntity(new UrlEncodedFormEntity(pairs, UTF_8));
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return handlerRequest(httpPost);
+    }
+
+
+}

+ 5 - 0
sckw-common/sckw-common-mongo/src/main/java/com/sckw/mongo/model/TableTops.java

@@ -21,4 +21,9 @@ public class TableTops {
      * 数量
      * 数量
      */
      */
     private Integer total;
     private Integer total;
+
+    /**
+     * 数量
+     */
+    private Integer sort;
 }
 }

+ 2 - 15
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/controller/KwfTruckController.java

@@ -230,26 +230,13 @@ public class KwfTruckController {
 
 
     /**
     /**
      * @param params {truckNo 車牌號}
      * @param params {truckNo 車牌號}
-     * @description 车辆查询(业务关联+归属车辆)
+     * @desc 车辆查询(业务关联+归属车辆)
      * @author zk
      * @author zk
      * @date 2023/7/26
      * @date 2023/7/26
      **/
      **/
     @PostMapping("/findTruck")
     @PostMapping("/findTruck")
     public HttpResult findTruck(@RequestBody Map<String, Object> params) {
     public HttpResult findTruck(@RequestBody Map<String, Object> params) {
-        params.put("entId", LoginUserHolder.getEntId());
-        List<KwfTruckVo> trucks = truckService.findPage(params);
-
-        List<Map<String, Object>> data = new ArrayList();
-        for (KwfTruckVo truck:trucks) {
-            int bbb = new Random().nextInt(10) / 4;
-            data.add(new HashMap<>(Global.NUMERICAL_SIXTEEN){{put("truckNo", truck.getTruckNo());
-                put("entId", truck.getEntId());
-                put("firmName", truck.getFirmName());
-                put("businessStatus", truck.getTruckNo().contains("1") ? 0 : 1);
-                put("runStatus", bbb == 0 ? 0 : bbb == 1 ? 1 : 2);}});
-        }
-
-        return HttpResult.ok(data);
+        return HttpResult.ok(truckService.findTruck(params));
     }
     }
 
 
     /**
     /**

+ 15 - 1
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfTruckMapper.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.fleet.model.KwfTruck;
 import com.sckw.fleet.model.KwfTruck;
 import com.sckw.fleet.model.vo.KwfDriverVo;
 import com.sckw.fleet.model.vo.KwfDriverVo;
 import com.sckw.fleet.model.vo.KwfTableTopCount;
 import com.sckw.fleet.model.vo.KwfTableTopCount;
+import com.sckw.fleet.model.vo.KwfTruckMonitorVo;
 import com.sckw.fleet.model.vo.KwfTruckVo;
 import com.sckw.fleet.model.vo.KwfTruckVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
@@ -49,8 +50,21 @@ public interface KwfTruckMapper extends BaseMapper<KwfTruck> {
 
 
     /**
     /**
      * 企业运力统计
      * 企业运力统计
-     * @param entIds
+     * @param entIds 企业id集
      * @return
      * @return
      */
      */
     List<Map<String, Object>> capacityStatistics(@Param("entIds") List entIds);
     List<Map<String, Object>> capacityStatistics(@Param("entIds") List entIds);
+
+    /**
+     * 查询企业车辆
+     * @param entId 企业id
+     * @return
+     */
+    List<KwfTruckMonitorVo> findTruckByEnt(@Param("entId") Long entId);
+
+    /**
+     * 查询全部车辆
+     * @return
+     */
+    List<KwfTruckMonitorVo> findTruckByAll();
 }
 }

+ 49 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfTruckGpsVo.java

@@ -0,0 +1,49 @@
+package com.sckw.fleet.model.vo;
+
+import lombok.Data;
+
+/**
+ * desc 车辆定位
+ * author zk
+ * date 2023/9/5 0005
+ */
+@Data
+public class KwfTruckGpsVo {
+
+    /**
+     *车牌号
+     */
+    private String truckNo;
+
+    /**
+     *业务状态(0空闲、1任务中)
+     */
+    private Integer businessStatus;
+
+    /**
+     *运行状态(0行驶、1停止、2离线)
+     */
+    private Integer runStatus;
+
+    /**
+     *纬度
+     */
+    private String lat;
+
+    /**
+     *经度
+     */
+    private String lng;
+
+    /**
+     *速度
+     */
+    private Double speed;
+
+    /**
+     *gps时间
+     */
+    private String gpsTime;
+
+}
+

+ 38 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/model/vo/KwfTruckMonitorVo.java

@@ -0,0 +1,38 @@
+package com.sckw.fleet.model.vo;
+
+import lombok.Data;
+
+/**
+ * desc 车辆监控
+ * author zk
+ * date 2023/9/5 0005
+ */
+@Data
+public class KwfTruckMonitorVo {
+
+    /**
+     *企业id
+     */
+    private Long entId;
+
+    /**
+     *企业名称
+     */
+    private String firmName;
+
+    /**
+     *车牌号
+     */
+    private String truckNo;
+
+    /**
+     *业务状态(0空闲、1任务中)
+     */
+    private Integer businessStatus;
+
+    /**
+     *运行状态(0行驶、1停止、2离线)
+     */
+    private Integer runStatus;
+
+}

+ 0 - 1
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfFleetService.java

@@ -184,5 +184,4 @@ public class KwfFleetService {
         result.put("truckCounts", truckCounts);
         result.put("truckCounts", truckCounts);
         return result;
         return result;
     }
     }
-
 }
 }

+ 160 - 8
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckService.java

@@ -4,17 +4,18 @@ import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelReader;
 import com.alibaba.excel.ExcelReader;
 import com.alibaba.excel.read.metadata.ReadSheet;
 import com.alibaba.excel.read.metadata.ReadSheet;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.common.enums.enums.FileEnum;
 import com.sckw.core.common.enums.enums.FileEnum;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.model.file.FileInfo;
 import com.sckw.core.model.file.FileInfo;
-import com.sckw.core.utils.BeanUtils;
-import com.sckw.core.utils.CollectionUtils;
-import com.sckw.core.utils.FileUtils;
-import com.sckw.core.utils.StringUtils;
+import com.sckw.core.utils.*;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.core.web.request.HttpClientUtil;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.easyexcel.ExcelImportListener;
 import com.sckw.excel.easyexcel.ExcelImportListener;
 import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.excel.utils.ExcelUtil;
@@ -28,15 +29,13 @@ import com.sckw.system.api.model.dto.res.SysDictResDto;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 import java.io.InputStream;
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 /**
 /**
@@ -587,6 +586,50 @@ public class KwfTruckService {
         }
         }
     }
     }
 
 
+    /**
+     * @param params {truckNo 車牌號}
+     * @desc 车辆查询(业务关联+归属车辆)
+     * @author zk
+     * @date 2023/9/5
+     **/
+    public List<KwfTruckMonitorVo> findTruck(Map<String, Object> params){
+        /**车辆查询**/
+        List<KwfTruckMonitorVo> trucks = new ArrayList<>();
+        if (LoginUserHolder.getSystemType() == SystemTypeEnum.COMPANY.getCode()) {
+            trucks = truckDao.findTruckByEnt(LoginUserHolder.getEntId());
+        }
+        if (LoginUserHolder.getSystemType() == SystemTypeEnum.MANAGE.getCode()) {
+            trucks = truckDao.findTruckByAll();
+        }
+        if (trucks == null || trucks.size() == 0) {
+            return trucks;
+        }
+
+        /**数据配置**/
+        List<Long> entIds = new ArrayList<>();
+        List<String> truckNos = new ArrayList<>();
+        for (KwfTruckMonitorVo truck:trucks) {
+            entIds.add(truck.getEntId());
+            truckNos.add(truck.getTruckNo());
+        }
+
+        //企业数据集
+        entIds = entIds.stream().distinct().collect(Collectors.toList());
+        Map<Long, EntCacheResDto> ents = remoteSystemService.queryEntCacheMapByIds(entIds);
+        //车辆定位数据集
+        Map<String, KwfTruckGpsVo> truckGpsMap = findTruckLocateHandle(truckNos);
+
+        /**数据组装**/
+        for (KwfTruckMonitorVo truck:trucks) {
+            EntCacheResDto ent = ents == null ? null : ents.get(truck.getEntId());
+            KwfTruckGpsVo truckGps = truckGpsMap != null ? truckGpsMap.get(truck.getTruckNo()) : null;
+            truck.setFirmName(ent != null ? ent.getFirmName() : null);
+            truck.setRunStatus(truckGps != null ? truckGps.getRunStatus() : null);
+        }
+
+        return trucks;
+    }
+
     /**
     /**
      * @param params 参数
      * @param params 参数
      * @desc 校验车辆是否有证书
      * @desc 校验车辆是否有证书
@@ -690,4 +733,113 @@ public class KwfTruckService {
         }
         }
         return false;
         return false;
     }
     }
+
+    /**
+     * @param truckNos 车牌号
+     * @desc 查询车辆定位数据
+     * @author zk
+     * @date 2023/9/5
+     **/
+    public Map<String, KwfTruckGpsVo> findTruckLocateHandle(List<String> truckNos){
+        /**车牌号超过100则分批次请求数据**/
+        int maxLimit = 100;
+        List<List<String>> truckNoList = new ArrayList<List<String>>();
+        List<String> findTruckSon = null;
+        for (int i = 0; i < truckNos.size(); i++) {
+            if (i % maxLimit == 0) {
+                findTruckSon = new ArrayList<String>();
+                truckNoList.add(findTruckSon);
+            }
+            findTruckSon.add(truckNos.get(i));
+        }
+
+        /**获取数据**/
+        Map<String, KwfTruckGpsVo> truckGpsMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
+        for (List<String> turckNo:truckNoList) {
+            Map<String, KwfTruckGpsVo> truckGps = findTruckLocate(turckNo);
+            truckGpsMap.putAll(truckGps);
+        }
+
+        return truckGpsMap;
+    }
+
+    @Value("${external.openapi.queryLocate}")
+    private String queryLocate;
+
+    /**
+     * @param truckNos 车牌号
+     * @desc 查询车辆定位数据
+     * @author zk
+     * @date 2023/9/5
+     **/
+    public Map<String, KwfTruckGpsVo> findTruckLocate(List<String> truckNos){
+        Map<String, KwfTruckGpsVo> truckGpsMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
+        if (truckNos == null || truckNos.size() == 0) {
+            return truckGpsMap;
+        }
+
+        try {
+            Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN) {{
+                put("vehicleNoList", truckNos);
+            }};
+            String httpResult = HttpClientUtil.post(queryLocate, JSON.toJSONString(params));
+            if (StringUtils.isNotBlank(httpResult)) {
+                JSONObject result = JSONObject.parseObject(httpResult);
+                if (result.getInteger("code") != null && result.getInteger("code") != 200) {
+                    return truckGpsMap;
+                } else {
+                    System.out.println(result);
+                }
+                JSONArray trucks = result.getJSONArray("data");
+                for (int i=0; trucks != null && i < trucks.size(); i++) {
+                    JSONObject truck = trucks.getJSONObject(i);
+                    JSONObject locateInfo = truck.getJSONObject("locateInfo");
+                    KwfTruckGpsVo truckGps = new KwfTruckGpsVo();
+                    truckGps.setTruckNo(truck.getString("vehicleNo"));
+                    truckGps.setLat(locateInfo.getString("lng"));
+                    truckGps.setLng(locateInfo.getString("vehicleNo"));
+                    truckGps.setSpeed(locateInfo.getDouble("speed"));
+                    truckGps.setGpsTime(locateInfo.getString("createTime"));
+                    truckGps.setRunStatus(runStatus(truckGps.getGpsTime(), truckGps.getSpeed()));
+                    truckGpsMap.put(truckGps.getTruckNo(), truckGps);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return truckGpsMap;
+    }
+
+    /**
+     * @param gpsTimeStr 地位时间
+     * @param speed 速度
+     * @desc 校验当前车辆运行状态
+     * @author zk
+     * @date 2023/9/5
+     **/
+    public int runStatus(String gpsTimeStr, Double speed){
+        if (StringUtils.isBlank(gpsTimeStr)) {
+            return Global.NUMERICAL_TWO;
+        }
+        Date gpsTime = DateUtils.formatDate(gpsTimeStr);
+        if (gpsTime == null) {
+            return Global.NUMERICAL_TWO;
+        }
+        Date newTime = DateUtils.addDateMinutes(gpsTime, 15);
+        int compareTo = DateUtils.compareTo(newTime, new Date());
+        //-1 date1小于date2、0 date1等于date2、1 date1大于date2
+        //运行状态(0行驶、1停止、2离线)
+        return compareTo < 0 ? 2 : (speed == null || speed == 0) ? 1 : 0;
+    }
+
+    public static void main(String[] args) {
+        String url = "http://10.10.10.224:27802/openapi/vehicleLocate/queryLocateByDesignatedTime";
+        Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN){{put("vehicleNo", "川L01819D");}};
+        String result = HttpClientUtil.post(url, JSON.toJSONString(params));
+        System.out.println(result);
+
+
+
+    }
+
 }
 }

+ 16 - 0
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfTruckMapper.xml

@@ -234,4 +234,20 @@
         GROUP BY ent_id
         GROUP BY ent_id
     </select>
     </select>
 
 
+    <select id="findTruckByEnt" resultType="com.sckw.fleet.model.vo.KwfTruckMonitorVo" >
+        SELECT
+            kt.truck_no, kt.business_status businessStatus, kte.ent_id entId
+        from kwf_truck kt
+        left join kwf_truck_ent kte on kte.truck_id = kt.id
+        where kt.del_flag = 0 and kte.del_flag = 0
+        and kte.ent_id = #{entId, jdbcType=BIGINT}
+    </select>
+
+    <select id="findTruckByAll" resultType="com.sckw.fleet.model.vo.KwfTruckMonitorVo" >
+        SELECT
+        kt.truck_no, kt.business_status businessStatus, kt.ent_id entId
+        from kwf_truck kt
+        where kt.del_flag = 0
+    </select>
+
 </mapper>
 </mapper>

+ 10 - 0
sckw-modules/sckw-message/src/main/java/com/sckw/message/dao/KwmMessageMapper.java

@@ -1,6 +1,7 @@
 package com.sckw.message.dao;
 package com.sckw.message.dao;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sckw.core.model.vo.TableTop;
 import com.sckw.message.model.KwmMessage;
 import com.sckw.message.model.KwmMessage;
 import com.sckw.message.model.dto.MessageListDTO;
 import com.sckw.message.model.dto.MessageListDTO;
 import com.sckw.message.model.dto.SelectMessagesDTO;
 import com.sckw.message.model.dto.SelectMessagesDTO;
@@ -24,4 +25,13 @@ public interface KwmMessageMapper extends BaseMapper<KwmMessage> {
      * @return java.util.List<com.sckw.message.model.dto.MessageListDTO>
      * @return java.util.List<com.sckw.message.model.dto.MessageListDTO>
      */
      */
     List<MessageListDTO> findPage(@Param("item") SelectMessagesDTO item);
     List<MessageListDTO> findPage(@Param("item") SelectMessagesDTO item);
+
+    /**
+     * @desc: 统计查询
+     * @author: yzc
+     * @date: 2023-09-06 9:21
+     * @Param item:
+     * @return: java.util.List<com.sckw.core.model.vo.TableTop>
+     */
+    List<TableTop> statistics(@Param("item") SelectMessagesDTO item);
 }
 }

+ 5 - 0
sckw-modules/sckw-message/src/main/java/com/sckw/message/model/dto/SelectMessagesDTO.java

@@ -50,4 +50,9 @@ public class SelectMessagesDTO {
      */
      */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date endCreateTime;
     private Date endCreateTime;
+
+    /**
+     * 消息列表排序类型 1状态升序,创建时间降序   2创建时间降序
+     */
+    private Integer sortType;
 }
 }

+ 6 - 0
sckw-modules/sckw-message/src/main/java/com/sckw/message/model/vo/req/SelectMessagesReqVO.java

@@ -2,9 +2,11 @@ package com.sckw.message.model.vo.req;
 
 
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.sckw.core.model.page.PageRequest;
 import com.sckw.core.model.page.PageRequest;
+import jakarta.validation.constraints.NotNull;
 import lombok.Getter;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.Setter;
 import lombok.ToString;
 import lombok.ToString;
+import org.hibernate.validator.constraints.Range;
 
 
 import java.util.Date;
 import java.util.Date;
 
 
@@ -40,5 +42,9 @@ public class SelectMessagesReqVO extends PageRequest {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date endCreateTime;
     private Date endCreateTime;
 
 
+    @NotNull(message = "消息列表排序类型不能为空")
+    @Range(min = 1, max = 2, message = "非法消息列表排序类型")
+    private Integer sortType;
+
 
 
 }
 }

+ 3 - 0
sckw-modules/sckw-message/src/main/java/com/sckw/message/model/vo/req/StatisticsMessagesReqVO.java

@@ -1,5 +1,6 @@
 package com.sckw.message.model.vo.req;
 package com.sckw.message.model.vo.req;
 
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Getter;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.Setter;
 import lombok.ToString;
 import lombok.ToString;
@@ -24,11 +25,13 @@ public class StatisticsMessagesReqVO {
     /**
     /**
      * 创建时间开始(yyyy-MM-dd HH:mm:ss)
      * 创建时间开始(yyyy-MM-dd HH:mm:ss)
      */
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date startCreateTime;
     private Date startCreateTime;
 
 
     /**
     /**
      * 创建时间结束(yyyy-MM-dd HH:mm:ss)
      * 创建时间结束(yyyy-MM-dd HH:mm:ss)
      */
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date endCreateTime;
     private Date endCreateTime;
 
 
 
 

+ 12 - 0
sckw-modules/sckw-message/src/main/java/com/sckw/message/service/KwmMessageService.java

@@ -3,6 +3,7 @@ package com.sckw.message.service;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.sckw.core.model.vo.TableTop;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.message.dao.KwmMessageMapper;
 import com.sckw.message.dao.KwmMessageMapper;
@@ -101,6 +102,17 @@ public class KwmMessageService {
         return kwmMessageMapper.findPage(dto);
         return kwmMessageMapper.findPage(dto);
     }
     }
 
 
+    /**
+     * @desc: 统计查询
+     * @author: yzc
+     * @date: 2023-09-06 9:21
+     * @Param dto:
+     * @return: java.util.List<com.sckw.core.model.vo.TableTop>
+     */
+    public List<TableTop> statistics(SelectMessagesDTO dto) {
+        return kwmMessageMapper.statistics(dto);
+    }
+
     /**
     /**
      * @param id
      * @param id
      * @return com.sckw.message.model.KwmMessage
      * @return com.sckw.message.model.KwmMessage

+ 21 - 11
sckw-modules/sckw-message/src/main/java/com/sckw/message/service/MessageService.java

@@ -58,7 +58,7 @@ public class MessageService {
      */
      */
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
     public void read(ReadMessagesReqVO reqVO) {
     public void read(ReadMessagesReqVO reqVO) {
-        List<Long> ids = StringUtils.splitStrToList(reqVO.toString(), Long.class);
+        List<Long> ids = StringUtils.splitStrToList(reqVO.getIds(), Long.class);
         List<KwmMessageUser> msgList = kwmMessageUserService.getByMsgIds(ids);
         List<KwmMessageUser> msgList = kwmMessageUserService.getByMsgIds(ids);
         if (!Objects.equals(ids.size(), msgList.size())) {
         if (!Objects.equals(ids.size(), msgList.size())) {
             throw new BusinessException("无权限读取消息!");
             throw new BusinessException("无权限读取消息!");
@@ -215,22 +215,32 @@ public class MessageService {
      */
      */
     public TableStatisticRes statistics(StatisticsMessagesReqVO params) {
     public TableStatisticRes statistics(StatisticsMessagesReqVO params) {
         TableStatisticRes res = new TableStatisticRes();
         TableStatisticRes res = new TableStatisticRes();
-        List<KwmMessageListResVO> messages = this.select(BeanUtils.copyProperties(params, SelectMessagesReqVO.class));
-        Map<Integer, List<KwmMessageListResVO>> map = messages.stream().collect(Collectors.groupingBy(KwmMessageListResVO::getStatus));
+        SelectMessagesDTO dto = BeanUtils.copyProperties(params, SelectMessagesDTO.class);
+        //当前登录人是企业管理员则查看全部消息,否则只查看对应用户消息
+        if (Objects.equals(LoginUserHolder.getIsMain(), 1)) {
+            dto.setEntId(LoginUserHolder.getEntId());
+        } else {
+            dto.setUserId(LoginUserHolder.getUserId());
+        }
+        List<TableTop> statistics = kwmMessageService.statistics(dto);
+        Map<Integer, Integer> map = statistics.stream().
+                collect(Collectors.toMap(TableTop::getValue, TableTop::getTotal, (k1, k2) -> k1));
         List<TableTop> tableTops = new ArrayList<>();
         List<TableTop> tableTops = new ArrayList<>();
-        TableTop all = new TableTop();
-        all.setName("全部").setTotal(CollectionUtils.isEmpty(messages) ? 0 : messages.size());
-        tableTops.add(all);
+        int totalCount = 0;
         List<MsgStatusEnum> enums = MsgStatusEnum.getSortList();
         List<MsgStatusEnum> enums = MsgStatusEnum.getSortList();
-        enums.forEach(e -> {
-            List<KwmMessageListResVO> list = map.get(e.getCode());
-            int total = CollectionUtils.isEmpty(list) ? 0 : list.size();
+        for (MsgStatusEnum e : enums) {
+            Integer count = map.get(e.getCode());
+            int total = Objects.isNull(count) ? 0 : count;
             TableTop tableTop = new TableTop();
             TableTop tableTop = new TableTop();
             tableTop.setName(e.getMsg()).setValue(e.getCode()).setTotal(total);
             tableTop.setName(e.getMsg()).setValue(e.getCode()).setTotal(total);
             tableTops.add(tableTop);
             tableTops.add(tableTop);
-        });
+            totalCount = totalCount + total;
+        }
+        TableTop all = new TableTop();
+        all.setName("全部").setTotal(totalCount);
+        tableTops.add(0, all);
         TableBottom tableBottom = new TableBottom();
         TableBottom tableBottom = new TableBottom();
-        tableBottom.setTotal(CollectionUtils.isEmpty(messages) ? 0 : messages.size());
+        tableBottom.setTotal(totalCount);
         res.setTableTops(tableTops).setTableBottom(tableBottom);
         res.setTableTops(tableTops).setTableBottom(tableBottom);
         return res;
         return res;
     }
     }

+ 62 - 27
sckw-modules/sckw-message/src/main/resources/mapper/KwmMessageMapper.xml

@@ -3,34 +3,69 @@
 <mapper namespace="com.sckw.message.dao.KwmMessageMapper">
 <mapper namespace="com.sckw.message.dao.KwmMessageMapper">
 
 
   <select id="findPage" resultType="com.sckw.message.model.dto.MessageListDTO" >
   <select id="findPage" resultType="com.sckw.message.model.dto.MessageListDTO" >
-    select
-      mu.id, mu.ent_id entId, mu.user_id userId, mu.status, mu.reamrk, mu.create_by createBy, mu.create_time createTime,
+      select
+      mu.id, mu.ent_id entId, mu.user_id userId, mu.status, mu.remark, mu.create_by createBy, mu.create_time createTime,
       mu.update_by updateBy, mu.update_time updateTime, m.id as msgId, m.category, m.type, m.title, m.content, m.url,
       mu.update_by updateBy, mu.update_time updateTime, m.id as msgId, m.category, m.type, m.title, m.content, m.url,
       m.params, m.client_type clientType, m.remark as msgRemark
       m.params, m.client_type clientType, m.remark as msgRemark
-    from kwm_message_user mu
-    left join kwm_message m
-    on mu.msg_id = m.id
-    <where>
-        m.del_flag = 0 and mu.del_flag = 0
-        <if test="item.entId != null">
-            and mu.ent_id = #{item.entId}
-        </if>
-        <if test="item.userId != null">
-            and mu.user_id = #{item.userId}
-        </if>
-        <if test="item.status != null">
-            and mu.status = #{item.status}
-        </if>
-        <if test="item.category != null and item.category != ''">
-          and m.category = #{item.category}
-        </if>
-        <if test="item.startCreateTime != null">
-            and m.create_time &gt;= #{item.startCreateTime,jdbcType=TIMESTAMP}
-        </if>
-        <if test="item.endCreateTime != null">
-            and m.create_time &lt;= #{item.endCreateTime,jdbcType=TIMESTAMP}
-        </if>
-    </where>
-    ORDER BY m.create_time desc
+      from kwm_message_user mu
+      left join kwm_message m
+      on mu.msg_id = m.id
+      <where>
+          m.del_flag = 0 and mu.del_flag = 0
+          <if test="item.entId != null">
+              and mu.ent_id = #{item.entId}
+          </if>
+          <if test="item.userId != null">
+              and mu.user_id = #{item.userId}
+          </if>
+          <if test="item.status != null">
+              and mu.status = #{item.status}
+          </if>
+          <if test="item.category != null and item.category != ''">
+              and m.category = #{item.category}
+          </if>
+          <if test="item.startCreateTime != null">
+              and mu.create_time &gt;= #{item.startCreateTime,jdbcType=TIMESTAMP}
+          </if>
+          <if test="item.endCreateTime != null">
+              and mu.create_time &lt;= #{item.endCreateTime,jdbcType=TIMESTAMP}
+          </if>
+      </where>
+      ORDER BY
+      <choose>
+          <when test="item.sortType != null and item.sortType == 1">
+              mu.status ASC, mu.create_time DESC
+          </when>
+          <otherwise>
+              mu.create_time DESC
+          </otherwise>
+      </choose>
   </select>
   </select>
+    <select id="statistics" resultType="com.sckw.core.model.vo.TableTop">
+        select
+        mu.status as value,count(*) as total
+        from kwm_message_user mu
+        left join kwm_message m
+        on mu.msg_id = m.id
+        <where>
+            m.del_flag = 0 and mu.del_flag = 0
+            <if test="item.entId != null">
+                and mu.ent_id = #{item.entId}
+            </if>
+            <if test="item.userId != null">
+                and mu.user_id = #{item.userId}
+            </if>
+            <if test="item.category != null and item.category != ''">
+                and m.category = #{item.category}
+            </if>
+            <if test="item.startCreateTime != null">
+                and mu.create_time &gt;= #{item.startCreateTime,jdbcType=TIMESTAMP}
+            </if>
+            <if test="item.endCreateTime != null">
+                and mu.create_time &lt;= #{item.endCreateTime,jdbcType=TIMESTAMP}
+            </if>
+        </where>
+        group by mu.status
+
+    </select>
 </mapper>
 </mapper>

+ 7 - 7
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwOrderService.java

@@ -97,13 +97,16 @@ public class KwOrderService {
             String loadDetailAddress = Objects.isNull(e.getLoadDetailAddress()) ? "" : e.getLoadDetailAddress();
             String loadDetailAddress = Objects.isNull(e.getLoadDetailAddress()) ? "" : e.getLoadDetailAddress();
             String unloadDetailAddress = Objects.isNull(e.getUnloadDetailAddress()) ? "" : e.getUnloadDetailAddress();
             String unloadDetailAddress = Objects.isNull(e.getUnloadDetailAddress()) ? "" : e.getUnloadDetailAddress();
             order.setStatusLabel(DictEnum.getLabel(DictTypeEnum.TORDER_STATUS.getType(), String.valueOf(e.getStatus())))
             order.setStatusLabel(DictEnum.getLabel(DictTypeEnum.TORDER_STATUS.getType(), String.valueOf(e.getStatus())))
+                    .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
                     .setTrading(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
                     .setTrading(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
+                    .setDeliveryTypeLabel(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
                     .setDeliveryType(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
                     .setDeliveryType(DictEnum.getLabel(DictTypeEnum.DELIVERY_TYPE.getType(), e.getDeliveryType()))
                     .setPickupTypeLabel(DictEnum.getLabel(DictTypeEnum.PICKUP_TYPE.getType(), e.getPickupType()))
                     .setPickupTypeLabel(DictEnum.getLabel(DictTypeEnum.PICKUP_TYPE.getType(), e.getPickupType()))
+                    .setSourceLabel(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()))
+                    .setSource(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()))
                     .setLoadDetailAddressInfo(loadCityName + loadDetailAddress)
                     .setLoadDetailAddressInfo(loadCityName + loadDetailAddress)
                     .setUnloadDetailAddressInfo(unloadCityName + unloadDetailAddress)
                     .setUnloadDetailAddressInfo(unloadCityName + unloadDetailAddress)
-                    .setWaitEntrustAmount(getWaitEntrustAmount(e.getAmount(), e.getEntrustAmount()))
-                    .setSource(DictEnum.getLabel(DictTypeEnum.TORDER_SOURCE.getType(), e.getSource()));
+                    .setWaitEntrustAmount(getWaitEntrustAmount(e.getAmount(), e.getEntrustAmount()));
             result.add(order);
             result.add(order);
         });
         });
         return PageResult.build(page, pageSize, count, result);
         return PageResult.build(page, pageSize, count, result);
@@ -137,7 +140,7 @@ public class KwOrderService {
         Long userId = LoginUserHolder.getUserId();
         Long userId = LoginUserHolder.getUserId();
         Criteria criteria = new Criteria();
         Criteria criteria = new Criteria();
         String topEnt = Objects.equals(params.getOrderType(), 1) ? "procureTopEntId" : "supplyTopEntId";
         String topEnt = Objects.equals(params.getOrderType(), 1) ? "procureTopEntId" : "supplyTopEntId";
-        criteria.and("delFlag").is(0);
+        criteria.and(topEnt).is(entId).and("delFlag").is(0);
         //日期范围
         //日期范围
         if (Objects.nonNull(params.getStartCreateTime()) && Objects.nonNull(params.getEndCreateTime())) {
         if (Objects.nonNull(params.getStartCreateTime()) && Objects.nonNull(params.getEndCreateTime())) {
             criteria.and("createTime").gte(params.getStartCreateTime()).lte(params.getEndCreateTime());
             criteria.and("createTime").gte(params.getStartCreateTime()).lte(params.getEndCreateTime());
@@ -190,14 +193,11 @@ public class KwOrderService {
             if (Objects.equals(params.getStatus(), 0)) {
             if (Objects.equals(params.getStatus(), 0)) {
                 //草稿状态只能创建订单的人能看
                 //草稿状态只能创建订单的人能看
                 criteria.and("createBy").is(userId);
                 criteria.and("createBy").is(userId);
-            }else {
-                criteria.and(topEnt).is(entId);
             }
             }
         } else {
         } else {
             //非草稿状态且一级企业匹配or草稿状态且是当前人
             //非草稿状态且一级企业匹配or草稿状态且是当前人
             Criteria orOperator = new Criteria().orOperator(
             Criteria orOperator = new Criteria().orOperator(
-                    new Criteria().andOperator(Criteria.where("status").ne(0),
-                            Criteria.where(topEnt).is(entId)),
+                    Criteria.where("status").ne(0),
                     new Criteria().andOperator(Criteria.where("status").is(0),
                     new Criteria().andOperator(Criteria.where("status").is(0),
                             Criteria.where("createBy").is(userId)));
                             Criteria.where("createBy").is(userId)));
             orOperators.add(orOperator);
             orOperators.add(orOperator);

+ 120 - 42
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwTransportService.java

@@ -39,10 +39,7 @@ import org.springframework.stereotype.Service;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Pattern;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
@@ -200,14 +197,17 @@ public class KwTransportService {
                 statuses.add(CarWaybillEnum.REJECT_ORDER.getCode().longValue());
                 statuses.add(CarWaybillEnum.REJECT_ORDER.getCode().longValue());
                 statuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode().longValue());
                 statuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode().longValue());
                 statuses.add(CarWaybillEnum.REVOKED.getCode().longValue());
                 statuses.add(CarWaybillEnum.REVOKED.getCode().longValue());
-                statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
+//                statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
                 criteria.and("status").in(statuses);
                 criteria.and("status").in(statuses);
             } else if (query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode()))) {
             } else if (query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode()))) {
                 List<Long> statuses = new ArrayList<>();
                 List<Long> statuses = new ArrayList<>();
                 statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode().longValue());
                 statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode().longValue());
                 statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
                 statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
                 criteria.and("status").in(statuses);
                 criteria.and("status").in(statuses);
-            } else if (!query.getStatus().equals("all")) {
+            } else if (!query.getStatus().equals("all")
+                    && (!query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode())))
+                    && (!query.getStatus().equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO)))
+            ) {
                 criteria.and("status").is(Integer.valueOf(query.getStatus()));
                 criteria.and("status").is(Integer.valueOf(query.getStatus()));
             }
             }
         }
         }
@@ -293,45 +293,122 @@ public class KwTransportService {
         topTotal.setName("全部");
         topTotal.setName("全部");
         topTotal.setValue("all");
         topTotal.setValue("all");
         topTotal.setTotal(0);
         topTotal.setTotal(0);
-        list.add(topTotal);
+
 
 
         TableTops topExpired = new TableTops();
         TableTops topExpired = new TableTops();
         topExpired.setName("已作废");
         topExpired.setName("已作废");
         topExpired.setValue(String.valueOf(NumberConstant.ONE_ZERO_ZERO));
         topExpired.setValue(String.valueOf(NumberConstant.ONE_ZERO_ZERO));
+        topExpired.setSort(NumberConstant.ONE_ZERO_ZERO);
         topExpired.setTotal(0);
         topExpired.setTotal(0);
-        ArrayList<Long> expiredStatuses = new ArrayList<>();
-        expiredStatuses.add(CarWaybillEnum.REJECT_ORDER.getCode().longValue());
-        expiredStatuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode().longValue());
-        expiredStatuses.add(CarWaybillEnum.REVOKED.getCode().longValue());
-        expiredStatuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
-        for (CarWaybillEnum status : CarWaybillEnum.values()) {
-            boolean expiredFlag = expiredStatuses.contains(status.getCode().longValue());
+
+        list.addAll(results);
+        list.add(topExpired);
+//        ArrayList<Long> expiredStatuses = new ArrayList<>();
+//        expiredStatuses.add(CarWaybillEnum.REJECT_ORDER.getCode().longValue());
+//        expiredStatuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode().longValue());
+//        expiredStatuses.add(CarWaybillEnum.REVOKED.getCode().longValue());
+//        expiredStatuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
+//        for (CarWaybillEnum status : CarWaybillEnum.values()) {
+//            boolean expiredFlag = expiredStatuses.contains(status.getCode().longValue());
+//            TableTops top = new TableTops();
+//            top.setName(status.getDestination());
+//            top.setValue(String.valueOf(status.getCode()));
+//            top.setTotal(0);
+//            if (CollectionUtils.isNotEmpty(results)) {
+//                for (TableTops result : results) {
+//                    if (StringUtils.isNotEmpty(result.getValue())
+//                            && String.valueOf(result.getValue()).equals(String.valueOf(status.getCode()))) {
+//                        if (expiredFlag) {
+//                            topExpired.setTotal(topExpired.getTotal() + result.getTotal());
+//                        } else {
+//                            top.setTotal(result.getTotal());
+//                        }
+//                        break;
+//                    }
+//                }
+//            }
+//            if (!expiredFlag) {
+//                list.add(top);
+//            }
+//        }
+        /**数据统计计算*/
+        orderNumberCount(list);
+        /**补齐全部状态值*/
+        List<String> codeList = CarWaybillEnum.getStringCodes();
+        List<String> collect = list.stream().map(e -> e.getValue()).collect(Collectors.toList());
+        List<String> diffrentList = getDiffrentList(collect, codeList);
+        for (String s : diffrentList) {
             TableTops top = new TableTops();
             TableTops top = new TableTops();
-            top.setName(status.getDestination());
-            top.setValue(String.valueOf(status.getCode()));
-            top.setTotal(0);
-            if (CollectionUtils.isNotEmpty(results)) {
-                for (TableTops result : results) {
-                    if (StringUtils.isNotEmpty(result.getValue())
-                            && String.valueOf(result.getValue()).equals(String.valueOf(status.getCode()))) {
-                        if (expiredFlag) {
-                            topExpired.setTotal(topExpired.getTotal() + result.getTotal());
-                        } else {
-                            top.setTotal(result.getTotal());
-                        }
-                        break;
-                    }
+            top.setValue(s);
+            top.setTotal(NumberConstant.ZERO);
+            top.setSort(Integer.valueOf(s));
+            list.add(top);
+        }
+        /**状态赋值翻译*/
+        for (CarWaybillEnum waybillEnum : CarWaybillEnum.values()) {
+            for (TableTops tops : list) {
+                if (waybillEnum.getStatus().equals(tops.getValue())) {
+                    tops.setName(waybillEnum.getDestination());
+                    tops.setSort(waybillEnum.getCode());
+                    continue;
                 }
                 }
             }
             }
-            if (!expiredFlag) {
-                list.add(top);
+        }
+//        list.add(topExpired);
+        /**去除不展示统计字段*/
+        List<TableTops> returnList = new ArrayList<>();
+        for (TableTops tops : list) {
+            if ((!CarWaybillEnum.REFUSE_TRAFFIC.getStatus().equals(tops.getValue()))
+                    && (!CarWaybillEnum.APPROVAL_NO_PASS.getStatus().equals(tops.getValue()))
+                    && (!CarWaybillEnum.REVOKED.getStatus().equals(tops.getValue()))
+                    && (!CarWaybillEnum.REJECT_ORDER.getStatus().equals(tops.getValue()))
+            ) {
+                returnList.add(tops);
             }
             }
         }
         }
-        list.add(topExpired);
+        /**排序*/
+        returnList = returnList.stream().sorted(Comparator.comparing(TableTops::getSort)).collect(Collectors.toList());
+        returnList.add(0,topTotal);
         // 总计
         // 总计
-        topTotal.setTotal(list.parallelStream().mapToInt(item -> item.getTotal()).sum());
+        topTotal.setTotal(returnList.parallelStream().mapToInt(item -> item.getTotal()).sum());
         // 查询结果
         // 查询结果
-        return HttpResult.ok(list);
+        return HttpResult.ok(returnList);
+    }
+
+    /**
+     * 统计top计算
+     *
+     * @param results
+     */
+    private void orderNumberCount(List<TableTops> results) {
+        if (!org.springframework.util.CollectionUtils.isEmpty(results)) {
+            //已卸货包含本身以及审核不通过
+            Integer orderCancel = 0;
+            //已作废包含本身以及拒绝出车、已撤销、拒绝接单
+            Integer orderCancellation = 0;
+            for (TableTops result : results) {
+                if (CarWaybillEnum.COMPLETION_UNLOADING.getStatus().equals(result.getValue())
+                        || CarWaybillEnum.APPROVAL_NO_PASS.getStatus().equals(result.getValue())) {
+                    orderCancel = orderCancel + result.getTotal();
+                }
+                if (CarWaybillEnum.REJECT_ORDER.getStatus().equals(result.getValue())
+                        || CarWaybillEnum.REVOKED.getStatus().equals(result.getValue())
+                        || CarWaybillEnum.REFUSE_TRAFFIC.getStatus().equals(result.getValue())
+                ) {
+                    orderCancellation = orderCancellation + result.getTotal();
+                }
+            }
+            for (TableTops result : results) {
+                if (CarWaybillEnum.COMPLETION_UNLOADING.getStatus().equals(result.getValue())) {
+                    result.setTotal(orderCancel);
+                    result.setSort(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
+                }
+                if (String.valueOf(NumberConstant.ONE_ZERO_ZERO).equals(result.getValue())) {
+                    result.setTotal(orderCancellation);
+                    result.setSort(NumberConstant.ONE_ZERO_ZERO);
+                }
+            }
+        }
     }
     }
 
 
     /**
     /**
@@ -383,7 +460,7 @@ public class KwTransportService {
                 typeString = "循环";
                 typeString = "循环";
             }
             }
             vo.setTypeLabel(typeString);
             vo.setTypeLabel(typeString);
-            if(status.equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO))) {
+            if (status.equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO))) {
                 vo.setStatus(String.valueOf(NumberConstant.ONE_ZERO_ZERO));
                 vo.setStatus(String.valueOf(NumberConstant.ONE_ZERO_ZERO));
             } else {
             } else {
                 vo.setStatus(waybillOrder.getStatus() == null ?
                 vo.setStatus(waybillOrder.getStatus() == null ?
@@ -424,12 +501,12 @@ public class KwTransportService {
             // 存在装卸货差时 计算扣亏量
             // 存在装卸货差时 计算扣亏量
             BigDecimal lossAmount = BigDecimal.valueOf(0);
             BigDecimal lossAmount = BigDecimal.valueOf(0);
             BigDecimal loss = waybillOrder.getLoss() == null ? new BigDecimal("0.00") : waybillOrder.getLoss();
             BigDecimal loss = waybillOrder.getLoss() == null ? new BigDecimal("0.00") : waybillOrder.getLoss();
-            if(deficitAmount.compareTo(new BigDecimal("0.00")) > 0 && loss.compareTo(new BigDecimal("0.00")) > 0) {
+            if (deficitAmount.compareTo(new BigDecimal("0.00")) > 0 && loss.compareTo(new BigDecimal("0.00")) > 0) {
                 String lossUnit = waybillOrder.getLossUnit();
                 String lossUnit = waybillOrder.getLossUnit();
                 Map<String, SysDictResDto> LossUnitType = remoteSystemService.queryDictMapByType(DictTypeEnum.TAX_RATE_TYPE.getType());
                 Map<String, SysDictResDto> LossUnitType = remoteSystemService.queryDictMapByType(DictTypeEnum.TAX_RATE_TYPE.getType());
                 SysDictResDto sysDictRes = LossUnitType.get(lossUnit);
                 SysDictResDto sysDictRes = LossUnitType.get(lossUnit);
 
 
-                if(sysDictRes.getLabel().equals("%")) {
+                if (sysDictRes.getLabel().equals("%")) {
                     // 百分比
                     // 百分比
                     lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(100));
                     lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(100));
                 } else {
                 } else {
@@ -437,7 +514,7 @@ public class KwTransportService {
                     lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(1000));
                     lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(1000));
                 }
                 }
                 lossAmount = deficitAmount.subtract(lossAmount);
                 lossAmount = deficitAmount.subtract(lossAmount);
-                if(lossAmount.compareTo(new BigDecimal("0.00")) < 0) {
+                if (lossAmount.compareTo(new BigDecimal("0.00")) < 0) {
                     lossAmount = new BigDecimal("0.00");
                     lossAmount = new BigDecimal("0.00");
                 }
                 }
             }
             }
@@ -500,16 +577,16 @@ public class KwTransportService {
     public HttpResult getLogisticsOrderByContractId(ContractParam contractParam) {
     public HttpResult getLogisticsOrderByContractId(ContractParam contractParam) {
         HttpResult result = new HttpResult();
         HttpResult result = new HttpResult();
         if (String.valueOf(NumberConstant.ONE).equals(contractParam.getContractType())) {
         if (String.valueOf(NumberConstant.ONE).equals(contractParam.getContractType())) {
-            result = getLogisticsOrderContract(contractParam,"1");
+            result = getLogisticsOrderContract(contractParam, "1");
         } else if (String.valueOf(NumberConstant.TWO).equals(contractParam.getContractType())) {
         } else if (String.valueOf(NumberConstant.TWO).equals(contractParam.getContractType())) {
-            result = getLogisticsOrderContract(contractParam,"2");
+            result = getLogisticsOrderContract(contractParam, "2");
         } else {
         } else {
             return HttpResult.error("合同类型错误");
             return HttpResult.error("合同类型错误");
         }
         }
         return result;
         return result;
     }
     }
 
 
-    private HttpResult getLogisticsOrderContract(ContractParam contractParam,String unitType) {
+    private HttpResult getLogisticsOrderContract(ContractParam contractParam, String unitType) {
         String contractIds = contractParam.getContractIds();
         String contractIds = contractParam.getContractIds();
         int page = contractParam.getPage();
         int page = contractParam.getPage();
         int pageSize = contractParam.getPageSize();
         int pageSize = contractParam.getPageSize();
@@ -550,7 +627,7 @@ public class KwTransportService {
         // 12. 总记录数
         // 12. 总记录数
         long total = mongoTemplate.count(query1, SckwLogisticsOrder.class);
         long total = mongoTemplate.count(query1, SckwLogisticsOrder.class);
         // 10. 分页
         // 10. 分页
-        query1.with(PageRequest.of(page - 1, pageSize, Sort.by(Sort.Direction.DESC,"contractId","createTime")));
+        query1.with(PageRequest.of(page - 1, pageSize, Sort.by(Sort.Direction.DESC, "contractId", "createTime")));
         // 执行查询
         // 执行查询
         List<SckwLogisticsOrder> list = mongoTemplate.find(query1, SckwLogisticsOrder.class);
         List<SckwLogisticsOrder> list = mongoTemplate.find(query1, SckwLogisticsOrder.class);
         //字典等数据转换
         //字典等数据转换
@@ -610,7 +687,8 @@ public class KwTransportService {
     }
     }
 
 
     /**
     /**
-     *  运单列表导出
+     * 运单列表导出
+     *
      * @param query
      * @param query
      * @return
      * @return
      */
      */

+ 11 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/KwtWaybillOrderController.java

@@ -288,6 +288,17 @@ public class KwtWaybillOrderController {
         return waybillOrderService.editTicket(params);
         return waybillOrderService.editTicket(params);
     }
     }
 
 
+    /**
+     * @param params {}
+     * @desc 修改单证-装卸货一起修改
+     * @author zk
+     * @date 2023/7/26
+     **/
+    @PostMapping("/editTicketV1")
+    public HttpResult editTicketV1(@RequestBody @Valid WaybillOrderTicketV1Dto params){
+        return waybillOrderService.editTicket(params);
+    }
+
     /**
     /**
      * @param wOrderId
      * @param wOrderId
      * @desc 修改单证查询运单
      * @desc 修改单证查询运单

+ 13 - 6
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java

@@ -198,7 +198,9 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
     List<AcceptCarriageOrderVO> selectLogisticsOrderList(@Param("query") AcceptCarriageOrderQuery query,
     List<AcceptCarriageOrderVO> selectLogisticsOrderList(@Param("query") AcceptCarriageOrderQuery query,
                                                          @Param("orderList") List<Integer> orderList,
                                                          @Param("orderList") List<Integer> orderList,
                                                          @Param("type") String type,
                                                          @Param("type") String type,
-                                                         @Param("entId") Long entId
+                                                         @Param("entId") Long entId,
+                                                         @Param("contactsIds") List<Long> contactsIds,
+                                                         @Param("userIds") List<Long> userIds
     );
     );
 
 
     /**
     /**
@@ -211,7 +213,9 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
     List<ConsignOrderVO> selectConsignLogisticsOrderList(@Param("query") ConsignOrderQuery query,
     List<ConsignOrderVO> selectConsignLogisticsOrderList(@Param("query") ConsignOrderQuery query,
                                                          @Param("orderList") List<Integer> orderList,
                                                          @Param("orderList") List<Integer> orderList,
                                                          @Param("type") String type,
                                                          @Param("type") String type,
-                                                         @Param("entId") Long entId
+                                                         @Param("entId") Long entId,
+                                                         @Param("contactsIds") List<Long> contactsIds,
+                                                         @Param("userIds") List<Long> userIds
     );
     );
 
 
     /**
     /**
@@ -232,15 +236,18 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
 
 
     /**
     /**
      * @param query
      * @param query
-     * @param orderList
-     * @param type
-     * @param entId
+     * @param orderList 单据状态
+     * @param type      代表承运或者托运
+     * @param entId 企业id
+     * @param contactsIds 联系人id
      * @return
      * @return
      */
      */
     List<TableTops> countLogisticsOrderListByStatus(@Param("query") AcceptCarriageOrderQuery query,
     List<TableTops> countLogisticsOrderListByStatus(@Param("query") AcceptCarriageOrderQuery query,
                                                     @Param("orderList") List<Integer> orderList,
                                                     @Param("orderList") List<Integer> orderList,
                                                     @Param("type") String type,
                                                     @Param("type") String type,
-                                                    @Param("entId") Long entId
+                                                    @Param("entId") Long entId,
+                                                    @Param("contactsIds") List<Long> contactsIds,
+                                                    @Param("userIds") List<Long> userIds
     );
     );
 
 
     /**
     /**

+ 16 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/LogisticsOrderDTO.java

@@ -52,18 +52,34 @@ public class LogisticsOrderDTO {
      * 计划量
      * 计划量
      */
      */
     private BigDecimal amount;
     private BigDecimal amount;
+    private String unit;
+    private String unitLabel;
     /**
     /**
      * 运价
      * 运价
      */
      */
     private String price;
     private String price;
+
+    /**
+     * 运价
+     */
+    private String priceType;
+
+    /**
+     * 运价
+     */
+    private String priceLabel;
     /**
     /**
      * 合理损耗
      * 合理损耗
      */
      */
     private String loss;
     private String loss;
+    private String lossUnit;
+    private String lossUnitLabel;
     /**
     /**
      * 扣亏货值
      * 扣亏货值
      */
      */
     private String goodsPrice;
     private String goodsPrice;
+    private String goodsPriceUnit;
+    private String goodsPriceUnitLabel;
     /**
     /**
      * 联系人
      * 联系人
      */
      */

+ 83 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/WaybillOrderTicketV1Dto.java

@@ -0,0 +1,83 @@
+package com.sckw.transport.model.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import jakarta.validation.constraints.DecimalMin;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+
+/**
+ * @author zk
+ * @desc 车辆运单审核
+ * @date 2023/7/27 0027
+ */
+@Data
+public class WaybillOrderTicketV1Dto {
+    /**
+     * 车辆运单id
+     */
+    @JsonProperty("wOrderId")
+    @NotNull(message = "车辆运单ID不能为空")
+    private Long wOrderId;
+
+    /**
+     * 装卸货数量
+     */
+    @JsonProperty("loadAmount")
+    @NotNull(message = "装货净重不能为空")
+    @DecimalMin(value= "0", inclusive=false, message = "装卸货净重必须等于或大于0")
+    private BigDecimal loadAmount;
+
+    /**
+     * 上传凭证地址,多个以英文逗号隔开
+     */
+    @JsonProperty("loadUrls")
+    @NotBlank(message = "装货凭证不能为空")
+    private String loadUrls;
+
+    /**
+     * 操作时间
+     */
+    @JsonProperty("loadOperateTime")
+    @JsonFormat(locale="zh", pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @NotNull(message = "装货时间不能为空")
+    private Date loadOperateTime;
+
+    /**
+     * 装卸货数量
+     */
+    @JsonProperty("unloadAmount")
+    @NotNull(message = "卸货净重不能为空")
+    @DecimalMin(value= "0", inclusive=false, message = "装卸货净重必须等于或大于0")
+    private BigDecimal unloadAmount;
+
+    /**
+     * 上传凭证地址,多个以英文逗号隔开
+     */
+    @JsonProperty("unloadUrls")
+    @NotBlank(message = "卸货凭证不能为空")
+    private String unloadUrls;
+
+    /**
+     * 操作时间
+     */
+    @JsonProperty("unloadOperateTime")
+    @JsonFormat(locale="zh", pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @NotNull(message = "卸货时间不能为空")
+    private Date unloadOperateTime;
+
+    /**
+     * 备注
+     */
+    @Size(max=100, message = "原因长度不能大于100个字符!")
+    private String remark;
+}

+ 4 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/AcceptCarriageOrderVO.java

@@ -286,4 +286,8 @@ public class AcceptCarriageOrderVO /*extends PageRequest*/ {
      */
      */
     private BigDecimal totalUnloadAmount;
     private BigDecimal totalUnloadAmount;
 
 
+    /**
+     * 订单主体企业id
+     */
+    private  Long entId;
 }
 }

+ 17 - 7
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/AcceptCarriageOrderService.java

@@ -1316,13 +1316,13 @@ public class AcceptCarriageOrderService {
 //        if (amount.compareTo(orderFinishDTO.getLoadAmount()) < 0) {
 //        if (amount.compareTo(orderFinishDTO.getLoadAmount()) < 0) {
 //            throw new BusinessException("完结订单,装货量不能大于运输总量");
 //            throw new BusinessException("完结订单,装货量不能大于运输总量");
 //        }
 //        }
-        if (orderFinishDTO.getUnloadAmount().compareTo(orderFinishDTO.getLoadAmount()) > 0) {
-            throw new BusinessException("完结订单,填写卸货量不能大于装货量");
-        }
+//        if (orderFinishDTO.getUnloadAmount().compareTo(orderFinishDTO.getLoadAmount()) > 0) {
+//            throw new BusinessException("完结订单,填写卸货量不能大于装货量");
+//        }
         /**订单状态验证*/
         /**订单状态验证*/
         if (!LogisticsOrderEnum.WAIT_DELIVERY.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))
         if (!LogisticsOrderEnum.WAIT_DELIVERY.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))
                 && !LogisticsOrderEnum.IN_TRANSIT.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))) {
                 && !LogisticsOrderEnum.IN_TRANSIT.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))) {
-            throw new RuntimeException("当前单并不属于【待派车】,【运输中】状态");
+            throw new RuntimeException("当前单并不属于【待派车】,【运输中】状态");
         }
         }
         /**完结拦截*/
         /**完结拦截*/
         List<Integer> statusList = new ArrayList<>();
         List<Integer> statusList = new ArrayList<>();
@@ -2221,7 +2221,11 @@ public class AcceptCarriageOrderService {
                 case 3 -> query.setUnloadAddressCode(loadCode);
                 case 3 -> query.setUnloadAddressCode(loadCode);
             }
             }
         }
         }
-        List<AcceptCarriageOrderVO> list = logisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId);
+        List<Long> longs = LoginUserHolder.getAuthUserIdList();
+        longs.add(LoginUserHolder.getUserId());
+        List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
+//        LoginUserHolder.getIsMain()
+        List<AcceptCarriageOrderVO> list = logisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId,longList,longList);
         PageInfo<AcceptCarriageOrderVO> pageInfo = new PageInfo<>(list);
         PageInfo<AcceptCarriageOrderVO> pageInfo = new PageInfo<>(list);
         if (CollectionUtils.isEmpty(list)) {
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(pageInfo, list);
             return PageRes.build(pageInfo, list);
@@ -2326,7 +2330,10 @@ public class AcceptCarriageOrderService {
                 case 3 -> query.setUnloadAddressCode(loadCode);
                 case 3 -> query.setUnloadAddressCode(loadCode);
             }
             }
         }
         }
-        List<TableTops> list = logisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId);
+        List<Long> longs = LoginUserHolder.getAuthUserIdList();
+        longs.add(LoginUserHolder.getUserId());
+        List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
+        List<TableTops> list = logisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId,longList,longList);
         List<TableTops> arrayList = new ArrayList<>();
         List<TableTops> arrayList = new ArrayList<>();
         arrayList.addAll(list);
         arrayList.addAll(list);
         /**补全数据状态不齐的情况*/
         /**补全数据状态不齐的情况*/
@@ -2443,7 +2450,10 @@ public class AcceptCarriageOrderService {
                 case 3 -> query.setUnloadAddressCode(loadCode);
                 case 3 -> query.setUnloadAddressCode(loadCode);
             }
             }
         }
         }
-        List<AcceptCarriageOrderVO> list = logisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId);
+        List<Long> longs = LoginUserHolder.getAuthUserIdList();
+        longs.add(LoginUserHolder.getUserId());
+        List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
+        List<AcceptCarriageOrderVO> list = logisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId,longList,longList);
         /**计费方式*/
         /**计费方式*/
         Map<String, String> chargingDictData = getDictData(DictTypeEnum.CHARGING_TYPE.getType());
         Map<String, String> chargingDictData = getDictData(DictTypeEnum.CHARGING_TYPE.getType());
         /**结算周期*/
         /**结算周期*/

+ 16 - 7
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java

@@ -764,13 +764,13 @@ public class ConsignOrderService {
 //        if (amount.compareTo(orderFinishDTO.getLoadAmount()) < 0) {
 //        if (amount.compareTo(orderFinishDTO.getLoadAmount()) < 0) {
 //            throw new BusinessException("完结订单,装货量不能大于运输总量");
 //            throw new BusinessException("完结订单,装货量不能大于运输总量");
 //        }
 //        }
-        if (orderFinishDTO.getUnloadAmount().compareTo(orderFinishDTO.getLoadAmount()) > 0) {
-            throw new BusinessException("完结订单,填写卸货量不能大于装货量");
-        }
+//        if (orderFinishDTO.getUnloadAmount().compareTo(orderFinishDTO.getLoadAmount()) > 0) {
+//            throw new BusinessException("完结订单,填写卸货量不能大于装货量");
+//        }
         /**订单状态验证*/
         /**订单状态验证*/
         if (!LogisticsOrderEnum.WAIT_DELIVERY.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))
         if (!LogisticsOrderEnum.WAIT_DELIVERY.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))
                 && !LogisticsOrderEnum.IN_TRANSIT.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))) {
                 && !LogisticsOrderEnum.IN_TRANSIT.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))) {
-            throw new BusinessException("当前单并不属于【待派车】,【运输中】状态");
+            throw new BusinessException("当前单并不属于【待派车】,【运输中】状态");
         }
         }
         //验证当前物流订单是否还存在进行的车辆运单
         //验证当前物流订单是否还存在进行的车辆运单
         boolean flag = judgmentWaybillOrderIsFinish(id);
         boolean flag = judgmentWaybillOrderIsFinish(id);
@@ -1629,7 +1629,10 @@ public class ConsignOrderService {
                 case 3 -> query.setUnloadAddressCode(loadCode);
                 case 3 -> query.setUnloadAddressCode(loadCode);
             }
             }
         }
         }
-        List<AcceptCarriageOrderVO> list = kwtLogisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId);
+        List<Long> longs = LoginUserHolder.getAuthUserIdList();
+        longs.add(LoginUserHolder.getUserId());
+        List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
+        List<AcceptCarriageOrderVO> list = kwtLogisticsOrderMapper.selectLogisticsOrderList(query, orderList, type, entId,longList,longList);
         PageInfo<AcceptCarriageOrderVO> pageInfo = new PageInfo<>(list);
         PageInfo<AcceptCarriageOrderVO> pageInfo = new PageInfo<>(list);
         if (CollectionUtils.isEmpty(list)) {
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(pageInfo, list);
             return PageRes.build(pageInfo, list);
@@ -1735,7 +1738,10 @@ public class ConsignOrderService {
                 case 3 -> query.setUnloadAddressCode(loadCode);
                 case 3 -> query.setUnloadAddressCode(loadCode);
             }
             }
         }
         }
-        List<TableTops> list = kwtLogisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId);
+        List<Long> longs = LoginUserHolder.getAuthUserIdList();
+        longs.add(LoginUserHolder.getUserId());
+        List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
+        List<TableTops> list = kwtLogisticsOrderMapper.countLogisticsOrderListByStatus(query, orderList, type, entId,longList,longList);
         List<TableTops> arrayList = new ArrayList<>();
         List<TableTops> arrayList = new ArrayList<>();
         arrayList.addAll(list);
         arrayList.addAll(list);
         /**补全数据状态不齐的情况*/
         /**补全数据状态不齐的情况*/
@@ -1826,7 +1832,10 @@ public class ConsignOrderService {
                 case 3 -> query.setUnloadAddressCode(loadCode);
                 case 3 -> query.setUnloadAddressCode(loadCode);
             }
             }
         }
         }
-        List<ConsignOrderVO> list = kwtLogisticsOrderMapper.selectConsignLogisticsOrderList(query, orderList, type, entId);
+        List<Long> longs = LoginUserHolder.getAuthUserIdList();
+        longs.add(LoginUserHolder.getUserId());
+        List<Long> longList = longs.stream().distinct().collect(Collectors.toList());
+        List<ConsignOrderVO> list = kwtLogisticsOrderMapper.selectConsignLogisticsOrderList(query, orderList, type, entId,longList,longList);
         /**计费方式*/
         /**计费方式*/
         Map<String, String> chargingDictData = commonService.getDictData(DictTypeEnum.CHARGING_TYPE.getType());
         Map<String, String> chargingDictData = commonService.getDictData(DictTypeEnum.CHARGING_TYPE.getType());
         /**结算周期*/
         /**结算周期*/

+ 74 - 7
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtWaybillOrderService.java

@@ -1526,7 +1526,7 @@ public class KwtWaybillOrderService {
         wOrder.set_id(waybillOrder.getId());
         wOrder.set_id(waybillOrder.getId());
         wOrder.setLoadAmount(waybillOrder.getLoadAmount());
         wOrder.setLoadAmount(waybillOrder.getLoadAmount());
         wOrder.setLoadUrls(params.getUrls());
         wOrder.setLoadUrls(params.getUrls());
-        wOrder.setLoadTime(waybillOrder.getUpdateTime());
+        wOrder.setLoadTime(params.getOperateTime());
         editSckwWaybillOrder(wOrder, waybillOrder, 2);
         editSckwWaybillOrder(wOrder, waybillOrder, 2);
 
 
         //2承运订单
         //2承运订单
@@ -1661,7 +1661,7 @@ public class KwtWaybillOrderService {
         wOrder.setDeficitAmount(waybillOrder.getDeficitAmount());
         wOrder.setDeficitAmount(waybillOrder.getDeficitAmount());
         wOrder.setDeficitPrice(waybillOrder.getDeficitPrice());
         wOrder.setDeficitPrice(waybillOrder.getDeficitPrice());
         wOrder.setUnloadUrls(params.getUrls());
         wOrder.setUnloadUrls(params.getUrls());
-        wOrder.setUnloadTime(waybillOrder.getUpdateTime());
+        wOrder.setUnloadTime(params.getOperateTime());
         editSckwWaybillOrder(wOrder, waybillOrder, 2);
         editSckwWaybillOrder(wOrder, waybillOrder, 2);
 
 
         //2承运订单
         //2承运订单
@@ -1742,7 +1742,7 @@ public class KwtWaybillOrderService {
                 && subcontractBool) {
                 && subcontractBool) {
             //---------------------------------------------zk 2023-08-01 全量可运
             //---------------------------------------------zk 2023-08-01 全量可运
             /**1-3下级分包承运订单运输完成**/
             /**1-3下级分包承运订单运输完成**/
-            logisticsOrder.setStatus(LogisticsOrderEnum.HAVE_FINISHED.getCode());
+            //logisticsOrder.setStatus(LogisticsOrderEnum.HAVE_FINISHED.getCode());//取消自动完结
             logisticsOrderDao.updateById(logisticsOrder);
             logisticsOrderDao.updateById(logisticsOrder);
 
 
             /**1-4承运订单状态记录**/
             /**1-4承运订单状态记录**/
@@ -1909,6 +1909,65 @@ public class KwtWaybillOrderService {
         return HttpResult.ok("修改单证成功!");
         return HttpResult.ok("修改单证成功!");
     }
     }
 
 
+    /**
+     * @param params {}
+     * @desc 单证审核(编辑单证)
+     * @author zk
+     * @date 2023/7/26
+     **/
+    public HttpResult editTicket(WaybillOrderTicketV1Dto params) {
+        /**1数据校验**/
+        KwtWaybillOrder waybillOrder = waybillOrderDao.selectById(params.getWOrderId());
+        if (waybillOrder == null) {
+            return HttpResult.error("车辆运单不存在!");
+        }
+        //已卸货/审批不通过车辆运单才能审核
+        if (waybillOrder.getStatus() != CarWaybillEnum.COMPLETION_UNLOADING.getCode()
+                && waybillOrder.getStatus() != CarWaybillEnum.APPROVAL_NO_PASS.getCode()) {
+            return HttpResult.error("车辆运单当前状态不能编辑!");
+        }
+
+        /**2更新车辆运单**/
+        KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(waybillOrder.getLOrderId());
+        waybillOrder.setLoadAmount(params.getLoadAmount());
+        waybillOrder.setUnloadAmount(params.getUnloadAmount());
+        waybillOrder.setDeficitAmount(waybillOrder.getLoadAmount().subtract(waybillOrder.getUnloadAmount()));
+        BigDecimal deficitPrice = deficitPrice(waybillOrder.getLoadAmount(), waybillOrder.getDeficitAmount(),
+                logisticsOrder.getLoss(), logisticsOrder.getLossUnit(), logisticsOrder.getGoodsPrice());
+        waybillOrder.setDeficitPrice(deficitPrice);
+        waybillOrderDao.updateById(waybillOrder);
+
+        /**3更新榜单信息**/
+        KwtWaybillOrderTicket loadTicket = waybillOrderTicketDao.findWaybillOrderTicket(params.getWOrderId(), Global.NUMERICAL_ONE);
+        loadTicket.setAmount(params.getLoadAmount());
+        loadTicket.setUrls(params.getLoadUrls());
+        loadTicket.setOperateTime(params.getLoadOperateTime());
+        waybillOrderTicketDao.updateById(loadTicket);
+        KwtWaybillOrderTicket unloadTicket = waybillOrderTicketDao.findWaybillOrderTicket(params.getWOrderId(), Global.NUMERICAL_TWO);
+        unloadTicket.setAmount(params.getUnloadAmount());
+        unloadTicket.setUrls(params.getUnloadUrls());
+        unloadTicket.setOperateTime(params.getUnloadOperateTime());
+        waybillOrderTicketDao.updateById(unloadTicket);
+
+        /**4Mongodb数据更新**/
+        //1车辆运单
+        SckwWaybillOrder wOrder = new SckwWaybillOrder();
+        wOrder.set_id(waybillOrder.getId());
+        wOrder.setLoadAmount(waybillOrder.getLoadAmount());
+        wOrder.setLoadTime(params.getLoadOperateTime());
+        wOrder.setLoadUrls(params.getLoadUrls());
+        wOrder.setUnloadAmount(waybillOrder.getUnloadAmount());
+        wOrder.setUnloadTime(params.getUnloadOperateTime());
+        wOrder.setUnloadUrls(params.getUnloadUrls());
+        wOrder.setDeficitAmount(waybillOrder.getDeficitAmount());
+        wOrder.setDeficitPrice(waybillOrder.getDeficitPrice());
+        editSckwWaybillOrder(wOrder, waybillOrder, Global.NUMERICAL_TWO);
+
+        /**5发送消息**/
+
+        return HttpResult.ok("车辆运单审核完成!");
+    }
+
     /**
     /**
      * @param wOrderId
      * @param wOrderId
      * @desc 修改单证查询运单
      * @desc 修改单证查询运单
@@ -1931,15 +1990,20 @@ public class KwtWaybillOrderService {
         KwtWaybillOrderAddress unloadAddress = this.getAddress(waybillOrder.getId(), Global.NUMERICAL_TWO, Global.NUMERICAL_TWO);
         KwtWaybillOrderAddress unloadAddress = this.getAddress(waybillOrder.getId(), Global.NUMERICAL_TWO, Global.NUMERICAL_TWO);
         //商品信息
         //商品信息
         KwtLogisticsOrderGoods goods = logisticsOrderGoodsDao.findByGoods(waybillOrder.getLOrderId());
         KwtLogisticsOrderGoods goods = logisticsOrderGoodsDao.findByGoods(waybillOrder.getLOrderId());
+        //审批意见
+        KwtWaybillOrderTrack track = waybillOrderTrackDao.findWaybillOrderTrack(waybillOrder.getLOrderId(), CarWaybillEnum.APPROVAL_NO_PASS.getCode());
+
         //用户数据集
         //用户数据集
         List<Long> createBys = new ArrayList() {{
         List<Long> createBys = new ArrayList() {{
-            add(loadTicket.getUpdateBy());
-            add(unloadTicket.getUpdateBy());
+            add(loadTicket != null ? loadTicket.getUpdateBy() : null);
+            add(unloadTicket != null ? unloadTicket.getUpdateBy() : null);
+            add(track != null ? track.getCreateBy() : null);
         }};
         }};
         createBys = createBys.stream().distinct().collect(Collectors.toList());
         createBys = createBys.stream().distinct().collect(Collectors.toList());
         Map<Long, UserCacheResDto> users = remoteSystemService.queryUserCacheMapByIds(createBys);
         Map<Long, UserCacheResDto> users = remoteSystemService.queryUserCacheMapByIds(createBys);
-        UserCacheResDto loadUser = users == null ? null : users.get(loadTicket.getUpdateBy());
-        UserCacheResDto unloadUser = users == null ? null : users.get(unloadTicket.getUpdateBy());
+        UserCacheResDto loadUser = users == null ? null : users.get(loadTicket != null ? loadTicket.getUpdateBy() : null);
+        UserCacheResDto unloadUser = users == null ? null : users.get(unloadTicket != null ? unloadTicket.getUpdateBy() : null);
+        UserCacheResDto approver = users == null ? null : users.get(track != null ? track.getCreateBy() : null);
 
 
         Map result = new HashMap();
         Map result = new HashMap();
         result.put("wOrderId", wOrderId);
         result.put("wOrderId", wOrderId);
@@ -1966,6 +2030,9 @@ public class KwtWaybillOrderService {
         result.put("unloadCreateByName", unloadUser != null ? unloadUser.getName() : null);
         result.put("unloadCreateByName", unloadUser != null ? unloadUser.getName() : null);
         result.put("unloadCityName", unloadAddress != null ? unloadAddress.getCityName() : null);
         result.put("unloadCityName", unloadAddress != null ? unloadAddress.getCityName() : null);
         result.put("unloadDetailAddress", unloadAddress != null ? unloadAddress.getDetailAddress() : null);
         result.put("unloadDetailAddress", unloadAddress != null ? unloadAddress.getDetailAddress() : null);
+        result.put("approvalTime", track != null ? track.getCreateTime() : null);
+        result.put("approvalOpinions", track != null ? track.getRemark() : null);
+        result.put("approver", approver != null ? approver.getName() : null);
 
 
         return HttpResult.ok(result);
         return HttpResult.ok(result);
     }
     }

+ 25 - 5
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/LogisticsConsignmentService.java

@@ -656,6 +656,12 @@ public class LogisticsConsignmentService {
             if (flag) {
             if (flag) {
                 /**数据展示*/
                 /**数据展示*/
                 list = kwtLogisticsOrderMapper.selectOrderListNotPage(id, type);
                 list = kwtLogisticsOrderMapper.selectOrderListNotPage(id, type);
+                /**计量单位*/
+                Map<String, String> unitTypeDictData = commonService.getDictData(DictTypeEnum.UNIT_TYPE.getType());
+                /**运价方式*/
+                Map<String, String> priceDictData = commonService.getDictData(DictTypeEnum.PRICE_TYPE.getType());
+                /**合理损耗*/
+                Map<String, String> taxRateTypeDictData = commonService.getDictData(DictTypeEnum.TAX_RATE_TYPE.getType());
                 if (CollectionUtils.isNotEmpty(list)) {
                 if (CollectionUtils.isNotEmpty(list)) {
                     for (LogisticsOrderDTO logisticsOrderDTO : list) {
                     for (LogisticsOrderDTO logisticsOrderDTO : list) {
                         logisticsOrderDTO.setStatusLabel(LogisticsOrderEnum.getDestination(logisticsOrderDTO.getStatus()));
                         logisticsOrderDTO.setStatusLabel(LogisticsOrderEnum.getDestination(logisticsOrderDTO.getStatus()));
@@ -663,6 +669,10 @@ public class LogisticsConsignmentService {
                                 (remoteSystemService.queryUserCacheById(Long.parseLong(logisticsOrderDTO.getCreateBy())) == null ? null :
                                 (remoteSystemService.queryUserCacheById(Long.parseLong(logisticsOrderDTO.getCreateBy())) == null ? null :
                                         remoteSystemService.queryUserCacheById(Long.parseLong(logisticsOrderDTO.getCreateBy())).getName());
                                         remoteSystemService.queryUserCacheById(Long.parseLong(logisticsOrderDTO.getCreateBy())).getName());
                         logisticsOrderDTO.setCreateName(createName);
                         logisticsOrderDTO.setCreateName(createName);
+                        logisticsOrderDTO.setPriceLabel(priceDictData.get(logisticsOrderDTO.getPriceType()));
+                        logisticsOrderDTO.setLossUnitLabel(taxRateTypeDictData.get(logisticsOrderDTO.getLossUnit()));
+                        logisticsOrderDTO.setGoodsPriceUnitLabel(priceDictData.get(logisticsOrderDTO.getGoodsPriceUnit()));
+                        logisticsOrderDTO.setUnitLabel(unitTypeDictData.get(logisticsOrderDTO.getUnit()));
                     }
                     }
                     returnList.addAll(list);
                     returnList.addAll(list);
                 }
                 }
@@ -756,6 +766,12 @@ public class LogisticsConsignmentService {
             if (flag) {
             if (flag) {
                 /**数据展示*/
                 /**数据展示*/
                 list = kwtLogisticsOrderMapper.selectOrderListNotPage(id, type);
                 list = kwtLogisticsOrderMapper.selectOrderListNotPage(id, type);
+                /**计量单位*/
+                Map<String, String> unitTypeDictData = commonService.getDictData(DictTypeEnum.UNIT_TYPE.getType());
+                /**运价方式*/
+                Map<String, String> priceDictData = commonService.getDictData(DictTypeEnum.PRICE_TYPE.getType());
+                /**合理损耗*/
+                Map<String, String> taxRateTypeDictData = commonService.getDictData(DictTypeEnum.TAX_RATE_TYPE.getType());
                 if (CollectionUtils.isNotEmpty(list)) {
                 if (CollectionUtils.isNotEmpty(list)) {
                     for (LogisticsOrderDTO logisticsOrderDTO : list) {
                     for (LogisticsOrderDTO logisticsOrderDTO : list) {
                         logisticsOrderDTO.setStatusLabel(LogisticsOrderEnum.getDestination(logisticsOrderDTO.getStatus()));
                         logisticsOrderDTO.setStatusLabel(LogisticsOrderEnum.getDestination(logisticsOrderDTO.getStatus()));
@@ -763,6 +779,10 @@ public class LogisticsConsignmentService {
                                 (remoteSystemService.queryUserCacheById(Long.parseLong(logisticsOrderDTO.getCreateBy())) == null ? null :
                                 (remoteSystemService.queryUserCacheById(Long.parseLong(logisticsOrderDTO.getCreateBy())) == null ? null :
                                         remoteSystemService.queryUserCacheById(Long.parseLong(logisticsOrderDTO.getCreateBy())).getName());
                                         remoteSystemService.queryUserCacheById(Long.parseLong(logisticsOrderDTO.getCreateBy())).getName());
                         logisticsOrderDTO.setCreateName(createName);
                         logisticsOrderDTO.setCreateName(createName);
+                        logisticsOrderDTO.setPriceLabel(priceDictData.get(logisticsOrderDTO.getPriceType()));
+                        logisticsOrderDTO.setLossUnitLabel(taxRateTypeDictData.get(logisticsOrderDTO.getLossUnit()));
+                        logisticsOrderDTO.setGoodsPriceUnitLabel(priceDictData.get(logisticsOrderDTO.getGoodsPriceUnit()));
+                        logisticsOrderDTO.setUnitLabel(unitTypeDictData.get(logisticsOrderDTO.getUnit()));
                     }
                     }
                     returnList.addAll(list);
                     returnList.addAll(list);
                 }
                 }
@@ -1171,13 +1191,13 @@ public class LogisticsConsignmentService {
 //        if (amount.compareTo(orderFinishDTO.getLoadAmount()) < 0) {
 //        if (amount.compareTo(orderFinishDTO.getLoadAmount()) < 0) {
 //            throw new BusinessException("完结订单,装货量不能大于运输总量");
 //            throw new BusinessException("完结订单,装货量不能大于运输总量");
 //        }
 //        }
-        if (orderFinishDTO.getUnloadAmount().compareTo(orderFinishDTO.getLoadAmount()) > 0) {
-            throw new BusinessException("完结订单,填写卸货量不能大于装货量");
-        }
+//        if (orderFinishDTO.getUnloadAmount().compareTo(orderFinishDTO.getLoadAmount()) > 0) {
+//            throw new BusinessException("完结订单,填写卸货量不能大于装货量");
+//        }
         /**订单状态验证*/
         /**订单状态验证*/
         if (!LogisticsOrderEnum.WAIT_DELIVERY.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))
         if (!LogisticsOrderEnum.WAIT_DELIVERY.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))
                 && !LogisticsOrderEnum.IN_TRANSIT.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))) {
                 && !LogisticsOrderEnum.IN_TRANSIT.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))) {
-            throw new BusinessException("当前单并不属于【待派车】,【运输中】状态");
+            throw new BusinessException("当前单并不属于【待派车】,【运输中】状态");
         }
         }
         //验证当前物流订单是否还存在进行的车辆运单
         //验证当前物流订单是否还存在进行的车辆运单
         boolean flag = judgmentWaybillOrderIsFinish(id);
         boolean flag = judgmentWaybillOrderIsFinish(id);
@@ -1236,7 +1256,7 @@ public class LogisticsConsignmentService {
         tradeOrder.setActualUnloadAmount(map.get("totalUnloadAmount"));
         tradeOrder.setActualUnloadAmount(map.get("totalUnloadAmount"));
         tradeOrder.setUpdateBy(LoginUserHolder.getUserId());
         tradeOrder.setUpdateBy(LoginUserHolder.getUserId());
         tradeOrder.setUpdateByName(LoginUserHolder.getUserName());
         tradeOrder.setUpdateByName(LoginUserHolder.getUserName());
-        log.info("采购订单手动完结订单请求参数:{}",JSONObject.toJSONString(tradeOrder));
+        log.info("采购订单手动完结订单请求参数:{}", JSONObject.toJSONString(tradeOrder));
         HttpResult httpResult = tradeOrderInfoService.completeLogisticsOrder(tradeOrder);
         HttpResult httpResult = tradeOrderInfoService.completeLogisticsOrder(tradeOrder);
         if (httpResult.getCode() != HttpStatus.SUCCESS_CODE) {
         if (httpResult.getCode() != HttpStatus.SUCCESS_CODE) {
             log.info("贸易订单-采购订单/销售订单-手动完结订单异常,传递信息:{},返回信息:{}", JSONObject.toJSONString(tradeOrder), JSONObject.toJSONString(httpResult));
             log.info("贸易订单-采购订单/销售订单-手动完结订单异常,传递信息:{},返回信息:{}", JSONObject.toJSONString(tradeOrder), JSONObject.toJSONString(httpResult));

+ 56 - 14
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java

@@ -20,10 +20,7 @@ import com.sckw.system.api.model.dto.res.AreaTreeFrontResDto;
 import com.sckw.system.api.model.dto.res.SysDictResDto;
 import com.sckw.system.api.model.dto.res.SysDictResDto;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import com.sckw.transport.dao.*;
 import com.sckw.transport.dao.*;
-import com.sckw.transport.model.KwtLogisticsOrder;
-import com.sckw.transport.model.KwtLogisticsOrderCirculate;
-import com.sckw.transport.model.KwtWaybillOrder;
-import com.sckw.transport.model.KwtWaybillOrderTrack;
+import com.sckw.transport.model.*;
 import com.sckw.transport.model.dto.AddressDropListDTO;
 import com.sckw.transport.model.dto.AddressDropListDTO;
 import com.sckw.transport.model.dto.WayBillDetailDTO;
 import com.sckw.transport.model.dto.WayBillDetailDTO;
 import com.sckw.transport.model.dto.WaybillListAppDTO;
 import com.sckw.transport.model.dto.WaybillListAppDTO;
@@ -154,16 +151,28 @@ public class WaybillManagementService {
             waybillCarVO.setDriverId(String.valueOf(info.getTruckId()));
             waybillCarVO.setDriverId(String.valueOf(info.getTruckId()));
             waybillCarVO.setTrailerNo(info.getTruckTrailerNo());
             waybillCarVO.setTrailerNo(info.getTruckTrailerNo());
             // 票据
             // 票据
-            if (info.getLoadTime() != null) {
-                waybillTicketVO.setLoadTime(DateUtil.getDateTime(info.getLoadTime()));
-            }
-            waybillTicketVO.setLoadWeight(String.valueOf(info.getLoadAmount()));
-            waybillTicketVO.setLoadUrl(String.valueOf(info.getLoadUrls()));
-            if (info.getUnloadTime() != null) {
-                waybillTicketVO.setUnloadTime(DateUtil.getDateTime(info.getUnloadTime()));
+            List<KwtWaybillOrderTicket> waybillOrderTickets = kwtWaybillOrderTicketMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrderTicket>()
+                    .eq(KwtWaybillOrderTicket::getWOrderId, id)
+            );
+            if (!org.springframework.util.CollectionUtils.isEmpty(waybillOrderTickets)) {
+                for (KwtWaybillOrderTicket waybillOrderTicket : waybillOrderTickets) {
+                    //1装货单/2卸货单
+                    if (waybillOrderTicket.getType() == 1) {
+                        if (info.getLoadTime() != null) {
+                            waybillTicketVO.setLoadTime(waybillOrderTicket.getOperateTime() == null ? null : DateUtil.getDateTime(waybillOrderTicket.getOperateTime()));
+                        }
+                        waybillTicketVO.setLoadWeight(String.valueOf(info.getLoadAmount()));
+                        waybillTicketVO.setLoadUrl(String.valueOf(info.getLoadUrls()));
+                    }
+                    if (waybillOrderTicket.getType() == 2) {
+                        if (info.getUnloadTime() != null) {
+                            waybillTicketVO.setUnloadTime(waybillOrderTicket.getOperateTime() == null ? null : DateUtil.getDateTime(waybillOrderTicket.getOperateTime()));
+                        }
+                        waybillTicketVO.setUnloadWeight(String.valueOf(info.getUnloadAmount()));
+                        waybillTicketVO.setUnloadUrl(String.valueOf(info.getUnloadUrls()));
+                    }
+                }
             }
             }
-            waybillTicketVO.setUnloadWeight(String.valueOf(info.getUnloadAmount()));
-            waybillTicketVO.setUnloadUrl(String.valueOf(info.getUnloadUrls()));
             waybillTicketVO.setDeficitAmount(String.valueOf(info.getDeficitAmount()));
             waybillTicketVO.setDeficitAmount(String.valueOf(info.getDeficitAmount()));
             BigDecimal deficitLoss = info.getLoss() == null ? BigDecimal.valueOf(0) : info.getLoss();
             BigDecimal deficitLoss = info.getLoss() == null ? BigDecimal.valueOf(0) : info.getLoss();
             BigDecimal deficitAmount = info.getDeficitAmount() == null ? BigDecimal.valueOf(0) : info.getDeficitAmount();
             BigDecimal deficitAmount = info.getDeficitAmount() == null ? BigDecimal.valueOf(0) : info.getDeficitAmount();
@@ -360,6 +369,7 @@ public class WaybillManagementService {
         // mongo查询列数据,不足的数据单独关联表查询
         // mongo查询列数据,不足的数据单独关联表查询
         // 状态查询 status [2-8]
         // 状态查询 status [2-8]
         List<Integer> statuses = initWaybillIndexStatus();
         List<Integer> statuses = initWaybillIndexStatus();
+//        List<Integer> statuses = CarWaybillEnum.getCodes();
         // 初始化各状态
         // 初始化各状态
         List<WaybillStatusVO> statusVOS = new ArrayList<>();
         List<WaybillStatusVO> statusVOS = new ArrayList<>();
         statuses.forEach(e -> {
         statuses.forEach(e -> {
@@ -461,6 +471,7 @@ public class WaybillManagementService {
         statuses.add(CarWaybillEnum.WAIT_UNLOADING.getCode());
         statuses.add(CarWaybillEnum.WAIT_UNLOADING.getCode());
         statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
         statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
         statuses.add(CarWaybillEnum.APPROVAL_PASS.getCode());
         statuses.add(CarWaybillEnum.APPROVAL_PASS.getCode());
+//        List<Integer> statuses = CarWaybillEnum.getCodes();
         return statuses;
         return statuses;
     }
     }
 
 
@@ -485,7 +496,16 @@ public class WaybillManagementService {
                 _statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
                 _statuses.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
                 _statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode());
                 _statuses.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode());
                 criteria.and("status").in(_statuses);
                 criteria.and("status").in(_statuses);
-            } else if (!query.getStatus().equals("all") && (!query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode())))) {
+            } else if (query.getStatus().equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO))) {
+                List<Integer> _statuses = new ArrayList<>();
+                _statuses.add(CarWaybillEnum.REJECT_ORDER.getCode());
+                _statuses.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode());
+                _statuses.add(CarWaybillEnum.REVOKED.getCode());
+                criteria.and("status").in(_statuses);
+            } else if (!query.getStatus().equals("all")
+                    && (!query.getStatus().equals(String.valueOf(CarWaybillEnum.COMPLETION_UNLOADING.getCode())))
+                    && (!query.getStatus().equals(String.valueOf(NumberConstant.ONE_ZERO_ZERO)))
+            ) {
                 criteria.and("status").is(Integer.valueOf(query.getStatus()));
                 criteria.and("status").is(Integer.valueOf(query.getStatus()));
             }
             }
         }
         }
@@ -582,6 +602,7 @@ public class WaybillManagementService {
             top.setName(CarWaybillEnum.getName(e));
             top.setName(CarWaybillEnum.getName(e));
             listMap.put(String.valueOf(e), top);
             listMap.put(String.valueOf(e), top);
         });
         });
+        /**计算总条数*/
         if (CollectionUtils.isNotEmpty(results)) {
         if (CollectionUtils.isNotEmpty(results)) {
             for (TableTops result : results) {
             for (TableTops result : results) {
                 if (listMap.containsKey(result.getValue())) {
                 if (listMap.containsKey(result.getValue())) {
@@ -590,7 +611,28 @@ public class WaybillManagementService {
                 allTotal += result.getTotal();
                 allTotal += result.getTotal();
             }
             }
         }
         }
+        // allTotal= Math.toIntExact(results.stream().filter(item -> ObjectUtil.isNotEmpty(item.getTotal())).collect(Collectors.summarizingInt(item -> item.getTotal())).getSum());
         listMap.get("all").setTotal(allTotal);
         listMap.get("all").setTotal(allTotal);
+
+        /**数据状态整合做计算
+         * 整合页面数据状态查询*/
+        if (CollectionUtils.isNotEmpty(results)) {
+            //已卸货包含本身以及审核不通过
+            Integer number = 0;
+            for (TableTops result : results) {
+                if (CarWaybillEnum.APPROVAL_NO_PASS.getStatus().equals(result.getValue())) {
+                    Integer total = result.getTotal();
+                    number = number + total;
+                }
+            }
+            for (TableTops result : results) {
+                if (CarWaybillEnum.COMPLETION_UNLOADING.getStatus().equals(result.getValue())) {
+                    result.setTotal(result.getTotal() + number);
+                    listMap.put(result.getValue(), result);
+                }
+            }
+        }
+
         return HttpResult.ok(listMap.values());
         return HttpResult.ok(listMap.values());
     }
     }
 
 

+ 121 - 16
sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

@@ -77,21 +77,25 @@
     </select>
     </select>
 
 
     <select id="selectOrderListNotPage" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
     <select id="selectOrderListNotPage" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
-        SELECT a.id          as lOrderId,
-               a.l_order_no  as lOrderNo,
-               b.`status`    as `status`,
-               a.t_order_id  as tOrderId,
-               a.t_order_no  as tOrderNo,
-               a.payment     as payment,
+        SELECT a.id               as lOrderId,
+               a.l_order_no       as lOrderNo,
+               b.`status`         as `status`,
+               a.t_order_id       as tOrderId,
+               a.t_order_no       as tOrderNo,
+               a.payment          as payment,
                a.amount,
                a.amount,
+               a.unit             as unit,
                a.price,
                a.price,
+               a.price_type       as priceType,
                a.loss,
                a.loss,
-               a.goods_price as goodsPrice,
-               c.firm_name   as companyName,
+               a.loss_unit        AS lossUnit,
+               a.goods_price      as goodsPrice,
+               a.goods_price_unit as goodsPriceUnit,
+               c.firm_name        as companyName,
                c.contacts,
                c.contacts,
                c.phone,
                c.phone,
-               a.create_by   as createBy,
-               a.create_time as createTime
+               a.create_by        as createBy,
+               a.create_time      as createTime
         FROM kwt_logistics_order a
         FROM kwt_logistics_order a
                  LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
                  LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
                  LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
                  LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
@@ -791,7 +795,6 @@
         g.goods_type AS goodsType,
         g.goods_type AS goodsType,
         f.contract_id AS contractId,
         f.contract_id AS contractId,
         f.contract_no AS contractNo,
         f.contract_no AS contractNo,
-        <!--        f.contract_name AS contractName,-->
         f.signing_way AS signing,
         f.signing_way AS signing,
         d.ent_id AS consignCompanyId,
         d.ent_id AS consignCompanyId,
         d.top_ent_id AS consignTopEntId,
         d.top_ent_id AS consignTopEntId,
@@ -851,14 +854,44 @@
             <if test="type == 1">
             <if test="type == 1">
                 and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
                 and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
 <!--                AND (-->
 <!--                AND (-->
-<!--                a.ent_id = 156382319450525696-->
-<!--                AND a.create_by IN ( 156382319433748480 ))-->
+<!--                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 (-->
 <!--                OR (-->
-<!--                ( d.top_ent_id = 156382319450525696 OR d.ent_id = 156382319450525696 )-->
-<!--                AND d.contacts_id IN ( 156382319433748480, 156382319433748480 ))-->
+<!--                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>
             <if test="type == 2">
             <if test="type == 2">
                 and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
                 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>-->
+<!--                )-->
             </if>
             </if>
             <if test="query.keywords != null and query.keywords != ''">
             <if test="query.keywords != null and query.keywords != ''">
                 and (
                 and (
@@ -902,7 +935,7 @@
                 and a.billing_mode =#{query.billingMode}
                 and a.billing_mode =#{query.billingMode}
             </if>
             </if>
         </where>
         </where>
-        ORDER BY a.id DESC
+        ORDER BY a.create_time DESC
         <!--               ,a.create_time-->
         <!--               ,a.create_time-->
     </select>
     </select>
     <select id="countLogisticsOrderListByStatus" resultType="com.sckw.mongo.model.TableTops">
     <select id="countLogisticsOrderListByStatus" resultType="com.sckw.mongo.model.TableTops">
@@ -925,9 +958,45 @@
             a.del_flag = 0
             a.del_flag = 0
             <if test="type == 1">
             <if test="type == 1">
                 and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
                 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>-->
+<!--                )-->
             </if>
             </if>
             <if test="type == 2">
             <if test="type == 2">
                 and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
                 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>-->
+<!--                )-->
             </if>
             </if>
             <if test="query.keywords != null and query.keywords != ''">
             <if test="query.keywords != null and query.keywords != ''">
                 and (
                 and (
@@ -1104,9 +1173,45 @@
             a.del_flag = 0
             a.del_flag = 0
             <if test="type == 1">
             <if test="type == 1">
                 and (d.top_ent_id = #{entId} or d.ent_id = #{entId})
                 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>-->
+<!--                )-->
             </if>
             </if>
             <if test="type == 2">
             <if test="type == 2">
                 and (e.top_ent_id = #{entId} or e.ent_id = #{entId})
                 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>-->
+<!--                )-->
             </if>
             </if>
             <if test="query.keywords != null and query.keywords != ''">
             <if test="query.keywords != null and query.keywords != ''">
                 and (
                 and (