| | |
| | | import com.mes.bigstoragecagetask.service.BigStorageCageTaskService; |
| | | import com.mes.bigstoragetask.entity.UpdateBigStorageCageDTO; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.common.config.ConstSysConfig; |
| | | import com.mes.damage.entity.Damage; |
| | | import com.mes.damage.service.DamageService; |
| | | import com.mes.edgglasstask.entity.EdgGlassTaskInfo; |
| | | import com.mes.edgglasstask.service.EdgGlassTaskInfoService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.sysconfig.service.SysConfigService; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import com.mes.utils.RedisUtil; |
| | |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | @Autowired(required = false) |
| | | MiloService miloService; |
| | | |
| | | @Resource |
| | | SysConfigService sysConfigService; |
| | | |
| | | /** |
| | | * 直通格子 |
| | | */ |
| | |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Value("${mes.slotWidth}") |
| | | private Integer slotWidth; |
| | | |
| | | @Value("${mes.glassGap}") |
| | | private Integer glassGap; |
| | | |
| | | @Value("${mes.carWidth}") |
| | | private Integer carWidth; |
| | | |
| | | @Value("${mes.outCarMaxSize}") |
| | | private Integer outCarMaxSize; |
| | | |
| | | @Value("${mes.temperingOutTargetPosition}") |
| | | private Integer temperingOutTargetPosition; |
| | | @Value("${mes.artificialOutTargetPosition}") |
| | | private Integer artificialOutTargetPosition; |
| | | @Value("${mes.slotMaxHeight}") |
| | | private Integer slotMaxHeight; |
| | | @Value("${mes.slotMaxthickness}") |
| | | private Integer slotMaxthickness; |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | // @Scheduled(fixedDelay = 1000) |
| | | public void inBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | |
| | | return; |
| | | } |
| | | log.info("获取任务的玻璃id:{}", glassIdList); |
| | | ReadWriteEntity countEntity = miloService.readFromOpcUa("DLP1A.DLP1A.glassCount"); |
| | | if (null == countEntity.getValue() || Integer.parseInt(countEntity.getValue() + "") != glassIdList.size()) { |
| | | log.info("当前大车进片玻璃数量{}与mes读取到的数量{}不匹配,结束进片任务", countEntity.getValue(), glassIdList.size()); |
| | | //向plc发送报警:当前大车进片玻璃数量与mes读取到的数量不匹配 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 1)); |
| | | return; |
| | | } |
| | | Map<String, Long> glassCountMap = glassIdList.stream().collect(Collectors.groupingBy(e -> e, Collectors.counting())); |
| | | for (Map.Entry<String, Long> entry : glassCountMap.entrySet()) { |
| | | if (entry.getValue() > 1) { |
| | | log.info("进片玻璃{}存在相同,结束本次任务", entry.getKey()); |
| | | //todo:向plc发送报警 |
| | | //向plc发送报警:同一车进片玻璃存在相同 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 2)); |
| | | return; |
| | | } |
| | | } |
| | |
| | | .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO)); |
| | | if (CollectionUtil.isNotEmpty(detailsList)) { |
| | | log.info("理片笼存在相同的进片玻璃{},结束本次任务", detailsList); |
| | | //todo:向plc发送报警 |
| | | //向plc发送报警:理片笼存在相同的进片玻璃 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 4)); |
| | | return; |
| | | } |
| | | List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().in(GlassInfo::getGlassId, glassIdList)); |
| | | |
| | | if (glassInfoList.size() != inTaskList.size()) { |
| | | log.info("进片任务数量{}与玻璃数量{}不匹配,结束本次进片", inTaskList.size(), glassInfoList.size()); |
| | | //todo:向plc发送报警 |
| | | //向plc发送报警:进片任务数量与系统查询到的玻璃数量不匹配 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 8)); |
| | | return; |
| | | } |
| | | Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_GLASS_GAP); |
| | | Integer slotMaxthickness = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_MAX_THICKNESS); |
| | | Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_WIDTH); |
| | | Integer slotMaxHeight = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_MAX_HEIGHT); |
| | | //按照玻璃厚度分组,判断剩余格子是否可以存放 |
| | | Map<Double, Long> thickCountMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getThickness, Collectors.counting())); |
| | | for (Map.Entry<Double, Long> entry : thickCountMap.entrySet()) { |
| | | int count = bigStorageCageService.count(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth) |
| | | .le(BigStorageCage::getMinThickness, entry.getKey()) |
| | | .ge(BigStorageCage::getMaxThickness, entry.getKey())); |
| | | if (count < entry.getValue()) { |
| | | log.info("笼内格子剩余数量不足,结束本次进片"); |
| | | //todo:向plc发送报警 |
| | | return; |
| | | if (glassInfoList.get(0).getThickness() < slotMaxthickness) { |
| | | for (Map.Entry<Double, Long> entry : thickCountMap.entrySet()) { |
| | | int count = bigStorageCageService.count(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth) |
| | | .le(BigStorageCage::getMinThickness, entry.getKey()) |
| | | .ge(BigStorageCage::getMaxThickness, entry.getKey())); |
| | | if (count < entry.getValue()) { |
| | | log.info("笼内格子剩余数量不足,结束本次进片"); |
| | | //向plc发送报警:笼内格子剩余数量不足 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 16)); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | //todo:超大尺寸 |
| | | if (slotMaxHeight < Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) || glassInfoList.get(0).getThickness() > slotMaxthickness) { |
| | | //超大尺寸 |
| | | if (slotMaxHeight < Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) || glassInfoList.get(0).getThickness() >= slotMaxthickness) { |
| | | int count = bigStorageCageDetailsService.count(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getSlot, THROUGH_SLOT) |
| | | .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); |
| | | if (count > 0) { |
| | | log.info("直通片台存在玻璃,结束本次进片"); |
| | | //todo:向plc发送报警 |
| | | //向plc发送报警:直通片台存在玻璃,无法继续直通 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.alarmSignal", 64)); |
| | | return; |
| | | } |
| | | } |
| | |
| | | .set(EdgGlassTaskInfo::getState, Const.EDG_GLASS_SUCCESS).in(EdgGlassTaskInfo::getGlassId, glassIdList)); |
| | | //报工 |
| | | for (String glass : glassIdList) { |
| | | damageService.autoSubmitReport(glass, inTaskList.get(0).getStartSlot(), "磨边", "进大理片笼"); |
| | | damageService.autoSubmitReport(glass, inTaskList.get(0).getStartSlot(), "磨边", "进大理片笼", 1); |
| | | } |
| | | |
| | | Map<String, List<GlassInfo>> glassListMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getGlassId)); |
| | | //计算目标格子 |
| | | List<BigStorageCageHistoryTask> historyTasks = new ArrayList<>(); |
| | | //超大尺寸与正常尺寸玻璃计算方式不一样 |
| | | if (slotMaxHeight > Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight())) { |
| | | if (slotMaxHeight > Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) && glassInfoList.get(0).getThickness() < slotMaxthickness) { |
| | | for (BigStorageCageTask task : inTaskList) { |
| | | GlassInfo info = glassListMap.get(task.getGlassId()).get(0); |
| | | BigStorageDTO bigStorageDTO = bigStorageGlassInfoService.queryBigStorageTargetSlot(info.getEngineerId(), info.getTemperingLayoutId(), info.getTemperingFeedSequence()); |
| | |
| | | cageDetails.setState(Const.GLASS_STATE_NEW); |
| | | cageDetails.setDeviceId(bigStorageDTO.getDeviceId()); |
| | | cageDetails.setSequence(bigStorageDTO.getSlotSequence()); |
| | | cageDetails.setAngle((int) info.getAngle()); |
| | | cageDetails.setGap(glassGap); |
| | | cageDetails.setFilmsId(info.getFilmsid()); |
| | | cageDetails.setId(null); |
| | |
| | | cageDetails.setDeviceId(0); |
| | | cageDetails.setSequence(0); |
| | | cageDetails.setGap(glassGap); |
| | | cageDetails.setAngle((int) info.getAngle()); |
| | | cageDetails.setFilmsId(info.getFilmsid()); |
| | | cageDetails.setId(null); |
| | | bigStorageCageDetailsService.save(cageDetails); |
| | |
| | | miloService.writeToOpcWord(list); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | // @Scheduled(fixedDelay = 1000) |
| | | public void outBigStorageTask() throws Exception { |
| | | Date startDate = new Date(); |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | |
| | | //是否允许钢化 |
| | | //是否有正在钢化的玻璃:钢化小片表关联历史任务表,筛选未出笼的玻璃信息 |
| | | // 获取当前钢化任务未完成出片的玻璃信息 |
| | | |
| | | Integer temperingOutTargetPosition = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_TEMPERING_OUT_TARGET_POSITION); |
| | | List<TemperingGlassInfo> unFinishTemperingGlassInfoList = temperingGlassInfoService.list(new LambdaQueryWrapper<TemperingGlassInfo>() |
| | | .eq(TemperingGlassInfo::getState, Const.TEMPERING_NEW).orderByAsc(TemperingGlassInfo::getTemperingFeedSequence)); |
| | | .eq(TemperingGlassInfo::getState, Const.TEMPERING_NEW).orderByAsc(TemperingGlassInfo::getTemperingLayoutId).orderByAsc(TemperingGlassInfo::getTemperingFeedSequence)); |
| | | if (CollectionUtil.isNotEmpty(unFinishTemperingGlassInfoList)) { |
| | | log.info("有正在出片的钢化任务"); |
| | | computeOutGlassInfoByVirtualSlot(unFinishTemperingGlassInfoList, "big_storage_cage_out_one_task", temperingOutTargetPosition, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT); |
| | |
| | | for (TemperingLayoutDTO item : temperingLayoutDTOList) { |
| | | // if (item.getEngineerId().equals(redisUtil.getCacheObject("temperingengineerId"))) { |
| | | List<TemperingGlassInfo> temperingGlassInfos = glassInfoService.selectJoinList(TemperingGlassInfo.class, JoinWrappers.lambda(GlassInfo.class) |
| | | .selectAll(GlassInfo.class) |
| | | .select("-1 as state") |
| | | .selectAs(BigStorageCageDetails::getSlot, TemperingGlassInfo::getSlot) |
| | | .select("-1 as state,t.filmsid as films_id,t.glass_id,t.flow_card_id,t.glass_type,t.width,t.height" + |
| | | ",t.thickness,t.ishorizontal,t.tempering_layout_id,t.tempering_feed_sequence,t.x_coordinate,t.y_coordinate," + |
| | | "t.angle,t1.slot,t.engineer_id") |
| | | .innerJoin(BigStorageCageDetails.class, BigStorageCageDetails::getGlassId, GlassInfo::getGlassId) |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | .eq(GlassInfo::getTemperingLayoutId, item.getTemperingLayoutId()) |
| | |
| | | } |
| | | } |
| | | //是否有人工下片任务 有直接出 |
| | | Integer artificialOutTargetPosition = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_ARTIFICIAL_OUT_TARGET_POSITION); |
| | | Integer outCarMaxSize = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_OUT_CAR_SIZE); |
| | | List<BigStorageCageDetails> artificialList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_ARTIFICIAL) |
| | | .orderByAsc(BigStorageCageDetails::getSlot) |
| | |
| | | return; |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | // @Scheduled(fixedDelay = 1000) |
| | | public void finishInBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | |
| | | miloService.writeToOpcWord(list); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | // @Scheduled(fixedDelay = 1000) |
| | | public void finishOutBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | |
| | | bigStorageCageDetailsService.updateBySlot(storageCageDTOList, Const.GLASS_STATE_OUT); |
| | | } else { |
| | | bigStorageCageDetailsService.updateBySlot(storageCageDTOList, Const.GLASS_STATE_IN); |
| | | //todo:按照格子信息更新对应的设备id |
| | | //按照格子信息更新对应的设备id |
| | | List<Integer> slotList = storageCageDTOList.stream().map(UpdateBigStorageCageDTO::getTargetSlot).distinct().collect(Collectors.toList()); |
| | | bigStorageCageDetailsService.updateDeviceIdBySlot(slotList); |
| | | |
| | |
| | | */ |
| | | private <T extends BigStorageCageBaseInfo> Boolean computeOutGlassInfoByVirtualSlot(List<T> list, String tableName, int targetSlot, int state, int taskType) { |
| | | //任务数据:获取车子存放玻璃最大数量,玻璃间隔 |
| | | List<String> glassIdList = bigStorageGlassRelationInfoService.queryNeedOutGlassId( |
| | | list.get(0).getEngineerId(), list.get(0).getTemperingLayoutId(), list.get(0).getTemperingFeedSequence()); |
| | | List<T> outGlassList = list.stream().filter(e -> glassIdList.contains(e.getGlassId())).collect(Collectors.toList()); |
| | | List<T> outGlassList = list; |
| | | if (!THROUGH_SLOT.equals(list.get(0).getSlot())) { |
| | | //todo:临时解决方案:出片时考虑玻璃碰撞,改为一片一出 |
| | | // 界面关闭调度开关 !Const.BIG_STORAGE_BEFORE_DISPATCH.equals(taskType) |
| | | if (list.get(0).getThickness() >= 8) { |
| | | outGlassList = list.subList(0, 1); |
| | | } else { |
| | | List<String> glassIdList = bigStorageGlassRelationInfoService.queryNeedOutGlassId( |
| | | list.get(0).getEngineerId(), list.get(0).getTemperingLayoutId(), list.get(0).getTemperingFeedSequence()); |
| | | outGlassList = list.stream().filter(e -> glassIdList.contains(e.getGlassId())).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | Assert.isFalse(CollectionUtil.isEmpty(outGlassList), "未获取出片数据,结束出片任务"); |
| | | log.info("获取出片任务数据{}条,执行保存", outGlassList.size()); |
| | | List<BigStorageCageTask> bigStorageCageTaskList = outGlassList.stream() |
| | |
| | | //任务数据:获取车子存放玻璃最大数量,玻璃间隔 |
| | | List<BigStorageCageTask> bigStorageCageTaskList = new ArrayList<>(); |
| | | //打车剩余尺寸 |
| | | Integer remainWidth = carWidth; |
| | | Integer outCarMaxSize = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_OUT_CAR_SIZE); |
| | | Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_GLASS_GAP); |
| | | Integer remainWidth = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_CAR_WIDTH); |
| | | for (T e : list) { |
| | | if (bigStorageCageTaskList.size() >= outCarMaxSize || Math.max((int) e.getWidth(), (int) e.getHeight()) > remainWidth) { |
| | | break; |
| | |
| | | List<BigStorageCageDetails> inSlotGlassList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .in(BigStorageCageDetails::getSlot, slotList).in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); |
| | | Map<Integer, Double> slotRemainMap = new HashMap<>(); |
| | | Integer glassGap = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_GLASS_GAP); |
| | | Integer slotWidth = sysConfigService.queryConfigValue(ConstSysConfig.VERTICAL_SLOT_WIDTH); |
| | | //是否存在有格子非空的玻璃 |
| | | if (CollectionUtil.isNotEmpty(inSlotGlassList)) { |
| | | //存在 将格子内的玻璃分别进行更新 |