Browse Source

增加历史数据区分数据源

xueyiming 6 tháng trước cách đây
mục cha
commit
b93beba17f

+ 30 - 1
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
 import com.tzld.piaoquan.wecom.common.constant.TimeConstant;
 import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum;
+import com.tzld.piaoquan.wecom.common.enums.SourceEnum;
 import com.tzld.piaoquan.wecom.component.HttpPoolClient;
 import com.tzld.piaoquan.wecom.dao.mapper.HistoryMessageMapper;
 import com.tzld.piaoquan.wecom.dao.mapper.StaffMapper;
@@ -409,7 +410,35 @@ public class WeComHistoryDataJob {
         return httpPoolClient.post(url, param.toJSONString());
     }
 
-
+    @XxlJob("insetHistoryMessageSourceJob")
+    public ReturnT<String> insetHistoryMessageSource(String param) {
+        if (StringUtils.isEmpty(param)) {
+            return ReturnT.FAIL;
+        }
+        JSONArray jsonArray = JSONArray.parseArray(param);
+        for (int i = 0; i < jsonArray.size(); i++) {
+            JSONObject jsonObject = jsonArray.getJSONObject(i);
+            Long startTime = jsonObject.getLong("startTime");
+            Long endTime = jsonObject.getLong("endTime");
+
+            JSONArray videos = jsonObject.getJSONArray("videos");
+            List<Long> videoList = videos.stream().map(String::valueOf).map(Long::parseLong).collect(Collectors.toList());
+            HistoryMessageExample example = new HistoryMessageExample();
+            example.createCriteria().andSendTimeBetween(new Date(startTime), new Date(endTime))
+                    .andVideoIdIn(videoList);
+            HistoryMessage historyMessage = new HistoryMessage();
+            historyMessage.setSource(MANUAL.getName());
+            historyMessageMapper.updateByExampleSelective(historyMessage, example);
+
+            HistoryMessageExample example1 = new HistoryMessageExample();
+            example1.createCriteria().andSendTimeBetween(new Date(startTime), new Date(endTime))
+                    .andVideoIdNotIn(videoList);
+            HistoryMessage historyMessage1 = new HistoryMessage();
+            historyMessage1.setSource(HISTORICAL_TOP.getName());
+            historyMessageMapper.updateByExampleSelective(historyMessage1, example1);
+        }
+        return ReturnT.SUCCESS;
+    }
 }