update 聊天模块新增异常
This commit is contained in:
parent
80b15dcf5b
commit
f8264b2df1
|
@ -15,7 +15,9 @@ public enum ExceptionEnum {
|
||||||
SET_PRINCIPAL_FAIL(1022, "websocket链接异常,用户身份设置失败"),
|
SET_PRINCIPAL_FAIL(1022, "websocket链接异常,用户身份设置失败"),
|
||||||
GET_PRINCIPAL_FAIL(1023, "websocket链接异常,用户信息邮箱获取失败"),
|
GET_PRINCIPAL_FAIL(1023, "websocket链接异常,用户信息邮箱获取失败"),
|
||||||
ACCOUNT_HAS_CONNECTED(1024, "当前登录用户在其他地方链接"),
|
ACCOUNT_HAS_CONNECTED(1024, "当前登录用户在其他地方链接"),
|
||||||
;
|
|
||||||
|
ROOM_NOT_EXIST(1025, "聊天室不存在,发送消息失败");
|
||||||
|
|
||||||
|
|
||||||
private final int code;
|
private final int code;
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.m2pool.chat.service.impl;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.m2pool.chat.config.CustomWebSocketConfig;
|
import com.m2pool.chat.config.CustomWebSocketConfig;
|
||||||
import com.m2pool.chat.constant.Destination;
|
import com.m2pool.chat.constant.Destination;
|
||||||
|
import com.m2pool.chat.constant.ExceptionEnum;
|
||||||
import com.m2pool.chat.dto.WebsocketMessageDto;
|
import com.m2pool.chat.dto.WebsocketMessageDto;
|
||||||
import com.m2pool.chat.entity.ChatMessage;
|
import com.m2pool.chat.entity.ChatMessage;
|
||||||
import com.m2pool.chat.entity.ChatRoom;
|
import com.m2pool.chat.entity.ChatRoom;
|
||||||
|
@ -13,6 +14,7 @@ import com.m2pool.chat.service.StompService;
|
||||||
import com.m2pool.chat.vo.UserMessageVo;
|
import com.m2pool.chat.vo.UserMessageVo;
|
||||||
import com.m2pool.common.core.web.Result.AjaxResult;
|
import com.m2pool.common.core.web.Result.AjaxResult;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.messaging.MessageDeliveryException;
|
||||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||||
import org.springframework.messaging.simp.user.SimpUserRegistry;
|
import org.springframework.messaging.simp.user.SimpUserRegistry;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -64,24 +66,7 @@ public class StompServiceImpl implements StompService {
|
||||||
ChatRoom chatRoom = chatRoomMapper.selectOne(new LambdaQueryWrapper<ChatRoom>()
|
ChatRoom chatRoom = chatRoomMapper.selectOne(new LambdaQueryWrapper<ChatRoom>()
|
||||||
.eq(ChatRoom::getUserOneEmail,userMessageVo.getEmail())
|
.eq(ChatRoom::getUserOneEmail,userMessageVo.getEmail())
|
||||||
.eq(ChatRoom::getUserTwoEmail,principal.getName()));
|
.eq(ChatRoom::getUserTwoEmail,principal.getName()));
|
||||||
|
build(chatRoom,userMessageVo,principal,build);
|
||||||
build.setRoomId(userMessageVo.getRoomId());
|
|
||||||
int serviceReadNum = chatRoom != null ? chatRoom.getClientReadNum() : 0;
|
|
||||||
build.setClientReadNum( serviceReadNum+ 1);
|
|
||||||
//分块传输,只有最后一个块拼接完成才能发送消息
|
|
||||||
//if (userMessageVo.getCurrentChunk() == userMessageVo.getTotalChunks()-1){
|
|
||||||
// build.setContent(handleImage(userMessageVo.getEmail()+principal.getName(),userMessageVo.getContent()));
|
|
||||||
// System.out.println("发送图片成功"+build.getContent());
|
|
||||||
// messagingTemplate.convertAndSendToUser(userMessageVo.getEmail(), Destination.QUEUE_USER + "/" + userMessageVo.getEmail(),build);
|
|
||||||
// executeTran(principal, userMessageVo, chatRoom);
|
|
||||||
// imageContent.remove(userMessageVo.getEmail()+principal.getName());
|
|
||||||
//}else{
|
|
||||||
// handleImage(userMessageVo.getEmail()+principal.getName(),userMessageVo.getContent());
|
|
||||||
//}
|
|
||||||
Long id = executeTran(principal, userMessageVo, chatRoom);
|
|
||||||
System.out.println("发送消息,聊天室id"+userMessageVo.getRoomId()+"发送者邮箱"+principal.getName()+"接受者邮箱"+userMessageVo.getEmail()+"消息id"+id);
|
|
||||||
//多端情况下,需要把消息发送给自己
|
|
||||||
build.setId(id);
|
|
||||||
messagingTemplate.convertAndSendToUser(principal.getName(), Destination.QUEUE_CUSTOMER + "/" + principal.getName(),build);
|
messagingTemplate.convertAndSendToUser(principal.getName(), Destination.QUEUE_CUSTOMER + "/" + principal.getName(),build);
|
||||||
messagingTemplate.convertAndSendToUser(userMessageVo.getEmail(), Destination.QUEUE_USER + "/" + userMessageVo.getEmail(),build);
|
messagingTemplate.convertAndSendToUser(userMessageVo.getEmail(), Destination.QUEUE_USER + "/" + userMessageVo.getEmail(),build);
|
||||||
return AjaxResult.success("成功");
|
return AjaxResult.success("成功");
|
||||||
|
@ -93,35 +78,28 @@ public class StompServiceImpl implements StompService {
|
||||||
ChatRoom chatRoom = chatRoomMapper.selectOne(new LambdaQueryWrapper<ChatRoom>()
|
ChatRoom chatRoom = chatRoomMapper.selectOne(new LambdaQueryWrapper<ChatRoom>()
|
||||||
.eq(ChatRoom::getUserOneEmail, principal.getName())
|
.eq(ChatRoom::getUserOneEmail, principal.getName())
|
||||||
.eq(ChatRoom::getUserTwoEmail, userMessageVo.getEmail()));
|
.eq(ChatRoom::getUserTwoEmail, userMessageVo.getEmail()));
|
||||||
build.setRoomId(userMessageVo.getRoomId());
|
build(chatRoom,userMessageVo,principal,build);
|
||||||
int serviceReadNum = chatRoom != null ? chatRoom.getServiceReadNum() : 0;
|
|
||||||
build.setClientReadNum(serviceReadNum + 1);
|
|
||||||
|
|
||||||
//分块传输,只有最后一个块拼接完成才能发送消息
|
|
||||||
//if (userMessageVo.getCurrentChunk() == userMessageVo.getTotalChunks()-1){
|
|
||||||
// build.setContent(handleImage(userMessageVo.getEmail()+principal.getName(),userMessageVo.getContent()));
|
|
||||||
// messagingTemplate.convertAndSendToUser(userMessageVo.getEmail(), Destination.QUEUE_CUSTOMER + "/" + userMessageVo.getEmail(),build);
|
|
||||||
// executeTran(principal, userMessageVo, chatRoom);
|
|
||||||
// imageContent.remove(userMessageVo.getEmail()+principal.getName());
|
|
||||||
//}else{
|
|
||||||
// handleImage(userMessageVo.getEmail()+principal.getName(),userMessageVo.getContent());
|
|
||||||
//}
|
|
||||||
Long id = executeTran(principal, userMessageVo, chatRoom);
|
|
||||||
System.out.println("发送消息,聊天室id"+userMessageVo.getRoomId()+"发送者邮箱"+principal.getName()+"接受者邮箱"+userMessageVo.getEmail()+"消息id"+id);
|
|
||||||
// 多端情况下,需要把消息发送给
|
|
||||||
build.setId(id);
|
|
||||||
messagingTemplate.convertAndSendToUser(principal.getName(), Destination.QUEUE_USER + "/" + principal.getName(),build);
|
messagingTemplate.convertAndSendToUser(principal.getName(), Destination.QUEUE_USER + "/" + principal.getName(),build);
|
||||||
messagingTemplate.convertAndSendToUser(userMessageVo.getEmail(), Destination.QUEUE_CUSTOMER + "/" + userMessageVo.getEmail(),build);
|
messagingTemplate.convertAndSendToUser(userMessageVo.getEmail(), Destination.QUEUE_CUSTOMER + "/" + userMessageVo.getEmail(),build);
|
||||||
|
|
||||||
return AjaxResult.success("成功");
|
return AjaxResult.success("成功");
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 分片图片处理
|
public void build(ChatRoom chatRoom,UserMessageVo userMessageVo,StompPrincipal principal,WebsocketMessageDto build){
|
||||||
* @return
|
if (chatRoom == null && userMessageVo.getRoomId() == null){
|
||||||
*/
|
throw new MessageDeliveryException(ExceptionEnum.fromCode(ExceptionEnum.ROOM_NOT_EXIST));
|
||||||
//private String handleImage(String key,String value){
|
}
|
||||||
// return imageContent.compute(key, (k, s) -> s + value);
|
if(chatRoom != null && userMessageVo.getRoomId() == null){
|
||||||
//}
|
userMessageVo.setRoomId(chatRoom.getId());
|
||||||
|
}
|
||||||
|
build.setRoomId(userMessageVo.getRoomId());
|
||||||
|
int serviceReadNum = chatRoom != null ? chatRoom.getServiceReadNum() : 0;
|
||||||
|
build.setClientReadNum(serviceReadNum + 1);
|
||||||
|
Long id = executeTran(principal, userMessageVo, chatRoom);
|
||||||
|
System.out.println("发送消息,聊天室id"+userMessageVo.getRoomId()+"发送者邮箱"+principal.getName()+"接受者邮箱"+userMessageVo.getEmail()+"消息id"+id);
|
||||||
|
// 多端情况下,需要把消息发送给
|
||||||
|
build.setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建聊天实时返回信息
|
* 构建聊天实时返回信息
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -78,7 +79,6 @@ public interface ManageBroadcastMapper extends BaseMapper<ManageBroadcast> {
|
||||||
* @param endDate
|
* @param endDate
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@HashRateDB
|
|
||||||
List<ManageMiningUserOnlineDto> getMinerUserOnlineStatus(@Param("minerUser") String minerUser, @Param("coin") String coin, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
|
List<ManageMiningUserOnlineDto> getMinerUserOnlineStatus(@Param("minerUser") String minerUser, @Param("coin") String coin, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,4 +95,18 @@ public interface ManageBroadcastMapper extends BaseMapper<ManageBroadcast> {
|
||||||
|
|
||||||
@DistributionDB
|
@DistributionDB
|
||||||
BigDecimal getAccountExpend(@Param("user") String user, @Param("coin") String coin);
|
BigDecimal getAccountExpend(@Param("user") String user, @Param("coin") String coin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除1个月前所有在线离线数据
|
||||||
|
* @param coin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int deleteOnlineAndOfflineData(@Param("coin") String coin, @Param("date") LocalDateTime date);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询需要删除的行数
|
||||||
|
* @param coin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int selectNeedDeleteNumbers(@Param("coin") String coin, @Param("date") LocalDateTime date);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.m2pool.manage.task;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.m2pool.manage.entity.ManageWalletOutIn;
|
import com.m2pool.manage.entity.ManageWalletOutIn;
|
||||||
|
import com.m2pool.manage.mapper.ManageBroadcastMapper;
|
||||||
import com.m2pool.manage.mapper.ManageWalletOutInMapper;
|
import com.m2pool.manage.mapper.ManageWalletOutInMapper;
|
||||||
import com.m2pool.manage.service.ManageWalletOutInService;
|
import com.m2pool.manage.service.ManageWalletOutInService;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
@ -30,6 +31,11 @@ public class ManageTask {
|
||||||
@Resource
|
@Resource
|
||||||
private ManageWalletOutInMapper manageWalletOutInMapper;
|
private ManageWalletOutInMapper manageWalletOutInMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ManageBroadcastMapper manageBroadcastMapper;
|
||||||
|
/**
|
||||||
|
* 存储交易记录定时任务
|
||||||
|
*/
|
||||||
@Scheduled(cron = "22 21 0/1 * * ?")
|
@Scheduled(cron = "22 21 0/1 * * ?")
|
||||||
public void insertDataToWalletOutInDb(){
|
public void insertDataToWalletOutInDb(){
|
||||||
ManageWalletOutIn manageWalletOutIn = manageWalletOutInMapper.selectOne(new LambdaQueryWrapper<ManageWalletOutIn>().orderByDesc(
|
ManageWalletOutIn manageWalletOutIn = manageWalletOutInMapper.selectOne(new LambdaQueryWrapper<ManageWalletOutIn>().orderByDesc(
|
||||||
|
@ -43,4 +49,156 @@ public class ManageTask {
|
||||||
boolean b = manageWalletOutInService.saveBatch(walletInfo);
|
boolean b = manageWalletOutInService.saveBatch(walletInfo);
|
||||||
System.out.println("walletOutIn 插入结果"+b);
|
System.out.println("walletOutIn 插入结果"+b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除再离线数据
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "5 5 1 * * ?")
|
||||||
|
public void deleteOnlineAndOfflineDataForNexa(){
|
||||||
|
// 记录开始时间(纳秒)
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
LocalDateTime oneMonthAgo = now.minusMonths(1);
|
||||||
|
int count = manageBroadcastMapper.selectNeedDeleteNumbers("nexa", oneMonthAgo);
|
||||||
|
while (count > 0) {
|
||||||
|
int deletedCount = manageBroadcastMapper.deleteOnlineAndOfflineData("nexa", oneMonthAgo);
|
||||||
|
count -= deletedCount;
|
||||||
|
}
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
long duration = (endTime - startTime) / 1_000_000;
|
||||||
|
System.out.println("删除nexa在离线时间: " + duration + " 毫秒");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "10 5 2 * * ?")
|
||||||
|
public void deleteOnlineAndOfflineDataForMona(){
|
||||||
|
// 记录开始时间(纳秒)
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
LocalDateTime oneMonthAgo = now.minusMonths(1);
|
||||||
|
int count = manageBroadcastMapper.selectNeedDeleteNumbers("mona", oneMonthAgo);
|
||||||
|
while (count > 0) {
|
||||||
|
int deletedCount = manageBroadcastMapper.deleteOnlineAndOfflineData("mona", oneMonthAgo);
|
||||||
|
count -= deletedCount;
|
||||||
|
}
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
long duration = (endTime - startTime) / 1_000_000;
|
||||||
|
System.out.println("删除mona在离线时间: " + duration + " 毫秒");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "10 5 3 * * ?")
|
||||||
|
public void deleteOnlineAndOfflineDataForRxd(){
|
||||||
|
// 记录开始时间(纳秒)
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
LocalDateTime oneMonthAgo = now.minusMonths(1);
|
||||||
|
int count = manageBroadcastMapper.selectNeedDeleteNumbers("rxd", oneMonthAgo);
|
||||||
|
while (count > 0) {
|
||||||
|
int deletedCount = manageBroadcastMapper.deleteOnlineAndOfflineData("rxd", oneMonthAgo);
|
||||||
|
count -= deletedCount;
|
||||||
|
}
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
long duration = (endTime - startTime) / 1_000_000;
|
||||||
|
System.out.println("删除rxd在离线时间: " + duration + " 毫秒");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "10 5 4 * * ?")
|
||||||
|
public void deleteOnlineAndOfflineDataForGrs(){
|
||||||
|
// 记录开始时间(纳秒)
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
LocalDateTime oneMonthAgo = now.minusMonths(1);
|
||||||
|
int count = manageBroadcastMapper.selectNeedDeleteNumbers("grs", oneMonthAgo);
|
||||||
|
while (count > 0) {
|
||||||
|
int deletedCount = manageBroadcastMapper.deleteOnlineAndOfflineData("grs", oneMonthAgo);
|
||||||
|
count -= deletedCount;
|
||||||
|
}
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
long duration = (endTime - startTime) / 1_000_000;
|
||||||
|
System.out.println("删除Grs在离线时间: " + duration + " 毫秒");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "10 5 5 * * ?")
|
||||||
|
public void deleteOnlineAndOfflineDataForEnx(){
|
||||||
|
// 记录开始时间(纳秒)
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
LocalDateTime oneMonthAgo = now.minusMonths(1);
|
||||||
|
int count = manageBroadcastMapper.selectNeedDeleteNumbers("enx", oneMonthAgo);
|
||||||
|
while (count > 0) {
|
||||||
|
int deletedCount = manageBroadcastMapper.deleteOnlineAndOfflineData("enx", oneMonthAgo);
|
||||||
|
count -= deletedCount;
|
||||||
|
}
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
long duration = (endTime - startTime) / 1_000_000;
|
||||||
|
System.out.println("删除enx在离线时间: " + duration + " 毫秒");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "10 5 6 * * ?")
|
||||||
|
public void deleteOnlineAndOfflineDataForAlph(){
|
||||||
|
// 记录开始时间(纳秒)
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
LocalDateTime oneMonthAgo = now.minusMonths(1);
|
||||||
|
int count = manageBroadcastMapper.selectNeedDeleteNumbers("alph", oneMonthAgo);
|
||||||
|
while (count > 0) {
|
||||||
|
int deletedCount = manageBroadcastMapper.deleteOnlineAndOfflineData("alph", oneMonthAgo);
|
||||||
|
count -= deletedCount;
|
||||||
|
}
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
long duration = (endTime - startTime) / 1_000_000;
|
||||||
|
System.out.println("删除alph在离线时间: " + duration + " 毫秒");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "10 5 7 * * ?")
|
||||||
|
public void deleteOnlineAndOfflineDataForDgbo(){
|
||||||
|
// 记录开始时间(纳秒)
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
LocalDateTime oneMonthAgo = now.minusMonths(1);
|
||||||
|
int count = manageBroadcastMapper.selectNeedDeleteNumbers("dgbo", oneMonthAgo);
|
||||||
|
while (count > 0) {
|
||||||
|
int deletedCount = manageBroadcastMapper.deleteOnlineAndOfflineData("dgbo", oneMonthAgo);
|
||||||
|
count -= deletedCount;
|
||||||
|
}
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
long duration = (endTime - startTime) / 1_000_000;
|
||||||
|
System.out.println("删除dgbo在离线时间: " + duration + " 毫秒");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "10 5 8 * * ?")
|
||||||
|
public void deleteOnlineAndOfflineDataForDgbq(){
|
||||||
|
// 记录开始时间(纳秒)
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
LocalDateTime oneMonthAgo = now.minusMonths(1);
|
||||||
|
int count = manageBroadcastMapper.selectNeedDeleteNumbers("dgbq", oneMonthAgo);
|
||||||
|
while (count > 0) {
|
||||||
|
int deletedCount = manageBroadcastMapper.deleteOnlineAndOfflineData("dgbq", oneMonthAgo);
|
||||||
|
count -= deletedCount;
|
||||||
|
}
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
long duration = (endTime - startTime) / 1_000_000;
|
||||||
|
System.out.println("删除dgbq在离线时间: " + duration + " 毫秒");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "10 5 9 * * ?")
|
||||||
|
public void deleteOnlineAndOfflineDataForDgbs(){
|
||||||
|
// 记录开始时间(纳秒)
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
LocalDateTime oneMonthAgo = now.minusMonths(1);
|
||||||
|
int count = manageBroadcastMapper.selectNeedDeleteNumbers("dgbs", oneMonthAgo);
|
||||||
|
while (count > 0) {
|
||||||
|
int deletedCount = manageBroadcastMapper.deleteOnlineAndOfflineData("dgbs", oneMonthAgo);
|
||||||
|
count -= deletedCount;
|
||||||
|
}
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
long duration = (endTime - startTime) / 1_000_000;
|
||||||
|
System.out.println("删除dgbs在离线时间: " + duration + " 毫秒");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
<mapper namespace="com.m2pool.manage.mapper.ManageBroadcastMapper">
|
<mapper namespace="com.m2pool.manage.mapper.ManageBroadcastMapper">
|
||||||
|
|
||||||
|
|
||||||
<select id="selectUserListByPage" resultType="com.m2pool.manage.dto.ManageUserDto">
|
<select id="selectUserListByPage" resultType="com.m2pool.manage.dto.ManageUserDto">
|
||||||
SELECT
|
SELECT
|
||||||
uma.id,
|
uma.id,
|
||||||
|
@ -101,7 +102,7 @@
|
||||||
sum(case when `state` = "online" then 1 else 0 end) as onlineNum,
|
sum(case when `state` = "online" then 1 else 0 end) as onlineNum,
|
||||||
sum(case when `state` = "offline" then 1 else 0 end) as offlineNum
|
sum(case when `state` = "offline" then 1 else 0 end) as offlineNum
|
||||||
from
|
from
|
||||||
${coin}_mhsv2
|
${coin}_mhs30m
|
||||||
<where>
|
<where>
|
||||||
`user` = #{minerUser}
|
`user` = #{minerUser}
|
||||||
<choose>
|
<choose>
|
||||||
|
@ -148,5 +149,12 @@
|
||||||
where
|
where
|
||||||
coin = #{coin} AND `user` = #{user}
|
coin = #{coin} AND `user` = #{user}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectNeedDeleteNumbers" resultType="java.lang.Integer">
|
||||||
|
select count(*) from ${coin}_mhs30m where `date` <![CDATA[ <= ]]> #{date}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteOnlineAndOfflineData">
|
||||||
|
delete from ${coin}_mhs30m where `date` <![CDATA[ <= ]]> #{date} LIMIT 5000
|
||||||
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class OffLineNoticeTask {
|
||||||
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.NEXA.getMhs() + "30m", nowStr);
|
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.NEXA.getMhs() + "30m", nowStr);
|
||||||
|
|
||||||
System.out.println("查询到离线矿机结果 "+list.size()+"条");
|
System.out.println("查询到离线矿机结果 "+list.size()+"条");
|
||||||
if(StringUtils.isNotNull(list)){
|
if(StringUtils.isNotEmpty(list)){
|
||||||
//list不为空才处理
|
//list不为空才处理
|
||||||
|
|
||||||
//先获取通知列表
|
//先获取通知列表
|
||||||
|
@ -82,7 +82,7 @@ public class OffLineNoticeTask {
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
if(StringUtils.isNotNull(userEmails)){
|
if(StringUtils.isNotEmpty(userEmails)){
|
||||||
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
||||||
Map<String, Long> map = redisService.getCacheMap("NEXA_USERS_OFFLINE");
|
Map<String, Long> map = redisService.getCacheMap("NEXA_USERS_OFFLINE");
|
||||||
list.stream().forEach(e -> {
|
list.stream().forEach(e -> {
|
||||||
|
@ -153,7 +153,7 @@ public class OffLineNoticeTask {
|
||||||
//查询离线矿机数和离线矿机 按挖矿账户分
|
//查询离线矿机数和离线矿机 按挖矿账户分
|
||||||
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.GRS.getMhs() + "30m", nowStr);
|
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.GRS.getMhs() + "30m", nowStr);
|
||||||
|
|
||||||
if(StringUtils.isNotNull(list)){
|
if(StringUtils.isNotEmpty(list)){
|
||||||
//list不为空才处理
|
//list不为空才处理
|
||||||
|
|
||||||
//先获取通知列表
|
//先获取通知列表
|
||||||
|
@ -166,7 +166,7 @@ public class OffLineNoticeTask {
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
if(StringUtils.isNotNull(userEmails)){
|
if(StringUtils.isNotEmpty(userEmails)){
|
||||||
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
||||||
Map<String, Long> map = redisService.getCacheMap("NEXA_USERS_OFFLINE");
|
Map<String, Long> map = redisService.getCacheMap("NEXA_USERS_OFFLINE");
|
||||||
list.stream().forEach(e -> {
|
list.stream().forEach(e -> {
|
||||||
|
@ -232,7 +232,7 @@ public class OffLineNoticeTask {
|
||||||
//查询离线矿机数和离线矿机 按挖矿账户分
|
//查询离线矿机数和离线矿机 按挖矿账户分
|
||||||
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.MONA.getMhs() + "30m", nowStr);
|
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.MONA.getMhs() + "30m", nowStr);
|
||||||
|
|
||||||
if(StringUtils.isNotNull(list)){
|
if(StringUtils.isNotEmpty(list)){
|
||||||
//list不为空才处理
|
//list不为空才处理
|
||||||
|
|
||||||
//先获取通知列表
|
//先获取通知列表
|
||||||
|
@ -245,7 +245,7 @@ public class OffLineNoticeTask {
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
if(StringUtils.isNotNull(userEmails)){
|
if(StringUtils.isNotEmpty(userEmails)){
|
||||||
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
||||||
Map<String, Long> map = redisService.getCacheMap("MONA_USERS_OFFLINE");
|
Map<String, Long> map = redisService.getCacheMap("MONA_USERS_OFFLINE");
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ public class OffLineNoticeTask {
|
||||||
//查询离线矿机数和离线矿机 按挖矿账户分
|
//查询离线矿机数和离线矿机 按挖矿账户分
|
||||||
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.DGBO.getMhs() + "30m", nowStr);
|
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.DGBO.getMhs() + "30m", nowStr);
|
||||||
|
|
||||||
if(StringUtils.isNotNull(list)){
|
if(StringUtils.isNotEmpty(list)){
|
||||||
//list不为空才处理
|
//list不为空才处理
|
||||||
|
|
||||||
//先获取通知列表
|
//先获取通知列表
|
||||||
|
@ -325,7 +325,7 @@ public class OffLineNoticeTask {
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
if(StringUtils.isNotNull(userEmails)){
|
if(StringUtils.isNotEmpty(userEmails)){
|
||||||
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
||||||
Map<String, Long> map = redisService.getCacheMap("DGBO_USERS_OFFLINE");
|
Map<String, Long> map = redisService.getCacheMap("DGBO_USERS_OFFLINE");
|
||||||
list.stream().forEach(e -> {
|
list.stream().forEach(e -> {
|
||||||
|
@ -391,7 +391,7 @@ public class OffLineNoticeTask {
|
||||||
//查询离线矿机数和离线矿机 按挖矿账户分
|
//查询离线矿机数和离线矿机 按挖矿账户分
|
||||||
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.DGBQ.getMhs() + "30m", nowStr);
|
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.DGBQ.getMhs() + "30m", nowStr);
|
||||||
|
|
||||||
if(StringUtils.isNotNull(list)){
|
if(StringUtils.isNotEmpty(list)){
|
||||||
//list不为空才处理
|
//list不为空才处理
|
||||||
|
|
||||||
//先获取通知列表
|
//先获取通知列表
|
||||||
|
@ -404,7 +404,7 @@ public class OffLineNoticeTask {
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
if(StringUtils.isNotNull(userEmails)){
|
if(StringUtils.isNotEmpty(userEmails)){
|
||||||
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
||||||
Map<String, Long> map = redisService.getCacheMap("DGBQ_USERS_OFFLINE");
|
Map<String, Long> map = redisService.getCacheMap("DGBQ_USERS_OFFLINE");
|
||||||
list.stream().forEach(e -> {
|
list.stream().forEach(e -> {
|
||||||
|
@ -470,7 +470,7 @@ public class OffLineNoticeTask {
|
||||||
//查询离线矿机数和离线矿机 按挖矿账户分
|
//查询离线矿机数和离线矿机 按挖矿账户分
|
||||||
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.DGBS.getMhs() + "30m", nowStr);
|
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.DGBS.getMhs() + "30m", nowStr);
|
||||||
|
|
||||||
if(StringUtils.isNotNull(list)){
|
if(StringUtils.isNotEmpty(list)){
|
||||||
//list不为空才处理
|
//list不为空才处理
|
||||||
|
|
||||||
//先获取通知列表
|
//先获取通知列表
|
||||||
|
@ -483,7 +483,7 @@ public class OffLineNoticeTask {
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
if(StringUtils.isNotNull(userEmails)){
|
if(StringUtils.isNotEmpty(userEmails)){
|
||||||
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
||||||
Map<String, Long> map = redisService.getCacheMap("DGBS_USERS_OFFLINE");
|
Map<String, Long> map = redisService.getCacheMap("DGBS_USERS_OFFLINE");
|
||||||
list.stream().forEach(e -> {
|
list.stream().forEach(e -> {
|
||||||
|
@ -549,7 +549,7 @@ public class OffLineNoticeTask {
|
||||||
//查询离线矿机数和离线矿机 按挖矿账户分
|
//查询离线矿机数和离线矿机 按挖矿账户分
|
||||||
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.RXD.getMhs() + "30m", nowStr);
|
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.RXD.getMhs() + "30m", nowStr);
|
||||||
|
|
||||||
if(StringUtils.isNotNull(list)){
|
if(StringUtils.isNotEmpty(list)){
|
||||||
//list不为空才处理
|
//list不为空才处理
|
||||||
|
|
||||||
//先获取通知列表
|
//先获取通知列表
|
||||||
|
@ -562,7 +562,7 @@ public class OffLineNoticeTask {
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
if(StringUtils.isNotNull(userEmails)){
|
if(StringUtils.isNotEmpty(userEmails)){
|
||||||
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
||||||
Map<String, Long> map = redisService.getCacheMap("RXD_USERS_OFFLINE");
|
Map<String, Long> map = redisService.getCacheMap("RXD_USERS_OFFLINE");
|
||||||
list.stream().forEach(e -> {
|
list.stream().forEach(e -> {
|
||||||
|
@ -628,7 +628,7 @@ public class OffLineNoticeTask {
|
||||||
//查询离线矿机数和离线矿机 按挖矿账户分
|
//查询离线矿机数和离线矿机 按挖矿账户分
|
||||||
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.ALPH.getMhs() + "30m", nowStr);
|
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.ALPH.getMhs() + "30m", nowStr);
|
||||||
|
|
||||||
if(StringUtils.isNotNull(list)){
|
if(StringUtils.isNotEmpty(list)){
|
||||||
//list不为空才处理
|
//list不为空才处理
|
||||||
|
|
||||||
//先获取通知列表
|
//先获取通知列表
|
||||||
|
@ -641,7 +641,7 @@ public class OffLineNoticeTask {
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
if(StringUtils.isNotNull(userEmails)){
|
if(StringUtils.isNotEmpty(userEmails)){
|
||||||
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
||||||
Map<String, Long> map = redisService.getCacheMap("ALPH_USERS_OFFLINE");
|
Map<String, Long> map = redisService.getCacheMap("ALPH_USERS_OFFLINE");
|
||||||
list.stream().forEach(e -> {
|
list.stream().forEach(e -> {
|
||||||
|
@ -707,7 +707,7 @@ public class OffLineNoticeTask {
|
||||||
//查询离线矿机数和离线矿机 按挖矿账户分
|
//查询离线矿机数和离线矿机 按挖矿账户分
|
||||||
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.ENX.getMhs() + "30m", nowStr);
|
List<OfflineUserMinerDto> list = poolMapper.getOfflineList(Pools.ENX.getMhs() + "30m", nowStr);
|
||||||
|
|
||||||
if(StringUtils.isNotNull(list)){
|
if(StringUtils.isNotEmpty(list)){
|
||||||
//list不为空才处理
|
//list不为空才处理
|
||||||
|
|
||||||
//先获取通知列表
|
//先获取通知列表
|
||||||
|
@ -720,7 +720,7 @@ public class OffLineNoticeTask {
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
if(StringUtils.isNotNull(userEmails)){
|
if(StringUtils.isNotEmpty(userEmails)){
|
||||||
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0
|
||||||
Map<String, Long> map = redisService.getCacheMap("ENX_USERS_OFFLINE");
|
Map<String, Long> map = redisService.getCacheMap("ENX_USERS_OFFLINE");
|
||||||
list.stream().forEach(e -> {
|
list.stream().forEach(e -> {
|
||||||
|
|
Loading…
Reference in New Issue