From b4ff04d7dd22f0e48bf386cd422e885aef08fed7 Mon Sep 17 00:00:00 2001 From: ZengTao <2773468879@qq.com> Date: 星期四, 22 五月 2025 15:03:10 +0800 Subject: [PATCH] OPC通讯修改为S7通讯 --- hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java | 83 +++++++++++++++++++++++++++++++++++++---- 1 files changed, 74 insertions(+), 9 deletions(-) diff --git a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java index e0a91f0..52b49a6 100644 --- a/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java +++ b/hangzhoumesParent/moduleService/TemperingGlassModule/src/main/java/com/mes/job/PlcTemperingGlassTask.java @@ -1,14 +1,24 @@ package com.mes.job; + import cn.hutool.json.JSONObject; -import com.mes.temperingglass.service.TemperingGlassInfoService; +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.mes.common.config.Const; +import com.mes.damage.service.DamageService; +import com.mes.largenscreen.entity.PieChartVO; import com.mes.temperingglass.entity.TemperingGlassInfo; +import com.mes.temperingglass.service.TemperingGlassInfoService; import com.mes.tools.WebSocketServer; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import java.time.LocalDate; +import java.time.ZoneId; import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -20,24 +30,27 @@ @Autowired private TemperingGlassInfoService temperingAgoService; + @Autowired + private DamageService damageService; + /** * fixedRate : 涓婁竴涓皟鐢ㄥ紑濮嬪悗鍐嶆璋冪敤鐨勫欢鏃讹紙涓嶇敤绛夊緟涓婁竴娆¤皟鐢ㄥ畬鎴愶級 * fixedDelay : 涓婁竴涓皟鐢ㄧ粨鏉熷悗鍐嶆璋冪敤鐨勫欢鏃� */ @Scheduled(fixedDelay = 1000) - public void temperingGlassHome(){ + public void temperingGlassHome() { JSONObject jsonObject = new JSONObject(); //姝e湪绛夊緟杩涚墖鐨勭幓鐠� - List<TemperingGlassInfo> waitingGlass = temperingAgoService.selectWaitingGlass(); - if(waitingGlass!=null){ + List<TemperingGlassInfo> waitingGlass = temperingAgoService.selectWaitingGlassByOpc(); + if (waitingGlass != null) { jsonObject.append("waitingGlass", waitingGlass); } //鑾峰彇鏁村湪鐐変腑鐨勪袱涓増鍥緄d List<TemperingGlassInfo> layoutId = temperingAgoService.selectLayoutId(); //杩涚倝涓殑鐜荤拑 - if(!layoutId.isEmpty()) { + if (!layoutId.isEmpty()) { List<TemperingGlassInfo> intoGlass = temperingAgoService.selectIntoGlass(layoutId.get(0)); jsonObject.append("intoGlass", intoGlass); //杩涚倝涓殑绗簩涓増鍥� @@ -48,7 +61,7 @@ } //鍑虹倝鍚庣殑鐜荤拑 List<TemperingGlassInfo> outGlass = temperingAgoService.selectOutGlass(); - if(outGlass!=null){ + if (outGlass != null) { jsonObject.append("outGlass", outGlass); } @@ -70,13 +83,16 @@ } } } + @Scheduled(fixedDelay = 1000) - public void temperingIsRun(){ + public void temperingIsRun() { JSONObject jsonObject = new JSONObject(); //姝e湪杩涜鐨勪换鍔� - List<TemperingGlassInfo>temperingTaskType=temperingAgoService.selectTaskType(); + List<TemperingGlassInfo> temperingTaskType = temperingAgoService.selectTaskType(); jsonObject.append("temperingTaskType", temperingTaskType); - ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("isRun"); + + + ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("temperingIsRun"); if (sendwServer != null) { for (WebSocketServer webserver : sendwServer) { if (webserver != null) { @@ -86,7 +102,56 @@ } } } + } + @Scheduled(fixedDelay = 1000) + public void largenScreen() { + JSONObject jsonObject = new JSONObject(); + //澶у睆閽㈠寲淇℃伅 + Date startOfToday = new Date(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli()); + + Integer putGlass = temperingAgoService.count( + new QueryWrapper<TemperingGlassInfo>() + .eq("state", Const.TEMPERING_NEW) + .gt("create_time", startOfToday) + ); + jsonObject.append("temperingTaskType", putGlass); + //澶у睆閽㈠寲淇℃伅 + List<TemperingGlassInfo> temperingGlassInfoList = temperingAgoService.list( + new QueryWrapper<TemperingGlassInfo>() + .select("engineer_id" ,"tempering_layout_id") + .eq("state", Const.TEMPERING_START) + .gt("create_time", startOfToday) + .groupBy("engineer_id" ,"tempering_layout_id") + ); + jsonObject.append("temperingGlassInfoList", temperingGlassInfoList.size()); + //澶у睆閽㈠寲淇℃伅 + List<TemperingGlassInfo> temperingGlassInfoInList = temperingAgoService.list( + new LambdaQueryWrapper<TemperingGlassInfo>() + .select(TemperingGlassInfo::getEngineerId, TemperingGlassInfo::getTemperingLayoutId) // 閫夋嫨瑕佸幓閲嶇殑瀛楁 + .eq(TemperingGlassInfo::getState, Const.TEMPERING_DROP) + .groupBy(TemperingGlassInfo::getEngineerId, TemperingGlassInfo::getTemperingLayoutId) // 鎸� engineerId 鍜� temperingLayoutId 鍒嗙粍 + ); + jsonObject.append("temperingGlassInfoInList", temperingGlassInfoInList.size()); + //閽㈠寲楗煎浘鏁版嵁 + List<PieChartVO> pieChartVOS = temperingAgoService.queryPieChart(); + jsonObject.append("pieChartVOS", pieChartVOS); + ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("largenScreen"); + if (sendwServer != null) { + for (WebSocketServer webserver : sendwServer) { + if (webserver != null) { + webserver.sendMessage(jsonObject.toString()); + List<String> messages = webserver.getMessages(); + if (!messages.isEmpty()) { + // // 灏嗘渶鍚庝竴涓秷鎭浆鎹负鏁存暟绫诲瀷鐨勫垪琛� + webserver.clearMessages(); + } + } else { + log.info("largenScreen is closed"); + } + } + } + } } \ No newline at end of file -- Gitblit v1.8.0