opt:1.增加操作台功能。2.调整数据刷新时间。
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package org.nl.monitor.optionManager.controller;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.logging.annotation.Log;
|
||||
import org.nl.monitor.optionManager.service.OptionManagerService;
|
||||
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
|
||||
* 2026/3/18
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/optionManager")
|
||||
@Slf4j
|
||||
public class OptionManagerController {
|
||||
|
||||
@Resource
|
||||
private OptionManagerService optionManagerService;
|
||||
|
||||
@GetMapping("/queryAllStationWithTaskStatus")
|
||||
@Log("查询所有站点任务状态")
|
||||
public ResponseEntity<Object> queryAllStationWithTaskStatus() {
|
||||
return new ResponseEntity<>(optionManagerService.queryAllStationWithTaskStatus(), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.monitor.optionManager.service;
|
||||
|
||||
import org.nl.response.WebResponse;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2026/3/18
|
||||
*/
|
||||
public interface OptionManagerService {
|
||||
|
||||
/**
|
||||
* 查询所有站点及其任务状态(前端房间列表展示用)
|
||||
* @return List,每项包含站点信息 + 当前任务状态
|
||||
*/
|
||||
WebResponse queryAllStationWithTaskStatus();
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.nl.monitor.optionManager.service.impl;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.api.map.api.MapAPI;
|
||||
import org.nl.api.task.api.TaskAPI;
|
||||
import org.nl.monitor.optionManager.service.OptionManagerService;
|
||||
import org.nl.response.WebResponse;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dsh
|
||||
* 2026/3/18
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class OptionManagerServiceImpl implements OptionManagerService {
|
||||
|
||||
@Resource
|
||||
private MapAPI mapAPI;
|
||||
|
||||
@Resource
|
||||
private TaskAPI taskAPI;
|
||||
|
||||
@Override
|
||||
public WebResponse queryAllStationWithTaskStatus() {
|
||||
// 获取所有站点
|
||||
List<Map<String, Object>> stationList = mapAPI.getAllStationList();
|
||||
// 获取所有有任务的房间状态 Map: stationCode -> taskInfo
|
||||
WebResponse roomStatusResponse = taskAPI.queryAllRoomStatus();
|
||||
Map<String, Object> roomStatusMap = new HashMap<>();
|
||||
if (roomStatusResponse != null && roomStatusResponse.getData() instanceof Map) {
|
||||
roomStatusMap = (Map<String, Object>) roomStatusResponse.getData();
|
||||
}
|
||||
// 合并:每个站点附加任务状态
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
for (Map<String, Object> station : stationList) {
|
||||
Map<String, Object> item = new HashMap<>(station);
|
||||
String stationCode = String.valueOf(station.get("station_code"));
|
||||
Object taskInfo = roomStatusMap.get(stationCode);
|
||||
// hasTask: 该站点是否有未完成任务
|
||||
item.put("hasTask", taskInfo != null);
|
||||
// taskInfo: 任务详情,无任务时为 null
|
||||
item.put("taskInfo", taskInfo);
|
||||
result.add(item);
|
||||
}
|
||||
return WebResponse.requestParamOk(result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user