update 后台管理新增定时任务开关,收益入库定时任务修改。新增用户待支付汇总 接口
This commit is contained in:
parent
a9ddc0b9d3
commit
ec8faeb41d
|
@ -95,6 +95,8 @@ public class ManageDocumentsController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//@PostMapping("/searchDocument")
|
//@PostMapping("/searchDocument")
|
||||||
//@ApiOperation(value = "业务系统:按关键字搜索文章内容")
|
//@ApiOperation(value = "业务系统:按关键字搜索文章内容")
|
||||||
//public TableDataInfo<ManageDocumentDto> searchDocument(@RequestBody ManageSearchDocumentVo manageSearchDocumentVo){
|
//public TableDataInfo<ManageDocumentDto> searchDocument(@RequestBody ManageSearchDocumentVo manageSearchDocumentVo){
|
||||||
|
|
|
@ -10,10 +10,7 @@ import com.m2pool.manage.service.ManageUserService;
|
||||||
import com.m2pool.manage.vo.*;
|
import com.m2pool.manage.vo.*;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -83,4 +80,11 @@ public class ManageUserController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/summaryOfPendingPayments")
|
||||||
|
@ApiOperation(value = "管理系统:用户待支付汇总")
|
||||||
|
@RequiresLogin
|
||||||
|
@RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
|
||||||
|
public R<List<SummaryOfPendingPaymentsDto>> summaryOfPendingPayments(){
|
||||||
|
return manageUserService.summaryOfPendingPayments();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,4 +109,12 @@ public interface ManageBroadcastMapper extends BaseMapper<ManageBroadcast> {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int selectNeedDeleteNumbers(@Param("coin") String coin, @Param("date") LocalDateTime date);
|
int selectNeedDeleteNumbers(@Param("coin") String coin, @Param("date") LocalDateTime date);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取起付额
|
||||||
|
* @param coin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<SummaryOfPendingPaymentsDto> getStartPayments(@Param("list") List<SummaryOfPendingPaymentsDto> summaryOfPendingPaymentsList );
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,4 +35,12 @@ public interface ManageWalletOutInMapper extends BaseMapper<ManageWalletOutIn> {
|
||||||
@DistributionDB
|
@DistributionDB
|
||||||
List<ManageWalletOutIn> getWalletOut(@Param("startDate") LocalDateTime startDate);
|
List<ManageWalletOutIn> getWalletOut(@Param("startDate") LocalDateTime startDate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户待支付汇总
|
||||||
|
* @param coin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@DistributionDB
|
||||||
|
List<SummaryOfPendingPaymentsDto> summaryOfPendingPayments();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,4 +59,13 @@ public interface ManageUserService{
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
R<List<ManageMiningUserOnlineDto>> getMinerUserOnlineStatus(ManageMiningUserPowerVo manageMiningUserPowerVo);
|
R<List<ManageMiningUserOnlineDto>> getMinerUserOnlineStatus(ManageMiningUserPowerVo manageMiningUserPowerVo);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 管理系统:用户待支付汇总
|
||||||
|
* @param coinVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
R<List<SummaryOfPendingPaymentsDto>> summaryOfPendingPayments();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.m2pool.common.core.utils.StringUtils;
|
||||||
import com.m2pool.common.core.web.page.TableDataInfo;
|
import com.m2pool.common.core.web.page.TableDataInfo;
|
||||||
import com.m2pool.manage.dto.*;
|
import com.m2pool.manage.dto.*;
|
||||||
import com.m2pool.manage.mapper.ManageBroadcastMapper;
|
import com.m2pool.manage.mapper.ManageBroadcastMapper;
|
||||||
|
import com.m2pool.manage.mapper.ManageWalletOutInMapper;
|
||||||
import com.m2pool.manage.service.ManageUserService;
|
import com.m2pool.manage.service.ManageUserService;
|
||||||
import com.m2pool.manage.utils.PowerUnitUtils;
|
import com.m2pool.manage.utils.PowerUnitUtils;
|
||||||
import com.m2pool.manage.vo.*;
|
import com.m2pool.manage.vo.*;
|
||||||
|
@ -35,6 +36,9 @@ public class ManageUserServiceImpl implements ManageUserService {
|
||||||
@Resource
|
@Resource
|
||||||
private ManageBroadcastMapper manageBroadcastMapper;
|
private ManageBroadcastMapper manageBroadcastMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ManageWalletOutInMapper manageWalletOutInMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private JavaMailSenderImpl javaMailSender;
|
private JavaMailSenderImpl javaMailSender;
|
||||||
|
|
||||||
|
@ -240,7 +244,29 @@ public class ManageUserServiceImpl implements ManageUserService {
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<List<SummaryOfPendingPaymentsDto>> summaryOfPendingPayments() {
|
||||||
|
List<SummaryOfPendingPaymentsDto> summaryOfPendingPaymentsList = manageWalletOutInMapper.summaryOfPendingPayments();
|
||||||
|
System.out.println("起付额:"+summaryOfPendingPaymentsList);
|
||||||
|
//查询起付额
|
||||||
|
List<SummaryOfPendingPaymentsDto> startPayments = manageBroadcastMapper.getStartPayments(summaryOfPendingPaymentsList);
|
||||||
|
|
||||||
|
// 创建一个 Map 用于存储第二个集合中元素的 user 和 coin 组合对应的 startPayAmount
|
||||||
|
Map<String, BigDecimal> startPayAmountMap = startPayments.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
dto -> dto.getUser() + "_" + dto.getCoin(),
|
||||||
|
SummaryOfPendingPaymentsDto::getStartPayAmount
|
||||||
|
));
|
||||||
|
System.out.println("起付额22:"+startPayAmountMap);
|
||||||
|
// 遍历第一个集合,根据 user 和 coin 从 Map 中查找对应的 startPayAmount 并填充
|
||||||
|
for (SummaryOfPendingPaymentsDto dto : summaryOfPendingPaymentsList) {
|
||||||
|
String key = dto.getUser() + "_" + dto.getCoin();
|
||||||
|
if (startPayAmountMap.containsKey(key)) {
|
||||||
|
dto.setStartPayAmount(startPayAmountMap.get(key));
|
||||||
|
}else{
|
||||||
|
dto.setStartPayAmount(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return R.success(summaryOfPendingPaymentsList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import com.m2pool.manage.entity.ManageWalletOutIn;
|
||||||
import com.m2pool.manage.mapper.ManageBroadcastMapper;
|
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 lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
@ -22,9 +24,12 @@ import java.util.stream.Stream;
|
||||||
* @Date 2025/7/15 15:45
|
* @Date 2025/7/15 15:45
|
||||||
* @Author yyb
|
* @Author yyb
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "task.manage")
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
public class ManageTask {
|
public class ManageTask {
|
||||||
|
private boolean enable;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ManageWalletOutInService manageWalletOutInService;
|
private ManageWalletOutInService manageWalletOutInService;
|
||||||
|
@ -37,7 +42,7 @@ public class ManageTask {
|
||||||
/**
|
/**
|
||||||
* 存储交易记录定时任务
|
* 存储交易记录定时任务
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron = "22 17 0/1 * * ?")
|
@Scheduled(cron = "22 35 0/1 * * ?")
|
||||||
//@Scheduled(cron = "0 0/1 * * * ?")
|
//@Scheduled(cron = "0 0/1 * * * ?")
|
||||||
public void insertDataToWalletOutInDb(){
|
public void insertDataToWalletOutInDb(){
|
||||||
ManageWalletOutIn manageWalletOutIn = manageWalletOutInMapper.selectOne(new LambdaQueryWrapper<ManageWalletOutIn>()
|
ManageWalletOutIn manageWalletOutIn = manageWalletOutInMapper.selectOne(new LambdaQueryWrapper<ManageWalletOutIn>()
|
||||||
|
@ -147,6 +152,9 @@ public class ManageTask {
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron = "5 5 1 * * ?")
|
@Scheduled(cron = "5 5 1 * * ?")
|
||||||
public void deleteOnlineAndOfflineDataForNexa(){
|
public void deleteOnlineAndOfflineDataForNexa(){
|
||||||
|
if (!enable){
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 记录开始时间(纳秒)
|
// 记录开始时间(纳秒)
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
|
|
||||||
|
@ -164,6 +172,9 @@ public class ManageTask {
|
||||||
|
|
||||||
@Scheduled(cron = "10 5 2 * * ?")
|
@Scheduled(cron = "10 5 2 * * ?")
|
||||||
public void deleteOnlineAndOfflineDataForMona(){
|
public void deleteOnlineAndOfflineDataForMona(){
|
||||||
|
if (!enable){
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 记录开始时间(纳秒)
|
// 记录开始时间(纳秒)
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
@ -180,6 +191,9 @@ public class ManageTask {
|
||||||
|
|
||||||
@Scheduled(cron = "10 5 3 * * ?")
|
@Scheduled(cron = "10 5 3 * * ?")
|
||||||
public void deleteOnlineAndOfflineDataForRxd(){
|
public void deleteOnlineAndOfflineDataForRxd(){
|
||||||
|
if (!enable){
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 记录开始时间(纳秒)
|
// 记录开始时间(纳秒)
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
@ -196,6 +210,9 @@ public class ManageTask {
|
||||||
|
|
||||||
@Scheduled(cron = "10 5 4 * * ?")
|
@Scheduled(cron = "10 5 4 * * ?")
|
||||||
public void deleteOnlineAndOfflineDataForGrs(){
|
public void deleteOnlineAndOfflineDataForGrs(){
|
||||||
|
if (!enable){
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 记录开始时间(纳秒)
|
// 记录开始时间(纳秒)
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
@ -212,6 +229,9 @@ public class ManageTask {
|
||||||
|
|
||||||
@Scheduled(cron = "10 5 5 * * ?")
|
@Scheduled(cron = "10 5 5 * * ?")
|
||||||
public void deleteOnlineAndOfflineDataForEnx(){
|
public void deleteOnlineAndOfflineDataForEnx(){
|
||||||
|
if (!enable){
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 记录开始时间(纳秒)
|
// 记录开始时间(纳秒)
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
@ -228,6 +248,9 @@ public class ManageTask {
|
||||||
|
|
||||||
@Scheduled(cron = "10 5 6 * * ?")
|
@Scheduled(cron = "10 5 6 * * ?")
|
||||||
public void deleteOnlineAndOfflineDataForAlph(){
|
public void deleteOnlineAndOfflineDataForAlph(){
|
||||||
|
if (!enable){
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 记录开始时间(纳秒)
|
// 记录开始时间(纳秒)
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
@ -244,6 +267,9 @@ public class ManageTask {
|
||||||
|
|
||||||
@Scheduled(cron = "10 5 7 * * ?")
|
@Scheduled(cron = "10 5 7 * * ?")
|
||||||
public void deleteOnlineAndOfflineDataForDgbo(){
|
public void deleteOnlineAndOfflineDataForDgbo(){
|
||||||
|
if (!enable){
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 记录开始时间(纳秒)
|
// 记录开始时间(纳秒)
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
@ -260,6 +286,9 @@ public class ManageTask {
|
||||||
|
|
||||||
@Scheduled(cron = "10 5 8 * * ?")
|
@Scheduled(cron = "10 5 8 * * ?")
|
||||||
public void deleteOnlineAndOfflineDataForDgbq(){
|
public void deleteOnlineAndOfflineDataForDgbq(){
|
||||||
|
if (!enable){
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 记录开始时间(纳秒)
|
// 记录开始时间(纳秒)
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
@ -276,6 +305,9 @@ public class ManageTask {
|
||||||
|
|
||||||
@Scheduled(cron = "10 5 9 * * ?")
|
@Scheduled(cron = "10 5 9 * * ?")
|
||||||
public void deleteOnlineAndOfflineDataForDgbs(){
|
public void deleteOnlineAndOfflineDataForDgbs(){
|
||||||
|
if (!enable){
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 记录开始时间(纳秒)
|
// 记录开始时间(纳秒)
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|
|
@ -2,10 +2,7 @@ package com.m2pool.manage.vo;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.*;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description 发送的邮箱信息
|
* @Description 发送的邮箱信息
|
||||||
|
@ -16,7 +13,7 @@ import lombok.NoArgsConstructor;
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ApiModel(value = "发送的邮箱信息")
|
@ApiModel(description = "发送的邮箱信息", value="EmailVo")
|
||||||
public class EmailVo{
|
public class EmailVo{
|
||||||
@ApiModelProperty(value = "接受者邮箱,多个以逗号隔开",example = "1416014977@qq.com,1328642438@qq.com")
|
@ApiModelProperty(value = "接受者邮箱,多个以逗号隔开",example = "1416014977@qq.com,1328642438@qq.com")
|
||||||
private String to;
|
private String to;
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.time.LocalDateTime;
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ApiModel(value = "基础请求对象")
|
@ApiModel(description = "基础请求对象",value = "ManageBaseVo")
|
||||||
public class ManageBaseVo {
|
public class ManageBaseVo {
|
||||||
@ApiModelProperty(value = "id",example = "1")
|
@ApiModelProperty(value = "id",example = "1")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.time.LocalDateTime;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
@ApiModel(value = "广播请求对象")
|
@ApiModel(description = "广播请求对象",value = "ManageBroadcastVo")
|
||||||
public class ManageBroadcastVo{
|
public class ManageBroadcastVo{
|
||||||
@ApiModelProperty(value = "id",example = "1")
|
@ApiModelProperty(value = "id",example = "1")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description 用户请求对象
|
* @Description 用户挖矿账户详情请求对象
|
||||||
* @Date 2025/5/22 17:18
|
* @Date 2025/5/22 17:18
|
||||||
* @Author yyb
|
* @Author yyb
|
||||||
*/
|
*/
|
||||||
|
@ -16,7 +16,7 @@ import lombok.NoArgsConstructor;
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ApiModel(value = "用户挖矿账户详情请求对象")
|
@ApiModel(value = "ManageMiningUserVo",description = "用户挖矿账户详情请求对象")
|
||||||
public class ManageMiningUserVo{
|
public class ManageMiningUserVo{
|
||||||
|
|
||||||
@ApiModelProperty(value = "用户名(邮箱)",example = "1328642438@qq.com",required = true)
|
@ApiModelProperty(value = "用户名(邮箱)",example = "1328642438@qq.com",required = true)
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.time.LocalDateTime;
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ApiModel(value = "用户请求对象")
|
@ApiModel(value = "ManageUserVo",description = "用户请求对象")
|
||||||
public class ManageUserVo extends PageVo{
|
public class ManageUserVo extends PageVo{
|
||||||
@ApiModelProperty(value = "查询条件:币种,进入页面默认只显示出nexa,用户可选择",example = "nexa",required = true)
|
@ApiModelProperty(value = "查询条件:币种,进入页面默认只显示出nexa,用户可选择",example = "nexa",required = true)
|
||||||
private String coin;
|
private String coin;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import lombok.Data;
|
||||||
* @Author yyb
|
* @Author yyb
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@ApiModel(value = "分页请求对象")
|
@ApiModel(value = "PageVo",description = "分页请求对象")
|
||||||
public class PageVo {
|
public class PageVo {
|
||||||
@ApiModelProperty(value = "当前页码 (默认为1)",example = "1")
|
@ApiModelProperty(value = "当前页码 (默认为1)",example = "1")
|
||||||
private Integer pageNum = 1;
|
private Integer pageNum = 1;
|
||||||
|
|
|
@ -139,7 +139,7 @@
|
||||||
FROM
|
FROM
|
||||||
wallet_in
|
wallet_in
|
||||||
where
|
where
|
||||||
coin = #{coin} AND `user` = #{user}
|
coin = #{coin} AND `user` = #{user} and state = 1
|
||||||
</select>
|
</select>
|
||||||
<select id="getAccountExpend" resultType="java.math.BigDecimal">
|
<select id="getAccountExpend" resultType="java.math.BigDecimal">
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -153,8 +153,23 @@
|
||||||
select count(*) from ${coin}_mhs30m where `date` <![CDATA[ <= ]]> #{date}
|
select count(*) from ${coin}_mhs30m where `date` <![CDATA[ <= ]]> #{date}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<delete id="deleteOnlineAndOfflineData">
|
<delete id="deleteOnlineAndOfflineData">
|
||||||
delete from ${coin}_mhs30m where `date` <![CDATA[ <= ]]> #{date} LIMIT 5000
|
delete from ${coin}_mhs30m where `date` <![CDATA[ <= ]]> #{date} LIMIT 5000
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<select id="getStartPayments" resultType="com.m2pool.manage.dto.SummaryOfPendingPaymentsDto">
|
||||||
|
SELECT
|
||||||
|
uma.miner_user AS `user`,
|
||||||
|
uma.coin,
|
||||||
|
COALESCE ( uab.amount, 0 ) as startPayAmount
|
||||||
|
FROM
|
||||||
|
user_account_balance uab
|
||||||
|
JOIN user_miner_account uma ON uma.id = uab.ma_id
|
||||||
|
WHERE
|
||||||
|
<foreach collection="list" item="item" separator="OR">
|
||||||
|
(`user` = #{item.user} AND coin = #{item.coin})
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -9,19 +9,19 @@
|
||||||
SELECT
|
SELECT
|
||||||
wi.coin,
|
wi.coin,
|
||||||
wi.`user`,
|
wi.`user`,
|
||||||
wi.should_out_date AS shouldOutDate,
|
wi.should_out_date AS `date`,
|
||||||
wi.amount AS allocationAmount,
|
wi.amount AS allocationAmount,
|
||||||
wi.`create_date` as `date`,
|
wi.`create_date` as `shouldOutDate`,
|
||||||
wi.max_height AS maxHeight
|
wi.max_height AS maxHeight
|
||||||
FROM
|
FROM
|
||||||
wallet_in wi
|
wallet_in wi
|
||||||
<where>
|
<where>
|
||||||
<choose>
|
<choose>
|
||||||
<when test="startDate != null">
|
<when test="startDate != null">
|
||||||
wi.`create_date` >= DATE(#{startDate})
|
wi.`should_out_date` >= DATE(#{startDate})
|
||||||
</when>
|
</when>
|
||||||
<otherwise>
|
<otherwise>
|
||||||
wi.`create_date` <![CDATA[ <= ]]> NOW()
|
wi.`should_out_date` <![CDATA[ <= ]]> NOW()
|
||||||
</otherwise>
|
</otherwise>
|
||||||
</choose>
|
</choose>
|
||||||
</where>
|
</where>
|
||||||
|
@ -44,4 +44,7 @@
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="summaryOfPendingPayments" resultType="com.m2pool.manage.dto.SummaryOfPendingPaymentsDto">
|
||||||
|
select coin, max(max_height) as maxHeight, max(should_out_date) AS shouldOutDate, `user`, sum(amount) as needPayAmount from wallet_in where state = 2 group by coin,`user`;
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -147,6 +147,9 @@ public interface PoolMapper {
|
||||||
|
|
||||||
//写入币价数据 30m
|
//写入币价数据 30m
|
||||||
public boolean insertPrice(@Param("table") String table,@Param("date") String date,@Param("vo") DateValueVo vo);
|
public boolean insertPrice(@Param("table") String table,@Param("date") String date,@Param("vo") DateValueVo vo);
|
||||||
|
|
||||||
|
public BigDecimal selectPrice(@Param("coin") String coin);
|
||||||
|
|
||||||
//@Pool2DB
|
//@Pool2DB
|
||||||
//public boolean insertMhsDataToDB(@Param("table") String table,@Param("list") List<MinerDataDto> list);
|
//public boolean insertMhsDataToDB(@Param("table") String table,@Param("list") List<MinerDataDto> list);
|
||||||
//报块信息表
|
//报块信息表
|
||||||
|
|
|
@ -189,6 +189,8 @@ public class PoolServiceImpl implements PoolService {
|
||||||
|
|
||||||
int scale = PoolProfitScale.getScaleByCoin(pool.getCoin());
|
int scale = PoolProfitScale.getScaleByCoin(pool.getCoin());
|
||||||
|
|
||||||
|
PowerLineDto powerLineDto = priceList.stream()
|
||||||
|
.max(Comparator.comparing(PowerLineDto::getPrice)).orElse(new PowerLineDto());
|
||||||
|
|
||||||
if("1h".equals(vo.getInterval()) || "rt".equals(vo.getInterval())){
|
if("1h".equals(vo.getInterval()) || "rt".equals(vo.getInterval())){
|
||||||
// 获取当前日期
|
// 获取当前日期
|
||||||
|
@ -215,13 +217,19 @@ public class PoolServiceImpl implements PoolService {
|
||||||
list = fillMissingOnlineData(list,oneDayAgo,currentDate,powerUnit.getUnit(),30);
|
list = fillMissingOnlineData(list,oneDayAgo,currentDate,powerUnit.getUnit(),30);
|
||||||
//通过全网算力接口 获取到的时间段价格补充到矿池算力接口的价格中
|
//通过全网算力接口 获取到的时间段价格补充到矿池算力接口的价格中
|
||||||
list.stream().forEach(e -> priceList.stream().anyMatch(p ->{
|
list.stream().forEach(e -> priceList.stream().anyMatch(p ->{
|
||||||
if(p.getDate().equals(e.getDate())){
|
if( p.getDate().equals(e.getDate())){
|
||||||
e.setPrice(p.getPrice());
|
e.setPrice(p.getPrice());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return AjaxResult.success(list);
|
List<PowerLineDto> collect = list.stream().peek(e -> {
|
||||||
|
if (e.getPrice() == 0) {
|
||||||
|
e.setPrice(powerLineDto.getPrice());
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
return AjaxResult.success(collect);
|
||||||
}else if ("1d".equals(vo.getInterval())){
|
}else if ("1d".equals(vo.getInterval())){
|
||||||
|
|
||||||
//获取当天零点时间
|
//获取当天零点时间
|
||||||
|
@ -256,13 +264,17 @@ public class PoolServiceImpl implements PoolService {
|
||||||
|
|
||||||
list = fillMissingOnlineData(list,oneMonthAgo,currentDate,powerUnit.getUnit(),24*60);
|
list = fillMissingOnlineData(list,oneMonthAgo,currentDate,powerUnit.getUnit(),24*60);
|
||||||
list.stream().forEach(e -> priceList.stream().anyMatch(p ->{
|
list.stream().forEach(e -> priceList.stream().anyMatch(p ->{
|
||||||
if(p.getDate().equals(e.getDate())){
|
if( p.getDate().equals(e.getDate())){
|
||||||
e.setPrice(p.getPrice());
|
e.setPrice(p.getPrice());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}));
|
}));
|
||||||
|
List<PowerLineDto> collect = list.stream().peek(e -> {
|
||||||
return AjaxResult.success(list);
|
if (e.getPrice() == 0) {
|
||||||
|
e.setPrice(powerLineDto.getPrice());
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return AjaxResult.success(collect);
|
||||||
}else {
|
}else {
|
||||||
return AjaxResult.error("参数错误:interval");
|
return AjaxResult.error("参数错误:interval");
|
||||||
}
|
}
|
||||||
|
@ -404,6 +416,17 @@ public class PoolServiceImpl implements PoolService {
|
||||||
|
|
||||||
|
|
||||||
List<PowerLineDto> list = poolMapper.getHourNetPowerList(pool.getCoin());
|
List<PowerLineDto> list = poolMapper.getHourNetPowerList(pool.getCoin());
|
||||||
|
|
||||||
|
PowerLineDto powerLineDto = list.stream()
|
||||||
|
.max(Comparator.comparing(PowerLineDto::getPrice)).orElse(new PowerLineDto());
|
||||||
|
|
||||||
|
list = list.stream().peek(e -> {
|
||||||
|
if (e.getPrice() == 0) {
|
||||||
|
e.setPrice(powerLineDto.getPrice());
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
if("1h".equals(vo.getInterval()) || "rt".equals(vo.getInterval())){
|
if("1h".equals(vo.getInterval()) || "rt".equals(vo.getInterval())){
|
||||||
PageHelper.clearPage();
|
PageHelper.clearPage();
|
||||||
//30m数据 限制条数为最近1天的条数 即1*48=48
|
//30m数据 限制条数为最近1天的条数 即1*48=48
|
||||||
|
|
|
@ -3945,7 +3945,7 @@ public class DataTask {
|
||||||
List<UserPowerDto> userMhsList = poolMapper.getUserTodayTotalPower("alph", nowStr);
|
List<UserPowerDto> userMhsList = poolMapper.getUserTodayTotalPower("alph", nowStr);
|
||||||
HashMap<String,BigDecimal> map = new HashMap<>();
|
HashMap<String,BigDecimal> map = new HashMap<>();
|
||||||
userMhsList.stream().forEach(e ->{
|
userMhsList.stream().forEach(e ->{
|
||||||
if(poolMhs != BigDecimal.ZERO){
|
if(poolMhs.compareTo(BigDecimal.ZERO) != 0){
|
||||||
map.put(e.getUser(),e.getMhs().divide(poolMhs,8, RoundingMode.HALF_UP));
|
map.put(e.getUser(),e.getMhs().divide(poolMhs,8, RoundingMode.HALF_UP));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -4323,4 +4323,441 @@ public class DataTask {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Scheduled(cron = "20 1,3,10,31,33,40 * * * ?")
|
||||||
|
public void MONERO30mDataToDB(){
|
||||||
|
//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);
|
||||||
|
now.setSeconds(0);
|
||||||
|
String nowStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, now);
|
||||||
|
|
||||||
|
System.out.println("MONERO 30分钟定时任务执行时间:"+now);
|
||||||
|
System.out.println("格式化后的时间:"+nowStr);
|
||||||
|
|
||||||
|
//检查二级表是否有当前时间数据
|
||||||
|
int count = poolMapper.getLastDataTime(Pools.MONERO.getMhs() + "30m", nowStr);
|
||||||
|
|
||||||
|
if(count == 0) {
|
||||||
|
List<MinerDataDto> list = poolMapper.getHourMinerDataList(Pools.MONERO.getMhs()+"_realv2",nowStr);
|
||||||
|
if(list.size() > 0){
|
||||||
|
List<MinerDataDto> offlineList = new ArrayList<>();
|
||||||
|
list.stream().forEach(e -> {
|
||||||
|
if(StringUtils.isNotNull(e.getMhs())){
|
||||||
|
e.setMhs(e.getMhs() * Pools.MONERO.getFac());
|
||||||
|
}
|
||||||
|
if("offline".equals(e.getState())){
|
||||||
|
offlineList.add(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
list = filterList(list,now);
|
||||||
|
|
||||||
|
boolean result = poolMapper.batchInsertMhsDataToDB(Pools.MONERO.getMhs() + "30m", getToHourDBListByMinerDataList(list));
|
||||||
|
|
||||||
|
Map<Date, List<MinerDataDto>> map = list.stream().collect(Collectors.groupingBy(MinerDataDto::getDate));
|
||||||
|
map.forEach((date,dList) -> {
|
||||||
|
PoolPower poolPower = new PoolPower();
|
||||||
|
//poolPower.setDate(date);
|
||||||
|
poolPower.setDateStr(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,date));
|
||||||
|
Map<String, Long> stateCount = dList.stream().collect(Collectors.groupingBy(MinerDataDto::getState, Collectors.counting()));
|
||||||
|
poolPower.setMhs(dList.stream().map(e -> BigDecimal.valueOf(e.getMhs())).reduce(BigDecimal::add).get().stripTrailingZeros());
|
||||||
|
poolPower.setMiners(dList.size());
|
||||||
|
poolPower.setOnline(Convert.toInt(stateCount.get("online"),0));
|
||||||
|
poolPower.setOffline(Convert.toInt(stateCount.get("offline"),0));
|
||||||
|
|
||||||
|
boolean poolResult = poolMapper.insertPoolPower(Pools.MONERO.getPoolTable() + "_30m", poolPower);
|
||||||
|
int time =0;
|
||||||
|
while (!poolResult){
|
||||||
|
poolResult = poolMapper.insertPoolPower(Pools.MONERO.getPoolTable() + "_30m", poolPower);
|
||||||
|
if (time > 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
time ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("构造写入user算力表数据");
|
||||||
|
Map<String, List<MinerDataDto>> userMap = dList.stream().collect(Collectors.groupingBy(MinerDataDto::getUser));
|
||||||
|
List<MinerDataInsertDBDto> userList = new ArrayList<>();
|
||||||
|
userMap.forEach((user,uList)->{
|
||||||
|
MinerDataInsertDBDto uDto = new MinerDataInsertDBDto();
|
||||||
|
uDto.setDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,date));
|
||||||
|
uDto.setUser(user);
|
||||||
|
uDto.setMhs(uList.stream().map(e->BigDecimal.valueOf(e.getMhs())).reduce(BigDecimal::add).get().doubleValue());
|
||||||
|
userList.add(uDto);
|
||||||
|
} );
|
||||||
|
System.out.println("user算力表入库数据条数:"+userList.size());
|
||||||
|
boolean userResult = poolMapper.batchInsertUserMhsDateToDB(Pools.MONERO.getName() + "_users_30m", userList);
|
||||||
|
int uTime =0;
|
||||||
|
while (!userResult){
|
||||||
|
userResult = poolMapper.batchInsertUserMhsDateToDB(Pools.MONERO.getName() + "_users_30m", userList);
|
||||||
|
if (uTime > 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
uTime ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, List<MinerDataDto>> userMap = list.stream().collect(Collectors.groupingBy(MinerDataDto::getMiner));
|
||||||
|
if (result) {
|
||||||
|
System.out.println(DateUtils.dateTimeNow() + "MONERO 小时数据存入数据成功");
|
||||||
|
} else {
|
||||||
|
System.out.println(DateUtils.dateTimeNow() + "MONERO 小时数据存入数据失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(offlineList.size() >0){
|
||||||
|
CompletableFuture.runAsync(()->{
|
||||||
|
|
||||||
|
//根据挖矿账户分组、统计离线矿机名单、离线矿机数
|
||||||
|
|
||||||
|
//对比redis中该挖矿账户上一次离线矿机数
|
||||||
|
//有redis数据 需要判断 上一次离线矿机数<本次矿机离线数 才执行通知 否则跳过
|
||||||
|
//无redis数据 说明是第一次 执行通知
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//重来一次!
|
||||||
|
CompletableFuture.runAsync(()->{
|
||||||
|
System.out.println("MONERO 30分钟定时任务执行失败 延时一分钟时间重新查询");
|
||||||
|
System.out.println("延迟后使用的查询时间:"+now);
|
||||||
|
System.out.println("延迟后 格式化后的时间:"+nowStr);
|
||||||
|
|
||||||
|
//检查二级表是否有当前时间数据
|
||||||
|
int newCount = poolMapper.getLastDataTime(Pools.MONERO.getMhs() + "30m", nowStr);
|
||||||
|
if(newCount == 0){
|
||||||
|
List<MinerDataDto> newList = poolMapper.getHourMinerDataList(Pools.MONERO.getMhs()+"_realv2",nowStr);
|
||||||
|
if(newList.size() > 0){
|
||||||
|
|
||||||
|
newList.stream().forEach(e -> {
|
||||||
|
if(StringUtils.isNotNull(e.getMhs())){
|
||||||
|
e.setMhs(e.getMhs() * Pools.MONERO.getFac());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
newList = filterList(newList,now);
|
||||||
|
|
||||||
|
boolean newResult = poolMapper.batchInsertMhsDataToDB(Pools.MONERO.getMhs() + "30m", getToHourDBListByMinerDataList(newList));
|
||||||
|
|
||||||
|
Map<Date, List<MinerDataDto>> map2 = newList.stream().collect(Collectors.groupingBy(MinerDataDto::getDate));
|
||||||
|
map2.forEach((date,dList) -> {
|
||||||
|
PoolPower poolPower = new PoolPower();
|
||||||
|
//poolPower.setDate(date);
|
||||||
|
poolPower.setDateStr(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,date));
|
||||||
|
Map<String, Long> stateCount = dList.stream().collect(Collectors.groupingBy(MinerDataDto::getState, Collectors.counting()));
|
||||||
|
poolPower.setMhs(dList.stream().map(e -> BigDecimal.valueOf(e.getMhs())).reduce(BigDecimal::add).get().stripTrailingZeros());
|
||||||
|
poolPower.setMiners(dList.size());
|
||||||
|
poolPower.setOnline(Convert.toInt(stateCount.get("online"),0));
|
||||||
|
poolPower.setOffline(Convert.toInt(stateCount.get("offline"),0));
|
||||||
|
|
||||||
|
boolean poolResult2 = poolMapper.insertPoolPower(Pools.MONERO.getPoolTable() + "_30m", poolPower);
|
||||||
|
int time =0;
|
||||||
|
while (!poolResult2){
|
||||||
|
poolResult2 = poolMapper.insertPoolPower(Pools.MONERO.getPoolTable() + "_30m", poolPower);
|
||||||
|
if (time > 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
time ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("延迟任务 构造写入user算力表数据");
|
||||||
|
Map<String, List<MinerDataDto>> userMap = dList.stream().collect(Collectors.groupingBy(MinerDataDto::getUser));
|
||||||
|
List<MinerDataInsertDBDto> userList = new ArrayList<>();
|
||||||
|
userMap.forEach((user,uList)->{
|
||||||
|
MinerDataInsertDBDto uDto = new MinerDataInsertDBDto();
|
||||||
|
uDto.setDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,date));
|
||||||
|
uDto.setUser(user);
|
||||||
|
uDto.setMhs(uList.stream().map(e->BigDecimal.valueOf(e.getMhs())).reduce(BigDecimal::add).get().doubleValue());
|
||||||
|
userList.add(uDto);
|
||||||
|
} );
|
||||||
|
System.out.println("延迟任务 user算力表入库数据条数:"+userList.size());
|
||||||
|
boolean userResult = poolMapper.batchInsertUserMhsDateToDB(Pools.MONERO.getName() + "_users_30m", userList);
|
||||||
|
int uTime =0;
|
||||||
|
while (!userResult){
|
||||||
|
userResult = poolMapper.batchInsertUserMhsDateToDB(Pools.MONERO.getName() + "_users_30m", userList);
|
||||||
|
if (uTime > 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
uTime ++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (newResult) {
|
||||||
|
System.out.println(DateUtils.dateTimeNow() + "MONERO 30m数据 延迟存入数据成功");
|
||||||
|
} else {
|
||||||
|
System.out.println(DateUtils.dateTimeNow() + "MONERO 30m数据 延迟存入数据失败");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 1,3,5 0 * * ?")
|
||||||
|
public void MONERODailyDataToDB(){
|
||||||
|
if(!enable){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String nowStr = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD);
|
||||||
|
Date now = DateUtils.parseDate( nowStr);
|
||||||
|
|
||||||
|
//检查二级表是否有当前时间数据
|
||||||
|
int count = poolMapper.getLastDataTime(Pools.MONERO.getMhs() + "24h", nowStr);
|
||||||
|
|
||||||
|
if(count == 0) {
|
||||||
|
List<MinerDataDto> list = poolMapper.getDailyMinerDataList(Pools.MONERO.getMhs()+"_realv2", nowStr);
|
||||||
|
if(list.size() > 0){
|
||||||
|
list.stream().forEach(e -> {
|
||||||
|
if(StringUtils.isNotNull(e.getMhs())){
|
||||||
|
e.setMhs(e.getMhs() * Pools.MONERO.getFac());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
list = filterList(list,now);
|
||||||
|
//list.stream().forEach(e ->{
|
||||||
|
// e.setDate(DateUtils.addDays(e.getDate(),-1));
|
||||||
|
//});
|
||||||
|
boolean result = poolMapper.batchInsertMhsDataToDB(Pools.MONERO.getMhs() + "24h", getToDailyDBListByMinerDataList(list));
|
||||||
|
//todo 统计矿池数据写入矿池数据库 $coin_pool_24h
|
||||||
|
Map<Date, List<MinerDataDto>> map = list.stream().collect(Collectors.groupingBy(MinerDataDto::getDate));
|
||||||
|
map.forEach((date,dList) -> {
|
||||||
|
PoolPower poolPower = new PoolPower();
|
||||||
|
//poolPower.setDate(date);
|
||||||
|
poolPower.setDateStr(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,date));
|
||||||
|
Map<String, Long> stateCount = dList.stream().collect(Collectors.groupingBy(MinerDataDto::getState, Collectors.counting()));
|
||||||
|
poolPower.setMhs(dList.stream().map(e -> BigDecimal.valueOf(e.getMhs())).reduce(BigDecimal::add).get().stripTrailingZeros());
|
||||||
|
poolPower.setMiners(dList.size());
|
||||||
|
poolPower.setOnline(Convert.toInt(stateCount.get("online"),0));
|
||||||
|
poolPower.setOffline(Convert.toInt(stateCount.get("offline"),0));
|
||||||
|
|
||||||
|
boolean poolResult = poolMapper.insertPoolPower(Pools.MONERO.getPoolTable() + "_24h", poolPower);
|
||||||
|
int time =0;
|
||||||
|
while (!poolResult){
|
||||||
|
poolResult = poolMapper.insertPoolPower(Pools.MONERO.getPoolTable() + "_24h", poolPower);
|
||||||
|
if (time > 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
time ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//写入数据到coin_users表中
|
||||||
|
Map<String, List<MinerDataDto>> userMap = dList.stream().collect(Collectors.groupingBy(MinerDataDto::getUser));
|
||||||
|
List<MinerDataInsertDBDto> userList = new ArrayList<>();
|
||||||
|
userMap.forEach((user,uList)->{
|
||||||
|
MinerDataInsertDBDto uDto = new MinerDataInsertDBDto();
|
||||||
|
uDto.setDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,date));
|
||||||
|
uDto.setUser(user);
|
||||||
|
uDto.setMhs(uList.stream().map(e->BigDecimal.valueOf(e.getMhs())).reduce(BigDecimal::add).get().doubleValue());
|
||||||
|
userList.add(uDto);
|
||||||
|
} );
|
||||||
|
|
||||||
|
boolean userResult = poolMapper.batchInsertUserMhsDateToDB(Pools.MONERO.getName() + "_users_24h", userList);
|
||||||
|
int uTime =0;
|
||||||
|
while (!userResult){
|
||||||
|
userResult = poolMapper.batchInsertUserMhsDateToDB(Pools.MONERO.getName() + "_users_24h", userList);
|
||||||
|
if (uTime > 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
uTime ++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(result){
|
||||||
|
System.out.println(DateUtils.dateTimeNow()+"MONERO 每日存入数据成功");
|
||||||
|
}else {
|
||||||
|
System.out.println(DateUtils.dateTimeNow()+"MONERO 每日存入数据失败");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
CompletableFuture.runAsync(()->{
|
||||||
|
System.out.println("MONERO 每日矿池定时任务执行失败 延时一分钟时间重新查询");
|
||||||
|
System.out.println("延迟后使用的查询时间:"+now);
|
||||||
|
System.out.println("延迟后 格式化后的时间:"+nowStr);
|
||||||
|
|
||||||
|
//检查二级表是否有当前时间数据
|
||||||
|
int newCount = poolMapper.getLastDataTime(Pools.MONERO.getMhs() + "24h", nowStr);
|
||||||
|
if(newCount == 0){
|
||||||
|
List<MinerDataDto> newList = poolMapper.getDailyMinerDataList(Pools.MONERO.getMhs()+"_realv2", nowStr);
|
||||||
|
if(newList.size() > 0){
|
||||||
|
|
||||||
|
newList.stream().forEach(e -> {
|
||||||
|
if(StringUtils.isNotNull(e.getMhs())){
|
||||||
|
e.setMhs(e.getMhs() * Pools.MONERO.getFac());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
newList = filterList(newList,now);
|
||||||
|
|
||||||
|
boolean newResult = poolMapper.batchInsertMhsDataToDB(Pools.MONERO.getMhs() + "24h", getToDailyDBListByMinerDataList(newList));
|
||||||
|
|
||||||
|
Map<Date, List<MinerDataDto>> map2 = newList.stream().collect(Collectors.groupingBy(MinerDataDto::getDate));
|
||||||
|
map2.forEach((date,dList) -> {
|
||||||
|
PoolPower poolPower = new PoolPower();
|
||||||
|
//poolPower.setDate(date);
|
||||||
|
poolPower.setDateStr(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,date));
|
||||||
|
Map<String, Long> stateCount = dList.stream().collect(Collectors.groupingBy(MinerDataDto::getState, Collectors.counting()));
|
||||||
|
poolPower.setMhs(dList.stream().map(e -> BigDecimal.valueOf(e.getMhs())).reduce(BigDecimal::add).get().stripTrailingZeros());
|
||||||
|
poolPower.setMiners(dList.size());
|
||||||
|
poolPower.setOnline(Convert.toInt(stateCount.get("online"),0));
|
||||||
|
poolPower.setOffline(Convert.toInt(stateCount.get("offline"),0));
|
||||||
|
|
||||||
|
boolean poolResult2 = poolMapper.insertPoolPower(Pools.MONERO.getPoolTable() + "_24h", poolPower);
|
||||||
|
int time =0;
|
||||||
|
while (!poolResult2){
|
||||||
|
poolResult2 = poolMapper.insertPoolPower(Pools.MONERO.getPoolTable() + "_24h", poolPower);
|
||||||
|
if (time > 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
time ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, List<MinerDataDto>> userMap = dList.stream().collect(Collectors.groupingBy(MinerDataDto::getUser));
|
||||||
|
List<MinerDataInsertDBDto> userList = new ArrayList<>();
|
||||||
|
userMap.forEach((user,uList)->{
|
||||||
|
MinerDataInsertDBDto uDto = new MinerDataInsertDBDto();
|
||||||
|
uDto.setDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,date));
|
||||||
|
uDto.setUser(user);
|
||||||
|
uDto.setMhs(uList.stream().map(e->BigDecimal.valueOf(e.getMhs())).reduce(BigDecimal::add).get().doubleValue());
|
||||||
|
userList.add(uDto);
|
||||||
|
} );
|
||||||
|
|
||||||
|
boolean userResult = poolMapper.batchInsertUserMhsDateToDB(Pools.MONERO.getName() + "_users_24h", userList);
|
||||||
|
int uTime =0;
|
||||||
|
while (!userResult){
|
||||||
|
userResult = poolMapper.batchInsertUserMhsDateToDB(Pools.MONERO.getName() + "_users_24h", userList);
|
||||||
|
if (uTime > 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
uTime ++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}else {
|
||||||
|
PoolPower poolPower = new PoolPower();
|
||||||
|
poolPower.setDate(now);
|
||||||
|
poolPower.setMhs(BigDecimal.ZERO);
|
||||||
|
poolPower.setMiners(0);
|
||||||
|
poolPower.setOnline(0);
|
||||||
|
poolPower.setOffline(0);
|
||||||
|
boolean poolResult = poolMapper.insertPoolPower(Pools.MONERO.getPoolTable() + "_24h", poolPower);
|
||||||
|
System.out.println("延时任务未查到 构造0数据入库,结果:"+poolPower);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "50 0,1,30,31 * * * ?")
|
||||||
|
public void MONEROUserPowerRatioDataToDB(){
|
||||||
|
//String nowStr = DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:00");
|
||||||
|
if(!enable){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Date now = new Date();
|
||||||
|
now.setHours(0);
|
||||||
|
now.setMinutes(0);
|
||||||
|
now.setSeconds(0);
|
||||||
|
String nowStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, now);
|
||||||
|
|
||||||
|
BigDecimal poolMhs = poolMapper.getPoolTodayTotalPower("monero", nowStr);
|
||||||
|
List<UserPowerDto> userMhsList = poolMapper.getUserTodayTotalPower("monero", nowStr);
|
||||||
|
HashMap<String,BigDecimal> map = new HashMap<>();
|
||||||
|
userMhsList.stream().forEach(e ->{
|
||||||
|
map.put(e.getUser(),e.getMhs().divide(poolMhs,8,BigDecimal.ROUND_HALF_UP));
|
||||||
|
});
|
||||||
|
|
||||||
|
if(map.size() >0){
|
||||||
|
redisService.deleteObject("NEXAUserPowerRatio");
|
||||||
|
redisService.setCacheMap("NEXAUserPowerRatio",map);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Scheduled(cron = "30 3 0/1 * * ?")
|
||||||
|
//@Scheduled(cron = "0 0/2 * * * ?")
|
||||||
|
public void MONEROLuckyDataToDB(){
|
||||||
|
if(!enable){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("MONERO 幸运值---定时任务开始");
|
||||||
|
LuckDto dto = new LuckDto();
|
||||||
|
Date end = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS));
|
||||||
|
//幸运值 = 矿池实际报块/矿池理论报块
|
||||||
|
//矿池实际报块 = distribution数据库查询表名为 币名_blkreportprofitv2
|
||||||
|
//矿池理论报块 = (矿池过去N段时间的平均算力 / 全网过去N段时间平均算力) * 全网过去N段时间实际报块
|
||||||
|
Date start3d = DateUtils.addDays(end,-3);
|
||||||
|
Date start7d = DateUtils.addDays(end,-7);
|
||||||
|
Date start30d = DateUtils.addDays(end,-30);
|
||||||
|
Date start90d = DateUtils.addDays(end,-90);
|
||||||
|
|
||||||
|
//获取全网实际90天内的报块数(v2)
|
||||||
|
List<BlockInfoDto> blockPerDays = poolMapper.selectNetBlock("monero_net_block");
|
||||||
|
boolean useAggregated = blockPerDays.get(blockPerDays.size()-1).getDate().before(start3d);
|
||||||
|
//获取3天内全网的实际报块数
|
||||||
|
BlockTimeAndNumberDto blockData = blockDataContext.getBlockData("monero",start3d, end,blockPerDays, useAggregated);
|
||||||
|
//3天矿池理论报块数
|
||||||
|
BigDecimal throreticalBlocks = getTheoreticalBlocks("monero",PoolUnits.MONERO.gethRate(),start3d, end, blockData);
|
||||||
|
//3天矿池实际报块数
|
||||||
|
int actualBlocks = poolMapper.selectPoolBlock(start3d, end,"monero",3);
|
||||||
|
log.info("monero 3天实际报块数{},理论报块数{},全网实际报块数{},开始时间{},结束时间{}",actualBlocks,throreticalBlocks,blockData.getHeight(),start3d,end);
|
||||||
|
//3天幸运值
|
||||||
|
if(!BigDecimal.ZERO.equals(throreticalBlocks)){
|
||||||
|
dto.setLuck3d(BigDecimal.valueOf(actualBlocks).multiply(BigDecimal.valueOf(100)).divide(throreticalBlocks,2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
}
|
||||||
|
//7天幸运值
|
||||||
|
useAggregated = blockPerDays.get(blockPerDays.size()-1).getDate().before(start7d);
|
||||||
|
|
||||||
|
blockData = blockDataContext.getBlockData("monero",start7d, end,blockPerDays, useAggregated);
|
||||||
|
throreticalBlocks= getTheoreticalBlocks("monero",PoolUnits.MONERO.gethRate(),start7d, end, blockData);
|
||||||
|
actualBlocks = poolMapper.selectPoolBlock(start7d, end,"monero",7);
|
||||||
|
log.info("monero 7天实际报块数{},理论报块数{}",actualBlocks,throreticalBlocks);
|
||||||
|
if(!BigDecimal.ZERO.equals(throreticalBlocks)){
|
||||||
|
dto.setLuck7d(BigDecimal.valueOf(actualBlocks).multiply(BigDecimal.valueOf(100)).divide(throreticalBlocks,2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
//30天幸运值
|
||||||
|
useAggregated = blockPerDays.get(blockPerDays.size()-1).getDate().before(start30d);
|
||||||
|
|
||||||
|
blockData = blockDataContext.getBlockData("monero",start30d, end,blockPerDays, useAggregated);
|
||||||
|
throreticalBlocks= getTheoreticalBlocks("monero",PoolUnits.MONERO.gethRate(),start30d, end, blockData);
|
||||||
|
actualBlocks = poolMapper.selectPoolBlock(start30d, end,"monero",30);
|
||||||
|
log.info("monero 30天实际报块数{},理论报块数{}",actualBlocks,throreticalBlocks);
|
||||||
|
if(!BigDecimal.ZERO.equals(throreticalBlocks)){
|
||||||
|
dto.setLuck30d(BigDecimal.valueOf(actualBlocks).multiply(BigDecimal.valueOf(100)).divide(throreticalBlocks,2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
//90天幸运值
|
||||||
|
useAggregated = blockPerDays.get(blockPerDays.size()-1).getDate().before(start90d);
|
||||||
|
|
||||||
|
blockData = blockDataContext.getBlockData("monero",start90d, end,blockPerDays, useAggregated);
|
||||||
|
throreticalBlocks= getTheoreticalBlocks("monero",PoolUnits.MONERO.gethRate(),start90d, end, blockData);
|
||||||
|
actualBlocks = poolMapper.selectPoolBlock(start90d, end,"monero",90);
|
||||||
|
log.info("monero 90天实际报块数{},理论报块数{}",actualBlocks,throreticalBlocks);
|
||||||
|
if(!BigDecimal.ZERO.equals(throreticalBlocks)){
|
||||||
|
dto.setLuck90d(BigDecimal.valueOf(actualBlocks).multiply(BigDecimal.valueOf(100)).divide(throreticalBlocks,2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
redisService.deleteObject("MONEROLuck");
|
||||||
|
redisService.setCacheObject("NMONEROLuck",dto);
|
||||||
|
log.info("monero幸运值入库完成---幸运值3天:{},幸运值7天:{},幸运值30天:{},幸运值90天:{},",
|
||||||
|
dto.getLuck3d(),dto.getLuck7d(),dto.getLuck30d(),dto.getLuck90d());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -698,6 +698,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
`date` = VALUES(`date`)
|
`date` = VALUES(`date`)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<select id="selectPrice" resultType="java.math.BigDecimal">
|
||||||
|
select
|
||||||
|
`value`
|
||||||
|
from
|
||||||
|
${coin}_price
|
||||||
|
order by id desc
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="batchInsertNexaPoolBlkToDB">
|
<insert id="batchInsertNexaPoolBlkToDB">
|
||||||
insert into nexa_pool_blkstats (
|
insert into nexa_pool_blkstats (
|
||||||
`date`,
|
`date`,
|
||||||
|
|
Loading…
Reference in New Issue