<template>
  <div
      :style="{ width: `${style.width}px`, height: `${style.height}px`, transform: `${style.transform}` }"
      class="container">
      <div class="flex-box-top">
        <div
          class="item-box"
          v-for="(item, index) in topLabelList"
          :key="index">
          <div class="item-box-icon" :style="{ color: item.color }">
            <svg-icon :icon-class="item.svg" />
          </div>
          <div class="item-box-label">{{ item.label }}</div>
        </div>
      </div>
    <div class="rightBottomLogo" style="position: fixed;bottom: 20px;right: 40px;z-index: 9999;">
      <img style="height: 100px;width: 300px;"  alt="logo" src="@/assets/meswork2.png"/>
    </div>
      <div class="content">
      <div class="c-left">
        <div class="left-header">
          <div>
            <img  alt="logo" src="@/assets/LCLogo.png"/>
          </div>
        </div>
        <div class="left-content">
          <div class="main">
            <dv-border-box-12 style="padding: 5px 10px; width: 95%; height: 95%">
              <div style="margin: 5px 0 5px 10px">
                <span
                    style="
                    width: 20px;
                    height: 10px;
                    background: #016ce9;
                    display: inline-block;
                  "></span>
                <span style="color: #fff;margin-left: 10px;font-size: 20px">SPC</span>
              </div>
              <div class="spcData" @click="shouEditSpcBox">
                <div>{{ spcOpName }}</div>
                <div>{{ spcTestPosition }}</div>
              </div>
              <div
                  id="leftTopColumnar"
                  style="width: 100%; height: 300px;margin-top: 20px;position: relative;top: -20px"></div>
            </dv-border-box-12>
          </div>
          <div class="main2">
            <dv-border-box-12
                style="padding: 5px 10px; width: 95%; height: 95%"
            >
              <div style="margin: 5px 0 5px 10px">
                <span
                    style="
                    width: 20px;
                    height: 10px;
                    background: #016ce9;
                    display: inline-block;
                  "
                ></span>
                <span style="color: #fff;margin-left: 10px;font-size: 20px">零部件智能预测性维护（h）</span>
              </div>
              <div id="leftMiddleColumnar" style="width: 100%; height: 240px;margin-top: 20px"></div>
            </dv-border-box-12>
          </div>
          <div class="main3">
            <dv-border-box-12
                style="padding: 10px; width: 95%; height: 95%"
            >
              <div style="margin: 5px 0 5px 10px">
                <span
                    style="
                    width: 20px;
                    height: 10px;
                    background: #016ce9;
                    display: inline-block;
                  "
                ></span>
                <span style="color: #fff;margin-left: 10px;font-size: 20px">设备运行履历</span>
              </div>
              <div id="leftBottom" style="width: 100%; height: 240px;margin-top: 20px"></div>
            </dv-border-box-12>
          </div>
        </div>
      </div>
      <div class="c-center">
        <div class="center-header">数字孪生智能制造工厂平台</div>
        <div class="center-head">
          <div class="left">{{ hour + ':' + minute }}</div>
          <div class="right">
            <div class="r1">{{ year + '-' + month + '-' + day }}</div>
            <div class="r2">{{ dayOfWeek }}</div>
          </div>
        </div>
        <div v-if="refreshTab" class="center-content">
          <dv-border-box-12 class="items" style="padding: 10px;">
            <div style="width: 100%;margin: 0px 0%;z-index: 999;">
              <div style="width: 100%;margin: 1px 0%;z-index: 999;">
                <d-m-t
                    ref="dmtCom"
                    containerHeight="916px"
                    containerWidth="100%"
                />
              </div>
              <!--              <div class="inputvideo">-->
              <!--                <video-player-->
              <!--                    class="video-player vjs-custom-skin"-->
              <!--                    ref="videoPlayer"-->
              <!--                    :playsinline="true"-->
              <!--                    :options="playerOptions"-->
              <!--                    style="height: 570px"-->
              <!--                ></video-player>-->
              <!--              </div>-->
            </div>
          </dv-border-box-12>

        </div>
      </div>
    </div>
    <el-dialog
        :modal="false"
        :visible.sync="isShowEditSpcBox"
        title="SPC 参数设置"
        width="13%"
    >
      <el-select
          v-model="spcOpName2"
          filterable
          placeholder="请选择工位号"
          size="small"
          style="width: 200px"
          @change="getCheckPosition">
        <el-option
            v-for="item in workOkDataInfo"
            :key="item.工位"
            :label="item.工位"
            :value="item.工位"
            size="mini"/>
      </el-select>
      <el-select
          v-model="spcTestPosition2"
          placeholder="请选择测量位置"
          size="small"
          style="width: 200px"
      >
        <el-option
            v-for="item in checkPositionList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
            size="mini"/>
      </el-select>
      <span slot="footer" class="dialog-footer">
        <el-button @click="isShowEditSpcBox = false">取 消</el-button>
        <el-button type="primary" @click="editSpcBoxSubmit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>

import { mqttIp, mqttPort, opname } from '@/utils/request'
import mqtt from 'mqtt'
import DMT from '@/components/DMT/index'
import * as echarts from 'echarts'
import { getLine } from '@/api/FactoryCalendar'
import axios from 'axios'

