Commit 6e04f592 6e04f5920179c3255fcb42e33cd1388c105223f0 by lWoHvYe

自动上线功能调整,添加更新时间与创建时间的差值限制。当前依据为当天的内容、文件就绪、状态下线、创建更新时间相差半小时以内

1 parent 728edf62
......@@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
import com.topdraw.platform.util.DbUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
......@@ -16,6 +17,9 @@ public class AutoOnlineProcessor {
@Autowired
DbUtil dbUtil;
@Value("${entity.difference}")
private Long DIFFERENCE;
@Transactional(rollbackFor = Exception.class)
public void execute() {
Connection connection = null;
......@@ -23,7 +27,7 @@ public class AutoOnlineProcessor {
try {
connection = dbUtil.getConnection();
// 查询未绑定
String sql = " update `x_media` set `status` = '001' where `status` = '000' and file_status = '001' and create_time >= ? ";
String sql = StrUtil.format(" update `x_media` set `status` = '001' where `status` = '000' and file_status = '001' and (update_time - create_time) < {} and create_time >= ? ", DIFFERENCE);
dbUtil.doExecute(connection, sql, today);
// 提交事务
dbUtil.commitTransaction(connection);
......
......@@ -3,12 +3,16 @@ server:
scheduler:
auto-bind:
# 自动绑应用
app-enabled: true
# 自动绑服务包
service-enabled: true
# 内容自动上线
media-online-enabled: true
cron:
auto-bind:
# 任务执行间隔
app: 0/10 * * * * ?
service: 0/10 * * * * ?
media-online: 0/10 * * * * ?
......@@ -26,5 +30,9 @@ spring:
active: dev
entity:
# 自动绑的应用id
appId: 63
# 自动绑的服务包id
serviceId: 1
# 自动上线判断依据:创建更新时间间隔秒
difference: 1800
......