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 4ae2dcd3
authored
Sep 11, 2023
by
tiger
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
sop / tpl
1 parent
bb3aee2e
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
190 deletions
platform-process/src/main/java/cn/com/glsx/process/config/WebConfig.java
platform-process/src/main/java/cn/com/glsx/process/job/DynamicConfig.java
platform-process/src/main/java/cn/com/glsx/process/job/DynamicTaskAdd.java
platform-process/src/main/java/cn/com/glsx/process/job/instance/DynamicJob.java
platform-process/src/main/java/cn/com/glsx/process/modules/api/SopTplApiController.java → platform-process/src/main/java/cn/com/glsx/process/modules/api/SopApiController.java
platform-process/src/main/java/cn/com/glsx/process/modules/controller/AdminController.java
platform-process/src/main/java/cn/com/glsx/process/modules/controller/TestJobController.java
platform-process/src/main/resources/application.properties_standalone
platform-process/src/main/java/cn/com/glsx/process/config/WebConfig.java
View file @
4ae2dcd
...
...
@@ -67,8 +67,6 @@ public class WebConfig implements WebMvcConfigurer {
.
excludePathPatterns
(
"/"
)
.
excludePathPatterns
(
"/login"
)
.
excludePathPatterns
(
"/actuator/**"
)
.
excludePathPatterns
(
"/*.shtml"
)
.
excludePathPatterns
(
"/admin/**"
)
.
excludePathPatterns
(
"/api/**"
)
.
excludePathPatterns
(
"/sop/**"
)
.
excludePathPatterns
(
uploadProperties
.
getFilepath
())
...
...
platform-process/src/main/java/cn/com/glsx/process/job/DynamicConfig.java
View file @
4ae2dcd
package
cn
.
com
.
glsx
.
process
.
job
;
import
com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration
;
import
com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration
;
import
com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter
;
@Configuration
public
class
DynamicConfig
{
@Value
(
"${elaticjob.zookeeper.dynamiczk}"
)
private
String
dynamiczk
;
@Value
(
"${elaticjob.zookeeper.namespace}"
)
private
String
dynamicnamespace
;
@Value
(
"${elaticjob.zookeeper.dynamiczk}"
)
private
String
dynamiczk
;
@Value
(
"${elaticjob.zookeeper.namespace}"
)
private
String
dynamicnamespace
;
@Bean
public
ZookeeperConfiguration
zookeeperConfiguration
()
{
return
new
ZookeeperConfiguration
(
dynamiczk
,
dynamicnamespace
);
}
@Bean
public
ZookeeperConfiguration
zookeeperConfiguration
()
{
return
new
ZookeeperConfiguration
(
dynamiczk
,
dynamicnamespace
);
}
@Bean
(
initMethod
=
"init"
)
public
ZookeeperRegistryCenter
zookeeperRegistryCenter
(
ZookeeperConfiguration
zookeeperConfiguration
)
{
return
new
ZookeeperRegistryCenter
(
zookeeperConfiguration
);
}
@Bean
(
initMethod
=
"init"
)
public
ZookeeperRegistryCenter
zookeeperRegistryCenter
(
ZookeeperConfiguration
zookeeperConfiguration
)
{
return
new
ZookeeperRegistryCenter
(
zookeeperConfiguration
);
}
}
platform-process/src/main/java/cn/com/glsx/process/job/DynamicTaskAdd.java
View file @
4ae2dcd
package
cn
.
com
.
glsx
.
process
.
job
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
com.dangdang.ddframe.job.api.simple.SimpleJob
;
import
com.dangdang.ddframe.job.config.JobCoreConfiguration
;
import
com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration
;
import
com.dangdang.ddframe.job.lite.config.LiteJobConfiguration
;
import
com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler
;
import
com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
@Component
public
class
DynamicTaskAdd
{
@Autowired
private
ZookeeperRegistryCenter
zookeeperRegistryCenter
;
/***
* 动态创建定时任务
* @param jobName:定时任务名称
* @param cron:表达式
* @param shardingTotalCount:分片数量
* @param instance:定时任务实例
* @param parameters:参数
*/
public
void
create
(
String
jobName
,
String
cron
,
int
shardingTotalCount
,
SimpleJob
instance
,
String
parameters
){
LiteJobConfiguration
.
Builder
builder
=
LiteJobConfiguration
.
newBuilder
(
new
SimpleJobConfiguration
(
JobCoreConfiguration
.
newBuilder
(
jobName
,
cron
,
shardingTotalCount
).
jobParameter
(
parameters
).
build
(),
instance
.
getClass
().
getName
()
)).
overwrite
(
true
);
LiteJobConfiguration
liteJobConfiguration
=
builder
.
build
();
new
SpringJobScheduler
(
instance
,
zookeeperRegistryCenter
,
liteJobConfiguration
).
init
();
}
@Autowired
private
ZookeeperRegistryCenter
zookeeperRegistryCenter
;
/***
* 动态创建定时任务
*
* @param jobName:定时任务名称
* @param cron:表达式
* @param shardingTotalCount:分片数量
* @param instance:定时任务实例
* @param parameters:参数
*/
public
void
create
(
String
jobName
,
String
cron
,
int
shardingTotalCount
,
SimpleJob
instance
,
String
parameters
)
{
LiteJobConfiguration
.
Builder
builder
=
LiteJobConfiguration
.
newBuilder
(
new
SimpleJobConfiguration
(
JobCoreConfiguration
.
newBuilder
(
jobName
,
cron
,
shardingTotalCount
).
jobParameter
(
parameters
).
build
(),
instance
.
getClass
().
getName
()))
.
overwrite
(
true
);
LiteJobConfiguration
liteJobConfiguration
=
builder
.
build
();
new
SpringJobScheduler
(
instance
,
zookeeperRegistryCenter
,
liteJobConfiguration
).
init
();
}
}
platform-process/src/main/java/cn/com/glsx/process/job/instance/DynamicJob.java
View file @
4ae2dcd
...
...
@@ -5,11 +5,11 @@ import com.dangdang.ddframe.job.api.simple.SimpleJob;
public
class
DynamicJob
implements
SimpleJob
{
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
// 参数
String
JobParameter
=
shardingContext
.
getJobParameter
();
System
.
out
.
println
(
"---------DynamicJob-------------:"
+
JobParameter
);
}
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
// 参数
String
JobParameter
=
shardingContext
.
getJobParameter
();
System
.
out
.
println
(
"---------DynamicJob-------------:"
+
JobParameter
);
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/api/Sop
Tpl
ApiController.java
→
platform-process/src/main/java/cn/com/glsx/process/modules/api/SopApiController.java
View file @
4ae2dcd
...
...
@@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.RestController;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
cn.com.glsx.echocenter.api.EchoCenterFeignClient
;
import
cn.com.glsx.process.modules.model.inst.SopStruct
;
import
cn.com.glsx.process.modules.service.SopService
;
import
io.swagger.v3.oas.annotations.Operation
;
...
...
@@ -20,18 +19,15 @@ import lombok.extern.slf4j.Slf4j;
* @author kome
*/
@Slf4j
@Tag
(
name
=
"sop
模板
"
)
@Tag
(
name
=
"sop
服务
"
)
@RestController
@RequestMapping
(
value
=
"/sop
/sop-tpl
"
)
@RequestMapping
(
value
=
"/sop"
)
@ResponseResultBody
public
class
Sop
Tpl
ApiController
{
public
class
SopApiController
{
@Resource
private
SopService
sopService
;
@Resource
private
EchoCenterFeignClient
echoCenterFeignClient
;
@Operation
(
summary
=
"查询实例"
)
@GetMapping
(
value
=
"/inst/{instId}"
)
public
SopStruct
inst
(
@PathVariable
(
"instId"
)
String
instId
)
{
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/controller/AdminController.java
deleted
100644 → 0
View file @
bb3aee2
package
cn
.
com
.
glsx
.
process
.
modules
.
controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
/**
* 通用访问拦截匹配
* 创建者 科帮网
* 创建时间 2018年4月3日
*/
@Controller
@RequestMapping
(
value
=
"/admin"
)
public
class
AdminController
{
/**
* 页面跳转
*
* @param url
* @return
*/
@RequestMapping
(
"/{url}.shtml"
)
public
String
page
(
@PathVariable
(
"url"
)
String
url
)
{
return
url
;
}
/**
* 页面跳转(二级目录)
*
* @param module
* @param url
* @return
*/
@RequestMapping
(
"/{module}/{url}.shtml"
)
public
String
page
(
@PathVariable
(
"module"
)
String
module
,
@PathVariable
(
"url"
)
String
url
)
{
return
module
+
"/"
+
url
;
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/controller/TestJobController.java
View file @
4ae2dcd
package
cn
.
com
.
glsx
.
process
.
modules
.
controller
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
cn.com.glsx.process.job.DynamicTaskAdd
;
import
cn.com.glsx.process.job.instance.DynamicJob
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
@Slf4j
@Tag
(
name
=
"动态任务(Demo)"
)
...
...
@@ -16,15 +21,15 @@ import org.springframework.web.bind.annotation.*;
@ResponseResultBody
public
class
TestJobController
{
@Autowired
private
DynamicTaskAdd
dynamicTaskAdd
;
@Autowired
private
DynamicTaskAdd
dynamicTaskAdd
;
@GetMapping
(
"/jobtest"
)
@Operation
(
summary
=
"动态任务添加"
,
description
=
"动态任务添加"
)
public
void
test
(
@RequestParam
(
"cron"
)
String
cron
)
{
// cron表达式
dynamicTaskAdd
.
create
(
"job001"
,
cron
,
1
,
new
DynamicJob
(),
"test"
);
@GetMapping
(
"/jobtest"
)
@Operation
(
summary
=
"动态任务添加"
,
description
=
"动态任务添加"
)
public
void
test
(
@RequestParam
(
"cron"
)
String
cron
)
{
// cron表达式
dynamicTaskAdd
.
create
(
"job001"
,
cron
,
1
,
new
DynamicJob
(),
"test"
);
}
}
}
platform-process/src/main/resources/application.properties_standalone
View file @
4ae2dcd
s
pring.application.name=process
logging.path=/data/java_log/jetty/${spring.application.name}/${spring.application.name}.log
s
erver.port=9823
server.servlet.context-path=/process
#server
server.port=8202
server.servlet.context-path=/${spring.application.name}
server.servlet.session.timeout=2592000
server.max-http-header-size=8192
server.tomcat.uri-encoding=UTF-8
server.tomcat.max-threads=1000
server.tomcat.min-spare-threads=30s
server.tomcat.basedir=/temp
#database
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.1.136:3306/sop_process?serverTimeZone=Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false
# database
spring.datasource.url=jdbc:mysql://192.168.3.227:3306/platform_process?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=123456
# Hikari will use the above plus the following to setup connection pooling
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=15
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
spring.data.redis.repositories.enabled = false
#redis config
spring.redis.host=192.168.0.39
spring.redis.port=6379
spring.redis.password=hhxredis
spring.redis.database=1
spring.redis.timeout=200000
#jwt config
jwt.config.header=Authorization
jwt.config.ttl=7200
jwt.config.key=5371f568a45e5ab1f442c38e0932aef24447139c
# session最大超时时间(分钟),默认为30
server.session-timeout=60
# tomcat最大线程数,默认为200
server.tomcat.max-threads=100
# tomcat的URI编码
server.tomcat.uri-encoding=UTF-8
# 静态文件请求匹配方式
spring.mvc.static-path-pattern=/**
#spring.thymeleaf.mode=LEGACYHTML5
#spring boot 2.x 参数变化
spring.thymeleaf.mode=HTML
#dev tools
spring.devtools.livereload.enabled=true
spring.thymeleaf.cache=false
spring.thymeleaf.cache-period=0
spring.thymeleaf.template.cache=false
# quartz任务配置
spring.quartz.job-store-type=jdbc
spring.quartz.properties.org.quartz.scheduler.instanceName=clusteredScheduler
spring.quartz.properties.org.quartz.scheduler.instanceId=AUTO
spring.quartz.properties.org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
spring.quartz.properties.org.quartz.jobStore.dataSource=quartzDataSource
spring.quartz.properties.org.quartz.jobStore.tablePrefix=QRTZ_
# 打开集群配置
spring.quartz.properties.org.quartz.jobStore.isClustered=true
# 设置集群检查间隔100s
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval=10000
spring.quartz.properties.org.quartz.jobStore.useProperties=false
spring.quartz.properties.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
spring.quartz.properties.org.quartz.threadPool.threadCount=10
spring.quartz.properties.org.quartz.threadPool.threadPriority=5
spring.quartz.properties.org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread=true
spring.datasource.password=manager
elaticjob.zookeeper.server-lists=192.168.3.101:2181
elaticjob.zookeeper.dynamiczk=192.168.3.101:2181
elaticjob.zookeeper.namespace=glsx_sop
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