用raphael画一个流程图,将流程图的数据变成有层级的json类型,传给Conductor
我现在需要做一个编排器,前端的页面是自定义的,可以拖动服务和逻辑判断;
当前用raphael自定义出来一个流程图,可是raphael的数据结构是这样的:
{
"nodes":[
{
"nodecode":"DEV001",
"nodetype":"first",
"nodestat":{
"main":0
},
"nodedesc":"",
"nodename":"开始",
"posx":478,
"posy":160
},
{
"nodecode":"DEV002",
"nodetype":"end",
"nodestat":{
"main":0
},
"nodedesc":"",
"nodename":"结束",
"posx":478,
"posy":260
},
{
"nodecode":"rest_1r1",
"nodetype":"first",
"nodestat":{
"main":0
},
"nodedesc":"",
"nodename":"服务1",
"posx":437,
"posy":161
},
{
"nodecode":"asyn_1a1",
"nodetype":"first",
"nodestat":{
"main":0
},
"nodedesc":"",
"nodename":"逻辑判断",
"posx":477,
"posy":227
},
{
"nodecode":"rest_2r1",
"nodetype":"first",
"nodestat":{
"main":0
},
"nodedesc":"",
"nodename":"服务2",
"posx":467,
"posy":395
},
{
"nodecode":"rest_3r1",
"nodetype":"first",
"nodestat":{
"main":0
},
"nodedesc":"",
"nodename":"服务3",
"posx":327,
"posy":264
},
{
"nodecode":"asyn_2a1",
"nodetype":"first",
"nodestat":{
"main":0
},
"nodedesc":"",
"nodename":"并行处理开始",
"posx":300,
"posy":240
},
{
"nodecode":"rest_6r1",
"nodetype":"first",
"nodestat":{
"main":0
},
"nodedesc":"",
"nodename":"服务6",
"posx":211,
"posy":405
},
{
"nodecode":"rest_5r1",
"nodetype":"first",
"nodestat":{
"main":0
},
"nodedesc":"",
"nodename":"服务5",
"posx":355,
"posy":389
},
{
"nodecode":"asyn_3a1",
"nodetype":"first",
"nodestat":{
"main":0
},
"nodedesc":"",
"nodename":"并行处理结束",
"posx":278,
"posy":476
}
],
"lines":[
{
"linecode":"",
"linedesc":"",
"lineend":"rest_1r1",
"linestart":"DEV001",
"linestat":{
"main":0
},
"sys":""
},
{
"linecode":"",
"linedesc":"",
"lineend":"asyn_1a1",
"linestart":"rest_1r1",
"linestat":{
"main":0
},
"sys":""
},
{
"linecode":"",
"linedesc":"是",
"lineend":"rest_3r1",
"linestart":"asyn_1a1",
"linestat":{
"main":0
},
"sys":""
},
{
"linecode":"",
"linedesc":"",
"lineend":"asyn_2a1",
"linestart":"rest_3r1",
"linestat":{
"main":0
},
"sys":""
},
{
"linecode":"",
"linedesc":"",
"lineend":"rest_6r1",
"linestart":"asyn_2a1",
"linestat":{
"main":0
},
"sys":""
},
{
"linecode":"",
"linedesc":"",
"lineend":"rest_5r1",
"linestart":"asyn_2a1",
"linestat":{
"main":0
},
"sys":""
},
{
"linecode":"",
"linedesc":"",
"lineend":"asyn_3a1",
"linestart":"rest_5r1",
"linestat":{
"main":0
},
"sys":""
},
{
"linecode":"",
"linedesc":"",
"lineend":"asyn_3a1",
"linestart":"rest_6r1",
"linestat":{
"main":0
},
"sys":""
},
{
"linecode":"",
"linedesc":"否",
"lineend":"rest_2r1",
"linestart":"asyn_1a1",
"linestat":{
"main":0
},
"sys":""
},
{
"linecode":"",
"linedesc":"",
"lineend":"DEV002",
"linestart":"rest_2r1",
"linestat":{
"main":0
},
"sys":""
}
]
}
但是conductor接收的json数据类型是下面这种格式的 是有层级关系的
{
"name": "exampleFlow",
"description": "an test flow including flow control structure",
"version": 1,
"tasks": [{
"name": "peRcheckScore",
"taskReferenceName": "peRcheckScore1",
"inputParameters": {
"AccessLinkCode": "${workflow.input.AccessLinkCode}"
},
"type": "SUB_WORKFLOW",
"subWorkflowParam": {
"name": "peRcheckScore",
"version": 1
}
}, {
"name": "sys_DECISION",
"taskReferenceName": "sys_DECISION1",
"inputParameters": {
"score": "${peRcheckScore1.output.score}"
},
"type": "DECISION",
"caseExpression": "$.score > 90",
"decisionCases": {
"true": [{
"name": "mplsVpnLinkFlux",
"taskReferenceName": "mplsVpnLinkFlux1",
"inputParameters": {
"http_request": {
"uri": "",
"method": "POST",
"body": {
"AccessLinkCode": "${workflow.input.AccessLinkCode}"
}
}
},
"type": "HTTP"
}, {
"name": "sys_FORK_JOIN",
"taskReferenceName": "sys_fork_join1",
"type": "FORK_JOIN",
"forkTasks": [
[{
"name": "DeviceQuery",
"taskReferenceName": "DeviceQuery1",
"inputParameters": {
"http_request": {
"uri": "",
"method": "POST",
"body": {
"DeviceName": "${peRcheckScore1.output.DeviceName}"
}
}
},
"type": "HTTP"
}],
[{
"name": "DevIpQry",
"taskReferenceName": "DevIpQry1",
"inputParameters": {
"http_request": {
"uri": "",
"method": "POST",
"body": {
"Ip": "${peRcheckScore1.output.PEIntIP}"
}
}
},
"type": "HTTP"
}],
[{
"name": "getBGPRoute",
"taskReferenceName": "getBGPRoute1",
"inputParameters": {
"http_request": {
"uri": "",
"method": "POST",
"body": {
"prefix": "208.67.73.0/24"
}
}
},
"type": "HTTP"
}]
]
}, {
"name": "sys_JOIN",
"taskReferenceName": "sys_JOIN1",
"type": "JOIN",
"joinOn": ["DeviceQuery1", "DevIpQry1", "getBGPRoute1"]
}],
"false": [{
"name": "DevCutQry",
"taskReferenceName": "DevCutQry1",
"inputParameters": {
"http_request": {
"uri": "",
"method": "POST",
"body": {
"DevName": "${peRcheckScore1.output.DeviceName}"
}
}
},
"type": "HTTP"
}]
}
}, {
"name": "DevCutQry",
"taskReferenceName": "DevCutQry2",
"inputParameters": {
"http_request": {
"uri": "",
"method": "POST",
"body": {
"DevName": "${peRcheckScore1.output.DeviceName}"
}
}
},
"type": "HTTP"
}],
"inputParameters": ["AccessLinkCode"],
"outputParameters": {
"score": "${peRcheckScore1.output.score}"
},
"schemaVersion": 2
}
请问有什么思路可以将raphael的数据转化为conductor接收的json格式的思路或者方方法吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论