From 20a4348ffdb9a933c3473bae257567620aea2cd1 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期二, 02 十二月 2025 09:26:31 +0800
Subject: [PATCH] #

---
 src/main/webapp/views/watch/console2.html |   89 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 78 insertions(+), 11 deletions(-)

diff --git a/src/main/webapp/views/watch/console2.html b/src/main/webapp/views/watch/console2.html
index deea72b..9ae1c46 100644
--- a/src/main/webapp/views/watch/console2.html
+++ b/src/main/webapp/views/watch/console2.html
@@ -105,6 +105,7 @@
     let pixiShuttleMoveAdvancePathMap = new Map();
     let pixiShuttleMoveAdvancePathList = [];
     let pixiStaMap = new Map();
+    let pixiCrnMap = new Map();
     let objectsContainer;
     let objectsContainer2;
     let graphicsShelf;
@@ -252,7 +253,7 @@
           // 浠嶨raphics瀵硅薄鍒涘缓涓�涓汗鐞�
           graphicsShelf = pixiApp.renderer.generateTexture(getContainer('shelf'));
           graphicsDevp = pixiApp.renderer.generateTexture(getContainer('devp'));
-          graphicsCrn = pixiApp.renderer.generateTexture(getContainer('crn'));
+          graphicsCrn = createCrnTexture();
           graphicsCrnTrack = createTrackTexture();
 
           // 鍒涘缓涓�涓鍣ㄦ潵绠$悊澶ф壒閲忕殑鏄剧ず瀵硅薄
@@ -262,6 +263,12 @@
           // 鍒涘缓涓�涓鍣ㄦ潵绠$悊澶ф壒閲忕殑鏄剧ず瀵硅薄
           objectsContainer2 = new PIXI.Container();
           pixiApp.stage.addChild(objectsContainer2);
+
+          pixiApp.stage.sortableChildren = true;
+          objectsContainer.sortableChildren = true;
+          objectsContainer2.sortableChildren = true;
+          objectsContainer.zIndex = 10;
+          objectsContainer2.zIndex = 20;
 
           //*******************鎷栧姩鐢诲竷*******************
           let stageOriginalPos;
@@ -874,6 +881,44 @@
       return rt;
     }
 
+    function createCrnTexture() {
+      const g = new PIXI.Graphics();
+      const yTop = Math.round(height * 0.1);
+      let deviceWidth  = width * 2;
+
+      g.beginFill(0x999999);
+      g.drawRect(2, yTop, 3, height - yTop - 2);
+      g.drawRect(deviceWidth - 5, yTop, 3, height - yTop - 2);
+      g.endFill();
+      g.beginFill(0x999999);
+      g.drawRect(0, yTop, deviceWidth, 3);
+      g.endFill();
+      const cabW = Math.round(deviceWidth * 0.68);
+      const cabH = Math.round(height * 0.38);
+      const cabX = Math.round((deviceWidth - cabW) / 2);
+      const cabY = Math.round(height * 0.52 - cabH / 2);
+      g.beginFill(0x245a9a);
+      g.drawRect(cabX, cabY, cabW, cabH);
+      g.endFill();
+      const winW = Math.round(cabW * 0.6);
+      const winH = Math.round(cabH * 0.45);
+      const winX = cabX + Math.round((cabW - winW) / 2);
+      const winY = cabY + Math.round((cabH - winH) / 2);
+      g.beginFill(0xd0e8ff);
+      g.drawRect(winX, winY, winW, winH);
+      g.endFill();
+      const forkW = Math.round(deviceWidth * 0.8);
+      const forkH = Math.max(2, Math.round(height * 0.08));
+      const forkX = Math.round((deviceWidth - forkW) / 2);
+      const forkY = cabY + cabH;
+      g.beginFill(0x666666);
+      g.drawRect(forkX, forkY, forkW, forkH);
+      g.endFill();
+      const rt = PIXI.RenderTexture.create({ width: deviceWidth, height: height });
+      pixiApp.renderer.render(g, rt);
+      return rt;
+    }
+
     function getContainerWithSize(value, w, h) {
       let graphics = new PIXI.Graphics();
       if (value === 0) {
@@ -923,11 +968,21 @@
       } else if (item.type == 'crn') {
         if (getDeviceNo(value) == -1) {
           sprite = new PIXI.Sprite(graphicsCrnTrack);
+          sprite.zIndex = 0;
         } else {
           sprite = new PIXI.Sprite(graphicsCrn);
+          const deviceNo = getDeviceNo(value);
+          const taskNo = getTaskNo(value);
+          const style = new PIXI.TextStyle({ fontFamily: 'Arial', fontSize: 12, fill: '#ffffff', stroke: '#000000', strokeThickness: 2 });
+          const txt = taskNo > 0 ? (deviceNo + "(" + taskNo + ")") : String(deviceNo);
+          const text = new PIXI.Text(txt, style);
+          text.anchor.set(0.5);
+          text.position.set(sprite.width / 2, sprite.height / 2);
+          sprite.addChild(text);
+          sprite.textObj = text;
+          pixiCrnMap.set(parseInt(deviceNo), sprite);
+          sprite.zIndex = 1;
         }
-      } else if (item.type == 'crnTrack') {
-        sprite = new PIXI.Sprite(graphicsCrnTrack);
       } else {
         return null;
       }
@@ -985,17 +1040,29 @@
       }
     }
 
-    function getDeviceNo(obj) {
-      if (this.isJson(obj)) {
-        let data = JSON.parse(obj)
-        if (data.deviceNo == null || data.deviceNo == undefined) {
-          return -1;
-        }
-        return data.deviceNo;
-      } else {
+  function getDeviceNo(obj) {
+    if (this.isJson(obj)) {
+      let data = JSON.parse(obj)
+      if (data.deviceNo == null || data.deviceNo == undefined) {
         return -1;
       }
+      return data.deviceNo;
+    } else {
+      return -1;
     }
+  }
+
+  function getTaskNo(obj) {
+    if (this.isJson(obj)) {
+      let data = JSON.parse(obj)
+      if (data.taskNo == null || data.taskNo == undefined) {
+        return -1;
+      }
+      return data.taskNo;
+    } else {
+      return -1;
+    }
+  }
 
     function getStationId(obj) {
       if (this.isJson(obj)) {

--
Gitblit v1.9.1