| | |
| | | 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'; |
| | | |
| | | /** |
| | |
| | | @InjectEntityModel(PushAuditlogEntity) |
| | | pushAuditlogEntity: Repository<PushAuditlogEntity>; |
| | | |
| | | @Inject() |
| | | pluginService: PluginService; |
| | | |
| | | @InjectClient(CachingFactory, 'default') |
| | | midwayCache: MidwayCache; |
| | |
| | | |
| | | // 萤石告警 |
| | | 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), |
| | |
| | | location: body.location, |
| | | relationId: body.relationId, |
| | | status: body.status ? Number(body.status) : 1, |
| | | pictureList: body.pictureList || [] |
| | | pictureList: localUrls || [] |
| | | }); |
| | | break; |
| | | } |