Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-process-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 99045d10
authored
Nov 06, 2023
by
周海宝
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'v1.0.1' into 'master'
V1.0.1 See merge request
!2
2 parents
a353e50b
ed2065c2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
12 deletions
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/core/SopXxlJobUtil.java
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/core/XxlJobUtil.java
platform-process/src/main/java/cn/com/glsx/process/modules/controller/SopInstController.java
platform-process/src/main/java/cn/com/glsx/process/modules/controller/TestXXLJobController.java
platform-process/src/test/java/cn/com/glsx/test/service/TestSopService.java
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/core/SopXxlJobUtil.java
View file @
99045d1
...
@@ -218,7 +218,18 @@ public class SopXxlJobUtil {
...
@@ -218,7 +218,18 @@ public class SopXxlJobUtil {
}
}
// 隐藏任务执行:
// 隐藏任务执行:
String
jobBusId
=
jobBusId
(
sop
.
getInst
(),
node
);
String
jobBusId
=
jobBusId
(
sop
.
getInst
(),
node
);
XxlJobUtil
.
trigger
(
jobBusId
);
// 前置节点,后置节点
Pair
<
Set
<
Integer
>,
Set
<
Integer
>>
linkPair
=
sop
.
getInstLinkMap
().
get
(
node
.
getNodeId
());
SopInstNodeParam
params
=
new
SopInstNodeParam
();
params
.
setInstId
(
node
.
getInstId
());
params
.
setNodeId
(
node
.
getNodeId
());
params
.
setPreIds
(
linkPair
.
getKey
());
params
.
setNextIds
(
linkPair
.
getValue
());
String
paramJson
=
JSONUtil
.
toJsonStr
(
params
);
XxlJobUtil
.
trigger
(
jobBusId
,
paramJson
);
log
.
info
(
"【{}】手动触发隐藏任务:{} - {}"
,
jobBusId
,
node
.
getNodeName
(),
node
.
getNodeCron
());
log
.
info
(
"【{}】手动触发隐藏任务:{} - {}"
,
jobBusId
,
node
.
getNodeName
(),
node
.
getNodeCron
());
list
.
add
(
node
.
getNodeName
());
list
.
add
(
node
.
getNodeName
());
}
}
...
...
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/core/XxlJobUtil.java
View file @
99045d1
...
@@ -142,10 +142,10 @@ public class XxlJobUtil {
...
@@ -142,10 +142,10 @@ public class XxlJobUtil {
* @param buskey 业务key
* @param buskey 业务key
* @return {@link String}
* @return {@link String}
**/
**/
public
static
String
trigger
(
String
buskey
)
{
public
static
String
trigger
(
String
buskey
,
String
params
)
{
XxlJobInfo
byBusKey
=
findByBusKey
(
buskey
);
XxlJobInfo
byBusKey
=
findByBusKey
(
buskey
);
if
(
byBusKey
!=
null
)
{
if
(
byBusKey
!=
null
)
{
return
doPost
(
adminAddresses
+
ADD_AND_START_URL
+
"?id="
+
byBusKey
.
getId
(),
null
,
String
.
class
);
return
doPost
(
adminAddresses
+
ADD_AND_START_URL
+
"?id="
+
byBusKey
.
getId
(),
params
,
String
.
class
);
}
}
return
null
;
return
null
;
}
}
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/controller/SopInstController.java
View file @
99045d1
package
cn
.
com
.
glsx
.
process
.
modules
.
controller
;
package
cn
.
com
.
glsx
.
process
.
modules
.
controller
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -76,10 +77,14 @@ public class SopInstController extends BaseController {
...
@@ -76,10 +77,14 @@ public class SopInstController extends BaseController {
return
sopInstService
.
customerDetail
(
search
);
return
sopInstService
.
customerDetail
(
search
);
}
}
@Operation
(
summary
=
"根据id查询SOP门店模板实例详情
"
,
description
=
"根据id查询SOP门店模板实例详情
"
)
@Operation
(
summary
=
"根据id查询SOP门店模板实例详情
(无快照信息)"
,
description
=
"根据id查询SOP门店模板实例详情(无快照信息)
"
)
@GetMapping
(
"/{instId}"
)
@GetMapping
(
"/{instId}"
)
public
SopInstDTO
findById
(
@PathVariable
(
"instId"
)
String
instId
)
{
public
SopInstDTO
findById
(
@PathVariable
(
"instId"
)
String
instId
)
{
return
sopInstService
.
findById
(
instId
);
SopInstDTO
instDTO
=
sopInstService
.
findById
(
instId
);
if
(
Objects
.
nonNull
(
instDTO
))
{
instDTO
.
setInstSnapshot
(
null
);
}
return
instDTO
;
}
}
@Operation
(
summary
=
"更新SOP门店模板实例初始参数里的门店自定义参数(关联活动)"
,
description
=
"更新SOP门店模板实例初始参数里的门店自定义参数(关联活动)"
)
@Operation
(
summary
=
"更新SOP门店模板实例初始参数里的门店自定义参数(关联活动)"
,
description
=
"更新SOP门店模板实例初始参数里的门店自定义参数(关联活动)"
)
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/controller/TestXXLJobController.java
View file @
99045d1
package
cn
.
com
.
glsx
.
process
.
modules
.
controller
;
package
cn
.
com
.
glsx
.
process
.
modules
.
controller
;
import
cn.com.glsx.process.common.sysenum.ResultEnum
;
import
cn.com.glsx.process.exception.AdminException
;
import
com.glsx.plat.exception.BusinessException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
@@ -13,8 +10,11 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -13,8 +10,11 @@ import org.springframework.web.bind.annotation.RestController;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
import
cn.com.glsx.process.common.sysenum.ResultEnum
;
import
cn.com.glsx.process.exception.AdminException
;
import
cn.com.glsx.process.job.xxljob.core.XxlJobInfo
;
import
cn.com.glsx.process.job.xxljob.core.XxlJobInfo
;
import
cn.com.glsx.process.job.xxljob.core.XxlJobUtil
;
import
cn.com.glsx.process.job.xxljob.core.XxlJobUtil
;
import
cn.com.glsx.process.job.xxljob.impl.SopInstNodeExecuteJobHandler
;
import
cn.com.glsx.process.modules.service.UserDemoService
;
import
cn.com.glsx.process.modules.service.UserDemoService
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
...
@@ -29,10 +29,13 @@ public class TestXXLJobController {
...
@@ -29,10 +29,13 @@ public class TestXXLJobController {
@Autowired
@Autowired
private
UserDemoService
userDemoService
;
private
UserDemoService
userDemoService
;
@Autowired
private
SopInstNodeExecuteJobHandler
nodeExecutor
;
@GetMapping
(
"/jobtest"
)
@GetMapping
(
"/jobtest"
)
@Operation
(
summary
=
"动态任务添加"
,
description
=
"动态任务添加"
)
@Operation
(
summary
=
"动态任务添加"
,
description
=
"动态任务添加"
)
public
void
addtest
(
@RequestParam
(
"cron"
)
String
cron
,
@RequestParam
(
"jobName"
)
String
jobName
,
@RequestParam
(
"param"
)
String
param
,
@RequestParam
(
"executorHandler"
)
String
executorHandler
,
@RequestParam
(
"busKey"
)
String
busKey
)
{
public
void
addtest
(
@RequestParam
(
"cron"
)
String
cron
,
@RequestParam
(
"jobName"
)
String
jobName
,
@RequestParam
(
"param"
)
String
param
,
@RequestParam
(
"executorHandler"
)
String
executorHandler
,
@RequestParam
(
"busKey"
)
String
busKey
)
{
// cron表达式
// cron表达式
XxlJobInfo
jobInfo
=
new
XxlJobInfo
();
XxlJobInfo
jobInfo
=
new
XxlJobInfo
();
jobInfo
.
setExecutorParam
(
param
);
jobInfo
.
setExecutorParam
(
param
);
...
@@ -46,7 +49,10 @@ public class TestXXLJobController {
...
@@ -46,7 +49,10 @@ public class TestXXLJobController {
@PostMapping
(
"/jobtestupdate"
)
@PostMapping
(
"/jobtestupdate"
)
@Operation
(
summary
=
"动态任务更新"
,
description
=
"动态任务更新"
)
@Operation
(
summary
=
"动态任务更新"
,
description
=
"动态任务更新"
)
public
void
updatetest
(
@RequestParam
(
value
=
"cron"
,
required
=
false
)
String
cron
,
@RequestParam
(
"id"
)
String
id
,
@RequestParam
(
value
=
"executorParam"
,
required
=
false
)
String
executorParam
,
@RequestParam
(
value
=
"jobDesc"
,
required
=
false
)
String
jobDesc
,
@RequestParam
(
value
=
"triggerStatus"
,
required
=
false
)
Integer
triggerStatus
)
{
public
void
updatetest
(
@RequestParam
(
value
=
"cron"
,
required
=
false
)
String
cron
,
@RequestParam
(
"id"
)
String
id
,
@RequestParam
(
value
=
"executorParam"
,
required
=
false
)
String
executorParam
,
@RequestParam
(
value
=
"jobDesc"
,
required
=
false
)
String
jobDesc
,
@RequestParam
(
value
=
"triggerStatus"
,
required
=
false
)
Integer
triggerStatus
)
{
XxlJobInfo
jobInfo
=
new
XxlJobInfo
();
XxlJobInfo
jobInfo
=
new
XxlJobInfo
();
jobInfo
.
setBusKey
(
id
);
jobInfo
.
setBusKey
(
id
);
jobInfo
.
setScheduleConf
(
cron
);
jobInfo
.
setScheduleConf
(
cron
);
...
@@ -77,7 +83,7 @@ public class TestXXLJobController {
...
@@ -77,7 +83,7 @@ public class TestXXLJobController {
@PostMapping
(
"/trigger"
)
@PostMapping
(
"/trigger"
)
@Operation
(
summary
=
"动态任务触发"
,
description
=
"动态任务触发"
)
@Operation
(
summary
=
"动态任务触发"
,
description
=
"动态任务触发"
)
public
void
trigger
(
@RequestParam
(
"id"
)
String
id
)
{
public
void
trigger
(
@RequestParam
(
"id"
)
String
id
)
{
XxlJobUtil
.
trigger
(
id
);
XxlJobUtil
.
trigger
(
id
,
null
);
}
}
@PostMapping
(
"/findBybusKey"
)
@PostMapping
(
"/findBybusKey"
)
...
@@ -94,4 +100,11 @@ public class TestXXLJobController {
...
@@ -94,4 +100,11 @@ public class TestXXLJobController {
}
}
return
R
.
ok
().
data
(
userDemoService
.
testJava
(
busKey
));
return
R
.
ok
().
data
(
userDemoService
.
testJava
(
busKey
));
}
}
@PostMapping
(
"/testExecutor"
)
@Operation
(
summary
=
"测试Executor"
,
description
=
"动态任务触发"
)
public
R
testNodeExecutor
(
@RequestParam
(
"json"
)
String
json
)
throws
Exception
{
nodeExecutor
.
handler
(
json
);
return
R
.
ok
();
}
}
}
platform-process/src/test/java/cn/com/glsx/test/service/TestSopService.java
View file @
99045d1
package
cn
.
com
.
glsx
.
test
.
service
;
package
cn
.
com
.
glsx
.
test
.
service
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -8,9 +7,11 @@ import org.springframework.boot.test.context.SpringBootTest;
...
@@ -8,9 +7,11 @@ import org.springframework.boot.test.context.SpringBootTest;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
cn.com.glsx.Application
;
import
cn.com.glsx.Application
;
import
cn.com.glsx.process.job.xxljob.impl.SopInstNodeExecuteJobHandler
;
import
cn.com.glsx.process.modules.model.SopStruct
;
import
cn.com.glsx.process.modules.model.SopStruct
;
import
cn.com.glsx.process.modules.service.SopService
;
import
cn.com.glsx.process.modules.service.SopService
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
lombok.extern.slf4j.Slf4j
;
/**
/**
* 测试spring cloud 服务调用方式
* 测试spring cloud 服务调用方式
...
@@ -23,6 +24,9 @@ public class TestSopService {
...
@@ -23,6 +24,9 @@ public class TestSopService {
@Autowired
@Autowired
private
SopService
sopService
;
private
SopService
sopService
;
@Autowired
private
SopInstNodeExecuteJobHandler
job
;
@Test
@Test
public
void
test
()
{
public
void
test
()
{
String
instId
=
"xblc7"
;
String
instId
=
"xblc7"
;
...
@@ -30,5 +34,16 @@ public class TestSopService {
...
@@ -30,5 +34,16 @@ public class TestSopService {
System
.
out
.
println
(
JSONUtil
.
toJsonStr
(
sop
));
System
.
out
.
println
(
JSONUtil
.
toJsonStr
(
sop
));
}
}
@Test
public
void
testNode
()
{
try
{
String
json
=
"{\"preIds\":[2],\"finishedIds\":[2],\"instId\":\"xblc172\",\"nextIds\":[9],\"nodeId\":12}"
;
job
.
handler
(
json
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment