diff options
| author | shizhendong <[email protected]> | 2023-08-01 17:05:14 +0800 |
|---|---|---|
| committer | shizhendong <[email protected]> | 2023-08-01 17:05:14 +0800 |
| commit | b1d5fd039bdc8adb9f9ecdef2c8f433ab2c24339 (patch) | |
| tree | b525f8aaf5a0959576f1fa51f9baac2c63e99392 | |
| parent | cfd464e573364a63486133b9fe45aa193c819803 (diff) | |
feat: NEZ-3013 新增 Module 配置同步更新接口rel-23.07.01
3 files changed, 55 insertions, 0 deletions
diff --git a/nz-admin/src/main/java/com/nis/modules/module/controller/MonitorModuleController.java b/nz-admin/src/main/java/com/nis/modules/module/controller/MonitorModuleController.java index 796f77f6..b5cca5b0 100644 --- a/nz-admin/src/main/java/com/nis/modules/module/controller/MonitorModuleController.java +++ b/nz-admin/src/main/java/com/nis/modules/module/controller/MonitorModuleController.java @@ -167,5 +167,26 @@ public class MonitorModuleController { return R.ok(); } + /** + * Module 配置同步更新 dashboard,endpoint + * + * @return + */ + @RequestMapping(value = "/module/sync", method = {RequestMethod.POST, RequestMethod.PUT}) + @SysLog(operation = OperationEnum.UPDATE, type = TypeEnum.MODULE) + public R syncModuleEndpointAndDashboard(@RequestBody(required = false) Map<String, Object> requestParam) { + // validate param + requestParam = Tool.MapUtil.defaultIfEmpty(requestParam, Tool.MapUtil.empty()); + + List<Integer> syncModuleIdList = (List<Integer>) requestParam.get("ids"); + ValidateUtils.is(syncModuleIdList).notNull(RCode.MODULE_ID_ISNULL); + + Integer isSyncEndpoint = Tool.MapUtil.getInt(requestParam, "endpoint", 0); + Integer isSyncDashboard = Tool.MapUtil.getInt(requestParam, "dashboard", 0); + + monitorModuleService.syncModuleEndpointAndDashboard(syncModuleIdList, isSyncEndpoint, isSyncDashboard); + return R.ok(); + } + } diff --git a/nz-admin/src/main/java/com/nis/modules/module/service/MonitorModuleService.java b/nz-admin/src/main/java/com/nis/modules/module/service/MonitorModuleService.java index d469d452..d1267389 100644 --- a/nz-admin/src/main/java/com/nis/modules/module/service/MonitorModuleService.java +++ b/nz-admin/src/main/java/com/nis/modules/module/service/MonitorModuleService.java @@ -48,4 +48,13 @@ public interface MonitorModuleService extends IService<MonitorModule> { String queryAssetMoudules(Integer assetId); + /** + * sync Module Endpoint And Dashboard + * + * @param syncModuleIdList + * @param isSyncEndpoint + * @param isSyncDashboard + */ + void syncModuleEndpointAndDashboard(List<Integer> syncModuleIdList, Integer isSyncEndpoint, Integer isSyncDashboard); + } diff --git a/nz-admin/src/main/java/com/nis/modules/module/service/impl/MonitorModuleServiceImpl.java b/nz-admin/src/main/java/com/nis/modules/module/service/impl/MonitorModuleServiceImpl.java index 5b50d599..4e42534b 100644 --- a/nz-admin/src/main/java/com/nis/modules/module/service/impl/MonitorModuleServiceImpl.java +++ b/nz-admin/src/main/java/com/nis/modules/module/service/impl/MonitorModuleServiceImpl.java @@ -1075,4 +1075,29 @@ public class MonitorModuleServiceImpl extends ServiceImpl<MonitorModuleDao, Moni return this.baseMapper.queryAssetMoudules(assetId); } + @Override + @Transactional(rollbackFor = Exception.class) + public void syncModuleEndpointAndDashboard(List<Integer> syncModuleIdList, Integer isSyncEndpoint, Integer isSyncDashboard) { + log.info("[syncModuleEndpointAndDashboard] [begin] [syncModuleIdList: {}] [isSyncEndpoint: {}] [isSyncDashboard: {}]", JSONUtil.toJsonStr(syncModuleIdList), isSyncEndpoint, isSyncDashboard); + if (ObjectUtil.equal(1, isSyncEndpoint)) { + List<MonitorEndpoint> syncEndpointList = monitorEndpointService.list(new LambdaQueryWrapper<MonitorEndpoint>().in(MonitorEndpoint::getModuleId, syncModuleIdList)); + if (CollUtil.isEmpty(syncEndpointList)) { + log.warn("[syncModuleEndpointAndDashboard] [module has no endpoint to sync] [syncModuleIdList: {}]", JSONUtil.toJsonStr(syncModuleIdList)); + } else { + List<Integer> syncEndpointIdList = syncEndpointList.stream().map(MonitorEndpoint::getId).collect(Collectors.toList()); + monitorEndpointService.syncConfigByIdList(syncEndpointIdList); + } + } + + if (ObjectUtil.equal(1, isSyncDashboard)) { + List<MonitorModule> moduleList = this.getBaseMapper().selectBatchIds(syncModuleIdList); + ValidateUtils.is(moduleList).notNull(RCode.MODULE_NOTFOUND); + + for (MonitorModule module : moduleList) { + visualService.syncTemplateDashboard(null, null, null, module.getId()); + } + } + log.info("[syncModuleEndpointAndDashboard] [finshed]"); + } + } |
