add:增加不对接MES包装关系逻辑

This commit is contained in:
2024-07-02 23:57:50 +08:00
parent d4708ccc7a
commit d02dea3fcc

View File

@@ -2,8 +2,6 @@ package org.nl.b_lms.pdm.subpackagerelation.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.StopWatch;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -227,6 +225,7 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
return pdmBiSubpackagerelationList;
}
/**
* 创建
*
@@ -744,6 +743,8 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
if (StrUtil.isEmpty(containerName)) {
throw new BadRequestException("输入的子卷号不能为空!");
}
}
/**
* 子卷装箱
@@ -806,7 +807,8 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
/**
* 空木箱出库
*/
private void outBox(List<String> workIdList, Set<String> containerNameList, String deviceCode, Integer maxBoxGroup, String boxType) {
private void outBox(List<String> workIdList, Set<String> containerNameList, String deviceCode, Integer
maxBoxGroup, String boxType) {
//均衡获取装箱对接位
//String deviceCode = "ZXQ_1_1";
StopWatch stopWatch = new StopWatch();
@@ -886,146 +888,6 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
taskQueue.addTasksToQueue(groupId, schBaseTaskList);
}
}
/**
* 子卷装箱
*
* @param whereJson 分配信息
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void updateEntityList(JSONObject whereJson) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<PdmBiSubpackagerelation> packagerelationList = JSONObject.parseArray(whereJson.getJSONArray("tableMater").toJSONString(), PdmBiSubpackagerelation.class);
if (CollectionUtils.isEmpty(packagerelationList)) {
throw new BadRequestException("无选中子卷信息");
}
if (packagerelationList.size() > 1) {
throw new BadRequestException("暂时只能选择一个子卷");
}
//检查是否存在已分配规格的子卷号
List<PdmBiSubpackagerelation> isOutBox = packagerelationList.stream().filter(r -> r.getStatus().equals("0")).collect(Collectors.toList());
if (isOutBox.size() > 0) {
throw new BadRequestException("标记为黄色的子卷号已分配且对应的木箱已出库,请重新选择未分配木箱规格的子卷");
}
//均衡获取木箱出库装箱区对接位
String deviceCode = getPointCode();
Integer taskCount = bstIvtPackageinfoivtMapper.getZxqTaskCount(deviceCode.substring(deviceCode.lastIndexOf("_") + 1));
if (taskCount + packagerelationList.size() > 10) {
throw new BadRequestException("子卷搬运任务数已达上限!");
}
List<PdmBiSubpackagerelation> pdmBiSubpackagerelationList = pdmBiSubpackagerelationMapper
.selectList(new LambdaQueryWrapper<PdmBiSubpackagerelation>().eq(PdmBiSubpackagerelation::getSale_order_name, packagerelationList.get(0).getSale_order_name()));
Integer maxBoxGroup = pdmBiSubpackagerelationList.stream()
.map(PdmBiSubpackagerelation::getBox_group)
.filter(Objects::nonNull)
.map(Integer::parseInt)
.max(Integer::compareTo)
.orElse(0) + 1;
try {
List<String> workIdList = JSONObject.parseArray(whereJson.getJSONArray("tableMater").toJSONString(), PdmBiSubpackagerelation.class).stream()
.map(PdmBiSubpackagerelation::getWorkorder_id)
.map(String::valueOf)
.collect(Collectors.toList());
if (workIdList.isEmpty()) {
return;
}
//根据分切计划获取子卷重量计算理论毛重
Set<String> containerNameList = packagerelationList.stream()
.map(PdmBiSubpackagerelation::getContainer_name)
.collect(Collectors.toSet());
stopWatch.stop();
System.out.println("子卷装箱代码1装箱信息查询执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
log.info("子卷装箱代码1箱信息查询执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
outBox(workIdList, containerNameList, deviceCode, maxBoxGroup, whereJson.getString("checked"));
} catch (Exception e) {
log.error("子卷装箱updateEntityList接口捕获异常信息" + e);
}
}
/**
* 空木箱出库
*/
private void outBox(List<String> workIdList, Set<String> containerNameList, String deviceCode, Integer maxBoxGroup, String boxType) {
//均衡获取装箱对接位
//String deviceCode = "ZXQ_1_1";
StopWatch stopWatch = new StopWatch();
stopWatch.start();
JSONObject boxInfo = new JSONObject();
//确定装箱区终点
boxInfo.put("device_code", deviceCode);
boxInfo.put("material_code", boxType);
boxInfo.put("num", workIdList.size());
//String boxSn = outBoxManageService.outBox(boxInfo);
stopWatch.stop();
System.out.println("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
log.info("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
String boxSn = "MX230118000013";
StopWatch stopWatch1 = new StopWatch();
stopWatch1.start();
//更新及子卷包装状态已分配规格及木箱规格组
CompletableFuture.runAsync(() -> {
try {
updateBoxGroup(maxBoxGroup, workIdList, boxSn, boxType);
} catch (Exception e) {
log.error("异常信息:" + e);
}
}, pool);
//待检区->装箱区agv任务
CompletableFuture.runAsync(() -> {
try {
agvTransfer(containerNameList, deviceCode, boxSn);
} catch (Exception e) {
log.error("异常信息:" + e);
}
}, pool);
stopWatch1.stop();
System.out.println("子卷装箱代码2装箱信息更新执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch1.getTotalTimeMillis());
log.info("子卷装箱代码2装箱信息更新执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch1.getTotalTimeMillis());
}
protected void agvTransfer(Set<String> containerNameList, String deviceCode, String boxSn) {
//待检区点位
List<BstIvtPackageinfoivt> djqPointList = packageinfoivtService
.list(new LambdaUpdateWrapper<BstIvtPackageinfoivt>()
.eq(BstIvtPackageinfoivt::getPoint_status, PackageInfoIvtEnum.POINT_STATUS.code("待检区"))
.eq(BstIvtPackageinfoivt::getIs_used, PackageInfoIvtEnum.IS_USED.code("启用"))
.eq(BstIvtPackageinfoivt::getIvt_status, PackageInfoIvtEnum.IVT_STATUS.code("合格品"))
//.eq(BstIvtPackageinfoivt::getIvt_status, PackageInfoIvtEnum.IVT_STATUS.code("有子卷"))
.orderByAsc(BstIvtPackageinfoivt::getSort_seq));
List<BstIvtPackageinfoivt> djqPoints = djqPointList.stream()
.filter(r -> containerNameList.contains(r.getContainer_name()))
.collect(Collectors.toList());
//任务组id
String groupId = deviceCode.substring(deviceCode.lastIndexOf("_") + 1);
List<SchBaseTask> schBaseTaskList = new ArrayList<>();
//确定起点,安装装箱组标识加入任务队列
djqPoints.forEach(r -> {
//校验重复任务
List<SchBaseTask> taskList = taskService.list(new LambdaQueryWrapper<SchBaseTask>().eq(SchBaseTask::getVehicle_code, r.getContainer_name()).eq(SchBaseTask::getTask_type, PackageInfoIvtEnum.TASK_TYPE.code("待检区->装箱区"))
.eq(SchBaseTask::getIs_delete, IOSEnum.IS_NOTANDYES.code("")));
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("task_status", TaskStatusEnum.SURE_START.getCode());
//木箱号
jo.put("vehicle_code2", groupId);
//任务组id
SchBaseTask task = new SchBaseTask();
SchBaseTask taskDto = zxqTask.createTaskReturnTask(jo);
task.setTask_id(taskDto.getTask_id());
task.setVehicle_code(taskDto.getVehicle_code());
//增加任务到队列
schBaseTaskList.add(task);
}
});
if (CollectionUtils.isNotEmpty(schBaseTaskList)) {
taskQueue.addTasksToQueue(groupId, schBaseTaskList);
}
}
}