update 广播模块,新增广播按钮和跳转路径。定时任务新增开关功能

This commit is contained in:
yyb 2025-07-08 14:22:25 +08:00
parent c698a8244c
commit a51771db2e
21 changed files with 493 additions and 95 deletions

View File

@ -320,4 +320,46 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
return DateUtils.parseDate(format);
}
/**
* 获取当前时间前一个包含 30 分或整点的 30 分钟时间段起始时间
* @param date 输入的日期
* @return 前一个 30 分或整点时间段起始的日期
*/
public static Date getPreviousHalfHourOrFullHour(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int minute = calendar.get(Calendar.MINUTE);
// 如果当前分钟数小于 30前一个时间段起始是上一个整点
if (minute < 30) {
calendar.set(Calendar.MINUTE, 0);
} else {
// 如果当前分钟数大于等于 30前一个时间段起始是 30
calendar.set(Calendar.MINUTE, 30);
}
// 将秒和毫秒置为 0
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
// 如果当前分钟已经是 0 分或者 30 需要再往前推 30 分钟
if (minute == 0 || minute == 30) {
calendar.add(Calendar.MINUTE, -30);
}
return calendar.getTime();
}
/**
* 获取指定日期一个月前的时间
* @param date 输入的日期
* @return 一个月前的日期
*/
public static Date getOneMonthAgo(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, -1);
return calendar.getTime();
}
}

View File

