diff --git a/datavines-connector/datavines-connector-api/src/main/java/io/datavines/connector/api/LineageParser.java b/datavines-connector/datavines-connector-api/src/main/java/io/datavines/connector/api/LineageParser.java index 2c5a03cf1..3e62f4daa 100644 --- a/datavines-connector/datavines-connector-api/src/main/java/io/datavines/connector/api/LineageParser.java +++ b/datavines-connector/datavines-connector-api/src/main/java/io/datavines/connector/api/LineageParser.java @@ -26,7 +26,7 @@ public class LineageParser { - public static ScriptMetadata parseScript(String script, StatementSplitter statementSplitter, StatementParser statementParser) { + public static ScriptMetadata parseScript(String script, StatementSplitter statementSplitter, StatementParser statementParser) { if (StringUtils.isEmpty(script)) { return null; } diff --git a/datavines-connector/datavines-connector-api/src/main/java/io/datavines/connector/api/StatementSplitter.java b/datavines-connector/datavines-connector-api/src/main/java/io/datavines/connector/api/StatementSplitter.java index 6357aa299..196b1b6ca 100644 --- a/datavines-connector/datavines-connector-api/src/main/java/io/datavines/connector/api/StatementSplitter.java +++ b/datavines-connector/datavines-connector-api/src/main/java/io/datavines/connector/api/StatementSplitter.java @@ -20,5 +20,5 @@ public interface StatementSplitter { - List splitStatements(String body) ; + List splitStatements(String body); } diff --git a/datavines-metric/datavines-metric-result-formula-plugins/datavines-metric-result-formula-diff-percentage/src/main/java/io/datavines/metric/result/formula/DiffPercentage.java b/datavines-metric/datavines-metric-result-formula-plugins/datavines-metric-result-formula-diff-percentage/src/main/java/io/datavines/metric/result/formula/DiffPercentage.java index a5ab86f42..d1d2b66de 100644 --- a/datavines-metric/datavines-metric-result-formula-plugins/datavines-metric-result-formula-diff-percentage/src/main/java/io/datavines/metric/result/formula/DiffPercentage.java +++ b/datavines-metric/datavines-metric-result-formula-plugins/datavines-metric-result-formula-diff-percentage/src/main/java/io/datavines/metric/result/formula/DiffPercentage.java @@ -38,8 +38,8 @@ public String getZhName() { @Override public BigDecimal getResult(BigDecimal actualValue, BigDecimal expectedValue) { BigDecimal result = BigDecimal.valueOf(0); - if (expectedValue != null && expectedValue.compareTo(BigDecimal.ZERO) != 0) { - BigDecimal quotient = actualValue.divide(expectedValue, 2, RoundingMode.HALF_UP); + if (expectedValue != null && expectedValue.compareTo(BigDecimal.ZERO) != 0 && actualValue != null) { + BigDecimal quotient = actualValue.subtract(expectedValue).abs(); result = quotient.divide(expectedValue, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)); } diff --git a/datavines-notification/datavines-notification-plugins/datavines-notification-plugin-dingtalk/src/main/java/io/datavines/notification/plugin/dingtalk/DingTalkSender.java b/datavines-notification/datavines-notification-plugins/datavines-notification-plugin-dingtalk/src/main/java/io/datavines/notification/plugin/dingtalk/DingTalkSender.java index e109760c3..445469efc 100644 --- a/datavines-notification/datavines-notification-plugins/datavines-notification-plugin-dingtalk/src/main/java/io/datavines/notification/plugin/dingtalk/DingTalkSender.java +++ b/datavines-notification/datavines-notification-plugins/datavines-notification-plugin-dingtalk/src/main/java/io/datavines/notification/plugin/dingtalk/DingTalkSender.java @@ -108,7 +108,7 @@ public SlaNotificationResultRecord sendCardMsg(Set receiverSet, private String generateMsgJson(String title, String content,ReceiverConfig receiverConfig) { final String atMobiles = receiverConfig.getAtMobiles(); - final String atUserIds = receiverConfig.getAtUserIds(); + final String atDingtalkIds = receiverConfig.getAtDingtalkIds(); final Boolean isAtAll = receiverConfig.getIsAtAll(); if (org.apache.commons.lang3.StringUtils.isBlank(msgType)) { @@ -133,8 +133,8 @@ private String generateMsgJson(String title, String content,ReceiverConfig recei builder.append(" "); }); } - if (org.apache.commons.lang3.StringUtils.isNotBlank(atUserIds)) { - Arrays.stream(atUserIds.split(",")).forEach(value -> { + if (org.apache.commons.lang3.StringUtils.isNotBlank(atDingtalkIds)) { + Arrays.stream(atDingtalkIds.split(",")).forEach(value -> { builder.append("@"); builder.append(value); builder.append(" "); @@ -163,10 +163,10 @@ private String generateMsgJson(String title, String content,ReceiverConfig recei org.apache.commons.lang3.StringUtils.isNotBlank(atMobiles) ? atMobiles.split(",") : new String[0]; String[] atUserArray = - org.apache.commons.lang3.StringUtils.isNotBlank(atUserIds) ? atUserIds.split(",") + org.apache.commons.lang3.StringUtils.isNotBlank(atDingtalkIds) ? atDingtalkIds.split(",") : new String[0]; at.put("atMobiles", atMobileArray); - at.put("atUserIds", atUserArray); + at.put("atDingtalkIds", atUserArray); at.put("isAtAll", isAtAll); items.put("at", at); diff --git a/datavines-notification/datavines-notification-plugins/datavines-notification-plugin-dingtalk/src/main/java/io/datavines/notification/plugin/dingtalk/DingTalkSlasHandlerPlugin.java b/datavines-notification/datavines-notification-plugins/datavines-notification-plugin-dingtalk/src/main/java/io/datavines/notification/plugin/dingtalk/DingTalkSlasHandlerPlugin.java index 70952df9b..5c51e5300 100644 --- a/datavines-notification/datavines-notification-plugins/datavines-notification-plugin-dingtalk/src/main/java/io/datavines/notification/plugin/dingtalk/DingTalkSlasHandlerPlugin.java +++ b/datavines-notification/datavines-notification-plugins/datavines-notification-plugin-dingtalk/src/main/java/io/datavines/notification/plugin/dingtalk/DingTalkSlasHandlerPlugin.java @@ -107,10 +107,10 @@ public String getConfigJson() { List paramsList = new ArrayList<>(); InputParam atMobiles = InputParam.newBuilder("atMobiles", "atMobiles") - .addValidate(Validate.newBuilder().setRequired(true).build()) + .addValidate(Validate.newBuilder().setRequired(false).build()) .build(); - InputParam atUserIds = InputParam.newBuilder("atUserIds", "atUserIds") - .addValidate(Validate.newBuilder().setRequired(true).build()) + InputParam atDingtalkIds = InputParam.newBuilder("atDingtalkIds", "atDingtalkIds") + .addValidate(Validate.newBuilder().setRequired(false).build()) .build(); RadioParam isAtAll = RadioParam.newBuilder("isAtAll", "isAtAll") .addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false)) @@ -120,7 +120,7 @@ public String getConfigJson() { .build(); paramsList.add(atMobiles); - paramsList.add(atUserIds); + paramsList.add(atDingtalkIds); paramsList.add(isAtAll); ObjectMapper mapper = new ObjectMapper(); @@ -135,4 +135,4 @@ public String getConfigJson() { return result; } -} \ No newline at end of file +} diff --git a/datavines-notification/datavines-notification-plugins/datavines-notification-plugin-dingtalk/src/main/java/io/datavines/notification/plugin/dingtalk/entity/ReceiverConfig.java b/datavines-notification/datavines-notification-plugins/datavines-notification-plugin-dingtalk/src/main/java/io/datavines/notification/plugin/dingtalk/entity/ReceiverConfig.java index a9c531843..3a6fc7f71 100644 --- a/datavines-notification/datavines-notification-plugins/datavines-notification-plugin-dingtalk/src/main/java/io/datavines/notification/plugin/dingtalk/entity/ReceiverConfig.java +++ b/datavines-notification/datavines-notification-plugins/datavines-notification-plugin-dingtalk/src/main/java/io/datavines/notification/plugin/dingtalk/entity/ReceiverConfig.java @@ -29,7 +29,7 @@ public class ReceiverConfig { private String atMobiles; - private String atUserIds; + private String atDingtalkIds; private Boolean isAtAll; @@ -47,6 +47,6 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(atMobiles, atUserIds); + return Objects.hash(atMobiles, atDingtalkIds); } -} \ No newline at end of file +} diff --git a/datavines-server/src/main/java/io/datavines/server/api/controller/CatalogLineageController.java b/datavines-server/src/main/java/io/datavines/server/api/controller/CatalogLineageController.java index e713caff2..b6f6fa70b 100644 --- a/datavines-server/src/main/java/io/datavines/server/api/controller/CatalogLineageController.java +++ b/datavines-server/src/main/java/io/datavines/server/api/controller/CatalogLineageController.java @@ -18,7 +18,7 @@ import io.datavines.core.aop.RefreshToken; import io.datavines.core.constant.DataVinesConstants; -import io.datavines.server.api.dto.bo.catalog.lineage.EntityEdgeInfo; +import io.datavines.server.api.dto.bo.catalog.lineage.LineageEntityEdgeInfo; import io.datavines.server.api.dto.bo.catalog.lineage.SqlWithDataSourceKeyProperties; import io.datavines.server.api.dto.bo.catalog.lineage.SqlWithDataSourceList; import io.datavines.server.repository.entity.catalog.CatalogTagCategory; @@ -42,7 +42,7 @@ public class CatalogLineageController { @ApiOperation(value = "add lineage", response = Long.class) @PostMapping(value = "/add", consumes = MediaType.APPLICATION_JSON_VALUE) - public Object addLineage(@Valid @RequestBody EntityEdgeInfo entityEdgeInfo) { + public Object addLineage(@Valid @RequestBody LineageEntityEdgeInfo entityEdgeInfo) { return catalogEntityRelService.addLineage(entityEdgeInfo); } diff --git a/datavines-server/src/main/java/io/datavines/server/api/controller/SlaController.java b/datavines-server/src/main/java/io/datavines/server/api/controller/SlaController.java index 3a1505db5..7d42564cf 100644 --- a/datavines-server/src/main/java/io/datavines/server/api/controller/SlaController.java +++ b/datavines-server/src/main/java/io/datavines/server/api/controller/SlaController.java @@ -100,6 +100,16 @@ public Object test(@PathVariable("slaId") Long slaId) { return client.notify(message, configuration); } + @ApiOperation(value = "test sla sender") + @PostMapping(value = "/sender/test") + public Object testSend(@Valid @RequestBody SlaNotificationCreate slaNotificationSendTest) { + SlaNotificationMessage message = new SlaNotificationMessage(); + message.setMessage("[\"test sla sender\"]"); + message.setSubject("Test sender"); + Map> configuration = slaNotificationService.getSlasNotificationConfigurationBySlasIdAndSenderId(slaNotificationSendTest.getSlaId(), slaNotificationSendTest.getSenderId(), slaNotificationSendTest.getConfig()); + return client.notify(message, configuration); + } + @ApiOperation(value = "page list sla") @GetMapping(value = "/page") public Object listSlas(@RequestParam("workspaceId") Long workspaceId, @@ -219,4 +229,4 @@ public Object pageListNotification(@RequestParam("workspaceId") Long workspaceId @RequestParam("pageSize") Integer pageSize) { return slaNotificationService.pageListNotification(workspaceId, slaId, searchVal, pageNumber, pageSize); } -} \ No newline at end of file +} diff --git a/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/CatalogEntityColumnLineageDetail.java b/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/CatalogEntityColumnLineageDetail.java index e32f776e1..3fcad0e7d 100644 --- a/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/CatalogEntityColumnLineageDetail.java +++ b/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/CatalogEntityColumnLineageDetail.java @@ -16,6 +16,7 @@ */ package io.datavines.server.api.dto.bo.catalog.lineage; +import io.datavines.server.api.dto.bo.catalog.CatalogEntityInstanceInfo; import lombok.Data; import java.io.Serializable; @@ -26,9 +27,9 @@ public class CatalogEntityColumnLineageDetail implements Serializable { private static final long serialVersionUID = -1L; - private List fromChildren; + private List fromChildren; private String function; - private String toChild; + private CatalogEntityInstanceInfo toChild; } diff --git a/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/CatalogEntityLineageDetail.java b/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/CatalogEntityLineageDetail.java index 52e332eeb..4732fe4b2 100644 --- a/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/CatalogEntityLineageDetail.java +++ b/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/CatalogEntityLineageDetail.java @@ -20,13 +20,14 @@ import lombok.Data; import java.io.Serializable; +import java.util.List; @Data public class CatalogEntityLineageDetail implements Serializable { private static final long serialVersionUID = -1L; - private CatalogEntityColumnLineageDetail childRelDetail; + private List childRelDetailList; private String description; diff --git a/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/LineageEntityEdgeInfo.java b/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/LineageEntityEdgeInfo.java new file mode 100644 index 000000000..69700e814 --- /dev/null +++ b/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/LineageEntityEdgeInfo.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.datavines.server.api.dto.bo.catalog.lineage; + +import io.datavines.server.api.dto.bo.catalog.CatalogEntityInstanceInfo; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class LineageEntityEdgeInfo implements Serializable { + + private static final long serialVersionUID = -1L; + + private String uuid; + + private CatalogEntityInstanceInfo fromEntity; + + private String description; + + private CatalogEntityLineageDetail lineageDetail; + + private CatalogEntityInstanceInfo toEntity; + +} diff --git a/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/LineageEntityNodeInfo.java b/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/LineageEntityNodeInfo.java new file mode 100644 index 000000000..fa89fc674 --- /dev/null +++ b/datavines-server/src/main/java/io/datavines/server/api/dto/bo/catalog/lineage/LineageEntityNodeInfo.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.datavines.server.api.dto.bo.catalog.lineage; + +import io.datavines.server.api.dto.bo.catalog.CatalogEntityInstanceInfo; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class LineageEntityNodeInfo implements Serializable { + + private static final long serialVersionUID = -1L; + + private Long id; + + private String uuid; + + private Long datasourceId; + + private String type; + + private String fullyQualifiedName; + + private String displayName; + + private String description; + + private CatalogEntityInstanceInfo datasource; + + private CatalogEntityInstanceInfo database; + + private CatalogEntityInstanceInfo schema; + + private CatalogEntityInstanceInfo catalog; + + private List columns; + +} diff --git a/datavines-server/src/main/java/io/datavines/server/api/dto/vo/catalog/lineage/CatalogEntityLineageVO.java b/datavines-server/src/main/java/io/datavines/server/api/dto/vo/catalog/lineage/CatalogEntityLineageVO.java index 40409855d..f0b9665d9 100644 --- a/datavines-server/src/main/java/io/datavines/server/api/dto/vo/catalog/lineage/CatalogEntityLineageVO.java +++ b/datavines-server/src/main/java/io/datavines/server/api/dto/vo/catalog/lineage/CatalogEntityLineageVO.java @@ -16,8 +16,8 @@ */ package io.datavines.server.api.dto.vo.catalog.lineage; -import io.datavines.server.api.dto.bo.catalog.CatalogEntityInstanceInfo; -import io.datavines.server.api.dto.bo.catalog.lineage.EntityEdgeInfo; +import io.datavines.server.api.dto.bo.catalog.lineage.LineageEntityEdgeInfo; +import io.datavines.server.api.dto.bo.catalog.lineage.LineageEntityNodeInfo; import lombok.Data; import java.io.Serializable; @@ -26,9 +26,9 @@ @Data public class CatalogEntityLineageVO implements Serializable { - public List upstreamEdges; + public LineageEntityNodeInfo currentNode; - public List downstreamEdges; + public List nodes; - public CatalogEntityInstanceInfo currentEntity; -} + public List edges; + } diff --git a/datavines-server/src/main/java/io/datavines/server/enums/LineageSourceType.java b/datavines-server/src/main/java/io/datavines/server/enums/LineageSourceType.java index 5d65dfaba..ce1bf3fdf 100644 --- a/datavines-server/src/main/java/io/datavines/server/enums/LineageSourceType.java +++ b/datavines-server/src/main/java/io/datavines/server/enums/LineageSourceType.java @@ -42,19 +42,29 @@ public enum LineageSourceType { private final String description; - private static final Map COMMAND_CATEGORY_MAP = new HashMap<>(); + private static final Map CODE_2_MAP = new HashMap<>(); + + private static final Map DESC_2_MAP = new HashMap<>(); static { for (LineageSourceType commandCategory : LineageSourceType.values()) { - COMMAND_CATEGORY_MAP.put(commandCategory.code,commandCategory); + CODE_2_MAP.put(commandCategory.code,commandCategory); + DESC_2_MAP.put(commandCategory.description,commandCategory); } } public static LineageSourceType of(Integer status) { - if (COMMAND_CATEGORY_MAP.containsKey(status)) { - return COMMAND_CATEGORY_MAP.get(status); + if (CODE_2_MAP.containsKey(status)) { + return CODE_2_MAP.get(status); + } + throw new IllegalArgumentException("invalid lineage source type : " + status); + } + + public static LineageSourceType descOf(String description) { + if (DESC_2_MAP.containsKey(description)) { + return DESC_2_MAP.get(description); } - throw new IllegalArgumentException("invalid command category : " + status); + throw new IllegalArgumentException("invalid lineage source type : " + description); } public int getCode() { diff --git a/datavines-server/src/main/java/io/datavines/server/repository/service/CatalogEntityInstanceService.java b/datavines-server/src/main/java/io/datavines/server/repository/service/CatalogEntityInstanceService.java index cb5235f4e..0cdae4ec8 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/service/CatalogEntityInstanceService.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/service/CatalogEntityInstanceService.java @@ -34,6 +34,10 @@ public interface CatalogEntityInstanceService extends IService getChildren(String uuid); + CatalogEntityInstance getByUUID(String uuid); CatalogEntityInstance getByDataSourceAndFQN(Long dataSourceId, String fqn); diff --git a/datavines-server/src/main/java/io/datavines/server/repository/service/CatalogEntityRelService.java b/datavines-server/src/main/java/io/datavines/server/repository/service/CatalogEntityRelService.java index 1b58b6ffa..8d648b7d4 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/service/CatalogEntityRelService.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/service/CatalogEntityRelService.java @@ -17,7 +17,7 @@ package io.datavines.server.repository.service; import com.baomidou.mybatisplus.extension.service.IService; -import io.datavines.server.api.dto.bo.catalog.lineage.EntityEdgeInfo; +import io.datavines.server.api.dto.bo.catalog.lineage.LineageEntityEdgeInfo; import io.datavines.server.api.dto.bo.catalog.lineage.SqlWithDataSourceKeyProperties; import io.datavines.server.api.dto.bo.catalog.lineage.SqlWithDataSourceList; import io.datavines.server.api.dto.vo.catalog.lineage.CatalogEntityLineageVO; @@ -25,7 +25,7 @@ public interface CatalogEntityRelService extends IService { - public boolean addLineage(EntityEdgeInfo entityEdgeInfo); + public boolean addLineage(LineageEntityEdgeInfo entityEdgeInfo); public boolean addLineageByParseSql(SqlWithDataSourceList sqlWithDataSourceList); diff --git a/datavines-server/src/main/java/io/datavines/server/repository/service/SlaNotificationService.java b/datavines-server/src/main/java/io/datavines/server/repository/service/SlaNotificationService.java index 221503e54..fdabbd698 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/service/SlaNotificationService.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/service/SlaNotificationService.java @@ -31,6 +31,8 @@ public interface SlaNotificationService extends IService{ Map> getSlasNotificationConfigurationBySlasId(Long slaId); + Map> getSlasNotificationConfigurationBySlasIdAndSenderId(Long slaId, Long senderId, String config); + Map> getSlasNotificationConfigurationByJobId(Long job); String getConfigJson(String type); diff --git a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogEntityInstanceServiceImpl.java b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogEntityInstanceServiceImpl.java index b577e1fdd..79e1a9972 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogEntityInstanceServiceImpl.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogEntityInstanceServiceImpl.java @@ -16,6 +16,7 @@ */ package io.datavines.server.repository.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -99,6 +100,39 @@ public CatalogEntityInstance getByUUID(String uuid) { return baseMapper.selectOne(new QueryWrapper().lambda().eq(CatalogEntityInstance::getUuid, uuid)); } + @Override + public CatalogEntityInstance getParent(String uuid) { + CatalogEntityRel parentEntityRel = entityRelService.getOne(new LambdaQueryWrapper() + .eq(CatalogEntityRel::getEntity2Uuid, uuid) + .eq(CatalogEntityRel::getType, EntityRelType.CHILD.getDescription()), false); + + CatalogEntityInstance parentEntity = null; + if (parentEntityRel == null) { + return parentEntity; + } + + parentEntity = getByUUID(parentEntityRel.getEntity1Uuid()); + return parentEntity; + } + + @Override + public List getChildren(String uuid) { + List childEntityRelList = entityRelService.list(new LambdaQueryWrapper() + .eq(CatalogEntityRel::getEntity1Uuid, uuid) + .eq(CatalogEntityRel::getType, EntityRelType.CHILD.getDescription())); + List childEntityList = new ArrayList<>(); + if (CollectionUtils.isEmpty(childEntityRelList)) { + return childEntityList; + } + + for (CatalogEntityRel childEntityRel : childEntityRelList) { + CatalogEntityInstance childEntity = getByUUID(childEntityRel.getEntity2Uuid()); + childEntityList.add(childEntity); + } + + return childEntityList; + } + @Override public CatalogEntityInstance getByDataSourceAndFQN(Long dataSourceId, String fqn) { return baseMapper.selectOne(new QueryWrapper().lambda() diff --git a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogEntityRelServiceImpl.java b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogEntityRelServiceImpl.java index 56db6fbe6..0f68a59e0 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogEntityRelServiceImpl.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogEntityRelServiceImpl.java @@ -17,7 +17,6 @@ package io.datavines.server.repository.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import io.datavines.common.datasource.jdbc.JdbcConnectionInfo; import io.datavines.common.enums.EntityRelType; @@ -31,9 +30,7 @@ import io.datavines.core.enums.Status; import io.datavines.core.exception.DataVinesServerException; import io.datavines.server.api.dto.bo.catalog.CatalogEntityInstanceInfo; -import io.datavines.server.api.dto.bo.catalog.lineage.EntityEdgeInfo; -import io.datavines.server.api.dto.bo.catalog.lineage.SqlWithDataSourceKeyProperties; -import io.datavines.server.api.dto.bo.catalog.lineage.SqlWithDataSourceList; +import io.datavines.server.api.dto.bo.catalog.lineage.*; import io.datavines.server.api.dto.bo.datasource.DataSourceInfo; import io.datavines.server.api.dto.vo.catalog.lineage.CatalogEntityLineageVO; import io.datavines.server.enums.LineageSourceType; @@ -51,10 +48,11 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; @Service("catalogEntityRelService") public class CatalogEntityRelServiceImpl extends ServiceImpl implements CatalogEntityRelService { @@ -65,12 +63,81 @@ public class CatalogEntityRelServiceImpl extends ServiceImpl() + .eq(CatalogEntityRel::getEntity1Uuid, fromUUID) + .eq(CatalogEntityRel::getEntity2Uuid, toUUID) + .eq(CatalogEntityRel::getType, EntityRelType.DOWNSTREAM.getDescription()), false); + if (rel == null) { + rel = new CatalogEntityRel(); + } + + rel.setEntity1Uuid(fromUUID); + rel.setEntity2Uuid(toUUID); + rel.setType(EntityRelType.DOWNSTREAM.getDescription()); + rel.setSourceType(entityEdgeInfo.getLineageDetail().getSourceType().getDescription()); + rel.setRelatedScript(entityEdgeInfo.getLineageDetail().getSqlQuery()); + rel.setUpdateBy(ContextHolder.getUserId()); + rel.setUpdateTime(LocalDateTime.now()); + + boolean result; + if (rel.getId() == null) { + result = save(rel); + } else { + result = updateById(rel); + } + + if (result) { + CatalogEntityLineageDetail catalogEntityLineageDetail = entityEdgeInfo.getLineageDetail(); + List detailList = catalogEntityLineageDetail.getChildRelDetailList(); + if (CollectionUtils.isEmpty(detailList)) { + return true; + } + + for (CatalogEntityColumnLineageDetail detail : detailList) { + List fromEntityList = detail.getFromChildren(); + if (CollectionUtils.isEmpty(fromEntityList)) { + continue; + } + + CatalogEntityInstanceInfo toEntity = detail.getToChild(); + if (toEntity == null) { + continue; + } + + for (CatalogEntityInstanceInfo fromEntity : fromEntityList) { + CatalogEntityRel columnRel = getOne(new LambdaQueryWrapper() + .eq(CatalogEntityRel::getEntity1Uuid, fromEntity.getUuid()) + .eq(CatalogEntityRel::getEntity2Uuid, toEntity.getUuid()) + .eq(CatalogEntityRel::getType, EntityRelType.DOWNSTREAM.getDescription()), false); + if (columnRel == null) { + columnRel = new CatalogEntityRel(); + } + + columnRel.setEntity1Uuid(fromEntity.getUuid()); + columnRel.setEntity2Uuid(toEntity.getUuid()); + columnRel.setType(EntityRelType.DOWNSTREAM.getDescription()); + columnRel.setSourceType(catalogEntityLineageDetail.getSourceType().getDescription()); + columnRel.setRelatedScript(catalogEntityLineageDetail.getSqlQuery()); + columnRel.setUpdateBy(ContextHolder.getUserId()); + columnRel.setUpdateTime(LocalDateTime.now()); + + if (columnRel.getId() == null) { + save(columnRel); + } else { + updateById(columnRel); + } + } + } + + return true; + } - return addLineage(fromUUID, toUUID, entityEdgeInfo.getLineageDetail().getSourceType(),entityEdgeInfo.getLineageDetail().getSqlQuery()); + return false; } @Override @@ -168,51 +235,218 @@ public CatalogEntityLineageVO getLineageByFqn(Long datasourceId, String fqn, int @NotNull private CatalogEntityLineageVO getCatalogEntityLineageVO(CatalogEntityInstance catalogEntityInstance) { + Set nodeSet = new HashSet<>(); + Set edgeSet = new HashSet<>(); + CatalogEntityLineageVO catalogEntityLineageVO = new CatalogEntityLineageVO(); CatalogEntityInstanceInfo currentEntityInstanceInfo = new CatalogEntityInstanceInfo(); BeanUtils.copyProperties(catalogEntityInstance, currentEntityInstanceInfo); - catalogEntityLineageVO.setCurrentEntity(currentEntityInstanceInfo); String fromUUID = catalogEntityInstance.getUuid(); + + LineageEntityNodeInfo currentNode = new LineageEntityNodeInfo(); + BeanUtils.copyProperties(catalogEntityInstance, currentNode); + CatalogEntityInstance databaseEntity = catalogEntityInstanceService.getParent(fromUUID); + CatalogEntityInstanceInfo databaseEntityInstanceInfo = new CatalogEntityInstanceInfo(); + BeanUtils.copyProperties(databaseEntity, databaseEntityInstanceInfo); + currentNode.setDatabase(databaseEntityInstanceInfo); + DataSource dataSource = dataSourceService.getById(catalogEntityInstance.getDatasourceId()); + CatalogEntityInstanceInfo datasourceEntityInstanceInfo = new CatalogEntityInstanceInfo(); + datasourceEntityInstanceInfo.setType(dataSource.getType()); + datasourceEntityInstanceInfo.setDisplayName(dataSource.getName()); + datasourceEntityInstanceInfo.setUuid(dataSource.getUuid()); + datasourceEntityInstanceInfo.setId(dataSource.getId()); + List currentChildEntityInstances = catalogEntityInstanceService.getChildren(catalogEntityInstance.getUuid()); + if (CollectionUtils.isNotEmpty(currentChildEntityInstances)) { + List columns = new ArrayList<>(); + for (CatalogEntityInstance childEntityInstance : currentChildEntityInstances) { + CatalogEntityInstanceInfo columnEntityInstanceInfo = new CatalogEntityInstanceInfo(); + BeanUtils.copyProperties(childEntityInstance, columnEntityInstanceInfo); + columns.add(columnEntityInstanceInfo); + } + currentNode.setColumns(columns); + } + currentNode.setDatasource(datasourceEntityInstanceInfo); + catalogEntityLineageVO.setCurrentNode(currentNode); + + List nodes = new ArrayList<>(); + nodes.add(currentNode); + + List edges = new ArrayList<>(); + List downstreamRelList = list(new LambdaQueryWrapper() .eq(CatalogEntityRel::getEntity1Uuid, fromUUID) .eq(CatalogEntityRel::getType, EntityRelType.DOWNSTREAM.getDescription())); if (CollectionUtils.isNotEmpty(downstreamRelList)) { - List downstreamEdges = new ArrayList<>(); for (CatalogEntityRel rel : downstreamRelList) { CatalogEntityInstance downstreamEntityInstance = catalogEntityInstanceService.getByUUID(rel.getEntity2Uuid()); - if (downstreamEntityInstance != null) { - EntityEdgeInfo entityEdgeInfo = new EntityEdgeInfo(); - CatalogEntityInstanceInfo fromEntity = new CatalogEntityInstanceInfo(); - BeanUtils.copyProperties(currentEntityInstanceInfo, fromEntity); - CatalogEntityInstanceInfo toEntity = new CatalogEntityInstanceInfo(); - BeanUtils.copyProperties(downstreamEntityInstance, toEntity); - entityEdgeInfo.setFromEntity(fromEntity); - entityEdgeInfo.setToEntity(toEntity); - downstreamEdges.add(entityEdgeInfo); + if (downstreamEntityInstance != null && !nodeSet.contains(downstreamEntityInstance.getUuid())) { + LineageEntityNodeInfo downstreamNode = new LineageEntityNodeInfo(); + BeanUtils.copyProperties(downstreamEntityInstance, downstreamNode); + CatalogEntityInstance toDatabaseEntity = catalogEntityInstanceService.getParent(fromUUID); + CatalogEntityInstanceInfo toDatabaseEntityInstanceInfo = new CatalogEntityInstanceInfo(); + BeanUtils.copyProperties(toDatabaseEntity, toDatabaseEntityInstanceInfo); + downstreamNode.setDatabase(databaseEntityInstanceInfo); + DataSource toDataSource = dataSourceService.getById(catalogEntityInstance.getDatasourceId()); + CatalogEntityInstanceInfo toDatasourceEntityInstanceInfo = new CatalogEntityInstanceInfo(); + toDatasourceEntityInstanceInfo.setType(toDataSource.getType()); + toDatasourceEntityInstanceInfo.setDisplayName(toDataSource.getName()); + toDatasourceEntityInstanceInfo.setUuid(toDataSource.getUuid()); + toDatasourceEntityInstanceInfo.setId(toDataSource.getId()); + downstreamNode.setDatasource(toDatasourceEntityInstanceInfo); + List childEntityInstances = catalogEntityInstanceService.getChildren(downstreamEntityInstance.getUuid()); + if (CollectionUtils.isNotEmpty(childEntityInstances)) { + List columns = new ArrayList<>(); + for (CatalogEntityInstance childEntityInstance : childEntityInstances) { + CatalogEntityInstanceInfo columnEntityInstanceInfo = new CatalogEntityInstanceInfo(); + BeanUtils.copyProperties(childEntityInstance, columnEntityInstanceInfo); + columns.add(columnEntityInstanceInfo); + } + downstreamNode.setColumns(columns); + } + + nodes.add(downstreamNode); + nodeSet.add(downstreamEntityInstance.getUuid()); + + if (!edgeSet.contains(currentEntityInstanceInfo.getUuid() + ":" + downstreamEntityInstance.getUuid())) { + LineageEntityEdgeInfo edgeInfo = new LineageEntityEdgeInfo(); + CatalogEntityInstanceInfo fromEntity = new CatalogEntityInstanceInfo(); + BeanUtils.copyProperties(currentEntityInstanceInfo, fromEntity); + CatalogEntityInstanceInfo toEntity = new CatalogEntityInstanceInfo(); + BeanUtils.copyProperties(downstreamEntityInstance, toEntity); + edgeInfo.setFromEntity(fromEntity); + edgeInfo.setToEntity(toEntity); + edgeInfo.setUuid(fromEntity.getUuid() + ":" + toEntity.getUuid()); + + CatalogEntityLineageDetail lineageDetail = new CatalogEntityLineageDetail(); + List childRelDetailList = new ArrayList<>(); + + if (CollectionUtils.isNotEmpty(currentNode.getColumns()) + && CollectionUtils.isNotEmpty(downstreamNode.getColumns())) { + Map key2ColumnMap = new HashMap<>(); + for (CatalogEntityInstanceInfo column : currentNode.getColumns()) { + key2ColumnMap.put(column.getUuid(), column); + } + + List columns = downstreamNode.getColumns(); + for (CatalogEntityInstanceInfo column : columns) { + List columnDownstreamRelList = list(new LambdaQueryWrapper() + .eq(CatalogEntityRel::getEntity2Uuid, column.getUuid()) + .eq(CatalogEntityRel::getType, EntityRelType.DOWNSTREAM.getDescription())); + if (CollectionUtils.isNotEmpty(columnDownstreamRelList)) { + List fromChildren = columnDownstreamRelList + .stream() + .filter(x-> key2ColumnMap.containsKey(x.getEntity1Uuid())) + .map(item -> key2ColumnMap.get(item.getEntity1Uuid())).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(fromChildren)) { + CatalogEntityColumnLineageDetail + columnLineageDetail = new CatalogEntityColumnLineageDetail(); + columnLineageDetail.setFromChildren(fromChildren); + columnLineageDetail.setToChild(column); + childRelDetailList.add(columnLineageDetail); + } + } + } + } + + lineageDetail.setChildRelDetailList(childRelDetailList); + lineageDetail.setSourceType(LineageSourceType.descOf(rel.getSourceType())); + lineageDetail.setSqlQuery(rel.getRelatedScript()); + edgeInfo.setLineageDetail(lineageDetail); + edges.add(edgeInfo); + edgeSet.add(fromEntity.getUuid() + ":" + toEntity.getUuid()); + } } } - catalogEntityLineageVO.setDownstreamEdges(downstreamEdges); } - List upstreamRelList = list(new LambdaQueryWrapper().eq(CatalogEntityRel::getEntity2Uuid, fromUUID) + List upstreamRelList = list(new LambdaQueryWrapper() + .eq(CatalogEntityRel::getEntity2Uuid, fromUUID) .eq(CatalogEntityRel::getType, EntityRelType.DOWNSTREAM.getDescription())); if (CollectionUtils.isNotEmpty(upstreamRelList)) { - List upstreamEdges = new ArrayList<>(); for (CatalogEntityRel rel : upstreamRelList) { CatalogEntityInstance upstreamEntityInstance = catalogEntityInstanceService.getByUUID(rel.getEntity1Uuid()); - if (upstreamEntityInstance != null) { - EntityEdgeInfo entityEdgeInfo = new EntityEdgeInfo(); - CatalogEntityInstanceInfo fromEntity = new CatalogEntityInstanceInfo(); - BeanUtils.copyProperties(upstreamEntityInstance, fromEntity); - CatalogEntityInstanceInfo toEntity = new CatalogEntityInstanceInfo(); - BeanUtils.copyProperties(currentEntityInstanceInfo, toEntity); - entityEdgeInfo.setFromEntity(fromEntity); - entityEdgeInfo.setToEntity(toEntity); - upstreamEdges.add(entityEdgeInfo); + if (upstreamEntityInstance != null && !nodeSet.contains(upstreamEntityInstance.getUuid())) { + LineageEntityNodeInfo upstreamNode = new LineageEntityNodeInfo(); + BeanUtils.copyProperties(upstreamEntityInstance, upstreamNode); + CatalogEntityInstance fromDatabaseEntity = catalogEntityInstanceService.getParent(fromUUID); + CatalogEntityInstanceInfo fromDatabaseEntityInstanceInfo = new CatalogEntityInstanceInfo(); + BeanUtils.copyProperties(fromDatabaseEntity, fromDatabaseEntityInstanceInfo); + upstreamNode.setDatabase(databaseEntityInstanceInfo); + DataSource fromDataSource = dataSourceService.getById(catalogEntityInstance.getDatasourceId()); + CatalogEntityInstanceInfo fromDatasourceEntityInstanceInfo = new CatalogEntityInstanceInfo(); + fromDatasourceEntityInstanceInfo.setType(fromDataSource.getType()); + fromDatasourceEntityInstanceInfo.setDisplayName(fromDataSource.getName()); + fromDatasourceEntityInstanceInfo.setUuid(fromDataSource.getUuid()); + fromDatasourceEntityInstanceInfo.setId(fromDataSource.getId()); + upstreamNode.setDatasource(fromDatasourceEntityInstanceInfo); + List childEntityInstances = catalogEntityInstanceService.getChildren(upstreamEntityInstance.getUuid()); + if (CollectionUtils.isNotEmpty(childEntityInstances)) { + List columns = new ArrayList<>(); + for (CatalogEntityInstance childEntityInstance : childEntityInstances) { + CatalogEntityInstanceInfo columnEntityInstanceInfo = new CatalogEntityInstanceInfo(); + BeanUtils.copyProperties(childEntityInstance, columnEntityInstanceInfo); + columns.add(columnEntityInstanceInfo); + } + upstreamNode.setColumns(columns); + } + nodes.add(upstreamNode); + nodeSet.add(upstreamEntityInstance.getUuid()); + + if (!edgeSet.contains(upstreamEntityInstance.getUuid() + ":" + currentEntityInstanceInfo.getUuid())) { + LineageEntityEdgeInfo edgeInfo = new LineageEntityEdgeInfo(); + CatalogEntityInstanceInfo fromEntity = new CatalogEntityInstanceInfo(); + BeanUtils.copyProperties(upstreamEntityInstance, fromEntity); + CatalogEntityInstanceInfo toEntity = new CatalogEntityInstanceInfo(); + BeanUtils.copyProperties(currentEntityInstanceInfo, toEntity); + edgeInfo.setFromEntity(fromEntity); + edgeInfo.setToEntity(toEntity); + edgeInfo.setUuid(fromEntity.getUuid() + ":" + toEntity.getUuid()); + + CatalogEntityLineageDetail lineageDetail = new CatalogEntityLineageDetail(); + List childRelDetailList = new ArrayList<>(); + + if (CollectionUtils.isNotEmpty(currentNode.getColumns()) + && CollectionUtils.isNotEmpty(upstreamNode.getColumns())) { + Map key2ColumnMap = new HashMap<>(); + for (CatalogEntityInstanceInfo column : upstreamNode.getColumns()) { + key2ColumnMap.put(column.getUuid(), column); + } + + List columns = currentNode.getColumns(); + for (CatalogEntityInstanceInfo column : columns) { + List columnDownstreamRelList = list(new LambdaQueryWrapper() + .eq(CatalogEntityRel::getEntity2Uuid, column.getUuid()) + .eq(CatalogEntityRel::getType, EntityRelType.DOWNSTREAM.getDescription())); + if (CollectionUtils.isNotEmpty(columnDownstreamRelList)) { + List fromChildren = columnDownstreamRelList + .stream() + .filter(x-> key2ColumnMap.containsKey(x.getEntity1Uuid())) + .map(item -> key2ColumnMap.get(item.getEntity1Uuid())).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(fromChildren)) { + CatalogEntityColumnLineageDetail + columnLineageDetail = new CatalogEntityColumnLineageDetail(); + columnLineageDetail.setFromChildren(fromChildren); + columnLineageDetail.setToChild(column); + childRelDetailList.add(columnLineageDetail); + } + } + } + } + + lineageDetail.setChildRelDetailList(childRelDetailList); + lineageDetail.setSourceType(LineageSourceType.descOf(rel.getSourceType())); + lineageDetail.setSqlQuery(rel.getRelatedScript()); + edgeInfo.setLineageDetail(lineageDetail); + edges.add(edgeInfo); + edgeSet.add(fromEntity.getUuid() + ":" + toEntity.getUuid()); + } } } - catalogEntityLineageVO.setUpstreamEdges(upstreamEdges); } + + catalogEntityLineageVO.setNodes(nodes); + catalogEntityLineageVO.setEdges(edges); + return catalogEntityLineageVO; } @@ -232,9 +466,9 @@ public boolean deleteLineage(String fromUUID, String toUUID) { } private boolean addLineage(String fromUUID, String toUUID, LineageSourceType sourceType, String sql) { - List relList = list(new QueryWrapper() - .eq("entity1_uuid", fromUUID) - .eq("entity2_uuid", toUUID).eq("type", EntityRelType.DOWNSTREAM.getDescription())); + List relList = list(new LambdaQueryWrapper() + .eq(CatalogEntityRel::getEntity1Uuid, fromUUID) + .eq(CatalogEntityRel::getEntity2Uuid, toUUID).eq(CatalogEntityRel::getType, EntityRelType.DOWNSTREAM.getDescription())); CatalogEntityRel rel; if (CollectionUtils.isEmpty(relList)) { rel = new CatalogEntityRel(); diff --git a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/SlaNotificationServiceImpl.java b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/SlaNotificationServiceImpl.java index 4acb13cd5..92cea1a87 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/SlaNotificationServiceImpl.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/SlaNotificationServiceImpl.java @@ -88,6 +88,21 @@ public Map> getSlasNotificationConfigura return result; } + @Override + public Map> getSlasNotificationConfigurationBySlasIdAndSenderId(Long slaId, Long senderId, String config) { + // Assemble sender information + SlaSender slaSender = slaSenderService.getById(senderId); + SlaSenderMessage slaSenderMessage = BeanConvertUtils.convertBean(slaSender, SlaSenderMessage::new); + HashMap> result = new HashMap<>(); + SlaConfigMessage configMessage = new SlaConfigMessage(); + configMessage.setType(slaSender.getType()); + configMessage.setConfig(config); + HashSet set = new HashSet<>(); + set.add(configMessage); + result.put(slaSenderMessage, set); + return result; + } + @Override public Map> getSlasNotificationConfigurationByJobId(Long jobId) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); diff --git a/datavines-ui/src/locale/en_US.ts b/datavines-ui/src/locale/en_US.ts index ee2969655..f3918770d 100644 --- a/datavines-ui/src/locale/en_US.ts +++ b/datavines-ui/src/locale/en_US.ts @@ -321,4 +321,5 @@ export default { next_ten_cron_run_times: 'Next ten cron run times', view_future_execute_plan: 'view future execute plan', + test_send: 'test send', }; diff --git a/datavines-ui/src/locale/zh_CN.ts b/datavines-ui/src/locale/zh_CN.ts index 91a0f2214..a1fe685e6 100644 --- a/datavines-ui/src/locale/zh_CN.ts +++ b/datavines-ui/src/locale/zh_CN.ts @@ -319,4 +319,5 @@ export default { next_ten_cron_run_times: '未来十次执行时间', view_future_execute_plan: '查看未来执行计划', + test_send: '测试发送', }; diff --git a/datavines-ui/src/view/Main/HomeDetail/Jobs/components/Schedule/index.tsx b/datavines-ui/src/view/Main/HomeDetail/Jobs/components/Schedule/index.tsx index 2e92820a2..2162f6d6a 100644 --- a/datavines-ui/src/view/Main/HomeDetail/Jobs/components/Schedule/index.tsx +++ b/datavines-ui/src/view/Main/HomeDetail/Jobs/components/Schedule/index.tsx @@ -209,11 +209,11 @@ const Schedule: React.FC = ({ formRef, detail }) => { return ( <> {getIntl('jobs_nhour_before')} - {timeMap.nhour()} - : {timeMap.hour()} - {getIntl('jobs_nhour_middle')} + : {timeMap.minute()} + {getIntl('jobs_nhour_middle')} + {timeMap.nhour()} {getIntl('jobs_nhour_after')} ); diff --git a/datavines-ui/src/view/Main/Warning/SLAsSetting/useNotificationFormModal.tsx b/datavines-ui/src/view/Main/Warning/SLAsSetting/useNotificationFormModal.tsx index 0a6d4b428..c05cc38e9 100644 --- a/datavines-ui/src/view/Main/Warning/SLAsSetting/useNotificationFormModal.tsx +++ b/datavines-ui/src/view/Main/Warning/SLAsSetting/useNotificationFormModal.tsx @@ -1,6 +1,6 @@ import React, { useState, useRef } from 'react'; import { - Input, ModalProps, Form, FormInstance, Radio, message, + Input, ModalProps, Form, FormInstance, Radio, message, Button, } from 'antd'; import { useIntl } from 'react-intl'; import querystring from 'querystring'; @@ -53,6 +53,9 @@ const Inner = ({ form }: InnerProps) => { }; const list = (await $http.get('/sla/sender/list', params)) || []; setSenderList(list); + form?.setFieldsValue({ + senderId: undefined, + }); if (res) { const $res = JSON.parse(res) as NoticeDynamicItem[]; setDynamicMeta($res.map((item) => { @@ -144,6 +147,27 @@ export const useNotificationFormModal = (options: ModalProps) => { editRef.current = editInfo; const [qs] = useState(querystring.parse(window.location.href.split('?')[1] || '')); const { workspaceId } = useSelector((r) => r.workSpaceReducer); + const testSender = usePersistFn(async () => { + form.validateFields().then(async (values) => { + try { + setLoading(true); + const { senderId, ...rest } = values; + const params = { + senderId, + slaId: qs.slaId, + config: JSON.stringify(rest), + }; + await $http.post('/sla/sender/test', params); + message.success(intl.formatMessage({ id: 'common_success' })); + } catch (error) { + console.log(error); + } finally { + setLoading(false); + } + }).catch((err) => { + console.log(err); + }); + }); const onOk = usePersistFn(async () => { form.validateFields().then(async (values) => { try { @@ -179,6 +203,18 @@ export const useNotificationFormModal = (options: ModalProps) => { onOk, width: 600, ...(options || {}), + footer: ( +
+ + +
+ ), }); return { Render: useImmutable(() => ()), diff --git a/scripts/sql/datavines-mysql.sql b/scripts/sql/datavines-mysql.sql index 672142416..f690373a5 100644 --- a/scripts/sql/datavines-mysql.sql +++ b/scripts/sql/datavines-mysql.sql @@ -274,8 +274,8 @@ CREATE TABLE `dv_catalog_entity_rel` ( `entity1_uuid` varchar(64) NOT NULL COMMENT '实体1UUID', `entity2_uuid` varchar(64) NOT NULL COMMENT '实体2UUID', `type` varchar(64) NOT NULL COMMENT '关系类型,upstream-2是1上游,downstream-2是1下游, child-2是1的子类,parent-2是1的父类', - `source_type` varchar(64) NOT NULL COMMENT '来源类型', - `related_script` text NOT NULL COMMENT '关联脚本', + `source_type` varchar(64) DEFAULT NULL COMMENT '来源类型', + `related_script` text DEFAULT NULL COMMENT '关联脚本', `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `update_by` bigint(20) NOT NULL COMMENT '更新用户ID', PRIMARY KEY (`id`),