opt: 锁更改
This commit is contained in:
@@ -66,7 +66,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -81,11 +80,17 @@ import static org.nl.b_lms.sch.tasks.slitter.util.SlitterTaskUtil.getPointLocati
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SlitterServiceImpl implements SlitterService {
|
||||
/** 是否使用虚拟卷 */
|
||||
/**
|
||||
* 是否使用虚拟卷
|
||||
*/
|
||||
public final static String USE_XN = "USE_XN";
|
||||
/** 套轴期限 */
|
||||
/**
|
||||
* 套轴期限
|
||||
*/
|
||||
public final static String TZ_DAY = "TZ_DAY";
|
||||
/** 套轴区域 */
|
||||
/**
|
||||
* 套轴区域
|
||||
*/
|
||||
public final static String PARAM_CODE_PLAN_AREA = "PARAM_CODE_PLAN_AREA";
|
||||
@Autowired
|
||||
private BstIvtStockingivtMapper bstIvtStockingivtMapper;
|
||||
@@ -302,7 +307,7 @@ public class SlitterServiceImpl implements SlitterService {
|
||||
List<String> stepTipLogs = getRedisListValue("ERROR" + deviceCode);
|
||||
// 枷锁
|
||||
RLock lock = redissonClient.getLock("doAcsFinishLoadShaft");
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
boolean tryLock = lock.tryLock(10, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
log.info("ACS申请套管完成参数: {}", param);
|
||||
@@ -1201,60 +1206,55 @@ public class SlitterServiceImpl implements SlitterService {
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public JSONObject pdaSendSubVolumeToNBJ(JSONObject param) {
|
||||
log.info("手持申请送子卷到内包间参数:{}", param);
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("status", HttpStatus.HTTP_OK);
|
||||
res.put("message", "创建AGV任务成功!");
|
||||
// param: point_code
|
||||
String pointCode = param.getString("point_code");
|
||||
// 校验是否存在任务
|
||||
List<SchBaseTask> taskList = taskService.checkHaveStartTask(pointCode);
|
||||
if (taskList.size() > 0) {
|
||||
throw new BadRequestException("操作失败,点位[" + pointCode + "]存在未完成的任务!");
|
||||
}
|
||||
BstIvtCutpointivt point = bcutpointivtService.getPintByAgvCode(pointCode, false);
|
||||
if (Objects.equals(point.getPoint_status(), "1")) {
|
||||
// 如果是没货
|
||||
throw new BadRequestException("点位:" + point.getPoint_code() + "检测无货,请确保任务执行完毕后触发!");
|
||||
}
|
||||
if (ObjectUtil.equals(point.getPoint_status(), "2")) {
|
||||
// 如果是没货
|
||||
throw new BadRequestException("点位:" + point.getPoint_code() + "检测空气胀轴,请确保下卷任务是否完毕后触发!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(point.getQzz_no1()) && ObjectUtil.isEmpty(point.getQzz_no2())) {
|
||||
throw new BadRequestException("点位:" + point.getPoint_code() + " 的气胀轴编码为空!");
|
||||
}
|
||||
JSONObject taskParam = new JSONObject();
|
||||
// 将子卷信息存到任务中
|
||||
List<String> qzzNos = Stream.of(point.getQzz_no1(), point.getQzz_no2()).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(qzzNos)) {
|
||||
List<PdmBiSlittingproductionplan> plans = slittingproductionplanService.getByQzzNos(qzzNos);
|
||||
List<String> collect = plans.stream().map(PdmBiSlittingproductionplan::getContainer_name).collect(Collectors.toList());
|
||||
if (collect.size() == 0) {
|
||||
throw new BadRequestException("操作失败,点位[" + pointCode + "]未查到子卷分切计划,请先绑定子卷库存!");
|
||||
}
|
||||
taskParam.put("containers", collect);
|
||||
} else {
|
||||
throw new BadRequestException("操作失败,点位[" + pointCode + "]无气胀轴信息,请先绑定子卷库存!");
|
||||
}
|
||||
// List<BstIvtCutpointivt> areaEmptyNotTaskPoint = bcutpointivtService.getAreaNotTaskPointByStatus("1",
|
||||
// "1", "0", "2");
|
||||
List<BstIvtCutpointivt> areaEmptyNotTaskPoint = bcutpointivtService.getNBJCanUsePoint("1", "1", "0", "2");
|
||||
if (areaEmptyNotTaskPoint.size() <= 1) {
|
||||
throw new BadRequestException("请求搬运失败,内包间没有可存放位置!");
|
||||
}
|
||||
BstIvtCutpointivt endPoint = areaEmptyNotTaskPoint.get(0);
|
||||
RLock lock = redissonClient.getLock(endPoint.getPoint_code());
|
||||
RLock lock = redissonClient.getLock("doAcsFinishLoadShaft");
|
||||
boolean tryLock;
|
||||
try {
|
||||
tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
throw new BadRequestException("获取锁异常");
|
||||
}
|
||||
tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
// param: point_code
|
||||
String pointCode = param.getString("point_code");
|
||||
// 校验是否存在任务
|
||||
List<SchBaseTask> taskList = taskService.checkHaveStartTask(pointCode);
|
||||
if (taskList.size() > 0) {
|
||||
throw new BadRequestException("操作失败,点位[" + pointCode + "]存在未完成的任务!");
|
||||
}
|
||||
BstIvtCutpointivt point = bcutpointivtService.getPintByAgvCode(pointCode, false);
|
||||
if (Objects.equals(point.getPoint_status(), "1")) {
|
||||
// 如果是没货
|
||||
throw new BadRequestException("点位:" + point.getPoint_code() + "检测无货,请确保任务执行完毕后触发!");
|
||||
}
|
||||
if (ObjectUtil.equals(point.getPoint_status(), "2")) {
|
||||
// 如果是没货
|
||||
throw new BadRequestException("点位:" + point.getPoint_code() + "检测空气胀轴,请确保下卷任务是否完毕后触发!");
|
||||
}
|
||||
if (ObjectUtil.isEmpty(point.getQzz_no1()) && ObjectUtil.isEmpty(point.getQzz_no2())) {
|
||||
throw new BadRequestException("点位:" + point.getPoint_code() + " 的气胀轴编码为空!");
|
||||
}
|
||||
JSONObject taskParam = new JSONObject();
|
||||
// 将子卷信息存到任务中
|
||||
List<String> qzzNos = Stream.of(point.getQzz_no1(), point.getQzz_no2()).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(qzzNos)) {
|
||||
List<PdmBiSlittingproductionplan> plans = slittingproductionplanService.getByQzzNos(qzzNos);
|
||||
List<String> collect = plans.stream().map(PdmBiSlittingproductionplan::getContainer_name).collect(Collectors.toList());
|
||||
if (collect.size() == 0) {
|
||||
throw new BadRequestException("操作失败,点位[" + pointCode + "]未查到子卷分切计划,请先绑定子卷库存!");
|
||||
}
|
||||
taskParam.put("containers", collect);
|
||||
} else {
|
||||
throw new BadRequestException("操作失败,点位[" + pointCode + "]无气胀轴信息,请先绑定子卷库存!");
|
||||
}
|
||||
List<BstIvtCutpointivt> areaEmptyNotTaskPoint = bcutpointivtService.getNBJCanUsePoint("1", "1", "0", "2");
|
||||
if (areaEmptyNotTaskPoint.size() <= 1) {
|
||||
throw new BadRequestException("请求搬运失败,内包间没有可存放位置!");
|
||||
}
|
||||
BstIvtCutpointivt endPoint = areaEmptyNotTaskPoint.get(0);
|
||||
taskParam.put("point_code1", point.getPoint_code());
|
||||
taskParam.put("point_code2", endPoint.getPoint_code());
|
||||
taskParam.put("vehicle_code1", point.getQzz_no1());
|
||||
@@ -2649,7 +2649,7 @@ public class SlitterServiceImpl implements SlitterService {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
throw new BadRequestException("点位:" + point.getPoint_code() + "点位状态不对,请先设置点位信息再触发!!");
|
||||
}
|
||||
return res;
|
||||
|
||||
Reference in New Issue
Block a user