update 矿机离线邮箱发送定时任务修改

This commit is contained in:
yyb
2025-10-14 15:49:23 +08:00
parent 4929188dd7
commit da64a7a517
8 changed files with 43 additions and 10 deletions

View File

@@ -36,7 +36,7 @@
wallet_outv2
<where>
<if test="startDate != null">
`date` > #{startDate}
`date` >= #{startDate}
</if>
</where>
</select>

View File

@@ -77,6 +77,13 @@ public class NoticeController extends BaseController {
}
@PostMapping("/getNoticeInfoListInCache")
@ApiOperation(value = "获取用户最新的矿机在离线警报")
@RequiresLogin
public AjaxResult getNoticeInfoListInCache(){
return noticeService.getNoticeInfoListInCache();
}
}

View File

@@ -21,6 +21,9 @@ public class NoticeMinerCoinListDto implements Serializable {
/** 挖矿账户 */
private String miner;
/** 挖矿账户表主键id */
private Long maId;
///** 币种 */
//private String coin;

View File

@@ -108,4 +108,7 @@ public interface UserAccountMapper {
* @return
*/
int deleteBatchReadOnlyPage(@Param("list")List<UserAccountDto> list);
List<UserAccountDto> getUserMinerByUserEmail(@Param("email") String email);
}

View File

@@ -21,7 +21,9 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* @Description TODO
@@ -223,4 +225,7 @@ public class NoticeServiceImpl implements NoticeService {
return AjaxResult.error(r.getCode(),r.getMsg());
}
}
}

View File

@@ -78,19 +78,16 @@ public class OffLineNoticeTask {
Collectors.mapping(NoticeMinerCoinListDto::getEmail, Collectors.toList())
));
//获取通知列表 TODO 这里查询notice_info为空,notice_info 里面存的从哪里来? (这张表不再使用)
// 获取通知列表
//List<NoticeMinerCoinListDto> nmcList = noticeMapper.getNoticeEmailListByMinerAndCoin(list, Pools.NEXA.getCoin());
//System.out.println("查询到离线通知列表"+nmcList);
//Map<String, List<String>> userEmails = nmcList.stream().
// collect(Collectors.groupingBy(
// NoticeMinerCoinListDto::getMiner,
// Collectors.mapping(NoticeMinerCoinListDto::getEmail, Collectors.toList())
// ));
//Map<String, List<String>> userEmails = nmcList.stream().collect(Collectors.groupingBy(NoticeMinerCoinListDto::getMiner, Collectors.mapping(NoticeMinerCoinListDto::getEmail, Collectors.toList())));
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0 TODO 这里也没看到redis里面存储的位置
Map<String, Long> map = redisService.getCacheMap("NEXA_USERS_OFFLINE");
list.stream().forEach(e -> {
list.forEach(e -> {
long lastOff = 0;
if(StringUtils.isNotNull(map)){
lastOff = map.getOrDefault(e.getUser(),0L);
@@ -104,7 +101,9 @@ public class OffLineNoticeTask {
String text = "您的"+Pools.NEXA.getCoin()+"下挖矿账户: "+e.getUser()+"\n有" +
e.getOffline() + "台矿机离线!\n"+
"若您的矿机是因异常断开,请及时处理!";
emails.stream().forEach(email ->{
//emails为list实际情况下一个miner只会对应一个邮箱
emails.forEach(email ->{
System.out.println("用户"+e.getUser()+"矿机离线通知到"+email);
EmailEntity entity = new EmailEntity();
entity.setSubject("[M2Pool] 矿机离线提示");
@@ -115,6 +114,7 @@ public class OffLineNoticeTask {
redisService.setCacheMapValue("NEXA_USERS_OFFLINE",e.getUser(),e.getOffline());
}else {
System.out.println("该用户未添加离线通知 :"+userEmails.toString());
}
}else {
@@ -122,8 +122,11 @@ public class OffLineNoticeTask {
System.out.println("挖矿账户"+e.getUser()+"本次无需通知,本次离线为"+e.getOffline()+",上次离线数"+
map.getOrDefault(e.getUser(),0L));
}
});
//TODO 离线警报数据入库或者修改
}

View File

@@ -80,6 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getNoticeEmailListByMinerAndCoin" resultType="com.m2pool.pool.dto.NoticeMinerCoinListDto">
select
n.email email,
u.id as maId,
u.miner_user miner
from
notice_info n

View File

@@ -318,7 +318,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and id = #{id}
limit 1
</select>
<select id="getUserMinerByUserEmail" resultType="com.m2pool.pool.dto.UserAccountDto">
select
id,
`user`,
miner_user account,
coin
from
user_miner_account
where
`user` = #{user}
and status = 0
</select>
</mapper>