hangzhoumesParent/common/servicebase/src/main/java/com/mes/damage/service/impl/DamageServiceImpl.java
@@ -1,15 +1,13 @@ package com.mes.damage.service.impl; import cn.hutool.core.date.DateTime; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.mes.damage.entity.Damage; import com.mes.damage.mapper.DamageMapper; import com.mes.damage.service.DamageService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.mes.glassinfo.entity.GlassInfo; import com.mes.glassinfo.mapper.GlassInfoMapper; import com.mes.pp.entity.BasicDataProduce; import com.mes.pp.entity.ReportingWork; import com.mes.work_assignment.entity.WorkAssignment; import com.mes.work_assignment.mapper.WorkAssignmentMapper; hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java
@@ -74,11 +74,17 @@ @Value("${mes.max.secondLength}") private String secondLength; @Value("${mes.min.firstLength}") private String minFirstLength; @Value("${mes.min.one.firstLength}") private String minOneFirstLength; @Value("${mes.min.secondLength}") private String minSecondLength; @Value("${mes.min.one.secondLength}") private String minOneSecondLength; @Value("${mes.min.two.firstLength}") private String minTwoFirstLength; @Value("${mes.min.two.secondLength}") private String minTwoSecondLength; @Scheduled(fixedDelay = 1000) public void plcHomeEdgTask() { @@ -115,7 +121,7 @@ inTo(glassIdeValue, confirmationWrodAddress, currentSlot); } else if ("2".equals(taskRequestTypeValue)) { //09空闲 :1 10空闲 :2 都空闲:3 其他0 log.info("2、出片请求,且确认字为0,执行进片任务"); log.info("2、出片请求,且确认字为0,执行出片任务"); outTo(Integer.parseInt(out08Glassstate), Integer.parseInt(out10Glassstate), confirmationWrodAddress, "", 0); } else if ("3".equals(taskRequestTypeValue)) { @@ -227,7 +233,7 @@ // 2、如果没有历史出片任务 // 2.1、出当前版图id最小版序最小的玻璃(问题:两条线都没有历史任务,出片时两条线的玻璃尺寸相同,是否找尺寸不同的) if ((out08Glassstate == 2 && out10Glassstate == 2) || (out08Glassstate == 0 && out10Glassstate == 0)) { log.info("A09、A10为{},{}非自动状态,无法出片"); log.info("A09、A10为{},{}非自动状态,无法出片", out08Glassstate, out10Glassstate); return Boolean.FALSE; } log.info("0、出片任务出的状态:A09:【{}】;A10:【{}】)", out08Glassstate, out10Glassstate); @@ -263,26 +269,27 @@ if (endcell == Const.A10_OUT_TARGET_POSITION) { wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " + "on t.glass_id = t1.glass_id and (t1.first_length <=" + firstLength + " and t1.second_length<=" + secondLength + ") "); "on t.glass_id = t1.glass_id and (t1.first_length between " + minTwoFirstLength + " and " + firstLength + " and t1.second_length between " + minTwoSecondLength + " and " + secondLength + ") "); } else { wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " + "on t.glass_id = t1.glass_id and (t1.first_length >=" + minFirstLength + " and t1.second_length>=" + minSecondLength + ") "); "on t.glass_id = t1.glass_id and (t1.first_length >=" + minOneFirstLength + " and t1.second_length>=" + minOneSecondLength + ") "); } wrapper.last("order by count(t.glass_id) desc limit 2"); List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(wrapper); if (CollectionUtil.isEmpty(list)) { MPJQueryWrapper<GlassInfo> queryWrapper = new MPJQueryWrapper<GlassInfo>() .selectAll(GlassInfo.class).eq("t.glass_id", glassId); // .inSql("t.engineer_id", "select engineer_id from engineering where state = 1"); if (endcell == Const.A10_OUT_TARGET_POSITION) { wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + queryWrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " + "on t.glass_id = t1.glass_id and (t1.first_length <=" + firstLength + " and t1.second_length<=" + secondLength + ") "); "on t.glass_id = t1.glass_id and (t1.first_length between " + minTwoFirstLength + " and " + firstLength + " and t1.second_length between " + minTwoSecondLength + " and " + secondLength + ") "); } else { wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + queryWrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " + "on t.glass_id = t1.glass_id and (t1.first_length >=" + minFirstLength + " and t1.second_length>=" + minSecondLength + ") "); "on t.glass_id = t1.glass_id and (t1.first_length >=" + minOneFirstLength + " and t1.second_length>=" + minOneSecondLength + ") "); } GlassInfo one = glassInfoService.getOne(queryWrapper); if (one != null) { @@ -504,11 +511,12 @@ if (endcell == Const.A10_OUT_TARGET_POSITION) { wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " + "on t.glass_id = t1.glass_id and (t1.first_length <=" + firstLength + " and t1.second_length<=" + secondLength + ") "); "on t.glass_id = t1.glass_id and (t1.first_length between " + minTwoFirstLength + " and " + firstLength + " and t1.second_length between " + minTwoSecondLength + " and " + secondLength + ") "); } else { wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " + "on t.glass_id = t1.glass_id and (t1.first_length >=" + minFirstLength + " and t1.second_length>=" + minSecondLength + ") "); "on t.glass_id = t1.glass_id and (t1.first_length >=" + minOneFirstLength + " and t1.second_length>=" + minOneSecondLength + ") "); } wrapper.last("order by count(t.glass_id) desc limit 2"); List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(wrapper); @@ -546,7 +554,7 @@ return queryMinGlass(firstSize.getWidth(), firstSize.getHeight(), glassId); } EdgStorageCageDetails outGlassInfo = edgStorageCageDetailsService.getOne(new LambdaQueryWrapper<EdgStorageCageDetails>() .eq(EdgStorageCageDetails::getGlassId, taskCache.getGlassId())); .eq(EdgStorageCageDetails::getGlassId, taskCache.getGlassId()).last("limit 1")); log.info("{}线有出片任务信息,任务信息为{},玻璃信息为{}", endcell, taskCache, outGlassInfo); if (outGlassInfo.getWidth() == firstWidth && outGlassInfo.getHeight() == firstHeight) { log.info("数量最多的宽{}高{}和{}线任务的宽{}高{}相同,出数量排第二的玻璃,宽{}高{}", @@ -641,6 +649,8 @@ edgGlassTaskInfo.setStatus(Const.EDG_GLASS_BEFORE); edgGlassTaskInfo.setLine(endcell); edgGlassTaskInfo.setTime(new Date()); //先将历史对列表中本玻璃的数据删除,重新新增一份最新的数据 edgGlassTaskInfoService.remove(new LambdaQueryWrapper<EdgGlassTaskInfo>().eq(EdgGlassTaskInfo::getGlassId, glassInfo.getGlassId())); return edgGlassTaskInfoService.save(edgGlassTaskInfo); } hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java
@@ -244,7 +244,7 @@ log.info("大理片笼空车进片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); } @Scheduled(fixedDelay = 2000) @Scheduled(fixedDelay = 300) public void plcToHomeEdgOutTask() { Date startDate = new Date(); log.info("大理片笼空车进片任务开始执行时间:{}", startDate); @@ -484,6 +484,7 @@ bigStorageCageDetailsService.remove(new LambdaQueryWrapper<BigStorageCageDetails>() .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_NEW).in(BigStorageCageDetails::getGlassId, inDamageTaskInfoList.stream().map(BigStorageCageFeedTask::getGlassId).collect(Collectors.toList()))); //将破损信息新增入破损表 List<Integer> slotList = new ArrayList<>(); for (BigStorageCageFeedTask bigStorageCageFeedTask : inDamageTaskInfoList) { Damage damage = new Damage(); damage.setGlassId(bigStorageCageFeedTask.getGlassId()); @@ -492,7 +493,10 @@ damage.setRemark("进笼前卧转立"); damage.setStatus(2); damageService.insertDamage(damage); slotList.add(bigStorageCageFeedTask.getTargetSlot()); } //更新格子剩余宽度 updateSlotRemainBySlots(slotList); log.info("进片任务执行完成"); } //获取出片任务表中状态为破损的数据 @@ -500,7 +504,7 @@ .eq(BigStorageCageOutTask::getTaskState, Const.BIG_STORAGE_OUT_DAMAGE)); if (CollectionUtils.isNotEmpty(outDamageTaskInfoList)) { log.info("获取出片任务表中破损的玻璃信息{}", outDamageTaskInfoList); bigStorageCageOutTaskService.remove(new LambdaQueryWrapper<BigStorageCageOutTask>().eq(BigStorageCageOutTask::getTaskState, Const.BIG_STORAGE_IN_DAMAGE)); bigStorageCageOutTaskService.remove(new LambdaQueryWrapper<BigStorageCageOutTask>().eq(BigStorageCageOutTask::getTaskState, Const.BIG_STORAGE_OUT_DAMAGE)); List<String> glassIdList = outDamageTaskInfoList.stream().map(BigStorageCageOutTask::getGlassId).collect(Collectors.toList()); //移除钢化下片表数据 temperingGlassInfoService.remove(new LambdaQueryWrapper<TemperingGlassInfo>().in(TemperingGlassInfo::getGlassId, glassIdList)); @@ -508,6 +512,7 @@ bigStorageCageDetailsService.remove(new LambdaQueryWrapper<BigStorageCageDetails>().in(BigStorageCageDetails::getGlassId, glassIdList)); //将破损信息新增入破损表 List<Integer> slotList = new ArrayList<>(); for (BigStorageCageOutTask bigStorageCageOutTask : outDamageTaskInfoList) { Damage damage = new Damage(); damage.setGlassId(bigStorageCageOutTask.getGlassId()); @@ -516,7 +521,10 @@ damage.setRemark("出片后卧转立"); damage.setStatus(2); damageService.insertDamage(damage); slotList.add(bigStorageCageOutTask.getStartSlot()); } //更新格子剩余宽度 updateSlotRemainBySlots(slotList); log.info("出片任务执行完成"); } Date endDate = new Date(); @@ -704,7 +712,69 @@ } } /** * 出片一次仅生成一车玻璃 * * @param list * @param isTempering * @param mesToPLCAddress * @param <T> * @return */ private <T extends BigStorageCageBaseInfo> Boolean computeOutGlassInfo(List<T> list, Boolean isTempering, String mesToPLCAddress) { //任务数据 获取车子存放玻璃最大数量 玻璃间隔 List<BigStorageCageOutTask> bigStorageCageOutTaskList = new ArrayList<>(); //打车剩余尺寸 Integer remainWidth = carWidth; int maxX = 0; for (T e : list) { if (bigStorageCageOutTaskList.size() >= outCarMaxSize || e.getWidth() > remainWidth) { break; } remainWidth = remainWidth - (int) e.getWidth() - glassGap; if (isTempering) { int minLength = Math.min((int) e.getWidth(), (int) e.getHeight()); if (maxX + minLength <= xMaxSize) { bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getSlot(), Const.TEMPERING_OUT_TARGET_POSITION, e.getWidth() * 10, e.getHeight() * 10, 0, 0, 1)); maxX = Math.max(maxX, e.getXCoordinate()); } else { break; } } else { bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getSlot(), Const.ARTIFICIAL_OUT_TARGET_POSITION, e.getWidth() * 10, e.getHeight(), 0, 0, 1)); } } Assert.isFalse(CollectionUtils.isEmpty(bigStorageCageOutTaskList), "未获取出片数据,结束出片任务"); log.info("获取出片任务数据{}条,执行保存", bigStorageCageOutTaskList.size()); bigStorageCageOutTaskService.saveBatch(bigStorageCageOutTaskList); List<String> glassIds = bigStorageCageOutTaskList.stream().map(BigStorageCageOutTask::getGlassId).collect(Collectors.toList()); log.info("将出片玻璃{}玻璃状态改为已出片", glassIds); bigStorageCageDetailsService.update(new LambdaUpdateWrapper<BigStorageCageDetails>() .set(BigStorageCageDetails::getState, Const.GLASS_STATE_OUT_ING) .in(BigStorageCageDetails::getGlassId, glassIds)); int returnData = 0; int count = 1; while (returnData == 0) { S7object.getinstance().plccontrol.writeWord(mesToPLCAddress, 1); returnData = S7object.getinstance().plccontrol.readWord(mesToPLCAddress, 1).get(0); log.info("已向plc第{}次发送出片任务确认,地址为:{},写入的内容为{}", count++, mesToPLCAddress, returnData); } return Boolean.TRUE; } /** * 出片一次生成一炉玻璃 * * @param list * @param isTempering * @param mesToPLCAddress * @param <T> * @return */ private <T extends BigStorageCageBaseInfo> Boolean computeOutMoreGlassInfo(List<T> list, Boolean isTempering, String mesToPLCAddress) { //任务数据 获取车子存放玻璃最大数量 玻璃间隔 List<BigStorageCageOutTask> bigStorageCageOutTaskList = new ArrayList<>(); //打车剩余尺寸 @@ -714,12 +784,11 @@ int maxX = 0; for (T e : list) { int maxLength = Math.max((int) e.getWidth(), (int) e.getHeight()); if (bigStorageCageOutTaskList.size() >= outCarMaxSize || maxLength > remainWidth) { if (serialNumber > outCarMaxSize || maxLength > remainWidth) { remainWidth = carWidth; trainNumber = trainNumber + 1; serialNumber = 1; maxX = 0; continue; } remainWidth = remainWidth - maxLength - glassGap; if (isTempering) { @@ -729,11 +798,12 @@ e.getWidth() * 10, e.getHeight() * 10, trainNumber, serialNumber++, 1)); maxX = Math.max(maxX, e.getXCoordinate()); } else { remainWidth = carWidth; remainWidth = carWidth - maxLength - glassGap; trainNumber = trainNumber + 1; serialNumber = 1; maxX = 0; continue; maxX = e.getXCoordinate(); bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getSlot(), Const.ARTIFICIAL_OUT_TARGET_POSITION, e.getWidth() * 10, e.getHeight(), trainNumber, serialNumber++, 1)); } } else { bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getSlot(), Const.ARTIFICIAL_OUT_TARGET_POSITION, hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java
@@ -134,13 +134,15 @@ log.info("2、查询卧式理片笼里面的空格:{}", nearestEmpty); GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId)); Assert.isFalse(null == glassInfo, "玻璃信息不存在"); if ("1".equals(requestWord) && (glassInfo.getWidth() > throughWidth || glassInfo.getHeight() > throughHeight)) { log.info("玻璃当前尺寸宽:{},高:{}只能直通,当前进片任务需等待", glassInfo.getWidth(), glassInfo.getHeight()); double glassWidth = Math.max(glassInfo.getWidth(), glassInfo.getHeight()); double glassHeight = Math.min(glassInfo.getWidth(), glassInfo.getHeight()); if ("1".equals(requestWord) && (glassWidth > throughWidth || glassHeight > throughHeight)) { log.info("玻璃当前尺寸宽:{},高:{}只能直通,当前进片任务需等待", glassWidth, glassHeight); return; } Boolean checkFlag = Boolean.FALSE; //玻璃尺寸是否走人工下片 if (glassInfo.getWidth() > maxWidth || glassInfo.getHeight() > maxHeight || glassInfo.getWidth() < minWidth || glassInfo.getHeight() < minHeight) { if (glassWidth > maxWidth || glassHeight > maxHeight || glassWidth < minWidth || glassHeight < minHeight) { log.info("该玻璃尺寸不符合要求,需要走人工下片直接进片"); } else { log.info("该玻璃尺寸非人工下片"); @@ -148,6 +150,7 @@ DownWorkstation one = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>() .eq(DownWorkstation::getLayer, glassInfo.getLayer()) .eq(DownWorkstation::getFlowCardId, glassInfo.getFlowCardId())); //是否已经绑定 true:已绑定 false:未绑定 Boolean isBind = Boolean.FALSE; if (null != one) { log.info("该流程卡已绑定架子"); @@ -157,7 +160,7 @@ if (!checkFlag && !isBind) { log.info("该玻璃的流程卡未绑定架子,获取是否有空架子"); List<DownWorkstation> list = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>() .isNull(DownWorkstation::getFlowCardId).orderByDesc(DownWorkstation::getWorkstationId)); .and(on -> on.isNull(DownWorkstation::getFlowCardId).or().eq(DownWorkstation::getFlowCardId, "")).orderByDesc(DownWorkstation::getWorkstationId)); if (CollectionUtils.isNotEmpty(list)) { log.info("有空架子,将流程卡与架子好绑定,执行进片任务 结束"); //绑定流程卡 @@ -176,12 +179,14 @@ endLoop: for (DownGlassInfoDTO e : downGlassInfoDTOList) { List<GlassInfo> glassInfoList = e.getGlassInfoList(); Optional<GlassInfo> glassInfoTempOptional = glassInfoList.stream().filter(item -> item.getWidth() == glassInfo.getWidth() && item.getHeight() == glassInfo.getHeight() && item.getThickness() == glassInfo.getThickness() && item.getFilmsid().equals(glassInfo.getFilmsid())) .findFirst(); if (glassInfoTempOptional.isPresent()) { GlassInfo item = glassInfoTempOptional.get(); //玻璃是否为多层 List<GlassInfo> glassInfoTempList = glassInfoList.stream().filter(item -> item.getWidth() == glassInfo.getWidth() && item.getHeight() == glassInfo.getHeight() && item.getThickness() == glassInfo.getThickness() && item.getFilmsid().equals(glassInfo.getFilmsid())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(glassInfoTempList)) { for (GlassInfo item : glassInfoTempList) { //玻璃是否为多层:1、先获取当前流程卡落架最多的层数,如果为空,表明未绑定流程卡,未落架,然后按照是否可绑定架子决定是否替换。(可忽略不计,本校验仅在前一次调用起作用) // 2、判断落架最多的层数是否为当前替换玻璃的层数,是 则走替换逻辑返回true // 3、不是最多的层数,获取落架最多层数的相同次序的玻璃尺寸与当前替换玻璃的尺寸比较,相同走替换,否则继续循环 // 4、单层玻璃直接走替换 checkFlag = multilayerCheck(item, Boolean.FALSE); if (checkFlag) { //玻璃替换 仅替换流程卡id及层数 @@ -204,13 +209,13 @@ } } } } //将任务插入理片笼详情表 DownStorageCageDetails downStorageCageDetails = new DownStorageCageDetails(); BeanUtils.copyProperties(glassInfo, downStorageCageDetails); downStorageCageDetails.setState(Const.GLASS_STATE_IN); downStorageCageDetails.setSlot(nearestEmpty.getSlot()); downStorageCageDetailsService.save(downStorageCageDetails); // 生成进片任务 initDownGlassTask(glassInfo, 0, nearestEmpty.getSlot(), Const.GLASS_CACHE_TYPE_IN); } @@ -221,9 +226,9 @@ log.info("G06、G11、G13分别为{},{}、{}非自动状态,无法出片", glassStatus06, glassStatus11, glassStatus13); return Boolean.FALSE; } List<DownStorageCageDetails> tempList = downStorageCageDetailsService.list(new LambdaQueryWrapper<DownStorageCageDetails>() .eq(DownStorageCageDetails::getState, Const.GLASS_STATE_IN)); log.info("出片1、笼内的玻璃信息有:{}", tempList); //获取待进片玻璃 DownStorageCageDetails cageDetails = new DownStorageCageDetails(); if (StringUtils.isNotBlank(glassId)) { @@ -234,12 +239,15 @@ cageDetails.setSlot(empty.getSlot()); tempList.add(cageDetails); } log.info("笼内玻璃的数据有:{}", tempList); log.info("出片2:笼内玻璃的数据(包括待进片)有:{}", tempList); if (CollectionUtils.isEmpty(tempList)) { log.info("笼内没有玻璃,无法执行出片"); return Boolean.FALSE; } //优先走08片台的玻璃:走人工下片或者2号机械臂 //1、08台忙碌,仅走1号机械臂 //2、08台空闲,先走扔工下片或2号机械臂,无玻璃出片 在走1号机械臂 //机械臂被禁用的情况下不能继续向禁用的机械臂放玻璃 Boolean flag08 = "1".equals(out08Glassstate) ? Boolean.TRUE : Boolean.FALSE; if (!flag08) { generateTaskByShelf(glassStatus06, glassStatus11, flag08, glassStatus13, tempList, cageDetails, glassId); @@ -248,7 +256,6 @@ return generateTaskByShelf(glassStatus06, glassStatus11, !flag08, glassStatus13, tempList, cageDetails, glassId); } } return Boolean.TRUE; } @@ -264,7 +271,6 @@ log.info("架子已经占满,多层玻璃无法找到对应的格子,需执行替换玻璃的操作"); return Boolean.FALSE; } } if (downGlassInfoDTO.getLayer().equals(glassInfo.getLayer())) { log.info("当前玻璃的流程在架子上落架最多 直接进片"); @@ -293,7 +299,6 @@ glassStatus13, List<DownStorageCageDetails> tempList, DownStorageCageDetails cageDetails, String glassId) { //获取2个机械臂范围内的架子绑定的流程卡信息 List<Integer> workList = new ArrayList(); if (flag08) { if (!"2".equals(glassStatus11)) { workList.addAll(Const.G11_WORK_STATION); @@ -306,51 +311,59 @@ List<Integer> workStationAll = Arrays.asList(1, 2, 3, 4, 5, 6); List<Integer> offWorkStationList = workStationAll.stream().filter(e -> !workList.contains(e)).collect(Collectors.toList()); List<DownStorageCageDetails> list = new ArrayList(); //是否有空架子 true:有 false:无 Boolean isEmptyShelf = Boolean.FALSE; //对笼内玻璃进行过滤,仅出符合逻辑的玻璃 if (CollectionUtils.isNotEmpty(workList)) { List<DownWorkstation> downWorkstationList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>() .eq(DownWorkstation::getEnableState, Const.SLOT_ON).in(DownWorkstation::getWorkstationId, workList)); // log.info("架子被禁用,无法出片落架"); if (CollectionUtils.isEmpty(downWorkstationList)) { log.info("笼子被禁用,无法走机械臂下片"); //走人工下片 if (!"2".equals(glassStatus13)) { list = tempList.stream().filter(item -> item.getWidth() > maxWidth || item.getHeight() > maxHeight).collect(Collectors.toList()); if (flag08 && !"2".equals(glassStatus13)) { list = tempList.stream().filter(item -> { double firstLength = Math.max(item.getWidth(), item.getHeight()); double secondLength = Math.min(item.getWidth(), item.getHeight()); return firstLength > maxWidth || secondLength > maxHeight; }).collect(Collectors.toList()); } } else { //获取可落架的的架子信息(包括空架子) List<DownWorkstation> workstationsIsNotBind = downWorkstationList.stream().filter(item -> null == (item.getFlowCardId())).collect(Collectors.toList()); //将架子的流程卡号及层数作为key //仅获取空架子信息 List<DownWorkstation> workstationsIsNotBind = downWorkstationList.stream().filter(item -> StringUtils.isBlank(item.getFlowCardId())).collect(Collectors.toList()); //将架子的流程卡号及层数作为key 不存在空架子的情况 if (CollectionUtils.isEmpty(workstationsIsNotBind)) { log.info("不存在未绑定流程卡架子"); //筛选出对应架子已绑定流程卡可下片的玻璃 Map<String, List<DownWorkstation>> listMap = downWorkstationList.stream() .filter(item -> null != (item.getFlowCardId())).collect(Collectors.groupingBy(item -> item.getFlowCardId() + ":" + item.getLayer())); .filter(item -> StringUtils.isNotBlank(item.getFlowCardId())).collect(Collectors.groupingBy(item -> item.getFlowCardId() + ":" + item.getLayer())); //过滤筛选获取架子上对应流程卡+层数的笼子内的玻璃信息 list = tempList.stream().filter(item -> listMap.containsKey(item.getFlowCardId() + ":" + item.getLayer())).collect(Collectors.toList()); } else { log.info("存在未绑定流程卡架子,直接获取笼内所有玻璃,且未绑定架子的玻璃信息"); //获取禁用架子的流程号,将笼内绑定架子且架子被禁用的流程卡信息 //获取禁用及非本机械臂的架子的流程号及层数对应的玻璃信息 List<DownWorkstation> downWorkstationOffList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>() .and(i -> i.in(DownWorkstation::getWorkstationId, offWorkStationList).or().eq(DownWorkstation::getEnableState, Const.SLOT_OFF))); //获取被禁用的流程卡信息 //获取被禁用的流程卡信息 为空:将返回笼内的所有玻璃信息 if (CollectionUtils.isEmpty(downWorkstationOffList)) { list = tempList; } else { Map<String, List<DownWorkstation>> listOffMap = downWorkstationOffList.stream().filter(item -> null != (item.getFlowCardId())).collect(Collectors.groupingBy(item -> item.getFlowCardId() + ":" + item.getLayer())); //笼内存在无法出片的玻璃信息,过滤无法出片的玻璃信息,仅获取可出片的玻璃信息 无法出片的玻璃为:未绑定架子、绑定架子被禁用、非本机械臂对应的架子 Map<String, List<DownWorkstation>> listOffMap = downWorkstationOffList.stream().filter(item -> StringUtils.isNotBlank(item.getFlowCardId())).collect(Collectors.groupingBy(item -> item.getFlowCardId() + ":" + item.getLayer())); list = tempList.stream().filter(item -> !listOffMap.containsKey(item.getFlowCardId() + ":" + item.getLayer())).collect(Collectors.toList()); } //空架子表示置为true isEmptyShelf = Boolean.TRUE; //todo:如果禁用架子已绑定流程卡,因为时间不确定,笼子内的玻璃可重新绑定新架子 // list = tempList.stream().filter(item -> !listMap.containsKey(item.getFlowCardId() + ":" + item.getLayer())).collect(Collectors.toList()); } } } else { if (flag08 && !"2".equals(glassStatus13)) { //直接走人工下片 list = tempList.stream().filter(item -> item.getWidth() > maxWidth || item.getHeight() > maxHeight).collect(Collectors.toList()); list = tempList.stream().filter(item -> { double firstLength = Math.max(item.getWidth(), item.getHeight()); double secondLength = Math.min(item.getWidth(), item.getHeight()); return firstLength > maxWidth || secondLength > maxHeight; }).collect(Collectors.toList()); } } if (CollectionUtils.isEmpty(list)) { @@ -358,10 +371,12 @@ return Boolean.FALSE; } String tempGlassId = null; Boolean isBind = Boolean.FALSE; Boolean isNeedBind = Boolean.FALSE; for (DownStorageCageDetails item : list) { if (item.getWidth() > maxWidth || item.getHeight() > maxHeight) { double firstLength = Math.max(item.getWidth(), item.getHeight()); double secondLength = Math.min(item.getWidth(), item.getHeight()); if (firstLength > maxWidth || secondLength > maxHeight) { if (flag08 && !"2".equals(glassStatus13)) { log.info("玻璃宽度或高度超出阈值,执行人工下片"); tempGlassId = item.getGlassId(); @@ -378,7 +393,7 @@ //架子都未绑定流程卡,出笼内子数量最多尺寸最大的玻璃id,无 则返回扫描扫到的玻璃id进行出片 tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId, offWorkStationList); isBind = Boolean.TRUE; isNeedBind = Boolean.TRUE; break loop; } //将笼子内的玻璃进行过滤,仅获取无法落架的流程卡玻璃 @@ -391,7 +406,7 @@ if (isEmptyShelf) { //架子都未绑定流程卡,出笼内子数量最多尺寸最大的玻璃id,无 则返回扫描扫到的玻璃id进行出片 tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId, offWorkStationList); isBind = Boolean.TRUE; isNeedBind = Boolean.TRUE; break loop; } } @@ -409,16 +424,13 @@ DownGlassInfoDTO downGlassInfoDTO = downGlassInfoService.queryDownGlassMaxLayer(item.getFlowCardId()); if (null == downGlassInfoDTO) { // 历史落架玻璃按照相关流程卡取数据库未找到最多玻璃信息,表明当前流程卡下的有层的玻璃均未落架,直接可出当前玻璃 log.info(""); isBind = Boolean.FALSE; tempGlassId = item.getGlassId(); log.info("当前流程卡不存在落架的玻璃,可直接出片落架,玻璃id:{}", tempGlassId); break loop; } if (downGlassInfoDTO.getLayer().equals(downGlassInfoDTO.getLayer())) { log.info("当前玻璃的流程在架子上落架最多,直接出片"); //更新玻璃状态,生成出片任务 tempGlassId = item.getGlassId(); isBind = Boolean.FALSE; log.info("当前玻璃的流程在架子上落架最多,直接出片,玻璃id:{}", tempGlassId); break loop; } Integer sequence = downGlassInfoService.queryMaxSequence(item.getFlowCardId(), item.getLayer()); @@ -427,10 +439,8 @@ .eq(DownGlassInfo::getFlowCardId, downGlassInfoDTO.getFlowCardId()) .eq(DownGlassInfo::getLayer, downGlassInfoDTO.getLayer()).eq(DownGlassInfo::getSequence, sequence)); if (null != downGlassInfoDTO && downGlassInfo.getWidth() == item.getWidth() && downGlassInfo.getHeight() == item.getHeight()) { log.info("相同次序玻璃对应上,可执行进片任务"); //更新玻璃状态,生成出片任务 tempGlassId = item.getGlassId(); isBind = Boolean.FALSE; log.info("相同次序玻璃对应上,可执行进片任务,玻璃id:{}", tempGlassId); break loop; } } @@ -445,7 +455,6 @@ List<DownStorageCageDetails> downStorageCageDetails = singleLayerMap.get(e.getFlowCardId() + e.getLayer()); if (CollectionUtils.isNotEmpty(downStorageCageDetails)) { tempGlassId = downStorageCageDetails.get(0).getGlassId(); isBind = Boolean.FALSE; break; } } @@ -457,12 +466,12 @@ return Boolean.FALSE; } else { //按照出片的玻璃id更新笼内的玻璃状态为已出片 return generateDownGlassOutTask(tempGlassId, Const.GLASS_CACHE_TYPE_OUT, isBind, cageDetails, workList); return generateDownGlassOutTask(tempGlassId, Const.GLASS_CACHE_TYPE_OUT, isNeedBind, cageDetails, workList); } } public Boolean generateDownGlassOutTask(String glassId, Integer taskType, Boolean isBind, DownStorageCageDetails cageDetails, List<Integer> workList) { isNeedBind, DownStorageCageDetails cageDetails, List<Integer> workList) { //按玻璃id获取玻璃信息 DownStorageCageDetails downStorageCageDetails = null; if (glassId.equals(cageDetails.getGlassId())) { @@ -486,10 +495,10 @@ } Integer endCell = null; if (isBind) { if (isNeedBind) { //获取空架子信息,将空架子信息绑定流程卡 DownWorkstation emptyDownWorkstation = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>() .isNull(DownWorkstation::getFlowCardId).in(DownWorkstation::getWorkstationId, workList).orderByDesc(DownWorkstation::getWorkstationId).last("limit 1")); .and(on -> on.isNull(DownWorkstation::getFlowCardId).or().eq(DownWorkstation::getFlowCardId, "")).in(DownWorkstation::getWorkstationId, workList).orderByDesc(DownWorkstation::getWorkstationId).last("limit 1")); if (null != emptyDownWorkstation) { log.info("获取到空架子信息,绑定流程卡"); downWorkstationService.updateFlowCardIdAndCount(downStorageCageDetails.getFlowCardId(), emptyDownWorkstation.getWorkstationId(), downStorageCageDetails.getLayer()); @@ -515,7 +524,7 @@ //生成任务信息 DownGlassInfo downGlassInfo = new DownGlassInfo(); BeanUtils.copyProperties(downStorageCageDetails, downGlassInfo); //todo:落架片序 //落架片序 downGlassInfo.setSequence(downGlassInfoService.queryMaxSequence(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer())); downGlassInfoService.save(downGlassInfo); //生成任务信息