1.用能代码提交
2.系统并发bug修改
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.auth.controller;
|
package com.njcn.auth.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
import com.nimbusds.jose.jwk.JWKSet;
|
import com.nimbusds.jose.jwk.JWKSet;
|
||||||
import com.nimbusds.jose.jwk.RSAKey;
|
import com.nimbusds.jose.jwk.RSAKey;
|
||||||
import com.njcn.auth.service.UserTokenService;
|
import com.njcn.auth.service.UserTokenService;
|
||||||
@@ -44,10 +45,7 @@ import java.security.Principal;
|
|||||||
import java.security.interfaces.RSAPublicKey;
|
import java.security.interfaces.RSAPublicKey;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,14 +100,18 @@ public class AuthController extends BaseController {
|
|||||||
username = parameters.get(SecurityConstants.PHONE);
|
username = parameters.get(SecurityConstants.PHONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//判断当前登录是否超过最大并发数
|
||||||
UserStrategy data = passWordRuleFeugnClient.getUserStrategy().getData();
|
UserStrategy data = passWordRuleFeugnClient.getUserStrategy().getData();
|
||||||
String onlineUserKey = SecurityConstants.TOKEN_ONLINE_PREFIX;
|
String onlineUserKey = SecurityConstants.TOKEN_ONLINE_PREFIX;
|
||||||
List<UserTokenInfo> onLineUser = (List<UserTokenInfo>) redisUtil.getLikeListAllValues(onlineUserKey);
|
List<UserTokenInfo> onLineUser = (List<UserTokenInfo>) redisUtil.getLikeListAllValues(onlineUserKey);
|
||||||
if(CollectionUtil.isNotEmpty(onLineUser)){
|
if(CollectionUtil.isNotEmpty(onLineUser)){
|
||||||
String finalUsername = username;
|
String finalUsername = username;
|
||||||
onLineUser = onLineUser.stream().filter(item->{
|
onLineUser = onLineUser.stream().filter(item->{
|
||||||
String login = AuthPubUtil.getLoginByToken(item.getRefreshToken());
|
JSONObject jsonObject = AuthPubUtil.getLoginByToken(item.getRefreshToken());
|
||||||
return !login.equals(finalUsername);
|
String login = jsonObject.getStr(SecurityConstants.USER_NAME_KEY);
|
||||||
|
long exp = Long.parseLong(jsonObject.getStr(SecurityConstants.JWT_EXP));
|
||||||
|
long now = Calendar.getInstance().getTimeInMillis()/1000;
|
||||||
|
return (exp > now) && !login.equals(finalUsername);
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ public class AuthPubUtil {
|
|||||||
|
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static String getLoginByToken(String token){
|
public static JSONObject getLoginByToken(String token){
|
||||||
JWSObject jwsObject = JWSObject.parse(token);
|
JWSObject jwsObject = JWSObject.parse(token);
|
||||||
String payload = jwsObject.getPayload().toString();
|
String payload = jwsObject.getPayload().toString();
|
||||||
JSONObject jsonObject = JSONUtil.parseObj(payload);
|
JSONObject jsonObject = JSONUtil.parseObj(payload);
|
||||||
return jsonObject.getStr(SecurityConstants.USER_NAME_KEY);
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,11 +36,9 @@ public class AirStrategyParam{
|
|||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
@ApiModelProperty(name = "开始时间",required = true)
|
@ApiModelProperty(name = "开始时间",required = true)
|
||||||
@NotBlank(message = "开始时间不可为空")
|
|
||||||
private String startTime;
|
private String startTime;
|
||||||
|
|
||||||
@ApiModelProperty(name = "开始时间",required = true)
|
@ApiModelProperty(name = "结束时间",required = true)
|
||||||
@NotBlank(message = "开始时间不可为空")
|
|
||||||
private String endTime;
|
private String endTime;
|
||||||
|
|
||||||
@ApiModelProperty(name = "空调模式",required = true)
|
@ApiModelProperty(name = "空调模式",required = true)
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ public class StatisticDataRunController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.error(start + "——————" + end + "数据为空");
|
log.error(start + "——————" + end + "influxdb数据库power_data表数据为空,请联系管理员排查");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -530,7 +530,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
this.mqttSendCount = 0;
|
this.mqttSendCount = 0;
|
||||||
this.mqttJsonMsg = json;
|
this.mqttJsonMsg = json;
|
||||||
this.mqttSendTopic = topic;
|
this.mqttSendTopic = topic;
|
||||||
Thread.sleep(3000);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -555,8 +555,11 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
this.mqttSendCount = 0;
|
this.mqttSendCount = 0;
|
||||||
this.mqttJsonMsg = json;
|
this.mqttJsonMsg = json;
|
||||||
this.mqttSendTopic = topic;
|
this.mqttSendTopic = topic;
|
||||||
Thread.sleep(3000);
|
|
||||||
|
System.out.println("发送关空调控制"+LocalDateTime.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Thread.sleep(8000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("close".equals(operation) && airStrategy.getType() == 0) {
|
if ("close".equals(operation) && airStrategy.getType() == 0) {
|
||||||
@@ -583,6 +586,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
|
|
||||||
@MqttSubscribe(value = "/platform/devack/#", qos = 1)
|
@MqttSubscribe(value = "/platform/devack/#", qos = 1)
|
||||||
public void airOperation(String topic, MqttMessage message, @Payload String payload) {
|
public void airOperation(String topic, MqttMessage message, @Payload String payload) {
|
||||||
|
System.out.println("收到网关反馈控制"+LocalDateTime.now());
|
||||||
System.out.println(message.toString());
|
System.out.println(message.toString());
|
||||||
JSONObject jsonObject = new JSONObject(message.toString());
|
JSONObject jsonObject = new JSONObject(message.toString());
|
||||||
String str = jsonObject.getStr("userId");
|
String str = jsonObject.getStr("userId");
|
||||||
@@ -594,6 +598,7 @@ public class EleAirStrategyServiceImpl extends ServiceImpl<AirStrategyMapper, Ai
|
|||||||
System.out.println("进入错误重发++++++");
|
System.out.println("进入错误重发++++++");
|
||||||
System.out.println("错误重发详情" + mqttJsonMsg);
|
System.out.println("错误重发详情" + mqttJsonMsg);
|
||||||
publisher.send(mqttSendTopic, mqttJsonMsg, 1, false);
|
publisher.send(mqttSendTopic, mqttJsonMsg, 1, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
|||||||
String jti = jsonObject.getStr(SecurityConstants.JWT_JTI);
|
String jti = jsonObject.getStr(SecurityConstants.JWT_JTI);
|
||||||
String exp = jsonObject.getStr(SecurityConstants.JWT_EXP);
|
String exp = jsonObject.getStr(SecurityConstants.JWT_EXP);
|
||||||
LocalDateTime expTime = LocalDateTimeUtil.of(Long.parseLong(exp + "000"));
|
LocalDateTime expTime = LocalDateTimeUtil.of(Long.parseLong(exp + "000"));
|
||||||
if(expTime.isAfter(LocalDateTimeUtil.now())){
|
if(expTime.isBefore(LocalDateTimeUtil.now())){
|
||||||
return ResponseUtils.writeErrorInfo(response, GateWayEnum.ACCESS_TOKEN_EXPIRE_JWT);
|
return ResponseUtils.writeErrorInfo(response, GateWayEnum.ACCESS_TOKEN_EXPIRE_JWT);
|
||||||
}
|
}
|
||||||
String blackUserKey = SecurityConstants.TOKEN_BLACKLIST_PREFIX + userIndex;
|
String blackUserKey = SecurityConstants.TOKEN_BLACKLIST_PREFIX + userIndex;
|
||||||
|
|||||||
Reference in New Issue
Block a user