Commit 95d46883 authored by fangxinjiang's avatar fangxinjiang

预估生成逻辑更新-fxj

parent 28377cae
......@@ -2185,16 +2185,60 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
**/
@Override
public void everyMonthCreateForecastLibary() {
List<TSocialFundInfo> socialFundInfoList = socialFundInfoMapper.selectList(Wrappers.<TSocialFundInfo>query().lambda());
int pageSize = 5000; // 根据实际内存调整,建议从配置文件中读取
int page = 0;
String payMonth = DateUtil.addMonth(1);
Page<TSocialFundInfo> pageInfo;
List<TSocialFundInfo> batch;
Map<String,TSettleDomainSelectVo> mapSelectVo = this.getSelectVoMap();
try {
while (true) {
pageInfo = new Page<>(page, pageSize);
batch = socialFundInfoMapper.selectPage(pageInfo,
Wrappers.<TSocialFundInfo>query().lambda()).getRecords();
if (batch == null || batch.isEmpty()) {
break; // 明确退出条件
}
// 并行处理,确保线程安全性
batch.parallelStream().forEach(socialFundInfo -> {
try {
everyMonthCreateForecastLibaryCore(payMonth, socialFundInfo,mapSelectVo);
} catch (Exception e) {
// 捕获并记录单个处理中的异常,避免影响其他数据
log.error("Error processing socialFundInfo: " + socialFundInfo.getId() + ", Exception: " + e.getMessage());
}
});
page++;
// 增加内存监控点
if((Runtime.getRuntime().freeMemory() * 100 / Runtime.getRuntime().totalMemory()) < 20) {
log.error("内存警戒值达到80%使用率=>"+"可用内存:"+(Runtime.getRuntime().freeMemory()));
}else {
log.info("本次可用内存:"+(Runtime.getRuntime().freeMemory()) + ",总内存:" + Runtime.getRuntime().totalMemory());
}
}
} catch (Exception e) {
// 捕获外部异常,防止程序崩溃
log.error("An error occurred during batch processing: " + e.getMessage());
}
// 移除强制GC,让JVM自动管理内存
/*List<TSocialFundInfo> socialFundInfoList = socialFundInfoMapper.selectList(Wrappers.<TSocialFundInfo>query().lambda());
if (socialFundInfoList != null && !socialFundInfoList.isEmpty()) {
String payMonth = DateUtil.addMonth(1);
for (TSocialFundInfo socialFundInfo : socialFundInfoList) {
everyMonthCreateForecastLibaryCore(payMonth, socialFundInfo);
}
}
}*/
}
private R<String> everyMonthCreateForecastLibaryCore(String payMonth, TSocialFundInfo socialFundInfo) {
private R<String> everyMonthCreateForecastLibaryCore(String payMonth,
TSocialFundInfo socialFundInfo,
Map<String,TSettleDomainSelectVo> mapSelectVo) {
String empIdCard = socialFundInfo.getEmpIdcard();
//定义未推送的按条件查询得到的预估数据
List<TForecastLibrary> librarySocialList = null;
......@@ -2295,7 +2339,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
List<TForecastLibrary> libraryFundInfoListSocial = new ArrayList<>();
List<TForecastLibrary> libraryFundInfoListFund = new ArrayList<>();
//社保收入
Map<String,TSettleDomainSelectVo> mapSelectVo = this.getSelectVoMap();
//Map<String,TSettleDomainSelectVo> mapSelectVo = this.getSelectVoMap();
String redisKey = String.valueOf(UUID.randomUUID()).replaceAll("-", "") + "_incomePush";
if (Common.isNotNull(socialFundInfo.getSocialId())
&& CommonConstants.FOUR_STRING.equals(socialFundInfo.getSocialStatus())
......@@ -2453,6 +2497,7 @@ public class TForecastLibraryServiceImpl extends ServiceImpl<TForecastLibraryMap
return mapSelectVo;
}
@Override
public void createForecastFundInfo() {
long count = baseMapper.selectCount(Wrappers.<TForecastLibrary>query().lambda()
......
......@@ -962,7 +962,7 @@ public class DoJointSocialTask {
settleDomain = selectVoMap.get(library.getDeptNo());
if (Common.isEmpty(settleDomain)) {
// 抛出异常错误,通过邮件提醒处理
log.error("获取结算主体(“+library.getDeptNo()+”)异常,请检查传参和档案服务状态!");
log.error("获取结算主体("+library.getDeptNo()+")异常,请检查传参和档案服务状态!");
continue;
//ServiceUtil.runTimeExceptionDiy("获取结算主体异常,请检查传参和档案服务状态!");
}
......@@ -1259,7 +1259,7 @@ public class DoJointSocialTask {
settleDomain = selectVoMap.get(library.getDeptNo());
if (Common.isEmpty(settleDomain)) {
// 抛出异常错误,通过邮件提醒处理
log.error("获取结算主体(“+library.getDeptNo()+”)异常,请检查传参和档案服务状态!");
log.error("获取结算主体("+library.getDeptNo()+")异常,请检查传参和档案服务状态!");
continue;
//ServiceUtil.runTimeExceptionDiy("获取结算主体异常,请检查传参和档案服务状态!");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment