style:产线运行看板-接口添加orgId入参,产量趋势模块对接

main
黄伟杰 5 days ago
parent 68eb8d86ec
commit d26482d4cb

@ -73,8 +73,8 @@ getPlan: async () => {
getTodoList: async () => { getTodoList: async () => {
return await request.get({ url: `/mes/dashboard/getTodoList` }) return await request.get({ url: `/mes/dashboard/getTodoList` })
}, },
getDeviceOperationalStatus: async () => { getDeviceOperationalStatus: async (params?: any) => {
return await request.get({ url: `/iot/device/getDeviceOperationalStatus` }) return await request.get({ url: `/iot/device/getDeviceOperationalStatus`, params })
}, },
getDeviceRepairLineOptions: async () => { getDeviceRepairLineOptions: async () => {
return await request.get({ url: `/mes/dashboard/getDeviceRepairLineOptions` }) return await request.get({ url: `/mes/dashboard/getDeviceRepairLineOptions` })
@ -85,11 +85,11 @@ getDeviceTypePieOptions: async () => {
getMoldTypeBarOptions: async () => { getMoldTypeBarOptions: async () => {
return await request.get({ url: `/mes/dashboard/getMoldTypeBarOptions` }) return await request.get({ url: `/mes/dashboard/getMoldTypeBarOptions` })
}, },
getTaskStatistics: async () => { getTaskStatistics: async (params?: any) => {
return await request.get<TaskStatisticsResponse>({ url: `/mes/dashboard/getTaskStatistics` }) return await request.get<TaskStatisticsResponse>({ url: `/mes/dashboard/getTaskStatistics`, params })
}, },
getAllTaskList: async () => { getAllTaskList: async (params?: any) => {
return await request.get<DashboardTaskListResponse>({ url: `/mes/dashboard/getAllTaskList` }) return await request.get<DashboardTaskListResponse>({ url: `/mes/dashboard/getAllTaskList`, params })
} }
} }

@ -98,7 +98,7 @@ export const DeviceApi = {
}, },
// 批量获取设备属性列表 // 批量获取设备属性列表
getDeviceAttributeBatchList: async (params: { deviceIds: string }) => { getDeviceAttributeBatchList: async (params: { deviceIds: string; orgId?: number | string }) => {
return await request.get({ url: `/iot/device/device-attribute/batchList`, params }) return await request.get({ url: `/iot/device/device-attribute/batchList`, params })
}, },
// 修改物联设备 // 修改物联设备

@ -24,5 +24,9 @@ export const DeviceWarningRecordApi = {
// 获得实时报警记录列表 // 获得实时报警记录列表
getList: async (params?: any) => { getList: async (params?: any) => {
return await request.get({ url: `/iot/device-warinning-record/getList`, params }) return await request.get({ url: `/iot/device-warinning-record/getList`, params })
},
// 获得最近7小时产量
getLastSevenHoursCount: async (params?: any) => {
return await request.get({ url: `/iot/device-warinning-record/getLastSevenHoursCount`, params })
} }
} }

@ -43,7 +43,7 @@ export const EnergyTypeApi = {
}, },
// 获得能耗类型列表 // 获得能耗类型列表
getEnergyTypeList: async () => { getEnergyTypeList: async (params?: any) => {
return await request.get({ url: `/mes/energy-type/list`}) return await request.get({ url: `/mes/energy-type/list`, params })
}, },
} }

@ -47,10 +47,10 @@
</div> </div>
</div> </div>
<div class="header-right"> <div class="header-right">
<div class="back-btn" @click="goBack"> <!-- <div class="back-btn" @click="goBack">
<Icon icon="ep:back" /> <Icon icon="ep:back" />
<span>返回</span> <span>返回</span>
</div> </div> -->
<div class="weather"> <div class="weather">
<Icon icon="fa-solid:cloud-sun" class="weather-icon" /> <Icon icon="fa-solid:cloud-sun" class="weather-icon" />
<div class="weather-meta"> <div class="weather-meta">

