#
Junjie
2025-11-21 7f9435bb4a074b4964f290c4d6905e0e233a19ec
src/main/webapp/views/watch/console.html
@@ -21,14 +21,25 @@
                  <el-tab-pane label="堆垛机" name="crn">
                     <watch-crn-card :param="crnParam"></watch-crn-card>
                  </el-tab-pane>
                  <el-tab-pane label="输送线" name="devp">输送线</el-tab-pane>
                  <el-tab-pane label="RGV" name="rgv">RGV</el-tab-pane>
                  <el-tab-pane label="输送站" name="devp">
                     <devp-card :param="devpParam"></devp-card>
                  </el-tab-pane>
                  <el-tab-pane label="RGV" name="rgv">
                     <watch-rgv-card :param="rgvParam"></watch-rgv-card>
                  </el-tab-pane>
                  <el-tab-pane label="地图配置" name="mapSetting">
                     <map-setting-card :param="mapSettingParam"></map-setting-card>
                  </el-tab-pane>
               </el-tabs>
            </div>
            <div id="mapDataId" style="position: relative;" :style="{zoom: mapSettingParam.zoom / 100}">
            <div style="position: absolute;top: 15px;left: 50%;display: flex;">
               <div v-if="levList.length > 1" v-for="(lev,index) in levList" :key="index" style="margin-right: 10px;">
                  <el-button :type="currentLev == lev ? 'primary' : ''" @click="switchLev(lev)" size="mini">{{ lev }}F</el-button>
               </div>
            </div>
            <div id="mapDataId" style="position: relative;margin-top: 50px;" :style="{zoom: mapSettingParam.zoom / 100}">
               <table class="excel-table">
                  <tr v-for="(row,index) in map" :key="index">
                     <td
@@ -45,7 +56,7 @@
                           <div class="shelf">{{col.shelfIdx}}</div>
                        </div>
                        <div v-else-if="col.type == 'devp'">
                           <div class="site" :style="{height: col.rowPx}" :id="'site-' + col.value" @click="openSite(col.value)">{{col.value}}</div>
                           <div class="site" :style="{height: col.rowPx}" :id="'site-' + getStationId(col.value)" @click="openSite(getStationId(col.value))">{{getStationId(col.value)}}</div>
                        </div>
                        <div v-else-if="col.type == 'rgv'" style="position: relative;">
                           <div class="rgv-item" v-if="getDeviceNo(col.value) != -1" :style="{width: col.width}" :id="'rgv-' + getDeviceNo(col.value)" @click="openRgv(getDeviceNo(col.value))">{{getDeviceNo(col.value)}}</div>
@@ -59,10 +70,6 @@
                        </div>
                     </td>
<!--                     <td>-->
<!--                        &lt;!&ndash; 显示行号 &ndash;&gt;-->
<!--                        <div class="item" style="background: none;color: #000;">#{{index+1}}</div>-->
<!--                     </td>-->
                  </tr>
               </table>
            </div>
