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 2a6f1ef6
authored
Oct 31, 2023
by
tiger
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
单元测试
1 parent
ed2065c2
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
144 additions
and
22 deletions
.gitignore
platform-process/pom.xml
platform-process/src/main/java/cn/com/glsx/Application.java
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/impl/SopInstNodeExecuteJobHandler.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/JavaExecutor.java
platform-process/src/main/resources/application.properties_standalone
platform-process/src/main/resources/bootstrap.properties
platform-process/src/test/java/cn/com/glsx/AppDemo2.java
platform-process/src/test/java/cn/com/glsx/test/service/TestSopService.java
.gitignore
View file @
2a6f1ef
...
@@ -10,3 +10,4 @@
...
@@ -10,3 +10,4 @@
*.name
*.name
/platform-process-api/*.factorypath
/platform-process-api/*.factorypath
/platform-process/*.path_IS_UNDEFINED
/platform-process/*.path_IS_UNDEFINED
/platform-process/logs/platform-process/*.log
platform-process/pom.xml
View file @
2a6f1ef
...
@@ -35,6 +35,10 @@
...
@@ -35,6 +35,10 @@
<groupId>
log4j
</groupId>
<groupId>
log4j
</groupId>
<artifactId>
log4j
</artifactId>
<artifactId>
log4j
</artifactId>
</exclusion>
</exclusion>
<exclusion>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
</exclusion>
</exclusions>
</exclusions>
</dependency>
</dependency>
...
...
platform-process/src/main/java/cn/com/glsx/Application.java
View file @
2a6f1ef
package
cn
.
com
.
glsx
;
package
cn
.
com
.
glsx
;
import
cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil
;
import
static
java
.
time
.
ZoneId
.
of
;
import
com.glsx.plat.context.EnableRestAdmin
;
import
static
java
.
util
.
TimeZone
.
getTimeZone
;
import
java.util.TimeZone
;
import
javax.annotation.PostConstruct
;
import
org.apache.dubbo.config.spring.context.annotation.EnableDubbo
;
import
org.apache.dubbo.config.spring.context.annotation.EnableDubbo
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
...
@@ -12,11 +17,9 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
...
@@ -12,11 +17,9 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
import
org.springframework.context.annotation.EnableAspectJAutoProxy
;
import
org.springframework.context.annotation.EnableAspectJAutoProxy
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
javax.annotation.PostConstruct
;
import
com.glsx.plat.context.EnableRestAdmin
;
import
java.util.TimeZone
;
import
static
java
.
time
.
ZoneId
.
of
;
import
cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil
;
import
static
java
.
util
.
TimeZone
.
getTimeZone
;
/**
/**
* @author payu
* @author payu
...
@@ -28,6 +31,7 @@ import static java.util.TimeZone.getTimeZone;
...
@@ -28,6 +31,7 @@ import static java.util.TimeZone.getTimeZone;
@SpringBootApplication
@SpringBootApplication
@EnableAspectJAutoProxy
@EnableAspectJAutoProxy
@EnableTransactionManagement
@EnableTransactionManagement
// @PropertySource("application.properties_standalone")
public
class
Application
implements
CommandLineRunner
{
public
class
Application
implements
CommandLineRunner
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/impl/SopInstNodeExecuteJobHandler.java
View file @
2a6f1ef
...
@@ -37,7 +37,7 @@ public class SopInstNodeExecuteJobHandler {
...
@@ -37,7 +37,7 @@ public class SopInstNodeExecuteJobHandler {
@XxlJob
(
SopXxlJobUtil
.
SOP_NODE_EXECUTE_JOB_ID
)
@XxlJob
(
SopXxlJobUtil
.
SOP_NODE_EXECUTE_JOB_ID
)
public
void
handler
(
String
param1
)
throws
Exception
{
public
void
handler
(
String
param1
)
throws
Exception
{
String
json
=
XxlJobHelper
.
getJobParam
(
);
String
json
=
ObjectUtil
.
defaultIfNull
(
XxlJobHelper
.
getJobParam
(),
param1
);
SopInstNodeParam
param
=
JacksonUtils
.
fromJson
(
json
,
SopInstNodeParam
.
class
);
SopInstNodeParam
param
=
JacksonUtils
.
fromJson
(
json
,
SopInstNodeParam
.
class
);
SopXxlJobUtil
.
log
(
log
,
"【执行Sop节点】{}"
,
param
);
SopXxlJobUtil
.
log
(
log
,
"【执行Sop节点】{}"
,
param
);
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/JavaExecutor.java
View file @
2a6f1ef
...
@@ -29,6 +29,13 @@ public class JavaExecutor implements SopNodeExecutor {
...
@@ -29,6 +29,13 @@ public class JavaExecutor implements SopNodeExecutor {
JSONObject
paramMap
=
JSON
.
parseObject
(
nodeContent
);
JSONObject
paramMap
=
JSON
.
parseObject
(
nodeContent
);
String
javacode
=
paramMap
.
get
(
"source"
)
+
""
;
String
javacode
=
paramMap
.
get
(
"source"
)
+
""
;
// if (StringUtils.isNotEmpty(javacode)) {
// javacode = javacode
// .replace("console.info(", "console.info(\"" + mcgWebScoketCode + "\", \"" + httpSessionId + "\", \"" + flowId + "\", ")
// .replace("console.success(", "console.success(\"" + mcgWebScoketCode + "\", \"" + httpSessionId + "\", \"" + flowId + "\", ")
// .replace("console.error(", "console.error(\"" + mcgWebScoketCode + "\", \"" + httpSessionId + "\", \"" + flowId + "\", ");
// }
// java参数处理,执行java
// java参数处理,执行java
DynamicEngine
de
=
DynamicEngine
.
getInstance
();
DynamicEngine
de
=
DynamicEngine
.
getInstance
();
...
@@ -48,6 +55,7 @@ public class JavaExecutor implements SopNodeExecutor {
...
@@ -48,6 +55,7 @@ public class JavaExecutor implements SopNodeExecutor {
return
instance
;
return
instance
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
SopXxlJobUtil
.
log
(
log
,
"【{}】{}"
,
getClass
().
getSimpleName
(),
e
.
getMessage
(),
e
);
SopXxlJobUtil
.
log
(
log
,
"【{}】{}"
,
getClass
().
getSimpleName
(),
e
.
getMessage
(),
e
);
e
.
printStackTrace
();
}
}
return
null
;
return
null
;
...
...
platform-process/src/main/resources/application.properties_standalone
View file @
2a6f1ef
server.port=9823
server.port=9823
server.servlet.context-path=/process
server.servlet.context-path=/process
#配置服务中心,原则上用那个nacos配置中心就注册到那个nacos
spring.cloud.nacos.discovery.server-addr=192.168.3.239:8868
#spring.cloud.nacos.discovery.server-addr=nacos2.dev.glsx.com:8868
spring.cloud.nacos.discovery.group=platform
# database
# database
spring.datasource.url=jdbc:mysql://192.168.3.222:3308/platform_process
_dev
?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&allowMultiQueries=true
spring.datasource.url=jdbc:mysql://192.168.3.222:3308/platform_process?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&allowMultiQueries=true
spring.datasource.username=user_zhouhb
spring.datasource.username=user_zhouhb
spring.datasource.password=WoWP7N1u
spring.datasource.password=WoWP7N1u
elaticjob.zookeeper.server-lists=192.168.3.101:2181
xxl.job.admin.addresses=http://192.168.3.34:8080/xxl-job-admin
elaticjob.zookeeper.dynamiczk=192.168.3.101:2181
elaticjob.zookeeper.namespace=glsx_sop
xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin
xxl.job.accessToken=default_token
xxl.job.accessToken=default_token
xxl.job.executor.appname=xxl-job-executor-
test
xxl.job.executor.appname=xxl-job-executor-
sample
xxl.job.executor.address=
xxl.job.executor.address=
xxl.job.executor.ip=
127.0.0.1
xxl.job.executor.ip=
xxl.job.executor.port=
8080
xxl.job.executor.port=
9999
xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler
xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler
xxl.job.executor.logretentiondays=30
xxl.job.executor.logretentiondays=30
xxl.job.executor.groupId=1
xxl.job.executor.groupId=1
# redis配置
spring.redis.host=192.168.3.207
spring.redis.port=6379
spring.redis.password=
spring.redis.database=0
spring.redis.timeout=200000
spring.data.redis.repositories.enabled=false
server:
port: 8080
#admin 监控配置 暴露所有端点 可以取消自己看效果
management.endpoints.web.exposure.include=*
management.endpoints.health.show-details=always
#sba服务器上显示的客户端名称
spring.boot.admin.client.url=http://192.168.3.102:8188
spring.boot.admin.client.instance.prefer-ip=true
spring.boot.admin.client.instance.name=${spring.application.name}
logging.file.name=logs/${spring.application.name}/${spring.application.name}.log
spring.zipkin.base-url=http://192.168.0.63:9411/zipkin/
spring.zipkin.sleuth.sampler.probability=1
spring.zipkin.sender.type=web
logging.level.org.springframework.web.servlet.DispatcherServlet=DEBUG
spring.cloud.sentinel.transport.port=8719
spring.cloud.sentinel.transport.dashboard=http://192.168.0.63:8718/
spring.cloud.sentinel.eager=true
#feign sentinel
feign.sentinel.enabled=false
#mybatis config
mybatis.mapperLocations=classpath:mapper/*.xml
mybatis.configuration.map-underscore-to-camel-case=true
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
# rabbitmq 配置
spring.rabbitmq.host=192.168.3.34
spring.rabbitmq.port=5672
spring.rabbitmq.username=admin
spring.rabbitmq.password=glsx#0926
spring.rabbitmq.publisher-confirm-type=correlated
spring.rabbitmq.listener.simple.acknowledge-mode=manual
# 这个比较重要
spring.rabbitmq.virtual-host=/
elaticjob.zookeeper.server-lists=192.168.3.101:2181
elaticjob.zookeeper.dynamiczk=192.168.3.101:2181
elaticjob.zookeeper.namespace=glsx_sop
#feign config
feign.enable=true
feign.httpclient.enabled=false
feign.shopmall.name=platform-process
feign.shopmall.path=/process
# 跨域配置
ore.adapter.cross-domain=true
ore.adapter.allowed-origins=http://192.168.1.155:6650
platform-process/src/main/resources/bootstrap.properties
View file @
2a6f1ef
...
@@ -9,7 +9,7 @@ logging.path=/data/java_log/jetty/${spring.application.name}/${spring.applicatio
...
@@ -9,7 +9,7 @@ logging.path=/data/java_log/jetty/${spring.application.name}/${spring.applicatio
#spring.cloud.nacos.discovery.enabled=false
#spring.cloud.nacos.discovery.enabled=false
#spring.cloud.nacos.discovery.instance-enabled=false
#spring.cloud.nacos.discovery.instance-enabled=false
spring.cloud.nacos.config.server-
addr
=
192.168.
0.63
:8868
spring.cloud.nacos.config.server-
addr
=
192.168.
3.239
:8868
spring.cloud.nacos.config.group
=
platform
spring.cloud.nacos.config.group
=
platform
spring.cloud.nacos.config.prefix
=
${spring.application.name}
spring.cloud.nacos.config.prefix
=
${spring.application.name}
...
...
platform-process/src/test/java/cn/com/glsx/AppDemo2.java
0 → 100644
View file @
2a6f1ef
package
cn
.
com
.
glsx
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
cn.com.glsx.process.job.xxljob.impl.SopInstNodeExecuteJobHandler
;
import
cn.com.glsx.process.modules.service.SopService
;
import
lombok.extern.slf4j.Slf4j
;
@SpringBootTest
(
classes
=
Application
.
class
)
@Slf4j
public
class
AppDemo2
{
@Autowired
private
SopService
sopService
;
@Autowired
private
SopInstNodeExecuteJobHandler
job
;
@Test
public
void
test
()
{
// String instId = "xblc174";
// SopStruct sop = sopService.loadSop(instId);
// System.out.println(JSONUtil.toJsonStr(sop));
}
@Test
public
void
testNode
()
{
try
{
String
json
=
"{\"preIds\":[2],\"finishedIds\":[2],\"instId\":\"xblc174\",\"nextIds\":[9],\"nodeId\":12}"
;
job
.
handler
(
json
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
\ No newline at end of file
platform-process/src/test/java/cn/com/glsx/test/service/TestSopService.java
View file @
2a6f1ef
package
cn
.
com
.
glsx
.
test
.
service
;
package
cn
.
com
.
glsx
.
test
.
service
;
import
org.junit.Test
;
import
org.junit.jupiter.api.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
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.job.xxljob.impl.SopInstNodeExecuteJobHandler
;
...
@@ -16,7 +14,6 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -16,7 +14,6 @@ import lombok.extern.slf4j.Slf4j;
/**
/**
* 测试spring cloud 服务调用方式
* 测试spring cloud 服务调用方式
*/
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
Application
.
class
)
@SpringBootTest
(
classes
=
Application
.
class
)
@Slf4j
@Slf4j
public
class
TestSopService
{
public
class
TestSopService
{
...
...
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