| | |
| | | import cn.hutool.core.lang.Assert; |
| | | import cn.smallbun.screw.core.util.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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.damage.entity.Damage; |
| | | import com.mes.damage.service.DamageService; |
| | | import com.mes.device.PlcParameterObject; |
| | | import com.mes.downglassinfo.entity.DownGlassInfo; |
| | | import com.mes.downglassinfo.entity.DownGlassTask; |
| | |
| | | DownWorkstationService downWorkstationService; |
| | | @Autowired |
| | | DownGlassInfoService downGlassInfoService; |
| | | @Autowired |
| | | DamageService damageService; |
| | | |
| | | @Value("${mes.threshold}") |
| | | private Integer threshold; |
| | | |
| | | @Value("${mes.throughWidth}") |
| | | private Integer throughWidth; |
| | |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 300) |
| | | public void plcShelfFull() { |
| | | List<DownWorkstation> list = downGlassInfoService.queryWorkStationIsFull(); |
| | | if (CollectionUtils.isNotEmpty(list)) { |
| | | S7control s7control = S7object.getinstance().plccontrol; |
| | | PlcParameterObject plcMesObject = S7object.getinstance().PlcMesObject; |
| | | s7control.writeWord(plcMesObject.getPlcParameter("alarm_signal").getAddress(), 1); |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void dealDamageTask() { |
| | | Date startDate = new Date(); |
| | | log.info("下片破损玻璃清除任务开始执行时间:{}", startDate); |
| | | List<DownGlassTask> downGlassTaskList = downGlassTaskService.list(new LambdaQueryWrapper<DownGlassTask>() |
| | | .in(DownGlassTask::getTaskType, Const.GLASS_CACHE_TYPE_OUT_ALL).in(DownGlassTask::getTaskStatus, Const.GLASS_STATE_DAMAGE_TAKE)); |
| | | if (CollectionUtils.isNotEmpty(downGlassTaskList)) { |
| | | //获取破损/拿走玻璃id |
| | | List<String> glassList = downGlassTaskList.stream().map(DownGlassTask::getGlassId).collect(Collectors.toList()); |
| | | //将任务表中的数据删除 |
| | | downGlassTaskService.remove(new LambdaQueryWrapper<DownGlassTask>().in(DownGlassTask::getTaskType, Const.GLASS_CACHE_TYPE_OUT_ALL).in(DownGlassTask::getGlassId, glassList)); |
| | | List<Damage> damageList = downGlassTaskList.stream().map(e -> { |
| | | Damage damage = new Damage(); |
| | | damage.setGlassId(e.getGlassId()); |
| | | damage.setLine(Const.TEMPERING_OUT_TARGET_POSITION); |
| | | damage.setWorkingProcedure("下片"); |
| | | damage.setRemark("下片"); |
| | | damage.setStatus(0); |
| | | damage.setType(e.getTaskStatus()); |
| | | return damage; |
| | | }).collect(Collectors.toList()); |
| | | damageService.batchInsertDamage(damageList); |
| | | } |
| | | Date endDate = new Date(); |
| | | log.info("本次任务结束时间:{},共耗时:{}ms", endDate, endDate.getTime() - startDate.getTime()); |
| | | } |
| | | |
| | | /** |
| | | * 更新已绑定工位流程卡的破损/拿走的数量信息 |
| | | */ |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void updateWorkStationOtherCount() { |
| | | Date startDate = new Date(); |
| | | log.info("下片破更新损玻璃数量任务开始执行时间:{}", startDate); |
| | | //获取已绑定流程卡的工位信息 |
| | | List<DownWorkstation> downWorkstationList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>() |
| | | .isNotNull(DownWorkstation::getFlowCardId) |
| | | .ne(DownWorkstation::getFlowCardId, "") |
| | | .orderByDesc(DownWorkstation::getWorkstationId)); |
| | | for (DownWorkstation downWorkstation : downWorkstationList) { |
| | | //更新工位其他玻璃信息的数量 |
| | | QueryWrapper<Damage> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("process_id", downWorkstation.getFlowCardId()); |
| | | queryWrapper.eq("technology_number", downWorkstation.getLayer()); |
| | | int otherNumber = damageService.count(queryWrapper); |
| | | downWorkstationService.update(new LambdaUpdateWrapper<DownWorkstation>().set(DownWorkstation::getOtherNumber, otherNumber) |
| | | .eq(DownWorkstation::getWorkstationId, downWorkstation.getWorkstationId())); |
| | | } |
| | | Date endDate = new Date(); |
| | | log.info("下片破更新损玻璃数量任务结束时间:{},共耗时:{}ms", endDate, endDate.getTime() - startDate.getTime()); |
| | | } |
| | | |
| | | public void inTo(String glassId, String requestWord, String currentSlot) { |
| | | log.info("1、按照玻璃id:{}获取玻璃小片信息,当前格子为:{}", glassId, currentSlot); |
| | | //添加进片任务 查找空格 |
| | |
| | | } |
| | | if (!checkFlag) { |
| | | log.info("无空架子,获取已绑定架子的流程卡信息,查看玻璃信息是否可被对调"); |
| | | List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Const.WORK_STATION_ALL, Boolean.FALSE); |
| | | List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Boolean.FALSE); |
| | | log.info("获取架子上已绑定流程卡落架的数量及未落架的玻璃数据:{}", downGlassInfoDTOList); |
| | | if (CollectionUtils.isEmpty(downGlassInfoDTOList)) { |
| | | log.info("已绑定流程卡均无未落架玻璃,请及时处理架子上的玻璃,清除流程卡,执行进片任务"); |
| | |
| | | BeanUtils.copyProperties(glassInfo, downStorageCageDetails); |
| | | downStorageCageDetails.setState(Const.GLASS_STATE_IN); |
| | | downStorageCageDetails.setSlot(nearestEmpty.getSlot()); |
| | | downStorageCageDetails.setDeviceId(nearestEmpty.getDeviceId()); |
| | | downStorageCageDetailsService.save(downStorageCageDetails); |
| | | // 生成进片任务 |
| | | initDownGlassTask(glassInfo, 0, nearestEmpty.getSlot(), Const.GLASS_CACHE_TYPE_IN); |
| | |
| | | //获取当前笼子空格信息 |
| | | DownStorageCage empty = downStorageCageService.selectCacheEmpty(Integer.parseInt(currentSlot), Boolean.TRUE); |
| | | cageDetails.setSlot(empty.getSlot()); |
| | | cageDetails.setDeviceId(empty.getDeviceId()); |
| | | tempList.add(cageDetails); |
| | | } |
| | | log.info("出片2:笼内玻璃的数据(包括待进片)有:{}", tempList); |
| | |
| | | } |
| | | } |
| | | 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:无 |
| | |
| | | .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()); |
| | | if (CollectionUtils.isEmpty(list) && 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 { |
| | | log.info("存在未绑定流程卡架子,直接获取笼内所有玻璃,且未绑定架子的玻璃信息(都可以出的玻璃)"); |
| | | log.info("存在未绑定流程卡架子,直接获取笼内所有玻璃,且未绑定架子的玻璃信息"); |
| | | //获取禁用及非本机械臂的架子的流程号及层数对应的玻璃信息 |
| | | List<DownWorkstation> downWorkstationOffList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>() |
| | | .and(i -> i.in(DownWorkstation::getWorkstationId, offWorkStationList).or().eq(DownWorkstation::getEnableState, Const.SLOT_OFF))); |
| | |
| | | log.info("笼内玻璃无法执行出片"); |
| | | return Boolean.FALSE; |
| | | } |
| | | //获取具体出那一片玻璃 |
| | | //tao:人工--> 所有架子都未绑定时进行绑定 --->有未绑定架子时进行绑定 --->绑定过流程卡的玻璃-->玻璃流程卡多层--->玻璃流程卡单层 |
| | | String tempGlassId = null; |
| | | Boolean isNeedBind = Boolean.FALSE; |
| | | |
| | |
| | | loop: |
| | | if (StringUtils.isBlank(tempGlassId)) { |
| | | //获取正在落架的绑定流程卡的信息(流程卡、层数、落架数量) |
| | | //落架玻璃数为0,即使绑定了流程卡,也无法找到对应的架子信息,只能重新绑定 |
| | | List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationFlowCard(workList); |
| | | 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)) { |
| | | //架子都未绑定流程卡,出笼内子数量最多尺寸最大的玻璃id,无 则返回扫描扫到的玻璃id进行出片 |
| | | tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId, offWorkStationList); |
| | | |
| | | isNeedBind = Boolean.TRUE; |
| | | break loop; |
| | | } |
| | | //将笼子内的玻璃进行过滤,仅获取无法落架的流程卡玻璃 |
| | | //tao:当有空架时优先对笼内可出片且未绑架子的玻璃进出绑架并出片 |
| | | List<DownStorageCageDetails> noDownLoadList = list.stream().filter(item -> !downGlassFlowList.contains(item.getFlowCardId() + ":" + item.getLayer())) |
| | | .collect(Collectors.toList()); |
| | | if (CollectionUtils.isNotEmpty(noDownLoadList)) { |
| | |
| | | return Boolean.FALSE; |
| | | } |
| | | //将笼内玻璃的流程卡+层号 和落架的流程卡 去重,得出展示无法落架的玻璃,判断玻璃数是否超过阈值 |
| | | //笼内玻璃是否可落架:笼内是否有需要中空 |
| | | //笼内玻璃是否可落架:笼内是否有需要中空的 |
| | | List<DownStorageCageDetails> multiLayerList = list.stream().filter(item -> item.getTotalLayer() >= 2).collect(Collectors.toList()); |
| | | if (CollectionUtils.isNotEmpty(multiLayerList)) { |
| | | for (DownStorageCageDetails item : multiLayerList) { |
| | |
| | | break loop; |
| | | } |
| | | Integer sequence = downGlassInfoService.queryMaxSequence(item.getFlowCardId(), item.getLayer()); |
| | | log.info("获取当前玻璃需要放的次序:笼内同流程 同层数的落架次序+1:{}", sequence); |
| | | log.info("获取当前玻璃需要放的次序:笼内同流程 同层数的通达次序+1:{}", sequence); |
| | | DownGlassInfo downGlassInfo = downGlassInfoService.getOne(new LambdaQueryWrapper<DownGlassInfo>() |
| | | .eq(DownGlassInfo::getFlowCardId, downGlassInfoDTO.getFlowCardId()) |
| | | .eq(DownGlassInfo::getLayer, downGlassInfoDTO.getLayer()).eq(DownGlassInfo::getSequence, sequence)); |
| | |
| | | if (CollectionUtils.isNotEmpty(downStorageCageDetails)) { |
| | | tempGlassId = downStorageCageDetails.get(0).getGlassId(); |
| | | break; |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | //落架片序 |
| | | downGlassInfo.setSequence(downGlassInfoService.queryMaxSequence(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer())); |
| | | downGlassInfo.setWorkStationId(endCell); |
| | | downGlassInfo.setGmtCreate(new Date()); |
| | | downGlassInfoService.save(downGlassInfo); |
| | | //生成任务信息 |
| | | GlassInfo glassInfo = new GlassInfo(); |