const TaskBase=require("../task.base");
const system=require("../../system")
class CheckDownloadTask extends TaskBase{
  constructor(){
    super(TaskBase.getServiceName(CheckDownloadTask));
    this.rs=system.getObject("util.restClient");
  }
  async subDoTask(){
    //循环检查downloadtasks队列中的记录
    console.log("CheckDownloadTask.........outer");
    var xt=await this.redisClient.rpop("downloadtaxtasks");
    console.log("CheckDownloadTask........."+xt);
    while(xt && xt.indexOf("_")>=0){
       console.log("CheckDownloadTask inner.........");
       var ccid=xt.split("_")[0];
       var cemail=xt.split("_")[1];
      //await this.rs.execPost({cid:ccid,email:cemail},"http://127.0.0.1:3000/web/taskCtl/makerpt");
        this.rs.execPost({sharecode:ccid,email:cemail},"https://boss.gongsibao.com/web/taskCtl/makerpt");
       xt=await this.redisClient.rpop("downloadtaxtasks");
    }
  }
}
module.exports=CheckDownloadTask;
