其他分享
首页 > 其他分享> > Thingworx扩展开发之传参Infotable的处理

Thingworx扩展开发之传参Infotable的处理

作者:互联网

    thingworx的主要优点之一就是它的扩展性比较强,开发者可以根据自己需求功能的不同定制开发特定功能的扩展(包括extension和wiedget),而在开发extension过程中经常会遇到需要传参infotable的情况,为了便于测试,可用以下代码直接将传参的infotable转化为list<Object[]>,这样就能直接在java类中测试运行而不用依赖于thingworx的环境了.

代码如下:

    

String[] columns= {"hh","UBdh","UBdhh","scddgx","wlbm","wlms","kjpsl","sjgzsl","xsddhh","Mm","psqy","xlh","hjh","bz"};;
        //Body为传入的Infotable
        
        
        //String message = "";
        List<HashMap<String, Object>> listMap = new ArrayList<>();
        int length1 = Body.getLength().intValue();
        String aa;
        for (int i = 0; i < length1; i++)
        {
          ValueCollection rowValue = Body.getRow(i);
          Set<String> keys = rowValue.keySet();
          HashMap<String,Object> dataMap = new HashMap<>();
          for (String key : keys){    
              aa = " ";
              if(rowValue.getStringValue(key).isEmpty()||rowValue.getStringValue(key).length() == 0) {
                   aa = "  ";
              }else {
                   aa = rowValue.getStringValue(key);
              }
            dataMap.put(key, aa);
          }
          listMap.add(dataMap);
        };
        
        
        List<Object[]>  dataList = new ArrayList<Object[]>();
        Object[] objs = null;
        for (int i = 0; i < listMap.size(); i++) {
            HashMap<String, Object> data = listMap.get(i);
            objs = new Object[columns.length];
            for(int q = 0; q < columns.length; q++) {
                if(data.get(columns[q]) != null) {
                    objs[q] = data.get(columns[q]);
                }
                else {
                    objs[q] = " ";
                }               
            }           
            dataList.add(objs);
        }
       // GenerateExcel ge=new GenerateExcel(shdd, psdh, zjsl, jsz, psry, fckcd, dysj, jskcd, jssj, dataList,RepositoryName);
       // message = ge.Generate();
        
       // return message;

标签:aa,之传参,rowValue,objs,key,new,Infotable,columns,Thingworx
来源: https://www.cnblogs.com/shenjikongjian/p/12196325.html