密码规则配置功能
This commit is contained in:
@@ -81,7 +81,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
||||
private final RedisUtil redisUtil;
|
||||
private final CarryCapacityResultPOService carryCapacityResultPOService;
|
||||
private final CarryCapacityUserPOService carryCapacityUserPOService;
|
||||
private static final double DEFAULTVALUE=3141.5926;
|
||||
private static final double DEFAULTVALUE=3.1415926;
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
@@ -152,7 +152,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
||||
缺失布置3.1415926,后边更具3.1415926个数来判断数据完整性,及进行数据补充*/
|
||||
//有功功率
|
||||
String SqlP1 = "select mean(p)*1000 as value from data_harmpower_p where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||
"' and time >= '" + startTime + "'and time <= '" +endTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
"' and time >= '" + startTime + "'and time <= '" +endTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
dataHarmPowerPList = dataHarmPowerPMapper.getSqlResult(SqlP1);
|
||||
|
||||
//数据校验
|
||||
@@ -172,7 +172,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
||||
|
||||
//无功功率
|
||||
String SqlQ1 = "select mean(q)*1000 as value from data_harmpower_q where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||
"' and time >= '" + startTime + "'and time <= '" +endTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
"' and time >= '" + startTime + "'and time <= '" +endTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
dataHarmPowerQList = dataHarmPowerQMapper.getSqlResult(SqlQ1);
|
||||
//数据缺失填补
|
||||
//数据校验
|
||||
@@ -201,7 +201,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
||||
, formatter) + " 23:59:00";
|
||||
|
||||
String SqlP2 = "select mean(p)*1000 as value from data_harmpower_p where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
dataHarmPowerP2List = dataHarmPowerPMapper.getSqlResult(SqlP2);
|
||||
//数据校验
|
||||
if(CollectionUtil.isEmpty(dataHarmPowerP2List)){
|
||||
@@ -220,7 +220,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
||||
|
||||
//无功功率
|
||||
String SqlQ2 = "select mean(q)*1000 as value from data_harmpower_q where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
dataHarmPowerQ2List = dataHarmPowerQMapper.getSqlResult(SqlQ2);
|
||||
//数据校验
|
||||
//数据校验
|
||||
@@ -240,7 +240,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
||||
|
||||
//电压
|
||||
String SqlU2 = "select mean(rms)*1000 as value from data_v where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
dataHarmPowerU2List = dataVMapper.getSqlResult(SqlU2);
|
||||
//数据校验
|
||||
//数据校验
|
||||
@@ -325,7 +325,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
||||
if(CollectionUtil.isEmpty(dataHarmPowerQList)){
|
||||
//无功功率
|
||||
String SqlQ1 = "select mean(q)*1000 as value from data_harmpower_q where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||
"' and time >= '" + startTime + "'and time <= '" +endTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
"' and time >= '" + startTime + "'and time <= '" +endTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
dataHarmPowerQList = dataHarmPowerQMapper.getSqlResult(SqlQ1);
|
||||
if(CollectionUtil.isEmpty(dataHarmPowerQList)){
|
||||
throw new BusinessException(AdvanceResponseEnum.DATA_NOT_FOUND);
|
||||
@@ -796,7 +796,7 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
||||
, formatter) + " 23:59:00";
|
||||
|
||||
String SqlP2 = "select mean(p)*1000 as value from data_harmpower_p where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
dataHarmPowerP2List = dataHarmPowerPMapper.getSqlResult(SqlP2);
|
||||
//数据校验
|
||||
if(CollectionUtil.isEmpty(dataHarmPowerP2List)){
|
||||
@@ -818,14 +818,14 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
||||
|
||||
//无功功率
|
||||
String SqlQ2 = "select mean(q)*1000 as value from data_harmpower_q where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
dataHarmPowerQ2List = dataHarmPowerQMapper.getSqlResult(SqlQ2);
|
||||
//数据校验
|
||||
//数据缺失填补
|
||||
linearInterpolation(dataHarmPowerQ2List);
|
||||
//电压
|
||||
String SqlU2 = "select mean(rms)*1000 as value from data_v where value_type='CP95' and phasic_type!='T' and line_id='"+lineId+
|
||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(3.1415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
"' and time >= '" + forwardStartTime + "'and time <= '" +forwardEndTime + "'"+"group by time("+timeInterval+"m) ,* fill(0.0031415926)"+InfluxDBPublicParam.TIME_ZONE;
|
||||
dataHarmPowerU2List = dataVMapper.getSqlResult(SqlU2);
|
||||
//数据校验
|
||||
|
||||
@@ -1163,24 +1163,31 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
||||
*/
|
||||
public static void linearInterpolation(List<CarryCapcityData> data) {
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
if (data.get(i).getValue() == DEFAULTVALUE ||Objects.isNull(data.get(i).getValue())) {
|
||||
|
||||
|
||||
data.stream().collect(Collectors.groupingBy(CarryCapcityData::getPhaseType)).forEach((k,v)->{
|
||||
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
if (v.get(i).getValue() == DEFAULTVALUE ||Objects.isNull(v.get(i).getValue())) {
|
||||
int prevIndex = i - 1;
|
||||
int nextIndex = i + 1;
|
||||
while (prevIndex >= 0 && (data.get(prevIndex).getValue() == DEFAULTVALUE|| Objects.isNull(data.get(prevIndex).getValue()))) {
|
||||
while (prevIndex >= 0 && (v.get(prevIndex).getValue() == DEFAULTVALUE|| Objects.isNull(v.get(prevIndex).getValue()))) {
|
||||
prevIndex--;
|
||||
}
|
||||
while (nextIndex < data.size() && (data.get(nextIndex).getValue() == DEFAULTVALUE|| Objects.isNull(data.get(nextIndex).getValue()))) {
|
||||
while (nextIndex < v.size() && (v.get(nextIndex).getValue() == DEFAULTVALUE|| Objects.isNull(v.get(nextIndex).getValue()))) {
|
||||
nextIndex++;
|
||||
}
|
||||
if (prevIndex >= 0 && nextIndex < data.size()) {
|
||||
double slope = (data.get(nextIndex).getValue() - data.get(prevIndex).getValue()) / (nextIndex - prevIndex);
|
||||
data.get(i).setValue(data.get(prevIndex).getValue() + slope * (i - prevIndex));
|
||||
if (prevIndex >= 0 && nextIndex < v.size()) {
|
||||
double slope = (v.get(nextIndex).getValue() - v.get(prevIndex).getValue()) / (nextIndex - prevIndex);
|
||||
v.get(i).setValue(v.get(prevIndex).getValue() + slope * (i - prevIndex));
|
||||
} else {
|
||||
data.get(i).setValue(DEFAULTVALUE);
|
||||
v.get(i).setValue(DEFAULTVALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
@@ -1192,72 +1199,76 @@ public class CarryCapcityServiceImpl implements CarryCapcityService {
|
||||
*/
|
||||
public static void linearInterpolationI(List<DataI> data) {
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
if (data.get(i).getI2() == DEFAULTVALUE||Objects.isNull(data.get(i).getI2())) {
|
||||
data.stream().collect(Collectors.groupingBy(DataI::getPhaseType)).forEach((k,v)->{
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
if (v.get(i).getI2() == DEFAULTVALUE||Objects.isNull(v.get(i).getI2())) {
|
||||
int prevIndex = i - 1;
|
||||
int nextIndex = i + 1;
|
||||
while (prevIndex >= 0 && (data.get(prevIndex).getI2() == DEFAULTVALUE||Objects.isNull(data.get(prevIndex).getI2()))) {
|
||||
while (prevIndex >= 0 && (v.get(prevIndex).getI2() == DEFAULTVALUE||Objects.isNull(v.get(prevIndex).getI2()))) {
|
||||
prevIndex--;
|
||||
}
|
||||
while (nextIndex < data.size() && (data.get(nextIndex).getI2() == DEFAULTVALUE||Objects.isNull(data.get(nextIndex).getI2()))) {
|
||||
while (nextIndex < v.size() && (v.get(nextIndex).getI2() == DEFAULTVALUE||Objects.isNull(v.get(nextIndex).getI2()))) {
|
||||
nextIndex++;
|
||||
}
|
||||
if (prevIndex >= 0 && nextIndex < data.size()) {
|
||||
double slope = (data.get(nextIndex).getI2() - data.get(prevIndex).getI2()) / (nextIndex - prevIndex);
|
||||
data.get(i).setI2(data.get(prevIndex).getI2() + slope * (i - prevIndex));
|
||||
data.get(i).setI3(data.get(prevIndex).getI3() + slope * (i - prevIndex));
|
||||
data.get(i).setI4(data.get(prevIndex).getI4() + slope * (i - prevIndex));
|
||||
data.get(i).setI5(data.get(prevIndex).getI5() + slope * (i - prevIndex));
|
||||
data.get(i).setI6(data.get(prevIndex).getI6() + slope * (i - prevIndex));
|
||||
data.get(i).setI7(data.get(prevIndex).getI7() + slope * (i - prevIndex));
|
||||
data.get(i).setI8(data.get(prevIndex).getI8() + slope * (i - prevIndex));
|
||||
data.get(i).setI9(data.get(prevIndex).getI9() + slope * (i - prevIndex));
|
||||
data.get(i).setI10(data.get(prevIndex).getI10() + slope * (i - prevIndex));
|
||||
data.get(i).setI11(data.get(prevIndex).getI11() + slope * (i - prevIndex));
|
||||
data.get(i).setI12(data.get(prevIndex).getI12() + slope * (i - prevIndex));
|
||||
data.get(i).setI13(data.get(prevIndex).getI13() + slope * (i - prevIndex));
|
||||
data.get(i).setI14(data.get(prevIndex).getI14() + slope * (i - prevIndex));
|
||||
data.get(i).setI15(data.get(prevIndex).getI15() + slope * (i - prevIndex));
|
||||
data.get(i).setI16(data.get(prevIndex).getI16() + slope * (i - prevIndex));
|
||||
data.get(i).setI17(data.get(prevIndex).getI17() + slope * (i - prevIndex));
|
||||
data.get(i).setI18(data.get(prevIndex).getI18() + slope * (i - prevIndex));
|
||||
data.get(i).setI19(data.get(prevIndex).getI19() + slope * (i - prevIndex));
|
||||
data.get(i).setI20(data.get(prevIndex).getI20() + slope * (i - prevIndex));
|
||||
data.get(i).setI21(data.get(prevIndex).getI21() + slope * (i - prevIndex));
|
||||
data.get(i).setI22(data.get(prevIndex).getI22() + slope * (i - prevIndex));
|
||||
data.get(i).setI23(data.get(prevIndex).getI23() + slope * (i - prevIndex));
|
||||
data.get(i).setI24(data.get(prevIndex).getI24() + slope * (i - prevIndex));
|
||||
data.get(i).setI25(data.get(prevIndex).getI25() + slope * (i - prevIndex));
|
||||
if (prevIndex >= 0 && nextIndex < v.size()) {
|
||||
double slope = (v.get(nextIndex).getI2() - v.get(prevIndex).getI2()) / (nextIndex - prevIndex);
|
||||
v.get(i).setI2(v.get(prevIndex).getI2() + slope * (i - prevIndex));
|
||||
v.get(i).setI3(v.get(prevIndex).getI3() + slope * (i - prevIndex));
|
||||
v.get(i).setI4(v.get(prevIndex).getI4() + slope * (i - prevIndex));
|
||||
v.get(i).setI5(v.get(prevIndex).getI5() + slope * (i - prevIndex));
|
||||
v.get(i).setI6(v.get(prevIndex).getI6() + slope * (i - prevIndex));
|
||||
v.get(i).setI7(v.get(prevIndex).getI7() + slope * (i - prevIndex));
|
||||
v.get(i).setI8(v.get(prevIndex).getI8() + slope * (i - prevIndex));
|
||||
v.get(i).setI9(v.get(prevIndex).getI9() + slope * (i - prevIndex));
|
||||
v.get(i).setI10(v.get(prevIndex).getI10() + slope * (i - prevIndex));
|
||||
v.get(i).setI11(v.get(prevIndex).getI11() + slope * (i - prevIndex));
|
||||
v.get(i).setI12(v.get(prevIndex).getI12() + slope * (i - prevIndex));
|
||||
v.get(i).setI13(v.get(prevIndex).getI13() + slope * (i - prevIndex));
|
||||
v.get(i).setI14(v.get(prevIndex).getI14() + slope * (i - prevIndex));
|
||||
v.get(i).setI15(v.get(prevIndex).getI15() + slope * (i - prevIndex));
|
||||
v.get(i).setI16(v.get(prevIndex).getI16() + slope * (i - prevIndex));
|
||||
v.get(i).setI17(v.get(prevIndex).getI17() + slope * (i - prevIndex));
|
||||
v.get(i).setI18(v.get(prevIndex).getI18() + slope * (i - prevIndex));
|
||||
v.get(i).setI19(v.get(prevIndex).getI19() + slope * (i - prevIndex));
|
||||
v.get(i).setI20(v.get(prevIndex).getI20() + slope * (i - prevIndex));
|
||||
v.get(i).setI21(v.get(prevIndex).getI21() + slope * (i - prevIndex));
|
||||
v.get(i).setI22(v.get(prevIndex).getI22() + slope * (i - prevIndex));
|
||||
v.get(i).setI23(v.get(prevIndex).getI23() + slope * (i - prevIndex));
|
||||
v.get(i).setI24(v.get(prevIndex).getI24() + slope * (i - prevIndex));
|
||||
v.get(i).setI25(v.get(prevIndex).getI25() + slope * (i - prevIndex));
|
||||
|
||||
} else {
|
||||
data.get(i).setI2(DEFAULTVALUE);
|
||||
data.get(i).setI3(DEFAULTVALUE);
|
||||
data.get(i).setI4(DEFAULTVALUE);
|
||||
data.get(i).setI5(DEFAULTVALUE);
|
||||
data.get(i).setI6(DEFAULTVALUE);
|
||||
data.get(i).setI7(DEFAULTVALUE);
|
||||
data.get(i).setI8(DEFAULTVALUE);
|
||||
data.get(i).setI9(DEFAULTVALUE);
|
||||
data.get(i).setI10(DEFAULTVALUE);
|
||||
data.get(i).setI11(DEFAULTVALUE);
|
||||
data.get(i).setI12(DEFAULTVALUE);
|
||||
data.get(i).setI13(DEFAULTVALUE);
|
||||
data.get(i).setI14(DEFAULTVALUE);
|
||||
data.get(i).setI15(DEFAULTVALUE);
|
||||
data.get(i).setI16(DEFAULTVALUE);
|
||||
data.get(i).setI17(DEFAULTVALUE);
|
||||
data.get(i).setI18(DEFAULTVALUE);
|
||||
data.get(i).setI19(DEFAULTVALUE);
|
||||
data.get(i).setI20(DEFAULTVALUE);
|
||||
data.get(i).setI21(DEFAULTVALUE);
|
||||
data.get(i).setI22(DEFAULTVALUE);
|
||||
data.get(i).setI23(DEFAULTVALUE);
|
||||
data.get(i).setI24(DEFAULTVALUE);
|
||||
data.get(i).setI25(DEFAULTVALUE);
|
||||
v.get(i).setI2(DEFAULTVALUE);
|
||||
v.get(i).setI3(DEFAULTVALUE);
|
||||
v.get(i).setI4(DEFAULTVALUE);
|
||||
v.get(i).setI5(DEFAULTVALUE);
|
||||
v.get(i).setI6(DEFAULTVALUE);
|
||||
v.get(i).setI7(DEFAULTVALUE);
|
||||
v.get(i).setI8(DEFAULTVALUE);
|
||||
v.get(i).setI9(DEFAULTVALUE);
|
||||
v.get(i).setI10(DEFAULTVALUE);
|
||||
v.get(i).setI11(DEFAULTVALUE);
|
||||
v.get(i).setI12(DEFAULTVALUE);
|
||||
v.get(i).setI13(DEFAULTVALUE);
|
||||
v.get(i).setI14(DEFAULTVALUE);
|
||||
v.get(i).setI15(DEFAULTVALUE);
|
||||
v.get(i).setI16(DEFAULTVALUE);
|
||||
v.get(i).setI17(DEFAULTVALUE);
|
||||
v.get(i).setI18(DEFAULTVALUE);
|
||||
v.get(i).setI19(DEFAULTVALUE);
|
||||
v.get(i).setI20(DEFAULTVALUE);
|
||||
v.get(i).setI21(DEFAULTVALUE);
|
||||
v.get(i).setI22(DEFAULTVALUE);
|
||||
v.get(i).setI23(DEFAULTVALUE);
|
||||
v.get(i).setI24(DEFAULTVALUE);
|
||||
v.get(i).setI25(DEFAULTVALUE);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.auth.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.nimbusds.jose.jwk.JWKSet;
|
||||
import com.nimbusds.jose.jwk.RSAKey;
|
||||
import com.njcn.auth.service.UserTokenService;
|
||||
@@ -9,12 +10,16 @@ import com.njcn.common.pojo.constant.SecurityConstants;
|
||||
import com.njcn.common.pojo.dto.UserTokenInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.common.utils.sm.DesUtils;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.user.api.PassWordRuleFeugnClient;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.enums.UserResponseEnum;
|
||||
import com.njcn.user.pojo.po.UserStrategy;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import com.njcn.web.utils.RestTemplateUtil;
|
||||
@@ -38,7 +43,10 @@ import java.security.Principal;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -59,6 +67,8 @@ public class AuthController extends BaseController {
|
||||
|
||||
private final UserFeignClient userFeignClient;
|
||||
|
||||
private final PassWordRuleFeugnClient passWordRuleFeugnClient;
|
||||
|
||||
private final UserTokenService userTokenService;
|
||||
|
||||
|
||||
@@ -80,6 +90,15 @@ public class AuthController extends BaseController {
|
||||
public Object postAccessToken(@ApiIgnore Principal principal, @RequestParam @ApiIgnore Map<String, String> parameters) throws HttpRequestMethodNotSupportedException {
|
||||
String methodDescribe = getMethodDescribe("postAccessToken");
|
||||
String username = parameters.get(SecurityConstants.USERNAME);
|
||||
UserStrategy data = passWordRuleFeugnClient.getUserStrategy().getData();
|
||||
|
||||
String onlineUserKey = SecurityConstants.TOKEN_ONLINE_PREFIX;
|
||||
List<UserTokenInfo> onLineUser = (List<UserTokenInfo>) redisUtil.getLikeListAllValues(onlineUserKey);
|
||||
Integer maxNum = data.getMaxNum();
|
||||
if((CollectionUtil.isNotEmpty(onLineUser)?onLineUser.size():0)>=maxNum){
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_OVERLIMIT);
|
||||
}
|
||||
|
||||
String grantType = parameters.get(SecurityConstants.GRANT_TYPE);
|
||||
if (grantType.equalsIgnoreCase(SecurityConstants.GRANT_CAPTCHA) || grantType.equalsIgnoreCase(SecurityConstants.REFRESH_TOKEN_KEY)) {
|
||||
username = DesUtils.aesDecrypt(username);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.user.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.user.api.fallback.PassWordRuleClientFallbackFactory;
|
||||
import com.njcn.user.pojo.po.UserStrategy;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/7/12 15:59【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.USER,
|
||||
// url = "http://127.0.0.1:10201",
|
||||
path = "/password", fallbackFactory = PassWordRuleClientFallbackFactory.class,
|
||||
contextId = "password"
|
||||
)
|
||||
public interface PassWordRuleFeugnClient {
|
||||
@PostMapping(value = "/getUserStrategy")
|
||||
public HttpResult<UserStrategy> getUserStrategy() ;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.user.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.user.api.PassWordRuleFeugnClient;
|
||||
import com.njcn.user.pojo.po.UserStrategy;
|
||||
import com.njcn.user.utils.UserEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年08月24日 10:21
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PassWordRuleClientFallbackFactory implements FallbackFactory<PassWordRuleFeugnClient> {
|
||||
|
||||
|
||||
/**
|
||||
* 输出远程请求接口异常日志
|
||||
* @param cause RPC请求异常
|
||||
*/
|
||||
@Override
|
||||
public PassWordRuleFeugnClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if(cause.getCause() instanceof BusinessException){
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = UserEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new PassWordRuleFeugnClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<UserStrategy> getUserStrategy() {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询密码规则",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,8 @@ public enum UserResponseEnum {
|
||||
CODE_TYPE_ERROR("A0101","验证码类型非法"),
|
||||
SEND_CODE_FAIL("A0101","验证码发送失败"),
|
||||
LOGIN_USER_DELETE("A0101", "账号已被注销"),
|
||||
LOGIN_USER_LOCKED("A0101", "账号已被锁定"),
|
||||
LOGIN_USER_OVERLIMIT("A0101", "登陆用户数不能大于配置用户并发量"),
|
||||
LOGIN_USER_LOCKED("A0102", "账号已被锁定"),
|
||||
LOGIN_USER_UNAUDITED("A0101", "账号未审核"),
|
||||
NEED_MODIFY_PASSWORD("A0101", "密码需修改"),
|
||||
LOGIN_USER_SLEEP("A0101", "账号已休眠"),
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.user.pojo.param.PassWordRuleParam;
|
||||
import com.njcn.user.pojo.po.UserStrategy;
|
||||
import com.njcn.user.service.PassWordRuleService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -53,6 +54,16 @@ public class PassWordRuleController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, passWordRuleParam, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("获取密码规则")
|
||||
@RequestMapping(value = "/getUserStrategy", method = RequestMethod.POST)
|
||||
public HttpResult<UserStrategy> getUserStrategy() {
|
||||
String methodDescribe = getMethodDescribe("getRule");
|
||||
UserStrategy userStrategy = passWordRuleService.getUserStrategy();
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userStrategy, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("解锁超级管理员")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.user.service;
|
||||
|
||||
import com.njcn.user.pojo.param.PassWordRuleParam;
|
||||
import com.njcn.user.pojo.po.UserStrategy;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
@@ -15,4 +16,6 @@ public interface PassWordRuleService {
|
||||
PassWordRuleParam getRule();
|
||||
|
||||
Boolean unlockRoot();
|
||||
|
||||
UserStrategy getUserStrategy();
|
||||
}
|
||||
|
||||
@@ -69,4 +69,12 @@ public class PassWordRuleServiceImpl implements PassWordRuleService {
|
||||
userService.lambdaUpdate().eq(User::getLoginName,"root").set(User::getState,DataStateEnum.ENABLE.getCode()).update();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserStrategy getUserStrategy() {
|
||||
return iUserStrategyService.lambdaQuery()
|
||||
.eq(UserStrategy::getType, 1)
|
||||
.eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode())
|
||||
.one();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.njcn.user.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -20,12 +19,10 @@ import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.common.utils.sm.DesUtils;
|
||||
import com.njcn.common.utils.sm.Sm4Utils;
|
||||
import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.device.pq.api.PqsTerminalLogsClient;
|
||||
import com.njcn.device.pq.pojo.po.PqsTerminalLogs;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.poi.excel.ExcelUtil;
|
||||
import com.njcn.poi.pojo.bo.BaseLineProExcelBody;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
@@ -55,7 +52,11 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -117,64 +118,64 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||
@Override
|
||||
public void judgeUserStatus(String loginName) {
|
||||
User user = getUserByLoginName(loginName);
|
||||
|
||||
if (Objects.isNull(user)) {
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_WRONG_PWD);
|
||||
}
|
||||
//超级管理员则不做任何逻辑判断
|
||||
if (user.getType() == 0) {
|
||||
//更新用户登录时间,以及错误登录记录的信息归零。
|
||||
user.setState(UserState.ENABLE);
|
||||
user.setLoginErrorTimes(0);
|
||||
user.setLoginTime(LocalDateTime.now());
|
||||
user.setFirstErrorTime(null);
|
||||
user.setLockTime(null);
|
||||
this.baseMapper.updateById(user);
|
||||
return;
|
||||
}
|
||||
//根据用户类型获取对应用户策略
|
||||
UserStrategy userStrategy = userStrategyService.lambdaQuery()
|
||||
.eq(UserStrategy::getType, user.getCasualUser())
|
||||
.eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode())
|
||||
.one();
|
||||
switch (user.getState()) {
|
||||
case UserState.LOCKED:
|
||||
LocalDateTime lockTime = user.getLockTime();
|
||||
lockTime = lockTime.plusMinutes(userStrategy.getLockPwdTime());
|
||||
LocalDateTime nowTime = LocalDateTime.now();
|
||||
//判断是否满足锁定时间
|
||||
if (nowTime.isBefore(lockTime)) {
|
||||
CommonResponseEnum testEnum = CommonResponseEnum.DYNAMIC_RESPONSE_ENUM;
|
||||
testEnum.setMessage("测试自定义等于失败");
|
||||
testEnum.setMessage("账号已被锁定:锁定剩余时长"+ ChronoUnit.MINUTES.between(nowTime, lockTime)+"分钟");
|
||||
throw new BusinessException(testEnum);
|
||||
// if (Objects.isNull(user)) {
|
||||
// throw new BusinessException(UserResponseEnum.LOGIN_WRONG_PWD);
|
||||
// }
|
||||
// //超级管理员则不做任何逻辑判断
|
||||
// if (user.getType() == 0) {
|
||||
// //更新用户登录时间,以及错误登录记录的信息归零。
|
||||
// user.setState(UserState.ENABLE);
|
||||
// user.setLoginErrorTimes(0);
|
||||
// user.setLoginTime(LocalDateTime.now());
|
||||
// user.setFirstErrorTime(null);
|
||||
// user.setLockTime(null);
|
||||
// this.baseMapper.updateById(user);
|
||||
// return;
|
||||
// }
|
||||
// //根据用户类型获取对应用户策略
|
||||
// UserStrategy userStrategy = userStrategyService.lambdaQuery()
|
||||
// .eq(UserStrategy::getType, user.getCasualUser())
|
||||
// .eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode())
|
||||
// .one();
|
||||
// switch (user.getState()) {
|
||||
// case UserState.LOCKED:
|
||||
// LocalDateTime lockTime = user.getLockTime();
|
||||
// lockTime = lockTime.plusMinutes(userStrategy.getLockPwdTime());
|
||||
// LocalDateTime nowTime = LocalDateTime.now();
|
||||
// //判断是否满足锁定时间
|
||||
// if (nowTime.isBefore(lockTime)) {
|
||||
// throw new BusinessException(UserResponseEnum.LOGIN_USER_LOCKED);
|
||||
// }
|
||||
// break;
|
||||
// case UserState.DELETE:
|
||||
// //用户已注销
|
||||
// throw new BusinessException(UserResponseEnum.LOGIN_USER_DELETE);
|
||||
// case UserState.UNCHECK:
|
||||
// //用户未审核
|
||||
// throw new BusinessException(UserResponseEnum.LOGIN_USER_UNAUDITED);
|
||||
// case UserState.SLEEP:
|
||||
// //用户已休眠
|
||||
// throw new BusinessException(UserResponseEnum.LOGIN_USER_SLEEP);
|
||||
// case UserState.OVERDUE:
|
||||
// //用户密码已过期
|
||||
// throw new BusinessException(UserResponseEnum.LOGIN_USER_PASSWORD_EXPIRED);
|
||||
// default:
|
||||
// if (user.getPwdState() == 1) {
|
||||
// throw new BusinessException(UserResponseEnum.NEED_MODIFY_PWD);
|
||||
// }
|
||||
// //用户状态正常,判断其他细节
|
||||
// judgeFirstLogin(user, userStrategy);
|
||||
// }
|
||||
// //所有验证通过后,更新用户登录时间,以及错误登录记录的信息归零。
|
||||
// user.setState(UserState.ENABLE);
|
||||
// user.setLoginErrorTimes(0);
|
||||
// user.setLoginTime(LocalDateTime.now());
|
||||
// user.setFirstErrorTime(null);
|
||||
// user.setLockTime(null);
|
||||
// this.baseMapper.updateById(user);
|
||||
}
|
||||
break;
|
||||
case UserState.DELETE:
|
||||
//用户已注销
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_DELETE);
|
||||
case UserState.UNCHECK:
|
||||
//用户未审核
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_UNAUDITED);
|
||||
case UserState.SLEEP:
|
||||
//用户已休眠
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_SLEEP);
|
||||
case UserState.OVERDUE:
|
||||
//用户密码已过期
|
||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_PASSWORD_EXPIRED);
|
||||
default:
|
||||
if (user.getPwdState() == 1) {
|
||||
throw new BusinessException(UserResponseEnum.NEED_MODIFY_PWD);
|
||||
}
|
||||
//用户状态正常,判断其他细节
|
||||
judgeFirstLogin(user, userStrategy);
|
||||
}
|
||||
//所有验证通过后,更新用户登录时间,以及错误登录记录的信息归零。
|
||||
user.setState(UserState.ENABLE);
|
||||
user.setLoginErrorTimes(0);
|
||||
user.setLoginTime(LocalDateTime.now());
|
||||
user.setFirstErrorTime(null);
|
||||
user.setLockTime(null);
|
||||
this.baseMapper.updateById(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user