#
Junjie
5 天以前 4538940441646916ac577b7cc251f1e0593accc5
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)
          //清空预计路径
@@ -630,93 +628,51 @@
            });
          }
        },
        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);
              }
            }
            console.log(status);
            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
@@ -817,6 +773,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);
            }
          });
        },
@@ -965,6 +932,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;
@@ -998,6 +976,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;
@@ -1037,9 +1016,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;
    }