lyhzzz 2 yıl önce
ebeveyn
işleme
2e4c07b8a5

+ 16 - 6
src/main/java/com/fdkankan/manage/controller/DataController.java

@@ -48,26 +48,36 @@ public class DataController {
     /**
      *统计近半年新增用户数趋势
      * @param type  0:日 ,1:周,2:月
+     * @param dataType 0 新增,1累加 ,2活跃度趋势
      */
     @GetMapping("/userTrend")
-    public ResultData userTrend(@RequestParam(required = false,defaultValue = "0") Integer type){
-        return ResultData.ok(dataService.userTrend(type));
+    public ResultData userTrend(@RequestParam(required = false,defaultValue = "0") Integer type,
+                                @RequestParam(required = false,defaultValue = "0") Integer dataType,
+                                @RequestParam(required = false) String startTime,
+                                @RequestParam(required = false) String endTime){
+        return ResultData.ok(dataService.userTrend(type,dataType,startTime,endTime));
     }
     /**
      *统计近半年新线上订单趋势
      * @param type  0:日 ,1:周,2:月
      */
     @GetMapping("/orderTrend")
-    public ResultData orderTrend(@RequestParam(required = false,defaultValue = "0") Integer type){
-        return ResultData.ok(dataService.orderTrend(type));
+    public ResultData orderTrend(@RequestParam(required = false,defaultValue = "0") Integer type,
+                                 @RequestParam(required = false) String startTime,
+                                 @RequestParam(required = false) String endTime){
+        return ResultData.ok(dataService.orderTrend(type,startTime,endTime));
     }
     /**
      *统计近半年场景新增趋势
      * @param type  0:日 ,1:周,2:月
+     * @param dataType 0 新增,1累加
      */
     @GetMapping("/sceneTrend")
-    public ResultData sceneTrend(@RequestParam(required = false,defaultValue = "0") Integer type){
-        return ResultData.ok(dataService.sceneTrend(type));
+    public ResultData sceneTrend(@RequestParam(required = false,defaultValue = "0") Integer type,
+                                 @RequestParam(required = false,defaultValue = "0") Integer dataType,
+                                 @RequestParam(required = false) String startTime,
+                                 @RequestParam(required = false) String endTime){
+        return ResultData.ok(dataService.sceneTrend(type,dataType,startTime,endTime));
     }
 
 

+ 7 - 3
src/main/java/com/fdkankan/manage/mapper/IDataMapper.java

@@ -11,7 +11,8 @@ import java.util.List;
 @Mapper
 public interface IDataMapper {
 
-    List<DataGroupByCount> userDataGroupBy(@Param("tb") String tb,@Param("dateFormat")String dateFormat);
+    List<DataGroupByCount> userDataGroupBy(@Param("tb") String tb,@Param("dateFormat")String dateFormat,
+                                           @Param("startTime")String startTime,@Param("endTime")String endTime);
 
     Long totalUserCount(@Param("tb") String tb,@Param("type")Integer type);
 
@@ -21,7 +22,10 @@ public interface IDataMapper {
 
     Long todayActiveCount();
 
-    List<DataGroupByCount> userDataGroupByWeek(@Param("tb") String tb);
+    List<DataGroupByCount> userDataGroupByWeek(@Param("tb") String tb, @Param("startTime")String startTime,@Param("endTime")String endTime);
 
-    List<DataGroupByCount> sceneGroupBy(@Param("tb") String tb, @Param("dateFormat")String dateFormat);
+    List<DataGroupByCount> sceneGroupBy(@Param("tb") String tb, @Param("dateFormat")String dateFormat,
+                                        @Param("startTime")String startTime,@Param("endTime")String endTime);
+
+    List<DataGroupByCount> sceneGroupByWeek(@Param("tb") String tb,@Param("startTime")String startTime,@Param("endTime")String endTime);
 }

+ 4 - 3
src/main/java/com/fdkankan/manage/service/IDataService.java

@@ -13,9 +13,10 @@ public interface IDataService {
 
     OrderTotalVo orderTotal();
 
-    List<DataGroupByCount> userTrend(Integer type);
+    List<DataGroupByCount> userTrend(Integer type,Integer dataType,String startTime,String endTime);
 
-    HashMap<String, List<DataGroupByCount>> orderTrend(Integer type);
+    HashMap<String, List<DataGroupByCount>> orderTrend(Integer type,String startTime,String endTime);
+
+    HashMap<String, List<DataGroupByCount>> sceneTrend(Integer type,Integer dataType,String startTime,String endTime);
 
-    HashMap<String, List<DataGroupByCount>> sceneTrend(Integer type);
 }

+ 4 - 0
src/main/java/com/fdkankan/manage/service/ISceneProService.java

@@ -56,4 +56,8 @@ public interface ISceneProService extends IService<ScenePro> {
     void uploadNewSceneToOss(String newNum);
 
     void copyDataSource(String newDataSource,String oldDataSource,Integer sceneType,String time) throws Exception;
+
+    Long getKkCount(List<String> asList, String startTime);
+    Long getSsCount(List<String> asList, String startTime);
+    Long getSsObjCount(List<String> asList, String startTime);
 }

+ 151 - 29
src/main/java/com/fdkankan/manage/service/impl/DataService.java

@@ -1,15 +1,20 @@
 package com.fdkankan.manage.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.manage.entity.User;
 import com.fdkankan.manage.mapper.IDataMapper;
 import com.fdkankan.manage.service.IDataService;
+import com.fdkankan.manage.service.ISceneProService;
+import com.fdkankan.manage.service.IUserService;
+import com.fdkankan.manage.util.Dateutils;
 import com.fdkankan.manage.vo.response.*;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.formula.functions.Count;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
 
 @Service
 public class DataService implements IDataService {
@@ -20,6 +25,10 @@ public class DataService implements IDataService {
 
     @Resource
     IDataMapper dataMapper;
+    @Autowired
+    IUserService userService;
+    @Autowired
+    ISceneProService sceneProService;
 
     @Override
     public UserTotalVo getUserTotal() {
@@ -64,77 +73,190 @@ public class DataService implements IDataService {
 
 
     @Override
-    public List<DataGroupByCount> userTrend(Integer type) {
+    public List<DataGroupByCount> userTrend(Integer type,Integer dataType,String startTime,String endTime) {
+        startTime = Dateutils.formatStartTime(startTime,type);
+        endTime = Dateutils.formatEndTime(endTime,type);
+
+        List<DataGroupByCount> dataList = new ArrayList<>();
         List<DataGroupByCount> result = new ArrayList<>();
+        int rule = Dateutils.DAY;
+        String tb = "t_user";
+        if(dataType == 2){
+            tb = "t_login_log";
+        }
         switch (type){
-            case 0 : return  dataMapper.userDataGroupBy("t_user",dayFormat);
-            case 1 : return  dataMapper.userDataGroupByWeek("t_user");
-            case 2 : return  dataMapper.userDataGroupBy("t_user",mouthFormat);
+            case 0 :
+                dataList = dataMapper.userDataGroupBy(tb, dayFormat, startTime, endTime);
+                break;
+            case 1 :
+                rule = Dateutils.WEEK;
+                dataList = dataMapper.userDataGroupByWeek(tb,startTime,endTime);
+                break;
+            case 2 :
+                rule = Dateutils.MONTH;
+                dataList =  dataMapper.userDataGroupBy(tb,mouthFormat,startTime,endTime);
+                break;
         }
+        Long totalCount = 0L;
+        if(dataType == 1){          //累加
+            LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
+            wrapper.lt(User::getCreateTime,startTime);
+            totalCount = userService.count(wrapper);
+        }
+        //查询从开始时间到结束时间为止所有天数,月份,不存在结果补零
+        HashMap<String,Long> map = new HashMap<>();
+        dataList.forEach(entity -> map.put(entity.getGroupKey(),entity.getCount()));
+        List<String> dates = Dateutils.findDatesStr(Dateutils.getDate(startTime), Dateutils.getDate(endTime),rule );
+
+        setListData(result,map,dates,dataType,totalCount);
+
         return result;
     }
 
     @Override
-    public HashMap<String, List<DataGroupByCount>> orderTrend(Integer type) {
+    public HashMap<String, List<DataGroupByCount>> orderTrend(Integer type,String startTime,String endTime) {
+        startTime = Dateutils.formatStartTime(startTime,type);
+        endTime = Dateutils.formatEndTime(endTime,type);
+
         HashMap<String,List<DataGroupByCount>> map = new HashMap<>();
         List<DataGroupByCount> incrementOrderList = new ArrayList<>();
         List<DataGroupByCount> downOrderList = new ArrayList<>();
         List<DataGroupByCount> partOrderList = new ArrayList<>();
+        List<DataGroupByCount> incrementOrderResultList = new ArrayList<>();
+        List<DataGroupByCount> downOrderResultList = new ArrayList<>();
+        List<DataGroupByCount> partOrderResultList = new ArrayList<>();
+        int rule = Dateutils.DAY;
         switch (type){
             case 0 :
-                incrementOrderList = dataMapper.userDataGroupBy("t_increment_order",dayFormat);
-                downOrderList = dataMapper.userDataGroupBy("t_download_order",dayFormat);
+                incrementOrderList = dataMapper.userDataGroupBy("t_increment_order",dayFormat,startTime,endTime);
+                downOrderList = dataMapper.userDataGroupBy("t_download_order",dayFormat,startTime,endTime);
                 break;
             case 1 :
-                incrementOrderList = dataMapper.userDataGroupByWeek("t_increment_order");
-                downOrderList = dataMapper.userDataGroupByWeek("t_download_order");
+                rule = Dateutils.WEEK;
+                incrementOrderList = dataMapper.userDataGroupByWeek("t_increment_order",startTime,endTime);
+                downOrderList = dataMapper.userDataGroupByWeek("t_download_order",startTime,endTime);
                 break;
             case 2 :
-                incrementOrderList = dataMapper.userDataGroupBy("t_increment_order",mouthFormat);
-                downOrderList = dataMapper.userDataGroupBy("t_download_order",mouthFormat);
+                rule = Dateutils.MONTH;
+                incrementOrderList = dataMapper.userDataGroupBy("t_increment_order",mouthFormat,startTime,endTime);
+                downOrderList = dataMapper.userDataGroupBy("t_download_order",mouthFormat,startTime,endTime);
                 break;
         }
-        map.put("incrementOrder",incrementOrderList);
-        map.put("downOrder",downOrderList);
+        //查询从开始时间到结束时间为止所有天数,月份,不存在结果补零
+        HashMap<String,Long> incrementMap = new HashMap<>();
+        HashMap<String,Long> downOrderMap = new HashMap<>();
+        HashMap<String,Long> partMap = new HashMap<>();
+        incrementOrderList.forEach(entity -> incrementMap.put(entity.getGroupKey(),entity.getCount()));
+        downOrderList.forEach(entity -> downOrderMap.put(entity.getGroupKey(),entity.getCount()));
+
+        List<String> dates = Dateutils.findDatesStr(Dateutils.getDate(startTime), Dateutils.getDate(endTime),rule );
+        for (String date : dates) {
+            DataGroupByCount groupByCount = new DataGroupByCount();
+            groupByCount.setGroupKey(date);
+            groupByCount.setCount(incrementMap.get(date)== null ?0 :incrementMap.get(date));
+            incrementOrderResultList.add(groupByCount);
+
+            DataGroupByCount groupByCount2 = new DataGroupByCount();
+            groupByCount2.setGroupKey(date);
+            groupByCount2.setCount(downOrderMap.get(date)== null ?0 :downOrderMap.get(date));
+            downOrderResultList.add(groupByCount2);
+        }
+        map.put("incrementOrder",incrementOrderResultList);
+        map.put("downOrder",downOrderResultList);
         map.put("partOrder",partOrderList);
         return map;
     }
 
     @Override
-    public HashMap<String, List<DataGroupByCount>> sceneTrend(Integer type) {
+    public HashMap<String, List<DataGroupByCount>> sceneTrend(Integer type,Integer dataType,String startTime,String endTime) {
+        startTime = Dateutils.formatStartTime(startTime,type);
+        endTime = Dateutils.formatEndTime(endTime,type);
+
         HashMap<String,List<DataGroupByCount>> map = new HashMap<>();
         List<DataGroupByCount> kkList = new ArrayList<>();
         List<DataGroupByCount> kjList = new ArrayList<>();
         List<DataGroupByCount> ssList = new ArrayList<>();
-        List<DataGroupByCount> ssobjList = new ArrayList<>();
-        List<DataGroupByCount> allList = new ArrayList<>();
+        List<DataGroupByCount> ssObjList = new ArrayList<>();
+        List<DataGroupByCount> proList = new ArrayList<>();
+        List<DataGroupByCount> plusList = new ArrayList<>();
+        int rule = Dateutils.DAY;
         switch (type){
             case 0 :
-                allList = dataMapper.sceneGroupBy("t_scene_pro",dayFormat);
+                proList = dataMapper.sceneGroupBy("t_scene_pro",dayFormat,startTime,endTime);
+                plusList = dataMapper.sceneGroupBy("t_scene_plus",dayFormat,startTime,endTime);
                 break;
             case 1 :
-                allList = dataMapper.sceneGroupBy("t_scene_pro",dayFormat);
+                rule = Dateutils.WEEK;
+                proList = dataMapper.sceneGroupByWeek("t_scene_pro",startTime,endTime);
+                plusList = dataMapper.sceneGroupByWeek("t_scene_plus",startTime,endTime);
                 break;
             case 2 :
-                allList = dataMapper.sceneGroupBy("t_scene_pro",mouthFormat);
+                rule = Dateutils.MONTH;
+                proList = dataMapper.sceneGroupBy("t_scene_pro",mouthFormat,startTime,endTime);
+                plusList = dataMapper.sceneGroupBy("t_scene_plus",mouthFormat,startTime,endTime);
                 break;
         }
-        for (DataGroupByCount dataGroupByCount : allList) {
+        HashMap<String, Long> kkMap = new HashMap<>();
+        HashMap<String, Long> kjMap = new HashMap<>();
+        HashMap<String, Long> ssMap = new HashMap<>();
+        HashMap<String, Long> ssObjMap = new HashMap<>();
+        for (DataGroupByCount dataGroupByCount : proList) {
             if(dataGroupByCount.getGroupKey2().equals("3")){    //看见
-                kjList.add(dataGroupByCount);
+                kjMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
             }
             if(dataGroupByCount.getGroupKey2().equals("4")){    //深时
-                ssList.add(dataGroupByCount);
+                ssMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
             }
             if(Arrays.asList("1","2","12","13","14").contains(dataGroupByCount.getGroupKey2())){    //看看
-                kkList.add(dataGroupByCount);
+                kkMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
+            }
+        }
+        for (DataGroupByCount dataGroupByCount : plusList) {
+            if(dataGroupByCount.getGroupKey2().equals("3")){    //看见
+                kjMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
+            }
+            if(dataGroupByCount.getGroupKey2().equals("4")){    //深时
+                ssObjMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
+            }
+            if(Arrays.asList("1","2","12","13","14").contains(dataGroupByCount.getGroupKey2())){    //看看
+                kkMap.merge(dataGroupByCount.getGroupKey(),dataGroupByCount.getCount(), Long:: sum);
             }
-
         }
+        Long kkCount = 0L;
+        Long KjCount = 0L;
+        Long ssCount = 0L;
+        Long ssObjCount = 0L;
+        if(dataType == 1){
+            kkCount = sceneProService.getKkCount(Arrays.asList("1","2","12","13","14"),startTime);
+            KjCount = sceneProService.getKkCount(Arrays.asList("3"),startTime);
+            ssCount = sceneProService.getSsCount(Arrays.asList("4"),startTime);
+            ssObjCount = sceneProService.getSsObjCount(Arrays.asList("4"),startTime);
+        }
+        List<String> dates = Dateutils.findDatesStr(Dateutils.getDate(startTime), Dateutils.getDate(endTime),rule );
+        setListData(kkList,kkMap,dates,dataType,kkCount);
+        setListData(kjList,kjMap,dates,dataType,KjCount);
+        setListData(ssList,ssMap,dates,dataType,ssObjCount);
+        setListData(ssObjList,ssObjMap,dates,dataType,ssObjCount);
+
         map.put("kkList",kkList);
         map.put("kjList",kjList);
         map.put("ssList",ssList);
-        map.put("ssobjList",ssobjList);
+        map.put("ssobjList",ssObjList);
         return map;
     }
+
+
+    private void setListData(List<DataGroupByCount> kkList, HashMap<String, Long> kkMap, List<String> dates,Integer dataType,Long totalCount) {
+        for (String key : dates) {
+            DataGroupByCount newCount = new DataGroupByCount();
+            newCount.setGroupKey(key);
+            Long count = kkMap.get(key) == null ?0 : kkMap.get(key);
+            if(dataType == 1){
+                count += totalCount;
+                totalCount = count;
+            }
+            newCount.setCount(count);
+            kkList.add(newCount);
+        }
+    }
 }

+ 29 - 0
src/main/java/com/fdkankan/manage/service/impl/SceneProServiceImpl.java

@@ -542,4 +542,33 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         FileUtils.copyFolderAllFiles(oldDataSource+"/",newDataSource+"/", true);
     }
 
+    @Override
+    public Long getKkCount(List<String> asList, String startTime) {
+        LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(ScenePro::getSceneSource,asList);
+        wrapper.eq(ScenePro::getIsUpgrade,0);
+        wrapper.lt(ScenePro::getCreateTime,startTime);
+        long count = this.count(wrapper);
+
+        LambdaQueryWrapper<ScenePlus> wrapper2 = new LambdaQueryWrapper<>();
+        wrapper2.in(ScenePlus::getSceneSource,asList);
+        wrapper2.lt(ScenePlus::getCreateTime,startTime);
+        long count1 = scenePlusService.count(wrapper2);
+        return count + count1;
+    }
+    @Override
+    public Long getSsCount(List<String> asList, String startTime) {
+        LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(ScenePro::getSceneSource,asList);
+        wrapper.eq(ScenePro::getIsUpgrade,0);
+        wrapper.lt(ScenePro::getCreateTime,startTime);
+        return this.count(wrapper);
+    }
+    @Override
+    public Long getSsObjCount(List<String> asList, String startTime) {
+        LambdaQueryWrapper<ScenePlus> wrapper2 = new LambdaQueryWrapper<>();
+        wrapper2.in(ScenePlus::getSceneSource,asList);
+        wrapper2.lt(ScenePlus::getCreateTime,startTime);
+        return scenePlusService.count(wrapper2);
+    }
 }

+ 150 - 0
src/main/java/com/fdkankan/manage/util/Dateutils.java

@@ -0,0 +1,150 @@
+package com.fdkankan.manage.util;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.text.SimpleDateFormat;
+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.Date;
+import java.util.List;
+
+public class Dateutils {
+
+    public static int  DAY =  Calendar.DAY_OF_MONTH;
+    public static int  WEEK =  Calendar.WEEK_OF_MONTH;
+    public static int  MONTH =  Calendar.MONTH;
+
+    /**
+     * 获取指定时间区间的所有数据(包含日期和月份)
+     * @param dBegin
+     * @param dEnd
+     * @param rule 日历规则 如:Calendar.DAY_OF_MONTH
+     * @return
+     */
+    public static List<Date> findDates(Date dBegin, Date dEnd, int rule) {
+        List<Date> lDate = new ArrayList<>();
+        if (dEnd.before(dBegin)){
+            return lDate;
+        }
+        Calendar calBegin = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calBegin.setTime(dBegin);
+        Calendar calEnd = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calEnd.setTime(dEnd);
+        // 测试此日期是否在指定日期之后
+        while (dEnd.after(calBegin.getTime())) {
+            // 根据日历的规则,为给定的日历字段添加或减去指定的时间量
+            Date time = calBegin.getTime();
+            if(rule == Calendar.WEEK_OF_MONTH){
+                time = getMonday(time);
+            }
+            lDate.add(time);
+            calBegin.add(rule, 1);
+        }
+        return lDate;
+    }
+    public static List<String> findDatesStr(Date dBegin, Date dEnd, int rule) {
+        List<String> datesStr = new ArrayList<>();
+        List<Date> dates = findDates(dBegin, dEnd, rule);
+        for (Date date : dates) {
+            String day ;
+            if(rule == MONTH){
+                day =getMonthDate(date);
+            }else {
+                day = getDayDate(date);
+            }
+            datesStr.add(day);
+        }
+        return datesStr;
+    }
+    public static Date getDate(String date) {
+        try {
+            return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(date);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return new Date();
+    }
+    public static Date getMonday(Date date) {
+        Calendar calBegin = Calendar.getInstance();
+        calBegin.setTime(date);
+        calBegin.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);    //周一
+        return calBegin.getTime();
+    }
+
+    public static String getDate(Date date) {
+        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
+    }
+
+    public static String getMonthDate(Date date) {
+        return new SimpleDateFormat("yyyy-MM").format(date);
+    }
+    public static Date getMonthDate(String date) {
+        try {
+            return new SimpleDateFormat("yyyy-MM").parse(date);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return new Date();
+    }
+
+    public static String getDayDate(Date date) {
+        return new SimpleDateFormat("yyyy-MM-dd").format(date);
+    }
+    public static String getDayZeroDate(Date date) {
+        return new SimpleDateFormat("yyyy-MM-dd").format(date) +" 00:00:00";
+    }
+
+
+    public static String getHalfYearStr() {
+        return new SimpleDateFormat("yyyy-MM-dd").format(getHalfYear())+" 00:00:00";
+    }
+    public static Date getHalfYear() {
+        Calendar c = Calendar.getInstance();
+        c.setTime(new Date());
+        c.add(Calendar.MONTH, -6);
+        return c.getTime();
+    }
+
+    public static  String getLastMonTh(Date date){
+        Calendar ca = Calendar.getInstance();
+        ca.setTime(date);
+        ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
+        return new SimpleDateFormat("yyyy-MM-dd").format(ca.getTime()) +" 23:59:59";
+    }
+
+    public static String formatStartTime(String startTime,Integer type) {
+        if(StringUtils.isBlank(startTime)){
+            startTime = Dateutils.getHalfYearStr();
+            if(type == 2){  //月,开始时间到1号 0点
+                Date date = Dateutils.getDate(startTime);
+                startTime =  Dateutils.getDate(Dateutils.getMonthDate( Dateutils.getMonthDate(date)));
+            }
+        }
+        if(type == 1){  //周,开始时间到周一 0点
+            Date date = Dateutils.getDate(startTime);
+            Date monday = Dateutils.getMonday(date);
+            startTime = Dateutils.getDayZeroDate(monday);
+        }
+        if(type == 2 && startTime.length() <10 ){  //月,开始时间到1号 0点
+            Date date = Dateutils.getMonthDate(startTime);
+            startTime =  Dateutils.getDate(date);
+        }
+        return startTime;
+    }
+    public static String formatEndTime(String endTime,Integer type) {
+        if(StringUtils.isBlank(endTime)){
+            endTime = Dateutils.getDate(new Date());
+        }
+        if(type == 2 && endTime.length() <10 ){  //月,开始时间到月最后一天 0点
+            endTime =  getLastMonTh(Dateutils.getDate(endTime));
+        }
+        return endTime;
+    }
+
+
+}

+ 40 - 0
src/main/resources/bootstrap-dev.yml

@@ -0,0 +1,40 @@
+spring:
+  application:
+    name: 4dkankan-center-manage
+  cloud:
+    nacos:
+      config:
+        server-addr: 120.24.144.164:8848
+        file-extension: yaml
+        namespace: 4dkankan-test
+        extension-configs:
+          - data-id: 4dkankan-center-manage.yaml
+            group: DEFAULT_GROUP
+            refresh: true
+        shared-configs:
+
+          - data-id: common-redis-config-52.yaml
+            group: DEFAULT_GROUP
+            refresh: true
+
+          - data-id: other-config.yaml
+            group: DEFAULT_GROUP
+            refresh: true
+
+          - data-id: common-upload-config.yaml
+            group: DEFAULT_GROUP
+            refresh: true
+
+          - data-id: common-mongodb-config.yaml
+            group: DEFAULT_GROUP
+            refresh: true
+      discovery:
+        server-addr: ${spring.cloud.nacos.config.server-addr}
+        namespace: ${spring.cloud.nacos.config.namespace}
+
+
+
+
+
+
+

+ 1 - 1
src/main/resources/bootstrap.yml

@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: test
+    active: dev
 
 logging:
   config: classpath:logback-spring.xml

+ 19 - 4
src/main/resources/mapper/manage/DataMapper.xml

@@ -4,7 +4,7 @@
 
     <select id="userDataGroupBy" resultType="com.fdkankan.manage.vo.response.DataGroupByCount">
         SELECT DATE_FORMAT(create_time,#{dateFormat}) AS groupKey, count(id) AS count FROM ${tb} WHERE rec_status = 'A'
-           and create_time between date_sub(now(),interval 6 month) and now()
+           and create_time between #{startTime} and #{endTime}
         <include refid="tbWhereSql"></include>
         GROUP BY groupKey
     </select>
@@ -13,7 +13,8 @@
         SELECT groupKey ,count(1) as count FROM (
                select date_format(date_add(create_time,interval-(weekday(create_time ))day),'%Y-%m-%d')  as groupKey
                 from ${tb}
-               WHERE rec_status = 'A'and create_time between date_sub(now(),interval 6 month) and now()
+               WHERE rec_status = 'A'
+                 and create_time between #{startTime} and #{endTime}
                 <include refid="tbWhereSql"></include>
          ) as tb GROUP BY groupKey
     </select>
@@ -54,6 +55,7 @@
         SELECT count(distinct user_name) FROM t_login_log
         WHERE rec_status = 'A' and DATEDIFF(create_time,NOW())=0
     </select>
+
     <select id="sceneGroupBy" resultType="com.fdkankan.manage.vo.response.DataGroupByCount">
         SELECT DATE_FORMAT(create_time,#{dateFormat}) AS groupKey, count(id) AS count ,scene_source as groupKey2
         FROM ${tb}
@@ -61,8 +63,21 @@
           <if test="tb == 't_scene_pro'">
               AND is_upgrade = 0
           </if>
-          and create_time between date_sub(now(),interval 6 month) and now()
-        GROUP BY groupKey ,scene_source
+        and create_time between #{startTime} and #{endTime}
+        GROUP BY groupKey ,groupKey2
+    </select>
+
+    <select id="sceneGroupByWeek" resultType="com.fdkankan.manage.vo.response.DataGroupByCount">
+        SELECT groupKey ,scene_source as groupKey2,count(1) as count FROM (
+        select date_format(date_add(create_time,interval-(weekday(create_time ))day),'%Y-%m-%d')  as groupKey
+        ,scene_source
+        from ${tb}
+        WHERE rec_status = 'A'
+        <if test="tb == 't_scene_pro'">
+            AND is_upgrade = 0
+        </if>
+        and create_time between #{startTime} and #{endTime}
+        ) as tb GROUP BY groupKey,groupKey2
     </select>