From 9d29759cc03eb05bbeaf449f83cc14b7c57c4373 Mon Sep 17 00:00:00 2001
From: moyongzhen <2534173414@qq.com>
Date: Fri, 29 Mar 2024 14:14:19 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E5=AF=B9=E5=A4=96=E6=8E=A5=E5=8F=A3?=
=?UTF-8?q?=E5=8C=85=20=20unifyResultDto?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/IOrderService.cs | 6 +++---
.../ProvideServices/OrderService.Link.cs | 17 +++++++++--------
.../Services/ProvideServices/OrderService.cs | 11 ++++++-----
3 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/src/SJZY.Track.Application.Contract/Services/IOrderService.cs b/src/SJZY.Track.Application.Contract/Services/IOrderService.cs
index 0dd34413..adff3b24 100644
--- a/src/SJZY.Track.Application.Contract/Services/IOrderService.cs
+++ b/src/SJZY.Track.Application.Contract/Services/IOrderService.cs
@@ -10,19 +10,19 @@ public interface IOrderService : IRemoteService
///
///
///
- Task UpsertAsync(UpsertOrderInput input);
+ Task UpsertAsync(UpsertOrderInput input);
///
/// 删除订单
///
///
///
- Task DeleteOrderAsync(DeleteOrderInput input);
+ Task DeleteOrderAsync(DeleteOrderInput input);
///
/// 关联订单
///
///
///
- Task LinkOrderAsync(LinkOrderInput input);
+ Task LinkOrderAsync(LinkOrderInput input);
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
index 88eb9530..7226ee0f 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
@@ -22,13 +22,14 @@ public partial class OrderService
///
///
[HttpPost("Order/Link")]
- public async Task LinkOrderAsync(LinkOrderInput input)
+ public async Task LinkOrderAsync(LinkOrderInput input)
{
var order = await _orderRepository.GetFirstAsync(x =>
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
- {
- x.Id, x.SubSystemId
- });
+ {
+ x.Id,
+ x.SubSystemId
+ });
if (order == default)
{
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
@@ -40,7 +41,7 @@ public partial class OrderService
throw new BusinessException(message: "不能同级关联");
}
- if (input.LinkOrderNos.Count < 1 || input.LinkOrderType == 0) return true;
+ if (input.LinkOrderNos.Count < 1 || input.LinkOrderType == 0) return new UnifyResultDto(true);
// 单号去重,去空,去自己
input.LinkOrderNos = input.LinkOrderNos
@@ -64,7 +65,7 @@ public partial class OrderService
});
}
- return true;
+ return new UnifyResultDto(true);
}
private async Task> DoLinkOrderAsync(LinkOrderInput input, int orderId)
@@ -97,7 +98,7 @@ public partial class OrderService
return canLinkOrders.Select(x => x.Id).ToList();
}
- private async Task UnLinkOrderAsync(LinkOrderInput input)
+ private async Task UnLinkOrderAsync(LinkOrderInput input)
{
var unLinkIds = await _orderLinkQuery.GetListAsync(x =>
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo &&
@@ -107,6 +108,6 @@ public partial class OrderService
// real del
await _orderRepository.UnLinkByIdsAsync(unLinkIds);
- return true;
+ return new UnifyResultDto(true);
}
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
index 712b775c..d562ef9b 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
@@ -30,7 +30,7 @@ public partial class OrderService : ApplicationService, IOrderService
///
///
[HttpPost("Order/Upsert")]
- public async Task UpsertAsync(UpsertOrderInput input)
+ public async Task UpsertAsync(UpsertOrderInput input)
{
if (input.Templates.Count == 0) throw new BusinessException(message: "至少有一个模板");
var order = await _orderRepository.GetFirstAsync(x =>
@@ -39,7 +39,8 @@ public partial class OrderService : ApplicationService, IOrderService
{
// 订单已存在则视为更新
await UpdateOrderAsync(input, order);
- return "更新成功";
+
+ return new UnifyResultDto() { Code = "200", Msg = "操作成功", Data = "创建成功" };
}
order = ObjectMapper.Map(input);
@@ -48,7 +49,7 @@ public partial class OrderService : ApplicationService, IOrderService
order.OrderFlights = ObjectMapper.Map, List>(input.FlightInfos);
await _orderRepository.CreateOrderAsync(order);
- return "创建成功";
+ return new UnifyResultDto() { Code = "200", Msg = "操作成功", Data = "新增成功" };
}
///
@@ -58,7 +59,7 @@ public partial class OrderService : ApplicationService, IOrderService
///
///
[HttpPost("Order/Delete")]
- public async Task DeleteOrderAsync(DeleteOrderInput input)
+ public async Task DeleteOrderAsync(DeleteOrderInput input)
{
var orderId = await _orderRepository.GetFirstAsync(x =>
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => x.Id);
@@ -69,7 +70,7 @@ public partial class OrderService : ApplicationService, IOrderService
await _orderRepository.DeleteOrderAsync(orderId);
- return true;
+ return new UnifyResultDto(true);
}
private async Task UpdateOrderAsync(UpdateOrderInput input, OrderEntity order)
From 5818d8ddd87b8829e1ef072f6438452977dd0359 Mon Sep 17 00:00:00 2001
From: moyongzhen <2534173414@qq.com>
Date: Fri, 29 Mar 2024 14:39:30 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E5=AF=B9=E5=A4=96=E6=8E=A5=E5=8F=A3?=
=?UTF-8?q?=E8=BF=94=E5=8F=82=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/ITrackService.cs | 6 +--
.../ProvideServices/OrderService.Link.cs | 4 +-
.../Services/ProvideServices/OrderService.cs | 2 +-
.../Services/ProvideServices/TrackService.cs | 47 ++++++++++++-------
4 files changed, 35 insertions(+), 24 deletions(-)
diff --git a/src/SJZY.Track.Application.Contract/Services/ITrackService.cs b/src/SJZY.Track.Application.Contract/Services/ITrackService.cs
index 1b0ec5b5..31dae617 100644
--- a/src/SJZY.Track.Application.Contract/Services/ITrackService.cs
+++ b/src/SJZY.Track.Application.Contract/Services/ITrackService.cs
@@ -10,21 +10,21 @@ public interface ITrackService : IRemoteService
///
///
///
- Task UpsertTrackAsync(UpsertTrackInput input);
+ Task UpsertTrackAsync(UpsertTrackInput input);
///
/// 删除轨迹
///
///
///
- Task DeleteTrackAsync(DeleteTrackInput input);
+ Task DeleteTrackAsync(DeleteTrackInput input);
///
/// 批量删除轨迹
///
///
///
- Task BatchDeleteTrackAsync(BatchDeleteTrackInput input);
+ Task BatchDeleteTrackAsync(BatchDeleteTrackInput input);
///
/// 根据订单号获取轨迹
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
index 7226ee0f..1f5e0446 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs
@@ -65,7 +65,7 @@ public partial class OrderService
});
}
- return new UnifyResultDto(true);
+ return new UnifyResultDto(true, true);
}
private async Task> DoLinkOrderAsync(LinkOrderInput input, int orderId)
@@ -108,6 +108,6 @@ public partial class OrderService
// real del
await _orderRepository.UnLinkByIdsAsync(unLinkIds);
- return new UnifyResultDto(true);
+ return new UnifyResultDto(true, true);
}
}
\ No newline at end of file
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
index d562ef9b..d1086bf7 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs
@@ -70,7 +70,7 @@ public partial class OrderService : ApplicationService, IOrderService
await _orderRepository.DeleteOrderAsync(orderId);
- return new UnifyResultDto(true);
+ return new UnifyResultDto(true, true);
}
private async Task UpdateOrderAsync(UpdateOrderInput input, OrderEntity order)
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
index 72fe2f20..ab387b25 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackService.cs
@@ -38,13 +38,17 @@ public partial class TrackService : ApplicationService, ITrackService
///
///
[HttpPost("Track/Upsert")]
- public async Task UpsertTrackAsync(UpsertTrackInput input)
+ public async Task UpsertTrackAsync(UpsertTrackInput input)
{
var order = await _orderRepository.GetFirstAsync(x =>
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
- {
- x.Id, x.SubSystemId, x.LatestPushTrackContentId, x.CustomId, x.IsCompleted
- });
+ {
+ x.Id,
+ x.SubSystemId,
+ x.LatestPushTrackContentId,
+ x.CustomId,
+ x.IsCompleted
+ });
if (order == default)
{
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
@@ -59,7 +63,7 @@ public partial class TrackService : ApplicationService, ITrackService
@event.IsCompleted = order.IsCompleted;
@event.OperationMan = CurrentUserRequest.CurrentUser.Name;
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
- return true;
+ return new UnifyResultDto(true, true);
}
///
@@ -69,7 +73,7 @@ public partial class TrackService : ApplicationService, ITrackService
///
///
[HttpPost("Track/BatchUpsert")]
- public async Task BatchUpsertTrackAsync(BatchUpsertTrackInput input)
+ public async Task BatchUpsertTrackAsync(BatchUpsertTrackInput input)
{
input.OrderNos = input.OrderNos.Where(x => !x.IsNullOrWhiteSpace()).Distinct().ToList(); // 单号去重、去空
if (input.OrderNos.Count == 0)
@@ -79,9 +83,14 @@ public partial class TrackService : ApplicationService, ITrackService
var orders = await _orderRepository.GetListAsync(x =>
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo), x => new
- {
- x.Id, x.OrderNo, x.SubSystemId, x.LatestPushTrackContentId, x.CustomId, x.IsCompleted
- });
+ {
+ x.Id,
+ x.OrderNo,
+ x.SubSystemId,
+ x.LatestPushTrackContentId,
+ x.CustomId,
+ x.IsCompleted
+ });
foreach (var order in orders)
{
@@ -105,7 +114,7 @@ public partial class TrackService : ApplicationService, ITrackService
await _capPublisher.PublishAsync(GlobalConst.TrackUpsertSubscribe, @event);
}
- return true;
+ return new UnifyResultDto(true, true);
}
///
@@ -115,13 +124,14 @@ public partial class TrackService : ApplicationService, ITrackService
///
///
[HttpPost("Track/Delete")]
- public async Task DeleteTrackAsync(DeleteTrackInput input)
+ public async Task DeleteTrackAsync(DeleteTrackInput input)
{
var order = await _orderRepository.GetFirstAsync(x =>
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
- {
- x.Id, x.SubSystemId
- });
+ {
+ x.Id,
+ x.SubSystemId
+ });
if (order == default)
{
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
@@ -144,7 +154,7 @@ public partial class TrackService : ApplicationService, ITrackService
};
await _capPublisher.PublishAsync(GlobalConst.TrackDeleteSubscribe, @event);
- return true;
+ return new UnifyResultDto(true, true);
}
///
@@ -154,13 +164,14 @@ public partial class TrackService : ApplicationService, ITrackService
///
///
[HttpPost("Track/BatchDelete")]
- public async Task BatchDeleteTrackAsync(BatchDeleteTrackInput input)
+ public async Task BatchDeleteTrackAsync(BatchDeleteTrackInput input)
{
var orders = await _orderRepository.GetListAsync(x =>
x.OrderType == input.OrderType && input.OrderNos.Contains(x.OrderNo)
, x => new
{
- x.Id, x.SubSystemId
+ x.Id,
+ x.SubSystemId
});
var codes = await _provideQueries.GetCanDeleteTrackCodesAsync(
@@ -185,6 +196,6 @@ public partial class TrackService : ApplicationService, ITrackService
await _capPublisher.PublishAsync(GlobalConst.TrackDeleteSubscribe, @event);
}
- return true;
+ return new UnifyResultDto(true, true);
}
}
\ No newline at end of file
From 8962d032b1575affbcd5ba06ec1d8647de6c0542 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Fri, 29 Mar 2024 15:26:39 +0800
Subject: [PATCH 3/4] 7.0.0
---
.../SJZY.Track.Application.Contract.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj b/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj
index fe8765ac..1b129506 100644
--- a/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj
+++ b/src/SJZY.Track.Application.Contract/SJZY.Track.Application.Contract.csproj
@@ -5,7 +5,7 @@
net7.0
True
- 1.0.3
+ 7.0.0
True
From 322a3a67ed35897928d6038ef4318f61e100e102 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=86=9B?= <2357729423@qq.com>
Date: Sat, 30 Mar 2024 15:24:11 +0800
Subject: [PATCH 4/4] =?UTF-8?q?fix=EF=BC=9A=E9=A2=84=E8=AD=A6OOM?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ProvideServices/TrackPushService.cs | 18 +++----------
.../OrderAggregate/IOrderRepository.cs | 4 +--
.../Repositories/OrderRepository.cs | 25 +++++++------------
3 files changed, 14 insertions(+), 33 deletions(-)
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
index 78611294..ab655a04 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackPushService.cs
@@ -7,7 +7,6 @@ using SJZY.Track.Domain.Aggregates.OrderAggregate;
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
using SJZY.Track.Domain.Consts;
-using SJZY.Track.Domain.Enums;
using SJZY.UserCenter.HttpApi.Services;
namespace SJZY.Track.Application.Services.ProvideServices;
@@ -120,20 +119,9 @@ public class TrackPushService : ApplicationService
[HttpPost("Track/PushWarnForTask")]
public async Task PushWarnForTaskAsync()
{
- var orders = await _orderRepository.GetPushWarnOrdersAsync();
-
- var time = DateTime.Now.Subtract(TimeSpan.FromHours(12));
-
- orders.ForEach(x =>
- {
- x.QuestionType = x.LatestPushTime == null || x.LatestPushTime < time
- ? (int)TrackProblemType.Warn
- : (int)TrackProblemType.None;
- });
-
- await _orderRepository.UpdateRangeAsync(orders, x => new { x.QuestionType });
-
- return $"成功将:{orders.Count(x => x.QuestionType == (int)TrackProblemType.Warn)}个订单置为预警";
+ // todo:订单数据上来后一次性update是否会引发长时间X独占?
+ var count = await _orderRepository.PushWarnOrdersAsync();
+ return $"本次预警扫描了:{count}个订单";
}
///
diff --git a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs
index 10832b40..7eaf030f 100644
--- a/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs
+++ b/src/SJZY.Track.Domain/Aggregates/OrderAggregate/IOrderRepository.cs
@@ -26,10 +26,10 @@ public interface IOrderRepository : IBasicRepository
Task DeleteOrderAsync(int orderId);
///
- /// 获取推送预警单
+ /// 更新推送预警单
///
///
- Task> GetPushWarnOrdersAsync();
+ Task PushWarnOrdersAsync();
#region 订单关联
diff --git a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
index bbbdca05..b6b49e77 100644
--- a/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/OrderRepository.cs
@@ -1,8 +1,6 @@
using SJZY.Track.Domain;
using SJZY.Track.Domain.Aggregates.OrderAggregate;
-using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
using SJZY.Track.Domain.Dtos.Order;
-using SJZY.Track.Domain.Enums;
namespace SJZY.Track.Repository.Repositories;
@@ -55,21 +53,16 @@ public class OrderRepository : BasicRepository, IOrderRepository, I
tran.Complete();
}
- public async Task> GetPushWarnOrdersAsync()
+ public async Task PushWarnOrdersAsync()
{
- var errorType = (int)TrackProblemType.Error;
-
- return await Context.Queryable()
- .LeftJoin((a, b) => a.SubSystemId == b.SubSystemId && a.CustomId == b.CustomId)
- .Where((a, b) => !b.IsCompleted && b.QuestionType != errorType)
- .Where("a.CreateTime < DATE_SUB(now(),INTERVAL 12 hour)") // 过滤掉创建时间不足12小时的
- .Select((a, b) => new OrderEntity
- {
- Id = b.Id,
- QuestionType = b.QuestionType,
- LatestPushTime = b.LatestPushTime
- })
- .ToListAsync();
+ return await Context.Ado.ExecuteCommandAsync(@"UPDATE `t_track_push_config` `a`
+LEFT JOIN `t_order` `b` ON `a`.`SubSystemId` = `b`.`SubSystemId` AND `a`.`CustomId` = `b`.`CustomId`
+SET `b`.`QuestionType` = CASE
+ WHEN `b`.`LatestPushTime` IS NULL THEN 2
+ WHEN `b`.`LatestPushTime` < DATE_SUB(NOW(), INTERVAL 12 HOUR) THEN 2
+ ELSE 0 END
+WHERE `b`.`IsCompleted` = 0 AND `b`.`QuestionType` != 1 AND `b`.`CreateTime` < DATE_SUB(NOW(), INTERVAL 12 HOUR)
+AND `a`.`IsDeleted` = 0 AND `b`.`IsDeleted` = 0;");
}
#region 订单关联