|
@@ -20,6 +20,10 @@ using Hotline.Settings.Hotspots;
|
|
|
using Hotline.Share.Dtos.FlowEngine;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Hotline.Settings;
|
|
|
+using SqlSugar;
|
|
|
+using Hotline.Push.Notifies;
|
|
|
+using Hotline.Share.Enums.Push;
|
|
|
+using MediatR;
|
|
|
|
|
|
namespace Hotline.Orders;
|
|
|
|
|
@@ -42,6 +46,7 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
private readonly IWorkflowDomainService _workflowDomainService;
|
|
|
private readonly IRepository<Hotspot> _hotspotRepository;
|
|
|
+ private readonly IMediator _mediator;
|
|
|
|
|
|
|
|
|
public OrderDomainService(
|
|
@@ -62,7 +67,8 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
ISystemSettingCacheManager systemSettingCacheManager,
|
|
|
IRepository<Scheduling> schedulingRepository,
|
|
|
IWorkflowDomainService workflowDomainService,
|
|
|
- IRepository<Hotspot> hotspotRepository)
|
|
|
+ IRepository<Hotspot> hotspotRepository,
|
|
|
+ IMediator mediator)
|
|
|
{
|
|
|
_orderRepository = orderRepository;
|
|
|
_orderRedoRepository = orderRedoRepository;
|
|
@@ -81,6 +87,7 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
|
_workflowDomainService = workflowDomainService;
|
|
|
_hotspotRepository = hotspotRepository;
|
|
|
+ _mediator = mediator;
|
|
|
}
|
|
|
|
|
|
public async Task<Order> GetOrderAsync(string? orderId, bool withHotspot = false, bool withAcceptor = false,
|
|
@@ -411,17 +418,38 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
{
|
|
|
var now = DateTime.Now;
|
|
|
//查询即将超期和超期工单
|
|
|
- var orderList = await _orderRepository.Queryable().Where(x=>x.NearlyExpiredTime> now && x.Status< EOrderStatus.Filed).ToListAsync(cancellationToken);
|
|
|
- //即将超期工单
|
|
|
- var nearlyOrderList = orderList.Where(x => x.NearlyExpiredTime >= now && x.ExpiredTime > now).ToList();
|
|
|
- nearlyOrderList.GroupBy(x => x.CurrentHandleOrgId).Select(x => new
|
|
|
+ var orderList = await _orderRepository.Queryable()
|
|
|
+ .Where(x=>x.NearlyExpiredTime> now && x.Status< EOrderStatus.Filed && !string.IsNullOrEmpty(x.CurrentHandleOrgId))
|
|
|
+ .GroupBy(x=>x.CurrentHandleOrgId)
|
|
|
+ .Select(x => new OverTimeOrderDto
|
|
|
+ {
|
|
|
+ OrgId = x.CurrentHandleOrgId,
|
|
|
+ NearlyOrderCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.NearlyExpiredTime >= now && x.ExpiredTime > now,1,0)),
|
|
|
+ ExpiredTimeOrderCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.ExpiredTime>now,1,0))
|
|
|
+ })
|
|
|
+ .ToListAsync(cancellationToken);
|
|
|
+
|
|
|
+ foreach (var item in orderList)
|
|
|
{
|
|
|
- OrgId = x.Key,
|
|
|
- Count = x.Count()
|
|
|
- });
|
|
|
-
|
|
|
- //超期工单
|
|
|
- var expiredOrderList = orderList.Where(x => x.ExpiredTime > now).ToList();
|
|
|
+ //查询部门所有账号
|
|
|
+ var userlist = await _userRepository.Queryable().Where(x =>
|
|
|
+ x.OrgId == item.OrgId && !string.IsNullOrEmpty(x.PhoneNo) &&
|
|
|
+ x.Roles.Any(d => d.Id == "08dae71e-0eca-4bc4-89fe-7eaefae8a98e")).ToListAsync();
|
|
|
+ //发送短信
|
|
|
+ foreach (var user in userlist)
|
|
|
+ {
|
|
|
+ var messageDto = new Share.Dtos.Push.MessageDto
|
|
|
+ {
|
|
|
+ PushBusiness = EPushBusiness.OrderExpire,
|
|
|
+ PushPlatform = EPushPlatform.Sms,
|
|
|
+ Name = user.Name,
|
|
|
+ TemplateCode = "1009",
|
|
|
+ Params = new List<string>() { item.NearlyOrderCount.ToString(), item.ExpiredTimeOrderCount.ToString() },
|
|
|
+ TelNumber = user.PhoneNo,
|
|
|
+ };
|
|
|
+ await _mediator.Publish(new PushMessageNotify(messageDto), cancellationToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#endregion
|