薪酬系统, 关闭加密方法优化
This commit is contained in:
parent
ef3260085f
commit
0427ec5ed4
|
|
@ -8,6 +8,9 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import weaver.general.AES;
|
||||
import weaver.general.BaseBean;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 此AES加密工具类仅用于关联应用设置中是否开启加密的应用使用
|
||||
* 如另有需要,请重写工具类
|
||||
|
|
@ -77,12 +80,58 @@ public class AESEncryptUtil {
|
|||
*/
|
||||
public static String closeEncryptSetting(String encryptStr) {
|
||||
SalarySysConfPO sysConfPo = salarySysConfService.getOneByCode(SalarySysConstant.OPEN_APPLICATION_ENCRYPT);
|
||||
if (StringUtils.isNotBlank(encryptStr) && encryptStr.startsWith(SalarySysConstant.PRE_SIGN_ENCRYPT)) {
|
||||
encryptStr = encryptStr.substring(4, encryptStr.length());
|
||||
return AES.decrypt(encryptStr, aesEncryptScrect);
|
||||
} else if (sysConfPo == null && StringUtils.isNotBlank(encryptStr)) {
|
||||
return AES.decrypt(encryptStr, aesEncryptScrect);
|
||||
// if (StringUtils.isNotBlank(encryptStr) && encryptStr.startsWith(SalarySysConstant.PRE_SIGN_ENCRYPT)) {
|
||||
// encryptStr = encryptStr.substring(4, encryptStr.length());
|
||||
// return AES.decrypt(encryptStr, aesEncryptScrect);
|
||||
// } else if (sysConfPo == null && StringUtils.isNotBlank(encryptStr)) {
|
||||
// return AES.decrypt(encryptStr, aesEncryptScrect);
|
||||
// }
|
||||
// return encryptStr;
|
||||
if (encryptStr == null) {
|
||||
return null;
|
||||
} else {
|
||||
//AES_前缀的密文
|
||||
if (encryptStr.startsWith(SalarySysConstant.PRE_SIGN_ENCRYPT)) {
|
||||
encryptStr = encryptStr.substring(4, encryptStr.length());
|
||||
return AES.decrypt(encryptStr, aesEncryptScrect);
|
||||
} else if (isNumeric(encryptStr) || checkHaveChinese(encryptStr) || encryptStr.startsWith("{") || encryptStr.contains("-") || encryptStr.contains(".")) {
|
||||
return encryptStr;
|
||||
} else if ("null".equals(encryptStr) || " ".equals(encryptStr) || "".equals(encryptStr)) {
|
||||
return encryptStr;
|
||||
} else if (sysConfPo == null || sysConfPo.getConfValue().equals(OpenEnum.OFF.getValue())) {
|
||||
return AES.decrypt(encryptStr, aesEncryptScrect);
|
||||
} else {
|
||||
return encryptStr;
|
||||
}
|
||||
}
|
||||
return encryptStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否为整数或者小数或者负数
|
||||
*/
|
||||
public static boolean isNumeric(String str) {
|
||||
|
||||
Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$");
|
||||
Matcher isNum = pattern.matcher(str);
|
||||
if (!isNum.matches()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否包含中文字符
|
||||
*/
|
||||
public static boolean checkHaveChinese(String countname) {
|
||||
|
||||
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
|
||||
Matcher m = p.matcher(countname);
|
||||
if (m.find()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -770,7 +770,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
|
|||
po.setTotal(AESEncryptUtil.encrypt(po.getTotal()));
|
||||
}
|
||||
});
|
||||
List<List<InsuranceAccountDetailPO>> partition = Lists.partition(insuranceAccountDetailPos, 50);
|
||||
List<List<InsuranceAccountDetailPO>> partition = Lists.partition(insuranceAccountDetailPos, 20);
|
||||
InsuranceAccountDetailMapper mapper = sqlSession.getMapper(InsuranceAccountDetailMapper.class);
|
||||
partition.forEach(mapper::batchUpdate);
|
||||
sqlSession.commit();
|
||||
|
|
|
|||
Loading…
Reference in New Issue