opt:优化装箱区装箱空载具按空载具数量进行下发agv任务

This commit is contained in:
2024-07-17 09:35:47 +08:00
parent 2ae67fc99e
commit 9e0e105785
3 changed files with 54 additions and 14 deletions

View File

@@ -27,17 +27,23 @@ import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
import org.nl.common.enums.PackageInfoIvtEnum;
import org.nl.common.utils.SecurityUtils;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.RedisUtils;
import org.nl.wms.sch.AcsTaskDto;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.util.TaskUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* 6 目标装箱对接位, 装箱区 -> 装箱对接位,桁架任务
@@ -46,10 +52,14 @@ import java.util.List;
* @since 2024-02-01
*/
@Service()
@RequiredArgsConstructor
@Slf4j
public class ZxDjwTask extends AbstractAcsTask {
@Resource
@Qualifier("threadPoolExecutor")
private ThreadPoolExecutor pool;
@Resource
private AutoSendVehicleToDjq autoSendVehicleToDjq;
@Resource
@@ -63,6 +73,9 @@ public class ZxDjwTask extends AbstractAcsTask {
@Resource
private IPdmBiSlittingproductionplanService productionPlanService;
@Resource
private RedisUtils redisUtils;
private static final String NUM_KEY = "AutoSendZxToDjw:NUM";
private final String THIS_CLASS = ZxDjwTask.class.getName();
@Override
@@ -120,31 +133,32 @@ public class ZxDjwTask extends AbstractAcsTask {
} else if (StrUtil.isEmpty(containerInfo.getContainer_name())) {
throw new BadRequestException("子卷号不能为空!");
}
//1.判断是否最后一个子卷相同木箱号的子卷包装关系如果生成状态0,且个数等于1且子卷号等于当前载具号就是最后一个子卷
//1.更改任务状态为完成
updateWrapper.set(SchBaseTask::getTask_status, TaskStatusEnum.FINISHED.getCode());
//2.改变起点点位状态
packageinfoivtService.update(null, new UpdateWrapper<BstIvtPackageinfoivt>().set("ivt_status", PackageInfoIvtEnum.IVT_STATUS.code("空载具")).set("container_name", null).eq("point_code", schBaseTask.getPoint_code1()));
//3.判断是否最后一个子卷相同木箱号的子卷包装关系如果生成状态0,且个数等于1且子卷号等于当前载具号就是最后一个子卷
List<PdmBiSubpackagerelation> packagerelationList = subpackageRelationService.list(new LambdaQueryWrapper<PdmBiSubpackagerelation>().eq(PdmBiSubpackagerelation::getPackage_box_sn, schBaseTask.getVehicle_code2()).eq(PdmBiSubpackagerelation::getStatus, "0"));
if (packagerelationList.size() == 1 && packagerelationList.get(0).getContainer_name().equals(schBaseTask.getVehicle_code())) {
//2.更改木箱信息为已装箱:1
//4.更改木箱信息为已装箱:1
BstIvtBoxinfo bstIvtBoxinfo = bstIvtBoxinfoMapper.selectOne(new LambdaQueryWrapper<BstIvtBoxinfo>().eq(BstIvtBoxinfo::getBox_no, schBaseTask.getVehicle_code2()).ne(BstIvtBoxinfo::getIs_packing, "1"));
if (bstIvtBoxinfo == null) {
throw new BadRequestException("子卷包装关系为已装箱或找该任务的木箱号不存在!");
}
bstIvtBoxinfo.setIs_packing(IOSEnum.IS_NOTANDYES.code(""));
bstIvtBoxinfoMapper.updateById(bstIvtBoxinfo);
//3.最后一个子卷,清除装箱位木箱信息
//5.最后一个子卷,清除装箱位木箱信息
packageinfoivtService.update(null, new UpdateWrapper<BstIvtPackageinfoivt>().set("ivt_status", PackageInfoIvtEnum.IVT_STATUS.code("")).set("container_name", null).eq("point_code", schBaseTask.getPoint_code2()));
//4.创建装箱区->待检区或管制区补空任务
autoSendVehicleToDjq.sendVehicleToDjqOrGzq1(IOSEnum.IS_NOTANDYES.code(""));
//清除最后一个子卷计数
redisUtils.set(NUM_KEY, 0);
//6.创建装箱区->待检区或管制区补空任务
callingVehicleToDjqOrGzq(packagerelationList);
}
//5.改变子卷包装状态为已装箱1
//7.改变子卷包装状态为已装箱1
PdmBiSubpackagerelation pdmBiSubpackagerelation = subpackageRelationService
.getOne(new LambdaUpdateWrapper<PdmBiSubpackagerelation>().eq(PdmBiSubpackagerelation::getContainer_name, schBaseTask.getVehicle_code()), false);
pdmBiSubpackagerelation.setStatus(IOSEnum.IS_NOTANDYES.code(""));
subpackageRelationService.updateById(pdmBiSubpackagerelation);
//6.更改任务状态为完成
updateWrapper.set(SchBaseTask::getTask_status, TaskStatusEnum.FINISHED.getCode());
//7.改变起点点位状态
packageinfoivtService.update(null, new UpdateWrapper<BstIvtPackageinfoivt>().set("ivt_status", PackageInfoIvtEnum.IVT_STATUS.code("空载具")).set("container_name", null).eq("point_code", schBaseTask.getPoint_code1()));
}
// 取消
if (status.equals(IOSEnum.IS_NOTANDYES.code(""))) {
@@ -159,6 +173,33 @@ public class ZxDjwTask extends AbstractAcsTask {
taskService.update(null, updateWrapper);
}
@Async("pool")
public void callingVehicleToDjqOrGzq(List<PdmBiSubpackagerelation> packagerelationList) {
callingVehicleToDjqOrGzq(Integer.parseInt(packagerelationList.get(0).getQuanlity_in_box().toString()));
}
/**
* 装箱任务完成,异步调用装箱区->待检区补空任务
*/
private void callingVehicleToDjqOrGzq(Integer callingNum) {
for (int i = 0; i < callingNum; i++) {
final int index = i;
pool.execute(() -> {
try {
TimeUnit.SECONDS.sleep(4L * index);
autoSendVehicleToDjq.sendVehicleToDjqOrGzq1(IOSEnum.IS_NOTANDYES.code(""));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
e.printStackTrace();
}
});
}
}
@Override
public String createTask(JSONObject form) {

View File

@@ -34,7 +34,6 @@ public class AutoSendVehicleToDjq {
@Resource
private IschBaseTaskService taskService;
@Resource
private RedissonClient redissonClient;
@Resource
@@ -109,6 +108,7 @@ public class AutoSendVehicleToDjq {
private String getPointCode(JSONObject task, String taskType) {
String pointCode2 = null;
List<BstIvtPackageinfoivt> packageList;

View File

@@ -51,7 +51,6 @@ import static org.nl.wms.util.TaskUtil.getMaxNum;
public class AutoSendZxToDjw {
private final String THIS_CLASS = AutoSendZxToDjw.class.getName();
private final Integer NUM = 0;
private static final String NUM_KEY = "AutoSendZxToDjw:NUM";
private final RedissonClient redissonClient;