餐饮油烟智能监测与监管一体化平台
riku
2026-03-20 59af55dc3e72f8f2655ae06af9d1b6f766bac423
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
function generateTestShops() {
  // 指定的店铺名称
  const specifiedShops = [
    '付小姐在成都',
    '吉刻联盟',
    '家在塔啦',
    '狼来了',
    '乐凯撒星游店',
    '馨远美食小镇(哈尼美食广场)',
    '棒约翰',
    '弄堂咪道',
    '杨记齐齐哈尔烤肉',
    '上海稔传餐饮管理有限公司(人生一串)',
    '缘家',
    '泉盛餐饮(上海)有限公司(食其家)',
    '丰茂烤串',
    '上海泰煌餐饮管理有限公司(泰煌鸡)',
    '徐汇区辰熙餐馆(小铁君串烧居酒屋)',
  ]
 
  // 随机店铺名称前缀和后缀
  const namePrefixes = [
    '风味',
    '特色',
    '正宗',
    '传统',
    '经典',
    '创意',
    '时尚',
    '休闲',
    '精致',
    '地道',
  ]
  const nameSuffixes = [
    '餐厅',
    '饭店',
    '酒楼',
    '菜馆',
    '小吃',
    '食堂',
    '美食',
    '饮食',
    '餐饮',
    '饭庄',
  ]
  const cuisines = [
    '川菜',
    '粤菜',
    '鲁菜',
    '淮扬菜',
    '闽菜',
    '湘菜',
    '徽菜',
    '浙菜',
    '东北菜',
    '西北菜',
    '西餐',
    '日料',
    '韩料',
    '东南亚菜',
  ]
 
  // 环信码等级
  const ringCodeLevels = [0, 1, 2]
 
  // 生成测试数据
  const shops = []
 
  // 先添加指定的店铺
  specifiedShops.forEach((name, index) => {
    // 随机生成在线状态(80%概率在线)
    const isOnline = Math.random() < 0.8
    // 随机生成异常状态(只有在线时才可能有异常)
    // 0: 油烟浓度超标, 1: 供电异常, 2: 设备或网络异常, 3: 无异常
    const exceptionStatus = isOnline ? Math.floor(Math.random() * 4) : 2 // 离线时默认为设备或网络异常
 
    shops.push({
      shop: {
        name: name,
        address: `上海市徐汇区${index + 1}号`,
        latitude: 31.17 + Math.random() * 0.1,
        longitude: 121.45 + Math.random() * 0.1,
        ringCodeLevel: ringCodeLevels[Math.floor(Math.random() * ringCodeLevels.length)],
        ringCodePublishTime: '2023-03-16 10:00:00',
        isOnline: isOnline,
        exceptionStatus: exceptionStatus,
      },
      recentData: generateRecentData(),
    })
  })
 
  // 生成剩余的随机店铺
  for (let i = specifiedShops.length; i < 100; i++) {
    const prefix = namePrefixes[Math.floor(Math.random() * namePrefixes.length)]
    const cuisine = cuisines[Math.floor(Math.random() * cuisines.length)]
    const suffix = nameSuffixes[Math.floor(Math.random() * nameSuffixes.length)]
    const randomName = `${prefix}${cuisine}${suffix}${i}`
 
    // 随机生成在线状态(80%概率在线)
    const isOnline = Math.random() < 0.8
    // 随机生成异常状态(只有在线时才可能有异常)
    // 0: 油烟浓度超标, 1: 供电异常, 2: 设备或网络异常, 3: 无异常
    const exceptionStatus = isOnline ? Math.floor(Math.random() * 4) : 2 // 离线时默认为设备或网络异常
 
    shops.push({
      shop: {
        name: randomName,
        address: `上海市徐汇区${i + 1}号`,
        latitude: 31.19 + Math.random() * 0.1,
        longitude: 121.41 + Math.random() * 0.1,
        ringCodeLevel: ringCodeLevels[Math.floor(Math.random() * ringCodeLevels.length)],
        ringCodePublishTime: '2023-03-16 10:00:00',
        isOnline: isOnline,
        exceptionStatus: exceptionStatus,
      },
      recentData: generateRecentData(),
    })
  }
 
  return shops
}
function generateRecentData() {
  // 生成近1小时的监测数据,每10分钟一条
  const data = []
  const now = new Date()
  now.setFullYear(2023)
 
  for (let i = 5; i >= 0; i--) {
    const time = new Date(now.getTime() - i * 10 * 60 * 1000)
    data.push({
      sampleTime: time.toISOString().slice(0, 19).replace('T', ' '),
      oilSmokeConcentration: (Math.random() * 2).toFixed(2),
      purifierCurrent: (Math.random() * 10).toFixed(2),
      fanCurrent: (Math.random() * 15).toFixed(2),
    })
  }
 
  return data
}
 
export { generateTestShops }