From cb504dfba5e544f3ef57b6b46a32c8ce0105aae0 Mon Sep 17 00:00:00 2001 From: jianjun Date: Sun, 25 Apr 2021 12:55:00 +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 --- .../group/controller/ResiGroupController.java | 21 ++++++--- .../dao/ResiGroupAchievementStatsDao.java | 2 +- .../AbstractStatsAchievementService.java | 44 ++++++++++++++++++- .../service/StatsAchievementService.java | 3 +- .../impl/StatsAchievementServiceImpl.java | 21 +++++---- .../impl/StatsAchievementServiceImplTest.java | 2 +- 6 files changed, 75 insertions(+), 18 deletions(-) diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java index 30c0282b40..9f6ca58452 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java @@ -25,6 +25,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.modules.group.service.ResiGroupService; import com.epmet.modules.group.service.ResiGroupStatisticalService; +import com.epmet.modules.group.service.StatsAchievementService; import com.epmet.resi.group.dto.group.GroupProcessingCountResultDTO; import com.epmet.resi.group.dto.group.ResiGroupDTO; import com.epmet.resi.group.dto.group.form.*; @@ -32,14 +33,9 @@ import com.epmet.resi.group.dto.group.result.*; import com.epmet.resi.group.dto.member.form.EditAuditSwitchFormDTO; import com.epmet.resi.group.dto.member.form.ResiIdentityFormDTO; import com.epmet.resi.group.dto.member.result.AchievementResultDTO; -import oracle.jdbc.proxy.annotation.Post; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; import java.util.List; @@ -58,6 +54,8 @@ public class ResiGroupController { private ResiGroupService resiGroupService; @Autowired private ResiGroupStatisticalService resiGroupStatisticalService; + @Autowired + private StatsAchievementService statsAchievementService; /** * @param tokenDto @@ -562,4 +560,17 @@ public class ResiGroupController { public Result achievement(@LoginUser TokenDto tokenDto) { return new Result().ok(resiGroupService.achievement(tokenDto)); } + + /** + * desc: 初始化小组成就(用于小组成就上线后-历史小组的成就的初始化;执行过后就再无意义) + * + * @param customerId + * @return com.epmet.commons.tools.utils.Result + * @author LiuJanJun + * @date 2021/4/25 12:41 下午 + */ + @GetMapping("initachievement") + public Result initAchievement(@RequestParam String customerId) { + return new Result().ok(statsAchievementService.initAllGroupAchievement(customerId)); + } } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupAchievementStatsDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupAchievementStatsDao.java index 247c371ed6..d1113cc8cc 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupAchievementStatsDao.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupAchievementStatsDao.java @@ -58,7 +58,7 @@ public interface ResiGroupAchievementStatsDao extends BaseDao haveArrive, boolean updateAll){ + return achievementStatsService.saveOrUpdate(haveArrive,updateAll); + } + + /** + * desc: 获取小组最后一个未实现的成就 + * + * @param customerId + * @param groupId + * @param achievementType + * @return com.epmet.modules.group.entity.ResiGroupAchievementStatsEntity + * @author LiuJanJun + * @date 2021/4/25 12:28 下午 + */ + protected ResiGroupAchievementStatsEntity selectLastUnAchieved(String customerId, String groupId, String achievementType){ + return achievementStatsService.selectLastUnAchieved(customerId, groupId, achievementType); + } + + /** + * desc: 更新小组成就 + * + * @param recordDTO + * @return java.lang.Integer + * @author LiuJanJun + * @date 2021/4/25 12:30 下午 + */ + protected void update(ResiGroupAchievementStatsDTO recordDTO){ + achievementStatsService.update(recordDTO); + } } 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 c668caeacc..981c31f46a 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 @@ -28,11 +28,12 @@ public interface StatsAchievementService{ /** * desc: 初始化所有小组的各种成就入口 * + * @param customerId * @return java.lang.Boolean * @author LiuJanJun * @date 2021/4/20 */ - Boolean initAllGroupAchievement(); + Boolean initAllGroupAchievement(String customerId); /** * desc: 根据小组Id计算小组成就 入口 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 b4acd9fd50..1ef3e9f452 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 @@ -52,16 +52,19 @@ public class StatsAchievementServiceImpl extends AbstractStatsAchievementService * @date 2021/4/20 */ @Override - public Boolean initAllGroupAchievement() { + public Boolean initAllGroupAchievement(String customerId) { //计算所有类型的 小组人数、话题数、转议题数、小组内问题解决数 QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(ResiGroupEntity::getDelFlag,'0'); + if (StringUtils.isNotBlank(customerId)){ + queryWrapper.lambda().eq(ResiGroupEntity::getCustomerId,customerId); + } List groupEntities = resiGroupDao.selectList(queryWrapper); groupEntities.forEach(group->{ AchievementTypeEnum[] achievementTypeEnum = AchievementTypeEnum.values(); - Integer integer = super.initPre(group.getCustomerId()); - log.info("initPre del:{}",integer); + //Integer integer = super.initPre(group.getCustomerId()); + //log.info("initPre del:{}",integer); for (AchievementTypeEnum anEnum : achievementTypeEnum) { try { Thread.sleep(2); @@ -140,14 +143,14 @@ public class StatsAchievementServiceImpl extends AbstractStatsAchievementService */ private void calculateGroupAchievement(String customerId, String groupId, int currentValue, String achievementType) { //根据成就类型获取小组未实现成就 数据库正常只会有一条 - ResiGroupAchievementStatsEntity one = super.achievementStatsService.selectLastUnAchieved(customerId, groupId, achievementType); + ResiGroupAchievementStatsEntity one = super.selectLastUnAchieved(customerId, groupId, achievementType); List haveArrive = new ArrayList<>(); //如果没有实现的成就则说明是初始化 if (one == null) { initAchievementStat(customerId, groupId, achievementType, currentValue, haveArrive); //初始化如果记录存在 只更新修改时间 - super.achievementStatsService.saveOrUpdate(haveArrive, false); + super.saveOrUpdate(haveArrive, false); return; } @@ -167,13 +170,13 @@ public class StatsAchievementServiceImpl extends AbstractStatsAchievementService } if (isBatch) { - super.achievementStatsService.saveOrUpdate(haveArrive, true); + super.saveOrUpdate(haveArrive, true); } else { //未实现 只更新当前值 ResiGroupAchievementStatsDTO newStat = new ResiGroupAchievementStatsDTO(); newStat.setId(one.getId()); newStat.setCurrentValue(currentValue); - super.achievementStatsService.update(newStat); + super.update(newStat); } } @@ -218,14 +221,16 @@ public class StatsAchievementServiceImpl extends AbstractStatsAchievementService statsEntity.setGroupId(groupId); statsEntity.setAchievementId(configEntity.getId()); statsEntity.setAchievementName(configEntity.getAchievementName()); - statsEntity.setArriveTime(new Date()); + statsEntity.setAchievementType(achievementType); statsEntity.setCurrentValue(currentValue); statsEntity.setTargetValue(configEntity.getTargetValue()); + statsEntity.setDelFlag(NumConstant.ZERO_STR); haveArrive.add(statsEntity); if (currentValue >= configEntity.getTargetValue()) { statsEntity.setIsArrive(NumConstant.ONE); + statsEntity.setArriveTime(new Date()); } else { //如果没有达到则 放入这一条后 退出 statsEntity.setIsArrive(NumConstant.ZERO); 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 4bdb7677b8..c38cf87259 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 @@ -15,7 +15,7 @@ public class StatsAchievementServiceImplTest { @Test public void initAll() { - Boolean aBoolean = statsAchievementService.initAllGroupAchievement(); + Boolean aBoolean = statsAchievementService.initAllGroupAchievement(null); System.out.println(aBoolean); }