wangrong
10 天以前 c4d7079ac30b4ed0393c2dc831627825c7a545d6
src/modules/push/service/open.ts
@@ -9,6 +9,8 @@
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';
@@ -37,6 +39,9 @@
  @InjectEntityModel(PushAuditlogEntity)
  pushAuditlogEntity: Repository<PushAuditlogEntity>;
  @InjectEntityModel(PushIsapiRawEntity)
  pushIsapiRawEntity: Repository<PushIsapiRawEntity>;
  @Inject()
  pluginService: PluginService;
@@ -199,12 +204,35 @@
//     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: