From 71594bd2dc9201834aa533099e9e49a9b84506cd Mon Sep 17 00:00:00 2001 From: wangfei <3597712270@qq.com> Date: 星期四, 12 六月 2025 15:32:25 +0800 Subject: [PATCH] 新增韩语 --- hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OPCPlcSlicecage.java | 164 ++++++++++++++++++++++++++++++++---------------------- 1 files changed, 96 insertions(+), 68 deletions(-) diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OPCPlcSlicecage.java b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OPCPlcSlicecage.java index 487d00e..0224a8d 100644 --- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OPCPlcSlicecage.java +++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OPCPlcSlicecage.java @@ -1,29 +1,34 @@ package com.mes.job; import cn.hutool.json.JSONObject; -import cn.smallbun.screw.core.util.CollectionUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.kangaroohy.milo.model.ReadWriteEntity; +import com.kangaroohy.milo.service.MiloService; import com.mes.bigstorage.entity.BigStorageCageDetails; +import com.mes.bigstorage.entity.dto.BigStorageSummaryDTO; import com.mes.bigstorage.service.BigStorageCageDetailsService; import com.mes.bigstorage.service.BigStorageCageService; +import com.mes.bigstoragecagetask.entity.BigStorageCageHistoryTask; import com.mes.bigstoragecagetask.entity.BigStorageCageTask; +import com.mes.bigstoragecagetask.entity.BigStorageTaskVO; +import com.mes.bigstoragecagetask.service.BigStorageCageHistoryTaskService; import com.mes.bigstoragecagetask.service.BigStorageCageTaskService; -import com.mes.glassinfo.entity.GlassInfo; +import com.mes.common.config.Const; import com.mes.glassinfo.service.GlassInfoService; +import com.mes.largenscreen.entity.PieChartVO; +import com.mes.largenscreen.entity.RunTime; import com.mes.temperingglass.entity.TemperingGlassInfo; import com.mes.temperingglass.service.TemperingGlassInfoService; import com.mes.tools.WebSocketServer; import com.mes.utils.RedisUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import javax.annotation.Resource; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.Socket; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -47,37 +52,75 @@ private GlassInfoService glassInfoService; @Resource private BigStorageCageTaskService bigStorageCageTaskService; + @Resource + private BigStorageCageHistoryTaskService bigStorageCageHistoryTaskService; - @Value("${mes.scan.ip}") - private String scanIp; - - @Value("${mes.scan.port}") - private Integer scanPort; + @Autowired(required = false) + MiloService miloService; private JSONObject jsonObject = new JSONObject(); - public void queryDataSource1() throws InterruptedException { + public void queryDataSource1() throws Exception { List<Double> carPostion = new ArrayList<>(); carPostion.add(0.25); carPostion.add(0.5); jsonObject.append("carPostion", carPostion); //鐣岄潰灞曠ず绗煎瓙淇℃伅 -// jsonObject.append("bigStorageCageInfos", bigStorageCageService.querybigStorageCageDetail()); + jsonObject.append("bigStorageCageInfos", bigStorageCageDetailsService.querybigStorageCageDetail()); - //杩涚墖浠诲姟鏁版嵁 - List<BigStorageCageTask> inTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_in_one_task"); - jsonObject.append("bigStorageCageDetailsFeedTask", inTaskList); + try { + //杩涚墖浠诲姟鏁版嵁 + List<BigStorageTaskVO> inTaskList = new ArrayList(); + ReadWriteEntity fromOpcUa = miloService.readFromOpcUa("DLP1A.DLP1A.FROM1"); + for (int i = 1; i <= 6; i++) { + ReadWriteEntity requestWord = miloService.readFromOpcUa("DLP1A.DLP1A.DI" + i); + ReadWriteEntity targetSlotWord = miloService.readFromOpcUa("DLP1A.DLP1A.TO" + i); + ReadWriteEntity stateWord = miloService.readFromOpcUa("DLP1A.DLP1A.STATE" + i); + if (null != requestWord.getValue()) { + BigStorageTaskVO task = new BigStorageTaskVO(); + task.setGlassId(requestWord.getValue() + ""); + int isExistCount = bigStorageCageDetailsService.count(new LambdaQueryWrapper<BigStorageCageDetails>().in(BigStorageCageDetails::getGlassId, task.getGlassId()) + .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); + if (isExistCount > 0) { + task.setIsSame(1); + } else { + task.setIsSame(0); + } + task.setStartSlot(Integer.parseInt(fromOpcUa.getValue() + "")); + task.setTargetSlot(Integer.parseInt(targetSlotWord.getValue() + "")); + task.setTaskState(Integer.parseInt(stateWord.getValue() + "")); + inTaskList.add(task); + continue; + } + } + jsonObject.append("bigStorageCageDetailsFeedTask", inTaskList); + } catch (Exception e) { + //todo:涓嶅仛浠诲姟澶勭悊 + } + try { + //杩涚墖鑱旀満 + ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); + jsonObject.append("inkageEntity", inkageEntity.getValue()); + //杩涚墖璇锋眰 + ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1A.DLP1A.RequestMes"); + jsonObject.append("requestEntity", requestEntity.getValue()); + //鍚姩鍛戒护 + ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP1A.DLP1A.MesReply"); + jsonObject.append("mesReplyEntity", mesReplyEntity.getValue()); + //鍑虹墖鑱旀満 + ReadWriteEntity outInkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); + jsonObject.append("outInkageEntity", outInkageEntity.getValue()); + //鍑虹墖璇锋眰 + ReadWriteEntity outRequestEntity = miloService.readFromOpcUa("DLP1B.DLP1B.RequestMes"); + jsonObject.append("outRequestEntity", outRequestEntity.getValue()); - //鍑虹墖浠诲姟鏁版嵁 - List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_one_task"); - jsonObject.append("bigStorageCageDetailsOutTask", outTaskList); - //鐞嗙墖绗间娇鐢ㄦ儏鍐� - List<Map<String, Object>> bigStorageCageUsage = bigStorageCageService.selectBigStorageCageUsage(); -// jsonObject.append("bigStorageCageUsage", bigStorageCageUsage); - - //鐞嗙墖绗艰〃鏍间俊鎭� -// jsonObject.append("bigStorageCageInfo", bigStorageCageService.querybigStorageCageDetailAll()); + //鍑虹墖浠诲姟鏁版嵁 + List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_one_task"); + jsonObject.append("bigStorageCageDetailsOutTask", outTaskList); + } catch (Exception e) { + //todo:涓嶅仛浠诲姟澶勭悊 + } //閽㈠寲寮�鍏� boolean temperingSwitch = false; @@ -87,6 +130,7 @@ temperingSwitch = redisUtil.getCacheObject("temperingSwitch"); } jsonObject.append("temperingSwitch", temperingSwitch); + //璋冨害寮�鍏� boolean dispatchSwitch = false; if (redisUtil.getCacheObject("dispatchSwitch") == null) { @@ -95,6 +139,15 @@ dispatchSwitch = redisUtil.getCacheObject("dispatchSwitch"); } jsonObject.append("dispatchSwitch", dispatchSwitch); + + //鐞嗙墖绗间娇鐢ㄦ儏鍐� + List<Map<String, Object>> bigStorageCageUsage = bigStorageCageService.selectBigStorageCageUsage(); + jsonObject.append("bigStorageCageUsage", bigStorageCageUsage); + + //澶х悊鐗囨眹鎬讳俊鎭� + List<BigStorageSummaryDTO> bigStorageSummary = bigStorageCageService.selectBigStorageSummary(); + jsonObject.append("bigStorageSummary", bigStorageSummary); + //鎵撳嵃寮�鍏� boolean autoPrint = false; if (redisUtil.getCacheObject("autoPrint") == null) { @@ -130,14 +183,14 @@ * fixedRate : 涓婁竴涓皟鐢ㄥ紑濮嬪悗鍐嶆璋冪敤鐨勫欢鏃讹紙涓嶇敤绛夊緟涓婁竴娆¤皟鐢ㄥ畬鎴愶級 * fixedDelay : 涓婁竴涓皟鐢ㄧ粨鏉熷悗鍐嶆璋冪敤鐨勫欢鏃� */ - @Scheduled(fixedDelay = 1000) + @Scheduled(fixedDelay = 3000) public void plcStorageCageTask() throws InterruptedException { jsonObject = new JSONObject(); try { //鏌ヨ浣跨敤鏁版嵁婧�1鏌ヨ鏁版嵁 queryDataSource1(); //鏌ヨ浣跨敤鏁版嵁婧�2鏌ヨ鏁版嵁 - queryDataSource2(); +// queryDataSource2(); ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("slicecage"); if (sendwServer != null) { @@ -159,54 +212,29 @@ } } - // @Scheduled(fixedDelay = 1000) - public void temperingIsRun() { + @Scheduled(fixedDelay = 1000) + public void largenScreen() { JSONObject jsonObject = new JSONObject(); - //杩涚墖浠诲姟鏁版嵁 - List<BigStorageCageDetails> bigStorageCageDetailsFeedTask = bigStorageCageDetailsService.selectFeedTask(); - jsonObject.append("bigStorageCageDetailsFeedTask", bigStorageCageDetailsFeedTask); - //鍑虹墖浠诲姟鏁版嵁 - List<BigStorageCageDetails> bigStorageCageDetailsOutTask = bigStorageCageDetailsService.selectOutTask(); - jsonObject.append("bigStorageCageDetailsOutTask", bigStorageCageDetailsOutTask); - ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("isRun"); + //鐞嗙墖绗间娇鐢ㄦ儏鍐� + ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("largenScreen"); if (sendwServer != null) { + List<Map<String, Object>> bigStorageCageUsage = bigStorageCageService.selectBigStorageCageUsage(); + jsonObject.append("bigStorageCageUsage", bigStorageCageUsage); + List<PieChartVO> pieChartVOS = bigStorageCageService.queryPieChart(); + jsonObject.append("pieChartVOS", pieChartVOS); + List<RunTime> tempRunTimes = bigStorageCageHistoryTaskService.queryRunTimes(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); + jsonObject.append("tempRunTimes", tempRunTimes); for (WebSocketServer webserver : sendwServer) { if (webserver != null) { webserver.sendMessage(jsonObject.toString()); - } else { - log.info("Home is closed"); - } - } - } - } - - // @Scheduled(fixedDelay = Long.MAX_VALUE) - public void scanCodeTask() { - log.info("鎵弿浠诲姟宸插惎鍔�"); - while (true) { - JSONObject jsonObject = new JSONObject(); - try (Socket socket = new Socket(scanIp, scanPort); - BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) { - // 鎺ユ敹鏈嶅姟鍣ㄥ搷搴� - log.info("绛夊緟鎵爜涓�......"); - String glassId = in.readLine(); - log.info("鎵弿鍒扮殑鐜荤拑id锛歿}", glassId); - List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("slicecage"); - if (CollectionUtils.isNotEmpty(sendwServer)) { - //鎸夌収鐜荤拑id鑾峰彇鐜荤拑淇℃伅杩斿洖缁欏墠绔晫闈紝鍏蜂綋闇�瑕佸摢浜涙暟鎹緟纭 - GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>() - .eq(GlassInfo::getGlassId, glassId).last("limit 1")); - if (null == glassInfo) { - log.info("鎸夌収鐜荤拑id锛歿}锛屾棤娉曟壘鍒扮幓鐠冧俊鎭�", glassId); - } else { - for (WebSocketServer webserver : sendwServer) { - jsonObject.append("scanGlass", glassInfo); - webserver.sendMessage(jsonObject.toString()); - } + List<String> messages = webserver.getMessages(); + if (!messages.isEmpty()) { + // // 灏嗘渶鍚庝竴涓秷鎭浆鎹负鏁存暟绫诲瀷鐨勫垪琛� + webserver.clearMessages(); } + } else { + log.info("largenScreen is closed"); } - } catch (Exception exception) { - log.info("璇诲彇寮傚父锛屽師鍥犱负{}", exception.getMessage()); } } } -- Gitblit v1.8.0