| | |
| | | import cn.smallbun.screw.core.util.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.mes.common.S7object; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.device.PlcParameterObject; |
| | |
| | | @Value("${mes.maxHeight}") |
| | | private Integer maxHeight; |
| | | |
| | | @Value("${mes.minWidth}") |
| | | private Integer minWidth; |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | @Value("${mes.minHeight}") |
| | | private Integer minHeight; |
| | | |
| | | |
| | | @Scheduled(fixedDelay = 3000) |
| | | public void plcHomeEdgTask() { |
| | | PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | String requestWord = plcParameterObject.getPlcParameter("requestWord").getValue(); |
| | |
| | | String confirmationWrodValue = plcParameterObject.getPlcParameter("confirmationWord").getValue(); |
| | | String confirmationWrodAddress = plcParameterObject.getPlcParameter("confirmationWord").getAddress(); |
| | | String currentSlot = plcParameterObject.getPlcParameter("currentCell").getValue(); |
| | | |
| | | |
| | | log.info("1、获取到的请求字为:{},获取到的扫描ID为:{},获取到的确认字为:{},获取到的出片状态分别为:g06:{}、g08:{}、g11:{}、g13:{},当前格子号为:{}", |
| | | requestWord, glassIdeValue, confirmationWrodValue, out06Glassstate, out08Glassstate, out11Glassstate, out13Glassstate, currentSlot); |
| | |
| | | inTo(glassIdeValue, requestWord, currentSlot); |
| | | } else if ("2".equals(requestWord)) { |
| | | //09空闲 :1 10空闲 :2 都空闲:3 其他0 |
| | | log.info("2、出片请求,且确认字为0,执行进片任务"); |
| | | log.info("2、出片请求,且确认字为0,执行出片任务"); |
| | | outTo(out06Glassstate, out08Glassstate, out11Glassstate, out13Glassstate, glassIdeValue, currentSlot); |
| | | } else if ("3".equals(requestWord)) { |
| | | log.info("2、进片和出片都空闲,执行出片任务"); |
| | |
| | | } |
| | | Boolean checkFlag = Boolean.FALSE; |
| | | //玻璃尺寸是否走人工下片 |
| | | if (glassInfo.getWidth() > maxWidth || glassInfo.getHeight() > maxHeight) { |
| | | log.info("该玻璃尺寸走人工下片,直接进片"); |
| | | if (glassInfo.getWidth() > maxWidth || glassInfo.getHeight() > maxHeight || glassInfo.getWidth() < minWidth || glassInfo.getHeight() < minHeight) { |
| | | log.info("该玻璃尺寸不符合要求,需要走人工下片直接进片"); |
| | | } else { |
| | | log.info("该玻璃尺寸非人工下片"); |
| | | //获取该玻璃的流程卡是否已绑定架子 |
| | |
| | | if (!checkFlag && !isBind) { |
| | | log.info("该玻璃的流程卡未绑定架子,获取是否有空架子"); |
| | | List<DownWorkstation> list = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>() |
| | | .isNull(DownWorkstation::getFlowCardId)); |
| | | .isNull(DownWorkstation::getFlowCardId).orderByDesc(DownWorkstation::getWorkstationId)); |
| | | if (CollectionUtils.isNotEmpty(list)) { |
| | | log.info("有空架子,将流程卡与架子好绑定,执行进片任务 结束"); |
| | | //绑定流程卡 |
| | |
| | | return Boolean.FALSE; |
| | | } |
| | | Boolean flag08 = "1".equals(out08Glassstate) ? Boolean.TRUE : Boolean.FALSE; |
| | | if (!generateTaskByShelf(glassStatus11, flag08, glassStatus13, tempList, cageDetails)) { |
| | | return generateTaskByShelf(glassStatus11, !flag08, glassStatus13, tempList, cageDetails); |
| | | if (!generateTaskByShelf(glassStatus06, glassStatus11, flag08, glassStatus13, tempList, cageDetails, glassId)) { |
| | | return generateTaskByShelf(glassStatus06, glassStatus11, !flag08, glassStatus13, tempList, cageDetails, glassId); |
| | | } |
| | | return Boolean.TRUE; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private Boolean generateTaskByShelf(String glassStatus, Boolean flag08, String glassStatus13, List<DownStorageCageDetails> tempList, DownStorageCageDetails cageDetails) { |
| | | private Boolean generateTaskByShelf(String glassStatus06, String glassStatus11, Boolean flag08, String glassStatus13, List<DownStorageCageDetails> tempList, DownStorageCageDetails cageDetails, String glassId) { |
| | | //获取2个机械臂范围内的架子绑定的流程卡信息 |
| | | List<Integer> workList = new ArrayList(); |
| | | |
| | | if (flag08) { |
| | | if (!"2".equals(glassStatus)) { |
| | | if (!"2".equals(glassStatus11)) { |
| | | workList.addAll(Const.G11_WORK_STATION); |
| | | } |
| | | } else { |
| | | if (!"2".equals(glassStatus)) { |
| | | if (!"2".equals(glassStatus06)) { |
| | | workList.addAll(Const.G06_WORK_STATION); |
| | | } |
| | | } |
| | |
| | | //对笼内玻璃进行过滤,仅出符合逻辑的玻璃 |
| | | if (CollectionUtils.isNotEmpty(workList)) { |
| | | List<DownWorkstation> downWorkstationList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>() |
| | | .eq(DownWorkstation::getEnableState, 0).in(DownWorkstation::getWorkstationId, workList)); |
| | | .eq(DownWorkstation::getEnableState, Const.SLOT_ON).in(DownWorkstation::getWorkstationId, workList)); |
| | | log.info("架子被禁用,无法出片落架"); |
| | | if (CollectionUtils.isEmpty(downWorkstationList)) { |
| | | log.info("笼子被禁用,无法走机械臂下片"); |
| | |
| | | List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Boolean.TRUE); |
| | | List<String> downGlassFlowList = downGlassInfoDTOList.stream().map(item -> item.getFlowCardId() + ":" + item.getLayer()).collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(downGlassFlowList)) { |
| | | //架子都未绑定流程卡,出笼内子数量最多尺寸最大的玻璃 |
| | | DownStorageCageDetails downStorageCageDetails = downStorageCageDetailsService.getGlassInfoMaxCount(); |
| | | //绑定流程卡,更新玻璃状态,生成出片任务, |
| | | tempGlassId = downStorageCageDetails.getGlassId(); |
| | | //架子都未绑定流程卡,出笼内子数量最多尺寸最大的玻璃id,无 则返回扫描扫到的玻璃id进行出片 |
| | | tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId); |
| | | isBind = Boolean.TRUE; |
| | | break loop; |
| | | } |
| | |
| | | // List<DownWorkstation> emptyShelfList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>() |
| | | // .isNull(DownWorkstation::getFlowCardId)); |
| | | if (isEmptyShelf) { |
| | | DownStorageCageDetails downStorageCageDetails = downStorageCageDetailsService.getGlassInfoMaxCount(); |
| | | //绑定流程卡,更新玻璃状态,生成出片任务 |
| | | tempGlassId = downStorageCageDetails.getGlassId(); |
| | | //架子都未绑定流程卡,出笼内子数量最多尺寸最大的玻璃id,无 则返回扫描扫到的玻璃id进行出片 |
| | | tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId); |
| | | isBind = Boolean.TRUE; |
| | | break loop; |
| | | } |
| | |
| | | return Boolean.FALSE; |
| | | } |
| | | //更新落架玻璃数量 |
| | | if (endCell == 7) { |
| | | downWorkstationService.update(new UpdateWrapper<DownWorkstation>().eq("flow_card_id", downStorageCageDetails.getFlowCardId()) |
| | | .eq("layer", downStorageCageDetails.getLayer()).setSql("artificial_number = artificial_number +1")); |
| | | } else { |
| | | downWorkstationService.update(new UpdateWrapper<DownWorkstation>().eq("flow_card_id", downStorageCageDetails.getFlowCardId()) |
| | | .eq("layer", downStorageCageDetails.getLayer()).setSql("racks_number = racks_number +1")); |
| | | } |
| | | |
| | | //生成任务信息 |
| | | DownGlassInfo downGlassInfo = new DownGlassInfo(); |
| | |
| | | downGlassTask.setStartCell(startCell); |
| | | downGlassTask.setGlassId(glassInfo.getGlassId()); |
| | | downGlassTask.setEndCell(endCell); |
| | | downGlassTask.setTaskType(taskType + ""); |
| | | downGlassTask.setTaskType(taskType); |
| | | downGlassTask.setWidth((int) glassInfo.getWidth()); |
| | | downGlassTask.setHeight((int) glassInfo.getHeight()); |
| | | downGlassTask.setFlowCardId(glassInfo.getFlowCardId()); |
| | | downGlassTask.setLayer(glassInfo.getLayer()); |
| | | downGlassTask.setTaskStauts(0); |
| | | downGlassTask.setTaskStatus(0); |
| | | downGlassTask.setCreateTime(new Date()); |
| | | downGlassTaskService.save(downGlassTask); |
| | | //向plc发送命令 |