|
@@ -1,129 +0,0 @@
|
|
|
-package cn.iocoder.yudao.module.pms.job;
|
|
|
|
|
-
|
|
|
|
|
-import cn.hutool.json.JSONObject;
|
|
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportRespVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport.vo.IotRhDailyReportSaveReqVO;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.dal.mysql.IotDeviceMapper;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.dal.mysql.TDDeviceMapper;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapper;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.service.iotprojectinfo.IotProjectInfoService;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.service.iotprojecttask.IotProjectTaskService;
|
|
|
|
|
-import cn.iocoder.yudao.module.pms.service.iotrhdailyreport.IotRhDailyReportService;
|
|
|
|
|
-import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
|
|
-import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
|
-import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
-import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
-import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
-import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
-import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
-import org.springframework.util.MultiValueMap;
|
|
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
|
-import org.springframework.web.client.RestTemplate;
|
|
|
|
|
-
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
|
-import javax.validation.Valid;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
-
|
|
|
|
|
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
-
|
|
|
|
|
-@Tag(name = "中航北斗")
|
|
|
|
|
-@RestController
|
|
|
|
|
-@RequestMapping("/pms/iot-zhbd")
|
|
|
|
|
-@Validated
|
|
|
|
|
-public class IotZHBDController {
|
|
|
|
|
-
|
|
|
|
|
- @Resource
|
|
|
|
|
- private IotRhDailyReportService iotRhDailyReportService;
|
|
|
|
|
- @Resource
|
|
|
|
|
- private DeptService deptService;
|
|
|
|
|
- @Resource
|
|
|
|
|
- private IotProjectInfoService iotProjectInfoService;
|
|
|
|
|
- @Resource
|
|
|
|
|
- private IotProjectTaskService iotProjectTaskService;
|
|
|
|
|
- @Resource
|
|
|
|
|
- private DictDataService dictDataService;
|
|
|
|
|
-
|
|
|
|
|
- private static final String ID = "NjI1LjUyNS42ODg";
|
|
|
|
|
- private static final String SECRET = "3897865b70d7bf29fcca5029147f7d0a";
|
|
|
|
|
- private static final String TOKEN_URL = "https://zhbdgps.cn/video/webapi/user/login";
|
|
|
|
|
- private static final String LOCATION_URL="https://zhbdgps.cn/video/webapi/report/fuel/daily/detail";
|
|
|
|
|
- private static final String parameter = "lng,lat,today_distance,distance,todayoil,totaloil,online,oil1,oil2,oil3,oil4,vehicle_name";
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private StringRedisTemplate redisTemplate;
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private RestTemplate restTemplate;
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private IotOpeationFillMapper zhbdmapper;
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private TDDeviceMapper deviceMapper;
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private IotDeviceMapper iotDeviceMapper;
|
|
|
|
|
-
|
|
|
|
|
- @PostMapping("/create")
|
|
|
|
|
- @Operation(summary = "创建瑞恒日报")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('pms:iot-rh-daily-report:create')")
|
|
|
|
|
- public CommonResult<Long> createIotRhDailyReport(@Valid @RequestBody IotRhDailyReportSaveReqVO createReqVO) {
|
|
|
|
|
- return success(iotRhDailyReportService.createIotRhDailyReport(createReqVO));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @PutMapping("/update")
|
|
|
|
|
- @Operation(summary = "更新瑞恒日报")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('pms:iot-rh-daily-report:update')")
|
|
|
|
|
- public CommonResult<Boolean> updateIotRhDailyReport(@Valid @RequestBody IotRhDailyReportSaveReqVO updateReqVO) {
|
|
|
|
|
- iotRhDailyReportService.updateIotRhDailyReport(updateReqVO);
|
|
|
|
|
- return success(true);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @DeleteMapping("/delete")
|
|
|
|
|
- @Operation(summary = "删除瑞恒日报")
|
|
|
|
|
- @Parameter(name = "id", description = "编号", required = true)
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('pms:iot-rh-daily-report:delete')")
|
|
|
|
|
- public CommonResult<Boolean> deleteIotRhDailyReport(@RequestParam("id") Long id) {
|
|
|
|
|
- iotRhDailyReportService.deleteIotRhDailyReport(id);
|
|
|
|
|
- return success(true);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/get")
|
|
|
|
|
- @Operation(summary = "获得车辆油耗")
|
|
|
|
|
- @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('pms:iot-rh-daily-report:query')")
|
|
|
|
|
- public CommonResult<IotRhDailyReportRespVO> getIotRhDailyReport(@RequestParam("id") Long id) {
|
|
|
|
|
- IotRhDailyReportRespVO result = new IotRhDailyReportRespVO();
|
|
|
|
|
-
|
|
|
|
|
- String zhbdtoken = redisTemplate.opsForValue().get("zhbdtoken");
|
|
|
|
|
- if (StringUtils.isBlank(zhbdtoken)) {
|
|
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
|
|
- map.put("id", ID);
|
|
|
|
|
- map.put("secret", SECRET);
|
|
|
|
|
- JSONObject entries = restTemplate.postForObject(TOKEN_URL, map, JSONObject.class);
|
|
|
|
|
- if (Objects.nonNull(entries)&&entries.get("code") != null&&Integer.parseInt(String.valueOf(entries.get("code")))==200) {
|
|
|
|
|
- com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(entries.get("data")));
|
|
|
|
|
- zhbdtoken = jsonObject.get("token").toString();
|
|
|
|
|
- redisTemplate.opsForValue().set("zhbdtoken", zhbdtoken, 80000, TimeUnit.SECONDS);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- // 1. 设置请求头
|
|
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
- headers.add("Authorization", zhbdtoken); // 添加自定义头信息
|
|
|
|
|
- // headers.addHeader("User-Agent", "Apifox/1.0.0 (https://apifox.com)")
|
|
|
|
|
- headers.add("Content-Type", "application/json");
|
|
|
|
|
- headers.add("Accept", "*/*");
|
|
|
|
|
- headers.add("Host", "zhbdgps.cn");
|
|
|
|
|
- headers.add("Connection", "keep-alive");
|
|
|
|
|
- MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
|
|
|
|
- params.add("client_ids", "8203");
|
|
|
|
|
- params.add("vehicle_ids", "8203");
|
|
|
|
|
- return success(result);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|