<template>
  <div class="container" :style="{ width: `${style.width}px`, height: `${style.height}px`, transform: `${style.transform}` }">
    <div class="content">
      <div class="c-left">
        <div class="left-header">
          <div>
            <img :src="titlePng" alt="logo" />
          </div>
        </div>
        <div class="left-content">
          <div class="main">
            <dv-border-box-12 style="padding: 10px; width: 95%; height: 94%">
              <div style="margin: 5px 0 5px 10px">
                <span style="width: 20px;height: 10px;background: #016ce9;display: inline-block;"></span>
                <span style="color: #fff"> 生产信息</span>
              </div>
              <div class="plan-info">
                <el-row>
                  <el-col :span="12">
                    <span>车型：</span>
                    <span style="color: #00b153">{{planCountInfo.productType}}</span>
                  </el-col>
                  <el-col :span="12">
                    <span>当班计划：</span>
                    <span style="color: #00b153">{{planCountInfo.beatPlanCount}}</span>
                  </el-col>
                </el-row>
                <el-row style="margin-top: 30px">
                  <el-col :span="12">
                    <span>应到人数：</span>
                    <span style="color: #00b153">{{planCountInfo.peopleCountExpectedArrive}}</span>
                  </el-col>
                  <el-col :span="12">
                    <span>实到人数：</span>
                    <span style="color: #00b153">{{planCountInfo.peopleCountCActualArrive}}</span>
                  </el-col>
                </el-row>
                <el-row style="margin-top: 30px">
                  <div style="display: flex;align-items: center;">
                    <span style="letter-spacing: 5px">出勤率：</span>
                    <div style="width: 250px">
                      <el-progress :text-inside="true" :stroke-width="15" :percentage="planCountInfo.attendanceRate"></el-progress>
                    </div>
                  </div>
                </el-row>
                <el-row style="margin-top: 30px">
                  <el-col :span="12">
                    <span>当前计划：</span>
                    <span style="color: #00b153">{{planCountInfo.currentPlan}}</span>
                  </el-col>
                  <el-col :span="12">
                    <span>实际完成：</span>
                    <span style="color: #00b153">{{planCountInfo.finishCount}}</span>
                  </el-col>
                </el-row>
                <el-row style="margin-top: 30px">
                  <div style="display: flex;align-items: center;">
                    <span>生产进度：</span>
                    <div style="width: 250px">
                      <el-progress :text-inside="true" :stroke-width="15" :percentage="planCountInfo.finishRate"></el-progress>
                    </div>
                  </div>
                </el-row>
              </div>
            </dv-border-box-12>
          </div>
          <div class="main2">
            <dv-border-box-12 style="padding: 5px 10px; width: 95%; height: 96.5%">
              <div style="margin: 5px 0 5px 10px">
                <span style="width: 20px;height: 10px;background: #016ce9;display: inline-block;"></span>
                <span style="color: #fff"> 综合可动率</span>
              </div>
              <div style="position: relative; top: 0px">
                <div id="leftMiddlePie" style="height: 280px"></div>
              </div>
            </dv-border-box-12>
          </div>
          <div class="main3">
            <dv-border-box-12 style="padding: 5px 10px; width: 95%; height: 89%">
              <div style="margin: 5px 0 5px 10px">
                <span style="width: 20px;height: 10px;background: #016ce9;display: inline-block;"></span>
                <span style="color: #fff"> OEE</span>
              </div>
              <div style="position: relative; top: 0px">
                <div id="leftBottomPie" style="height: 280px"></div>
              </div>
            </dv-border-box-12>
          </div>
        </div>
      </div>
      <div class="c-center">
        <div class="center-header">前悬装配线智慧系统</div>
        <div class="center-content" v-if="refreshTab">
          <dv-border-box-12 class="items">
            <div style="margin: 5px 0 5px 10px">
              <span style="width: 20px;height: 10px;background: #016ce9;display: inline-block;"></span>
              <span style="color: #fff"> 统计计数</span>
            </div>
            <el-col :span="1">
              <div style="display: flex;flex-direction: column;">
                <br>
                <br>
                <br>
                <div style="width: 15px;word-wrap: break-word;word-break:break-all; ">生产效能</div>
                <br>
                <br>
                <br>
                <br>
                <br>
                <br>
                <div style="width: 15px;word-wrap: break-word;word-break:break-all; ">电能成本</div>
                <br>
                <br>
                <br>
                <br>
                <br>
                <br>
                <div style="width: 15px;word-wrap: break-word;word-break:break-all; ">OEE效率显示</div>
                <br>
                <br>
                <br>
                <br>
                <br>
                <div style="width: 15px;word-wrap: break-word;word-break:break-all; ">停机时间</div>
              </div>

            </el-col>
            <el-col :span="23">
              <div style="position: relative; top: 0px">
                <div id="centerTopPie" style="height: 225px"></div>
              </div>
              <div style="position: relative; top: 0px">
                <div id="centerMiddlePie" style="height: 225px"></div>
              </div>
              <div style="position: relative; top: 0px">
                <div id="centerBottomPie" style="height: 225px"></div>
              </div>
              <div style="position: relative; top: 0px">
                <div id="centerBottomPie1" style="height: 225px"></div>
              </div>
            </el-col>
          </dv-border-box-12>
        </div>
      </div>
      <div class="c-right">
        <div class="right">
          <div class="right-head">
            <span>{{ time }}</span>
          </div>
          <div class="main">
            <div class="top">
              <dv-border-box-12 style="padding: 5px 10px 14px 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"> 抽检计时(分钟)</span>
                </div>
                <div style="position: relative; top: 0px">
                  <div id="rightTopColumnar" style="height: 250px"></div>
                  <div class="spot-check">
                    <el-row style="font-size: 1.5rem;text-align: center">
                      <el-col :span="8">
                        <span>计划抽检次数：</span>
                        <span style="color: #00b153">{{rightTopPieData_text.planCheckCount}}</span>
                      </el-col>
                      <el-col :span="8">
                        <span>已抽检次数：</span>
                        <span style="color: #00b153">{{rightTopPieData_text.activityCheckCount}}</span>
                      </el-col>
                      <el-col :span="8">
                        <span>合格次数：</span>
                        <span style="color: #00b153">{{rightTopPieData_text.checkOkRate}}</span>
                      </el-col>
                    </el-row>
                  </div>
                </div>
              </dv-border-box-12>
            </div>
            <div class="center">
              <dv-border-box-12 style="padding: 5px 10px; width: 95%; height: 97%">
                <div style="margin: 5px 0 5px 10px">
                  <span style="width: 20px;height: 10px;background: #016ce9;display: inline-block;"></span>
                  <span style="color: #fff"> 年度计划</span>
                </div>
                <div>
                  <div id="rightMiddlePie" style="height: 230px"></div>
                  <div class="year-plan">
                    <el-row style="font-size: 1.5rem;text-align: center">
                      <el-col :span="12">
                        <span>计划生产数量：</span>
                        <span style="color: #00b153">{{rightMiddlePieData.currentPlan}}</span>
                      </el-col>
                      <el-col :span="12">
                        <span>实际生产数量：</span>
                        <span style="color: #00b153">{{rightMiddlePieData.finishCount}}</span>
                      </el-col>
                    </el-row>
                    <div style="width: 350px;margin: 5px 0 0 10px">
                      <el-progress :text-inside="true" :stroke-width="15" :percentage="rightMiddlePieData.finishRate"></el-progress>
                    </div>
                  </div>
                </div>
              </dv-border-box-12>
            </div>
            <div class="bottom">
              <dv-border-box-12 style="padding: 5px 10px; width: 95%; height: 94%">
                <div style="margin: 5px 0 5px 10px">
                  <span style="width: 20px;height: 10px;background: #016ce9;display: inline-block;"></span>
                  <span style="color: #fff"> 月度计划</span>
                </div>
                <div id="rightBottomPie" style="height: 210px"></div>
                <div class="year-plan">
                  <el-row style="font-size: 1.5rem;text-align: center">
                    <el-col :span="12">
                      <span>计划生产数量：</span>
                      <span style="color: #00b153">{{rightBottomPieData.currentPlan}}</span>
                    </el-col>
                    <el-col :span="12">
                      <span>实际生产数量：</span>
                      <span style="color: #00b153">{{rightBottomPieData.finishCount}}</span>
                    </el-col>
                  </el-row>
                  <div style="width: 350px;margin: 5px 0 0 10px">
                    <el-progress :text-inside="true" :stroke-width="15" :percentage="rightBottomPieData.finishRate"></el-progress>
                  </div>
                </div>
              </dv-border-box-12>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>

