| | |
| | | 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("有空架子,将流程卡与架子好绑定,执行进片任务 结束"); |
| | | //绑定流程卡 |
| | | downWorkstationService.update(new LambdaUpdateWrapper<DownWorkstation>() |
| | | .set(DownWorkstation::getFlowCardId, glassInfo.getFlowCardId()) |
| | | .set(DownWorkstation::getLayer, glassInfo.getLayer()) |
| | | .eq(DownWorkstation::getWorkstationId, list.get(0).getWorkstationId())); |
| | | downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), glassInfo.getLayer(), list.get(0).getWorkstationId()); |
| | | checkFlag = Boolean.TRUE; |
| | | } |
| | | } |
| | |
| | | return Boolean.FALSE; |
| | | } |
| | | Boolean flag08 = "1".equals(out08Glassstate) ? Boolean.TRUE : Boolean.FALSE; |
| | | if (!generateTaskByShelf(glassStatus06, glassStatus11, flag08, glassStatus13, tempList, cageDetails)) { |
| | | return generateTaskByShelf(glassStatus06, 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 glassStatus06, String glassStatus11, 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(); |
| | | |
| | |
| | | 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; |
| | | } |
| | |
| | | .isNull(DownWorkstation::getFlowCardId).orderByDesc(DownWorkstation::getWorkstationId).last("limit 1")); |
| | | if (null != emptyDownWorkstation) { |
| | | log.info("获取到空架子信息,绑定流程卡"); |
| | | emptyDownWorkstation.setFlowCardId(downStorageCageDetails.getFlowCardId()); |
| | | emptyDownWorkstation.setLayer(downStorageCageDetails.getLayer()); |
| | | downWorkstationService.updateById(emptyDownWorkstation); |
| | | downWorkstationService.updateFlowCardIdAndCount(downStorageCageDetails.getFlowCardId(), downStorageCageDetails.getLayer(), emptyDownWorkstation.getWorkstationId()); |
| | | endCell = emptyDownWorkstation.getWorkstationId(); |
| | | } else { |
| | | log.info("没有空架子信息,无法绑定流程卡"); |
| | |
| | | return Boolean.FALSE; |
| | | } |
| | | //更新落架玻璃数量 |
| | | if (endCell == 7) { |
| | | downWorkstationService.update(new UpdateWrapper<DownWorkstation>().eq("flow_card_id", downStorageCageDetails.getFlowCardId()) |
| | | .eq("layer", downStorageCageDetails.getLayer()).setSql("other_number = other_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.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发送命令 |