export default {
  components: {
    DMT
  },
  data() {
    return {
      mqttClient: null,
      dt_IframeUrl: '',
      timer1: null,
      refreshTab: true,
      isShowEditSpcBox: false,
      planCountInfo: [4624, 2696, 58.3, 1252, 50, 96],
      config: {},
      config2: {},
      config3: {},
      data: [],
      data2: [],
      data3: [],
      energyAll: [0, 0, 0],
      OpStatusList: [
        [{ name: '自动运行', value: true }, { name: '自动运行', 'value': true }, {
          name: '自动运行',
          'value': true
        }, { name: '自动运行', 'value': true }],
        [{ name: '手动暂停', value: true }, { name: '手动暂停', 'value': true }, {
          name: '手动暂停',
          'value': true
        }, { name: '手动暂停', 'value': true }],
        [{ name: '报警待机', value: false }, { name: '报警待机', 'value': false }, {
          name: '报警待机',
          'value': false
        }, { name: '报警待机', 'value': false }],
        [{ name: '初始化', value: true }, { name: '初始化', 'value': true }, {
          name: '初始化',
          'value': true
        }, { name: '初始化', 'value': true }]
      ],
      mainShowIndex: 'jd',
      开始日期: '',
      leftTopColumnar: null, // 左上柱状曲线
      leftMiddleColumnar: null, // 左中饼图
      leftBottom: null, // 左下设备履历
      bottomMiddle: null, // 下中 柱状
      bottomRightPie: null, // 下右饼图

      leftTopColumnarOption: null, // 左上柱状曲线配置
      leftMiddleColumnarOption: null, // 左中饼图配置
      leftBottomOption: null, // 左下设备履历配置
      bottomMiddleOption: null, // 下中 柱状配置
      bottomRightPieOption: null, // 下右饼图配置

      leftTopCurveX: [],
      leftTopCurveXData1: [],
      leftTopCurveXData2: [],
      leftTopCurveXData3: [],
      leftTopCurveXData4: [],
      leftBottomPieData: {
        外派: '0',
        采购: '0',
        自制: '0'
      },
      leftBottomColumnarX: [],
      leftBottomColumnarXData1: [],
      leftBottomColumnarXData2: [],
      leftBottomColumnarXData3: [],
      rightMiddleCurveX: [],
      rightMiddleCurveXData1: [],
      rightMiddleCurveXData2: [],
      rightMiddleCurveXData3: [],
      rightBottomPieDataColor: ['#49a9ee', '#98d87d', '#ffd86e', '#f3857b', '#8996e6'],
      rightBottomPieData: [
        { value: 76, name: 'OP10', itemStyle: { color: '#49a9ee' }},
        { value: 56, name: 'OP20', itemStyle: { color: '#98d87d' }},
        { value: 40, name: 'OP30', itemStyle: { color: '#ffd86e' }},
        { value: 20, name: 'OP40', itemStyle: { color: '#f3857b' }},
        { value: 12, name: 'OP50', itemStyle: { color: '#8996e6' }}
      ],
      style: {
        width: '1920',
        height: '1080',
        transform: 'scaleY(1) scaleX(1) translate(-50%, -50%)'
      },
      spcOpName: '',
      spcTestPosition: '',
      spcOpName2: '',
      spcTestPosition2: '',
      checkPositionList: [],
      // playerOptions: {
      //   // 视频源
      //   sources: [
      //     {
      //       type: 'video/mp4', // 视频类型
      //       src: require('@/assets/精力.mp4') // 视频源地址
      //     }
      //     // 你可以在这里添加多个源以支持不同的格式或分辨率
      //   ],
      //   // 视频封面
      //   // poster: 'https://example.com/path/to/poster.jpg',
      //   // 是否自动播放
      //   autoplay: true,
      //   // 是否静音
      //   muted: true,
      //   // 是否循环播放
      //   loop: true,
      //   // 是否预加载视频
      //   preload: 'auto',
      //   // 控制栏显示选项
      //   controls: true,
      //   // 语言
      //   language: 'zh-CN',
      //   // 其他播放器选项
      //   notSupportedMessage: '此视频暂无法播放，请稍后再试', // 当无法播放时显示的消息
      //   // 流配置，适用于直播流
      //   live: false
      //   // 更多配置...
      // },
      timer: '',
      time: 'time',
      // 时间属性
      year: '',
      month: '',
      day: '',
      hour: '',
      minute: '',
      second: '',
      dayOfWeek: '',
      deviceStatus_colors: ['grey', 'orange', 'green', 'red', 'blue'],
      deviceStatus_state: ['关机', '待机', '运行', '报警', '暂停'],
      deviceStatus_table: [],
      leftTopColumnarX: ['0.01', '0.02', '0.03', '0.04', '0.05', '0.06', '0.07', '0.08', '0.09'],
      leftTopColumnarXData1: [3, 9, 12, 41, 56, 43, 21, 11, 5],
      leftTopColumnarXData2: [2, 7, 11, 34, 41, 31, 16, 6, 2],
      leftMiddleColumnarX: ['进料部件', '加工部件', '装配部件', '检测部件'],
      leftMiddleColumnarXData1: [16, 40, 67, 41],
      leftMiddleColumnarXData2: [48, 28, 46, 38],
      leftMiddleColumnarXData3: [31, 17, 44, 28],
      rightMiddlePieColorList: ['#e2ae03', '#aa493c', '#459763', '#49a9ee'],
      bottomMiddleX: ['08', '09', '10', '11', '12', '13', '14'],
      bottomMiddleXData1: [48, 45, 62, 42, 50, 52, 49],
      // 中间滚动
      MiddleOption: {
        step: 0.2,
        direction: 1,
        limitMoveNum: 9,
        openWatch: true,
        hoverStop: true
      },
      // 订单看板
      workOkDataInfo: [
        {
          工位: 'IT240211-1',
          工位名称: '2024-06-05',
          手自动: '80',
          状态: '80',
          合格数: '80',
          不合格数: '80',
          总数: '',
          合格率: ''
        },
        { 内部合同号: 'IT240211-2', 交货日期: '2024-06-05', 工艺部: '80', 采购部: '80', 生产部: '80', 装配部: '80' },
        { 内部合同号: 'IT240211-3', 交货日期: '2024-06-05', 工艺部: '80', 采购部: '80', 生产部: '80', 装配部: '80' },
        { 内部合同号: 'IT240211-4', 交货日期: '2024-06-05', 工艺部: '80', 采购部: '80', 生产部: '80', 装配部: '80' },
        { 内部合同号: 'IT240211-5', 交货日期: '2024-06-05', 工艺部: '80', 采购部: '80', 生产部: '80', 装配部: '80' }
      ],
      topLabelList: [
        { label: '订单查询', url: 'ReportQuery/WorkOrderSearch/index', svg: 'MenuManagement', color: '#34812e' },
        { label: '报警查询', url: 'ReportQuery/AlarmSearch/index', svg: 'BasicAlarmMaintenance', color: '#897a4e' },
        { label: '关键数据曲线', url: 'ReportQuery/SpcSearch/index', svg: 'GrindingQualityHistory', color: '#705e92' },
        { label: '设备状态履历', url: 'ReportQuery/DeviceRunTimeStatus/index', svg: 'MachiningSequenceAdjustment', color: '#6c7e24' },
        { label: '日产量统计', url: 'ReportQuery/DayOutputCount/index', svg: 'MachineToolsMaintenance', color: '#197f31' },
        { label: 'JPH统计', url: 'ReportQuery/JPHCount/index', svg: 'ProcessPlanningNew', color: '#715f4c' },
        { label: '质量数据查询', url: 'ReportQuery/QualityDataSearch/index', svg: 'ReplenishmentOrders', color: '#217f6e' },
        { label: '过点信息查询', url: 'ReportQuery/WorkpieceOverStationSearch/index', svg: 'TLScoresApproval', color: '#3b7c38' },
        { label: '参数实时监控', url: 'ReportQuery/SignalNowSearch/index', svg: 'ViewFocusMaintenance', color: '#6d7c8a' },
        { label: '信号实时监控', url: 'ReportQuery/KeyPositionNowSearch/index', svg: 'BasicVariableMaintenance', color: '#75371c' },
        { label: '设备实时状态', url: 'ReportQuery/DeviceNowStatusSearch/index', svg: 'MachiningSequenceAdjustment', color: '#75371c' }
      ],
      workStatusData: {
        order: '',
        engineType: '',
        planCount: 3000,
        actualCount: 1024,
        fillRate: 34
      },
      lineNo: ''// 产线编号
    }
  },
  created() {
    // this.dt_IframeUrl = window.ConnectConfig.dt_IframeUrl
  },
  mounted() {
    const that = this
    // http://127.0.0.1:8082/#/?lineNo=12
    // const params = this.$route.query
    // console.log('产线编号', params.lineNo)
    // this.lineNo = JSON.parse(JSON.stringify(params.lineNo))

    // 页面自适应大小部分
    that.setScale()
    window.addEventListener('resize', () => {
      that.setScale()
    })
    // echarts图表绘制部分
    this.initEchartDom()
    this.setEchartData()
    this.searchChartData44()
    // 定时器部分
    this.timer = setInterval(() => {
      this.getNowTime()
    }, 1000)
    // this.timer = setInterval(() => {
    //   this.getWorkStatusData()
    // }, 1000 * window.dt_Config.topDataRefreshTime)
    // this.timer = setInterval(() => {
    //   this.setEchartData()
    // }, 1000 * window.dt_Config.mainDataRefreshTime)
    // setInterval(() => {
    //   this.searchChartData44()
    // }, 1000 * 60)
  },
  beforeDestroy() {
    clearInterval(this.timer)
  },
  methods: {
    getLineData() {
      const url = window.dt_Config.lineUrlList[this.lineNo]
      var param = []
      var data = {
        name: '订单_查询',
        param: JSON.stringify(param),
        type: '11',
        ModularID: '/SystemMaintenance/TVConfigManager/index'
      }
      axios.post(url, data).then(response => {
        if (response.data.length > 0) {
          this.workStatusData.order = response.data[0].订单号
          this.workStatusData.engineType = response.data[0].机型号
        } else {
          this.$message.error('操作失败！')
        }
      })
    },
    getMainPlanCountInfoData() {
      const data = this.CreateData1('11', '主页六个关键数据_查询')
      this.ExecDatabase(data).then((res) => {
        this.planCountInfo = []
        this.planCountInfo.push(this.num(res.data[0].当前计划))
        this.planCountInfo.push(this.num(res.data[0].当前产量))
        this.planCountInfo.push(this.num(res.data[0].计划完成))
        this.planCountInfo.push(this.num(res.data[0].工时消耗))
        this.planCountInfo.push(this.num(res.data[0].当前齐套率))
        this.planCountInfo.push(this.num(res.data[0].当前合格率))
      })
    },
    getOrderDataInfo() {
      const data = this.CreateData1('11', '左上订单看板_表格_查询')
      this.ExecDatabase(data).then((res) => {
        res.data.forEach((ele) => {
          ele.工艺部 = this.num(ele.工艺部)
          ele.采购部 = this.num(ele.采购部)
          ele.生产部 = this.num(ele.生产部)
          ele.装配部 = this.num(ele.装配部)
        })
        this.orderDataInfo = res.data
      })
    },
    getWorkDataInfo() {
      const data = this.CreateData1('11', '左中装配看板_表格_查询')
      this.ExecDatabase(data).then((res) => {
        this.workDataInfo = res.data
      })
    },
    getUnfinishedDataInfo() {
      const data = this.CreateData1('11', '左下未完成看板_表格_查询')
      this.ExecDatabase(data).then((res) => {
        this.unfinishedDataInfo = res.data
      })
    },
    getContract2DataInfo() {
      const data = this.CreateData1('11', '右上合同看板_表格_查询')
      this.ExecDatabase(data).then((res) => {
        this.contract2DataInfo = res.data
      })
    },
    getLackDataInfo() {
      const data = this.CreateData1('11', '右中缺件看板_表格_查询')
      this.ExecDatabase(data).then((res) => {
        this.lackDataInfo = res.data
      })
    },
    getQualityDataInfo() {
      const data = this.CreateData1('11', '右下质量看板_表格_查询')
      this.ExecDatabase(data).then((res) => {
        this.qualityDataInfo = res.data
      })
    },
    getContractMainDataInfo() {
      const data = this.CreateData1('11', '中间主体订单_表格_查询')
      this.ExecDatabase(data).then((res) => {
        res.data.forEach((ele) => {
          ele.工艺部 = this.num(ele.工艺部)
          ele.采购部 = this.num(ele.采购部)
          ele.生产部 = this.num(ele.生产部)
          ele.装配部 = this.num(ele.装配部)
        })
        this.contractMainDataInfo = res.data
      })
    },
    getContractMainDataInfoDetail(row) {
      const param = []
      param[0] = ['合同号', row.内部合同号]
      const data = this.CreateData1('11', '中间主体订单详情_表格_查询', param)
      this.ExecDatabase(data).then((res) => {
        if (res.data.length > 0) {
          // res.data.forEach((ele) => {
          //   ele.工艺部 = this.num(ele.工艺部)
          //   ele.采购部 = this.num(ele.采购部)
          //   ele.生产部 = this.num(ele.生产部)
          //   ele.装配部 = this.num(ele.装配部)
          // })
          this.contractMainDataInfoDetail = res.data
          this.mainShowIndex = 'jd-detail'
        }
      })
    },
    getScale() {
      const w = window.innerWidth / this.style.width
      const h = window.innerHeight / this.style.height
      return { x: w, y: h }
    },
    setScale() {
      const scale = this.getScale()
      this.style.transform = 'scaleY(' + scale.y + ') scaleX(' + scale.x + ') translate(-50%, -50%)'
    },
    initEchartDom() {
      this.leftTopColumnar = echarts.init(document.getElementById('leftTopColumnar'))
      this.leftMiddleColumnar = echarts.init(document.getElementById('leftMiddleColumnar'))
      // this.bottomMiddle = echarts.init(document.getElementById('bottomMiddle'))
      // this.bottomRightPie = echarts.init(document.getElementById('bottomRightPie'))
      this.leftBottom = echarts.init(document.getElementById('leftBottom')) // 取消注释
    },
    setEchartData() {
      // this.getSpcBaseData()
      this.getLeftTopColumnarData()
      this.getLeftMiddleColumnarData()
      // this.getBottomMiddleOptionData()
      // this.getBottomRightPieOptionData()
      // this.getWorkOkDataInfo()
      // this.getLineData()
    },
    initMqtt() {
      const scope = this
      const connection = {
        host: mqttIp,
        port: mqttPort,
        endpoint: '/mqtt',
        clean: true, // 保留会话
        connectTimeout: 4000, // 超时时间
        reconnectPeriod: 4000, // 重连时间间隔
        // 认证信息
        clientId: 'mqttjs_3be2c321' + new Date().getTime(), // 同一个ID 无法二次连接
        username: 'DT_WEB1',
        password: ''
      }
      const subscription = {
        topic: opname,
        qos: 0
      }
      const { host, port, endpoint, ...options } = connection
      const connectUrl = `ws://${host}:${port}${endpoint}`
      try {
        console.log(mqtt)
        this.mqttClient = mqtt.connect(connectUrl, options)
      } catch (error) {
        console.log('MQTT connect error', error)
      }

      this.mqttClient.on('connect', () => {
        this.$message.success('加载完成，连接MQTT服务器成功！')
        console.log('MQTT Connection succeeded!')
        const { topic, qos } = subscription
        this.mqttClient.subscribe(topic, { qos }, (error, res) => {
          if (error) {
            console.log('Subscribe to topics error', error)
          }
        })
      })
      this.mqttClient.on('error', error => {
        console.log('MQTT Connection failed', error)
        try {
          // scope.$message.error('MQTT服务器连接失败')
          if (scope.IsAllowConnect) {
            // 显示一下
            scope.$message.warning('重新连接MQTT服务器')
            console.log('重新连接MQTT服务器')
            // 重新连接,打开计时器
            setTimeout(function() {
              scope.initMqtt()
            }, 5000)
          }
        } catch (exception) {
          const error = exception.toString()
          scope.$message.error('MQTT服务器出现错误,关闭连接' + error)
        }
      })
      // 接收消息
      this.mqttClient.on('message', (topic, message) => {
        try {
          scope.websocketonmessage({ data: message.toString() })
        } catch (exception) {
          console.log(exception.toString())
        }
      })
      // 模拟接收消息
      // setInterval(() => {
      //   // this.websocketonmessage({ data: 'DT|C_B_DeviceInfo|[{"Name":"CUT","Id":"cfc74901-f68e-45e2-8735-8c07b5fd8a3f","Status":"中断","Program":"D:\\\\USER\\\\18126-P03-P10.MJB","Feed":null,"Speed":null,"Rapid":null,"ProgramStatus":null,"Tool":null,"Axis":[{"AxisName":"X","AxisValue":"0"},{"AxisName":"Y","AxisValue":"0"},{"AxisName":"Z","AxisValue":"60.7"},{"AxisName":"U","AxisValue":"0"},{"AxisName":"V","AxisValue":"0"}],"OtherParameter":[{"ParameterName":"当前钢丝架文件的名称","ParameterValue":"AC BRASS 900 0.250"},{"ParameterName":"当前选择的线径","ParameterValue":"0.25"},{"ParameterName":"电极丝特性","ParameterValue":"-841100"},{"ParameterName":"电极丝速度","ParameterValue":"8.2"},{"ParameterName":"发电机接通时间","ParameterValue":"697"},{"ParameterName":"总执行时间","ParameterValue":"817"},{"ParameterName":"机床接通的总时间","ParameterValue":"30704238"},{"ParameterName":"加工时电极丝速度","ParameterValue":"0"},{"ParameterName":"上喷射压力","ParameterValue":"0.2"},{"ParameterName":"下喷射压力","ParameterValue":"0.1"},{"ParameterName":"过滤器中的压力","ParameterValue":"1.1"}],"Alarm":[{"Alarm":"?????","AlarmTime":"2023-06-08 09:12:39 851"}]}]' })
      //   // this.websocketonmessage({ data: 'DT|C_B_DeviceInfo|[{"Name":"FORM","Id":"cfc74901-f68e-45e2-8735-8c07b5fd8a3f","Status":"ACTIVE","Program":"wdawda46d65a","Feed":"22","Speed":"33","Rapid":"44","ProgramStatus":null,"Tool":null,"Axis":[{"AxisName":"Xact","AxisValue":"10.5231"},{"AxisName":"Yact","AxisValue":"12.1368"},{"AxisName":"Zact","AxisValue":"35.8"},{"AxisName":"Uact","AxisValue":"0"},{"AxisName":"Vact","AxisValue":"0.0008"}],"OtherParameter":[{"ParameterName":"programnumber","ParameterValue":"SHAPE_SKIMMINGUNTILREMNANT2_CUT2"},{"ParameterName":"wirename","ParameterValue":"AC BRASS 900 0.250"},{"ParameterName":"wirediam","ParameterValue":"0.25"},{"ParameterName":"wireleftlength","ParameterValue":"-824956"},{"ParameterName":"wirespeed","ParameterValue":"8"},{"ParameterName":"sequence","ParameterValue":"GEO 8"},{"ParameterName":"sequencepass","ParameterValue":"3"},{"ParameterName":"genontime","ParameterValue":"4095"},{"ParameterName":"executiontime","ParameterValue":"4313"},{"ParameterName":"machinecounter","ParameterValue":"30503331"},{"ParameterName":"machineerosioncounter","ParameterValue":"12426498"},{"ParameterName":"machiningspeedmax","ParameterValue":"2.99"},{"ParameterName":"machiningspeedmin","ParameterValue":"2.32"},{"ParameterName":"machiningspeed","ParameterValue":"2.62"},{"ParameterName":"deio","ParameterValue":"9.7"},{"ParameterName":"temperature","ParameterValue":"21.9"},{"ParameterName":"pressureupper","ParameterValue":"0.3"},{"ParameterName":"pressurelower","ParameterValue":"0.1"},{"ParameterName":"pressurefilter","ParameterValue":"1.3"},{"ParameterName":"cuttinglength","ParameterValue":"24.2675"},{"ParameterName":"meanmachvoltage","ParameterValue":"30.0"},{"ParameterName":"wiretension","ParameterValue":"4.9"},{"ParameterName":"good","ParameterValue":"0.831"},{"ParameterName":"shortcircuit","ParameterValue":"0.150"},{"ParameterName":"arckill","ParameterValue":"0.019"},{"ParameterName":"cold","ParameterValue":"0.000"},{"ParameterName":"frequency","ParameterValue":"34990"},{"ParameterName":"timeTD","ParameterValue":"0.014"},{"ParameterName":"shc_warningnumber","ParameterValue":"56"},{"ParameterName":"shc_warningtime","ParameterValue":"45592"},{"ParameterName":"shc_longnumber","ParameterValue":"52"},{"ParameterName":"shc_longtime","ParameterValue":"45316"},{"ParameterName":"shc_time","ParameterValue":"45528"}]}]' })
      //   // this.websocketonmessage({ data: 'DT|C_B_DeviceInfo|[{"Name":"98","Id":"cfc74901-f68e-45e2-8735-8c07b5fd8a3f","Status":"ACTIVE","Program":null,"Feed":"22","Speed":"33","Rapid":"44","ProgramStatus":null,"Tool":null,"Axis":[{"AxisName":"Xact","AxisValue":"10.5231"},{"AxisName":"Yact","AxisValue":"12.1368"},{"AxisName":"Zact","AxisValue":"35.8"},{"AxisName":"Uact","AxisValue":"0"},{"AxisName":"Vact","AxisValue":"0.0008"}],"OtherParameter":[{"ParameterName":"programnumber","ParameterValue":"SHAPE_SKIMMINGUNTILREMNANT2_CUT2"},{"ParameterName":"wirename","ParameterValue":"AC BRASS 900 0.250"},{"ParameterName":"wirediam","ParameterValue":"0.25"},{"ParameterName":"wireleftlength","ParameterValue":"-824956"},{"ParameterName":"wirespeed","ParameterValue":"8"},{"ParameterName":"sequence","ParameterValue":"GEO 8"},{"ParameterName":"sequencepass","ParameterValue":"3"},{"ParameterName":"genontime","ParameterValue":"4095"},{"ParameterName":"executiontime","ParameterValue":"4313"},{"ParameterName":"machinecounter","ParameterValue":"30503331"},{"ParameterName":"machineerosioncounter","ParameterValue":"12426498"},{"ParameterName":"machiningspeedmax","ParameterValue":"2.99"},{"ParameterName":"machiningspeedmin","ParameterValue":"2.32"},{"ParameterName":"machiningspeed","ParameterValue":"2.62"},{"ParameterName":"deio","ParameterValue":"9.7"},{"ParameterName":"temperature","ParameterValue":"21.9"},{"ParameterName":"pressureupper","ParameterValue":"0.3"},{"ParameterName":"pressurelower","ParameterValue":"0.1"},{"ParameterName":"pressurefilter","ParameterValue":"1.3"},{"ParameterName":"cuttinglength","ParameterValue":"24.2675"},{"ParameterName":"meanmachvoltage","ParameterValue":"30.0"},{"ParameterName":"wiretension","ParameterValue":"4.9"},{"ParameterName":"good","ParameterValue":"0.831"},{"ParameterName":"shortcircuit","ParameterValue":"0.150"},{"ParameterName":"arckill","ParameterValue":"0.019"},{"ParameterName":"cold","ParameterValue":"0.000"},{"ParameterName":"frequency","ParameterValue":"34990"},{"ParameterName":"timeTD","ParameterValue":"0.014"},{"ParameterName":"shc_warningnumber","ParameterValue":"56"},{"ParameterName":"shc_warningtime","ParameterValue":"45592"},{"ParameterName":"shc_longnumber","ParameterValue":"52"},{"ParameterName":"shc_longtime","ParameterValue":"45316"},{"ParameterName":"shc_time","ParameterValue":"45528"}]}]' })
      //   this.websocketonmessage({ data: 'DT|C_B_DeviceInfo|[{"Name":"ST10","Id":"72e95caa-d510-4090-9dfa-9c55b8220999","Status":[{"StatusName":"自动运行","StatusValue":"0"},{"StatusName":"自动运行","StatusValue":"0"},{"StatusName":"自动运行","StatusValue":"0"},{"StatusName":"自动运行","StatusValue":"0"}],"Program":"TNC:\\\\CNC\\\\_model1-2.H","Feed":"18","Speed":"120","Rapid":"18","ProgramStatus":"闲置","Tool":null,"Axis":[{"AxisName":"X","AxisValue":"-279.766"},{"AxisName":"Y","AxisValue":"224.906"},{"AxisName":"Z","AxisValue":"231.568"},{"AxisName":"C","AxisValue":"333.580"},{"AxisName":"B","AxisValue":"0.000"}],"OtherParameter":[{"ParameterName":"NC启动时间","ParameterValue":"4192:47"},{"ParameterName":"MACHINE启动时间","ParameterValue":"3015:41"},{"ParameterName":"MACHINE运行时间","ParameterValue":"428:58"},{"ParameterName":"SPINDLE运行时间","ParameterValue":"0:00"}],"Alarm":null}]' })
      //   // this.websocketonmessage({ data: 'DT|C_B_DeviceInfo|[{"Name":"FANUC","Id":"cfc74901-f68e-45e2-8735-8c07b5fd8a3f","Status":"ACTIVE","Program":null,"Feed":"22","Speed":"33","Rapid":"44","ProgramStatus":null,"Tool":null,"Axis":[{"AxisName":"Xact","AxisValue":"10.5231"},{"AxisName":"Yact","AxisValue":"12.1368"},{"AxisName":"Zact","AxisValue":"35.8"},{"AxisName":"Uact","AxisValue":"0"},{"AxisName":"Vact","AxisValue":"0.0008"}],"OtherParameter":[{"ParameterName":"programnumber","ParameterValue":"SHAPE_SKIMMINGUNTILREMNANT2_CUT2"},{"ParameterName":"wirename","ParameterValue":"AC BRASS 900 0.250"},{"ParameterName":"wirediam","ParameterValue":"0.25"},{"ParameterName":"wireleftlength","ParameterValue":"-824956"},{"ParameterName":"wirespeed","ParameterValue":"8"},{"ParameterName":"sequence","ParameterValue":"GEO 8"},{"ParameterName":"sequencepass","ParameterValue":"3"},{"ParameterName":"genontime","ParameterValue":"4095"},{"ParameterName":"executiontime","ParameterValue":"4313"},{"ParameterName":"machinecounter","ParameterValue":"30503331"},{"ParameterName":"machineerosioncounter","ParameterValue":"12426498"},{"ParameterName":"machiningspeedmax","ParameterValue":"2.99"},{"ParameterName":"machiningspeedmin","ParameterValue":"2.32"},{"ParameterName":"machiningspeed","ParameterValue":"2.62"},{"ParameterName":"deio","ParameterValue":"9.7"},{"ParameterName":"temperature","ParameterValue":"21.9"},{"ParameterName":"pressureupper","ParameterValue":"0.3"},{"ParameterName":"pressurelower","ParameterValue":"0.1"},{"ParameterName":"pressurefilter","ParameterValue":"1.3"},{"ParameterName":"cuttinglength","ParameterValue":"24.2675"},{"ParameterName":"meanmachvoltage","ParameterValue":"30.0"},{"ParameterName":"wiretension","ParameterValue":"4.9"},{"ParameterName":"good","ParameterValue":"0.831"},{"ParameterName":"shortcircuit","ParameterValue":"0.150"},{"ParameterName":"arckill","ParameterValue":"0.019"},{"ParameterName":"cold","ParameterValue":"0.000"},{"ParameterName":"frequency","ParameterValue":"34990"},{"ParameterName":"timeTD","ParameterValue":"0.014"},{"ParameterName":"shc_warningnumber","ParameterValue":"56"},{"ParameterName":"shc_warningtime","ParameterValue":"45592"},{"ParameterName":"shc_longnumber","ParameterValue":"52"},{"ParameterName":"shc_longtime","ParameterValue":"45316"},{"ParameterName":"shc_time","ParameterValue":"45528"}]}]' })
      //   console.log('mqtt发送了一条数据')
      // }, 5000)
    },
    websocketonmessage(msg) { // 数据接收
      console.log('接收到了一条数据', msg)
      this.msg = msg
      // 返回的数据msg.data，包含了协议中的4部分9
      // TOBS??SCADADetailed?MES|Current|opName|电流^电压
      var arrays_signal = msg.data.split('|')
      var interFaceType = arrays_signal[0]
      var dataType = arrays_signal[1]
      var m_data = arrays_signal[2]
      switch (interFaceType) {
        case 'DT':
          switch (dataType) {
            case 'C_B_DeviceInfo': {
              {
                // console.log('S_data0', m_data)
                const S_data = JSON.parse(m_data)[0]
                // console.log('S_data', S_data)
                for (let i = 0; i < this.deviceList.length; i++) {
                  let item = this.deviceList[i]
                  // console.log('item.name', item.Name, 'S_data.Name', S_data.Name)
                  if (S_data.Name === item.Name) {
                    // console.log('有匹配上的数据')

                    // 2.对对象进行拷贝覆盖
                    item = { ...item, ...S_data }
                    if (item.hasOwnProperty('Alarm')) {
                      if (item.Alarm === null) item.Alarm = []
                      // 遍历报警信息 去除所有问号
                      if (item.Alarm !== null) {
                        if (item.Alarm.length > 0) {
                          for (const item of item.Alarm) {
                            item.Alarm = item.Alarm.replaceAll('?', '')
                            item.Alarm = item.Alarm.replaceAll('？', '')
                          }
                        }
                      }
                    }
                    if (item.hasOwnProperty('Status')) {
                      if (item.Status === null) item.Status = []
                    }
                    if (item.hasOwnProperty('Axis')) {
                      if (item.Axis === null) item.Axis = []
                    }
                    if (item.hasOwnProperty('OtherParameter')) {
                      if (item.OtherParameter === null) item.OtherParameter = []
                    }
                    if (item.hasOwnProperty('Program')) {
                      // 将设备程序只使用最后一个文件名 \ 分割
                      if (item.Program !== null) {
                        item.Program = item.Program.split('\\')[item.Program.split('\\').length - 1]
                      } else {
                        item.Program = ''
                      }
                    }
                    if (item.hasOwnProperty('Tool')) {
                      if (item.Tool === null) item.Tool = {}
                    }

                    // 4.重新赋值给原对象
                    this.deviceList[i] = item
                    // console.log('覆盖后的对象', this.deviceList[i])
                    // console.log('此时数组对象', this.deviceList)
                    break
                  }
                }
              }
              break
            }
            case 'C_B_TagIDTrigger': {
              const tag = JSON.parse(m_data)
              switch (tag.TagID) {
                case 'CB614A60-D0D2-4D76-96AA-FF433CAC0076': {
                  // 红
                  this.lightForm.red = tag.TagValue
                  break
                }
                case 'CB614A60-D0D2-4D76-96AA-FF433CAC0077': {
                  // 黄
                  this.lightForm.yellow = tag.TagValue
                  break
                }
                case 'CB614A60-D0D2-4D76-96AA-FF433CAC0078': {
                  this.lightForm.green = tag.TagValue
                  // 绿
                  break
                }
              }
            }
              break
          }
          break
      }
    },
    getRightMiddlePieData() {
      const data = this.CreateData1('11', '设备管理_设备报警_查询')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) {
          return
        }
        this.rightMiddlePieData = []
        for (let i = 0; i < res.data.length; i++) {
          const ele = res.data[i]
          this.rightMiddlePieData.push({
            value: ele.value,
            name: ele.name,
            itemStyle: { color: this.rightMiddlePieColorList[i] }
          })
        }
        console.log(this.rightMiddlePieData)
      }).then(() => {
        this.rightMiddlePieOptionSet()
      })
    },
    getLeftMiddlePieData() {
      const data = this.CreateData1('11', '产量管理_稼动率查询')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) {
          return
        }
        this.leftMiddlePieData = 0
        this.leftMiddlePiePlanData = 0
        this.leftMiddlePiePlanText = ''
        this.leftMiddlePieData = res.data[0].稼动率
        this.leftMiddlePiePlanData = res.data[0].目标稼动率
        const difference = Number(this.leftMiddlePieData) - Number(this.leftMiddlePiePlanData)
        if (difference > 0) {
          this.leftMiddlePiePlanText = '比目标值高 ' + Math.abs(difference) + '%'
        } else {
          this.leftMiddlePiePlanText = '比目标值低 ' + Math.abs(difference) + '%'
        }
      }).then(() => {
        this.leftMiddlePieOptionSet()
      })
    },
    getRightTopColumnarData() {
      const data = this.CreateData1('11', '产量管理_JPH_查询')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) {
          return
        }
        this.rightTopColumnarX = []
        this.rightTopColumnarXData = []
        for (let i = 0; i < res.data.length; i++) {
          const ele = res.data[i]
          this.rightTopColumnarX.push(ele.HH)
          this.rightTopColumnarXData.push(Number(ele.DataCountOK) + Number(ele.DataCountNG))
        }
      }).then(() => {
        this.rightTopColumnarOptionSet()
      })
    },
    getLeftTopColumnarData() {
      // getLine().then(response => {
      //   console.log(response.data, 4444)
      //   if (response.data.length !== 0) {
      //     // this.drawLine(response.data)
      //     this.leftTopColumnarOptionSet(response.data)
      //   } else {
      //     this.$message.error('数据数量过少,无法统计')
      //   }
      // })
      this.leftTopColumnarOptionSet('0.00007853298075,0.00260065515129,0.03168246567441,0.14199096013435,0.20659562794888,0.23410351622064,0.20659562794888,0.14199096013435,0.03168246567441,0.00260065515129,0.00007853298075|1.11282367146487,16.8210500000005,-9.0969,-9.3999,-19.3066276714648,0.778745672560654,0.393924862252413|0,0.0515,0.103,0.1545,0.206,0.2575|-19.3066276714648,-16.7541962535986,-14.2017648357324,-11.6493334178662,-10.3731177089331,-9.09690199999995,-7.82068629106685,-6.54447058213375,-3.99203916426754,-1.43960774640134,1.11282367146487|0,10,5.00000156713316,4.76258088826273,0')
      // const data = this.CreateData1('11', 'SPC_查询')
      // this.ExecDatabase(data).then((res) => {
      //   if (res.data.length <= 0) {
      //     return
      //   }
      //   this.leftTopColumnarX = []
      //   this.leftTopColumnarXData1 = []
      //   this.leftTopColumnarXData2 = []
      //   for (let i = 0; i < res.data.length; i++) {
      //     const ele = res.data[i]
      //     this.leftTopColumnarX.push(ele.value1)
      //     this.leftTopColumnarXData1.push(ele.value2)
      //     this.leftTopColumnarXData2.push(ele.value3)
      //   }
      // }).then(() => {
      //   this.leftTopColumnarOptionSet()
      // })
    },
    getLeftMiddleColumnarData() {
      // var param = []
      // param[0] = ['产线编号', this.lineNo]
      // const data = this.CreateData1('11', '零部件智能预测性维护_查询', param)
      // this.ExecDatabase(data).then((res) => {
      //   if (res.data.length <= 0) {
      //     return
      //   }
      //   this.leftMiddleColumnarX = []
      //   this.leftMiddleColumnarXData1 = []
      //   this.leftMiddleColumnarXData2 = []
      //   this.leftMiddleColumnarXData3 = []
      //   for (let i = 0; i < res.data.length; i++) {
      //     const ele = res.data[i]
      //     this.leftMiddleColumnarX.push(ele.名称)
      //     this.leftMiddleColumnarXData1.push(ele.制定)
      //     this.leftMiddleColumnarXData2.push(ele.已用)
      //     this.leftMiddleColumnarXData3.push(ele.剩余)
      //   }
      // }).then(() => {
      //   this.leftMiddleColumnarOptionSet()
      // })
      this.leftMiddleColumnarOptionSet()
    },
    getSpcBaseData() {
      const data = this.CreateData1('11', '大屏看板配置_查询')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length > 0) {
          this.spcOpName = res.data[0].SPC工位号
          this.spcTestPosition = res.data[0].SPC测量项目
        }
      })
    },
    getBottomMiddleOptionData() {
      var param = []
      param[0] = ['产线编号', this.lineNo]
      const data = this.CreateData1('11', '产量管理_JPH_查询', param)
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) {
          return
        }
        this.bottomMiddleX = []
        this.bottomMiddleXData1 = []
        for (let i = 0; i < res.data.length; i++) {
          const ele = res.data[i]
          this.bottomMiddleX.push(ele.HH)
          this.bottomMiddleXData1.push(Number(ele.DataCountOK))
        }
      }).then(() => {
        this.bottomMiddleOptionSet()
      })
    },
    getBottomRightPieOptionData() {
      var param = []
      param[0] = ['产线编号', this.lineNo]
      const data = this.CreateData1('11', '故障统计_查询', param)
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) {
          res.data[0] = { 数量: 0, 工位号: '无' }
        }
        this.rightBottomPieData = []
        for (let i = 0; i < res.data.length; i++) {
          const ele = res.data[i]
          const obj = {
            value: ele.数量,
            name: ele.工位号,
            itemStyle: {
              color: this.rightBottomPieDataColor[i]
            }
          }
          this.rightBottomPieData.push(obj)
        }
      }).then(() => {
        this.bottomRightPieOptionSet()
      })
    },
    // 查询设备运行履历
    searchChartData44() {
      // this.deviceStatus_table = []
      // var param = []
      // param[0] = ['产线编号', this.lineNo]
      // const data = this.CreateData1('11', '设备管理_设备每分钟状态_查询', param)
      // this.ExecDatabase(data).then((response) => {
      //   this.deviceStatus_table = response.data
      // }).then(() => {
      //   this.drawDashboard44()
      // })
      const scope = this
      // 从本地json文件读取设备状态数据
      fetch('/DeviceStatus.json')
        .then(response => response.json())
        .then(data => {
          console.log('设备状态读取成功！', data)
          this.deviceStatus_table = data
          this.drawDashboard44()
        })
        .catch(error => {
          console.log('加载设备状态数据失败:', error)
          this.deviceStatus_table = []
          this.drawDashboard44()
        })
    },
    getWorkOkDataInfo() {
      var param = []
      param[0] = ['产线编号', this.lineNo]
      const data = this.CreateData1('11', '合格率_查询', param)
      this.ExecDatabase(data).then((response) => {
        if (response.data.length > 0) {
          this.workOkDataInfo = response.data
        } else {
          this.workOkDataInfo = []
        }
      })
    },
    getWorkStatusData() {
      var param = []
      param[0] = ['产线编号', this.lineNo]
      const data = this.CreateData1('11', '生产状态_查询', param)
      this.ExecDatabase(data).then((response) => {
        this.workStatusData.planCount = response.data[0].计划产量
        this.workStatusData.actualCount = response.data[0].实际产量
        this.workStatusData.fillRate = this.num(response.data[0].完成率)
      })
    },
    // 设备运行履历
    drawDashboard44() {
      // const scope = this // 移除未使用的变量
      const deviceStatus_data = []
      const deviceStatus_yAxisValue = []
      let deviceStatus_index = 0
      if (this.deviceStatus_table.length === 1) {
        deviceStatus_data.push({
          itemStyle: { normal: { color: this.deviceStatus_table[0].颜色 }}, // 条形颜色
          name: this.deviceStatus_table[0].设备状态名称,
          value: [0, this.deviceStatus_table[0].开始时间, this.deviceStatus_table[0].结束时间]
        })
      } else {
        for (let i = 0; i < this.deviceStatus_table.length; i++) {
          if (i < this.deviceStatus_table.length) {
            if (i === 0) {
              deviceStatus_index = 0
              deviceStatus_yAxisValue.push(this.deviceStatus_table[i].工位号)
            } else if (this.deviceStatus_table[i].工位号 !== this.deviceStatus_table[i - 1].工位号) {
              deviceStatus_index++ // y轴索引
              deviceStatus_yAxisValue.push(this.deviceStatus_table[i].工位号)
            }
          }
          deviceStatus_data.push({
            itemStyle: { normal: { color: this.deviceStatus_table[i].颜色 }}, // 条形颜色
            name: this.deviceStatus_table[i].设备状态名称,
            value: [parseInt(deviceStatus_index), this.deviceStatus_table[i].开始时间, this.deviceStatus_table[i].结束时间]
          })
        }
      }
      // const myChart = echarts.init(document.getElementById('myChart4'))
      this.leftBottomOption = {
        // title: {
        //   left: 'center',
        //   text: '设备状态分布图(分钟)',
        //   textStyle: {
        //     color: '#ffffff'
        //   }
        // },
        color: this.deviceStatus_colors,
        tooltip: { // 提示框
          formatter(params) {
            return params.value[1].substr(11, 5) + '~' + params.value[2].substr(11, 5)
          } // 数据的值
        },
        grid: { // 绘图网格
          left: '10px',
          right: '4%',
          top: '10%',
          bottom: '2%',
          containLabel: true
        },
        legend: { // 图例
          data: ['关机', '待机', '运行', '暂停', '报警'],
          selectedMode: false,
          textStyle: {
            color: '#ffffff'
          }
        },
        xAxis: {
          type: 'time',
          axisLine: {
            lineStyle: {
              color: '#ffffff'
            },
            show: true
          },
          axisTick: {
            show: true
          },
          interval: 1000 * 60 * 60 * 2,
          axisLabel: {
            formatter(value) {
              var date = new Date(value)
              return getzf(date.getHours()) + ':' + getzf(date.getMinutes())

              function getzf(num) {
                if (parseInt(num) < 10) {
                  num = '0' + num
                }
                return num
              }
            }
          }
        },
        yAxis: {
          axisLine: {
            lineStyle: {
              color: '#ffffff'
            }
          },
          data: deviceStatus_yAxisValue
        },
        series: [
          // 用空bar来显示几个图例
          { name: this.deviceStatus_state[0], type: 'bar', data: [] },
          { name: this.deviceStatus_state[1], type: 'bar', data: [] },
          { name: this.deviceStatus_state[2], type: 'bar', data: [] },
          { name: this.deviceStatus_state[3], type: 'bar', data: [] },
          { name: this.deviceStatus_state[4], type: 'bar', data: [] },
          {
            type: 'custom',
            renderItem(params, api) { // 开发者自定义的图形元素渲染逻辑，是通过书写 renderItem 函数实现的
              var categoryIndex = api.value(0) // 这里使用 api.value(0) 取出当前 dataItem 中第一个维度的数值。
              var start = api.coord([api.value(1), categoryIndex]) // 这里使用 api.coord(...) 将数值在当前坐标系中转换成为屏幕上的点的像素值。
              var end = api.coord([api.value(2), categoryIndex])
              var height = 18 // 柱体宽度
              return {
                type: 'rect', // 表示这个图形元素是矩形。还可以是 'circle', 'sector', 'polygon' 等等。
                shape: echarts.graphic.clipRectByRect({ // 矩形的位置和大小。
                  x: start[0],
                  y: start[1] - height,
                  width: end[0] - start[0],
                  height: height * 1.2
                }, { // 当前坐标系的包围盒。
                  x: params.coordSys.x,
                  y: params.coordSys.y,
                  width: params.coordSys.width,
                  height: params.coordSys.height
                }),
                style: api.style()
              }
            },
            encode: {
              x: [1, 2], // data 中『维度1』和『维度2』对应到 X 轴
              y: 0 // data 中『维度0』对应到 Y 轴
            },
            data: deviceStatus_data
          }
        ]
      }
      this.leftBottom.setOption(this.leftBottomOption)
    },
    middleButtonOptionSet() {
      this.middleButtonOption = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        legend: {
          right: 10, // 将图例放置在右侧
          icon: 'circle', // 设置图例的标识样式为实心圆点
          itemWidth: 10, // 设置图例标记的宽度
          itemHeight: 10, // 设置图例标记的高度
          textStyle: {
            color: '#a2a7b3',
            fontSize: 12
          }
        },
        grid: {
          left: '2%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'value',
          boundaryGap: [0, 0.01],
          axisLine: {
            show: true
          },
          axisLabel: {
            show: true,
            color: '#747c8c',
            formatter: function(value) {
              const hours = Math.floor(value / 60)
              const mins = value % 60
              return `${String(hours).padStart(2, '0')}:${String(mins).padStart(2, '0')}`
            },
            interval: 0
          },
          max: 1440,
          splitLine: {
            show: false
          }
        },
        yAxis: {
          type: 'category',
          data: ['ST10工站', 'ST20工站', 'ST30工站', 'ST40工站'],
          axisLine: {
            show: true
          },
          axisLabel: {
            show: true,
            color: '#747c8c'
          }
        },
        series: [
          {
            data: [300, 300, 300, 300],
            type: 'bar',
            stack: 'a',
            name: '正常待机',
            color: '#eff2f8',
            itemStyle: {
              borderRadius: 15
            },
            barMaxWidth: 15
          },
          {
            data: [240, 200, 200, 200],
            type: 'bar',
            stack: 'a',
            name: '初始化',
            color: '#409eff',
            itemStyle: {
              borderRadius: 15
            }
          },
          {
            data: [200, 100, 300, 200],
            type: 'bar',
            stack: 'a',
            name: '自动运行',
            color: '#67c23a',
            itemStyle: {
              borderRadius: 15
            }
          },
          {
            data: [200, 200, 200, 200],
            type: 'bar',
            stack: 'a',
            name: '报警暂停',
            color: '#f56c6c',
            itemStyle: {
              borderRadius: 15
            }
          },
          {
            data: [60, 200, 100, 100],
            type: 'bar',
            stack: 'a',
            name: '服务暂停',
            color: '#fff476',
            itemStyle: {
              borderRadius: 15
            }
          },
          {
            data: [440, 440, 340, 440],
            type: 'bar',
            stack: 'a',
            name: '正常待机',
            color: '#eff2f8',
            itemStyle: {
              borderRadius: 15
            }
          }
        ]
      }
      this.middleButton.setOption(this.middleButtonOption)
    },
    shouEditSpcBox() {
      this.isShowEditSpcBox = true
      this.spcOpName2 = this.spcOpName
      this.getCheckPosition()
    },
    editSpcBoxSubmit() {
      var param = []
      param[0] = ['工位号', this.spcOpName2]
      param[1] = ['测量位置', this.spcTestPosition2]
      const data = this.CreateData1('11', '大屏看板配置_SPC_修改', param)
      this.ExecDatabase(data).then((response) => {
        if (response.data[0].result == 1) {
          this.isShowEditSpcBox = false
          this.$message.success('修改成功!')
          this.getSpcBaseData()
          this.getLeftTopColumnarData()
        }
      })
    },
    getCheckPosition() {
      this.checkPositionList = []
      this.spcTestPosition2 = ''
      const datetime = new Date().toLocaleString()
      // 获取当前时间 写入 datetime
      var param = []
      param[0] = ['工位号', this.spcOpName2]
      param[1] = ['开始时间', '2000/11/4 16:29:25']
      param[2] = ['结束时间', datetime]
      var Data = this.CreateData1('11', 'SPC_测量位置_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          // 添加到checkPositionList 下拉框
          for (let i = 0; i < response.data.length; i++) {
            this.checkPositionList.push({ label: response.data[i].测量项目, value: response.data[i].测量项目 })
          }
          this.spcTestPosition2 = response.data[0].测量项目
        }
      })
    },
    rightMiddlePieOptionSet() {
      this.rightMiddlePieOption = {
        tooltip: {
          trigger: 'item'
        },
        legend: {
          top: '0%',
          orient: 'vertical',
          right: 40, // 将图例放置在右侧
          icon: 'circle', // 设置图例的标识样式为实心圆点
          itemGap: 10,
          itemWidth: 14, // 设置图例标记的宽度
          itemHeight: 14, // 设置图例标记的高度
          textStyle: {
            fontSize: 14,
            color: function(params) {
              // 获取对应的系列项
              var series = this.rightMiddlePieOption.series[0].data // 使用 this.rightMiddlePieOption
              for (var i = 0; i < series.length; i++) {
                if (series[i].name === params) {
                  // 返回对应系列项的颜色
                  return series[i].itemStyle.color
                }
              }
              return '#000' // 默认颜色，如果没有匹配到
            }
          }
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: ['50%', '90%'],
            center: ['45%', '50%'],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 10,
              borderColor: 'rgba(9, 26, 54,1)',
              borderWidth: 5
            },
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: 40,
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: false
            },
            data: this.rightMiddlePieData// [
            // { value: 10, name: 'ST10工站', itemStyle: { color: '#e2ae03' }},
            // { value: 30, name: 'ST20工站', itemStyle: { color: '#aa493c' }},
            // { value: 50, name: 'ST30工站', itemStyle: { color: '#459763' }},
            // { value: 5, name: 'ST40工站', itemStyle: { color: '#49a9ee' }}
            // ]
          }
        ]
      }
      this.rightMiddlePie.setOption(this.rightMiddlePieOption)
    },
    rightTopColumnarOptionSet() {
      this.rightTopColumnarOption = {
        grid: {
          left: '1%',
          right: '6%',
          bottom: '10%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: this.rightTopColumnarX, // ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
          axisLabel: {
            interval: 0, // 显示所有标签
            fontSize: 10, // 设置x轴文字的大小
            color: '#626c7f'
          }
        },
        yAxis: {
          type: 'value',
          axisLine: {
            show: true
          },
          splitLine: {
            show: false
          }
        },
        series: [
          {
            data: this.rightTopColumnarXData, // [120, 200, 150, 80, 70, 110, 130, 130, 98, 115, 98, 115],
            color: '#49a9ee',
            type: 'bar',
            barMaxWidth: 15
          }
        ]
      }
      this.rightTopColumnar.setOption(this.rightTopColumnarOption)
    },
    leftMiddlePieOptionSet() {
      const value = this.leftMiddlePieData
      // 进度百分比
      this.leftMiddlePieOption = {
        title: [{
          text: value + '%',
          left: 'center',
          top: '40%',
          textStyle: {
            color: '#757575',
            fontSize: 35,
            fontWeight: 'bold'
          }
        }, {
          text: this.leftMiddlePiePlanText,
          left: 'center',
          top: '92%',
          textStyle: {
            color: '#7b7e87',
            fontSize: 12
          }
        }],
        angleAxis: {
          show: false,
          // 后面的180表示圆环的跨越的角度， 如max设置为100*360/270,startAngle设置为-135
          max: 100 * 360 / 270,
          type: 'value',
          startAngle: -135,
          splitLine: {
            show: false
          }
        },
        // 修改环形的宽度
        barMaxWidth: 20,
        radiusAxis: {
          show: false,
          type: 'category'
        },
        polar: {
          // 设置环形的位置
          center: ['50%', '50%'],
          // 设置环形大小
          radius: '180%'
        },
        series: [{
          type: 'bar',
          data: [
            {
              value: value,
              itemStyle: {
                // 这里是已经达到进度的颜色
                color: '#48a9ee'
              }
            }
          ],
          itemStyle: {
            normal: {
              color: 'white' // 设置环形图中心的颜色为白色
            }
          },
          barGap: '-100%',
          coordinateSystem: 'polar',
          z: 3
        }, {
          type: 'bar',
          data: [{
            value: 100,
            itemStyle: {
              // 这里是环形底色
              color: '#f4f4f4',
              borderWidth: 0
            }
          }],
          barGap: '-100%',
          coordinateSystem: 'polar',
          z: 1
        }]
      }
      this.leftMiddlePie.setOption(this.leftMiddlePieOption)
    },
    leftTopColumnarOptionSet(res) {
      const usl = parseFloat(res.split('|')[4].split(',')[0]).toFixed(4)
      const qu = parseFloat(res.split('|')[4].split(',')[1]).toFixed(4)
      const sl = parseFloat(res.split('|')[4].split(',')[2]).toFixed(4)
      const ql = parseFloat(res.split('|')[4].split(',')[3]).toFixed(4)
      const lsl = parseFloat(res.split('|')[4].split(',')[4]).toFixed(4)
      const cpk = parseFloat(res.split('|')[1].split(',')[6]).toFixed(2)
      const cp = parseFloat(res.split('|')[1].split(',')[5]).toFixed(2)
      const USL = parseInt(res.split('|')[4].split(',')[0])
      const QU = parseInt(res.split('|')[4].split(',')[1])
      const SL = parseInt(res.split('|')[4].split(',')[2])
      const QL = parseInt(res.split('|')[4].split(',')[3])
      const LSL = parseInt(res.split('|')[4].split(',')[4])
      const xData = res.split('|')[3].split(',')
      const xdata = []
      for (let i = 0; i < xData.length; i++) {
        xdata.push(xData[i])
      }
      const yData = res.split('|')[2].split(',')
      const ydata = []
      for (let i = 0; i < yData.length; i++) {
        ydata.push(yData[i])
      }
      const lineData = res.split('|')[0].split(',')
      const linedata = []
      for (let i = 0; i < lineData.length; i++) {
        linedata.push(lineData[i])
      }
      console.log(xData, 1, lineData, 2)
      const leftTopColumnarOption2 = {
        title: {
          left: 'center',
          text: '正态分布图',
          subtext: 'Cp=' + cp + ' Cpk=' + cpk,
          textStyle: {
            color: '#afafaf'
          }
        },
        tooltip: {
          trigger: 'axis'
        },
        xAxis: {
          type: 'category',
          data: xdata,
          show: false
        },
        yAxis: {
          type: 'value',
          scale: 'true'
        },
        series: [
          {
            smooth: true,
            showSymbol: false,
            name: '测量值',
            type: 'line',
            data: linedata,
            markLine: {
              data: [
                { xAxis: USL, name: 'USL', value: usl },
                { xAxis: LSL, name: 'LSL', value: lsl },
                { xAxis: QU, name: 'QU', value: qu },
                { xAxis: QL, name: 'QL', value: ql },
                { xAxis: SL, name: 'SL', value: sl }
              ],
              label: {
                normal: {
                  position: 'middle',
                  formatter: '{b} : {c}'
                }
              },
              lineStyle: {
                color: {
                  type: 'radial',
                  x: 0.5,
                  y: 0.5,
                  r: 0.5,
                  colorStops: [{
                    offset: 0, color: 'red' // 0% 处的颜色
                  }, {
                    offset: 1, color: 'blue' // 100% 处的颜色
                  }],
                  globalCoord: false // 缺省为 false
                }
              }
            }
          }
        ]
      }
      if (this.leftTopColumnarOption !== leftTopColumnarOption2) {
        this.leftTopColumnarOption = leftTopColumnarOption2
        this.leftTopColumnar.setOption(this.leftTopColumnarOption)
      }
      // this.leftTopColumnarOption = {
      //   grid: {
      //     top: '5%',
      //     left: '7%',
      //     right: '5%',
      //     bottom: '10%'
      //   },
      //   tooltip: {
      //     trigger: 'item'
      //   },
      //   xAxis: {
      //     type: 'category',
      //     data: this.leftTopColumnarX, // ['1T240211-1', '1T240211-2', '1T240211-3', '1T240211-4'],
      //     axisLabel: {
      //       interval: 0, // 显示所有标签
      //       fontSize: 10, // 设置x轴文字的大小
      //       color: '#fff'
      //     }
      //   },
      //   yAxis: {
      //     type: 'value',
      //     splitLine: {
      //       show: true,
      //       lineStyle: {
      //         type: 'dashed' // 分隔线类型设置为虚线
      //       }
      //     },
      //     axisTick: {
      //       show: false
      //     },
      //     axisLine: {
      //       show: true
      //     }
      //   },
      //   series: [
      //     {
      //       name: 'B1',
      //       data: this.leftTopColumnarXData1, // [40, 22, 47, 39],
      //       type: 'bar',
      //       itemStyle: { color: '#3c5497' },
      //       barMaxWidth: 10
      //     },
      //     {
      //       name: 'B2',
      //       data: this.leftTopColumnarXData2, // [21, 45, 32, 46],
      //       type: 'bar',
      //       itemStyle: { color: '#659260' },
      //       barMaxWidth: 10
      //     },
      //     {
      //       name: 'L3',
      //       data: this.leftTopColumnarXData2, // [21, 45, 32, 46],
      //       type: 'line',
      //       smooth: true,
      //       itemStyle: { color: '#733c4a' }
      //     }
      //   ]
      // }
      // this.leftTopColumnar.setOption(this.leftTopColumnarOption)
    },
    inputPlanCount() {
      // 使用element ui弹出输入框输入计划产量
      this.$prompt('请输入计划产量', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputPattern: /^[0-9]*$/,
        inputErrorMessage: '请输入数字'
      }).then(({ value }) => {
        var param = []
        param[0] = ['计划产量', value]
        const data = this.CreateData1('12', '大屏看板配置_计划产量_修改', param)
        this.ExecDatabase(data).then((response) => {
          if (response.data[0].result == 1) {
            this.$message({
              type: 'success',
              message: '修改成功!'
            })
            this.getWorkStatusData()
          } else {
            this.$message({
              type: 'error',
              message: '修改失败!'
            })
          }
        })
      })
    },
    leftMiddleColumnarOptionSet() {
      this.leftMiddleColumnarOption = {
        legend: {
          top: '5%',
          right: '5%', // 将图例放置在右侧
          icon: 'circle', // 设置图例的标识样式为实心圆点
          itemWidth: 10, // 设置图例标记的宽度
          itemHeight: 10, // 设置图例标记的高度
          textStyle: {
            fontSize: 12,
            color: function(params) {
              // 获取对应的系列项
              var series = this.leftMiddleColumnarOption.series // 使用 this.leftMiddleColumnarOption
              for (var i = 0; i < series.length; i++) {
                if (series[i].name === params) {
                  // 返回对应系列项的颜色
                  return series[i].itemStyle.color
                }
              }
              return '#000' // 默认颜色，如果没有匹配到
            }
          }
        },
        grid: {
          top: '15%',
          left: '7%',
          right: '5%',
          bottom: '10%'
        },
        tooltip: {
          trigger: 'item'
        },
        xAxis: {
          type: 'category',
          data: this.leftMiddleColumnarX, // ['1T240211-1', '1T240211-2', '1T240211-3', '1T240211-4'],
          axisLabel: {
            interval: 0, // 显示所有标签
            fontSize: 10, // 设置x轴文字的大小
            color: '#fff'
          }
        },
        yAxis: {
          type: 'value',
          splitLine: {
            show: true,
            lineStyle: {
              type: 'dashed' // 分隔线类型设置为虚线
            }
          },
          axisTick: {
            show: false
          },
          axisLine: {
            show: true
          }
        },
        series: [
          {
            name: '制定',
            data: this.leftMiddleColumnarXData1, // [40, 22, 47, 39],
            type: 'bar',
            itemStyle: { color: '#ad4846' },
            barWidth: 15,
            barCategoryGap: '30'
          },
          {
            name: '已用',
            data: this.leftMiddleColumnarXData2, // [21, 45, 32, 46],
            type: 'bar',
            itemStyle: { color: '#479867' },
            barWidth: 15,
            barCategoryGap: '30'
          },
          {
            name: '剩余',
            data: this.leftMiddleColumnarXData3, // [21, 45, 32, 46],
            type: 'bar',
            smooth: true,
            itemStyle: { color: '#e6ad00' },
            barWidth: 15,
            barCategoryGap: '30'
          }
        ]
      }
      this.leftMiddleColumnar.setOption(this.leftMiddleColumnarOption)
    },
    bottomMiddleOptionSet() {
      this.bottomMiddleOption = {
        legend: {
          top: '0%',
          right: '15%', // 将图例放置在右侧
          icon: 'circle', // 设置图例的标识样式为实心圆点
          itemWidth: 10, // 设置图例标记的宽度
          itemHeight: 10, // 设置图例标记的高度
          textStyle: {
            fontSize: 14,
            color: function(params) {
              // 获取对应的系列项
              var series = this.bottomMiddleOption.series // 使用 this.bottomMiddleOption
              for (var i = 0; i < series.length; i++) {
                if (series[i].name === params) {
                  // 返回对应系列项的颜色
                  return series[i].itemStyle.color
                }
              }
              return '#000' // 默认颜色，如果没有匹配到
            }
          }
        },
        grid: {
          top: '15%',
          left: '7%',
          right: '5%',
          bottom: '10%'
        },
        tooltip: {
          trigger: 'item'
        },
        xAxis: {
          type: 'category',
          data: this.bottomMiddleX, // ['1T240211-1', '1T240211-2', '1T240211-3', '1T240211-4'],
          axisLabel: {
            interval: 0, // 显示所有标签
            fontSize: 10, // 设置x轴文字的大小
            color: '#fff'
          }
        },
        yAxis: {
          name: '台',
          type: 'value',
          splitLine: {
            show: false,
            lineStyle: {
              type: 'dashed' // 分隔线类型设置为虚线
            }
          },
          axisTick: {
            show: false
          },
          axisLine: {
            show: true
          }
        },
        series: [
          {
            name: '合格台数',
            data: this.bottomMiddleXData1, // [40, 22, 47, 39],
            type: 'bar',
            itemStyle: { color: '#4572a7' },
            barWidth: 10
          }
        ]
      }
      this.bottomMiddle.setOption(this.bottomMiddleOption)
    },
    bottomRightPieOptionSet() {
      this.bottomRightPieOption = {
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          right: 9,
          top: '20%',
          itemGap: 10,
          icon: 'circle',
          formatter: function(name) {
            var total = 0
            var targetValue
            // 直接使用rightBottomPieOption，而不是this
            this.bottomRightPieOption.series[0].data.forEach(function(item) {
              total += item.value
              if (item.name === name) {
                targetValue = item.value
              }
            })
            var percentage = targetValue ? ((targetValue / total) * 100).toFixed(2) + '%' : '100%'
            return name + ' ' + targetValue + '个 ' + percentage
          }.bind(this), // 使用bind(this)确保this指向正确的上下文
          textStyle: {
            fontSize: 12,
            color: '#fff'
          }
        },
        series: [
          {
            name: '故障统计',
            type: 'pie',
            radius: '100%',
            right: '50%',
            center: ['60%', '50%'],
            labelLine: {
              show: false
            },
            label: {
              show: false
            },
            data: this.rightBottomPieData,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
      this.bottomRightPie.setOption(this.bottomRightPieOption)
    },
    num(num) {
      return (num + '').indexOf('.') === -1 ? num : num.toFixed(1) // 使用 ===
      // return num
    },
    getmidddlelist() {
      const data = this.CreateData1(
        '11',
        '中间实时OEE数据展示_查询'
      )
      this.ExecDatabase(data).then((res) => {
        // res.data.forEach((ele) => {
        //   ele.OEE = this.num(ele.OEE)
        //   ele.合格率 = this.num(ele.合格率)
        //   ele.性能利用率 = this.num(ele.性能利用率)
        //   ele.时间利用率 = this.num(ele.时间利用率)
        // })
        this.lineInfo = res.data
      })
    },
    clareData() {
      this.contractMainDataInfoDetail = []
      this.mainShowIndex = 'jd'
    },
    // 查询中间订单 工时 能源 出勤等信息
    getPlanCountInfo() {
      const params = []
      var data = this.CreateData1(
        11,
        'visualization_中间产线实时信息_查询',
        params
      )
      this.ExecDatabase(data).then((res) => {
        this.planCountInfo = []
        if (res.data.length > 0) {
          this.planCountInfo[0] = res.data[0]['当前计划']
          this.planCountInfo[1] = res.data[0]['当前产量']
          this.planCountInfo[2] = res.data[0]['计划完成']
          this.planCountInfo[3] = res.data[0]['工时消耗']
          this.planCountInfo[4] = res.data[0]['能源消耗']
          this.planCountInfo[5] = res.data[0]['生产出勤']
        }
      })
    },
    zeroFill(i) {
      if (i >= 0 && i <= 9) {
        return '0' + i
      } else {
        return i
      }
    },
    getNowTime() {
      const weekday = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
      const date = new Date()
      this.year = date.getFullYear()
      this.month = this.zeroFill(date.getMonth() + 1)
      this.day = this.zeroFill(date.getDate())
      this.hour = this.zeroFill(date.getHours())
      this.minute = this.zeroFill(date.getMinutes())
      this.second = this.zeroFill(date.getSeconds())
      this.dayOfWeek = weekday[date.getDay()]
    }
  },
  computed: {},
  watch: {},
  props: {},
  directives: {
    scroll: {
      bind(
        el,
        {
          value: { delay, speed } = {
            delay: 0,
            speed: 50
          }
        }
      ) {
        //  delay 延迟  //speed滚动速度
        // 数据少不滚动
        // 无缝滚动
        let scrollInterval
        setTimeout(() => {
          scrollInterval = setInterval(goScroll, speed)
        }, delay)
        el.addEventListener('mouseenter', () => {
          clearInterval(scrollInterval)
        })
        el.addEventListener('mouseleave', () => {
          scrollInterval = setInterval(goScroll, speed)
        })

        function goScroll() {
          const scrollTotalHeight = JSON.parse(JSON.stringify(el.scrollTop))
          el.scrollTop++
          if (scrollTotalHeight === el.scrollTop) {
            el.scrollTop = 0
          }
        }
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.container {
  width: 100%;
  height: 100%;
  overflow-y: hidden;
  z-index: 100;
  transform-origin: 0 0;
  position: fixed;
  left: 50%;
  top: 50%;
  background-color: #000d3a;
  color: white;

  .content {
    width: 100%;
    height: 100%;
    display: flex;
    overflow: hidden;

    .c-left {
      width: 27%;
      height: 100%;
      background-color: #000d3a;
      margin-left: 15px;

      .left-header {
        margin-top: 2%;
        background-color: #000d3a;
        height: 11%;
        display: flex;
        align-items: center;

        img {
          margin: 10px;
          height: 100px;
          margin-left: 50px;
          width: 400px;
        }

        span {
          font-size: 3.5rem;
          margin-left: 1rem;
        }
      }

      .left-content {
        height: 90%;

        .main {
          height: 32%;
        }

        .main2 {
          height: 32%;
        }

        .main3 {
          height: 32%;
        }

        .box {
          display: flex;
          justify-content: space-between;
          height: 90%;
          width: 100%;
        }

        .left {
          width: 50%;
          height: 100%;
        }

        .right {
          width: 44.5%;
          height: 100%;
        }

        .box2 {
          display: flex;
          justify-content: space-between;
          height: 53%;
        }

        .left1 {
          width: 45%;
        }

        .right1 {
          width: 100%;
        }

        .row-item {
          height: 20px !important;
          line-height: 20px !important;
          font-size: 12px;
        }

        .header-item {
          height: 24px;
          line-height: 24px;
        }

        .dv-scroll-board .header {
          font-size: 12px;
        }

        .hezi1 {
          position: absolute;
          top: 10%;
          left: 23%;
        }

        .n1 {
          color: #fff;
        }

        .n2 {
          color: #fff;
          font-size: 12px;
        }

        .n3 {
          color: #fff;
          font-size: 12px;
        }

        .n4 {
          color: #fff;
          font-size: 12px;
        }

        .n5 {
          color: #fff;
          font-size: 12px;
        }
      }
    }

    .c-center {
      width: 76%;
      background-color: #000d3a;
      box-sizing: border-box;
      position: relative;
      left: -0.5%;

      .center-header {
        background-color: #000d3a;
        height: 10.7%;
        display: flex;
        //justify-content: center;
        margin-left: 120px;
        //align-items: center;
        font-size: 50px;
        font-weight: bold;
        letter-spacing: 5px;
        line-height: 130px;
      }

      .center-head {
        width: 300px;
        height: 60px;
        position: absolute;
        right: 60px;
        top: 30px;
        display: flex;
        text-align: center;

        .left {
          width: 40%;
          font-size: 40px;
          line-height: 70px;
          font-weight: bold;
        }

        .right {
          width: 60%;
          font-size: 25px;
          line-height: 35px;
        }
      }

      .center-content {
        height: 965px;
        padding: 1rem;
        box-sizing: border-box;
        z-index: -10;

        .items {
          height: 100%;
          padding: 1rem;
          box-sizing: border-box;

          .item-head {
            height: 10rem;
            display: grid;
            grid-template-columns: repeat(3, 33.3%);
            grid-template-rows: repeat(2, 50%);
            justify-items: center;
            align-content: center;
            box-sizing: border-box;
            padding-bottom: 1rem;

            background: linear-gradient(90deg, #043079 50%, transparent 0) repeat-x,
            linear-gradient(90deg, #043079 50%, transparent 0) repeat-x,
            linear-gradient(0deg, #043079 50%, transparent 0) repeat-y,
            linear-gradient(0deg, #043079 50%, transparent 0) repeat-y;
            background-size: 0px 10px, 20px 10px, 10px 0px, 10px 0px;
            background-position: 0 0, 0 100%, 0 0, 100% 0;

            animation: linearGradientMove 0.3s infinite linear;
          }

          @keyframes linearGradientMove {
            100% {
              background-position: -20px 0, 20px 100%, 0 20px, 100% -20px;
            }
          }

          .item-content {
            box-sizing: border-box;
            margin-top: 50px;
            box-sizing: border-box;

            .bg {
              width: 100%;
              height: 100%;
              background-size: 100% 100%;
            }

            .btns {
              position: absolute;
              margin-left: 1rem;
              z-index: 999;

              div {
                border: 2px solid #244d71;
                background-color: #000d3a;
                color: #ffffff;
                padding: 0.5rem 2rem;
                margin: 0.5rem 0;
                font-size: 1.2rem;
              }
            }

            .center-tab {
              position: absolute;
              margin-left: calc(50% - 22.5rem);
              margin-top: 0rem;
              width: 45rem;
              height: 10rem;

              box-sizing: border-box;
              //box-shadow: inset 0 0 3rem rgb(24, 78, 135);
            }

          }

          .item-head > div {
            display: flex;
            align-items: center;
            width: 15rem;

            img {
              height: 4.5rem;
              width: 4.5rem;
              object-fit: cover;
            }

            .data {
              display: flex;
              flex-direction: column;

              .data-value {
                font-size: 1.5rem;
                font-weight: bold;
              }
            }
          }
        }

        .middle-bottom {
          width: 100%;
          height: 315px;
          box-sizing: border-box;
          margin-top: 10px;
          display: flex;

          .middle-bottom-left {
            width: 37%;
          }

          .middle-bottom-middle {
            width: 37%;
            margin: 0 3px;
          }

          .middle-bottom-right {
            width: 27%;
          }
        }
      }

      .center-bottom {
        height: 300px;
        padding: 1rem;
        box-sizing: border-box;
      }
    }

    .c-right {
      width: 25%;
      background-color: #000d3a;

      border-left: 1px solid #3d4a61;

      .right-header {
        background-color: #000d3a;
        height: 13.2rem;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 4rem;
      }

      .right-content {
        height: calc(100% - 8rem);
      }
    }

    .items {
      height: 30%;
      width: 100%;
      box-sizing: border-box;
      /*右下*/
      box-shadow: inset 0 0 3rem rgb(24, 78, 135);

      .title {
        height: 15%;
        display: flex;
        align-items: center;
        padding-left: 10%;
        box-sizing: border-box;

        .sign {
          height: 60%;
          width: 1rem;
          background-color: #016eea;
        }

        .text {
          color: white;
          font-size: 1.7rem;
          box-sizing: border-box;
          margin-left: 1.2rem;
        }
      }
    }

    .items > div:last-child {
      height: 85%;
      width: 100%;
    }
  }
}

.topWorkStatus {
  //height: 300px;
  position: fixed;
  top: 150px;
  left: 550px;
  width: 1330px;
  z-index: 10;
  display: flex;
  justify-content: space-evenly;
  background-color: rgba(0, 0, 0, .0);

  .item {
    display: flex;
    width: 200px;

    .left {
      width: 75px;
      height: 60px;
      background: url("~@/../src/assets/time.png") no-repeat !important;
      background-size: 100% 100% !important;
      margin-right: 10px;
    }

    .right {
      background-color: rgba(0, 0, 0, .0) !important;

      .top {
        font-size: 22px;
        font-weight: 700;
      }

      .bottom {
        font-size: 20px;
        font-weight: 700;
      }
    }
  }

  .item1 {
    .right > .bottom {
      color: #4572a7;
    }
  }

  .item2 {
    margin: 0 0px;

    .right > .bottom {
      color: #f9bf00;
    }
  }

  .item3 {
    .right > .bottom {
      color: #479867;
    }
  }
}

.right {
  width: 100%;
  height: 100%;
  background-color: #000d3a;
  padding-left: 1.5%;
  box-sizing: border-box;

  .right-head {
    height: 12%;
    display: flex;
    justify-content: flex-end;

    span {
      margin: 25px;
      margin-top: 40px;
      font-weight: 700;
      font-size: 35px;
      color: #fff;
    }
  }

  .main {
    height: 90%;

    .top {
      width: 100%;
      height: 35%;

      .cook-list {
        width: 100%;
        height: 80%;
        display: flex;
        flex-wrap: wrap;
      }
    }

    .center {
      width: 100%;
      height: 25%;

      .center-main {
        width: 100%;
        height: 90%;

        .center-left {
          height: 100%;

          .left-top {
            height: 50%;
            display: flex;

            div {
              width: 33.33%;
              height: 100%;
            }
          }

          .left-bottom {
            height: 50%;
          }
        }

        .center-right {
          width: 40%;
          height: 100%;

          > span {
            color: #fff;
          }

          ::v-deep .row-item {
            .ceil {
              padding: 0;
            }
          }
        }
      }
    }

    .bottom {
      width: 100%;
      height: 35%;

      .bottom-top {
        display: flex;
        width: 100%;
        height: 45%;

        .andong-left {
          width: 60%;
          height: 100%;

          > span {
            color: #fff;
          }

          .analyse {
            width: 100%;
            height: 90%;
          }
        }

        .andong-right {
          width: 40%;
          height: 100%;

          > span {
            color: #fff;
          }

          .call {
            width: 100%;
            height: 90%;
          }
        }
      }

      .bottom-bottom {
        width: 100%;
        height: 44.5%;

        ::v-deep .header-item {
          font-size: 6px;
          padding: 0;
        }

        ::v-deep .row-item {
          font-size: 4px;
          padding: 0;

          .ceil {
            padding: 0;
          }
        }
      }
    }
  }
}

.roll-table {
  border: 1px solid #22405c;
  width: 94%;
  margin-left: 3%;
  height: 250px;
  overflow: hidden;
}

.roll-table-box, .roll-box {
  display: flex;
  justify-content: space-around;
}

.roll-table-box div,
.roll-box div {
  flex: 1;
  text-align: center;
  height: 28px;
  line-height: 28px;
  font-size: 10px;
  overflow: hidden;
}

.roll-table-box div {
  overflow: auto;
  word-wrap: break-word; /* 允许在长单词内部换行 */
  word-break: break-all; /* 允许在任意位置换行 */
  white-space: normal; /* 处理空白符，自动换行 */
  height: 30px;
  line-height: 30px;
  font-size: 11px;
  font-weight: 700;
}

.roll-box {
  display: flex;
}

.table-title {
  width: 100%;
  text-align: center;
  color: #016f74;
  font-size: 20px;
  font-weight: bold;
}

.robot-table {
  width: 100%;
  text-align: center;
  border-collapse: collapse;
  font-size: 15px;
  margin: 10px 0;

  tr {
    border: 3px solid #132d4e;
    height: 40px;
  }

  td {
    .status {
      display: inline-block;
      width: 20px;
      height: 20px;
      border-radius: 10px;
      background-color: #98d87d;
      float: right;
      position: relative;
      right: 10px;
    }
  }
}

span {
  font-size: 13px;
}

.redColor {
  color: #ae021a !important;
}

.red2Color {
  color: #e44035 !important;
}

.yellowColor {
  color: #b89112 !important;
}

.greenColor {
  color: #00b153 !important;
}

.inputvideo {
  //position: fixed;
  //bottom: 0;
  //left: 0px;
  height: 570px;
  width: 100%;

  .video-player {
    height: 570px;

    video {
      width: 100%; /* 视频宽度占满容器 */
      height: 100%; /* 视频高度占满容器 */
      object-fit: fill; /* 视频内容拉伸以填满整个容器，不保持宽高比 */
    }
  }
}

.spcData {
  float: right;
  color: rgb(165, 166, 168);
  font-size: 12px;
  margin-top: 10px;
  margin-right: 30px;
  z-index: 10;
  position: relative;
}

.flex-box-top {
  display: flex;
  position: fixed;
  top: 140px;
  left: 27%;
  width: 71%;
  height: 10vh;
  z-index: 100;
  text-align: center;
  justify-content: space-evenly;

  .item-box {

    .item-box-icon {
      width: 100px;
      height: 80px;
      margin: 0 auto;
      font-size: 60px;
      color: #fff;
    }

    .item-box-label {
      font-size: 20px;
      font-weight: 700;
      color: #fff;
    }
  }
}

::v-deep .v-model {
  display: none;
}

::v-deep .video-js .vjs-tech {
  object-fit: fill;
}

::v-deep .vjs-poster {
  background-size: cover;
}

::v-deep .video-js {
  height: 570px !important;
  z-index: 10;
}

</style>
