• 标准数据补零操作


    根据项目需要,需要对不存在的数据加0操作,标准数据补零操作。需要有一个标准数据,真实数据可能有的部分没有数据。就是用有数据的就修改标准数据。没有修改的就是0.

     1     var k_val = [
     2         {"file_count":11,"file_size":120171220,"file_type":4,"id":485,h:"00",m:"0","time":"2017-03-29 00:00:01"},
     3         {"file_count":88,"file_size":120171220,"file_type":4,"id":492,h:"00",m:"3","time":"2017-03-29 00:30:01"},
     4         {"file_count":55,"file_size":120171220,"file_type":4,"id":499,h:"02",m:"0","time":"2017-03-29 02:00:01"},
     5         {"file_count":34,"file_size":120171220,"file_type":4,"id":506,h:"02",m:"3","time":"2017-03-29 02:30:01"}];
     6 
     7     var s_val = [
     8         {"file_count":0,"file_size":0,"file_type":4,"id":485,"time":"2017-03-29 00:00:01",h:"00",m:"0"},
     9         {"file_count":0,"file_size":0,"file_type":4,"id":492,"time":"2017-03-29 00:30:01",h:"00",m:"3"},
    10         {"file_count":0,"file_size":0,"file_type":4,"id":499,"time":"2017-03-29 01:00:01",h:"01",m:"0"},
    11         {"file_count":0,"file_size":0,"file_type":4,"id":506,"time":"2017-03-29 01:30:01",h:"01",m:"3"},
    12         {"file_count":0,"file_size":0,"file_type":4,"id":513,"time":"2017-03-29 02:00:01",h:"02",m:"0"},
    13         {"file_count":0,"file_size":0,"file_type":4,"id":520,"time":"2017-03-29 02:30:01",h:"02",m:"3"},
    14         {"file_count":0,"file_size":0,"file_type":4,"id":527,"time":"2017-03-29 03:00:01",h:"03",m:"0"},
    15         {"file_count":0,"file_size":0,"file_type":4,"id":527,"time":"2017-03-29 03:30:01",h:"03",m:"3"}];
    16 
    17     for(var i = 0 ; i < k_val.length ; i++){
    18         var hour = parseInt(k_val[i].h).toFixed(0);
    19         var minute = parseInt(k_val[i].m).toFixed(0);
    20         if(minute == 3){
    21             s_val[hour*2+1].file_count =k_val[i].file_count;
    22         }else{
    23             s_val[hour*2].file_count =k_val[i].file_count;
    24         }
    25 
    26     }
    27     console.log(s_val);
  • 相关阅读:
    [转] 英语飙升的好方法
    jndi数据源方式配制SPY
    OJB查询
    ODP.NET应用之我所见
    C#中利用ODP实现瞬间导入百万级数据详解
    Sys.Extended.UI' is null or not an object 中文的訊息
    oracle数据库连接字符串
    seo
    宽幅FLASH产品展示代码多图带左右显示按钮 图
    网站盈利模式分类详解
  • 原文地址:https://www.cnblogs.com/liubeimeng/p/6644497.html
Copyright © 2020-2023  润新知