| | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.DeserializationFeature; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.common.collect.Maps; |
| | | import com.highdatas.srs.pojo.Segment; |
| | | import com.highdatas.srs.pojo.TableSchemaResult; |
| | | import com.highdatas.srs.service.IModuleService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cglib.beans.BeanMap; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Method; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.Random; |
| | | import java.util.UUID; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * @author kimi |
| | |
| | | @Slf4j |
| | | public class DbUtils { |
| | | |
| | | public static IModuleService moduleService; |
| | | |
| | | |
| | | @Autowired |
| | | public void setModuleService (IModuleService moduleService) { |
| | | DbUtils.moduleService = moduleService; |
| | | } |
| | | |
| | | public static String getUUID() { |
| | | String id = UUID.randomUUID().toString().replaceAll("-", ""); |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public static String lineToHump(String str) { |
| | | Pattern linePattern = Pattern.compile("_(\\w)"); |
| | | str = str.toLowerCase(); |
| | | Matcher matcher = linePattern.matcher(str); |
| | | StringBuffer sb = new StringBuffer(); |
| | | while (matcher.find()) { |
| | | matcher.appendReplacement(sb, matcher.group(1).toUpperCase()); |
| | | } |
| | | matcher.appendTail(sb); |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public static <T> Map<String, Object> beanToMap(T bean) { |
| | | Map<String, Object> map = Maps.newHashMap(); |
| | | if (bean != null) { |
| | | BeanMap beanMap = BeanMap.create(bean); |
| | | for (Object key : beanMap.keySet()) { |
| | | map.put(key+"", beanMap.get(key)); |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | public static int getRangeDays(Date startDate, Date endDate, Date rangeStart, Date rangEnd) throws ParseException { |
| | | Date realStart, realEnd; |
| | | if (startDate.before(rangeStart)) { |
| | | realStart = rangeStart; |
| | | } else { |
| | | realStart = startDate; |
| | | } |
| | | if (endDate.before(rangEnd)) { |
| | | realEnd = endDate; |
| | | } else { |
| | | realEnd = rangEnd; |
| | | } |
| | | return getDayDiffer(realStart, realEnd); |
| | | } |
| | | |
| | | public static int getDayDiffer(Date startDate, Date endDate) throws ParseException { |
| | | //判断是否跨年 |
| | | SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy"); |