1
0

2 Коммитууд 525c989f87 ... 4e7bb02a1e

Эзэн SHA1 Мессеж Огноо
  lisheng 4e7bb02a1e Merge branch 'master' of http://111.75.220.136:10030/turborao/jyyy 1 өдөр өмнө
  lisheng bdcff27f3c 1.报销工作台代码插件提交 1 өдөр өмнө

+ 63 - 0
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/common/util/CommonUtils.java

@@ -0,0 +1,63 @@
+package nckd.jimin.jyyy.fi.common.util;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import kd.bos.algo.DataSet;
+
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+public class CommonUtils {
+
+    public static Set getFiledFromDataSet(DataSet dt , String field){
+        DataSet copy = dt.copy();
+        Set datas = new HashSet();
+        List<String> fileds = Arrays.stream(copy.getRowMeta().getFieldNames()).collect(Collectors.toList());
+        while (copy.hasNext()){
+            if(fileds.contains(field)){
+                datas.add(copy.next().get(field));
+            }
+        }
+        return datas;
+    }
+
+    public static JSONArray transDataSetJson(DataSet dt , String... selectFiled){
+        JSONArray jsonArray = new JSONArray();
+        List<String> fileds = Arrays.stream(dt.getRowMeta().getFieldNames()).collect(Collectors.toList());
+        while (dt.hasNext()){
+            JSONObject obj = new JSONObject();
+            for(String field : selectFiled){
+                if(fileds.contains(field)){
+                    obj.put(field,dt.next().get(field));
+                }
+            }
+        }
+        return jsonArray;
+    }
+
+    public static Set getFieldFormArray(JSONArray jsonArray , String filed){
+        Set datas = new HashSet(jsonArray.size());
+        for(int i = 0 ; i < jsonArray.size(); i++){
+            JSONObject jsonObject = jsonArray.getJSONObject(i);
+            datas.add(jsonObject.get(filed));
+        }
+
+        return datas;
+    }
+
+    public static DataSet joinDataSetList(List<DataSet> dataSetList){
+        DataSet dataSet = null;
+        for(DataSet dt : dataSetList){
+            if(dataSet == null){
+                dataSet = dt;
+            }else{
+                dataSet = dt.union(dataSet);
+            }
+        }
+        return dataSet;
+    }
+}