上线逻辑调整
Showing
1 changed file
with
15 additions
and
8 deletions
1 | package com.topdraw.platform.executor; | 1 | package com.topdraw.platform.executor; |
2 | 2 | ||
3 | import cn.hutool.core.collection.CollUtil; | ||
3 | import cn.hutool.core.date.DateUtil; | 4 | import cn.hutool.core.date.DateUtil; |
4 | import cn.hutool.core.util.StrUtil; | 5 | import cn.hutool.core.util.StrUtil; |
5 | import com.topdraw.platform.util.DbUtil; | 6 | import com.topdraw.platform.util.DbUtil; |
6 | import lombok.extern.slf4j.Slf4j; | 7 | import lombok.extern.slf4j.Slf4j; |
8 | import lombok.var; | ||
7 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
8 | import org.springframework.beans.factory.annotation.Value; | 10 | import org.springframework.beans.factory.annotation.Value; |
9 | import org.springframework.stereotype.Component; | 11 | import org.springframework.stereotype.Component; |
... | @@ -11,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional; | ... | @@ -11,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional; |
11 | 13 | ||
12 | import java.sql.Connection; | 14 | import java.sql.Connection; |
13 | import java.util.Date; | 15 | import java.util.Date; |
16 | import java.util.Map; | ||
14 | 17 | ||
15 | @Component | 18 | @Component |
16 | @Slf4j | 19 | @Slf4j |
... | @@ -26,14 +29,18 @@ public class AutoOnlineProcessor { | ... | @@ -26,14 +29,18 @@ public class AutoOnlineProcessor { |
26 | String today = DateUtil.today(); | 29 | String today = DateUtil.today(); |
27 | try { | 30 | try { |
28 | connection = dbUtil.getConnection(); | 31 | connection = dbUtil.getConnection(); |
29 | // 查询未绑定 | 32 | String quSql = "select xm.id from `x_media` xm LEFT JOIN x_content_status_change xcsc on xm.id = xcsc.content_id and xcsc.content_class = 'media' " + |
30 | String sql = StrUtil.format(" update `x_media` set `status` = '001',`update_time` = '{}' " + | 33 | "where xm.`status` = '000' and xm.file_status = '001' and xm.update_time >= ? and xcsc.id is null "; |
31 | "where id in ( select a.id from " + | 34 | var mapList = dbUtil.queryList(connection, quSql, today); |
32 | "(select xm.id from `x_media` xm LEFT JOIN x_content_status_change xcsc on xm.id = xcsc.content_id and xcsc.content_class = 'media' " + | 35 | dbUtil.beginTransaction(connection); |
33 | "where xm.`status` = '000' and xm.file_status = '001' and xm.create_time >= ? and xcsc.id is null " + | 36 | if (CollUtil.isNotEmpty(mapList)) { |
34 | ") as a ) ", DateUtil.now()); | 37 | for (Map<String, Object> map : mapList) { |
35 | dbUtil.doExecute(connection, sql, today); | 38 | var id = (Long) map.get("id"); |
36 | 39 | String upSql = StrUtil.format(" update `x_media` set `status` = '001',`update_time` = '{}' where id = ?", DateUtil.now()); | |
40 | dbUtil.doExecute(connection, upSql, id); | ||
41 | } | ||
42 | } | ||
43 | dbUtil.commitTransaction(connection); | ||
37 | } catch (Exception ex) { | 44 | } catch (Exception ex) { |
38 | ex.printStackTrace(); | 45 | ex.printStackTrace(); |
39 | } finally { | 46 | } finally { | ... | ... |
-
Please register or sign in to post a comment