Unverified Commit c861202b authored by Zzm0809's avatar Zzm0809 Committed by GitHub

Fix push ds locations bug (#2807)

* fix-push-ds-locations-bug * Spotless Apply --------- Co-authored-by: 's avatarZzm0809 <Zzm0809@users.noreply.github.com>
parent ccfc44ec
...@@ -117,8 +117,8 @@ public class SchedulerServiceImpl implements SchedulerService { ...@@ -117,8 +117,8 @@ public class SchedulerServiceImpl implements SchedulerService {
DagNodeLocation dagNodeLocation = new DagNodeLocation(); DagNodeLocation dagNodeLocation = new DagNodeLocation();
dagNodeLocation.setTaskCode(taskCode); dagNodeLocation.setTaskCode(taskCode);
dagNodeLocation.setX(RandomUtil.randomLong(200, 500)); dagNodeLocation.setX(RandomUtil.randomLong(200, 800));
dagNodeLocation.setY(RandomUtil.randomLong(100, 400)); dagNodeLocation.setY(RandomUtil.randomLong(100, 600));
log.info("DagNodeLocation Info: {}", dagNodeLocation); log.info("DagNodeLocation Info: {}", dagNodeLocation);
ProcessTaskRelation processTaskRelation = ProcessTaskRelation.generateProcessTaskRelation(taskCode); ProcessTaskRelation processTaskRelation = ProcessTaskRelation.generateProcessTaskRelation(taskCode);
...@@ -176,43 +176,32 @@ public class SchedulerServiceImpl implements SchedulerService { ...@@ -176,43 +176,32 @@ public class SchedulerServiceImpl implements SchedulerService {
} }
List<ProcessTaskRelation> processTaskRelationList = dagData.getProcessTaskRelationList(); List<ProcessTaskRelation> processTaskRelationList = dagData.getProcessTaskRelationList();
List<TaskDefinition> taskDefinitionList = dagData.getTaskDefinitionList(); List<TaskDefinition> taskDefinitionList = dagData.getTaskDefinitionList();
List<DagNodeLocation> locations = process.getLocations(); List<DagNodeLocation> locations = JSONUtil.toList(process.getLocations(), DagNodeLocation.class);
if (CollUtil.isNotEmpty(process.getLocations())) { if (CollUtil.isNotEmpty(locations)) {
boolean matched = process.getLocations().stream().anyMatch(location -> location.getTaskCode() == taskCode); boolean matched = locations.stream().anyMatch(location -> location.getTaskCode() == taskCode);
// if not matched, add a new location
if (!matched) {
// 获取最大的 x y 坐标 // 获取最大的 x y 坐标
long xMax = process.getLocations().stream() long xMax =
.mapToLong(DagNodeLocation::getX) locations.stream().mapToLong(DagNodeLocation::getX).max().getAsLong();
.max()
.getAsLong(); long yMax =
long xMin = process.getLocations().stream() locations.stream().mapToLong(DagNodeLocation::getY).max().getAsLong();
.mapToLong(DagNodeLocation::getX)
.min() // if not matched, add a new location
.getAsLong(); if (matched) {
long yMax = process.getLocations().stream()
.mapToLong(DagNodeLocation::getY)
.max()
.getAsLong();
long yMin = process.getLocations().stream()
.mapToLong(DagNodeLocation::getY)
.min()
.getAsLong();
// 随机出一个 x y 坐标 // 随机出一个 x y 坐标
DagNodeLocation dagNodeLocation = new DagNodeLocation(); DagNodeLocation dagNodeLocation = new DagNodeLocation();
dagNodeLocation.setTaskCode(taskCode); dagNodeLocation.setTaskCode(taskCode);
dagNodeLocation.setX(RandomUtil.randomLong(xMin == xMax ? 0 : xMin, xMax)); dagNodeLocation.setX(RandomUtil.randomLong(xMax - 200, xMax));
dagNodeLocation.setY(RandomUtil.randomLong(yMin == yMax ? 0 : yMin, yMax)); dagNodeLocation.setY(RandomUtil.randomLong(yMax - 150, yMax));
locations = process.getLocations();
locations.add(dagNodeLocation); locations.add(dagNodeLocation);
} }
} else { } else {
// 随机出一个 x y 坐标 // 随机出一个 x y 坐标
DagNodeLocation dagNodeLocation = new DagNodeLocation(); DagNodeLocation dagNodeLocation = new DagNodeLocation();
dagNodeLocation.setTaskCode(taskCode); dagNodeLocation.setTaskCode(taskCode);
dagNodeLocation.setX(RandomUtil.randomLong(200, 500)); dagNodeLocation.setX(RandomUtil.randomLong(200, 800));
dagNodeLocation.setY(RandomUtil.randomLong(100, 400)); dagNodeLocation.setY(RandomUtil.randomLong(100, 600));
locations.add(dagNodeLocation); locations.add(dagNodeLocation);
} }
......
...@@ -46,6 +46,7 @@ import cn.hutool.core.util.StrUtil; ...@@ -46,6 +46,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
/** /**
* 工作流定义 * 工作流定义
...@@ -88,7 +89,7 @@ public class ProcessClient { ...@@ -88,7 +89,7 @@ public class ProcessClient {
ProcessDefinition processDefinition = MyJSONUtil.toBean(jsonObject, ProcessDefinition.class); ProcessDefinition processDefinition = MyJSONUtil.toBean(jsonObject, ProcessDefinition.class);
// The locations of processDefinition is json string // The locations of processDefinition is json string
List<DagNodeLocation> locations = jsonObject.getBeanList("locations", DagNodeLocation.class); List<DagNodeLocation> locations = jsonObject.getBeanList("locations", DagNodeLocation.class);
processDefinition.setLocations(locations); processDefinition.setLocations(JSONUtil.toJsonStr(locations));
lists.add(processDefinition); lists.add(processDefinition);
} }
return lists; return lists;
......
...@@ -21,9 +21,15 @@ package org.dinky.scheduler.model; ...@@ -21,9 +21,15 @@ package org.dinky.scheduler.model;
import java.io.Serializable; import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
@Data @Data
@AllArgsConstructor(onConstructor = @__(@JsonCreator))
@NoArgsConstructor
public class DagNodeLocation implements Serializable { public class DagNodeLocation implements Serializable {
private static final long serialVersionUID = -5243356147439794746L; private static final long serialVersionUID = -5243356147439794746L;
......
...@@ -23,7 +23,6 @@ import org.dinky.scheduler.enums.Flag; ...@@ -23,7 +23,6 @@ import org.dinky.scheduler.enums.Flag;
import org.dinky.scheduler.enums.ProcessExecutionTypeEnum; import org.dinky.scheduler.enums.ProcessExecutionTypeEnum;
import org.dinky.scheduler.enums.ReleaseState; import org.dinky.scheduler.enums.ReleaseState;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -88,7 +87,7 @@ public class ProcessDefinition { ...@@ -88,7 +87,7 @@ public class ProcessDefinition {
private String projectName; private String projectName;
@ApiModelProperty(value = "位置") @ApiModelProperty(value = "位置")
private List<DagNodeLocation> locations = new ArrayList<>(); private String locations;
@ApiModelProperty(value = "计划发布状态 online/offline") @ApiModelProperty(value = "计划发布状态 online/offline")
private ReleaseState scheduleReleaseState; private ReleaseState scheduleReleaseState;
......
...@@ -17,17 +17,17 @@ ...@@ -17,17 +17,17 @@
* *
*/ */
import {Card, Typography} from 'antd'; import { Card, Typography } from 'antd';
const {Text, Paragraph} = Typography; const { Text, Paragraph } = Typography;
const DagPlanNode = (props: any) => { const DagPlanNode = (props: any) => {
const {node} = props; const { node } = props;
const data: any = node?.getData(); const data: any = node?.getData();
return ( return (
<Card <Card
style={{width: 270, padding: 0, margin: 0, height: 140}} style={{ width: 270, padding: 0, margin: 0, height: 140 }}
bordered={false} bordered={false}
size={'small'} size={'small'}
type={'inner'} type={'inner'}
...@@ -37,9 +37,10 @@ const DagPlanNode = (props: any) => { ...@@ -37,9 +37,10 @@ const DagPlanNode = (props: any) => {
> >
<Paragraph <Paragraph
ellipsis={{ ellipsis={{
tooltip: {title: data.description, zIndex: 2000}, tooltip: { title: data.description, zIndex: 2000 },
rows: 3 rows: 3
}}> }}
>
<blockquote> <blockquote>
<Text>{data.description}</Text> <Text>{data.description}</Text>
</blockquote> </blockquote>
......
...@@ -58,7 +58,7 @@ export const BOOLEAN_VALUE_ENUM: DefaultOptionType[] = [ ...@@ -58,7 +58,7 @@ export const BOOLEAN_VALUE_ENUM: DefaultOptionType[] = [
export const AlertRules: any = { export const AlertRules: any = {
jobName: { jobName: {
label: l('sys.alert.rule.label.taskId'), label: l('sys.alert.rule.label.taskId'),
valueType: OperatorType.NUMBER_VALUE, valueType: OperatorType.NUMBER_VALUE
}, },
duration: { duration: {
label: l('sys.alert.rule.label.duration'), label: l('sys.alert.rule.label.duration'),
...@@ -81,7 +81,7 @@ export const AlertRules: any = { ...@@ -81,7 +81,7 @@ export const AlertRules: any = {
}, },
checkpointCostTime: { checkpointCostTime: {
label: l('sys.alert.rule.label.checkpointTime'), label: l('sys.alert.rule.label.checkpointTime'),
valueType: OperatorType.NUMBER_VALUE, valueType: OperatorType.NUMBER_VALUE
}, },
isCheckpointFailed: { isCheckpointFailed: {
label: l('sys.alert.rule.label.checkpointFailed'), label: l('sys.alert.rule.label.checkpointFailed'),
......
...@@ -66,13 +66,14 @@ export const buildValueItem = (key: string, isSystem: boolean) => { ...@@ -66,13 +66,14 @@ export const buildValueItem = (key: string, isSystem: boolean) => {
/> />
); );
case OperatorType.STR_VALUE: case OperatorType.STR_VALUE:
return <ProFormText width={'sm'} disabled={isSystem} name={'ruleValue'} placeholder={plh} />; return (
<ProFormText width={'sm'} disabled={isSystem} name={'ruleValue'} placeholder={plh} />
);
case OperatorType.OPTIONS_SEL: case OperatorType.OPTIONS_SEL:
return ( return (
<ProFormSelect <ProFormSelect
width={'sm'} width={'sm'}
disabled={isSystem} disabled={isSystem}
width={'sm'}
name='ruleValue' name='ruleValue'
mode={'single'} mode={'single'}
placeholder={plh} placeholder={plh}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment