后台统计-统计-公会-公会长国家
This commit is contained in:
@@ -14,8 +14,14 @@ public class WeekActiveGuildStat {
|
||||
private Integer partitionId;
|
||||
private Integer guildId;
|
||||
|
||||
private Long ownerUid;
|
||||
@TableField(exist = false)
|
||||
private Long ownErbanNo;
|
||||
private Long ownerErbanNo;
|
||||
@TableField(exist = false)
|
||||
private Integer ownerRegionId;
|
||||
@TableField(exist = false)
|
||||
private String ownerRegionName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String groupByKey;
|
||||
|
||||
|
@@ -1,20 +1,22 @@
|
||||
package com.accompany.business.service;
|
||||
|
||||
import com.accompany.business.dto.WeekActiveGuildStat;
|
||||
import com.accompany.business.model.Hall;
|
||||
import com.accompany.business.model.WeekGuildStat;
|
||||
import com.accompany.business.model.family.Family;
|
||||
import com.accompany.business.model.guild.Guild;
|
||||
import com.accompany.business.mybatismapper.WeekGuildStatMapper;
|
||||
import com.accompany.business.mybatismapper.WeekActiveGuildStatMapper;
|
||||
import com.accompany.business.service.family.FamilyService;
|
||||
import com.accompany.business.service.guild.GuildService;
|
||||
import com.accompany.business.service.hall.HallService;
|
||||
import com.accompany.business.vo.family.SimpleFamilyMemberVo;
|
||||
import com.accompany.business.vo.guild.AgencyOwnerVo;
|
||||
import com.accompany.business.vo.hall.HallVo;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.model.PageReq;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.common.utils.StringUtils;
|
||||
import com.accompany.core.enumeration.PartitionEnum;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.region.RegionInfoService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -47,6 +49,10 @@ public class WeekGuildStatService {
|
||||
private FamilyService familyService;
|
||||
@Autowired
|
||||
private HallService hallService;
|
||||
@Autowired
|
||||
private RegionInfoService regionInfoService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
|
||||
public void stat(String monday) {
|
||||
stat(monday, true);
|
||||
@@ -165,36 +171,106 @@ public class WeekGuildStatService {
|
||||
|
||||
Map<Integer, List<WeekActiveGuildStat>> activeGuildPartitionMap = activeGuildStatList.stream().collect(Collectors.groupingBy(WeekActiveGuildStat::getPartitionId));
|
||||
|
||||
List<WeekActiveGuildStat> enActiveGuildList = activeGuildPartitionMap.getOrDefault(PartitionEnum.ENGLISH.getId(), Collections.emptyList())
|
||||
.stream().sorted(Comparator.comparing(WeekActiveGuildStat::getGuildDiamondFlow).reversed()).collect(Collectors.toList());
|
||||
List<WeekActiveGuildStat> enActiveGuildList = buildActiveCountDetail(activeGuildPartitionMap, PartitionEnum.ENGLISH.getId());
|
||||
stat.setEnActiveCount(enActiveGuildList.size());
|
||||
stat.setEnActiveCountDetail(JSON.toJSONString(enActiveGuildList));
|
||||
|
||||
List<WeekActiveGuildStat> arActiveGuildList = activeGuildPartitionMap.getOrDefault(PartitionEnum.ARAB.getId(), Collections.emptyList())
|
||||
.stream().sorted(Comparator.comparing(WeekActiveGuildStat::getGuildDiamondFlow).reversed()).collect(Collectors.toList());;
|
||||
List<WeekActiveGuildStat> arActiveGuildList = buildActiveCountDetail(activeGuildPartitionMap, PartitionEnum.ARAB.getId());
|
||||
stat.setArActiveCount(arActiveGuildList.size());
|
||||
stat.setArActiveCountDetail(JSON.toJSONString(arActiveGuildList));
|
||||
|
||||
List<WeekActiveGuildStat> zhActiveGuildList = activeGuildPartitionMap.getOrDefault(PartitionEnum.CHINESE.getId(), Collections.emptyList())
|
||||
.stream().sorted(Comparator.comparing(WeekActiveGuildStat::getGuildDiamondFlow).reversed()).collect(Collectors.toList());;
|
||||
List<WeekActiveGuildStat> zhActiveGuildList = buildActiveCountDetail(activeGuildPartitionMap, PartitionEnum.CHINESE.getId());
|
||||
stat.setZhActiveCount(zhActiveGuildList.size());
|
||||
stat.setZhActiveCountDetail(JSON.toJSONString(zhActiveGuildList));
|
||||
|
||||
List<WeekActiveGuildStat> trActiveGuildList = activeGuildPartitionMap.getOrDefault(PartitionEnum.TURKEY.getId(), Collections.emptyList())
|
||||
.stream().sorted(Comparator.comparing(WeekActiveGuildStat::getGuildDiamondFlow).reversed()).collect(Collectors.toList());;
|
||||
List<WeekActiveGuildStat> trActiveGuildList = buildActiveCountDetail(activeGuildPartitionMap, PartitionEnum.TURKEY.getId());
|
||||
stat.setTrActiveCount(trActiveGuildList.size());
|
||||
stat.setTrActiveCountDetail(JSON.toJSONString(trActiveGuildList));
|
||||
|
||||
List<WeekActiveGuildStat> en2ActiveGuildList = activeGuildPartitionMap.getOrDefault(PartitionEnum.ENGLISH2.getId(), Collections.emptyList())
|
||||
.stream().sorted(Comparator.comparing(WeekActiveGuildStat::getGuildDiamondFlow).reversed()).collect(Collectors.toList());;
|
||||
List<WeekActiveGuildStat> en2ActiveGuildList = buildActiveCountDetail(activeGuildPartitionMap, PartitionEnum.ENGLISH2.getId());
|
||||
stat.setEn2ActiveCount(en2ActiveGuildList.size());
|
||||
stat.setEn2ActiveCountDetail(JSON.toJSONString(en2ActiveGuildList));
|
||||
|
||||
guildWeekPlatformStatMapper.insertOrUpdate(stat);
|
||||
}
|
||||
|
||||
private List<WeekActiveGuildStat> buildActiveCountDetail(Map<Integer, List<WeekActiveGuildStat>> activeGuildPartitionMap, Integer partitionId) {
|
||||
if (!activeGuildPartitionMap.containsKey(partitionId)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<WeekActiveGuildStat> detailList = activeGuildPartitionMap.get(partitionId);
|
||||
|
||||
Map<Integer, Long> ownerUidMap = new HashMap<>();
|
||||
|
||||
List<Integer> guildIdList = detailList.stream().map(WeekActiveGuildStat::getGuildId).distinct().toList();
|
||||
if (!CollectionUtils.isEmpty(guildIdList)){
|
||||
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
|
||||
if (Constant.ClanMode.CLAN_HALL.equals(partitionEnum.getClanMode())){
|
||||
List<Hall> hallList = hallService.listHallByIds(guildIdList.stream().map(Integer::longValue).toList());
|
||||
hallList.forEach(hall->{
|
||||
ownerUidMap.put(hall.getId().intValue(), hall.getOwnerUid());
|
||||
});
|
||||
} else if (Constant.ClanMode.FAMILY.equals(partitionEnum.getClanMode())) {
|
||||
List<Family> familyList = familyService.listByIds(guildIdList);
|
||||
familyList.forEach(family->{
|
||||
ownerUidMap.put(family.getId(), family.getOwnerUid());
|
||||
});
|
||||
} else if (Constant.ClanMode.GUILD.equals(partitionEnum.getClanMode()) || Constant.ClanMode.GUILD_POLICY2.equals(partitionEnum.getClanMode())) {
|
||||
List<Guild> guildList = guildService.listByIds(guildIdList);
|
||||
guildList.forEach(guild->{
|
||||
ownerUidMap.put(guild.getId(), guild.getOwnerUid());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<Long, Users> ownerUserMap = usersService.getUsersMapByUids(ownerUidMap.values().stream().toList());
|
||||
|
||||
Map<Integer, String> regionNameMap = regionInfoService.getRegionName();
|
||||
|
||||
return detailList.stream().peek(item->{
|
||||
Long ownerUid = ownerUidMap.get(item.getGuildId());
|
||||
if (null != ownerUid){
|
||||
Users ownerUser = ownerUserMap.get(ownerUid);
|
||||
if (ownerUser != null){
|
||||
item.setOwnerRegionId(ownerUser.getRegionId());
|
||||
item.setOwnerRegionName(regionNameMap.get(ownerUser.getRegionId()));
|
||||
item.setOwnerUid(ownerUser.getUid());
|
||||
item.setOwnerErbanNo(ownerUser.getErbanNo());
|
||||
}
|
||||
}
|
||||
}).sorted(Comparator.comparing(WeekActiveGuildStat::getGuildDiamondFlow).reversed()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<WeekActiveGuildStat> buildNewCountDetail(Map<Integer, List<String>> newGuildCountMap, Map<String, WeekActiveGuildStat> activeGuildStatMap,
|
||||
Integer partitionId, String monday, String sunday){
|
||||
Map<Integer, Long> ownerUidMap = new HashMap<>();
|
||||
|
||||
List<Long> guildIdList = newGuildCountMap.containsKey(partitionId)? newGuildCountMap.get(partitionId).stream().map(key->Long.parseLong(key.split("_")[1])).distinct().toList():Collections.emptyList();
|
||||
if (!CollectionUtils.isEmpty(guildIdList)){
|
||||
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
|
||||
if (Constant.ClanMode.CLAN_HALL.equals(partitionEnum.getClanMode())){
|
||||
List<Hall> hallList = hallService.listHallByIds(guildIdList);
|
||||
hallList.forEach(hall->{
|
||||
ownerUidMap.put(hall.getId().intValue(), hall.getOwnerUid());
|
||||
});
|
||||
} else if (Constant.ClanMode.FAMILY.equals(partitionEnum.getClanMode())) {
|
||||
List<Family> familyList = familyService.listByIds(guildIdList);
|
||||
familyList.forEach(family->{
|
||||
ownerUidMap.put(family.getId(), family.getOwnerUid());
|
||||
});
|
||||
} else if (Constant.ClanMode.GUILD.equals(partitionEnum.getClanMode()) || Constant.ClanMode.GUILD_POLICY2.equals(partitionEnum.getClanMode())) {
|
||||
List<Guild> guildList = guildService.listByIds(guildIdList);
|
||||
guildList.forEach(guild->{
|
||||
ownerUidMap.put(guild.getId(), guild.getOwnerUid());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<Long, Users> ownerUserMap = usersService.getUsersMapByUids(ownerUidMap.values().stream().toList());
|
||||
|
||||
Map<Integer, String> regionNameMap = regionInfoService.getRegionName();
|
||||
|
||||
return newGuildCountMap.containsKey(partitionId)?
|
||||
newGuildCountMap.get(partitionId).stream().map(key->{
|
||||
WeekActiveGuildStat item = activeGuildStatMap.get(key);
|
||||
@@ -210,8 +286,20 @@ public class WeekGuildStatService {
|
||||
item.setGuildGoldFlow(BigDecimal.ZERO);
|
||||
return item;
|
||||
}
|
||||
|
||||
return item;
|
||||
}).sorted(Comparator.comparing(WeekActiveGuildStat::getGuildDiamondFlow).reversed())
|
||||
}).peek(item->{
|
||||
Long ownerUid = ownerUidMap.get(item.getGuildId());
|
||||
if (null != ownerUid){
|
||||
Users ownerUser = ownerUserMap.get(ownerUid);
|
||||
if (null != ownerUser){
|
||||
item.setOwnerErbanNo(ownerUser.getErbanNo());
|
||||
item.setOwnerRegionId(ownerUser.getRegionId());
|
||||
item.setOwnerRegionName(regionNameMap.get(ownerUser.getRegionId()));
|
||||
}
|
||||
}
|
||||
|
||||
}).sorted(Comparator.comparing(WeekActiveGuildStat::getGuildDiamondFlow).reversed())
|
||||
.collect(Collectors.toList()): Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -224,147 +312,7 @@ public class WeekGuildStatService {
|
||||
Page<WeekGuildStat> page = new Page<>(pageReq.getPage(), pageReq.getPageSize());
|
||||
QueryWrapper<WeekGuildStat> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().orderByDesc(WeekGuildStat::getDate);
|
||||
Page<WeekGuildStat> weekGuildStatPage = guildWeekPlatformStatMapper.selectPage(page, queryWrapper);
|
||||
List<WeekGuildStat> records = weekGuildStatPage.getRecords();
|
||||
if (CollectionUtils.isEmpty(records)) {
|
||||
return weekGuildStatPage;
|
||||
}
|
||||
Map<Integer, AgencyOwnerVo> guildMap = guildService.getAgencyOwnerMapByHallIds(null);
|
||||
Map<Integer, SimpleFamilyMemberVo> familyMap = familyService.getOwnerUserMap(null);
|
||||
Map<Long, HallVo> hallMap = hallService.mapHallByIds(null);
|
||||
for (WeekGuildStat record : records) {
|
||||
try {
|
||||
String enNewCountDetail = record.getEnNewCountDetail();
|
||||
if (StringUtils.isNotEmpty(enNewCountDetail)) {
|
||||
List<WeekActiveGuildStat> enNewCountDetailList = JSON.parseArray(enNewCountDetail, WeekActiveGuildStat.class);
|
||||
for (WeekActiveGuildStat weekActiveGuildStat : enNewCountDetailList) {
|
||||
SimpleFamilyMemberVo memberVo = familyMap.get(weekActiveGuildStat.getGuildId());
|
||||
if (memberVo != null) {
|
||||
weekActiveGuildStat.setOwnErbanNo(memberVo.getErbanNo());
|
||||
}
|
||||
}
|
||||
record.setEnNewCountDetail(JSON.toJSONString(enNewCountDetailList));
|
||||
}
|
||||
|
||||
String arNewCountDetail = record.getArNewCountDetail();
|
||||
if (StringUtils.isNotEmpty(arNewCountDetail)) {
|
||||
List<WeekActiveGuildStat> arNewCountDetailList = JSON.parseArray(arNewCountDetail, WeekActiveGuildStat.class);
|
||||
for (WeekActiveGuildStat weekActiveGuildStat : arNewCountDetailList) {
|
||||
AgencyOwnerVo memberVo = guildMap.get(weekActiveGuildStat.getGuildId());
|
||||
if (memberVo != null) {
|
||||
weekActiveGuildStat.setOwnErbanNo(memberVo.getErbanNo());
|
||||
}
|
||||
}
|
||||
record.setArNewCountDetail(JSON.toJSONString(arNewCountDetailList));
|
||||
}
|
||||
|
||||
String zhNewCountDetail = record.getZhNewCountDetail();
|
||||
if (StringUtils.isNotEmpty(zhNewCountDetail)) {
|
||||
List<WeekActiveGuildStat> zhNewCountDetailList = JSON.parseArray(zhNewCountDetail, WeekActiveGuildStat.class);
|
||||
for (WeekActiveGuildStat weekActiveGuildStat : zhNewCountDetailList) {
|
||||
HallVo memberVo = hallMap.get(weekActiveGuildStat.getGuildId().longValue());
|
||||
if (memberVo != null) {
|
||||
weekActiveGuildStat.setOwnErbanNo(memberVo.getOwnerErbanNo());
|
||||
}
|
||||
}
|
||||
record.setZhNewCountDetail(JSON.toJSONString(zhNewCountDetailList));
|
||||
}
|
||||
|
||||
String trNewCountDetail = record.getTrNewCountDetail();
|
||||
if (StringUtils.isNotEmpty(trNewCountDetail)) {
|
||||
List<WeekActiveGuildStat> trNewCountDetailList = JSON.parseArray(trNewCountDetail, WeekActiveGuildStat.class);
|
||||
for (WeekActiveGuildStat weekActiveGuildStat : trNewCountDetailList) {
|
||||
AgencyOwnerVo memberVo = guildMap.get(weekActiveGuildStat.getGuildId());
|
||||
if (memberVo != null) {
|
||||
weekActiveGuildStat.setOwnErbanNo(memberVo.getErbanNo());
|
||||
}
|
||||
}
|
||||
record.setTrNewCountDetail(JSON.toJSONString(trNewCountDetailList));
|
||||
}
|
||||
|
||||
String en2NewCountDetail = record.getEn2NewCountDetail();
|
||||
if (StringUtils.isNotEmpty(en2NewCountDetail)) {
|
||||
List<WeekActiveGuildStat> en2NewCountDetailList = JSON.parseArray(en2NewCountDetail, WeekActiveGuildStat.class);
|
||||
for (WeekActiveGuildStat weekActiveGuildStat : en2NewCountDetailList) {
|
||||
if (weekActiveGuildStat.getGuildId() == null) {
|
||||
continue;
|
||||
}
|
||||
AgencyOwnerVo memberVo = guildMap.get(weekActiveGuildStat.getGuildId());
|
||||
if (memberVo != null) {
|
||||
weekActiveGuildStat.setOwnErbanNo(memberVo.getErbanNo());
|
||||
}
|
||||
}
|
||||
record.setEn2NewCountDetail(JSON.toJSONString(en2NewCountDetailList));
|
||||
}
|
||||
//-----------------------
|
||||
String enActiveCountDetail = record.getEnActiveCountDetail();
|
||||
if (StringUtils.isNotEmpty(enActiveCountDetail)) {
|
||||
List<WeekActiveGuildStat> enActiveGuildList = JSON.parseArray(enActiveCountDetail, WeekActiveGuildStat.class);
|
||||
for (WeekActiveGuildStat weekActiveGuildStat : enActiveGuildList) {
|
||||
SimpleFamilyMemberVo memberVo = familyMap.get(weekActiveGuildStat.getGuildId());
|
||||
if (memberVo != null) {
|
||||
weekActiveGuildStat.setOwnErbanNo(memberVo.getErbanNo());
|
||||
}
|
||||
}
|
||||
record.setEnActiveCountDetail(JSON.toJSONString(enActiveGuildList));
|
||||
}
|
||||
|
||||
String arActiveCountDetail = record.getArActiveCountDetail();
|
||||
if (StringUtils.isNotEmpty(arActiveCountDetail)) {
|
||||
List<WeekActiveGuildStat> arActiveGuildList = JSON.parseArray(arActiveCountDetail, WeekActiveGuildStat.class);
|
||||
for (WeekActiveGuildStat weekActiveGuildStat : arActiveGuildList) {
|
||||
AgencyOwnerVo memberVo = guildMap.get(weekActiveGuildStat.getGuildId());
|
||||
if (memberVo != null) {
|
||||
weekActiveGuildStat.setOwnErbanNo(memberVo.getErbanNo());
|
||||
}
|
||||
}
|
||||
record.setArActiveCountDetail(JSON.toJSONString(arActiveGuildList));
|
||||
}
|
||||
|
||||
String zhActiveCountDetail = record.getZhActiveCountDetail();
|
||||
if (StringUtils.isNotEmpty(zhActiveCountDetail)) {
|
||||
List<WeekActiveGuildStat> zhActiveGuildList = JSON.parseArray(zhActiveCountDetail, WeekActiveGuildStat.class);
|
||||
for (WeekActiveGuildStat weekActiveGuildStat : zhActiveGuildList) {
|
||||
HallVo memberVo = hallMap.get(weekActiveGuildStat.getGuildId().longValue());
|
||||
if (memberVo != null) {
|
||||
weekActiveGuildStat.setOwnErbanNo(memberVo.getOwnerErbanNo());
|
||||
}
|
||||
}
|
||||
record.setZhActiveCountDetail(JSON.toJSONString(zhActiveGuildList));
|
||||
}
|
||||
|
||||
|
||||
String trActiveCountDetail = record.getTrActiveCountDetail();
|
||||
if (StringUtils.isNotEmpty(trActiveCountDetail)) {
|
||||
List<WeekActiveGuildStat> trActiveGuildList = JSON.parseArray(trActiveCountDetail, WeekActiveGuildStat.class);
|
||||
for (WeekActiveGuildStat weekActiveGuildStat : trActiveGuildList) {
|
||||
AgencyOwnerVo memberVo = guildMap.get(weekActiveGuildStat.getGuildId());
|
||||
if (memberVo != null) {
|
||||
weekActiveGuildStat.setOwnErbanNo(memberVo.getErbanNo());
|
||||
}
|
||||
}
|
||||
record.setTrActiveCountDetail(JSON.toJSONString(trActiveGuildList));
|
||||
}
|
||||
|
||||
String en2ActiveCountDetail = record.getEn2ActiveCountDetail();
|
||||
if (StringUtils.isNotEmpty(en2ActiveCountDetail)) {
|
||||
List<WeekActiveGuildStat> en2ActiveGuildList = JSON.parseArray(en2ActiveCountDetail, WeekActiveGuildStat.class);
|
||||
for (WeekActiveGuildStat weekActiveGuildStat : en2ActiveGuildList) {
|
||||
if (weekActiveGuildStat.getGuildId() == null) {
|
||||
continue;
|
||||
}
|
||||
AgencyOwnerVo memberVo = guildMap.get(weekActiveGuildStat.getGuildId());
|
||||
if (memberVo != null) {
|
||||
weekActiveGuildStat.setOwnErbanNo(memberVo.getErbanNo());
|
||||
}
|
||||
}
|
||||
record.setEn2ActiveCountDetail(JSON.toJSONString(en2ActiveGuildList));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("WeekGuildStatService.pageWeekGuildStat,e:{}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return weekGuildStatPage;
|
||||
return guildWeekPlatformStatMapper.selectPage(page, queryWrapper);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user