Browse Source

Merge branch 'dev_group_point' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_temp

master
jianjun 4 years ago
parent
commit
9f3f9c16e4
  1. 21
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java
  2. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupAchievementStatsDao.java
  3. 44
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/AbstractStatsAchievementService.java
  4. 3
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/StatsAchievementService.java
  5. 21
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/StatsAchievementServiceImpl.java
  6. 2
      epmet-module/resi-group/resi-group-server/src/test/com/epmet/modules/group/service/impl/StatsAchievementServiceImplTest.java

21
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,7 +33,6 @@ 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.PostMapping;
@ -40,10 +40,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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;
@ -62,6 +58,8 @@ public class ResiGroupController {
private ResiGroupService resiGroupService;
@Autowired
private ResiGroupStatisticalService resiGroupStatisticalService;
@Autowired
private StatsAchievementService statsAchievementService;
/**
* @param tokenDto
@ -578,4 +576,17 @@ public class ResiGroupController {
public Result<AchievementResultDTO> achievement(@LoginUser TokenDto tokenDto) {
return new Result<AchievementResultDTO>().ok(resiGroupService.achievement(tokenDto));
}
/**
* desc: 初始化小组成就用于小组成就上线后-历史小组的成就的初始化执行过后就再无意义
*
* @param customerId
* @return com.epmet.commons.tools.utils.Result<java.lang.Boolean>
* @author LiuJanJun
* @date 2021/4/25 12:41 下午
*/
@GetMapping("initachievement")
public Result<Boolean> initAchievement(@RequestParam String customerId) {
return new Result<Boolean>().ok(statsAchievementService.initAllGroupAchievement(customerId));
}
}

2
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<ResiGroupAchieveme
/**
* desc: 插入或更新成就
*
* @param haveArrive
* @param list
* @param updateAll
* @return int
* @author LiuJanJun

44
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/AbstractStatsAchievementService.java

@ -23,7 +23,9 @@ 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.entity.ResiGroupAchievementConfigEntity;
import com.epmet.modules.group.entity.ResiGroupAchievementStatsEntity;
import com.epmet.modules.support.GroupAchievementUtils;
import com.epmet.resi.group.dto.group.ResiGroupAchievementStatsDTO;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
@ -38,9 +40,9 @@ import java.util.List;
public abstract class AbstractStatsAchievementService {
@Autowired
public ResiGroupAchievementConfigService achievementConfigService;
private ResiGroupAchievementConfigService achievementConfigService;
@Autowired
public ResiGroupAchievementStatsService achievementStatsService;
private ResiGroupAchievementStatsService achievementStatsService;
/**
@ -105,4 +107,42 @@ public abstract class AbstractStatsAchievementService {
return newConfigList;
}
/**
* desc: 插入或新增成就统计
*
* @param haveArrive
* @param updateAll
* @return void
* @author LiuJanJun
* @date 2021/4/25 12:26 下午
*/
protected Integer saveOrUpdate(List<ResiGroupAchievementStatsEntity> 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);
}
}

3
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计算小组成就 入口

21
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<ResiGroupEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(ResiGroupEntity::getDelFlag,'0');
if (StringUtils.isNotBlank(customerId)){
queryWrapper.lambda().eq(ResiGroupEntity::getCustomerId,customerId);
}
List<ResiGroupEntity> 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<ResiGroupAchievementStatsEntity> 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);

2
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);
}

Loading…
Cancel
Save