Browse Source

Merge branch 'master' into 20250530-wyp-contentPlatformDatastat

wangyunpeng 1 month ago
parent
commit
45091cc4a3

+ 7 - 1
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImpl.java

@@ -340,6 +340,12 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
             }
         }
         for (GzhPlanVideoContentItemParam vo : param.getVideoList()) {
+            if (!StringUtils.hasText(vo.getCustomTitle())) {
+                vo.setCustomTitle(null);
+            }
+            if (!StringUtils.hasText(vo.getCustomCover())) {
+                vo.setCustomCover(null);
+            }
             if (existsVideoIds.contains(vo.getVideoId())) {
                 ContentPlatformGzhPlanVideo item = existsVideoMap.get(vo.getVideoId());
                 item.setTitle(vo.getTitle());
@@ -367,7 +373,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
                 }
                 item.setCreateAccountId(loginAccount.getId());
                 item.setCreateTimestamp(System.currentTimeMillis());
-                gzhPlanVideoMapper.insertSelective(item);
+                gzhPlanVideoMapper.insert(item);
             }
         }
         if (CollectionUtils.isNotEmpty(param.getVideoList())) {

+ 24 - 17
common-module/src/main/java/com/tzld/piaoquan/growth/common/component/ProxyHttpPoolClient.java

@@ -71,24 +71,31 @@ public class ProxyHttpPoolClient {
     }
 
     public String request(HttpRequestBase request) throws IOException {
-
-        HttpEntity entity = null;
-        CloseableHttpResponse response = request((HttpUriRequest) request);
-        if (response == null) {
-            log.error("call api exception no response");
-            throw new RuntimeException("call api exception no response");
-        }
-        entity = response.getEntity();
-        String content = null;
-        if (entity != null) {
-            content = EntityUtils.toString(entity, "UTF-8");
-        }
-        int httpStatus = response.getStatusLine().getStatusCode();
-        if (httpStatus == HttpStatus.SC_OK) {
-            return content;
+        int retry = 0;
+        while (retry <= 3) {
+            try {
+                retry++;
+                HttpEntity entity = null;
+                CloseableHttpResponse response = request((HttpUriRequest) request);
+                if (response == null) {
+                    log.error("call api exception no response");
+                    throw new RuntimeException("call api exception no response");
+                }
+                entity = response.getEntity();
+                String content = null;
+                if (entity != null) {
+                    content = EntityUtils.toString(entity, "UTF-8");
+                }
+                int httpStatus = response.getStatusLine().getStatusCode();
+                if (httpStatus == HttpStatus.SC_OK) {
+                    return content;
+                }
+                String path = request.getURI().toString();
+                log.error("http call api {} fail response status {} content {}", path, httpStatus, content);
+            } catch (Exception e) {
+                log.error("request error", e);
+            }
         }
-        String path = request.getURI().toString();
-        log.error("http call api {} fail response status {} content {}", path, httpStatus, content);
         return null;
     }
 

+ 25 - 24
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComHistoryDataJob.java

@@ -91,41 +91,39 @@ public class WeComHistoryDataJob {
     @Autowired
     private WeComSendService weComSendService;
 
-    private static final String START_TIME_KEY = "start_time_key";
+    private static final String START_TIME_KEY = "start_time_key_%s";
 
     @XxlJob("saveHistoryMessageJob1")
     public ReturnT<String> saveHistoryMessageJob1(String param) {
-        Integer startTimeVal = (Integer) redisTemplate.opsForValue().get(START_TIME_KEY);
-        Long dayStartTime = DateUtil.getBeforeDayStart(0);
-        Long startTime;
-        if (startTimeVal == null) {
-            startTime = DateUtil.getBeforeDayStart(0);
-        } else {
-            if (dayStartTime > startTimeVal) {
-                startTime = dayStartTime;
-            } else {
-                startTime = (long) startTimeVal;
-            }
-        }
-
-        Long endTime = System.currentTimeMillis() / 1000;
         CorpExample example = new CorpExample();
         List<Corp> corps = corpMapper.selectByExample(example);
         if (CollectionUtils.isEmpty(corps)) {
             return ReturnT.SUCCESS;
         }
         for (Corp corp : corps) {
+            String key = String.format(START_TIME_KEY, corp.getId());
+            Integer startTimeVal = (Integer) redisTemplate.opsForValue().get(key);
+            Long dayStartTime = DateUtil.getBeforeDayStart(0);
+            Long startTime;
+            if (startTimeVal == null) {
+                startTime = DateUtil.getBeforeDayStart(0);
+            } else {
+                if (dayStartTime > startTimeVal) {
+                    startTime = dayStartTime;
+                } else {
+                    startTime = (long) startTimeVal;
+                }
+            }
+            Long endTime = System.currentTimeMillis() / 1000;
             selectGroupMsgList(startTime, endTime, corp.getId(), null);
-        }
-        boolean isAllSend = true;
-        for (Corp corp : corps) {
+            boolean isAllSend = true;
             long notSentCount = newSelectAlertHistoryMessage(startTime, endTime + TimeConstant.HOUR, corp.getId(), corp.getName());
             if (notSentCount > 0) {
                 isAllSend = false;
             }
-        }
-        if (isAllSend) {
-            redisTemplate.opsForValue().set(START_TIME_KEY, endTime, 1, TimeUnit.DAYS);
+            if (isAllSend) {
+                redisTemplate.opsForValue().set(key, endTime, 1, TimeUnit.DAYS);
+            }
         }
         return ReturnT.SUCCESS;
     }
@@ -177,7 +175,7 @@ public class WeComHistoryDataJob {
                 LarkRobotUtil.sendMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
                 LarkRobotUtil.sendTipMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
                 //8点前报警
-                if (DateUtil.getHourOfDay() < 8) {
+                if (DateUtil.getHourOfDay() < 8 && corpId == 1) {
                     LarkRobotUtil.sendNotPushMessage("<at user_id=\"all\">所有人</at> " + sendDetail.getRemark() + " 存在未发送记录,请检查");
                 }
             }
@@ -482,6 +480,9 @@ public class WeComHistoryDataJob {
         String cursor = "";
         do {
             String res = getGroupMsgTask(msgId, cursor, corpId);
+            if (StringUtils.isEmpty(res)) {
+                break;
+            }
             JSONObject jsonObject = JSONObject.parseObject(res);
             Integer errCode = jsonObject.getInteger("errcode");
             if (errCode != 0) {
@@ -645,8 +646,8 @@ public class WeComHistoryDataJob {
                 + "?access_token=" + accessToken;
         JSONObject param = new JSONObject();
         param.put("chat_type", "single");
-        param.put("start_time", startTime);
-        param.put("end_time", endTime);
+        param.put("start_time", String.valueOf(startTime));
+        param.put("end_time", String.valueOf(endTime));
         param.put("limit", 100);
         if (StringUtils.isNotEmpty(cursor)) {
             param.put("cursor", cursor);