update 新增后台管理系统文档管理模块,以及业务系统帮助中心文档接口。修改首页折线图补零逻辑bug,及管理系统挖矿账户详情页,收支详情修改
This commit is contained in:
@@ -15,7 +15,7 @@ public class ScheduledTaskConfig implements SchedulingConfigurer {
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
||||
taskScheduler.setPoolSize(20);
|
||||
taskScheduler.setPoolSize(8);
|
||||
taskScheduler.initialize();
|
||||
taskRegistrar.setTaskScheduler(taskScheduler);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.m2pool.pool.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
@@ -12,6 +14,8 @@ import java.util.Date;
|
||||
* @Author dy
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PowerLineDto implements Serializable {
|
||||
|
||||
/** 日期 */
|
||||
|
||||
@@ -31,9 +31,9 @@ public interface PoolMapper {
|
||||
@HashRateDB
|
||||
public Double getNowPoolPower(@Param("table") String table);
|
||||
|
||||
public List<PowerLineDto> get30mPoolPowerList(@Param("table") String table);
|
||||
public List<PowerLineDto> get30mPoolPowerList(@Param("table") String table,@Param("startDate") Date startDate,@Param("endDate") Date endDate);
|
||||
|
||||
public List<PowerLineDto> getDailyPoolPowerList(@Param("table") String table);
|
||||
public List<PowerLineDto> getDailyPoolPowerList(@Param("table") String table,@Param("startDate") Date startDate,@Param("endDate") Date endDate);
|
||||
|
||||
public List<PowerLineDto> getHourNetPowerList(@Param("table") String table);
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -134,6 +137,41 @@ public class PoolServiceImpl implements PoolService {
|
||||
return AjaxResult.success(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据补零 30分钟时间端
|
||||
* @param dataList
|
||||
* @return
|
||||
*/
|
||||
public static List<PowerLineDto> fillMissingOnlineData(List<PowerLineDto> dataList,Date startTime,Date endTime,String unit,int interval) {
|
||||
|
||||
List<PowerLineDto> resultList = new ArrayList<>();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
|
||||
calendar.setTime(startTime);
|
||||
Map<Long, PowerLineDto> timeDataMap = new HashMap<>();
|
||||
for (PowerLineDto data : dataList) {
|
||||
timeDataMap.put(data.getDate().getTime(), data);
|
||||
}
|
||||
|
||||
while (calendar.getTime().getTime() <= endTime.getTime()) {
|
||||
long currentTime = calendar.getTime().getTime();
|
||||
PowerLineDto data = timeDataMap.get(currentTime);
|
||||
if (data != null) {
|
||||
resultList.add(data);
|
||||
} else {
|
||||
if (calendar.getTime().getTime() != endTime.getTime()){
|
||||
resultList.add(new PowerLineDto(calendar.getTime(),BigDecimal.valueOf(0), BigDecimal.valueOf(0),0,unit));
|
||||
}
|
||||
}
|
||||
// 增加 30 分钟
|
||||
calendar.add(Calendar.MINUTE, interval);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AjaxResult getPoolPower(CoinVo vo) {
|
||||
|
||||
@@ -150,18 +188,29 @@ public class PoolServiceImpl implements PoolService {
|
||||
|
||||
int scale = PoolProfitScale.getScaleByCoin(pool.getCoin());
|
||||
|
||||
|
||||
if("1h".equals(vo.getInterval()) || "rt".equals(vo.getInterval())){
|
||||
// 获取当前日期
|
||||
Date currentDate = DateUtils.getPreviousHalfHourOrFullHour(new Date());
|
||||
// 获取一天前的日期时间
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(currentDate);
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
Date oneDayAgo = calendar.getTime();
|
||||
//30m
|
||||
PageHelper.clearPage();
|
||||
//矿池算力从$coin_pool_30m拿 获取的 算力单位为MH/S
|
||||
List<PowerLineDto> list = poolMapper.get30mPoolPowerList(pool.getPoolTable()+"_30m");
|
||||
Collections.reverse(list);
|
||||
List<PowerLineDto> list = poolMapper.get30mPoolPowerList(pool.getPoolTable()+"_30m",oneDayAgo,currentDate);
|
||||
|
||||
//根据币种做参数处理
|
||||
PowerLineDto maxPv = list.stream().max(Comparator.comparing(PowerLineDto::getPv)).orElse(new PowerLineDto());
|
||||
PowerUnitUtils.NetPowerUnit powerUnit = PowerUnitUtils.getPowerUnit(maxPv.getPv().multiply(BigDecimal.valueOf(1000 * 1000)));
|
||||
list = changeUnit(powerUnit, list, pool,BigDecimal.valueOf(1000 * 1000));
|
||||
|
||||
//数据补零
|
||||
list = fillMissingOnlineData(list,oneDayAgo,currentDate,powerUnit.getUnit(),30);
|
||||
|
||||
//通过全网算力接口 获取到的时间段价格补充到矿池算力接口的价格中
|
||||
list.stream().forEach(e -> priceList.stream().anyMatch(p ->{
|
||||
if(p.getDate().equals(e.getDate())){
|
||||
e.setPrice(p.getPrice());
|
||||
@@ -171,19 +220,23 @@ public class PoolServiceImpl implements PoolService {
|
||||
|
||||
return AjaxResult.success(list);
|
||||
}else if ("1d".equals(vo.getInterval())){
|
||||
|
||||
//获取当天零点时间
|
||||
LocalDateTime todayStart = LocalDate.now().atStartOfDay();
|
||||
Date currentDate = Date.from(todayStart.atZone(ZoneId.systemDefault()).toInstant());
|
||||
// 获取一个月前的日期
|
||||
Date oneMonthAgo = DateUtils.getOneMonthAgo(currentDate);
|
||||
PageHelper.clearPage();
|
||||
//矿池算力从$coin_pool_1d拿
|
||||
List<PowerLineDto> list = poolMapper.getDailyPoolPowerList(pool.getPoolTable()+"_24h");
|
||||
Collections.reverse(list);
|
||||
List<PowerLineDto> list = poolMapper.getDailyPoolPowerList(pool.getPoolTable()+"_24h",oneMonthAgo,currentDate);
|
||||
|
||||
//根据币种做参数处理
|
||||
list.stream().forEach(e -> {
|
||||
e.setDate(DateUtils.addDays(e.getDate(),-1));
|
||||
});
|
||||
//根据币种做参数处理
|
||||
|
||||
|
||||
|
||||
//从hashRate库中获取最后一天数据用作当天实时24h算力
|
||||
List<MinerDataDto> lastList = poolMapper.getMinerInfoList(pool.getMhs());
|
||||
BigDecimal mhs = lastList.stream().map(e -> {
|
||||
return BigDecimal.valueOf(e.getMhs24h());
|
||||
@@ -193,22 +246,12 @@ public class PoolServiceImpl implements PoolService {
|
||||
lastPLDto.setDate(now);
|
||||
lastPLDto.setPv(mhs);
|
||||
list.add(lastPLDto);
|
||||
|
||||
//根据集合中最大算力一个对象转换的后单位,把集合中所有元素都转换成该单位
|
||||
PowerLineDto maxPv = list.stream().max(Comparator.comparing(PowerLineDto::getPv)).orElse(new PowerLineDto());
|
||||
PowerUnitUtils.NetPowerUnit powerUnit = PowerUnitUtils.getPowerUnit(maxPv.getPv() .multiply(BigDecimal.valueOf(1000 * 1000)));
|
||||
list = changeUnit(powerUnit, list, pool,BigDecimal.valueOf(1000 * 1000));
|
||||
//todo 最后一天数据用当天实时24h算力
|
||||
//List<MinerDataDto> lastList = poolMapper.getMinerInfoList(pool.getMhs());
|
||||
//BigDecimal mhs = lastList.stream().map(e -> {
|
||||
// return BigDecimal.valueOf(e.getMhs24h());
|
||||
//}).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
//
|
||||
//PowerLineDto lastPLDto= new PowerLineDto();
|
||||
//Date now = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD));
|
||||
//lastPLDto.setDate(now);
|
||||
//lastPLDto.setPv(mhs);
|
||||
//list.add(lastPLDto);
|
||||
|
||||
list = fillMissingOnlineData(list,oneMonthAgo,currentDate,powerUnit.getUnit(),24*60);
|
||||
list.stream().forEach(e -> priceList.stream().anyMatch(p ->{
|
||||
if(p.getDate().equals(e.getDate())){
|
||||
e.setPrice(p.getPrice());
|
||||
|
||||
@@ -41,5 +41,7 @@ public class SocketDemo {
|
||||
Date endDate = DateUtils.getPreviousHalfHourOrFullHour(new Date());
|
||||
Date startDate = DateUtils.getOneMonthAgo(endDate);
|
||||
System.out.println(startDate+" "+endDate);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,22 +15,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by `date` desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="get30mPoolPowerList" resultType="com.m2pool.pool.dto.PowerLineDto" statementType="STATEMENT">
|
||||
<select id="get30mPoolPowerList" resultType="com.m2pool.pool.dto.PowerLineDto">
|
||||
select
|
||||
`date`,
|
||||
mhs pv
|
||||
mhs as pv
|
||||
from
|
||||
${table}
|
||||
order by `date` desc limit 48
|
||||
where
|
||||
`date` >= #{startDate} AND `date` <![CDATA[ <= ]]> #{endDate}
|
||||
order by `date`
|
||||
</select>
|
||||
|
||||
<select id="getDailyPoolPowerList" resultType="com.m2pool.pool.dto.PowerLineDto" statementType="STATEMENT">
|
||||
<select id="getDailyPoolPowerList" resultType="com.m2pool.pool.dto.PowerLineDto" >
|
||||
select
|
||||
`date`,
|
||||
mhs pv
|
||||
mhs as pv
|
||||
from
|
||||
${table}
|
||||
order by `date` desc limit 30
|
||||
where
|
||||
`date` >= #{startDate} AND `date` <![CDATA[ <= ]]> #{endDate}
|
||||
order by `date`
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user