|
@@ -16,10 +16,11 @@ function getCodeFromUrl(url) {
|
|
|
}
|
|
|
async function processTask(){
|
|
|
let connection = null
|
|
|
+ let status = 0
|
|
|
try{
|
|
|
const today = helper.getLocalDate();
|
|
|
let date = today.replace(/-/g, '');
|
|
|
- let table_name = `video_product`;
|
|
|
+ let table_name = `qm_iap_lib`;
|
|
|
// 创建数据库连接
|
|
|
connection = await mysql.createConnection({
|
|
|
...dbConfig,
|
|
@@ -40,178 +41,45 @@ async function processTask(){
|
|
|
throw new Error(`表 ${table_name} 不存在`);
|
|
|
} else {
|
|
|
const [rows] = await connection.execute(
|
|
|
- `SELECT * FROM ${table_name} WHERE book_platform = 3 LIMIT 6498`
|
|
|
+ `SELECT * FROM ${table_name} WHERE is_have_iaa = -1 LIMIT 100`
|
|
|
);
|
|
|
|
|
|
if(rows.length<=0){
|
|
|
- throw "没有数据处理!"
|
|
|
+ throw -1
|
|
|
+ }
|
|
|
+ for (let index = 0; index < rows.length; index++) {
|
|
|
+ const element = rows[index];
|
|
|
+ let iaa_book_info = await require('./src/api/qm_mf/qm_mf_search_book').search_name(element.book_author,element.book_origin_name)
|
|
|
+ if(iaa_book_info!=null){
|
|
|
+ await connection.execute(
|
|
|
+ `UPDATE ${table_name} SET is_have_iaa = 1 , iaa_book_id = ${iaa_book_info.book_id} WHERE book_id = ${element.book_id}`
|
|
|
+ );
|
|
|
+ }else{
|
|
|
+ await connection.execute(
|
|
|
+ `UPDATE ${table_name} SET is_have_iaa = 0 WHERE book_id = ${element.book_id}`
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // let id_list = []
|
|
|
-
|
|
|
- // let video_id_list = []
|
|
|
- // let video_data_list = []
|
|
|
- // rows.forEach((row, index) => {
|
|
|
- // id_list.push(row.id)
|
|
|
- // video_id_list.push(row.video_id)
|
|
|
- // video_data_list[row.video_id] = row
|
|
|
- // });
|
|
|
-
|
|
|
- // const [filter_rows] = await connection.execute(
|
|
|
- // `SELECT * FROM filter_data WHERE video_id IN (${video_id_list.join(",")})`
|
|
|
- // );
|
|
|
-
|
|
|
- // function getFilterById(video_id){
|
|
|
- // for (let index = 0; index < filter_rows.length; index++) {
|
|
|
- // const element = filter_rows[index];
|
|
|
- // if(element.video_id==video_id){
|
|
|
- // return element
|
|
|
- // }
|
|
|
- // }
|
|
|
- // return null
|
|
|
- // }
|
|
|
-
|
|
|
- // let need_insert_list = []
|
|
|
-
|
|
|
- // for (let index = 0; index < video_id_list.length; index++) {
|
|
|
- // const video_id = video_id_list[index];
|
|
|
- // let d = getFilterById(video_id)
|
|
|
- // if(d==null){
|
|
|
- // need_insert_list.push(video_data_list[video_id])
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // let client = new HttpClient()
|
|
|
- // let values = []
|
|
|
-
|
|
|
- // let sid_tt_status = true
|
|
|
- // for (let index = 0; index < need_insert_list.length; index++) {
|
|
|
- // const row = need_insert_list[index];
|
|
|
- // if(helper.checkChannel(row.guajian_link,"pages/theatre/index")){
|
|
|
- // let key = getCodeFromUrl(row.guajian_link)
|
|
|
- // let book_name = ""
|
|
|
- // let book_id = ""
|
|
|
- // if(key!=null){
|
|
|
-
|
|
|
- // let fq_book_result = await get_fq_book_tab_controllers.getData({ book_id: key });
|
|
|
- // if(fq_book_result.success){
|
|
|
- // book_name = JSON.parse(fq_book_result.data.info.info).book_name
|
|
|
- // book_id = fq_book_result.data.book_id
|
|
|
- // }else{
|
|
|
- // let sid_tt = await tools.getFqSidtt()
|
|
|
- // let {url,params,headers} = helper.getFqRequestOpt(key,sid_tt)
|
|
|
- // let response = await client.fqProxyGet(url, params,headers)
|
|
|
-
|
|
|
-
|
|
|
- // if(response.code==0){
|
|
|
- // let obj = response['data']
|
|
|
-
|
|
|
- // book_name = obj['video_info'].book_name
|
|
|
- // book_id = obj['video_info'].book_id
|
|
|
-
|
|
|
- // let fq_book = {}
|
|
|
- // fq_book.key = key
|
|
|
- // let fq_book_data = {book_name:book_name,book_id:book_id,info:JSON.stringify(obj['video_info'])}
|
|
|
- // await CMD.add_fq_book(fq_book,fq_book_data)
|
|
|
- // }else{
|
|
|
- // if(response==""){
|
|
|
- // sid_tt_status = false
|
|
|
- // }
|
|
|
- // console.log("error response:",response)
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // }else{
|
|
|
- // console.log("key = null:",row.guajian_link)
|
|
|
- // }
|
|
|
-
|
|
|
- // if(book_name!=""){
|
|
|
- // values.push({video_id:row.video_id,
|
|
|
- // video_link:row.video_link,
|
|
|
- // title:row.title,
|
|
|
- // book_name:book_name,
|
|
|
- // book_id:book_id,
|
|
|
- // tg_platform_id:config.platform_fanqie_dx,
|
|
|
- // like_num:row.like_num,
|
|
|
- // comment_num:row.comment_num,
|
|
|
- // shared_num:row.shared_num,
|
|
|
- // kepp_num:row.kepp_num,
|
|
|
- // create_time:new Date(),
|
|
|
- // create_day:date,
|
|
|
- // status:0,
|
|
|
- // data_source:2
|
|
|
- // })
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // console.log("values:",values)
|
|
|
-
|
|
|
- // if(values.length>0&&sid_tt_status){
|
|
|
-
|
|
|
- // const formattedValues = values.map(item => [
|
|
|
- // item.video_id,
|
|
|
- // item.video_link,
|
|
|
- // item.title,
|
|
|
- // item.book_name,
|
|
|
- // item.book_id,
|
|
|
- // item.tg_platform_id,
|
|
|
- // item.like_num,
|
|
|
- // item.comment_num,
|
|
|
- // item.shared_num,
|
|
|
- // item.kepp_num,
|
|
|
- // item.create_time,
|
|
|
- // item.create_day,
|
|
|
- // item.status,
|
|
|
- // item.data_source
|
|
|
- // ]);
|
|
|
- // // 插入数据
|
|
|
- // const insertSQL = `
|
|
|
- // INSERT IGNORE INTO filter_data
|
|
|
- // (video_id, video_link, title, book_name,
|
|
|
- // book_id, tg_platform_id, like_num, comment_num, shared_num,
|
|
|
- // kepp_num, create_time, create_day, status,data_source)
|
|
|
- // VALUES ?
|
|
|
- // `;
|
|
|
-
|
|
|
- // await connection.query(insertSQL, [formattedValues]);
|
|
|
- // }
|
|
|
-
|
|
|
-
|
|
|
- // const updateSQL = `
|
|
|
- // UPDATE xs_origin_data
|
|
|
- // SET sync_info_status = 1
|
|
|
- // WHERE FIND_IN_SET(id, ?)
|
|
|
- // `;
|
|
|
-
|
|
|
- // await connection.query(updateSQL, [id_list.join(',')]);
|
|
|
}
|
|
|
|
|
|
}catch(e){
|
|
|
+ if(e==-1){
|
|
|
+ status = -1
|
|
|
+ }
|
|
|
console.error("processTask error:",e)
|
|
|
} finally{
|
|
|
- global.setTimeout(processTask, 1000);
|
|
|
- // if(connection!=null){
|
|
|
- // await connection.end();
|
|
|
- // }
|
|
|
+ if(status!=-1){
|
|
|
+ global.setTimeout(processTask, 1000);
|
|
|
+ }else{
|
|
|
+ console.log("完成所有定义!")
|
|
|
+ }
|
|
|
+ if(connection!=null){
|
|
|
+ await connection.end();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
-CMD.add_fq_book = async function(data,response){
|
|
|
- let book_name = response.book_name
|
|
|
- let book_id = response.book_id
|
|
|
-
|
|
|
- data.book_name = book_name
|
|
|
- data.book_id = book_id
|
|
|
- let tab = {
|
|
|
- book_key:data.key,
|
|
|
- book_id:data.book_id,
|
|
|
- info:JSON.stringify(response)
|
|
|
- }
|
|
|
- return await get_fq_book_tab_controllers.createData( tab)
|
|
|
-}
|
|
|
|
|
|
CMD.init = async function(){
|
|
|
redis_help.connect((results)=>{
|