Jelajahi Sumber

新增无二维码可用飞书通知功能

lqc 4 tahun lalu
induk
melakukan
eb96fd0b54

+ 49 - 0
src/main/java/com/mokamrp/privates/task/pangu/CheckPoolStatus.java

@@ -0,0 +1,49 @@
+package com.mokamrp.privates.task.pangu;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobilePool;
+import com.mokamrp.privates.service.pangu.FosterwxMobilePoolService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**检查个微池二维码是否有能用的
+ * @author luqiucheng
+ */
+@Component
+@Slf4j
+public class CheckPoolStatus {
+    @Autowired
+    private FosterwxMobilePoolService fosterwxMobilePoolService;
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Scheduled(cron = "0 */1 * * * ?")
+    public void execute() {
+        LambdaQueryWrapper<FosterwxMobilePool> fosterwxMobilePoolLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        // 查询有分组的 类型为游戏导粉的
+        fosterwxMobilePoolLambdaQueryWrapper.ne(FosterwxMobilePool::getFlowPosition, "").eq(FosterwxMobilePool::getIncomeFansType, 2).groupBy(FosterwxMobilePool::getFlowPosition);
+        fosterwxMobilePoolService.list(fosterwxMobilePoolLambdaQueryWrapper).forEach(fosterwxMobilePool -> {
+            // 判断分组下未停用账号是否存在
+            if (fosterwxMobilePoolService.count(new LambdaQueryWrapper<FosterwxMobilePool>().eq(FosterwxMobilePool::getFlowPosition, fosterwxMobilePool.getFlowPosition()).ne(FosterwxMobilePool::getStatus, 0)) == 0) {
+                Map<String, Object> jsonObject = new HashMap<>();
+                jsonObject.put("msg_type", "text");
+                Map<String, String> contentObj = new HashMap<>();
+                String info = "流量位置:" + fosterwxMobilePool.getFlowPosition() + "已没有可以使用的二维码了!";
+                contentObj.put("text", info);
+                jsonObject.put("content", contentObj);
+                HttpEntity<Map<String, Object>> entity = new HttpEntity<>(jsonObject, null);
+                ResponseEntity<String> str = restTemplate.exchange("https://open.feishu.cn/open-apis/bot/v2/hook/782210e2-b016-4dd7-885b-e0ea5e58be94", HttpMethod.POST, entity, String.class);
+            }
+        });
+    }
+}

+ 6 - 1
src/test/java/com/mokamrp/WebTest.java

@@ -10,6 +10,7 @@ import com.mokamrp.privates.service.pangu.FosterwxMobilePoolService;
 import com.mokamrp.privates.service.pangu.FosterwxMobileService;
 import com.mokamrp.privates.service.pangu.FosterwxMobileTaskTimeListService;
 import com.mokamrp.privates.service.pangu.FosterwxTaskScheduleService;
+import com.mokamrp.privates.task.pangu.CheckPoolStatus;
 import com.mokamrp.privates.task.pangu.SyncFosterwxMobilePool;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
@@ -42,6 +43,9 @@ public class WebTest {
     @Autowired
     private FosterwxTaskScheduleService fosterwxTaskScheduleService;
 
+    @Autowired
+    private CheckPoolStatus checkPoolStatus;
+
     @Test
     public void test1() {
         // 清洗数据
@@ -67,7 +71,8 @@ public class WebTest {
 
     @Test
     public void test2() {
-        syncFosterwxMobilePool.execute();
+        // syncFosterwxMobilePool.execute();
+        checkPoolStatus.execute();
     }
 
     /**