From c4d7079ac30b4ed0393c2dc831627825c7a545d6 Mon Sep 17 00:00:00 2001
From: wangrong <wangrong@shsening.com>
Date: 星期一, 10 八月 2026 18:51:37 +0800
Subject: [PATCH] 增加监控点每日抓图

---
 src/modules/push/service/open.ts |   40 ++++++++++++++++++++++++++++++++++------
 1 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/src/modules/push/service/open.ts b/src/modules/push/service/open.ts
index b6421f5..7bc185d 100644
--- a/src/modules/push/service/open.ts
+++ b/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:

--
Gitblit v1.9.1