opt:优化装箱区装箱空载具按空载具数量进行下发agv任务
This commit is contained in:
@@ -27,17 +27,23 @@ import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
|
|||||||
import org.nl.common.enums.PackageInfoIvtEnum;
|
import org.nl.common.enums.PackageInfoIvtEnum;
|
||||||
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.common.utils.RedisUtils;
|
||||||
import org.nl.wms.sch.AcsTaskDto;
|
import org.nl.wms.sch.AcsTaskDto;
|
||||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||||
import org.nl.wms.util.TaskUtil;
|
import org.nl.wms.util.TaskUtil;
|
||||||
import org.springframework.beans.BeanUtils;
|
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.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 6 目标装箱对接位, 装箱区 -> 装箱对接位,桁架任务
|
* 6 目标装箱对接位, 装箱区 -> 装箱对接位,桁架任务
|
||||||
@@ -46,10 +52,14 @@ import java.util.List;
|
|||||||
* @since 2024-02-01
|
* @since 2024-02-01
|
||||||
*/
|
*/
|
||||||
@Service()
|
@Service()
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ZxDjwTask extends AbstractAcsTask {
|
public class ZxDjwTask extends AbstractAcsTask {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Qualifier("threadPoolExecutor")
|
||||||
|
private ThreadPoolExecutor pool;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AutoSendVehicleToDjq autoSendVehicleToDjq;
|
private AutoSendVehicleToDjq autoSendVehicleToDjq;
|
||||||
@Resource
|
@Resource
|
||||||
@@ -63,6 +73,9 @@ public class ZxDjwTask extends AbstractAcsTask {
|
|||||||
@Resource
|
@Resource
|
||||||
private IPdmBiSlittingproductionplanService productionPlanService;
|
private IPdmBiSlittingproductionplanService productionPlanService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisUtils redisUtils;
|
||||||
|
private static final String NUM_KEY = "AutoSendZxToDjw:NUM";
|
||||||
private final String THIS_CLASS = ZxDjwTask.class.getName();
|
private final String THIS_CLASS = ZxDjwTask.class.getName();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -120,31 +133,32 @@ public class ZxDjwTask extends AbstractAcsTask {
|
|||||||
} else if (StrUtil.isEmpty(containerInfo.getContainer_name())) {
|
} else if (StrUtil.isEmpty(containerInfo.getContainer_name())) {
|
||||||
throw new BadRequestException("子卷号不能为空!");
|
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"));
|
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())) {
|
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"));
|
BstIvtBoxinfo bstIvtBoxinfo = bstIvtBoxinfoMapper.selectOne(new LambdaQueryWrapper<BstIvtBoxinfo>().eq(BstIvtBoxinfo::getBox_no, schBaseTask.getVehicle_code2()).ne(BstIvtBoxinfo::getIs_packing, "1"));
|
||||||
if (bstIvtBoxinfo == null) {
|
if (bstIvtBoxinfo == null) {
|
||||||
throw new BadRequestException("子卷包装关系为已装箱或找该任务的木箱号不存在!");
|
throw new BadRequestException("子卷包装关系为已装箱或找该任务的木箱号不存在!");
|
||||||
}
|
}
|
||||||
bstIvtBoxinfo.setIs_packing(IOSEnum.IS_NOTANDYES.code("是"));
|
bstIvtBoxinfo.setIs_packing(IOSEnum.IS_NOTANDYES.code("是"));
|
||||||
bstIvtBoxinfoMapper.updateById(bstIvtBoxinfo);
|
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()));
|
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
|
PdmBiSubpackagerelation pdmBiSubpackagerelation = subpackageRelationService
|
||||||
.getOne(new LambdaUpdateWrapper<PdmBiSubpackagerelation>().eq(PdmBiSubpackagerelation::getContainer_name, schBaseTask.getVehicle_code()), false);
|
.getOne(new LambdaUpdateWrapper<PdmBiSubpackagerelation>().eq(PdmBiSubpackagerelation::getContainer_name, schBaseTask.getVehicle_code()), false);
|
||||||
pdmBiSubpackagerelation.setStatus(IOSEnum.IS_NOTANDYES.code("是"));
|
pdmBiSubpackagerelation.setStatus(IOSEnum.IS_NOTANDYES.code("是"));
|
||||||
subpackageRelationService.updateById(pdmBiSubpackagerelation);
|
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("否"))) {
|
if (status.equals(IOSEnum.IS_NOTANDYES.code("否"))) {
|
||||||
@@ -159,6 +173,33 @@ public class ZxDjwTask extends AbstractAcsTask {
|
|||||||
taskService.update(null, updateWrapper);
|
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
|
@Override
|
||||||
public String createTask(JSONObject form) {
|
public String createTask(JSONObject form) {
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ public class AutoSendVehicleToDjq {
|
|||||||
@Resource
|
@Resource
|
||||||
private IschBaseTaskService taskService;
|
private IschBaseTaskService taskService;
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RedissonClient redissonClient;
|
private RedissonClient redissonClient;
|
||||||
@Resource
|
@Resource
|
||||||
@@ -109,6 +108,7 @@ public class AutoSendVehicleToDjq {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String getPointCode(JSONObject task, String taskType) {
|
private String getPointCode(JSONObject task, String taskType) {
|
||||||
String pointCode2 = null;
|
String pointCode2 = null;
|
||||||
List<BstIvtPackageinfoivt> packageList;
|
List<BstIvtPackageinfoivt> packageList;
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ import static org.nl.wms.util.TaskUtil.getMaxNum;
|
|||||||
public class AutoSendZxToDjw {
|
public class AutoSendZxToDjw {
|
||||||
private final String THIS_CLASS = AutoSendZxToDjw.class.getName();
|
private final String THIS_CLASS = AutoSendZxToDjw.class.getName();
|
||||||
|
|
||||||
private final Integer NUM = 0;
|
|
||||||
private static final String NUM_KEY = "AutoSendZxToDjw:NUM";
|
private static final String NUM_KEY = "AutoSendZxToDjw:NUM";
|
||||||
|
|
||||||
private final RedissonClient redissonClient;
|
private final RedissonClient redissonClient;
|
||||||
|
|||||||
Reference in New Issue
Block a user