From 584989385e05b8ad887431da2ab7da1e93e1ffaa Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期一, 03 三月 2025 14:59:52 +0800 Subject: [PATCH] 大屏展示,消息推送部分优化 --- pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java | 56 +++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 43 insertions(+), 13 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java index f4705ec..0678465 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java @@ -1,21 +1,24 @@ package com.dy.pipIrrRemote.msCenter; +import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.dy.common.contant.Constant; import com.dy.common.multiDataSource.DataSourceContext; +import com.dy.common.util.NumUtil; import com.dy.common.webUtil.BaseResponse; +import com.dy.common.webUtil.WebSocketMessage; +import com.dy.pipIrrRemote.largeScreen.WebSocketServer; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - -import java.util.Iterator; import java.util.List; /** @@ -25,15 +28,19 @@ */ @Slf4j -@Tag(name = "閫氫俊涓棿娑堟伅涓績鎺ㄩ�佹秷鎭帴鏀舵柟", description = "閫氫俊涓棿娑堟伅涓績鎺ㄩ�佹秷鎭帴鏀舵柟") +@Hidden //涓嶅叕寮�鎺ュ彛锛屽叾鍙湁閫氫俊涓棿浠惰皟鐢� +@Tag(name = "閫氫俊涓棿浠舵秷鎭腑蹇冩帹閫佹秷鎭帴鏀惰��", description = "閫氫俊涓棿浠舵秷鎭腑蹇冩帹閫佹秷鎭帴鏀惰��") @RestController @RequestMapping(path="msCenter") public class CenterMsReceiveCtrl{ + @Autowired + private CenterMsReceiveSv sv ; + /** - * 閫氫俊涓棿娑堟伅涓績鎺ㄩ�佹秷鎭帴鏀� - * @param list 娑堟伅闆嗗悎 - * @return 鎿嶄綔缁撴灉 + * 閫氫俊涓棿浠舵秷鎭腑蹇冩帹閫佹秷鎭帴鏀� + * @param list 娑堟伅鏁版嵁闆嗗悎 + * @return 鏃犺繑鍥炵粨鏋� */ @Hidden //涓嶅叕寮�鎺ュ彛锛屽叾鍙湁閫氫俊涓棿浠惰皟鐢� @PostMapping(path = "receive", consumes = MediaType.APPLICATION_JSON_VALUE) @@ -45,17 +52,40 @@ if(list != null && list.size() > 0){ for (JSONObject jo : list) { if(jo != null){ - log.info("----------------start " + token + " 娑堟伅鏁版嵁--------------") ; - Iterator<String> it = jo.keySet().iterator() ; - String key ; - while (it.hasNext()){ - key = it.next() ; - log.info(key + "锛�" + jo.get(key)); + if(jo.containsKey("intakeId")){ + Object intakeIdObj = jo.get("intakeId") ; + Long intakeId = null ; + if(intakeIdObj != null && intakeIdObj instanceof Long){ + intakeId = (Long) intakeIdObj ; + }else if(intakeIdObj != null && intakeIdObj instanceof String){ + if(NumUtil.isPlusIntNumber(intakeIdObj.toString())){ + intakeId = Long.parseLong(intakeIdObj.toString()) ; + } + } + if(intakeId != null){ + String intakeNum = this.sv.selectIntakeName(intakeId) ; + jo.put("intakeNum", intakeNum) ; + } } - log.info("----------------end " + token + " 娑堟伅鏁版嵁--------------") ; } } + sendByWebSocket(list) ; } return null ; } + + /** + * 閫氳繃websocket鎶婃秷鎭帹閫佸嚭鍘伙紝褰撳墠鎺ユ敹鏂规槸鍓嶇鐨勫ぇ灞忓睍绀烘ā鍧� + * @param list + */ + private void sendByWebSocket(List<JSONObject> list){ + WebSocketMessage vo = new WebSocketMessage() ; + vo.type = WebSocketMessage.TYPE_JSON ; + vo.content = list ; + try { + WebSocketServer.sendMessage2AllClient(JSON.toJSONString(vo)); + }catch (Exception e){ + log.error("鎺ㄩ�佹秷鎭け璐�", e) ; + } + } } -- Gitblit v1.8.0