| | |
| | | import { PushVehicleGpsEntity } from '../entity/vehiclegps'; |
| | | import { PushDeviceOnoffEntity } from '../entity/deviceonoff'; |
| | | import { PushDevicealarmEntity } from '../entity/devicealarm'; |
| | | import { PushIsapiRawEntity } from '../entity/isapientity'; |
| | | import { IsapiEventType } from '../entity/isapieventtype'; |
| | | import { PluginService } from '../../plugin/service/info'; |
| | | import { CachingFactory, MidwayCache } from '@midwayjs/cache-manager'; |
| | | |
| | |
| | | |
| | | @InjectEntityModel(PushAuditlogEntity) |
| | | pushAuditlogEntity: Repository<PushAuditlogEntity>; |
| | | |
| | | @InjectEntityModel(PushIsapiRawEntity) |
| | | pushIsapiRawEntity: Repository<PushIsapiRawEntity>; |
| | | |
| | | @Inject() |
| | | pluginService: PluginService; |
| | |
| | | // type: 'ys.open.isapi' |
| | | // } |
| | | // } |
| | | // processCameraGpsAsync(body) |
| | | // await this.pushIsapiRepo.save({ |
| | | // messageId, |
| | | // raw: JSON.stringify(body), |
| | | // createTime: new Date(), |
| | | // }); |
| | | const header = body.header; |
| | | const payloadStr = body.body?.payload; |
| | | if (!payloadStr) { |
| | | console.warn('ISAPI payload missing'); |
| | | break; |
| | | } |
| | | let parsed: any; |
| | | try { |
| | | parsed = JSON.parse(payloadStr); |
| | | } catch (e) { |
| | | console.error('ISAPI payload parse error', e); |
| | | break; |
| | | } |
| | | const eventType = |
| | | Object.values(IsapiEventType).includes(parsed.eventType) |
| | | ? parsed.eventType |
| | | : IsapiEventType.UNKNOWN; |
| | | await this.pushIsapiRawEntity.save({ |
| | | messageId: header.messageId, |
| | | deviceId: header.deviceId, |
| | | channelNo: header.channelNo ?? 0, |
| | | eventType, |
| | | eventState: parsed.eventState, |
| | | rawPayload: payloadStr, |
| | | parsed, |
| | | eventTime: parsed.dateTime |
| | | ? new Date(parsed.dateTime) |
| | | : new Date(header.messageTime), |
| | | }); |
| | | break; |
| | | } |
| | | default: |