如何根据计时器条目使计时器循环运行

时间:2017-07-25 11:39:04

标签: javascript angular timer

我有一个计时器,它有一个圆圈。圆圈也随着计时器的运行条目一起移动。如果我玩圆圈,它会按秒移动,如果我暂停,圆圈也会暂停,停止意味着它会回到零。但现在如果我运行计时器并更改页面,计时器圈将前进和后退。它没有按照目前的秒数运行。它正在接收两个我无法从问题出现的条目。请帮忙 我特此分享我的代码,请帮忙:

HTML代码

                this.ApiService
                    .runningEntries(this.user_id)
                    .subscribe(
                      entries  => {
                       if(entries.current) {
                         this.currentTask = entries.current;
                         var miliSecond = entries.current.ms;
                         var second = parseInt(miliSecond) / 1000;
                         this.current = parseInt(second.toFixed(2))
                         if(this.current < 0)
                          {
                          this.current = 0;
                          }
                         this.playPauseStopUnsubscribe.unsubscribe();
                         var last = entries.current.times[entries.current.times.length - 1];
                         if((last.state == 'start') || (last.state == 'resume')) {
                           this.play = true;
                         } else if(last.state == 'pause') {
                           this.play = false;
                         }
                       }
                    }

track.ts

this.ApiService
        .checklogin()
        .subscribe(
          user  => {
            /*Get Running Entries */  
            this.ApiService
                .runningEntries(user.user._id)
                .subscribe(
                    entries  => {
                     if(entries.current) {
                        var miliSecond = entries.current.ms;
                        var second = parseInt(miliSecond) / 1000;
                        second = parseInt(second.toFixed(2))
                        this.start = second;
                        var length = entries.current.times.length;
                        var last_entry = entries.current.times[length - 1];
                        if((last_entry.state == 'start') || (last_entry.state == 'resume')) {
                           this.startTimer();
                        } else if(last_entry.state == 'pause') {
                           this.pauseInitTimer();

                        }
                     }
                 }, error =>{
                    //console.log(error);
                 }); 

time.ts

MongoClient mongoClient = new MongoClient( "localhost" , 27017 );
           DB db = mongoClient.getDB("yourdb_name");
           System.out.println("Connected to Database successfully");
           DBCollection coll = db.getCollection("your_collection name");
           System.out.println("Collection your_collection name selected successfully");

                DBCollection OR = db.getCollection("Input_Container");
                System.out.println("Collection Device_Details selected successfully");
                OR.drop();
                DBObject arg1 = null;
                //coll.update(query, update);
                DBCollection OR_UPLOAD = 
                db.createCollection("Input_Container", arg1);
                String path =" your file path";

                File myFile = new File(path);
                FileInputStream inputStream = new FileInputStream(myFile);
                XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
                int number=workbook.getNumberOfSheets();
                  System.out.println("NumberOfSheets "+number);

                  for(int i=0;i<number;i++)
                  {
                XSSFSheet sheet = workbook.getSheetAt(i);
                int col_value=sheet.getRow(0).getLastCellNum();
                int row_num= sheet.getLastRowNum();
                System.out.println("row_num "+row_num);
                List<String> DBheader = new ArrayList<String>();
                List<String> Data = new ArrayList<String>();

                for(int z=1;z<=row_num;z++){
                     DBheader.clear();
                     Data.clear();
                 for(int j=0;j<col_value;j++)
                {
                    if(sheet.getRow(0).getCell(j).toString()!=null || sheet.getRow(0)!=null)
                    {
                    String cel_value = sheet.getRow(0).getCell(j).toString();
                    DBheader.add(cel_value.trim());
                    }
                    else{
                        break;

                    }
                }
                for(int k=0;k<col_value;k++){
                    String data =" ";   
                    if(sheet.getRow(z).getCell(k)!=null)
                    {
                    data =  sheet.getRow(z).getCell(k).toString();
                    }
                    Data.add(data.trim());

                    }
                BasicDBObject doc = new BasicDBObject();
                System.out.println("Data.size() "+Data.size());

                int l=0;
                for(String headers:DBheader)
                { 
                if(l>Data.size()){break;}
                    doc.append(headers, Data.get(l));
                    l++;
                 }
                OR_UPLOAD.insert(doc);
                }

            }System.out.println("File Upload Done");
                  mongoClient.close();

0 个答案:

没有答案