@ -37,7 +37,7 @@ let chart: echarts.ECharts | null = null
const getEnergyTypes = async () => { const getEnergyTypes = async () => {
try { try {
const res = await EnergyTypeApi.getEnergyTypeList() const res = await EnergyTypeApi.getEnergyTypeList({ orgId })
const list = (res as any).data || (Array.isArray(res) ? res : []) const list = (res as any).data || (Array.isArray(res) ? res : [])
energyTypes.value = list energyTypes.value = list
if (list.length > 0) { if (list.length > 0) {

@ -13,27 +13,60 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, onUnmounted, ref } from 'vue' import { onMounted, onUnmounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import * as echarts from 'echarts' import * as echarts from 'echarts'
import { colors, style } from '../utils' import { colors, style } from '../utils'
import { DeviceWarningRecordApi } from '@/api/iot/deviceWarningRecord'
const route = useRoute()
const chartRef = ref<HTMLElement | null>(null) const chartRef = ref<HTMLElement | null>(null)
let chart: echarts.ECharts | null = null let chart: echarts.ECharts | null = null
const render = () => { const render = async () => {
if (!chart) return if (!chart) return
const x = ['9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00']
const output = [320, 460, 520, 610, 720, 690, 780] let x: string[] = []
const passRate = [98.5, 99.2, 98.1, 98.9, 99.0, 98.6, 99.3] let output: number[] = []
try {
const orgId = route.query.orgId
const res = await DeviceWarningRecordApi.getLastSevenHoursCount({ orgId })
const raw = res && typeof res === 'object' && 'data' in (res as any) ? (res as any).data : res
const list = Array.isArray(raw) ? raw : []
if (list.length > 0) {
x = list.map((item: any) => {
const h = item.hour || item.time || item.key || item.name || ''
if (typeof h === 'string' && h.includes(' ')) {
return h.split(' ')[1]
}
return h
})
output = list.map((item: any) => {
const val = item.count ?? item.value ?? item.output ?? 0
const n = Number(val)
return Number.isFinite(n) ? n : 0
})
}
} catch (e) {
console.error('Fetch production trend failed:', e)
}
chart.setOption({ chart.setOption({
backgroundColor: 'transparent', backgroundColor: 'transparent',
tooltip: { trigger: 'axis' }, tooltip: { trigger: 'axis' },
grid: { top: '18%', left: '6%', right: '6%', bottom: '12%', containLabel: true }, grid: { top: '18%', left: '6%', right: '6%', bottom: '16%', containLabel: true },
xAxis: { type: 'category', data: x, axisLine: style.axisLine, axisLabel: { ...style.axisLabel, fontSize: 10 } }, xAxis: {
yAxis: [ type: 'category',
{ type: 'value', axisLine: { show: false }, axisLabel: { ...style.axisLabel, fontSize: 10 }, splitLine: style.splitLine }, data: x,
{ type: 'value', min: 96, max: 100, axisLine: { show: false }, axisLabel: { ...style.axisLabel, fontSize: 10 }, splitLine: { show: false } } axisLine: style.axisLine,
], axisLabel: { ...style.axisLabel, fontSize: 10, rotate: 40 }
},
yAxis: {
type: 'value',
axisLine: { show: false },
axisLabel: { ...style.axisLabel, fontSize: 10 },
splitLine: style.splitLine
},
series: [ series: [
{ {
name: '产量', name: '产量',
@ -47,15 +80,6 @@ const render = () => {
]) ])
}, },
data: output data: output
},
{
name: '良率',
type: 'line',
yAxisIndex: 1,
smooth: true,
showSymbol: false,
lineStyle: { width: 2, color: colors.cyan },
data: passRate
} }
] ]
}) })

@ -99,6 +99,7 @@ import ProductionTrend from './components/ProductionTrend.vue'
const route = useRoute() const route = useRoute()
const deviceIds = route.query.deviceIds as string const deviceIds = route.query.deviceIds as string
const orgId = route.query.orgId
interface DeviceAttribute { interface DeviceAttribute {
attributeName: string attributeName: string
@ -129,7 +130,7 @@ const getBottomLeft = (index: number) => {
const loadDeviceAttributes = async () => { const loadDeviceAttributes = async () => {
if (!deviceIds) return if (!deviceIds) return
try { try {
const res = await DeviceApi.getDeviceAttributeBatchList({ deviceIds }) const res = await DeviceApi.getDeviceAttributeBatchList({ deviceIds, orgId })
const list = (res && Array.isArray(res) ? res : []) as any[] const list = (res && Array.isArray(res) ? res : []) as any[]
// list deviceIds deviceId // list deviceIds deviceId

@ -11,10 +11,10 @@
</div> </div>
</div> </div>
<div class="header-right"> <div class="header-right">
<el-button class="back-btn" type="primary" size="small" plain @click="goBack"> <!-- <el-button class="back-btn" type="primary" size="small" plain @click="goBack">
<Icon icon="fa-solid:arrow-left" class="back-icon" /> <Icon icon="fa-solid:arrow-left" class="back-icon" />
<span>返回</span> <span>返回</span>
</el-button> </el-button> -->
<span class="chip"> <span class="chip">
<Icon icon="fa-regular:clock" class="chip-icon" /> <Icon icon="fa-regular:clock" class="chip-icon" />
<span>{{ timeStr }}</span> <span>{{ timeStr }}</span>

@ -39,7 +39,7 @@ let chart: echarts.ECharts | null = null
const getEnergyTypes = async () => { const getEnergyTypes = async () => {
try { try {
const res = await EnergyTypeApi.getEnergyTypeList() const res = await EnergyTypeApi.getEnergyTypeList({ orgId })
const list = (res as any).data || (Array.isArray(res) ? res : []) const list = (res as any).data || (Array.isArray(res) ? res : [])
energyTypes.value = list energyTypes.value = list
if (list.length > 0 && !selectedEnergyTypeId.value) { if (list.length > 0 && !selectedEnergyTypeId.value) {
@ -110,14 +110,6 @@ const render = (data: any = []) => {
]) ])
}, },
data: actual data: actual
},
{
name: '基准能耗(kWh)',
type: 'line',
smooth: true,
showSymbol: false,
lineStyle: { width: 2, color: colors.green },
data: baseline
} }
] ]
}) })

Loading…
Cancel
Save