@@ -71,13 +78,16 @@
      </div>
      <script src="../../components/WatchCrnCard.js"></script>
      <script src="../../components/DevpCard.js"></script>
      <script src="../../components/MapSettingCard.js"></script>
      <script src="../../components/WatchRgvCard.js"></script>
      <script>
         var app = new Vue({
            el: '#app',
            data: {
               map: [],//地图数据
               crnList: [], //堆垛机集合
               levList: [],
               currentLev: 1,
               systemStatus: true,//系统运行状态
               consoleInterval: null,//定时器存储变量
               crnInitPosition: [],
@@ -88,6 +98,12 @@
               },
               mapSettingParam: {
                  zoom: 70
               },
               devpParam: {
                  stationId: 0
               },
               rgvParam: {
                  rgvNo: 0
               }
            },
            created() {
@@ -100,20 +116,39 @@
               init() {
                  this.getMap()
                  this.getSystemRunningStatus() //获取系统运行状态
                  this.getLevList() //获取地图层级列表
                  // this.consoleInterval = setInterval(() => {
                  //    this.getCrnInfo() //获取堆垛机数据
                  //    this.getSiteInfo() //获取输送站点数据
                  //    this.getRgvInfo() //获取RGV数据
                  // }, 1000)
                  this.consoleInterval = setInterval(() => {
                     this.getCrnInfo() //获取堆垛机数据
                     this.getSiteInfo() //获取输送站点数据
                     this.getRgvInfo() //获取RGV数据
                  }, 1000)
               },
               getLevList() {
                  let that = this;
                  $.ajax({
                     url: baseUrl + "/basMap/getLevList",
                     headers: {
                        'token': localStorage.getItem('token')
                     },
                     method: "get",
                     success: (res) => {
                        let data = res.data;
                        that.levList = data;
                     }
                  })
               },
               //获取地图数据
               getMap() {
                  let that = this
                  let rowPx = 35;
                  let colPx = 35;
                  $.ajax({
                     url: "./test.json",
                     url: baseUrl + "/basMap/lev/" + this.currentLev + "/auth",
                     headers: {
                        'token': localStorage.getItem('token')
                     },
                     method: "get",
                     success: (res) => {
                        let data = res.data;
@@ -132,81 +167,42 @@
                              col.width = (col.cellWidth / 30) + "px";
                           })
                        })
                        this.map = mapData;
                        that.map = mapData;
                     }
                  })
               },
               switchLev(lev) {
                  this.currentLev = lev;
                  this.getMap()
               },
               openCrn(id) {
                  this.crnParam.crnNo = id;
                  this.activateCard = 'crn';
               },
               openRgv(id) {
                  this.rgvWindow = true; //打开RGV信息弹窗
                  $(".detailed").empty();
                  $('.detailed').append(id + '号RGV');
                  $.ajax({
                     url: baseUrl + "/console/rgv/detail",
                     headers: {
                        'token': localStorage.getItem('token')
                     },
                     data: {
                        rgvNo: id
                     },
                     method: 'post',
                     success: function(res) {
                        for (var val in res.data) {
                           var find = $("#rgvWindow").find(":input[name='" + val + "']");
                           if (find[0].type === 'text') {
                              find.val(res.data[val]);
                           } else if (find[0].type === 'checkbox') {
                              find.attr("checked", res.data[val] === 'Y');
                           }
                        }
                     }
                  })
                  this.rgvParam.rgvNo = id;
                  this.activateCard = 'rgv';
               },
               openSite(id) {
                  this.siteWindow = true; //打开站点信息弹窗
                  $(".detailed").empty();
                  $('.detailed').append(id + '站点详细信息');
                  $.ajax({
                     url: baseUrl + "/console/site/detail",
                     headers: {
                        'token': localStorage.getItem('token')
                     },
                     data: {
                        siteId: id
                     },
                     method: 'post',
                     success: function(res) {
                        for (var val in res.data) {
                           var find = $("#siteWindow").find(":input[name='" + val + "']");
                           if (find[0].type === 'text') {
                              find.val(res.data[val]);
                           } else if (find[0].type === 'checkbox') {
                              find.attr("checked", res.data[val] === 'Y');
                           }
                        }
                     }
                  })
                  this.devpParam.stationId = id;
                  this.activateCard = 'devp';
               },
               getSiteInfo() {
                  //获取输送站点数据
                  $.ajax({
                     url: baseUrl + "/console/latest/data/site",
                     url: baseUrl + "/console/latest/data/station",
                     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 + "]");
                              var siteEl = $("#site-"+sites[i].stationId);
                              siteEl.attr("class", "site " + sites[i].stationStatus);
                              if (sites[i].taskNo != null && sites[i].taskNo>0) {
                                 siteEl.html(sites[i].stationId + "[" + sites[i].taskNo + "]");
                              } else {
                                 siteEl.html(sites[i].siteId);
                                 siteEl.html(sites[i].stationId);
                              }
                           }
                        } else if (res.code === 403) {
@@ -232,6 +228,9 @@
                              let position = []
                              for (var i = 0; i < crns.length; i++) {
                                 var crnEl = $("#crn-" + crns[i].crnId);
                                 if(crnEl.offset() == undefined) {
                                    continue;
                                 }
                                 position.push({
                                    id: crns[i].crnId,
                                    left: crnEl.offset().left + crnEl.width()
@@ -269,8 +268,6 @@
                                 crnStatus: crns[i].crnStatus
                              })
                           }
                           that.crnList = crnList;
                        } else if (res.code === 403) {
                           parent.location.href = baseUrl + "/login";
                        } else {
@@ -293,9 +290,12 @@
                           if (that.rgvPosition.length == 0) {
                              let position = []
                              for (var i = 0; i < rgvs.length; i++) {
                                 var rgvEl = $("#rgv-" + rgvs[i].rgvId);
                                 var rgvEl = $("#rgv-" + rgvs[i].rgvNo);
                                 if(rgvEl.offset() == undefined) {
                                    continue;
                                 }
                                 position.push({
                                    id: rgvs[i].rgvId,
                                    id: rgvs[i].rgvNo,
                                    trackSiteNo: rgvs[i].trackSiteNo,
                                    initLeft: rgvEl.offset().left
                                 })
@@ -305,48 +305,31 @@
                           }
                           for (var i = 0; i < rgvs.length; i++) {
                              var rgvEl = $("#rgv-" + rgvs[i].rgvId);
                              if (rgvs[i].rgvStatus == 'IDLE') {
                              var rgvEl = $("#rgv-" + rgvs[i].rgvNo);
                              if (rgvs[i].rgvStatus == 'idle') {
                                 rgvEl.attr("class", "rgv-item");
                              }else if (rgvs[i].rgvStatus == 'WORKING') {
                              }else if (rgvs[i].rgvStatus == 'working') {
                                 rgvEl.attr("class", "rgv-item machine-working");
                              }else if (rgvs[i].rgvStatus == 'waiting') {
                                 rgvEl.attr("class", "rgv-item machine-working");
                              }else {
                                 rgvEl.attr("class", "rgv-item machine-un-auto");
                              }
                              let trackSiteNo = rgvs[i].trackSiteNo;
                              let trackSiteEl = $("#rgvTrackSiteNo-" + trackSiteNo);
                              let flag = false;
                              that.rgvPosition.forEach((item) => {
                                 if (item.id == rgvs[i].rgvId) {
                                    if (item.trackSiteNo != trackSiteNo) {
                                       flag = true
                                    }
                                 }
                              })
                              if (flag) {
                                 let finalOffset = 0;
                                 let targetPosition = trackSiteEl.parent().parent().position().left;
                                 let rgvPosition = rgvEl.position().left;
                                 let calcResult = targetPosition - rgvPosition
                                 if (calcResult > 0) {
                                    finalOffset = targetPosition + trackSiteEl.width();
                                 }else {
                                    finalOffset = targetPosition;
                                 }
                                 rgvEl.animate({left: finalOffset + "px"}, 500);
                                 let position = []
                                 that.rgvPosition.forEach((item) => {
                                    if (item.id == rgvs[i].rgvId) {
                                       item.trackSiteNo = trackSiteNo
                                    }
                                    position.push(item)
                                 })
                                 that.rgvPosition = position
                              if(rgvEl.offsetParent().offset() == undefined) {
                                 continue;
                              }
                              let parentLeft = rgvEl.offsetParent().offset().left;
                              let targetPosition = trackSiteEl.parent().parent().offset().left - parentLeft;
                              let rgvPosition = rgvEl.position().left;
                              let zoomFactor = that.mapSettingParam.zoom ? (that.mapSettingParam.zoom / 100) : 1;
                              if (zoomFactor <= 0) { zoomFactor = 1; }
                              let finalOffset = targetPosition / zoomFactor;
                              rgvEl.animate({left: finalOffset + "px"}, 500);
                           }
                        } else if (res.code === 403) {
                           parent.location.href = baseUrl + "/login";
@@ -454,6 +437,17 @@
                     return -1;
                  }
               },
               getStationId(obj) {
                  if (this.isJson(obj)) {
                     let data = JSON.parse(obj)
                     if (data.stationId == null || data.stationId == undefined) {
                        return -1;
                     }
                     return data.stationId;
                  }else {
                     return -1;
                  }
               },
               getTrackSiteNo(obj) {
                  if (this.isJson(obj)) {
                     let data = JSON.parse(obj)