| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.github.yulichang.toolkit.JoinWrappers; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.base.entity.BigStorageCageBaseInfo; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.entity.BigStorageDTO; |
| | |
| | | import com.mes.bigstoragetask.entity.BigStorageCageOutTask; |
| | | import com.mes.bigstoragetask.service.BigStorageCageFeedTaskService; |
| | | import com.mes.bigstoragetask.service.BigStorageCageOutTaskService; |
| | | import com.mes.common.S7object; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.device.PlcParameterObject; |
| | | import com.mes.edgglasstask.entity.EdgGlassTaskInfo; |
| | | import com.mes.edgglasstask.service.EdgGlassTaskInfoService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Value("${mes.sequence.order}") |
| | | private boolean sequenceOrder; |
| | | |
| | | @Value("${mes.carWidth}") |
| | | private Integer carWidth; |
| | | |
| | | @Value("${mes.slotWidth}") |
| | | private Integer slotWidth; |
| | | |
| | | // @Scheduled(fixedDelay = 5000) |
| | | public void plcToHomeEdgScan(String d01Id) { |
| | | // PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | // String d01Request = plcParameterObject.getPlcParameter("D01Request").getValue(); |
| | | // String d01Id = plcParameterObject.getPlcParameter("D01ID1").getValue(); |
| | | // String d02SitState = plcParameterObject.getPlcParameter("D02SitState").getValue(); |
| | | // String d04Request = plcParameterObject.getPlcParameter("D04Request").getValue(); |
| | | // String d04Id = plcParameterObject.getPlcParameter("D04ID1").getValue(); |
| | | // String d05SitState = plcParameterObject.getPlcParameter("D05SitState").getValue(); |
| | | @Value("${mes.carMaxSize}") |
| | | private Integer carMaxSize; |
| | | |
| | | String d01Request = "1"; |
| | | String d02SitState = "0"; |
| | | // String d01Id = "P24060403|3|6"; |
| | | String d04Request = "0"; |
| | | String d05SitState = "0"; |
| | | // String d04Id = "P24060403|4|3"; |
| | | String d04Id = "P24060403|5|4"; |
| | | @Value("${mes.galssGap}") |
| | | private Integer galssGap; |
| | | |
| | | @Scheduled(fixedDelay = 5000) |
| | | public void plcToHomeEdgScan() { |
| | | PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | String d01Request = plcParameterObject.getPlcParameter("D01Request").getValue(); |
| | | String d01Id = plcParameterObject.getPlcParameter("D01ID1").getValue(); |
| | | String d02SitState = plcParameterObject.getPlcParameter("D02SitState").getValue(); |
| | | String d04Request = plcParameterObject.getPlcParameter("D04Request").getValue(); |
| | | String d04Id = plcParameterObject.getPlcParameter("D04ID1").getValue(); |
| | | String d05SitState = plcParameterObject.getPlcParameter("D05SitState").getValue(); |
| | | |
| | | log.info("1、获取到的请求字d01为:{},获取到的扫描ID为:{};获取到的请求字d04为:{},获取到的扫描ID为:{};", |
| | | d01Request, d01Id, d04Request, d04Id); |
| | | if (!REQUEST_WORD.equals(d01Request) && !REQUEST_WORD.equals(d04Request)) { |
| | |
| | | } |
| | | } |
| | | |
| | | // @Scheduled(fixedDelay = 5000) |
| | | @Scheduled(fixedDelay = 5000) |
| | | public void plcToHomeEdgFreeCarTask() { |
| | | // PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | // String e01Status = plcParameterObject.getPlcParameter("E01Status").getValue(); |
| | | String e01Status = "0"; |
| | | PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | String e01Status = plcParameterObject.getPlcParameter("E01Status").getValue(); |
| | | if (REQUEST_WORD.equals(e01Status)) { |
| | | log.info("进片大车非空闲"); |
| | | return; |
| | | } |
| | | // String d01Request = plcParameterObject.getPlcParameter("D01Request").getValue(); |
| | | // String d01Id = plcParameterObject.getPlcParameter("D01ID1").getValue(); |
| | | // String d04Request = plcParameterObject.getPlcParameter("D04Request").getValue(); |
| | | // String d04Id = plcParameterObject.getPlcParameter("D04ID1").getValue(); |
| | | String d01Request = ""; |
| | | String d01Id = ""; |
| | | String d04Request = "1"; |
| | | String d04Id = ""; |
| | | String d01Request = plcParameterObject.getPlcParameter("D01Request").getValue(); |
| | | String d01Id = plcParameterObject.getPlcParameter("D01ID1").getValue(); |
| | | String d04Request = plcParameterObject.getPlcParameter("D04Request").getValue(); |
| | | String d04Id = plcParameterObject.getPlcParameter("D04ID1").getValue(); |
| | | log.info("1、获取到的请求字d01为:{},获取到的扫描ID为:{};获取到的请求字d04为:{},获取到的扫描ID为:{};", |
| | | d01Request, d01Id, d04Request, d04Id); |
| | | //两条线都有进卧转立任务,直接结束 |
| | |
| | | computeTargetByLine(outLine); |
| | | } |
| | | |
| | | // @Scheduled(fixedDelay = 5000) |
| | | @Scheduled(fixedDelay = 5000) |
| | | public void plcToHomeEdgOutTask() { |
| | | //任务数据 获取车子存放玻璃最大数量 玻璃间隔 |
| | | List<BigStorageCageOutTask> bigStorageCageOutTaskList = new ArrayList<>(); |
| | | |
| | | List<BigStorageCageOutTask> outingList = bigStorageCageOutTaskService.list(new LambdaQueryWrapper<BigStorageCageOutTask>().eq(BigStorageCageOutTask::getTaskState, Const.BIG_STORAGE_OUT_NEW)); |
| | | Assert.isTrue(CollectionUtils.isEmpty(outingList), "有正在执行出片的任务,结束当前出片线程"); |
| | | |
| | | //是否有正在钢化的玻璃 |
| | | List<TemperingGlassInfo> temperingGlassInfoList = temperingGlassInfoService.list(new LambdaQueryWrapper<TemperingGlassInfo>() |
| | | List<TemperingGlassInfo> temperingGlassInfoList = temperingGlassInfoService.selectJoinList(TemperingGlassInfo.class, new MPJLambdaWrapper<TemperingGlassInfo>() |
| | | .selectAll(TemperingGlassInfo.class) |
| | | .leftJoin(BigStorageCageOutTask.class, BigStorageCageOutTask::getGlassId, TemperingGlassInfo::getGlassId) |
| | | .eq(TemperingGlassInfo::getState, Const.TEMPERING_NEW) |
| | | .isNull(BigStorageCageOutTask::getGlassId) |
| | | .orderBy(Boolean.TRUE, sequenceOrder, TemperingGlassInfo::getTemperingFeedSequence)); |
| | | if (CollectionUtils.isNotEmpty(temperingGlassInfoList)) { |
| | | log.info("有正在出片的钢化任务"); |
| | | //打车剩余尺寸 |
| | | Integer remainWidth = Const.BIG_STORAGE_WIDTH; |
| | | for (TemperingGlassInfo e : temperingGlassInfoList) { |
| | | if (bigStorageCageOutTaskList.size() > 5 || e.getWidth() > remainWidth) { |
| | | break; |
| | | } |
| | | remainWidth = remainWidth - e.getWidth().intValue() - Const.BIG_STORAGE_GAP; |
| | | bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getState(), Const.A09_OUT_TARGET_POSITION, |
| | | e.getWidth().intValue(), 0, 0, 1)); |
| | | } |
| | | bigStorageCageOutTaskService.saveBatch(bigStorageCageOutTaskList); |
| | | computeOutGlassInfo(temperingGlassInfoList); |
| | | return; |
| | | } |
| | | //是否有人工下片任务 有直接出 |
| | | List<BigStorageCageDetails> artificialList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_ARTIFICIAL).orderByDesc(BigStorageCageDetails::getWidth)); |
| | | if (CollectionUtils.isNotEmpty(artificialList)) { |
| | | Integer remainWidth = Const.BIG_STORAGE_WIDTH; |
| | | for (BigStorageCageDetails e : artificialList) { |
| | | if (remainWidth < e.getWidth().intValue()) { |
| | | break; |
| | | } |
| | | bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getSlot(), Const.A10_OUT_TARGET_POSITION, |
| | | e.getWidth().intValue(), 0, 0, 1)); |
| | | remainWidth = remainWidth - e.getWidth().intValue() - Const.BIG_STORAGE_GAP; |
| | | } |
| | | bigStorageCageOutTaskService.saveBatch(bigStorageCageOutTaskList); |
| | | computeOutGlassInfo(temperingGlassInfoList); |
| | | return; |
| | | } |
| | | //钢化优先:获取理片笼 玻璃小片 破损表 数量 判断笼内版图是否到齐 |
| | |
| | | //到齐,将玻璃小片数据存入钢化小片表,逻辑生成出片任务 结束 |
| | | List<TemperingGlassInfo> temperingGlassInfos = glassInfoService.selectJoinList(TemperingGlassInfo.class, JoinWrappers.lambda(GlassInfo.class) |
| | | .selectAll(GlassInfo.class) |
| | | .select("-1 as state") |
| | | .selectAs(BigStorageCageDetails::getSlot, TemperingGlassInfo::getSlot) |
| | | .innerJoin(BigStorageCageDetails.class, BigStorageCageDetails::getGlassId, GlassInfo::getGlassId) |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | .eq(GlassInfo::getTemperingLayoutId, temperingLayoutDTO.getTemperingLayoutId()) |
| | | .eq(GlassInfo::getEngineerId, temperingLayoutDTO.getEngineerId())); |
| | | temperingGlassInfoService.saveBatch(temperingGlassInfos); |
| | | |
| | | //大车剩余尺寸 |
| | | Integer remainWidth = Const.BIG_STORAGE_WIDTH; |
| | | for (TemperingGlassInfo e : temperingGlassInfos) { |
| | | if (bigStorageCageOutTaskList.size() > 5 || e.getWidth() > remainWidth) { |
| | | break; |
| | | } |
| | | remainWidth = remainWidth - e.getWidth().intValue() - Const.BIG_STORAGE_GAP; |
| | | bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getState(), Const.A09_OUT_TARGET_POSITION, |
| | | e.getWidth().intValue(), 0, 0, 1)); |
| | | } |
| | | bigStorageCageOutTaskService.saveBatch(bigStorageCageOutTaskList); |
| | | computeOutGlassInfo(temperingGlassInfoList); |
| | | return; |
| | | } |
| | | //未到齐 执行内部调度任务 |
| | |
| | | for (int i = 0; i < slotSequenceList.size() - 1; i++) { |
| | | SlotSequenceDTO first = slotSequenceList.get(i); |
| | | SlotSequenceDTO second = slotSequenceList.get(i + 1); |
| | | int slotWidth = Const.BIG_STORAGE_WIDTH - first.getRemainWidth() - Const.BIG_STORAGE_GAP; |
| | | int slotWidth = carWidth - first.getRemainWidth() - galssGap; |
| | | if (first.getMinSequence() == second.getMaxSequence() + 1 |
| | | && second.getRemainWidth() > slotWidth) { |
| | | List<BigStorageCageDetails> list = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | |
| | | Integer remainWidth; |
| | | Integer glassCount; |
| | | if (0 == sitToUpRemainWidth.getGlassCount()) { |
| | | remainWidth = Const.BIG_STORAGE_WIDTH; |
| | | remainWidth = carWidth; |
| | | glassCount = 0; |
| | | } else { |
| | | remainWidth = sitToUpRemainWidth.getWidth(); |
| | |
| | | } else { |
| | | Integer widthSecond = edgGlassTaskInfoList.get(1).getWidth(); |
| | | if (remainWidth >= widthFirst) { |
| | | if (remainWidth - widthFirst - Const.BIG_STORAGE_GAP >= widthSecond) { |
| | | if (glassCount <= 5) { |
| | | if (remainWidth - widthFirst - galssGap >= widthSecond) { |
| | | if (glassCount <= carMaxSize - 1) { |
| | | addFeedTask(glassId, line, Const.BIG_STORAGE_IN_WAIT, widthFirst); |
| | | return Boolean.FALSE; |
| | | } else { |
| | |
| | | } |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | private <T extends BigStorageCageBaseInfo> Boolean computeOutGlassInfo(List<T> list) { |
| | | //任务数据 获取车子存放玻璃最大数量 玻璃间隔 |
| | | List<BigStorageCageOutTask> bigStorageCageOutTaskList = new ArrayList<>(); |
| | | //打车剩余尺寸 |
| | | Integer remainWidth = carWidth; |
| | | for (T e : list) { |
| | | if (bigStorageCageOutTaskList.size() > carMaxSize || e.getWidth() > remainWidth) { |
| | | break; |
| | | } |
| | | remainWidth = remainWidth - e.getWidth().intValue() - galssGap; |
| | | bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getSlot(), Const.A09_OUT_TARGET_POSITION, |
| | | e.getWidth().intValue(), 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) |
| | | .in(BigStorageCageDetails::getGlassId, glassIds)); |
| | | //更新笼子内格子的剩余尺寸 |
| | | updateSlotRemain(list, glassIds); |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | /** |
| | | * 更新笼子内格子的剩余尺寸 |
| | | * |
| | | * @param list |
| | | * @param taskGlassIds |
| | | * @param <T> |
| | | */ |
| | | public <T extends BigStorageCageBaseInfo> void updateSlotRemain(List<T> list, List<String> taskGlassIds) { |
| | | //获取需要出去(包括待出去的)的所有玻璃格子号 |
| | | List<Integer> slotList = list.stream().map(T::getSlot).distinct().collect(Collectors.toList()); |
| | | //获取待出去的玻璃信息(等下车出去的玻璃) |
| | | Map<Integer, Double> slotRemainMap = list.stream().filter(e -> !taskGlassIds.contains(e.getGlassId())) |
| | | .collect(Collectors.groupingBy(T::getSlot, Collectors.summingDouble(item -> item.getWidth() + galssGap))); |
| | | if (CollectionUtils.isNotEmpty(slotRemainMap)) { |
| | | //按照格子号更新剩余尺寸 |
| | | slotRemainMap.forEach((e, v) -> { |
| | | bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>().set(BigStorageCage::getRemainWidth, slotWidth - v) |
| | | .eq(BigStorageCage::getSlot, e)); |
| | | }); |
| | | } |
| | | Set<Integer> remainSlotList = slotRemainMap.keySet(); |
| | | slotList.removeAll(remainSlotList); |
| | | if (CollectionUtils.isNotEmpty(slotList)) { |
| | | bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>().set(BigStorageCage::getRemainWidth, slotWidth) |
| | | .in(BigStorageCage::getSlot, slotList)); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |