Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -2136,7 +2136,11 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
String phases = phaseEntry.getKey();
|
String phases = phaseEntry.getKey();
|
||||||
List<Integer> harmNums = phaseEntry.getValue();
|
List<Integer> harmNums = phaseEntry.getValue();
|
||||||
specialCaseDesc.append("第").append(formatHarmNumbers(harmNums, isInterHarmonic)).append("次谐波");
|
specialCaseDesc.append("第").append(formatHarmNumbers(harmNums, isInterHarmonic)).append("次谐波");
|
||||||
specialCaseDesc.append(phases).append("无样本数据满足误差比较的前置条件,无法执行有效性判定。");
|
// 如果是T相,则不拼接相别
|
||||||
|
if (!"T相".equals(phases)) {
|
||||||
|
specialCaseDesc.append(phases);
|
||||||
|
}
|
||||||
|
specialCaseDesc.append("无样本数据满足误差比较的前置条件,无法执行有效性判定。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2360,11 +2364,17 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
// 生成无法比较的描述
|
// 生成无法比较的描述
|
||||||
if (!unComparablePhases.isEmpty()) {
|
if (!unComparablePhases.isEmpty()) {
|
||||||
specialCaseDesc.append("注:");
|
specialCaseDesc.append("注:");
|
||||||
|
// 如果只有T相,则不拼接相别
|
||||||
|
if (unComparablePhases.size() == 1 && "T相".equals(unComparablePhases.get(0))) {
|
||||||
|
// T相不拼接相别
|
||||||
|
} else {
|
||||||
|
// 其他情况拼接相别
|
||||||
if (unComparablePhases.size() == 1) {
|
if (unComparablePhases.size() == 1) {
|
||||||
specialCaseDesc.append(unComparablePhases.get(0));
|
specialCaseDesc.append(unComparablePhases.get(0));
|
||||||
} else {
|
} else {
|
||||||
specialCaseDesc.append(String.join("、", unComparablePhases));
|
specialCaseDesc.append(String.join("、", unComparablePhases));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
specialCaseDesc.append("无样本数据满足误差比较的前置条件,无法执行有效性判定。");
|
specialCaseDesc.append("无样本数据满足误差比较的前置条件,无法执行有效性判定。");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import com.njcn.common.pojo.response.HttpResult;
|
|||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
import com.njcn.gather.tool.active.service.ActivateService;
|
import com.njcn.gather.tool.active.service.ActivateService;
|
||||||
import com.njcn.gather.tool.active.vo.ActivationCodePlaintext;
|
import com.njcn.gather.tool.active.vo.ActivationCodePlaintext;
|
||||||
import com.njcn.gather.tool.active.vo.ApplicationCodePlaintext;
|
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import com.njcn.web.utils.HttpResultUtil;
|
import com.njcn.web.utils.HttpResultUtil;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
@@ -33,12 +32,11 @@ public class ActivateController extends BaseController {
|
|||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@ApiOperation("生成设备申请码")
|
@ApiOperation("生成设备申请码")
|
||||||
@ApiImplicitParam(name = "data", value = "生成设备申请码参数", required = true)
|
|
||||||
@PostMapping("/generateApplicationCode")
|
@PostMapping("/generateApplicationCode")
|
||||||
public HttpResult generateApplicationCode(@RequestBody ApplicationCodePlaintext data) {
|
public HttpResult generateApplicationCode() {
|
||||||
String methodDescribe = getMethodDescribe("generateApplicationCode");
|
String methodDescribe = getMethodDescribe("generateApplicationCode");
|
||||||
LogUtil.njcnDebug(log, "{},生成设备申请码:{}", methodDescribe, JSONUtil.toJsonStr(data));
|
LogUtil.njcnDebug(log, "{},生成设备申请码", methodDescribe);
|
||||||
String applicationCode = activateService.generateApplicationCode(data);
|
String applicationCode = activateService.generateApplicationCode();
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, applicationCode, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, applicationCode, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +93,7 @@ public class ActivateController extends BaseController {
|
|||||||
@ApiImplicitParam(name = "params", value = "参数", required = true, dataType = "ApplicationCodeParams")
|
@ApiImplicitParam(name = "params", value = "参数", required = true, dataType = "ApplicationCodeParams")
|
||||||
@PostMapping("/generateActivationCode")
|
@PostMapping("/generateActivationCode")
|
||||||
public HttpResult generateActivationCode(@RequestBody ApplicationCodeParams params) {
|
public HttpResult generateActivationCode(@RequestBody ApplicationCodeParams params) {
|
||||||
String activationCode = activateService.generateActivationCode(params.getApplicationCode(), params.getPermanently());
|
String activationCode = activateService.generateActivationCode(params.getApplicationCode(), params.getActivationModule());
|
||||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), activationCode, "");
|
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), activationCode, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +102,7 @@ public class ActivateController extends BaseController {
|
|||||||
public static class ApplicationCodeParams {
|
public static class ApplicationCodeParams {
|
||||||
@ApiModelProperty(value = "设备申请码", required = true)
|
@ApiModelProperty(value = "设备申请码", required = true)
|
||||||
private String applicationCode;
|
private String applicationCode;
|
||||||
@ApiModelProperty(value = "是否永久激活", example = "1", required = true)
|
@ApiModelProperty(value = "激活模块", required = true)
|
||||||
private int permanently;
|
private ActivationCodePlaintext activationModule;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.njcn.gather.tool.active.service;
|
package com.njcn.gather.tool.active.service;
|
||||||
|
|
||||||
import com.njcn.gather.tool.active.vo.ActivationCodePlaintext;
|
import com.njcn.gather.tool.active.vo.ActivationCodePlaintext;
|
||||||
import com.njcn.gather.tool.active.vo.ApplicationCodePlaintext;
|
|
||||||
|
|
||||||
public interface ActivateService {
|
public interface ActivateService {
|
||||||
|
|
||||||
@@ -9,10 +8,9 @@ public interface ActivateService {
|
|||||||
/**
|
/**
|
||||||
* 生成设备申请码
|
* 生成设备申请码
|
||||||
*
|
*
|
||||||
* @param data
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String generateApplicationCode(ApplicationCodePlaintext data);
|
String generateApplicationCode();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证激活码
|
* 验证激活码
|
||||||
@@ -33,10 +31,10 @@ public interface ActivateService {
|
|||||||
* 生成设备激活码
|
* 生成设备激活码
|
||||||
*
|
*
|
||||||
* @param applicationCode 申请码
|
* @param applicationCode 申请码
|
||||||
* @param permanently 是否永久激活
|
* @param activationCodePlaintext
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String generateActivationCode(String applicationCode, int permanently);
|
String generateActivationCode(String applicationCode, ActivationCodePlaintext activationCodePlaintext);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,10 +26,11 @@ public class ActivateServiceImpl implements ActivateService {
|
|||||||
private final ActivateProperties props;
|
private final ActivateProperties props;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateApplicationCode(ApplicationCodePlaintext data) {
|
public String generateApplicationCode() {
|
||||||
// 获取当前设备MAC地址
|
// 获取当前设备MAC地址
|
||||||
String macAddress = NetUtil.getLocalMacAddress();
|
String macAddress = NetUtil.getLocalMacAddress();
|
||||||
log.debug("当前设备MAC地址:{}", macAddress);
|
log.debug("当前设备MAC地址:{}", macAddress);
|
||||||
|
ApplicationCodePlaintext data = new ApplicationCodePlaintext();
|
||||||
data.setMacAddress(macAddress);
|
data.setMacAddress(macAddress);
|
||||||
String plaintext = JSONUtil.toJsonStr(data);
|
String plaintext = JSONUtil.toJsonStr(data);
|
||||||
// RSA 加密
|
// RSA 加密
|
||||||
@@ -79,7 +80,7 @@ public class ActivateServiceImpl implements ActivateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateActivationCode(String applicationCode, int permanently) {
|
public String generateActivationCode(String applicationCode, ActivationCodePlaintext activationCodePlaintext) {
|
||||||
// RSA 解密
|
// RSA 解密
|
||||||
String plaintext;
|
String plaintext;
|
||||||
try {
|
try {
|
||||||
@@ -88,27 +89,18 @@ public class ActivateServiceImpl implements ActivateService {
|
|||||||
log.error("申请码解密失败", e);
|
log.error("申请码解密失败", e);
|
||||||
throw new BusinessException(CommonResponseEnum.FAIL, "无效的申请码");
|
throw new BusinessException(CommonResponseEnum.FAIL, "无效的申请码");
|
||||||
}
|
}
|
||||||
ActivationCodePlaintext activationCodePlaintext = JSONUtil.toBean(plaintext, ActivationCodePlaintext.class);
|
ApplicationCodePlaintext applicationCodePlaintext = JSONUtil.toBean(plaintext, ApplicationCodePlaintext.class);
|
||||||
if (activationCodePlaintext == null) {
|
if (applicationCodePlaintext == null) {
|
||||||
log.error("申请码内容为空");
|
log.error("申请码内容为空");
|
||||||
throw new BusinessException(CommonResponseEnum.FAIL, "无效的申请码");
|
throw new BusinessException(CommonResponseEnum.FAIL, "无效的申请码");
|
||||||
}
|
}
|
||||||
|
String macAddress = applicationCodePlaintext.getMacAddress();
|
||||||
|
if (StrUtil.isBlank(macAddress)) {
|
||||||
|
log.error("mac地址为空");
|
||||||
|
throw new BusinessException(CommonResponseEnum.FAIL, "无效的申请码");
|
||||||
|
}
|
||||||
// 激活码明文
|
// 激活码明文
|
||||||
ActivationModule contrast = activationCodePlaintext.getContrast();
|
activationCodePlaintext.setMacAddress(applicationCodePlaintext.getMacAddress());
|
||||||
ActivationModule simulate = activationCodePlaintext.getSimulate();
|
|
||||||
ActivationModule digital = activationCodePlaintext.getDigital();
|
|
||||||
if (contrast.isApply()) {
|
|
||||||
contrast.setPermanently(permanently);
|
|
||||||
activationCodePlaintext.setContrast(contrast);
|
|
||||||
}
|
|
||||||
if (simulate.isApply()) {
|
|
||||||
simulate.setPermanently(permanently);
|
|
||||||
activationCodePlaintext.setSimulate(simulate);
|
|
||||||
}
|
|
||||||
if (digital.isApply()) {
|
|
||||||
digital.setPermanently(permanently);
|
|
||||||
activationCodePlaintext.setDigital(digital);
|
|
||||||
}
|
|
||||||
// RSA 加密
|
// RSA 加密
|
||||||
String jsonStr = JSONUtil.toJsonStr(activationCodePlaintext);
|
String jsonStr = JSONUtil.toJsonStr(activationCodePlaintext);
|
||||||
log.info("生成激活码明文:{}", jsonStr);
|
log.info("生成激活码明文:{}", jsonStr);
|
||||||
@@ -133,20 +125,7 @@ public class ActivateServiceImpl implements ActivateService {
|
|||||||
ActivationModule newContrast = newActivationCodePlaintext.getContrast();
|
ActivationModule newContrast = newActivationCodePlaintext.getContrast();
|
||||||
ActivationModule newDigital = newActivationCodePlaintext.getDigital();
|
ActivationModule newDigital = newActivationCodePlaintext.getDigital();
|
||||||
ActivationModule newSimulate = newActivationCodePlaintext.getSimulate();
|
ActivationModule newSimulate = newActivationCodePlaintext.getSimulate();
|
||||||
boolean verifyStatus = false;
|
|
||||||
if (newContrast.isApply() && newContrast.isPermanently()) {
|
|
||||||
verifyStatus = true;
|
|
||||||
}
|
|
||||||
if (newDigital.isApply() && newDigital.isPermanently()) {
|
|
||||||
verifyStatus = true;
|
|
||||||
}
|
|
||||||
if (newSimulate.isApply() && newSimulate.isPermanently()) {
|
|
||||||
verifyStatus = true;
|
|
||||||
}
|
|
||||||
if (!verifyStatus) {
|
|
||||||
log.error("授权码格式错误");
|
|
||||||
throw new BusinessException(CommonResponseEnum.FAIL, "无效的激活码");
|
|
||||||
}
|
|
||||||
String licenseFilePath = props.getLicenseFilePath();
|
String licenseFilePath = props.getLicenseFilePath();
|
||||||
log.info("授权文件路径:{}", licenseFilePath);
|
log.info("授权文件路径:{}", licenseFilePath);
|
||||||
ActivationCodePlaintext oldActivationCodePlaintext = this.readLicenseFile();
|
ActivationCodePlaintext oldActivationCodePlaintext = this.readLicenseFile();
|
||||||
@@ -159,13 +138,13 @@ public class ActivateServiceImpl implements ActivateService {
|
|||||||
} else {
|
} else {
|
||||||
log.info("旧授权码明文:{}", JSONUtil.toJsonStr(oldActivationCodePlaintext));
|
log.info("旧授权码明文:{}", JSONUtil.toJsonStr(oldActivationCodePlaintext));
|
||||||
oldActivationCodePlaintext.setMacAddress(newActivationCodePlaintext.getMacAddress());
|
oldActivationCodePlaintext.setMacAddress(newActivationCodePlaintext.getMacAddress());
|
||||||
if (newContrast.isApply()) {
|
if (newContrast != null && newContrast.isPermanently()) {
|
||||||
oldActivationCodePlaintext.setContrast(newContrast);
|
oldActivationCodePlaintext.setContrast(newContrast);
|
||||||
}
|
}
|
||||||
if (newDigital.isApply()) {
|
if (newDigital != null && newDigital.isPermanently()) {
|
||||||
oldActivationCodePlaintext.setDigital(newDigital);
|
oldActivationCodePlaintext.setDigital(newDigital);
|
||||||
}
|
}
|
||||||
if (newSimulate.isApply()) {
|
if (newSimulate != null && newSimulate.isPermanently()) {
|
||||||
oldActivationCodePlaintext.setSimulate(newSimulate);
|
oldActivationCodePlaintext.setSimulate(newSimulate);
|
||||||
}
|
}
|
||||||
log.info("最新授权码明文:{}", JSONUtil.toJsonStr(oldActivationCodePlaintext));
|
log.info("最新授权码明文:{}", JSONUtil.toJsonStr(oldActivationCodePlaintext));
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package com.njcn.gather.tool.active.vo;
|
package com.njcn.gather.tool.active.vo;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class ActivationCodePlaintext {
|
public class ActivationCodePlaintext extends ApplicationCodePlaintext {
|
||||||
/**
|
|
||||||
* mac地址
|
|
||||||
*/
|
|
||||||
private String macAddress;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模拟式模块
|
* 模拟式模块
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package com.njcn.gather.tool.active.vo;
|
package com.njcn.gather.tool.active.vo;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
@Data
|
||||||
public class ActivationModule extends ApplicationModule {
|
public class ActivationModule {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否永久授权
|
* 是否永久授权
|
||||||
|
|||||||
@@ -13,23 +13,4 @@ public class ApplicationCodePlaintext {
|
|||||||
@ApiModelProperty(value = "mac地址", hidden = true)
|
@ApiModelProperty(value = "mac地址", hidden = true)
|
||||||
private String macAddress;
|
private String macAddress;
|
||||||
|
|
||||||
/**
|
|
||||||
* 模拟式模块
|
|
||||||
*/
|
|
||||||
@ApiModelProperty("模拟式模块")
|
|
||||||
private ApplicationModule simulate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字式模块
|
|
||||||
*/
|
|
||||||
@ApiModelProperty("数字式模块")
|
|
||||||
private ApplicationModule digital;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 比对式模块
|
|
||||||
*/
|
|
||||||
@ApiModelProperty("比对式模块")
|
|
||||||
private ApplicationModule contrast;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.njcn.gather.tool.active.vo;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class ApplicationModule {
|
|
||||||
/**
|
|
||||||
* 是否申请 1是 0否
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "是否申请 1是 0否")
|
|
||||||
private int apply;
|
|
||||||
|
|
||||||
public boolean isApply() {
|
|
||||||
return apply == 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user