fix:装箱区任务不生成
This commit is contained in:
@@ -55,6 +55,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
@@ -244,7 +245,8 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
|
||||
//子卷信息校验
|
||||
checkEntityList(whereJson, packagerelationList);
|
||||
//均衡获取木箱出库装箱区对接位
|
||||
String deviceCode = getPointCode(packagerelationList.size());
|
||||
//= getPointCode(packagerelationList.size());
|
||||
String deviceCode = "ZXQ_1_1";
|
||||
try {
|
||||
List<String> workIdList = JSONObject.parseArray(whereJson.getJSONArray("tableMater").toJSONString(), PdmBiSubpackagerelation.class).stream()
|
||||
.map(PdmBiSubpackagerelation::getWorkorder_id)
|
||||
@@ -347,6 +349,7 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
|
||||
log.error("子卷装箱异常,updateBoxGroup更新子卷包装关系异常,木箱号为:" + boxSn + ",异常信息:" + e);
|
||||
}
|
||||
}, pool);
|
||||
agvTransfer(containerNameList, deviceCode, boxSn);
|
||||
//待检区->装箱区agv任务
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
@@ -430,7 +433,10 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
|
||||
|
||||
private String getPointCode(Integer entitySize) {
|
||||
//装箱区对接位
|
||||
List<BstIvtPackageinfoivt> bstIvtPackageinfoivtList = bstIvtPackageinfoivtMapper.selectList(new LambdaQueryWrapper<BstIvtPackageinfoivt>().eq(BstIvtPackageinfoivt::getPoint_status, PackageInfoIvtEnum.POINT_STATUS.code("装箱位")).eq(BstIvtPackageinfoivt::getIs_used, IOSEnum.IS_NOTANDYES.code("是")).orderByAsc(BstIvtPackageinfoivt::getPoint_code));
|
||||
List<BstIvtPackageinfoivt> bstIvtPackageinfoivtList = bstIvtPackageinfoivtMapper.selectList(new LambdaQueryWrapper<BstIvtPackageinfoivt>()
|
||||
.eq(BstIvtPackageinfoivt::getPoint_status, PackageInfoIvtEnum.POINT_STATUS.code("装箱位"))
|
||||
.eq(BstIvtPackageinfoivt::getIs_used, IOSEnum.IS_NOTANDYES.code("是"))
|
||||
.orderByAsc(BstIvtPackageinfoivt::getPoint_code));
|
||||
if (ObjectUtils.isEmpty(bstIvtPackageinfoivtList)) {
|
||||
throw new BadRequestException("没有可用的装箱区对接位");
|
||||
}
|
||||
@@ -571,34 +577,25 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
List<SchBaseTaskDto> schBaseTaskList = new ArrayList<>();
|
||||
//确定起点,安装装箱组标识加入任务队列
|
||||
djqPoints.forEach(r -> {
|
||||
String now = DateUtil.now();
|
||||
for (int i1 = 0; i1 < djqPoints.size(); i1++) {
|
||||
BstIvtPackageinfoivt item = djqPoints.get(i1);
|
||||
//校验重复任务
|
||||
List<SchBaseTask> taskList = taskService.list(new LambdaQueryWrapper<SchBaseTask>().eq(SchBaseTask::getVehicle_code, r.getContainer_name()).eq(SchBaseTask::getTask_type, PackageInfoIvtEnum.TASK_TYPE.code("待检区->装箱区"))
|
||||
List<SchBaseTask> taskList = taskService.list(new LambdaQueryWrapper<SchBaseTask>().eq(SchBaseTask::getVehicle_code, item.getContainer_name()).eq(SchBaseTask::getTask_type, PackageInfoIvtEnum.TASK_TYPE.code("待检区->装箱区"))
|
||||
.eq(SchBaseTask::getIs_delete, IOSEnum.IS_NOTANDYES.code("否")).lt(SchBaseTask::getTask_status, TaskStatusEnum.FINISHED.getCode()));
|
||||
if (ObjectUtils.isEmpty(taskList)) {
|
||||
if (CollectionUtils.isEmpty(taskList)){
|
||||
JSONObject jo = new JSONObject();
|
||||
//确定搬运任务不执行
|
||||
jo.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("待检区->装箱区"));
|
||||
jo.put("vehicle_code", r.getContainer_name());
|
||||
jo.put("point_code1", r.getPoint_code());
|
||||
jo.put("vehicle_code", item.getContainer_name());
|
||||
jo.put("point_code1", item.getPoint_code());
|
||||
jo.put("date",now);
|
||||
jo.put("task_step",i1);
|
||||
jo.put("task_status", TaskStatusEnum.SURE_START.getCode());
|
||||
//木箱号
|
||||
jo.put("vehicle_code2", groupId);
|
||||
//任务组id
|
||||
SchBaseTaskDto task = new SchBaseTaskDto();
|
||||
//保存任务子卷号
|
||||
SchBaseTask taskDto = zxqTask.createTaskReturnTask(jo);
|
||||
task.setTask_id(taskDto.getTask_id());
|
||||
task.setTask_code(taskDto.getTask_code());
|
||||
task.setVehicle_code(taskDto.getVehicle_code());
|
||||
//增加任务到队列
|
||||
schBaseTaskList.add(task);
|
||||
zxqTask.createTaskReturnTask(jo);
|
||||
}
|
||||
});
|
||||
if (ObjectUtils.isNotEmpty(schBaseTaskList)) {
|
||||
taskQueue.addTasksToQueue(groupId, schBaseTaskList);
|
||||
}
|
||||
} else {
|
||||
log.info("待检区->装箱区任务队列正在创建被锁住。");
|
||||
|
||||
@@ -269,10 +269,11 @@ public class ZxqTask extends AbstractAcsTask {
|
||||
.task_id(org.nl.common.utils.IdUtil.getStringId())
|
||||
.task_code(org.nl.common.utils.IdUtil.getStringId())
|
||||
.handle_class(THIS_CLASS)
|
||||
.task_step(form.getBigDecimal("task_step"))
|
||||
.car_no(form.getString("car_no"))
|
||||
.create_id(SecurityUtils.getCurrentUserId())
|
||||
.create_name(SecurityUtils.getCurrentUsername())
|
||||
.create_time(DateUtil.now())
|
||||
.create_time(form.getString("date"))
|
||||
.is_send(isSend ? "1" : "0")
|
||||
.request_param(form.getString("request_param"))
|
||||
.acs_task_type(StrUtil.isEmpty(form.getString("acs_task_type")) ? PackageInfoIvtEnum.ACS_TASK_TYPE.code("agv任务") : form.getString("acs_task_type"))
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -33,7 +34,7 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AutoExecuteWaitTask {
|
||||
public class AutoExecuteWaitTask extends Prun{
|
||||
private final String THIS_CLASS = AutoExecuteWaitTask.class.getName();
|
||||
|
||||
@Resource
|
||||
@@ -49,6 +50,7 @@ public class AutoExecuteWaitTask {
|
||||
private IbstIvtPackageinfoivtService packageinfoivtService;
|
||||
|
||||
//自动执行等待的桁架任务
|
||||
@Autowired
|
||||
public void run() {
|
||||
this.executeWaitTask();
|
||||
}
|
||||
|
||||
@@ -76,7 +76,6 @@ public class AutoSendToZxq extends Prun{
|
||||
LinkedHashMap::new,
|
||||
Collectors.mapping(BstIvtPackageinfoivt::getPoint_code, Collectors.toList())
|
||||
));
|
||||
//taskQueueManager.processTasks(ivtList);
|
||||
taskQueue.processTasks(ivtList);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.b_lms.sch.tasks.first_floor_area.auto;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -15,16 +16,17 @@ import org.nl.b_lms.sch.task.dto.SchBaseTaskDto;
|
||||
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
|
||||
import org.nl.b_lms.sch.tasks.first_floor_area.ShiftingTask;
|
||||
import org.nl.b_lms.sch.tasks.first_floor_area.ZxqTask;
|
||||
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
|
||||
import org.nl.common.enums.PackageInfoIvtEnum;
|
||||
import org.nl.modules.common.utils.RedisUtils;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.wms.sch.AcsUtil;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -33,16 +35,18 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class TaskQueue {
|
||||
|
||||
@Resource
|
||||
@Autowired
|
||||
private IschBaseTaskService taskService;
|
||||
@Resource
|
||||
@Autowired
|
||||
private IbstIvtPackageinfoivtService packageinfoivtService;
|
||||
@Resource
|
||||
@Autowired
|
||||
private BstIvtPackageinfoivtMapper bstIvtPackageinfoivtMapper;
|
||||
@Resource
|
||||
@Autowired
|
||||
private ZxqTask zxqTask;
|
||||
@Resource
|
||||
@Autowired
|
||||
private ShiftingTask shiftingTask;
|
||||
@Autowired
|
||||
private AcsUtil acsUtil;
|
||||
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@@ -64,38 +68,36 @@ public class TaskQueue {
|
||||
* 任务下发
|
||||
*/
|
||||
public void processTasks(Map<String, List<String>> tasksToProcessPerQueue) {
|
||||
tasksToProcessPerQueue.forEach((groupId, points) -> {
|
||||
int taskCount = points.size();
|
||||
for (int i = 0; i < taskCount; i++) {
|
||||
//List<Object> taskElements = getTaskElements(groupId);
|
||||
//Long taskCounts = getTaskCount(groupId);
|
||||
SchBaseTask task = (SchBaseTask) redisUtils.popFromList(TASK_QUEUE_PREFIX + groupId, SchBaseTask.class);
|
||||
if (task != null) {
|
||||
try {
|
||||
String pointCode = points.get(i);
|
||||
executeTask(task, pointCode);
|
||||
} catch (Exception ex) {
|
||||
log.info("子卷装箱:从待检区任务队列消费任务失败,检查检查,任务组为:" + groupId + ",任务编号为:" + task.getTask_code() + "子卷号为:" + task.getVehicle_code() + "异常信息:" + ex.toString());
|
||||
}
|
||||
}
|
||||
//车间分区
|
||||
zxqTask.immediateNotifyAcs(null);
|
||||
for (String block : tasksToProcessPerQueue.keySet()) {
|
||||
List<String> empPointList = tasksToProcessPerQueue.get(block);
|
||||
List<SchBaseTask> list = taskService.list(new QueryWrapper<SchBaseTask>()
|
||||
.lt("task_status", TaskStatusEnum.SURE_START.getCode())
|
||||
.eq("vehicle_code2", block)
|
||||
.eq("task_type", PackageInfoIvtEnum.TASK_TYPE.code("待检区->装箱区"))
|
||||
.eq("is_delete", IOSEnum.IS_NOTANDYES.code("否")).orderByDesc("create_time", "task_step"));
|
||||
log.info("当前zxq有起点任务数量"+list.size());
|
||||
for (int i = 0; i < Math.min(empPointList.size(),list.size()); i++) {
|
||||
String empPoin = empPointList.get(i);
|
||||
SchBaseTask task = list.get(i);
|
||||
executeTask(task,empPoin);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void executeTask(SchBaseTask task, String pointCode) {
|
||||
if (task != null) {
|
||||
//查询子卷号的货位
|
||||
BstIvtPackageinfoivt newIvt = packageinfoivtService.list(new LambdaQueryWrapper<BstIvtPackageinfoivt>().eq(BstIvtPackageinfoivt::getContainer_name, task.getVehicle_code())).get(0);
|
||||
BstIvtPackageinfoivt newIvt = packageinfoivtService.list(new LambdaQueryWrapper<BstIvtPackageinfoivt>()
|
||||
.eq(BstIvtPackageinfoivt::getContainer_name, task.getVehicle_code())).get(0);
|
||||
String pointCode1 = newIvt.getPoint_code();
|
||||
//是否深库位
|
||||
if (newIvt.getDepth().equals(PackageInfoIvtEnum.DEPTH_TYPE.code("浅货位"))) {
|
||||
//是浅货位,直接创建搬运任务
|
||||
task.setPoint_code1(pointCode1);
|
||||
task.setPoint_code2(pointCode);
|
||||
log.info("子卷装箱:待检区->装箱区agv任务编号为:" + task.getTask_code() + "子卷号为:" + task.getVehicle_code() + ",任务状态为:" + task.getTask_status() + "任务开始下发。");
|
||||
task.setTask_status(TaskStatusEnum.START_AND_POINT.getCode());
|
||||
taskService.updateById(task);
|
||||
zxqTask.immediateNotifyAcs(null);
|
||||
log.info("子卷装箱:待检区->装箱区agv任务编号为:" + "子卷号为:" + task.getVehicle_code() + task.getTask_code() + ",任务状态为:" + task.getTask_status() + "下发完成。");
|
||||
} else {
|
||||
//是深货位,查询对应的浅货位
|
||||
@@ -110,38 +112,9 @@ public class TaskQueue {
|
||||
if (ObjectUtils.isEmpty(existTaskList)) {
|
||||
task.setPoint_code1(pointCode1);
|
||||
task.setPoint_code2(pointCode);
|
||||
log.info("子卷装箱:待检区->装箱区agv任务编号为:" + "子卷号为:" + task.getVehicle_code() + task.getTask_code() + ",任务状态为:" + task.getTask_status() + "任务开始下发。");
|
||||
task.setTask_status(TaskStatusEnum.START_AND_POINT.getCode());
|
||||
taskService.updateById(task);
|
||||
zxqTask.immediateNotifyAcs(null);
|
||||
log.info("子卷装箱:待检区->装箱区agv任务编号为:" + "子卷号为:" + task.getVehicle_code() + task.getTask_code() + ",任务状态为:" + task.getTask_status() + "下发完成。");
|
||||
} else {
|
||||
//有放货任务,先创建移库任务确定起点,再创建搬运任务确定终点,等任务放货任务完成,再执行移库任务,移库任务完成,再执行搬运任务
|
||||
//更新搬运任务新起点
|
||||
task.setPoint_code1(pointCode1);
|
||||
task.setPoint_code2(pointCode);
|
||||
task.setTask_status(TaskStatusEnum.SURE_END.getCode());
|
||||
taskService.updateById(task);
|
||||
//查找移库目标点位
|
||||
JSONObject task1 = new JSONObject();
|
||||
//获取移库任务目标点
|
||||
String pointCode2 = packageinfoivtService.getDjqShiftingPoint(shallowIvt, true);
|
||||
task1.put("task_status", StringUtils.isBlank(pointCode2) ? TaskStatusEnum.SURE_START.getCode() : TaskStatusEnum.SURE_END.getCode());
|
||||
task1.put("vehicle_code2", PackageInfoIvtEnum.AGV_ACTION_TYPE.code("移库任务"));
|
||||
task1.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("待检区移库任务"));
|
||||
task1.put("vehicle_code", shallowIvt.getContainer_name());
|
||||
task1.put("point_code1", shallowIvt.getPoint_code());
|
||||
task1.put("point_code2", pointCode2);
|
||||
//移库任务绑定搬运任务组标识
|
||||
task1.put("task_group_id", task.getTask_id());
|
||||
task1.put("material_code", shallowIvt.getIvt_status());
|
||||
//创建移库任务
|
||||
String shiftingTaskId = shiftingTask.createTask(task1);
|
||||
//放货任务绑定移库任务组标识
|
||||
LambdaUpdateWrapper<SchBaseTask> updateWrapper = new LambdaUpdateWrapper<SchBaseTask>()
|
||||
.eq(SchBaseTask::getTask_id, existTaskList.get(0).getTask_id());
|
||||
updateWrapper.set(SchBaseTask::getTask_group_id, shiftingTaskId);
|
||||
taskService.update(null, updateWrapper);
|
||||
}
|
||||
} else {
|
||||
//库位不为空,创建移库任务,查询该点位是否存在取货任务,如果存在,先更新搬运任务为确定终点任务,则等任务完成后再下发
|
||||
@@ -149,24 +122,8 @@ public class TaskQueue {
|
||||
pointCodes2.add(shallowIvt.getPoint_code());
|
||||
List<SchBaseTask> existTaskList = bstIvtPackageinfoivtMapper.getTaskList(pointCodes2, null, null, null).stream().filter(r -> !r.getTask_type().equals(PackageInfoIvtEnum.TASK_TYPE.code("待检区->装箱区"))).collect(Collectors.toList());
|
||||
//存在取货任务
|
||||
if (ObjectUtils.isNotEmpty(existTaskList)) {
|
||||
//无需移库,等待取货任务完成,创建搬运任务
|
||||
//放货任务绑定移库任务组标识
|
||||
LambdaUpdateWrapper<SchBaseTask> updateWrapper = new LambdaUpdateWrapper<SchBaseTask>()
|
||||
.eq(SchBaseTask::getTask_id, existTaskList.get(0).getTask_id());
|
||||
updateWrapper.set(SchBaseTask::getTask_group_id, task.getTask_id());
|
||||
taskService.update(null, updateWrapper);
|
||||
//更新搬运任务只确定终点
|
||||
task.setPoint_code1(newIvt.getPoint_code());
|
||||
task.setPoint_code2(pointCode);
|
||||
task.setTask_status(TaskStatusEnum.SURE_END.getCode());
|
||||
taskService.updateById(task);
|
||||
} else {
|
||||
//更新搬运任务终点
|
||||
task.setPoint_code1(newIvt.getPoint_code());
|
||||
task.setPoint_code2(pointCode);
|
||||
task.setTask_status(TaskStatusEnum.SURE_END.getCode());
|
||||
taskService.updateById(task);
|
||||
if (ObjectUtils.isEmpty(existTaskList)) {
|
||||
//任务等下次在做
|
||||
//直接创建移库任务
|
||||
//获取移库任务目标点
|
||||
JSONObject task1 = new JSONObject();
|
||||
@@ -185,7 +142,6 @@ public class TaskQueue {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
//@Component
|
||||
@RequiredArgsConstructor
|
||||
@Order(100)
|
||||
public class JobRunner implements ApplicationRunner {
|
||||
|
||||
@@ -50,7 +50,6 @@ public class AcsToWmsController {
|
||||
|
||||
@PostMapping("/apply")
|
||||
@Log(value = "申请任务", isInterfaceLog = true, interfaceLogType = InterfaceLogType.ACS_TO_LMS)
|
||||
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> apply(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(acsToWmsService.apply(whereJson), HttpStatus.OK);
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.sch.AcsTaskDto;
|
||||
import org.nl.wms.sch.AcsUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,6 +20,8 @@ import java.util.List;
|
||||
* @created 2020年6月12日 下午5:53:28
|
||||
*/
|
||||
public abstract class AbstractAcsTask {
|
||||
@Autowired
|
||||
AcsUtil acsUtil;
|
||||
/**
|
||||
* @discription 在如果任务无法形成会一直定时刷新判断
|
||||
* @author ldjun
|
||||
@@ -111,7 +114,7 @@ public abstract class AbstractAcsTask {
|
||||
List<AcsTaskDto> taskList = this.schedule();
|
||||
if (ObjectUtil.isNotEmpty(taskList)) {
|
||||
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(taskList));
|
||||
return AcsUtil.notifyAcs("api/wms/task", arr);
|
||||
return acsUtil.notifyAcs3("api/wms/task", arr);
|
||||
}
|
||||
return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user