소스 검색

Merge branch 'master' of http://git.zthymaoyi.com/gongdecai/wangluohuoyun

ccj 2 년 전
부모
커밋
e42f46eda0

+ 2 - 2
winsea-haixin-platform-backend/src/main/resources/application.yml

@@ -14,7 +14,7 @@ spring:
     serialization:
       write_dates_as_timestamps: false
   profiles:
-    active: test
+    active: local
   resources:
     static-locations: file:///winsea/static/
   thymeleaf:
@@ -166,7 +166,7 @@ auth:
   expire-in: 2592000
   login-url: /login.html
   logout-url: /auth/api/logout
-  session-timeout: 1800000
+  session-timeout: -1
   success-url: ''
   unauthorized-url: ''
 

+ 1 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/CarrierInfoController.java

@@ -41,7 +41,7 @@ public class CarrierInfoController {
      */
     @Log(title = "确认装车")
     @PostMapping("/loadingAdd")
-    public String loadingAdd(@RequestBody HyCarrierInfo hyCarrierInfo) {
+    public String loadingAdd(@RequestBody HyCarrierInfo hyCarrierInfo) throws Exception {
         return carrierInfoService.loadingAdd(hyCarrierInfo);
     }
 

+ 1 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/ICarrierInfoService.java

@@ -22,7 +22,7 @@ public interface ICarrierInfoService extends IService<HyCarrierInfo> {
     /**
      * 确认装车
      */
-    String loadingAdd(HyCarrierInfo hyCarrierInfo);
+    String loadingAdd(HyCarrierInfo hyCarrierInfo) throws Exception;
     /**
      * 确认卸车
      */

+ 130 - 2
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/CarrierInfoServiceImpl.java

@@ -1,7 +1,10 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.google.gson.internal.$Gson$Preconditions;
+import com.openapi.sdk.service.DataExchangeService;
 import com.yh.saas.common.support.util.IdGenerator;
 import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
 import com.yh.saas.plugin.yiliangyiyun.entity.*;
@@ -14,9 +17,12 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * <p>
@@ -44,7 +50,10 @@ public class CarrierInfoServiceImpl extends ServiceImpl<CarrierInfoMapper, HyCar
     private IHyCargoOwnerCapitalInfoService hyCargoOwnerCapitalInfoService;
     @Autowired
     private IHyFreightSettlementInfoService hyFreightSettlementInfoService;
-
+    @Autowired
+    private IDriverCarInfoService driverCarInfoService;
+    @Autowired
+    private IHyTokenService hyToken;
 
     /**
      * 查看装车信息
@@ -67,7 +76,7 @@ public class CarrierInfoServiceImpl extends ServiceImpl<CarrierInfoMapper, HyCar
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public String loadingAdd(HyCarrierInfo hyCarrierInfo) {
+    public String loadingAdd(HyCarrierInfo hyCarrierInfo) throws Exception {
         HyCarrierInfo hyCarrierInfo1 = this.selectById(hyCarrierInfo.getId());
         if (hyCarrierInfo != null) {
             //判断暂存提交(前端传参1暂存3提交)
@@ -75,6 +84,54 @@ public class CarrierInfoServiceImpl extends ServiceImpl<CarrierInfoMapper, HyCar
                 hyCarrierInfo.setStatus(StatusEnum.TEMPORARILY_STORED.getName());
                 hyCarrierInfo.setStatusFlag(StatusEnum.TEMPORARILY_STORED.getFlag());
             } else {
+                /****************************判断发货地和车辆位置开始************************************/
+                HyToken token = hyToken.selectOne(new EntityWrapper<HyToken>()
+                        .eq("delete_flag", 0));
+                if (token == null) {
+                    token = login();
+                }
+                //查询车辆信息
+                HyDriverCarInfo hyDriverCarInfo = driverCarInfoService.selectOne(new EntityWrapper<HyDriverCarInfo>().eq("car_number", hyCarrierInfo1.getCarNo())
+                        .eq("delete_flag", "0"));
+                Map<String, String> map = new HashMap<String, String>(4);
+                map.put("token", token.getToken());
+                map.put("cid", "871a05fd-a098-49af-9760-27ce9ecf61e3");
+                map.put("srt", "762ea319-5f05-4810-aa28-5f92c99485ae");
+                //车牌颜色
+                String color = "2";
+                if ("黄色".equals(hyDriverCarInfo.getCarNumberColour())) {
+                    color = "2";
+                } else {
+                    color = "1";
+                }
+                map.put("vnos", hyCarrierInfo.getCarNo()+"_"+color);
+                String url = "https://zhiyunopenapi.95155.com/save/apis/transTimeManageV2";
+                // 设置 http 读写超时
+                DataExchangeService des = new DataExchangeService(5000, 8000);
+                System.out.println("请求地址:" + url);
+                // 通过 https 方式调用,此方法内部会使用私钥生成签名参数 sign,私钥不会发送
+                String res = des.postHttps(url, map);
+                JSONObject jsonObject = JSONObject.parseObject(res);
+                if (jsonObject.get("status").toString().equals("1001")) {
+                    JSONObject jsonData = jsonObject.getJSONObject("result");
+                    JSONObject jsonArray = jsonData.getJSONObject("firstVcl");
+                    BigDecimal lonResult = jsonArray.getBigDecimal("lon");
+                    Double lon = lonResult.doubleValue() / 600000;
+                    BigDecimal latResult = jsonArray.getBigDecimal("lat");
+                    Double lat = latResult.doubleValue() / 600000;
+                    //发货地经纬度
+                    BigDecimal lonb = new BigDecimal(hyCarrierInfo.getLoadingLongitude());
+                    BigDecimal latb = new BigDecimal(hyCarrierInfo.getLoadingLatitude());
+                    Double lon1 = lonb.doubleValue() / 600000;
+                    Double lat1 = latb.doubleValue() / 600000;
+                     // 距离
+                    double s = GetDistance(lon,lat,lon1,lat1);
+                    if(s>3000){
+                        throw new ArithmeticException("请检查北斗导航可以正常使用!");
+                    }
+                }
+                /****************************判断发货地和车辆位置结束************************************/
+
                 hyCarrierInfo.setStatus(StatusEnum.SUBMITTED.getName());
                 hyCarrierInfo.setStatusFlag(StatusEnum.SUBMITTED.getFlag());
                 //司机确认装车后,订单状态改为待货主确认装车
@@ -105,6 +162,77 @@ public class CarrierInfoServiceImpl extends ServiceImpl<CarrierInfoMapper, HyCar
         return "OK";
     }
 
+
+    /**
+     * 默认地球半径
+     */
+    private static double EARTH_RADIUS = 6371000;//赤道半径(单位m)
+
+    /**
+     * 转化为弧度(rad)
+     * */
+    private static double rad(double d)
+    {
+        return d * Math.PI / 180.0;
+    }
+    /**
+     * @param lon1 第一点的精度
+     * @param lat1 第一点的纬度
+     * @param lon2 第二点的精度
+     * @param lat2 第二点的纬度
+     * @return 返回的距离,单位m
+     * */
+    public static double GetDistance(double lon1,double lat1,double lon2, double lat2) {
+        double radLat1 = rad(lat1);
+        double radLat2 = rad(lat2);
+        double a = radLat1 - radLat2;
+        double b = rad(lon1) - rad(lon2);
+        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
+        s = s * EARTH_RADIUS;
+        s = Math.round(s * 10000) / 10000;
+        return s;
+    }
+
+
+
+    public HyToken login() {
+        try {
+            Map<String, String> map = new HashMap<String, String>(4);
+            map.put("user", "ec841c89-4550-4dae-a377-0bda27185932");
+            map.put("pwd", "z6ZJcF32T28EF9Tkn8923uDT42609w");
+            map.put("srt", "762ea319-5f05-4810-aa28-5f92c99485ae");
+            map.put("cid", "871a05fd-a098-49af-9760-27ce9ecf61e3");
+            String url = "https://zhiyunopenapi.95155.com/save/apis/login";
+            // 设置 http 读写超时
+            DataExchangeService des = new DataExchangeService(5000, 8000);
+            System.out.println("请求地址:" + url);
+            // 通过 https 方式调用,此方法内部会使用私钥生成签名参数 sign,私钥不会发送
+            String res = des.postHttps(url, map);
+            res = res.substring(1, res.length() - 1);
+            String[] strs = res.split(",");
+            Map<String, String> map1 = new HashMap<String, String>();
+            for (String string : strs) {
+                String key = string.split(":")[0];
+                String value = string.split(":")[1];
+                // 去掉头部空格
+                String key1 = key.trim().replaceAll("\"", "");
+                String value1 = value.trim().replaceAll("\"", "");
+                map1.put(key1, value1);
+            }
+            hyToken.delete(new EntityWrapper<HyToken>().eq("delete_flag", "0"));
+            HyToken token = new HyToken();
+            token.setId(IdGenerator.generateUUID());
+            token.setToken(map1.get("\"result\"").replaceAll("\"", ""));
+            hyToken.insert(token);
+            System.out.println("返回:" + res);
+            return token;
+        } catch (Exception e) {
+            System.out.println("e:" + e.getMessage());
+        }
+        return null;
+    }
+
+
     /**
      * 确认卸车
      *

+ 6 - 6
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/HyOrderTravelPathServiceImpl.java

@@ -154,10 +154,10 @@ public class HyOrderTravelPathServiceImpl extends ServiceImpl<HyOrderTravelPathM
                 .eq("delete_flag", "0"));
         //装车时间
         String startDate = f.format(hyCarrierInfo.getLoadingDate());
-        //发货地经纬度
-        String startLonlat = publishTaskInfo.getSendLongitude() + "," + publishTaskInfo.getSendLatitude();
-        //收货地经纬度
-        String endLonlat = publishTaskInfo.getUnsendLongitude() + "," + publishTaskInfo.getUnsendLatitude();
+//        //发货地经纬度
+//        String startLonlat = publishTaskInfo.getSendLongitude() + "," + publishTaskInfo.getSendLatitude();
+//        //收货地经纬度
+//        String endLonlat = publishTaskInfo.getUnsendLongitude() + "," + publishTaskInfo.getUnsendLatitude();
         //订单确认卸车之后
         Double skey = Double.valueOf(orderInfo1.getOrderStatusKey());
 
@@ -179,8 +179,8 @@ public class HyOrderTravelPathServiceImpl extends ServiceImpl<HyOrderTravelPathM
             map.put("vco", "1");
         }
         map.put("qryBtm", startDate);
-        map.put("startLonlat", startLonlat);
-        map.put("endLonlat", endLonlat);
+        map.put("startAreaCode", publishTaskInfo.getSendAdCode());
+        map.put("endAreaCode", publishTaskInfo.getUnsendAdCode());
         if (skey >= 15) {
             //查询订单轨迹表有没有北斗轨迹
             HyOrderTravelPath hyOrderTravelPath1 = this.selectOne(new EntityWrapper<HyOrderTravelPath>()

+ 2 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/resources/mapper/OrderInfoMapper.xml

@@ -63,9 +63,11 @@
         o.send_private as sendPrivate,
         o.send_city as sendCity,
         o.send_area as sendArea,
+        o.send_detailed_address as sendDetailedAddress,
         o.unload_private as unloadPrivate,
         o.unload_city as unloadCity,
         o.unload_area as unloadArea,
+        o.unload_detailed_address as unloadDetailedAddress,
         o.comp_name as compName,
         o.cargo_owner as cargoOwner,
         o.driver_name as driverName,