From 45c61c834deddb3d16805fb132cbf4ca4298e444 Mon Sep 17 00:00:00 2001 From: jianjun Date: Sun, 25 Apr 2021 11:19:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=B0=8F=E7=BB=84?= =?UTF-8?q?=E6=88=90=E5=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractStatsAchievementService.java | 10 +++--- .../ResiGroupAchievementStatsService.java | 10 ++++++ .../service/StatsAchievementService.java | 5 ++- .../ResiGroupAchievementStatsServiceImpl.java | 10 +++++- .../impl/StatsAchievementServiceImpl.java | 34 ++++++++++++++----- .../impl/StatsAchievementServiceImplTest.java | 6 ++++ 6 files changed, 58 insertions(+), 17 deletions(-) diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/AbstractStatsAchievementService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/AbstractStatsAchievementService.java index 82b0e2afdb..41dd3e497b 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/AbstractStatsAchievementService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/AbstractStatsAchievementService.java @@ -44,14 +44,16 @@ public abstract class AbstractStatsAchievementService { /** - * desc: 根据成绩类型 分页获取成就配置 按targetValue 升序 + * desc: 根据客户Id清空客户小组成就数据 * - * @param offset - * @param pageSize + * @param customerId * @return java.util.List * @author LiuJanJun * @date 2021/4/22 1:36 下午 */ + protected Integer initPre(String customerId) { + return achievementStatsService.deleteByCId(customerId); + } /** * desc: 根据成绩类型 分页获取成就配置 按targetValue 升序 * @@ -61,7 +63,7 @@ public abstract class AbstractStatsAchievementService { * @author LiuJanJun * @date 2021/4/22 1:36 下午 */ - protected List getAchievemnetConfigPage(int pageNum, int pageSize, String achievementType) { + protected List getAchievementConfigPage(int pageNum, int pageSize, String achievementType) { return achievementConfigService.selectMoreThanOneByValue(achievementType, (pageNum - NumConstant.ONE) * pageSize, pageSize); } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupAchievementStatsService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupAchievementStatsService.java index 4fc8370ad9..fa51ca64f6 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupAchievementStatsService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupAchievementStatsService.java @@ -133,4 +133,14 @@ public interface ResiGroupAchievementStatsService extends BaseService haveArrive, boolean updateAll); + + /** + * desc: 请描述类的业务用途 + * + * @param customerId + * @return int + * @author LiuJanJun + * @date 2021/4/25 11:01 上午 + */ + int deleteByCId(String customerId); } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/StatsAchievementService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/StatsAchievementService.java index 7b532f83e0..c668caeacc 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/StatsAchievementService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/StatsAchievementService.java @@ -26,14 +26,13 @@ package com.epmet.modules.group.service; public interface StatsAchievementService{ /** - * desc: 计算小组成就 统一入口 + * desc: 初始化所有小组的各种成就入口 * - * @param achievementType 成就类型 小组人数、话题数、转议题数、小组内问题解决数 * @return java.lang.Boolean * @author LiuJanJun * @date 2021/4/20 */ - Boolean calculateAcm(String achievementType); + Boolean initAllGroupAchievement(); /** * desc: 根据小组Id计算小组成就 入口 diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupAchievementStatsServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupAchievementStatsServiceImpl.java index 3e84f116a3..92e1da3374 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupAchievementStatsServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupAchievementStatsServiceImpl.java @@ -20,10 +20,10 @@ package com.epmet.modules.group.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.modules.group.dao.ResiGroupAchievementStatsDao; import com.epmet.modules.group.entity.ResiGroupAchievementStatsEntity; import com.epmet.modules.group.service.ResiGroupAchievementStatsService; @@ -33,6 +33,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -141,4 +142,11 @@ public class ResiGroupAchievementStatsServiceImpl extends BaseServiceImpl param = new HashMap<>(); + param.put("CUSTOMER_ID",customerId); + return baseDao.deleteByMap(param); + } + } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/StatsAchievementServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/StatsAchievementServiceImpl.java index 973fda879d..b4acd9fd50 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/StatsAchievementServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/StatsAchievementServiceImpl.java @@ -5,8 +5,10 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.modules.enums.AchievementTypeEnum; +import com.epmet.modules.group.dao.ResiGroupDao; import com.epmet.modules.group.entity.ResiGroupAchievementConfigEntity; import com.epmet.modules.group.entity.ResiGroupAchievementStatsEntity; +import com.epmet.modules.group.entity.ResiGroupEntity; import com.epmet.modules.group.service.AbstractStatsAchievementService; import com.epmet.modules.group.service.StatsAchievementService; import com.epmet.modules.member.dao.ResiGroupMemberDao; @@ -38,22 +40,39 @@ public class StatsAchievementServiceImpl extends AbstractStatsAchievementService private ResiGroupMemberDao resiGroupMemberDao; @Autowired private ResiTopicDao resiTopicDao; + @Autowired + private ResiGroupDao resiGroupDao; /** * desc: 计算小组成就 统一入口 * - * @param achievementType 成就类型 * @return java.lang.Boolean * @author LiuJanJun * @date 2021/4/20 */ @Override - public Boolean calculateAcm(String achievementType) { - if (StringUtils.isBlank(achievementType)) { + public Boolean initAllGroupAchievement() { + //计算所有类型的 小组人数、话题数、转议题数、小组内问题解决数 - } - return null; + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(ResiGroupEntity::getDelFlag,'0'); + List groupEntities = resiGroupDao.selectList(queryWrapper); + groupEntities.forEach(group->{ + AchievementTypeEnum[] achievementTypeEnum = AchievementTypeEnum.values(); + Integer integer = super.initPre(group.getCustomerId()); + log.info("initPre del:{}",integer); + for (AchievementTypeEnum anEnum : achievementTypeEnum) { + try { + Thread.sleep(2); + } catch (InterruptedException e) { + e.printStackTrace(); + } + calculateAcm(group.getCustomerId(),group.getId(),anEnum.getCode()); + } + }); + + return true; } /** @@ -108,9 +127,6 @@ public class StatsAchievementServiceImpl extends AbstractStatsAchievementService default: log.info("calculateAcm error"); } - if (currentValue == 0) { - return true; - } log.info("calculateAcm achievementType:{},groupId:{},currentValue:{}", groupId, currentValue, achievementType); calculateGroupAchievement(customerId, groupId, currentValue, achievementType); return true; @@ -221,7 +237,7 @@ public class StatsAchievementServiceImpl extends AbstractStatsAchievementService } private List getConfigByType(String achievementType, int pageNum, int pageSize) { - List list = super.getAchievemnetConfigPage(pageNum, pageSize, achievementType); + List list = super.getAchievementConfigPage(pageNum, pageSize, achievementType); if (CollectionUtils.isEmpty(list)) { log.warn("获取小组成就配置错误,{} 开始进行初始化规则", achievementType); list = super.initAchievementConfig(achievementType); diff --git a/epmet-module/resi-group/resi-group-server/src/test/com/epmet/modules/group/service/impl/StatsAchievementServiceImplTest.java b/epmet-module/resi-group/resi-group-server/src/test/com/epmet/modules/group/service/impl/StatsAchievementServiceImplTest.java index c8e0e3b19d..4bdb7677b8 100644 --- a/epmet-module/resi-group/resi-group-server/src/test/com/epmet/modules/group/service/impl/StatsAchievementServiceImplTest.java +++ b/epmet-module/resi-group/resi-group-server/src/test/com/epmet/modules/group/service/impl/StatsAchievementServiceImplTest.java @@ -13,6 +13,12 @@ public class StatsAchievementServiceImplTest { @Autowired private StatsAchievementService statsAchievementService; + @Test + public void initAll() { + Boolean aBoolean = statsAchievementService.initAllGroupAchievement(); + System.out.println(aBoolean); + } + @Test public void calculateAcm() {