薪资档案加密设置

This commit is contained in:
李栋 2022-10-17 11:14:21 +08:00
parent 918441fb38
commit fc94b50c60
2 changed files with 38 additions and 24 deletions

View File

@ -41,6 +41,9 @@ import com.engine.salary.sys.enums.*;
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.util.db.MapperProxyFactory;
import com.google.common.collect.Lists;
import com.weaver.util.threadPool.ThreadPoolUtil;
import com.weaver.util.threadPool.constant.ModulePoolEnum;
import com.weaver.util.threadPool.entity.LocalRunnable;
import dm.jdbc.util.IdGenerator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
@ -69,7 +72,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
return SqlProxyHandle.getProxy(SalarySysConfMapper.class);
}
private static final ExecutorService fixedThreadPool = newFixedThreadPool(13);
private static final ExecutorService fixedThreadPool = newFixedThreadPool(3);
private SalaryAcctResultMapper getSalaryAcctResultMapper() {
return MapperProxyFactory.getProxy(SalaryAcctResultMapper.class);
@ -297,8 +300,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
@Override
public Map<String, Object> saveEncryptSetting(AppSettingSaveParam param) {
Map<String, Object> resultMap = new HashMap<>();
boolean flag = false;
resultMap.put("isSuccess", false);
resultMap.put("isSuccess", true);
String progressId = UUID.randomUUID().toString();
resultMap.put("progressId", progressId);
try {
@ -313,25 +315,31 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
if (isOpenEncrypt.equals(OpenEnum.OPEN.getValue())) {
saveSettingByType(isOpenEncrypt, OPEN_APPLICATION_ENCRYPT, "开启加密设置", "app");
//对数据库数据加解密
flag = encryptOrDecryptDbWithAsync(isOpenEncrypt, progressId);
ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.erkai, "saveEncryptSetting", new LocalRunnable() {
@Override
public void execute() {
Boolean aBoolean = encryptOrDecryptDbWithAsync(isOpenEncrypt, progressId);
}
});
} else if (isOpenEncrypt.equals(OpenEnum.OFF.getValue())) {
flag = encryptOrDecryptDbWithAsync(isOpenEncrypt, progressId);
ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.erkai, "saveEncryptSetting", new LocalRunnable() {
@Override
public void execute() {
Boolean aBoolean = encryptOrDecryptDbWithAsync(isOpenEncrypt, progressId);
}
});
//不要调换方法的位置
saveSettingByType(isOpenEncrypt, OPEN_APPLICATION_ENCRYPT, "开启加密设置", "app");
}
}
Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS);
Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "success", 30);
resultMap.put("isSuccess", flag);
resultMap.put("isSuccess", true);
return resultMap;
} catch (Exception e) {
Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS);
Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "fail", 30);
resultMap.put("isSuccess", flag);
resultMap.put("isSuccess", false);
resultMap.put("msg", "系统异常请联系管理员");
return resultMap;
} finally {
Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS);
}
}
@ -450,7 +458,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
po.setResultValue(AESEncryptUtil.encrypt(po.getResultValue()));
}
});
List<List<ExcelAcctResultPO>> partition = Lists.partition(excelAcctResultPos, 1000);
List<List<ExcelAcctResultPO>> partition = Lists.partition(excelAcctResultPos, 100);
ExcelAcctResultMapper mapper = sqlSession.getMapper(ExcelAcctResultMapper.class);
partition.forEach(mapper::batchUpdate);
baseBean.writeLog("hrsa_excel_acct_result:");
@ -477,7 +485,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
po.setFieldValue(AESEncryptUtil.encrypt(po.getFieldValue()));
}
});
List<List<TaxDeclarationDetailPO>> partition = Lists.partition(taxDeclarationDetailPos, 1000);
List<List<TaxDeclarationDetailPO>> partition = Lists.partition(taxDeclarationDetailPos, 100);
TaxDeclarationDetailMapper mapper = sqlSession.getMapper(TaxDeclarationDetailMapper.class);
partition.forEach(mapper::batchUpdate);
sqlSession.commit();
@ -508,7 +516,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
po.setLowerLimit(AESEncryptUtil.encrypt(po.getLowerLimit()));
}
});
List<List<InsuranceSchemeDetailPO>> partition = Lists.partition(insuranceSchemeDetailPos, 1000);
List<List<InsuranceSchemeDetailPO>> partition = Lists.partition(insuranceSchemeDetailPos, 100);
InsuranceSchemeDetailMapper mapper = sqlSession.getMapper(InsuranceSchemeDetailMapper.class);
partition.forEach(mapper::batchUpdate);
sqlSession.commit();
@ -535,7 +543,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
po.setSocialPaymentBaseString(AESEncryptUtil.encrypt(po.getSocialPaymentBaseString()));
}
});
List<List<InsuranceArchivesSocialSchemePO>> partition = Lists.partition(insuranceArchivesSocialSchemePos, 1000);
List<List<InsuranceArchivesSocialSchemePO>> partition = Lists.partition(insuranceArchivesSocialSchemePos, 100);
SocialSchemeMapper mapper = sqlSession.getMapper(SocialSchemeMapper.class);
partition.forEach(mapper::batchUpdate);
sqlSession.commit();
@ -562,7 +570,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
po.setFundPaymentBaseString(AESEncryptUtil.encrypt(po.getFundPaymentBaseString()));
}
});
List<List<InsuranceArchivesFundSchemePO>> partition = Lists.partition(insuranceArchivesFundSchemePos, 1000);
List<List<InsuranceArchivesFundSchemePO>> partition = Lists.partition(insuranceArchivesFundSchemePos, 100);
FundSchemeMapper mapper = sqlSession.getMapper(FundSchemeMapper.class);
partition.forEach(mapper::batchUpdate);
sqlSession.commit();
@ -589,7 +597,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
po.setOtherPaymentBaseString(AESEncryptUtil.encrypt(po.getOtherPaymentBaseString()));
}
});
List<List<InsuranceArchivesOtherSchemePO>> partition = Lists.partition(insuranceArchivesOtherSchemePos, 1000);
List<List<InsuranceArchivesOtherSchemePO>> partition = Lists.partition(insuranceArchivesOtherSchemePos, 100);
OtherSchemeMapper mapper = sqlSession.getMapper(OtherSchemeMapper.class);
partition.forEach(mapper::batchUpdate);
sqlSession.commit();
@ -620,7 +628,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
po.setFundPay(AESEncryptUtil.encrypt(po.getFundPay()));
}
});
List<List<InsuranceAccountBatchPO>> partition = Lists.partition(insuranceAccountBatchPos, 1000);
List<List<InsuranceAccountBatchPO>> partition = Lists.partition(insuranceAccountBatchPos, 100);
InsuranceAccountBatchMapper mapper = sqlSession.getMapper(InsuranceAccountBatchMapper.class);
partition.forEach(mapper::batchUpdate);
sqlSession.commit();
@ -683,7 +691,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
po.setTotal(AESEncryptUtil.encrypt(po.getTotal()));
}
});
List<List<InsuranceAccountDetailPO>> partition = Lists.partition(insuranceAccountDetailPos, 1000);
List<List<InsuranceAccountDetailPO>> partition = Lists.partition(insuranceAccountDetailPos, 100);
InsuranceAccountDetailMapper mapper = sqlSession.getMapper(InsuranceAccountDetailMapper.class);
partition.forEach(mapper::batchUpdate);
sqlSession.commit();
@ -710,7 +718,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
po.setItemValue(AESEncryptUtil.encrypt(po.getItemValue()));
}
});
List<List<SalaryArchiveItemPO>> partition = Lists.partition(salaryArchiveItemPos, 1000);
List<List<SalaryArchiveItemPO>> partition = Lists.partition(salaryArchiveItemPos, 100);
SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class);
partition.forEach(mapper::batchUpdate);
sqlSession.commit();
@ -745,7 +753,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
po.setAddUpSupportElderly(AESEncryptUtil.encrypt(po.getAddUpSupportElderly()));
}
});
List<List<AddUpDeduction>> partition = Lists.partition(addUpDeductions, 1000);
List<List<AddUpDeduction>> partition = Lists.partition(addUpDeductions, 100);
AddUpDeductionMapper mapper = sqlSession.getMapper(AddUpDeductionMapper.class);
partition.forEach(mapper::updateData);
sqlSession.commit();
@ -778,7 +786,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
po.setDeductionAllowedDonation(AESEncryptUtil.encrypt(po.getDeductionAllowedDonation()));
}
});
List<List<OtherDeductionPO>> partition = Lists.partition(otherDeductionPos, 1000);
List<List<OtherDeductionPO>> partition = Lists.partition(otherDeductionPos, 100);
OtherDeductionMapper mapper = sqlSession.getMapper(OtherDeductionMapper.class);
partition.forEach(mapper::updateData);
sqlSession.commit();
@ -831,7 +839,7 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
po.setAddUpAdvanceTax(AESEncryptUtil.encrypt(po.getAddUpAdvanceTax()));
}
});
List<List<AddUpSituation>> partition = Lists.partition(addUpSituations, 1000);
List<List<AddUpSituation>> partition = Lists.partition(addUpSituations, 100);
AddUpSituationMapper mapper = sqlSession.getMapper(AddUpSituationMapper.class);
partition.forEach(mapper::updateData);
sqlSession.commit();
@ -847,10 +855,16 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
return 1;
});
int flag = submit.get() + submit1.get() + submit2.get() + submit3.get() + submit4.get() + submit5.get() + submit6.get() + submit7.get() + submit8.get() + submit9.get() + submit10.get() + submit11.get() + submit12.get();
Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "success", 30);
Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS);
return flag == 13;
} catch (Exception e) {
Util_DataCache.setObjVal(ENCRYPT_IN_PROGRESS + progressId, "fail", 30);
Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS);
baseBean.writeLog("应用设置加解密数据异常", e.getMessage());
return false;
} finally {
Util_DataCache.clearVal(AES_ENCRYPT_IN_PROGRESS);
}
}
}

View File

@ -229,7 +229,7 @@ public class SalarySystemConfigController {
}
/**
* 加密设置的状态
* 加密设置的进度
*
* @param request
* @param response