style:设备运行参数-修复id转换导致精度缺失问题

main
黄伟杰 4 days ago
parent 4623e356fe
commit 38050e953e

@ -83,12 +83,50 @@ export interface DeviceContactModelVO {
dataUnit?: string dataUnit?: string
} }
export interface ProductionDailyReportGenerateReqVO {
deviceIds: Array<string | number>
reportDate: string
workTeamId: string | number
}
export interface ProductionDailyReportFileVO {
fileName: string
fileUrl: string
filePath?: string
reportDate: string
workTeamId: string | number
workTeamName?: string
startTime?: string | null
endTime?: string | null
deviceIds: Array<string | number>
devices?: Array<{
deviceId: string | number
deviceCode?: string
deviceName?: string
capacityCode?: string
capacityName?: string
startValue?: number
endValue?: number
capacityDiff?: number
unit?: string
}> | null
createTime?: string
}
// 物联设备 API // 物联设备 API
export const DeviceApi = { export const DeviceApi = {
// 查询物联设备分页 // 查询物联设备分页
getDevicePage: async (params: any) => { getDevicePage: async (params: any) => {
return await request.get({ url: `/iot/device/page`, params }) return await request.get({ url: `/iot/device/page`, params })
}, },
generateProductionDailyReport: async (data: ProductionDailyReportGenerateReqVO) => {
return await request.post({ url: `/iot/device/production-daily-report/generate`, data })
},
getProductionDailyReportPage: async (params: any) => {
return await request.get({ url: `/iot/device/production-daily-report/page`, params })
},
// 查询物联设备 // 查询物联设备
getDeviceList: async (params?: any) => { getDeviceList: async (params?: any) => {
return await request.get({ url: `/iot/device/deviceList`, params }) return await request.get({ url: `/iot/device/deviceList`, params })

@ -57,8 +57,8 @@ export const DeviceModelAttributeApi = {
}, },
operationAnalysisDetails: async (params: { operationAnalysisDetails: async (params: {
deviceId: number deviceId: string | number
modelId?: number modelId?: string | number
collectionStartTime?: string collectionStartTime?: string
collectionEndTime?: string collectionEndTime?: string
}) => { }) => {

@ -313,7 +313,6 @@ const handleExport = async () => {
try { try {
await message.exportConfirm() await message.exportConfirm()
exportLoading.value = true exportLoading.value = true
parseKeyword()
const data = await MoldBrandApi.exportMoldBrand(queryParams) const data = await MoldBrandApi.exportMoldBrand(queryParams)
download.excel(data, t('MoldManagement.MoldBrandPage.exportFilename')) download.excel(data, t('MoldManagement.MoldBrandPage.exportFilename'))
} finally { } finally {

@ -115,8 +115,8 @@ type DeviceTreeNode = {
tag?: TreeNodeTag tag?: TreeNodeTag
children?: DeviceTreeNode[] children?: DeviceTreeNode[]
orgClass?: string orgClass?: string
deviceId?: number deviceId?: string
modelId?: number modelId?: string
paramKey?: string paramKey?: string
unit?: string unit?: string
paramCount?: number paramCount?: number
@ -124,14 +124,14 @@ type DeviceTreeNode = {
} }
type ApiTreeParameter = { type ApiTreeParameter = {
id: number id: string | number
name: string name: string
code?: string code?: string
unit?: string | null unit?: string | null
} }
type ApiTreeEquipment = { type ApiTreeEquipment = {
id: number id: string | number
name: string name: string
parameters?: ApiTreeParameter[] parameters?: ApiTreeParameter[]
} }
@ -192,8 +192,8 @@ type ChartState = 'idle' | 'loading' | 'empty' | 'ready'
type SelectedGroup = { type SelectedGroup = {
id: string id: string
param: DeviceTreeNode param: DeviceTreeNode
deviceId?: number deviceId?: string
modelId?: number modelId?: string
dateRange: [string, string] dateRange: [string, string]
requestSeq: number requestSeq: number
chartLoading: boolean chartLoading: boolean
@ -226,28 +226,18 @@ const handleTreeRefresh = async () => {
await loadTree() await loadTree()
} }
const toFiniteId = (value: any): number | undefined => { const toIdString = (value: unknown): string | undefined => {
if (typeof value === 'number') return Number.isFinite(value) ? value : undefined const id = String(value ?? '').trim()
if (typeof value === 'string') { return id || undefined
if (/^\d+$/.test(value.trim())) return Number(value)
const n = Number(value)
return Number.isFinite(n) ? n : undefined
}
return undefined
} }
const toNodeIds = (node: DeviceTreeNode): { deviceId?: number; modelId?: number } => { const toNodeIds = (node: DeviceTreeNode): { deviceId?: string; modelId?: string } => {
const modelId = typeof node.modelId === 'number' && Number.isFinite(node.modelId) ? node.modelId : undefined const modelId = toIdString(node.modelId)
const deviceId = typeof node.deviceId === 'number' && Number.isFinite(node.deviceId) ? node.deviceId : undefined const deviceId = toIdString(node.deviceId)
if (typeof deviceId === 'number') return { deviceId, modelId } if (deviceId) return { deviceId, modelId }
const parts = String(node.id ?? '').split('-').filter(Boolean) const parts = String(node.id ?? '').split('-').filter(Boolean)
const last = parts.length ? parts[parts.length - 1] : undefined return { deviceId: toIdString(parts[parts.length - 1]), modelId }
const parsed = toFiniteId(last)
if (typeof parsed !== 'number' || !Number.isFinite(parsed) || parsed <= 0) {
return { modelId }
}
return { deviceId: parsed, modelId }
} }
const buildParamTitle = (param: DeviceTreeNode) => { const buildParamTitle = (param: DeviceTreeNode) => {
@ -312,8 +302,8 @@ const buildTreeFromApi = (orgs: ApiTreeOrg[]): DeviceTreeNode[] => {
id: `param-${eq.id}-${p.id}`, id: `param-${eq.id}-${p.id}`,
label: p?.name ?? p?.code ?? String(p?.id ?? ''), label: p?.name ?? p?.code ?? String(p?.id ?? ''),
type: 'param', type: 'param',
deviceId: toFiniteId(eq.id), deviceId: toIdString(eq.id),
modelId: toFiniteId(p.id), modelId: toIdString(p.id),
paramKey: p?.code ? String(p.code) : undefined, paramKey: p?.code ? String(p.code) : undefined,
unit: p?.unit ? String(p.unit) : undefined, unit: p?.unit ? String(p.unit) : undefined,
disabled: false disabled: false
@ -324,7 +314,7 @@ const buildTreeFromApi = (orgs: ApiTreeOrg[]): DeviceTreeNode[] => {
label: eq?.name ?? String(eq?.id ?? ''), label: eq?.name ?? String(eq?.id ?? ''),
type: 'device', type: 'device',
tag: 'equipment', tag: 'equipment',
deviceId: toFiniteId(eq.id), deviceId: toIdString(eq.id),
paramCount: params.length, paramCount: params.length,
children: paramNodes.length ? paramNodes : undefined, children: paramNodes.length ? paramNodes : undefined,
disabled: true disabled: true
@ -506,7 +496,7 @@ const extractChartRows = (res: any): Record<string, any>[] => {
} }
const fetchGroupChart = async (group: SelectedGroup, notify: boolean) => { const fetchGroupChart = async (group: SelectedGroup, notify: boolean) => {
if (typeof group.deviceId !== 'number' || !Number.isFinite(group.deviceId)) return if (!group.deviceId) return
ensureDateRange(group) ensureDateRange(group)
const [start, end] = group.dateRange const [start, end] = group.dateRange
@ -526,7 +516,7 @@ const fetchGroupChart = async (group: SelectedGroup, notify: boolean) => {
collectionStartTime: buildDateTime(start, '00:00:00'), collectionStartTime: buildDateTime(start, '00:00:00'),
collectionEndTime: buildDateTime(end, '23:59:59') collectionEndTime: buildDateTime(end, '23:59:59')
} }
if (typeof group.modelId === 'number' && Number.isFinite(group.modelId)) { if (group.modelId) {
req.modelId = group.modelId req.modelId = group.modelId
} }
@ -537,9 +527,6 @@ const fetchGroupChart = async (group: SelectedGroup, notify: boolean) => {
group.chartXAxis = [] group.chartXAxis = []
group.chartSeries = [] group.chartSeries = []
group.chartState = 'empty' group.chartState = 'empty'
if (notify) {
message.warning(t('DataCollection.DeviceParamAnalysis.messageNodeNoParams'))
}
return return
} }
@ -643,7 +630,7 @@ const syncGroupsByCheckedNodes = (checkedNodes: DeviceTreeNode[]) => {
const addedGroups: SelectedGroup[] = [] const addedGroups: SelectedGroup[] = []
for (const node of toAdd) { for (const node of toAdd) {
const { deviceId, modelId } = toNodeIds(node) const { deviceId, modelId } = toNodeIds(node)
if (typeof deviceId !== 'number') { if (!deviceId) {
continue continue
} }
const group: SelectedGroup = { const group: SelectedGroup = {

Loading…
Cancel
Save