From dcebdcd9f512e111ff8f9cb22056a01f0652dea7 Mon Sep 17 00:00:00 2001 From: 15856 <15856818120@163.com> Date: Thu, 8 Aug 2024 15:43:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgzb/common/core/constant/HttpStatus.java | 25 +++++++++++++++++++ .../common/core/constant/UserConstants.java | 20 +++++++++++++++ .../sgzb/common/core/utils/HttpHelper.java | 12 +++++---- .../service/impl/IotMachineServiceImpl.java | 9 ++++--- 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/constant/HttpStatus.java b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/constant/HttpStatus.java index d8b2a12..2665356 100644 --- a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/constant/HttpStatus.java +++ b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/constant/HttpStatus.java @@ -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="; } diff --git a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/constant/UserConstants.java b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/constant/UserConstants.java index 1efbd51..e302651 100644 --- a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/constant/UserConstants.java +++ b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/constant/UserConstants.java @@ -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"; } diff --git a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java index 56f1600..33014a8 100644 --- a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java +++ b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/HttpHelper.java @@ -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 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("返回数据为空!!"); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java index 4dc783e..563bab1 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java @@ -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 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 iotLocationVoList = resultReportAlarm(res); log.info("resultDataHandler:{}", iotLocationVo);