|
@@ -7,6 +7,10 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
|
|
|
+import net.sf.json.JSONArray;
|
|
|
+import net.sf.json.util.JSONUtils;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.eis.exception.SystemException;
|
|
|
|
|
@@ -82,6 +86,28 @@ public class BaseUtil {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 数组转化成字符串, null和空字符自动去掉
|
|
|
+ *
|
|
|
+ * @param arr
|
|
|
+ * 待转化数组
|
|
|
+ * @param ch
|
|
|
+ * 分割符
|
|
|
+ */
|
|
|
+ public static String parseArray2Str(Object[] arr, String ch) {
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (Object s : arr) {
|
|
|
+ if (s != null && !s.toString().trim().equals("")) {
|
|
|
+ sb.append(s);
|
|
|
+ sb.append(ch);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sb.length() > 0 && ch.length() > 0) {
|
|
|
+ return sb.substring(0, sb.lastIndexOf(ch));
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
* 数据转换,将传入的数据转成需要调用接口规定的数据格式
|
|
@@ -89,7 +115,7 @@ public class BaseUtil {
|
|
|
* @param keyMap UAS与外部系统的键 映射
|
|
|
* @return
|
|
|
*/
|
|
|
- public static Map<String, Object> JsonToMap(String jsonStr, Map<String, String> keyMap){
|
|
|
+ public static Map<String, Object> jsonToMap(String jsonStr, Map<String, String> keyMap){
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
Map<String, Object> jsonMap = JSONObject.parseObject(jsonStr);
|
|
|
Set<String> set = jsonMap.keySet();
|
|
@@ -103,5 +129,11 @@ public class BaseUtil {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ public static String parsetListToJson(Map<String, Object> formMap,List<Map<String, Object>> gridList){
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("form", JSON.toJSON(formMap));
|
|
|
+ json.put("grid", JSONArray.fromObject(gridList));
|
|
|
+ return json.toString();
|
|
|
+ }
|
|
|
|
|
|
}
|