riku
2026-04-02 3282e95db0207ee133d1e98d9771dec9d83b0fc4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import dayjs from 'dayjs';
import { toLabel as toLabelFreq } from '../common/dataMaintainFrequency';
import { toLabel as toLabelOwner } from '../common/dataOwnership';
import { toLabel as toLabelStatus } from '../common/dataRunningStatus';
import { toLabel as toLabelMonitor } from '../common/dataMonitorDeviceType';
import { toLabel as toLabelTreatment } from '../common/dataTreatmentDeviceType';
import { toLabel as toLabelProduction } from '../common/dataProductionDeviceType';
import { inspectPicUrl } from '../config/index';
 
// 设备信息更新时间超过几个月后,被认为需要确认
const intervalMonth = 3;
 
// 监测设备
export function getMonitorDevice(data) {
  data._id = data.diId;
  data._name = data.diName;
  data._deviceCode = data.diDeviceCode;
  data._updateTime = dayjs(data.diUpdateTime).format('YYYY年MM月DD日');
  data._maintainFrequency = toLabelFreq(data.diMaintainFrequency);
  data._ownership = toLabelOwner(data.diOwnership);
  data._runningStatus = toLabelStatus(data.diRunningStatus);
  const labelArr = toLabelMonitor(data.diSceneTypeId, [data.diTypeId, data.diSubtypeId]);
  data._type = labelArr[0];
  data._subType = labelArr[1];
 
  // 上次更新时间距现在相差的月份数
  data._diffMonth = dayjs(data.diUpdateTime).diff(dayjs(), 'month');
  // 必要信息是否完整
  data._fullInfo =
    data.diName &&
    data.diDeviceCode &&
    data._subType &&
    data.diSupplier &&
    data.diMaintainer &&
    typeof data.diMaintainFrequency === 'number' &&
    typeof data.diRunningStatus === 'number';
  return data;
}
 
// 治理设备
export function getTreatmentDevice(data) {
  data._id = data.piId;
  data._name = data.piName;
  data._deviceCode = data.piDeviceCode;
  data._updateTime = dayjs(data.piUpdateTime).format('YYYY年MM月DD日');
  data._maintainFrequency = toLabelFreq(data.piMaintainFrequency);
  data._ownership = toLabelOwner(data.piOwnership);
  data._runningStatus = toLabelStatus(data.piRunningStatus);
  const labelArr = toLabelTreatment(data.piSceneTypeId, [data.piTypeId, data.piSubtypeId]);
  data._type = labelArr[0];
  data._subType = labelArr[1];
 
  // 上次更新时间距现在相差的月份数
  data._diffMonth = dayjs(data.piUpdateTime).diff(dayjs(), 'month');
  // 必要信息是否完整
  data._fullInfo =
    data.piName &&
    data.piDeviceCode &&
    data._subType &&
    data.piSupplier &&
    data.piMaintainer &&
    typeof data.piMaintainFrequency === 'number' &&
    typeof data.piRunningStatus === 'number';
 
  return data;
}
 
// 生产设备
export function getProductionDevice(data) {
  data._id = data.wiId;
  data._name = data.wiName;
  data._deviceCode = data.wiDeviceCode;
  data._updateTime = dayjs(data.wiUpdateTime).format('YYYY年MM月DD日');
  data._ownership = toLabelOwner(data.wiOwnership);
  data._runningStatus = toLabelStatus(data.wiRunningStatus);
  const labelArr = toLabelProduction(data.wiSceneTypeId, [data.wiTypeId, data.wiSubtypeId]);
  data._type = labelArr[0];
  data._subType = labelArr[1];
 
  // 上次更新时间距现在相差的月份数
  data._diffMonth = dayjs(data.wiUpdateTime).diff(dayjs(), 'month');
  // 必要信息是否完整
  data._fullInfo =
    data.wiName &&
    data.wiDeviceCode &&
    data._subType &&
    data.wiSupplier &&
    typeof data.wiRunningStatus === 'number';
  return data;
}
 
export function getDeviceList(dataList, deviceType) {
  return dataList.map(item => {
    // 监测设备
    if (deviceType == 0) {
      return getMonitorDevice(item);
    }
    // 治理设备
    else if (deviceType == 1) {
      return getTreatmentDevice(item);
    }
    // 生产设备
    else if (deviceType == 2) {
      return getProductionDevice(item);
    }
  });
}
 
export function getDeviceStatus(data) {
  data._createTime = dayjs(data.dlCreateTime).format('YYYY年MM月DD日');
  data._imgPath = data.dlPicUrl.split(';').map(p => inspectPicUrl + p);
  return data;
}
 
export function getDeviceStatusList(dataList) {
  return dataList.map(item => {
    return getDeviceStatus(item);
  });
}