wangrong
2026-07-20 b46304989eaefa139e41456331e419cc3b2ff4cc
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;
        }