添加统计接口
This commit is contained in:
parent
c3548ea38c
commit
7e9cba4e33
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.ruoyi.device.api;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||||
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.device.api.domain.StatisticsVO;
|
||||||
|
import com.ruoyi.device.api.factory.RemoteStatisticsFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计服务
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-23
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteStatisticsService", value = ServiceNameConstants.DEVICE_SERVICE, fallbackFactory = RemoteStatisticsFallbackFactory.class)
|
||||||
|
public interface RemoteStatisticsService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取系统统计信息
|
||||||
|
*
|
||||||
|
* @param source 请求来源
|
||||||
|
* @return 统计信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
R<StatisticsVO> getStatistics(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.ruoyi.device.api.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计信息VO对象
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class StatisticsVO implements Serializable
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
// ========== 机场统计 ==========
|
||||||
|
/** 机场个数 */
|
||||||
|
private Integer dockCount;
|
||||||
|
|
||||||
|
/** 空闲机场个数 */
|
||||||
|
private Integer idleDockCount;
|
||||||
|
|
||||||
|
/** 任务中机场个数 */
|
||||||
|
private Integer workingDockCount;
|
||||||
|
|
||||||
|
/** 调试机场个数 */
|
||||||
|
private Integer debuggingDockCount;
|
||||||
|
|
||||||
|
/** 离线机场个数 */
|
||||||
|
private Integer offlineDockCount;
|
||||||
|
|
||||||
|
// ========== 无人机统计 ==========
|
||||||
|
/** 无人机个数 */
|
||||||
|
private Integer aircraftCount;
|
||||||
|
|
||||||
|
/** 舱内开机个数 */
|
||||||
|
private Integer powerOnInCabinCount;
|
||||||
|
|
||||||
|
/** 舱内关机个数 */
|
||||||
|
private Integer powerOffInCabinCount;
|
||||||
|
|
||||||
|
/** 任务中个数 */
|
||||||
|
private Integer inMissionCount;
|
||||||
|
|
||||||
|
/** 调试中个数 */
|
||||||
|
private Integer debuggingAircraftCount;
|
||||||
|
|
||||||
|
/** 离线个数 */
|
||||||
|
private Integer offlineAircraftCount;
|
||||||
|
|
||||||
|
// ========== 挂载统计 ==========
|
||||||
|
/** 全部挂载个数 */
|
||||||
|
private Integer payloadCount;
|
||||||
|
|
||||||
|
/** 离线个数 */
|
||||||
|
private Integer offlinePayloadCount;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.ruoyi.device.api.factory;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.device.api.RemoteStatisticsService;
|
||||||
|
import com.ruoyi.device.api.domain.StatisticsVO;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计服务降级处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-23
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemoteStatisticsFallbackFactory implements FallbackFactory<RemoteStatisticsService>
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RemoteStatisticsFallbackFactory.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RemoteStatisticsService create(Throwable throwable)
|
||||||
|
{
|
||||||
|
log.error("统计服务调用失败:{}", throwable.getMessage());
|
||||||
|
return new RemoteStatisticsService()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public R<StatisticsVO> getStatistics(String source)
|
||||||
|
{
|
||||||
|
return R.fail("获取统计信息失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7348cf68f62ef4950740dd3ea8800109016e54b8
|
Subproject commit 8daf7a6d842dad1070246129f0629d7090ab1787
|
||||||
Loading…
Reference in New Issue