Просмотр исходного кода

1、对接车辆中台;
2、新增运单单据编辑接口;

zk 2 лет назад
Родитель
Сommit
02587d6c65

+ 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
      *
@@ -365,9 +384,113 @@ public class DateUtils extends DateUtil {
         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);
+    }
+
+
+}

+ 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 車牌號}
-     * @description 车辆查询(业务关联+归属车辆)
+     * @desc 车辆查询(业务关联+归属车辆)
      * @author zk
      * @date 2023/7/26
      **/
     @PostMapping("/findTruck")
     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.vo.KwfDriverVo;
 import com.sckw.fleet.model.vo.KwfTableTopCount;
+import com.sckw.fleet.model.vo.KwfTruckMonitorVo;
 import com.sckw.fleet.model.vo.KwfTruckVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -49,8 +50,21 @@ public interface KwfTruckMapper extends BaseMapper<KwfTruck> {
 
     /**
      * 企业运力统计
-     * @param entIds
+     * @param entIds 企业id集
      * @return
      */
     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);
         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.read.metadata.ReadSheet;
 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.FileEnum;
 import com.sckw.core.exception.SystemException;
 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.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.context.LoginUserHolder;
+import com.sckw.core.web.request.HttpClientUtil;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.easyexcel.ExcelImportListener;
 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 org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 import java.io.InputStream;
 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;
 
 /**
@@ -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 参数
      * @desc 校验车辆是否有证书
@@ -690,4 +733,113 @@ public class KwfTruckService {
         }
         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
     </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>

+ 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);
     }
 
+    /**
+     * @param params {}
+     * @desc 修改单证-装卸货一起修改
+     * @author zk
+     * @date 2023/7/26
+     **/
+    @PostMapping("/editTicketV1")
+    public HttpResult editTicketV1(@RequestBody @Valid WaybillOrderTicketV1Dto params){
+        return waybillOrderService.editTicket(params);
+    }
+
     /**
      * @param wOrderId
      * @desc 修改单证查询运单

+ 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;
+}

+ 70 - 3
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.setLoadAmount(waybillOrder.getLoadAmount());
         wOrder.setLoadUrls(params.getUrls());
-        wOrder.setLoadTime(waybillOrder.getUpdateTime());
+        wOrder.setLoadTime(params.getOperateTime());
         editSckwWaybillOrder(wOrder, waybillOrder, 2);
 
         //2承运订单
@@ -1661,7 +1661,7 @@ public class KwtWaybillOrderService {
         wOrder.setDeficitAmount(waybillOrder.getDeficitAmount());
         wOrder.setDeficitPrice(waybillOrder.getDeficitPrice());
         wOrder.setUnloadUrls(params.getUrls());
-        wOrder.setUnloadTime(waybillOrder.getUpdateTime());
+        wOrder.setUnloadTime(params.getOperateTime());
         editSckwWaybillOrder(wOrder, waybillOrder, 2);
 
         //2承运订单
@@ -1742,7 +1742,7 @@ public class KwtWaybillOrderService {
                 && subcontractBool) {
             //---------------------------------------------zk 2023-08-01 全量可运
             /**1-3下级分包承运订单运输完成**/
-            logisticsOrder.setStatus(LogisticsOrderEnum.HAVE_FINISHED.getCode());
+            //logisticsOrder.setStatus(LogisticsOrderEnum.HAVE_FINISHED.getCode());//取消自动完结
             logisticsOrderDao.updateById(logisticsOrder);
 
             /**1-4承运订单状态记录**/
@@ -1909,6 +1909,65 @@ public class KwtWaybillOrderService {
         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
      * @desc 修改单证查询运单
@@ -1931,15 +1990,20 @@ public class KwtWaybillOrderService {
         KwtWaybillOrderAddress unloadAddress = this.getAddress(waybillOrder.getId(), Global.NUMERICAL_TWO, Global.NUMERICAL_TWO);
         //商品信息
         KwtLogisticsOrderGoods goods = logisticsOrderGoodsDao.findByGoods(waybillOrder.getLOrderId());
+        //审批意见
+        KwtWaybillOrderTrack track = waybillOrderTrackDao.findWaybillOrderTrack(waybillOrder.getLOrderId(), CarWaybillEnum.APPROVAL_NO_PASS.getCode());
+
         //用户数据集
         List<Long> createBys = new ArrayList() {{
             add(loadTicket.getUpdateBy());
             add(unloadTicket.getUpdateBy());
+            add(track.getCreateBy());
         }};
         createBys = createBys.stream().distinct().collect(Collectors.toList());
         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 approver = users == null ? null : users.get(track.getCreateBy());
 
         Map result = new HashMap();
         result.put("wOrderId", wOrderId);
@@ -1966,6 +2030,9 @@ public class KwtWaybillOrderService {
         result.put("unloadCreateByName", unloadUser != null ? unloadUser.getName() : null);
         result.put("unloadCityName", unloadAddress != null ? unloadAddress.getCityName() : 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);
     }