fix:二次分配及行架任务并发问题
This commit is contained in:
@@ -33,6 +33,7 @@ import org.nl.common.domain.query.PageQuery;
|
|||||||
import org.nl.common.enums.PackageInfoIvtEnum;
|
import org.nl.common.enums.PackageInfoIvtEnum;
|
||||||
import org.nl.common.enums.SpecEnum;
|
import org.nl.common.enums.SpecEnum;
|
||||||
import org.nl.common.utils.MapOf;
|
import org.nl.common.utils.MapOf;
|
||||||
|
import org.nl.common.utils.RedissonUtils;
|
||||||
import org.nl.common.utils.SecurityUtils;
|
import org.nl.common.utils.SecurityUtils;
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
import org.nl.modules.wql.util.SpringContextHolder;
|
import org.nl.modules.wql.util.SpringContextHolder;
|
||||||
@@ -154,46 +155,36 @@ public class BstIvtPackageinfoivtServiceImpl extends ServiceImpl<BstIvtPackagein
|
|||||||
* @param actionType 1、取货分配 2、放货分配 3、取货完成
|
* @param actionType 1、取货分配 2、放货分配 3、取货完成
|
||||||
* @author gbx
|
* @author gbx
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Map<String, Object> secondaryAllocationPoint(String taskCode, String actionType) {
|
public Map<String, Object> secondaryAllocationPoint(String taskCode, String actionType) {
|
||||||
String pointCode = "";
|
|
||||||
String action = "";
|
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
RLock lock = redissonClient.getLock(taskCode);
|
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
RedissonUtils.lock(c-> {
|
||||||
try {
|
String pointCode = "";
|
||||||
if (tryLock) {
|
String action = "";
|
||||||
switch (actionType) {
|
switch (actionType) {
|
||||||
case "1":
|
case "1":
|
||||||
case "2":
|
case "2":
|
||||||
// 取货分配, 放货分配
|
// 取货分配, 放货分配
|
||||||
pointCode = getNewPoint(taskCode, actionType);
|
pointCode = getNewPoint(taskCode, actionType);
|
||||||
result.put("data", pointCode);
|
result.put("data", pointCode);
|
||||||
result.put("message", taskCode + "取放货分配成功,新点位为:" + pointCode);
|
result.put("message", taskCode + "取放货分配成功,新点位为:" + pointCode);
|
||||||
break;
|
break;
|
||||||
case "3":
|
case "3":
|
||||||
case "4":
|
case "4":
|
||||||
// 取货完成,放货完成
|
// 取货完成,放货完成
|
||||||
updatePointStatus(taskCode, actionType);
|
updatePointStatus(taskCode, actionType);
|
||||||
action = taskCode + "取放货完成!";
|
action = taskCode + "取放货完成!";
|
||||||
result.put("data", action);
|
result.put("data", action);
|
||||||
result.put("message", taskCode + "取放货完成!");
|
result.put("message", taskCode + "取放货完成!");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
result.put("status", HttpStatus.OK.value());
|
|
||||||
} else {
|
|
||||||
log.info("一楼装箱区点位二次分配接口异常,正在分配中!");
|
|
||||||
result.put("status", HttpStatus.BAD_REQUEST.value());
|
|
||||||
result.put("message", "二次分配点位正在分配中,已锁住!");
|
|
||||||
}
|
}
|
||||||
} finally {
|
result.put("status", HttpStatus.OK.value());
|
||||||
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
return null;
|
||||||
lock.unlock();
|
},"sendProductToFirstFloor",null);
|
||||||
}
|
|
||||||
}
|
|
||||||
log.info("一楼装箱区点位二次分配" + taskCode + "---------------------------------------------" + result);
|
log.info("一楼装箱区点位二次分配" + taskCode + "---------------------------------------------" + result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,8 +71,6 @@ public class MzhcwTask extends AbstractAcsTask {
|
|||||||
@Resource
|
@Resource
|
||||||
private DjqToKzjhcwTask djqToKzjhcwTask;
|
private DjqToKzjhcwTask djqToKzjhcwTask;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private SsxDjwTask ssxDjwTask;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -153,35 +151,6 @@ public class MzhcwTask extends AbstractAcsTask {
|
|||||||
log.info(schBaseTask.getTask_code() + "检查检查->四个点任务,桁架取货完成信号未发送!已在手动点击完成时清除空载具位:" + schBaseTask.getPoint_code3() + "的库存");
|
log.info(schBaseTask.getTask_code() + "检查检查->四个点任务,桁架取货完成信号未发送!已在手动点击完成时清除空载具位:" + schBaseTask.getPoint_code3() + "的库存");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//3.更新库存记录
|
|
||||||
// packageinfoivtService.update(null,new UpdateWrapper<BstIvtPackageinfoivt>().set("ivt_status", PackageInfoIvtEnum.IVT_STATUS.code("有子卷")).set("container_name", schBaseTask.getVehicle_code()).eq("point_code", schBaseTask.getPoint_code2()));
|
|
||||||
//4.任务一、待检区AGV搬运任务,查询子卷信息,去分切计划表查找定级数据,桁架任务完成根据子卷定级创建AGV任务将满轴搬运至质检区或管制区
|
|
||||||
//createTaskToDjq(schBaseTask);
|
|
||||||
//5.创建空载具到输送线任务,完成后需要创建空载具缓存位->输送线任务
|
|
||||||
// if (schBaseTask.getTask_type().equals(PackageInfoIvtEnum.TASK_TYPE.code("输送线四个点任务"))) {
|
|
||||||
//四个点任务,改变pointCode3点位状态
|
|
||||||
// packageinfoivtService.update(null,new UpdateWrapper<BstIvtPackageinfoivt>().set("ivt_status", PackageInfoIvtEnum.IVT_STATUS.code("空")).set("container_name", null).eq("point_code", schBaseTask.getPoint_code3()));
|
|
||||||
//校验任务是否存在
|
|
||||||
// List<String> taskTypes = new ArrayList<>(Collections.singletonList(PackageInfoIvtEnum.TASK_TYPE.code("放空(空载具缓存位->输送线)")));
|
|
||||||
// List<SchBaseTask> existTask = taskService.getExistTasks(taskTypes);
|
|
||||||
// if (ObjectUtils.isEmpty(existTask)) {
|
|
||||||
// List<BstIvtPackageinfoivt> kzjPointList = packageinfoivtService
|
|
||||||
// .list(new LambdaUpdateWrapper<BstIvtPackageinfoivt>()
|
|
||||||
// .eq(BstIvtPackageinfoivt::getIs_used, PackageInfoIvtEnum.IS_USED.code("启用"))
|
|
||||||
// .eq(BstIvtPackageinfoivt::getPoint_status, PackageInfoIvtEnum.POINT_STATUS.code("空载具缓存位"))
|
|
||||||
// .eq(BstIvtPackageinfoivt::getIvt_status, PackageInfoIvtEnum.IVT_STATUS.code("空载具"))
|
|
||||||
// .orderByDesc(BstIvtPackageinfoivt::getSort_seq));
|
|
||||||
// JSONObject toSsxTask = new JSONObject();
|
|
||||||
// toSsxTask.put("acs_task_type", PackageInfoIvtEnum.ACS_TASK_TYPE.code("桁架任务"));
|
|
||||||
// toSsxTask.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("放空(空载具缓存位->输送线)"));
|
|
||||||
// toSsxTask.put("vehicle_code", schBaseTask.getVehicle_code());
|
|
||||||
// //判断空载具缓存位是否有空载具库存,有就叫桁架去任一位置搬空载具,如果暂时没有空载具,定时任务会不断判断是否有空载具
|
|
||||||
// toSsxTask.put("task_status", TaskStatusEnum.SURE_END.getCode());
|
|
||||||
// //终点为输送线点位
|
|
||||||
// toSsxTask.put("point_code2", schBaseTask.getPoint_code1());
|
|
||||||
// ssxDjwTask.createTask(toSsxTask);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
// 取消
|
// 取消
|
||||||
if (status.equals(IOSEnum.IS_NOTANDYES.code("否"))) {
|
if (status.equals(IOSEnum.IS_NOTANDYES.code("否"))) {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import org.nl.common.enums.PackageInfoIvtEnum;
|
|||||||
import org.nl.common.enums.SpecEnum;
|
import org.nl.common.enums.SpecEnum;
|
||||||
import org.nl.common.utils.CodeUtil;
|
import org.nl.common.utils.CodeUtil;
|
||||||
import org.nl.common.utils.MapOf;
|
import org.nl.common.utils.MapOf;
|
||||||
|
import org.nl.common.utils.RedissonUtils;
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
import org.nl.modules.wql.WQL;
|
import org.nl.modules.wql.WQL;
|
||||||
import org.nl.modules.wql.core.bean.WQLObject;
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
@@ -1845,102 +1846,62 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
* 二楼到一楼,成品子卷到达一楼输送线
|
* 二楼到一楼,成品子卷到达一楼输送线
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional
|
||||||
@SneakyThrows
|
|
||||||
public JSONObject sendProductToFirstFloor(JSONObject whereJson) {
|
public JSONObject sendProductToFirstFloor(JSONObject whereJson) {
|
||||||
// JSONObject whereJson 应该传子卷号,设备号,车间号
|
log.info("sendProductToFirstFloor被调用--------------------------:" + whereJson.toString());
|
||||||
// 先查询满轴缓存位是否有可用库位,有创建搬运任务
|
|
||||||
// 任务完成创建空载具补充到输送线桁架任务,子卷搬运至待检区或或管制区agv任务
|
|
||||||
// 如果满轴位没有可用的空点位,先创建一个桁架任务但是不下发,等这边空出来点位,判断是否有这种桁架任务然后补发;
|
|
||||||
// 这个情况是有agv任务在搬去待检区或管制区的路上,还没有更新任务状态;需要查询是否有这种任务,等这个任务更新完后,
|
|
||||||
// 再补发之前创建的输送线到满轴缓存位任务;
|
|
||||||
log.info("二楼到一楼,成品子卷到达一楼输送线接口sendProductToFirstFloor被调用--------------------------:" + whereJson.toString());
|
|
||||||
if (StringUtils.isBlank(whereJson.getString("device_code")) || StringUtils.isBlank(whereJson.getString("material_barcode"))) {
|
if (StringUtils.isBlank(whereJson.getString("device_code")) || StringUtils.isBlank(whereJson.getString("material_barcode"))) {
|
||||||
throw new BadRequestException("接口sendProductToFirstFloor,目标站点或子卷号参数为空!");
|
throw new BadRequestException("接口sendProductToFirstFloor,目标站点或子卷号参数为空!");
|
||||||
}
|
}
|
||||||
if (whereJson.getString("device_code").equals("null") || whereJson.getString("material_barcode").equals("null")) {
|
if (whereJson.getString("device_code").equals("null") || whereJson.getString("material_barcode").equals("null")) {
|
||||||
throw new BadRequestException("接口sendProductToFirstFloor,目标站点或子卷号参数为null!");
|
throw new BadRequestException("接口sendProductToFirstFloor,目标站点或子卷号参数为null!");
|
||||||
}
|
}
|
||||||
String containerName = whereJson.getString("material_barcode");
|
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
result.put("data", containerName);
|
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||||
RLock lock = redissonClient.getLock(containerName);
|
result.put("data", whereJson.getString("material_barcode"));
|
||||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
RedissonUtils.lock(c->{
|
||||||
try {
|
//1.查询满轴缓存位是否有空位
|
||||||
if (tryLock) {
|
List<BstIvtPackageinfoivt> MzPoints = packageinfoivtService
|
||||||
//1.查询满轴缓存位是否有空位
|
.list(new LambdaUpdateWrapper<BstIvtPackageinfoivt>()
|
||||||
List<BstIvtPackageinfoivt> bstIvtPackageinfoivtList = packageinfoivtService
|
.eq(BstIvtPackageinfoivt::getIs_used, PackageInfoIvtEnum.IS_USED.code("启用"))
|
||||||
.list(new LambdaUpdateWrapper<BstIvtPackageinfoivt>().eq(BstIvtPackageinfoivt::getIs_used, PackageInfoIvtEnum.IS_USED.code("启用"))
|
.eq(BstIvtPackageinfoivt::getPoint_status, PackageInfoIvtEnum.POINT_STATUS.code("满轴缓存位"))
|
||||||
.orderByAsc(BstIvtPackageinfoivt::getSort_seq));
|
.eq(BstIvtPackageinfoivt::getIvt_status, PackageInfoIvtEnum.IVT_STATUS.code("空"))
|
||||||
List<BstIvtPackageinfoivt> mzPointList = bstIvtPackageinfoivtList.stream()
|
.orderByAsc(BstIvtPackageinfoivt::getSort_seq));
|
||||||
.filter(r -> PackageInfoIvtEnum.POINT_STATUS.code("满轴缓存位").equals(r.getPoint_status())
|
if (CollectionUtils.isEmpty(MzPoints)){
|
||||||
&& PackageInfoIvtEnum.IVT_STATUS.code("空").equals(r.getIvt_status()))
|
result.put("message", "满轴位无可用位置");
|
||||||
.sorted(Comparator.comparing(BstIvtPackageinfoivt::getSort_seq).reversed()).collect(Collectors.toList());
|
return result;
|
||||||
|
|
||||||
JSONObject jo = new JSONObject();
|
|
||||||
jo.put("acs_task_type", PackageInfoIvtEnum.ACS_TASK_TYPE.code("桁架任务"));
|
|
||||||
jo.put("vehicle_code", containerName);
|
|
||||||
//2.创建输送线->满轴位桁架任务,
|
|
||||||
String point_code1 = whereJson.getString("device_code");
|
|
||||||
jo.put("point_code1", point_code1);
|
|
||||||
if (ObjectUtils.isNotEmpty(mzPointList)) {
|
|
||||||
//任意一个满轴缓存位为终点
|
|
||||||
jo.put("point_code2", mzPointList.get(0).getPoint_code());
|
|
||||||
List<BstIvtPackageinfoivt> kzjPointList = bstIvtPackageinfoivtList.stream()
|
|
||||||
.filter(r -> PackageInfoIvtEnum.POINT_STATUS.code("空载具缓存位").equals(r.getPoint_status())
|
|
||||||
&& PackageInfoIvtEnum.IVT_STATUS.code("空载具").equals(r.getIvt_status()))
|
|
||||||
.sorted(Comparator.comparing(BstIvtPackageinfoivt::getSort_seq)).collect(Collectors.toList());
|
|
||||||
//空载具缓存位有空载具,桁架取空载具从外到里取空载具,升序
|
|
||||||
if (ObjectUtils.isNotEmpty(kzjPointList)) {
|
|
||||||
//创建输送线四个点任务
|
|
||||||
return createTask(containerName, jo, kzjPointList.get(0).getPoint_code(), whereJson.getString("device_code"));
|
|
||||||
} else {
|
|
||||||
result.put("status", HttpStatus.BAD_REQUEST.value());
|
|
||||||
result.put("message", "空轴位缓存位无载具");
|
|
||||||
return result;
|
|
||||||
//创建输送线->满轴缓存位两个点任务
|
|
||||||
// return createTask2(containerName, jo);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.put("status", HttpStatus.BAD_REQUEST.value());
|
|
||||||
result.put("message", "满轴缓存位无可用位置");
|
|
||||||
return result;
|
|
||||||
// //如果满轴位没有可用的空点位,先创建一个桁架任务但是不下发,等这边空出来点位,判断是否有这种桁架任务然后补发;
|
|
||||||
// List<String> taskTypes = new ArrayList<>(Arrays.asList(PackageInfoIvtEnum.TASK_TYPE.code("输送线四个点任务"), PackageInfoIvtEnum.TASK_TYPE.code("输送线->满轴缓存位"), PackageInfoIvtEnum.TASK_TYPE.code("放空(空载具缓存位->输送线)")));
|
|
||||||
// List<SchBaseTask> existTaskList = taskService.getExistTasks(taskTypes);
|
|
||||||
// //如果有就不创建,没有就创建
|
|
||||||
// if (ObjectUtils.isEmpty(existTaskList)) {
|
|
||||||
// //只确定起点NBJ1002
|
|
||||||
// JSONObject jo2 = new JSONObject();
|
|
||||||
// jo2.put("acs_task_type", PackageInfoIvtEnum.ACS_TASK_TYPE.code("桁架任务"));
|
|
||||||
// jo2.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("输送线->满轴缓存位"));
|
|
||||||
// jo2.put("point_code1", "NBJ1002");
|
|
||||||
// jo2.put("vehicle_code", containerName);
|
|
||||||
// jo2.put("task_status", TaskStatusEnum.SURE_START.getCode());
|
|
||||||
// jo2.put("is_send", false);
|
|
||||||
// mzhcwTask.createTask(jo2);
|
|
||||||
// PdmProductSpecServiceImpl.doRecord(SpecEnum.XX,null,Boolean.TRUE,null,containerName);
|
|
||||||
// //不确定起点的空载具缓存位->输送线任务
|
|
||||||
// createTask3(containerName);
|
|
||||||
// result.put("status", HttpStatus.OK.value());
|
|
||||||
// result.put("message", "反馈成功!");
|
|
||||||
// } else {
|
|
||||||
// log.info("已存在未完成的且已分配的补空载具或桁架任务,任务编号为:" + existTaskList.get(0).getTask_code() + ",请检查!");
|
|
||||||
// result.put("status", HttpStatus.BAD_REQUEST.value());
|
|
||||||
// result.put("message", "已存在未完成的且已分配的补空载具或桁架任务,任务编号为:" + existTaskList.get(0).getTask_code() + ",请检查!");
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.info("二楼到一楼成品子卷到达一楼输送线任务正在创建被锁住。");
|
|
||||||
result.put("status", HttpStatus.BAD_REQUEST.value());
|
|
||||||
result.put("message", "二楼到一楼成品子卷到达一楼输送线任务正在创建被锁住。");
|
|
||||||
}
|
}
|
||||||
} finally {
|
List<BstIvtPackageinfoivt> empPoints = packageinfoivtService
|
||||||
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
.selectEmpPoints(PackageInfoIvtEnum.POINT_STATUS.code("空载具缓存位"), PackageInfoIvtEnum.IVT_STATUS.code("空"));
|
||||||
lock.unlock();
|
if (CollectionUtils.isEmpty(empPoints)){
|
||||||
|
result.put("message", "空轴位无可用位置");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
// 创建前先判断是否有已创建相同任务
|
||||||
log.info("二楼到一楼,成品子卷到达一楼输送线接口sendProductToFirstFloor调用成功--------------------------:" + result.toString());
|
List<String> taskTypes = new ArrayList<>(Arrays.asList(PackageInfoIvtEnum.TASK_TYPE.code("输送线四个点任务"), PackageInfoIvtEnum.TASK_TYPE.code("输送线->满轴缓存位"), PackageInfoIvtEnum.TASK_TYPE.code("放空(空载具缓存位->输送线)"), PackageInfoIvtEnum.TASK_TYPE.code("补空(待检区->空载具缓存位)"), PackageInfoIvtEnum.TASK_TYPE.code("补空(管制区->空载具缓存位)")));
|
||||||
|
List<SchBaseTask> existTaskList1 = taskService.getExistTasks(taskTypes);
|
||||||
|
List<SchBaseTask> existTaskList2 = existTaskList1.stream().filter(r -> r.getTask_type().equals(PackageInfoIvtEnum.TASK_TYPE.code("输送线四个点任务"))||r.getTask_type().equals(PackageInfoIvtEnum.TASK_TYPE.code("输送线->满轴缓存位"))||r.getTask_type().equals(PackageInfoIvtEnum.TASK_TYPE.code("放空(空载具缓存位->输送线)"))).collect(Collectors.toList());
|
||||||
|
List<SchBaseTask> existTaskList3 = existTaskList1.stream().filter(r -> StringUtils.isNotBlank(r.getResponse_param())).collect(Collectors.toList());
|
||||||
|
if (!CollectionUtils.isEmpty(existTaskList2) ||!CollectionUtils.isEmpty(existTaskList3) ){
|
||||||
|
result.put("message", "存在正在执行的输送线行架任务");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
List<BstIvtPackageinfoivt> sortEmpPoint = empPoints.stream().sorted(Comparator.comparing(BstIvtPackageinfoivt::getSort_seq)).collect(Collectors.toList());
|
||||||
|
JSONObject taskParam = new JSONObject();
|
||||||
|
taskParam.put("acs_task_type", PackageInfoIvtEnum.ACS_TASK_TYPE.code("桁架任务"));
|
||||||
|
taskParam.put("vehicle_code", whereJson.getString("material_barcode"));
|
||||||
|
taskParam.put("point_code1", whereJson.getString("device_code"));
|
||||||
|
taskParam.put("point_code2", MzPoints.get(0).getPoint_code());
|
||||||
|
taskParam.put("point_code3", sortEmpPoint.get(0).getPoint_code());
|
||||||
|
taskParam.put("point_code4", whereJson.getString("device_code"));
|
||||||
|
taskParam.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("输送线四个点任务"));
|
||||||
|
taskParam.put("is_send", true);
|
||||||
|
mzhcwTask.createTask(taskParam);
|
||||||
|
PdmProductSpecServiceImpl.doRecord(SpecEnum.XX,null,Boolean.TRUE,null,whereJson.getString("material_barcode"));
|
||||||
|
result.put("status", HttpStatus.OK.value());
|
||||||
|
result.put("message", "反馈成功!");
|
||||||
|
return result;
|
||||||
|
},"sendProductToFirstFloor",null);
|
||||||
|
log.info("sendProductToFirstFloor调用成功--------------------------:" + result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user