update 新增一个查询所有矿工账号对应币种,的一段时间内的算力总和
This commit is contained in:
parent
b6b26e591f
commit
6b72064d5c
|
@ -183,6 +183,12 @@ public class PoolController extends BaseController {
|
|||
|
||||
}
|
||||
|
||||
@PostMapping("/getMinerPowerFor30min")
|
||||
@ApiOperation(value = "根据矿工账号从hashrate库获取30m的平均算力")
|
||||
public AjaxResult getMinerPowerFor30min(@RequestBody MinerMhsVo minerMhsVo){
|
||||
return poolService.getMinerPowerFor30min(minerMhsVo);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/test2")
|
||||
@ApiOperation(value = "")
|
||||
|
@ -200,4 +206,6 @@ public class PoolController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.m2pool.pool.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description 矿工对应的平均算力返回对象
|
||||
* @Date 2025/05/26 15:17
|
||||
* @Author yyb
|
||||
*/
|
||||
@Data
|
||||
public class MinerMhsDto implements Serializable {
|
||||
|
||||
/** 日期 */
|
||||
private Date date;
|
||||
|
||||
/**
|
||||
* 矿工账号
|
||||
*/
|
||||
private String user;
|
||||
|
||||
|
||||
private BigDecimal mhs30m;
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ import com.m2pool.pool.vo.DateValueVo;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -217,4 +218,13 @@ public interface PoolMapper {
|
|||
*/
|
||||
DateBigDecimalDto getAvgPowerForNet(@Param("coin") String coin, @Param("start")Date start, @Param("end")Date end);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param coin
|
||||
* @param startTime
|
||||
* @return
|
||||
*/
|
||||
@HashRateDB
|
||||
List<MinerMhsDto> getMinerPowerFor30min(@Param("coin") String coin, @Param("startTime") LocalDateTime startTime,@Param("endTime") LocalDateTime endTime);
|
||||
}
|
||||
|
|
|
@ -39,4 +39,11 @@ public interface PoolService {
|
|||
|
||||
public AjaxResult test1();
|
||||
|
||||
|
||||
/**
|
||||
* 根据矿工账号获取30m的平均算力
|
||||
* @param minerMhsVo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getMinerPowerFor30min( MinerMhsVo minerMhsVo);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.m2pool.pool.utils.PowerUnitUtils;
|
|||
import com.m2pool.pool.vo.BalanceListGetVo;
|
||||
import com.m2pool.pool.vo.CoinVo;
|
||||
import com.m2pool.pool.vo.MinerAccountAddVo;
|
||||
import com.m2pool.pool.vo.MinerMhsVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -605,4 +606,15 @@ public class PoolServiceImpl implements PoolService {
|
|||
|
||||
return returnList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AjaxResult getMinerPowerFor30min(MinerMhsVo minerMhsVo) {
|
||||
if (StringUtils.isNull(minerMhsVo.getCoin()) || StringUtils.isNull(minerMhsVo.getStartTime()) || StringUtils.isNull(minerMhsVo.getEndTime())){
|
||||
return AjaxResult.error("币种或开始日期或结束日期参数未传递");
|
||||
}
|
||||
List<MinerMhsDto> minerPowerFor30min = poolMapper.getMinerPowerFor30min(minerMhsVo.getCoin(), minerMhsVo.getStartTime(), minerMhsVo.getEndTime());
|
||||
|
||||
return AjaxResult.success(minerPowerFor30min);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.m2pool.pool.vo;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 矿工算力请求对象
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(description = "矿工算力请求对象")
|
||||
public class MinerMhsVo {
|
||||
@ApiModelProperty(value = "币种", example = "dgbo")
|
||||
public String coin;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "开始时间", example = "2025-05-20 01:00:00")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "结束时间", example = "2025-05-26 01:00:00")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
}
|
||||
|
|
@ -898,6 +898,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="getAvgPowerForNet" resultType="com.m2pool.pool.dto.DateBigDecimalDto">
|
||||
select avg(`value`) `value` from ${coin}_net_power where `date` >= #{start} and `date` <![CDATA[ <= ]]> #{end}
|
||||
</select>
|
||||
<select id="getMinerPowerFor30min" resultType="com.m2pool.pool.dto.MinerMhsDto">
|
||||
select `date`,`user`,sum(mhs30m) mhs30m from ${coin}_mhsv2 where `date` >= #{startTime} and `date` <![CDATA[ <= ]]> #{endTime}
|
||||
group by `date`,`user`
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
|
Loading…
Reference in New Issue