|
@@ -90,6 +90,7 @@ public class CoreUtil {
|
|
|
return setPropertyList(list, "name", "standName", map);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 循环向上转型, 获取对象的 DeclaredField
|
|
|
* @param object : 子类对象
|
|
@@ -171,6 +172,48 @@ public class CoreUtil {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public static <T> List<String> setPropertyList(List<T> list, String name, String detailName,String uniqueName, Map<String, String> map) {
|
|
|
+ List<String> res = new ArrayList<>();
|
|
|
+ if (ListUtil.isEmpty(list)) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ for (T t : list) {
|
|
|
+ try {
|
|
|
+ setFieldValue(t, name, detailName,uniqueName, map);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void setFieldValue(Object object, String name, String standName,String unique, Map<String, String> value){
|
|
|
+
|
|
|
+ //根据 对象和属性名通过反射 调用上面的方法获取 Field对象
|
|
|
+ Field field = getDeclaredField(object, name) ;
|
|
|
+ Field field1 = getDeclaredField(object, standName) ;
|
|
|
+ //抑制Java对其的检查
|
|
|
+ field.setAccessible(true) ;
|
|
|
+ field1.setAccessible(true) ;
|
|
|
+
|
|
|
+ try {
|
|
|
+ //将 object 中 field 所代表的值 设置为 value
|
|
|
+ String key = (String)field.get(object);
|
|
|
+ String key1 = (String)field1.get(object);
|
|
|
+ String lis_c = key+key1;
|
|
|
+ if (value != null && value.get(lis_c) != null) {
|
|
|
+ Field standField = getDeclaredField(object, unique) ;
|
|
|
+ standField.setAccessible(true) ;
|
|
|
+ standField.set(object, value.get(lis_c));
|
|
|
+ }
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 开单合理性通用提示信息
|
|
|
*
|