fix: 修复轨迹查询报错问题。
更换了接口地址和增加请求参数
| | |
| | | } |
| | | |
| | | // 处理开始时间 |
| | | beginTime = beginTime.replace("T", " ").replace(" ","%20"); |
| | | beginTime = beginTime.replace("T", " "); |
| | | if (beginTime.split(":").length == 2) { // 只有小时和分钟 |
| | | beginTime += ":00"; |
| | | } |
| | | |
| | | // 处理结束时间 |
| | | endTime = endTime.replace("T", " ").replace(" ","%20"); |
| | | // endTime = endTime.replace("T", " ").replace(" ","%20"); |
| | | endTime = endTime.replace("T", " "); |
| | | if (endTime.split(":").length == 2) { // 只有小时和分钟 |
| | | endTime += ":59"; |
| | | } |
| | |
| | | * 消息 |
| | | */ |
| | | private String message; |
| | | |
| | | private Integer serverid; |
| | | |
| | | /** |
| | | * Token |
| | |
| | | public void setToken(String token) { |
| | | this.token = token; |
| | | } |
| | | |
| | | |
| | | public void setServerid(Integer serviceid){this.serverid=serviceid;} |
| | | public Integer getServerid(){return this.serverid;} |
| | | } |
| | |
| | | @Excel(name = "最后查询位置时间") |
| | | private Long lastquerypositiontime; |
| | | |
| | | /** 服务器ID */ |
| | | @Excel(name = "服务器ID") |
| | | private Integer serverid; |
| | | |
| | | public void setConfigId(Long configId) { |
| | | this.configId = configId; |
| | | } |
| | |
| | | this.lastquerypositiontime = lastquerypositiontime; |
| | | } |
| | | |
| | | public Integer getServerid() { |
| | | return serverid; |
| | | } |
| | | |
| | | public void setServerid(Integer serverid) { |
| | | this.serverid = serverid; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) |
| | |
| | | .append("token", getToken()) |
| | | .append("tokenExpireTime", getTokenExpireTime()) |
| | | .append("lastquerypositiontime", getLastquerypositiontime()) |
| | | .append("serverid", getServerid()) |
| | | .append("createBy", getCreateBy()) |
| | | .append("createTime", getCreateTime()) |
| | | .append("updateBy", getUpdateBy()) |
| | |
| | | * @param expireTime token过期时间 |
| | | * @return 更新结果 |
| | | */ |
| | | public int updateToken(String configKey, String token, Date expireTime); |
| | | public int updateToken(String configKey, String token,Integer serviceid, Date expireTime); |
| | | } |
| | |
| | | response.setSuccess(true); |
| | | response.setMessage("登录成功"); |
| | | response.setToken(jsonResult.getString("token")); |
| | | response.setServerid(jsonResult.getInteger("serverid")); |
| | | break; |
| | | case -1: |
| | | response.setSuccess(false); |
| | |
| | | if (loginResponse.isSuccess()) { |
| | | //将token写入gspconfig |
| | | token = loginResponse.getToken(); |
| | | Integer serviceid = loginResponse.getServerid(); |
| | | //getTokenExpireTime 这个是没有的 需要自己计算,当前时间+23小时 |
| | | Date expireTime = DateUtils.addHours(new Date(), 23); |
| | | gpsConfigService.updateToken("gps51", token, expireTime); |
| | | gpsConfigService.updateToken("gps51", token,serviceid, expireTime); |
| | | System.out.println("GPS系统登录成功,token已更新"); |
| | | return token; |
| | | } else { |
| | |
| | | |
| | | String username = config.getUsername(); |
| | | // 构建请求URL |
| | | String url = config.getDomain() + "/webapi?action=querymonitorlist&token=" + token; |
| | | String url = config.getDomain() + "/webapi?action=querymonitorlist&token=" + token+"&serverid="+config.getServerid(); |
| | | Map<String, String> params = new HashMap<>(); |
| | | params.put("username", username); |
| | | |
| | |
| | | System.out.println("token获取成功!"+token); |
| | | |
| | | // 构建请求URL |
| | | String url = config.getDomain() + "/webapi?action=lastposition&token="+token; |
| | | String url = config.getDomain() + "/webapi?action=lastposition&token="+token+"&serverid="+config.getServerid(); |
| | | System.out.println("请求URL:"+url); |
| | | |
| | | // 构建请求参数 |
| | |
| | | System.out.println("Token获取成功: " + token); |
| | | |
| | | // 构建请求URL |
| | | String url = config.getDomain() + "/webapi?action=querytracks&token=" + token; |
| | | String url = config.getDomain() + "/webapi?action=querytracks&token=" + token+"&serverid="+config.getServerid(); |
| | | System.out.println("请求URL: " + url); |
| | | |
| | | // 构建请求参数 |
| | |
| | | response.setDeviceid(jsonResult.getString("deviceid")); |
| | | |
| | | if (response.getStatus() == 0) { |
| | | |
| | | if(jsonResult.getJSONObject("result")==null) |
| | | { |
| | | System.err.println("查询轨迹失败,轨迹记录为空"); |
| | | GpsTrackQueryResponse responseErr = new GpsTrackQueryResponse(); |
| | | responseErr.setStatus(-1); |
| | | responseErr.setCause("轨迹记录为空"); |
| | | return responseErr; |
| | | } |
| | | |
| | | // 解析轨迹记录列表 |
| | | JSONArray recordsArray = jsonResult.getJSONArray("records"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public int updateToken(String configKey, String token, Date expireTime) { |
| | | public int updateToken(String configKey, String token,Integer serviceid, Date expireTime) { |
| | | SysGpsConfig config = new SysGpsConfig(); |
| | | config.setConfigKey(configKey); |
| | | config.setToken(token); |
| | | config.setServerid(serviceid); |
| | | config.setTokenExpireTime(expireTime); |
| | | config.setUpdateTime(new Date()); |
| | | |
| | |
| | | <result property="token" column="token" /> |
| | | <result property="tokenExpireTime" column="token_expire_time" /> |
| | | <result property="lastquerypositiontime" column="lastquerypositiontime" /> |
| | | <result property="serverid" column="serverid" /> |
| | | <result property="createBy" column="create_by" /> |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="updateBy" column="update_by" /> |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="selectSysGpsConfigVo"> |
| | | select config_id, config_key, domain, username, password, token, token_expire_time, lastquerypositiontime, create_by, create_time, update_by, update_time, remark |
| | | select config_id, config_key, domain, username, password, token, token_expire_time, lastquerypositiontime, serverid, create_by, create_time, update_by, update_time, remark |
| | | from sys_gps_config |
| | | </sql> |
| | | |
| | |
| | | <if test="token != null">token,</if> |
| | | <if test="tokenExpireTime != null">token_expire_time,</if> |
| | | <if test="lastquerypositiontime != null">lastquerypositiontime,</if> |
| | | <if test="serverid != null">serverid,</if> |
| | | <if test="createBy != null">create_by,</if> |
| | | <if test="createTime != null">create_time,</if> |
| | | <if test="updateBy != null">update_by,</if> |
| | |
| | | <if test="token != null">#{token},</if> |
| | | <if test="tokenExpireTime != null">#{tokenExpireTime},</if> |
| | | <if test="lastquerypositiontime != null">#{lastquerypositiontime},</if> |
| | | <if test="serverid != null">#{serverid},</if> |
| | | <if test="createBy != null">#{createBy},</if> |
| | | <if test="createTime != null">#{createTime},</if> |
| | | <if test="updateBy != null">#{updateBy},</if> |
| | |
| | | <if test="token != null and token != ''">token = #{token},</if> |
| | | <if test="tokenExpireTime != null">token_expire_time = #{tokenExpireTime},</if> |
| | | <if test="lastquerypositiontime != null">lastquerypositiontime = #{lastquerypositiontime},</if> |
| | | <if test="serverid != null and serverid != ''">serverid = #{serverid},</if> |
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| | | update_time = sysdate() |
| | | </set> |