|
@@ -5,9 +5,11 @@ import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.openapi.sdk.service.DataExchangeService;
|
|
import com.openapi.sdk.service.DataExchangeService;
|
|
import com.steerinfo.dil.mapper.QueueInterfaceMapper;
|
|
import com.steerinfo.dil.mapper.QueueInterfaceMapper;
|
|
|
|
+import org.apache.poi.util.StringUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -47,7 +49,11 @@ public class QueueInterfaceServiceImpl {
|
|
* @param map
|
|
* @param map
|
|
* @return
|
|
* @return
|
|
**/
|
|
**/
|
|
- public String subsCapacity(Map<String, Object> map){
|
|
|
|
|
|
+ public String subsCapacity(Map<String, Object> map,int i){
|
|
|
|
+
|
|
|
|
+ if (i==3){
|
|
|
|
+ return "超出递归次数限制";
|
|
|
|
+ }
|
|
|
|
|
|
if (map.get("capacityNumber")==null||"".equals(map.get("capacityNumber").toString())){
|
|
if (map.get("capacityNumber")==null||"".equals(map.get("capacityNumber").toString())){
|
|
return "参数【capacityNumber】车号,为空";
|
|
return "参数【capacityNumber】车号,为空";
|
|
@@ -57,7 +63,11 @@ public class QueueInterfaceServiceImpl {
|
|
mesMap.put("cid", cid);
|
|
mesMap.put("cid", cid);
|
|
mesMap.put("srt", srt);
|
|
mesMap.put("srt", srt);
|
|
mesMap.put("userflag", userflag);
|
|
mesMap.put("userflag", userflag);
|
|
- mesMap.put("areaid", queueInterfaceMapper.getAreaId());
|
|
|
|
|
|
+ String areaId = queueInterfaceMapper.getAreaId();
|
|
|
|
+ if(areaId==null){
|
|
|
|
+ return "区域id为空";
|
|
|
|
+ }
|
|
|
|
+ mesMap.put("areaid", areaId);
|
|
mesMap.put("vnos", (String) map.get("capacityNumber"));
|
|
mesMap.put("vnos", (String) map.get("capacityNumber"));
|
|
String url = "https://openapi-test.sinoiov.cn/save/apis/vnoReg";
|
|
String url = "https://openapi-test.sinoiov.cn/save/apis/vnoReg";
|
|
try {
|
|
try {
|
|
@@ -68,7 +78,7 @@ public class QueueInterfaceServiceImpl {
|
|
Object status = jsonMap.get("status");
|
|
Object status = jsonMap.get("status");
|
|
if("1016".equals(status.toString())){
|
|
if("1016".equals(status.toString())){
|
|
if(login() == 1){
|
|
if(login() == 1){
|
|
- subsCapacity(map); //递归订阅
|
|
|
|
|
|
+ return subsCapacity(map,i+1); //递归订阅
|
|
}else {
|
|
}else {
|
|
return "登录失败,状态码:"+status;
|
|
return "登录失败,状态码:"+status;
|
|
}
|
|
}
|
|
@@ -77,7 +87,7 @@ public class QueueInterfaceServiceImpl {
|
|
if("2".equals(jsonMap.get("result").toString())){
|
|
if("2".equals(jsonMap.get("result").toString())){
|
|
//如果是自定义区域不存在则重新注册自定义区域
|
|
//如果是自定义区域不存在则重新注册自定义区域
|
|
if(registerAreaReg() == 1){
|
|
if(registerAreaReg() == 1){
|
|
- subsCapacity(map);
|
|
|
|
|
|
+ return subsCapacity(map,i+1);
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
return "订阅成功";
|
|
return "订阅成功";
|
|
@@ -171,25 +181,40 @@ public class QueueInterfaceServiceImpl {
|
|
* @param map
|
|
* @param map
|
|
* @return
|
|
* @return
|
|
**/
|
|
**/
|
|
- public void cancelSubsCapacity(Map<String, Object> map){
|
|
|
|
|
|
+ public int cancelSubsCapacity(Map<String, Object> map,int i){
|
|
|
|
+ if (i==3){
|
|
|
|
+ return -2;
|
|
|
|
+ }
|
|
Map<String, String> mesMap = new HashMap<>(4);
|
|
Map<String, String> mesMap = new HashMap<>(4);
|
|
mesMap.put("cid", cid);
|
|
mesMap.put("cid", cid);
|
|
mesMap.put("srt", srt);
|
|
mesMap.put("srt", srt);
|
|
mesMap.put("token", token);
|
|
mesMap.put("token", token);
|
|
mesMap.put("userflag", userflag);
|
|
mesMap.put("userflag", userflag);
|
|
- mesMap.put("vons", (String) map.get("capacityNumber"));
|
|
|
|
|
|
+ mesMap.put("vnos", (String) map.get("capacityNumber"));
|
|
mesMap.put("areaid", queueInterfaceMapper.getAreaId());
|
|
mesMap.put("areaid", queueInterfaceMapper.getAreaId());
|
|
String url = "https://openapi-test.sinoiov.cn/save/apis/vnoDel";
|
|
String url = "https://openapi-test.sinoiov.cn/save/apis/vnoDel";
|
|
try {
|
|
try {
|
|
DataExchangeService des = new DataExchangeService(5000, 8000);
|
|
DataExchangeService des = new DataExchangeService(5000, 8000);
|
|
String res = des.postHttps(url, mesMap);
|
|
String res = des.postHttps(url, mesMap);
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
- if("1".equals(jsonObject.get("result"))){
|
|
|
|
- System.out.println(map.get("capacityNumber") + "取消订阅成功");
|
|
|
|
|
|
+ if("1016".equals(StringUtils.isEmpty(jsonObject.get("status"))?"":jsonObject.get("status").toString())){
|
|
|
|
+ if (login()==1) {
|
|
|
|
+ return cancelSubsCapacity(map,i+1);
|
|
|
|
+ }else {
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if("1001".equals(StringUtils.isEmpty(jsonObject.get("status"))?"":jsonObject.get("status").toString())){
|
|
|
|
+ if("1".equals(StringUtils.isEmpty(jsonObject.get("result"))?"":jsonObject.get("result").toString())){
|
|
|
|
+ return 1;
|
|
|
|
+ }else {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ return 0;
|
|
}
|
|
}
|
|
}
|
|
}
|