逻辑调整。引入接收表相关逻辑
Showing
1 changed file
with
12 additions
and
3 deletions
... | @@ -2,6 +2,7 @@ package com.topdraw.platform.executor; | ... | @@ -2,6 +2,7 @@ package com.topdraw.platform.executor; |
2 | 2 | ||
3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
4 | import cn.hutool.core.date.DateUtil; | 4 | import cn.hutool.core.date.DateUtil; |
5 | import cn.hutool.core.util.ObjectUtil; | ||
5 | import cn.hutool.core.util.StrUtil; | 6 | import cn.hutool.core.util.StrUtil; |
6 | import com.topdraw.platform.util.DbUtil; | 7 | import com.topdraw.platform.util.DbUtil; |
7 | import lombok.extern.slf4j.Slf4j; | 8 | import lombok.extern.slf4j.Slf4j; |
... | @@ -9,10 +10,8 @@ import lombok.var; | ... | @@ -9,10 +10,8 @@ import lombok.var; |
9 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
10 | import org.springframework.beans.factory.annotation.Value; | 11 | import org.springframework.beans.factory.annotation.Value; |
11 | import org.springframework.stereotype.Component; | 12 | import org.springframework.stereotype.Component; |
12 | import org.springframework.transaction.annotation.Transactional; | ||
13 | 13 | ||
14 | import java.sql.Connection; | 14 | import java.sql.Connection; |
15 | import java.util.Date; | ||
16 | import java.util.Map; | 15 | import java.util.Map; |
17 | 16 | ||
18 | @Component | 17 | @Component |
... | @@ -29,17 +28,27 @@ public class AutoOnlineProcessor { | ... | @@ -29,17 +28,27 @@ public class AutoOnlineProcessor { |
29 | String today = DateUtil.today(); | 28 | String today = DateUtil.today(); |
30 | try { | 29 | try { |
31 | connection = dbUtil.getConnection(); | 30 | connection = dbUtil.getConnection(); |
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' " + | 31 | String quSql = "select xm.id,xm.external_code from `x_media` xm LEFT JOIN x_content_status_change xcsc on xm.id = xcsc.content_id and xcsc.content_class = 'media' " + |
33 | "where xm.`status` = '000' and xm.file_status = '001' and xm.update_time >= ? and xcsc.id is null "; | 32 | "where xm.`status` = '000' and xm.file_status = '001' and xm.update_time >= ? and xcsc.id is null "; |
34 | var mapList = dbUtil.queryList(connection, quSql, today); | 33 | var mapList = dbUtil.queryList(connection, quSql, today); |
35 | dbUtil.beginTransaction(connection); | 34 | dbUtil.beginTransaction(connection); |
36 | if (CollUtil.isNotEmpty(mapList)) { | 35 | if (CollUtil.isNotEmpty(mapList)) { |
37 | for (Map<String, Object> map : mapList) { | 36 | for (Map<String, Object> map : mapList) { |
38 | var id = (Long) map.get("id"); | 37 | var id = (Long) map.get("id"); |
38 | var externalCode = (String) map.get("external_code"); | ||
39 | String chkSql = "select wrc.operation from ws_c2_recieve_cmd wrc where wrc.obj_code = ? and wrc.obj_type = 'media' and `status` = 200 ORDER BY wrc.create_time desc limit 1 "; | ||
40 | // 查询最新的接收工单状态 | ||
41 | var wrcRecord = dbUtil.queryUniqueResult(connection, chkSql, externalCode); | ||
42 | if (ObjectUtil.isNotNull(wrcRecord)) { | ||
43 | var operation = (String) wrcRecord.get("operation"); | ||
44 | // 最新为注入再处理。避免对C2正在处理的回收进行操作 | ||
45 | if (ObjectUtil.equal("REGIST", operation)) { | ||
39 | String upSql = StrUtil.format(" update `x_media` set `status` = '001',`update_time` = '{}' where id = ?", DateUtil.now()); | 46 | String upSql = StrUtil.format(" update `x_media` set `status` = '001',`update_time` = '{}' where id = ?", DateUtil.now()); |
40 | dbUtil.doExecute(connection, upSql, id); | 47 | dbUtil.doExecute(connection, upSql, id); |
41 | } | 48 | } |
42 | } | 49 | } |
50 | } | ||
51 | } | ||
43 | dbUtil.commitTransaction(connection); | 52 | dbUtil.commitTransaction(connection); |
44 | } catch (Exception ex) { | 53 | } catch (Exception ex) { |
45 | ex.printStackTrace(); | 54 | ex.printStackTrace(); | ... | ... |
-
Please register or sign in to post a comment