代码迁移
This commit is contained in:
parent
3d31f7d089
commit
dcebdcd9f5
|
|
@ -91,4 +91,29 @@ public class HttpStatus
|
|||
* 系统警告消息
|
||||
*/
|
||||
public static final int WARN = 601;
|
||||
|
||||
/**
|
||||
*iot设备登录地址
|
||||
*/
|
||||
public static final String LOGIN_URL = "http://gps51.com/webapi?action=login";
|
||||
|
||||
/**
|
||||
*iot设备定位地址
|
||||
*/
|
||||
public static final String LAST_POSITION_URL = "http://gps51.com/webapi?action=lastposition&token=";
|
||||
|
||||
/**
|
||||
*iot查询行程地址
|
||||
*/
|
||||
public static final String QUERY_TRIPS_URL = "http://gps51.com/webapi?action=querytrips&token=";
|
||||
|
||||
/**
|
||||
*iot查询停留点地址
|
||||
*/
|
||||
public static final String REPORT_PARK_DETAIL_BY_TIME_URL = "http://gps51.com/webapi?action=reportparkdetailbytime&token=";
|
||||
|
||||
/**
|
||||
*iot报警地址
|
||||
*/
|
||||
public static final String REPORT_ALARM_URL = "http://gps51.com/webapi?action=reportalarm&token=";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,4 +92,24 @@ public class UserConstants
|
|||
* 手机1天限制
|
||||
*/
|
||||
public static final String MOBILE_PHONE_1D_LIMIT_DIR = "mobilePhoneDay:";
|
||||
|
||||
/**
|
||||
*登录类型 :"USER","DEVICE"
|
||||
*/
|
||||
public static final String IOT_TYPE = "USER";
|
||||
|
||||
/**
|
||||
*登录来源 :"ANDROID","IPHONE","WEB","WEIXIN"
|
||||
*/
|
||||
public static final String IOT_FROM = "WEB";
|
||||
|
||||
/**
|
||||
*登录名
|
||||
*/
|
||||
public static final String IOT_USERNAME = "omni-demo";
|
||||
|
||||
/**
|
||||
*密码,采用md5加密
|
||||
*/
|
||||
public static final String IOT_PASSWORD = "7d8609761efffc818e5ed11531ea2507";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.bonus.sgzb.common.core.utils;
|
|||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.bonus.sgzb.common.core.constant.HttpStatus;
|
||||
import com.bonus.sgzb.common.core.constant.UserConstants;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
|
|
@ -115,13 +117,13 @@ public class HttpHelper {
|
|||
public static String getIotToken() {
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
String redisCode = null;
|
||||
map.put("type","USER");
|
||||
map.put("from","web");
|
||||
map.put("username","omni-demo");
|
||||
map.put("type", UserConstants.IOT_TYPE);
|
||||
map.put("from",UserConstants.IOT_FROM);
|
||||
map.put("username",UserConstants.IOT_USERNAME);
|
||||
//采用md5加密
|
||||
map.put("password","7d8609761efffc818e5ed11531ea2507");
|
||||
map.put("password",UserConstants.IOT_PASSWORD);
|
||||
String param = JSON.toJSONString(map);
|
||||
String resultUser = HttpHelper.doPost("http://gps51.com/webapi?action=login",param);
|
||||
String resultUser = HttpHelper.doPost(HttpStatus.LOGIN_URL,param);
|
||||
if (resultUser == null){
|
||||
throw new RuntimeException("返回数据为空!!");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.sgzb.material.service.impl;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.bonus.sgzb.common.core.constant.HttpStatus;
|
||||
import com.bonus.sgzb.common.core.constant.TokenConstants;
|
||||
import com.bonus.sgzb.common.core.utils.HttpHelper;
|
||||
import com.bonus.sgzb.common.core.utils.StringHelper;
|
||||
|
|
@ -301,7 +302,7 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
list.add(iotDto.getIotId().toString());
|
||||
map.put("deviceids",list);
|
||||
String param = JSON.toJSONString(map);
|
||||
String res = HttpHelper.doPost("http://gps51.com/webapi?action=lastposition&token="+redisCode,param);
|
||||
String res = HttpHelper.doPost(HttpStatus.LAST_POSITION_URL+redisCode,param);
|
||||
//对返回的结果进行解析
|
||||
IotLocationVo iotLocationVo = resultDataHandler(res);
|
||||
log.info("resultDataHandler:{}", iotLocationVo);
|
||||
|
|
@ -332,7 +333,7 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
map.put("begintime",iotLocationVo.getBeginTime());
|
||||
map.put("endtime",iotLocationVo.getEndTime());
|
||||
String param = JSON.toJSONString(map);
|
||||
String res = HttpHelper.doPost("http://gps51.com/webapi?action=querytrips&token="+redisCode,param);
|
||||
String res = HttpHelper.doPost(HttpStatus.QUERY_TRIPS_URL+redisCode,param);
|
||||
return AjaxResult.success(res);
|
||||
}
|
||||
|
||||
|
|
@ -361,7 +362,7 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
map.put("begintime",iotLocationVo.getBeginTime());
|
||||
map.put("endtime",iotLocationVo.getEndTime());
|
||||
String param = JSON.toJSONString(map);
|
||||
String res = HttpHelper.doPost("http://gps51.com/webapi?action=reportparkdetailbytime&token="+redisCode,param);
|
||||
String res = HttpHelper.doPost(HttpStatus.REPORT_PARK_DETAIL_BY_TIME_URL+redisCode,param);
|
||||
//对返回的结果进行解析
|
||||
List<IotLocationVo> iotLocationVoList = resultReportParkDetailByTime(res);
|
||||
log.info("resultDataHandler:{}", iotLocationVo);
|
||||
|
|
@ -468,7 +469,7 @@ public class IotMachineServiceImpl implements IotMachineService {
|
|||
//报警类型
|
||||
map.put("needalarm","");
|
||||
String param = JSON.toJSONString(map);
|
||||
String res = HttpHelper.doPost("http://gps51.com/webapi?action=reportalarm&token="+redisCode,param);
|
||||
String res = HttpHelper.doPost(HttpStatus.REPORT_ALARM_URL+redisCode,param);
|
||||
//对返回的结果进行解析
|
||||
List<IotLocationVo> iotLocationVoList = resultReportAlarm(res);
|
||||
log.info("resultDataHandler:{}", iotLocationVo);
|
||||
|
|
|
|||
Loading…
Reference in New Issue