From b46304989eaefa139e41456331e419cc3b2ff4cc Mon Sep 17 00:00:00 2001
From: wangrong <wangrong@shsening.com>
Date: 星期一, 20 七月 2026 14:23:33 +0800
Subject: [PATCH] 修复告警消息中图片处理
---
src/modules/push/service/open.ts | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/src/modules/push/service/open.ts b/src/modules/push/service/open.ts
index ee49cbb..4190436 100644
--- a/src/modules/push/service/open.ts
+++ b/src/modules/push/service/open.ts
@@ -9,6 +9,7 @@
import { PushVehicleGpsEntity } from '../entity/vehiclegps';
import { PushDeviceOnoffEntity } from '../entity/deviceonoff';
import { PushDevicealarmEntity } from '../entity/devicealarm';
+import { PluginService } from '../../plugin/service/info';
import { CachingFactory, MidwayCache } from '@midwayjs/cache-manager';
/**
@@ -37,6 +38,8 @@
@InjectEntityModel(PushAuditlogEntity)
pushAuditlogEntity: Repository<PushAuditlogEntity>;
+ @Inject()
+ pluginService: PluginService;
@InjectClient(CachingFactory, 'default')
midwayCache: MidwayCache;
@@ -139,6 +142,19 @@
// 钀ょ煶鍛婅
case 'ys.alarm': {
+ // 鍥剧墖涓嬭浇骞朵笂浼犲埌鏈湴/瀵硅薄瀛樺偍 pictureList: Array<{ url: string; id: string }>;
+ const localUrls: Record<string, string>[] = [];
+ if (body.pictureList && Array.isArray(body.pictureList)) {
+ const filePlugin = await this.pluginService.getInstance('upload');
+ for (const item of body.pictureList) {
+ try {
+ const result = await filePlugin.downAndUpload(item.url);
+ localUrls.push({url: result, id: item.id});
+ } catch (err) {
+ console.error(`鍥剧墖涓嬭浇澶辫触: ${item.url}`, err);
+ }
+ }
+ }
await this.pushDevicealarmEntity.save({
devSerial: body.devSerial,
channelNo: body.channelNo || String(body.channel),
@@ -155,7 +171,7 @@
location: body.location,
relationId: body.relationId,
status: body.status ? Number(body.status) : 1,
- pictureList: body.pictureList || []
+ pictureList: localUrls || []
});
break;
}
--
Gitblit v1.9.1