From 52a3d2b51c7ca58abcb0e31783671af98d526aef Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期五, 22 十二月 2023 12:17:23 +0800
Subject: [PATCH] #检料盘点工作档更新

---
 src/main/webapp/views/console.html |  218 +++++++++++++++++++++++++++++++-----------------------
 1 files changed, 125 insertions(+), 93 deletions(-)

diff --git a/src/main/webapp/views/console.html b/src/main/webapp/views/console.html
index 37e92a7..1f9a9dd 100644
--- a/src/main/webapp/views/console.html
+++ b/src/main/webapp/views/console.html
@@ -76,8 +76,8 @@
 						<el-button :style="{background:currentLev === lev ? '#7DCDFF':''}" @click="changFloor(lev)">{{lev}}F</el-button>
 					</div>
 					<div>
-						<el-button @click="testMove()">娴嬭瘯绉诲姩杞�</el-button>
-						<el-button @click="resetMap()">閲嶇疆鍦板浘</el-button>
+<!--						<el-button @click="testMove()">娴嬭瘯绉诲姩杞�</el-button>-->
+<!--						<el-button @click="resetMap()">閲嶇疆鍦板浘</el-button>-->
 					</div>
 				</div>
 			</div>
@@ -187,7 +187,7 @@
 							<li><span>鏉$爜鍚嶇О</span><span class="right">鎵爜鏃堕棿</span></li>
 						</div>
 						<div id="barcode1" class="table-body">
-							<li v-for="(item,index) in codeList" :key="index"><span>{{item.barcode}}</span><span class="right">{{item.time}}</span></li>
+							<li v-for="(item,index) in codeList1" :key="index"><span>{{item.barcode}}</span><span class="right">{{item.time}}</span></li>
 						</div>
 					</div>
 					<div class="tablebox">
@@ -195,7 +195,7 @@
 							<li><span>鏉$爜鍚嶇О</span><span class="right">鎵爜鏃堕棿</span></li>
 						</div>
 						<div id="barcode2" class="table-body">
-
+							<li v-for="(item,index) in codeList2" :key="index"><span>{{item.barcode}}</span><span class="right">{{item.time}}</span></li>
 						</div>
 					</div>
 				</div>
@@ -340,7 +340,9 @@
 					liftList: [], //鎻愬崌鏈洪泦鍚�
 					systemStatus: true,//绯荤粺杩愯鐘舵��
 					consoleInterval: null,//瀹氭椂鍣ㄥ瓨鍌ㄥ彉閲�
