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

数据库id换varchar

上级 aa5b40b7
...@@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import java.math.BigInteger; import java.math.BigInteger;
import java.sql.Timestamp;
/** /**
* 实体[任务信息] 自定义服务对象 * 实体[任务信息] 自定义服务对象
...@@ -41,7 +42,7 @@ public class JobsInfoServiceEx extends JobsInfoServiceImpl { ...@@ -41,7 +42,7 @@ public class JobsInfoServiceEx extends JobsInfoServiceImpl {
if (null == dbJobInfo) { if (null == dbJobInfo) {
throw new BadRequestAlertException("未找到任务","JobsInfo",""); 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); return super.execute(et);
} }
...@@ -53,12 +54,12 @@ public class JobsInfoServiceEx extends JobsInfoServiceImpl { ...@@ -53,12 +54,12 @@ public class JobsInfoServiceEx extends JobsInfoServiceImpl {
} }
et.setStatus(0); et.setStatus(0);
et.setLastTime(new BigInteger("0")); et.setLastTime(0L);
if(!JobsHelper.cronValidate(dbJobInfo.getCron())) if(!JobsHelper.cronValidate(dbJobInfo.getCron()))
throw new BadRequestAlertException("CRON 表达式不可用","JobsInfo",dbJobInfo.getCron()); throw new BadRequestAlertException("CRON 表达式不可用","JobsInfo",dbJobInfo.getCron());
// next trigger time (10s后生效,避开预读周期) // next trigger time (10s后生效,避开预读周期)
et.setNextTime(BigInteger.valueOf(JobsHelper.cronNextTime(dbJobInfo.getCron()) + 10000)); et.setNextTime(JobsHelper.cronNextTime(dbJobInfo.getCron()) + 10000);
this.update(et); this.update(et);
return et; return et;
} }
......
...@@ -43,7 +43,7 @@ public class JobsInfo extends EntityMP implements Serializable { ...@@ -43,7 +43,7 @@ public class JobsInfo extends EntityMP implements Serializable {
* 主键ID * 主键ID
*/ */
@DEField(isKeyField=true) @DEField(isKeyField=true)
@TableId(value= "id",type=IdType.ASSIGN_UUID) @TableId(value= "id",type=IdType.ASSIGN_ID)
@JSONField(name = "id") @JSONField(name = "id")
@JsonProperty("id") @JsonProperty("id")
private String id; private String id;
...@@ -106,7 +106,7 @@ public class JobsInfo extends EntityMP implements Serializable { ...@@ -106,7 +106,7 @@ public class JobsInfo extends EntityMP implements Serializable {
@TableField(value = "last_time") @TableField(value = "last_time")
@JSONField(name = "last_time") @JSONField(name = "last_time")
@JsonProperty("last_time") @JsonProperty("last_time")
private BigInteger lastTime; private Long lastTime;
/** /**
* 下次调度时间 * 下次调度时间
*/ */
...@@ -114,7 +114,7 @@ public class JobsInfo extends EntityMP implements Serializable { ...@@ -114,7 +114,7 @@ public class JobsInfo extends EntityMP implements Serializable {
@TableField(value = "next_time") @TableField(value = "next_time")
@JSONField(name = "next_time") @JSONField(name = "next_time")
@JsonProperty("next_time") @JsonProperty("next_time")
private BigInteger nextTime; private Long nextTime;
/** /**
* 所有者 * 所有者
*/ */
...@@ -216,7 +216,7 @@ public class JobsInfo extends EntityMP implements Serializable { ...@@ -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.lastTime = lastTime ;
this.modify("last_time",lastTime); this.modify("last_time",lastTime);
} }
...@@ -224,7 +224,7 @@ public class JobsInfo extends EntityMP implements Serializable { ...@@ -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.nextTime = nextTime ;
this.modify("next_time",nextTime); this.modify("next_time",nextTime);
} }
......
...@@ -43,7 +43,7 @@ public class JobsLock extends EntityMP implements Serializable { ...@@ -43,7 +43,7 @@ public class JobsLock extends EntityMP implements Serializable {
* 主键ID * 主键ID
*/ */
@DEField(isKeyField=true) @DEField(isKeyField=true)
@TableId(value= "id",type=IdType.ASSIGN_UUID) @TableId(value= "id",type=IdType.ASSIGN_ID)
@JSONField(name = "id") @JSONField(name = "id")
@JsonProperty("id") @JsonProperty("id")
private String id; private String id;
......
...@@ -43,7 +43,7 @@ public class JobsLog extends EntityMP implements Serializable { ...@@ -43,7 +43,7 @@ public class JobsLog extends EntityMP implements Serializable {
* 主键ID * 主键ID
*/ */
@DEField(isKeyField=true) @DEField(isKeyField=true)
@TableId(value= "id",type=IdType.ASSIGN_UUID) @TableId(value= "id",type=IdType.ASSIGN_ID)
@JSONField(name = "id") @JSONField(name = "id")
@JsonProperty("id") @JsonProperty("id")
private String id; private String id;
......
...@@ -43,7 +43,7 @@ public class JobsRegistry extends EntityMP implements Serializable { ...@@ -43,7 +43,7 @@ public class JobsRegistry extends EntityMP implements Serializable {
* 主键ID * 主键ID
*/ */
@DEField(isKeyField=true) @DEField(isKeyField=true)
@TableId(value= "id",type=IdType.ASSIGN_UUID) @TableId(value= "id",type=IdType.ASSIGN_ID)
@JSONField(name = "id") @JSONField(name = "id")
@JsonProperty("id") @JsonProperty("id")
private String id; private String id;
......
...@@ -8,6 +8,7 @@ import cn.ibizlab.core.task.service.IJobsLockService; ...@@ -8,6 +8,7 @@ import cn.ibizlab.core.task.service.IJobsLockService;
import cn.ibizlab.core.task.service.IJobsLogService; import cn.ibizlab.core.task.service.IJobsLogService;
import cn.ibizlab.core.task.service.IJobsRegistryService; import cn.ibizlab.core.task.service.IJobsRegistryService;
import cn.ibizlab.util.helper.CachedBeanCopier; import cn.ibizlab.util.helper.CachedBeanCopier;
import cn.ibizlab.util.helper.DataObject;
import com.baomidou.jobs.JobsClock; import com.baomidou.jobs.JobsClock;
import com.baomidou.jobs.model.JobsInfo; import com.baomidou.jobs.model.JobsInfo;
import com.baomidou.jobs.model.JobsLog; import com.baomidou.jobs.model.JobsLog;
...@@ -19,7 +20,8 @@ import lombok.extern.slf4j.Slf4j; ...@@ -19,7 +20,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigInteger; //import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -49,7 +51,7 @@ public class JobsServiceImpl implements IJobsService { ...@@ -49,7 +51,7 @@ public class JobsServiceImpl implements IJobsService {
jobsRegistry.setApp(registryParam.getApp()); jobsRegistry.setApp(registryParam.getApp());
jobsRegistry.setAddress(registryParam.getAddress()); jobsRegistry.setAddress(registryParam.getAddress());
jobsRegistry.setStatus(registryParam.getRegisterStatusEnum().getValue()); jobsRegistry.setStatus(registryParam.getRegisterStatusEnum().getValue());
jobsRegistry.setUpdateTime(BigInteger.valueOf(JobsClock.currentTimeMillis())); jobsRegistry.setUpdateTime(new Timestamp(JobsClock.currentTimeMillis()));
int ret = jobsRegistryService.getBaseMapper().update(jobsRegistry, int ret = jobsRegistryService.getBaseMapper().update(jobsRegistry,
Wrappers.<JobsRegistry>lambdaQuery().eq(JobsRegistry::getApp, registryParam.getApp()) Wrappers.<JobsRegistry>lambdaQuery().eq(JobsRegistry::getApp, registryParam.getApp())
...@@ -65,7 +67,7 @@ public class JobsServiceImpl implements IJobsService { ...@@ -65,7 +67,7 @@ public class JobsServiceImpl implements IJobsService {
public List<JobsInfo> getJobsInfoList(long nextTime) { public List<JobsInfo> getJobsInfoList(long nextTime) {
List<cn.ibizlab.core.task.domain.JobsInfo> list = jobsInfoService.list(Wrappers.<cn.ibizlab.core.task.domain.JobsInfo>lambdaQuery() 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) .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<JobsInfo> ret = new ArrayList<>();
list.forEach(obj->ret.add(change(obj))); list.forEach(obj->ret.add(change(obj)));
return ret; return ret;
...@@ -86,7 +88,7 @@ public class JobsServiceImpl implements IJobsService { ...@@ -86,7 +88,7 @@ public class JobsServiceImpl implements IJobsService {
JobsLock lock = new JobsLock(); JobsLock lock = new JobsLock();
lock.setName(name); lock.setName(name);
lock.setOwner(owner); lock.setOwner(owner);
lock.setCreateTime(BigInteger.valueOf(JobsClock.currentTimeMillis())); lock.setCreateTime(new Timestamp(JobsClock.currentTimeMillis()));
return jobsLockService.getBaseMapper().insert(lock)>0; return jobsLockService.getBaseMapper().insert(lock)>0;
} }
...@@ -101,7 +103,7 @@ public class JobsServiceImpl implements IJobsService { ...@@ -101,7 +103,7 @@ public class JobsServiceImpl implements IJobsService {
JobsRegistry jobsRegistry = new JobsRegistry(); JobsRegistry jobsRegistry = new JobsRegistry();
jobsRegistry.setStatus(1); jobsRegistry.setStatus(1);
if(jobsRegistryService.update(jobsRegistry, Wrappers.<JobsRegistry>lambdaQuery() 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 1;
return 0; return 0;
} }
...@@ -152,15 +154,15 @@ public class JobsServiceImpl implements IJobsService { ...@@ -152,15 +154,15 @@ public class JobsServiceImpl implements IJobsService {
jobsInfo.setTenantId(et.getTenantId()); jobsInfo.setTenantId(et.getTenantId());
jobsInfo.setTimeout(et.getTimeout()); jobsInfo.setTimeout(et.getTimeout());
if(et.getId()!=null) if(et.getId()!=null)
jobsInfo.setId(et.getId().longValue()); jobsInfo.setId(DataObject.getLongValue(et.getId(),et.getCreateTime().getTime()));
if(et.getLastTime()!=null) if(et.getLastTime()!=null)
jobsInfo.setLastTime(et.getLastTime().longValue()); jobsInfo.setLastTime(et.getLastTime());
if(et.getNextTime()!=null) if(et.getNextTime()!=null)
jobsInfo.setNextTime(et.getNextTime().longValue()); jobsInfo.setNextTime(et.getNextTime());
if(et.getCreateTime()!=null) if(et.getCreateTime()!=null)
jobsInfo.setCreateTime(et.getCreateTime().longValue()); jobsInfo.setCreateTime(et.getCreateTime().getTime());
if(et.getUpdateTime()!=null) if(et.getUpdateTime()!=null)
jobsInfo.setUpdateTime(et.getUpdateTime().longValue()); jobsInfo.setUpdateTime(et.getUpdateTime().getTime());
return jobsInfo; return jobsInfo;
} }
...@@ -180,15 +182,15 @@ public class JobsServiceImpl implements IJobsService { ...@@ -180,15 +182,15 @@ public class JobsServiceImpl implements IJobsService {
jobsInfo.setTenantId(et.getTenantId()); jobsInfo.setTenantId(et.getTenantId());
jobsInfo.setTimeout(et.getTimeout()); jobsInfo.setTimeout(et.getTimeout());
if(et.getId()!=null) if(et.getId()!=null)
jobsInfo.setId(BigInteger.valueOf(et.getId())); jobsInfo.setId(et.getId()+"");
if(et.getLastTime()!=null) if(et.getLastTime()!=null)
jobsInfo.setLastTime(BigInteger.valueOf(et.getLastTime())); jobsInfo.setLastTime(et.getLastTime());
if(et.getNextTime()!=null) if(et.getNextTime()!=null)
jobsInfo.setNextTime(BigInteger.valueOf(et.getNextTime())); jobsInfo.setNextTime(et.getNextTime());
if(et.getCreateTime()!=null) if(et.getCreateTime()!=null)
jobsInfo.setCreateTime(BigInteger.valueOf(et.getCreateTime())); jobsInfo.setCreateTime(new Timestamp(et.getCreateTime()));
if(et.getUpdateTime()!=null) if(et.getUpdateTime()!=null)
jobsInfo.setUpdateTime(BigInteger.valueOf(et.getUpdateTime())); jobsInfo.setUpdateTime(new Timestamp(et.getUpdateTime()));
return jobsInfo; return jobsInfo;
} }
...@@ -206,11 +208,11 @@ public class JobsServiceImpl implements IJobsService { ...@@ -206,11 +208,11 @@ public class JobsServiceImpl implements IJobsService {
jobsLog.setTriggerMsg(et.getTriggerMsg()); jobsLog.setTriggerMsg(et.getTriggerMsg());
jobsLog.setTriggerType(et.getTriggerType()); jobsLog.setTriggerType(et.getTriggerType());
if(et.getId()!=null) if(et.getId()!=null)
jobsLog.setId(BigInteger.valueOf(et.getId())); jobsLog.setId(et.getId()+"");
if(et.getCreateTime()!=null) if(et.getCreateTime()!=null)
jobsLog.setCreateTime(BigInteger.valueOf(et.getCreateTime())); jobsLog.setCreateTime(new Timestamp(et.getCreateTime()));
if(et.getJobId()!=null) if(et.getJobId()!=null)
jobsLog.setJobId(BigInteger.valueOf(et.getJobId())); jobsLog.setJobId(et.getJobId()+"");
return jobsLog; 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 { ...@@ -93,7 +93,7 @@ public class JobsInfoDTO extends DTOBase implements Serializable {
*/ */
@JSONField(name = "last_time") @JSONField(name = "last_time")
@JsonProperty("last_time") @JsonProperty("last_time")
private BigInteger lastTime; private Long lastTime;
/** /**
* 属性 [NEXT_TIME] * 属性 [NEXT_TIME]
...@@ -101,7 +101,7 @@ public class JobsInfoDTO extends DTOBase implements Serializable { ...@@ -101,7 +101,7 @@ public class JobsInfoDTO extends DTOBase implements Serializable {
*/ */
@JSONField(name = "next_time") @JSONField(name = "next_time")
@JsonProperty("next_time") @JsonProperty("next_time")
private BigInteger nextTime; private Long nextTime;
/** /**
* 属性 [AUTHOR] * 属性 [AUTHOR]
...@@ -205,7 +205,7 @@ public class JobsInfoDTO extends DTOBase implements Serializable { ...@@ -205,7 +205,7 @@ public class JobsInfoDTO extends DTOBase implements Serializable {
/** /**
* 设置 [LAST_TIME] * 设置 [LAST_TIME]
*/ */
public void setLastTime(BigInteger lastTime){ public void setLastTime(Long lastTime){
this.lastTime = lastTime ; this.lastTime = lastTime ;
this.modify("last_time",lastTime); this.modify("last_time",lastTime);
} }
...@@ -213,7 +213,7 @@ public class JobsInfoDTO extends DTOBase implements Serializable { ...@@ -213,7 +213,7 @@ public class JobsInfoDTO extends DTOBase implements Serializable {
/** /**
* 设置 [NEXT_TIME] * 设置 [NEXT_TIME]
*/ */
public void setNextTime(BigInteger nextTime){ public void setNextTime(Long nextTime){
this.nextTime = nextTime ; this.nextTime = nextTime ;
this.modify("next_time",nextTime); this.modify("next_time",nextTime);
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册