|
@@ -1,5 +1,6 @@
|
|
package com.citu.module.menduner.im.service.statistics;
|
|
package com.citu.module.menduner.im.service.statistics;
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
import com.citu.framework.common.pojo.CommonResult;
|
|
import com.citu.framework.common.pojo.CommonResult;
|
|
import com.citu.module.menduner.im.controller.app.base.statistics.ImRecentConversationsStatisticsReqVo;
|
|
import com.citu.module.menduner.im.controller.app.base.statistics.ImRecentConversationsStatisticsReqVo;
|
|
import com.citu.module.menduner.im.controller.app.base.statistics.imRecentConversationsStatisticsRespVo;
|
|
import com.citu.module.menduner.im.controller.app.base.statistics.imRecentConversationsStatisticsRespVo;
|
|
@@ -8,6 +9,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+import java.time.temporal.ChronoField;
|
|
|
|
+import java.time.temporal.TemporalField;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -16,8 +20,14 @@ public class ImRecentConversationsStatisticsServiceImpl implements ImRecentConve
|
|
|
|
|
|
ImRecentConversationsStatisticsMapper mapper;
|
|
ImRecentConversationsStatisticsMapper mapper;
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
- public CommonResult imRecentConversationsStatistics(ImRecentConversationsStatisticsReqVo reqVo) {
|
|
|
|
|
|
+ public CommonResult<imRecentConversationsStatisticsRespVo> imRecentConversationsStatistics(ImRecentConversationsStatisticsReqVo reqVo) {
|
|
|
|
+ LocalDateTime[] localDateTimes = generateDateTimeRange(reqVo);
|
|
|
|
+ reqVo.setStartTime( DateUtil.date(localDateTimes[0]).getTime()/1000L);
|
|
|
|
+ reqVo.setEndTime( DateUtil.date(localDateTimes[1]).getTime()/1000L);
|
|
|
|
+
|
|
imRecentConversationsStatisticsRespVo resp =new imRecentConversationsStatisticsRespVo();
|
|
imRecentConversationsStatisticsRespVo resp =new imRecentConversationsStatisticsRespVo();
|
|
BigDecimal bigDecimal =new BigDecimal("100");
|
|
BigDecimal bigDecimal =new BigDecimal("100");
|
|
reqVo.setCommunicateType(0); // 我发起的
|
|
reqVo.setCommunicateType(0); // 我发起的
|
|
@@ -70,6 +80,37 @@ public class ImRecentConversationsStatisticsServiceImpl implements ImRecentConve
|
|
return CommonResult.success(resp);
|
|
return CommonResult.success(resp);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public LocalDateTime[] generateDateTimeRange(ImRecentConversationsStatisticsReqVo reqVO) {
|
|
|
|
+ if (ImRecentConversationsStatisticsReqVo.TYPE_CUSTOM.equals(reqVO.getType())) {
|
|
|
|
+ return reqVO.getTime();
|
|
|
|
+ }
|
|
|
|
+ LocalDateTime[] dateTimeRange = new LocalDateTime[2];
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
+ switch (reqVO.getType()) {
|
|
|
|
+ case ImRecentConversationsStatisticsReqVo.TYPE_RECENT_7_DAYS:
|
|
|
|
+ // 最新7天内
|
|
|
|
+ dateTimeRange[0] = now.minusDays(7);
|
|
|
|
+ dateTimeRange[1] = now;
|
|
|
|
+ break;
|
|
|
|
+ case ImRecentConversationsStatisticsReqVo.TYPE_LAST_MONTH:
|
|
|
|
+ // 上个月
|
|
|
|
+ dateTimeRange[0] = now.minusMonths(1).withDayOfMonth(1);
|
|
|
|
+ dateTimeRange[1] = now.withDayOfMonth(1).minusNanos(1);
|
|
|
|
+ break;
|
|
|
|
+ case ImRecentConversationsStatisticsReqVo.TYPE_LAST_QUARTER:
|
|
|
|
+ // 上季度
|
|
|
|
+ int currentMonth = now.getMonthValue();
|
|
|
|
+ // 计算上一季度的起始月份
|
|
|
|
+ int quarterStartMonth = ((currentMonth - 1) / 3) * 3 + 1;
|
|
|
|
+ int lastQuarterStartMonth = quarterStartMonth - 3;
|
|
|
|
+ dateTimeRange[0] = now.withMonth(lastQuarterStartMonth).withDayOfMonth(1);
|
|
|
|
+ dateTimeRange[1] = now.withMonth(quarterStartMonth).withDayOfMonth(1).minusNanos(1);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return dateTimeRange;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
public void setMapper(ImRecentConversationsStatisticsMapper mapper) {
|
|
public void setMapper(ImRecentConversationsStatisticsMapper mapper) {
|