| 
															
																@ -3,7 +3,12 @@ package com.yihu.jw.base.util; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import com.alibaba.fastjson.JSONArray; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import com.alibaba.fastjson.JSONObject; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import com.fasterxml.jackson.databind.ObjectMapper; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import org.apache.commons.beanutils.BeanUtils; 
															 | 
															
															 | 
															
																import org.apache.commons.beanutils.BeanUtils; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import org.springframework.beans.factory.annotation.Autowired; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import org.springframework.util.CollectionUtils; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import java.beans.BeanInfo; 
															 | 
															
															 | 
															
																import java.beans.BeanInfo; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import java.beans.IntrospectionException; 
															 | 
															
															 | 
															
																import java.beans.IntrospectionException; 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -18,6 +23,24 @@ import java.util.*; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 * @project jw2.0 
															 | 
															
															 | 
															
																 * @project jw2.0 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 */ 
															 | 
															
															 | 
															
																 */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																public class JavaBeanUtils { 
															 | 
															
															 | 
															
																public class JavaBeanUtils { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    private static JavaBeanUtils javaBeanUtils = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    private JavaBeanUtils(){} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public static JavaBeanUtils getInstance(){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        if (javaBeanUtils == null) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            synchronized (JavaBeanUtils.class) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                if (javaBeanUtils == null) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    javaBeanUtils = new JavaBeanUtils(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        return javaBeanUtils; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    @Autowired 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    private ObjectMapper objectMapper; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    /** 
															 | 
															
															 | 
															
																    /** 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * 将一个 Map 对象转化为一个 JavaBean 
															 | 
															
															 | 
															
																     * 将一个 Map 对象转化为一个 JavaBean 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * 
															 | 
															
															 | 
															
																     * 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -36,7 +59,7 @@ public class JavaBeanUtils { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     *             如果调用属性的 setter 方法失败 
															 | 
															
															 | 
															
																     *             如果调用属性的 setter 方法失败 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     */ 
															 | 
															
															 | 
															
																     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @SuppressWarnings("unchecked") 
															 | 
															
															 | 
															
																    @SuppressWarnings("unchecked") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public static Object map2Bean(Class type, Map map) 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public  Object map2Bean(Class type, Map map) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            throws IntrospectionException, IllegalAccessException, 
															 | 
															
															 | 
															
																            throws IntrospectionException, IllegalAccessException, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            InstantiationException, InvocationTargetException { 
															 | 
															
															 | 
															
																            InstantiationException, InvocationTargetException { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        Object obj = type.newInstance(); // 创建 JavaBean 对象 
															 | 
															
															 | 
															
																        Object obj = type.newInstance(); // 创建 JavaBean 对象 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -58,7 +81,7 @@ public class JavaBeanUtils { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     *             如果调用属性的 setter 方法失败 
															 | 
															
															 | 
															
																     *             如果调用属性的 setter 方法失败 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     */ 
															 | 
															
															 | 
															
																     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @SuppressWarnings("unchecked") 
															 | 
															
															 | 
															
																    @SuppressWarnings("unchecked") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public static Map bean2Map(Object bean) throws IntrospectionException, 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public  Map bean2Map(Object bean) throws IntrospectionException, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            IllegalAccessException, InvocationTargetException { 
															 | 
															
															 | 
															
																            IllegalAccessException, InvocationTargetException { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        Class type = bean.getClass(); 
															 | 
															
															 | 
															
																        Class type = bean.getClass(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        Map returnMap = new HashMap(); 
															 | 
															
															 | 
															
																        Map returnMap = new HashMap(); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -94,7 +117,7 @@ public class JavaBeanUtils { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @time:2014年9月3日上午10:37:32 
															 | 
															
															 | 
															
																     * @time:2014年9月3日上午10:37:32 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     */ 
															 | 
															
															 | 
															
																     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @SuppressWarnings("unchecked") 
															 | 
															
															 | 
															
																    @SuppressWarnings("unchecked") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public static List<Map> beans2Maps(List<Object> beans) 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public  List<Map> beans2Maps(List<Object> beans) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            throws IllegalAccessException, InvocationTargetException, 
															 | 
															
															 | 
															
																            throws IllegalAccessException, InvocationTargetException, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            IntrospectionException { 
															 | 
															
															 | 
															
																            IntrospectionException { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        List<Map> maps = new ArrayList<Map>(); 
															 | 
															
															 | 
															
																        List<Map> maps = new ArrayList<Map>(); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -119,7 +142,7 @@ public class JavaBeanUtils { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @time:2014年9月3日上午10:40:00 
															 | 
															
															 | 
															
																     * @time:2014年9月3日上午10:40:00 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     */ 
															 | 
															
															 | 
															
																     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @SuppressWarnings("unchecked") 
															 | 
															
															 | 
															
																    @SuppressWarnings("unchecked") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public static List<Object> mapstoBeans(Class type, List<Map> maps) 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public  List<Object> mapstoBeans(Class type, List<Map> maps) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            throws IntrospectionException, IllegalAccessException, 
															 | 
															
															 | 
															
																            throws IntrospectionException, IllegalAccessException, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            InstantiationException, InvocationTargetException { 
															 | 
															
															 | 
															
																            InstantiationException, InvocationTargetException { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        List<Object> beans = new ArrayList<Object>(); 
															 | 
															
															 | 
															
																        List<Object> beans = new ArrayList<Object>(); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -142,7 +165,7 @@ public class JavaBeanUtils { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @throws InvocationTargetException 
															 | 
															
															 | 
															
																     * @throws InvocationTargetException 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @time:2014年9月3日上午11:47:45 
															 | 
															
															 | 
															
																     * @time:2014年9月3日上午11:47:45 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     */ 
															 | 
															
															 | 
															
																     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public static Object copyProperties(Object toBean, Object fromBean) 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public  Object copyProperties(Object toBean, Object fromBean) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            throws IllegalAccessException, InvocationTargetException { 
															 | 
															
															 | 
															
																            throws IllegalAccessException, InvocationTargetException { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        if (fromBean == null) { 
															 | 
															
															 | 
															
																        if (fromBean == null) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return null; 
															 | 
															
															 | 
															
																            return null; 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -164,7 +187,7 @@ public class JavaBeanUtils { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @throws ClassNotFoundException 
															 | 
															
															 | 
															
																     * @throws ClassNotFoundException 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @time:2014年9月3日下午12:05:23 
															 | 
															
															 | 
															
																     * @time:2014年9月3日下午12:05:23 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     */ 
															 | 
															
															 | 
															
																     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public static Object copyProperties(Class toClassBean, Object fromBean) 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public  Object copyProperties(Class toClassBean, Object fromBean) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            throws IllegalAccessException, InvocationTargetException, 
															 | 
															
															 | 
															
																            throws IllegalAccessException, InvocationTargetException, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            InstantiationException, ClassNotFoundException { 
															 | 
															
															 | 
															
																            InstantiationException, ClassNotFoundException { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        if (fromBean == null) { 
															 | 
															
															 | 
															
																        if (fromBean == null) { 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -190,7 +213,7 @@ public class JavaBeanUtils { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @throws ClassNotFoundException 
															 | 
															
															 | 
															
																     * @throws ClassNotFoundException 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @time:2014年9月3日下午12:33:24 
															 | 
															
															 | 
															
																     * @time:2014年9月3日下午12:33:24 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     */ 
															 | 
															
															 | 
															
																     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public static List copyProperties(Class toClassBean, List beans) 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public List copyProperties(Class toClassBean, List beans) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            throws IllegalAccessException, InvocationTargetException, 
															 | 
															
															 | 
															
																            throws IllegalAccessException, InvocationTargetException, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            InstantiationException, ClassNotFoundException { 
															 | 
															
															 | 
															
																            InstantiationException, ClassNotFoundException { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        List list = new ArrayList(); 
															 | 
															
															 | 
															
																        List list = new ArrayList(); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -200,4 +223,37 @@ public class JavaBeanUtils { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        return list; 
															 | 
															
															 | 
															
																        return list; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    } 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    /** 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																     * map转为json 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																     * @return 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public String mapJson(Map<String, Object> map) throws Exception { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        if (CollectionUtils.isEmpty(map)) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            return "paramter is null"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        List<Map<String, Object>> result = new ArrayList<>(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        JSONArray jsonArray = new JSONArray(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        JSONObject jsonObject = JSONObject.parseObject(objectMapper.writeValueAsString(map)); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        return jsonArray.toJSONString(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    /** 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																     * map转为json 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																     * @return 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public String mapListJson(List<Map<String, Object>> mapList) throws Exception { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        if (CollectionUtils.isEmpty(mapList)) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            return "paramter is null"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        List<Map<String, Object>> result = new ArrayList<>(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        JSONArray jsonArray = new JSONArray(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        for(Map<String, Object> map : mapList){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            JSONObject jsonObject = JSONObject.parseObject(objectMapper.writeValueAsString(map)); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            jsonArray.add(jsonObject); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																        return jsonArray.toJSONString(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																} 
															 | 
															
															 | 
															
																} 
															 |