V13
This commit is contained in:
@@ -1,14 +1,19 @@
|
|||||||
package com.ruoyi.test;
|
package com.ruoyi.test;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.ruoyi.cai.service.AnchorImCountDayService;
|
||||||
|
import com.ruoyi.web.controller.monitor.SysOperlogController;
|
||||||
import com.ruoyi.yunxin.client.ImUserRefClient;
|
import com.ruoyi.yunxin.client.ImUserRefClient;
|
||||||
import com.ruoyi.yunxin.req.GetUnifoReq;
|
import com.ruoyi.yunxin.req.GetUnifoReq;
|
||||||
import com.ruoyi.yunxin.resp.YxUpdateUinfoR;
|
import com.ruoyi.yunxin.resp.YxUpdateUinfoR;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@SpringBootTest // 此注解只能在 springboot 主包下使用 需包含 main 方法与 yml 配置文件
|
@SpringBootTest // 此注解只能在 springboot 主包下使用 需包含 main 方法与 yml 配置文件
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -16,6 +21,8 @@ public class OpTest {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ImUserRefClient imUserRefClient;
|
private ImUserRefClient imUserRefClient;
|
||||||
|
@Autowired
|
||||||
|
private AnchorImCountDayService anchorImCountDayService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test(){
|
public void test(){
|
||||||
@@ -25,4 +32,22 @@ public class OpTest {
|
|||||||
YxUpdateUinfoR uinfos = imUserRefClient.getUinfos(getUnifoReq);
|
YxUpdateUinfoR uinfos = imUserRefClient.getUinfos(getUnifoReq);
|
||||||
log.info(JSON.toJSONString(uinfos));
|
log.info(JSON.toJSONString(uinfos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test1(){
|
||||||
|
anchorImCountDayService.incCount(2L);
|
||||||
|
anchorImCountDayService.incCount(2L);
|
||||||
|
anchorImCountDayService.incCount(2L);
|
||||||
|
anchorImCountDayService.incCount(2L);
|
||||||
|
anchorImCountDayService.incCount(2L);
|
||||||
|
anchorImCountDayService.incCount(2L);
|
||||||
|
anchorImCountDayService.incCount(4L);
|
||||||
|
anchorImCountDayService.incCount(4L);
|
||||||
|
anchorImCountDayService.incCount(4L);
|
||||||
|
anchorImCountDayService.incCount(4L);
|
||||||
|
anchorImCountDayService.incCount(4L);
|
||||||
|
System.out.println("asd");
|
||||||
|
anchorImCountDayService.refreshCount(LocalDate.now());
|
||||||
|
anchorImCountDayService.totalUserCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ public class AnchorImCountDayServiceImpl extends ServiceImpl<AnchorImCountDayMap
|
|||||||
public void incCount(Long userId){
|
public void incCount(Long userId){
|
||||||
try {
|
try {
|
||||||
String redisKey = getRedisKey(LocalDate.now());
|
String redisKey = getRedisKey(LocalDate.now());
|
||||||
RMap<Long, Long> map = redissonClient.getMap(redisKey);
|
RMap<Long, Integer> map = redissonClient.getMap(redisKey);
|
||||||
Long newScore = map.addAndGet(userId, 1);
|
Integer newScore = map.addAndGet(userId, 1);
|
||||||
if(newScore == 1){
|
if(newScore == 1){
|
||||||
map.expire(5, TimeUnit.DAYS);
|
map.expire(5, TimeUnit.DAYS);
|
||||||
}
|
}
|
||||||
@@ -87,11 +87,11 @@ public class AnchorImCountDayServiceImpl extends ServiceImpl<AnchorImCountDayMap
|
|||||||
@Override
|
@Override
|
||||||
public void refreshCount(LocalDate localDate){
|
public void refreshCount(LocalDate localDate){
|
||||||
String redisKey = getRedisKey(localDate);
|
String redisKey = getRedisKey(localDate);
|
||||||
RMap<Long, Long> map = redissonClient.getMap(redisKey);
|
RMap<Long, Integer> map = redissonClient.getMap(redisKey);
|
||||||
Map<Long, Long> longMap = map.readAllMap();
|
Map<Long, Integer> longMap = map.readAllMap();
|
||||||
for (Map.Entry<Long, Long> entry : longMap.entrySet()) {
|
for (Map.Entry<Long, Integer> entry : longMap.entrySet()) {
|
||||||
Long userId = entry.getKey();
|
Long userId = entry.getKey();
|
||||||
Long imCount = entry.getValue();
|
Integer imCount = entry.getValue();
|
||||||
AnchorImCountDay one = this.getOne(Wrappers.lambdaQuery(AnchorImCountDay.class)
|
AnchorImCountDay one = this.getOne(Wrappers.lambdaQuery(AnchorImCountDay.class)
|
||||||
.eq(AnchorImCountDay::getCountDate, localDate)
|
.eq(AnchorImCountDay::getCountDate, localDate)
|
||||||
.eq(AnchorImCountDay::getUserId, userId));
|
.eq(AnchorImCountDay::getUserId, userId));
|
||||||
@@ -101,7 +101,8 @@ public class AnchorImCountDayServiceImpl extends ServiceImpl<AnchorImCountDayMap
|
|||||||
.set(AnchorImCountDay::getImCount, imCount));
|
.set(AnchorImCountDay::getImCount, imCount));
|
||||||
}else{
|
}else{
|
||||||
one = new AnchorImCountDay();
|
one = new AnchorImCountDay();
|
||||||
one.setImCount(imCount);
|
one.setCountDate(localDate);
|
||||||
|
one.setImCount(Long.valueOf(imCount));
|
||||||
one.setUserId(userId);
|
one.setUserId(userId);
|
||||||
one.setRefreshTime(LocalDateTime.now());
|
one.setRefreshTime(LocalDateTime.now());
|
||||||
this.save(one);
|
this.save(one);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="pageAdmin" resultType="com.ruoyi.cai.dto.admin.vo.AnchorImCountDayAdminVO">
|
<select id="pageAdmin" resultType="com.ruoyi.cai.dto.admin.vo.AnchorImCountDayAdminVO">
|
||||||
select t1.*,t2.usercode,t2.nickname,t2.mobile,t2.avatar,t2.gender,t2.is_anchor,t2.age,t2.im_speck,t2.enable_im,t2.status
|
select t1.*,t2.usercode,t2.nickname,t2.mobile,t2.avatar,t2.gender,t2.is_anchor,t2.age,t2.im_speck,t2.enable_im,t2.status
|
||||||
from cai_anchor_im_count_day t1
|
from cai_anchor_im_count_day t1
|
||||||
left join cai_user t2 on t1.user_id = t2.id
|
join cai_user t2 on t1.user_id = t2.id
|
||||||
<where>
|
<where>
|
||||||
<if test="bo.mobile != null and bo.mobile != ''">
|
<if test="bo.mobile != null and bo.mobile != ''">
|
||||||
and t2.mobile = #{bo.mobile}
|
and t2.mobile = #{bo.mobile}
|
||||||
|
|||||||
Reference in New Issue
Block a user