From 989bf3f8a3e09a8dd46c4c5f79abc5f7421ebd14 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 27 六月 2025 15:46:42 +0800 Subject: [PATCH] 修改轨迹存储问题 --- /dev/null | 240 ---------------------------------------- DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderPositionServiceImpl.java | 2 DriverQYTTravel/guns-admin/src/main/resources/application.yml | 36 +++--- DriverQYTTravel/guns-admin/src/test/java/com/stylefeng/guns/GunsApplicationTest.java | 28 +-- DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java | 9 - DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/GunsApplication.java | 9 - 6 files changed, 35 insertions(+), 289 deletions(-) diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/GunsApplication.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/GunsApplication.java index 83950ef..e82bce4 100644 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/GunsApplication.java +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/GunsApplication.java @@ -34,13 +34,8 @@ private final static Logger logger = LoggerFactory.getLogger(GunsApplication.class); public static void main(String[] args) { - try { - SpringApplication.run(GunsApplication.class, args); - logger.info("GunsApplication is success!"); - } catch (Exception e) { - e.printStackTrace(); - logger.error("GunsApplication启动异常", e); - } + SpringApplication.run(GunsApplication.class, args); + logger.info("GunsApplication is success!"); } diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderPositionServiceImpl.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderPositionServiceImpl.java index d55a2b6..d00647c 100644 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderPositionServiceImpl.java +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderPositionServiceImpl.java @@ -54,7 +54,7 @@ //将数据存储到文件中 List<OrderPosition> orderPositions = this.queryPosition(orderPosition.getOrderId(), orderPosition.getOrderType()); orderPositions.add(orderPosition); - mongoTemplate.save(orderPositions); + mongoTemplate.insert(orderPositions, OrderPosition.class); } new Thread(new Runnable() { diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/NCOSSUtil.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/NCOSSUtil.java deleted file mode 100644 index 0d30226..0000000 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/qianyuntong/NCOSSUtil.java +++ /dev/null @@ -1,240 +0,0 @@ -//package com.stylefeng.guns.modular.system.util.qianyuntong; -// -//import com.heredata.hos.HOS; -//import com.heredata.hos.HOSClientBuilder; -//import com.heredata.hos.model.CreateBucketRequest; -//import com.heredata.hos.model.HOSObject; -//import com.heredata.hos.model.PutObjectRequest; -//import com.heredata.hos.model.PutObjectResult; -//import com.heredata.hos.model.bucket.Bucket; -//import com.heredata.model.VoidResult; -//import lombok.extern.slf4j.Slf4j; -// -//import java.io.InputStream; -// -///** -// * OSS 工具类 -// * @author zhibing.pu -// * @Date 2025/6/23 17:50 -// */ -//@Slf4j -//public class NCOSSUtil { -// -// /** -// * 创建桶 -// * @param bucketName -// * @return -// */ -// public static Boolean createBucket(String bucketName) { -// /** -// * endPoint:HOS的基础路径(公共前缀) -// * account:账户的ID -// * accessKey:向UAAS服务请求到的access_key -// * secretKey:向UAAS服务请求到的secret_key -// */ -// HOS hos = new HOSClientBuilder().build(QianYunTongProperties.endPoint, QianYunTongProperties.account, QianYunTongProperties.accessKey, QianYunTongProperties.secretKey); -// try { -// // 创建请求对象,并且设置创建桶名为"example"的桶 -// CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName); -// VoidResult result = hos.createBucket(createBucketRequest); -// if (result.getResponse().isSuccessful()) { -// log.info("创建桶成功:" + bucketName); -// return true; -// } -// } catch (Exception e){ -// log.info("创建桶失败:" + bucketName); -// e.printStackTrace(); -// } -// return false; -// } -// -// -// /** -// * 查询桶详情 -// * @param bucketName -// * @return -// */ -// public static Bucket getBucketInfo(String bucketName) { -// /** -// * endPoint:HOS的基础路径(公共前缀) -// * account:账户的ID -// * accessKey:向UAAS服务请求到的access_key -// * secretKey:向UAAS服务请求到的secret_key -// */ -// HOS hos = new HOSClientBuilder().build(QianYunTongProperties.endPoint, QianYunTongProperties.account, QianYunTongProperties.accessKey, QianYunTongProperties.secretKey); -// try { -// // 查询桶名为"example"的详情 -// Bucket bucket = hos.getBucketInfo(bucketName); -// return bucket; -// } catch (Exception e){ -// e.printStackTrace(); -// } -// return null; -// } -// -// -// /** -// * 删除桶 -// * @param bucketName -// * @return -// */ -// public static Boolean deleteBucket(String bucketName) { -// /** -// * endPoint:HOS的基础路径(公共前缀) -// * account:账户的ID -// * accessKey:向UAAS服务请求到的access_key -// * secretKey:向UAAS服务请求到的secret_key -// */ -// HOS hos = new HOSClientBuilder().build(QianYunTongProperties.endPoint, QianYunTongProperties.account, QianYunTongProperties.accessKey, QianYunTongProperties.secretKey); -// try { -// VoidResult result = hos.deleteBucket(bucketName); -// if (result.getResponse().isSuccessful()) { -// log.info("删除桶成功:" + bucketName); -// return true; -// } -// } catch (Exception e){ -// log.info("删除桶成功:" + bucketName); -// e.printStackTrace(); -// } -// return false; -// } -// -// -// /** -// * 设置桶策略 -// * @param bucketName 桶名 -// * @param policyText 策略规则字符串 -// * { -// * // 策略配置的版本号,由用户定义 -// * "Version": "2012-10-17", -// * // 策略规则配置,可指定多条策略规则 -// * "Statement": [{ -// * // 策略规则ID,可用户指定,如不指定则服务自动生成一条 -// * "Sid": "sid", -// * // 策略规则指定的HOS API接口标识,可参照下表填写 -// * "Action": [ -// * "action" -// * ], -// * // 策略规则效果,具体表现为允许或拒绝,有效值为Allow(允许),Deny(拒绝); -// * "Effect": "Allow", -// * // 策略规则指定的资源参照下面resource配置 -// * "Resource": "resource", -// * // 策略规则指定的授权人 参照下面Principal配置 -// * "Principal": { -// * "HWS": [ -// * "account_id:root" -// * ] -// * } -// * } -// * ] -// * } -// * @return -// */ -// public static Boolean setBucketPolicy(String bucketName, String policyText) { -// /** -// * endPoint:HOS的基础路径(公共前缀) -// * account:账户的ID -// * accessKey:向UAAS服务请求到的access_key -// * secretKey:向UAAS服务请求到的secret_key -// */ -// HOS hos = new HOSClientBuilder().build(QianYunTongProperties.endPoint, QianYunTongProperties.account, QianYunTongProperties.accessKey, QianYunTongProperties.secretKey); -// // 桶策略字符串 -// try { -// VoidResult result = hos.setBucketPolicy(bucketName, policyText); -// if (result.getResponse().isSuccessful()) { -// log.info("设置桶策略成功:" + bucketName); -// return true; -// } -// } catch (Exception e) { -// log.info("设置桶策略失败:" + bucketName); -// e.printStackTrace(); -// } -// return false; -// } -// -// -// /** -// * 上传对象 -// * @param bucketName 桶名称 -// * @param key 存储文件名 -// * @param inputStream 上传文件流 -// * @return 对象唯一标识 -// */ -// public static String putObject(String bucketName, String key, InputStream inputStream) { -// /** -// * endPoint:HOS的基础路径(公共前缀) -// * account:账户的ID -// * accessKey:向UAAS服务请求到的access_key -// * secretKey:向UAAS服务请求到的secret_key -// */ -// HOS hos = new HOSClientBuilder().build(QianYunTongProperties.endPoint, QianYunTongProperties.account, QianYunTongProperties.accessKey, QianYunTongProperties.secretKey); -// try { -// PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key , inputStream); -// PutObjectResult example = hos.putObject(putObjectRequest); -// if (example.getResponse().isSuccessful()) { -// log.info("上传对象成功:" + bucketName + "--->" + key); -// return example.getETag(); -// } -// } catch (Exception e) { -// log.info("上传对象成功:" + bucketName); -// e.printStackTrace(); -// } -// return null; -// } -// -// -// /** -// * 查询对象 -// * @param bucketName 桶名称 -// * @param key 存储文件名 -// * @return -// */ -// public static HOSObject getObject(String bucketName, String key) { -// /** -// * endPoint:HOS的基础路径(公共前缀) -// * account:账户的ID -// * accessKey:向UAAS服务请求到的access_key -// * secretKey:向UAAS服务请求到的secret_key -// */ -// HOS hos = new HOSClientBuilder().build(QianYunTongProperties.endPoint, QianYunTongProperties.account, QianYunTongProperties.accessKey, QianYunTongProperties.secretKey); -// try { -// HOSObject example = hos.getObject(bucketName, key); -// if (example.getResponse().isSuccessful()) { -// log.info("查询对象成功:" + bucketName + "--->" + key); -// return example; -// } -// } catch (Exception e) { -// log.info("查询对象失败:" + bucketName); -// e.printStackTrace(); -// } -// return null; -// } -// -// -// /** -// * 删除对象 -// * @param bucketName 桶名称 -// * @param key 存储文件名 -// * @return -// */ -// public static Boolean deleteObject(String bucketName, String key) { -// /** -// * endPoint:HOS的基础路径(公共前缀) -// * account:账户的ID -// * accessKey:向UAAS服务请求到的access_key -// * secretKey:向UAAS服务请求到的secret_key -// */ -// HOS hos = new HOSClientBuilder().build(QianYunTongProperties.endPoint, QianYunTongProperties.account, QianYunTongProperties.accessKey, QianYunTongProperties.secretKey); -// try { -// VoidResult example = hos.deleteObject(bucketName, key); -// if (example.getResponse().isSuccessful()) { -// log.info("删除对象成功:" + bucketName + "--->" + key); -// return true; -// } -// } catch (Exception e) { -// log.info("删除对象失败:" + bucketName + "--->" + key); -// e.printStackTrace(); -// } -// return false; -// } -//} diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java index 4035453..6f5a29e 100644 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java @@ -753,7 +753,7 @@ }else{ orderTaxi.setMileage(0D); this.updateById(orderTaxi); -// return true;//第一条数据不作处理,直接存储 + return true;//第一条数据不作处理,直接存储 } Map<String, Double> distance = geodesyUtil.getDistance(now, old); if(null != distance){ @@ -764,13 +764,10 @@ if(orderTaxi.getState() == 5){//大于50米表示在移动,且正在服务中的时候存入里程 orderTaxi.setMileage(new BigDecimal(orderTaxi.getMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); this.updateById(orderTaxi); -// return true; + return true; } -// return false; - }else{ - System.err.println("调用高德计算距离出错"); } - return true; + return false; } diff --git a/DriverQYTTravel/guns-admin/src/main/resources/application.yml b/DriverQYTTravel/guns-admin/src/main/resources/application.yml index ba2e18c..9c13272 100644 --- a/DriverQYTTravel/guns-admin/src/main/resources/application.yml +++ b/DriverQYTTravel/guns-admin/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 8007 + port: 8007 guns: swagger-open: true #是否开启swagger (true/false) @@ -12,10 +12,10 @@ spring: application: - name: driver-server + name: driver-server profiles: - active: dev - # active: prod +# active: dev + active: prod mvc: static-path-pattern: /static/** view: @@ -53,11 +53,11 @@ eureka: - client: - service-url: #注册中心地址 - defaultZone: http://sinata:sinata@127.0.0.1:8000/eureka #启用身份验证的方式连接 - register-with-eureka: true #在注册中心进行注册 - fetch-registry: true #从Eureka中获取注册信息。 + client: + service-url: #注册中心地址 + defaultZone: http://sinata:sinata@127.0.0.1:8000/eureka #启用身份验证的方式连接 + register-with-eureka: true #在注册中心进行注册 + fetch-registry: true #从Eureka中获取注册信息。 --- @@ -89,24 +89,24 @@ --- alipay: - appid: 111 #应用程序唯一标识 - appPrivateKey: 111 #开发者应用私钥 - alipayPublicKey: 1 #应用公钥 - alipay_public_key: 111 #支付宝公钥 + appid: 111 #应用程序唯一标识 + appPrivateKey: 111 #开发者应用私钥 + alipayPublicKey: 1 #应用公钥 + alipay_public_key: 111 #支付宝公钥 --- juhe: #聚合数据 - appKey: 111 # + appKey: 111 # --- jiguang: - appKey-driver: 111 #极光推送应用唯一标识 - masterSecret-driver: 111 #用于服务器端 API 调用时与 AppKey 配合使用达到鉴权的目的 - appKey-dispatch: 111 #极光推送应用唯一标识 - masterSecret-dispatch: 111 #用于服务器端 API 调用时与 AppKey 配合使用达到鉴权的目的 + appKey-driver: 111 #极光推送应用唯一标识 + masterSecret-driver: 111 #用于服务器端 API 调用时与 AppKey 配合使用达到鉴权的目的 + appKey-dispatch: 111 #极光推送应用唯一标识 + masterSecret-dispatch: 111 #用于服务器端 API 调用时与 AppKey 配合使用达到鉴权的目的 --- diff --git a/DriverQYTTravel/guns-admin/src/test/java/com/stylefeng/guns/GunsApplicationTest.java b/DriverQYTTravel/guns-admin/src/test/java/com/stylefeng/guns/GunsApplicationTest.java index 70818e0..543c653 100644 --- a/DriverQYTTravel/guns-admin/src/test/java/com/stylefeng/guns/GunsApplicationTest.java +++ b/DriverQYTTravel/guns-admin/src/test/java/com/stylefeng/guns/GunsApplicationTest.java @@ -1,17 +1,11 @@ -package com.stylefeng.guns; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class GunsApplicationTest { - - - @Test - public void test() throws Exception { - - } -} +//package com.stylefeng.guns; +// +//import org.junit.runner.RunWith; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.junit4.SpringRunner; +// +//@RunWith(SpringRunner.class) +//@SpringBootTest +//public class GunsApplicationTest { +// +//} -- Gitblit v1.7.1