微调
This commit is contained in:
@@ -2,7 +2,7 @@ package com.njcn.gather.device.pojo.vo;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.njcn.gather.util.DeviceUtil;
|
||||
import com.njcn.common.utils.EncryptionUtil;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@@ -109,7 +109,7 @@ public class PreDetection {
|
||||
|
||||
public String getDevKey() {
|
||||
if (StrUtil.isNotBlank(devKey)) {
|
||||
String key = DeviceUtil.decoderString(1, devKey);
|
||||
String key = EncryptionUtil.decoderString(1, devKey);
|
||||
if (StrUtil.isNotBlank(key)) {
|
||||
return key;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class PreDetection {
|
||||
|
||||
public String getDevCode() {
|
||||
if (StrUtil.isNotBlank(devCode)) {
|
||||
String code = DeviceUtil.decoderString(1, devCode);
|
||||
String code = EncryptionUtil.decoderString(1, devCode);
|
||||
if (StrUtil.isNotBlank(code)) {
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.poi.PullDown;
|
||||
import com.njcn.common.utils.EncryptionUtil;
|
||||
import com.njcn.db.mybatisplus.constant.DbConstant;
|
||||
import com.njcn.gather.device.mapper.PqDevMapper;
|
||||
import com.njcn.gather.device.pojo.enums.*;
|
||||
@@ -37,7 +38,6 @@ import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTypeService;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import com.njcn.gather.util.DeviceUtil;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -72,10 +72,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
Page<PqDev> page1 = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), this.getQueryWrapper(queryParam));
|
||||
page1.getRecords().forEach(p -> {
|
||||
if (ObjectUtil.isNotNull(p.getSeries())) {
|
||||
p.setSeries(DeviceUtil.decoderString(1, p.getSeries()));
|
||||
p.setSeries(EncryptionUtil.decoderString(1, p.getSeries()));
|
||||
}
|
||||
if (ObjectUtil.isNotNull(p.getDevKey())) {
|
||||
p.setDevKey(DeviceUtil.decoderString(1, p.getDevKey()));
|
||||
p.setDevKey(EncryptionUtil.decoderString(1, p.getDevKey()));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -103,8 +103,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
BeanUtil.copyProperties(pqDevParam, pqDev);
|
||||
if (pqDevParam.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqDevParam.getSeries()) && StrUtil.isNotBlank(pqDevParam.getDevKey())) {
|
||||
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
@@ -137,8 +137,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
BeanUtil.copyProperties(updateParam, pqDev);
|
||||
if (pqDev.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries()) && StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
@@ -434,10 +434,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries())) {
|
||||
pqDev.setSeries(DeviceUtil.decoderString(1, pqDev.getSeries()));
|
||||
pqDev.setSeries(EncryptionUtil.decoderString(1, pqDev.getSeries()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setDevKey(DeviceUtil.decoderString(1, pqDev.getDevKey()));
|
||||
pqDev.setDevKey(EncryptionUtil.decoderString(1, pqDev.getDevKey()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -470,10 +470,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries())) {
|
||||
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
|
||||
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
|
||||
}
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
@@ -701,8 +701,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
if (pqDev.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries()) && StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.njcn.gather.util;
|
||||
|
||||
import com.njcn.common.utils.sm.Sm4Utils;
|
||||
import com.njcn.common.utils.sm.ThreeDesUtil;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/1/6
|
||||
*/
|
||||
public class DeviceUtil {
|
||||
|
||||
|
||||
/**
|
||||
* cd 系统配置的解密方式
|
||||
* content 需要解密的内容
|
||||
* 解密对应内容
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2021/10/12
|
||||
*/
|
||||
public static String decoderString(Integer cd, String content) {
|
||||
String seriesTmp = null;
|
||||
if (cd == 0) {
|
||||
seriesTmp = Base64.decodeBase64(content).toString();
|
||||
} else if (cd == 1) {
|
||||
seriesTmp = ThreeDesUtil.decryptThreeDes(content);
|
||||
} else if (cd == 2) {
|
||||
//SM4加密密码
|
||||
String secretkey = Sm4Utils.globalSecretKey;
|
||||
Sm4Utils sm4 = new Sm4Utils(secretkey);
|
||||
seriesTmp = sm4.decryptData_ECB(content);
|
||||
}
|
||||
return seriesTmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* cd 系统配置的加密方式
|
||||
* content 需要加密的内容
|
||||
* 加密对应内容
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2021/10/12
|
||||
*/
|
||||
public static String encodeString(Integer cd, String content) {
|
||||
String key = null;
|
||||
if (cd == 0) {
|
||||
key = Base64.encodeBase64String(content.getBytes());
|
||||
} else if (cd == 1) {
|
||||
key = ThreeDesUtil.encryptThreeDes(content);
|
||||
} else if (cd == 2) {
|
||||
//SM4加密密码
|
||||
// String secretkey = Sm4Utils.globalSecretKey;
|
||||
// Sm4Utils sm4 = new Sm4Utils(secretkey);
|
||||
// key = sm4.encryptData_ECB(content);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user