aiboxController.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import {
  2. addAiBoxForward,
  3. aiboxLevelUp,
  4. delAiBoxForward,
  5. dimensionAiBox,
  6. getAiBoxEvent,
  7. getAiBoxForward,
  8. getAiBoxList,
  9. getAiBoxPage,
  10. getStream,
  11. getSys,
  12. getTaskByClientId,
  13. getWarnOssUrl,
  14. reboot,
  15. refreshStream,
  16. refreshSys,
  17. refreshTask,
  18. updateAiBoxForward
  19. } from '@/api/cvs/aibox'
  20. import { getAig } from '@/api/cvs/aiboxCloud'
  21. import { updateForward } from '@/api/iot/rule'
  22. import { message } from 'ant-design-vue'
  23. export class AiboxController {
  24. static eventType: {EventType: CVS.AiBox.eventType, EventName: string}[] = [
  25. { EventType: '0', EventName: '人脸识别' },
  26. { EventType: '1', EventName: '人流统计' },
  27. { EventType: '2', EventName: '明烟明火' },
  28. { EventType: '3', EventName: '抽烟打电话' },
  29. { EventType: '4', EventName: '口罩检测' },
  30. { EventType: '5', EventName: '安全帽检测' },
  31. { EventType: '6', EventName: '越线监测' },
  32. { EventType: '7', EventName: '区域围栏' },
  33. { EventType: '8', EventName: '反光衣检测' },
  34. { EventType: '9', EventName: '电动车检测' }
  35. ]
  36. static eventTypeMap = new Map([
  37. ['0', '人脸识别'],
  38. ['1', '人流统计'],
  39. ['2', '明烟明火'],
  40. ['3', '抽烟打电话'],
  41. ['4', '口罩检测'],
  42. ['5', '安全帽检测'],
  43. ['6', '越线监测'],
  44. ['7', '区域围栏'],
  45. ['8', '反光衣检测'],
  46. ['9', '电动车检测']
  47. ])
  48. static async page (params: COMMON.API.QueryParams & {name?: string, state: 'OFFLINE' | 'ONLINE'}) {
  49. return await getAiBoxPage(params)
  50. }
  51. static async list () {
  52. const { code, data } = await getAiBoxList()
  53. if (code === 200) {
  54. return data
  55. }
  56. }
  57. static async dimension (data: Partial<CVS.AiBox.AiBox>) {
  58. const { code, msg } = await dimensionAiBox(data)
  59. code === 200 ? message.success('修改成功') : message.error(msg)
  60. }
  61. static async levelUp (params: {devId: string, aiId: string, version: string, file: any}) {
  62. const { code, data } = await aiboxLevelUp(params)
  63. code === 200 && data ? message.success('升级成功') : message.error('升级失败')
  64. }
  65. static async taskById (clientId: string) {
  66. const { code, data } = await getTaskByClientId(clientId)
  67. if (code === 200) {
  68. return data
  69. }
  70. }
  71. static async refreshTask (clientId: string) {
  72. await refreshTask(clientId)
  73. }
  74. static async stream (clientId: string) {
  75. const { code, data } = await getStream(clientId)
  76. if (code === 200) {
  77. return data
  78. }
  79. }
  80. static async refreshStream (clientId: string) {
  81. await refreshStream(clientId)
  82. }
  83. static async sys (clientId: string) {
  84. const { code, data } = await getSys(clientId)
  85. if (code === 200) {
  86. return data
  87. }
  88. }
  89. static async warnOssUrl () {
  90. const { code, data } = await getWarnOssUrl()
  91. if (code === 200) {
  92. return data
  93. }
  94. }
  95. static async refreshSys (clientId: string) {
  96. await refreshSys(clientId)
  97. }
  98. static async reboot (clientId: string) {
  99. const { code, msg } = await reboot(clientId)
  100. code === 200 ? message.success('重启成功') : message.error(msg)
  101. }
  102. static async event (params: {devId: string, eventType: CVS.AiBox.eventType, start: string, end: string}) {
  103. return await getAiBoxEvent(params)
  104. }
  105. static async forward () {
  106. return await getAiBoxForward()
  107. }
  108. static async addForward (data: CVS.AiBox.Forward) {
  109. const { code, msg } = await addAiBoxForward(data)
  110. code === 200 ? message.success('新增成功') : message.error(msg)
  111. }
  112. static async updateForward (data: CVS.AiBox.Forward) {
  113. const { code, msg } = await updateAiBoxForward(data)
  114. code === 200 ? message.success('修改成功') : message.error(msg)
  115. }
  116. static async delForward (id: string, _data: CVS.AiBox.Forward) {
  117. const { code, msg, data } = await delAiBoxForward(id, _data)
  118. code === 200 && data ? message.success('删除成功') : message.error('删除失败')
  119. }
  120. }