fix: 手持暂存下料修改
This commit is contained in:
@@ -965,73 +965,56 @@ public class SlitterServiceImpl implements SlitterService {
|
|||||||
@Override
|
@Override
|
||||||
public JSONObject pdaSendSubVolumeToNBJ(JSONObject param) {
|
public JSONObject pdaSendSubVolumeToNBJ(JSONObject param) {
|
||||||
log.info("手持申请送子卷到内包间参数:{}", param);
|
log.info("手持申请送子卷到内包间参数:{}", param);
|
||||||
|
JSONObject res = new JSONObject();
|
||||||
|
res.put("status", HttpStatus.HTTP_OK);
|
||||||
|
res.put("message", "创建AGV任务成功!");
|
||||||
// param: point_code
|
// param: point_code
|
||||||
String pointCode = param.getString("point_code");
|
String pointCode = param.getString("point_code");
|
||||||
RLock open = redissonClient.getLock(pointCode);
|
// 校验是否存在任务
|
||||||
boolean openLock;
|
List<SchBaseTask> taskList = taskService.checkHaveTask(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() + "检测空气胀轴,请确保下卷任务是否完毕后触发!");
|
||||||
|
}
|
||||||
|
List<BstIvtCutpointivt> areaEmptyNotTaskPoint = bcutpointivtService.getAreaNotTaskPointByStatus("1",
|
||||||
|
"1", "0", "2");
|
||||||
|
if (areaEmptyNotTaskPoint.size() == 0) {
|
||||||
|
throw new BadRequestException("请求搬运失败,内包间没有可存放位置!");
|
||||||
|
}
|
||||||
|
BstIvtCutpointivt endPoint = areaEmptyNotTaskPoint.get(0);
|
||||||
|
RLock lock = redissonClient.getLock(endPoint.getPoint_code());
|
||||||
|
boolean tryLock;
|
||||||
try {
|
try {
|
||||||
openLock = open.tryLock(0, TimeUnit.SECONDS);
|
tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new BadRequestException("获取锁异常");
|
throw new BadRequestException("获取锁异常");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (openLock) {
|
if (tryLock) {
|
||||||
// 校验是否存在任务
|
JSONObject taskParam = new JSONObject();
|
||||||
List<SchBaseTask> taskList = taskService.checkHaveTask(pointCode);
|
taskParam.put("point_code1", point.getPoint_code());
|
||||||
if (taskList.size() > 0) {
|
taskParam.put("point_code2", endPoint.getPoint_code());
|
||||||
throw new BadRequestException("操作失败,点位[" + pointCode + "]存在未完成的任务!");
|
taskParam.put("vehicle_code1", point.getQzz_no1());
|
||||||
}
|
taskParam.put("vehicle_code2", point.getQzz_no2());
|
||||||
BstIvtCutpointivt point = bcutpointivtService.getPintByAgvCode(pointCode, false);
|
taskParam.put("task_type", SlitterEnum.TASK_TYPE.code("分切机下料AGV到内包间"));
|
||||||
if (Objects.equals(point.getPoint_status(), "1")) {
|
taskParam.put("product_area", SlitterConstant.SLITTER_TASK_AREA);
|
||||||
// 如果是没货
|
slitterDownAgvTask.createTask(taskParam);
|
||||||
throw new BadRequestException("点位:" + point.getPoint_code() + "检测无货,请确保任务执行完毕后触发!");
|
|
||||||
}
|
|
||||||
if (ObjectUtil.equals(point.getPoint_status(), "2")) {
|
|
||||||
// 如果是没货
|
|
||||||
throw new BadRequestException("点位:" + point.getPoint_code() + "检测空气胀轴,请确保下卷任务是否完毕后触发!");
|
|
||||||
}
|
|
||||||
List<BstIvtCutpointivt> areaEmptyNotTaskPoint = bcutpointivtService.getAreaNotTaskPointByStatus("1",
|
|
||||||
"1", "0", "2");
|
|
||||||
if (areaEmptyNotTaskPoint.size() == 0) {
|
|
||||||
throw new BadRequestException("请求搬运失败,内包间没有可存放位置!");
|
|
||||||
}
|
|
||||||
BstIvtCutpointivt endPoint = areaEmptyNotTaskPoint.get(0);
|
|
||||||
RLock lock = redissonClient.getLock(endPoint.getPoint_code());
|
|
||||||
boolean tryLock;
|
|
||||||
try {
|
|
||||||
tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new BadRequestException("获取锁异常");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (tryLock) {
|
|
||||||
JSONObject taskParam = new JSONObject();
|
|
||||||
taskParam.put("point_code1", point.getPoint_code());
|
|
||||||
taskParam.put("point_code2", endPoint.getPoint_code());
|
|
||||||
taskParam.put("vehicle_code1", point.getQzz_no1());
|
|
||||||
taskParam.put("vehicle_code2", point.getQzz_no2());
|
|
||||||
taskParam.put("task_type", SlitterEnum.TASK_TYPE.code("分切机下料AGV到内包间"));
|
|
||||||
taskParam.put("product_area", SlitterConstant.SLITTER_TASK_AREA);
|
|
||||||
slitterDownAgvTask.createTask(taskParam);
|
|
||||||
} else {
|
|
||||||
throw new BadRequestException("系统繁忙,稍后在试!!");
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (tryLock) {
|
|
||||||
lock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestException("系统繁忙,稍后在试!!");
|
throw new BadRequestException("系统繁忙,稍后在试!!");
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (openLock) {
|
if (tryLock) {
|
||||||
open.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JSONObject res = new JSONObject();
|
|
||||||
res.put("status", HttpStatus.HTTP_OK);
|
|
||||||
res.put("message", "创建AGV任务请求成功!");
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user