| | |
| | | <!-- |
| | | * @Date: 2024-04-09 22:11:21 |
| | | * @LastEditors: gaoshp |
| | | * @LastEditTime: 2024-10-22 22:30:19 |
| | | * @LastEditTime: 2024-11-13 20:20:54 |
| | | * @FilePath: /cps-web/src/views/mdc/processParam/index.vue |
| | | 实时看板 |
| | | --> |
| | |
| | | </el-row> |
| | | <TimeLine v-model="timeRange" ref="timeLine"></TimeLine> |
| | | <el-collapse v-model="activeList"> |
| | | <el-collapse-item :title="item.description" :name="index" v-for="(item, index) in list" |
| | | <el-collapse-item :title="item.dpLabel" :name="index" v-for="(item, index) in list" |
| | | :key="index"> |
| | | <div |
| | | v-if="(['DeviceStatus', 'ProcessProgram'].includes(item.name) && item?.dayCharts?.series?.length > 1) || (!['DeviceStatus', 'ProcessProgram'].includes(item.name) && item?.dayCharts?.series?.length > 0) && activeList.indexOf(index) > -1"> |
| | | v-if="(item.paramChartType == 'distribute' && item?.dayCharts?.series?.length > 1) || (item.paramChartType !== 'distribute' && item?.dayCharts?.series?.length > 0) && activeList.indexOf(index) > -1"> |
| | | <div> |
| | | <el-button size="small" @click="viewData(item)">查看数据</el-button> |
| | | <el-switch style="margin-left: 8px;" v-model="item.showPie" |
| | | v-show="item.paramChartType == 'distribute'" active-text="饼图" |
| | | inactive-text="" /> |
| | | </div> |
| | | <scEcharts style="width:100%" :height="item.height" :option="item?.dayCharts"> |
| | | <scEcharts v-if="!item.showPie" style="width:100%" :height="item.height" |
| | | :option="item?.dayCharts"> |
| | | </scEcharts> |
| | | <scEcharts v-else style="width:100%" height="300px" :option="item?.pieCharts"> |
| | | </scEcharts> |
| | | </div> |
| | | <el-empty v-else description="暂无数据" /> |
| | |
| | | }, |
| | | save() { |
| | | console.log(this.checkedCities) |
| | | this.$HTTP.post(`/api/blade-mdc/process-parameter/excel/export`, { |
| | | this.$HTTP.post(`/api/mdc/process-parameter/excel/export`, { |
| | | collectItem: this.list.filter(v => this.checkedCities.includes(v.id)), |
| | | endTime: this.timeRange.endTime, |
| | | startTime: this.timeRange.startTime, |
| | |
| | | this.visible = true |
| | | }, |
| | | init() { |
| | | this.$HTTP.get('/api/blade-mdc/process-parameter').then(res => { |
| | | this.$HTTP.get('/api/smis/global_wcs/wcs-achievements').then(res => { |
| | | if (res.code === 200) { |
| | | this.legend = res.data |
| | | } |
| | | }) |
| | | }, |
| | | viewData(item) { |
| | | let data = { |
| | | FeedOverride: '进给倍率', |
| | | FeedSpeed: '进给速度', |
| | | SpindleOverride: '主轴倍率', |
| | | SpindleSpeed: '主轴转速', |
| | | Output: '产量', |
| | | ProcessProgram: '程序名', |
| | | DeviceStatus: '设备状态', |
| | | } |
| | | this.drawerName = data[item.name] |
| | | this.drawerName = item.dpLabel |
| | | |
| | | this.$HTTP.post('/api/blade-mdc/process-parameter/item?current=1&size=1500', { |
| | | this.$HTTP.post('/api/mdc/process-parameter/item?current=1&size=1500', { |
| | | endTime: this.timeRange.endTime, |
| | | startTime: this.timeRange.startTime, |
| | | item: item.name, |
| | | item: item.dpName, |
| | | methodEnum: "HOUR", |
| | | workstationId: this.treeChecked.toString(), |
| | | workstationName: '' |
| | |
| | | }, |
| | | query() { |
| | | if (!this.treeChecked.toString()) return |
| | | console.log(this.treeChecked.toString(), '>>>>>>>>>/') |
| | | this.$refs?.timeLine?.init({ |
| | | dates: this.time, |
| | | workstationId: this.treeChecked.toString() |
| | | }) |
| | | this.list = [] |
| | | this.$HTTP.get('/api/blade-mdc/process-parameter/param', { workstationId: this.treeChecked.toString() }).then(res => { |
| | | this.$HTTP.get('/api/mdc/process-parameter/params', { workstationId: this.treeChecked.toString() }).then(res => { |
| | | if (res.code === 200) { |
| | | console.log('jkjkjkjkj', this.list) |
| | | this.list = res.data.map(v => { |
| | | let name = v.isProcessParam ? 'ProcessProgram' : v.dpName |
| | | return { |
| | | ...v, |
| | | height: ['ProcessProgram', 'DeviceStatus'].includes(v.name) ? '100px' : '200px' |
| | | name: name, |
| | | height: v.paramChartType == 'distribute' ? '300px' : '200px' |
| | | } |
| | | }) |
| | | this.queryChart() |
| | |
| | | }) |
| | | }, |
| | | queryChart1(item) { |
| | | let index = this.list.findIndex(item => item.name === 'DeviceStatus') |
| | | let index = this.list.findIndex(item => item.dpName === 'DeviceStatus') |
| | | this.list[index] = Object.assign({ |
| | | ...this.list[index], |
| | | dayCharts: {} |
| | | }) |
| | | this.$HTTP.post('/api/blade-mdc/process-parameter/chart/dmp-item', { |
| | | let params = { ...item } |
| | | try { |
| | | delete params.name |
| | | delete params.height |
| | | } catch (err) { console.error(err) } |
| | | this.$HTTP.post('/api/mdc/process-parameter/chart/dmp-item', { |
| | | methodEnum: "HOUR", |
| | | startTime: this.timeRange.startTime, |
| | | endTime: this.timeRange.endTime, |
| | | workstationId: this.treeChecked.toString(), |
| | | workstationName: '', |
| | | dmpDTO: { |
| | | dpDTO: { |
| | | id: this.treeChecked.toString(), |
| | | dmpDeviced: item.dmpDeviceId, |
| | | name: item.name, |
| | | description: item.description, |
| | | dataType: item.dataType, |
| | | wcsDataType: item.wcsDataType, |
| | | processParameter: item.processParameter |
| | | // name: item.name, |
| | | ...params |
| | | // dmpDeviced: item.dmpDeviceId, |
| | | // description: item.description, |
| | | // dataType: item.dataType, |
| | | // wcsDataType: item.wcsDataType, |
| | | // processParameter: item.processParameter |
| | | } |
| | | }).then(res => { |
| | | if (['DeviceStatus', 'ProcessProgram'].includes(item.name)) { |
| | | this.setDeviceStatusOptions(res.data, item.name) |
| | | // if (['DeviceStatus', 'ProcessProgram'].includes(item.name)) { |
| | | if (item.paramChartType === 'distribute') { |
| | | this.setDeviceStatusOptions(res.data, item.dpName) |
| | | } else { |
| | | this.setLineOptions(res.data.data, item.name) |
| | | this.setLineOptions(res.data.data, item.dpName) |
| | | } |
| | | }) |
| | | }, |
| | |
| | | }, |
| | | } |
| | | if (yAxisData?.length == 0) { |
| | | let index = this.list.findIndex(item => item.name === myname) |
| | | let index = this.list.findIndex(item => item.dpName === myname) |
| | | this.list[index] = Object.assign({ |
| | | ...this.list[index], |
| | | dayCharts: {} |
| | | dayCharts: {}, |
| | | showPie: false |
| | | }) |
| | | } else { |
| | | let index = this.list.findIndex(item => item.name === myname) |
| | | let index = this.list.findIndex(item => item.dpName === myname) |
| | | this.list[index] = Object.assign({ |
| | | ...this.list[index], |
| | | dayCharts |
| | | dayCharts, |
| | | showPie: false |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | setDeviceStatusOptions(data, myname) { |
| | | debugger |
| | | let total = Math.abs(moment(this.timeRange.startTime).diff(moment(this.timeRange.endTime))) |
| | | let start = this.timeRange.startTime |
| | | let len = data?.data?.length |
| | | if (len > 0 && moment(data.data[len - 1].time).unix() < moment(this.timeRange.endTime).unix()) { |
| | | let addItem = { |
| | | time: this.timeRange.endTime, |
| | | value: data.data[len - 1].value |
| | | value: myname === 'DeviceStatus' ? data.data[len - 1].name : data.data[len - 1].value, |
| | | } |
| | | data.data.push(addItem) |
| | | } |
| | | let series = data.data.map((item, i) => { |
| | | let current = Math.abs(moment(start).diff(moment(item.time))) |
| | | start = item.time |
| | | let name = i === 0 ? '' : data.data[i - 1].name |
| | | if (myname === 'ProcessProgram') { |
| | | name = item.value |
| | | let name = i === 0 ? '' : myname === 'DeviceStatus' ? data.data[i - 1].name : data.data[i - 1].value |
| | | // if (myname === 'ProcessProgram') { |
| | | try { |
| | | name = myname === 'DeviceStatus' ? item.name.slice(-50) : item.value.slice(-50) |
| | | } catch (err) { |
| | | name = myname === 'DeviceStatus' ? item.name : item.value |
| | | } |
| | | // } |
| | | // let color = !name ? 'transparent' : data.data[i - 1].color |
| | | return { |
| | | name, |
| | |
| | | // return `${name}:开始时间${moment(data.data[i - 1].time).format('HH:mm')}-${moment(item.time).format('HH:mm')}` |
| | | // } |
| | | // }, |
| | | // itemStyle: { |
| | | // // color, // 这一行固定的颜色值需要删除或注释 |
| | | // borderColor: '#FFF', |
| | | // borderWidth: 1 |
| | | // }, |
| | | itemStyle: { |
| | | color: item.color, // 这一行固定的颜色值需要删除或注释 |
| | | }, |
| | | tooltip: { |
| | | show: true, |
| | | trigger: 'item', |
| | | position: 'top', |
| | | // position: 'top', |
| | | triggerOn: 'click', |
| | | formatter: (value, ticket) => { |
| | | // console.log('----------1111') |
| | |
| | | // return current.format('HH:mm') |
| | | // return value |
| | | if (i == 0 || current === 0) return '' |
| | | return `${name}:时段${moment(data.data[i - 1].time).format('HH:mm')}-${moment(item.time).format('HH:mm')}` |
| | | return `${name}:时段${moment(data.data[i - 1].time).format('HH:mm:ss')}-${moment(item.time).format('HH:mm:ss')}` |
| | | } |
| | | }, |
| | | } |
| | |
| | | }, |
| | | }, |
| | | } |
| | | console.log(dayCharts, '>>>>>>>???') |
| | | let index = this.list.findIndex(item => item.name === myname) |
| | | let index = this.list.findIndex(item => item.dpName === myname) |
| | | |
| | | this.list[index] = Object.assign({ |
| | | ...this.list[index], |
| | | dayCharts |
| | | dayCharts, |
| | | pieCharts: this.getPieCharts(data.data, myname), |
| | | showPie: false |
| | | }) |
| | | // console.log(this.list, '>>>>>>>>>>>>>>>>>>>>>>111') |
| | | }, |
| | | getPieCharts(data, myname) { |
| | | let start = this.timeRange.startTime |
| | | const obj = { |
| | | } |
| | | let key = myname === 'DeviceStatus' ? 'name' : 'value' |
| | | data.forEach(v => { |
| | | if (obj[v[key]]) { |
| | | obj[v[key]] += moment(v.time).valueOf() - moment(start).valueOf() |
| | | } else { |
| | | obj[v[key]] = moment(v.time).valueOf() - moment(start).valueOf() |
| | | } |
| | | start = v.time |
| | | |
| | | }) |
| | | let result = Object.keys(obj).map(key => { |
| | | return { |
| | | value: obj[key] / 1000, |
| | | name: key, |
| | | // itemStyle: { |
| | | // color: item.color, // 这一行固定的颜色值需要删除或注释 |
| | | // }, |
| | | } |
| | | }).map(v => { |
| | | if (myname === 'DeviceStatus') { |
| | | return { |
| | | ...v, |
| | | itemStyle: { |
| | | color: this.legend.find(item => item.name === v.name).color |
| | | } |
| | | } |
| | | } |
| | | return v |
| | | |
| | | }) |
| | | let charts = { |
| | | tooltip: { |
| | | trigger: 'item', |
| | | formatter: function (params) { |
| | | let d = moment.duration(params.value, 'seconds') |
| | | return `${params.name}: ${d.hours()}小时${d.minutes()}分${d.seconds()}秒` |
| | | } |
| | | }, |
| | | legend: { |
| | | orient: 'vertical', |
| | | left: 'left' |
| | | }, |
| | | series: [ |
| | | { |
| | | name: '', |
| | | type: 'pie', |
| | | radius: '50%', |
| | | data: result, |
| | | } |
| | | ], |
| | | } |
| | | return charts |
| | | }, |
| | | change(e) { |
| | | this.timeStart = e[0] || moment().format('YYYY-MM-DD') |