opt: redission锁
This commit is contained in:
@@ -497,8 +497,13 @@ public class PdaProductionServiceImpl implements PdaProductionService {
|
||||
* 入库
|
||||
* @param param
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void productionInStorage(JSONObject param, SchBasePoint point) {
|
||||
RLock lock = redissonClient.getLock("lock:productionInStorage");
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
// 入库库区
|
||||
String inSect = point.getIn_sect();
|
||||
if (ObjectUtil.isEmpty(inSect)) {
|
||||
@@ -528,7 +533,14 @@ public class PdaProductionServiceImpl implements PdaProductionService {
|
||||
// 3 创建任务
|
||||
Map<String, Object> jsonMst = defaultPdaBuildParam.buildTaskData(point, invId);
|
||||
rawAssistIStorService.divPoint(jsonMst);
|
||||
|
||||
} else {
|
||||
throw new BadRequestException("速度太快啦,稍后再试...");
|
||||
}
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@@ -695,9 +707,14 @@ public class PdaProductionServiceImpl implements PdaProductionService {
|
||||
return PdaResponse.requestParamOk(res);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public PdaResponse manualInbound(JSONObject param) {
|
||||
RLock lock = redissonClient.getLock("lock:manualInbound");
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
assertNotBlankJson(param, "当前点位不能为空!", "row", "current_point", "vehicle_code");
|
||||
JSONObject row = param.getJSONObject("row");
|
||||
String currentPoint = param.getString("current_point");
|
||||
@@ -730,11 +747,24 @@ public class PdaProductionServiceImpl implements PdaProductionService {
|
||||
// 3 创建任务
|
||||
Map<String, Object> jsonMst = defaultPdaBuildParam.buildTaskData(startPoint, invId);
|
||||
rawAssistIStorService.divPoint(jsonMst);
|
||||
} else {
|
||||
throw new BadRequestException("速度太快啦,稍后再试...");
|
||||
}
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
return PdaResponse.requestOk();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public PdaResponse manualOutbound(JSONObject param) {
|
||||
RLock lock = redissonClient.getLock("lock:manualOutbound");
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
assertNotBlankJson(param, "当前点位不能为空!", "row", "current_point", "vehicle_code");
|
||||
JSONObject row = param.getJSONObject("row");
|
||||
String currentPoint = param.getString("current_point");
|
||||
@@ -781,6 +811,14 @@ public class PdaProductionServiceImpl implements PdaProductionService {
|
||||
ext.put("target", row.getString("station"));
|
||||
AbstractTask coatingUpTask = taskFactory.getTask("CoatingUpTask");
|
||||
coatingUpTask.create(ext);
|
||||
} else {
|
||||
throw new BadRequestException("速度太快啦,稍后再试...");
|
||||
}
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
return PdaResponse.requestOk();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.wms.sch_manage.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.SneakyThrows;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.config.IdUtil;
|
||||
@@ -19,12 +20,15 @@ import org.nl.wms.sch_manage.service.util.tasks.WrappingDownTask;
|
||||
import org.nl.wms.sch_manage.service.util.tasks.WrappingUpTask;
|
||||
import org.nl.wms.warehouse_management.service.IMdPbGroupplateService;
|
||||
import org.nl.wms.warehouse_management.service.dao.GroupPlate;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -51,10 +55,17 @@ public class SecondaryPackagingServiceImpl implements SecondaryPackagingService
|
||||
private EmptyDiskConveyTask emptyDiskConveyTask;
|
||||
@Resource(name = "EmptyDiskEnterTask")
|
||||
private EmptyDiskEnterTask emptyDiskEnterTask;
|
||||
@Resource
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void palletizingDown(JSONObject param) {
|
||||
RLock lock = redissonClient.getLock("lock:palletizingDown");
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
// device_code、material_code、qty、vehicle_seq、pcsn、cases
|
||||
MdMeMaterialbase materialCode = materialbaseService.getByCode(param.getString("material_code"));
|
||||
// 组盘
|
||||
@@ -84,10 +95,23 @@ public class SecondaryPackagingServiceImpl implements SecondaryPackagingService
|
||||
param.put("vehicle_code", groupPlate.getVehicle_code());
|
||||
AbstractTask palletizingDownTask = taskFactory.getTask("PalletizingDownTask");
|
||||
palletizingDownTask.create(param);
|
||||
} else {
|
||||
throw new BadRequestException("速度太快啦,稍后再试...");
|
||||
}
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void wrappingCall(JSONObject param) {
|
||||
RLock lock = redissonClient.getLock("lock:wrappingCall");
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
// 校验任务
|
||||
Integer num = taskService.haveTaskAll(param.getString("device_code"));
|
||||
if (num > 0) {
|
||||
@@ -95,10 +119,23 @@ public class SecondaryPackagingServiceImpl implements SecondaryPackagingService
|
||||
}
|
||||
param.put("config_code", "WrappingUpTask");
|
||||
wrappingUpTask.create(param);
|
||||
} else {
|
||||
throw new BadRequestException("速度太快啦,稍后再试...");
|
||||
}
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void wrappingDown(JSONObject param) {
|
||||
RLock lock = redissonClient.getLock("lock:wrappingDown");
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
// 校验任务
|
||||
Integer num = taskService.haveTaskAll(param.getString("device_code"));
|
||||
if (num > 0) {
|
||||
@@ -106,10 +143,23 @@ public class SecondaryPackagingServiceImpl implements SecondaryPackagingService
|
||||
}
|
||||
param.put("config_code", "WrappingDownTask");
|
||||
wrappingDownTask.create(param);
|
||||
} else {
|
||||
throw new BadRequestException("速度太快啦,稍后再试...");
|
||||
}
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void palletizingCallEmpty(JSONObject param) {
|
||||
RLock lock = redissonClient.getLock("lock:palletizingCallEmpty");
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
// 空盘进入任务、空盘运输任务、
|
||||
// 校验任务
|
||||
Integer num = taskService.haveTaskAll(param.getString("device_code"));
|
||||
@@ -130,5 +180,13 @@ public class SecondaryPackagingServiceImpl implements SecondaryPackagingService
|
||||
param.put("point_code2", param.getString("device_code"));
|
||||
param.put("config_code", "EmptyDiskEnterTask");
|
||||
emptyDiskConveyTask.create(param);
|
||||
} else {
|
||||
throw new BadRequestException("速度太快啦,稍后再试...");
|
||||
}
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user