From b2abd25927c39e849e592f1abdc08879d8d35245 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期三, 07 五月 2025 09:48:39 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java | 91 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 91 insertions(+), 0 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 new file mode 100644 index 0000000..0678465 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java @@ -0,0 +1,91 @@ +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.List; + +/** + * @Author: liurunyu + * @Date: 2025/2/12 17:34 + * @Description + */ + +@Slf4j +@Hidden //涓嶅叕寮�鎺ュ彛锛屽叾鍙湁閫氫俊涓棿浠惰皟鐢� +@Tag(name = "閫氫俊涓棿浠舵秷鎭腑蹇冩帹閫佹秷鎭帴鏀惰��", description = "閫氫俊涓棿浠舵秷鎭腑蹇冩帹閫佹秷鎭帴鏀惰��") +@RestController +@RequestMapping(path="msCenter") +public class CenterMsReceiveCtrl{ + + @Autowired + private CenterMsReceiveSv sv ; + + /** + * 閫氫俊涓棿浠舵秷鎭腑蹇冩帹閫佹秷鎭帴鏀� + * @param list 娑堟伅鏁版嵁闆嗗悎 + * @return 鏃犺繑鍥炵粨鏋� + */ + @Hidden //涓嶅叕寮�鎺ュ彛锛屽叾鍙湁閫氫俊涓棿浠惰皟鐢� + @PostMapping(path = "receive", consumes = MediaType.APPLICATION_JSON_VALUE) + public BaseResponse<Boolean> receive(@RequestBody List<JSONObject> list, HttpServletRequest req, HttpServletResponse rep) { + //閫氫俊涓棿浠朵紶杩囨潵鐨勬満鏋則ag锛屼互鐢ㄤ簬鏌ユ壘鏁版嵁婧� + String token = req.getHeader(Constant.UserTokenKeyInHeader); + DataSourceContext.set(token); + + if(list != null && list.size() > 0){ + for (JSONObject jo : list) { + if(jo != null){ + 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) ; + } + } + } + } + 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