lyhzzz před 9 měsíci
rodič
revize
26fb6833c3

+ 9 - 0
src/main/java/com/fdkankan/manage/mapper/IDataMapper.java

@@ -18,10 +18,13 @@ public interface IDataMapper {
                                             @Param("startTime")String startTime, @Param("endTime")String endTime);
 
     Long totalUserCount(@Param("tb") String tb,@Param("type")Integer type);
+    Long totalUserCount(@Param("tb") String tb,@Param("type")Integer type,@Param("userIds") List<Long> userIds);
 
     Long preMonthAddCount(@Param("tb") String tb,@Param("type")Integer type);
+    Long preMonthAddCount(@Param("tb") String tb,@Param("type")Integer type,@Param("userIds") List<Long> userIds);
 
     Long todayAddCount(@Param("tb") String tb,@Param("type")Integer type);
+    Long todayAddCount(@Param("tb") String tb,@Param("type")Integer type,@Param("userIds") List<Long> userIds);
 
     Long todayActiveCount();
 
@@ -30,13 +33,19 @@ public interface IDataMapper {
 
     List<DataGroupByCount> sceneGroupBy(@Param("tb") String tb, @Param("dateFormat")String dateFormat,
                                         @Param("startTime")String startTime,@Param("endTime")String endTime);
+    List<DataGroupByCount> sceneGroupBy(@Param("tb") String tb, @Param("dateFormat")String dateFormat,
+                                        @Param("startTime")String startTime,@Param("endTime")String endTime,@Param("userIds") List<Long> userIds);
 
     List<DataGroupByCount> sceneGroupByWeek(@Param("tb") String tb,@Param("startTime")String startTime,@Param("endTime")String endTime);
+    List<DataGroupByCount> sceneGroupByWeek(@Param("tb") String tb,@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("userIds") List<Long> userIds);
 
     List<DataGroupByCount> sceneObjGroupBy(@Param("tb") String tb, @Param("dateFormat")String dateFormat,
                                            @Param("startTime")String startTime,@Param("endTime")String endTime);
+    List<DataGroupByCount> sceneObjGroupBy(@Param("tb") String tb, @Param("dateFormat")String dateFormat,
+                                           @Param("startTime")String startTime,@Param("endTime")String endTime,@Param("userIds") List<Long> userIds);
 
     List<DataGroupByCount> sceneObjGroupByWeek(@Param("tb") String tb,@Param("startTime")String startTime,@Param("endTime")String endTime);
+    List<DataGroupByCount> sceneObjGroupByWeek(@Param("tb") String tb,@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("userIds") List<Long> userIds);
 
     List<DataGroupByCount> sceneOutTimeGroupBy(@Param("tb") String tb, @Param("dateFormat")String dateFormat,
                                         @Param("startTime")String startTime,@Param("endTime")String endTime);

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

@@ -40,9 +40,9 @@ public interface ISceneProService extends IService<ScenePro> {
 
     ScenePro getByNum(String sceneNum);
 
-    Long getKkCount(List<String> asList, String startTime);
-    Long getSsCount(List<String> asList, String startTime);
-    Long getSsObjCount(List<String> asList, String startTime);
+    Long getKkCount(List<String> asList, String startTime,List<Long> userIds);
+    Long getSsCount(List<String> asList, String startTime,List<Long> userIds);
+    Long getSsObjCount(List<String> asList, String startTime,List<Long> userIds);
 
     HashMap<String, String> getSnCodeByNumList(Set<String> numList);
 

+ 37 - 24
src/main/java/com/fdkankan/manage/service/impl/DataService.java

@@ -3,9 +3,7 @@ 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.service.*;
 import com.fdkankan.manage.util.Dateutils;
 import com.fdkankan.manage.vo.response.*;
 import org.apache.commons.lang3.StringUtils;
@@ -29,6 +27,10 @@ public class DataService implements IDataService {
     IUserService userService;
     @Autowired
     ISceneProService sceneProService;
+    @Autowired
+    IJyUserPlatformService jyUserPlatformService;
+    @Autowired
+    IJyUserService jyUserService;
 
     @Override
     public UserTotalVo getUserTotal() {
@@ -47,10 +49,15 @@ public class DataService implements IDataService {
 
     @Override
     public SceneTotalVo sceneTotal() {
+        Integer loginPlatformId = jyUserPlatformService.getLoginPlatformId();
+        List<Long> userIds = new ArrayList<>();
+        if(loginPlatformId != null) {
+            userIds = jyUserService.getByUserIdPlatform(loginPlatformId);
+        }
         SceneTotalVo totalVo = new SceneTotalVo();
-        Long totalSceneCount = dataMapper.totalUserCount("t_scene_pro",1) + dataMapper.totalUserCount("t_scene_plus",0);
-        Long preMonthAddCount = dataMapper.preMonthAddCount("t_scene_pro",1) + dataMapper.preMonthAddCount("t_scene_plus",0);
-        Long todayAddCount = dataMapper.todayAddCount("t_scene_pro",1) + dataMapper.todayAddCount("t_scene_plus",0);
+        Long totalSceneCount = dataMapper.totalUserCount("t_scene_pro",1,userIds) + dataMapper.totalUserCount("t_scene_plus",0,userIds);
+        Long preMonthAddCount = dataMapper.preMonthAddCount("t_scene_pro",1,userIds) + dataMapper.preMonthAddCount("t_scene_plus",0,userIds);
+        Long todayAddCount = dataMapper.todayAddCount("t_scene_pro",1,userIds) + dataMapper.todayAddCount("t_scene_plus",0,userIds);
 
         totalVo.setTotalSceneCount(totalSceneCount);
         totalVo.setPreMonthAddCount(preMonthAddCount);
@@ -242,6 +249,12 @@ public class DataService implements IDataService {
         startTime = Dateutils.formatStartTime(startTime);
         endTime = Dateutils.formatEndTime(endTime);
 
+        Integer loginPlatformId = jyUserPlatformService.getLoginPlatformId();
+        List<Long> userIds = new ArrayList<>();
+        if(loginPlatformId != null) {
+            userIds = jyUserService.getByUserIdPlatform(loginPlatformId);
+        }
+
         HashMap<String,List<DataGroupByCount>> map = new HashMap<>();
         List<DataGroupByCount> kkList = new ArrayList<>();
         List<DataGroupByCount> kjList = new ArrayList<>();
@@ -256,24 +269,24 @@ public class DataService implements IDataService {
         int rule = Dateutils.DAY;
         switch (type){
             case 0 :
-                proList = dataMapper.sceneGroupBy("t_scene_pro",dayFormat,startTime,endTime);
-                plusList = dataMapper.sceneGroupBy("t_scene_plus",dayFormat,startTime,endTime);
-                proObjList = dataMapper.sceneObjGroupBy("t_scene_pro",dayFormat,startTime,endTime);
-                plusObjList = dataMapper.sceneObjGroupBy("t_scene_plus",dayFormat,startTime,endTime);
+                proList = dataMapper.sceneGroupBy("t_scene_pro",dayFormat,startTime,endTime,userIds);
+                plusList = dataMapper.sceneGroupBy("t_scene_plus",dayFormat,startTime,endTime,userIds);
+                proObjList = dataMapper.sceneObjGroupBy("t_scene_pro",dayFormat,startTime,endTime,userIds);
+                plusObjList = dataMapper.sceneObjGroupBy("t_scene_plus",dayFormat,startTime,endTime,userIds);
                 break;
             case 1 :
                 rule = Dateutils.WEEK;
-                proList = dataMapper.sceneGroupByWeek("t_scene_pro",startTime,endTime);
-                plusList = dataMapper.sceneGroupByWeek("t_scene_plus",startTime,endTime);
-                proObjList = dataMapper.sceneObjGroupByWeek("t_scene_pro",startTime,endTime);
-                plusObjList = dataMapper.sceneObjGroupByWeek("t_scene_plus",startTime,endTime);
+                proList = dataMapper.sceneGroupByWeek("t_scene_pro",startTime,endTime,userIds);
+                plusList = dataMapper.sceneGroupByWeek("t_scene_plus",startTime,endTime,userIds);
+                proObjList = dataMapper.sceneObjGroupByWeek("t_scene_pro",startTime,endTime,userIds);
+                plusObjList = dataMapper.sceneObjGroupByWeek("t_scene_plus",startTime,endTime,userIds);
                 break;
             case 2 :
                 rule = Dateutils.MONTH;
-                proList = dataMapper.sceneGroupBy("t_scene_pro",mouthFormat,startTime,endTime);
-                plusList = dataMapper.sceneGroupBy("t_scene_plus",mouthFormat,startTime,endTime);
-                proObjList = dataMapper.sceneObjGroupBy("t_scene_pro",mouthFormat,startTime,endTime);
-                plusObjList = dataMapper.sceneObjGroupBy("t_scene_plus",mouthFormat,startTime,endTime);
+                proList = dataMapper.sceneGroupBy("t_scene_pro",mouthFormat,startTime,endTime,userIds);
+                plusList = dataMapper.sceneGroupBy("t_scene_plus",mouthFormat,startTime,endTime,userIds);
+                proObjList = dataMapper.sceneObjGroupBy("t_scene_pro",mouthFormat,startTime,endTime,userIds);
+                plusObjList = dataMapper.sceneObjGroupBy("t_scene_plus",mouthFormat,startTime,endTime,userIds);
                 break;
         }
         HashMap<String, Long> kkMap = new HashMap<>();
@@ -333,12 +346,12 @@ public class DataService implements IDataService {
         Long sgCount = 0L;
         Long sgObjCount = 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);
-            sgCount = sceneProService.getSsCount(Arrays.asList("5"),startTime);
-            sgObjCount = sceneProService.getSsObjCount(Arrays.asList("5"),startTime);
+            kkCount = sceneProService.getKkCount(Arrays.asList("1","2","12","13","14"),startTime,userIds);
+            KjCount = sceneProService.getKkCount(Arrays.asList("3"),startTime,userIds);
+            ssCount = sceneProService.getSsCount(Arrays.asList("4"),startTime,userIds);
+            ssObjCount = sceneProService.getSsObjCount(Arrays.asList("4"),startTime,userIds);
+            sgCount = sceneProService.getSsCount(Arrays.asList("5"),startTime,userIds);
+            sgObjCount = sceneProService.getSsObjCount(Arrays.asList("5"),startTime,userIds);
         }
         List<String> dates = Dateutils.findDatesStr(Dateutils.getDate(startTime), Dateutils.getDate(endTime),rule );
         setListData(kkList,kkMap,dates,dataType,kkCount);

+ 23 - 3
src/main/java/com/fdkankan/manage/service/impl/SceneProServiceImpl.java

@@ -585,36 +585,52 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
 
     }
 
+
     @Override
-    public Long getKkCount(List<String> asList, String startTime) {
+    public Long getKkCount(List<String> asList, String startTime,List<Long> userIds) {
         LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(ScenePro::getSceneSource,asList);
+        if(!userIds.isEmpty()){
+            wrapper.in(ScenePro::getUserId,userIds);
+        }
         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);
+        if(!userIds.isEmpty()){
+            wrapper2.in(ScenePlus::getUserId,userIds);
+        }
         wrapper2.lt(ScenePlus::getCreateTime,startTime);
         long count1 = scenePlusService.count(wrapper2);
         return count + count1;
     }
     @Override
-    public Long getSsCount(List<String> asList, String startTime) {
+    public Long getSsCount(List<String> asList, String startTime,List<Long> userIds) {
         LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(ScenePro::getSceneSource,asList);
+        if(!userIds.isEmpty()){
+            wrapper.in(ScenePro::getUserId,userIds);
+        }
         wrapper.eq(ScenePro::getIsUpgrade,0);
         wrapper.lt(ScenePro::getCreateTime,startTime);
         LambdaQueryWrapper<ScenePlus> wrapper2 = new LambdaQueryWrapper<>();
         wrapper2.in(ScenePlus::getSceneSource,asList);
+        if(!userIds.isEmpty()){
+            wrapper2.in(ScenePlus::getUserId,userIds);
+        }
         wrapper2.lt(ScenePlus::getCreateTime,startTime);
         long count = scenePlusService.count(wrapper2);
         return this.count(wrapper) + count;
     }
     @Override
-    public Long getSsObjCount(List<String> asList, String startTime) {
+    public Long getSsObjCount(List<String> asList, String startTime,List<Long> userIds) {
         LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(ScenePro::getSceneSource,asList);
+        if(!userIds.isEmpty()){
+            wrapper.in(ScenePro::getUserId,userIds);
+        }
         wrapper.eq(ScenePro::getIsUpgrade,0);
         if(StringUtils.isNotBlank(startTime)){
             wrapper.lt(ScenePro::getCreateTime,startTime);
@@ -622,6 +638,9 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         wrapper.eq(ScenePro::getIsObj,1);
         LambdaQueryWrapper<ScenePlus> wrapper2 = new LambdaQueryWrapper<>();
         wrapper2.in(ScenePlus::getSceneSource,asList);
+        if(!userIds.isEmpty()){
+            wrapper2.in(ScenePlus::getUserId,userIds);
+        }
         if(StringUtils.isNotBlank(startTime)){
             wrapper2.lt(ScenePlus::getCreateTime,startTime);
         }
@@ -638,6 +657,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         return this.count(wrapper) + count;
     }
 
+
     @Override
     public HashMap<String, String> getSnCodeByNumList(Set<String> numList) {
         HashMap<String, Long> sceneMap = new HashMap<>();

+ 42 - 0
src/main/resources/mapper/manage/DataMapper.xml

@@ -74,18 +74,36 @@
     <select id="totalUserCount" resultType="java.lang.Long">
         select  count(id) from ${tb} where rec_status = 'A'
         <include refid="typeSQL"></include>
+        <if test="userIds != null and userIds.size >0">
+            and user_id in
+            <foreach item="userId" collection="userIds" open="(" separator="," close=")">
+                #{userId}
+            </foreach>
+        </if>
     </select>
 
     <select id="preMonthAddCount" resultType="java.lang.Long">
         SELECT count(id) FROM ${tb}
         WHERE rec_status = 'A' and date_format(create_time, '%Y %m') = date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),'%Y %m')
         <include refid="typeSQL"></include>
+        <if test="userIds != null and userIds.size >0">
+            and user_id in
+            <foreach item="userId" collection="userIds" open="(" separator="," close=")">
+                #{userId}
+            </foreach>
+        </if>
     </select>
 
     <select id="todayAddCount" resultType="java.lang.Long">
         SELECT count(id) FROM ${tb}
         WHERE rec_status = 'A' and DATEDIFF(create_time,NOW())=0
         <include refid="typeSQL"></include>
+        <if test="userIds != null and userIds.size >0">
+            and user_id in
+            <foreach item="userId" collection="userIds" open="(" separator="," close=")">
+                #{userId}
+            </foreach>
+        </if>
     </select>
 
     <select id="todayActiveCount" resultType="java.lang.Long">
@@ -106,6 +124,12 @@
           <if test="tb == 't_scene_pro'">
               AND is_upgrade = 0
           </if>
+        <if test="userIds != null and userIds.size >0">
+            and user_id in
+            <foreach item="userId" collection="userIds" open="(" separator="," close=")">
+                #{userId}
+            </foreach>
+        </if>
         and create_time between #{startTime} and #{endTime}
         GROUP BY groupKey ,groupKey2
     </select>
@@ -131,6 +155,12 @@
         <if test="tb == 't_scene_pro'">
             AND is_upgrade = 0
         </if>
+        <if test="userIds != null and userIds.size >0">
+            and user_id in
+            <foreach item="userId" collection="userIds" open="(" separator="," close=")">
+                #{userId}
+            </foreach>
+        </if>
         and create_time between #{startTime} and #{endTime}
         ) as tb GROUP BY groupKey,groupKey2
     </select>
@@ -147,6 +177,12 @@
         <if test="tb == 't_scene_pro'">
             AND is_upgrade = 0
         </if>
+        <if test="userIds != null and userIds.size >0">
+            and user_id in
+            <foreach item="userId" collection="userIds" open="(" separator="," close=")">
+                #{userId}
+            </foreach>
+        </if>
         and p.create_time between #{startTime} and #{endTime}
         GROUP BY groupKey ,groupKey2
     </select>
@@ -163,6 +199,12 @@
         <if test="tb == 't_scene_pro'">
             AND is_upgrade = 0
         </if>
+        <if test="userIds != null and userIds.size >0">
+            and user_id in
+            <foreach item="userId" collection="userIds" open="(" separator="," close=")">
+                #{userId}
+            </foreach>
+        </if>
         and p.create_time between #{startTime} and #{endTime}
         ) as tb GROUP BY groupKey,groupKey2
     </select>