| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public void taskGetCarDeviceId(){ |
| | | Object o = redisTemplate.opsForValue().get("chuzu:token"); |
| | | String access_Token = ""; |
| | | if(null == o){ |
| | | HttpRequest get = HttpUtil.createGet("http://116.169.59.170:9986/MediaAPI/Token?token=shehongchuzu"); |
| | | HttpResponse execute = get.execute(); |
| | | String body = execute.body(); |
| | | Integer expires_in = JSON.parseObject(body).getInteger("Expires_In"); |
| | | access_Token = JSON.parseObject(body).getString("Access_Token"); |
| | | redisTemplate.opsForValue().set("chuzu:token", access_Token, expires_in, TimeUnit.SECONDS); |
| | | } |
| | | //获取车辆数据 |
| | | List<Car> cars = this.list(new QueryWrapper<Car>().eq("enterprise_id", 5)); |
| | | HttpRequest get = HttpUtil.createGet("http://116.169.59.170:9986/MediaAPI/BaseInfo/GetVehicleInfo?accessToken=" + access_Token + "&tenantNo=射洪出租"); |
| | | HttpResponse execute = get.execute(); |
| | | String body = execute.body(); |
| | | JSONObject jsonObject = JSON.parseObject(body); |
| | | Integer resultState = jsonObject.getInteger("ResultState"); |
| | | if(1 == resultState){ |
| | | JSONArray resultData = jsonObject.getJSONArray("ResultData"); |
| | | for (int i = 0; i < resultData.size(); i++) { |
| | | JSONObject jsonObject1 = resultData.getJSONObject(i); |
| | | String vehicleNo = jsonObject1.getString("VehicleNo"); |
| | | String Deviceid = jsonObject1.getString("Deviceid"); |
| | | cars.stream().filter(s->s.getVehicleNumber().equals(vehicleNo)).findFirst().ifPresent(car -> { |
| | | car.setDeviceId(Deviceid); |
| | | this.updateById(car); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |