From 0477b72d30cfe7d412edeb237aa587b1c5242207 Mon Sep 17 00:00:00 2001 From: zhoushihao <zsh19950802@163.com> Date: 星期二, 09 七月 2024 08:34:31 +0800 Subject: [PATCH] 1、任务新增计时功能,日志打印每次任务执行的周期 2、卧式理片笼更新出片规则:都为禁用(2),笼子不出玻璃;存在一个禁用,07片台可以存玻璃;都非禁用:两片台有玻璃笼子不出片 --- hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java | 274 ++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 190 insertions(+), 84 deletions(-) diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java index aebf46d..6d5c999 100644 --- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java +++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java @@ -27,6 +27,7 @@ import com.mes.glassinfo.service.GlassInfoService; import com.mes.temperingglass.entity.TemperingGlassInfo; import com.mes.temperingglass.service.TemperingGlassInfoService; +import com.mes.tools.S7control; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.beans.BeanUtils; @@ -71,105 +72,163 @@ @Value("${mes.slotWidth}") private Integer slotWidth; - @Value("${mes.carMaxSize}") - private Integer carMaxSize; + @Value("${mes.inCarMaxSize}") + private Integer inCarMaxSize; - @Value("${mes.galssGap}") - private Integer galssGap; + @Value("${mes.outCarMaxSize}") + private Integer outCarMaxSize; - @Scheduled(fixedDelay = 5000) + @Value("${mes.glassGap}") + private Integer glassGap; + + @Scheduled(fixedDelay = 300) public void plcToHomeEdgScan() { + Date startDate = new Date(); + log.info("澶х悊鐗囩鎵爜浠诲姟寮�濮嬫墽琛屾椂闂达細{}", startDate); 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(); + String d01Id = plcParameterObject.getPlcParameter("D01ID").getValue(); + String d04Id = plcParameterObject.getPlcParameter("D04ID").getValue(); + //D02id鍒ゆ柇鏄惁涓虹┖ 纭鏄惁绌洪棽 鍏佽杩涚墖 + String d02State = plcParameterObject.getPlcParameter("D02ID").getValue(); + String d03State = plcParameterObject.getPlcParameter("D03State").getValue(); + String d05State = plcParameterObject.getPlcParameter("D05State").getValue(); + String mesD01Address = plcParameterObject.getPlcParameter("MESToD01").getAddress(); + String mesD04Address = plcParameterObject.getPlcParameter("MESToD04").getAddress(); + String d01ToMES = plcParameterObject.getPlcParameter("D01ToMES").getValue(); + String d04ToMES = plcParameterObject.getPlcParameter("D04ToMES").getValue(); - log.info("1銆佽幏鍙栧埌鐨勮姹傚瓧d01涓猴細{}锛岃幏鍙栧埌鐨勬壂鎻廔D涓猴細{};鑾峰彇鍒扮殑璇锋眰瀛梔04涓猴細{}锛岃幏鍙栧埌鐨勬壂鎻廔D涓猴細{};", - d01Request, d01Id, d04Request, d04Id); - if (!REQUEST_WORD.equals(d01Request) && !REQUEST_WORD.equals(d04Request)) { + log.info("1銆佽幏鍙杁01Id鎵弿ID涓猴細{}锛岃姹傚瓧涓簕};鑾峰彇d04Id鎵弿ID涓猴細{}锛岃姹傚瓧涓簕};", d01Id, d01ToMES, d04Id, d04ToMES); + if (StringUtils.isBlank(d01ToMES) && StringUtils.isBlank(d04ToMES)) { log.info("涓ゆ潯绾挎湭鏀跺埌杩涚墖浠诲姟锛岀粨鏉熸湰娆℃壂鎻忚繘鍗ц浆绔嬩换鍔�"); return; } - if (REQUEST_WORD.equals(d02SitState) && REQUEST_WORD.equals(d05SitState)) { + if (REQUEST_WORD.equals(d03State) && REQUEST_WORD.equals(d05State)) { log.info("涓ゆ潯绾垮崸杞珛鍧囧湪鎵ц浠诲姟锛岀粨鏉熸湰娆℃壂鎻忚繘鍗ц浆绔嬩换鍔�"); return; } - Boolean flag01 = Boolean.FALSE; - Boolean flag04 = Boolean.FALSE; //鎸夌収绾胯矾鍙婄幓鐠僫d鑾峰彇鐩搁偦涓ゅ潡鐜荤拑 鍗ц浆绔嬩笂鐨勭幓鐠� - if (REQUEST_WORD.equals(d01Request) && !REQUEST_WORD.equals(d02SitState)) { - flag01 = judgeGlassTypeStatus(d01Id, Const.A09_OUT_TARGET_POSITION); + if (REQUEST_WORD.equals(d01ToMES) && (StringUtils.isBlank(d02State) || !REQUEST_WORD.equals(d03State))) { + judgeGlassTypeStatus(d01Id, Const.A09_OUT_TARGET_POSITION, mesD01Address); } - if (REQUEST_WORD.equals(d04Request) && !REQUEST_WORD.equals(d05SitState)) { - flag04 = judgeGlassTypeStatus(d04Id, Const.A10_OUT_TARGET_POSITION); + if (REQUEST_WORD.equals(d04ToMES) && !REQUEST_WORD.equals(d05State)) { + judgeGlassTypeStatus(d04Id, Const.A10_OUT_TARGET_POSITION, mesD04Address); } - if (flag01 && flag04) { - //姣旇緝鏈�鏃╀竴鐗囦换鍔$殑鐗堝浘id鍙婄増搴� 姹傚嚭鍗ц浆绔嬬殑绾胯矾 - Integer startLine = getStartLine(); - //璁$畻鐩爣鏍煎瓙锛屽彂閫佸惎鍔ㄤ换鍔� - computeTargetByLine(startLine); - } else if (flag01 || flag04) { - Integer startLine = flag01.equals(Boolean.TRUE) ? Const.A09_OUT_TARGET_POSITION : Const.A10_OUT_TARGET_POSITION; - //璁$畻鐩爣鏍煎瓙锛屽彂閫佸惎鍔ㄤ换鍔� - computeTargetByLine(startLine); - } else { - log.info("涓ゆ潯绾挎湭鏀跺埌杩涚墖浠诲姟锛岀粨鏉熸湰娆℃壂鎻忚繘鍗ц浆绔嬩换鍔�"); - } + Date endDate = new Date(); + log.info("澶х悊鐗囩鎵爜浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime()); } - @Scheduled(fixedDelay = 5000) + @Scheduled(fixedDelay = 300) public void plcToHomeEdgFreeCarTask() { + Date startDate = new Date(); + log.info("澶х悊鐗囩绌鸿溅杩涚墖浠诲姟寮�濮嬫墽琛屾椂闂达細{}", startDate); PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; - String e01Status = plcParameterObject.getPlcParameter("E01Status").getValue(); + String e01Status = plcParameterObject.getPlcParameter("E01State").getValue(); + String d03ToMES = plcParameterObject.getPlcParameter("D03ToMES").getValue(); + String d05ToMES = plcParameterObject.getPlcParameter("D05ToMES").getValue(); + log.info("鎵ц绌鸿溅閫佺墖浠诲姟锛岃幏鍙栧埌鐨勫ぇ杞︾姸鎬佷负{}锛屽崸杞珛鐘舵�佸垎鍒负d03:{}锛宒05:{}", e01Status, d03ToMES, d05ToMES); if (REQUEST_WORD.equals(e01Status)) { - log.info("杩涚墖澶ц溅闈炵┖闂�"); + Date endDate = new Date(); + log.info("杩涚墖澶ц溅闈炵┖闂诧紝缁撴潫閫佺墖浠诲姟锛屼换鍔$粨鏉熸椂闂达細{}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime()); 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(); - log.info("1銆佽幏鍙栧埌鐨勮姹傚瓧d01涓猴細{}锛岃幏鍙栧埌鐨勬壂鎻廔D涓猴細{};鑾峰彇鍒扮殑璇锋眰瀛梔04涓猴細{}锛岃幏鍙栧埌鐨勬壂鎻廔D涓猴細{};", - d01Request, d01Id, d04Request, d04Id); + if (!REQUEST_WORD.equals(d03ToMES) && !REQUEST_WORD.equals(d05ToMES)) { + Date endDate = new Date(); + log.info("鍗ц浆绔嬫病鏈夐�佺墖璇锋眰锛岀粨鏉熼�佺墖浠诲姟锛屼换鍔$粨鏉熸椂闂达細{}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime()); + return; + } + LambdaQueryWrapper<BigStorageCageFeedTask> wrapper = new LambdaQueryWrapper<BigStorageCageFeedTask>() + .eq(BigStorageCageFeedTask::getTaskType, Const.BIG_STORAGE_IN_RUN) + .eq(BigStorageCageFeedTask::getTaskState, Const.BIG_STORAGE_IN_UP); + //鑾峰彇鍙互鍚姩鍗ц浆绔嬬殑浠诲姟绾胯矾 + List<BigStorageCageFeedTask> feedTaskList = bigStorageCageFeedTaskService.list(wrapper); + if (CollectionUtils.isNotEmpty(feedTaskList)) { + if (feedTaskList.size() == 1) { + computeTargetByLine(feedTaskList.get(0).getLine()); + } else { + //姣旇緝鏈�鏃╀竴鐗囦换鍔$殑鐗堝浘id鍙婄増搴� 姹傚嚭鍗ц浆绔嬬殑绾胯矾 + Integer startLine = getStartLine(); +// //璁$畻鐩爣鏍煎瓙锛屽彂閫佸惎鍔ㄤ换鍔� + computeTargetByLine(startLine); + } + Date endDate = new Date(); + log.info("澶х悊鐗囩绌鸿溅杩涚墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime()); + return; + } + String d01Id = plcParameterObject.getPlcParameter("D01ID").getValue(); + String d04Id = plcParameterObject.getPlcParameter("D04ID").getValue(); + log.info("1銆佽幏鍙杁01Id鎵弿ID涓猴細{};鑾峰彇d04Id鎵弿ID涓猴細{};", d01Id, d04Id); //涓ゆ潯绾块兘鏈夎繘鍗ц浆绔嬩换鍔★紝鐩存帴缁撴潫 - if (Const.BIG_STORAGE_REQUEST_IN.equals(d01Request) - && Const.BIG_STORAGE_REQUEST_IN.equals(d04Request)) { - log.info("涓ゆ潯绾块兘瀛樺湪杩涚墖浠诲姟锛岀粨鏉熶换鍔�"); - return; - } +// if (StringUtils.isNotBlank(d01Id) && StringUtils.isNotBlank(d04Id)) { +// log.info("涓ゆ潯绾块兘瀛樺湪杩涚墖浠诲姟锛岀粨鏉熶换鍔�"); +// return; +// } //鑾峰彇涓ゆ潯绾垮崸杞珛鏄惁鏈夌幓鐠冿紝涓斾换鍔$姸鎬侀兘涓�2 List<Integer> lineList = bigStorageCageFeedTaskService.querySitToUpGlass(); if (CollectionUtils.isEmpty(lineList)) { - log.info("涓ゆ潯绾垮崸杞珛涓虹┖鎴栬�呮湁杩涚墖浠诲姟鏈畬鎴愶紝缁撴潫浠诲姟"); + Date endDate = new Date(); + log.info("涓ゆ潯绾垮崸杞珛涓虹┖鎴栬�呮湁杩涚墖浠诲姟鏈畬鎴愶紝缁撴潫浠诲姟锛屽ぇ鐞嗙墖绗肩┖杞﹁繘鐗囦换鍔$粨鏉熸椂闂达細{}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime()); return; } Integer lineFirst = lineList.get(0); String lineGlassId = lineFirst.equals(Const.A09_OUT_TARGET_POSITION) ? d01Id : d04Id; + //浠呮湁涓�鏉″厛绗﹀悎鍚姩鍚姩鏉′欢 if (lineList.size() == 1) { - //璁$畻浠诲姟琛ㄨ繘鐗囨牸瀛� 鍙戦�佽繘鐗囦换鍔� + //濡傛灉杩涚墖璇锋眰浣嗙幓鐠冧负绌猴紝璁$畻浠诲姟琛ㄨ繘鐗囨牸瀛� 鍙戦�佽繘鐗囦换鍔� if (StringUtils.isEmpty(lineGlassId)) { computeTargetByLine(lineFirst); + } else { + //todo:璁$畻鎵弿鍒扮殑鐜荤拑鏄惁鍙互瀛樿繘鍗ц浆绔� + //鑾峰彇鍗ц浆绔嬪墿浣欏搴� + if (computeIsRun(lineFirst, lineGlassId)) { + computeTargetByLine(lineFirst); + } } + Date endDate = new Date(); + log.info("澶х悊鐗囩绌鸿溅杩涚墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime()); return; } + //涓ゆ潯鍏堝潎鍙墽琛岃繘鐗囦换鍔★紝鍒ゆ柇涓ゆ潯绾挎槸鍚﹁繘鐗囪姹傛槸鍚﹂兘涓虹┖ if (StringUtils.isBlank(d01Id) && StringUtils.isBlank(d04Id)) { //姣旇緝鏈�鏃╀竴鐗囦换鍔$殑鐗堝浘id鍙婄増搴� 姹傚嚭鍗ц浆绔嬬殑绾胯矾 Integer line = getStartLine(); //璁$畻浠诲姟琛ㄨ繘鐗囨牸瀛� 鍙戦�佽繘鐗囦换鍔� computeTargetByLine(line); + Date endDate = new Date(); + log.info("澶х悊鐗囩绌鸿溅杩涚墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime()); return; + } else if (StringUtils.isNotBlank(d01Id) && StringUtils.isNotBlank(d04Id)) { +// todo:涓や釜閮芥湁杩涚墖鐜荤拑 + if (computeIsRun(Const.A09_OUT_TARGET_POSITION, d01Id) && computeIsRun(Const.A10_OUT_TARGET_POSITION, d04Id)) { + //姣旇緝鏈�鏃╀竴鐗囦换鍔$殑鐗堝浘id鍙婄増搴� 姹傚嚭鍗ц浆绔嬬殑绾胯矾 + Integer line = getStartLine(); + //璁$畻浠诲姟琛ㄨ繘鐗囨牸瀛� 鍙戦�佽繘鐗囦换鍔� + computeTargetByLine(line); + } else if (computeIsRun(Const.A09_OUT_TARGET_POSITION, d01Id)) { + computeTargetByLine(Const.A09_OUT_TARGET_POSITION); + } else if (computeIsRun(Const.A10_OUT_TARGET_POSITION, d04Id)) { + computeTargetByLine(Const.A10_OUT_TARGET_POSITION); + } else { + Date endDate = new Date(); + log.info("澶х悊鐗囩绌鸿溅杩涚墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime()); + return; + } + } else { + //锛屾垨鑰呬粎鏈変竴鏉℃湁鐜荤拑 + //涓�鏉$嚎涓虹┖锛屼竴鏉$嚎鏈夎繘鐗囪姹傛湁鐜荤拑 + int outLine = StringUtils.isBlank(d01Id) ? Const.A09_OUT_TARGET_POSITION : Const.A10_OUT_TARGET_POSITION; + //鑾峰彇杩涚墖璇锋眰鐜荤拑涓虹┖鐨勶紝璁$畻浠诲姟琛ㄨ繘鐗囨牸瀛� 鍙戦�佽繘鐗囦换鍔� + computeTargetByLine(outLine); } - int outLine = StringUtils.isBlank(d01Id) ? Const.A09_OUT_TARGET_POSITION : Const.A10_OUT_TARGET_POSITION; - //璁$畻浠诲姟琛ㄨ繘鐗囨牸瀛� 鍙戦�佽繘鐗囦换鍔� - computeTargetByLine(outLine); + Date endDate = new Date(); + log.info("澶х悊鐗囩绌鸿溅杩涚墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime()); } - @Scheduled(fixedDelay = 5000) + @Scheduled(fixedDelay = 300) public void plcToHomeEdgOutTask() { - + Date startDate = new Date(); + log.info("澶х悊鐗囩绌鸿溅杩涚墖浠诲姟寮�濮嬫墽琛屾椂闂达細{}", startDate); + PlcParameterObject plcMesObject = S7object.getinstance().PlcMesObject; + String mesToPLCAddress = plcMesObject.getPlcParameter("MESToPLC").getAddress(); List<BigStorageCageOutTask> outingList = bigStorageCageOutTaskService.list(new LambdaQueryWrapper<BigStorageCageOutTask>().eq(BigStorageCageOutTask::getTaskState, Const.BIG_STORAGE_OUT_NEW)); Assert.isTrue(CollectionUtils.isEmpty(outingList), "鏈夋鍦ㄦ墽琛屽嚭鐗囩殑浠诲姟锛岀粨鏉熷綋鍓嶅嚭鐗囩嚎绋�"); @@ -182,14 +241,18 @@ .orderBy(Boolean.TRUE, sequenceOrder, TemperingGlassInfo::getTemperingFeedSequence)); if (CollectionUtils.isNotEmpty(temperingGlassInfoList)) { log.info("鏈夋鍦ㄥ嚭鐗囩殑閽㈠寲浠诲姟"); - computeOutGlassInfo(temperingGlassInfoList); + computeOutGlassInfo(temperingGlassInfoList, Boolean.TRUE, mesToPLCAddress); + Date endDate = new Date(); + log.info("澶х悊鐗囩鍑虹墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime()); return; } //鏄惁鏈変汉宸ヤ笅鐗囦换鍔� 鏈夌洿鎺ュ嚭 List<BigStorageCageDetails> artificialList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_ARTIFICIAL).orderByDesc(BigStorageCageDetails::getWidth)); if (CollectionUtils.isNotEmpty(artificialList)) { - computeOutGlassInfo(temperingGlassInfoList); + computeOutGlassInfo(artificialList, Boolean.FALSE, mesToPLCAddress); + Date endDate = new Date(); + log.info("澶х悊鐗囩鍑虹墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime()); return; } //閽㈠寲浼樺厛锛氳幏鍙栫悊鐗囩 鐜荤拑灏忕墖 鐮存崯琛� 鏁伴噺 鍒ゆ柇绗煎唴鐗堝浘鏄惁鍒伴綈 @@ -206,7 +269,9 @@ .eq(GlassInfo::getTemperingLayoutId, temperingLayoutDTO.getTemperingLayoutId()) .eq(GlassInfo::getEngineerId, temperingLayoutDTO.getEngineerId())); temperingGlassInfoService.saveBatch(temperingGlassInfos); - computeOutGlassInfo(temperingGlassInfoList); + computeOutGlassInfo(temperingGlassInfoList, Boolean.TRUE, mesToPLCAddress); + Date endDate = new Date(); + log.info("澶х悊鐗囩鍑虹墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime()); return; } //鏈埌榻� 鎵ц鍐呴儴璋冨害浠诲姟 @@ -216,7 +281,7 @@ for (int i = 0; i < slotSequenceList.size() - 1; i++) { SlotSequenceDTO first = slotSequenceList.get(i); SlotSequenceDTO second = slotSequenceList.get(i + 1); - int slotWidth = carWidth - first.getRemainWidth() - galssGap; + int slotWidth = carWidth - first.getRemainWidth() - glassGap; if (first.getMinSequence() == second.getMaxSequence() + 1 && second.getRemainWidth() > slotWidth) { List<BigStorageCageDetails> list = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() @@ -224,6 +289,10 @@ List<BigStorageCageOutTask> outTasks = list.stream().map(e -> new BigStorageCageOutTask(e.getGlassId(), first.getSlot(), second.getSlot(), slotWidth, 0, 0, 1)).collect(Collectors.toList()); bigStorageCageOutTaskService.saveBatch(outTasks); + S7object.getinstance().plccontrol.writeWord(mesToPLCAddress, 1); + log.info("宸插悜plc鍙戦�佸嚭鐗囦换鍔$‘璁わ紝鍦板潃涓猴細{}", mesToPLCAddress); + Date endDate = new Date(); + log.info("澶х悊鐗囩鍑虹墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime()); return; } } @@ -234,7 +303,7 @@ /** * 鎸夌収鐜荤拑id鍒ゆ柇鐜荤拑鐘舵�佸強鍗ц浆绔嬫槸鍚﹀彲鐩存帴鍚姩 */ - public Boolean judgeGlassTypeStatus(String glassId, Integer line) { + public Boolean judgeGlassTypeStatus(String glassId, Integer line, String mesAddress) { //1銆佽幏鍙栦换鍔¤〃涓浉閭荤幓鐠� List<EdgGlassTaskInfo> edgGlassTaskInfoList = edgGlassTaskInfoService.list(new LambdaQueryWrapper<EdgGlassTaskInfo>() .eq(EdgGlassTaskInfo::getLine, line) @@ -252,36 +321,42 @@ remainWidth = sitToUpRemainWidth.getWidth(); glassCount = sitToUpRemainWidth.getGlassCount(); } + + Boolean flag = Boolean.TRUE; //2銆佽幏鍙栧崸杞珛 - Integer widthFirst = edgGlassTaskInfoList.get(0).getWidth(); + Integer widthFirst = Math.max(edgGlassTaskInfoList.get(0).getWidth() / 10, edgGlassTaskInfoList.get(0).getHeight() / 10); if (edgGlassTaskInfoList.size() == 1) { if (remainWidth >= widthFirst) { - if (glassCount <= 5) { + if (glassCount < inCarMaxSize) { addFeedTask(glassId, line, Const.BIG_STORAGE_IN_WAIT, widthFirst); - return Boolean.FALSE; } else { addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst); - return Boolean.TRUE; } + } else { + flag = Boolean.FALSE; } } else { - Integer widthSecond = edgGlassTaskInfoList.get(1).getWidth(); + Integer widthSecond = Math.max(edgGlassTaskInfoList.get(1).getWidth() / 10, edgGlassTaskInfoList.get(1).getHeight() / 10); if (remainWidth >= widthFirst) { - if (remainWidth - widthFirst - galssGap >= widthSecond) { - if (glassCount <= carMaxSize - 1) { + if (remainWidth - widthFirst - glassGap >= widthSecond) { + if (glassCount < inCarMaxSize) { addFeedTask(glassId, line, Const.BIG_STORAGE_IN_WAIT, widthFirst); - return Boolean.FALSE; } else { addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst); - return Boolean.TRUE; } } else { addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst); } + } else { + flag = Boolean.FALSE; } } + //鍚憄lc鍙戦�佽繘鐗囩‘璁� + if (flag) { + S7object.getinstance().plccontrol.writeWord(mesAddress, 1); + } //璁板綍鏃犳硶鏀句笅鐜荤拑锛屽悗缁垽鏂惎鍔� - return Boolean.TRUE; + return flag; } /** @@ -329,17 +404,17 @@ //2銆佸幓绗煎瓙鍐呮煡鎵炬槸鍚﹀彲浠ョ户缁瓨鏀剧殑绗煎瓙 List<String> glassIds = taskList.stream().map(BigStorageCageFeedTask::getGlassId).collect(Collectors.toList()); List<GlassInfo> glassInfos = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().in(GlassInfo::getGlassId, glassIds)); - return computeIsTemperingTargetByLine(glassInfos, taskList, Boolean.TRUE) && computeIsTemperingTargetByLine(glassInfos, taskList, Boolean.FALSE); + return computeIsTemperingTargetByLine(glassInfos, taskList, line); } /** * 鏄惁閽㈠寲鐜荤拑杩涚鐩爣浣嶇疆 * - * @param glassInfos 褰撴潯绾垮崸杞珛鎵�鏈夌幓鐠� - * @param taskList 褰撴潯绾垮崸杞珛鎵�鏈変换鍔� - * @param isTempering true 閽㈠寲 false 涓嶉挗鍖� + * @param glassInfos 褰撴潯绾垮崸杞珛鎵�鏈夌幓鐠� + * @param taskList 褰撴潯绾垮崸杞珛鎵�鏈変换鍔� + * @param line 浠诲姟鏄摢鏉$嚎 */ - private boolean computeIsTemperingTargetByLine(List<GlassInfo> glassInfos, List<BigStorageCageFeedTask> taskList, Boolean isTempering) { + private boolean computeIsTemperingTargetByLine(List<GlassInfo> glassInfos, List<BigStorageCageFeedTask> taskList, Integer line) { //1銆佸皢鐜荤拑淇℃伅闆嗗悎杞负glassid涓簁ey鐨刴ap Map<String, GlassInfo> glassInfoMap = glassInfos.stream() .collect(Collectors.toMap(GlassInfo::getGlassId, p -> p)); @@ -353,11 +428,11 @@ //2銆佽幏鍙栫洰鏍囨牸瀛愪俊鎭� BigStorageDTO bigStorageDTO = bigStorageCageDetailsService.queryTargetSlotByTempering(info); //3銆佹洿鏂板ぇ鐞嗙墖绗艰〃鍓╀綑瀹藉害 - bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>().set(BigStorageCage::getRemainWidth, bigStorageDTO.getWidth()) + bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>().set(BigStorageCage::getRemainWidth, bigStorageDTO.getWidth() - info.getWidth()) .eq(BigStorageCage::getSlot, bigStorageDTO.getSlot())); //4銆佹洿鏂拌繘鐗囦换鍔¤〃锛岀洰鏍囨牸瀛愬強鐘舵�侊紙鐘舵�佹敼涓�2 鐢垫皵鎵埌鑷澶勭悊锛� 閬囧埌闂锛氭棤娉曟壒閲忔洿鏂帮紝鎵归噺鏇存柊鏃犳硶璧版寚瀹氫粠搴� e.setTargetSlot(bigStorageDTO.getSlot()); - e.setTaskType(Const.BIG_STORAGE_IN_RUN); +// e.setTaskType(Const.BIG_STORAGE_IN_RUN); bigStorageCageFeedTaskService.updateById(e); //5銆佸皢杩涚墖淇℃伅瀛樺叆澶х悊鐗囩璇︽儏琛� @@ -365,21 +440,43 @@ cageDetails.setState(Const.GLASS_STATE_IN); bigStorageCageDetailsService.save(cageDetails); } + sendTaskListToPLC(taskList, line); return Boolean.TRUE; } - private <T extends BigStorageCageBaseInfo> Boolean computeOutGlassInfo(List<T> list) { + private void sendTaskListToPLC(List<BigStorageCageFeedTask> taskList, Integer line) { + log.info("閫佺墖浠诲姟鍙戦�佽繘鐗囩幓鐠冧俊鎭�"); + S7control s7control = S7object.getinstance().plccontrol; + PlcParameterObject plcMesObject = S7object.getinstance().PlcMesObject; + String mesD03Address = plcMesObject.getPlcParameter("MESToD03").getAddress(); + String mesD05Address = plcMesObject.getPlcParameter("MESToD05").getAddress(); + String outLine = line.equals(Const.A09_OUT_TARGET_POSITION) ? mesD03Address : mesD05Address; + for (int i = 1; i <= taskList.size(); i++) { + s7control.writeWord(plcMesObject.getPlcParameter("StartAddToImport" + i).getAddress(), taskList.get(i - 1).getLine()); + s7control.writeWord(plcMesObject.getPlcParameter("TargetAddToImport" + i).getAddress(), taskList.get(i - 1).getTargetSlot()); + } + s7control.writeWord(outLine, 2); + log.info("閫佺墖浠诲姟宸插彂閫佸畬鎴愶紝浠诲姟绾胯矾涓猴細{}锛屽惎鍔ㄥ湴鍧�涓簕},纭瀛椾负{}", line, outLine, 2); + } + + private <T extends BigStorageCageBaseInfo> Boolean computeOutGlassInfo(List<T> list, Boolean isTempering, String mesToPLCAddress) { //浠诲姟鏁版嵁 鑾峰彇杞﹀瓙瀛樻斁鐜荤拑鏈�澶ф暟閲� 鐜荤拑闂撮殧 List<BigStorageCageOutTask> bigStorageCageOutTaskList = new ArrayList<>(); //鎵撹溅鍓╀綑灏哄 Integer remainWidth = carWidth; for (T e : list) { - if (bigStorageCageOutTaskList.size() > carMaxSize || e.getWidth() > remainWidth) { + if (bigStorageCageOutTaskList.size() > outCarMaxSize || 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)); + remainWidth = remainWidth - (int) e.getWidth() - glassGap; + if (isTempering) { + bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getSlot(), Const.TEMPERING_OUT_TARGET_POSITION, + (int) e.getWidth() * 10, 0, 0, 1)); + } else { + bigStorageCageOutTaskList.add(new BigStorageCageOutTask(e.getGlassId(), e.getSlot(), Const.ARTIFICIAL_OUT_TARGET_POSITION, + (int) e.getWidth() * 10, 0, 0, 1)); + } + } Assert.isFalse(CollectionUtils.isEmpty(bigStorageCageOutTaskList), "鏈幏鍙栧嚭鐗囨暟鎹紝缁撴潫鍑虹墖浠诲姟"); log.info("鑾峰彇鍑虹墖浠诲姟鏁版嵁{}鏉★紝鎵ц淇濆瓨", bigStorageCageOutTaskList.size()); @@ -391,6 +488,8 @@ .in(BigStorageCageDetails::getGlassId, glassIds)); //鏇存柊绗煎瓙鍐呮牸瀛愮殑鍓╀綑灏哄 updateSlotRemain(list, glassIds); + S7object.getinstance().plccontrol.writeWord(mesToPLCAddress, 1); + log.info("宸插悜plc鍙戦�佸嚭鐗囦换鍔$‘璁わ紝鍦板潃涓猴細{}", mesToPLCAddress); return Boolean.TRUE; } @@ -406,7 +505,7 @@ 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))); + .collect(Collectors.groupingBy(T::getSlot, Collectors.summingDouble(item -> item.getWidth() + glassGap))); if (CollectionUtils.isNotEmpty(slotRemainMap)) { //鎸夌収鏍煎瓙鍙锋洿鏂板墿浣欏昂瀵� slotRemainMap.forEach((e, v) -> { @@ -420,7 +519,14 @@ bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>().set(BigStorageCage::getRemainWidth, slotWidth) .in(BigStorageCage::getSlot, slotList)); } - - } + + public Boolean computeIsRun(int line, String glassId) { + //鑾峰彇鍗ц浆绔嬪墿浣欏搴� + BigStorageDTO sitToUpRemainWidth = bigStorageCageFeedTaskService.querySitToUpRemainWidth(line); + //鑾峰彇鐜荤拑淇℃伅 + GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId)); + return sitToUpRemainWidth.getWidth() < glassInfo.getWidth(); + } + } \ No newline at end of file -- Gitblit v1.8.0