| | |
| | | import com.vci.ubcs.starter.web.wrapper.VciQueryWrapperForDO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.ResourceUtils; |
| | | |
| | |
| | | import java.math.BigInteger; |
| | | import java.net.InetAddress; |
| | | import java.net.NetworkInterface; |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | |
| | | } |
| | | |
| | | public static String getTableName(String btmname) { |
| | | return (VciQueryWrapperForDO.USER_TABLE_COMPATIBILITY ? "pl_code_" : "vcibt_") + btmname.trim().toLowerCase(); |
| | | return (VciQueryWrapperForDO.USER_TABLE_COMPATIBILITY ? "vcibt_" : "pl_code_") + btmname.trim().toLowerCase(); |
| | | } |
| | | |
| | | public static Field getTsField(Class c) { |
| | |
| | | * @return Map对象 |
| | | * @version 2016年3月20日 11:03:01 |
| | | */ |
| | | public static Map convertBean2Map(Object bean) throws Exception { |
| | | public static Map convertBean2Map(Object bean,Set<String> existFild) throws Exception { |
| | | Class type = bean.getClass(); |
| | | Map returnMap = new HashMap(); |
| | | BeanInfo beanInfo = Introspector.getBeanInfo(type); |
| | | PropertyDescriptor[] propertyDescriptors = beanInfo |
| | | .getPropertyDescriptors(); |
| | | Field[] declaredFields = type.getDeclaredFields(); |
| | | Map<String, String> fieldMap = new HashMap(); |
| | | String existField = ""; |
| | | if(existFild == null){ |
| | | existFild = new HashSet<>(); |
| | | } |
| | | for (Field declaredField : declaredFields) { |
| | | declaredField.setAccessible(true); |
| | | |
| | |
| | | if(fieldValue == false){ |
| | | existField += declaredField.getName().toLowerCase()+","; |
| | | } |
| | | String value = tableField.value(); |
| | | if(net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils.isNotBlank(value)){ |
| | | fieldMap.put(declaredField.getName(), value); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Map mapData = new HashMap<>(); |
| | | for (int i = 0, n = propertyDescriptors.length; i <n ; i++) { |
| | | PropertyDescriptor descriptor = propertyDescriptors[i]; |
| | | String propertyName = descriptor.getName(); |
| | |
| | | |
| | | if (result != null) { |
| | | if ("data".equals(propertyName)){ |
| | | returnMap.putAll((Map) result); |
| | | }else { |
| | | returnMap.put(propertyName, result); |
| | | mapData = (Map) result; |
| | | }else if(existFild.contains((fieldMap.containsKey(propertyName)?fieldMap.get(propertyName):propertyName).toLowerCase())){ |
| | | returnMap.put(fieldMap.containsKey(propertyName)?fieldMap.get(propertyName).toLowerCase():propertyName.toLowerCase(), result); |
| | | } |
| | | } else { |
| | | returnMap.put(propertyName, ""); |
| | | } else if(existFild.contains((fieldMap.containsKey(propertyName)?fieldMap.get(propertyName):propertyName).toLowerCase())){ |
| | | returnMap.put(fieldMap.containsKey(propertyName)?fieldMap.get(propertyName).toLowerCase():propertyName.toLowerCase(), ""); |
| | | } |
| | | } |
| | | } |
| | | //作用主要用于已MAP中的数据为准,bean里面遇到字段相同且map里面数据为空,则使用bean里面的值, |
| | | // Map resulMapChild = (Map) mapData; |
| | | for (Object o : mapData.keySet()) { |
| | | if(existFild == null || existFild.contains(String.valueOf(o).toLowerCase())){ |
| | | if((Func.isNotBlank(String.valueOf(returnMap.get(String.valueOf(o).toLowerCase()))) |
| | | && returnMap.get(String.valueOf(o).toLowerCase()) !=null) |
| | | && Func.isBlank(String.valueOf(mapData.get(o)))){ |
| | | continue; |
| | | } |
| | | returnMap.put(String.valueOf(o).toLowerCase(),mapData.get(o)); |
| | | } |
| | | } |
| | | return returnMap; |
| | |
| | | // String sqlField = camelToUnderscore(key); |
| | | |
| | | |
| | | if (map.containsKey(key.toUpperCase())) { |
| | | if (map.containsKey(key.toUpperCase(Locale.ROOT))||map.containsKey(key.toLowerCase(Locale.ROOT))) { |
| | | try { |
| | | Object value = map.get(key.toUpperCase()); |
| | | Object value=""; |
| | | if (map.containsKey(key.toUpperCase(Locale.ROOT))) { |
| | | value = map.get(key.toUpperCase()); |
| | | }else if(map.containsKey(key.toLowerCase(Locale.ROOT))){ |
| | | value = map.get(key.toLowerCase()); |
| | | } |
| | | // 得到property对应的setter方法 |
| | | Method setter = property.getWriteMethod(); |
| | | Class<?> type = property.getPropertyType(); |
| | |
| | | return beanList; |
| | | } |
| | | |
| | | |
| | | public static String camelToUnderscore(String name) { |
| | | if (name == null && name.length() <= 0) { |
| | | return name; |
| | |
| | | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public static String intToRomans(int num) { |
| | | String M[] = {"", "M", "MM", "MMM"}; |
| | | String C[] = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"}; |
| | | String X[] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"}; |
| | | String I[] = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"}; |
| | | return M[num/1000]+C[(num%1000)/100]+X[(num%100)/10]+I[num%10]; |
| | | } |
| | | } |
| | | |