| | |
| | | <artifactId>jcdm-system</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- SpringBoot Websocket --> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-websocket</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | </project> |
| | |
| | | // è¿æ»¤è¯·æ± |
| | | .authorizeRequests() |
| | | // 对äºç»å½login 注åregister éªè¯ç captchaImage å
许å¿åè®¿é® |
| | | .antMatchers("/login", "/register", "/captchaImage").permitAll() |
| | | .antMatchers("/login", "/register", "/captchaImage","/websocket/**").permitAll() |
| | | // éæèµæºï¼å¯å¿åè®¿é® |
| | | .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() |
| | | .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.jcdm.framework.websocket; |
| | | |
| | | import java.util.concurrent.Semaphore; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | /** |
| | | * ä¿¡å·éç¸å
³å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class SemaphoreUtils |
| | | { |
| | | /** |
| | | * SemaphoreUtils æ¥å¿æ§å¶å¨ |
| | | */ |
| | | private static final Logger LOGGER = LoggerFactory.getLogger(SemaphoreUtils.class); |
| | | |
| | | /** |
| | | * è·åä¿¡å·é |
| | | * |
| | | * @param semaphore |
| | | * @return |
| | | */ |
| | | public static boolean tryAcquire(Semaphore semaphore) |
| | | { |
| | | boolean flag = false; |
| | | |
| | | try |
| | | { |
| | | flag = semaphore.tryAcquire(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LOGGER.error("è·åä¿¡å·éå¼å¸¸", e); |
| | | } |
| | | |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * éæ¾ä¿¡å·é |
| | | * |
| | | * @param semaphore |
| | | */ |
| | | public static void release(Semaphore semaphore) |
| | | { |
| | | |
| | | try |
| | | { |
| | | semaphore.release(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LOGGER.error("éæ¾ä¿¡å·éå¼å¸¸", e); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.jcdm.framework.websocket; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.socket.server.standard.ServerEndpointExporter; |
| | | |
| | | /** |
| | | * websocket é
ç½® |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Configuration |
| | | public class WebSocketConfig |
| | | { |
| | | @Bean |
| | | public ServerEndpointExporter serverEndpointExporter() |
| | | { |
| | | return new ServerEndpointExporter(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.jcdm.framework.websocket; |
| | | |
| | | import java.util.concurrent.Semaphore; |
| | | import javax.websocket.OnClose; |
| | | import javax.websocket.OnError; |
| | | import javax.websocket.OnMessage; |
| | | import javax.websocket.OnOpen; |
| | | import javax.websocket.Session; |
| | | import javax.websocket.server.ServerEndpoint; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * websocket æ¶æ¯å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | @ServerEndpoint("/websocket/message") |
| | | public class WebSocketServer |
| | | { |
| | | /** |
| | | * WebSocketServer æ¥å¿æ§å¶å¨ |
| | | */ |
| | | private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketServer.class); |
| | | |
| | | /** |
| | | * é»è®¤æå¤å
许åæ¶å¨çº¿äººæ°100 |
| | | */ |
| | | public static int socketMaxOnlineCount = 100; |
| | | |
| | | private static Semaphore socketSemaphore = new Semaphore(socketMaxOnlineCount); |
| | | |
| | | /** |
| | | * è¿æ¥å»ºç«æåè°ç¨çæ¹æ³ |
| | | */ |
| | | @OnOpen |
| | | public void onOpen(Session session) throws Exception |
| | | { |
| | | boolean semaphoreFlag = false; |
| | | // å°è¯è·åä¿¡å·é |
| | | semaphoreFlag = SemaphoreUtils.tryAcquire(socketSemaphore); |
| | | if (!semaphoreFlag) |
| | | { |
| | | // æªè·åå°ä¿¡å·é |
| | | LOGGER.error("\n å½åå¨çº¿äººæ°è¶
è¿éå¶æ°- {}", socketMaxOnlineCount); |
| | | WebSocketUsers.sendMessageToUserByText(session, "å½åå¨çº¿äººæ°è¶
è¿éå¶æ°ï¼" + socketMaxOnlineCount); |
| | | session.close(); |
| | | } |
| | | else |
| | | { |
| | | // æ·»å ç¨æ· |
| | | WebSocketUsers.put(session.getId(), session); |
| | | LOGGER.info("\n 建ç«è¿æ¥ - {}", session); |
| | | LOGGER.info("\n å½åäººæ° - {}", WebSocketUsers.getUsers().size()); |
| | | WebSocketUsers.sendMessageToUserByText(session, "è¿æ¥æå"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è¿æ¥å
³éæ¶å¤ç |
| | | */ |
| | | @OnClose |
| | | public void onClose(Session session) |
| | | { |
| | | LOGGER.info("\n å
³éè¿æ¥ - {}", session); |
| | | // 移é¤ç¨æ· |
| | | WebSocketUsers.remove(session.getId()); |
| | | // è·åå°ä¿¡å·éåééæ¾ |
| | | SemaphoreUtils.release(socketSemaphore); |
| | | } |
| | | |
| | | /** |
| | | * æåºå¼å¸¸æ¶å¤ç |
| | | */ |
| | | @OnError |
| | | public void onError(Session session, Throwable exception) throws Exception |
| | | { |
| | | if (session.isOpen()) |
| | | { |
| | | // å
³éè¿æ¥ |
| | | session.close(); |
| | | } |
| | | String sessionId = session.getId(); |
| | | LOGGER.info("\n è¿æ¥å¼å¸¸ - {}", sessionId); |
| | | LOGGER.info("\n å¼å¸¸ä¿¡æ¯ - {}", exception); |
| | | // 移åºç¨æ· |
| | | WebSocketUsers.remove(sessionId); |
| | | // è·åå°ä¿¡å·éåééæ¾ |
| | | SemaphoreUtils.release(socketSemaphore); |
| | | } |
| | | |
| | | /** |
| | | * æå¡å¨æ¥æ¶å°å®¢æ·ç«¯æ¶æ¯æ¶è°ç¨çæ¹æ³ |
| | | */ |
| | | @OnMessage |
| | | public void onMessage(String message, Session session) |
| | | { |
| | | String msg = message.replace("ä½ ", "æ").replace("å", ""); |
| | | WebSocketUsers.sendMessageToUserByText(session, msg); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.jcdm.framework.websocket; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Collection; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import javax.websocket.Session; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | /** |
| | | * websocket 客æ·ç«¯ç¨æ·é |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class WebSocketUsers |
| | | { |
| | | /** |
| | | * WebSocketUsers æ¥å¿æ§å¶å¨ |
| | | */ |
| | | private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketUsers.class); |
| | | |
| | | /** |
| | | * ç¨æ·é |
| | | */ |
| | | private static Map<String, Session> USERS = new ConcurrentHashMap<String, Session>(); |
| | | |
| | | /** |
| | | * åå¨ç¨æ· |
| | | * |
| | | * @param key å¯ä¸é® |
| | | * @param session ç¨æ·ä¿¡æ¯ |
| | | */ |
| | | public static void put(String key, Session session) |
| | | { |
| | | USERS.put(key, session); |
| | | } |
| | | |
| | | /** |
| | | * 移é¤ç¨æ· |
| | | * |
| | | * @param session ç¨æ·ä¿¡æ¯ |
| | | * |
| | | * @return 移é¤ç»æ |
| | | */ |
| | | public static boolean remove(Session session) |
| | | { |
| | | String key = null; |
| | | boolean flag = USERS.containsValue(session); |
| | | if (flag) |
| | | { |
| | | Set<Map.Entry<String, Session>> entries = USERS.entrySet(); |
| | | for (Map.Entry<String, Session> entry : entries) |
| | | { |
| | | Session value = entry.getValue(); |
| | | if (value.equals(session)) |
| | | { |
| | | key = entry.getKey(); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return true; |
| | | } |
| | | return remove(key); |
| | | } |
| | | |
| | | /** |
| | | * 移åºç¨æ· |
| | | * |
| | | * @param key é® |
| | | */ |
| | | public static boolean remove(String key) |
| | | { |
| | | LOGGER.info("\n æ£å¨ç§»åºç¨æ· - {}", key); |
| | | Session remove = USERS.remove(key); |
| | | if (remove != null) |
| | | { |
| | | boolean containsValue = USERS.containsValue(remove); |
| | | LOGGER.info("\n 移åºç»æ - {}", containsValue ? "失败" : "æå"); |
| | | return containsValue; |
| | | } |
| | | else |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åå¨çº¿ç¨æ·å表 |
| | | * |
| | | * @return è¿åç¨æ·éå |
| | | */ |
| | | public static Map<String, Session> getUsers() |
| | | { |
| | | return USERS; |
| | | } |
| | | |
| | | /** |
| | | * 群åæ¶æ¯ææ¬æ¶æ¯ |
| | | * |
| | | * @param message æ¶æ¯å
容 |
| | | */ |
| | | public static void sendMessageToUsersByText(String message) |
| | | { |
| | | Collection<Session> values = USERS.values(); |
| | | for (Session value : values) |
| | | { |
| | | sendMessageToUserByText(value, message); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * åéææ¬æ¶æ¯ |
| | | * |
| | | * @param userName èªå·±çç¨æ·å |
| | | * @param message æ¶æ¯å
容 |
| | | */ |
| | | public static void sendMessageToUserByText(Session session, String message) |
| | | { |
| | | if (session != null) |
| | | { |
| | | try |
| | | { |
| | | session.getBasicRemote().sendText(message); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | LOGGER.error("\n[åéæ¶æ¯å¼å¸¸]", e); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LOGGER.info("\n[ä½ å·²ç¦»çº¿]"); |
| | | } |
| | | } |
| | | } |
| | |
| | | import {listFormulaChild} from "@/api/main/bs/formulaChild/formulaChild"; |
| | | |
| | | export default { |
| | | name: "index", |
| | | name: "Instructions", |
| | | data() { |
| | | return { |
| | | queryParams: { |
| | |
| | | this.changeProducts(this.productCode) |
| | | // this.autoShow() |
| | | }, |
| | | beforeDestroy() { |
| | | clearInterval(this.intervalId) |
| | | this.intervalId = null |
| | | }, |
| | | methods: { |
| | | // å®æ¶è§¦å |
| | | autoShow() { |
| | |
| | | <el-col :span="12"> |
| | | <el-card shadow="never"> |
| | | <span class="head-font">æ»æç¼ç : {{headContent.sfcCode}}</span> |
| | | <el-input v-model="input" style="float: right;width: 150px;" placeholder="请è¾å
¥å
容"></el-input> |
| | | <el-input v-model="content" style="float: right;width: 150px;" placeholder="请è¾å
¥å
容"></el-input> |
| | | <el-button @click="scanCompleted" style="float: right" type="primary">æ«ç å®æ</el-button> |
| | | <el-button @click="clearClick" style="float: right" type="danger">æ¸
é¤</el-button> |
| | | </el-card> |
| | |
| | | |
| | | </el-col> |
| | | <el-col :span="18"> |
| | | <el-tabs type="border-card" style="height: 600px"> |
| | | <el-tab-pane> |
| | | <el-tabs type="border-card" style="height: 600px" v-model="activeName" @tab-click="changeMenu"> |
| | | <el-tab-pane name="first"> |
| | | <span slot="label"> <a class="el-icon-date"></a>é¦é¡µ</span> |
| | | <el-col :span="8"> |
| | | <el-table> |
| | |
| | | <el-image style="height: 520px;width: 100%" :src="imgSrc"></el-image> |
| | | </el-col> |
| | | </el-tab-pane> |
| | | <el-tab-pane> |
| | | <el-tab-pane name="second"> |
| | | <span slot="label"> <b class="el-icon-date"></b>ç©æBOM</span> |
| | | <el-empty > |
| | | <span slot="description">ææ æ°æ®</span> |
| | | </el-empty> |
| | | </el-tab-pane> |
| | | <el-tab-pane> |
| | | <span slot="label"> <c class="el-icon-date"></c>ééæ¸
å</span> |
| | | <el-tab-pane name="third"> |
| | | <span slot="label"> <b class="el-icon-date"></b>ééæ¸
å</span> |
| | | <el-empty > |
| | | <span slot="description">ææ æ°æ®</span> |
| | | </el-empty> |
| | | </el-tab-pane> |
| | | <el-tab-pane> |
| | | <span slot="label"> <d class="el-icon-date"></d>å®ç¯ç¶æ</span> |
| | | <el-tab-pane name="fourth"> |
| | | <span slot="label"> <b class="el-icon-date"></b>å®ç¯ç¶æ</span> |
| | | <el-empty > |
| | | <span slot="description">ææ æ°æ®</span> |
| | | </el-empty> |
| | | </el-tab-pane> |
| | | <el-tab-pane> |
| | | <span slot="label"> <e class="el-icon-date"></e>å·¥èºé
æ¹</span> |
| | | <el-tab-pane name="fifth"> |
| | | <span slot="label"> <b class="el-icon-date"></b>å·¥èºé
æ¹</span> |
| | | <el-empty > |
| | | <span slot="description">ææ æ°æ®</span> |
| | | </el-empty> |
| | |
| | | data() { |
| | | return { |
| | | ipAddress: '', |
| | | input: null, |
| | | imgSrc: '', |
| | | headContent: { |
| | | processesCode: 'OP1010', |
| | |
| | | scanFinish: 0, |
| | | startWork: 0, |
| | | release: 0 //å
许æ¾è¡ |
| | | } |
| | | }, |
| | | content: '', |
| | | activeName: 'first' |
| | | } |
| | | }, |
| | | created() { |
| | | this.getIPAddress(); |
| | | this.getStationConfList(); |
| | | }, |
| | | methods: { |
| | | changeMenu(tab, event) { |
| | | console.log(tab, event); |
| | | }, |
| | | clearClick(){ |
| | | this.$message('è¿æ¯ä¸æ¡æ¸
é¤æ¶æ¯æ示'); |
| | | this.headContent.sfcCode = null |
| | | }, |
| | | scanCompleted(){ |
| | | this.$message('æ«ç å®æ'+this.input); |
| | | this.headContent.sfcCode = this.input |
| | | this.queryParams.sfcCode = this.input |
| | | this.$message('æ«ç å®æ'+this.content); |
| | | this.headContent.sfcCode = this.content |
| | | this.queryParams.sfcCode = this.content |
| | | this.getList() |
| | | this.cakeLamp.scanFinish = 1 |
| | | }, |
| | |
| | | clearInterval(this.timer); |
| | | this.$message('ä¿åèæ为'+this.workpieceInformation.beat+'ç§'); |
| | | }, |
| | | getIPAddress() { |
| | | this.ipAddress = window.location.hostname; |
| | | }, |
| | | /** æ¥è¯¢å·¥ä½ç»ç«¯é
ç½®å表 */ |
| | | getStationConfList() { |
| | | let queryParams = { |
| | |
| | | }); |
| | | listStationConf(queryParams).then(response => { |
| | | let rows = response.rows[0] |
| | | if(response.rows.length===0){ |
| | | this.$message('æ¹ipæ²æé
置工åºå·¥ä½ï¼è«é試ï¼'); |
| | | return |
| | | } |
| | | this.headContent.processesName = rows.processesName |
| | | this.headContent.processesCode = rows.processesCode |
| | | }); |
| | |
| | | font-size: 15px; |
| | | } |
| | | </style> |
| | | <!--<template>--> |
| | | <!-- <div>--> |
| | | <!-- <el-input v-model="url" type="text" style="width: 20%" /> --> |
| | | <!-- <el-button @click="join" type="primary">è¿æ¥</el-button>--> |
| | | <!-- <el-button @click="exit" type="danger">æå¼</el-button>--> |
| | | |
| | | <!-- <br />--> |
| | | <!-- <el-input type="textarea" v-model="message" :rows="9" />--> |
| | | <!-- <el-button type="info" @click="send">åéæ¶æ¯</el-button>--> |
| | | <!-- <br />--> |
| | | <!-- <br />--> |
| | | <!-- <el-input type="textarea" v-model="text_content" :rows="9" /> è¿åå
容--> |
| | | <!-- <br />--> |
| | | <!-- <br />--> |
| | | <!-- </div>--> |
| | | <!--</template>--> |
| | | |
| | | <!--<script>--> |
| | | <!--export default {--> |
| | | <!-- data() {--> |
| | | <!-- return {--> |
| | | <!-- url: "ws://127.0.0.1:8081/websocket/message",--> |
| | | <!-- message: "",--> |
| | | <!-- text_content: "",--> |
| | | <!-- ws: null,--> |
| | | <!-- };--> |
| | | <!-- },--> |
| | | <!-- methods: {--> |
| | | <!-- join() {--> |
| | | <!-- const wsuri = this.url;--> |
| | | <!-- this.ws = new WebSocket(wsuri);--> |
| | | <!-- const self = this;--> |
| | | <!-- this.ws.onopen = function (event) {--> |
| | | <!-- self.text_content = self.text_content + "å·²ç»æå¼è¿æ¥!" + "\n";--> |
| | | <!-- };--> |
| | | <!-- this.ws.onmessage = function (event) {--> |
| | | <!-- console.log("å端åè¿æ¥çæ¶æ¯"+event.data)--> |
| | | <!-- self.text_content = event.data + "\n";--> |
| | | <!-- };--> |
| | | <!-- this.ws.onclose = function (event) {--> |
| | | <!-- self.text_content = self.text_content + "å·²ç»å
³éè¿æ¥!" + "\n";--> |
| | | <!-- };--> |
| | | <!-- },--> |
| | | <!-- exit() {--> |
| | | <!-- if (this.ws) {--> |
| | | <!-- this.ws.close();--> |
| | | <!-- this.ws = null;--> |
| | | <!-- }--> |
| | | <!-- },--> |
| | | <!-- send() {--> |
| | | <!-- if (this.ws) {--> |
| | | <!-- this.ws.send(this.message);--> |
| | | <!-- } else {--> |
| | | <!-- alert("æªè¿æ¥å°æå¡å¨");--> |
| | | <!-- }--> |
| | | <!-- },--> |
| | | <!-- },--> |
| | | <!--};--> |
| | | <!--</script>--> |
| | | |
| | |
| | | </el-empty> |
| | | </el-tab-pane> |
| | | <el-tab-pane> |
| | | <span slot="label"> <c class="el-icon-date"></c>å¤æ¼æ£æµ</span> |
| | | <span slot="label"> <b class="el-icon-date"></b>å¤æ¼æ£æµ</span> |
| | | <el-empty > |
| | | <span slot="description">ææ æ°æ®</span> |
| | | </el-empty> |
| | | </el-tab-pane> |
| | | <el-tab-pane> |
| | | <span slot="label"> <d class="el-icon-date"></d>æºè½´å 注</span> |
| | | <span slot="label"> <b class="el-icon-date"></b>æºè½´å 注</span> |
| | | <el-empty > |
| | | <span slot="description">ææ æ°æ®</span> |
| | | </el-empty> |
| | | </el-tab-pane> |
| | | <el-tab-pane> |
| | | <span slot="label"> <e class="el-icon-date"></e>å·¥ä½ç»æ</span> |
| | | <span slot="label"> <b class="el-icon-date"></b>å·¥ä½ç»æ</span> |
| | | <el-empty > |
| | | <span slot="description">ææ æ°æ®</span> |
| | | </el-empty> |
| | |
| | | import { listRepairData, getRepairData, delRepairData, addRepairData, updateRepairData } from "@/api/main/rm/repairData/repairData"; |
| | | |
| | | export default { |
| | | name: "RepairData", |
| | | name: "rmRepairData", |
| | | dicts: ['qualified_status'], |
| | | data() { |
| | | return { |