|
@@ -2,6 +2,7 @@
|
|
using Hotline.Application.Snapshot.Contracts;
|
|
using Hotline.Application.Snapshot.Contracts;
|
|
using Hotline.Caching.Interfaces;
|
|
using Hotline.Caching.Interfaces;
|
|
using Hotline.Orders;
|
|
using Hotline.Orders;
|
|
|
|
+using Hotline.Repository.SqlSugar.Orders;
|
|
using Hotline.Settings;
|
|
using Hotline.Settings;
|
|
using Hotline.Share.Attributes;
|
|
using Hotline.Share.Attributes;
|
|
using Hotline.Share.Dtos.Article;
|
|
using Hotline.Share.Dtos.Article;
|
|
@@ -12,7 +13,9 @@ using Hotline.Share.Tools;
|
|
using Hotline.Snapshot;
|
|
using Hotline.Snapshot;
|
|
using Hotline.Snapshot.Contracts;
|
|
using Hotline.Snapshot.Contracts;
|
|
using Hotline.Snapshot.IRepository;
|
|
using Hotline.Snapshot.IRepository;
|
|
|
|
+using Hotline.ThirdAccountDomainServices;
|
|
using Mapster;
|
|
using Mapster;
|
|
|
|
+using Microsoft.Extensions.Logging;
|
|
using SqlSugar;
|
|
using SqlSugar;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Text.RegularExpressions;
|
|
@@ -30,8 +33,10 @@ public class SnapshotBulletinApplication : ISnapshotBulletinApplication, IScopeD
|
|
private readonly ISessionContext _sessionContext;
|
|
private readonly ISessionContext _sessionContext;
|
|
private readonly ISafetyTypeRepository _safetyTypeRepository;
|
|
private readonly ISafetyTypeRepository _safetyTypeRepository;
|
|
private readonly ICapPublisher _capPublisher;
|
|
private readonly ICapPublisher _capPublisher;
|
|
|
|
+ private readonly ICitizenRepository _citizenRepository;
|
|
|
|
+ private readonly ILogger<SnapshotBulletinApplication> _logger;
|
|
|
|
|
|
- public SnapshotBulletinApplication(ISystemSettingCacheManager systemSettingCacheManager, ISnapshotBulletinRepository bulletinRepository, INotificationDomainService notificationDomainService, ISessionContext sessionContext, ISafetyTypeRepository safetyTypeRepository, ICapPublisher capPublisher)
|
|
|
|
|
|
+ public SnapshotBulletinApplication(ISystemSettingCacheManager systemSettingCacheManager, ISnapshotBulletinRepository bulletinRepository, INotificationDomainService notificationDomainService, ISessionContext sessionContext, ISafetyTypeRepository safetyTypeRepository, ICapPublisher capPublisher, ICitizenRepository citizenRepository, ILogger<SnapshotBulletinApplication> logger)
|
|
{
|
|
{
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
_bulletinRepository = bulletinRepository;
|
|
_bulletinRepository = bulletinRepository;
|
|
@@ -39,6 +44,8 @@ public class SnapshotBulletinApplication : ISnapshotBulletinApplication, IScopeD
|
|
_sessionContext = sessionContext;
|
|
_sessionContext = sessionContext;
|
|
_safetyTypeRepository = safetyTypeRepository;
|
|
_safetyTypeRepository = safetyTypeRepository;
|
|
_capPublisher = capPublisher;
|
|
_capPublisher = capPublisher;
|
|
|
|
+ _citizenRepository = citizenRepository;
|
|
|
|
+ _logger = logger;
|
|
}
|
|
}
|
|
|
|
|
|
public async Task ExamineBulletinAsync(ExamineBulletinDto dto, CancellationToken token)
|
|
public async Task ExamineBulletinAsync(ExamineBulletinDto dto, CancellationToken token)
|
|
@@ -83,27 +90,43 @@ public class SnapshotBulletinApplication : ISnapshotBulletinApplication, IScopeD
|
|
if (bulletion!.SafetyTypeId!.IsNullOrEmpty()) return;
|
|
if (bulletion!.SafetyTypeId!.IsNullOrEmpty()) return;
|
|
foreach (var safetyTypeId in bulletion!.SafetyTypeId!)
|
|
foreach (var safetyTypeId in bulletion!.SafetyTypeId!)
|
|
{
|
|
{
|
|
- await _safetyTypeRepository.Queryable()
|
|
|
|
- .LeftJoin<CitizenRelationSafetyType>((safety, relation) => safety.Id == relation.SafetyTypeId)
|
|
|
|
- .LeftJoin<Citizen>((safety, relation, citizen) => relation.CitizenId == citizen.Id)
|
|
|
|
- .Where((safety, relation, citizen) => safety.Id == safetyTypeId)
|
|
|
|
- .Select((safety, relation, citizen) => relation.CitizenId)
|
|
|
|
- .ToListAsync(token)
|
|
|
|
- .Then(async citizenIds =>
|
|
|
|
- {
|
|
|
|
- var inDto = bulletion.Adapt<AddNotifyInDto>();
|
|
|
|
- inDto.UserIds = citizenIds;
|
|
|
|
- if (bulletion.Shape != null && bulletion.Shape == EBulletinShape.Video)
|
|
|
|
- {
|
|
|
|
- inDto.NotifyType = ENotificationType.Video;
|
|
|
|
- }
|
|
|
|
- inDto.ExternalId = bulletion.Id;
|
|
|
|
- await _notificationDomainService.AddNotifyAsync(inDto, token);
|
|
|
|
- });
|
|
|
|
|
|
+ var safetyType = await _safetyTypeRepository.GetAsync(safetyTypeId, token);
|
|
|
|
+ if (safetyType == null)
|
|
|
|
+ {
|
|
|
|
+ _logger.LogError($"安全员分类不存在: {safetyTypeId}");
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ var citizenIds = new List<string>();
|
|
|
|
+ if (safetyType.Flags == ESafeTypeFlags.All)
|
|
|
|
+ {
|
|
|
|
+ citizenIds = await _citizenRepository.Queryable()
|
|
|
|
+ .LeftJoin<ThirdAccount>((citizen, third) => citizen.Id == third.ExternalId)
|
|
|
|
+ .Where((citizen, third) => third.Id != null)
|
|
|
|
+ .Select((citizen, third) => citizen.Id)
|
|
|
|
+ .ToListAsync(token);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ citizenIds = await _safetyTypeRepository.Queryable()
|
|
|
|
+ .LeftJoin<CitizenRelationSafetyType>((safety, relation) => safety.Id == relation.SafetyTypeId)
|
|
|
|
+ .LeftJoin<Citizen>((safety, relation, citizen) => relation.CitizenId == citizen.Id)
|
|
|
|
+ .Where((safety, relation, citizen) => safety.Id == safetyTypeId)
|
|
|
|
+ .Select((safety, relation, citizen) => relation.CitizenId)
|
|
|
|
+ .ToListAsync(token);
|
|
|
|
+ }
|
|
|
|
+ if (citizenIds.IsNullOrEmpty()) continue;
|
|
|
|
+
|
|
|
|
+ var inDto = bulletion.Adapt<AddNotifyInDto>();
|
|
|
|
+ inDto.UserIds = citizenIds;
|
|
|
|
+ if (bulletion.Shape != null && bulletion.Shape == EBulletinShape.Video)
|
|
|
|
+ {
|
|
|
|
+ inDto.NotifyType = ENotificationType.Video;
|
|
|
|
+ }
|
|
|
|
+ inDto.ExternalId = bulletion.Id;
|
|
|
|
+ await _notificationDomainService.AddNotifyAsync(inDto, token);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 处理通知公告图片附件路径
|
|
/// 处理通知公告图片附件路径
|
|
/// </summary>
|
|
/// </summary>
|