Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibztask
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibztask
提交
f85b75ad
提交
f85b75ad
编写于
6月 19, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
数据库id换varchar
上级
aa5b40b7
变更
8
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
97 行增加
和
33 行删除
+97
-33
JobsInfoServiceEx.java
...cn/ibizlab/core/extensions.service/JobsInfoServiceEx.java
+4
-3
JobsInfo.java
...e/src/main/java/cn/ibizlab/core/task/domain/JobsInfo.java
+5
-5
JobsLock.java
...e/src/main/java/cn/ibizlab/core/task/domain/JobsLock.java
+1
-1
JobsLog.java
...re/src/main/java/cn/ibizlab/core/task/domain/JobsLog.java
+1
-1
JobsRegistry.java
...c/main/java/cn/ibizlab/core/task/domain/JobsRegistry.java
+1
-1
JobsServiceImpl.java
...va/cn/ibizlab/core/task/service/impl/JobsServiceImpl.java
+20
-18
20200619061521_changelog.xml
...esources/liquibase/changelog/20200619061521_changelog.xml
+61
-0
JobsInfoDTO.java
...der-api/src/main/java/cn/ibizlab/api/dto/JobsInfoDTO.java
+4
-4
未找到文件。
ibztask-core/src/main/java/cn/ibizlab/core/extensions.service/JobsInfoServiceEx.java
浏览文件 @
f85b75ad
...
...
@@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
import
org.springframework.context.annotation.Primary
;
import
java.math.BigInteger
;
import
java.sql.Timestamp
;
/**
* 实体[任务信息] 自定义服务对象
...
...
@@ -41,7 +42,7 @@ public class JobsInfoServiceEx extends JobsInfoServiceImpl {
if
(
null
==
dbJobInfo
)
{
throw
new
BadRequestAlertException
(
"未找到任务"
,
"JobsInfo"
,
""
);
}
JobsTrigger
.
trigger
(
et
.
getId
().
longValue
(
),
TriggerTypeEnum
.
MANUAL
,
-
1
,
dbJobInfo
.
getParam
());
JobsTrigger
.
trigger
(
Long
.
parseLong
(
et
.
getId
()
),
TriggerTypeEnum
.
MANUAL
,
-
1
,
dbJobInfo
.
getParam
());
return
super
.
execute
(
et
);
}
...
...
@@ -53,12 +54,12 @@ public class JobsInfoServiceEx extends JobsInfoServiceImpl {
}
et
.
setStatus
(
0
);
et
.
setLastTime
(
new
BigInteger
(
"0"
)
);
et
.
setLastTime
(
0L
);
if
(!
JobsHelper
.
cronValidate
(
dbJobInfo
.
getCron
()))
throw
new
BadRequestAlertException
(
"CRON 表达式不可用"
,
"JobsInfo"
,
dbJobInfo
.
getCron
());
// next trigger time (10s后生效,避开预读周期)
et
.
setNextTime
(
BigInteger
.
valueOf
(
JobsHelper
.
cronNextTime
(
dbJobInfo
.
getCron
())
+
10000
)
);
et
.
setNextTime
(
JobsHelper
.
cronNextTime
(
dbJobInfo
.
getCron
())
+
10000
);
this
.
update
(
et
);
return
et
;
}
...
...
ibztask-core/src/main/java/cn/ibizlab/core/task/domain/JobsInfo.java
浏览文件 @
f85b75ad
...
...
@@ -43,7 +43,7 @@ public class JobsInfo extends EntityMP implements Serializable {
* 主键ID
*/
@DEField
(
isKeyField
=
true
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_
UU
ID
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_ID
)
@JSONField
(
name
=
"id"
)
@JsonProperty
(
"id"
)
private
String
id
;
...
...
@@ -106,7 +106,7 @@ public class JobsInfo extends EntityMP implements Serializable {
@TableField
(
value
=
"last_time"
)
@JSONField
(
name
=
"last_time"
)
@JsonProperty
(
"last_time"
)
private
BigInteger
lastTime
;
private
Long
lastTime
;
/**
* 下次调度时间
*/
...
...
@@ -114,7 +114,7 @@ public class JobsInfo extends EntityMP implements Serializable {
@TableField
(
value
=
"next_time"
)
@JSONField
(
name
=
"next_time"
)
@JsonProperty
(
"next_time"
)
private
BigInteger
nextTime
;
private
Long
nextTime
;
/**
* 所有者
*/
...
...
@@ -216,7 +216,7 @@ public class JobsInfo extends EntityMP implements Serializable {
/**
* 设置 [上次调度时间]
*/
public
void
setLastTime
(
BigInteger
lastTime
){
public
void
setLastTime
(
Long
lastTime
){
this
.
lastTime
=
lastTime
;
this
.
modify
(
"last_time"
,
lastTime
);
}
...
...
@@ -224,7 +224,7 @@ public class JobsInfo extends EntityMP implements Serializable {
/**
* 设置 [下次调度时间]
*/
public
void
setNextTime
(
BigInteger
nextTime
){
public
void
setNextTime
(
Long
nextTime
){
this
.
nextTime
=
nextTime
;
this
.
modify
(
"next_time"
,
nextTime
);
}
...
...
ibztask-core/src/main/java/cn/ibizlab/core/task/domain/JobsLock.java
浏览文件 @
f85b75ad
...
...
@@ -43,7 +43,7 @@ public class JobsLock extends EntityMP implements Serializable {
* 主键ID
*/
@DEField
(
isKeyField
=
true
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_
UU
ID
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_ID
)
@JSONField
(
name
=
"id"
)
@JsonProperty
(
"id"
)
private
String
id
;
...
...
ibztask-core/src/main/java/cn/ibizlab/core/task/domain/JobsLog.java
浏览文件 @
f85b75ad
...
...
@@ -43,7 +43,7 @@ public class JobsLog extends EntityMP implements Serializable {
* 主键ID
*/
@DEField
(
isKeyField
=
true
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_
UU
ID
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_ID
)
@JSONField
(
name
=
"id"
)
@JsonProperty
(
"id"
)
private
String
id
;
...
...
ibztask-core/src/main/java/cn/ibizlab/core/task/domain/JobsRegistry.java
浏览文件 @
f85b75ad
...
...
@@ -43,7 +43,7 @@ public class JobsRegistry extends EntityMP implements Serializable {
* 主键ID
*/
@DEField
(
isKeyField
=
true
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_
UU
ID
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_ID
)
@JSONField
(
name
=
"id"
)
@JsonProperty
(
"id"
)
private
String
id
;
...
...
ibztask-core/src/main/java/cn/ibizlab/core/task/service/impl/JobsServiceImpl.java
浏览文件 @
f85b75ad
...
...
@@ -8,6 +8,7 @@ import cn.ibizlab.core.task.service.IJobsLockService;
import
cn.ibizlab.core.task.service.IJobsLogService
;
import
cn.ibizlab.core.task.service.IJobsRegistryService
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.baomidou.jobs.JobsClock
;
import
com.baomidou.jobs.model.JobsInfo
;
import
com.baomidou.jobs.model.JobsLog
;
...
...
@@ -19,7 +20,8 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.math.BigInteger
;
//import java.math.BigInteger;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -49,7 +51,7 @@ public class JobsServiceImpl implements IJobsService {
jobsRegistry
.
setApp
(
registryParam
.
getApp
());
jobsRegistry
.
setAddress
(
registryParam
.
getAddress
());
jobsRegistry
.
setStatus
(
registryParam
.
getRegisterStatusEnum
().
getValue
());
jobsRegistry
.
setUpdateTime
(
BigInteger
.
valueOf
(
JobsClock
.
currentTimeMillis
()));
jobsRegistry
.
setUpdateTime
(
new
Timestamp
(
JobsClock
.
currentTimeMillis
()));
int
ret
=
jobsRegistryService
.
getBaseMapper
().
update
(
jobsRegistry
,
Wrappers
.<
JobsRegistry
>
lambdaQuery
().
eq
(
JobsRegistry:
:
getApp
,
registryParam
.
getApp
())
...
...
@@ -65,7 +67,7 @@ public class JobsServiceImpl implements IJobsService {
public
List
<
JobsInfo
>
getJobsInfoList
(
long
nextTime
)
{
List
<
cn
.
ibizlab
.
core
.
task
.
domain
.
JobsInfo
>
list
=
jobsInfoService
.
list
(
Wrappers
.<
cn
.
ibizlab
.
core
.
task
.
domain
.
JobsInfo
>
lambdaQuery
()
.
eq
(
cn
.
ibizlab
.
core
.
task
.
domain
.
JobsInfo
::
getStatus
,
0
)
.
le
(
cn
.
ibizlab
.
core
.
task
.
domain
.
JobsInfo
::
getNextTime
,
BigInteger
.
valueOf
(
nextTime
)
));
.
le
(
cn
.
ibizlab
.
core
.
task
.
domain
.
JobsInfo
::
getNextTime
,
nextTime
));
List
<
JobsInfo
>
ret
=
new
ArrayList
<>();
list
.
forEach
(
obj
->
ret
.
add
(
change
(
obj
)));
return
ret
;
...
...
@@ -86,7 +88,7 @@ public class JobsServiceImpl implements IJobsService {
JobsLock
lock
=
new
JobsLock
();
lock
.
setName
(
name
);
lock
.
setOwner
(
owner
);
lock
.
setCreateTime
(
BigInteger
.
valueOf
(
JobsClock
.
currentTimeMillis
()));
lock
.
setCreateTime
(
new
Timestamp
(
JobsClock
.
currentTimeMillis
()));
return
jobsLockService
.
getBaseMapper
().
insert
(
lock
)>
0
;
}
...
...
@@ -101,7 +103,7 @@ public class JobsServiceImpl implements IJobsService {
JobsRegistry
jobsRegistry
=
new
JobsRegistry
();
jobsRegistry
.
setStatus
(
1
);
if
(
jobsRegistryService
.
update
(
jobsRegistry
,
Wrappers
.<
JobsRegistry
>
lambdaQuery
()
.
eq
(
JobsRegistry:
:
getStatus
,
0
).
le
(
JobsRegistry:
:
getUpdateTime
,
BigInteger
.
valueOf
(
JobsClock
.
currentTimeMillis
()
-
timeout
))))
.
eq
(
JobsRegistry:
:
getStatus
,
0
).
le
(
JobsRegistry:
:
getUpdateTime
,
new
Timestamp
(
JobsClock
.
currentTimeMillis
()
-
timeout
))))
return
1
;
return
0
;
}
...
...
@@ -152,15 +154,15 @@ public class JobsServiceImpl implements IJobsService {
jobsInfo
.
setTenantId
(
et
.
getTenantId
());
jobsInfo
.
setTimeout
(
et
.
getTimeout
());
if
(
et
.
getId
()!=
null
)
jobsInfo
.
setId
(
et
.
getId
().
longValue
(
));
jobsInfo
.
setId
(
DataObject
.
getLongValue
(
et
.
getId
(),
et
.
getCreateTime
().
getTime
()
));
if
(
et
.
getLastTime
()!=
null
)
jobsInfo
.
setLastTime
(
et
.
getLastTime
()
.
longValue
()
);
jobsInfo
.
setLastTime
(
et
.
getLastTime
());
if
(
et
.
getNextTime
()!=
null
)
jobsInfo
.
setNextTime
(
et
.
getNextTime
()
.
longValue
()
);
jobsInfo
.
setNextTime
(
et
.
getNextTime
());
if
(
et
.
getCreateTime
()!=
null
)
jobsInfo
.
setCreateTime
(
et
.
getCreateTime
().
longValu
e
());
jobsInfo
.
setCreateTime
(
et
.
getCreateTime
().
getTim
e
());
if
(
et
.
getUpdateTime
()!=
null
)
jobsInfo
.
setUpdateTime
(
et
.
getUpdateTime
().
longValu
e
());
jobsInfo
.
setUpdateTime
(
et
.
getUpdateTime
().
getTim
e
());
return
jobsInfo
;
}
...
...
@@ -180,15 +182,15 @@ public class JobsServiceImpl implements IJobsService {
jobsInfo
.
setTenantId
(
et
.
getTenantId
());
jobsInfo
.
setTimeout
(
et
.
getTimeout
());
if
(
et
.
getId
()!=
null
)
jobsInfo
.
setId
(
BigInteger
.
valueOf
(
et
.
getId
())
);
jobsInfo
.
setId
(
et
.
getId
()+
""
);
if
(
et
.
getLastTime
()!=
null
)
jobsInfo
.
setLastTime
(
BigInteger
.
valueOf
(
et
.
getLastTime
()
));
jobsInfo
.
setLastTime
(
et
.
getLastTime
(
));
if
(
et
.
getNextTime
()!=
null
)
jobsInfo
.
setNextTime
(
BigInteger
.
valueOf
(
et
.
getNextTime
()
));
jobsInfo
.
setNextTime
(
et
.
getNextTime
(
));
if
(
et
.
getCreateTime
()!=
null
)
jobsInfo
.
setCreateTime
(
BigInteger
.
valueOf
(
et
.
getCreateTime
()));
jobsInfo
.
setCreateTime
(
new
Timestamp
(
et
.
getCreateTime
()));
if
(
et
.
getUpdateTime
()!=
null
)
jobsInfo
.
setUpdateTime
(
BigInteger
.
valueOf
(
et
.
getUpdateTime
()));
jobsInfo
.
setUpdateTime
(
new
Timestamp
(
et
.
getUpdateTime
()));
return
jobsInfo
;
}
...
...
@@ -206,11 +208,11 @@ public class JobsServiceImpl implements IJobsService {
jobsLog
.
setTriggerMsg
(
et
.
getTriggerMsg
());
jobsLog
.
setTriggerType
(
et
.
getTriggerType
());
if
(
et
.
getId
()!=
null
)
jobsLog
.
setId
(
BigInteger
.
valueOf
(
et
.
getId
())
);
jobsLog
.
setId
(
et
.
getId
()+
""
);
if
(
et
.
getCreateTime
()!=
null
)
jobsLog
.
setCreateTime
(
BigInteger
.
valueOf
(
et
.
getCreateTime
()));
jobsLog
.
setCreateTime
(
new
Timestamp
(
et
.
getCreateTime
()));
if
(
et
.
getJobId
()!=
null
)
jobsLog
.
setJobId
(
BigInteger
.
valueOf
(
et
.
getJobId
())
);
jobsLog
.
setJobId
(
et
.
getJobId
()+
""
);
return
jobsLog
;
}
}
ibztask-core/src/main/resources/liquibase/changelog/20200619061521_changelog.xml
0 → 100644
浏览文件 @
f85b75ad
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
xmlns=
"http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext=
"http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:pro=
"http://www.liquibase.org/xml/ns/pro"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.8.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd"
>
<changeSet
author=
"sq3536 (generated)"
id=
"1592547336291-1"
>
<createTable
tableName=
"JOBS_INFO"
>
<column
name=
"ID"
type=
"VARCHAR(100)"
>
<constraints
nullable=
"false"
primaryKey=
"true"
primaryKeyName=
"PK_JOBS_INFO_ID"
/>
</column>
<column
name=
"TENANT_ID"
type=
"VARCHAR(100)"
/>
<column
name=
"APP"
type=
"VARCHAR(100)"
/>
<column
name=
"CRON"
type=
"VARCHAR(100)"
/>
<column
name=
"HANDLER"
type=
"VARCHAR(255)"
/>
<column
name=
"PARAM"
type=
"VARCHAR(512)"
/>
<column
name=
"TIMEOUT"
type=
"INT"
/>
<column
name=
"FAIL_RETRY_COUNT"
type=
"INT"
/>
<column
name=
"LAST_TIME"
type=
"BIGINT"
/>
<column
name=
"NEXT_TIME"
type=
"BIGINT"
/>
<column
name=
"AUTHOR"
type=
"VARCHAR(30)"
/>
<column
name=
"REMARK"
type=
"VARCHAR(30)"
/>
<column
name=
"STATUS"
type=
"INT"
/>
<column
name=
"UPDATE_TIME"
type=
"TIMESTAMP"
/>
<column
name=
"CREATE_TIME"
type=
"TIMESTAMP"
/>
</createTable>
</changeSet>
<changeSet
author=
"sq3536 (generated)"
id=
"1592547336291-2"
>
<createTable
tableName=
"JOBS_LOCK"
>
<column
name=
"ID"
type=
"VARCHAR(100)"
>
<constraints
nullable=
"false"
primaryKey=
"true"
primaryKeyName=
"PK_JOBS_LOCK_ID"
/>
</column>
<column
name=
"NAME"
type=
"VARCHAR(30)"
/>
<column
name=
"OWNER"
type=
"VARCHAR(100)"
/>
<column
name=
"CREATE_TIME"
type=
"TIMESTAMP"
/>
</createTable>
</changeSet>
<changeSet
author=
"sq3536 (generated)"
id=
"1592547336291-3"
>
<createTable
tableName=
"JOBS_LOG"
>
<column
name=
"ID"
type=
"VARCHAR(100)"
>
<constraints
nullable=
"false"
primaryKey=
"true"
primaryKeyName=
"PK_JOBS_LOG_ID"
/>
</column>
<column
name=
"JOB_ID"
type=
"VARCHAR(100)"
/>
<column
name=
"ADDRESS"
type=
"VARCHAR(255)"
/>
<column
name=
"HANDLER"
type=
"VARCHAR(255)"
/>
<column
name=
"PARAM"
type=
"VARCHAR(512)"
/>
<column
name=
"FAIL_RETRY_COUNT"
type=
"INT"
/>
<column
name=
"TRIGGER_CODE"
type=
"INT"
/>
<column
name=
"TRIGGER_TYPE"
type=
"VARCHAR(30)"
/>
<column
name=
"TRIGGER_MSG"
type=
"CLOB"
/>
<column
name=
"CREATE_TIME"
type=
"TIMESTAMP"
/>
</createTable>
</changeSet>
<changeSet
author=
"sq3536 (generated)"
id=
"1592547336291-4"
>
<createTable
tableName=
"JOBS_REGISTRY"
>
<column
name=
"ID"
type=
"VARCHAR(100)"
>
<constraints
nullable=
"false"
primaryKey=
"true"
primaryKeyName=
"PK_JOBS_REGISTRY_ID"
/>
</column>
<column
name=
"APP"
type=
"VARCHAR(100)"
/>
<column
name=
"ADDRESS"
type=
"VARCHAR(255)"
/>
<column
name=
"STATUS"
type=
"INT"
/>
<column
name=
"UPDATE_TIME"
type=
"TIMESTAMP"
/>
</createTable>
</changeSet>
</databaseChangeLog>
ibztask-provider/ibztask-provider-api/src/main/java/cn/ibizlab/api/dto/JobsInfoDTO.java
浏览文件 @
f85b75ad
...
...
@@ -93,7 +93,7 @@ public class JobsInfoDTO extends DTOBase implements Serializable {
*/
@JSONField
(
name
=
"last_time"
)
@JsonProperty
(
"last_time"
)
private
BigInteger
lastTime
;
private
Long
lastTime
;
/**
* 属性 [NEXT_TIME]
...
...
@@ -101,7 +101,7 @@ public class JobsInfoDTO extends DTOBase implements Serializable {
*/
@JSONField
(
name
=
"next_time"
)
@JsonProperty
(
"next_time"
)
private
BigInteger
nextTime
;
private
Long
nextTime
;
/**
* 属性 [AUTHOR]
...
...
@@ -205,7 +205,7 @@ public class JobsInfoDTO extends DTOBase implements Serializable {
/**
* 设置 [LAST_TIME]
*/
public
void
setLastTime
(
BigInteger
lastTime
){
public
void
setLastTime
(
Long
lastTime
){
this
.
lastTime
=
lastTime
;
this
.
modify
(
"last_time"
,
lastTime
);
}
...
...
@@ -213,7 +213,7 @@ public class JobsInfoDTO extends DTOBase implements Serializable {
/**
* 设置 [NEXT_TIME]
*/
public
void
setNextTime
(
BigInteger
nextTime
){
public
void
setNextTime
(
Long
nextTime
){
this
.
nextTime
=
nextTime
;
this
.
modify
(
"next_time"
,
nextTime
);
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录