add:第一版测试版本。

This commit is contained in:
2025-12-15 10:42:02 +08:00
parent 98e0bbcaa6
commit cd483c81d1
84 changed files with 3714 additions and 26 deletions

View File

@@ -0,0 +1,26 @@
package org.nl.monitor.map.controller;
import jakarta.annotation.Resource;
import org.nl.monitor.map.service.MapMonitorService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author dsh
* 2025/12/13
*/
@RestController
@RequestMapping("/mapMonitor")
public class MapMonitorController {
@Resource
private MapMonitorService mapMonitorService;
@GetMapping("/queryCurrentMapPoint")
public ResponseEntity<Object> queryCurrentMapPoint() {
return new ResponseEntity<>(mapMonitorService.queryCurrentMapPoint(), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,47 @@
package org.nl.monitor.map.dto;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
/**
* @author dsh
* 2025/12/13
*/
@Data
public class StationInfoDto {
/**
* 点位唯一标识
*/
private String id;
/**
* 点位名称
*/
private String name;
/**
* 点位类型
*/
private String type;
/**
* x坐标
*/
private double x;
/**
* Y坐标
*/
private double y;
/**
* 偏航角
*/
private double yaw;
/**
* 元数据
*/
private JSONObject metadata;
}

View File

@@ -0,0 +1,12 @@
package org.nl.monitor.map.service;
import org.nl.response.WebResponse;
/**
* @author dsh
* 2025/12/13
*/
public interface MapMonitorService {
WebResponse queryCurrentMapPoint();
}

View File

@@ -0,0 +1,53 @@
package org.nl.monitor.map.service.impl;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.nl.api.schedule.map.api.ScheduleMapAPI;
import org.nl.exception.BadRequestException;
import org.nl.monitor.map.dto.StationInfoDto;
import org.nl.monitor.map.service.MapMonitorService;
import org.nl.response.WebResponse;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author dsh
* 2025/12/13
*/
@Slf4j
@Service
public class MapMonitorServiceImpl implements MapMonitorService {
@Resource
private ScheduleMapAPI scheduleMapAPI;
@Override
public WebResponse queryCurrentMapPoint() {
HttpResponse httpResponse = scheduleMapAPI.queryCurrentMapPointInfo();
if (httpResponse == null || !httpResponse.isOk()){
throw new BadRequestException("获取调度当前地图点位信息失败");
}
List<StationInfoDto> result = new ArrayList<>();
JSONArray jsonArray = JSONArray.parseArray(httpResponse.body());
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
StationInfoDto stationInfoDto =new StationInfoDto();
stationInfoDto.setId(jsonObject.getString("id"));
stationInfoDto.setName(String.valueOf(i+1));
stationInfoDto.setType("1");
JSONObject poseJson = jsonObject.getJSONObject("pose");
stationInfoDto.setX(poseJson.getDouble("x"));
stationInfoDto.setY(poseJson.getDouble("y"));
stationInfoDto.setYaw(poseJson.getDouble("yaw"));
JSONObject metaDataJson = jsonObject.getJSONObject("metadata");
stationInfoDto.setMetadata(metaDataJson);
result.add(stationInfoDto);
}
return WebResponse.requestParamOk(result);
}
}