Commit b6598e9d by gechengyang

add

parent 4392b123
......@@ -180,7 +180,7 @@ public class NoUiPresentationUtil {
}
String realPath = alias.getRelPath(aliasKey);
IBaseObject baseObject = context.getSession().getBaseObject(context.getRoot(), realPath);
data.put(aliasKey, NoUiPresentationUtil.handIBaseObject(context, baseObject, realPath));
data.put(aliasKey, handIBaseObject(context, baseObject, realPath));
}
return data;
}
......@@ -201,6 +201,68 @@ public class NoUiPresentationUtil {
return data;
}
private static String handle(Object value, IDatafield<Object> dataField) {
if (null == value)
return null;
Class<?> dataType = dataField.getDataType();
if (dataType.equals(String.class)) {
String valStr = value.toString();
return valStr;
}
if (dataType.equals(Integer.TYPE) || dataType.equals(Integer.class)) {
String data = value.toString().trim();
return data;
}
if (dataType.equals(Double.TYPE) || dataType.equals(Double.class)) {
java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
nf.setGroupingUsed(false);
// 设置数的小数部分所允许的最小位数
nf.setMinimumFractionDigits(0);
// 设置数的小数部分所允许的最大位数
nf.setMaximumFractionDigits(2);
return nf.format(value);
}
if (dataType.equals(BigDecimal.class)) {
String data = value.toString().trim();
return data;
}
if (dataType.equals(Date.class)) {
Date date = (Date) value;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(date);
}
if (dataType.equals(Long.TYPE) || dataType.equals(Long.class)) {
String data = value.toString().trim();
return data;
}
return null;
}
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
try {
Date d = sdf.parse("2018/11/11 11:11:11");
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf1.format(d));
System.out.println(new BigDecimal("999999999999.99").toString());
long b = 999999999;
String bb = b + "";
System.out.println(String.valueOf(b));
java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
nf.setGroupingUsed(false);
// 设置数的小数部分所允许的最小位数
nf.setMinimumFractionDigits(0);
// 设置数的小数部分所允许的最大位数
nf.setMaximumFractionDigits(2);
System.out.println(nf.format(999999999999.0));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Object handIBaseObject(NoUiContext context, Object val, String path) {
if (val == null)
return null;
......@@ -211,8 +273,8 @@ public class NoUiPresentationUtil {
Map<String, Object> map = new HashMap<>();
IModule module = moduleList.get(index);
Collection<IDatafield> datafields = module.getDatafields();
for (IDatafield<?> datafield : datafields) {
map.put(datafield.getName(), datafield.getValue());
for (IDatafield<Object> datafield : datafields) {
map.put(datafield.getName(), handle(datafield.getValue(), datafield));
}
list.add(map);
}
......@@ -222,7 +284,7 @@ public class NoUiPresentationUtil {
return handIBaseObject(context, val, path);
} else if (val instanceof IDatafield) {
IDatafield datafield = (IDatafield) val;
return datafield.getValue();
return handle(datafield.getValue(), datafield);
}
return null;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment