update 工单,通知相关接口调试修改
This commit is contained in:
@@ -117,7 +117,7 @@ public class TicketController extends BaseController {
|
||||
@PostMapping("/bk/getAllTicket")
|
||||
@ApiOperation(value = "条件搜索后台所有工单列表")
|
||||
@RequiresLogin
|
||||
@RequiresRoles("admin")
|
||||
@RequiresRoles("back_admin")
|
||||
public TableDataInfo getAllTicket(@RequestBody AllTicketListVo vo){
|
||||
System.out.println("com.m2pool.chat.vo"+vo);
|
||||
if(StringUtils.isNotBlank(vo.getCond())){
|
||||
@@ -147,7 +147,7 @@ public class TicketController extends BaseController {
|
||||
@PostMapping("/bk/endTicket")
|
||||
@ApiOperation(value = "关闭用户工单")
|
||||
@RequiresLogin
|
||||
@RequiresRoles(value = {"admin"}, logical = Logical.OR)
|
||||
@RequiresRoles(value = {"back_admin"}, logical = Logical.OR)
|
||||
public AjaxResult endUserTicket(@RequestBody(required = false) IdVo vo){
|
||||
|
||||
return ticketService.closeTicket(vo);
|
||||
@@ -157,7 +157,7 @@ public class TicketController extends BaseController {
|
||||
@PostMapping("/bk/list")
|
||||
@ApiOperation(value = "根据状态获取type为线上(type=0)的工单")
|
||||
@RequiresLogin
|
||||
@RequiresRoles(value = {"admin"}, logical = Logical.OR)
|
||||
@RequiresRoles(value = {"back_admin"}, logical = Logical.OR)
|
||||
public TableDataInfo onlineTicketList(@RequestBody StatusVo vo){
|
||||
|
||||
PageHelper.startPage(vo.getPage(),vo.getLimit());
|
||||
@@ -168,7 +168,7 @@ public class TicketController extends BaseController {
|
||||
@PostMapping("/bk/details")
|
||||
@ApiOperation(value = "工单详情")
|
||||
@RequiresLogin
|
||||
@RequiresRoles(value = {"admin"}, logical = Logical.OR)
|
||||
@RequiresRoles(value = {"back_admin"}, logical = Logical.OR)
|
||||
public AjaxResult onlineTicketDetails(@RequestBody IdVo vo){
|
||||
if(StringUtils.isNull(vo)){
|
||||
return AjaxResult.error("工单id缺失");
|
||||
@@ -179,7 +179,7 @@ public class TicketController extends BaseController {
|
||||
@PostMapping("/bk/respon")
|
||||
@ApiOperation(value = "回复工单")
|
||||
@RequiresLogin
|
||||
@RequiresRoles(value = {"admin"}, logical = Logical.OR)
|
||||
@RequiresRoles(value = {"back_admin"}, logical = Logical.OR)
|
||||
public AjaxResult onlineResponTicket(@RequestBody ResponTicketVo vo){
|
||||
return ticketService.onlineResponTicket(vo);
|
||||
}
|
||||
|
||||
@@ -25,4 +25,9 @@ public class PowerLineDto implements Serializable {
|
||||
|
||||
private double price;
|
||||
|
||||
/**
|
||||
* 算力单位
|
||||
*/
|
||||
private String unit;
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -151,15 +152,14 @@ public class PoolServiceImpl implements PoolService {
|
||||
if("1h".equals(vo.getInterval()) || "rt".equals(vo.getInterval())){
|
||||
//30m
|
||||
PageHelper.clearPage();
|
||||
//矿池算力从$coin_pool_30m拿
|
||||
//矿池算力从$coin_pool_30m拿 获取的 算力单位为MH/S
|
||||
List<PowerLineDto> list = poolMapper.get30mPoolPowerList(pool.getPoolTable()+"_30m");
|
||||
Collections.reverse(list);
|
||||
|
||||
//根据币种做参数处理
|
||||
list.stream().forEach(e -> {
|
||||
//MH/s 每秒转GH/s
|
||||
e.setPv(e.getPv().divide(BigDecimal.valueOf(1000),scale,BigDecimal.ROUND_HALF_UP).stripTrailingZeros());
|
||||
});
|
||||
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.stream().forEach(e -> priceList.stream().anyMatch(p ->{
|
||||
if(p.getDate().equals(e.getDate())){
|
||||
@@ -177,10 +177,11 @@ public class PoolServiceImpl implements PoolService {
|
||||
|
||||
//根据币种做参数处理
|
||||
list.stream().forEach(e -> {
|
||||
//MH/s 每秒转GH/s
|
||||
e.setDate(DateUtils.addDays(e.getDate(),-1));
|
||||
e.setPv(e.getPv().divide(BigDecimal.valueOf(1000),scale,BigDecimal.ROUND_HALF_UP).stripTrailingZeros());
|
||||
});
|
||||
//根据币种做参数处理
|
||||
|
||||
|
||||
|
||||
List<MinerDataDto> lastList = poolMapper.getMinerInfoList(pool.getMhs());
|
||||
BigDecimal mhs = lastList.stream().map(e -> {
|
||||
@@ -189,9 +190,12 @@ public class PoolServiceImpl implements PoolService {
|
||||
PowerLineDto lastPLDto= new PowerLineDto();
|
||||
Date now = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD));
|
||||
lastPLDto.setDate(now);
|
||||
lastPLDto.setPv(mhs.divide(BigDecimal.valueOf(1000),scale,BigDecimal.ROUND_HALF_UP).stripTrailingZeros());
|
||||
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 -> {
|
||||
@@ -351,28 +355,23 @@ public class PoolServiceImpl implements PoolService {
|
||||
return AjaxResult.error("缺失参数:interval");
|
||||
}
|
||||
|
||||
int scale = PoolProfitScale.getScaleByCoin(pool.getCoin());
|
||||
List<PowerLineDto> list = poolMapper.getHourNetPowerList(pool.getCoin());
|
||||
//根据币种做参数处理
|
||||
list.stream().forEach(e -> {
|
||||
//H/s 每秒转GH/s
|
||||
if(StringUtils.isNotNull(e.getPv())){
|
||||
if("alph".equals(pool.getCoin())){
|
||||
//alph 数据库按MH/s存的
|
||||
e.setPv(e.getPv().divide(BigDecimal.valueOf(1000),scale,BigDecimal.ROUND_HALF_UP).stripTrailingZeros());
|
||||
}else {
|
||||
e.setPv(e.getPv().divide(BigDecimal.valueOf(1000000000),scale,BigDecimal.ROUND_HALF_UP).stripTrailingZeros());
|
||||
}
|
||||
}else {
|
||||
e.setPv(BigDecimal.valueOf(0));
|
||||
}
|
||||
|
||||
});
|
||||
List<PowerLineDto> list = poolMapper.getHourNetPowerList(pool.getCoin());
|
||||
|
||||
if("1h".equals(vo.getInterval()) || "rt".equals(vo.getInterval())){
|
||||
PageHelper.clearPage();
|
||||
//30m数据 限制条数为最近1天的条数 即1*48=48
|
||||
list = list.stream().sorted(Comparator.comparing(PowerLineDto::getDate, Comparator.reverseOrder())).limit(48).collect(Collectors.toList());
|
||||
PowerLineDto maxPv = list.stream().max(Comparator.comparing(PowerLineDto::getPv)).orElse(new PowerLineDto());
|
||||
//if("alph".equals(pool.getCoin())){
|
||||
// //alph 数据库按MH/s存的
|
||||
// PowerUnitUtils.NetPowerUnit powerUnit = PowerUnitUtils.getPowerUnit(maxPv.getPv().multiply(BigDecimal.valueOf(1000)));
|
||||
// list = changeUnit(powerUnit, list, pool,BigDecimal.valueOf(1000));
|
||||
//}else{
|
||||
//
|
||||
//}
|
||||
PowerUnitUtils.NetPowerUnit powerUnit = PowerUnitUtils.getPowerUnit(maxPv.getPv());
|
||||
list = changeUnit(powerUnit, list, pool,BigDecimal.valueOf(1));
|
||||
Collections.reverse(list);
|
||||
return AjaxResult.success(list);
|
||||
}else if ("1d".equals(vo.getInterval())){
|
||||
@@ -383,12 +382,44 @@ public class PoolServiceImpl implements PoolService {
|
||||
list = list.stream().sorted(Comparator.comparing(PowerLineDto::getDate, Comparator.reverseOrder())).limit(30).collect(Collectors.toList());
|
||||
Collections.reverse(list);
|
||||
}
|
||||
PowerLineDto maxPv = list.stream().max(Comparator.comparing(PowerLineDto::getPv)).orElse(new PowerLineDto());
|
||||
//if("alph".equals(pool.getCoin())){
|
||||
// //alph 数据库按MH/s存的
|
||||
// PowerUnitUtils.NetPowerUnit powerUnit = PowerUnitUtils.getPowerUnit(maxPv.getPv().multiply(BigDecimal.valueOf(1000)));
|
||||
// list = changeUnit(powerUnit, list, pool,BigDecimal.valueOf(1000));
|
||||
//}else{
|
||||
//
|
||||
//}
|
||||
PowerUnitUtils.NetPowerUnit powerUnit = PowerUnitUtils.getPowerUnit(maxPv.getPv());
|
||||
list = changeUnit(powerUnit, list, pool,BigDecimal.valueOf(1));
|
||||
return AjaxResult.success(list);
|
||||
}else {
|
||||
return AjaxResult.error("参数错误:interval");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 算力值单位换算
|
||||
* @param netPowerUnit 需要换算的单位 和值
|
||||
* @param list 需要换算的列表
|
||||
* @param pool 币种类型
|
||||
* @param factor 用于把初始power换算为H/S
|
||||
* @return
|
||||
*/
|
||||
private List<PowerLineDto> changeUnit(PowerUnitUtils.NetPowerUnit netPowerUnit, List<PowerLineDto> list, Pools pool,BigDecimal factor) {
|
||||
int scale = PoolProfitScale.getScaleByCoin(pool.getCoin());
|
||||
list.forEach(e -> {
|
||||
if(StringUtils.isNotNull(e.getPv())){
|
||||
e.setUnit(netPowerUnit.getUnit());
|
||||
e.setPv(e.getPv().multiply(factor).divide(netPowerUnit.getUnitValue(),scale, RoundingMode.HALF_UP).stripTrailingZeros());
|
||||
}else {
|
||||
e.setUnit(netPowerUnit.getUnit());
|
||||
e.setPv(BigDecimal.valueOf(0));
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getParam(CoinVo vo) {
|
||||
Pools pool = (Pools) EnumUtils.get(Pools.class, vo.getCoin());
|
||||
|
||||
@@ -238,10 +238,11 @@ public class NodeRpc{
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] params = {nowHeight,"2"};
|
||||
String[] params = {};
|
||||
Object[] statsParams = {Convert.toLong(nowHeight)};
|
||||
String result = getResult(coin, "getmininginfo", params);
|
||||
String result2 = getResultTest(coin, "getblockstats", statsParams);
|
||||
System.out.println("yyb-全网算力nexa"+result);
|
||||
BlockInfo blockInfo = new BlockInfo();
|
||||
|
||||
if(StringUtils.isBlank(result)){
|
||||
@@ -276,6 +277,7 @@ public class NodeRpc{
|
||||
|
||||
}
|
||||
BigDecimal netPower = jsonObject.getBigDecimal("networkhashps");
|
||||
System.out.println("yyb-全网算力nexa"+netPower);
|
||||
if (StringUtils.isNotNull(netPower)){
|
||||
blockInfo.setPower(netPower);
|
||||
}
|
||||
@@ -285,7 +287,7 @@ public class NodeRpc{
|
||||
// return null;
|
||||
//}
|
||||
//System.out.println(txs);
|
||||
final double[] reward = {0};
|
||||
//final double[] reward = {0};
|
||||
final double[] fees = {0};
|
||||
//txs.iterator().forEachRemaining(e -> {
|
||||
// JSONObject json = (JSONObject) e;
|
||||
@@ -351,29 +353,36 @@ public class NodeRpc{
|
||||
String result = getResultTest(coin, "getblockheader", params);
|
||||
|
||||
|
||||
String[] params1 = {};
|
||||
String result1 = getResult(coin, "getmininginfo", params1);
|
||||
|
||||
if(StringUtils.isBlank(result)){
|
||||
|
||||
if(StringUtils.isBlank(result) || StringUtils.isBlank(result1)){
|
||||
System.out.println("查询结果为空");
|
||||
return blockInfo;
|
||||
}
|
||||
|
||||
if(result.contains("error:")){
|
||||
if(result.contains("error:") || result1.contains("error:")){
|
||||
System.out.println("包含错误:"+result);
|
||||
return blockInfo;
|
||||
}
|
||||
|
||||
JSONObject jsonObject = JSON.parseObject(result);
|
||||
JSONObject jsonObject1 = JSON.parseObject(result1);
|
||||
BigDecimal netPower = jsonObject1.getBigDecimal("networkhashps");
|
||||
System.out.println("yyb-全网算力grs"+netPower);
|
||||
long height = jsonObject.getLongValue("height");
|
||||
blockInfo.setHeight(height);
|
||||
|
||||
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
|
||||
if(StringUtils.isNotNull(difficulty)){
|
||||
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
||||
BigDecimal factor = constant.getFactor();
|
||||
if(StringUtils.isNotNull(factor)){
|
||||
blockInfo.setPower(difficulty.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
||||
//BigDecimal factor = constant.getFactor();
|
||||
//if(StringUtils.isNotNull(factor)){
|
||||
// blockInfo.setPower(difficulty.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
//}
|
||||
blockInfo.setPower(netPower);
|
||||
|
||||
}
|
||||
|
||||
@@ -424,32 +433,37 @@ public class NodeRpc{
|
||||
Object[] params = {blockhash};
|
||||
|
||||
String result = getResultTest(coin, "getblockheader", params);
|
||||
System.out.println("result"+result);
|
||||
String[] params1 = {};
|
||||
String result1 = getResult(coin, "getmininginfo", params1);
|
||||
|
||||
|
||||
|
||||
if(StringUtils.isBlank(result)){
|
||||
if(StringUtils.isBlank(result) || StringUtils.isBlank(result1)){
|
||||
System.out.println("查询结果为空");
|
||||
return blockInfo;
|
||||
}
|
||||
|
||||
if(result.contains("error:")){
|
||||
if(result.contains("error:") || result1.contains("error:")){
|
||||
System.out.println("包含错误:"+result);
|
||||
return blockInfo;
|
||||
}
|
||||
|
||||
JSONObject jsonObject = JSON.parseObject(result);
|
||||
JSONObject jsonObject1 = JSON.parseObject(result1);
|
||||
long height = jsonObject.getLongValue("height");
|
||||
blockInfo.setHeight(height);
|
||||
|
||||
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
|
||||
BigDecimal netPower = jsonObject1.getBigDecimal("networkhashps");
|
||||
System.out.println("yyb-全网算力mona"+netPower);
|
||||
if(StringUtils.isNotNull(difficulty)){
|
||||
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
||||
BigDecimal factor = constant.getFactor();
|
||||
if(StringUtils.isNotNull(factor)){
|
||||
blockInfo.setPower(difficulty.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
||||
//BigDecimal factor = constant.getFactor();
|
||||
//if(StringUtils.isNotNull(factor)){
|
||||
// blockInfo.setPower(difficulty.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
//}
|
||||
blockInfo.setPower(netPower);
|
||||
|
||||
}
|
||||
|
||||
@@ -500,32 +514,36 @@ public class NodeRpc{
|
||||
Object[] params = {blockhash};
|
||||
|
||||
String result = getResultTest(coin, "getblockheader", params);
|
||||
System.out.println("result"+result);
|
||||
String[] params1 = {};
|
||||
String result1 = getResult(coin, "getmininginfo", params1);
|
||||
|
||||
|
||||
|
||||
if(StringUtils.isBlank(result)){
|
||||
if(StringUtils.isBlank(result) || StringUtils.isBlank(result1)){
|
||||
System.out.println("查询结果为空");
|
||||
return blockInfo;
|
||||
}
|
||||
|
||||
if(result.contains("error:")){
|
||||
if(result.contains("error:") || result1.contains("error:")){
|
||||
System.out.println("包含错误:"+result);
|
||||
return blockInfo;
|
||||
}
|
||||
|
||||
JSONObject jsonObject = JSON.parseObject(result);
|
||||
JSONObject jsonObject1 = JSON.parseObject(result1);
|
||||
long height = jsonObject.getLongValue("height");
|
||||
blockInfo.setHeight(height);
|
||||
|
||||
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
|
||||
BigDecimal netPower = jsonObject1.getBigDecimal("networkhashps");
|
||||
System.out.println("yyb-全网算力rxd"+netPower);
|
||||
if(StringUtils.isNotNull(difficulty)){
|
||||
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
||||
BigDecimal factor = constant.getFactor();
|
||||
if(StringUtils.isNotNull(factor)){
|
||||
blockInfo.setPower(difficulty.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
||||
//BigDecimal factor = constant.getFactor();
|
||||
//if(StringUtils.isNotNull(factor)){
|
||||
// blockInfo.setPower(difficulty.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
//}
|
||||
blockInfo.setPower(netPower);
|
||||
|
||||
}
|
||||
|
||||
@@ -787,6 +805,7 @@ public class NodeRpc{
|
||||
//todo 调用getblockstats 拿subsidy/100000000做reward fees设置为0、拿blockhash
|
||||
Object[] statsParams = {Convert.toLong(nowHeight)};
|
||||
String blockstats = getResultTest(coin, "getblockstats", statsParams);
|
||||
|
||||
if(StringUtils.isBlank(blockstats)){
|
||||
System.out.println("blockstats查询结果为空");
|
||||
return null;
|
||||
@@ -807,9 +826,11 @@ public class NodeRpc{
|
||||
System.out.println(subsidy);
|
||||
Object[] params = {};
|
||||
|
||||
String result = getResultTest(coin, "getblockchaininfo", params);
|
||||
System.out.println("result"+result);
|
||||
//替换掉
|
||||
//String result = getResultTest(coin, "getblockchaininfo", params);
|
||||
|
||||
String[] params1 = {};
|
||||
String result = getResult(coin, "getmininginfo", params1);
|
||||
|
||||
|
||||
if(StringUtils.isBlank(result)){
|
||||
@@ -823,13 +844,16 @@ public class NodeRpc{
|
||||
}
|
||||
|
||||
JSONObject jsonObject = JSON.parseObject(result);
|
||||
//难度
|
||||
JSONObject difficulties = jsonObject.getJSONObject("difficulties");
|
||||
if(StringUtils.isNull(difficulties)){
|
||||
//全网算力
|
||||
JSONObject networkhashesps = jsonObject.getJSONObject("networkhashesps");
|
||||
if(StringUtils.isNull(difficulties) || StringUtils.isNull(networkhashesps)){
|
||||
System.out.println("查询结果为空");
|
||||
return null;
|
||||
}
|
||||
System.out.println("difficulties:"+difficulties);
|
||||
BigDecimal sDiff = difficulties.getBigDecimal("skein");
|
||||
BigDecimal sNetwork = networkhashesps.getBigDecimal("skein");
|
||||
if(StringUtils.isNotNull(sDiff)){
|
||||
BlockInfo sBlockInfo = new BlockInfo();
|
||||
sBlockInfo.setHeight(Convert.toLong(nowHeight,20237944L));
|
||||
@@ -837,15 +861,17 @@ public class NodeRpc{
|
||||
sBlockInfo.setFees(BigDecimal.ZERO);
|
||||
sBlockInfo.setProfit(sBlockInfo.getReward().subtract(sBlockInfo.getFees()));
|
||||
sBlockInfo.setDifficulty(sDiff.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, "dgbs");
|
||||
BigDecimal factor = constant.getFactor();
|
||||
if(StringUtils.isNotNull(factor)){
|
||||
sBlockInfo.setPower(sDiff.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, "dgbs");
|
||||
//BigDecimal factor = constant.getFactor();
|
||||
//if(StringUtils.isNotNull(factor)){
|
||||
// sBlockInfo.setPower(sDiff.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
//}
|
||||
sBlockInfo.setPower(sNetwork);
|
||||
map.put("dgbs",sBlockInfo);
|
||||
}
|
||||
|
||||
BigDecimal oDiff = difficulties.getBigDecimal("odo");
|
||||
BigDecimal oNetwork = networkhashesps.getBigDecimal("odo");
|
||||
if(StringUtils.isNotNull(oDiff)){
|
||||
BlockInfo oBlockInfo = new BlockInfo();
|
||||
oBlockInfo.setHeight(Convert.toLong(nowHeight,20237944L));
|
||||
@@ -853,15 +879,17 @@ public class NodeRpc{
|
||||
oBlockInfo.setFees(BigDecimal.ZERO);
|
||||
oBlockInfo.setProfit(oBlockInfo.getReward().subtract(oBlockInfo.getFees()));
|
||||
oBlockInfo.setDifficulty(oDiff.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, "dgbo");
|
||||
BigDecimal factor = constant.getFactor();
|
||||
if(StringUtils.isNotNull(factor)){
|
||||
oBlockInfo.setPower(oDiff.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, "dgbo");
|
||||
//BigDecimal factor = constant.getFactor();
|
||||
//if(StringUtils.isNotNull(factor)){
|
||||
// oBlockInfo.setPower(oDiff.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
//}
|
||||
oBlockInfo.setPower(oNetwork);
|
||||
map.put("dgbo",oBlockInfo);
|
||||
}
|
||||
|
||||
BigDecimal qDiff = difficulties.getBigDecimal("qubit");
|
||||
BigDecimal qNetwork = networkhashesps.getBigDecimal("qubit");
|
||||
if(StringUtils.isNotNull(qDiff)){
|
||||
BlockInfo qBlockInfo = new BlockInfo();
|
||||
qBlockInfo.setHeight(Convert.toLong(nowHeight,20237944L));
|
||||
@@ -869,16 +897,15 @@ public class NodeRpc{
|
||||
qBlockInfo.setFees(BigDecimal.ZERO);
|
||||
qBlockInfo.setProfit(qBlockInfo.getReward().subtract(qBlockInfo.getFees()));
|
||||
qBlockInfo.setDifficulty(qDiff.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, "dgbq");
|
||||
BigDecimal factor = constant.getFactor();
|
||||
if(StringUtils.isNotNull(factor)){
|
||||
qBlockInfo.setPower(qDiff.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, "dgbq");
|
||||
//BigDecimal factor = constant.getFactor();
|
||||
//if(StringUtils.isNotNull(factor)){
|
||||
// qBlockInfo.setPower(qDiff.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
//}
|
||||
qBlockInfo.setPower(qNetwork);
|
||||
map.put("dgbq",qBlockInfo);
|
||||
}
|
||||
|
||||
System.out.println("map:"+map);
|
||||
|
||||
System.out.println("存储的数据"+map);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.m2pool.pool.utils;
|
||||
|
||||
import com.m2pool.common.core.utils.StringUtils;
|
||||
import com.m2pool.pool.enums.PoolProfitScale;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
/**
|
||||
* @Description 算力转换
|
||||
@@ -79,4 +81,61 @@ public class PowerUnitUtils {
|
||||
return value.setScale(2,BigDecimal.ROUND_HALF_UP).toEngineeringString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个算力值 对应应该换算的单位 和单位符号值
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static NetPowerUnit getPowerUnit(BigDecimal value){
|
||||
NetPowerUnit unit = new NetPowerUnit();
|
||||
//默认1K 以下
|
||||
unit.setUnit("H/s");
|
||||
unit.setUnitValue(BigDecimal.valueOf(1));
|
||||
if (value != null){
|
||||
//ps BigDecimal最大上限少于1000*1000*1000*1000*10 所以需要中间值 gValue
|
||||
BigDecimal gValue = value.divide(BigDecimal.valueOf(1000000000), 2, RoundingMode.HALF_UP);
|
||||
if (gValue.compareTo(BigDecimal.valueOf(1000L *1000*1000*10)) >= 0){
|
||||
//10E
|
||||
unit.setUnit("EH/s");
|
||||
unit.setUnitValue(BigDecimal.valueOf(1000L*1000*1000*1000*1000*1000));
|
||||
}
|
||||
else if (gValue.compareTo(BigDecimal.valueOf(1000*1000*10)) >= 0){
|
||||
//10P -10E
|
||||
|
||||
unit.setUnit("PH/s");
|
||||
unit.setUnitValue(BigDecimal.valueOf(1000L*1000*1000*1000*1000));
|
||||
}
|
||||
else if (gValue.compareTo(BigDecimal.valueOf(1000 * 10)) >= 0){
|
||||
//10 T - 10P
|
||||
unit.setUnit("TH/s");
|
||||
unit.setUnitValue(BigDecimal.valueOf(1000L*1000*1000*1000));
|
||||
}
|
||||
else if (value.compareTo(BigDecimal.valueOf(1000L *1000*1000 * 10)) >= 0){
|
||||
//10G - 10T
|
||||
unit.setUnit("GH/s");
|
||||
unit.setUnitValue(BigDecimal.valueOf(1000L*1000*1000));
|
||||
}
|
||||
else if (value.compareTo(BigDecimal.valueOf(1000*1000*10)) >= 0){
|
||||
//10M - 10G
|
||||
unit.setUnit("MH/s");
|
||||
unit.setUnitValue(BigDecimal.valueOf(1000L*1000));
|
||||
}
|
||||
else if (value.compareTo(BigDecimal.valueOf(1000 * 10)) >= 0){
|
||||
//10K-10M
|
||||
unit.setUnit("KH/s");
|
||||
unit.setUnitValue(BigDecimal.valueOf(1000));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return unit;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class NetPowerUnit{
|
||||
private String unit;
|
||||
private BigDecimal unitValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
spring:
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: test
|
||||
active: prod
|
||||
|
||||
Reference in New Issue
Block a user