提交 f85b75ad 编写于 作者: sq3536's avatar sq3536

数据库id换varchar

上级 aa5b40b7
......@@ -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;
}
......
......@@ -43,7 +43,7 @@ public class JobsInfo extends EntityMP implements Serializable {
* 主键ID
*/
@DEField(isKeyField=true)
@TableId(value= "id",type=IdType.ASSIGN_UUID)
@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);
}
......
......@@ -43,7 +43,7 @@ public class JobsLock extends EntityMP implements Serializable {
* 主键ID
*/
@DEField(isKeyField=true)
@TableId(value= "id",type=IdType.ASSIGN_UUID)
@TableId(value= "id",type=IdType.ASSIGN_ID)
@JSONField(name = "id")
@JsonProperty("id")
private String id;
......
......@@ -43,7 +43,7 @@ public class JobsLog extends EntityMP implements Serializable {
* 主键ID
*/
@DEField(isKeyField=true)
@TableId(value= "id",type=IdType.ASSIGN_UUID)
@TableId(value= "id",type=IdType.ASSIGN_ID)
@JSONField(name = "id")
@JsonProperty("id")
private String id;
......
......@@ -43,7 +43,7 @@ public class JobsRegistry extends EntityMP implements Serializable {
* 主键ID
*/
@DEField(isKeyField=true)
@TableId(value= "id",type=IdType.ASSIGN_UUID)
@TableId(value= "id",type=IdType.ASSIGN_ID)
@JSONField(name = "id")
@JsonProperty("id")
private String id;
......
......@@ -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().longValue());
jobsInfo.setCreateTime(et.getCreateTime().getTime());
if(et.getUpdateTime()!=null)
jobsInfo.setUpdateTime(et.getUpdateTime().longValue());
jobsInfo.setUpdateTime(et.getUpdateTime().getTime());
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;
}
}
<?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>
......@@ -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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册