@@ -61,4 +61,11 @@ public class MessageSharedController { | |||
return ApiResponse.of(pagination); | |||
} | |||
@ApiOperation(value = "首页统计") | |||
@PostMapping(value = "/homeStatistics") | |||
public ApiResponse<HomeStatisticsResponseDto> homeStatistics(@RequestBody @Valid HomeStatisticsRequestDto request){ | |||
HomeStatisticsResponseDto responseDto = messageWaitSendManager.homeStatistics(request); | |||
return ApiResponse.of(responseDto); | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
package cn.com.taiji.msgw.dto; | |||
import cn.com.taiji.common.entity.BaseEntity; | |||
import cn.com.taiji.core.entity.dict.msgw.MessageType; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import java.time.LocalDateTime; | |||
@Getter | |||
@Setter | |||
public class HomeStatisticsRequestDto extends BaseEntity { | |||
/** | |||
* 消息类型 | |||
*/ | |||
private MessageType messageType; | |||
/*** | |||
* 统计开始日期 | |||
*/ | |||
private LocalDateTime startDate; | |||
/*** | |||
* 统计结束日期 | |||
*/ | |||
private LocalDateTime endDate; | |||
} |
@@ -0,0 +1,19 @@ | |||
package cn.com.taiji.msgw.dto; | |||
import java.util.List; | |||
import cn.com.taiji.common.model.BaseModel; | |||
import cn.com.taiji.core.entity.msgw.MsgwSmsKeyConfig; | |||
import cn.com.taiji.msgw.model.HomeStatisticsModel; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class HomeStatisticsResponseDto extends BaseModel { | |||
List<HomeStatisticsModel> list; | |||
} |
@@ -31,4 +31,7 @@ public interface MessageWaitSendManager { | |||
/**用户分页*/ | |||
Pagination userPage(UserListRequestDto request); | |||
/**首页统计*/ | |||
HomeStatisticsResponseDto homeStatistics(HomeStatisticsRequestDto request); | |||
} |
@@ -4,6 +4,7 @@ import java.time.LocalDateTime; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import cn.com.taiji.msgw.model.HomeStatisticsModel; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -198,9 +199,6 @@ public class MessageWaitSendManagerImpl extends AbstractCommManager implements M | |||
return sendDetailsRepo.page(request); | |||
} | |||
@Override | |||
public Pagination userPage(UserListRequestDto request){ | |||
Pagination pagination = new Pagination(); | |||
@@ -236,5 +234,35 @@ public class MessageWaitSendManagerImpl extends AbstractCommManager implements M | |||
return pagination; | |||
} | |||
@Override | |||
public HomeStatisticsResponseDto homeStatistics(HomeStatisticsRequestDto request) { | |||
HomeStatisticsResponseDto response = new HomeStatisticsResponseDto(); | |||
// 获取开始时间与结束时间 | |||
LocalDateTime startDateTime = request.getStartDate(); | |||
LocalDateTime endDateTime = request.getEndDate(); | |||
// 循环从开始日期到结束日期的前一天 | |||
List<HomeStatisticsModel> list = new ArrayList<>(); | |||
LocalDateTime currentDate = startDateTime; | |||
while (currentDate.isBefore(endDateTime)) { | |||
LocalDateTime nextDate = currentDate.plusDays(1); | |||
Long totalNum = sendDetailsRepo.countStatistics(request.getMessageType(), null, currentDate, nextDate); | |||
//成功消息总数 | |||
Long successTotalNum = sendDetailsRepo.countStatistics(request.getMessageType(), MessageResult.SEND, currentDate, nextDate); | |||
//失败消息总数 | |||
Long failTotalNum = sendDetailsRepo.countStatistics(request.getMessageType(), MessageResult.FAIL, currentDate, nextDate); | |||
//待发送消息总数 | |||
Long waitTotalNum = sendDetailsRepo.countStatistics(request.getMessageType(), MessageResult.WAIT, currentDate, nextDate); | |||
//过期消息总数 | |||
Long expiredTotalNum = sendDetailsRepo.countStatistics(request.getMessageType(), MessageResult.EXPIRED, currentDate, nextDate); | |||
//取消消息总数 | |||
Long cancelTotalNum = sendDetailsRepo.countStatistics(request.getMessageType(), MessageResult.CANCEL, currentDate, nextDate); | |||
HomeStatisticsModel model = new HomeStatisticsModel(currentDate.toLocalDate().toString(), totalNum, successTotalNum, failTotalNum, waitTotalNum, expiredTotalNum, cancelTotalNum); | |||
list.add(model); | |||
currentDate = nextDate; | |||
} | |||
response.setList(list); | |||
return response; | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
package cn.com.taiji.msgw.model; | |||
import cn.com.taiji.common.model.BaseModel; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
@Getter | |||
@Setter | |||
public class HomeStatisticsModel extends BaseModel { | |||
private String date; | |||
private Long totalNum; | |||
private Long successTotalNum; | |||
private Long failTotalNum; | |||
private Long waitTotalNum; | |||
private Long expiredTotalNum; | |||
private Long cancelTotalNum; | |||
public HomeStatisticsModel(String date, Long totalNum, Long successTotalNum, Long failTotalNum, Long waitTotalNum, Long expiredTotalNum, Long cancelTotalNum) { | |||
this.date = date; | |||
this.totalNum = totalNum; | |||
this.successTotalNum = successTotalNum; | |||
this.failTotalNum = failTotalNum; | |||
this.waitTotalNum = waitTotalNum; | |||
this.expiredTotalNum = expiredTotalNum; | |||
this.cancelTotalNum = cancelTotalNum; | |||
} | |||
} |