From 195b15baf2d6d7cfdb0d928586602f8760863e04 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期二, 02 十二月 2025 15:48:11 +0800
Subject: [PATCH] #
---
src/main/webapp/views/watch/console2.html | 274 ++++++++++++++++++++----------------------------------
1 files changed, 104 insertions(+), 170 deletions(-)
diff --git a/src/main/webapp/views/watch/console2.html b/src/main/webapp/views/watch/console2.html
index e64714e..50082dd 100644
--- a/src/main/webapp/views/watch/console2.html
+++ b/src/main/webapp/views/watch/console2.html
@@ -86,6 +86,7 @@
let pixiCrnMap = new Map();
let pixiShelfMap = new Map();
let pixiTrackMap = new Map();
+ let pixiDevpTextureMap = new Map();
let crnList = [];
let objectsContainer;
let objectsContainer2;
@@ -101,15 +102,12 @@
map: [],
currentLev: 1,
floorList: [], //褰撳墠椤圭洰妤煎眰
- currentLevShuttleList: [],//褰撳墠妤煎眰鍥涘悜绌挎杞﹂泦鍚�
- shuttleColorList: [],//鍥涘悜绌挎杞﹂鑹查泦鍚�
drawer: false,
drawerLocNo: false,
drawerLocNoData: null,
drawerLocDetls: [],
mapFps: 0,
currentLevStaList: [],//褰撳墠妤煎眰绔欑偣list
- reloadSta: true,
drawerSta: false,
drawerStaData: null,
},
@@ -151,6 +149,7 @@
this.consoleInterval = setInterval(() => {
this.getCrnInfo() //鑾峰彇鍫嗗灈鏈烘暟鎹�
+ this.getSiteInfo() //鑾峰彇杈撻�佺珯鐐规暟鎹�
}, 1000)
},
@@ -198,7 +197,6 @@
changeFloor(lev) {
this.currentLev = lev
this.currentLevShuttleList = []
- this.reloadSta = true
this.getMap(lev)
//娓呯┖棰勮璺緞
@@ -288,29 +286,16 @@
pixiApp.view.addEventListener('wheel', (event) => {
event.stopPropagation();
event.preventDefault();
- // 鍥犱负鐢诲竷鏄厖婊¤绐楃殑锛屾墍浠lientX绛変簬mouse point鍦╮enderer涓婄殑x鍧愭爣
- const globalPos = [event.clientX, event.clientY];
- const delta = event.deltaY;
+ const sx = event.clientX;
+ const sy = event.clientY;
const oldZoom = pixiApp.stage.scale.x;
+ const delta = event.deltaY;
let newZoom = oldZoom * 0.999 ** delta;
-
- // const oldStageMatrix = app.stage.localTransform.clone();
- // const oldStagePos = oldStageMatrix.applyInverse(pointerGlobalPos);
- const oldStagePos = globalPos;
- const dx = oldStagePos[0] * oldZoom - oldStagePos[0] * newZoom;
- const dy = oldStagePos[1] * oldZoom - oldStagePos[1] * newZoom;
-
- pixiApp.stage.setTransform(
- pixiApp.stage.position.x + dx,
- pixiApp.stage.position.y + dy,
- newZoom,
- newZoom,
- 0,
- 0,
- 0,
- 0,
- 0
- );
+ const worldX = (sx - pixiApp.stage.position.x) / oldZoom;
+ const worldY = (sy - pixiApp.stage.position.y) / oldZoom;
+ const newPosX = sx - worldX * newZoom;
+ const newPosY = sy - worldY * newZoom;
+ pixiApp.stage.setTransform(newPosX, newPosY, newZoom, newZoom, 0, 0, 0, 0, 0);
});
//*******************缂╂斁鐢诲竷*******************
@@ -497,10 +482,21 @@
})
- //瑙嗚灞呬腑
- let containerWidth = (pixiApp.view.width - objectsContainer.width) / 2;
- let containerHeight = (pixiApp.view.height - objectsContainer.height) / 2;
- pixiApp.stage.position.set(containerWidth, containerHeight);
+ const b1 = objectsContainer.getLocalBounds();
+ const b2 = objectsContainer2.getLocalBounds();
+ const minX = Math.min(b1.x, b2.x);
+ const minY = Math.min(b1.y, b2.y);
+ const maxX = Math.max(b1.x + b1.width, b2.x + b2.width);
+ const maxY = Math.max(b1.y + b1.height, b2.y + b2.height);
+ const contentW = Math.max(0, maxX - minX);
+ const contentH = Math.max(0, maxY - minY);
+ const vw = pixiApp.view.width;
+ const vh = pixiApp.view.height;
+ let scale = Math.min(vw / contentW, vh / contentH) * 0.95;
+ if (!isFinite(scale) || scale <= 0) { scale = 1; }
+ const posX = (vw - contentW * scale) / 2 - minX * scale;
+ const posY = (vh - contentH * scale) / 2 - minY * scale;
+ pixiApp.stage.setTransform(posX, posY, scale, scale, 0, 0, 0, 0, 0);
this.map = map;
},
@@ -549,34 +545,6 @@
locSts: this.map[x][y].locSts, row: this.map[x][y].row, bay: this.map[x][y].bay, lev: this.currentLev
};
},
- checkStaInListDiff(sta, list) {
- //妫�娴嬬珯鐐规槸鍚﹀湪闆嗗悎涓湁鍙樺姩
- if (list.length == 0) {
- return false;//闆嗗悎涓虹┖
- }
-
- let tmp = null;
- for (var i = 0; i < list.length; i++) {
- if (sta.siteId == list[i].siteId) {
- tmp = list[i];//鎵惧埌鐩稿悓绔欑偣
- break
- }
- }
-
- if (tmp == null) {
- return false;//娌℃湁鎵惧埌鐩稿悓绔欑偣
- }
-
- if (sta.siteStatus != tmp.siteStatus) {
- return false;//绔欑偣鐘舵�佷笉鐩稿悓
- }
-
- if (sta.workNo != tmp.workNo) {
- return false;//绔欑偣宸ヤ綔鍙蜂笉鐩稿悓
- }
-
- return true;//鏃犲彉鍖�
- },
webSocketOnOpen(e) {
console.log("open");
},
@@ -607,118 +575,49 @@
ws.send(message)
}
},
- colorRGB() {
- //闅忔満棰滆壊
- const r = Math.floor(Math.random() * 256);
- const g = Math.floor(Math.random() * 256);
- const b = Math.floor(Math.random() * 256);
- return `rgb(${r},${g},${b})`;
- },
- updateShuttleXY(item) {
- const shuttle = pixiShuttleMap.get(item.shuttleNo);
- if (shuttle.updateMoveStatus) {//鍔ㄧ敾鎵ц瀹屾垚鎵嶅彲缁х画鎵ц鍔ㄧ敾
- shuttle.updateMoveStatus = false;//鍔ㄧ敾鎵ц涓�
- // 璁$畻涓ょ偣涔嬮棿鐨勮窛绂�1
- const distance = Math.sqrt(Math.pow((item.wcsPoint.x * width) - shuttle.x, 2) + Math.pow((item.wcsPoint.y * height) - shuttle.y, 2));
- gsap.killTweensOf(shuttle); // 鏉�姝绘墍鏈夐拡瀵�".class"鐨勫姩鐢�
- gsap.to(shuttle, {
- x: (item.wcsPoint.y - 0) * width, // 鐩爣浣嶇疆
- y: (item.wcsPoint.x - 1) * height, // 鐩爣浣嶇疆
- duration: 0.2, // 鍔ㄧ敾鎸佺画鏃堕棿锛堢锛�
- ease: "power1.inOut", // 缂撳姩绫诲瀷
- onComplete: () => {
- shuttle.updateMoveStatus = true;//鍔ㄧ敾鎵ц瀹屾垚
- }
- });
- }
- },
- getSiteInfo() {
- //鑾峰彇杈撻�佺珯鐐规暟鎹�
- this.sendWs(JSON.stringify({
- "url": "/console/latest/data/site",
- "data": {}
- }))
- },
setSiteInfo(res) {
- // var test = "{\"msg\":\"鎿嶄綔鎴愬姛\",\"code\":200,\"data\":[{\"siteId\":\"300\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"301\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"302\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"303\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"304\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"305\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"306\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"307\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"308\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"309\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"310\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"311\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"312\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"313\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"314\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"315\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"316\",\"siteStatus\":\"site-auto-run\",\"workNo\":0},{\"siteId\":\"317\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"318\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"319\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"320\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"321\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"322\",\"siteStatus\":\"site-auto-run\",\"workNo\":0},{\"siteId\":\"323\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"324\",\"siteStatus\":\"site-auto-run\",\"workNo\":0},{\"siteId\":\"325\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"326\",\"siteStatus\":\"site-auto-id\",\"workNo\":5451},{\"siteId\":\"327\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"200\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"328\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"201\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"329\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"202\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"330\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"203\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"331\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"204\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"332\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"205\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"333\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"334\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"335\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"336\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"337\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"338\",\"siteStatus\":\"site-auto-run\",\"workNo\":0},{\"siteId\":\"339\",\"siteStatus\":\"site-auto-run-id\",\"workNo\":5447},{\"siteId\":\"340\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"341\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"342\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"343\",\"siteStatus\":\"site-auto-run\",\"workNo\":0},{\"siteId\":\"344\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"345\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"346\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"100\",\"siteStatus\":\"site-auto-run-id\",\"workNo\":8851},{\"siteId\":\"101\",\"siteStatus\":\"site-auto-run-id\",\"workNo\":8855},{\"siteId\":\"102\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"103\",\"siteStatus\":\"site-auto\",\"workNo\":0},{\"siteId\":\"104\",\"siteStatus\":\"site-auto-run\",\"workNo\":0},{\"siteId\":\"105\",\"siteStatus\":\"site-auto\",\"workNo\":0}]}";
- // res = JSON.parse(test)
- //鑾峰彇杈撻�佺珯鐐规暟鎹�
- if (res.code === 200) {
- var sites = res.data;
- if (this.reloadSta && pixiStaMap.size > 0) {
- //閲嶆柊娓叉煋鎵�鏈夎緭閫佺珯鐐�
- this.currentLevStaList = sites;
- this.reloadSta = false;
- sites.forEach((item, index) => {
- let sta = pixiStaMap.get(parseInt(item.siteId));
- if (sta != undefined) {
- if (item.workNo > 0) {
- sta.textObj.text = item.siteId + "(" + item.workNo + ")";
- }
-
- //鍒涘缓閬僵灞�
- if (item.siteStatus == "site-auto") {
- //鑷姩鐘舵�侊紝绉婚櫎閬僵灞�
- if (sta.statusObj != null) {
- objectsContainer.removeChild(sta.statusObj)
- sta.statusObj = null;
- }
- } else if (item.siteStatus == "site-auto-run" || item.siteStatus == "site-auto-run-id") {
- //鑷姩鏈夌墿
- let graphics = getGraphics(0xfa51f6, width, height, sta.x, sta.y);
- graphics.addChild(sta.textObj);//缁ф壙鏂囧瓧淇℃伅
- sta.statusObj = graphics;
- objectsContainer.addChild(graphics);
- } else if (item.siteStatus == "site-unauto") {
- //闈炶嚜鍔�
- let graphics = getGraphics(0xb8b8b8, width, height, sta.x, sta.y);
- graphics.addChild(sta.textObj);//缁ф壙鏂囧瓧淇℃伅
- sta.statusObj = graphics;
- objectsContainer.addChild(graphics);
- }
- }
- });
- } else {
- //妫�娴嬩笉鐩稿悓绔欑偣杩涜灞�閮ㄦ洿鏂�
- this.currentLevStaList.forEach((item, index) => {
- let result = this.checkStaInListDiff(item, sites);
- if (!result) {
- //闇�瑕佹洿鏂�
- let sta = pixiStaMap.get(parseInt(item.siteId));
- if (item.workNo > 0) {
- sta.textObj.text = item.siteId + "(" + item.workNo + ")";
- } else {
- sta.textObj.text = item.siteId;
- }
-
- //鍒涘缓閬僵灞�
- if (item.siteStatus == "site-auto") {
- //鑷姩鐘舵�侊紝绉婚櫎閬僵灞�
- if (sta.statusObj != null) {
- objectsContainer.removeChild(sta.statusObj)
- sta.statusObj = null;
- }
- } else if (item.siteStatus == "site-auto-run") {
- //鑷姩鏈夌墿
- let graphics = getGraphics(0xfa51f6, width, height, sta.x, sta.y);
- graphics.addChild(sta.textObj);//缁ф壙鏂囧瓧淇℃伅
- sta.statusObj = graphics;
- objectsContainer.addChild(graphics);
- } else if (item.siteStatus == "site-unauto") {
- //闈炶嚜鍔�
- let graphics = getGraphics(0xb8b8b8, width, height, sta.x, sta.y);
- graphics.addChild(sta.textObj);//缁ф壙鏂囧瓧淇℃伅
- sta.statusObj = graphics;
- objectsContainer.addChild(graphics);
- }
- }
- });
- }
- } else if (res.code === 403) {
- parent.location.href = baseUrl + "/login";
- } else {
- console.log(res.msg);
+ let sites = Array.isArray(res) ? res : (res && res.code === 200 ? res.data : null);
+ if (res && !Array.isArray(res)) {
+ if (res.code === 403) { parent.location.href = baseUrl + "/login"; return; }
+ if (res.code !== 200) { console.log(res.msg); return; }
}
+ if (!sites) { return; }
+ this.currentLevStaList = sites;
+ sites.forEach((item) => {
+ let id = item.siteId != null ? item.siteId : item.stationId;
+ let status = item.siteStatus != null ? item.siteStatus : item.stationStatus;
+ let workNo = item.workNo != null ? item.workNo : item.taskNo;
+ if (id == null) { return; }
+ let sta = pixiStaMap.get(parseInt(id));
+ if (sta == undefined) { return; }
+ if (workNo != null && workNo > 0) {
+ sta.textObj.text = id + "(" + workNo + ")";
+ } else {
+ sta.textObj.text = String(id);
+ }
+ if (sta.statusObj) {
+ objectsContainer.removeChild(sta.statusObj);
+ sta.statusObj = null;
+ if (sta.textObj.parent !== sta) {
+ sta.addChild(sta.textObj);
+ sta.textObj.position.set(sta.width / 2, sta.height / 2);
+ }
+ }
+
+ if (status === "site-auto") {
+ updateColor(sta, 0x78ff81);
+ } else if (status === "site-auto-run" || status === "site-auto-run-id") {
+ updateColor(sta, 0xfa51f6);
+ } else if (status === "site-unauto") {
+ updateColor(sta, 0xb8b8b8);
+ } else if (status === "machine-pakin") {
+ updateColor(sta, 0x30bffc);
+ } else if (status === "machine-pakout") {
+ updateColor(sta, 0x97b400);
+ } else {
+ updateColor(sta, 0xb8b8b8);
+ }
+ });
},
openDrawerSta(data) {
let that = this
@@ -819,6 +718,17 @@
} else {
console.log(res.msg);
}
+ }
+ });
+ },
+ getSiteInfo() {
+ let that = this;
+ $.ajax({
+ url: baseUrl + "/console/latest/data/station",
+ headers: {'token': localStorage.getItem('token')},
+ method: 'POST',
+ success: function (res) {
+ that.setSiteInfo(res);
}
});
},
@@ -967,6 +877,17 @@
return rt;
}
+ function createDevpTextureColoredRect(width, height, color) {
+ const g = new PIXI.Graphics();
+ g.beginFill(color);
+ g.lineStyle(1, 0xffffff, 1);
+ g.drawRect(0, 0, width, height);
+ g.endFill();
+ const rt = PIXI.RenderTexture.create({ width: width, height: height });
+ pixiApp.renderer.render(g, rt);
+ return rt;
+ }
+
function updateCrnTextureColor(sprite, color) {
const tex = createCrnTextureColoredDevice(sprite.width, sprite.height, color);
sprite.texture = tex;
@@ -1000,6 +921,7 @@
const graphics = getContainer('devp', item.width, item.height);
const texture = pixiApp.renderer.generateTexture(graphics);
sprite = new PIXI.Sprite(texture);
+ sprite._kind = 'devp';
let siteId = getStationId(value);
if (siteId === -1) {
siteId = item.data;
@@ -1039,9 +961,21 @@
* 鏇存柊棰滆壊
*/
function updateColor(sprite, color) {
- // graphics.clear()
- // graphics.beginFill(color);
- // graphics.drawRect(0, 0, width, height);
+ if (sprite && sprite._kind === 'devp') {
+ const key = sprite.width + '-' + sprite.height + '-' + color;
+ let texture = pixiDevpTextureMap.get(key);
+ if (!texture) {
+ texture = createDevpTextureColoredRect(Math.round(sprite.width), Math.round(sprite.height), color);
+ pixiDevpTextureMap.set(key, texture);
+ }
+ const textObj = sprite.textObj;
+ sprite.texture = texture;
+ if (textObj) {
+ if (textObj.parent !== sprite) { sprite.addChild(textObj); }
+ textObj.position.set(sprite.width / 2, sprite.height / 2);
+ }
+ return;
+ }
sprite.tint = color;
}
--
Gitblit v1.9.1