DispatchQYTTravel/guns-admin/pom.xml
@@ -9,8 +9,9 @@ <relativePath>../pom.xml</relativePath> </parent> <artifactId>guns-admin</artifactId> <artifactId>dispatch</artifactId> <name>guns-admin</name> <version>1.0.0</version> <description>guns 的spring boot版本</description> <packaging>jar</packaging> @@ -186,6 +187,14 @@ <artifactId>jpush-client</artifactId> <version>3.3.10</version> </dependency> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb</artifactId> </dependency> </dependencies> DispatchQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderPositionServiceImpl.java
@@ -7,6 +7,10 @@ import com.stylefeng.guns.modular.system.model.OrderPosition; import com.stylefeng.guns.modular.system.service.IOrderPositionService; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -21,8 +25,8 @@ @Resource private OrderPositionMapper orderPositionMapper; @Value("${filePath}") private String filePath; @Resource private MongoTemplate mongoTemplate; @@ -50,22 +54,10 @@ @Override public List<OrderPosition> queryPosition(Integer orderId, Integer orderType) throws Exception{ //将数据存储到文件中 File file = new File(filePath + orderId + "_" + orderType + ".txt"); if(!file.exists()){ return new ArrayList<>(); } //读取文件(字符流) BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8")); //循环取出数据 String str = null; StringBuffer sb = new StringBuffer(); while ((str = in.readLine()) != null) { sb.append(str); } List<OrderPosition> list = new ArrayList<>(); if(ToolUtil.isNotEmpty(sb.toString())){ list = JSONArray.parseArray(sb.toString(), OrderPosition.class); } return list; Query query = new Query() .addCriteria(Criteria.where("orderId").is(orderId).and("orderType").is(orderType)) .with(new Sort(Sort.Direction.ASC, "insertTime")); List<OrderPosition> positions = mongoTemplate.find(query, OrderPosition.class); return positions; } } DispatchQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReassignServiceImpl.java
@@ -581,7 +581,9 @@ for(int i = orderCrossCity.getPeopleNumber(); i < split1.length; i++){ seat2 += split1[i] + ","; } lineShiftDriver1.setLaveSeatNumber(seat2.substring(0, seat2.length() - 1)); if(ToolUtil.isNotEmpty(seat2)){ lineShiftDriver1.setLaveSeatNumber(seat2.substring(0, seat2.length() - 1)); } lineShiftDriverMapper.updateById(lineShiftDriver1); Driver driver = driverService.selectById(driverId); if(driver.getState() == 1){ DispatchQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDFalconUtil.java
@@ -21,7 +21,7 @@ @Component public class GDFalconUtil implements ApplicationRunner { private String key = "ba2915f8d8c1428df72e964a5f94f167"; private String key = "ea7326a77175aba0e9435859b17bca36"; @Autowired private RestTemplate restTemplate; DispatchQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapElectricFenceUtil.java
@@ -34,7 +34,7 @@ @Autowired private IGDInterfaceService gdInterfaceService; private String key = "ba2915f8d8c1428df72e964a5f94f167"; private String key = "ea7326a77175aba0e9435859b17bca36"; private JSONArray jsonArray = new JSONArray(); DispatchQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapGeocodingUtil.java
@@ -20,7 +20,7 @@ @Component public class GDMapGeocodingUtil { private String key = "ba2915f8d8c1428df72e964a5f94f167"; private String key = "ea7326a77175aba0e9435859b17bca36"; @Autowired private RestTemplate restTemplate; DispatchQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushUtil.java
@@ -1,5 +1,8 @@ package com.stylefeng.guns.modular.system.util; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.stylefeng.guns.core.util.ToolUtil; @@ -8,6 +11,7 @@ import com.stylefeng.guns.modular.system.service.IOrderCrossCityService; import com.stylefeng.guns.modular.system.service.IOrderPrivateCarService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -24,6 +28,9 @@ */ @Component public class PushUtil { @Value("${qyt.socket_uri}") private String socket_uri; @Autowired private RestTemplate internalRestTemplate; @@ -66,19 +73,23 @@ jsonObject.put("data", map); //调用推送 HttpHeaders headers = new HttpHeaders(); // 以表单的方式提交 headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient"); post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE); //将请求头部和参数合成一个请求 MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); params.add("msg", jsonObject.toJSONString()); params.add("id", String.valueOf(uid)); params.add("type", String.valueOf(type)); HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); if(jsonObject1.getIntValue("code") != 200){ System.err.println(jsonObject1.getString("msg")); Map<String, Object> params = new HashMap<>(); params.put("msg", jsonObject.toJSONString()); params.put("id", uid); params.put("type", type); params.put("bussinessType", "dache"); post.form(params); HttpResponse execute = post.execute(); if (200 != execute.getStatus()) { System.err.println("推送异常"); } else { JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class); if (jsonObject1.getIntValue("code") != 200) { System.err.println(jsonObject1.getString("msg")); } } } @@ -101,19 +112,23 @@ jsonObject.put("data", map); //调用推送 HttpHeaders headers = new HttpHeaders(); // 以表单的方式提交 headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient"); post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE); //将请求头部和参数合成一个请求 MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); params.add("msg", jsonObject.toJSONString()); params.add("id", String.valueOf(uid)); params.add("type", String.valueOf(type)); HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); if(jsonObject1.getIntValue("code") != 200){ System.err.println(jsonObject1.getString("msg")); Map<String, Object> params = new HashMap<>(); params.put("msg", jsonObject.toJSONString()); params.put("id", uid); params.put("type", type); params.put("bussinessType", "dache"); post.form(params); HttpResponse execute = post.execute(); if (200 != execute.getStatus()) { System.err.println("推送异常"); } else { JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class); if (jsonObject1.getIntValue("code") != 200) { System.err.println(jsonObject1.getString("msg")); } } } @@ -258,10 +273,6 @@ msg.put("data", map); //调用推送 HttpHeaders headers = new HttpHeaders(); // 以表单的方式提交 headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); //将请求头部和参数合成一个请求 String value1 = redisUtil.getValue(orderId + "_" + orderType); if(ToolUtil.isEmpty(value1)){ @@ -269,15 +280,24 @@ return; } JSONObject jsonObject = JSON.parseObject(value1); MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); params.add("msg", msg.toJSONString()); params.add("id", jsonObject.getString("id")); params.add("type", jsonObject.getString("type")); HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); if(jsonObject1.getIntValue("code") != 200){ System.err.println(jsonObject1.getString("msg")); //调用推送 HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient"); post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE); //将请求头部和参数合成一个请求 Map<String, Object> params = new HashMap<>(); params.put("msg", msg.toJSONString()); params.put("id", jsonObject.getString("id")); params.put("type", jsonObject.getString("type")); params.put("bussinessType", "dache"); post.form(params); HttpResponse execute = post.execute(); if (200 != execute.getStatus()) { System.err.println("推送异常"); } else { JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class); if (jsonObject1.getIntValue("code") != 200) { System.err.println(jsonObject1.getString("msg")); } } } @@ -295,19 +315,23 @@ msg.put("data", new Object()); //调用推送 HttpHeaders headers = new HttpHeaders(); // 以表单的方式提交 headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); HttpRequest post = HttpUtil.createPost(socket_uri + "/netty/sendMsgToClient"); post.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE); //将请求头部和参数合成一个请求 MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); params.add("msg", msg.toJSONString()); params.add("id", id.toString()); params.add("type", type.toString()); HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class); JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); if(jsonObject1.getIntValue("code") != 200){ System.err.println(jsonObject1.getString("msg")); Map<String, Object> params = new HashMap<>(); params.put("msg", msg.toJSONString()); params.put("id", id); params.put("type", type); params.put("bussinessType", "dache"); post.form(params); HttpResponse execute = post.execute(); if (200 != execute.getStatus()) { System.err.println("推送异常"); } else { JSONObject jsonObject1 = JSON.parseObject(execute.body(), JSONObject.class); if (jsonObject1.getIntValue("code") != 200) { System.err.println(jsonObject1.getString("msg")); } } } DispatchQYTTravel/guns-admin/src/main/resources/application.yml
@@ -1,107 +1,3 @@ server: port: 7008 guns: swagger-open: true #是否开启swagger (true/false) kaptcha-open: false #是否开启登录时验证码 (true/false) # file-upload-path: d:/tmp #文件上传目录(不配置的话为java.io.tmpdir目录) spring-session-open: false #是否开启spring session,如果是多机环境需要开启(true/false) session-invalidate-time: 1800 #session失效时间(只在单机环境下生效,多机环境在SpringSessionConfig类中配置) 单位:秒 session-validation-interval: 900 #多久检测一次失效的session(只在单机环境下生效) 单位:秒 spring: application: name: dispatch-server profiles: active: dev # active: produce mvc: static-path-pattern: /static/** view: prefix: /WEB-INF/view devtools: restart: enabled: false additional-paths: src/main/java exclude: static/**,WEB-INF/view/** servlet: multipart: max-request-size: 100MB max-file-size: 100MB mybatis-plus: typeAliasesPackage: com.stylefeng.guns.modular.system.model log: path: guns-logs eureka: client: service-url: #注册中心地址 defaultZone: http://sinata:sinata@192.168.110.106:8000/eureka #启用身份验证的方式连接 register-with-eureka: true #在注册中心进行注册 fetch-registry: true #从Eureka中获取注册信息。 --- #配置Swagger接口扫描范围 swagger: base-package: com.stylefeng.guns.modular spring: datasource: url: jdbc:mysql://192.168.110.80:3306/qyttravel?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=Asia/Shanghai username: root password: 123456 db-name: jyxtravel #用来搜集数据库的所有表 filters: wall,mergeStat --- wx: grantType: authorization_code #填authorization_code appid: 111 #应用唯一标识,在微信开放平台提交应用审核通过后获得 appSecret: 111 #应用密钥AppSecret,在微信开放平台提交应用审核通过后获得 appletsAppid: wxcc3c9058e2b294db #小程序APPid appletsAppSecret: 5610fc6126255ca5f7bd9fa4330338b6 # mchId: 111 #微信支付分配的商户号 key: 111 #key为商户平台设置的密钥key: --- alipay: appid: 111 #应用程序唯一标识 appPrivateKey: 111 #开发者应用私钥 alipayPublicKey: ; #应用公钥 alipay_public_key: 111 #支付宝公钥 --- juhe: #聚合数据 appKey: 111 # --- filePath: C:/orderPostionFile/ #存储订单轨迹文件路径 #支付回调地址 #正式环境 callbackPath: https://zhentonggongsi.com:443/user --- #交通部推送数据功能开关 pushMinistryOfTransport: false --- jiguang: masterSecret: 111 appKey: 111 active: "@spring.active@" DispatchQYTTravel/pom.xml
@@ -222,19 +222,13 @@ <profiles> <profile> <id>local</id> <properties> <spring.active>local</spring.active> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>dev</id> <properties> <spring.active>dev</spring.active> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>test</id> @@ -243,9 +237,9 @@ </properties> </profile> <profile> <id>produce</id> <id>prod</id> <properties> <spring.active>produce</spring.active> <spring.active>prod</spring.active> </properties> </profile> </profiles> EurekaQYTTravel/src/main/resources/application-dev.yml
@@ -15,7 +15,7 @@ eureka: instance: hostname: 127.0.0.1 #注册中心地址 hostname: 192.168.110.106 #注册中心地址 client: service-url: #客户端调用地址 defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ ZuulQYTTravel/src/main/resources/application-dev.yml
@@ -10,7 +10,7 @@ eureka: client: service-url: #注册中心地址 defaultZone: http://sinata:sinata@127.0.0.1:8000/eureka #启用身份验证的方式连接 defaultZone: http://sinata:sinata@192.168.110.106:8000/eureka #启用身份验证的方式连接 register-with-eureka: true #在注册中心进行注册 fetch-registry: true #从Eureka中获取注册信息。 @@ -20,15 +20,15 @@ routes: user-server: #接口调用路由服务,名字任意取。(用户端服务) path: /user/** #配置请求URL的请求规则 url: http://127.0.0.1:8006 #真正的微服务地址,path匹配的请求都转发到这里 url: http://192.168.110.80:7006 #真正的微服务地址,path匹配的请求都转发到这里 serviceid: user-server #指定Eureka注册中心的服务id driver-server: #路由司机相关请求 path: /driver/** #配置请求URL的请求规则 url: http://127.0.0.1:8007 #真正的微服务地址,path匹配的请求都转发到这里 url: http://192.168.110.80:7007 #真正的微服务地址,path匹配的请求都转发到这里 serviceid: driver-server #指定Eureka注册中心的服务id dispatch-server: #路由调度相关请求 path: /dispatch/** #配置请求URL的请求规则 url: http://127.0.0.1:8008 #真正的微服务地址,path匹配的请求都转发到这里 url: http://192.168.110.80:7008 #真正的微服务地址,path匹配的请求都转发到这里 serviceid: dispatch-server #指定Eureka注册中心的服务id # 配置zuul超时时间 host: