Commit 7380f8b2 authored by fangxinjiang's avatar fangxinjiang

社保批量办理事务控制范围减少-fxj

parent b619bd72
...@@ -25,6 +25,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; ...@@ -25,6 +25,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.social.entity.TDispatchInfo; import com.yifu.cloud.plus.v1.yifu.social.entity.TDispatchInfo;
import com.yifu.cloud.plus.v1.yifu.social.entity.TSocialFundInfo;
import com.yifu.cloud.plus.v1.yifu.social.vo.*; import com.yifu.cloud.plus.v1.yifu.social.vo.*;
import org.apache.shardingsphere.transaction.annotation.ShardingTransactionType; import org.apache.shardingsphere.transaction.annotation.ShardingTransactionType;
import org.apache.shardingsphere.transaction.core.TransactionType; import org.apache.shardingsphere.transaction.core.TransactionType;
...@@ -34,6 +35,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -34,6 +35,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* 派单信息记录表 * 派单信息记录表
...@@ -84,6 +86,9 @@ public interface TDispatchInfoService extends IService<TDispatchInfo> { ...@@ -84,6 +86,9 @@ public interface TDispatchInfoService extends IService<TDispatchInfo> {
// isAutoFlag:是否社保士兵的自动办理,true :是 // isAutoFlag:是否社保士兵的自动办理,true :是
R<List<ErrorMessage>> addApplyHandle(List<String> ids, String typeSub, String handleStatus, String handleRemark, String socialType, String remark, YifuUser user, boolean isAutoHandle); R<List<ErrorMessage>> addApplyHandle(List<String> ids, String typeSub, String handleStatus, String handleRemark, String socialType, String remark, YifuUser user, boolean isAutoHandle);
//代码优化-解决死锁问题:fxj 2024-12-18 事务控制集中到每次循环,而不是所有for循环
boolean extracted(ConcurrentHashMap<String, String> socialMap, ConcurrentHashMap<String, String> fundMap, String typeSub, YifuUser user, int flag, String handleStatus, String handleRemark, String socialType, String remark, boolean isAutoHandle, List<ErrorMessage> errorList, Map<String, TSocialFundInfo> socialFundMap, TDispatchInfo dis);
/** /**
* @Description: 社保士兵导出 * @Description: 社保士兵导出
* @Author: hgw * @Author: hgw
......
...@@ -3944,7 +3944,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -3944,7 +3944,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
* @Author fxj * @Author fxj
* @Date 2022-07-26 * @Date 2022-07-26
**/ **/
@Transactional(rollbackFor = Exception.class) //@Transactional(rollbackFor = Exception.class)
public List<ErrorMessage> addBatchApplyHandle(ConcurrentHashMap<String, String> socialMap,ConcurrentHashMap<String, String> fundMap, public List<ErrorMessage> addBatchApplyHandle(ConcurrentHashMap<String, String> socialMap,ConcurrentHashMap<String, String> fundMap,
List<String> idsList, String typeSub, YifuUser user List<String> idsList, String typeSub, YifuUser user
, int flag, String handleStatus, String handleRemark, String socialType, String remark, boolean isAutoHandle) { , int flag, String handleStatus, String handleRemark, String socialType, String remark, boolean isAutoHandle) {
...@@ -3958,6 +3958,26 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -3958,6 +3958,26 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
// 获取所有派单查询信息 // 获取所有派单查询信息
Map<String,TSocialFundInfo> socialFundMap = initSocialFundMap(disList); Map<String,TSocialFundInfo> socialFundMap = initSocialFundMap(disList);
try { try {
for (TDispatchInfo dis : disList) {
if (extracted(socialMap, fundMap, typeSub, user, flag, handleStatus, handleRemark, socialType, remark, isAutoHandle, errorList, socialFundMap, dis))
continue;
}
} catch(Exception e){
log.error(DispatchConstants.DISPATCH_EXCEPTION, e);
errorList.add(new ErrorMessage(-1, DispatchConstants.DISPATCH_EXCEPTION + e.getMessage()));
return errorList;
}
} else{
errorList.add(new ErrorMessage(-1, DispatchConstants.NO_OPERATOR_DATA));
return errorList;
}
return errorList;
}
//代码优化-解决死锁问题:fxj 2024-12-18 事务控制集中到每次循环,而不是所有for循环 TODO参数过多需要二次优化
@Override
@Transactional(rollbackFor = Exception.class)
public boolean extracted(ConcurrentHashMap<String, String> socialMap, ConcurrentHashMap<String, String> fundMap, String typeSub, YifuUser user, int flag, String handleStatus, String handleRemark, String socialType, String remark, boolean isAutoHandle, List<ErrorMessage> errorList, Map<String, TSocialFundInfo> socialFundMap, TDispatchInfo dis) {
TSocialInfo socialInfo = null; TSocialInfo socialInfo = null;
TProvidentFund providentFund = null; TProvidentFund providentFund = null;
TAuditInfo auditInfo = null; TAuditInfo auditInfo = null;
...@@ -3971,7 +3991,6 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -3971,7 +3991,6 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
boolean auditFlag = true; boolean auditFlag = true;
boolean partSuccess = false; boolean partSuccess = false;
TDispatchSocialFundInfo socialFundInfo; TDispatchSocialFundInfo socialFundInfo;
for (TDispatchInfo dis : disList) {
auditFlag = true; auditFlag = true;
if (CommonConstants.ZERO_STRING.equals(typeSub)) { if (CommonConstants.ZERO_STRING.equals(typeSub)) {
forecastFlag = CommonConstants.ONE_INT; forecastFlag = CommonConstants.ONE_INT;
...@@ -3984,7 +4003,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -3984,7 +4003,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
} }
if (Common.isEmpty(sf)){ if (Common.isEmpty(sf)){
errorList.add(new ErrorMessage(-1, "找不到员工社保公积金查询数据:" + dis.getEmpName())); errorList.add(new ErrorMessage(-1, "找不到员工社保公积金查询数据:" + dis.getEmpName()));
continue; return true;
} }
partSuccess = Common.isNotNull(sf) && Common.isNotNull(dis.getSocialId()) partSuccess = Common.isNotNull(sf) && Common.isNotNull(dis.getSocialId())
&& (CommonConstants.ONE_STRING.equals(sf.getPensionHandle()) && (CommonConstants.ONE_STRING.equals(sf.getPensionHandle())
...@@ -4018,20 +4037,20 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -4018,20 +4037,20 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
); );
if (!CommonConstants.TWO_STRING.equals(dis.getStatus())) { if (!CommonConstants.TWO_STRING.equals(dis.getStatus())) {
errorList.add(new ErrorMessage(-1, "已办理完结,请勿重复操作:" + dis.getEmpName())); errorList.add(new ErrorMessage(-1, "已办理完结,请勿重复操作:" + dis.getEmpName()));
continue; return true;
} }
if (Common.isNotNull(dis.getSocialId())) { if (Common.isNotNull(dis.getSocialId())) {
// 无更新直接跳过 // 无更新直接跳过
if (Common.isEmpty(socialTypeRemark) if (Common.isEmpty(socialTypeRemark)
&& CommonConstants.ZERO_STRING.equals(typeSub) && CommonConstants.ZERO_STRING.equals(typeSub)
&& Common.isEmpty(socialType)) { && Common.isEmpty(socialType)) {
continue; return true;
} }
socialInfo = socialMapper.selectById(dis.getSocialId()); socialInfo = socialMapper.selectById(dis.getSocialId());
socialTypeRemark = getHandleRemark(socialType, socialInfo,dis.getType(),sf); socialTypeRemark = getHandleRemark(socialType, socialInfo, dis.getType(),sf);
// 无更新直接跳过 // 无更新直接跳过
if (Common.isEmpty(socialTypeRemark.toString()) && CommonConstants.ZERO_STRING.equals(typeSub)) { if (Common.isEmpty(socialTypeRemark.toString()) && CommonConstants.ZERO_STRING.equals(typeSub)) {
continue; return true;
} }
} else { } else {
socialInfo = null; socialInfo = null;
...@@ -4076,7 +4095,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -4076,7 +4095,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
} }
} else { } else {
errorList.add(new ErrorMessage(-1, "找不到对应员工社保派增派单数据:" + dis.getEmpName())); errorList.add(new ErrorMessage(-1, "找不到对应员工社保派增派单数据:" + dis.getEmpName()));
continue; return true;
} }
//公积金办理 //公积金办理
} else if (CommonConstants.ONE_STRING.equals(typeSub)) { } else if (CommonConstants.ONE_STRING.equals(typeSub)) {
...@@ -4137,7 +4156,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -4137,7 +4156,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
auditInfo.setProvidentId(dis.getId()); auditInfo.setProvidentId(dis.getId());
} else { } else {
errorList.add(new ErrorMessage(-1, "找不到对应员工公积金派增派单数据:" + dis.getEmpName())); errorList.add(new ErrorMessage(-1, "找不到对应员工公积金派增派单数据:" + dis.getEmpName()));
continue; return true;
} }
} }
//派减处理 //派减处理
...@@ -4176,7 +4195,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -4176,7 +4195,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
auditInfo.setSocialId(dis.getId()); auditInfo.setSocialId(dis.getId());
} else { } else {
errorList.add(new ErrorMessage(-1, "找不到对应员工社保数据:" + dis.getEmpName())); errorList.add(new ErrorMessage(-1, "找不到对应员工社保数据:" + dis.getEmpName()));
continue; return true;
} }
//公积金派减办理 //公积金派减办理
} else if (CommonConstants.ONE_STRING.equals(typeSub)) { } else if (CommonConstants.ONE_STRING.equals(typeSub)) {
...@@ -4215,7 +4234,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -4215,7 +4234,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
auditInfo.setProvidentId(dis.getId()); auditInfo.setProvidentId(dis.getId());
} else { } else {
errorList.add(new ErrorMessage(-1, "找不到对应员工公积金数据:" + dis.getEmpName())); errorList.add(new ErrorMessage(-1, "找不到对应员工公积金数据:" + dis.getEmpName()));
continue; return true;
} }
} }
...@@ -4306,7 +4325,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -4306,7 +4325,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
&& (CommonConstants.FIVE_STRING.equals(sf.getSocialStatus()) && (CommonConstants.FIVE_STRING.equals(sf.getSocialStatus())
|| CommonConstants.FOUR_STRING.equals(sf.getFundStatus()))) { || CommonConstants.FOUR_STRING.equals(sf.getFundStatus()))) {
// 派增办理,全部失败 同步预估库数据 // 派增办理,全部失败 同步预估库数据
socialTask.asynchronousDisPatchHandle(socialMap,fundMap,sf, forecastFlag, null, null, CommonConstants.ZERO_INT); socialTask.asynchronousDisPatchHandle(socialMap, fundMap,sf, forecastFlag, null, null, CommonConstants.ZERO_INT);
} }
// 社保办理只要办理成功就刷新预估数据 公积金办理不用处理(前面公积金办理成功的时候处理过了) // 社保办理只要办理成功就刷新预估数据 公积金办理不用处理(前面公积金办理成功的时候处理过了)
if (CommonConstants.ZERO_STRING.equals(typeSub) if (CommonConstants.ZERO_STRING.equals(typeSub)
...@@ -4314,9 +4333,9 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -4314,9 +4333,9 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
&& CommonConstants.FOUR_STRING.equals(sf.getSocialStatus()) && CommonConstants.FOUR_STRING.equals(sf.getSocialStatus())
|| CommonConstants.THREE_STRING.equals(sf.getSocialStatus()))) { || CommonConstants.THREE_STRING.equals(sf.getSocialStatus()))) {
if (partSuccess) { if (partSuccess) {
forecastLibraryService.updateForecastLibaryByDispatch(socialMap,fundMap,sf); forecastLibraryService.updateForecastLibaryByDispatch(socialMap, fundMap,sf);
} else { } else {
socialTask.asynchronousDisPatchHandle(socialMap,fundMap,sf, 0, null, null, CommonConstants.ONE_INT); socialTask.asynchronousDisPatchHandle(socialMap, fundMap,sf, 0, null, null, CommonConstants.ONE_INT);
} }
} }
} }
...@@ -4326,7 +4345,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -4326,7 +4345,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
&& (CommonConstants.EIGHT_STRING.equals(sf.getSocialStatus()) && (CommonConstants.EIGHT_STRING.equals(sf.getSocialStatus())
|| CommonConstants.SEVEN_STRING.equals(sf.getFundStatus()))){ || CommonConstants.SEVEN_STRING.equals(sf.getFundStatus()))){
// 同步预估库数据 // 同步预估库数据
socialTask.asynchronousDisPatchHandle(socialMap,fundMap,sf, forecastFlag,null,null,CommonConstants.ZERO_INT); socialTask.asynchronousDisPatchHandle(socialMap, fundMap,sf, forecastFlag,null,null,CommonConstants.ZERO_INT);
} }
//社保公积金派减办理成功 //社保公积金派减办理成功
if ((CommonConstants.ONE_STRING.equals(dis.getType()) && CommonConstants.ZERO_INT == flag if ((CommonConstants.ONE_STRING.equals(dis.getType()) && CommonConstants.ZERO_INT == flag
...@@ -4355,7 +4374,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -4355,7 +4374,7 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
R<Boolean> resUp = archivesDaprUtil.updateProjectSocialFund(vo); R<Boolean> resUp = archivesDaprUtil.updateProjectSocialFund(vo);
if (Common.isEmpty(resUp) || !(CommonConstants.SUCCESS.intValue() == resUp.getCode()) || !resUp.getData().booleanValue()) { if (Common.isEmpty(resUp) || !(CommonConstants.SUCCESS.intValue() == resUp.getCode()) || !resUp.getData().booleanValue()) {
errorList.add(new ErrorMessage(-1, vo.getEmpIdCard() + DispatchConstants.DISPATCH_SYN_DOC_EXE, CommonConstants.RED, dis.getEmpName())); errorList.add(new ErrorMessage(-1, vo.getEmpIdCard() + DispatchConstants.DISPATCH_SYN_DOC_EXE, CommonConstants.RED, dis.getEmpName()));
continue; return true;
} }
// 派减公积金办理失败不同步档案的相关字段信息 // 派减公积金办理失败不同步档案的相关字段信息
} else if (!(CommonConstants.ONE_STRING.equals(dis.getType()) } else if (!(CommonConstants.ONE_STRING.equals(dis.getType())
...@@ -4369,25 +4388,15 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T ...@@ -4369,25 +4388,15 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
vo.setDepartNo(dis.getSettleDomainCode()); vo.setDepartNo(dis.getSettleDomainCode());
R<Boolean> resUp = archivesDaprUtil.updateProjectSocialFund(vo); R<Boolean> resUp = archivesDaprUtil.updateProjectSocialFund(vo);
if (Common.isEmpty(resUp) || !(CommonConstants.SUCCESS.intValue() == resUp.getCode()) || !resUp.getData().booleanValue()){ if (Common.isEmpty(resUp) || !(CommonConstants.SUCCESS.intValue() == resUp.getCode()) || !resUp.getData().booleanValue()){
errorList.add(new ErrorMessage(-1, vo.getEmpIdCard()+DispatchConstants.DISPATCH_SYN_DOC_EXE,CommonConstants.RED,dis.getEmpName())); errorList.add(new ErrorMessage(-1, vo.getEmpIdCard()+DispatchConstants.DISPATCH_SYN_DOC_EXE,CommonConstants.RED, dis.getEmpName()));
continue; return true;
} }
} }
} }
} else { } else {
errorList.add(new ErrorMessage(-1, "派单数据错误!")); errorList.add(new ErrorMessage(-1, "派单数据错误!"));
} }
} return false;
} catch(Exception e){
log.error(DispatchConstants.DISPATCH_EXCEPTION, e);
errorList.add(new ErrorMessage(-1, DispatchConstants.DISPATCH_EXCEPTION + e.getMessage()));
return errorList;
}
} else{
errorList.add(new ErrorMessage(-1, DispatchConstants.NO_OPERATOR_DATA));
return errorList;
}
return errorList;
} }
/** /**
......
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