From 10b15315adbf81a2d88f22b33da11030c07f1918 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 09 十月 2026 10:46:03 +0800
Subject: [PATCH] 修改bug
---
UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapElectricFenceUtil.java | 132 +++
/dev/null | 1063 ---------------------------------
UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapGeocodingUtil.java | 43 +
UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/GDKeyMapper.java | 31
UserFBTravel/guns-admin/src/test/java/com/stylefeng/guns/modular/crossCity/server/impl/SiteServiceImplTest.java | 51 +
UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDKeyManager.java | 349 ++++++++++
UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDFalconUtil.java | 232 +++++--
7 files changed, 732 insertions(+), 1,169 deletions(-)
diff --git a/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/MinistryOfTransportController.java b/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/MinistryOfTransportController.java
deleted file mode 100644
index 49fa0b1..0000000
--- a/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/MinistryOfTransportController.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.stylefeng.guns.modular.api;
-
-
-import com.stylefeng.guns.modular.system.util.MinistryOfTransport;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
-
-
-/**
- * 交通部测试接口
- */
-@Api
-@RestController
-@RequestMapping("/base/ministryOfTransport")
-public class MinistryOfTransportController {
-
- @Autowired
- private MinistryOfTransport ministryOfTransport;
-
-
-
- @ResponseBody
- @ApiOperation(value = "上传企业基础信息", tags = {"交通部测试接口"})
- @RequestMapping(value = "/pushCompany", method = RequestMethod.POST)
- public void pushCompany() {
- try {
- ministryOfTransport.baseInfoCompany();
- }catch (Exception e){
- e.printStackTrace();
- }
- }
-}
diff --git a/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/GDKeyMapper.java b/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/GDKeyMapper.java
new file mode 100644
index 0000000..1fec0f6
--- /dev/null
+++ b/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/GDKeyMapper.java
@@ -0,0 +1,31 @@
+package com.stylefeng.guns.modular.system.dao;
+
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+import java.util.List;
+
+/**
+ * 高德地图key管理 Mapper(注解方式,无需XML)
+ */
+public interface GDKeyMapper {
+
+ /**
+ * 查询可用key(启用、未删除、未用完)
+ */
+ @Select("SELECT gdKey FROM t_gaode_account WHERE status = 1 AND delFlag = 0 AND useStatus <> 3")
+ List<String> selectAvailableKeys();
+
+ /**
+ * 查询已用完的key(用于每日凌晨重置校验)
+ */
+ @Select("SELECT gdKey FROM t_gaode_account WHERE status = 1 AND delFlag = 0 AND useStatus = 3")
+ List<String> selectExhaustedKeys();
+
+ /**
+ * 更新key的使用状态
+ */
+ @Update("UPDATE t_gaode_account SET useStatus = #{useStatus} WHERE gdKey = #{gdKey} AND delFlag = 0")
+ int updateUseStatus(@Param("gdKey") String gdKey, @Param("useStatus") Integer useStatus);
+}
diff --git a/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDFalconUtil.java b/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDFalconUtil.java
index 75ff775..7452ed3 100644
--- a/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDFalconUtil.java
+++ b/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDFalconUtil.java
@@ -17,16 +17,23 @@
/**
* 高德猎鹰服务
+ * key次数用完时自动切换可用key(切换后自动重建serverId)
*/
@Component
public class GDFalconUtil implements ApplicationRunner {
- private String key = "ca723c3c8a78962a7751129ae035dc9d";
-
@Autowired
private RestTemplate restTemplate;
+ @Autowired
+ private GDKeyManager gdKeyManager;
+
private static String serverId = null;
+
+ /**
+ * 当前serverId对应的key(key切换后需重建serverId)
+ */
+ private static volatile String currentKey = null;
public String getServerId() {
@@ -44,20 +51,137 @@
}
-
/**
* 初始化创建服务
*/
public void init(){
if(serverId == null){
- JSONArray jsonArray = this.selectServer();
- if(null == jsonArray){
- serverId = this.createServer("server");
- }else{
- serverId = jsonArray.getJSONObject(0).getString("sid");
+ if (gdKeyManager == null || restTemplate == null) {
+ // 非容器实例(如 GunsApplication.main 中 new 出来的对象),由容器内bean完成初始化
+ return;
}
+ ensureServerId();
}
+ }
+ /**
+ * 参数构造器:key与sid切换后需按最新值重新构造
+ */
+ private interface ParamsBuilder {
+ MultiValueMap<String, Object> build(String key, String sid);
+ }
+
+ /**
+ * 确保serverId与当前使用的key对应:
+ * key切换后自动查询/重建serverId;key用完自动切换可用key重试
+ */
+ private synchronized String ensureServerId(){
+ int maxAttempts = 5;
+ String lastKey = gdKeyManager.getKey();
+ for (int i = 0; i < maxAttempts; i++) {
+ String gdKey = gdKeyManager.getKey();
+ lastKey = gdKey;
+ if (serverId != null && gdKey.equals(currentKey)) {
+ return gdKey;
+ }
+ // 1. 查询该key下的服务列表
+ JSONArray jsonArray = null;
+ try {
+ String url = "https://tsapi.amap.com/v1/track/service/list?key=" + gdKey;
+ String forObject = restTemplate.getForObject(url, String.class);
+ JSONObject jsonObject = JSON.parseObject(forObject);
+ if (GDKeyManager.isFalconExhausted(jsonObject)) {
+ gdKeyManager.reportExhausted(gdKey);
+ serverId = null;
+ continue;
+ }
+ if (jsonObject.getIntValue("errcode") == 10000) {
+ JSONObject data = jsonObject.getJSONObject("data");
+ if (null != data) {
+ jsonArray = data.getJSONArray("results");
+ }
+ }
+ } catch (Exception e) {
+ loggerWarn("查询猎鹰服务列表异常", e);
+ }
+ if (jsonArray != null && jsonArray.size() > 0) {
+ serverId = jsonArray.getJSONObject(0).getString("sid");
+ currentKey = gdKey;
+ return gdKey;
+ }
+ // 2. 无服务:创建新服务
+ String sid = createServerInternal("server", gdKey);
+ if (sid != null) {
+ serverId = sid;
+ currentKey = gdKey;
+ return gdKey;
+ }
+ // 3. 创建失败(可能key用完):切换key重试
+ gdKeyManager.reportExhausted(gdKey);
+ serverId = null;
+ }
+ return lastKey;
+ }
+
+ private void loggerWarn(String msg, Exception e) {
+ System.err.println("[GDFalconUtil] " + msg + ":" + e.getMessage());
+ }
+
+ /**
+ * 执行猎鹰POST表单请求:key次数用完时自动切换key并重建serverId重试
+ */
+ private String doFalconPost(String url, ParamsBuilder builder) {
+ String lastResp = null;
+ int maxAttempts = 5;
+ for (int i = 0; i < maxAttempts; i++) {
+ String gdKey = ensureServerId();
+ String sid = serverId;
+ MultiValueMap<String, Object> params = builder.build(gdKey, sid);
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+ HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
+ String resp = restTemplate.postForObject(url, requestEntity, String.class);
+ lastResp = resp;
+ JSONObject jsonObject;
+ try {
+ jsonObject = JSON.parseObject(resp);
+ } catch (Exception e) {
+ return resp;
+ }
+ if (GDKeyManager.isFalconExhausted(jsonObject)) {
+ gdKeyManager.reportExhausted(gdKey);
+ serverId = null;
+ continue;
+ }
+ return resp;
+ }
+ return lastResp;
+ }
+
+ /**
+ * 执行猎鹰GET请求:key次数用完时自动切换可用key重试
+ */
+ private String doFalconGet(String baseUrl) {
+ String lastResp = null;
+ int maxAttempts = 5;
+ for (int i = 0; i < maxAttempts; i++) {
+ String gdKey = gdKeyManager.getKey();
+ String url = baseUrl + (baseUrl.contains("?") ? "&" : "?") + "key=" + gdKey;
+ String resp = restTemplate.getForObject(url, String.class);
+ lastResp = resp;
+ JSONObject jsonObject;
+ try {
+ jsonObject = JSON.parseObject(resp);
+ } catch (Exception e) {
+ return resp;
+ }
+ if (GDKeyManager.isFalconExhausted(jsonObject)) {
+ gdKeyManager.reportExhausted(gdKey);
+ continue;
+ }
+ return resp;
+ }
+ return lastResp;
}
@@ -66,6 +190,13 @@
* @return
*/
public String createServer(String name){
+ return createServerInternal(name, gdKeyManager.getKey());
+ }
+
+ /**
+ * 创建新的服务(内部直连,供ensureServerId使用)
+ */
+ private String createServerInternal(String name, String key){
String url = "https://tsapi.amap.com/v1/track/service/add";
//调用推送
HttpHeaders headers = new HttpHeaders();
@@ -89,24 +220,6 @@
/**
- * 查询服务
- * @return
- */
- private JSONArray selectServer(){
- String url = "https://tsapi.amap.com/v1/track/service/list?key=" + key;
- String forObject = restTemplate.getForObject(url, String.class);
- JSONObject jsonObject = JSON.parseObject(forObject);
- if(jsonObject.getIntValue("errcode") == 10000){
- JSONObject data = jsonObject.getJSONObject("data");
- if(null != data){
- return data.getJSONArray("results");
- }
- }
- return null;
- }
-
-
- /**
* 创建终端数据
* @param name
* @return
@@ -116,18 +229,13 @@
if(tid != null){
return tid;
}
- String url = "https://tsapi.amap.com/v1/track/terminal/add";
- //调用推送
- HttpHeaders headers = new HttpHeaders();
- // 以表单的方式提交
- headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
- //将请求头部和参数合成一个请求
- MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
- params.add("key", key);
- params.add("sid", serverId);
- params.add("name", name);
- HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
- String s = restTemplate.postForObject(url, requestEntity , String.class);
+ String s = doFalconPost("https://tsapi.amap.com/v1/track/terminal/add", (key, sid) -> {
+ MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
+ params.add("key", key);
+ params.add("sid", sid);
+ params.add("name", name);
+ return params;
+ });
JSONObject jsonObject = JSON.parseObject(s);
if(jsonObject.getIntValue("errcode") == 10000){
JSONObject data = jsonObject.getJSONObject("data");
@@ -144,8 +252,7 @@
* @return
*/
public String selectTerminal(String name){
- String url = "https://tsapi.amap.com/v1/track/terminal/list?key=" + key + "&name=" + name;
- String forObject = restTemplate.getForObject(url, String.class);
+ String forObject = doFalconGet("https://tsapi.amap.com/v1/track/terminal/list?name=" + name);
JSONObject jsonObject = JSON.parseObject(forObject);
if(jsonObject.getIntValue("errcode") == 10000){
JSONObject data = jsonObject.getJSONObject("data");
@@ -170,18 +277,13 @@
* @return
*/
public String createTrack(String tid){
- String url = "https://tsapi.amap.com/v1/track/trace/add";
- //调用推送
- HttpHeaders headers = new HttpHeaders();
- // 以表单的方式提交
- headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
- //将请求头部和参数合成一个请求
- MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
- params.add("key", key);
- params.add("sid", serverId);
- params.add("tid", tid);
- HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
- String s = restTemplate.postForObject(url, requestEntity , String.class);
+ String s = doFalconPost("https://tsapi.amap.com/v1/track/trace/add", (key, sid) -> {
+ MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
+ params.add("key", key);
+ params.add("sid", sid);
+ params.add("tid", tid);
+ return params;
+ });
JSONObject jsonObject = JSON.parseObject(s);
if(jsonObject.getIntValue("errcode") == 10000){
return jsonObject.getString("data");
@@ -197,28 +299,18 @@
* @param trid 轨迹id
*/
public void deleteTrack(String tid, String trid){
- String url = "https://tsapi.amap.com/v1/track/trace/delete";
- //调用推送
- HttpHeaders headers = new HttpHeaders();
- // 以表单的方式提交
- headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
- //将请求头部和参数合成一个请求
- MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
- params.add("key", key);
- params.add("sid", serverId);
- params.add("tid", tid);
- params.add("trid", trid);
- HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
- String s = restTemplate.postForObject(url, requestEntity , String.class);
+ String s = doFalconPost("https://tsapi.amap.com/v1/track/trace/delete", (key, sid) -> {
+ MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
+ params.add("key", key);
+ params.add("sid", sid);
+ params.add("tid", tid);
+ params.add("trid", trid);
+ return params;
+ });
JSONObject jsonObject = JSON.parseObject(s);
if(jsonObject.getIntValue("errcode") != 10000){
System.err.println(jsonObject.getString("errmsg"));
}
}
-
-//
-// public Map<String, Object> queryTrsearch(){
-//
-// }
}
diff --git a/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDKeyManager.java b/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDKeyManager.java
new file mode 100644
index 0000000..f42b2ca
--- /dev/null
+++ b/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDKeyManager.java
@@ -0,0 +1,349 @@
+package com.stylefeng.guns.modular.system.util;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.stylefeng.guns.modular.system.dao.GDKeyMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+import javax.annotation.PostConstruct;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * 高德地图key管理器
+ * <p>
+ * 功能:
+ * 1. key池管理:从 t_gaode_account 表加载可用key(启用、未删除、未用完),轮询获取;
+ * 表为空或全部用尽时降级使用兜底key(原硬编码key)。
+ * 2. 自动切换:调用方检测到key"次数用完"后调用 reportExhausted 上报,
+ * 管理器将key移出内存池并置库表 useStatus=3(已用完)。
+ * 3. 每日凌晨重置校验:每天 00:00 将 useStatus=3 的key重置为未使用并放回池,
+ * 随后调用高德最轻量接口校验配额是否真正恢复;未恢复的key重新标记已用完,
+ * 进入延迟重试队列,每30分钟校验一次直到恢复额度。
+ * 4. 兜底key:当天用完仅内存禁用,次日凌晨自动恢复;不写库(表内无对应记录)。
+ */
+@Component
+public class GDKeyManager {
+
+ private static final Logger logger = LoggerFactory.getLogger(GDKeyManager.class);
+
+ /**
+ * 兜底key(原硬编码key):管理端/用户端
+ */
+ public static final String FALLBACK_KEY = "39b31fa22955efa8fce9eed487241db9";
+
+ /**
+ * 配额校验接口:最轻量的通用Web服务接口,每次仅消耗1次配额
+ */
+ private static final String VERIFY_URL = "https://restapi.amap.com/v3/geocode/geo?output=JSON&address=%E5%8C%97%E4%BA%AC%E5%B8%82&key=";
+
+ @Autowired
+ private GDKeyMapper gdKeyMapper;
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+ /**
+ * 内存可用key池(refreshPool整体替换,保证getKey不会看到clear/addAll中间态)
+ */
+ private volatile List<String> availableKeys = new CopyOnWriteArrayList<>();
+
+ /**
+ * 轮询下标
+ */
+ private final AtomicInteger index = new AtomicInteger(0);
+
+ /**
+ * 延迟校验队列:key -> 已重试次数(每日凌晨校验未恢复的key)
+ */
+ private final ConcurrentHashMap<String, Integer> pendingVerifyKeys = new ConcurrentHashMap<>();
+
+ /**
+ * 兜底key当日是否已用完
+ */
+ private volatile boolean fallbackExhausted = false;
+
+ /**
+ * 已标记"使用中"(useStatus=2)的key集合,避免热路径每次取用都写库
+ */
+ private final Set<String> inUseKeys = ConcurrentHashMap.newKeySet();
+
+ @PostConstruct
+ public void init() {
+ refreshPool();
+ }
+
+ /**
+ * 刷新可用key池
+ */
+ public synchronized void refreshPool() {
+ try {
+ List<String> keys = gdKeyMapper.selectAvailableKeys();
+ List<String> newPool = new CopyOnWriteArrayList<>();
+ if (keys != null) {
+ newPool.addAll(keys);
+ }
+ // 整体替换,避免clear/addAll中间态导致getKey短暂看到空池误降级兜底key
+ availableKeys = newPool;
+ logger.info("[GDKeyManager] 高德key池刷新完成,可用key数:{}", newPool.size());
+ } catch (Exception e) {
+ // 表不存在(用户端/司机端未建表时)等异常:降级使用兜底key,不影响系统运行
+ logger.warn("[GDKeyManager] 加载高德key失败(t_gaode_account表可能不存在),降级使用兜底key", e);
+ availableKeys = new CopyOnWriteArrayList<>();
+ }
+ }
+
+ /**
+ * 获取一个可用key:池非空轮询池内key;池空使用兜底key(当日未用完时)
+ */
+ public String getKey() {
+ List<String> pool = availableKeys;
+ if (!pool.isEmpty()) {
+ String key = pickFromPool(pool);
+ markInUse(key);
+ return key;
+ }
+ if (!fallbackExhausted) {
+ return FALLBACK_KEY;
+ }
+ // 兜底key当日也已用完:尝试刷新池(可能有新录入的key)
+ refreshPool();
+ pool = availableKeys;
+ if (!pool.isEmpty()) {
+ String key = pickFromPool(pool);
+ markInUse(key);
+ return key;
+ }
+ return FALLBACK_KEY;
+ }
+
+ /**
+ * 从内存池轮询取一个key(使用调用方传入的池快照,避免与定时刷新交叉导致越界)
+ */
+ private String pickFromPool(List<String> pool) {
+ int i = Math.abs(index.getAndIncrement() % pool.size());
+ return pool.get(i);
+ }
+
+ /**
+ * 将表内key标记为"使用中"(useStatus=2):
+ * 仅key首次被取用时写库一次;兜底key不写库;写库失败不影响取key流程。
+ */
+ private void markInUse(String key) {
+ if (key == null || FALLBACK_KEY.equals(key) || inUseKeys.contains(key)) {
+ return;
+ }
+ try {
+ gdKeyMapper.updateUseStatus(key, 2);
+ inUseKeys.add(key);
+ logger.info("[GDKeyManager] 高德key[{}]开始使用,已标记为使用中", key);
+ } catch (Exception e) {
+ // 表不存在等异常:本次不标记,下次取用再尝试,不影响业务
+ logger.warn("[GDKeyManager] 标记高德key[{}]使用中失败(表可能不存在),不影响使用", key);
+ }
+ }
+
+ /**
+ * 定时刷新key池:每5分钟一次,让管理后台新录入的key及时生效
+ */
+ @Scheduled(fixedDelay = 5 * 60 * 1000, initialDelay = 60 * 1000)
+ public void scheduledRefreshPool() {
+ refreshPool();
+ }
+
+ /**
+ * 上报某个key次数用完:
+ * 表内key -> 移出内存池 + 置库表 useStatus=3;
+ * 兜底key -> 仅内存当日禁用(不写库),次日凌晨自动恢复。
+ */
+ public void reportExhausted(String usedKey) {
+ if (usedKey == null || usedKey.isEmpty()) {
+ return;
+ }
+ availableKeys.remove(usedKey);
+ inUseKeys.remove(usedKey);
+ if (FALLBACK_KEY.equals(usedKey)) {
+ fallbackExhausted = true;
+ logger.warn("[GDKeyManager] 兜底key次数已用完,今日禁用,次日凌晨自动恢复");
+ return;
+ }
+ try {
+ gdKeyMapper.updateUseStatus(usedKey, 3);
+ logger.warn("[GDKeyManager] 高德key[{}]次数用完,已标记为已用完并移出key池", usedKey);
+ } catch (Exception e) {
+ logger.warn("[GDKeyManager] 更新高德key[{}]使用状态失败(表可能不存在),仅内存剔除", usedKey);
+ }
+ }
+
+ /**
+ * 判断Web服务API响应是否为"次数用完/不可用"(依据infocode)
+ */
+ public static boolean isWebKeyExhausted(JSONObject resp) {
+ if (resp == null) {
+ return false;
+ }
+ String infocode = resp.getString("infocode");
+ if (infocode == null || infocode.isEmpty()) {
+ return false;
+ }
+ switch (infocode) {
+ case "10001": // key不正确或过期
+ case "10003": // 超过每日配额
+ case "10004": // 访问过于频繁
+ case "10005": // 超出每秒访问量限制
+ case "10010": // 权限不足
+ case "10012": // 服务未开放/权限不足
+ case "10019": // 使用配额已用尽
+ case "10020": // 并发超限
+ case "10044": // 签名错误/未开通
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * 判断猎鹰API响应是否为"次数用完"(依据errcode/errmsg)
+ */
+ public static boolean isFalconExhausted(JSONObject resp) {
+ if (resp == null) {
+ return false;
+ }
+ int errcode = resp.getIntValue("errcode");
+ if (errcode == 10000) {
+ return false;
+ }
+ if (errcode == 20001) {
+ return true; // 权限不足
+ }
+ String errmsg = resp.getString("errmsg");
+ if (errmsg == null) {
+ return false;
+ }
+ return errmsg.contains("配额") || errmsg.contains("上限") || errmsg.contains("次数")
+ || errmsg.contains("用完") || errmsg.contains("超限")
+ || errmsg.contains("quota") || errmsg.contains("limit");
+ }
+
+ // ==================== 每日凌晨重置 + API校验恢复额度 ====================
+
+ /**
+ * 每日凌晨 00:00 自动执行:
+ * 1. 将 useStatus=3(已用完)的key重置为未使用并放回内存池;
+ * 2. 调用高德API校验配额是否真正恢复;
+ * 3. 未恢复的key重新标记已用完,进入延迟重试队列,直到恢复额度。
+ */
+ @Scheduled(cron = "0 0 0 * * ?")
+ public void dailyResetAndVerify() {
+ logger.info("[GDKeyManager] 开始每日高德key配额重置校验");
+ // 兜底key当日禁用标记次日自动恢复
+ fallbackExhausted = false;
+ List<String> exhaustedKeys;
+ try {
+ exhaustedKeys = gdKeyMapper.selectExhaustedKeys();
+ } catch (Exception e) {
+ logger.warn("[GDKeyManager] 查询已用完key失败(表可能不存在),跳过重置校验", e);
+ return;
+ }
+ if (exhaustedKeys == null || exhaustedKeys.isEmpty()) {
+ logger.info("[GDKeyManager] 无已用完的key,跳过重置校验");
+ return;
+ }
+ for (String gdKey : exhaustedKeys) {
+ // 1. 先重置为未使用
+ try {
+ gdKeyMapper.updateUseStatus(gdKey, 1);
+ } catch (Exception e) {
+ logger.warn("[GDKeyManager] 重置key[{}]使用状态失败", gdKey, e);
+ }
+ // 2. 调用API校验是否真正恢复额度
+ boolean recovered = verifyQuota(gdKey);
+ if (recovered) {
+ if (!availableKeys.contains(gdKey)) {
+ availableKeys.add(gdKey);
+ }
+ pendingVerifyKeys.remove(gdKey);
+ logger.info("[GDKeyManager] 高德key[{}]配额已恢复,重新加入key池", gdKey);
+ } else {
+ // 未恢复:重新标记已用完,进入延迟重试队列
+ try {
+ gdKeyMapper.updateUseStatus(gdKey, 3);
+ } catch (Exception e) {
+ logger.warn("[GDKeyManager] 回写key[{}]已用完状态失败", gdKey, e);
+ }
+ availableKeys.remove(gdKey);
+ pendingVerifyKeys.put(gdKey, 0);
+ logger.warn("[GDKeyManager] 高德key[{}]配额尚未恢复,进入延迟重试队列", gdKey);
+ }
+ }
+ }
+
+ /**
+ * 延迟重试任务:每30分钟校验一次待恢复的key,直到恢复额度为止
+ */
+ @Scheduled(fixedDelay = 30 * 60 * 1000, initialDelay = 30 * 60 * 1000)
+ public void retryPendingKeys() {
+ if (pendingVerifyKeys.isEmpty()) {
+ return;
+ }
+ for (String gdKey : new ArrayList<>(pendingVerifyKeys.keySet())) {
+ boolean recovered = verifyQuota(gdKey);
+ if (recovered) {
+ try {
+ gdKeyMapper.updateUseStatus(gdKey, 1);
+ } catch (Exception e) {
+ logger.warn("[GDKeyManager] 恢复key[{}]使用状态失败", gdKey, e);
+ }
+ if (!availableKeys.contains(gdKey)) {
+ availableKeys.add(gdKey);
+ }
+ pendingVerifyKeys.remove(gdKey);
+ logger.info("[GDKeyManager] 高德key[{}]延迟校验通过,配额已恢复,重新加入key池", gdKey);
+ } else {
+ int count = pendingVerifyKeys.merge(gdKey, 1, Integer::sum);
+ logger.warn("[GDKeyManager] 高德key[{}]配额仍未恢复(已校验{}次),继续等待", gdKey, count);
+ }
+ }
+ }
+
+ /**
+ * 调用高德最轻量接口校验配额是否恢复
+ *
+ * @return true=已恢复(或无法判断,保守放行);false=明确未恢复(配额类错误)
+ */
+ private boolean verifyQuota(String gdKey) {
+ try {
+ String resp = restTemplate.getForObject(VERIFY_URL + gdKey, String.class);
+ JSONObject json = JSON.parseObject(resp);
+ String status = json.getString("status");
+ String infocode = json.getString("infocode");
+ if ("1".equals(status) && "10000".equals(infocode)) {
+ return true;
+ }
+ // 权限类错误:该key未开通Web服务校验权限(如猎鹰专用key),无法判断配额,按已恢复处理
+ if ("10044".equals(infocode) || "10012".equals(infocode)
+ || "10002".equals(infocode) || "10010".equals(infocode)) {
+ logger.info("[GDKeyManager] 高德key[{}]无Web服务校验权限(infocode={}),按已恢复处理", gdKey, infocode);
+ return true;
+ }
+ // 配额类错误:明确未恢复
+ if ("10001".equals(infocode) || "10003".equals(infocode) || "10019".equals(infocode)) {
+ return false;
+ }
+ // 其他错误(限流/网络等):保守放行,真实调用失败时会被自动切换机制再次标记
+ return true;
+ } catch (Exception e) {
+ logger.warn("[GDKeyManager] 校验key[{}]配额异常,按已恢复处理", gdKey, e);
+ return true;
+ }
+ }
+}
diff --git a/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapElectricFenceUtil.java b/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapElectricFenceUtil.java
index 029ec5e..785eaa1 100644
--- a/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapElectricFenceUtil.java
+++ b/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapElectricFenceUtil.java
@@ -33,9 +33,98 @@
@Autowired
private IGDInterfaceService gdInterfaceService;
- private String key = "ca723c3c8a78962a7751129ae035dc9d";
+ @Autowired
+ private GDKeyManager gdKeyManager;
private JSONArray jsonArray = new JSONArray();
+
+ /**
+ * 执行GET请求:key次数用完时自动切换可用key重试
+ */
+ private String doGetWithRetry(String baseUrl) {
+ String lastResp = null;
+ int maxAttempts = 5;
+ for (int i = 0; i < maxAttempts; i++) {
+ String key = gdKeyManager.getKey();
+ String url = baseUrl + (baseUrl.contains("?") ? "&" : "?") + "key=" + key;
+ String resp = restTemplate.getForObject(url, String.class);
+ lastResp = resp;
+ JSONObject jsonObject;
+ try {
+ jsonObject = JSON.parseObject(resp);
+ } catch (Exception e) {
+ return resp;
+ }
+ if (GDKeyManager.isWebKeyExhausted(jsonObject)) {
+ gdKeyManager.reportExhausted(key);
+ continue;
+ }
+ return resp;
+ }
+ return lastResp;
+ }
+
+ /**
+ * 执行POST请求(JSON体):key次数用完时自动切换可用key重试
+ */
+ private String doPostJsonWithRetry(String baseUrl, String jsonBody) {
+ String lastResp = null;
+ int maxAttempts = 5;
+ HttpHeaders headers = new HttpHeaders();
+ MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
+ headers.setContentType(type);
+ headers.add("Accept", MediaType.APPLICATION_JSON.toString());
+ for (int i = 0; i < maxAttempts; i++) {
+ String key = gdKeyManager.getKey();
+ String url = baseUrl + (baseUrl.contains("?") ? "&" : "?") + "key=" + key;
+ HttpEntity<String> formEntity = new HttpEntity<>(jsonBody, headers);
+ String resp = restTemplate.postForObject(url, formEntity, String.class);
+ lastResp = resp;
+ JSONObject jsonObject;
+ try {
+ jsonObject = JSON.parseObject(resp);
+ } catch (Exception e) {
+ return resp;
+ }
+ if (GDKeyManager.isWebKeyExhausted(jsonObject)) {
+ gdKeyManager.reportExhausted(key);
+ continue;
+ }
+ return resp;
+ }
+ return lastResp;
+ }
+
+ /**
+ * 执行PATCH请求(JSON体):key次数用完时自动切换可用key重试
+ */
+ private String doPatchJsonWithRetry(String baseUrl, String jsonBody) {
+ String lastResp = null;
+ int maxAttempts = 5;
+ HttpHeaders headers = new HttpHeaders();
+ MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
+ headers.setContentType(type);
+ headers.add("Accept", MediaType.APPLICATION_JSON.toString());
+ for (int i = 0; i < maxAttempts; i++) {
+ String key = gdKeyManager.getKey();
+ String url = baseUrl + (baseUrl.contains("?") ? "&" : "?") + "key=" + key;
+ HttpEntity<String> formEntity = new HttpEntity<>(jsonBody, headers);
+ String resp = restTemplate.patchForObject(url, formEntity, String.class);
+ lastResp = resp;
+ JSONObject jsonObject;
+ try {
+ jsonObject = JSON.parseObject(resp);
+ } catch (Exception e) {
+ return resp;
+ }
+ if (GDKeyManager.isWebKeyExhausted(jsonObject)) {
+ gdKeyManager.reportExhausted(key);
+ continue;
+ }
+ return resp;
+ }
+ return lastResp;
+ }
@Bean
@@ -81,14 +170,7 @@
json.put("alert_condition", "enter;leave");
json.put("desc", id);
- HttpHeaders headers = new HttpHeaders();
- MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
- headers.setContentType(type);
- headers.add("Accept", MediaType.APPLICATION_JSON.toString());
- HttpEntity<String> formEntity = new HttpEntity<>(json.toString(), headers);
-
- String url = "https://restapi.amap.com/v4/geofence/meta?key=" + key;
- String js = restTemplate.postForObject(url, formEntity, String.class);
+ String js = doPostJsonWithRetry("https://restapi.amap.com/v4/geofence/meta", json.toString());
JSONObject jsonObject = JSON.parseObject(js);
JSONObject data = jsonObject.getJSONObject("data");
String status = data.getString("status");
@@ -148,8 +230,8 @@
* 查询以创建的所有电子围栏
*/
public String findElectricFenc(String center, String radius, String points){
- String url = "https://restapi.amap.com/v4/geofence/meta?key=" + key;
- String forObject = restTemplate.getForObject(url, String.class);
+ String url = "https://restapi.amap.com/v4/geofence/meta";
+ String forObject = doGetWithRetry(url);
JSONObject jsonObject = JSON.parseObject(forObject);
JSONObject data = jsonObject.getJSONObject("data");
@@ -185,8 +267,8 @@
if(page == 1){
jsonArray = new JSONArray();
}
- String url = "https://restapi.amap.com/v4/geofence/meta?key=" + key + "&page_no=" + page + "&page_size=" + 30;
- String forObject = restTemplate.getForObject(url, String.class);
+ String url = "https://restapi.amap.com/v4/geofence/meta?page_no=" + page + "&page_size=" + 30;
+ String forObject = doGetWithRetry(url);
JSONObject jsonObject = JSON.parseObject(forObject);
JSONObject data = jsonObject.getJSONObject("data");
JSONArray rs_list = data.getJSONArray("rs_list");
@@ -275,14 +357,8 @@
json.put("alert_condition", "enter;leave");
json.put("desc", id + "围栏更新描述");
- HttpHeaders headers = new HttpHeaders();
- MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
- headers.setContentType(type);
- headers.add("Accept", MediaType.APPLICATION_JSON.toString());
- HttpEntity<String> formEntity = new HttpEntity<>(json.toString(), headers);
-
- String url = "https://restapi.amap.com/v4/geofence/meta?key=" + key + "&gid=" + gid;
- String s = restTemplate.patchForObject(url, formEntity, String.class);
+ String url = "https://restapi.amap.com/v4/geofence/meta?gid=" + gid;
+ String s = doPatchJsonWithRetry(url, json.toString());
System.out.println(s);
// gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/meta", "更新电子围栏");
@@ -304,8 +380,8 @@
diu = "B78F99DD-2496-4A43-843B-172CDA2D9798";
}
locations = locations + "," + (new Date().getTime() / 1000);
- String url = "https://restapi.amap.com/v4/geofence/status?key=" + key + "&diu=" + diu + "&locations=" + locations;
- String forObject = restTemplate.getForObject(url, String.class);
+ String url = "https://restapi.amap.com/v4/geofence/status?diu=" + diu + "&locations=" + locations;
+ String forObject = doGetWithRetry(url);
JSONObject jsonObject = JSON.parseObject(forObject);
List<String> ids = new ArrayList<>();
JSONObject data = jsonObject.getJSONObject("data");
@@ -334,7 +410,7 @@
* @return
*/
public boolean deleteElectricFenc(String gid){
- restTemplate.delete("https://restapi.amap.com/v4/geofence/meta?key={1}&gid={2}", key, gid);
+ restTemplate.delete("https://restapi.amap.com/v4/geofence/meta?key={1}&gid={2}", gdKeyManager.getKey(), gid);
System.out.println("删除:" );
// gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/meta", "删除电子围栏");
@@ -351,9 +427,9 @@
* @return
*/
public Map<String, String> getDistance(String origins, String destination, Integer type){
- String url = "https://restapi.amap.com/v3/distance?key=" + key + "&origins=" + origins + "&destination=" + destination +
+ String url = "https://restapi.amap.com/v3/distance?origins=" + origins + "&destination=" + destination +
"&type=" + type;
- String forObject = restTemplate.getForObject(url, String.class);
+ String forObject = doGetWithRetry(url);
JSONObject jsonObject = JSON.parseObject(forObject);
String status = jsonObject.getString("status");
@@ -381,9 +457,9 @@
* @return
*/
public Map<String, String> getDriving(String origins, String destination, String waypoints){
- String url = "https://restapi.amap.com/v3/direction/driving?key=" + key + "&origin=" + origins + "&destination=" + destination +
+ String url = "https://restapi.amap.com/v3/direction/driving?origin=" + origins + "&destination=" + destination +
"&waypoints=" + waypoints + "&extensions=base&strategy=0";
- String forObject = restTemplate.getForObject(url, String.class);
+ String forObject = doGetWithRetry(url);
JSONObject jsonObject = JSON.parseObject(forObject);
String status = jsonObject.getString("status");
diff --git a/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapGeocodingUtil.java b/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapGeocodingUtil.java
index 62bd4fb..8768d8f 100644
--- a/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapGeocodingUtil.java
+++ b/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapGeocodingUtil.java
@@ -20,13 +20,40 @@
@Component
public class GDMapGeocodingUtil {
- private String key = "ca723c3c8a78962a7751129ae035dc9d";
-
@Autowired
private RestTemplate restTemplate;
@Autowired
private IGDInterfaceService gdInterfaceService;
+
+ @Autowired
+ private GDKeyManager gdKeyManager;
+
+ /**
+ * 执行GET请求:key次数用完时自动切换可用key重试
+ */
+ private String doGetWithRetry(String baseUrl) {
+ String lastResp = null;
+ int maxAttempts = 5;
+ for (int i = 0; i < maxAttempts; i++) {
+ String key = gdKeyManager.getKey();
+ String url = baseUrl + (baseUrl.contains("?") ? "&" : "?") + "key=" + key;
+ String resp = restTemplate.getForObject(url, String.class);
+ lastResp = resp;
+ JSONObject jsonObject;
+ try {
+ jsonObject = JSON.parseObject(resp);
+ } catch (Exception e) {
+ return resp;
+ }
+ if (GDKeyManager.isWebKeyExhausted(jsonObject)) {
+ gdKeyManager.reportExhausted(key);
+ continue;
+ }
+ return resp;
+ }
+ return lastResp;
+ }
/**
@@ -55,9 +82,9 @@
return map;
}
- String url = "https://restapi.amap.com/v3/geocode/geo?key=" + key + "&output=JSON";
+ String url = "https://restapi.amap.com/v3/geocode/geo?output=JSON";
url += "&address=" + province + (ToolUtil.isNotEmpty(city) ? city : "") + (ToolUtil.isNotEmpty(county) ? county : "") + (ToolUtil.isNotEmpty(address) ? address : "");
- String forObject = restTemplate.getForObject(url, String.class);
+ String forObject = doGetWithRetry(url);
JSONObject jsonObject = JSON.parseObject(forObject);
String status = jsonObject.getString("status");
List<String> list = new ArrayList<>();
@@ -80,8 +107,8 @@
public Map<String, Object> geocoding(String address){
Map<String, Object> map = new HashMap<>();
- String url = "https://restapi.amap.com/v3/geocode/geo?key=" + key + "&output=JSON&address=" + address;
- String forObject = restTemplate.getForObject(url, String.class);
+ String url = "https://restapi.amap.com/v3/geocode/geo?output=JSON&address=" + address;
+ String forObject = doGetWithRetry(url);
JSONObject jsonObject = JSON.parseObject(forObject);
String status = jsonObject.getString("status");
List<String> list = new ArrayList<>();
@@ -110,8 +137,8 @@
* @throws Exception
*/
public Map<String, String> geocode(String lon, String lan) throws Exception{
- String url = "https://restapi.amap.com/v3/geocode/regeo?key=" + key + "&location=" + lon + "," + lan;
- String forObject = restTemplate.getForObject(url, String.class);
+ String url = "https://restapi.amap.com/v3/geocode/regeo?location=" + lon + "," + lan;
+ String forObject = doGetWithRetry(url);
JSONObject jsonObject = JSON.parseObject(forObject);
Map<String, String> map = new HashMap<>();
diff --git a/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/MinistryOfTransport.java b/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/MinistryOfTransport.java
deleted file mode 100644
index e6327bc..0000000
--- a/UserFBTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/MinistryOfTransport.java
+++ /dev/null
@@ -1,1063 +0,0 @@
-package com.stylefeng.guns.modular.system.util;
-
-
-import com.alibaba.fastjson.JSONObject;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import sun.security.krb5.internal.PAData;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 交通部接口对接
- */
-@Component
-public class MinistryOfTransport {
-
- private final String CompanyId = "4502YSGSGK3Y";//公司标识
-
- private final String Source = "0";//消息来源标识
-
- private final String url = "http://172.19.5.101:8085";
-
- @Autowired
- private HttpClientUtil httpClientUtil;
-
- private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
-
- private SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
-
- private SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMddHHmmss");
-
-
- /**
- * 上传企业基础信息
- */
- public void baseInfoCompany(){
- String IPCType = "baseInfoCompany";
- String path = url + "/baseinfo/company";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("CompanyName", "广西云森科技有限公司");//公司名称
- jsonObject.put("Identifier", "91450200MA5K99GK3Y");//统一社会信用代码
- jsonObject.put("Address", 450204);//注册地行政区划代码
- jsonObject.put("BusinessScope", "网络预约出租汽车客运");//经营范围
- jsonObject.put("ContactAddress", "柳州市柳南区航银路8号万利大厦3楼303室");//通信地址
- jsonObject.put("EconomicType", "150");//经营业户经济类型
- jsonObject.put("RegCapital", "壹仟万圆整");//注册资本
- jsonObject.put("LegalName", "翁克顺");//法人代表姓名
- jsonObject.put("LegalID", "44052419650805207X");//法人代表身份证号
- jsonObject.put("LegalPhone", "13907728585");//法人代表电话
- jsonObject.put("LegalPhoto", "");//法人代表身份证扫描件文件编号
- jsonObject.put("State", 0);//状态(0:有效,1:失效)
- jsonObject.put("Flag", 2);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 网约车平台公司营运规模信息接口
- */
- public void baseInfoCompanyStat(){
- String IPCType = "baseInfoCompanyStat";
- String path = url + "/baseinfo/companystat";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("VehicleNum", 0);//平台注册网约车辆数
- jsonObject.put("DriverNum", 0);//平台注册驾驶员数
- jsonObject.put("Flag", 2);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 网约车平台公司支付信息
- */
- public void baseInfoCompanyPay(){
- String IPCType = "baseInfoCompanyPay";
- String path = url + "/baseinfo/companypay";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("PayName", "");//银行或者非银行支付机构名称
- jsonObject.put("PayId", "");//非银行支付机构支付业务许可证编号
- jsonObject.put("PayType", "");//支付业务类型
- jsonObject.put("PayScope", "");//业务覆盖范围
- jsonObject.put("PrepareBank", "");//备付金存管银行
- jsonObject.put("CountDate", 1);//结算周期
- jsonObject.put("State", 0);//状态(0:有效,1:失效)
- jsonObject.put("Flag", 2);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 网约车平台公司服务机构
- */
- public void baseInfoCompanyService(){
- String IPCType = "baseInfoCompanyService";
- String path = url + "/baseinfo/companyservice";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 450204);//行政区划代码
- jsonObject.put("ServiceNae", "广西云森科技有限公司");//服务机构名称
- jsonObject.put("ServiceNo", "");//服务机构代码
- jsonObject.put("DetailAddress", "柳州市柳南区航银路8号万利大厦3楼303室");//服务机构地址
- jsonObject.put("ResponsibleName", "");//服务机构负责人姓名
- jsonObject.put("ResponsiblePhone", "");//负责人联系电话
- jsonObject.put("ManagerName", "");//服务机构管理人姓名
- jsonObject.put("ManagerPhone", "");//管理人联系电话
- jsonObject.put("ContactPhone", "");//服务机构紧急联系电话
- jsonObject.put("MailAddress", "");//行政文书送达邮寄地址
- jsonObject.put("CreateDate", 20150918);//服务机构设立日期
- jsonObject.put("State", 0);//状态(0:有效,1:失效)
- jsonObject.put("Flag", 2);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 网约车平台公司经营许可
- */
- public void baseInfoCompanyPermit(){
- String IPCType = "baseInfoCompanyPermit";
- String path = url + "/baseinfo/companypermit";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 450204);//许可地行政区划代码
- jsonObject.put("Certificate", "450200005403");//网络预约出租车经营许可证号
- jsonObject.put("OperationArea", "广西壮族自治州柳州市城区");//经营区域
- jsonObject.put("OwnerName", "广西云森科技有限公司");//公司名称
- jsonObject.put("Organization", "柳州市行政审批据");//发证机构名称
- jsonObject.put("StartDate", 20180330);//有效期起YYYYMMDD
- jsonObject.put("StopDate", 20220329);//有效期止YYYYMMDD
- jsonObject.put("CertifyDate", 0);//初次发证日期YYYYMMDD
- jsonObject.put("State", 0);//状态(0:有效,1:失效)
- jsonObject.put("Flag", 2);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 网约车平台公司运价信息
- */
- public void baseInfoCompanyFare(){
- String IPCType = "baseInfoCompanyFare";
- String path = url + "/baseinfo/companyfare";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 450204);//运价适用地行政区划代码
- jsonObject.put("FareType", "");//运价类型编码(由网约车平台公司统一编码,应确保唯一性)
- jsonObject.put("FareTypeNote", "");//运价类型说明
- jsonObject.put("FareValidOn", 0);//运价有效期起YYYYMMDDhhmmss
- jsonObject.put("FareValidOff", 0);//运价有效止YYYYMMDDhhmmss
- jsonObject.put("StartFare", 0);//起步价(元)
- jsonObject.put("StartMile", 0);//起步里程(km)
- jsonObject.put("UnitPricePerMile", 0);//计程单价(按公里/元)
- jsonObject.put("UnitPricePerMinute", 0);//计时单价(按分钟/元)
- jsonObject.put("UpPrice", 0);//单程加价单价(元)
- jsonObject.put("UpPriceStartMile", 0);//单程加价公里(km)
- jsonObject.put("MorningPeakTimeOn", "");//营运早高峰时间起(HHmm 24小时)
- jsonObject.put("MorningPeakTimeOff", "");//营运早高峰时间止(HHmm 24小时)
- jsonObject.put("EveningPeakTimeOn", "");//营运晚高峰时间起(HHmm 24小时)
- jsonObject.put("EveningPeakTimeOff", "");//营运晚高峰时间止(HHmm 24小时)
- jsonObject.put("OtherPeakTimeOn", "");//其他营运高等时间起(HHmm 24小时)
- jsonObject.put("OtherPeakTineOff", "");//其他营运高等时间止(HHmm 24小时)
- jsonObject.put("PeakUnitPrice", 0);//高峰时间单程加价单价(元)
- jsonObject.put("PeakPriceStartMile", 0);//高峰时间单程加价公里(km)
- jsonObject.put("LowSpeedPriceMinute", 0);//低速计时加价(按分钟 元)
- jsonObject.put("NightPricePerMile", 0);//夜间费(按公里 元)
- jsonObject.put("NightPricePerMinute", 0);//夜间费(按分钟 元)
- jsonObject.put("OtherPrice", 0);//其它加价金额(元)
-
- jsonObject.put("State", 0);//状态(0:有效,1:失效)
- jsonObject.put("Flag", 2);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 车辆基本信息
- */
- public void baseInfoVehicle(){
- String IPCType = "baseInfoVehicle";
- String path = url + "/baseinfo/vehicle";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 450204);//车辆所在城市行政区划代码
- jsonObject.put("VehicleNo", "");//车辆号牌
- jsonObject.put("PlateColor", "");//车牌颜色
- jsonObject.put("Seats", 5);//核定载客位
- jsonObject.put("Brand", "");//车辆厂牌
- jsonObject.put("Model", "");//车辆型号
- jsonObject.put("VehicleType", "");//车辆类型(以机动车行驶证为准)
- jsonObject.put("OwnerName", "");//车辆所有人(以机动车行驶证为准)
- jsonObject.put("VehicleColor", "");//车身颜色
- jsonObject.put("EngineId", "");//发送机号(以机动车行驶证为准)
- jsonObject.put("VIN", "");//车辆VIN码(以机动车行驶证为准)
- jsonObject.put("CertifyDateA", 0);//车辆注册日期(以机动车行驶证为准)
- jsonObject.put("FuelType", "");//车辆燃料类型
- jsonObject.put("EngineDisplace", "");//发送机排量(毫升)
- jsonObject.put("PhotoId", "");//车辆照片文件编号
- jsonObject.put("Certificate", "");//运输证字号
- jsonObject.put("TransAgency", "");//车辆运输证发证机构
- jsonObject.put("TransArea", "");//车辆经营区域
- jsonObject.put("TransDateStart", 0);//车辆运输证有效期起YYYYMMDD
- jsonObject.put("TransDateStop", 0);//车辆运输证有效期止YYYYMMDD
- jsonObject.put("CertifyDateB", 0);//车辆初次登记日期
- jsonObject.put("FixState", "");//车辆维修状态(0:未检修,1:已检修,2:未知)
- jsonObject.put("NextFixDate", 0);//车辆下次年检时间
- jsonObject.put("CheckState", "");//车辆年度审验状态
- jsonObject.put("FeePrintId", "");//发票打印设备序列号
- jsonObject.put("GPSBrand", "");//卫星定位装置品牌
- jsonObject.put("GPSModel", "");//卫星定位装置型号
- jsonObject.put("GPSIMEI", "");//卫星定位装置IMEI号
- jsonObject.put("GPSInstallDate", 0);//卫星定位设备安装日期YYYYMMDD
- jsonObject.put("RegisterDate", 0);//报备日期(车辆信息向服务所在地出租车行政主管部门报备日期YYYYMMDD)
- jsonObject.put("CommercialType", 0);//服务类型(1:网络预约出租车,2:巡游出租汽车,3:私人小客车合乘)
- jsonObject.put("FareType", "");//运价类型编码(与云间信息中一一对应)
-
- jsonObject.put("State", 0);//状态(0:有效,1:失效)
- jsonObject.put("Flag", 2);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 车辆保险信息
- */
- public void baseInfoVehicleInsurance(){
- String IPCType = "baseInfoVehicleInsurance";
- String path = url + "/baseinfo/vehicleinsurance";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("VehicleNo", "");//车辆号牌
- jsonObject.put("InsurCom", "");//保险公司名称
- jsonObject.put("InsurNum", "");//保险号
- jsonObject.put("InsurType", "");//保险类型
- jsonObject.put("InsurCount", 0);//保险金额(元)
- jsonObject.put("InsurEff", 0);//保险生效时间YYYYMMDD
- jsonObject.put("InsurExp", 0);//保险到期时间YYYYMMDD
-
- jsonObject.put("Flag", 1);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 网约车车辆里程信息
- */
- public void baseInfoVehicleTotalMile(){
- String IPCType = "baseInfoVehicleTotalMile";
- String path = url + "/baseinfo/vehicletotalmile";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 450204);//注册地行政区划代码
- jsonObject.put("VehicleNo", "");//车辆号牌
- jsonObject.put("TotalMile", 0);//行驶总里程(km)
-
- jsonObject.put("Flag", 1);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 驾驶员基本信息
- */
- public void baseInfoDriver(){
- String IPCType = "baseInfoDriver";
- String path = url + "/baseinfo/driver";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 450204);//注册地行政区划代码
- jsonObject.put("DriverName", "");//机动车驾驶员姓名
- jsonObject.put("DriverPhone", "");//驾驶员手机号
- jsonObject.put("DriverGender", "");//驾驶员性别
- jsonObject.put("DriverBirthday", 0);//出生日期YYYYMMDD
- jsonObject.put("DriverNationality", "");//国籍
- jsonObject.put("DriverNation", "");//驾驶员民族
- jsonObject.put("DriverMaritalStatus", "");//驾驶员婚姻状况(未婚,已婚,离异)
- jsonObject.put("DriverLanguageLevel", "");//驾驶员外语能力
- jsonObject.put("DriverEducation", "");//驾驶员学历
- jsonObject.put("DriverCensus", "");//户口登记机关名称
- jsonObject.put("DriverAddress", "");//户口住址或长住地址
- jsonObject.put("DriverContactAddress", "");//驾驶员通信地址
- jsonObject.put("PhotoId", "");//驾驶员照片文件编号
- jsonObject.put("LicenseId", "");//机动车驾驶证号
- jsonObject.put("LicensePhotoId", "");//机动车驾驶证扫描件文件编号
- jsonObject.put("DriverType", "");//准驾车型
- jsonObject.put("GetDriverLicenseDate", 0);//初次领取驾驶证日期YYYYMMDD
- jsonObject.put("DriverLicenseOn", 0);//驾驶证有效期限起YYYYMMDD
- jsonObject.put("DriverLicenseOff", 0);//驾驶证有效期限止YYYYMMDD
- jsonObject.put("TaxiDriver", 0);//是否巡游出租汽车驾驶员(1:是,2:否)
- jsonObject.put("CertificateNo", "");//网络预约出租汽车驾驶员资格证号
- jsonObject.put("NetworkCarIssueOrganization", "");//网络预约出租汽车驾驶员证发证机构
- jsonObject.put("NetworkCarIssueDate", 0);//资格证发证日期YYYYMMDD
- jsonObject.put("GetNetworkCarProofDate", 0);//初次领取资格证日期YYYYMMDD
- jsonObject.put("NetworkCarProofOn", 0);//资格证有效起始日期YYYYMMDD
- jsonObject.put("NetworkCarProofOff", 0);//资格证有截止日期YYYYMMDD
- jsonObject.put("RegisterDate", 0);//报备日期(驾驶员信息向服务所在地出租车行政主管部门报备日期)
- jsonObject.put("FullTimeDriver", 0);//是否专职驾驶员(1:是,0:否)
- jsonObject.put("InDriverBlacklist", 0);//是否在驾驶员黑名单内(1:是,0:否)
- jsonObject.put("CommercialType", 0);//服务类型(1:网络预约出租汽车,2:巡游出租汽车,3:私人小客车合乘)
- jsonObject.put("ContractCompany", "");//驾驶员合同签署公司
- jsonObject.put("ContractOn", 0);//合同有效期起YYYYMMDD
- jsonObject.put("ContractOff", 0);//合同有效期止YYYYMMDD
- jsonObject.put("EmergencyContact", "");//紧急情况联系人
- jsonObject.put("EmergencyContactPhone", "");//紧急情况联系人电话
- jsonObject.put("EmergencyContactAddress", "");//紧急情况联系人通信地址
-
- jsonObject.put("State", 0);//状态(0:有效,1:失效)
- jsonObject.put("Flag", 1);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 网约车驾驶员培训信息
- */
- public void baseInfoDriverEducate(){
- String IPCType = "baseInfoDriverEducate";
- String path = url + "/baseinfo/drivereducate";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 450204);//注册地行政区划代码
- jsonObject.put("LicenseId", "");//机动车驾驶证号
- jsonObject.put("CourseName", "");//驾驶员培训课程名称
- jsonObject.put("CourseDate", 0);//培训课程日期YYYYMMDD
- jsonObject.put("StartTime", "");//培训开始时间
- jsonObject.put("StopTime", "");//培训结束时间
- jsonObject.put("Duration", 0);//培训时长
-
- jsonObject.put("Flag", 1);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 驾驶员移动终端信息
- */
- public void baseInfoDriverApp(){
- String IPCType = "baseInfoDriverApp";
- String path = url + "/baseinfo/driverapp";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 450204);//注册地行政区划代码
- jsonObject.put("LicenseId", "");//机动车驾驶证号
- jsonObject.put("DriverPhone", "");//驾驶员手机号
- jsonObject.put("NetType", 0);//手机运营商(1:中国联通,2:中国移动,3:中国电信,4:其他)
- jsonObject.put("AppVersion", "");//使用APP版本号
- jsonObject.put("MapType", 0);//使用地图类型(1:百度地图,2:高德地图,3:其他)
-
- jsonObject.put("State", 0);//状态(0:有效,1:失效)
- jsonObject.put("Flag", 1);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 驾驶员统计信息
- */
- public void baseInfoDriverStat(){
- String IPCType = "baseInfoDriverStat";
- String path = url + "/baseinfo/driverstat";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 450204);//注册地行政区划代码
- jsonObject.put("LicenseId", "");//机动车驾驶证号
- jsonObject.put("Cycle", 0);//统计周期(统计周期按月,内容填写统计月份YYYYMM)
- jsonObject.put("OrderCount", 0);//完成订单次数
- jsonObject.put("TrafficViolationCount", 0);//交通违章次数
- jsonObject.put("ComplainedCount", 0);//被投诉次数
-
- jsonObject.put("Flag", 1);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 乘客基本信息
- */
- public void baseInfoPassenger(){
- String IPCType = "baseInfoPassenger";
- String path = url + "/baseinfo/passenger";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("RegisterDate", 0);//注册日期YYYYMMDD
- jsonObject.put("PassengerPhone", "");//乘客手机号
- jsonObject.put("PassengerName", "");//乘客称谓
- jsonObject.put("PassengerGender", "");//乘客性别
-
- jsonObject.put("State", 0);//状态(0:有效,1:失效)
- jsonObject.put("Flag", 1);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", Long.valueOf(sdf.format(new Date())));
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 订单发起接口
- */
- public void orderCreate(){
- String IPCType = "orderCreate";
- String path = url + "/order/create";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 0);//发起第行政区划代码
- jsonObject.put("OrderId", "");//订单编号
- jsonObject.put("DepartTime", 0);//预计用车时间YYYYMMDDhhmmss
- jsonObject.put("OrderTime", 0);//订单发起时间YYYYMMDDhhmmss
- jsonObject.put("PassengerNote", "");//乘客备注
- jsonObject.put("Departure", "");//预计出发地点详细地址
- jsonObject.put("DepLongitude", 0);//预计出发地点经度
- jsonObject.put("DepLatitude", 0);//预计出发地点纬度
- jsonObject.put("Destination", "");//预计目的地
- jsonObject.put("DestLongitude", 0);//预计目的地经度
- jsonObject.put("DestLatitude", 0);//预计目的地纬度
- jsonObject.put("Encrypt", 0);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
- jsonObject.put("FareType", "");//运价类型编码
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 订单成功接口
- */
- public void orderMatch(){
- String IPCType = "orderMatch";
- String path = url + "/order/match";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 0);//发起第行政区划代码
- jsonObject.put("OrderId", "");//订单编号
- jsonObject.put("Longitude", 0);//车辆经度
- jsonObject.put("Latitude", 0);//车辆纬度
- jsonObject.put("Encrypt", 0);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
- jsonObject.put("LicenseId", "");//机动车驾驶证编号
- jsonObject.put("DriverPhone", "");//驾驶员手机号
- jsonObject.put("VehicleNo", "");//车辆号牌
- jsonObject.put("DistributeTime", 0);//派单成功时间YYYYMMDDhhmmss
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 订单撤销接口
- */
- public void orderCancel(){
- String IPCType = "orderCancel";
- String path = url + "/order/cancel";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 0);//上车地点行政区划代码
- jsonObject.put("OrderId", "");//订单编号
- jsonObject.put("OrderTime", 0);//订单时间YYYYMMDDhhmmss
- jsonObject.put("CancelTime", 0);//订单撤销时间YYYYMMDDhhmmss
- jsonObject.put("Operator", "");//撤销发起方(1:乘客,2:驾驶员,3:平台公司)
- jsonObject.put("CancelTypeCode", "");//机动车驾驶证编号
- jsonObject.put("DriverPhone", "");//撤销类型代码(1:乘客提前撤销,2:驾驶员提前撤销,3:平台公司撤销,4:乘客违约撤销,5:驾驶员违约撤销)
- jsonObject.put("CancelReason", "");//撤销或违约原因
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 车辆经营上线接口
- */
- public void operateLogin(){
- String IPCType = "operateLogin";
- String path = url + "/operate/login";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("LicenseId", "");//机动车驾驶证号
- jsonObject.put("VehicleNo", "");//车辆号牌
- jsonObject.put("LoginTime", 0);//车辆经营上线时间YYYYMMDDhhmmss
- jsonObject.put("Longitude", 0);//上线经度
- jsonObject.put("Latitude", 0);//上线纬度
- jsonObject.put("Encrypt", 0);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 车辆经营下线接口
- */
- public void operateLogout(){
- String IPCType = "operateLogout";
- String path = url + "/operate/logout";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("LicenseId", "");//机动车驾驶证号
- jsonObject.put("VehicleNo", "");//车辆号牌
- jsonObject.put("LoginTime", 0);//车辆经营下线时间YYYYMMDDhhmmss
- jsonObject.put("Longitude", 0);//下线经度
- jsonObject.put("Latitude", 0);//下线纬度
- jsonObject.put("Encrypt", 0);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 经营出发接口
- */
- public void operateDepart(){
- String IPCType = "operateDepart";
- String path = url + "/operate/depart";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("OrderId", "");//订单号
- jsonObject.put("LicenseId", "");//机动车驾驶证号
- jsonObject.put("FareType", "");//运价类型编码
- jsonObject.put("VehicleNo", "");//车辆号牌
- jsonObject.put("DepLongitude", 0);//车辆出发经度
- jsonObject.put("DepLatitude", 0);//车辆出发纬度
- jsonObject.put("Encrypt", 0);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
- jsonObject.put("DepTime", 0);//上车时间YYYYMMDDhhmmss
- jsonObject.put("WaitMile", 0);//空驶里程(km)
- jsonObject.put("WaitTime", 0);//等待时间(秒)
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 经营到达接口
- */
- public void operateArrive(){
- String IPCType = "operateArrive";
- String path = url + "/operate/arrive";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("OrderId", "");//订单号
- jsonObject.put("DestLongitude", 0);//车辆到达经度
- jsonObject.put("DestLatitude", 0);//车辆到达纬度
- jsonObject.put("Encrypt", 0);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
- jsonObject.put("DestTime", 0);//下车时间YYYYMMDDhhmmss
- jsonObject.put("DriveMile", 0);//载客里程(km)
- jsonObject.put("DriveTime", 0);//载客时间(秒)
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 经营支付接口
- */
- public void operatePay(){
- String IPCType = "operatePay";
- String path = url + "/operate/pay";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("OrderId", "");//订单号
- jsonObject.put("OnArea", 0);//上车位置行政区划代码
- jsonObject.put("DriverName", "");//机动车驾驶员
- jsonObject.put("LicenseId", "");//机动车驾驶证号
- jsonObject.put("FareType", "");//运价类型编码(由网约车公司定义,与运价信息接口保持一街)
- jsonObject.put("VehicleNo", "");//车辆号牌
- jsonObject.put("BookDepTime", 0);//预计上车时间YYYYMMDDhhmmss
- jsonObject.put("WaitTime", 0);//等待时间(秒)
- jsonObject.put("DepLongitude", 0);//车辆出发经度
- jsonObject.put("DepLatitude", 0);//车辆出发纬度
- jsonObject.put("DepArea", "");//上车点
- jsonObject.put("DepTime", 0);//上车时间YYYYMMDDhhmmss
- jsonObject.put("DestLongitude", 0);//车辆到达经度
- jsonObject.put("DestLatitude", 0);//车辆到达纬度
- jsonObject.put("DestArea", "");//下车地点
- jsonObject.put("DestTime", 0);//下车时间YYYYMMDDhhmmss
- jsonObject.put("BookModel", "");//预定车型
- jsonObject.put("DriveMile", 0);//载客里程(km)
- jsonObject.put("DriveTime", 0);//载客时间(秒)
- jsonObject.put("WaitMile", 0);//空驶里程(km)
- jsonObject.put("FactPrice", 0);//实收金额(元)
- jsonObject.put("Price", 0);//应收金额(元)
- jsonObject.put("CashPrice", 0);//现金支付金额(元)
- jsonObject.put("LineName", "");//电子支付机构
- jsonObject.put("LinePrice", 0);//电子支付金额(元)
- jsonObject.put("PosName", "");//POS机支付机构
- jsonObject.put("PosPrice", 0);//POS机支付金额(元)
- jsonObject.put("BenfitPrice", 0);//优惠金额(元)
- jsonObject.put("BookTip", 0);//预约服务费(元)
- jsonObject.put("PassengerTip", 0);//附加费(元)
- jsonObject.put("PeakUpPrice", 0);//高峰时段时间加价金额(元)
- jsonObject.put("NightUpPrice", 0);//夜间时段里程加价金额(元)
- jsonObject.put("FarUpPrice", 0);//远途加价金额(元)
- jsonObject.put("OtherUpPrice", 0);//其他加价金额(元)
- jsonObject.put("PayState", "");//结算状态(0:未结算,1:已结算,2:未知)
- jsonObject.put("PayTime", 0);//乘客结算时间YYYYMMDDhhmmss
- jsonObject.put("OrderMatchTime", 0);//订单完成时间YYYYMMDDhhmmss
- jsonObject.put("InvoiceStatus", "");//发票状态(0:未开票,1:已开票,2:未知)
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 驾驶员定位信息
- */
- public void positionDriver(){
- String IPCType = "positionDriver";
- String path = url + "/position/driver";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("LicenseId", "");//机动车驾驶证号
- jsonObject.put("DriverRegionCode", 0);//行政区划代码
- jsonObject.put("VehicleNo", "");//车辆号牌
- jsonObject.put("PositionTime", 0);//定位时间(时间戳)
- jsonObject.put("Longitude", 0);//经度
- jsonObject.put("Latitude", 0);//纬度
- jsonObject.put("Encrypt", 0);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
- jsonObject.put("Direction", 0);//方向角
- jsonObject.put("Elevation", 0);//海拔高度
- jsonObject.put("Speed", 0);//瞬时速度(km/h)
- jsonObject.put("BizStatus", 0);//营运状态(1:载客,2:接单,3:空驶,4:停运)
- jsonObject.put("OrderId", "");//订单编号
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 车辆定位信息
- */
- public void positionVehicle(){
- String IPCType = "positionVehicle";
- String path = url + "/position/vehicle";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("VehicleNo", "");//车辆号牌
- jsonObject.put("VehicleRegionCode", 0);//行政区划代码
- jsonObject.put("PositionTime", 0);//定位时间(时间戳)
- jsonObject.put("Longitude", 0);//经度
- jsonObject.put("Latitude", 0);//纬度
- jsonObject.put("Speed", 0);//瞬时速度(km/h)
- jsonObject.put("Direction", 0);//方向角
- jsonObject.put("Elevation", 0);//海拔高度
- jsonObject.put("Mileage", 0);//行驶里程(KM)
- jsonObject.put("Encrypt", 0);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
- jsonObject.put("WarnStatus", 0);//预警状态
- jsonObject.put("VehStatus", 0);//车辆状态
- jsonObject.put("BizStatus", 0);//营运状态(1:载客,2:接单,3:空驶,4:停运)
- jsonObject.put("OrderId", "");//订单编号(非营运状态下填"0")
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 乘客评价信息
- */
- public void ratedPassenger(){
- String IPCType = "ratedPassenger";
- String path = url + "/rated/passenger";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("OrderId", "");//订单号
- jsonObject.put("EvaluateTime", 0);//评价时间YYYYMMDDhhmms
- jsonObject.put("ServiceScore", 0);//服务满意度(五分制)
- jsonObject.put("DriverScore", 0);//驾驶员满意度(五分制)
- jsonObject.put("VehicleScore", 0);//车辆满意度(五分制)
- jsonObject.put("Detail", "");//评价内容
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 乘客投诉信息
- */
- public void ratedPassengerComplaint(){
- String IPCType = "ratedPassengerComplaint";
- String path = url + "/rated/passengercomplaint";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("OrderId", "");//订单号
- jsonObject.put("ComplaintTime", 0);//投诉时间YYYYMMDDhhmms
- jsonObject.put("Detail", "");//投诉内容
- jsonObject.put("Result", "");//处理结果
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
- /**
- * 驾驶员处罚信息
- */
- public void ratedDriverPunish(){
- String IPCType = "ratedDriverPunish";
- String path = url + "/rated/driverpunish";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("LicenseId", "");//机动车驾驶证编号
- jsonObject.put("PunishTime", 0);//处罚时间YYYYMMDDhhmms
- jsonObject.put("PunishReason", "");//处罚原因
- jsonObject.put("PunishReault", "");//处罚结果
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 驾驶员信誉信息
- */
- public void ratedDriver(){
- String IPCType = "ratedDriver";
- String path = url + "/rated/driver";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("LicenseId", "");//机动车驾驶证编号
- jsonObject.put("Level", 0);//服务质量信誉等级(五分制)
- jsonObject.put("TestDate", 0);//服务质量信誉考核日期YYYYMMDD
- jsonObject.put("TestDepartment", "");//服务质量信誉考核机构
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 私人小客车合乘信息服务平台基本信息
- */
- public void shareCompany(){
- String IPCType = "shareCompany";
- String path = url + "/share/company";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("CompanyName", "");//公司名称
- jsonObject.put("Identifier", "");//统一社会信用代码
- jsonObject.put("Address", 0);//注册地行政区划代码
- jsonObject.put("ContactAddress", "");//通信地址
- jsonObject.put("EconomicType", "");//经营业户经济类型
- jsonObject.put("LegalName", "");//法人代表姓名(按照营业执照填写)
- jsonObject.put("LegalPhone", "");//法人代表电话
- jsonObject.put("State", 0);//状态(0:有效,1:失效)
- jsonObject.put("Flag", 1);//操作标识(1:新增,2:更新,3:删除)
- jsonObject.put("UpdateTime", 1);//更新时间YYYYMMDDhhmmss
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
- /**
- * 私人小客车合乘驾驶员行程发布接口
- */
- public void shareRoute(){
- String IPCType = "shareRoute";
- String path = url + "/share/route";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 0);//行政区划代码
- jsonObject.put("RouteId", "");//驾驶员发起行程编号
- jsonObject.put("DriverName", "");//驾驶员姓名
- jsonObject.put("DriverPhone", "");//驾驶员手机号
- jsonObject.put("LicenseId", "");//机动车驾驶证号
- jsonObject.put("VehicleNo", "");//车辆号牌
- jsonObject.put("Departure", "");//行程出发地点
- jsonObject.put("DepLongitude", 0);//车辆出发经度
- jsonObject.put("DepLatitude", 0);//车辆出发纬度
- jsonObject.put("Destination", "");//行程到达地点
- jsonObject.put("DestLongitude", 0);//到达地经度
- jsonObject.put("DestLatitude", 0);//到达纬度
- jsonObject.put("Encrypt", 0);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
- jsonObject.put("RouteCreateTime", 0);//行程发布时间YYYYMMDDhhmmss
- jsonObject.put("RouteMile", 0);//行程预计里程(km)
- jsonObject.put("RouteNote", "");//行程备注
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 此人小客车合乘订单接口
- */
- public void shareOrder(){
- String IPCType = "shareOrder";
- String path = url + "/share/order";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 0);//行政区划代码
- jsonObject.put("RouteId", "");//驾驶员发起行程编号
- jsonObject.put("OrderId", "");//乘客合乘订单号
- jsonObject.put("BookDepartTime", 0);//预计上车时间YYYYMMDDhhmmss
- jsonObject.put("Departure", "");//预计上车地点
- jsonObject.put("DepLongitude", 0);//预计上车地点经度
- jsonObject.put("DepLatitude", 0);//预计上车地点纬度
- jsonObject.put("Destination", "");//预计下车地点
- jsonObject.put("DestLongitude", 0);//预计下车地点经度
- jsonObject.put("DestLatitude", 0);//预计下车地点纬度
- jsonObject.put("Encrypt", 0);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
- jsonObject.put("OrderEnsureTime", 0);//订单确认时间YYYYMMDDhhmmss
- jsonObject.put("PassengerNum", 0);//乘客人数
- jsonObject.put("PassengerNote", "");//乘客备注
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-
-
- /**
- * 私人小客车合乘订单支付接口
- */
- public void sharePay(){
- String IPCType = "sharePay";
- String path = url + "/share/pay";
- Map<String, Object> data = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("CompanyId", CompanyId);
- jsonObject.put("Address", 0);//行政区划代码
- jsonObject.put("RouteId", "");//驾驶员发起行程编号
- jsonObject.put("OrderId", "");//乘客合乘订单号
- jsonObject.put("DriverPhone", "");//驾驶员手机号
- jsonObject.put("LicenseId", "");//机动车驾驶证号
- jsonObject.put("VehicleNo", "");//车辆号牌
- jsonObject.put("FareType", "");//运价类型编码
- jsonObject.put("BookDepartTime", 0);//预计上车时间YYYYMMDDhhmmss
- jsonObject.put("DepartTime", 0);//实际上车时间YYYYMMDDhhmmss
- jsonObject.put("Departure", "");//上车地点
- jsonObject.put("DepLongitude", 0);//上车地点经度
- jsonObject.put("DepLatitude", 0);//上车地点纬度
- jsonObject.put("DestTime", 0);//下车时间YYYYMMDDhhmmss
- jsonObject.put("Destination", "");//下车地点
- jsonObject.put("DestLongitude", 0);//下车地点经度
- jsonObject.put("DestLatitude", "");//下车地点纬度
- jsonObject.put("Encrypt", 0);//坐标加密标识(1:GCJ-02测绘局标准,2:WGS84 GPS标准,3:BD-09百度标准,4:CGCS2000北斗标准,0:其他)
- jsonObject.put("DriveMile", 0);//载客里程(km)
- jsonObject.put("DriveTime", 0);//载客时间(秒)
- jsonObject.put("FactPrice", 0);//实收金额(元)
- jsonObject.put("Price", 0);//应收金额(元)
- jsonObject.put("CashPrice", 0);//现金支付金额(元)
- jsonObject.put("LineName", "");//电子支付机构
- jsonObject.put("LinePrice", 0);//电子支付金额(元)
- jsonObject.put("BenfitPrice", 0);//优惠金额(元)
- jsonObject.put("ShareFuelFee", 0);//燃料成本分摊金额(元)
- jsonObject.put("ShareHighwayToll", 0);//路桥通行分摊金额(元)
- jsonObject.put("PassengerTip", 0);//附加费(元)
- jsonObject.put("ShareOther", 0);//其他费用分摊金额(元)
- jsonObject.put("PayState", 0);//结算状态(0:未结算,1:已结算,2:未知)
- jsonObject.put("PassengerNum", 0);//乘客人数(元)
- jsonObject.put("PayTime", 0);//乘客结算时间YYYYMMDDhhmmss
- jsonObject.put("OrderMatchTime", 0);//订单完成时间YYYYMMDDhhmmss
-
- data.put("CompanyId", CompanyId);
- data.put("Source", Source);
- data.put("IPCType", IPCType);
- data.put("baseInfoCompany", jsonObject);
- String s = httpClientUtil.pushHttpRequset("POST", path, data, null, "json");
- System.err.println(s);
- }
-}
diff --git a/UserFBTravel/guns-admin/src/test/java/com/stylefeng/guns/modular/crossCity/server/impl/SiteServiceImplTest.java b/UserFBTravel/guns-admin/src/test/java/com/stylefeng/guns/modular/crossCity/server/impl/SiteServiceImplTest.java
new file mode 100644
index 0000000..006ce6a
--- /dev/null
+++ b/UserFBTravel/guns-admin/src/test/java/com/stylefeng/guns/modular/crossCity/server/impl/SiteServiceImplTest.java
@@ -0,0 +1,51 @@
+package com.stylefeng.guns.modular.crossCity.server.impl;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class SiteServiceImplTest {
+
+ private static final String SQUARE = "0,0;10,0;10,10;0,10";
+
+ @Test
+ public void shouldRecognizePointInsidePolygon() {
+ assertTrue(SiteServiceImpl.isPointInElectronicFence("5,5", SQUARE));
+ }
+
+ @Test
+ public void shouldRecognizePointOutsidePolygon() {
+ assertFalse(SiteServiceImpl.isPointInElectronicFence("11,5", SQUARE));
+ }
+
+ @Test
+ public void shouldIncludePointOnEdgeAndVertex() {
+ assertTrue(SiteServiceImpl.isPointInElectronicFence("10,5", SQUARE));
+ assertTrue(SiteServiceImpl.isPointInElectronicFence("0,0", SQUARE));
+ }
+
+ @Test
+ public void shouldRecognizeConcavePolygon() {
+ String concavePolygon = "0,0;10,0;10,10;5,5;0,10";
+ assertTrue(SiteServiceImpl.isPointInElectronicFence("5,4", concavePolygon));
+ assertFalse(SiteServiceImpl.isPointInElectronicFence("5,8", concavePolygon));
+ }
+
+ @Test
+ public void shouldRecognizeAnyOfMultiplePolygons() {
+ String multiplePolygons = SQUARE + "_20,20;30,20;30,30;20,30";
+ assertTrue(SiteServiceImpl.isPointInElectronicFence("25,25", multiplePolygons));
+ assertFalse(SiteServiceImpl.isPointInElectronicFence("15,15", multiplePolygons));
+ }
+
+ @Test
+ public void shouldHandleWhitespaceAndInvalidCoordinates() {
+ assertTrue(SiteServiceImpl.isPointInElectronicFence(" 5 , 5 ", " 0,0 ; 10,0 ; 10,10 ; 0,10 "));
+ assertFalse(SiteServiceImpl.isPointInElectronicFence("invalid", SQUARE));
+ assertFalse(SiteServiceImpl.isPointInElectronicFence("5,5", "0,0;10,0"));
+ assertFalse(SiteServiceImpl.isPointInElectronicFence("5,5", "0,0;invalid;10,10"));
+ assertFalse(SiteServiceImpl.isPointInElectronicFence(null, SQUARE));
+ assertFalse(SiteServiceImpl.isPointInElectronicFence("5,5", null));
+ }
+}
--
Gitblit v1.7.1