diff --git a/README.md b/README.md index 66c53ee..7203266 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ CN_Tool 是一个基于 Spring Boot 的多模块后端聚合工程,当前仓 - `entrance` - `system` - `systemmonitor` +- `system-ops` - `user` - `detection` - `tools` @@ -23,6 +24,11 @@ CN_Tool 是一个基于 Spring Boot 的多模块后端聚合工程,当前仓 - `disk-monitor` +其中 `system-ops` 当前包含: + +- `dbms` +- `deploy` + 其中 `tools` 当前包含: - `activate-tool` @@ -37,7 +43,7 @@ CN_Tool 是一个基于 Spring Boot 的多模块后端聚合工程,当前仓 - `entrance/src/main/java/com/njcn/gather/EntranceApplication.java` -`entrance` 模块聚合了 `system`、`disk-monitor`、`user`、`detection`、`activate-tool`、`add-data`、`add-ledger`、`wave-tool`、`mms-mapping`,是当前运行时主入口。 +`entrance` 模块聚合了 `system`、`disk-monitor`、`dbms`、`deploy`、`user`、`detection`、`activate-tool`、`add-data`、`add-ledger`、`wave-tool`、`mms-mapping`,是当前运行时主入口。 ## 技术基线 @@ -80,6 +86,10 @@ P0 已补齐基线文档,建议按以下顺序阅读: - 负责字典、日志、系统配置、注册资源相关能力 - `systemmonitor/disk-monitor` - 负责磁盘监控相关能力的独立扩展实现 +- `system-ops/dbms` + - 负责系统运维下数据库监控基础入口 +- `system-ops/deploy` + - 负责系统运维下系统部署基础入口 - `detection` - 当前以通信基础设施为主,包含 WebSocket / Netty 相关组件 - `tools/activate-tool` diff --git a/entrance/pom.xml b/entrance/pom.xml index 16f8932..94f3867 100644 --- a/entrance/pom.xml +++ b/entrance/pom.xml @@ -21,6 +21,16 @@ disk-monitor 1.0.0 + + com.njcn.gather + dbms + 1.0.0 + + + com.njcn.gather + deploy + 1.0.0 + com.njcn.gather detection diff --git a/pom.xml b/pom.xml index 85cf6bb..3da870e 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ entrance system systemmonitor + system-ops user detection tools diff --git a/steady/steady-DataView/src/main/java/com/njcn/gather/steady/datavie/component/SteadyTrendIndicatorCatalog.java b/steady/steady-DataView/src/main/java/com/njcn/gather/steady/datavie/component/SteadyTrendIndicatorCatalog.java index 69d1ded..94a6515 100644 --- a/steady/steady-DataView/src/main/java/com/njcn/gather/steady/datavie/component/SteadyTrendIndicatorCatalog.java +++ b/steady/steady-DataView/src/main/java/com/njcn/gather/steady/datavie/component/SteadyTrendIndicatorCatalog.java @@ -29,7 +29,7 @@ public class SteadyTrendIndicatorCatalog { List result = new ArrayList(); result.add(indicator("V_RMS", "相电压有效值", "VOLTAGE", "电压趋势", "data_v", ABC_PHASES, fields(field("rms", "相电压有效值")), FULL_STATS, "V")); - result.add(indicator("V_LINE_RMS", "线电压有效值", "VOLTAGE", "电压趋势", "data_v", T_PHASE, + result.add(indicator("V_LINE_RMS", "线电压有效值", "VOLTAGE", "电压趋势", "data_v", ABC_PHASES, fields(field("rms_lvr", "线电压有效值")), FULL_STATS, "V")); result.add(indicator("FREQ", "频率", "FREQUENCY", "频率趋势", "data_v", T_PHASE, diff --git a/steady/steady-DataView/src/main/java/com/njcn/gather/steady/datavie/service/impl/SteadyDataViewTrendServiceImpl.java b/steady/steady-DataView/src/main/java/com/njcn/gather/steady/datavie/service/impl/SteadyDataViewTrendServiceImpl.java index 7ec8299..be9031b 100644 --- a/steady/steady-DataView/src/main/java/com/njcn/gather/steady/datavie/service/impl/SteadyDataViewTrendServiceImpl.java +++ b/steady/steady-DataView/src/main/java/com/njcn/gather/steady/datavie/service/impl/SteadyDataViewTrendServiceImpl.java @@ -33,6 +33,7 @@ import java.util.Map; public class SteadyDataViewTrendServiceImpl implements SteadyDataViewTrendService { private static final String EMPTY_TEXT = "-"; + private static final String LINE_VOLTAGE_RMS_INDICATOR = "V_LINE_RMS"; private final SteadyTrendFieldResolver fieldResolver; private final SteadyInfluxQueryComponent influxQueryComponent; @@ -91,13 +92,29 @@ public class SteadyDataViewTrendServiceImpl implements SteadyDataViewTrendServic series.setIndicatorCode(field.getIndicatorCode()); series.setIndicatorName(field.getIndicatorName()); series.setSeriesName(field.getSeriesName()); - series.setPhase(field.getPhase()); + series.setPhase(resolveDisplayPhase(field)); series.setStatType(field.getStatType()); series.setUnit(field.getUnit()); series.setPoints(points); return series; } + private String resolveDisplayPhase(SteadyTrendResolvedFieldBO field) { + if (!LINE_VOLTAGE_RMS_INDICATOR.equals(field.getIndicatorCode())) { + return field.getPhase(); + } + if ("A".equals(field.getPhase())) { + return "AB"; + } + if ("B".equals(field.getPhase())) { + return "BC"; + } + if ("C".equals(field.getPhase())) { + return "CA"; + } + return field.getPhase(); + } + private void enrichLineNames(List fields) { List lineIds = new ArrayList(); for (SteadyTrendResolvedFieldBO field : fields) { diff --git a/steady/steady-DataView/src/test/java/com/njcn/gather/steady/datavie/component/SteadyTrendFieldResolverTest.java b/steady/steady-DataView/src/test/java/com/njcn/gather/steady/datavie/component/SteadyTrendFieldResolverTest.java index adbcf84..642e919 100644 --- a/steady/steady-DataView/src/test/java/com/njcn/gather/steady/datavie/component/SteadyTrendFieldResolverTest.java +++ b/steady/steady-DataView/src/test/java/com/njcn/gather/steady/datavie/component/SteadyTrendFieldResolverTest.java @@ -54,7 +54,7 @@ class SteadyTrendFieldResolverTest { } @Test - void shouldExpandTotalPhaseIndicatorWithoutRequestPhaseFilter() { + void shouldExpandLineVoltageIndicatorWithQueryPhases() { SteadyTrendQueryParam param = new SteadyTrendQueryParam(); param.setLineIds(Arrays.asList("line-001")); param.setIndicatorCodes(Arrays.asList("V_LINE_RMS")); @@ -63,9 +63,9 @@ class SteadyTrendFieldResolverTest { param.setTimeEnd("2026-05-01 01:00:00"); List fields = resolver.resolveFields(param); + List phases = fields.stream().map(SteadyTrendResolvedFieldBO::getPhase).collect(Collectors.toList()); - Assertions.assertEquals(1, fields.size()); - Assertions.assertEquals("T", fields.get(0).getPhase()); + Assertions.assertEquals(Arrays.asList("A", "B", "C"), phases); Assertions.assertEquals("rms_lvr", fields.get(0).getField()); } diff --git a/steady/steady-DataView/src/test/java/com/njcn/gather/steady/datavie/service/impl/SteadyDataViewTrendServiceImplTest.java b/steady/steady-DataView/src/test/java/com/njcn/gather/steady/datavie/service/impl/SteadyDataViewTrendServiceImplTest.java new file mode 100644 index 0000000..859a236 --- /dev/null +++ b/steady/steady-DataView/src/test/java/com/njcn/gather/steady/datavie/service/impl/SteadyDataViewTrendServiceImplTest.java @@ -0,0 +1,54 @@ +package com.njcn.gather.steady.datavie.service.impl; + +import com.njcn.gather.steady.datavie.component.SteadyInfluxQueryComponent; +import com.njcn.gather.steady.datavie.component.SteadyTrendFieldResolver; +import com.njcn.gather.steady.datavie.component.SteadyTrendIndicatorCatalog; +import com.njcn.gather.steady.datavie.pojo.bo.SteadyTrendResolvedFieldBO; +import com.njcn.gather.steady.datavie.pojo.param.SteadyTrendQueryParam; +import com.njcn.gather.steady.datavie.pojo.vo.SteadyTrendQueryVO; +import com.njcn.gather.tool.addledger.service.AddLedgerService; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** + * 稳态趋势查询服务测试。 + */ +class SteadyDataViewTrendServiceImplTest { + + @Test + void shouldDisplayLineVoltagePhasesAsLinePairs() { + SteadyInfluxQueryComponent influxQueryComponent = mock(SteadyInfluxQueryComponent.class); + AddLedgerService addLedgerService = mock(AddLedgerService.class); + SteadyDataViewTrendServiceImpl service = new SteadyDataViewTrendServiceImpl( + new SteadyTrendFieldResolver(new SteadyTrendIndicatorCatalog()), influxQueryComponent, addLedgerService); + when(addLedgerService.listLinePathByLineIds(eq(Collections.singletonList("line-001")))) + .thenReturn(Collections.emptyMap()); + when(influxQueryComponent.queryTrendPoints(any(SteadyTrendResolvedFieldBO.class), + any(LocalDateTime.class), any(LocalDateTime.class), eq(0))).thenReturn(Collections.emptyList()); + SteadyTrendQueryParam param = new SteadyTrendQueryParam(); + param.setLineIds(Collections.singletonList("line-001")); + param.setIndicatorCodes(Collections.singletonList("V_LINE_RMS")); + param.setStatTypes(Collections.singletonList("AVG")); + param.setTimeStart("2026-05-01 00:00:00"); + param.setTimeEnd("2026-05-01 01:00:00"); + param.setQualityFlag(0); + + SteadyTrendQueryVO result = service.queryTrend(param); + List phases = result.getSeries().stream() + .map(series -> series.getPhase()) + .collect(Collectors.toList()); + + Assertions.assertEquals(Arrays.asList("AB", "BC", "CA"), phases); + } +} diff --git a/system-ops/README.md b/system-ops/README.md new file mode 100644 index 0000000..ad88294 --- /dev/null +++ b/system-ops/README.md @@ -0,0 +1,34 @@ +# system-ops 模块说明 + +## 模块定位 + +`system-ops` 是根工程下的系统运维聚合模块,当前按菜单职责拆分为数据库监控和系统部署两个子模块。 + +当前包含: + +- `dbms`:数据库监控基础入口 +- `deploy`:系统部署基础入口 +- 系统运维菜单初始化 SQL + +## 当前结构 + +```text +system-ops/ +├── pom.xml +├── README.md +├── dbms/ +└── deploy/ +``` + +## 当前接口 + +- `GET /database/overview` + - 查询数据库监控基础信息。 +- `GET /deploy/overview` + - 查询系统部署基础信息。 + +## 当前限制 + +- 当前只完成后端基础入口,不包含真实数据库探测逻辑。 +- 当前只完成后端基础入口,不包含真实系统部署执行逻辑。 +- SQL 脚本不自动执行,需要按部署流程手动执行或纳入目标环境初始化流程。 diff --git a/system-ops/dbms/README.md b/system-ops/dbms/README.md new file mode 100644 index 0000000..6f63251 --- /dev/null +++ b/system-ops/dbms/README.md @@ -0,0 +1,14 @@ +# dbms 模块说明 + +## 模块定位 + +`dbms` 是 `system-ops` 下的数据库监控模块,当前先提供数据库监控菜单对应的后端基础入口。 + +## 当前接口 + +- `GET /database/overview` + - 查询数据库监控基础信息。 + +## 当前限制 + +- 当前只完成后端基础入口,不包含真实数据库连接状态、容量或性能指标探测逻辑。 diff --git a/system-ops/dbms/pom.xml b/system-ops/dbms/pom.xml new file mode 100644 index 0000000..79df890 --- /dev/null +++ b/system-ops/dbms/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + + com.njcn.gather + system-ops + 1.0.0 + + + dbms + jar + dbms + + + + com.njcn + njcn-common + 0.0.1 + + + + com.njcn + spingboot2.3.12 + 2.3.12 + + + diff --git a/system-ops/dbms/src/main/java/com/njcn/gather/systemops/database/controller/DatabaseController.java b/system-ops/dbms/src/main/java/com/njcn/gather/systemops/database/controller/DatabaseController.java new file mode 100644 index 0000000..6012548 --- /dev/null +++ b/system-ops/dbms/src/main/java/com/njcn/gather/systemops/database/controller/DatabaseController.java @@ -0,0 +1,41 @@ +package com.njcn.gather.systemops.database.controller; + +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.LogUtil; +import com.njcn.gather.systemops.database.pojo.vo.DatabaseOverviewVO; +import com.njcn.gather.systemops.database.service.DatabaseService; +import com.njcn.web.controller.BaseController; +import com.njcn.web.utils.HttpResultUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 数据库监控基础接口。 + */ +@Slf4j +@Api(tags = "数据库监控") +@RestController +@RequestMapping("/database") +@RequiredArgsConstructor +public class DatabaseController extends BaseController { + + private final DatabaseService databaseService; + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @ApiOperation("查询数据库监控基础信息") + @GetMapping("/overview") + public HttpResult overview() { + String methodDescribe = getMethodDescribe("overview"); + LogUtil.njcnDebug(log, "{},开始查询数据库监控基础信息", methodDescribe); + DatabaseOverviewVO result = databaseService.overview(); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } +} diff --git a/system-ops/dbms/src/main/java/com/njcn/gather/systemops/database/pojo/vo/DatabaseOverviewVO.java b/system-ops/dbms/src/main/java/com/njcn/gather/systemops/database/pojo/vo/DatabaseOverviewVO.java new file mode 100644 index 0000000..6e5106e --- /dev/null +++ b/system-ops/dbms/src/main/java/com/njcn/gather/systemops/database/pojo/vo/DatabaseOverviewVO.java @@ -0,0 +1,38 @@ +package com.njcn.gather.systemops.database.pojo.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 数据库监控基础信息。 + */ +@Data +public class DatabaseOverviewVO implements Serializable { + private static final long serialVersionUID = -6645576505607222597L; + + /** + * 菜单名称。 + */ + private String menuName; + + /** + * 菜单编码。 + */ + private String menuCode; + + /** + * 菜单路径。 + */ + private String path; + + /** + * 基础功能状态。 + */ + private String status; + + /** + * 功能说明。 + */ + private String description; +} diff --git a/system-ops/dbms/src/main/java/com/njcn/gather/systemops/database/service/DatabaseService.java b/system-ops/dbms/src/main/java/com/njcn/gather/systemops/database/service/DatabaseService.java new file mode 100644 index 0000000..76a49dd --- /dev/null +++ b/system-ops/dbms/src/main/java/com/njcn/gather/systemops/database/service/DatabaseService.java @@ -0,0 +1,16 @@ +package com.njcn.gather.systemops.database.service; + +import com.njcn.gather.systemops.database.pojo.vo.DatabaseOverviewVO; + +/** + * 数据库监控基础服务。 + */ +public interface DatabaseService { + + /** + * 查询数据库监控基础信息。 + * + * @return 数据库监控基础信息 + */ + DatabaseOverviewVO overview(); +} diff --git a/system-ops/dbms/src/main/java/com/njcn/gather/systemops/database/service/impl/DatabaseServiceImpl.java b/system-ops/dbms/src/main/java/com/njcn/gather/systemops/database/service/impl/DatabaseServiceImpl.java new file mode 100644 index 0000000..4cfcbb6 --- /dev/null +++ b/system-ops/dbms/src/main/java/com/njcn/gather/systemops/database/service/impl/DatabaseServiceImpl.java @@ -0,0 +1,25 @@ +package com.njcn.gather.systemops.database.service.impl; + +import com.njcn.gather.systemops.database.pojo.vo.DatabaseOverviewVO; +import com.njcn.gather.systemops.database.service.DatabaseService; +import org.springframework.stereotype.Service; + +/** + * 数据库监控基础服务实现。 + */ +@Service +public class DatabaseServiceImpl implements DatabaseService { + + private static final String STATUS_READY = "READY"; + + @Override + public DatabaseOverviewVO overview() { + DatabaseOverviewVO result = new DatabaseOverviewVO(); + result.setMenuName("数据库监控"); + result.setMenuCode("database"); + result.setPath("/systemOps/database"); + result.setStatus(STATUS_READY); + result.setDescription("数据库监控基础入口已接入,后续可在此扩展连接状态、容量和性能指标。"); + return result; + } +} diff --git a/system-ops/deploy/README.md b/system-ops/deploy/README.md new file mode 100644 index 0000000..0cdd12b --- /dev/null +++ b/system-ops/deploy/README.md @@ -0,0 +1,14 @@ +# deploy 模块说明 + +## 模块定位 + +`deploy` 是 `system-ops` 下的系统部署模块,当前先提供系统部署菜单对应的后端基础入口。 + +## 当前接口 + +- `GET /deploy/overview` + - 查询系统部署基础信息。 + +## 当前限制 + +- 当前只完成后端基础入口,不包含真实部署包、环境、执行记录或部署执行逻辑。 diff --git a/system-ops/deploy/pom.xml b/system-ops/deploy/pom.xml new file mode 100644 index 0000000..2a17c47 --- /dev/null +++ b/system-ops/deploy/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + + com.njcn.gather + system-ops + 1.0.0 + + + deploy + jar + deploy + + + + com.njcn + njcn-common + 0.0.1 + + + + com.njcn + spingboot2.3.12 + 2.3.12 + + + diff --git a/system-ops/deploy/src/main/java/com/njcn/gather/systemops/deploy/controller/DeployController.java b/system-ops/deploy/src/main/java/com/njcn/gather/systemops/deploy/controller/DeployController.java new file mode 100644 index 0000000..e4cb1d2 --- /dev/null +++ b/system-ops/deploy/src/main/java/com/njcn/gather/systemops/deploy/controller/DeployController.java @@ -0,0 +1,41 @@ +package com.njcn.gather.systemops.deploy.controller; + +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.LogUtil; +import com.njcn.gather.systemops.deploy.pojo.vo.DeployOverviewVO; +import com.njcn.gather.systemops.deploy.service.DeployService; +import com.njcn.web.controller.BaseController; +import com.njcn.web.utils.HttpResultUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 系统部署基础接口。 + */ +@Slf4j +@Api(tags = "系统部署") +@RestController +@RequestMapping("/deploy") +@RequiredArgsConstructor +public class DeployController extends BaseController { + + private final DeployService deployService; + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @ApiOperation("查询系统部署基础信息") + @GetMapping("/overview") + public HttpResult overview() { + String methodDescribe = getMethodDescribe("overview"); + LogUtil.njcnDebug(log, "{},开始查询系统部署基础信息", methodDescribe); + DeployOverviewVO result = deployService.overview(); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } +} diff --git a/system-ops/deploy/src/main/java/com/njcn/gather/systemops/deploy/pojo/vo/DeployOverviewVO.java b/system-ops/deploy/src/main/java/com/njcn/gather/systemops/deploy/pojo/vo/DeployOverviewVO.java new file mode 100644 index 0000000..60e6078 --- /dev/null +++ b/system-ops/deploy/src/main/java/com/njcn/gather/systemops/deploy/pojo/vo/DeployOverviewVO.java @@ -0,0 +1,38 @@ +package com.njcn.gather.systemops.deploy.pojo.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 系统部署基础信息。 + */ +@Data +public class DeployOverviewVO implements Serializable { + private static final long serialVersionUID = 5544653311667074541L; + + /** + * 菜单名称。 + */ + private String menuName; + + /** + * 菜单编码。 + */ + private String menuCode; + + /** + * 菜单路径。 + */ + private String path; + + /** + * 基础功能状态。 + */ + private String status; + + /** + * 功能说明。 + */ + private String description; +} diff --git a/system-ops/deploy/src/main/java/com/njcn/gather/systemops/deploy/service/DeployService.java b/system-ops/deploy/src/main/java/com/njcn/gather/systemops/deploy/service/DeployService.java new file mode 100644 index 0000000..b5362d9 --- /dev/null +++ b/system-ops/deploy/src/main/java/com/njcn/gather/systemops/deploy/service/DeployService.java @@ -0,0 +1,16 @@ +package com.njcn.gather.systemops.deploy.service; + +import com.njcn.gather.systemops.deploy.pojo.vo.DeployOverviewVO; + +/** + * 系统部署基础服务。 + */ +public interface DeployService { + + /** + * 查询系统部署基础信息。 + * + * @return 系统部署基础信息 + */ + DeployOverviewVO overview(); +} diff --git a/system-ops/deploy/src/main/java/com/njcn/gather/systemops/deploy/service/impl/DeployServiceImpl.java b/system-ops/deploy/src/main/java/com/njcn/gather/systemops/deploy/service/impl/DeployServiceImpl.java new file mode 100644 index 0000000..7b113c8 --- /dev/null +++ b/system-ops/deploy/src/main/java/com/njcn/gather/systemops/deploy/service/impl/DeployServiceImpl.java @@ -0,0 +1,25 @@ +package com.njcn.gather.systemops.deploy.service.impl; + +import com.njcn.gather.systemops.deploy.pojo.vo.DeployOverviewVO; +import com.njcn.gather.systemops.deploy.service.DeployService; +import org.springframework.stereotype.Service; + +/** + * 系统部署基础服务实现。 + */ +@Service +public class DeployServiceImpl implements DeployService { + + private static final String STATUS_READY = "READY"; + + @Override + public DeployOverviewVO overview() { + DeployOverviewVO result = new DeployOverviewVO(); + result.setMenuName("系统部署"); + result.setMenuCode("deploy"); + result.setPath("/systemOps/deploy"); + result.setStatus(STATUS_READY); + result.setDescription("系统部署基础入口已接入,后续可在此扩展部署包、环境和执行记录。"); + return result; + } +} diff --git a/system-ops/pom.xml b/system-ops/pom.xml new file mode 100644 index 0000000..78e13e5 --- /dev/null +++ b/system-ops/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + + com.njcn.gather + CN_Tool + 1.0.0 + + + system-ops + pom + system-ops + + + dbms + deploy + +