Преглед изворни кода

update:jsoup码池时可选忽略重试次数限制v1

tujidelv пре 3 година
родитељ
комит
329f5ab6d2

+ 2 - 2
src/main/java/top/lvzhiqiang/config/MyJobs.java

@@ -148,7 +148,7 @@ public class MyJobs {
     public void jsoupIcodePool4CrawingNo() {
         log.info("jsoupIcodePool4CrawingNo开始==============================");
 
-        bgService.jsoupIcodePool(1, 2);
+        bgService.jsoupIcodePool(1, 2, 2);
     }
 
     /**
@@ -158,6 +158,6 @@ public class MyJobs {
     public void jsoupIcodePool4CrawingFail() {
         log.info("jsoupIcodePool4CrawingFail开始==============================");
 
-        bgService.jsoupIcodePool(3, 2);
+        bgService.jsoupIcodePool(3, 2, 2);
     }
 }

+ 5 - 2
src/main/java/top/lvzhiqiang/controller/BgController.java

@@ -108,15 +108,18 @@ public class BgController {
      */
     @RequestMapping("/jsoupIcodePool")
     @ResponseBody
-    public R jsoupIcodePool(Integer status, Integer isDel) {
+    public R jsoupIcodePool(Integer status, Integer isDel, Integer ignoreRetryCount) {
         if (null == status) {
             status = 1;
         }
         if (null == isDel) {
             isDel = 2;
         }
+        if (null == ignoreRetryCount) {
+            isDel = 2;
+        }
 
-        bgService.jsoupIcodePool(status, isDel);
+        bgService.jsoupIcodePool(status, isDel, ignoreRetryCount);
         return R.ok();
     }
 

+ 3 - 1
src/main/java/top/lvzhiqiang/mapper/IcodePoolMapper.java

@@ -51,6 +51,9 @@ public interface IcodePoolMapper {
     @Select("SELECT identification_code FROM icode_pool WHERE delete_flag = 1 and status = #{status} and retry_count < 3")
     List<String> findIcodeByStatus(Integer status);
 
+    @Select("SELECT identification_code FROM icode_pool WHERE delete_flag = 1 and status = #{status}")
+    List<String> findIcodeByStatus4IgnoreRetryCount(Integer status);
+
     /**
      * 查询所有识别码
      */
@@ -83,5 +86,4 @@ public interface IcodePoolMapper {
             "</if>" +
             "</script>"})
     List<IcodePool> findByCodeAndStatus(String identificationCode, Integer status, String order);
-
 }

+ 1 - 1
src/main/java/top/lvzhiqiang/service/BgService.java

@@ -28,7 +28,7 @@ public interface BgService {
      *
      * @param status
      */
-    void jsoupIcodePool(Integer status, Integer isDel);
+    void jsoupIcodePool(Integer status, Integer isDel, Integer ignoreRetryCount);
 
     /**
      * 单个识别码

+ 8 - 2
src/main/java/top/lvzhiqiang/service/impl/BgServiceImpl.java

@@ -512,7 +512,7 @@ public class BgServiceImpl implements BgService {
      */
     @Async
     @Override
-    public void jsoupIcodePool(Integer status, Integer isDel) {
+    public void jsoupIcodePool(Integer status, Integer isDel, Integer ignoreRetryCount) {
         log.warn("jsoupIcodePool 开始:status={},isDel={}", status, isDel);
         if (isDel == 1) {
             videoInfoPoolMapper.deleteAll();
@@ -520,7 +520,13 @@ public class BgServiceImpl implements BgService {
 
 
         // 获取待抓取码列表
-        List<String> icodePoolList = icodePoolMapper.findIcodeByStatus(status);
+        List<String> icodePoolList;
+        if (1 == ignoreRetryCount) {
+            icodePoolList = icodePoolMapper.findIcodeByStatus4IgnoreRetryCount(status);
+        } else {
+            icodePoolList = icodePoolMapper.findIcodeByStatus(status);
+        }
+
         if (icodePoolList.size() == 0) {
             log.warn("status={}的icodePoolList为空", status);
             return;

+ 2 - 0
src/main/resources/static/bg.html

@@ -145,6 +145,8 @@
             <input type="text" name="status" placeholder="1:未爬取,3:爬取失败。默认是未爬取" style="width: 300px;"/>
             <span>isDel</span>
             <input type="text" name="isDel" placeholder="1:是,2:否。默认否"/>
+            <span>ignoreRetryCount</span>
+            <input type="text" name="ignoreRetryCount" placeholder="1:是,2:否。默认否"/>
             <input type="submit" value="提交">
         </form>
     </div>