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