| | |
| | | |
| | | public static String engineerId = ""; |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | @Scheduled(fixedDelay = 500) |
| | | public void plcHomeEdgTask() { |
| | | Date startDate = new Date(); |
| | | log.info("本次任务开始执行时间:{}", startDate); |
| | |
| | | String confirmationWrodValue = plcParameterObject.getPlcParameter("MES_confirmation_word").getValue(); |
| | | //A08 A09表示线路相同 可做等价 无数据转int异常 |
| | | String out08Glassstate = plcParameterObject.getPlcParameter("A08_glass_status").getValue(); |
| | | String out09Glassstate = plcParameterObject.getPlcParameter("A09_glass_status").getValue(); |
| | | String out10Glassstate = plcParameterObject.getPlcParameter("A10_glass_status").getValue(); |
| | | String confirmationWrodAddress = plcParameterObject.getPlcParameter("MES_confirmation_word").getAddress(); |
| | | String currentSlot = plcParameterObject.getPlcParameter("Current_slot").getValue(); |
| | | |
| | | if ("1".equals(out09Glassstate)) { |
| | | log.info("A09空闲"); |
| | | out08Glassstate = "1"; |
| | | } |
| | | |
| | | // taskRequestTypeValue = "2"; |
| | | // out08Glassstate = "1"; |
| | | // out10Glassstate = "1"; |
| | | // currentSlot = "5"; |
| | | // currentSlot = "1"; |
| | | // confirmationWrodValue = "0"; |
| | | // glassIdeValue = "P24092706|15|5"; |
| | | // glassIdeValue = "P25021704|75|12"; |
| | | |
| | | log.info("1、获取到的请求字为:{},获取到的扫描ID为:{},获取到的确认字为:{},获取到的出片状态分别为:A09:{}、A10:{},当前格子号为:{}", |
| | | taskRequestTypeValue, glassIdeValue, confirmationWrodValue, out08Glassstate, out10Glassstate, currentSlot); |
| | |
| | | return; |
| | | } |
| | | boolean result = edgStorageCageDetailsService.inToVerify(glassIdeValue); |
| | | if (!result) { |
| | | log.info("此玻璃id已经进过"); |
| | | return; |
| | | } |
| | | if ("1".equals(taskRequestTypeValue) && result) { |
| | | log.info("2、进片请求,且确认字为0,执行进片任务,扫码重复ID验证【有重复=false,无重复=true】:{}", result); |
| | | inTo(glassIdeValue, confirmationWrodAddress, currentSlot); |
| | | } else if ("2".equals(taskRequestTypeValue)) { |
| | | } else if ("2".equals(taskRequestTypeValue) && result) { |
| | | //09空闲 :1 10空闲 :2 都空闲:3 其他0 |
| | | log.info("2、出片请求,且确认字为0,执行出片任务"); |
| | | outTo(Integer.parseInt(out08Glassstate), |
| | | Integer.parseInt(out10Glassstate), confirmationWrodAddress, "", Integer.parseInt(currentSlot)); |
| | | } else if ("3".equals(taskRequestTypeValue)) { |
| | | } else if ("3".equals(taskRequestTypeValue) && result) { |
| | | log.info("2、进片和出片都空闲,执行出片任务"); |
| | | //加笼子里面是否有玻璃,有先出,无玻璃先进 |
| | | boolean outFlase = outTo(Integer.parseInt(out08Glassstate), |
| | |
| | | } |
| | | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | @Scheduled(fixedDelay = 500) |
| | | public void dealDamageTask() { |
| | | Date startDate = new Date(); |
| | | log.info("卧式理片破损玻璃清除任务开始执行时间:{}", startDate); |
| | |
| | | new LambdaQueryWrapper<GlassInfo>() |
| | | .eq(GlassInfo::getGlassId, glassId) |
| | | ); |
| | | if (Math.max(feedGlassInfo.getWidth(), feedGlassInfo.getHeight()) > cacheWidth || Math.min(feedGlassInfo.getWidth(), feedGlassInfo.getHeight()) > cacheHeight) { |
| | | log.info("1.1、玻璃超过卧式理片最大尺寸:{}", feedGlassInfo); |
| | | if (Math.max(feedGlassInfo.getWidth(), feedGlassInfo.getHeight()) > cacheWidth || |
| | | Math.min(feedGlassInfo.getWidth(), feedGlassInfo.getHeight()) > cacheHeight |
| | | || Math.min(feedGlassInfo.getWidth(), feedGlassInfo.getHeight()) < Integer.parseInt(minTwoFirstLength) |
| | | ) { |
| | | log.info("1.1、玻璃超过卧式理片尺寸范围:{}", feedGlassInfo); |
| | | return; |
| | | } |
| | | |
| | |
| | | details.setSlot(nearestEmpty.getSlot()); |
| | | details.setDeviceId(nearestEmpty.getDeviceId()); |
| | | edgStorageCageDetailsService.save(details); |
| | | damageService.deleteByGlassId(glassId); |
| | | log.info("5、玻璃信息已存入理片笼详情表,玻璃信息为{}", details); |
| | | //添加进片任务 |
| | | boolean taskCache = saveTaskCache(details.getGlassId(), 0, nearestEmpty.getSlot(), Const.GLASS_CACHE_TYPE_IN); |
| | |
| | | // 1.2.3、按照出片信息去详情表查询格子在笼子里面剩余相同尺寸的玻璃数据且以版图id、版序升序排序 取第一块玻璃出片 |
| | | // 2、如果没有历史出片任务 |
| | | // 2.1、出当前版图id最小版序最小的玻璃(问题:两条线都没有历史任务,出片时两条线的玻璃尺寸相同,是否找尺寸不同的) |
| | | if ((out08Glassstate == 2 && out10Glassstate == 2) || (out08Glassstate == 0 && out10Glassstate == 0)) { |
| | | // if ((out08Glassstate == 2 && out10Glassstate == 2) || (out08Glassstate == 0 && out10Glassstate == 0)) { |
| | | // log.info("A09、A10为{},{}非自动状态,无法出片", out08Glassstate, out10Glassstate); |
| | | // return Boolean.FALSE; |
| | | // } |
| | | if ((out08Glassstate == 2 && out10Glassstate == 2)) { |
| | | log.info("A09、A10为{},{}非自动状态,无法出片", out08Glassstate, out10Glassstate); |
| | | return Boolean.FALSE; |
| | | } |
| | | if ((out08Glassstate == 0 && out10Glassstate == 0)) { |
| | | out10Glassstate = 1; |
| | | } |
| | | log.info("0、出片任务出的状态:A09:【{}】;A10:【{}】)", out08Glassstate, out10Glassstate); |
| | | //定义出片玻璃信息 |
| | | int endcell = 0; |
| | | EdgStorageCageDetails glassInfo = null; |
| | | |
| | | //当笼子已满时,不考虑卧式理片前的玻璃 |
| | | EdgStorageCage nearestEmpty = edgStorageCageService.selectNearestEmpty(currentSlot, Boolean.FALSE); |
| | | if (nearestEmpty == null) { |
| | | glassId = ""; |
| | | } |
| | | |
| | | boolean flag = queryMaxMinDiff(threshold); |
| | | log.info("1、获取钢化版图是否超过阈值:{}", flag); |
| | |
| | | endcell = queryLineByGlassInfo(a09EdgGlass, a10EdgGlass, glassInfo, out08Glassstate, out10Glassstate); |
| | | } else { |
| | | //按照状态判断两条线走那条线 |
| | | endcell = computerLineByState(out08Glassstate, out10Glassstate); |
| | | |
| | | GlassInfo glassInfos = glassInfoService.getOne( |
| | | new LambdaQueryWrapper<GlassInfo>() |
| | | .eq(GlassInfo::getGlassId, glassId) |
| | | ); |
| | | if (glassInfos != null) { |
| | | if (Math.max(glassInfos.getWidth(), glassInfos.getHeight()) > Integer.parseInt(firstLength) && out08Glassstate == 1) { |
| | | endcell = Const.A09_OUT_TARGET_POSITION; |
| | | } else { |
| | | endcell = computerLineByState(out08Glassstate, out10Glassstate); |
| | | } |
| | | } else { |
| | | endcell = computerLineByState(out08Glassstate, out10Glassstate); |
| | | } |
| | | 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) { |
| | | if (a09EdgGlass != null || a10EdgGlass != null) { |
| | | MPJQueryWrapper<EdgStorageCageDetails> wrapper = new MPJQueryWrapper<>(); |
| | | wrapper.select("count(t.glass_id), t.width, t.height") |
| | | .eq("t.state", Const.GLASS_STATE_IN) |
| | |
| | | wrapper.last("order by count(t.glass_id) desc limit 2"); |
| | | List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(wrapper); |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | log.info("笼子内没有找到合适的玻璃"); |
| | | MPJQueryWrapper<GlassInfo> queryWrapper = new MPJQueryWrapper<GlassInfo>() |
| | | .selectAll(GlassInfo.class).eq("t.glass_id", glassId); |
| | | if (endcell == Const.A10_OUT_TARGET_POSITION) { |
| | | queryWrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + |
| | | queryWrapper.leftJoin("(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 between " + minTwoFirstLength + " and " + firstLength |
| | | + " and t1.second_length between " + minTwoSecondLength + " and " + secondLength + ") "); |
| | | } else { |
| | | queryWrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + |
| | | queryWrapper.leftJoin("(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 >=" + minOneFirstLength + " and t1.second_length>=" + minOneSecondLength + ") "); |
| | | } |
| | | GlassInfo one = glassInfoService.getOne(queryWrapper); |
| | | log.info("找到合适的玻璃" + one); |
| | | if (one != null) { |
| | | EdgStorageCageDetails resultDetails = new EdgStorageCageDetails(); |
| | | BeanUtils.copyProperties(one, resultDetails); |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (endcell == Const.A09_OUT_TARGET_POSITION && Math.min(glassInfo.getWidth(), glassInfo.getHeight()) < Integer.parseInt(minOneFirstLength)) { |
| | | log.info("尺寸不符合最大线最小尺寸{}", glassInfo); |
| | | return Boolean.FALSE; |
| | | } |
| | | return saveOutGlassMessageBySlot(glassInfo, endcell, confirmationWrodAddress, glassId, currentSlot); |
| | | } |
| | |
| | | damage.setType(1); |
| | | damage.setRemark("过卧式理片"); |
| | | damageService.insertDamage(damage); |
| | | damageService.deleteByGlassId(glassId); |
| | | return Boolean.TRUE; |
| | | } |
| | | return Boolean.FALSE; |
| | |
| | | glassInfo = currentGlass; |
| | | } |
| | | } |
| | | //玻璃信息替换 |
| | | String glassIdChange = queryAndChangeGlass(glassInfo.getGlassId()); |
| | | //处理在卧理内的玻璃信息:笼内的数据处理 |
| | | queryEdgAndChangeGlass(glassInfo.getGlassId(), glassIdChange); |
| | | // //玻璃信息替换 |
| | | // String glassIdChange = queryAndChangeGlass(glassInfo.getGlassId()); |
| | | // //处理在卧理内的玻璃信息:笼内的数据处理 |
| | | // queryEdgAndChangeGlass(glassInfo.getGlassId(), glassIdChange); |
| | | LambdaUpdateWrapper<EdgStorageCageDetails> wrapper = new LambdaUpdateWrapper<>(); |
| | | wrapper.eq(EdgStorageCageDetails::getGlassId, glassInfo.getGlassId()).set(EdgStorageCageDetails::getState, Const.GLASS_STATE_OUT); |
| | | edgStorageCageDetailsService.update(wrapper); |
| | |
| | | damage.setType(1); |
| | | damage.setRemark("过卧式理片"); |
| | | damageService.insertDamage(damage); |
| | | damageService.deleteByGlassId(glassId); |
| | | return Boolean.TRUE; |
| | | } |
| | | return Boolean.FALSE; |
| | |
| | | * @return |
| | | */ |
| | | private int computerLineByState(int out08Glassstate, int out10Glassstate) { |
| | | if (out08Glassstate == 0) { |
| | | if (out10Glassstate == 2) { |
| | | return Const.A09_OUT_TARGET_POSITION; |
| | | } else { |
| | | // 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; |
| | | // } |
| | | if (out10Glassstate == 0) { |
| | | if (out08Glassstate == 2) { |
| | | return Const.A10_OUT_TARGET_POSITION; |
| | | } else { |
| | | return Const.A09_OUT_TARGET_POSITION; |
| | | } |
| | | } else if (out08Glassstate == 1) { |
| | | return Const.A09_OUT_TARGET_POSITION; |
| | | } else { |
| | | } else if (out10Glassstate == 1) { |
| | | return Const.A10_OUT_TARGET_POSITION; |
| | | } else { |
| | | return Const.A09_OUT_TARGET_POSITION; |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | @Scheduled(fixedDelay = 3000) |
| | | public void CacheGlassTasks() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | List<Map<String, Object>> currentCutTerritorys = edgStorageCageDetailsService.selectCutTerritory(); |
| | | jsonObject.append("currentCutTerritory", currentCutTerritorys); |
| | | //log.info("本次识别版图{},++++{}",engineerId,currentCutTerritorys); |
| | | //卧室缓存笼内信息 |
| | | List<Map<String, Object>> EdgStorageCageinfos = edgStorageCageService.selectEdgStorageCages(); |
| | | jsonObject.append("EdgStorageCageinfos", EdgStorageCageinfos); |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("cacheGlass"); |
| | | if (sendwServer != null) { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | List<Map<String, Object>> currentCutTerritorys = edgStorageCageDetailsService.selectCutTerritory(); |
| | | jsonObject.append("currentCutTerritory", currentCutTerritorys); |
| | | //log.info("本次识别版图{},++++{}",engineerId,currentCutTerritorys); |
| | | //卧室缓存笼内信息 |
| | | List<Map<String, Object>> EdgStorageCageinfos = edgStorageCageService.selectEdgStorageCages(); |
| | | jsonObject.append("EdgStorageCageinfos", EdgStorageCageinfos); |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | if (webserver != null) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | @Scheduled(fixedDelay = 3000) |
| | | public void cacheGlassIsRun() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //正在进行的任务 |
| | |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | @Scheduled(fixedDelay = 3000) |
| | | public void CacheGlassTaskss() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //log.info("本次识别版图{},++++{}",engineerId,currentCutTerritorys); |