mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 13:22:07 +08:00
1、RedisLockUtil加锁解锁修复sonar.LocksNotUnlockedCheck;2、api、文件导入生产单数据加解锁基于多租户问题修复;
This commit is contained in:
+21
-13
@@ -10,6 +10,8 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
|
||||
import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
|
||||
import com.cf.imes.framework.redis.config.ChenfengCacheProperties;
|
||||
import com.cf.imes.framework.redis.constants.RedisKeyConstants;
|
||||
import com.cf.imes.framework.redis.util.RedisLockUtil;
|
||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
|
||||
@@ -107,7 +109,9 @@ public class OrderController {
|
||||
@Resource
|
||||
private OrderInputProcessor orderInputProcessor;
|
||||
|
||||
private String lockKey = "order:1631:lock:";
|
||||
@Resource
|
||||
private ChenfengCacheProperties chenfengCacheProperties;
|
||||
|
||||
private String errKey = "生产数据导入异常,{}";
|
||||
|
||||
public static final String ORDER_PLATE_MODEL = "imes_order_plate_model";
|
||||
@@ -229,13 +233,15 @@ public class OrderController {
|
||||
@OperateLog(module="管理后台 - 生产单管理",name = "生产单api数据导入新增",type = IMPORT)
|
||||
@Parameter(name = "orderNo", description = "原订单号", required = true, example = "20230809027818")
|
||||
@PreAuthorize("@ss.hasPermission('production:manager-list:create')")
|
||||
public CommonResult<String> getApiData(@RequestParam(value = "orderNo") String orderNo){
|
||||
|
||||
boolean isLocked = redisLockUtil.acquireLock(lockKey);
|
||||
public CommonResult<String> getApiData(@RequestParam(value = "orderNo") String orderNo) throws InterruptedException {
|
||||
// 加导入锁
|
||||
String importLockValue = "syncApiImport";
|
||||
String importLockKey = String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, getUserOrganId());
|
||||
boolean isLocked = redisLockUtil.acquireLock(importLockKey, importLockValue, chenfengCacheProperties.getLockTimeout());
|
||||
if (!isLocked) {
|
||||
log.error(errKey, LOCK_ERR);
|
||||
return error(LOCK_ERR);
|
||||
throw new ServiceException(ORDER_IMPORT_ORGAN_LOCK_ERROR);
|
||||
}
|
||||
Thread.sleep(20000);
|
||||
Long orderId = null;
|
||||
try {
|
||||
orderId = (Long) identifierGenerator.nextId(null);
|
||||
@@ -257,7 +263,8 @@ public class OrderController {
|
||||
return error((ServiceException) cause);
|
||||
|
||||
} finally {
|
||||
redisLockUtil.releaseLock(lockKey);
|
||||
// 导入锁解锁
|
||||
redisLockUtil.releaseLock(importLockKey, importLockValue);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -285,11 +292,12 @@ public class OrderController {
|
||||
Map<String, String> mapOrder = null;
|
||||
|
||||
Boolean flag = true;
|
||||
|
||||
boolean isLocked = redisLockUtil.acquireLock(lockKey);
|
||||
// 加导入锁
|
||||
String importLockValue = "syncFileImport";
|
||||
String importLockKey = String.format(RedisKeyConstants.ORDER_IMPORT_LOCK_KEY, getUserOrganId());
|
||||
boolean isLocked = redisLockUtil.acquireLock(importLockKey, importLockValue, chenfengCacheProperties.getLockTimeout());
|
||||
if (!isLocked) {
|
||||
log.error(errKey,LOCK_ERR);
|
||||
|
||||
throw new ServiceException(ORDER_IMPORT_ORGAN_LOCK_ERROR);
|
||||
} else {
|
||||
try {
|
||||
if (type == 0) { //excel
|
||||
@@ -404,8 +412,8 @@ public class OrderController {
|
||||
}
|
||||
|
||||
} finally {
|
||||
|
||||
redisLockUtil.releaseLock(lockKey);
|
||||
// 导入锁解锁
|
||||
redisLockUtil.releaseLock(importLockKey, importLockValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user