904118851 5 달 전
부모
커밋
155d819a8b
2개의 변경된 파일54개의 추가작업 그리고 11개의 파일을 삭제
  1. 4 4
      task_script.json
  2. 50 7
      task_script/async_filter_data.js

+ 4 - 4
task_script.json

@@ -1,15 +1,15 @@
 {
     "apps": [
         {
-            "name": "qm_mf_book_async",
-            "script": "./qm_mf_book_async.js",
+            "name": "async_filter_data",
+            "script": "./async_filter_data.js",
             "node_args": "--max-old-space-size=8192 --expose-gc",
             "max_memory_restart": "4G",
             "args": ["--type=data"],
             "cwd": "/home/tg_factory",
             "log_date_format": "YYYY-MM-DD HH:mm:ss",
-            "error_file": "./logs/task_script/qm_mf_book_async_error.log",
-            "out_file": "./logs/task_script/qm_mf_book_async_out.log",
+            "error_file": "./logs/task_script/async_filter_data_error.log",
+            "out_file": "./logs/task_script/async_filter_data_out.log",
             "merge_logs": true,
             "exec_mode": "fork",
             "autorestart": true

+ 50 - 7
task_script/async_filter_data.js

@@ -10,23 +10,66 @@ const CMD = {}
 async function processTask(){
     let right_status = true
     let connection  = null
+    let task_connection = null
     try{
+        //清理黑岩堆积数据
         //1.遍历书库
         //2.每一本书
-        // connection = await mysql.createConnection({
-        //     ...dbConfig,
-        //     multipleStatements: true
-        // });
-        let result = await filter_data_controllers.getFilterDataByStatusAndLimit({ status: 0 , tg_platform_id: config.platform_qimao },10,"DESC");
-        console.log("result:",result)
+        connection = await mysql.createConnection({
+            ...dbConfig,
+            multipleStatements: true
+        });
+
+        let sql = `SELECT * FROM filter_data WHERE tg_platform_id = 1 AND status = 0 AND weight = 0 LIMIT 1`
+        
+        const [row] = await connection.execute(sql)
+
+
+        if(row.length<=0){
+            throw 0
+        }
+
+        let filter_info = row[0]
+
+        task_connection = await mysql.createConnection({
+            ...taskdbConfig,
+            multipleStatements: true
+        });
+
+        sql = `SELECT * FROM video_product WHERE product_id = "${filter_info.book_id}" AND book_platform = 1 LIMIT 1`
+        
+        const [video_product_row] = await task_connection.execute(sql)
+
+        if(video_product_row.length<=0){
+            connection.execute(`UPDATE filter_data SET weight = 999 WHERE id = ${filter_info.id}`)
+            throw 999
+        }
+
+        sql = `UPDATE filter_data SET status = 1 , book_name = "${video_product_row.product_name}" , genre = ${video_product_row.genre} ,words = "${data.words}" WHERE book_id = "${video_product_row.product_id}" AND status = 0 AND tg_platform_id = ${video_product_row.book_platform} `
+
+        console.log("processTask:",video_product_row)
+
+        await connection.execute(
+            sql
+        );
+
     }catch(e){
         if(e==0){
             right_status = false
         }
         console.error("processTask error:",e)
     } finally{
+
+        if(connection!=null){
+            connection.end()
+        }
+
+        if(task_connection!=null){
+            task_connection.end()
+        }
+
         if(right_status){
-            // global.setTimeout(processTask, 1000);
+            global.setTimeout(processTask, 1000);
         }
 
     }