diff --git a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetTrackInput.cs b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetTrackInput.cs
index 578c31b2..7f6898d7 100644
--- a/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetTrackInput.cs
+++ b/src/SJZY.Track.Application.Contract/Dtos/ProvideServices/GetTrackInput.cs
@@ -1,3 +1,5 @@
+using System.ComponentModel.DataAnnotations;
+
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
public class GetTrackInput
@@ -5,6 +7,8 @@ public class GetTrackInput
///
/// 订单类型
///
+ [Required]
+ [Range(1, int.MaxValue)]
public int OrderType { get; set; }
///
@@ -14,12 +18,14 @@ public class GetTrackInput
///
/// 时区 +8 +8.25 -8.5 -9
+ /// 不传默认+8
///
- public float TimeZone { get; set; }
+ public float? TimeZone { get; set; } = 8;
///
/// 排序方式
///
+ [Required]
public SortMethod SortMethod { get; set; }
}
diff --git a/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs b/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs
index c3739029..8b6fd2cc 100644
--- a/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs
+++ b/src/SJZY.Track.Application/Services/ProvideServices/TrackQueryService.cs
@@ -22,7 +22,7 @@ public class TrackQueryService : ApplicationService
IProvideQueries provideQueries)
{
_trackDetailsRepository = trackDetailsRepository;
- _orderRepository=orderRepository;
+ _orderRepository = orderRepository;
_provideQueries = provideQueries;
}
@@ -44,7 +44,6 @@ public class TrackQueryService : ApplicationService
input.OrderNos = input.OrderNos.Distinct().ToList(); // 单号去重
var details = await _trackDetailsRepository.GetListAsync(input.OrderType, input.OrderNos);
- var isTurn = input.TimeZone != 0;
foreach (var group in details.GroupBy(x => x.OrderId))
{
var item = new GetTrackOutput();
@@ -57,8 +56,8 @@ public class TrackQueryService : ApplicationService
Status = x.TrackStatus,
Content = x.TrackContent,
Location = x.TrackPlace,
- Time = isTurn ? x.TrackTime.AddHours(input.TimeZone - x.TraceTimeZone) : x.TrackTime,
- TimeZone = isTurn ? input.TimeZone : x.TraceTimeZone
+ Time = x.TrackTime.AddHours(input.TimeZone!.Value - x.TraceTimeZone),
+ TimeZone = input.TimeZone!.Value
}).ToList();
res.Add(item);
diff --git a/src/SJZY.Track.Repository/Queries/ProvideQueries.cs b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
index 064f9445..a44a15bc 100644
--- a/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
+++ b/src/SJZY.Track.Repository/Queries/ProvideQueries.cs
@@ -56,7 +56,7 @@ public class ProvideQueries : ISugarRepository, IProvideQueries,
.OrderBy(a => a.Sort)
.Select((a, b) => new OrderedTrackCodeDto
{
- TemplateId = a.Id,
+ TemplateId = a.TrackTemplateId,
Code = b.Code
})
.ToListAsync();
diff --git a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
index 98a4d7d3..cf78c66f 100644
--- a/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
+++ b/src/SJZY.Track.Repository/Repositories/TrackDetailsRepository.cs
@@ -44,7 +44,7 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract(index.Id, u => u
.Index(index.IndexName)
.Doc(index)
- //.Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
+ //.Refresh(Refresh.True) // 可选:立即刷新索引使更改立即可见
);
if (!r.IsValid)
{
- LogHelper.Error($"轨迹数据更新失败,原因:{r.DebugInformation}。");
+ LogHelper.Error($"轨迹更新失败,原因:{r.DebugInformation}。");
}
}
}
@@ -68,6 +68,7 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract(x => x
.Source(s => s.Includes(fd => fd
+ .Field(f => f.OrderNo)
.Field(f => f.TrackStatus)
.Field(f => f.TrackCode)
.Field(f => f.TrackContent)
@@ -89,22 +90,26 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract?> GetListAsync(int orderId)
{
- var data = await Context.SearchAsync(x => x.Query(q => q.Term(t => t.OrderId, orderId)).Size(1000)
- .Sort(s => s.Field(f => f.TrackTime, SortOrder.Descending)));
+ var data = await Context.SearchAsync(x => x.Query(q => q.Term(t => t.OrderId, orderId))
+ .Size(1000)
+ .Sort(s => s.Field(f => f.TrackTime, SortOrder.Descending)));
return data?.Documents?.ToList();
}
public async Task DeleteTrackAsync(int orderId, List trackCodes)
{
- await Context.UpdateByQueryAsync(x => x
+ var r = await Context.UpdateByQueryAsync(x => x
.Query(
q =>
q.Term(t => t.OrderId, orderId)
- && q.Terms(t => t.Field(f => f.TrackCode).Terms(trackCodes)))
+ && q.Terms(t => t.Field(f => f.TrackCode.Suffix("keyword")).Terms(trackCodes)))
.Script(s => s
.Source("ctx._source.isDeleted = true"))
);
+
+ if (!r.IsValid)
+ throw new Exception($"轨迹数据删除失败,原因:{r.DebugInformation}");
}
public async Task<(List list, long total)> GetListAsync(TrackDetailsQueryInput input)