Skip to content

Commit

Permalink
Fix push ds locations bug (DataLinkDC#2807)
Browse files Browse the repository at this point in the history
* fix-push-ds-locations-bug

* Spotless Apply

---------

Co-authored-by: Zzm0809 <[email protected]>
  • Loading branch information
Zzm0809 and Zzm0809 authored Dec 26, 2023
1 parent ccfc44e commit c861202
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ public boolean pushAddTask(DinkyTaskRequest dinkyTaskRequest) {

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);
Expand Down Expand Up @@ -176,43 +176,32 @@ private void updateProcessDefinition(ProcessDefinition process, Long taskCode, T
}
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

/**
* 工作流定义
Expand Down Expand Up @@ -88,7 +89,7 @@ public List<ProcessDefinition> getProcessDefinition(Long projectCode, String pro
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit c861202

Please sign in to comment.