diff --git a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java index 42fa2735..bb87960b 100644 --- a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java @@ -2136,7 +2136,11 @@ public class ResultServiceImpl implements IResultService { String phases = phaseEntry.getKey(); List harmNums = phaseEntry.getValue(); specialCaseDesc.append("第").append(formatHarmNumbers(harmNums, isInterHarmonic)).append("次谐波"); - specialCaseDesc.append(phases).append("无样本数据满足误差比较的前置条件,无法执行有效性判定。"); + // 如果是T相,则不拼接相别 + if (!"T相".equals(phases)) { + specialCaseDesc.append(phases); + } + specialCaseDesc.append("无样本数据满足误差比较的前置条件,无法执行有效性判定。"); } } } @@ -2360,10 +2364,16 @@ public class ResultServiceImpl implements IResultService { // 生成无法比较的描述 if (!unComparablePhases.isEmpty()) { specialCaseDesc.append("注:"); - if (unComparablePhases.size() == 1) { - specialCaseDesc.append(unComparablePhases.get(0)); + // 如果只有T相,则不拼接相别 + if (unComparablePhases.size() == 1 && "T相".equals(unComparablePhases.get(0))) { + // T相不拼接相别 } else { - specialCaseDesc.append(String.join("、", unComparablePhases)); + // 其他情况拼接相别 + if (unComparablePhases.size() == 1) { + specialCaseDesc.append(unComparablePhases.get(0)); + } else { + specialCaseDesc.append(String.join("、", unComparablePhases)); + } } specialCaseDesc.append("无样本数据满足误差比较的前置条件,无法执行有效性判定。"); } diff --git a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/controller/ActivateController.java b/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/controller/ActivateController.java index 63b27ef1..630ff5a5 100644 --- a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/controller/ActivateController.java +++ b/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/controller/ActivateController.java @@ -10,7 +10,6 @@ import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.LogUtil; import com.njcn.gather.tool.active.service.ActivateService; 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.utils.HttpResultUtil; import io.swagger.annotations.*; @@ -33,12 +32,11 @@ public class ActivateController extends BaseController { @OperateInfo(info = LogEnum.BUSINESS_COMMON) @ApiOperation("生成设备申请码") - @ApiImplicitParam(name = "data", value = "生成设备申请码参数", required = true) @PostMapping("/generateApplicationCode") - public HttpResult generateApplicationCode(@RequestBody ApplicationCodePlaintext data) { + public HttpResult generateApplicationCode() { String methodDescribe = getMethodDescribe("generateApplicationCode"); - LogUtil.njcnDebug(log, "{},生成设备申请码:{}", methodDescribe, JSONUtil.toJsonStr(data)); - String applicationCode = activateService.generateApplicationCode(data); + LogUtil.njcnDebug(log, "{},生成设备申请码", methodDescribe); + String applicationCode = activateService.generateApplicationCode(); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, applicationCode, methodDescribe); } @@ -95,7 +93,7 @@ public class ActivateController extends BaseController { @ApiImplicitParam(name = "params", value = "参数", required = true, dataType = "ApplicationCodeParams") @PostMapping("/generateActivationCode") 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, ""); } @@ -104,7 +102,7 @@ public class ActivateController extends BaseController { public static class ApplicationCodeParams { @ApiModelProperty(value = "设备申请码", required = true) private String applicationCode; - @ApiModelProperty(value = "是否永久激活", example = "1", required = true) - private int permanently; + @ApiModelProperty(value = "激活模块", required = true) + private ActivationCodePlaintext activationModule; } } \ No newline at end of file diff --git a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/service/ActivateService.java b/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/service/ActivateService.java index b6adf10e..4c9e4628 100644 --- a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/service/ActivateService.java +++ b/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/service/ActivateService.java @@ -1,7 +1,6 @@ package com.njcn.gather.tool.active.service; import com.njcn.gather.tool.active.vo.ActivationCodePlaintext; -import com.njcn.gather.tool.active.vo.ApplicationCodePlaintext; public interface ActivateService { @@ -9,10 +8,9 @@ public interface ActivateService { /** * 生成设备申请码 * - * @param data * @return */ - String generateApplicationCode(ApplicationCodePlaintext data); + String generateApplicationCode(); /** * 验证激活码 @@ -32,11 +30,11 @@ public interface ActivateService { /** * 生成设备激活码 * - * @param applicationCode 申请码 - * @param permanently 是否永久激活 + * @param applicationCode 申请码 + * @param activationCodePlaintext * @return */ - String generateActivationCode(String applicationCode, int permanently); + String generateActivationCode(String applicationCode, ActivationCodePlaintext activationCodePlaintext); } diff --git a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/service/impl/ActivateServiceImpl.java b/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/service/impl/ActivateServiceImpl.java index 178de594..d9d33848 100644 --- a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/service/impl/ActivateServiceImpl.java +++ b/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/service/impl/ActivateServiceImpl.java @@ -26,10 +26,11 @@ public class ActivateServiceImpl implements ActivateService { private final ActivateProperties props; @Override - public String generateApplicationCode(ApplicationCodePlaintext data) { + public String generateApplicationCode() { // 获取当前设备MAC地址 String macAddress = NetUtil.getLocalMacAddress(); log.debug("当前设备MAC地址:{}", macAddress); + ApplicationCodePlaintext data = new ApplicationCodePlaintext(); data.setMacAddress(macAddress); String plaintext = JSONUtil.toJsonStr(data); // RSA 加密 @@ -79,7 +80,7 @@ public class ActivateServiceImpl implements ActivateService { } @Override - public String generateActivationCode(String applicationCode, int permanently) { + public String generateActivationCode(String applicationCode, ActivationCodePlaintext activationCodePlaintext) { // RSA 解密 String plaintext; try { @@ -88,27 +89,18 @@ public class ActivateServiceImpl implements ActivateService { log.error("申请码解密失败", e); throw new BusinessException(CommonResponseEnum.FAIL, "无效的申请码"); } - ActivationCodePlaintext activationCodePlaintext = JSONUtil.toBean(plaintext, ActivationCodePlaintext.class); - if (activationCodePlaintext == null) { + ApplicationCodePlaintext applicationCodePlaintext = JSONUtil.toBean(plaintext, ApplicationCodePlaintext.class); + if (applicationCodePlaintext == null) { log.error("申请码内容为空"); 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(); - 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); - } + activationCodePlaintext.setMacAddress(applicationCodePlaintext.getMacAddress()); // RSA 加密 String jsonStr = JSONUtil.toJsonStr(activationCodePlaintext); log.info("生成激活码明文:{}", jsonStr); @@ -133,20 +125,7 @@ public class ActivateServiceImpl implements ActivateService { ActivationModule newContrast = newActivationCodePlaintext.getContrast(); ActivationModule newDigital = newActivationCodePlaintext.getDigital(); 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(); log.info("授权文件路径:{}", licenseFilePath); ActivationCodePlaintext oldActivationCodePlaintext = this.readLicenseFile(); @@ -159,13 +138,13 @@ public class ActivateServiceImpl implements ActivateService { } else { log.info("旧授权码明文:{}", JSONUtil.toJsonStr(oldActivationCodePlaintext)); oldActivationCodePlaintext.setMacAddress(newActivationCodePlaintext.getMacAddress()); - if (newContrast.isApply()) { + if (newContrast != null && newContrast.isPermanently()) { oldActivationCodePlaintext.setContrast(newContrast); } - if (newDigital.isApply()) { + if (newDigital != null && newDigital.isPermanently()) { oldActivationCodePlaintext.setDigital(newDigital); } - if (newSimulate.isApply()) { + if (newSimulate != null && newSimulate.isPermanently()) { oldActivationCodePlaintext.setSimulate(newSimulate); } log.info("最新授权码明文:{}", JSONUtil.toJsonStr(oldActivationCodePlaintext)); diff --git a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ActivationCodePlaintext.java b/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ActivationCodePlaintext.java index f1953b03..28648063 100644 --- a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ActivationCodePlaintext.java +++ b/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ActivationCodePlaintext.java @@ -1,13 +1,11 @@ package com.njcn.gather.tool.active.vo; import lombok.Data; +import lombok.EqualsAndHashCode; +@EqualsAndHashCode(callSuper = true) @Data -public class ActivationCodePlaintext { - /** - * mac地址 - */ - private String macAddress; +public class ActivationCodePlaintext extends ApplicationCodePlaintext { /** * 模拟式模块 diff --git a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ActivationModule.java b/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ActivationModule.java index 0253153f..1b6e2cf6 100644 --- a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ActivationModule.java +++ b/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ActivationModule.java @@ -1,11 +1,9 @@ package com.njcn.gather.tool.active.vo; import lombok.Data; -import lombok.EqualsAndHashCode; -@EqualsAndHashCode(callSuper = true) @Data -public class ActivationModule extends ApplicationModule { +public class ActivationModule { /** * 是否永久授权 diff --git a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ApplicationCodePlaintext.java b/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ApplicationCodePlaintext.java index 1c549c2d..40b26781 100644 --- a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ApplicationCodePlaintext.java +++ b/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ApplicationCodePlaintext.java @@ -13,23 +13,4 @@ public class ApplicationCodePlaintext { @ApiModelProperty(value = "mac地址", hidden = true) private String macAddress; - /** - * 模拟式模块 - */ - @ApiModelProperty("模拟式模块") - private ApplicationModule simulate; - - /** - * 数字式模块 - */ - @ApiModelProperty("数字式模块") - private ApplicationModule digital; - - /** - * 比对式模块 - */ - @ApiModelProperty("比对式模块") - private ApplicationModule contrast; - - } diff --git a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ApplicationModule.java b/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ApplicationModule.java deleted file mode 100644 index 9c1cdfa6..00000000 --- a/tools/activate-tool/src/main/java/com/njcn/gather/tool/active/vo/ApplicationModule.java +++ /dev/null @@ -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; - } -} \ No newline at end of file