This commit is contained in:
zhangzhiqiang
2023-02-05 14:29:00 +08:00
parent cc3ee178fb
commit c47b61abdc
2 changed files with 19 additions and 29 deletions

View File

@@ -362,17 +362,17 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.12.3</version>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-actuator</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.redisson</groupId>-->
<!-- <artifactId>redisson-spring-boot-starter</artifactId>-->
<!-- <version>3.12.3</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <artifactId>spring-boot-starter-actuator</artifactId>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<!-- jwt -->
<dependency>
<groupId>io.jsonwebtoken</groupId>

View File

@@ -7,6 +7,8 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Interner;
import com.google.common.collect.Interners;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
@@ -26,8 +28,6 @@ import org.nl.wms.sch.tasks.EmptyVehicleTask;
import org.nl.wms.sch.tasks.SendOutTask;
import org.nl.wms.st.inbill.service.RawAssistIStorService;
import org.nl.wms.st.inbill.service.StorPublicService;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -44,6 +44,9 @@ import java.util.concurrent.TimeUnit;
@Slf4j
public class AcsToWmsServiceImpl implements AcsToWmsService {
private static Interner<String> lock = Interners.newWeakInterner();
private final PrintService printService;
private final RawAssistIStorService rawAssistIStorService;
@@ -52,8 +55,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
private final CutConveyorTask cutConveyorTask;
private final RedissonClient redissonClient;
/**
* task_id任务标识
* task_code任务编码
@@ -191,13 +192,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
log.info("apply请求参数---------------------------------------------"+whereJson.toString());
String type = whereJson.getString("type");
JSONObject result = new JSONObject();
RLock lock = redissonClient.getLock("acs_wms_apply:" + type);
boolean isLock = lock.tryLock(3,TimeUnit.SECONDS);
try {
if (isLock){
synchronized (lock.intern(type)){
String device_code = whereJson.getString("device_code");
String vehicle_code = whereJson.getString("vehicle_code");
WQLObject point_table = WQLObject.getWQLObject("SCH_BASE_Point");
WQLObject struct_table = WQLObject.getWQLObject("ST_IVT_StructAttr");
@@ -443,15 +440,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
result.put("status", HttpStatus.OK.value());
result.put("message", "下发成功!");
return result;
}
}finally {
if (isLock){
lock.unlock();
}
}
result.put("status", HttpStatus.BAD_REQUEST.value());
result.put("message", "锁超时下发失败");
return result;
}
}
@Override