zoukankan      html  css  js  c++  java
  • 标准数据补零操作

    根据项目需要,需要对不存在的数据加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);
  • 相关阅读:
    动态二维码
    二维码
    购物车
    logback学习与配置使用
    UML类图几种关系的总结
    java.lang.Excetion,java.lang.RuntimeException,java.lang.Error有什么区别?
    Java编程最差实践
    Hibernate利用@DynamicInsert和@DynamicUpdate生成动态SQL语句
    从 Java 代码到 Java 堆
    Project configuration is not up-to-date with pom.xml
  • 原文地址:https://www.cnblogs.com/liubeimeng/p/6644497.html
Copyright © 2011-2022 走看看