From 00c4dfc5ac687c93e0b7abafc33abb693b38edd6 Mon Sep 17 00:00:00 2001 From: 严智鑫 <test> Date: 星期一, 05 八月 2024 09:14:33 +0800 Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes --- hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java | 86 ++++++++++++++++++++++++++++++------------ 1 files changed, 61 insertions(+), 25 deletions(-) diff --git a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java index 98206a6..0dd3ec0 100644 --- a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java +++ b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java @@ -5,6 +5,7 @@ import cn.hutool.json.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.github.yulichang.query.MPJQueryWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.mes.common.S7object; @@ -20,6 +21,7 @@ import com.mes.glassinfo.service.GlassInfoService; import com.mes.taskcache.entity.TaskCache; import com.mes.taskcache.service.TaskCacheService; +import com.mes.temperingglass.entity.TemperingGlassInfo; import com.mes.tools.WebSocketServer; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -73,11 +75,19 @@ @Value("${mes.max.secondLength}") private String secondLength; - @Value("${mes.min.firstLength}") - private String minFirstLength; + @Value("${mes.min.one.firstLength}") + private String minOneFirstLength; - @Value("${mes.min.secondLength}") - private String minSecondLength; + @Value("${mes.min.one.secondLength}") + private String minOneSecondLength; + + @Value("${mes.min.two.firstLength}") + private String minTwoFirstLength; + + @Value("${mes.min.two.secondLength}") + private String minTwoSecondLength; + + public static String engineerId=""; @Scheduled(fixedDelay = 1000) public void plcHomeEdgTask() { @@ -114,7 +124,7 @@ inTo(glassIdeValue, confirmationWrodAddress, currentSlot); } else if ("2".equals(taskRequestTypeValue)) { //09绌洪棽 锛�1 10绌洪棽 锛�2 閮界┖闂诧細3 鍏朵粬0 - log.info("2銆佸嚭鐗囪姹傦紝涓旂‘璁ゅ瓧涓�0锛屾墽琛岃繘鐗囦换鍔�"); + log.info("2銆佸嚭鐗囪姹傦紝涓旂‘璁ゅ瓧涓�0锛屾墽琛屽嚭鐗囦换鍔�"); outTo(Integer.parseInt(out08Glassstate), Integer.parseInt(out10Glassstate), confirmationWrodAddress, "", 0); } else if ("3".equals(taskRequestTypeValue)) { @@ -130,7 +140,23 @@ Date endDate = new Date(); log.info("鏈浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms", endDate, endDate.getTime() - startDate.getTime()); } - + @Scheduled(fixedDelay = 1000) + public void temperingIsRun(){ + JSONObject jsonObject = new JSONObject(); + //姝e湪杩涜鐨勪换鍔� + List<TaskCache>taskCaches=taskCacheService.selectTaskCacheIsRun(); + jsonObject.append("taskCaches", taskCaches); + ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("isRun"); + if (sendwServer != null) { + for (WebSocketServer webserver : sendwServer) { + if (webserver != null) { + webserver.sendMessage(jsonObject.toString()); + } else { + log.info("Home is closed"); + } + } + } + } /** * 杩涚墖浠诲姟 * @@ -226,7 +252,7 @@ // 2銆佸鏋滄病鏈夊巻鍙插嚭鐗囦换鍔� // 2.1銆佸嚭褰撳墠鐗堝浘id鏈�灏忕増搴忔渶灏忕殑鐜荤拑锛堥棶棰橈細涓ゆ潯绾块兘娌℃湁鍘嗗彶浠诲姟锛屽嚭鐗囨椂涓ゆ潯绾跨殑鐜荤拑灏哄鐩稿悓锛屾槸鍚︽壘灏哄涓嶅悓鐨勶級 if ((out08Glassstate == 2 && out10Glassstate == 2) || (out08Glassstate == 0 && out10Glassstate == 0)) { - log.info("A09銆丄10涓簕},{}闈炶嚜鍔ㄧ姸鎬侊紝鏃犳硶鍑虹墖"); + log.info("A09銆丄10涓簕},{}闈炶嚜鍔ㄧ姸鎬侊紝鏃犳硶鍑虹墖", out08Glassstate, out10Glassstate); return Boolean.FALSE; } log.info("0銆佸嚭鐗囦换鍔″嚭鐨勭姸鎬�:A09:銆恵}銆�;A10:銆恵}銆�)", out08Glassstate, out10Glassstate); @@ -262,26 +288,27 @@ 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 + ") "); + "on t.glass_id = t1.glass_id and (t1.first_length between " + minTwoFirstLength + " and " + firstLength + + " and t1.second_length between " + minTwoSecondLength + " and " + 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 + ") "); + "on t.glass_id = t1.glass_id and (t1.first_length >=" + minOneFirstLength + " and t1.second_length>=" + minOneSecondLength + ") "); } wrapper.last("order by count(t.glass_id) desc limit 2"); List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(wrapper); if (CollectionUtil.isEmpty(list)) { MPJQueryWrapper<GlassInfo> queryWrapper = new MPJQueryWrapper<GlassInfo>() .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) { - wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + + 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 edg_storage_cage_details) t1 " + - "on t.glass_id = t1.glass_id and (t1.first_length <=" + firstLength + " and t1.second_length<=" + secondLength + ") "); + "on t.glass_id = t1.glass_id and (t1.first_length between " + minTwoFirstLength + " and " + firstLength + + " and t1.second_length between " + minTwoSecondLength + " and " + secondLength + ") "); } else { - wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " + + 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 edg_storage_cage_details) t1 " + - "on t.glass_id = t1.glass_id and (t1.first_length >=" + minFirstLength + " and t1.second_length>=" + minSecondLength + ") "); + "on t.glass_id = t1.glass_id and (t1.first_length >=" + minOneFirstLength + " and t1.second_length>=" + minOneSecondLength + ") "); } GlassInfo one = glassInfoService.getOne(queryWrapper); if (one != null) { @@ -375,7 +402,7 @@ List<Object> list = edgStorageCageDetailsService.listObjs(queryWrapper); //鑾峰彇绗煎唴鐜荤拑鐗堝浘宸�兼槸鍚﹀ぇ浜庨槇鍊� if (CollectionUtil.isNotEmpty(list)) { - int diff = (int) list.get(0); + Long diff = (Long) list.get(0); return diff > threshold; } else { return Boolean.FALSE; @@ -503,11 +530,12 @@ 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 + ") "); + "on t.glass_id = t1.glass_id and (t1.first_length between " + minTwoFirstLength + " and " + firstLength + + " and t1.second_length between " + minTwoSecondLength + " and " + 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 + ") "); + "on t.glass_id = t1.glass_id and (t1.first_length >=" + minOneFirstLength + " and t1.second_length>=" + minOneSecondLength + ") "); } wrapper.last("order by count(t.glass_id) desc limit 2"); List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(wrapper); @@ -545,7 +573,7 @@ return queryMinGlass(firstSize.getWidth(), firstSize.getHeight(), glassId); } EdgStorageCageDetails outGlassInfo = edgStorageCageDetailsService.getOne(new LambdaQueryWrapper<EdgStorageCageDetails>() - .eq(EdgStorageCageDetails::getGlassId, taskCache.getGlassId())); + .eq(EdgStorageCageDetails::getGlassId, taskCache.getGlassId()).last("limit 1")); log.info("{}绾挎湁鍑虹墖浠诲姟淇℃伅,浠诲姟淇℃伅涓簕}锛岀幓鐠冧俊鎭负{}", endcell, taskCache, outGlassInfo); if (outGlassInfo.getWidth() == firstWidth && outGlassInfo.getHeight() == firstHeight) { log.info("鏁伴噺鏈�澶氱殑瀹絳}楂榹}鍜寋}绾夸换鍔$殑瀹絳}楂榹}鐩稿悓锛屽嚭鏁伴噺鎺掔浜岀殑鐜荤拑锛屽{}楂榹}", @@ -587,11 +615,9 @@ log.info("6銆佹坊鍔犲嚭鐗囦换鍔℃槸鍚﹀畬鎴愶細{}", taskCacheStatus); } else { log.info("5銆侀潪鐩撮�氫换鍔�,灏嗙幓鐠冧俊鎭彃鍏ュ崸寮忕悊鐗囩,褰撳墠鐜荤拑淇℃伅:{}", glassInfo); - LambdaQueryWrapper<EdgStorageCageDetails> wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(EdgStorageCageDetails::getGlassId, glassInfo.getGlassId()); - EdgStorageCageDetails updateDetail = new EdgStorageCageDetails(); - updateDetail.setState(Const.GLASS_STATE_OUT); - edgStorageCageDetailsService.update(updateDetail, wrapper); + LambdaUpdateWrapper<EdgStorageCageDetails> wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(EdgStorageCageDetails::getGlassId, glassInfo.getGlassId()).set(EdgStorageCageDetails::getState, Const.GLASS_STATE_OUT); + edgStorageCageDetailsService.update(wrapper); log.info("5銆佹洿鏂板嚭鐗囩幓鐠冪殑鐘舵�佷负{}", Const.GLASS_STATE_OUT); boolean taskCacheStatus = saveTaskCache(glassInfo.getGlassId(), glassInfo.getSlot(), endcell, Const.GLASS_CACHE_TYPE_OUT); @@ -642,6 +668,8 @@ edgGlassTaskInfo.setStatus(Const.EDG_GLASS_BEFORE); edgGlassTaskInfo.setLine(endcell); edgGlassTaskInfo.setTime(new Date()); + //鍏堝皢鍘嗗彶瀵瑰垪琛ㄤ腑鏈幓鐠冪殑鏁版嵁鍒犻櫎锛岄噸鏂版柊澧炰竴浠芥渶鏂扮殑鏁版嵁 + edgGlassTaskInfoService.remove(new LambdaQueryWrapper<EdgGlassTaskInfo>().eq(EdgGlassTaskInfo::getGlassId, glassInfo.getGlassId())); return edgGlassTaskInfoService.save(edgGlassTaskInfo); } @@ -670,9 +698,17 @@ @Scheduled(fixedDelay = 1000) public void CacheGlassTasks() { JSONObject jsonObject = new JSONObject(); - //璇嗗埆鎽嗙墖 - List<Map<String, Object>> currentCutTerritorys = edgStorageCageDetailsService.selectCutTerritory(); + List<Map<String, Object>> currentCutTerritorys= edgStorageCageDetailsService.selectCutTerritory(); +// List<Map<String, Object>> currentCutTerritorys=new ArrayList<>(); +// if(engineerId==null||engineerId.isEmpty()){ +// //璇嗗埆鎽嗙墖 褰撳墠鐗堝浘鏁版嵁 +// currentCutTerritorys = edgStorageCageDetailsService.selectCutTerritory(); +// }else{ +// //璇嗗埆鎽嗙墖 姝ngineerId 宸ョ▼鐗堝浘鏁版嵁 +// currentCutTerritorys = edgStorageCageDetailsService.selectCurrentCutTerritory(engineerId); +// } jsonObject.append("currentCutTerritory", currentCutTerritorys); + //log.info("鏈璇嗗埆鐗堝浘{},++++{}",engineerId,currentCutTerritorys); //纾ㄨ竟淇℃伅 List<Map<String, Object>> EdgTasks1 = taskCacheService.selectEdgInfo("2001"); List<Map<String, Object>> EdgTasks2 = taskCacheService.selectEdgInfo("2002"); -- Gitblit v1.8.0