Browse Source

项目jdk改为1.7

chenw 6 years ago
parent
commit
3012a47dd1

+ 0 - 146
bi-core/src/main/java/com/usoftchina/bi/core/utils/CollectionUtils.java

@@ -1,146 +0,0 @@
-package com.usoftchina.bi.core.utils;
-
-import com.google.common.collect.HashBasedTable;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.common.collect.Table;
-
-import java.util.*;
-import java.util.function.Function;
-
-/**
- * @author ChenWei
- * @date 2019/04/22
- */
-public abstract class CollectionUtils extends org.springframework.util.CollectionUtils {
-    /**
-     * 按指定方法,将list分组返回map
-     *
-     * @param sources
-     * @param keyGetter
-     * @param <K>
-     * @param <V>
-     * @return
-     */
-    public static <K, V> Map<K, List<V>> groupBy(List<V> sources, Function<V, K> keyGetter) {
-        Map<K, List<V>> map = new HashMap<>(1);
-        if (!isEmpty(sources)) {
-            sources.forEach(source -> {
-                K key = keyGetter.apply(source);
-                if (map.containsKey(key)) {
-                    map.get(key).add(source);
-                } else {
-                    List<V> childList = new ArrayList<>();
-                    childList.add(source);
-                    map.put(key, childList);
-                }
-            });
-        }
-        return map;
-    }
-
-    /**
-     * 按两个指定方法,将list分组返回复合键map
-     *
-     * @param sources
-     * @param rKeyGetter
-     * @param cKeyGetter
-     * @param <R>
-     * @param <C>
-     * @param <V>
-     * @return
-     */
-    public static <R, C, V> Table<R, C, List<V>> groupBy(List<V> sources, Function<V, R> rKeyGetter, Function<V, C> cKeyGetter) {
-        Table<R, C, List<V>> table = HashBasedTable.create();
-        if (!isEmpty(sources)) {
-            sources.forEach(source -> {
-                R r = rKeyGetter.apply(source);
-                C c = cKeyGetter.apply(source);
-                if (table.contains(r, c)) {
-                    table.get(r, c).add(source);
-                } else {
-                    List<V> childList = new ArrayList<>();
-                    childList.add(source);
-                    table.put(r, c, childList);
-                }
-            });
-        }
-        return table;
-    }
-
-    /**
-     * 按三个指定方法,将list分组返回复合键map
-     *
-     * @param sources
-     * @param rKeyGetter
-     * @param cKeyGetter
-     * @param valueGetter
-     * @param <R>
-     * @param <C>
-     * @param <V>
-     * @param <S>
-     * @return
-     */
-    public static <R, C, V, S> Map<R, Map<C, List<V>>> groupBy(List<S> sources, Function<S, R> rKeyGetter, Function<S, C> cKeyGetter, Function<S, V> valueGetter) {
-        Map<R, Map<C, List<V>>> table = new HashMap<>(1);
-        if (!isEmpty(sources)) {
-            sources.forEach(source -> {
-                R r = rKeyGetter.apply(source);
-                C c = cKeyGetter.apply(source);
-                V v = valueGetter.apply(source);
-
-                if (table.containsKey(r)) {
-                    Map<C, List<V>> rows = table.get(r);
-                    if (rows.containsKey(c)) {
-                        rows.get(c).add(v);
-                    } else {
-                        rows.put(c, Lists.newArrayList(v));
-                    }
-                } else {
-                    Map<C, List<V>> rows = new HashMap<>(1);
-                    rows.put(c, Lists.newArrayList(v));
-                    table.put(r, rows);
-                }
-            });
-        }
-        return table;
-    }
-
-    /**
-     * 按三个指定方法,将list分组返回复合键map
-     *
-     * @param sources
-     * @param rKeyGetter
-     * @param cKeyGetter
-     * @param valueGetter
-     * @param <R>
-     * @param <C>
-     * @param <V>
-     * @param <S>
-     * @return
-     */
-    public static <R, C, V, S> Map<R, Map<C, Set<V>>> distinctBy(List<S> sources, Function<S, R> rKeyGetter, Function<S, C> cKeyGetter, Function<S, V> valueGetter) {
-        Map<R, Map<C, Set<V>>> table = new HashMap<>(1);
-        if (!isEmpty(sources)) {
-            sources.forEach(source -> {
-                R r = rKeyGetter.apply(source);
-                C c = cKeyGetter.apply(source);
-                V v = valueGetter.apply(source);
-
-                if (table.containsKey(r)) {
-                    Map<C, Set<V>> rows = table.get(r);
-                    if (rows.containsKey(c)) {
-                        rows.get(c).add(v);
-                    } else {
-                        rows.put(c, Sets.newHashSet(v));
-                    }
-                } else {
-                    Map<C, Set<V>> rows = new HashMap<>(1);
-                    rows.put(c, Sets.newHashSet(v));
-                    table.put(r, rows);
-                }
-            });
-        }
-        return table;
-    }
-}