import { opname, mqttIp, mqttPort } from '@/utils/request'
import * as echarts from 'echarts'
import axios from 'axios'
import mqtt from 'mqtt'
import LineStatus from '@/views/LineStatus.vue'
const leftTopColumnar = null // 左上曲线
let leftMiddlePie = null // 左中饼图
let leftBottomPie = null // 左下饼图

let centerTopPie = null // 中上下饼图
let centerMiddlePie = null // 中中饼图
let centerBottomPie = null // 中下饼图
let centerBottomPie1 = null // 中下饼图

let rightTopColumnar = null // 右上柱状
let rightMiddlePie = null // 右中饼图
let rightBottomPie = null // 右下饼图
export default {
  data() {
    return {
      viewType: 1,
      titlePng: '',
      mqttClient: null,
      dt_IframeUrl: '',
      refreshTab: true,
      planCountInfo: {
        productType: '',
        beatPlanCount: 0,
        peopleCountExpectedArrive: 0,
        peopleCountCActualArrive: 0,
        attendanceRate: 0,
        currentPlan: 0,
        finishCount: 0,
        finishRate: 0
      },

      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',
      开始日期: '',

      middleButton: null, // 中间不知道啥图

      leftTopColumnarOption: null, // 左上曲线配置
      leftMiddlePieOption: null, // 左中饼图配置
      leftBottomPieOption: null, // 左下饼图配置

      centerTopPieOption: null, // 中上不知道啥图配置
      centerMiddlePieOption: null, // 中中不知道啥图配置
      centerBottomPieOption: null, // 中下不知道啥图配置
      centerBottomPieOption1: null, // 中下不知道啥图配置

      rightTopColumnarOption: null, // 右上柱状配置
      rightMiddlePieOption: null, // 右中饼图配置

      leftTopCurveX: [],
      leftTopCurveXData1: [],
      leftTopCurveXData2: [],
      leftTopCurveXData3: [],
      leftTopCurveXData4: [],
      leftBottomColumnarX: [],
      leftBottomColumnarXData1: [],
      leftBottomColumnarXData2: [],
      leftBottomColumnarXData3: [],
      rightMiddleCurveX: [],
      rightMiddleCurveXData1: [],
      rightMiddleCurveXData2: [],
      rightMiddleCurveXData3: [],
      rightBottomPieDataColor: ['#49a9ee', '#98d87d', '#ffd86e', '#f3857b', '#8996e6'],

      style: {
        width: '1920',
        height: '1080',
        transform: 'scaleY(1) scaleX(1) translate(-50%, -50%)'
      },
      timer: '',
      timer1: '',
      time: 'time',
      deviceStatus_colors: ['grey', 'orange', 'green', 'red'],
      deviceStatus_state: ['关机', '待机', '运行', '报警'],
      deviceStatus_table: [],
      leftTopColumnarX: [],
      leftTopColumnarXData: [],
      rightTopColumnarXData: [],
      rightTopPieData: 0,
      rightTopPieData_text: {
        planCheckCount: 0,
        activityCheckCount: 0,
        checkOkRate: 0
      },
      leftMiddlePieData: 0,
      leftBottomPieData: 0,
      rightMiddlePieDataX: [],
      rightMiddlePieDataY: [],
      rightMiddlePieData: {
        currentPlan: 0,
        finishCount: 0,
        finishRate: 0
      },
      // rightMiddlePieDataX: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
      // rightMiddlePieDataY: [150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135],
      rightBottomPieDataX: [],
      rightBottomPieDataY: [],
      rightBottomPieData: {
        currentPlan: 0,
        finishCount: 0,
        finishRate: 0
      },
      // rightBottomPieDataX: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
      // rightBottomPieDataY: [150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 218, 135],
      centerTopPieDataX: [],
      centerTopPieDataY1: [],
      centerTopPieDataY2: [],
      centerTopPieDataY3: [],
      // centerTopPieDataX: ['11月1日',
      //   '11月2日',
      //   '11月3日',
      //   '11月4日',
      //   '11月5日',
      //   '11月6日',
      //   '11月7日',
      //   '11月8日',
      //   '11月9日',
      //   '11月10日',
      //   '11月11日',
      //   '11月12日',
      //   '11月13日',
      //   '11月14日',
      //   '11月15日',
      //   '11月16日',
      //   '11月17日',
      //   '11月18日',
      //   '11月19日',
      //   '11月20日',
      //   '11月21日',
      //   '11月22日',
      //   '11月23日',
      //   '11月24日',
      //   '11月25日',
      //   '11月26日',
      //   '11月27日',
      //   '11月28日',
      //   '11月29日',
      //   '11月30日'
      // ],
      // centerTopPieDataY1: [150, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 230, 224, 218, 135, 147, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 260, 150, 230, 224],
      // centerTopPieDataY2: [100, 100, 130, 124, 208, 175, 177, 270, 170, 270, 204, 180, 124, 268, 105, 247, 250, 130, 124, 208, 165, 177, 210, 100, 230, 234, 200, 180, 250, 20],
      // centerTopPieDataY3: [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],

      centerMiddlePieDataX: [],
      centerMiddlePieDataY1: [],
      centerMiddlePieDataY2: [],
      centerMiddlePieDataY3: [],
      // centerMiddlePieDataX: ['11月1日',
      //   '11月2日',
      //   '11月3日',
      //   '11月4日',
      //   '11月5日',
      //   '11月6日',
      //   '11月7日',
      //   '11月8日',
      //   '11月9日',
      //   '11月10日',
      //   '11月11日',
      //   '11月12日',
      //   '11月13日',
      //   '11月14日',
      //   '11月15日',
      //   '11月16日',
      //   '11月17日',
      //   '11月18日',
      //   '11月19日',
      //   '11月20日',
      //   '11月21日',
      //   '11月22日',
      //   '11月23日',
      //   '11月24日',
      //   '11月25日',
      //   '11月26日',
      //   '11月27日',
      //   '11月28日',
      //   '11月29日',
      //   '11月30日'
      // ],
      // centerMiddlePieDataY1: [150, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 230, 224, 218, 135, 147, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 260, 150, 230, 224],
      // centerMiddlePieDataY2: [100, 100, 130, 124, 208, 175, 177, 270, 170, 270, 204, 180, 124, 268, 105, 247, 250, 130, 124, 208, 165, 177, 210, 100, 230, 234, 200, 180, 250, 20],
      // centerMiddlePieDataY3: [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
      centerBottomPieDataX: [],
      centerBottomPieDataY1: [],
      centerBottomPieDataY2: [],
      centerBottomPieDataY3: [],

      // centerBottomPieDataX: ['11月1日',
      //   '11月2日',
      //   '11月3日',
      //   '11月4日',
      //   '11月5日',
      //   '11月6日',
      //   '11月7日',
      //   '11月8日',
      //   '11月9日',
      //   '11月10日',
      //   '11月11日',
      //   '11月12日',
      //   '11月13日',
      //   '11月14日',
      //   '11月15日',
      //   '11月16日',
      //   '11月17日',
      //   '11月18日',
      //   '11月19日',
      //   '11月20日',
      //   '11月21日',
      //   '11月22日',
      //   '11月23日',
      //   '11月24日',
      //   '11月25日',
      //   '11月26日',
      //   '11月27日',
      //   '11月28日',
      //   '11月29日',
      //   '11月30日'
      // ],
      // centerBottomPieDataY1: [150, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 230, 224, 218, 135, 147, 150, 230, 224, 218, 135, 147, 260, 150, 230, 224, 260, 150, 230, 224],
      // centerBottomPieDataY2: [100, 100, 130, 124, 208, 175, 177, 270, 170, 270, 204, 180, 124, 268, 105, 247, 250, 130, 124, 208, 165, 177, 210, 100, 230, 234, 200, 180, 250, 20],
      // centerBottomPieDataY3: [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
      centerBottomPieDataX1: [],
      centerBottomPieDataY11: [],
      centerBottomPieDataY12: [],
      centerBottomPieDataY13: [],
      centerBottomPieDataY14: [],
      // centerBottomPieDataX1: [
      //   '11月5日',
      //   '11月6日',
      //   '11月7日',
      //   '11月8日',
      //   '11月9日',
      //   '11月10日',
      //   '11月11日'
      // ],
      // centerBottomPieDataY11: [150, 150, 230, 224, 218, 135, 147],
      // centerBottomPieDataY12: [100, 100, 130, 124, 208, 175, 177],
      // centerBottomPieDataY13: [100, 10, 0, 36, 120, 58, 100],
      // centerBottomPieDataY14: [80, 120, 100, 130, 80, 52, 36],

      stationStatus: {
        'ST10': '2',
        'ST20': '1',
        'ST30': '0',
        'ST40': '-1'
      },
      stationStatusBase: [
        '自动运行',
        '设备待机',
        '报警停机',
        '设备关机'
      ],
      rightMiddlePieColorList: ['#e2ae03', '#aa493c', '#459763', '#49a9ee']
    }
  },
  created() {
    // this.dt_IframeUrl = window.ConnectConfig.dt_IframeUrl
  },
  mounted() {
    const that = this
    // 定时器部分
    this.timer = setInterval(() => {
      this.time = this.getNowTime()
    }, 1000)
    // 页面自适应大小部分
    that.setScale()
    window.addEventListener('resize', () => {
      that.setScale()
    })

    this.getLogo()
    // this.initMqtt()

    // 数据库读取部分
    this.getMainPlanCountInfoData()
    // this.getmidddlelist()
    // this.getOrderDataInfo()
    // this.getWorkDataInfo()
    // this.getUnfinishedDataInfo()
    // this.getContract2DataInfo()
    // this.getLackDataInfo()
    // this.getQualityDataInfo()
    // this.getContractMainDataInfo()

    // echarts图表绘制部分
    this.initEchartDom()
    this.setEchartData()

    this.timer = setInterval(() => {
      this.setEchartData()
    }, 3000)
    this.timer1 = setInterval(() => {
    }, 3000)
  },
  beforeDestroy() {
    clearInterval(this.timer)
    clearInterval(this.timer1)
  },
  methods: {
    getMainType(type) {
      return type === this.viewType ? 'warning' : 'primary'
    },
    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() {
      leftMiddlePie = echarts.init(document.getElementById('leftMiddlePie'))
      leftBottomPie = echarts.init(document.getElementById('leftBottomPie'))

      centerTopPie = echarts.init(document.getElementById('centerTopPie'))
      centerMiddlePie = echarts.init(document.getElementById('centerMiddlePie'))
      centerBottomPie = echarts.init(document.getElementById('centerBottomPie'))
      centerBottomPie1 = echarts.init(document.getElementById('centerBottomPie1'))

      rightTopColumnar = echarts.init(document.getElementById('rightTopColumnar'))
      rightMiddlePie = echarts.init(document.getElementById('rightMiddlePie'))
      rightBottomPie = echarts.init(document.getElementById('rightBottomPie'))
    },
    setEchartData() {
      this.getMainPlanCountInfoData()

      this.getLeftMiddlePieData()
      this.getLeftBottomPieData()

      this.getCenterTopColumnarData()
      this.getCenterMiddlePieData()
      this.getCenterBottomPieData()
      this.getCenterBottomPieData1()

      this.getRightTopColumnarData()
      this.getRightMiddlePieData()
      this.getRightMiddlePieData_text()
      this.getRightBottomPieData()
      this.getRightBottomPieData_text()
    },
    setRealData() {

    },
    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 {
        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())
        }
      })
    },
    websocketonmessage(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 'MES':
          switch (dataType) {
            case 'C_B_DeviceInfo': {
              {
                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
      }
    },
    getMainPlanCountInfoData() {
      const data = this.CreateData1('11', 'TV_生产信息_查询_QX')
      this.ExecDatabase(data).then((res) => {
        this.planCountInfo.planCountInfo = res.data[0].车型
        this.planCountInfo.beatPlanCount = res.data[0].当班计划
        this.planCountInfo.peopleCountExpectedArrive = res.data[0].应到人数
        this.planCountInfo.peopleCountCActualArrive = res.data[0].实到人数
        this.planCountInfo.attendanceRate = res.data[0].出勤率
        this.planCountInfo.currentPlan = res.data[0].当前计划
        this.planCountInfo.finishCount = res.data[0].实际完成
        this.planCountInfo.finishRate = res.data[0].生产进度
      })
    },
    getRightMiddlePieData() {
      const data = this.CreateData1('11', 'TV_年计划_查询_HX')
      this.ExecDatabase(data).then((res) => {
        this.rightMiddlePieDataX = []
        this.rightMiddlePieDataY = []
        if (res.data.length <= 0) { return }
        for (let i = 0; i < res.data.length; i++) {
          this.rightMiddlePieDataX.push(res.data[i]['月份'])
          this.rightMiddlePieDataY.push(res.data[i]['计划产量'])
        }
      }).then(() => {
        this.rightMiddlePieOptionSet()
      })
    },
    getRightMiddlePieData_text() {
      const data = this.CreateData1('11', 'TV_年计划进度_查询_HX')
      this.ExecDatabase(data).then((res) => {
        console.log(res.data)
        if (res.data.length <= 0) { return }
        this.rightMiddlePieData.currentPlan = res.data[0]['当前计划']
        this.rightMiddlePieData.finishCount = res.data[0]['实际完成']
        this.rightMiddlePieData.finishRate = res.data[0]['生产进度']
      })
    },
    getRightBottomPieData() {
      this.rightBottomPieOptionSet()
      const data = this.CreateData1('11', 'TV_月计划_查询_HX')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) { return }
        this.rightBottomPieDataX = []
        this.rightBottomPieDataY = []
        for (let i = 0; i < res.data.length; i++) {
          this.rightBottomPieDataX.push(res.data[i]['天'])
          this.rightBottomPieDataY.push(res.data[i]['计划产量'])
        }
      }).then(() => {
        this.rightBottomPieOptionSet()
      })
    },
    getRightBottomPieData_text() {
      const data = this.CreateData1('11', 'TV_月计划进度_查询_HX')
      this.ExecDatabase(data).then((res) => {
        console.log(res.data)
        if (res.data.length <= 0) { return }
        this.rightBottomPieData.currentPlan = res.data[0]['当前计划']
        this.rightBottomPieData.finishCount = res.data[0]['实际完成']
        this.rightBottomPieData.finishRate = res.data[0]['生产进度']
      })
    },
    getLeftMiddlePieData() {
      const data = this.CreateData1('11', 'TV_综合可动率_查询_HX')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) { return }
        this.leftMiddlePieData = res.data[0].综合可动率
      }).then(() => {
        this.leftMiddlePieOptionSet()
      })
    },
    getLeftBottomPieData() {
      const data = this.CreateData1('11', 'TV_OEE_查询_HX')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) { return }
        this.leftBottomPieData = res.data[0].OEE
      }).then(() => {
        this.leftBottomPieOptionSet()
      })
    },
    getRightTopColumnarData() {
      const data = this.CreateData1('11', 'TV_抽检计时_查询_HX')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) { return }
        this.rightTopPieData = res.data[0].合格率
        this.rightTopPieData_text.planCheckCount = res.data[0].计划抽检次数
        this.rightTopPieData_text.activityCheckCount = res.data[0].已经抽检次数
        this.rightTopPieData_text.checkOkRate = res.data[0].合格次数
      }).then(() => {
        this.rightTopColumnarOptionSet()
      })
    },

    getCenterTopColumnarData() {
      const data = this.CreateData1('11', 'TV_生产效能折线_查询_HX')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) { return }
        this.centerTopPieDataX = []
        this.centerTopPieDataY1 = []
        this.centerTopPieDataY2 = []
        this.centerTopPieDataY3 = []
        for (let i = 0; i < res.data.length; i++) {
          const ele = res.data[i]
          this.centerTopPieDataX.push(ele.日期)
          this.centerTopPieDataY1.push(ele.白班效能)
          this.centerTopPieDataY2.push(ele.夜班效能)
          this.centerTopPieDataY3.push(ele.平均效能)
        }
      }).then(() => {
        this.centerTopColumnarOptionSet()
      })
    },
    centerTopColumnarOptionSet() {
      this.centerTopPieOption = {
        tooltip: {
          trigger: 'item'
        },
        legend: {
          textStyle: {
            color: '#fff',
            fontSize: '0.8rem'
          }
        },
        grid: { // 绘图网格
          left: '10px',
          right: '4%',
          top: '10%',
          bottom: '0px',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: this.centerTopPieDataX,
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          axisLabel: {
            interval: 0, // 显示所有标签
            rotate: 40,
            fontSize: 10, // 设置x轴文字的大小
            color: '#ffffff'
          }
        },
        yAxis: {
          type: 'value',
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          splitLine: {
            show: false
          }
        },
        series: [
          {
            name: '白班',
            data: this.centerTopPieDataY1,
            type: 'line'
          },
          {
            name: '夜班',
            data: this.centerTopPieDataY2,
            type: 'line'
          },
          {
            name: '平均',
            data: this.centerTopPieDataY3,
            type: 'line'
          }
        ]
      }
      centerTopPie.setOption(this.centerTopPieOption)
    },
    getCenterMiddlePieData() {
      const data = this.CreateData1('11', 'TV_电能成本折线_查询_HX')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) { return }
        this.centerMiddlePieDataX = []
        this.centerMiddlePieDataY1 = []
        this.centerMiddlePieDataY2 = []
        this.centerMiddlePieDataY3 = []
        for (let i = 0; i < res.data.length; i++) {
          const ele = res.data[i]
          this.centerMiddlePieDataX.push(ele.日期)
          this.centerMiddlePieDataY1.push(ele.白班能耗)
          this.centerMiddlePieDataY2.push(ele.夜班能耗)
          this.centerMiddlePieDataY3.push(ele.平均能耗)
        }
      }).then(() => {
        this.centerMiddleColumnarOptionSet()
      })
    },
    centerMiddleColumnarOptionSet() {
      this.centerMiddlePieOption = {
        tooltip: {
          trigger: 'item'
        },
        legend: {
          textStyle: {
            color: '#fff',
            fontSize: '0.8rem'
          }
        },
        grid: { // 绘图网格
          left: '10px',
          right: '4%',
          top: '10%',
          bottom: '0px',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: this.centerMiddlePieDataX,
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          axisLabel: {
            interval: 0, // 显示所有标签
            rotate: 40,
            fontSize: 10, // 设置x轴文字的大小
            color: '#ffffff'
          }
        },
        yAxis: {
          type: 'value',
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          splitLine: {
            show: false
          }
        },
        series: [
          {
            name: '白班',
            data: this.centerMiddlePieDataY1,
            type: 'line'
          },
          {
            name: '夜班',
            data: this.centerMiddlePieDataY2,
            type: 'line'
          },
          {
            name: '平均',
            data: this.centerMiddlePieDataY3,
            type: 'line'
          }
        ]
      }
      centerMiddlePie.setOption(this.centerMiddlePieOption)
    },
    getCenterBottomPieData() {
      const data = this.CreateData1('11', 'TV_OEE折线_查询_HX')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) { return }
        this.centerBottomPieDataX = []
        this.centerBottomPieDataY1 = []
        this.centerBottomPieDataY2 = []
        this.centerBottomPieDataY3 = []
        for (let i = 0; i < res.data.length; i++) {
          const ele = res.data[i]
          this.centerBottomPieDataX.push(ele.日期)
          this.centerBottomPieDataY1.push(ele.白班OEE)
          this.centerBottomPieDataY2.push(ele.夜班OEE)
          this.centerBottomPieDataY3.push(ele.平均OEE)
        }
      }).then(() => {
        this.centerBottomColumnarOptionSet()
      })
    },
    centerBottomColumnarOptionSet() {
      this.centerBottomPieOption = {
        tooltip: {
          trigger: 'item'
        },
        legend: {
          textStyle: {
            color: '#fff',
            fontSize: '0.8rem'
          }
        },
        grid: { // 绘图网格
          left: '30px',
          right: '4%',
          top: '10%',
          bottom: '0px',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: this.centerBottomPieDataX,
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          axisLabel: {
            interval: 0, // 显示所有标签
            rotate: 40,
            fontSize: 10, // 设置x轴文字的大小
            color: '#ffffff'
          }
        },
        yAxis: {
          type: 'value',
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          splitLine: {
            show: false
          }
        },
        series: [
          {
            name: '白班',
            data: this.centerBottomPieDataY1,
            type: 'line'
          },
          {
            name: '夜班',
            data: this.centerBottomPieDataY2,
            type: 'line'
          },
          {
            name: '平均',
            data: this.centerBottomPieDataY3,
            type: 'line'
          }
        ]
      }
      centerBottomPie.setOption(this.centerBottomPieOption)
    },
    getCenterBottomPieData1() {
      const data = this.CreateData1('11', 'TV_停机时间折线_查询_HX')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) { return }
        this.centerBottomPieDataX1 = []
        this.centerBottomPieDataY11 = []
        this.centerBottomPieDataY12 = []
        this.centerBottomPieDataY13 = []
        this.centerBottomPieDataY14 = []
        for (let i = 0; i < res.data.length; i++) {
          const ele = res.data[i]
          this.centerBottomPieDataX1.push(ele.日期1)
          this.centerBottomPieDataY11.push(ele.设备停线)
          this.centerBottomPieDataY12.push(ele.工艺停线)
          this.centerBottomPieDataY13.push(ele.物料停线)
          this.centerBottomPieDataY14.push(ele.品质停线)
        }
      }).then(() => {
        this.centerBottomColumnarOptionSet1()
      })
    },
    centerBottomColumnarOptionSet1() {
      this.centerBottomPieOption1 = {
        tooltip: {
          trigger: 'item'
        },
        legend: {
          textStyle: {
            color: '#fff',
            fontSize: '0.8rem'
          }
        },
        grid: { // 绘图网格
          left: '10px',
          right: '4%',
          top: '10%',
          bottom: '0px',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: this.centerBottomPieDataX1,
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          axisLabel: {
            interval: 0, // 显示所有标签
            rotate: 40,
            fontSize: 10, // 设置x轴文字的大小
            color: '#ffffff'
          }
        },
        yAxis: {
          type: 'value',
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          splitLine: {
            show: false
          }
        },
        series: [
          {
            name: '设备',
            data: this.centerBottomPieDataY11,
            type: 'line'
          },
          {
            name: '工艺',
            data: this.centerBottomPieDataY12,
            type: 'line'
          },
          {
            name: '物料',
            data: this.centerBottomPieDataY13,
            type: 'line'
          },
          {
            name: '品质',
            data: this.centerBottomPieDataY14,
            type: 'line'
          }
        ]
      }
      centerBottomPie1.setOption(this.centerBottomPieOption1)
    },
    getLeftTopColumnarData() {
      const data = this.CreateData1('11', '产量管理_7日产出曲线')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) { return }
        this.leftTopColumnarXData = []
        this.leftTopColumnarX = []
        for (let i = 0; i < res.data.length; i++) {
          const ele = res.data[i]
          this.leftTopColumnarX.push(ele.date.slice(-5))
          this.leftTopColumnarXData.push(ele.num1)
        }
      }).then(() => {
        this.leftTopColumnarOptionSet()
      })
    },
    // 查询设备运行履历
    searchChartData44() {
      this.deviceStatus_table = []
      var param = []
      const data = this.CreateData1('11', '设备管理_设备每分钟状态_查询', param)
      this.ExecDatabase(data).then((response) => {
        this.deviceStatus_table = response.data
      }).then(() => {
        this.drawDashboard44()
      })
    },
    // 设备运行履历
    drawDashboard44() {
      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.middleButton.clear()
      this.middleButtonOption = {
        // 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: '0%',
          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.middleButton.setOption(this.middleButtonOption)
    },
    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)
    },
    rightMiddlePieOptionSet() {
      this.rightMiddlePieOption = {
        tooltip: {
          trigger: 'item'
        },
        grid: { // 绘图网格
          left: '10px',
          right: '4%',
          top: '10%',
          bottom: '0px',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: this.rightMiddlePieDataX,
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          axisLabel: {
            interval: 0, // 显示所有标签
            fontSize: 10, // 设置x轴文字的大小
            color: '#ffffff'
          }
        },
        yAxis: {
          type: 'value',
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          splitLine: {
            show: false
          }
        },
        series: [
          {
            data: this.rightMiddlePieDataY,
            type: 'line'
          }
        ]
      }
      rightMiddlePie.setOption(this.rightMiddlePieOption)
    },
    rightBottomPieOptionSet() {
      this.rightBottomPieOption = {
        tooltip: {
          trigger: 'item'
        },
        grid: { // 绘图网格
          left: '10px',
          right: '4%',
          top: '10%',
          bottom: '0px',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: this.rightBottomPieDataX,
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          axisLabel: {
            interval: 0, // 显示所有标签
            fontSize: 10, // 设置x轴文字的大小
            color: '#ffffff'
          }
        },
        yAxis: {
          type: 'value',
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          splitLine: {
            show: false
          }
        },
        series: [
          {
            data: this.rightBottomPieDataY,
            type: 'line'
          }
        ]
      }
      rightBottomPie.setOption(this.rightBottomPieOption)
    },
    rightTopColumnarOptionSet() {
      const value = this.rightTopPieData
      this.rightTopColumnarOption = {
        title: [{
          text: value + '%',
          left: 'center',
          top: '80%',
          textStyle: {
            color: '#ffffff',
            fontSize: 35,
            fontWeight: 'bold'
          }
        }],
        series: [
          {
            type: 'gauge',
            axisLine: {
              lineStyle: {
                width: 15,
                color: [
                  [0.6, '#ff0000'],
                  [0.8, '#ffcc00'],
                  [1, '#00893d']
                ]
              }
            },
            pointer: {
              itemStyle: {
                color: 'auto'
              }
            },
            axisTick: {
              distance: -15,
              length: 5,
              lineStyle: {
                color: '#fff',
                width: 1
              }
            },
            splitLine: {
              distance: -15,
              length: 15,
              lineStyle: {
                color: '#fff',
                width: 2
              }
            },
            axisLabel: {
              color: 'inherit',
              distance: 20,
              fontSize: 15
            },
            detail: {
              show: false
            },
            data: [
              {
                value: value
              }
            ]
          }
        ]
      }
      rightTopColumnar.setOption(this.rightTopColumnarOption)
    },
    leftMiddlePieOptionSet() {
      const value = this.leftMiddlePieData
      this.leftMiddlePieOption = {
        title: [{
          text: value + '%',
          left: 'center',
          top: '80%',
          textStyle: {
            color: '#ffffff',
            fontSize: 35,
            fontWeight: 'bold'
          }
        }],
        series: [
          {
            type: 'gauge',
            axisLine: {
              lineStyle: {
                width: 15,
                color: [
                  [0.6, '#ff0000'],
                  [0.8, '#ffcc00'],
                  [1, '#00893d']
                ]
              }
            },
            pointer: {
              itemStyle: {
                color: 'auto'
              }
            },
            axisTick: {
              distance: -15,
              length: 5,
              lineStyle: {
                color: '#fff',
                width: 1
              }
            },
            splitLine: {
              distance: -15,
              length: 15,
              lineStyle: {
                color: '#fff',
                width: 2
              }
            },
            axisLabel: {
              color: 'inherit',
              distance: 20,
              fontSize: 15
            },
            detail: {
              show: false
            },
            data: [
              {
                value: value
              }
            ]
          }
        ]
      }
      leftMiddlePie.setOption(this.leftMiddlePieOption)
    },
    leftBottomPieOptionSet() {
      const value = this.leftBottomPieData
      // 进度百分比
      this.leftBottomPieOption = {
        title: [{
          text: value + '%',
          left: 'center',
          top: '80%',
          textStyle: {
            color: '#ffffff',
            fontSize: 35,
            fontWeight: 'bold'
          }
        }],
        series: [
          {
            type: 'gauge',
            axisLine: {
              lineStyle: {
                width: 15,
                color: [
                  [0.6, '#ff0000'],
                  [0.8, '#ffcc00'],
                  [1, '#00893d']
                ]
              }
            },
            pointer: {
              itemStyle: {
                color: 'auto'
              }
            },
            axisTick: {
              distance: -15,
              length: 5,
              lineStyle: {
                color: '#fff',
                width: 1
              }
            },
            splitLine: {
              distance: -15,
              length: 15,
              lineStyle: {
                color: '#fff',
                width: 2
              }
            },
            axisLabel: {
              color: 'inherit',
              distance: 20,
              fontSize: 15
            },
            detail: {
              show: false
            },
            data: [
              {
                value: value
              }
            ]
          }
        ]
      }
      leftBottomPie.setOption(this.leftBottomPieOption)
    },
    leftTopColumnarOptionSet() {
      this.leftTopColumnarOption = {
        grid: {
          top: '10%',
          left: '1%',
          right: '6%',
          bottom: '5%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: this.leftTopColumnarX, // ['08-01', '08-02', '08-03', '08-04', '08-05', '08-06', '08-07', '08-08', '08-09', '08-10'],
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          axisLabel: {
            interval: 0, // 显示所有标签
            fontSize: 10, // 设置x轴文字的大小
            color: '#ffffff'
          }
        },
        yAxis: {
          type: 'value',
          axisLine: {
            show: true,
            lineStyle: {
              color: '#ffffff'
            }
          },
          splitLine: {
            show: false
          },
          axisLabel: {
            color: '#ffffff'
          }
        },
        series: [
          {
            data: this.leftTopColumnarXData, // [120, 200, 150, 80, 70, 110, 130, 130, 98, 115],
            color: '#ffd86e',
            type: 'bar',
            barMaxWidth: 20,
            label: {
              show: true,
              position: 'top',
              color: '#fff',
              formatter: function(data) {
                return data.value === 0 ? '' : data.value
              }
            }
          }
        ]
      }
      leftTopColumnar.setOption(this.leftTopColumnarOption)
    },
    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 date = new Date()
      const month = this.zeroFill(date.getMonth() + 1)
      const day = this.zeroFill(date.getDate())
      const hour = this.zeroFill(date.getHours())
      const minute = this.zeroFill(date.getMinutes())
      const second = this.zeroFill(date.getSeconds())
      return (
        date.getFullYear() +
          '-' +
          month +
          '-' +
          day +
          ' ' +
          hour +
          ':' +
          minute +
          ':' +
          second
      )
    },
    getOpStatus() {
      const data = this.CreateData1('11', '工位管理_工位基础信息_查询')
      this.ExecDatabase(data).then((res) => {
        if (res.data.length <= 0) { return }
        for (let i = 0; i < res.data.length; i++) {
          const ele = res.data[i]
          this.stationStatus[ele['工位号']] = ele['状态代码'].toString()
        }
      })
    },
    changeView(type) {
      this.viewType = type
    },
    routeJump(val, state) {
      if (val.indexOf('/') !== -1) {
        val = val.substring(1)
      }
      this.$router.push({
        path: '/' + val
      })
      this.$router.go(0)
    },
    getLogo() {
      axios.get('../../logo.png', {
        responseType: 'arraybuffer'
      }).then(res => {
        this.titlePng = 'data:image/jpeg;base64,' + btoa(new Uint8Array(res.data).reduce((data, byte) => data + String.fromCharCode(byte), ''))
      })
    }
  },
  computed: {
    LineStatus() {
      return LineStatus
    }
  },
  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: 22%;
      height: 100%;
      background-color: #000d3a;
      border-right: 2px solid #3d4a61;

      .left-header {
        margin-top: 2%;
        background-color: #000d3a;
        height: 7%;
        display: flex;
        align-items: center;
        img {
          margin-left: 50px;
          height: 50px;
        }
        span {
          font-size: 3.5rem;
          margin-left: 1rem;
        }
      }

      .left-content {
        height: 95%;

        .main {
          height: 33.3%;
          .plan-info {
            padding: 5px 10px;
            span {
              font-size: 1.5rem;
            }
          }
        }

        .main2 {
          height: 33.3%;
        }

        .main3 {
          height: 33%;
        }

        .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: 56%;
      background-color: #000d3a;
      box-sizing: border-box;

      .center-header {
        background-color: #000d3a;
        height: 6.5%;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 50px;
        font-weight: bold;
        letter-spacing: 15px;
      }

      .center-content {
        height: calc(100% - 5rem);
        padding: 1rem 0.5rem 1rem 0.4rem;
        box-sizing: border-box;
        .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);
            }

            .middle-bottom{
              position: absolute;
              width: 98%;
              margin-left: 1%;
              margin-top: -2rem;
              height: 350px;
              box-sizing: border-box;
              padding-top: 10px;
              padding-left: 10px;

              .diyTab{
                td{
                  font-size: 1.3rem;
                }
              }

              .roll-box div{
                font-size: 13px;
              }
              .roll-table-box div{
                font-size: 14px;
              }
            }
          }

          .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;
              }
            }
          }
        }
      }
    }

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

      border-left: 2px 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 #000d3a;

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

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

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

    .items > div:last-child {
      height: 85%;
      width: 100%;
    }
  }
}
.right {
  width: 100%;
  height: 100%;
  background-color: #000d3a;
  padding-left: 1.5%;
  box-sizing: border-box;
  .right-head {
    height: 8%;
    display: flex;
    justify-content: flex-end;
    span {
      margin: 25px;
      margin-top: 20px;
      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;
      }
      .spot-check {
        span {
          font-size: 1rem;
        }
      }
    }

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

      .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;
            }
          }
        }
      }
      .year-plan {
        span {
          font-size: 1rem;
        }
      }
    }

    .bottom {
      width: 100%;
      height: 33%;
      .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{
  margin-left: 5px;
  border: 1px solid #22405c;
  width: 99%;
}
.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;
}

</style>
