自动上线功能调整,添加更新时间与创建时间的差值限制。当前依据为当天的内容、文件就绪、状态下线、创建更新时间相差半小时以内
Showing
2 changed files
with
13 additions
and
1 deletions
... | @@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil; | ... | @@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil; |
5 | import com.topdraw.platform.util.DbUtil; | 5 | import com.topdraw.platform.util.DbUtil; |
6 | import lombok.extern.slf4j.Slf4j; | 6 | import lombok.extern.slf4j.Slf4j; |
7 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
8 | import org.springframework.beans.factory.annotation.Value; | ||
8 | import org.springframework.stereotype.Component; | 9 | import org.springframework.stereotype.Component; |
9 | import org.springframework.transaction.annotation.Transactional; | 10 | import org.springframework.transaction.annotation.Transactional; |
10 | 11 | ||
... | @@ -16,6 +17,9 @@ public class AutoOnlineProcessor { | ... | @@ -16,6 +17,9 @@ public class AutoOnlineProcessor { |
16 | @Autowired | 17 | @Autowired |
17 | DbUtil dbUtil; | 18 | DbUtil dbUtil; |
18 | 19 | ||
20 | @Value("${entity.difference}") | ||
21 | private Long DIFFERENCE; | ||
22 | |||
19 | @Transactional(rollbackFor = Exception.class) | 23 | @Transactional(rollbackFor = Exception.class) |
20 | public void execute() { | 24 | public void execute() { |
21 | Connection connection = null; | 25 | Connection connection = null; |
... | @@ -23,7 +27,7 @@ public class AutoOnlineProcessor { | ... | @@ -23,7 +27,7 @@ public class AutoOnlineProcessor { |
23 | try { | 27 | try { |
24 | connection = dbUtil.getConnection(); | 28 | connection = dbUtil.getConnection(); |
25 | // 查询未绑定 | 29 | // 查询未绑定 |
26 | String sql = " update `x_media` set `status` = '001' where `status` = '000' and file_status = '001' and create_time >= ? "; | 30 | 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); |
27 | dbUtil.doExecute(connection, sql, today); | 31 | dbUtil.doExecute(connection, sql, today); |
28 | // 提交事务 | 32 | // 提交事务 |
29 | dbUtil.commitTransaction(connection); | 33 | dbUtil.commitTransaction(connection); | ... | ... |
... | @@ -3,12 +3,16 @@ server: | ... | @@ -3,12 +3,16 @@ server: |
3 | 3 | ||
4 | scheduler: | 4 | scheduler: |
5 | auto-bind: | 5 | auto-bind: |
6 | # 自动绑应用 | ||
6 | app-enabled: true | 7 | app-enabled: true |
8 | # 自动绑服务包 | ||
7 | service-enabled: true | 9 | service-enabled: true |
10 | # 内容自动上线 | ||
8 | media-online-enabled: true | 11 | media-online-enabled: true |
9 | 12 | ||
10 | cron: | 13 | cron: |
11 | auto-bind: | 14 | auto-bind: |
15 | # 任务执行间隔 | ||
12 | app: 0/10 * * * * ? | 16 | app: 0/10 * * * * ? |
13 | service: 0/10 * * * * ? | 17 | service: 0/10 * * * * ? |
14 | media-online: 0/10 * * * * ? | 18 | media-online: 0/10 * * * * ? |
... | @@ -26,5 +30,9 @@ spring: | ... | @@ -26,5 +30,9 @@ spring: |
26 | active: dev | 30 | active: dev |
27 | 31 | ||
28 | entity: | 32 | entity: |
33 | # 自动绑的应用id | ||
29 | appId: 63 | 34 | appId: 63 |
35 | # 自动绑的服务包id | ||
30 | serviceId: 1 | 36 | serviceId: 1 |
37 | # 自动上线判断依据:创建更新时间间隔秒 | ||
38 | difference: 1800 | ... | ... |
-
Please register or sign in to post a comment