日期格式转换

This commit is contained in:
tianfeng 2025-09-12 19:26:19 +08:00
parent 07e2018a58
commit eff6cf17d0

View File

@ -11,6 +11,8 @@ import com.red.circle.other.app.dto.clientobject.sys.ActivityConfigVO;
import com.red.circle.other.app.dto.cmd.activity.WeekKingQueenRankingQueryCmd;
import com.red.circle.other.app.service.activity.WeekKingQueenService;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -43,6 +45,8 @@ public class WeekKingQueenController extends BaseController {
private final WeekKingQueenService weekKingQueenService;
private final WeekKingQueenCountService weekKingQueenCountService;
private final UserProfileGateway userProfileGateway;
private static final DateTimeFormatter oldFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
private static final DateTimeFormatter newFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
/**
* 排行榜.
@ -75,12 +79,15 @@ public class WeekKingQueenController extends BaseController {
List<WeekKingQueenGroupVO> result = new ArrayList<>();
for (Map.Entry<String, List<WeekKingQueenCount>> entry : groupMap.entrySet()) {
WeekKingQueenGroupVO vo = new WeekKingQueenGroupVO();
vo.setGroup(entry.getKey());
// 转换 group 格式
vo.setGroup(LocalDate.parse(entry.getKey(), oldFormatter).format(newFormatter));
// 遍历同一周的数据 WEALTH / CHARM 分开
for (WeekKingQueenCount e : entry.getValue()) {
WeekKingQueenHistoryVO historyVO = new WeekKingQueenHistoryVO();
BeanUtils.copyProperties(e, historyVO);
historyVO.setGroup(LocalDate.parse(entry.getKey(), oldFormatter).format(newFormatter));
UserProfile userProfile = profileMap.get(e.getUserId());
if (userProfile != null) {