Commit 8ff85070 authored by huyuchen's avatar huyuchen

派单优化修改

parent bc9c3206
......@@ -151,4 +151,7 @@ public interface CacheConstants {
String PAYMENT_DISPATCH_BATCH_REDUCE_IMPORT = "payment_dispatch_batch_reduce_import";
String PAYMENT_PRE_DISPATCH_BATCH_ADD_IMPORT = "payment_pre_dispatch_batch_add_import";
//社保公积金派单
String PAYMENT_DISPATCH_BATCH_IMPORT = "payment_dispatch_batch_import";
}
......@@ -40,7 +40,9 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.*;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttributeConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.redis.RedisDistributedLock;
import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.ArchivesDaprUtil;
......@@ -3364,34 +3366,49 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
@Override
public R<List<ErrorMessage>> addApplyHandle(List<String> ids, String typeSub, String handleStatus,
String handleRemark, String socialType, String remark) {
YifuUser user = SecurityUtils.getUser();
if (null == user) {
return R.failed(CommonConstants.USER_FAIL);
}
if (Common.isEmpty(ids)) {
return R.failed(DispatchConstants.DISPATCH_ID_NOT_EMPTY);
}
int flag;
if (CommonConstants.ONE_STRING.equals(handleStatus)) {
//办理成功
flag = CommonConstants.ZERO_INT;
} else if (CommonConstants.TWO_STRING.equals(handleStatus)) {
//办理失败
flag = CommonConstants.ONE_INT;
} else {
return R.failed("派单办理状态参数异常:0待办理 1办理通过 2办理不通过");
}
String key = CacheConstants.PAYMENT_DISPATCH_BATCH_IMPORT + CommonConstants.DOWN_LINE_STRING +user.getId() ;
// 获取redis分布式事务锁
String requestId;
try {
YifuUser user = SecurityUtils.getUser();
if (null == user) {
return R.failed(CommonConstants.USER_FAIL);
}
if (Common.isEmpty(ids)) {
return R.failed(DispatchConstants.DISPATCH_ID_NOT_EMPTY);
}
int flag;
if (CommonConstants.ONE_STRING.equals(handleStatus)) {
//办理成功
flag = CommonConstants.ZERO_INT;
} else if (CommonConstants.TWO_STRING.equals(handleStatus)) {
//办理失败
flag = CommonConstants.ONE_INT;
} else {
return R.failed("派单办理状态参数异常:0待办理 1办理通过 2办理不通过");
}
List<ErrorMessage> errorInfo = addBatchApplyHandle(ids, typeSub, user, flag, handleStatus,
Common.isNullToString(handleRemark), socialType,remark);
if (errorInfo == null || errorInfo.isEmpty()) {
return R.ok(null,"办理成功!");
} else {
return R.ok(errorInfo,"派单办理结果:");
}
requestId = RedisDistributedLock.getLock(key,"10");
} catch (Exception e) {
log.error(DispatchConstants.DISPATCH_EXCEPTION + e.getMessage());
return R.failed("数据异常,办理失败!");
throw new RuntimeException(ResultConstants.NO_GETLOCK_DATA+CommonConstants.DOWN_LINE_STRING+e.getMessage());
}
if (Common.isNotNull(requestId)) {
try {
List<ErrorMessage> errorInfo = addBatchApplyHandle(ids, typeSub, user, flag, handleStatus,
Common.isNullToString(handleRemark), socialType, remark);
if (errorInfo == null || errorInfo.isEmpty()) {
return R.ok(null, "办理成功!");
} else {
return R.ok(errorInfo, "派单办理结果:");
}
} catch (Exception e) {
log.error(DispatchConstants.DISPATCH_EXCEPTION + e.getMessage());
return R.failed("数据异常,办理失败!");
}finally {
//主动释放锁
RedisDistributedLock.unlock(key, requestId);
}
}else {
return R.failed(ResultConstants.NO_GETLOCK_DATA);
}
}
......
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