+ 5 - 1
bi-core/src/main/java/com/usoftchina/bi/core/utils/GetTokenDataUtil.java

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Component;
 import java.io.UnsupportedEncodingException;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 public class GetTokenDataUtil {
     //公共密钥
@@ -33,7 +34,10 @@ public class GetTokenDataUtil {
         }
         Map<String, Claim> claimMap = jwt.getClaims();
         Map<String, String> resultMap = new HashMap<String, String>();
-        claimMap.forEach((k,v) -> resultMap.put(k, v.asString()));
+        Set<String> keySet = claimMap.keySet();
+        for (String key : keySet) {
+            resultMap.put(key, String.valueOf(claimMap.get(key)));
+        }
         return resultMap;
     }
 }

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ChartsConfigService.java

@@ -262,7 +262,7 @@ public class ChartsConfigService {
         List<GroupInfo> addGroupInfoList = new ArrayList<>();
         List<GroupInfo> deleteGroupInfoList = new ArrayList<>();
         List<GroupInfo> updateGroupInfoList = new ArrayList<>();
-        groupInfoList.forEach(groupInfo -> {
+        for (GroupInfo groupInfo : groupInfoList) {
             if ("add".equals(groupInfo.getOperate())) {
                 addGroupInfoList.add(groupInfo);
             }else if ("delete".equals(groupInfo.getOperate())) {
@@ -270,7 +270,7 @@ public class ChartsConfigService {
             }else if ("update".equals(groupInfo.getOperate())) {
                 updateGroupInfoList.add(groupInfo);
             }
-        });
+        }
         if (addGroupInfoList.size() > 0) {
             messageLogService.save("图表分组", null, username, "批量创建图表分组");
             chartsConfigMapper.batchInsertCharts(addGroupInfoList);

+ 25 - 7
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowLineService.java

@@ -3,7 +3,6 @@ package com.usoftchina.bi.server.service.chart;
 import com.usoftchina.bi.core.base.RepCode;
 import com.usoftchina.bi.core.base.RepEntity;
 import com.usoftchina.bi.core.utils.CalculationJudgeUtil;
-import com.usoftchina.bi.core.utils.CollectionUtils;
 import com.usoftchina.bi.server.dao.chart.ChartsConfigMapper;
 import com.usoftchina.bi.server.dao.chart.ShowChartsMapper;
 import com.usoftchina.bi.server.model.bo.*;
@@ -11,14 +10,11 @@ import com.usoftchina.bi.server.model.vo.configVo.LineConfigInfo;
 import com.usoftchina.bi.server.model.vo.dataVo.ChartsDataInfo;
 import com.usoftchina.bi.core.jdbc.DynamicDataSourceContextHolder;
 import com.usoftchina.bi.server.utils.ScreenUtil;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Service
 public class ShowLineService {
@@ -145,7 +141,7 @@ public class ShowLineService {
                 String groupsName = (String)itGroupsData.next();
 
                 List<LineSeriesGroupMap> lineSeriesGroupMapList = showChartsMapper.getGroupsValuesTime(yAxisType, yColumn, tableName, groupByName, groupsName, xColumn, "'YYYY-MM-DD'");
-                Map<String, List<LineSeriesGroupMap>> lineSeriesGroupMap = CollectionUtils.groupBy(lineSeriesGroupMapList, LineSeriesGroupMap::getGroup);
+                Map<String, List<LineSeriesGroupMap>> lineSeriesGroupMap = groupBy(lineSeriesGroupMapList);
                 Iterator<Map.Entry<String, List<LineSeriesGroupMap>>> it = lineSeriesGroupMap.entrySet().iterator();
                 List<LineSeriesMap> lineSeriesMapList = null;
                 while (it.hasNext()) {
@@ -172,6 +168,28 @@ public class ShowLineService {
         return new RepEntity(RepCode.success, chartsDataInfo);
     }
 
+    /**
+     * 分组
+     * @param sources
+     * @return
+     */
+    private Map<String, List<LineSeriesGroupMap>> groupBy(List<LineSeriesGroupMap> sources){
+        Map<String, List<LineSeriesGroupMap>> map = new HashMap<>(1);
+        if (!CollectionUtils.isEmpty(sources)) {
+            for (LineSeriesGroupMap source : sources) {
+                String key = source.getGroup();
+                if (map.containsKey(key)) {
+                    map.get(key).add(source);
+                }else {
+                    List<LineSeriesGroupMap> childList = new ArrayList<>();
+                    childList.add(source);
+                    map.put(key, childList);
+                }
+            }
+        }
+        return map;
+    }
+
     /**
      * LineSeriesGroupMap 转 LineSeriesMap
      * @param source

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/DataConnectorService.java

@@ -278,7 +278,7 @@ public class DataConnectorService {
         List<GroupInfo> addGroupInfoList = new ArrayList<>();
         List<GroupInfo> deleteGroupInfoList = new ArrayList<>();
         List<GroupInfo> updateGroupInfoList = new ArrayList<>();
-        groupInfoList.forEach(groupInfo -> {
+        for (GroupInfo groupInfo : groupInfoList) {
             if ("add".equals(groupInfo.getOperate())) {
                 addGroupInfoList.add(groupInfo);
             }else if ("delete".equals(groupInfo.getOperate())) {
@@ -286,7 +286,7 @@ public class DataConnectorService {
             }else if ("update".equals(groupInfo.getOperate())) {
                 updateGroupInfoList.add(groupInfo);
             }
-        });
+        }
         if (addGroupInfoList.size() > 0) {
             messageLogService.save("数据源分组", null, username, "批量新增数据源分组");
             dataConnectorMapper.batchInsertDataConnector(addGroupInfoList);

+ 55 - 26
bi-server/src/main/java/com/usoftchina/bi/server/utils/ScreenUtil.java

@@ -8,11 +8,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.time.DayOfWeek;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.TemporalAdjusters;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Iterator;
 import java.util.List;
 
@@ -174,50 +176,75 @@ public class ScreenUtil {
      */
     private String TimeFormat(String value){
         String formatValue = "";
-        LocalDate localDate = LocalDate.now();
+        Calendar calendar = Calendar.getInstance();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         switch (value) {
             case "today" :
-                formatValue = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                formatValue = simpleDateFormat.format(calendar.getTime());
                 break;
             case "yesterday" :
-                formatValue = localDate.plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                calendar.add(Calendar.DAY_OF_MONTH, -1);
+                formatValue = simpleDateFormat.format(calendar.getTime());
                 break;
             case "week" :
-                formatValue = localDate.plusWeeks(0).with(DayOfWeek.MONDAY).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
-                        + localDate.plusWeeks(0).with(DayOfWeek.SUNDAY).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
+                formatValue = simpleDateFormat.format(calendar.getTime()) + ",";
+                calendar.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
+                formatValue += simpleDateFormat.format(calendar.getTime());
                 break;
             case "lastweek" :
-                formatValue = localDate.plusWeeks(-1).with(DayOfWeek.MONDAY).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
-                        + localDate.plusWeeks(-1).with(DayOfWeek.SUNDAY).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                calendar.add(Calendar.WEEK_OF_YEAR, -1);
+                calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
+                formatValue = simpleDateFormat.format(calendar.getTime()) + ",";
+                calendar.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
+                formatValue += simpleDateFormat.format(calendar.getTime());
                 break;
             case "month" :
-                formatValue = localDate.plusMonths(0).with(TemporalAdjusters.firstDayOfMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
-                        + localDate.plusWeeks(0).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                calendar.set(Calendar.DAY_OF_MONTH, 1);
+                formatValue = simpleDateFormat.format(calendar.getTime()) + ",";
+                calendar.add(Calendar.MONTH, 1);
+                calendar.set(Calendar.DAY_OF_MONTH, 0);
+                formatValue += simpleDateFormat.format(calendar.getTime());
                 break;
             case "lastmonth" :
-                formatValue = localDate.plusMonths(-1).with(TemporalAdjusters.firstDayOfMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
-                        + localDate.plusMonths(-1).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                calendar.add(Calendar.MONTH, -1);
+                calendar.set(Calendar.DAY_OF_MONTH, 1);
+                formatValue = simpleDateFormat.format(calendar.getTime()) + ",";
+                calendar.add(Calendar.MONTH, 1);
+                calendar.set(Calendar.DAY_OF_MONTH, 0);
+                formatValue += simpleDateFormat.format(calendar.getTime());
                 break;
             case "quarter" :
-                formatValue = quarterStart(0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
-                        + quarterStart(0).plusMonths(2).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                formatValue = simpleDateFormat.format(quarterStart(0).getTime()) + ",";
+                Calendar c1 = quarterStart(0);
+                c1.add(Calendar.MONTH, 2);
+                formatValue += simpleDateFormat.format(c1.getTime());
                 break;
             case "lastquarter" :
-                formatValue = quarterStart(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
-                        + quarterStart(-1).plusMonths(2).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-                formatValue = "";
+                formatValue = simpleDateFormat.format(quarterStart(-2).getTime()) + ",";
+                Calendar c2 = quarterStart(0);
+                c2.add(Calendar.MONTH, 2);
+                formatValue += simpleDateFormat.format(c2.getTime());
                 break;
             case "halfyear" :
-                formatValue = localDate.plusMonths(-6).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
-                        + localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                calendar.add(Calendar.MONTH, -6);
+                calendar.set(Calendar.DAY_OF_MONTH, 1);
+                formatValue = simpleDateFormat.format(calendar.getTime()) + ",";
+                calendar = Calendar.getInstance();
+                formatValue += simpleDateFormat.format(calendar.getTime());
                 break;
             case "year" :
-                formatValue = localDate.plusYears(0).with(TemporalAdjusters.firstDayOfYear()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
-                        + localDate.plusWeeks(0).with(TemporalAdjusters.firstDayOfYear()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                calendar.set(Calendar.DAY_OF_YEAR, 1);
+                formatValue = simpleDateFormat.format(calendar.getTime()) + ",";
+                calendar.roll(Calendar.DAY_OF_YEAR, -1);
+                formatValue += calendar.getTime();
                 break;
             case "lastyear" :
-                formatValue = localDate.plusYears(-1).with(TemporalAdjusters.firstDayOfYear()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
-                        + localDate.plusWeeks(-1).with(TemporalAdjusters.firstDayOfYear()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 1);
+                calendar.set(Calendar.DAY_OF_YEAR, 1);
+                formatValue = simpleDateFormat.format(calendar.getTime()) + ",";
+                calendar.roll(Calendar.DAY_OF_YEAR, -1);
+                formatValue += calendar.getTime();
                 break;
             default:
                 formatValue = value;
@@ -226,9 +253,9 @@ public class ScreenUtil {
         return formatValue;
     }
 
-    private static LocalDate quarterStart(int offset) {
-        final LocalDate date = LocalDate.now().plusMonths(offset * 3);
-        int month = date.getMonth().getValue();//当月
+    private static Calendar quarterStart(int offset) {
+        final Calendar calendar = Calendar.getInstance();
+        int month = calendar.get(Calendar.MONTH);//当月
         int start = 0;
         if (month >= 1 && month <= 3) {//第一季度
             start = 1;
@@ -242,6 +269,8 @@ public class ScreenUtil {
             start = 12;
             month = 14;
         }
-        return date.plusMonths(start - month).with(TemporalAdjusters.firstDayOfMonth());
+        calendar.add(Calendar.MONTH,start - month);
+        calendar.set(Calendar.DAY_OF_MONTH, 1);
+        return calendar;
     }
 }

+ 1 - 1
pom.xml

@@ -26,7 +26,7 @@
 
   <properties>
     <project.release.version>2.0.0-SNAPSHOT</project.release.version>
-    <java.version>1.8</java.version>
+    <java.version>1.7</java.version>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     <spring.boot.version>2.0.4.RELEASE</spring.boot.version>