合并解决冲突

This commit is contained in:
moyongzhen 2024-03-05 16:55:28 +08:00
commit 4f42663ad5
4 changed files with 23 additions and 13 deletions

View File

@ -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
/// <summary>
/// 订单类型
/// </summary>
[Required]
[Range(1, int.MaxValue)]
public int OrderType { get; set; }
/// <summary>
@ -14,12 +18,14 @@ public class GetTrackInput
/// <summary>
/// 时区 +8 +8.25 -8.5 -9
/// 不传默认+8
/// </summary>
public float TimeZone { get; set; }
public float? TimeZone { get; set; } = 8;
/// <summary>
/// 排序方式
/// </summary>
[Required]
public SortMethod SortMethod { get; set; }
}

View File

@ -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);

View File

@ -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();

View File

@ -44,7 +44,7 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
if (!r.IsValid)
{
LogHelper.Error($"轨迹数据新增失败,原因:{r.DebugInformation}。");
LogHelper.Error($"轨迹新增失败,原因:{r.DebugInformation}。");
}
}
else
@ -52,12 +52,12 @@ internal class TrackDetailsRepository : ElasticSearchContextAbstract<TrackDetail
var r = await Context.UpdateAsync<TrackDetailsIndex>(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<TrackDetail
var data = await Context.SearchAsync<TrackDetailsIndex>(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<TrackDetail
public async Task<List<TrackDetailsIndex>?> GetListAsync(int orderId)
{
var data = await Context.SearchAsync<TrackDetailsIndex>(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<TrackDetailsIndex>(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<string> trackCodes)
{
await Context.UpdateByQueryAsync<TrackDetailsIndex>(x => x
var r = await Context.UpdateByQueryAsync<TrackDetailsIndex>(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<TrackDetailsIndex> list, long total)> GetListAsync(TrackDetailsQueryInput input)