update 工单,通知相关接口调试修改
This commit is contained in:
parent
315079e5d1
commit
0b2decafc9
|
@ -1,3 +1,3 @@
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: test
|
active: prod
|
||||||
|
|
|
@ -215,6 +215,7 @@ public class AuthLogic {
|
||||||
{
|
{
|
||||||
if (requiresRoles.logical() == Logical.AND)
|
if (requiresRoles.logical() == Logical.AND)
|
||||||
{
|
{
|
||||||
|
|
||||||
checkRoleAnd(requiresRoles.value());
|
checkRoleAnd(requiresRoles.value());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -248,6 +249,8 @@ public class AuthLogic {
|
||||||
public void checkRoleOr(String... roles)
|
public void checkRoleOr(String... roles)
|
||||||
{
|
{
|
||||||
Set<String> roleList = getRoleList();
|
Set<String> roleList = getRoleList();
|
||||||
|
System.out.println("从token获取的role"+roleList +"需要的权限"+roles);
|
||||||
|
|
||||||
for (String role : roles)
|
for (String role : roles)
|
||||||
{
|
{
|
||||||
if (hasRole(roleList, role))
|
if (hasRole(roleList, role))
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: test
|
active: prod
|
||||||
|
|
|
@ -31,4 +31,11 @@ public interface ChatMessageMapper extends BaseMapper<ChatMessage> {
|
||||||
@MapKey("userEmail")
|
@MapKey("userEmail")
|
||||||
Map<String, Map<String,Integer>> findUnReadNums(@Param("userEmails") List<String> userEmails);
|
Map<String, Map<String,Integer>> findUnReadNums(@Param("userEmails") List<String> userEmails);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询当前客服参与过的所有聊天室
|
||||||
|
* @param userEmail
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Long> findRoomIdsByCustomerEmail(@Param("userEmail") String userEmail);
|
||||||
}
|
}
|
|
@ -16,10 +16,10 @@ public interface ChatRoomMapper extends BaseMapper<ChatRoom> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询客服的聊天室列表
|
* 查询客服的聊天室列表
|
||||||
* @param userEmail 客服邮箱
|
* @param ids 要查询的聊天室集合
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<ChatRoomDto> findRoomList(@Param("userEmail") String userEmail, @Param("sendDateTime") LocalDateTime sendDateTime);
|
List<ChatRoomDto> findRoomList(@Param("ids") List<Long> ids, @Param("sendDateTime") LocalDateTime sendDateTime);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.m2pool.chat.service.impl;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.m2pool.chat.config.CustomWebSocketConfig;
|
||||||
import com.m2pool.chat.dto.ChatRoomDto;
|
import com.m2pool.chat.dto.ChatRoomDto;
|
||||||
import com.m2pool.chat.entity.ChatRoom;
|
import com.m2pool.chat.entity.ChatRoom;
|
||||||
import com.m2pool.chat.mapper.ChatMessageMapper;
|
import com.m2pool.chat.mapper.ChatMessageMapper;
|
||||||
|
@ -26,8 +27,11 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ChatRoomServiceImpl extends ServiceImpl<ChatRoomMapper, ChatRoom> implements ChatRoomService {
|
public class ChatRoomServiceImpl extends ServiceImpl<ChatRoomMapper, ChatRoom> implements ChatRoomService {
|
||||||
|
@ -44,15 +48,21 @@ public class ChatRoomServiceImpl extends ServiceImpl<ChatRoomMapper, ChatRoom> i
|
||||||
@Autowired
|
@Autowired
|
||||||
private SimpUserRegistry userRegistry;
|
private SimpUserRegistry userRegistry;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CustomWebSocketConfig webSocketConfig;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<ChatRoomDto> findRoomList(RoomPageVo roomPageVo) {
|
public TableDataInfo<ChatRoomDto> findRoomList(RoomPageVo roomPageVo) {
|
||||||
String userEmail = SecurityUtils.getUsername();
|
String userEmail = SecurityUtils.getUsername();
|
||||||
PageHelper.startPage(1, 20);
|
List<Long> ids = chatMessageMapper.findRoomIdsByCustomerEmail(userEmail);
|
||||||
|
List<ChatRoomDto> roomList = new ArrayList<>();
|
||||||
|
if (ids.isEmpty()){
|
||||||
|
return getDataTable(roomList);
|
||||||
|
}
|
||||||
//1.查找当前客服对应的聊天室
|
//1.查找当前客服对应的聊天室
|
||||||
List<ChatRoomDto> roomList = chatRoomMapper.findRoomList(userEmail,roomPageVo.getSendDateTime());
|
roomList = chatRoomMapper.findRoomList(ids,roomPageVo.getSendDateTime());
|
||||||
|
|
||||||
|
|
||||||
PageUtils.clearPage();
|
|
||||||
// if (roomList.isEmpty()){
|
// if (roomList.isEmpty()){
|
||||||
// TableDataInfo tableDataInfo = new TableDataInfo();
|
// TableDataInfo tableDataInfo = new TableDataInfo();
|
||||||
// tableDataInfo.setCode(HttpStatus.ERROR);
|
// tableDataInfo.setCode(HttpStatus.ERROR);
|
||||||
|
@ -73,40 +83,69 @@ public class ChatRoomServiceImpl extends ServiceImpl<ChatRoomMapper, ChatRoom> i
|
||||||
rspData.setTotalPage(pageInfo.getPages());
|
rspData.setTotalPage(pageInfo.getPages());
|
||||||
return rspData;
|
return rspData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String EMAIL_REGEX = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,}$";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public R<ChatRoomDto> findRoomByUserid(RoomVo roomVo) {
|
public R<ChatRoomDto> findRoomByUserid(RoomVo roomVo) {
|
||||||
|
Random random = new Random();
|
||||||
//1.查询当前用户与对应用户是否已存在创建的聊天室
|
//1.查询当前用户与对应用户是否已存在创建的聊天室
|
||||||
String userEmail = roomVo.getEmail();
|
String userEmail = roomVo.getEmail();
|
||||||
ChatRoomDto roomByUserEmail = chatRoomMapper.findRoomByUserEmail(userEmail);
|
ChatRoomDto roomByUserEmail = chatRoomMapper.findRoomByUserEmail(userEmail);
|
||||||
|
//获取nacos中配置的客服邮箱列表,这个列表中的邮箱实际可能不是客服角色,但能够行驶客服角色功能
|
||||||
|
List<String> customerEmails = new ArrayList<>(Arrays.asList(webSocketConfig.getDefaultCustomerEmail().split(",")));
|
||||||
|
int i = random.nextInt(customerEmails.size());
|
||||||
|
String email = customerEmails.get(i);
|
||||||
|
customerEmails.removeIf(email1 -> !checkOnline(email1));
|
||||||
|
System.out.println("bby-在线的客服"+customerEmails + "初始化分配的客服"+email+"聊天室信息"+roomByUserEmail);
|
||||||
if(roomByUserEmail != null){
|
if(roomByUserEmail != null){
|
||||||
if (checkOnline(roomByUserEmail.getUserEmail())) {
|
//1.1 客服在线,并且在客服列表
|
||||||
|
if (checkOnline(roomByUserEmail.getUserEmail()) && customerEmails.contains(roomByUserEmail.getUserEmail())) {
|
||||||
roomByUserEmail.setCustomerIsOnline(true);
|
roomByUserEmail.setCustomerIsOnline(true);
|
||||||
} else{
|
}
|
||||||
|
// 1.2客服账号不在担任客服角色,选择使用nacos默认配置中的客服角色,并修改数据库中的聊天室信息为新的客服角色。
|
||||||
|
if(!customerEmails.contains(roomByUserEmail.getUserEmail())){
|
||||||
roomByUserEmail.setCustomerIsOnline(false);
|
roomByUserEmail.setCustomerIsOnline(false);
|
||||||
|
if (!customerEmails.isEmpty()){
|
||||||
|
email = customerEmails.get(random.nextInt(customerEmails.size()));
|
||||||
|
roomByUserEmail.setUserEmail(email);
|
||||||
|
roomByUserEmail.setCustomerIsOnline(true);
|
||||||
|
}
|
||||||
|
chatRoomMapper.updateById(ChatRoom.builder().id(roomByUserEmail.getId()).userTwoEmail(email).build());
|
||||||
|
}
|
||||||
|
// 1.3客服不在线,不在线情况如果从nacos配置中获取到多个客服,选择一个在线的客服发送。
|
||||||
|
if (!checkOnline(roomByUserEmail.getUserEmail())){
|
||||||
|
roomByUserEmail.setCustomerIsOnline(false);
|
||||||
|
if (!customerEmails.isEmpty()){
|
||||||
|
roomByUserEmail.setCustomerIsOnline(true);
|
||||||
|
email = customerEmails.get(random.nextInt(customerEmails.size()));
|
||||||
|
roomByUserEmail.setUserEmail(email);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return R.success(roomByUserEmail);
|
return R.success(roomByUserEmail);
|
||||||
}
|
}
|
||||||
|
|
||||||
//2.不存在创建一个聊天室
|
//2.不存在创建一个聊天室
|
||||||
List<SysUser> data = remoteUserService.getCSList().getData();
|
List<SysUser> data = remoteUserService.getCSList().getData();
|
||||||
if(Collections.isEmpty(data)){
|
List<String> emails = data.stream().map(SysUser::getEmail).collect(Collectors.toList());
|
||||||
return R.fail("客服人数不足");
|
emails.removeIf(email1 -> !checkOnline(email1));
|
||||||
|
//如果当前没有客服角色账号,使用nacos 默认配置中的客服角色
|
||||||
|
if(Collections.isEmpty(emails)){
|
||||||
|
emails = customerEmails;
|
||||||
|
// 自己不能创建
|
||||||
|
if(emails.contains( userEmail)){
|
||||||
|
return R.fail("您作为管理员无法创建与自己的连接");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Random random = new Random();
|
|
||||||
SysUser sysUser = data.get(random.nextInt(data.size()));
|
|
||||||
data.removeIf(datum -> !checkOnline(datum.getEmail()));
|
|
||||||
boolean customerIsOnline = false;
|
boolean customerIsOnline = false;
|
||||||
if (!data.isEmpty()){
|
|
||||||
sysUser = data.get(random.nextInt(data.size()));
|
//有在线客服,再次分配给在线的客服
|
||||||
|
if (!emails.isEmpty()){
|
||||||
customerIsOnline = true;
|
customerIsOnline = true;
|
||||||
|
email = emails.get(random.nextInt(emails.size()));
|
||||||
|
System.out.println("bby-最终分配的在线客服"+email);
|
||||||
}
|
}
|
||||||
ChatRoom build = ChatRoom.builder()
|
ChatRoom build = ChatRoom.builder()
|
||||||
.userOneEmail(userEmail)
|
.userOneEmail(userEmail)
|
||||||
.userTwoEmail(sysUser.getEmail())
|
.userTwoEmail(email)
|
||||||
.build();
|
.build();
|
||||||
int insert = chatRoomMapper.insert(build);
|
int insert = chatRoomMapper.insert(build);
|
||||||
if (insert > 0){
|
if (insert > 0){
|
||||||
|
@ -128,6 +167,7 @@ public class ChatRoomServiceImpl extends ServiceImpl<ChatRoomMapper, ChatRoom> i
|
||||||
.anyMatch(user -> user.getName().equals(email));
|
.anyMatch(user -> user.getName().equals(email));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<String> updateRoom(CharRoomVo charRoomVo) {
|
public R<String> updateRoom(CharRoomVo charRoomVo) {
|
||||||
int i = chatRoomMapper.updateById(ChatRoom.builder().id(charRoomVo.getId()).flag(charRoomVo.getFlag()).build());
|
int i = chatRoomMapper.updateById(ChatRoom.builder().id(charRoomVo.getId()).flag(charRoomVo.getFlag()).build());
|
||||||
|
|
|
@ -94,7 +94,6 @@ public class StompServiceImpl implements StompService {
|
||||||
.eq(ChatRoom::getUserOneEmail, principal.getName())
|
.eq(ChatRoom::getUserOneEmail, principal.getName())
|
||||||
.eq(ChatRoom::getUserTwoEmail, userMessageVo.getEmail()));
|
.eq(ChatRoom::getUserTwoEmail, userMessageVo.getEmail()));
|
||||||
build.setRoomId(userMessageVo.getRoomId());
|
build.setRoomId(userMessageVo.getRoomId());
|
||||||
System.out.println("发送消息,聊天室id"+userMessageVo.getRoomId()+"发送者邮箱"+principal.getName()+"接受者邮箱"+userMessageVo.getEmail());
|
|
||||||
int serviceReadNum = chatRoom != null ? chatRoom.getServiceReadNum() : 0;
|
int serviceReadNum = chatRoom != null ? chatRoom.getServiceReadNum() : 0;
|
||||||
build.setClientReadNum(serviceReadNum + 1);
|
build.setClientReadNum(serviceReadNum + 1);
|
||||||
|
|
||||||
|
@ -230,9 +229,12 @@ public class StompServiceImpl implements StompService {
|
||||||
public void customerCloseRoom(String userName){
|
public void customerCloseRoom(String userName){
|
||||||
//目前配置只配置了一个客服,如果多个关闭消息,需同时发送多个客服
|
//目前配置只配置了一个客服,如果多个关闭消息,需同时发送多个客服
|
||||||
System.out.println("当前配置的客服"+webSocketConfig.getDefaultCustomerEmail());
|
System.out.println("当前配置的客服"+webSocketConfig.getDefaultCustomerEmail());
|
||||||
|
String[] split = webSocketConfig.getDefaultCustomerEmail().split(",");
|
||||||
|
for (String email : split) {
|
||||||
messagingTemplate.convertAndSendToUser(
|
messagingTemplate.convertAndSendToUser(
|
||||||
webSocketConfig.getDefaultCustomerEmail(),
|
email,
|
||||||
Destination.QUEUE_CLOSE_ROOM + webSocketConfig.getDefaultCustomerEmail(),userName);
|
Destination.QUEUE_CLOSE_ROOM + email, userName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: test
|
active: prod
|
||||||
|
|
|
@ -33,5 +33,12 @@
|
||||||
AND is_read = false
|
AND is_read = false
|
||||||
GROUP BY send_email
|
GROUP BY send_email
|
||||||
</select>
|
</select>
|
||||||
|
<select id="findRoomIdsByCustomerEmail" resultType="java.lang.Long">
|
||||||
|
select room_id from chat_message where send_email = #{userEmail} group by room_id
|
||||||
|
UNION
|
||||||
|
select room_id from chat_message_history where send_email = #{userEmail} group by room_id
|
||||||
|
UNION
|
||||||
|
select id as room_id from chat_room where user_two_email = #{userEmail}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -13,8 +13,15 @@
|
||||||
FROM
|
FROM
|
||||||
chat_room
|
chat_room
|
||||||
<where>
|
<where>
|
||||||
user_two_email = #{userEmail} AND del = false
|
del = false
|
||||||
<choose>
|
<choose>
|
||||||
|
<when test="ids != null and ids.size() > 0">
|
||||||
|
AND id IN
|
||||||
|
<foreach item="id" index="index" collection="ids"
|
||||||
|
open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
<when test="sendDateTime != null">
|
<when test="sendDateTime != null">
|
||||||
AND last_user_send_time <![CDATA[ <= ]]> #{sendDateTime}
|
AND last_user_send_time <![CDATA[ <= ]]> #{sendDateTime}
|
||||||
</when>
|
</when>
|
||||||
|
@ -22,11 +29,11 @@
|
||||||
AND last_user_send_time <![CDATA[ <= ]]> NOW()
|
AND last_user_send_time <![CDATA[ <= ]]> NOW()
|
||||||
</otherwise>
|
</otherwise>
|
||||||
</choose>
|
</choose>
|
||||||
|
|
||||||
</where>
|
</where>
|
||||||
ORDER BY
|
ORDER BY
|
||||||
flag DESC,
|
flag DESC,
|
||||||
GREATEST( last_user_send_time, last_customer_send_time ) DESC
|
GREATEST( last_user_send_time, last_customer_send_time ) DESC
|
||||||
|
LIMIT 20
|
||||||
</select>
|
</select>
|
||||||
<select id="findRoomByUserEmail" resultType="com.m2pool.chat.dto.ChatRoomDto">
|
<select id="findRoomByUserEmail" resultType="com.m2pool.chat.dto.ChatRoomDto">
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
@ -3,7 +3,9 @@ package com.m2pool.manage.controller;
|
||||||
import com.m2pool.common.core.Result.R;
|
import com.m2pool.common.core.Result.R;
|
||||||
import com.m2pool.common.core.utils.PageUtils;
|
import com.m2pool.common.core.utils.PageUtils;
|
||||||
import com.m2pool.common.core.web.page.TableDataInfo;
|
import com.m2pool.common.core.web.page.TableDataInfo;
|
||||||
|
import com.m2pool.common.security.annotation.Logical;
|
||||||
import com.m2pool.common.security.annotation.RequiresLogin;
|
import com.m2pool.common.security.annotation.RequiresLogin;
|
||||||
|
import com.m2pool.common.security.annotation.RequiresRoles;
|
||||||
import com.m2pool.manage.dto.ManageBroadcastDto;
|
import com.m2pool.manage.dto.ManageBroadcastDto;
|
||||||
import com.m2pool.manage.service.ManageBroadcastService;
|
import com.m2pool.manage.service.ManageBroadcastService;
|
||||||
import com.m2pool.manage.vo.ManageBaseVo;
|
import com.m2pool.manage.vo.ManageBaseVo;
|
||||||
|
@ -35,19 +37,22 @@ public class ManageBroadcastController {
|
||||||
@PostMapping("/get/list/by/page")
|
@PostMapping("/get/list/by/page")
|
||||||
@ApiOperation(value = "管理系统:分页查询所有广播信息")
|
@ApiOperation(value = "管理系统:分页查询所有广播信息")
|
||||||
@RequiresLogin
|
@RequiresLogin
|
||||||
|
@RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
|
||||||
public TableDataInfo<ManageBroadcastDto> getListDataByPage(@RequestBody PageVo pageVo){
|
public TableDataInfo<ManageBroadcastDto> getListDataByPage(@RequestBody PageVo pageVo){
|
||||||
return manageBroadcastService.getListDataByPage(pageVo);
|
return manageBroadcastService.getListDataByPage(pageVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/find/data/by/id")
|
@PostMapping("/find/data/by/id")
|
||||||
@ApiOperation(value = "业务系统:用于获取m2pool广播数据")
|
@ApiOperation(value = "业务系统:用于获取m2pool广播数据")
|
||||||
public R<List<ManageBroadcastDto>> findDataById(@RequestBody ManageBaseVo manageBaseVo){
|
|
||||||
|
public R<List<ManageBroadcastDto>> findDataById(@RequestBody(required = false) ManageBaseVo manageBaseVo){
|
||||||
return manageBroadcastService.findDataById(manageBaseVo);
|
return manageBroadcastService.findDataById(manageBaseVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ApiOperation(value = "管理系统:新增广播")
|
@ApiOperation(value = "管理系统:新增广播")
|
||||||
@RequiresLogin
|
@RequiresLogin
|
||||||
|
@RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
|
||||||
public R<String> add(@RequestBody ManageBroadcastVo broadcastVo){
|
public R<String> add(@RequestBody ManageBroadcastVo broadcastVo){
|
||||||
return manageBroadcastService.addBroadcast(broadcastVo);
|
return manageBroadcastService.addBroadcast(broadcastVo);
|
||||||
}
|
}
|
||||||
|
@ -55,6 +60,7 @@ public class ManageBroadcastController {
|
||||||
@PostMapping("/delete")
|
@PostMapping("/delete")
|
||||||
@ApiOperation(value = "管理系统:删除广播")
|
@ApiOperation(value = "管理系统:删除广播")
|
||||||
@RequiresLogin
|
@RequiresLogin
|
||||||
|
@RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
|
||||||
public R<String> delete(@RequestBody ManageBaseVo manageBaseVo){
|
public R<String> delete(@RequestBody ManageBaseVo manageBaseVo){
|
||||||
return manageBroadcastService.deleteBroadcastById(manageBaseVo.getId());
|
return manageBroadcastService.deleteBroadcastById(manageBaseVo.getId());
|
||||||
}
|
}
|
||||||
|
@ -62,9 +68,17 @@ public class ManageBroadcastController {
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
@ApiOperation(value = "管理系统:修改广播")
|
@ApiOperation(value = "管理系统:修改广播")
|
||||||
@RequiresLogin
|
@RequiresLogin
|
||||||
|
@RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
|
||||||
public R<String> update(@RequestBody ManageBroadcastVo broadcastVo){
|
public R<String> update(@RequestBody ManageBroadcastVo broadcastVo){
|
||||||
return manageBroadcastService.updateBroadcast(broadcastVo);
|
return manageBroadcastService.updateBroadcast(broadcastVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/find/data/info")
|
||||||
|
@ApiOperation(value = "管理系统:用于获取通知详情")
|
||||||
|
@RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
|
||||||
|
public R<ManageBroadcastDto> findDataInfo(@RequestBody ManageBaseVo manageBaseVo){
|
||||||
|
return manageBroadcastService.findDataInfo(manageBaseVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@ package com.m2pool.manage.controller;
|
||||||
|
|
||||||
import com.m2pool.common.core.Result.R;
|
import com.m2pool.common.core.Result.R;
|
||||||
import com.m2pool.common.core.web.page.TableDataInfo;
|
import com.m2pool.common.core.web.page.TableDataInfo;
|
||||||
|
import com.m2pool.common.security.annotation.Logical;
|
||||||
import com.m2pool.common.security.annotation.RequiresLogin;
|
import com.m2pool.common.security.annotation.RequiresLogin;
|
||||||
|
import com.m2pool.common.security.annotation.RequiresRoles;
|
||||||
import com.m2pool.manage.dto.ManageBroadcastDto;
|
import com.m2pool.manage.dto.ManageBroadcastDto;
|
||||||
import com.m2pool.manage.dto.ManageUserDto;
|
import com.m2pool.manage.dto.ManageUserDto;
|
||||||
import com.m2pool.manage.dto.ManageUserInfoDto;
|
import com.m2pool.manage.dto.ManageUserInfoDto;
|
||||||
|
@ -33,6 +35,7 @@ public class ManageUserController {
|
||||||
@PostMapping("/list/info")
|
@PostMapping("/list/info")
|
||||||
@ApiOperation(value = "管理系统:查询注册用户信息列表,包括邮箱、挖矿账号、起付额、挖矿账户状态")
|
@ApiOperation(value = "管理系统:查询注册用户信息列表,包括邮箱、挖矿账号、起付额、挖矿账户状态")
|
||||||
@RequiresLogin
|
@RequiresLogin
|
||||||
|
@RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
|
||||||
public TableDataInfo<ManageUserDto> listInfo(@RequestBody ManageUserVo manageUserVo){
|
public TableDataInfo<ManageUserDto> listInfo(@RequestBody ManageUserVo manageUserVo){
|
||||||
return manageUserService.listInfo(manageUserVo);
|
return manageUserService.listInfo(manageUserVo);
|
||||||
}
|
}
|
||||||
|
@ -41,6 +44,7 @@ public class ManageUserController {
|
||||||
@PostMapping("/send/text/mail/message")
|
@PostMapping("/send/text/mail/message")
|
||||||
@ApiOperation(value = "管理系统:发送邮件给某些用户")
|
@ApiOperation(value = "管理系统:发送邮件给某些用户")
|
||||||
@RequiresLogin
|
@RequiresLogin
|
||||||
|
@RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
|
||||||
public void sendTextMailMessage(@RequestBody EmailVo emailVo){
|
public void sendTextMailMessage(@RequestBody EmailVo emailVo){
|
||||||
manageUserService.sendTextMailMessage(emailVo.getTo(),emailVo.getSubject(),emailVo.getText());
|
manageUserService.sendTextMailMessage(emailVo.getTo(),emailVo.getSubject(),emailVo.getText());
|
||||||
}
|
}
|
||||||
|
@ -48,6 +52,7 @@ public class ManageUserController {
|
||||||
@PostMapping("/get/user/info")
|
@PostMapping("/get/user/info")
|
||||||
@ApiOperation(value = "管理系统:挖矿账户所有收益金额、时间、状态、转账地址")
|
@ApiOperation(value = "管理系统:挖矿账户所有收益金额、时间、状态、转账地址")
|
||||||
@RequiresLogin
|
@RequiresLogin
|
||||||
|
@RequiresRoles(value = {"back_admin","admin"}, logical = Logical.OR)
|
||||||
public R<ManageUserInfoDto> getUserInfo(@RequestBody ManageUserInfoVo manageUserInfoVo){
|
public R<ManageUserInfoDto> getUserInfo(@RequestBody ManageUserInfoVo manageUserInfoVo){
|
||||||
return manageUserService.getUserInfo(manageUserInfoVo);
|
return manageUserService.getUserInfo(manageUserInfoVo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.m2pool.manage.dto;
|
package com.m2pool.manage.dto;
|
||||||
|
|
||||||
|
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
|
@ -35,7 +36,9 @@ public class ManageUserDto {
|
||||||
@ApiModelProperty(value = "最小起付金额",example = "100.0")
|
@ApiModelProperty(value = "最小起付金额",example = "100.0")
|
||||||
private String amount;
|
private String amount;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否激活自动提现0 是 1 否",example = "0")
|
||||||
|
private Integer active;
|
||||||
|
|
||||||
@ApiModelProperty(value = "挖矿用户状态",example = "0 11")
|
@ApiModelProperty(value = "挖矿用户状态0 正常 11 已删除 (废除:11已被过滤不会查询出来)",example = "0")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.m2pool.manage.entity.ManageBroadcast;
|
||||||
import com.m2pool.manage.vo.ManageBaseVo;
|
import com.m2pool.manage.vo.ManageBaseVo;
|
||||||
import com.m2pool.manage.vo.ManageBroadcastVo;
|
import com.m2pool.manage.vo.ManageBroadcastVo;
|
||||||
import com.m2pool.manage.vo.PageVo;
|
import com.m2pool.manage.vo.PageVo;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -56,4 +57,12 @@ public interface ManageBroadcastService extends IService<ManageBroadcast> {
|
||||||
R<String> updateBroadcast(ManageBroadcastVo broadcastVo);
|
R<String> updateBroadcast(ManageBroadcastVo broadcastVo);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询通知详情
|
||||||
|
* @param manageBaseVo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
R<ManageBroadcastDto> findDataInfo(ManageBaseVo manageBaseVo);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,10 +69,13 @@ public class ManageBroadcastServiceImpl extends ServiceImpl<ManageBroadcastMappe
|
||||||
public R<List<ManageBroadcastDto>> findDataById(ManageBaseVo manageBaseVo) {
|
public R<List<ManageBroadcastDto>> findDataById(ManageBaseVo manageBaseVo) {
|
||||||
LambdaQueryWrapper<ManageBroadcast> eq = new LambdaQueryWrapper<ManageBroadcast>()
|
LambdaQueryWrapper<ManageBroadcast> eq = new LambdaQueryWrapper<ManageBroadcast>()
|
||||||
.eq(ManageBroadcast::getDel, false);
|
.eq(ManageBroadcast::getDel, false);
|
||||||
if(manageBaseVo.getId() != null){
|
if(manageBaseVo != null && manageBaseVo.getId() != null){
|
||||||
eq.eq(ManageBroadcast::getId, manageBaseVo.getId());
|
eq.le(ManageBroadcast::getId, manageBaseVo.getId());
|
||||||
}
|
|
||||||
eq.orderByDesc(ManageBroadcast::getId).last("limit 20");
|
eq.orderByDesc(ManageBroadcast::getId).last("limit 20");
|
||||||
|
}else{
|
||||||
|
eq.orderByDesc(ManageBroadcast::getId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
List<ManageBroadcast> list = this.list(eq);
|
List<ManageBroadcast> list = this.list(eq);
|
||||||
List<ManageBroadcastDto> collect = list.stream()
|
List<ManageBroadcastDto> collect = list.stream()
|
||||||
|
@ -126,6 +129,7 @@ public class ManageBroadcastServiceImpl extends ServiceImpl<ManageBroadcastMappe
|
||||||
@Override
|
@Override
|
||||||
public R<String> updateBroadcast(ManageBroadcastVo broadcastVo) {
|
public R<String> updateBroadcast(ManageBroadcastVo broadcastVo) {
|
||||||
boolean b = this.updateById(ManageBroadcast.builder()
|
boolean b = this.updateById(ManageBroadcast.builder()
|
||||||
|
.id(broadcastVo.getId())
|
||||||
.content(broadcastVo.getContent())
|
.content(broadcastVo.getContent())
|
||||||
.updateUser(SecurityUtils.getUsername())
|
.updateUser(SecurityUtils.getUsername())
|
||||||
.build());
|
.build());
|
||||||
|
@ -134,4 +138,22 @@ public class ManageBroadcastServiceImpl extends ServiceImpl<ManageBroadcastMappe
|
||||||
}
|
}
|
||||||
return R.fail("修改失败");
|
return R.fail("修改失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<ManageBroadcastDto> findDataInfo(ManageBaseVo manageBaseVo) {
|
||||||
|
|
||||||
|
ManageBroadcast byId = this.getById(manageBaseVo.getId());
|
||||||
|
if(byId != null){
|
||||||
|
return R.success(ManageBroadcastDto.builder()
|
||||||
|
.content(byId.getContent())
|
||||||
|
.id(byId.getId())
|
||||||
|
.createUser(byId.getCreateUser())
|
||||||
|
.updateUser(byId.getUpdateUser())
|
||||||
|
.updateTime(byId.getUpdateTime())
|
||||||
|
.createTime(byId.getCreateTime())
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
return R.fail("该通知不存在");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,14 @@
|
||||||
uma.miner_user as minerUser,
|
uma.miner_user as minerUser,
|
||||||
uma.coin,
|
uma.coin,
|
||||||
uab.balance,
|
uab.balance,
|
||||||
|
uab.active,
|
||||||
COALESCE(uab.amount,0),
|
COALESCE(uab.amount,0),
|
||||||
uma.status
|
uma.status
|
||||||
FROM
|
FROM
|
||||||
user_account_balance uab
|
user_account_balance uab
|
||||||
LEFT JOIN user_miner_account uma ON uab.ma_id = uma.id
|
LEFT JOIN user_miner_account uma ON uab.ma_id = uma.id
|
||||||
<where>
|
<where>
|
||||||
uma.coin = #{coin}
|
uma.coin = #{coin} AND uma.status = 0
|
||||||
<if test="user != null and user != ''">
|
<if test="user != null and user != ''">
|
||||||
AND uma.user like CONCAT('%',#{user},'%')
|
AND uma.user like CONCAT('%',#{user},'%')
|
||||||
</if>
|
</if>
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class TicketController extends BaseController {
|
||||||
@PostMapping("/bk/getAllTicket")
|
@PostMapping("/bk/getAllTicket")
|
||||||
@ApiOperation(value = "条件搜索后台所有工单列表")
|
@ApiOperation(value = "条件搜索后台所有工单列表")
|
||||||
@RequiresLogin
|
@RequiresLogin
|
||||||
@RequiresRoles("admin")
|
@RequiresRoles("back_admin")
|
||||||
public TableDataInfo getAllTicket(@RequestBody AllTicketListVo vo){
|
public TableDataInfo getAllTicket(@RequestBody AllTicketListVo vo){
|
||||||
System.out.println("com.m2pool.chat.vo"+vo);
|
System.out.println("com.m2pool.chat.vo"+vo);
|
||||||
if(StringUtils.isNotBlank(vo.getCond())){
|
if(StringUtils.isNotBlank(vo.getCond())){
|
||||||
|
@ -147,7 +147,7 @@ public class TicketController extends BaseController {
|
||||||
@PostMapping("/bk/endTicket")
|
@PostMapping("/bk/endTicket")
|
||||||
@ApiOperation(value = "关闭用户工单")
|
@ApiOperation(value = "关闭用户工单")
|
||||||
@RequiresLogin
|
@RequiresLogin
|
||||||
@RequiresRoles(value = {"admin"}, logical = Logical.OR)
|
@RequiresRoles(value = {"back_admin"}, logical = Logical.OR)
|
||||||
public AjaxResult endUserTicket(@RequestBody(required = false) IdVo vo){
|
public AjaxResult endUserTicket(@RequestBody(required = false) IdVo vo){
|
||||||
|
|
||||||
return ticketService.closeTicket(vo);
|
return ticketService.closeTicket(vo);
|
||||||
|
@ -157,7 +157,7 @@ public class TicketController extends BaseController {
|
||||||
@PostMapping("/bk/list")
|
@PostMapping("/bk/list")
|
||||||
@ApiOperation(value = "根据状态获取type为线上(type=0)的工单")
|
@ApiOperation(value = "根据状态获取type为线上(type=0)的工单")
|
||||||
@RequiresLogin
|
@RequiresLogin
|
||||||
@RequiresRoles(value = {"admin"}, logical = Logical.OR)
|
@RequiresRoles(value = {"back_admin"}, logical = Logical.OR)
|
||||||
public TableDataInfo onlineTicketList(@RequestBody StatusVo vo){
|
public TableDataInfo onlineTicketList(@RequestBody StatusVo vo){
|
||||||
|
|
||||||
PageHelper.startPage(vo.getPage(),vo.getLimit());
|
PageHelper.startPage(vo.getPage(),vo.getLimit());
|
||||||
|
@ -168,7 +168,7 @@ public class TicketController extends BaseController {
|
||||||
@PostMapping("/bk/details")
|
@PostMapping("/bk/details")
|
||||||
@ApiOperation(value = "工单详情")
|
@ApiOperation(value = "工单详情")
|
||||||
@RequiresLogin
|
@RequiresLogin
|
||||||
@RequiresRoles(value = {"admin"}, logical = Logical.OR)
|
@RequiresRoles(value = {"back_admin"}, logical = Logical.OR)
|
||||||
public AjaxResult onlineTicketDetails(@RequestBody IdVo vo){
|
public AjaxResult onlineTicketDetails(@RequestBody IdVo vo){
|
||||||
if(StringUtils.isNull(vo)){
|
if(StringUtils.isNull(vo)){
|
||||||
return AjaxResult.error("工单id缺失");
|
return AjaxResult.error("工单id缺失");
|
||||||
|
@ -179,7 +179,7 @@ public class TicketController extends BaseController {
|
||||||
@PostMapping("/bk/respon")
|
@PostMapping("/bk/respon")
|
||||||
@ApiOperation(value = "回复工单")
|
@ApiOperation(value = "回复工单")
|
||||||
@RequiresLogin
|
@RequiresLogin
|
||||||
@RequiresRoles(value = {"admin"}, logical = Logical.OR)
|
@RequiresRoles(value = {"back_admin"}, logical = Logical.OR)
|
||||||
public AjaxResult onlineResponTicket(@RequestBody ResponTicketVo vo){
|
public AjaxResult onlineResponTicket(@RequestBody ResponTicketVo vo){
|
||||||
return ticketService.onlineResponTicket(vo);
|
return ticketService.onlineResponTicket(vo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,4 +25,9 @@ public class PowerLineDto implements Serializable {
|
||||||
|
|
||||||
private double price;
|
private double price;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 算力单位
|
||||||
|
*/
|
||||||
|
private String unit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -151,15 +152,14 @@ public class PoolServiceImpl implements PoolService {
|
||||||
if("1h".equals(vo.getInterval()) || "rt".equals(vo.getInterval())){
|
if("1h".equals(vo.getInterval()) || "rt".equals(vo.getInterval())){
|
||||||
//30m
|
//30m
|
||||||
PageHelper.clearPage();
|
PageHelper.clearPage();
|
||||||
//矿池算力从$coin_pool_30m拿
|
//矿池算力从$coin_pool_30m拿 获取的 算力单位为MH/S
|
||||||
List<PowerLineDto> list = poolMapper.get30mPoolPowerList(pool.getPoolTable()+"_30m");
|
List<PowerLineDto> list = poolMapper.get30mPoolPowerList(pool.getPoolTable()+"_30m");
|
||||||
Collections.reverse(list);
|
Collections.reverse(list);
|
||||||
|
|
||||||
//根据币种做参数处理
|
//根据币种做参数处理
|
||||||
list.stream().forEach(e -> {
|
PowerLineDto maxPv = list.stream().max(Comparator.comparing(PowerLineDto::getPv)).orElse(new PowerLineDto());
|
||||||
//MH/s 每秒转GH/s
|
PowerUnitUtils.NetPowerUnit powerUnit = PowerUnitUtils.getPowerUnit(maxPv.getPv().multiply(BigDecimal.valueOf(1000 * 1000)));
|
||||||
e.setPv(e.getPv().divide(BigDecimal.valueOf(1000),scale,BigDecimal.ROUND_HALF_UP).stripTrailingZeros());
|
list = changeUnit(powerUnit, list, pool,BigDecimal.valueOf(1000 * 1000));
|
||||||
});
|
|
||||||
|
|
||||||
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())){
|
||||||
|
@ -177,10 +177,11 @@ public class PoolServiceImpl implements PoolService {
|
||||||
|
|
||||||
//根据币种做参数处理
|
//根据币种做参数处理
|
||||||
list.stream().forEach(e -> {
|
list.stream().forEach(e -> {
|
||||||
//MH/s 每秒转GH/s
|
|
||||||
e.setDate(DateUtils.addDays(e.getDate(),-1));
|
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());
|
List<MinerDataDto> lastList = poolMapper.getMinerInfoList(pool.getMhs());
|
||||||
BigDecimal mhs = lastList.stream().map(e -> {
|
BigDecimal mhs = lastList.stream().map(e -> {
|
||||||
|
@ -189,9 +190,12 @@ public class PoolServiceImpl implements PoolService {
|
||||||
PowerLineDto lastPLDto= new PowerLineDto();
|
PowerLineDto lastPLDto= new PowerLineDto();
|
||||||
Date now = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD));
|
Date now = DateUtils.parseDate(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD));
|
||||||
lastPLDto.setDate(now);
|
lastPLDto.setDate(now);
|
||||||
lastPLDto.setPv(mhs.divide(BigDecimal.valueOf(1000),scale,BigDecimal.ROUND_HALF_UP).stripTrailingZeros());
|
lastPLDto.setPv(mhs);
|
||||||
list.add(lastPLDto);
|
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算力
|
//todo 最后一天数据用当天实时24h算力
|
||||||
//List<MinerDataDto> lastList = poolMapper.getMinerInfoList(pool.getMhs());
|
//List<MinerDataDto> lastList = poolMapper.getMinerInfoList(pool.getMhs());
|
||||||
//BigDecimal mhs = lastList.stream().map(e -> {
|
//BigDecimal mhs = lastList.stream().map(e -> {
|
||||||
|
@ -351,28 +355,23 @@ public class PoolServiceImpl implements PoolService {
|
||||||
return AjaxResult.error("缺失参数:interval");
|
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())){
|
if("1h".equals(vo.getInterval()) || "rt".equals(vo.getInterval())){
|
||||||
PageHelper.clearPage();
|
PageHelper.clearPage();
|
||||||
//30m数据 限制条数为最近1天的条数 即1*48=48
|
//30m数据 限制条数为最近1天的条数 即1*48=48
|
||||||
list = list.stream().sorted(Comparator.comparing(PowerLineDto::getDate, Comparator.reverseOrder())).limit(48).collect(Collectors.toList());
|
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);
|
Collections.reverse(list);
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}else if ("1d".equals(vo.getInterval())){
|
}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());
|
list = list.stream().sorted(Comparator.comparing(PowerLineDto::getDate, Comparator.reverseOrder())).limit(30).collect(Collectors.toList());
|
||||||
Collections.reverse(list);
|
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);
|
return AjaxResult.success(list);
|
||||||
}else {
|
}else {
|
||||||
return AjaxResult.error("参数错误:interval");
|
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
|
@Override
|
||||||
public AjaxResult getParam(CoinVo vo) {
|
public AjaxResult getParam(CoinVo vo) {
|
||||||
Pools pool = (Pools) EnumUtils.get(Pools.class, vo.getCoin());
|
Pools pool = (Pools) EnumUtils.get(Pools.class, vo.getCoin());
|
||||||
|
|
|
@ -238,10 +238,11 @@ public class NodeRpc{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] params = {nowHeight,"2"};
|
String[] params = {};
|
||||||
Object[] statsParams = {Convert.toLong(nowHeight)};
|
Object[] statsParams = {Convert.toLong(nowHeight)};
|
||||||
String result = getResult(coin, "getmininginfo", params);
|
String result = getResult(coin, "getmininginfo", params);
|
||||||
String result2 = getResultTest(coin, "getblockstats", statsParams);
|
String result2 = getResultTest(coin, "getblockstats", statsParams);
|
||||||
|
System.out.println("yyb-全网算力nexa"+result);
|
||||||
BlockInfo blockInfo = new BlockInfo();
|
BlockInfo blockInfo = new BlockInfo();
|
||||||
|
|
||||||
if(StringUtils.isBlank(result)){
|
if(StringUtils.isBlank(result)){
|
||||||
|
@ -276,6 +277,7 @@ public class NodeRpc{
|
||||||
|
|
||||||
}
|
}
|
||||||
BigDecimal netPower = jsonObject.getBigDecimal("networkhashps");
|
BigDecimal netPower = jsonObject.getBigDecimal("networkhashps");
|
||||||
|
System.out.println("yyb-全网算力nexa"+netPower);
|
||||||
if (StringUtils.isNotNull(netPower)){
|
if (StringUtils.isNotNull(netPower)){
|
||||||
blockInfo.setPower(netPower);
|
blockInfo.setPower(netPower);
|
||||||
}
|
}
|
||||||
|
@ -285,7 +287,7 @@ public class NodeRpc{
|
||||||
// return null;
|
// return null;
|
||||||
//}
|
//}
|
||||||
//System.out.println(txs);
|
//System.out.println(txs);
|
||||||
final double[] reward = {0};
|
//final double[] reward = {0};
|
||||||
final double[] fees = {0};
|
final double[] fees = {0};
|
||||||
//txs.iterator().forEachRemaining(e -> {
|
//txs.iterator().forEachRemaining(e -> {
|
||||||
// JSONObject json = (JSONObject) e;
|
// JSONObject json = (JSONObject) e;
|
||||||
|
@ -351,29 +353,36 @@ public class NodeRpc{
|
||||||
String result = getResultTest(coin, "getblockheader", params);
|
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("查询结果为空");
|
System.out.println("查询结果为空");
|
||||||
return blockInfo;
|
return blockInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result.contains("error:")){
|
if(result.contains("error:") || result1.contains("error:")){
|
||||||
System.out.println("包含错误:"+result);
|
System.out.println("包含错误:"+result);
|
||||||
return blockInfo;
|
return blockInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject jsonObject = JSON.parseObject(result);
|
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");
|
long height = jsonObject.getLongValue("height");
|
||||||
blockInfo.setHeight(height);
|
blockInfo.setHeight(height);
|
||||||
|
|
||||||
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
|
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
|
||||||
if(StringUtils.isNotNull(difficulty)){
|
if(StringUtils.isNotNull(difficulty)){
|
||||||
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
|
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||||
NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
||||||
BigDecimal factor = constant.getFactor();
|
//BigDecimal factor = constant.getFactor();
|
||||||
if(StringUtils.isNotNull(factor)){
|
//if(StringUtils.isNotNull(factor)){
|
||||||
blockInfo.setPower(difficulty.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
// blockInfo.setPower(difficulty.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||||
}
|
//}
|
||||||
|
blockInfo.setPower(netPower);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,32 +433,37 @@ public class NodeRpc{
|
||||||
Object[] params = {blockhash};
|
Object[] params = {blockhash};
|
||||||
|
|
||||||
String result = getResultTest(coin, "getblockheader", params);
|
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("查询结果为空");
|
System.out.println("查询结果为空");
|
||||||
return blockInfo;
|
return blockInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result.contains("error:")){
|
if(result.contains("error:") || result1.contains("error:")){
|
||||||
System.out.println("包含错误:"+result);
|
System.out.println("包含错误:"+result);
|
||||||
return blockInfo;
|
return blockInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject jsonObject = JSON.parseObject(result);
|
JSONObject jsonObject = JSON.parseObject(result);
|
||||||
|
JSONObject jsonObject1 = JSON.parseObject(result1);
|
||||||
long height = jsonObject.getLongValue("height");
|
long height = jsonObject.getLongValue("height");
|
||||||
blockInfo.setHeight(height);
|
blockInfo.setHeight(height);
|
||||||
|
|
||||||
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
|
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
|
||||||
|
BigDecimal netPower = jsonObject1.getBigDecimal("networkhashps");
|
||||||
|
System.out.println("yyb-全网算力mona"+netPower);
|
||||||
if(StringUtils.isNotNull(difficulty)){
|
if(StringUtils.isNotNull(difficulty)){
|
||||||
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
|
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||||
NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
||||||
BigDecimal factor = constant.getFactor();
|
//BigDecimal factor = constant.getFactor();
|
||||||
if(StringUtils.isNotNull(factor)){
|
//if(StringUtils.isNotNull(factor)){
|
||||||
blockInfo.setPower(difficulty.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
// blockInfo.setPower(difficulty.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||||
}
|
//}
|
||||||
|
blockInfo.setPower(netPower);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,32 +514,36 @@ public class NodeRpc{
|
||||||
Object[] params = {blockhash};
|
Object[] params = {blockhash};
|
||||||
|
|
||||||
String result = getResultTest(coin, "getblockheader", params);
|
String result = getResultTest(coin, "getblockheader", params);
|
||||||
System.out.println("result"+result);
|
String[] params1 = {};
|
||||||
|
String result1 = getResult(coin, "getmininginfo", params1);
|
||||||
|
|
||||||
|
|
||||||
|
if(StringUtils.isBlank(result) || StringUtils.isBlank(result1)){
|
||||||
if(StringUtils.isBlank(result)){
|
|
||||||
System.out.println("查询结果为空");
|
System.out.println("查询结果为空");
|
||||||
return blockInfo;
|
return blockInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result.contains("error:")){
|
if(result.contains("error:") || result1.contains("error:")){
|
||||||
System.out.println("包含错误:"+result);
|
System.out.println("包含错误:"+result);
|
||||||
return blockInfo;
|
return blockInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject jsonObject = JSON.parseObject(result);
|
JSONObject jsonObject = JSON.parseObject(result);
|
||||||
|
JSONObject jsonObject1 = JSON.parseObject(result1);
|
||||||
long height = jsonObject.getLongValue("height");
|
long height = jsonObject.getLongValue("height");
|
||||||
blockInfo.setHeight(height);
|
blockInfo.setHeight(height);
|
||||||
|
|
||||||
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
|
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
|
||||||
|
BigDecimal netPower = jsonObject1.getBigDecimal("networkhashps");
|
||||||
|
System.out.println("yyb-全网算力rxd"+netPower);
|
||||||
if(StringUtils.isNotNull(difficulty)){
|
if(StringUtils.isNotNull(difficulty)){
|
||||||
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
|
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||||
NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
||||||
BigDecimal factor = constant.getFactor();
|
//BigDecimal factor = constant.getFactor();
|
||||||
if(StringUtils.isNotNull(factor)){
|
//if(StringUtils.isNotNull(factor)){
|
||||||
blockInfo.setPower(difficulty.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
// 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
|
//todo 调用getblockstats 拿subsidy/100000000做reward fees设置为0、拿blockhash
|
||||||
Object[] statsParams = {Convert.toLong(nowHeight)};
|
Object[] statsParams = {Convert.toLong(nowHeight)};
|
||||||
String blockstats = getResultTest(coin, "getblockstats", statsParams);
|
String blockstats = getResultTest(coin, "getblockstats", statsParams);
|
||||||
|
|
||||||
if(StringUtils.isBlank(blockstats)){
|
if(StringUtils.isBlank(blockstats)){
|
||||||
System.out.println("blockstats查询结果为空");
|
System.out.println("blockstats查询结果为空");
|
||||||
return null;
|
return null;
|
||||||
|
@ -807,9 +826,11 @@ public class NodeRpc{
|
||||||
System.out.println(subsidy);
|
System.out.println(subsidy);
|
||||||
Object[] params = {};
|
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)){
|
if(StringUtils.isBlank(result)){
|
||||||
|
@ -823,13 +844,16 @@ public class NodeRpc{
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject jsonObject = JSON.parseObject(result);
|
JSONObject jsonObject = JSON.parseObject(result);
|
||||||
|
//难度
|
||||||
JSONObject difficulties = jsonObject.getJSONObject("difficulties");
|
JSONObject difficulties = jsonObject.getJSONObject("difficulties");
|
||||||
if(StringUtils.isNull(difficulties)){
|
//全网算力
|
||||||
|
JSONObject networkhashesps = jsonObject.getJSONObject("networkhashesps");
|
||||||
|
if(StringUtils.isNull(difficulties) || StringUtils.isNull(networkhashesps)){
|
||||||
System.out.println("查询结果为空");
|
System.out.println("查询结果为空");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
System.out.println("difficulties:"+difficulties);
|
|
||||||
BigDecimal sDiff = difficulties.getBigDecimal("skein");
|
BigDecimal sDiff = difficulties.getBigDecimal("skein");
|
||||||
|
BigDecimal sNetwork = networkhashesps.getBigDecimal("skein");
|
||||||
if(StringUtils.isNotNull(sDiff)){
|
if(StringUtils.isNotNull(sDiff)){
|
||||||
BlockInfo sBlockInfo = new BlockInfo();
|
BlockInfo sBlockInfo = new BlockInfo();
|
||||||
sBlockInfo.setHeight(Convert.toLong(nowHeight,20237944L));
|
sBlockInfo.setHeight(Convert.toLong(nowHeight,20237944L));
|
||||||
|
@ -837,15 +861,17 @@ public class NodeRpc{
|
||||||
sBlockInfo.setFees(BigDecimal.ZERO);
|
sBlockInfo.setFees(BigDecimal.ZERO);
|
||||||
sBlockInfo.setProfit(sBlockInfo.getReward().subtract(sBlockInfo.getFees()));
|
sBlockInfo.setProfit(sBlockInfo.getReward().subtract(sBlockInfo.getFees()));
|
||||||
sBlockInfo.setDifficulty(sDiff.setScale(2,BigDecimal.ROUND_HALF_UP));
|
sBlockInfo.setDifficulty(sDiff.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||||
NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, "dgbs");
|
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, "dgbs");
|
||||||
BigDecimal factor = constant.getFactor();
|
//BigDecimal factor = constant.getFactor();
|
||||||
if(StringUtils.isNotNull(factor)){
|
//if(StringUtils.isNotNull(factor)){
|
||||||
sBlockInfo.setPower(sDiff.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
// sBlockInfo.setPower(sDiff.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||||
}
|
//}
|
||||||
|
sBlockInfo.setPower(sNetwork);
|
||||||
map.put("dgbs",sBlockInfo);
|
map.put("dgbs",sBlockInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal oDiff = difficulties.getBigDecimal("odo");
|
BigDecimal oDiff = difficulties.getBigDecimal("odo");
|
||||||
|
BigDecimal oNetwork = networkhashesps.getBigDecimal("odo");
|
||||||
if(StringUtils.isNotNull(oDiff)){
|
if(StringUtils.isNotNull(oDiff)){
|
||||||
BlockInfo oBlockInfo = new BlockInfo();
|
BlockInfo oBlockInfo = new BlockInfo();
|
||||||
oBlockInfo.setHeight(Convert.toLong(nowHeight,20237944L));
|
oBlockInfo.setHeight(Convert.toLong(nowHeight,20237944L));
|
||||||
|
@ -853,15 +879,17 @@ public class NodeRpc{
|
||||||
oBlockInfo.setFees(BigDecimal.ZERO);
|
oBlockInfo.setFees(BigDecimal.ZERO);
|
||||||
oBlockInfo.setProfit(oBlockInfo.getReward().subtract(oBlockInfo.getFees()));
|
oBlockInfo.setProfit(oBlockInfo.getReward().subtract(oBlockInfo.getFees()));
|
||||||
oBlockInfo.setDifficulty(oDiff.setScale(2,BigDecimal.ROUND_HALF_UP));
|
oBlockInfo.setDifficulty(oDiff.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||||
NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, "dgbo");
|
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, "dgbo");
|
||||||
BigDecimal factor = constant.getFactor();
|
//BigDecimal factor = constant.getFactor();
|
||||||
if(StringUtils.isNotNull(factor)){
|
//if(StringUtils.isNotNull(factor)){
|
||||||
oBlockInfo.setPower(oDiff.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
// oBlockInfo.setPower(oDiff.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||||
}
|
//}
|
||||||
|
oBlockInfo.setPower(oNetwork);
|
||||||
map.put("dgbo",oBlockInfo);
|
map.put("dgbo",oBlockInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal qDiff = difficulties.getBigDecimal("qubit");
|
BigDecimal qDiff = difficulties.getBigDecimal("qubit");
|
||||||
|
BigDecimal qNetwork = networkhashesps.getBigDecimal("qubit");
|
||||||
if(StringUtils.isNotNull(qDiff)){
|
if(StringUtils.isNotNull(qDiff)){
|
||||||
BlockInfo qBlockInfo = new BlockInfo();
|
BlockInfo qBlockInfo = new BlockInfo();
|
||||||
qBlockInfo.setHeight(Convert.toLong(nowHeight,20237944L));
|
qBlockInfo.setHeight(Convert.toLong(nowHeight,20237944L));
|
||||||
|
@ -869,16 +897,15 @@ public class NodeRpc{
|
||||||
qBlockInfo.setFees(BigDecimal.ZERO);
|
qBlockInfo.setFees(BigDecimal.ZERO);
|
||||||
qBlockInfo.setProfit(qBlockInfo.getReward().subtract(qBlockInfo.getFees()));
|
qBlockInfo.setProfit(qBlockInfo.getReward().subtract(qBlockInfo.getFees()));
|
||||||
qBlockInfo.setDifficulty(qDiff.setScale(2,BigDecimal.ROUND_HALF_UP));
|
qBlockInfo.setDifficulty(qDiff.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||||
NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, "dgbq");
|
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, "dgbq");
|
||||||
BigDecimal factor = constant.getFactor();
|
//BigDecimal factor = constant.getFactor();
|
||||||
if(StringUtils.isNotNull(factor)){
|
//if(StringUtils.isNotNull(factor)){
|
||||||
qBlockInfo.setPower(qDiff.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
// qBlockInfo.setPower(qDiff.multiply(factor).setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||||
}
|
//}
|
||||||
|
qBlockInfo.setPower(qNetwork);
|
||||||
map.put("dgbq",qBlockInfo);
|
map.put("dgbq",qBlockInfo);
|
||||||
}
|
}
|
||||||
|
System.out.println("存储的数据"+map);
|
||||||
System.out.println("map:"+map);
|
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,10 @@ package com.m2pool.pool.utils;
|
||||||
|
|
||||||
import com.m2pool.common.core.utils.StringUtils;
|
import com.m2pool.common.core.utils.StringUtils;
|
||||||
import com.m2pool.pool.enums.PoolProfitScale;
|
import com.m2pool.pool.enums.PoolProfitScale;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description 算力转换
|
* @Description 算力转换
|
||||||
|
@ -79,4 +81,61 @@ public class PowerUnitUtils {
|
||||||
return value.setScale(2,BigDecimal.ROUND_HALF_UP).toEngineeringString();
|
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:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
# 环境配置
|
# 环境配置
|
||||||
active: test
|
active: prod
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: test
|
active: prod
|
||||||
|
|
Loading…
Reference in New Issue