帆软 数据工厂脚本代码示例

示例1

//数据源
{
    "code": 200,
    "data": {
        "data": [
            {
                "val": 503.0962,
                "name": "BF2_L2C_BD_AI04TE3137K_1h_avg",
                "clock": "1606582800000"
            },
            {
                "val": 470.796,
                "name": "BF2_L2C_BD_AI04TE3137K_1h_avg",
                "clock": "1606586400000"
            },
            {
                "val": 452.1628,
                "name": "BF2_L2C_BD_AI04TE3137K_1h_avg",
                "clock": "1606590000000"
            },
            {
                "val": 506.4587,
                "name": "BF2_L2C_BD_AI04TE3137K_1h_avg",
                "clock": "1606593600000"
            },
            {
                "val": 406.1744,
                "name": "BF2_L2C_BD_AI04TE3137K_1h_avg",
                "clock": "1606597200000"
            },
            {
                "val": 339.2718,
                "name": "BF2_L2C_BD_AI04TE3137K_1h_avg",
                "clock": "1606600800000"
            },
            {
                "val": 327.5219,
                "name": "BF2_L2C_BD_AI04TE3137K_1h_avg",
                "clock": "1606604400000"
            },
            {
                "val": 370.6676,
                "name": "BF2_L2C_BD_AI04TE3137K_1h_avg",
                "clock": "1606608000000"
            },
            {
                "val": 426.16,
                "name": "BF2_L2C_BD_AI04TE3137K_1h_avg",
                "clock": "1606611600000"
            },
            {
                "val": 112.5026,
                "name": "BF2_L2C_BD_TE_LG0204_1_1h_avg",
                "clock": "1606582800000"
            },
            {
                "val": 112.247,
                "name": "BF2_L2C_BD_TE_LG0204_1_1h_avg",
                "clock": "1606586400000"
            },
            {
                "val": 111.6722,
                "name": "BF2_L2C_BD_TE_LG0204_1_1h_avg",
                "clock": "1606590000000"
            },
            {
                "val": 112.6331,
                "name": "BF2_L2C_BD_TE_LG0204_1_1h_avg",
                "clock": "1606593600000"
            },
            {
                "val": 113.1826,
                "name": "BF2_L2C_BD_TE_LG0204_1_1h_avg",
                "clock": "1606597200000"
            },
            {
                "val": 111.7385,
                "name": "BF2_L2C_BD_TE_LG0204_1_1h_avg",
                "clock": "1606600800000"
            },
            {
                "val": 111.7101,
                "name": "BF2_L2C_BD_TE_LG0204_1_1h_avg",
                "clock": "1606604400000"
            },
            {
                "val": 112.0485,
                "name": "BF2_L2C_BD_TE_LG0204_1_1h_avg",
                "clock": "1606608000000"
            },
            {
                "val": 112.7521,
                "name": "BF2_L2C_BD_TE_LG0204_1_1h_avg",
                "clock": "1606611600000"
            }
        ]
    },
    "msg": "操作成功"
}
//接口配置
{
 url:"http://192.168.124.7:8181/reportTemplateTags/success",
    type:"post_raw",
    charset:"utf-8",
    header:{
       Content-Type:"application/json;charset=UTF-8"
    },
    body:{}
}

//js解析
function resolver(body){
   //获取参数要用get方法,写入要用put,长度使用size();
   //传入的是java对象,可以支持返回js的数组对象
   var data = body.get("data").get("data");
   for(var i = 0; i < data.size();i++){
     data.get(i).put("index",i);
  }
   return data;
}
//js解析(数组重组)
function resolver(body){
    var data = body.get("data").get("data");
    var resultData = [];
    for(var i = 0; i < data.size();i++){
        var item = {};
        var element = data.get(i);
        item.name = element.get("name");
        item.val = element.get("val");
        resultData.push(item);
    }
    return resultData;
}

示例2

