hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/edgglasstask/entity/EdgGlassTaskInfo.java
@@ -4,6 +4,7 @@ import lombok.EqualsAndHashCode; import java.io.Serializable; import java.util.Date; /** * <p> @@ -31,7 +32,8 @@ private Integer status; private Integer line; private Date time; } hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java
@@ -66,14 +66,22 @@ @Value("${mes.sequence.order}") private boolean sequenceOrder; @Value("${mes.firstLength}") @Value("${mes.max.firstLength}") private String firstLength; @Value("${mes.secondLength}") @Value("${mes.max.secondLength}") private String secondLength; @Value("${mes.min.firstLength}") private String minFirstLength; @Value("${mes.min.secondLength}") private String minSecondLength; @Scheduled(fixedDelay = 1000) public void plcHomeEdgTask() { Date startDate = new Date(); log.info("本次任务开始执行时间:{}", startDate); PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; String taskRequestTypeValue = plcParameterObject.getPlcParameter("A06_request_word").getValue(); String glassIdeValue = plcParameterObject.getPlcParameter("A05_scanning_ID").getValue(); @@ -118,6 +126,8 @@ inTo(glassIdeValue, confirmationWrodAddress, currentSlot); } } Date endDate = new Date(); log.info("本次任务结束时间:{},共耗时:{}ms", endDate, endDate.getTime() - startDate.getTime()); } public void plcToHomeEdgTask() { @@ -235,7 +245,7 @@ // 1.2.3、按照出片信息去详情表查询格子在笼子里面剩余相同尺寸的玻璃数据且以版图id、版序升序排序 取第一块玻璃出片 // 2、如果没有历史出片任务 // 2.1、出当前版图id最小版序最小的玻璃(问题:两条线都没有历史任务,出片时两条线的玻璃尺寸相同,是否找尺寸不同的) if (out08Glassstate == 2 && out10Glassstate == 2) { if ((out08Glassstate == 2 && out10Glassstate == 2) || (out08Glassstate == 0 && out10Glassstate == 0)) { log.info("A09、A10为{},{}非自动状态,无法出片"); return Boolean.FALSE; } @@ -257,10 +267,10 @@ EdgStorageCageDetails a10EdgGlass = queryGlassByTaskCache(Const.A10_OUT_TARGET_POSITION, Const.GLASS_CACHE_TYPE_OUT_ALL); endcell = queryLineByGlassInfo(a09EdgGlass, a10EdgGlass, glassInfo, out08Glassstate, out10Glassstate); } else { //判断两条线是否都空闲 endcell = out10Glassstate == 2 ? Const.A09_OUT_TARGET_POSITION : Const.A10_OUT_TARGET_POSITION; //按照状态判断两条线走那条线 endcell = computerLineByState(out08Glassstate, out10Glassstate); if ((out08Glassstate == 0 && out10Glassstate == 0) || (out08Glassstate == 1 && out10Glassstate == 1)) { if (out08Glassstate == 1 && out10Glassstate == 1) { EdgStorageCageDetails a09EdgGlass = queryGlassByTaskCache(Const.A09_OUT_TARGET_POSITION, Const.GLASS_CACHE_TYPE_OUT_ALL); EdgStorageCageDetails a10EdgGlass = queryGlassByTaskCache(Const.A10_OUT_TARGET_POSITION, Const.GLASS_CACHE_TYPE_OUT_ALL); if (a09EdgGlass == null && a10EdgGlass == null) { @@ -272,6 +282,10 @@ wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " + "on t.glass_id = t1.glass_id and (t1.first_length <=" + firstLength + " and t1.second_length<=" + secondLength + ") "); } else { wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " + "on t.glass_id = t1.glass_id and (t1.first_length >=" + minFirstLength + " and t1.second_length>=" + minSecondLength + ") "); } wrapper.last("order by count(t.glass_id) desc limit 2"); List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(wrapper); @@ -280,9 +294,13 @@ .selectAll(GlassInfo.class).eq("t.glass_id", glassId); // .inSql("t.engineer_id", "select engineer_id from engineering where state = 1"); if (endcell == Const.A10_OUT_TARGET_POSITION) { queryWrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + "case when width < height then width else height end as second_length from glass_info) t1 " + wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " + "on t.glass_id = t1.glass_id and (t1.first_length <=" + firstLength + " and t1.second_length<=" + secondLength + ") "); } else { wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " + "on t.glass_id = t1.glass_id and (t1.first_length >=" + minFirstLength + " and t1.second_length>=" + minSecondLength + ") "); } GlassInfo one = glassInfoService.getOne(queryWrapper); if (one != null) { @@ -467,18 +485,20 @@ */ private Integer queryLineByGlassInfo(EdgStorageCageDetails a08EdgStorageCageDetails, EdgStorageCageDetails a10EdgStorageCageDetails, EdgStorageCageDetails glassInfo, int out08Glassstate, int out10Glassstate) { boolean b08 = a08EdgStorageCageDetails != null && a08EdgStorageCageDetails.getHeight() == glassInfo.getHeight() && a08EdgStorageCageDetails.getWidth() == glassInfo.getWidth(); boolean b10 = a10EdgStorageCageDetails != null && a10EdgStorageCageDetails.getHeight() == glassInfo.getHeight() && a10EdgStorageCageDetails.getWidth() == glassInfo.getWidth(); //存在出片任务 07为空 if (b10) { return out10Glassstate == 2 ? Const.A09_OUT_TARGET_POSITION : Const.A10_OUT_TARGET_POSITION; if (out08Glassstate == 1 && out10Glassstate == 1) { boolean b08 = a08EdgStorageCageDetails != null && a08EdgStorageCageDetails.getHeight() == glassInfo.getHeight() && a08EdgStorageCageDetails.getWidth() == glassInfo.getWidth(); boolean b10 = a10EdgStorageCageDetails != null && a10EdgStorageCageDetails.getHeight() == glassInfo.getHeight() && a10EdgStorageCageDetails.getWidth() == glassInfo.getWidth(); if (b08) { return Const.A09_OUT_TARGET_POSITION; } if (b10) { return Const.A10_OUT_TARGET_POSITION; } } if (b08) { return out08Glassstate == 2 ? Const.A10_OUT_TARGET_POSITION : Const.A09_OUT_TARGET_POSITION; } return out10Glassstate == 2 ? Const.A09_OUT_TARGET_POSITION : Const.A10_OUT_TARGET_POSITION; return computerLineByState(out08Glassstate, out10Glassstate); } /** @@ -494,10 +514,14 @@ wrapper.select("count(t.glass_id) as count, t.width, t.height") .eq("t.state", Const.GLASS_STATE_IN) .groupBy("t.width, t.height"); if (endcell == Const.A09_OUT_TARGET_POSITION) { if (endcell == Const.A10_OUT_TARGET_POSITION) { wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " + "on t.glass_id = t1.glass_id and (t1.first_length <=" + firstLength + " and t1.second_length<=" + secondLength + ") "); } else { wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " + "on t.glass_id = t1.glass_id and (t1.first_length >=" + minFirstLength + " and t1.second_length>=" + minSecondLength + ") "); } wrapper.last("order by count(t.glass_id) desc limit 2"); List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(wrapper); @@ -587,7 +611,7 @@ boolean taskCacheStatus = saveTaskCache(glassInfo.getGlassId(), glassInfo.getSlot(), endcell, Const.GLASS_CACHE_TYPE_OUT); log.info("6、添加出片任务是否完成:{}", taskCacheStatus); } boolean glassSizeStatus = saveGlassSize(glassInfo); boolean glassSizeStatus = saveGlassSize(glassInfo, endcell); log.info("7、添加出片玻璃尺寸信息到磨边前玻璃表是否完成:{}", glassSizeStatus); S7object.getinstance().plccontrol.writeWord(confirmationWrodAddress, 1); log.info("8、发送确认字已完成"); @@ -620,19 +644,42 @@ * 添加理片笼任务 * * @param glassInfo * @param endcell * @return */ private boolean saveGlassSize(EdgStorageCageDetails glassInfo) { private boolean saveGlassSize(EdgStorageCageDetails glassInfo, int endcell) { EdgGlassTaskInfo edgGlassTaskInfo = new EdgGlassTaskInfo(); BeanUtils.copyProperties(glassInfo, edgGlassTaskInfo); edgGlassTaskInfo.setHeight((int) (glassInfo.getHeight() * ratio)); edgGlassTaskInfo.setWidth((int) (glassInfo.getWidth() * ratio)); edgGlassTaskInfo.setThickness((int) (glassInfo.getThickness() * ratio)); edgGlassTaskInfo.setStatus(Const.EDG_GLASS_BEFORE); edgGlassTaskInfo.setLine(endcell); edgGlassTaskInfo.setTime(new Date()); return edgGlassTaskInfoService.save(edgGlassTaskInfo); } /** * 计算出片线路 * 已排除都为2 都为0 的情况 * * @param out08Glassstate * @param out10Glassstate * @return */ private int computerLineByState(int out08Glassstate, int out10Glassstate) { if (out08Glassstate == 0) { if (out10Glassstate == 2) { return Const.A09_OUT_TARGET_POSITION; } else { return Const.A10_OUT_TARGET_POSITION; } } else if (out08Glassstate == 1) { return Const.A09_OUT_TARGET_POSITION; } else { return Const.A10_OUT_TARGET_POSITION; } } @Scheduled(fixedDelay = 1000) public void CacheGlassTasks() { @@ -666,7 +713,6 @@ } } } } hangzhoumesParent/moduleService/CacheGlassModule/src/main/resources/application.yml
@@ -13,8 +13,12 @@ mes: threshold: 3 ratio: 10 firstLength: 3500 secondLength: 2500 max: firstLength: 3500 secondLength: 2500 min: firstLength: 600 secondLength: 350 sequence: order: false hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/service/impl/BigStorageCageDetailsServiceImpl.java
@@ -60,8 +60,8 @@ @Value("${mes.slotWidth}") private Integer slotWidth; @Value("${mes.galssGap}") private Integer galssGap; @Value("${mes.glassGap}") private Integer glassGap; /** * 查询进/出片任务 @@ -144,7 +144,7 @@ for (BigStorageCageDetails bigStorageCageDetails : bigStorageCageDetailsList ) { if (bigStorageCageDetails.getBigStorageCageFeedTask().getTaskState() == 0) { carWidth = carWidth - bigStorageCageDetails.getWidth() - galssGap; carWidth = carWidth - bigStorageCageDetails.getWidth() - glassGap; } } return carWidth; @@ -200,7 +200,7 @@ if (glassInfo != null) { BeanUtils.copyProperties(glassInfo, bigStorageCageDetails); bigStorageCageDetails.setState(1); bigStorageCageDetails.setGap(galssGap); bigStorageCageDetails.setGap(glassGap); } List<BigStorageCageDetails> bigStorageCageDetailsList = new ArrayList<>(); bigStorageCageDetailsList.add(bigStorageCageDetails); hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstoragetask/mapper/BigStorageCageFeedTaskMapper.java
@@ -10,7 +10,7 @@ /** * <p> * Mapper 接口 * Mapper 接口 * </p> * * @author zhoush @@ -21,5 +21,5 @@ List<Integer> querySitToUpGlass(); BigStorageDTO querySitToUpRemainWidth(@Param(value = "line") Integer line); BigStorageDTO querySitToUpRemainWidth(@Param(value = "line") Integer line, @Param(value = "glassGap") Integer glassGap); } hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstoragetask/service/impl/BigStorageCageFeedTaskServiceImpl.java
@@ -7,13 +7,14 @@ import com.mes.bigstoragetask.entity.BigStorageCageFeedTask; import com.mes.bigstoragetask.mapper.BigStorageCageFeedTaskMapper; import com.mes.bigstoragetask.service.BigStorageCageFeedTaskService; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.util.List; /** * <p> * 服务实现类 * 服务实现类 * </p> * * @author zhoush @@ -22,9 +23,12 @@ @Service public class BigStorageCageFeedTaskServiceImpl extends ServiceImpl<BigStorageCageFeedTaskMapper, BigStorageCageFeedTask> implements BigStorageCageFeedTaskService { @Value("${mes.glassGap}") private Integer glassGap; @Override public void addFeedTask(BigStorageCageDetails slotInfo, Integer plcFeedReqLine, int taskType){ BigStorageCageFeedTask bigStorageCageFeedTask=new BigStorageCageFeedTask(); public void addFeedTask(BigStorageCageDetails slotInfo, Integer plcFeedReqLine, int taskType) { BigStorageCageFeedTask bigStorageCageFeedTask = new BigStorageCageFeedTask(); bigStorageCageFeedTask.setId(slotInfo.getId()); bigStorageCageFeedTask.setTaskState(0); bigStorageCageFeedTask.setLine(plcFeedReqLine); @@ -41,7 +45,7 @@ @Override public BigStorageDTO querySitToUpRemainWidth(Integer line) { return baseMapper.querySitToUpRemainWidth(line); return baseMapper.querySitToUpRemainWidth(line, glassGap); } @Override hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java
@@ -78,11 +78,13 @@ @Value("${mes.outCarMaxSize}") private Integer outCarMaxSize; @Value("${mes.galssGap}") private Integer galssGap; @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 d01Id = plcParameterObject.getPlcParameter("D01ID").getValue(); String d04Id = plcParameterObject.getPlcParameter("D04ID").getValue(); @@ -93,13 +95,10 @@ String mesD01Address = plcParameterObject.getPlcParameter("MESToD01").getAddress(); String mesD04Address = plcParameterObject.getPlcParameter("MESToD04").getAddress(); String d01ToMES = plcParameterObject.getPlcParameter("D01ToMES").getValue(); if (!REQUEST_WORD.equals(d01ToMES)) { log.info("请求字为{},结束本次扫描进卧转立任务", d01ToMES); return; } String d04ToMES = plcParameterObject.getPlcParameter("D04ToMES").getValue(); log.info("1、获取d01Id扫描ID为:{};获取d04Id扫描ID为:{};", d01Id, d04Id); if (StringUtils.isBlank(d01Id) && StringUtils.isBlank(d04Id)) { log.info("1、获取d01Id扫描ID为:{},请求字为{};获取d04Id扫描ID为:{},请求字为{};", d01Id, d01ToMES, d04Id, d04ToMES); if (StringUtils.isBlank(d01ToMES) && StringUtils.isBlank(d04ToMES)) { log.info("两条线未收到进片任务,结束本次扫描进卧转立任务"); return; } @@ -107,31 +106,34 @@ log.info("两条线卧转立均在执行任务,结束本次扫描进卧转立任务"); return; } // Boolean flag01 = Boolean.FALSE; // Boolean flag04 = Boolean.FALSE; //按照线路及玻璃id获取相邻两块玻璃 卧转立上的玻璃 if (StringUtils.isNotBlank(d01Id) && (StringUtils.isBlank(d02State) || !REQUEST_WORD.equals(d03State))) { if (REQUEST_WORD.equals(d01ToMES) && (StringUtils.isBlank(d02State) || !REQUEST_WORD.equals(d03State))) { judgeGlassTypeStatus(d01Id, Const.A09_OUT_TARGET_POSITION, mesD01Address); } if (StringUtils.isNotBlank(d04Id) && !REQUEST_WORD.equals(d05State)) { if (REQUEST_WORD.equals(d04ToMES) && !REQUEST_WORD.equals(d05State)) { judgeGlassTypeStatus(d04Id, Const.A10_OUT_TARGET_POSITION, mesD04Address); } log.info("结束扫码任务"); Date endDate = new Date(); log.info("大理片笼扫码任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); } @Scheduled(fixedDelay = 300) public void plcToHomeEdgFreeCarTask() { Date startDate = new Date(); log.info("大理片笼空车进片任务开始执行时间:{}", startDate); PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; String e01Status = plcParameterObject.getPlcParameter("E01State").getValue(); String d03ToMES = plcParameterObject.getPlcParameter("D03ToMES").getValue(); String d05ToMES = plcParameterObject.getPlcParameter("D05ToMES").getValue(); log.info("执行空车送片任务,获取到的大车状态为{},卧转立状态分别为d03:{},d05:{}", e01Status, d03ToMES, d05ToMES); if (REQUEST_WORD.equals(e01Status)) { log.info("进片大车非空闲,结束送片任务"); Date endDate = new Date(); log.info("进片大车非空闲,结束送片任务,任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); return; } if (!REQUEST_WORD.equals(d03ToMES) && !REQUEST_WORD.equals(d05ToMES)) { log.info("卧转立没有送片请求,结束送片任务"); Date endDate = new Date(); log.info("卧转立没有送片请求,结束送片任务,任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); return; } LambdaQueryWrapper<BigStorageCageFeedTask> wrapper = new LambdaQueryWrapper<BigStorageCageFeedTask>() @@ -142,14 +144,15 @@ if (CollectionUtils.isNotEmpty(feedTaskList)) { if (feedTaskList.size() == 1) { computeTargetByLine(feedTaskList.get(0).getLine()); return; } else { //比较最早一片任务的版图id及版序 求出卧转立的线路 Integer startLine = getStartLine(); // //计算目标格子,发送启动任务 computeTargetByLine(startLine); return; } 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(); @@ -162,7 +165,8 @@ //获取两条线卧转立是否有玻璃,且任务状态都为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); @@ -179,6 +183,8 @@ computeTargetByLine(lineFirst); } } Date endDate = new Date(); log.info("大理片笼空车进片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); return; } //两条先均可执行进片任务,判断两条线是否进片请求是否都为空 @@ -187,6 +193,8 @@ 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:两个都有进片玻璃 @@ -200,6 +208,8 @@ } 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 { @@ -209,11 +219,14 @@ //获取进片请求玻璃为空的,计算任务表进片格子 发送进片任务 computeTargetByLine(outLine); } Date endDate = new Date(); log.info("大理片笼空车进片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); } @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)); @@ -229,13 +242,17 @@ if (CollectionUtils.isNotEmpty(temperingGlassInfoList)) { log.info("有正在出片的钢化任务"); 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, Boolean.FALSE, mesToPLCAddress); computeOutGlassInfo(artificialList, Boolean.FALSE, mesToPLCAddress); Date endDate = new Date(); log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); return; } //钢化优先:获取理片笼 玻璃小片 破损表 数量 判断笼内版图是否到齐 @@ -253,6 +270,8 @@ .eq(GlassInfo::getEngineerId, temperingLayoutDTO.getEngineerId())); temperingGlassInfoService.saveBatch(temperingGlassInfos); computeOutGlassInfo(temperingGlassInfoList, Boolean.TRUE, mesToPLCAddress); Date endDate = new Date(); log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); return; } //未到齐 执行内部调度任务 @@ -262,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>() @@ -272,6 +291,8 @@ 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; } } @@ -303,10 +324,10 @@ 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); } else { addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst); @@ -315,10 +336,10 @@ 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 <= inCarMaxSize - 1) { if (remainWidth - widthFirst - glassGap >= widthSecond) { if (glassCount < inCarMaxSize) { addFeedTask(glassId, line, Const.BIG_STORAGE_IN_WAIT, widthFirst); } else { addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst); @@ -424,6 +445,7 @@ } 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(); @@ -434,7 +456,7 @@ s7control.writeWord(plcMesObject.getPlcParameter("TargetAddToImport" + i).getAddress(), taskList.get(i - 1).getTargetSlot()); } s7control.writeWord(outLine, 2); log.info("送片任务已发送完成,任务线路为:{},启动地址为{}", line, outLine); log.info("送片任务已发送完成,任务线路为:{},启动地址为{},确认字为{}", line, outLine, 2); } private <T extends BigStorageCageBaseInfo> Boolean computeOutGlassInfo(List<T> list, Boolean isTempering, String mesToPLCAddress) { @@ -446,7 +468,7 @@ if (bigStorageCageOutTaskList.size() > outCarMaxSize || e.getWidth() > remainWidth) { break; } remainWidth = remainWidth - (int) e.getWidth() - galssGap; 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)); @@ -483,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) -> { hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/application.yml
@@ -18,4 +18,4 @@ slotWidth: 5000 #大车宽度 inCarMaxSize: 6 #进片大车最大存放玻璃数量 outCarMaxSize: 1 #出片大车最大存放玻璃数量 galssGap: 300 #玻璃间距 glassGap: 300 #玻璃间距 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageFeedTaskMapper.xml
@@ -21,11 +21,21 @@ where t.total_count = t.real_count </select> <select id="querySitToUpRemainWidth" resultMap="bigStorageDTO"> SELECT cast(5000 - sum(width + 20) as INT) as REMAIN_WIDTH, count(glass_id) as GLASS_COUNT FROM big_storage_cage_feed_task WHERE line = #{line} AND task_state in (1, 2) SELECT CAST (5000 - SUM(MAX_LENGTH + #{glassGap}) AS INT) AS REMAIN_WIDTH, COUNT(GLASS_ID) AS GLASS_COUNT FROM ( SELECT GLASS_ID, CASE WHEN WIDTH >= HEIGHT THEN WIDTH ELSE HEIGHT END MAX_LENGTH FROM BIG_STORAGE_CAGE_FEED_TASK WHERE LINE = 2002 AND TASK_STATE IN (1, 2) ) T </select> </mapper> hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/common/S7object.java
@@ -52,7 +52,9 @@ } byte[] getplcvlues = plccontrol.readByte(PlcMesObject.getPlcAddressBegin(), PlcMesObject.getPlcAddressLength()); PlcMesObject.setPlcParameterList(getplcvlues); if (getplcvlues != null) { PlcMesObject.setPlcParameterList(getplcvlues); } } } hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/DownStorageCageDetailsService.java
@@ -71,7 +71,7 @@ */ boolean DirectConnection(GlassInfo glassInfo); DownStorageCageDetails getGlassInfoMaxCount(); String getGlassInfoMaxCount(String glassId); /** * @param glassId hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageDetailsServiceImpl.java
@@ -3,19 +3,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.yulichang.query.MPJLambdaQueryWrapper; import com.github.yulichang.query.MPJQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.yulichang.query.MPJLambdaQueryWrapper; import com.github.yulichang.toolkit.JoinWrappers; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.mes.common.config.Const; import com.mes.downstorage.entity.DownStorageCage; import com.mes.downstorage.entity.DownStorageCageDetails; import com.mes.downstorage.mapper.DownStorageCageDetailsMapper; import com.mes.downstorage.mapper.DownStorageCageMapper; import com.mes.downstorage.service.DownStorageCageDetailsService; import com.mes.downworkstation.entity.DownWorkstation; @@ -198,8 +193,9 @@ } @Override public DownStorageCageDetails getGlassInfoMaxCount() { return baseMapper.getGlassInfoMaxCount(); public String getGlassInfoMaxCount(String glassId) { DownStorageCageDetails glassInfoMaxCount = baseMapper.getGlassInfoMaxCount(); return null == glassInfoMaxCount ? glassId : glassInfoMaxCount.getGlassId(); } hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java
@@ -4,6 +4,7 @@ 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; @@ -81,7 +82,7 @@ @Scheduled(fixedDelay = 3000) public void plcHomeEdgTask() { PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; String requestWord = plcParameterObject.getPlcParameter("requestWord").getValue(); String glassIdeValue = plcParameterObject.getPlcParameter("requestID").getValue(); //A08 A09表示线路相同 可做等价 无数据转int异常 @@ -92,7 +93,6 @@ 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:{},当前格子号为:{}", @@ -145,8 +145,7 @@ //玻璃尺寸是否走人工下片 if (glassInfo.getWidth() > maxWidth || glassInfo.getHeight() > maxHeight || glassInfo.getWidth() < minWidth || glassInfo.getHeight() < minHeight) { log.info("该玻璃尺寸不符合要求,需要走人工下片直接进片"); } else { } else { log.info("该玻璃尺寸非人工下片"); //获取该玻璃的流程卡是否已绑定架子 DownWorkstation one = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>() @@ -161,7 +160,7 @@ 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("有空架子,将流程卡与架子好绑定,执行进片任务 结束"); //绑定流程卡 @@ -245,8 +244,8 @@ return Boolean.FALSE; } Boolean flag08 = "1".equals(out08Glassstate) ? Boolean.TRUE : Boolean.FALSE; if (!generateTaskByShelf(glassStatus11, flag08, glassStatus13, tempList, cageDetails)) { return generateTaskByShelf(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; } @@ -288,16 +287,16 @@ } } private Boolean generateTaskByShelf(String glassStatus, 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(); if (flag08) { if (!"2".equals(glassStatus)) { if (!"2".equals(glassStatus11)) { workList.addAll(Const.G11_WORK_STATION); } } else { if (!"2".equals(glassStatus)) { if (!"2".equals(glassStatus06)) { workList.addAll(Const.G06_WORK_STATION); } } @@ -306,7 +305,7 @@ //对笼内玻璃进行过滤,仅出符合逻辑的玻璃 if (CollectionUtils.isNotEmpty(workList)) { List<DownWorkstation> downWorkstationList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>() .eq(DownWorkstation::getEnableState, 0).in(DownWorkstation::getWorkstationId, workList)); .eq(DownWorkstation::getEnableState, Const.SLOT_ON).in(DownWorkstation::getWorkstationId, workList)); log.info("架子被禁用,无法出片落架"); if (CollectionUtils.isEmpty(downWorkstationList)) { log.info("笼子被禁用,无法走机械臂下片"); @@ -357,10 +356,8 @@ 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; } @@ -371,9 +368,8 @@ // 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; } @@ -484,7 +480,8 @@ return Boolean.FALSE; } //更新落架玻璃数量 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(); BeanUtils.copyProperties(downStorageCageDetails, downGlassInfo); hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/JsonFile/PlcdownGlass.json
@@ -12,7 +12,7 @@ { "codeId": "requestID", "addressIndex": "2", "addressLenght": "30" "addressLenght": "20" }, { "codeId": "currentCell", hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/resources/application.yml
@@ -3,7 +3,7 @@ spring: profiles: active: dev active: cz application: name: unLoadGlass @@ -14,11 +14,10 @@ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl mes: maxWidth: 2500 #下片的最大宽度 2500*2000 maxWidth: 2500 #下片的最大宽度 maxHeight: 2000 #下片的最大高度 minWidth: 400 #下片的最小宽度 minHeight: 400 #下片的最小高度 minWidth: 400 #下片的最大宽度 minHeight: 400 #下片的最大高度 throughWidth: 3000 throughHeight: 2500 threshold: 5 #下片的最大阈值