-					codeList: [],//鏉$爜List
+					codeList1: [],//鏉$爜List
+					codeList2: [],//鏉$爜List
+					ws: null,
 				},
 				created() {
 					this.init()
@@ -350,6 +352,12 @@
 				},
 				methods: {
 					init() {
+						this.ws = new WebSocket("ws://" + window.location.host + baseUrl + "/console/websocket");
+						this.ws.onopen = this.webSocketOnOpen
+						this.ws.onerror = this.webSocketOnError
+						this.ws.onmessage = this.webSocketOnMessage
+						this.ws.onclose = this.webSocketClose
+
 						this.getMap(this.currentLev)
 						this.getSystemRunningStatus() //鑾峰彇绯荤粺杩愯鐘舵��
 
@@ -363,22 +371,20 @@
 					},
 					//鑾峰彇鍦板浘鏁版嵁
 					getMap(lev) {
-						$.ajax({
-							type: "get",
-							url: baseUrl + "/console/map/" + lev + "/auth",
-							headers: {
-								'token': localStorage.getItem('token')
-							},
-							success: (res) => {
-								let data = res.data
-								let tmp = []
-								for (let i = 1; i < data.length - 1; i++) {
-									tmp.push(data[i])
-								}
-								// console.log(tmp)
-								this.map = tmp
-							}
-						})
+						this.sendWs(JSON.stringify({
+							"url": "/console/map/auth",
+							"data": lev
+						}))
+					},
+					setMap(res) {
+						//鑾峰彇鍦板浘鏁版嵁
+						let data = res.data
+						let tmp = []
+						for (let i = 1; i < data.length - 1; i++) {
+							tmp.push(data[i])
+						}
+						// console.log(tmp)
+						this.map = tmp
 					},
 					openSite(id) {
 						this.siteWindow = true; //鎵撳紑绔欑偣淇℃伅寮圭獥
@@ -408,29 +414,29 @@
 					},
 					getSiteInfo() {
 						//鑾峰彇杈撻�佺珯鐐规暟鎹�
-						$.ajax({
-							url: baseUrl+ "/console/latest/data/site",
-							headers: {'token': localStorage.getItem('token')},
-							method: 'POST',
-							success: function (res) {
-								if (res.code === 200){
-									var sites = res.data;
-									for (var i = 0; i < sites.length; i++){
-										var siteEl = $("#site-"+sites[i].siteId);
-										siteEl.attr("class", "site " + sites[i].siteStatus);
-										if (sites[i].workNo != null && sites[i].workNo>0) {
-											siteEl.html(sites[i].siteId + "[" + sites[i].workNo + "]");
-										} else {
-											siteEl.html(sites[i].siteId);
-										}
-									}
-								} else if (res.code === 403){
-									parent.location.href = baseUrl+"/login";
-								}  else {
-									console.log(res.msg);
+						this.sendWs(JSON.stringify({
+							"url": "/console/latest/data/site",
+							"data": {}
+						}))
+					},
+					setSiteInfo(res) {
+						//鑾峰彇杈撻�佺珯鐐规暟鎹�
+						if (res.code === 200){
+							var sites = res.data;
+							for (var i = 0; i < sites.length; i++){
+								var siteEl = $("#site-"+sites[i].siteId);
+								siteEl.attr("class", "site " + sites[i].siteStatus);
+								if (sites[i].workNo != null && sites[i].workNo>0) {
+									siteEl.html(sites[i].siteId + "[" + sites[i].workNo + "]");
+								} else {
+									siteEl.html(sites[i].siteId);
 								}
 							}
-						});
+						} else if (res.code === 403){
+							parent.location.href = baseUrl+"/login";
+						}  else {
+							console.log(res.msg);
+						}
 					},
 					changFloor(lev) {
 						this.currentLev = lev
@@ -438,53 +444,47 @@
 						this.getMap(lev)
 					},
 					getShuttleStateInfo() {
+						this.sendWs(JSON.stringify({
+							"url": "/shuttle/table/shuttle/state",
+							"data": {}
+						}))
+					},
+					setShuttleStateInfo(res) {
 						// 鍥涘悜绌挎杞︿俊鎭〃鑾峰彇
 						let that = this
-						$.ajax({
-							url: baseUrl + "/shuttle/table/shuttle/state",
-							headers: {
-								'token': localStorage.getItem('token')
-							},
-							method: 'POST',
-							success: function(res) {
-								if (res.code == 200) {
-									let currentLevShuttle = []//褰撳墠妤煎眰灏忚溅闆嗗悎
-									res.data.forEach((item,idx) => {
-										if (item != null && item.point != undefined && item.point != null) {
-											if (item.point.z == that.currentLev) {
-												currentLevShuttle.push(item);
-											}
-										}
-									})
-									that.currentLevShuttleList = currentLevShuttle
-									that.shuttleList = res.data
-
-									if (that.shuttleColorList.length == 0) {
-										let colorList = []//闅忔満灏忚溅棰滆壊
-										res.data.forEach((item,idx) => {
-											colorList[item.shuttleNo] = that.colorRGB()
-										})
-										that.shuttleColorList = colorList
+						if (res.code == 200) {
+							let currentLevShuttle = []//褰撳墠妤煎眰灏忚溅闆嗗悎
+							res.data.forEach((item,idx) => {
+								if (item != null && item.point != undefined && item.point != null) {
+									if (item.point.z == that.currentLev) {
+										currentLevShuttle.push(item);
 									}
 								}
+							})
+							that.currentLevShuttleList = currentLevShuttle
+							that.shuttleList = res.data
+
+							if (that.shuttleColorList.length == 0) {
+								let colorList = []//闅忔満灏忚溅棰滆壊
+								res.data.forEach((item,idx) => {
+									colorList[item.shuttleNo] = that.colorRGB()
+								})
+								that.shuttleColorList = colorList
 							}
-						});
+						}
 					},
 					getLiftStateInfo() {
 						// 鎻愬崌鏈轰俊鎭〃鑾峰彇
-						let that = this
-						$.ajax({
-							url: baseUrl + "/lift/table/lift/state",
-							headers: {
-								'token': localStorage.getItem('token')
-							},
-							method: 'POST',
-							success: function(res) {
-								if (res.code == 200) {
-									that.liftList = res.data
-								}
-							}
-						});
+						this.sendWs(JSON.stringify({
+							"url": "/lift/table/lift/state",
+							"data": {}
+						}))
+					},
+					setLiftStateInfo(res) {
+						// 鎻愬崌鏈轰俊鎭〃鑾峰彇
+						if (res.code == 200) {
+							this.liftList = res.data
+						}
 					},
 					systemSwitch() {
 						// 绯荤粺寮�鍏�
@@ -648,7 +648,7 @@
 						//閲嶇疆鍦板浘
 						let that = this
 						$.ajax({
-							url:baseUrl+"/console/map/resetMap/auth",
+							url:baseUrl+"/console/map/resetMap/" + this.currentLev,
 							headers:{
 								'token': localStorage.getItem('token')
 							},
@@ -656,24 +656,56 @@
 							method:'get',
 							success:function (res) {
 								that.$message({
-									message: '閲嶇疆瀹屾垚',
+									message: that.currentLev + '灞傚湴鍥鹃噸缃畬鎴�',
 									type: 'success'
 								});
 							}
 						})
 					},
 					getCodeData(){
-						let that = this
-						$.ajax({
-							url:baseUrl +'/console/barcode/output/site',
-							method:'GET',
-							success:function (res) {
-								if(res.code === 200){
-									let data = JSON.parse(res.data)
-									that.codeList = data
-								}
+						this.sendWs(JSON.stringify({
+							"url": "/console/barcode/output/site",
+							"data": {}
+						}))
+					},
+					setCodeData(res) {
+						if(res.code === 200){
+							let data = JSON.parse(res.data)
+							if (data.length <= 5) {
+								this.codeList1 = data;
+							} else {
+								this.codeList1 = data.slice(0, 5);
+								this.codeList2 = data.splice(5, 10);
 							}
-						})
+						}
+					},
+					webSocketOnOpen(e) {
+						console.log("open");
+					},
+					webSocketOnError(e) {
+						console.log(e);
+					},
+					webSocketOnMessage(e) {
+						const result = JSON.parse(e.data);
+						if (result.url == "/shuttle/table/shuttle/state") {
+							this.setShuttleStateInfo(JSON.parse(result.data))
+						}else if (result.url == "/lift/table/lift/state") {
+							this.setLiftStateInfo(JSON.parse(result.data))
+						}else if (result.url == "/console/latest/data/site") {
+							this.setSiteInfo(JSON.parse(result.data))
+						}else if (result.url == "/console/map/auth") {
+							this.setMap(JSON.parse(result.data))
+						}else if (result.url == "/console/barcode/output/site") {
+							this.setCodeData(JSON.parse(result.data))
+						}
+					},
+					webSocketClose(e) {
+						console.log("close");
+					},
+					sendWs(message) {
+						if (this.ws.readyState == WebSocket.OPEN) {
+							this.ws.send(message)
+						}
 					}
 				}
 			})

--
Gitblit v1.9.1