diff --git a/lms/nladmin-system/src/main/java/org/nl/b_lms/pdm/subpackagerelation/service/impl/PdmBiSubpackagerelationServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/b_lms/pdm/subpackagerelation/service/impl/PdmBiSubpackagerelationServiceImpl.java index 6df38bd92..6019b7883 100644 --- a/lms/nladmin-system/src/main/java/org/nl/b_lms/pdm/subpackagerelation/service/impl/PdmBiSubpackagerelationServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/b_lms/pdm/subpackagerelation/service/impl/PdmBiSubpackagerelationServiceImpl.java @@ -845,6 +845,147 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl containerNameList, String deviceCode, String boxSn) { + //待检区点位 + List djqPointList = packageinfoivtService + .list(new LambdaUpdateWrapper() + .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 djqPoints = djqPointList.stream() + .filter(r -> containerNameList.contains(r.getContainer_name())) + .collect(Collectors.toList()); + //任务组id + String groupId = deviceCode.substring(deviceCode.lastIndexOf("_") + 1); + List schBaseTaskList = new ArrayList<>(); + //确定起点,安装装箱组标识加入任务队列 + djqPoints.forEach(r -> { + //校验重复任务 + List taskList = taskService.list(new LambdaQueryWrapper().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); + } + } + /** + * 子卷装箱 + * + * @param whereJson 分配信息 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void updateEntityList(JSONObject whereJson) { + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + List packagerelationList = JSONObject.parseArray(whereJson.getJSONArray("tableMater").toJSONString(), PdmBiSubpackagerelation.class); + if (CollectionUtils.isEmpty(packagerelationList)) { + throw new BadRequestException("无选中子卷信息"); + } + if (packagerelationList.size() > 1) { + throw new BadRequestException("暂时只能选择一个子卷"); + } + //检查是否存在已分配规格的子卷号 + List 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 pdmBiSubpackagerelationList = pdmBiSubpackagerelationMapper + .selectList(new LambdaQueryWrapper().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 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 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 workIdList, Set 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 containerNameList, String deviceCode, String boxSn) { //待检区点位 List djqPointList = packageinfoivtService