@ -20,6 +20,7 @@ import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.messaging.support.ChannelInterceptor;
import org.springframework.messaging.support.MessageHeaderAccessor;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@ -77,6 +78,7 @@ public class WebsocketChannelInterceptor implements ChannelInterceptor {
//获取链接建立时的请求头信息
StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message);
if (accessor.getCommand() == StompCommand.CONNECT ) {
System.out.println("yyb-开始链接"+new Date());
StompHeaderAccessor mha = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
if(mha == null){
throw new MessageDeliveryException(ExceptionEnum.fromCode(ExceptionEnum.SET_PRINCIPAL_FAIL));
@ -90,6 +92,7 @@ public class WebsocketChannelInterceptor implements ChannelInterceptor {
ipLimit(accessor,type,email);
//链接请求头中用户信息存入stomp中
mha.setUser(new StompPrincipal(email,type,true));
System.out.println("yyb-链接成功"+new Date());
}
if (accessor.getCommand() == StompCommand.SUBSCRIBE) {
LOGGER.info("------------websocket subscribe message");

View File

@ -9,7 +9,11 @@ import com.m2pool.chat.entity.ChatRoom;
import com.m2pool.chat.mapper.ChatMessageMapper;
import com.m2pool.chat.mapper.ChatRoomMapper;
import com.m2pool.chat.service.ChatMessageHistoryService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
@ -25,7 +29,9 @@ import java.util.stream.Collectors;
* @Author yyb
* @Date 2025/4/15 11:51
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "task")
@EnableScheduling
public class ChatTask {
@ -37,9 +43,15 @@ public class ChatTask {
@Autowired
private ChatRoomMapper chatRoomMapper;
private boolean enable;
// @Scheduled(cron = "0 0/1 * * * ?")
@Scheduled(cron = "0 15 1 * * ?")
public void chatMessageDataSeparatedForHotAndCold(){
if(!enable){
System.out.println("ChatTask 定时任务已关闭请在nacos修改配置");
return;
}
int pageNum = 1;
int pageSize = 1000; // 每批处理数量
List<ChatMessage> chatMessages;
@ -82,8 +94,12 @@ public class ChatTask {
@Scheduled(cron = "0 16 1 * * ?")
//@Scheduled(cron = "0 0/1 * * * ?")
public void clearTouristDatas(){
if(!enable){
return;
}
chatMessageMapper.delete(new LambdaUpdateWrapper<ChatMessage>()
.like(ChatMessage::getSendEmail, "guest_"));
chatRoomMapper.delete(new LambdaUpdateWrapper<ChatRoom>().like(ChatRoom::getUserOneEmail, "guest_"));
}
}

View File

@ -44,7 +44,6 @@ public class ManageBroadcastController {
@PostMapping("/find/data/by/id")
@ApiOperation(value = "业务系统:用于获取m2pool广播数据")
public R<List<ManageBroadcastDto>> findDataById(@RequestBody(required = false) ManageBaseVo manageBaseVo){
return manageBroadcastService.findDataById(manageBaseVo);
}

View File

@ -33,4 +33,10 @@ public class ManageBroadcastDto {
@ApiModelProperty(value = "创建时间",example = "2025-05-22 14:22:13")
private LocalDateTime createTime;
@ApiModelProperty(value = "按钮内容",example = "按钮内容")
private String buttonContent;
@ApiModelProperty(value = "按钮跳转路径",example = "按钮跳转路径")
private String buttonPath;
}

View File

@ -26,7 +26,7 @@ public class ManageMiningUserOnlineDto {
//private String minerUser;
@ApiModelProperty(value = "时间",example = "2025-06-27 16:30:00",required = true)
private LocalDateTime date;
private Date date;
@ApiModelProperty(value = "在线数量",example = "15")
private Integer onlineNum;

View File

@ -7,6 +7,7 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
/**
@ -21,6 +22,9 @@ import java.util.List;
@ApiModel(value = "WalletEarningsInfoDto", description = "钱包收益详情信息返回对象")
public class WalletEarningsInfoDto {
@ApiModelProperty(value = "钱包余额",example = "100000.0000000000")
private BigDecimal accountBalance;
@ApiModelProperty(value = "钱包历史地址集合",example = "")
List<HistoryBalanceDto> historyBalance;

View File

@ -36,4 +36,10 @@ public class ManageBroadcast {
private LocalDateTime updateTime;
private Boolean del;
private String buttonContent;
private String buttonPath;
private String buttonContentEn;
}

View File

@ -9,6 +9,7 @@ import com.m2pool.manage.vo.ManageBaseVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
@ -87,4 +88,8 @@ public interface ManageBroadcastMapper extends BaseMapper<ManageBroadcast> {
* @return
*/
List<ManageBroadcastDto> getListDataByPage();
@DistributionDB
BigDecimal getAccountBalance(@Param("user") String user, @Param("coin") String coin);
}

View File

@ -81,6 +81,8 @@ public class ManageBroadcastServiceImpl extends ServiceImpl<ManageBroadcastMappe
collect = list.stream().map(broadcast ->
ManageBroadcastDto.builder()
.content(broadcast.getContent())
.buttonContent(broadcast.getButtonContent())
.buttonPath(broadcast.getButtonPath())
.id(broadcast.getId())
.createUser(broadcast.getCreateUser())
.updateUser(broadcast.getUpdateUser())
@ -91,12 +93,15 @@ public class ManageBroadcastServiceImpl extends ServiceImpl<ManageBroadcastMappe
}else{
collect = list.stream().map(broadcast -> {
//如果英文为null需要翻译并保存一下
if("".equals(broadcast.getContentEn())){
if("".equals(broadcast.getContentEn()) || "".equals(broadcast.getButtonContentEn())){
broadcast.setContentEn(TranslateUtils.translate(broadcast.getContent(), "zh", "en"));
broadcast.setButtonContentEn(TranslateUtils.translate(broadcast.getButtonContent(), "zh", "en"));
manageBroadcastMapper.updateById(broadcast);
}
return ManageBroadcastDto.builder()
.content(broadcast.getContentEn())
.buttonContent(broadcast.getButtonContentEn())
.buttonPath(broadcast.getButtonPath())
.id(broadcast.getId())
.createUser(broadcast.getCreateUser())
.updateUser(broadcast.getUpdateUser())
@ -110,6 +115,7 @@ public class ManageBroadcastServiceImpl extends ServiceImpl<ManageBroadcastMappe
return R.success(collect);
}
private static String SEPARATE = ",yKbjIAIgFpbdESYaE7A,";
/**
* 新增广播信息
*
@ -118,10 +124,20 @@ public class ManageBroadcastServiceImpl extends ServiceImpl<ManageBroadcastMappe
*/
@Override
public R<String> addBroadcast(ManageBroadcastVo broadcastVo) {
String translate = TranslateUtils.translate(broadcastVo.getContent(), "zh", "en");
String contentEn = TranslateUtils.translate(broadcastVo.getContent(), "zh", "en");
// 休眠 1 确保符合 API QPS 限制可升级为高级版qps为10不要把两个文本放到一起同时翻译会出问题
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
String buttonContentEn = TranslateUtils.translate(broadcastVo.getButtonContent(), "zh", "en");
ManageBroadcast broadcast = ManageBroadcast.builder()
.content(broadcastVo.getContent())
.contentEn(translate)
.contentEn(contentEn)
.buttonContent(broadcastVo.getButtonContent())
.buttonContentEn(buttonContentEn)
.buttonPath(broadcastVo.getButtonPath())
.createUser(SecurityUtils.getUsername())
.updateTime(LocalDateTime.now())
.build();
@ -148,11 +164,21 @@ public class ManageBroadcastServiceImpl extends ServiceImpl<ManageBroadcastMappe
@Override
public R<String> updateBroadcast(ManageBroadcastVo broadcastVo) {
String translate = TranslateUtils.translate(broadcastVo.getContent(), "zh", "en");
String contentEn = TranslateUtils.translate(broadcastVo.getContent(), "zh", "en");
// 休眠 1 确保符合 API QPS 限制可升级为高级版qps为10不要把两个文本放到一起同时翻译会出问题
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
String buttonContentEN = TranslateUtils.translate(broadcastVo.getButtonContent(), "zh", "en");
boolean b = this.updateById(ManageBroadcast.builder()
.id(broadcastVo.getId())
.content(broadcastVo.getContent())
.contentEn(translate)
.contentEn(contentEn)
.buttonContent(broadcastVo.getButtonContent())
.buttonContentEn(buttonContentEN)
.buttonPath(broadcastVo.getButtonPath())
.updateUser(SecurityUtils.getUsername())
.build());
if (b){
@ -170,6 +196,8 @@ public class ManageBroadcastServiceImpl extends ServiceImpl<ManageBroadcastMappe
return R.success(ManageBroadcastDto.builder()
.content(byId.getContent())
.id(byId.getId())
.buttonPath(byId.getButtonPath())
.buttonContent(byId.getButtonContent())
.createUser(byId.getCreateUser())
.updateUser(byId.getUpdateUser())
.updateTime(byId.getUpdateTime())

View File

@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.m2pool.common.core.Result.R;
import com.m2pool.common.core.constant.HttpStatus;
import com.m2pool.common.core.utils.DateUtils;
import com.m2pool.common.core.utils.StringUtils;
import com.m2pool.common.core.web.page.TableDataInfo;
import com.m2pool.manage.dto.*;
@ -96,11 +97,13 @@ public class ManageUserServiceImpl implements ManageUserService {
@Override
public R<WalletEarningsInfoDto> getUserInfo(ManageUserInfoVo manageUserInfoVo) {
//获取账户余额
BigDecimal accountBalance = manageBroadcastMapper.getAccountBalance(manageUserInfoVo.getMinerUser(), manageUserInfoVo.getCoin());
//获取挖矿账户历史收益记录
List<ManageUserInfoDto> walletInInfo = manageBroadcastMapper.getUserInfo(manageUserInfoVo.getMinerUser(), manageUserInfoVo.getCoin(), manageUserInfoVo.getStartDate(), manageUserInfoVo.getEndDate());
//获取挖矿账户历史地址
List<HistoryBalanceDto> historyBalance = manageBroadcastMapper.getHistoryBalance(manageUserInfoVo.getMinerUser(), manageUserInfoVo.getCoin());
WalletEarningsInfoDto manageUserInfoDto = new WalletEarningsInfoDto(historyBalance,walletInInfo);
WalletEarningsInfoDto manageUserInfoDto = new WalletEarningsInfoDto(accountBalance,historyBalance,walletInInfo);
return R.success(manageUserInfoDto);
}
@ -123,7 +126,19 @@ public class ManageUserServiceImpl implements ManageUserService {
powerUnit = new PowerUnitUtils.NetPowerUnit("GH/S", BigDecimal.valueOf(1000 * 1000 * 1000));
}
changeUnit(powerUnit, list,BigDecimal.valueOf(1000 * 1000));
list = fillMissingData(list,powerUnit.getUnit(),manageMiningUserPowerVo.getMinerUser());
if (manageMiningUserPowerVo.getStartDate()==null || manageMiningUserPowerVo.getEndDate()==null){
}
Date endDate = manageMiningUserPowerVo.getEndDate();
Date startDate = manageMiningUserPowerVo.getStartDate();
if (manageMiningUserPowerVo.getStartDate()==null || manageMiningUserPowerVo.getEndDate()==null){
endDate = DateUtils.getPreviousHalfHourOrFullHour(new Date());
startDate = DateUtils.getOneMonthAgo(endDate);
}
list = fillMissingData(list,powerUnit.getUnit(),manageMiningUserPowerVo.getMinerUser(),startDate,endDate);
return R.success(list);
}
@ -151,21 +166,10 @@ public class ManageUserServiceImpl implements ManageUserService {
* @param dataList
* @return
*/
public static List<ManageMiningUserPowerDto> fillMissingData(List<ManageMiningUserPowerDto> dataList,String unit,String minerUser) {
if (dataList == null || dataList.size() <= 1) {
return dataList;
}
// 对数据按时间排序
dataList.sort(Comparator.comparing(ManageMiningUserPowerDto::getDate));
public static List<ManageMiningUserPowerDto> fillMissingData(List<ManageMiningUserPowerDto> dataList,String unit,String minerUser,Date startTime,Date endTime) {
List<ManageMiningUserPowerDto> resultList = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
// 获取起始和结束时间
Date startTime = dataList.get(0).getDate();
Date endTime = dataList.get(dataList.size() - 1).getDate();
calendar.setTime(startTime);
Map<Long, ManageMiningUserPowerDto> timeDataMap = new HashMap<>();
for (ManageMiningUserPowerDto data : dataList) {
@ -195,6 +199,50 @@ public class ManageUserServiceImpl implements ManageUserService {
manageMiningUserPowerVo.getCoin(),
manageMiningUserPowerVo.getStartDate(),
manageMiningUserPowerVo.getEndDate());
return R.success(minerUserOnlineStatus);
Date endDate = manageMiningUserPowerVo.getEndDate();
Date startDate = manageMiningUserPowerVo.getStartDate();
if (manageMiningUserPowerVo.getStartDate()==null || manageMiningUserPowerVo.getEndDate()==null){
endDate = DateUtils.getPreviousHalfHourOrFullHour(new Date());
startDate = DateUtils.getOneMonthAgo(endDate);
}
return R.success(fillMissingOnlineData(minerUserOnlineStatus, startDate, endDate));
}
/**
* 数据补零 30分钟时间端
* @param dataList
* @return
*/
public static List<ManageMiningUserOnlineDto> fillMissingOnlineData(List<ManageMiningUserOnlineDto> dataList,Date startTime,Date endTime) {
List<ManageMiningUserOnlineDto> resultList = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
calendar.setTime(startTime);
Map<Long, ManageMiningUserOnlineDto> timeDataMap = new HashMap<>();
for (ManageMiningUserOnlineDto data : dataList) {
timeDataMap.put(data.getDate().getTime(), data);
}
while (calendar.getTime().getTime() <= endTime.getTime()) {
long currentTime = calendar.getTime().getTime();
ManageMiningUserOnlineDto data = timeDataMap.get(currentTime);
if (data != null) {
resultList.add(data);
} else {
resultList.add(new ManageMiningUserOnlineDto(calendar.getTime(),0, 0));
}
// 增加 30 分钟
calendar.add(Calendar.MINUTE, 30);
}
return resultList;
}
}

View File

@ -40,6 +40,7 @@ public class TranslateUtils {
private static String extractDstFromResponse(String response) {
try {
JsonObject jsonObject = JsonParser.parseString(response).getAsJsonObject();
JsonArray transResultArray = jsonObject.getAsJsonArray("trans_result");
@ -48,7 +49,7 @@ public class TranslateUtils {
return firstResult.get("dst").getAsString();
}
} catch (Exception e) {
System.out.println("翻译结果解析失败"+e.getMessage());
System.out.println("翻译结果解析失败"+e.getMessage()+"翻译结果:"+response);
}
return "";
}

View File

@ -25,4 +25,10 @@ public class ManageBroadcastVo{
@ApiModelProperty(value = "内容",example = "广播内容")
private String content;
@ApiModelProperty(value = "按钮内容",example = "按钮内容")
private String buttonContent;
@ApiModelProperty(value = "按钮跳转路径",example = "按钮跳转路径")
private String buttonPath;
}

View File

@ -17,4 +17,5 @@ public class PageVo {
@ApiModelProperty(value = "每页条数",example = "20")
private Integer pageSize;
}

View File

@ -13,7 +13,7 @@
uma.coin,
uab.balance,
uab.active,
COALESCE(uab.amount,0),
COALESCE(uab.amount,0) as amount,
uma.status
FROM
user_account_balance uab
@ -45,18 +45,14 @@
coin = #{coin} AND `user` = #{user}
<choose>
<when test="startDate != null and endDate != null">
and `create_date` >= #{startDate} AND `create_date`<![CDATA[ <= ]]> #{endDate}
and `create_date` >= #{startDate} and `create_date`<![CDATA[ <= ]]> #{endDate}
</when>
<otherwise>
and `create_date` >= DATE_SUB(NOW(), INTERVAL 1 MONTH)
</otherwise>
</choose>
</where>
</select>
<select id="getHistoryBalance" resultType="com.m2pool.manage.dto.HistoryBalanceDto">
SELECT
@ -87,9 +83,15 @@
${coin}_users_30m
<where>
`user` = #{minerUser}
<if test="startDate != null and endDate != null">
and `date` >= #{startDate} AND `date`<![CDATA[ <= ]]> #{endDate}
</if>
<choose>
<when test="startDate != null and endDate != null">
and `date` >= #{startDate} and `date`<![CDATA[ <= ]]> #{endDate}
</when>
<otherwise>
and `date` >= DATE_SUB(NOW(), INTERVAL 1 MONTH)
</otherwise>
</choose>
</where>
</select>
@ -102,9 +104,14 @@
${coin}_mhsv2
<where>
`user` = #{minerUser}
<if test="startDate != null and endDate != null">
and `date` >= #{startDate} AND `date`<![CDATA[ <= ]]> #{endDate}
</if>
<choose>
<when test="startDate != null and endDate != null">
and `date` >= #{startDate} and `date`<![CDATA[ <= ]]> #{endDate}
</when>
<otherwise>
and `date` >= DATE_SUB(NOW(), INTERVAL 1 MONTH)
</otherwise>
</choose>
</where>
group by `date`
</select>
@ -118,10 +125,20 @@
create_user as createUser,
update_user as updateUser,
update_time as updateTime,
create_time as createTime
create_time as createTime,
button_content as buttonContent,
button_path as buttonPath
FROM
manage_broadcast
where del =false
</select>
<select id="getAccountBalance" resultType="java.math.BigDecimal">
SELECT
SUM(amount)
FROM
wallet_in
where
coin = #{coin} AND `user` = #{user} AND state = 0
</select>
</mapper>

View File

@ -11,10 +11,12 @@ import com.m2pool.pool.enums.PoolCalParamConfig;
import com.m2pool.pool.enums.PoolUnits;
import com.m2pool.pool.enums.Pools;
import com.m2pool.pool.mapper.PoolMapper;
import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
@ -32,10 +34,14 @@ import java.util.stream.Collectors;
* @Date 2024/6/14 14:03
* @Author dy
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "task.data")
@EnableScheduling
public class DataTask {
private boolean enable;
@Autowired
private PoolMapper poolMapper;
@ -51,7 +57,10 @@ public class DataTask {
@Scheduled(cron = "20 1,3,10,31,33,40 * * * ?")
public void NEXA30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
System.out.println("DataTask 定时任务已关闭请在nacos修改配置");
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -229,6 +238,9 @@ public class DataTask {
@Scheduled(cron = "0 1,3,5 0 * * ?")
public void NEXADailyDataToDB(){
if(!enable){
return;
}
String nowStr = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD);
Date now = DateUtils.parseDate( nowStr);
@ -382,7 +394,9 @@ public class DataTask {
@Scheduled(cron = "50 0,1,30,31 * * * ?")
public void NEXAUserPowerRatioDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
now.setHours(0);
now.setMinutes(0);
@ -408,6 +422,9 @@ public class DataTask {
@Scheduled(cron = "30 3 0/1 * * ?")
//@Scheduled(cron = "0 0/2 * * * ?")
public void NEXALuckyDataToDB(){
if(!enable){
return;
}
log.info("nexa幸运值---定时任务开始");
LuckDto dto = new LuckDto();
Date end = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS));
@ -500,7 +517,9 @@ public class DataTask {
@Scheduled(cron = "11 1,3,11,31,33,41 * * * ?")
public void GRS30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -665,6 +684,9 @@ public class DataTask {
@Scheduled(cron = "1 1,3,5 0 * * ?")
public void GRSDailyDataToDB(){
if(!enable){
return;
}
String nowStr = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD);
Date now = DateUtils.parseDate( nowStr);
@ -819,7 +841,9 @@ public class DataTask {
@Scheduled(cron = "51 0,1,30,31 * * * ?")
public void GRSUserPowerRatioDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
now.setHours(0);
now.setMinutes(0);
@ -849,6 +873,9 @@ public class DataTask {
@Scheduled(cron = "31 3 0/1 * * ?")
//@Scheduled(cron = "0 0/2 * * * ?")
public void GRSLuckyDataToDB(){
if(!enable){
return;
}
log.info("GRS幸运值---定时任务开始");
LuckDto dto = new LuckDto();
Date end = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS));
@ -912,7 +939,9 @@ public class DataTask {
@Scheduled(cron = "12 1,3,12,31,33,42 * * * ?")
public void MONA30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -1074,6 +1103,9 @@ public class DataTask {
@Scheduled(cron = "2 1,3,5 0 * * ?")
public void MONADailyDataToDB(){
if(!enable){
return;
}
String nowStr = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD);
Date now = DateUtils.parseDate( nowStr);
@ -1230,7 +1262,9 @@ public class DataTask {
@Scheduled(cron = "52 0,1,30,31 * * * ?")
public void MONAUserPowerRatioDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
now.setHours(0);
now.setMinutes(0);
@ -1259,6 +1293,9 @@ public class DataTask {
@Scheduled(cron = "32 3 0/1 * * ?")
//@Scheduled(cron = "0 0/2 * * * ?")
public void MONALuckyDataToDB(){
if(!enable){
return;
}
log.info("MONA幸运值---定时任务开始");
LuckDto dto = new LuckDto();
Date end = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS));
@ -1325,7 +1362,9 @@ public class DataTask {
@Scheduled(cron = "14 1,3,9,31,33,39 * * * ?")
public void DGBO30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -1487,6 +1526,9 @@ public class DataTask {
@Scheduled(cron = "4 1,3,5 0 * * ?")
public void DGBODailyDataToDB(){
if(!enable){
return;
}
String nowStr = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD);
Date now = DateUtils.parseDate( nowStr);
@ -1643,7 +1685,9 @@ public class DataTask {
@Scheduled(cron = "54 0,1,30,31 * * * ?")
public void DGBOUserPowerRatioDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
now.setHours(0);
now.setMinutes(0);
@ -1673,7 +1717,9 @@ public class DataTask {
@Scheduled(cron = "34 3 0/1 * * ?")
//@Scheduled(cron = "0 0/2 * * * ?")
public void DGBOLuckyDataToDB(){
if(!enable){
return;
}
log.info("DGBO幸运值---定时任务开始");
LuckDto dto = new LuckDto();
Date end = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS));
@ -1740,7 +1786,9 @@ public class DataTask {
@Scheduled(cron = "16 1,3,8,31,33,38 * * * ?")
public void DGBQ30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -1902,6 +1950,9 @@ public class DataTask {
@Scheduled(cron = "6 1,3,5 0 * * ?")
public void DGBQDailyDataToDB(){
if(!enable){
return;
}
String nowStr = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD);
Date now = DateUtils.parseDate( nowStr);
@ -2058,7 +2109,9 @@ public class DataTask {
@Scheduled(cron = "56 0,1,30,31 * * * ?")
public void DGBQUserPowerRatioDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
now.setHours(0);
now.setMinutes(0);
@ -2087,6 +2140,9 @@ public class DataTask {
@Scheduled(cron = "36 3 0/1 * * ?")
//@Scheduled(cron = "0 0/2 * * * ?")
public void DGBQLuckyDataToDB(){
if(!enable){
return;
}
log.info("DGBQ幸运值---定时任务开始");
LuckDto dto = new LuckDto();
Date end = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS));
@ -2153,7 +2209,9 @@ public class DataTask {
@Scheduled(cron = "18 1,3,7,31,33,37 * * * ?")
public void DGBS30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -2315,6 +2373,9 @@ public class DataTask {
@Scheduled(cron = "8 1,3,5 0 * * ?")
public void DGBSDailyDataToDB(){
if(!enable){
return;
}
String nowStr = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD);
Date now = DateUtils.parseDate( nowStr);
@ -2469,7 +2530,9 @@ public class DataTask {
@Scheduled(cron = "58 0,1,30,31 * * * ?")
public void DGBSUserPowerRatioDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
now.setHours(0);
now.setMinutes(0);
@ -2498,6 +2561,9 @@ public class DataTask {
@Scheduled(cron = "38 3 0/1 * * ?")
//@Scheduled(cron = "0 0/2 * * * ?")
public void DGBSLuckyDataToDB(){
if(!enable){
return;
}
log.info("DGBS幸运值---定时任务开始");
LuckDto dto = new LuckDto();
Date end = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS));
@ -2564,7 +2630,9 @@ public class DataTask {
@Scheduled(cron = "19 1,3,13,31,33,43 * * * ?")
public void RXD30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -2724,6 +2792,9 @@ public class DataTask {
@Scheduled(cron = "9 1,3,5 0 * * ?")
public void RXDDailyDataToDB(){
if(!enable){
return;
}
String nowStr = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD);
Date now = DateUtils.parseDate( nowStr);
@ -2877,7 +2948,9 @@ public class DataTask {
@Scheduled(cron = "59 0,1,30,31 * * * ?")
public void RXDUserPowerRatioDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
now.setHours(0);
now.setMinutes(0);
@ -2901,6 +2974,9 @@ public class DataTask {
@Scheduled(cron = "39 3 0/1 * * ?")
//@Scheduled(cron = "0 0/2 * * * ?")
public void RXDLuckyDataToDB(){
if(!enable){
return;
}
log.info("rxd幸运值---定时任务开始");
LuckDto dto = new LuckDto();
Date end = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS));
@ -2966,7 +3042,9 @@ public class DataTask {
@Scheduled(cron = "21 1,3,13,31,33,43 * * * ?")
public void ENX30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -3126,6 +3204,9 @@ public class DataTask {
@Scheduled(cron = "10 1,3,5 0 * * ?")
public void ENXDailyDataToDB(){
if(!enable){
return;
}
String nowStr = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD);
Date now = DateUtils.parseDate( nowStr);
@ -3279,7 +3360,9 @@ public class DataTask {
@Scheduled(cron = "53 0,1,30,31 * * * ?")
public void ENXUserPowerRatioDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
now.setHours(0);
now.setMinutes(0);
@ -3303,6 +3386,9 @@ public class DataTask {
//@Scheduled(cron = "30 2,7 0,12 * * ?")
@Scheduled(cron = "41 2,5 0/12 * * ?")
public void ENXLuckyDataToDB(){
if(!enable){
return;
}
int time = 0;
LuckDto dto = new LuckDto();
Date end = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD));
@ -3531,7 +3617,9 @@ public class DataTask {
@Scheduled(cron = "23 1,3,13,31,33,43 * * * ?")
public void ALPH30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -3691,6 +3779,9 @@ public class DataTask {
@Scheduled(cron = "12 1,3,5 0 * * ?")
public void ALPHDailyDataToDB(){
if(!enable){
return;
}
String nowStr = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD);
Date now = DateUtils.parseDate( nowStr);
@ -3841,7 +3932,9 @@ public class DataTask {
@Scheduled(cron = "52 0,1,30,31 * * * ?")
public void ALPHUserPowerRatioDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
now.setHours(0);
now.setMinutes(0);
@ -3865,6 +3958,9 @@ public class DataTask {
//@Scheduled(cron = "30 2,7 0,12 * * ?")
@Scheduled(cron = "42 2,5 0/12 * * ?")
public void ALPHLuckyDataToDB(){
if(!enable){
return;
}
int time = 0;
LuckDto dto = new LuckDto();
Date end = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD));

View File

@ -9,8 +9,10 @@ import com.m2pool.common.redis.service.RedisService;
import com.m2pool.pool.mapper.PoolMapper;
import com.m2pool.pool.utils.NodeRpc;
import com.m2pool.pool.vo.DateValueVo;
import lombok.Data;
import org.apache.http.HttpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
@ -25,10 +27,14 @@ import java.util.Map;
* @Date 2024/6/14 14:03
* @Author dy
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "task.price")
@EnableScheduling
public class NeaxPriceTask {
private boolean enable;
@Autowired
private PoolMapper poolMapper;
@ -45,6 +51,10 @@ public class NeaxPriceTask {
@Scheduled(cron = "0 0,3,30,33 * * * ?")
public void NEXAPriceToRedis()
{
if(!enable){
System.out.println("NeaxPriceTask 定时任务已关闭请在nacos修改配置");
return;
}
Map<String, BigDecimal> map = getResultFromNetByAllCoins();
int count = 1;
while (StringUtils.isNull(map)

View File

@ -10,9 +10,13 @@ import com.m2pool.pool.entity.BlockInfo;
import com.m2pool.pool.mapper.PoolMapper;
import com.m2pool.pool.utils.NodeRpc;
import com.m2pool.pool.vo.DateValueVo;
import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@ -32,10 +36,13 @@ import java.util.Map;
* @Date 2024/6/14 14:03
* @Author dy
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "task.node")
@EnableScheduling
public class NodeTask {
private boolean enable;
private static final Logger log = LoggerFactory.getLogger(NodeTask.class);
@ -49,9 +56,14 @@ public class NodeTask {
@Autowired
private TransactionTemplate transactionTemplate;
//@Scheduled(cron = "0 0/2 * * * ?")
@Scheduled(cron = "5 0,30 * * * ?")
public void NEXABlockInfoToRedisAndDB(){
if(!enable){
return;
}
BlockInfo blockInfo = NodeRpc.getBlock("nexa");
int count = 1;
@ -83,6 +95,10 @@ public class NodeTask {
@Scheduled(cron = "0 0/1 * * * ?")
public void NEXABlockInfoToRedis(){
if(!enable){
System.out.println("NodeTask 定时任务已关闭请在nacos修改配置");
return;
}
BlockInfo blockInfo = NodeRpc.getBlock("nexa");
int count = 0;
while (StringUtils.isNull(blockInfo)){
@ -109,6 +125,9 @@ public class NodeTask {
@Scheduled(cron = "10 0,30 * * * ?")
public void GRSBlockInfoToRedisAndDB(){
if(!enable){
return;
}
BlockInfo blockInfo = NodeRpc.getBlock("grs");
int count = 1;
@ -139,8 +158,10 @@ public class NodeTask {
@Scheduled(cron = "2 0/1 * * * ?")
public void GRSBlockInfoToRedis(){
if(!enable){
return;
}
BlockInfo blockInfo = NodeRpc.getBlock("grs");
if(StringUtils.isNotNull(blockInfo)){
if(StringUtils.isNotNull(blockInfo.getPower())){
@ -160,6 +181,9 @@ public class NodeTask {
@Scheduled(cron = "15 0,30 * * * ?")
public void MONABlockInfoToRedisAndDB(){
if(!enable){
return;
}
BlockInfo blockInfo = NodeRpc.getBlock("mona");
int count = 1;
@ -191,6 +215,9 @@ public class NodeTask {
@Scheduled(cron = "4 0/1 * * * ?")
public void MONABlockInfoToRedis(){
if(!enable){
return;
}
BlockInfo blockInfo = NodeRpc.getBlock("mona");
if(StringUtils.isNotNull(blockInfo)){
@ -212,6 +239,9 @@ public class NodeTask {
@Scheduled(cron = "20 0,30 * * * ?")
public void DGBBlockInfoToRedisAndDB(){
if(!enable){
return;
}
Map<String, BlockInfo> dgbMap = NodeRpc.getDGBBlock();
int count = 1;
while (StringUtils.isNull(dgbMap)){
@ -299,6 +329,9 @@ public class NodeTask {
@Scheduled(cron = "6 0/1 * * * ?")
public void DGBBlockInfoToRedis(){
if(!enable){
return;
}
Map<String, BlockInfo> dgbMap = NodeRpc.getDGBBlock();
if(StringUtils.isNotNull(dgbMap)){
BlockInfo dgbo = dgbMap.getOrDefault("dgbo", null);
@ -344,6 +377,9 @@ public class NodeTask {
@Scheduled(cron = "25 0,30 * * * ?")
public void RXDBlockInfoToRedisAndDB(){
if(!enable){
return;
}
BlockInfo blockInfo = NodeRpc.getBlock("rxd");
int count = 1;
@ -375,6 +411,9 @@ public class NodeTask {
@Scheduled(cron = "8 0/1 * * * ?")
public void RXDBlockInfoToRedis(){
if(!enable){
return;
}
BlockInfo blockInfo = NodeRpc.getBlock("rxd");
if(StringUtils.isNotNull(blockInfo)){
@ -396,6 +435,9 @@ public class NodeTask {
@Scheduled(cron = "30 0,30 * * * ?")
public void ALPHBlockInfoToRedisAndDB(){
if(!enable){
return;
}
BlockInfo blockInfo = NodeRpc.getBlock("alph");
//改成根据swagger api调用 用与原有节点调用相比新的路径新的api
@ -428,6 +470,9 @@ public class NodeTask {
@Scheduled(cron = "14 0/1 * * * ?")
public void ALPHBlockInfoToRedis(){
if(!enable){
return;
}
BlockInfo blockInfo = NodeRpc.getBlock("alph");
if(StringUtils.isNotNull(blockInfo)){
@ -449,6 +494,9 @@ public class NodeTask {
@Scheduled(cron = "35 0,30 * * * ?")
public void ENXBlockInfoToRedisAndDB(){
if(!enable){
return;
}
BlockInfo blockInfo = NodeRpc.getBlock("enx");
int count = 1;
@ -480,6 +528,9 @@ public class NodeTask {
@Scheduled(cron = "12 0/1 * * * ?")
public void ENXBlockInfoToRedis(){
if(!enable){
return;
}
BlockInfo blockInfo = NodeRpc.getBlock("enx");
if(StringUtils.isNotNull(blockInfo)){
@ -506,6 +557,9 @@ public class NodeTask {
@Scheduled(cron = "0 2 0/1 * * ?")
//@Scheduled(cron = "0 0/2 * * * ?")
public void insertNetBlock(){
if(!enable){
return;
}
insertBlockWithRetry("nexa", "nexa_net_block", 5);
insertBlockWithRetry("mona", "mona_net_block", 5);
insertBlockWithRetry("rxd", "rxd_net_block", 5);

View File

@ -9,7 +9,9 @@ import com.m2pool.pool.mapper.NoticeMapper;
import com.m2pool.pool.mapper.PoolMapper;
import com.m2pool.system.api.RemoteMailService;
import com.m2pool.system.api.entity.EmailEntity;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
@ -22,9 +24,12 @@ import java.util.stream.Collectors;
* @Date 2024/6/14 14:03
* @Author dy
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "task.notice")
@EnableScheduling
public class OffLineNoticeTask {
private boolean enable;
@Autowired
private PoolMapper poolMapper;
@ -43,7 +48,10 @@ public class OffLineNoticeTask {
@Scheduled(cron = "20 15,45 * * * ?")
public void NEXA30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
System.out.println("OffLineNoticeTask 定时任务已关闭请在nacos修改配置");
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -125,7 +133,9 @@ public class OffLineNoticeTask {
@Scheduled(cron = "11 16,46 * * * ?")
public void GRS30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -203,7 +213,9 @@ public class OffLineNoticeTask {
@Scheduled(cron = "12 17,47 * * * ?")
public void MONA30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -281,7 +293,9 @@ public class OffLineNoticeTask {
@Scheduled(cron = "14 18,48 * * * ?")
public void DGBO30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -358,7 +372,9 @@ public class OffLineNoticeTask {
@Scheduled(cron = "16 19,49 * * * ?")
public void DGBQ30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -435,7 +451,9 @@ public class OffLineNoticeTask {
@Scheduled(cron = "18 20,50 * * * ?")
public void DGBS30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -512,7 +530,9 @@ public class OffLineNoticeTask {
@Scheduled(cron = "19 21,51 * * * ?")
public void RXD30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -589,7 +609,9 @@ public class OffLineNoticeTask {
@Scheduled(cron = "20 23,53 * * * ?")
public void ALPH30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);
@ -666,7 +688,9 @@ public class OffLineNoticeTask {
@Scheduled(cron = "21 25,55 * * * ?")
public void ENX30mDataToDB(){
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
if(!enable){
return;
}
Date now = new Date();
int minute = (now.getMinutes() / 30) * 30;
now.setMinutes( minute);

View File

@ -4,7 +4,9 @@ import com.m2pool.common.core.utils.DateUtils;
import com.m2pool.common.redis.service.RedisService;
import com.m2pool.pool.dto.BlockInfoDto;
import com.m2pool.pool.mapper.PoolMapper;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
@ -18,10 +20,14 @@ import java.util.List;
* @Date 2024/6/14 14:03
* @Author dy
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "task.pool")
@EnableScheduling
public class PoolBlkStatsTask {
private boolean enable;
@Autowired
private PoolMapper poolMapper;
@ -30,6 +36,10 @@ public class PoolBlkStatsTask {
@Scheduled(cron = "0 0/2 * * * ?")
public void NEXABlockInfoToRedis(){
if(!enable){
System.out.println("PoolBlkStatsTask 定时任务已关闭请在nacos修改配置");
return;
}
boolean result = NEXABlockInfo();
@ -46,7 +56,9 @@ public class PoolBlkStatsTask {
@Scheduled(cron = "5 0/2 * * * ?")
public void GRSBlockInfoToRedis(){
if(!enable){
return;
}
boolean result = GRSBlockInfo();
int count = 1;
@ -62,7 +74,9 @@ public class PoolBlkStatsTask {
@Scheduled(cron = "10 0/2 * * * ?")
public void MONABlockInfoToRedis(){
if(!enable){
return;
}
boolean result = MONABlockInfo();
int count = 1;
@ -78,7 +92,9 @@ public class PoolBlkStatsTask {
@Scheduled(cron = "15 0/2 * * * ?")
public void DGBOBlockInfoToRedis(){
if(!enable){
return;
}
boolean result = DGBOBlockInfo();
int count = 1;
@ -94,7 +110,9 @@ public class PoolBlkStatsTask {
@Scheduled(cron = "20 0/2 * * * ?")
public void DGBQBlockInfoToRedis(){
if(!enable){
return;
}
boolean result = DGBQBlockInfo();
int count = 1;
@ -110,7 +128,9 @@ public class PoolBlkStatsTask {
@Scheduled(cron = "25 0/2 * * * ?")
public void DGBSBlockInfoToRedis(){
if(!enable){
return;
}
boolean result = DGBSBlockInfo();
int count = 1;
@ -126,7 +146,9 @@ public class PoolBlkStatsTask {
@Scheduled(cron = "30 0/2 * * * ?")
public void RXDBlockInfoToRedis(){
if(!enable){
return;
}
boolean result = RXDBlockInfo();
int count = 1;
@ -142,7 +164,9 @@ public class PoolBlkStatsTask {
@Scheduled(cron = "35 0/2 * * * ?")
public void ALPHBlockInfoToRedis(){
if(!enable){
return;
}
boolean result = ALPHBlockInfo();
int count = 1;
@ -158,7 +182,9 @@ public class PoolBlkStatsTask {
@Scheduled(cron = "40 0/2 * * * ?")
public void ENXBlockInfoToRedis(){
if(!enable){
return;
}
boolean result = ENXBlockInfo();
int count = 1;

View File

@ -2,12 +2,14 @@ package com.m2pool.pool.utils;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.m2pool.common.core.utils.DateUtils;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Date;
/**
* @Description TODO
@ -25,15 +27,19 @@ public class SocketDemo {
//} catch (IOException e) {
// System.out.println("连接失败: " + e.getMessage());
//}
String url = "http://10.168.2.167:12973/blockflow/chain-info?fromGroup=0&toGroup=0";
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type","application/json");
headers.add("User-Agent", "Mozilla/5.0");
headers.add("apikey","0x09e220e226f2feb7a971a2b6f958e7d4b1c187c8");
HttpEntity<String> httpEntity = new HttpEntity<String>(null, headers);
String s = HttpUtil.get(url);
//String url = "http://10.168.2.167:12973/blockflow/chain-info?fromGroup=0&toGroup=0";
//HttpHeaders headers = new HttpHeaders();
//headers.add("Content-Type","application/json");
//headers.add("User-Agent", "Mozilla/5.0");
//headers.add("apikey","0x09e220e226f2feb7a971a2b6f958e7d4b1c187c8");
//HttpEntity<String> httpEntity = new HttpEntity<String>(null, headers);
//String s = HttpUtil.get(url);
//
//JSONObject jsonObject = JSONObject.parseObject(s);
//int currentHeight = jsonObject.getIntValue("currentHeight");
JSONObject jsonObject = JSONObject.parseObject(s);
int currentHeight = jsonObject.getIntValue("currentHeight");
Date endDate = DateUtils.getPreviousHalfHourOrFullHour(new Date());
Date startDate = DateUtils.getOneMonthAgo(endDate);
System.out.println(startDate+" "+endDate);
}
}