update 矿机离线邮箱发送定时任务修改
This commit is contained in:
@@ -36,7 +36,7 @@
|
|||||||
wallet_outv2
|
wallet_outv2
|
||||||
<where>
|
<where>
|
||||||
<if test="startDate != null">
|
<if test="startDate != null">
|
||||||
`date` > #{startDate}
|
`date` >= #{startDate}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -77,6 +77,13 @@ public class NoticeController extends BaseController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getNoticeInfoListInCache")
|
||||||
|
@ApiOperation(value = "获取用户最新的矿机在离线警报")
|
||||||
|
@RequiresLogin
|
||||||
|
public AjaxResult getNoticeInfoListInCache(){
|
||||||
|
return noticeService.getNoticeInfoListInCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ public class NoticeMinerCoinListDto implements Serializable {
|
|||||||
/** 挖矿账户 */
|
/** 挖矿账户 */
|
||||||
private String miner;
|
private String miner;
|
||||||
|
|
||||||
|
/** 挖矿账户表主键id */
|
||||||
|
private Long maId;
|
||||||
|
|
||||||
///** 币种 */
|
///** 币种 */
|
||||||
//private String coin;
|
//private String coin;
|
||||||
|
|
||||||
|
|||||||
@@ -108,4 +108,7 @@ public interface UserAccountMapper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int deleteBatchReadOnlyPage(@Param("list")List<UserAccountDto> list);
|
int deleteBatchReadOnlyPage(@Param("list")List<UserAccountDto> list);
|
||||||
|
|
||||||
|
|
||||||
|
List<UserAccountDto> getUserMinerByUserEmail(@Param("email") String email);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description TODO
|
* @Description TODO
|
||||||
@@ -223,4 +225,7 @@ public class NoticeServiceImpl implements NoticeService {
|
|||||||
return AjaxResult.error(r.getCode(),r.getMsg());
|
return AjaxResult.error(r.getCode(),r.getMsg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,19 +78,16 @@ public class OffLineNoticeTask {
|
|||||||
Collectors.mapping(NoticeMinerCoinListDto::getEmail, Collectors.toList())
|
Collectors.mapping(NoticeMinerCoinListDto::getEmail, Collectors.toList())
|
||||||
));
|
));
|
||||||
|
|
||||||
//先获取通知列表 TODO 这里查询notice_info为空,notice_info 里面存的从哪里来? (这张表不再使用)
|
// 获取通知列表
|
||||||
//List<NoticeMinerCoinListDto> nmcList = noticeMapper.getNoticeEmailListByMinerAndCoin(list, Pools.NEXA.getCoin());
|
//List<NoticeMinerCoinListDto> nmcList = noticeMapper.getNoticeEmailListByMinerAndCoin(list, Pools.NEXA.getCoin());
|
||||||
//System.out.println("查询到离线通知列表"+nmcList);
|
//System.out.println("查询到离线通知列表"+nmcList);
|
||||||
//Map<String, List<String>> userEmails = nmcList.stream().
|
//Map<String, List<String>> userEmails = nmcList.stream().collect(Collectors.groupingBy(NoticeMinerCoinListDto::getMiner, Collectors.mapping(NoticeMinerCoinListDto::getEmail, Collectors.toList())));
|
||||||
// collect(Collectors.groupingBy(
|
|
||||||
// NoticeMinerCoinListDto::getMiner,
|
|
||||||
// Collectors.mapping(NoticeMinerCoinListDto::getEmail, Collectors.toList())
|
|
||||||
// ));
|
|
||||||
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0 TODO 这里也没看到redis里面存储的位置
|
//获取上一次离线矿机数 可能为null 要做处理 如果没有redis记录 则上次离线数设置为0 若有redis但是key没有此挖矿账户也设置上次离线数为0 TODO 这里也没看到redis里面存储的位置
|
||||||
Map<String, Long> map = redisService.getCacheMap("NEXA_USERS_OFFLINE");
|
Map<String, Long> map = redisService.getCacheMap("NEXA_USERS_OFFLINE");
|
||||||
|
|
||||||
|
|
||||||
list.stream().forEach(e -> {
|
list.forEach(e -> {
|
||||||
long lastOff = 0;
|
long lastOff = 0;
|
||||||
if(StringUtils.isNotNull(map)){
|
if(StringUtils.isNotNull(map)){
|
||||||
lastOff = map.getOrDefault(e.getUser(),0L);
|
lastOff = map.getOrDefault(e.getUser(),0L);
|
||||||
@@ -104,7 +101,9 @@ public class OffLineNoticeTask {
|
|||||||
String text = "您的"+Pools.NEXA.getCoin()+"下挖矿账户: "+e.getUser()+"\n有" +
|
String text = "您的"+Pools.NEXA.getCoin()+"下挖矿账户: "+e.getUser()+"\n有" +
|
||||||
e.getOffline() + "台矿机离线!\n"+
|
e.getOffline() + "台矿机离线!\n"+
|
||||||
"若您的矿机是因异常断开,请及时处理!";
|
"若您的矿机是因异常断开,请及时处理!";
|
||||||
emails.stream().forEach(email ->{
|
|
||||||
|
//emails为list,实际情况下,一个miner只会对应一个邮箱
|
||||||
|
emails.forEach(email ->{
|
||||||
System.out.println("用户"+e.getUser()+"矿机离线通知到"+email);
|
System.out.println("用户"+e.getUser()+"矿机离线通知到"+email);
|
||||||
EmailEntity entity = new EmailEntity();
|
EmailEntity entity = new EmailEntity();
|
||||||
entity.setSubject("[M2Pool] 矿机离线提示");
|
entity.setSubject("[M2Pool] 矿机离线提示");
|
||||||
@@ -115,6 +114,7 @@ public class OffLineNoticeTask {
|
|||||||
redisService.setCacheMapValue("NEXA_USERS_OFFLINE",e.getUser(),e.getOffline());
|
redisService.setCacheMapValue("NEXA_USERS_OFFLINE",e.getUser(),e.getOffline());
|
||||||
}else {
|
}else {
|
||||||
System.out.println("该用户未添加离线通知 :"+userEmails.toString());
|
System.out.println("该用户未添加离线通知 :"+userEmails.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
@@ -122,8 +122,11 @@ public class OffLineNoticeTask {
|
|||||||
System.out.println("挖矿账户"+e.getUser()+"本次无需通知,本次离线为"+e.getOffline()+",上次离线数"+
|
System.out.println("挖矿账户"+e.getUser()+"本次无需通知,本次离线为"+e.getOffline()+",上次离线数"+
|
||||||
map.getOrDefault(e.getUser(),0L));
|
map.getOrDefault(e.getUser(),0L));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//TODO 离线警报数据入库或者修改
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="getNoticeEmailListByMinerAndCoin" resultType="com.m2pool.pool.dto.NoticeMinerCoinListDto">
|
<select id="getNoticeEmailListByMinerAndCoin" resultType="com.m2pool.pool.dto.NoticeMinerCoinListDto">
|
||||||
select
|
select
|
||||||
n.email email,
|
n.email email,
|
||||||
|
u.id as maId,
|
||||||
u.miner_user miner
|
u.miner_user miner
|
||||||
from
|
from
|
||||||
notice_info n
|
notice_info n
|
||||||
|
|||||||
@@ -318,7 +318,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
and id = #{id}
|
and id = #{id}
|
||||||
limit 1
|
limit 1
|
||||||
</select>
|
</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>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user