//数据源
{
  "pageNum": 1,
  "pageSize": 20,
  "total": 20,
  "data": [
    {
      "analysis": {
        "anaid": 9,
        "brandcode": "BM_PELLETS",
        "clock": 1648483200000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 5.57,
        "P": 0.135,
        "R2": 0.23,
        "FeO": 24.17,
        "TFe": 42.01,
        "S": 0.135,
        "MgO": 6.13,
        "H2O": 0.3,
        "V2O5": 0.67,
        "SiO2": 24.24,
        "Al2O3": 1.64,
        "TiO2": 0.22
      }
    },
    {
      "analysis": {
        "anaid": 38,
        "brandcode": "BM_PELLETS",
        "clock": 1648569600000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.63,
        "P": 0.006,
        "R2": 0.124,
        "FeO": 4,
        "TFe": 53.39,
        "S": 0.008,
        "MgO": 3.42,
        "H2O": 0.3,
        "V2O5": 0.68,
        "SiO2": 5.09,
        "Al2O3": 3.75,
        "TiO2": 9.67
      }
    },
    {
      "analysis": {
        "anaid": 67,
        "brandcode": "BM_PELLETS",
        "clock": 1648656000000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.69,
        "P": 0.007,
        "R2": 0.126,
        "FeO": 3.48,
        "TFe": 52.98,
        "S": 0.009,
        "MgO": 3.47,
        "H2O": 0.3,
        "V2O5": 0.67,
        "SiO2": 5.47,
        "Al2O3": 3.88,
        "TiO2": 9.62
      }
    },
    {
      "analysis": {
        "anaid": 96,
        "brandcode": "BM_PELLETS",
        "clock": 1648742400000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.77,
        "P": 0.008,
        "R2": 0.127,
        "FeO": 3.02,
        "TFe": 52.98,
        "S": 0.012,
        "MgO": 3.92,
        "H2O": 0.8,
        "V2O5": 0.65,
        "SiO2": 6.07,
        "Al2O3": 4.38,
        "TiO2": 9.44
      }
    },
    {
      "analysis": {
        "anaid": 125,
        "brandcode": "BM_PELLETS",
        "clock": 1648828800000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.71,
        "P": 0.007,
        "R2": 0.13,
        "FeO": 3.28,
        "TFe": 53.02,
        "S": 0.011,
        "MgO": 3.47,
        "H2O": 0.9,
        "V2O5": 0.66,
        "SiO2": 5.47,
        "Al2O3": 3.98,
        "TiO2": 9.57
      }
    },
    {
      "analysis": {
        "anaid": 154,
        "brandcode": "BM_PELLETS",
        "clock": 1648915200000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.67,
        "P": 0.009,
        "R2": 0.126,
        "FeO": 4.25,
        "TFe": 53.45,
        "S": 0.011,
        "MgO": 3.42,
        "H2O": 1.1,
        "V2O5": 0.66,
        "SiO2": 5.3,
        "Al2O3": 3.93,
        "TiO2": 9.47
      }
    },
    {
      "analysis": {
        "anaid": 183,
        "brandcode": "BM_PELLETS",
        "clock": 1649001600000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.69,
        "P": 0.007,
        "R2": 0.133,
        "FeO": 2.96,
        "TFe": 53.57,
        "S": 0.01,
        "MgO": 3.43,
        "H2O": 1.6,
        "V2O5": 0.68,
        "SiO2": 5.19,
        "Al2O3": 3.87,
        "TiO2": 9.54
      }
    },
    {
      "analysis": {
        "anaid": 212,
        "brandcode": "BM_PELLETS",
        "clock": 1649088000000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.66,
        "P": 0.007,
        "R2": 0.125,
        "FeO": 3.13,
        "TFe": 52.61,
        "S": 0.011,
        "MgO": 3.39,
        "H2O": 1.1,
        "V2O5": 0.65,
        "SiO2": 5.29,
        "Al2O3": 3.94,
        "TiO2": 9.43
      }
    },
    {
      "analysis": {
        "anaid": 241,
        "brandcode": "BM_PELLETS",
        "clock": 1649174400000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.7,
        "P": 0.005,
        "R2": 0.133,
        "FeO": 3.6,
        "TFe": 53.33,
        "S": 0.013,
        "MgO": 3.39,
        "H2O": 1,
        "V2O5": 0.67,
        "SiO2": 5.26,
        "Al2O3": 3.93,
        "TiO2": 9.56
      }
    },
    {
      "analysis": {
        "anaid": 270,
        "brandcode": "BM_PELLETS",
        "clock": 1649260800000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.68,
        "P": 0.007,
        "R2": 0.131,
        "FeO": 3.3,
        "TFe": 52.88,
        "S": 0.011,
        "MgO": 3.54,
        "H2O": 1.1,
        "V2O5": 0.66,
        "SiO2": 5.21,
        "Al2O3": 3.79,
        "TiO2": 9.52
      }
    },
    {
      "analysis": {
        "anaid": 299,
        "brandcode": "BM_PELLETS",
        "clock": 1649347200000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.65,
        "P": 0.006,
        "R2": 0.126,
        "FeO": 3.39,
        "TFe": 53.25,
        "S": 0.011,
        "MgO": 3.41,
        "H2O": 1.4,
        "V2O5": 0.66,
        "SiO2": 5.16,
        "Al2O3": 3.93,
        "TiO2": 9.54
      }
    },
    {
      "analysis": {
        "anaid": 328,
        "brandcode": "BM_PELLETS",
        "clock": 1649433600000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.63,
        "P": 0.005,
        "R2": 0.128,
        "FeO": 2.8,
        "TFe": 53.27,
        "S": 0.011,
        "MgO": 3.3,
        "H2O": 1.3,
        "V2O5": 0.68,
        "SiO2": 4.94,
        "Al2O3": 3.95,
        "TiO2": 9.43
      }
    },
    {
      "analysis": {
        "anaid": 357,
        "brandcode": "BM_PELLETS",
        "clock": 1649520000000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.6,
        "P": 0.007,
        "R2": 0.127,
        "FeO": 3.23,
        "TFe": 53.74,
        "S": 0.012,
        "MgO": 3.27,
        "H2O": 0.8,
        "V2O5": 0.66,
        "SiO2": 4.71,
        "Al2O3": 3.89,
        "TiO2": 9.44
      }
    },
    {
      "analysis": {
        "anaid": 386,
        "brandcode": "BM_PELLETS",
        "clock": 1649606400000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "R2": 0.123,
        "H2O": 0.7,
        "V2O5": 0.67,
        "Al2O3": 3.89,
        "CaO": 0.62,
        "P": 0.012,
        "FeO": 2.51,
        "TFe": 54.13,
        "S": 0.011,
        "MgO": 3.04,
        "抗压强度": 1918,
        "SiO2": 5.04,
        "TiO2": 8.86
      }
    },
    {
      "analysis": {
        "anaid": 415,
        "brandcode": "BM_PELLETS",
        "clock": 1649692800000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.58,
        "P": 0.006,
        "R2": 0.122,
        "FeO": 3.5,
        "TFe": 53.48,
        "S": 0.014,
        "MgO": 3.26,
        "H2O": 0.7,
        "V2O5": 0.68,
        "SiO2": 4.77,
        "Al2O3": 3.78,
        "TiO2": 9.53
      }
    },
    {
      "analysis": {
        "anaid": 444,
        "brandcode": "BM_PELLETS",
        "clock": 1649779200000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.65,
        "P": 0.005,
        "R2": 0.127,
        "FeO": 3.81,
        "TFe": 52.72,
        "S": 0.011,
        "MgO": 3.47,
        "H2O": 0.8,
        "V2O5": 0.67,
        "SiO2": 5.12,
        "Al2O3": 3.91,
        "TiO2": 9.54
      }
    },
    {
      "analysis": {
        "anaid": 474,
        "brandcode": "BM_PELLETS",
        "clock": 1649865600000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "R2": 0.112,
        "H2O": 0.7,
        "V2O5": 0.67,
        "Al2O3": 3.96,
        "CaO": 0.6,
        "P": 0.008,
        "FeO": 3.51,
        "TFe": 53.24,
        "S": 0.017,
        "MgO": 3.42,
        "抗压强度": 1957,
        "SiO2": 5.38,
        "TiO2": 9.54
      }
    },
    {
      "analysis": {
        "anaid": 504,
        "brandcode": "BM_PELLETS",
        "clock": 1649952000000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.68,
        "P": 0.006,
        "R2": 0.131,
        "FeO": 3.31,
        "TFe": 53.71,
        "S": 0.01,
        "MgO": 3.35,
        "H2O": 0.1,
        "V2O5": 0.67,
        "SiO2": 5.18,
        "Al2O3": 3.93,
        "TiO2": 9.61
      }
    },
    {
      "analysis": {
        "anaid": 534,
        "brandcode": "BM_PELLETS",
        "clock": 1650038400000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.67,
        "P": 0.007,
        "R2": 0.122,
        "FeO": 3.73,
        "TFe": 52.93,
        "S": 0.01,
        "MgO": 3.49,
        "H2O": 1,
        "V2O5": 0.66,
        "SiO2": 5.49,
        "Al2O3": 3.91,
        "TiO2": 9.57
      }
    },
    {
      "analysis": {
        "anaid": 564,
        "brandcode": "BM_PELLETS",
        "clock": 1650124800000,
        "sampletime": null,
        "updateTime": null,
        "integral": null,
        "type": "LC",
        "bfno": null,
        "iscorrect": null,
        "sampleid": null,
        "produnit": null,
        "sampleplace": null
      },
      "values": {
        "CaO": 0.57,
        "P": 0.003,
        "R2": 0.119,
        "FeO": 3.38,
        "TFe": 53.1,
        "S": 0.009,
        "MgO": 3.32,
        "H2O": 0.8,
        "V2O5": 0.66,
        "SiO2": 4.79,
        "Al2O3": 3.71,
        "TiO2": 9.55
      }
    }
  ]
}
//接口配置
{url:"${serverIP}/bf1/analysisDayValues/clock?type=${type}&starttime=${starttime}&endtime=${endtime}&brandcode=${bm}",
    type:"get",
    charset:"utf-8",
    header:{
       Content-Type:"application/json;charset=UTF-8"
    },
    body:{
    },
}
//js解析
function resolver(body){
var data=body.get("data");
var resultData=[];
for(var i=0;i<data.size();i++){
var item={};
var element=data.get(i);
item.drum=element.get("values").get("转鼓指数");
item.V2O5=element.get("values").get("V2O5");
item.Al2O3=element.get("values").get("Al2O3");
item.CaO=element.get("values").get("CaO");
item.P=element.get("values").get("P");
item.FeO=element.get("values").get("FeO");
item.R2=element.get("values").get("R2");
item.TFe=element.get("values").get("TFe");
item.S=element.get("values").get("S");
item.MgO=element.get("values").get("MgO");
item.RO=element.get("values").get("RO");
item.SiO2=element.get("values").get("SiO2");
item.clock=element.get("analysis").get("clock");
item.bolting=element.get("values").get("筛分效率(%)")
item.Na2O=element.get("values").get("Na2O");
item.K2O=element.get("values").get("K2O");
item.returnOre=element.get("values").get("返矿>5mm");
item.Zn=element.get("values").get("Zn");
item.ten=element.get("values").get("10mm-5mm粒度")
item.TiO2=element.get("values").get("TiO2");
item.sixty=element.get("values").get("60mm-40mm粒度");
item.moreSixty=element.get("values").get("大于60mm粒度");
item.beforeSieve=element.get("values").get("筛前粉末");
item.five=element.get("values").get("5mm-20mm粒度");
item.forty=element.get("values").get("40mm-20mm粒度");
item.average=element.get("values").get("平均粒度(mm)");
item.twenty=element.get("values").get("20mm-10mm粒度")
resultData.push(item)
}
 return resultData
}

效果图

//json解析(较js解析简单,推荐使用)

{
    dataPath:"root.data",
    showmap:"path1,value1,path2,value2"
}

效果图 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值