添加轨迹模板相关功能
This commit is contained in:
parent
eef795e2e3
commit
7419001845
@ -10,6 +10,16 @@ public class UpsertOrderInput : UpdateOrderInput
|
||||
[Required]
|
||||
[Range(1, int.MaxValue)]
|
||||
public int CustomId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模板code
|
||||
/// </summary>
|
||||
public List<string> TemplateCodes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前操作人
|
||||
/// </summary>
|
||||
public int OptionUserId { get; set; }
|
||||
}
|
||||
|
||||
public class OrderFlightInfo
|
||||
|
||||
@ -118,4 +118,9 @@ public class UpsertTrackInput : OrderNoInfo
|
||||
/// </summary>
|
||||
[Range(-12, 12)]
|
||||
public float? DestinationTimeZone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前操作人
|
||||
/// </summary>
|
||||
public int OptionUserId { get; set; }
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
namespace SJZY.Track.Application.Contract.Dtos.TrackContents;
|
||||
|
||||
public class GetContentDetailInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 子系统编号
|
||||
/// </summary>
|
||||
public int SystemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public string OrderNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹code
|
||||
/// </summary>
|
||||
public string TrackCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时间
|
||||
/// </summary>
|
||||
public DateTime TrackTime { get; set; }
|
||||
}
|
||||
@ -0,0 +1,192 @@
|
||||
namespace SJZY.Track.Application.Contract.Dtos.TrackContents;
|
||||
|
||||
public class GetContentDetailOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 子系统
|
||||
/// </summary>
|
||||
public int SubSystemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单Id
|
||||
/// </summary>
|
||||
public int OrderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
public string OrderNo { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 索引名称
|
||||
/// </summary>
|
||||
public string IndexName { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型(主数据枚举TrackOrderType)
|
||||
/// </summary>
|
||||
public int OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态
|
||||
/// </summary>
|
||||
public string TrackStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态code
|
||||
/// </summary>
|
||||
public string TrackStatusCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容代码
|
||||
/// </summary>
|
||||
public string TrackCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容
|
||||
/// </summary>
|
||||
public string TrackContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹内容英文
|
||||
/// </summary>
|
||||
public string TrackEnContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 服务商code
|
||||
/// </summary>
|
||||
public string ServiceProviderCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原轨迹内容
|
||||
/// </summary>
|
||||
public string? OriginTrackContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 原轨迹报文hash(刷新轨迹重复性校验使用)
|
||||
/// </summary>
|
||||
public string OriginTrackDataHash { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地
|
||||
/// </summary>
|
||||
public string TrackPlace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时间
|
||||
/// </summary>
|
||||
public DateTime TrackTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生时区
|
||||
/// </summary>
|
||||
public float TrackTimeZone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 转化后的轨迹发生时间
|
||||
/// </summary>
|
||||
public DateTime ZeroTrackTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
public string CreateUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改人
|
||||
/// </summary>
|
||||
public string UpdateUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户是否可见
|
||||
/// </summary>
|
||||
public bool IsVisibility { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据来源:1外部服务商创建,2内部系统创建,3人工创建
|
||||
/// </summary>
|
||||
public int Source { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? Remarks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 附件集合
|
||||
/// </summary>
|
||||
public List<FileItem>? Files { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地(城市)
|
||||
/// </summary>
|
||||
public string? TrackPlaceCity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地(城市)Id
|
||||
/// </summary>
|
||||
public int? TrackPlaceCityId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地(省/州)
|
||||
/// </summary>
|
||||
public string? TrackPlaceProvince { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///轨迹发生地(省/州)Id
|
||||
/// </summary>
|
||||
public int? TrackPlaceProvinceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地(国家/地区)
|
||||
/// </summary>
|
||||
public string? TrackPlaceNation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地(国家/地区)Id
|
||||
/// </summary>
|
||||
public int? TrackPlaceNationId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹发生地邮编
|
||||
/// </summary>
|
||||
public string? TrackPlacePostcode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预计签收时间
|
||||
/// </summary>
|
||||
public DateTime? EstimatedDeliveryDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 签收地时区
|
||||
/// </summary>
|
||||
public float? DestinationTimeZone { get; set; }
|
||||
}
|
||||
|
||||
public class FileItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件osskey
|
||||
/// </summary>
|
||||
public string OssKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件名称
|
||||
/// </summary>
|
||||
public string FileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 路径
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
using AutoMapper;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackContents;
|
||||
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Dtos.TrackContents;
|
||||
|
||||
namespace SJZY.Track.Application.AutoMapper;
|
||||
@ -16,5 +17,9 @@ public class TrackContentAutoMapperProfile : Profile
|
||||
CreateMap<UnifyPageResultDto<GetTrackContentListVO>, UnifyPageResultDto<GetTrackContentListDto>>(
|
||||
MemberList.None);
|
||||
CreateMap<EditTrackContentMapInput, TrackContentMapEntity>(MemberList.None);
|
||||
|
||||
CreateMap<TrackDetailsIndex, GetContentDetailOutput>(MemberList.None).ReverseMap();
|
||||
CreateMap< SJZY.Track.Domain.Aggregates.TrackDetailsAggregate.FileItem, SJZY.Track.Application.Contract.Dtos.TrackContents.FileItem>(MemberList.None).ReverseMap();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public partial class OrderService : ApplicationService, IOrderService
|
||||
{
|
||||
OrderId = order.Id,
|
||||
OrderNo = input.OrderNo,
|
||||
OptionType = OrderOperationType.修改订单.ToString(),
|
||||
OptionType = OrderOperationType.修改订单.ToString(),
|
||||
Content = input.ToJson(),
|
||||
CreateUserId = currentUser.UserId,
|
||||
CreateUserName = currentUser.Name,
|
||||
@ -76,6 +76,7 @@ public partial class OrderService : ApplicationService, IOrderService
|
||||
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
|
||||
order.OrderPullStatus = BuiltOrderPullStatus(input.PullConfigInfos);
|
||||
order.OrderPlatformNumbers = BuiltOrderPlatformNumbers(input.PullConfigInfos);
|
||||
order.TemplateCodes = string.Join(',', input.TemplateCodes);
|
||||
|
||||
var orderId = await _orderRepository.CreateOrderAsync(order);
|
||||
|
||||
|
||||
@ -108,7 +108,7 @@ public partial class TrackService : ApplicationService, ITrackService
|
||||
throw new BusinessException(message: $"订单:{input.OrderNo},轨迹代码:{input.TrackCode}存在多条记录,不允许修改");
|
||||
}
|
||||
|
||||
var userInfo = await _requestCurrentUserService.Service.GetCurrentUserBasicInfoAsync();
|
||||
var userInfo = await _requestCurrentUserService.Service.GetCurrentUserBasicInfoAsync(input.OptionUserId);
|
||||
if (userInfo.Code != GlobalConst.SuccessCode || userInfo.Data is null)
|
||||
{
|
||||
//TODO: log || ex
|
||||
|
||||
@ -2,6 +2,7 @@ using System.Linq.Expressions;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using SJZY.Expand.ABP.Core.Localization;
|
||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||
using SJZY.Expand.AliyunOSS;
|
||||
using SJZY.Track.Application.Contract.Dtos.ProvideServices;
|
||||
using SJZY.Track.Application.Contract.Dtos.TrackContents;
|
||||
using SJZY.Track.Application.Localization;
|
||||
@ -10,7 +11,9 @@ using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackFlagAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
|
||||
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.Dtos.TrackContents;
|
||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
using SJZY.Track.Domain.Queries;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackContents;
|
||||
@ -24,6 +27,7 @@ public class TrackContentService : ApplicationService
|
||||
{
|
||||
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
|
||||
private readonly ITrackContentRepository _trackContentRepository;
|
||||
private readonly ITrackTemplateRepository _trackTemplateRepository;
|
||||
private readonly IBasicQuery<TrackFlagEntity> _trackFlagBasicQuery;
|
||||
private readonly IBasicQuery<TrackStatusEntity> _trackStatusBasicQuery;
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
@ -35,7 +39,8 @@ public class TrackContentService : ApplicationService
|
||||
IBasicQuery<TrackStatusEntity> trackStatusBasicQuery,
|
||||
IBasicQuery<TrackFlagEntity> trackFlagBasicQuery,
|
||||
IOrderRepository orderRepository,
|
||||
ITrackDetailsEsRepository trackDetailsEsRepository)
|
||||
ITrackDetailsEsRepository trackDetailsEsRepository,
|
||||
ITrackTemplateRepository trackTemplateRepository)
|
||||
{
|
||||
_stringLocalizer = stringLocalizer;
|
||||
_trackContentRepository = trackContentRepository;
|
||||
@ -43,6 +48,7 @@ public class TrackContentService : ApplicationService
|
||||
_trackFlagBasicQuery = trackFlagBasicQuery;
|
||||
_orderRepository = orderRepository;
|
||||
_trackDetailsEsRepository = trackDetailsEsRepository;
|
||||
_trackTemplateRepository = trackTemplateRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -220,6 +226,50 @@ public class TrackContentService : ApplicationService
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据子系统id、单号、订单类型、轨迹发生时间、轨迹code获取轨迹内容
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("GetContentDetail")]
|
||||
public async Task<UnifyResultDto<GetContentDetailOutput>> GetContentDetail([FromBody] GetContentDetailInput input)
|
||||
{
|
||||
if (input.SystemId <= 0)
|
||||
return new UnifyResultDto<GetContentDetailOutput>(false, "子系统Id必须大于等于0");
|
||||
|
||||
if (string.IsNullOrEmpty(input.TrackCode))
|
||||
return new UnifyResultDto<GetContentDetailOutput>(false, "轨迹内容code不能为空");
|
||||
|
||||
if (string.IsNullOrEmpty(input.OrderNumber))
|
||||
return new UnifyResultDto<GetContentDetailOutput>(false, "订单code不能为空");
|
||||
|
||||
if (input.OrderType <= 0)
|
||||
return new UnifyResultDto<GetContentDetailOutput>(false, "订单类型不能为空");
|
||||
|
||||
if (input.TrackTime == default)
|
||||
return new UnifyResultDto<GetContentDetailOutput>(false, "轨迹发生时间不能为空");
|
||||
|
||||
var content = await _trackDetailsEsRepository.GetDetailAsync(input.OrderNumber, input.TrackCode, input.OrderType, input.SystemId, input.TrackTime);
|
||||
if (content == default)
|
||||
return new UnifyResultDto<GetContentDetailOutput>(false, "在当前子系统中未找到指定code的轨迹内容");
|
||||
|
||||
var res = new UnifyResultDto<GetContentDetailOutput>(true)
|
||||
{
|
||||
Data = ObjectMapper.Map<TrackDetailsIndex, GetContentDetailOutput>(content)
|
||||
};
|
||||
|
||||
|
||||
if (res.Data != default && res.Data.Files.Any())
|
||||
{
|
||||
foreach (var item in res.Data.Files)
|
||||
{
|
||||
item.Url = OSSHelper.GetUrlByKey(item.OssKey);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建轨迹时获取可用的轨迹内容
|
||||
/// </summary>
|
||||
@ -235,18 +285,25 @@ public class TrackContentService : ApplicationService
|
||||
return new UnifyResultDto<List<GetAvailableContentOutput>>(false, "单号不能为空!");
|
||||
|
||||
//获取当前订单下已有的轨迹内容
|
||||
var orderId = await _orderRepository.GetFirstAsync(x => x.OrderNo == input.OrderNo && x.SubSystemId == input.SystemId, x => x.Id);
|
||||
if (orderId == default)
|
||||
var order = await _orderRepository.GetFirstAsync(x => x.OrderNo == input.OrderNo && x.SubSystemId == input.SystemId);
|
||||
if (order == default)
|
||||
throw new BusinessException(message: "订单不存在!");
|
||||
|
||||
//获取轨迹详情
|
||||
var trackDetails = await _trackDetailsEsRepository.GetListAsync(orderId);
|
||||
var trackDetails = await _trackDetailsEsRepository.GetListAsync(order.Id);
|
||||
|
||||
//获取当前子系统下所有的轨迹内容
|
||||
var contentList = await _trackContentRepository.GetListBySystemIdAsync(input.SystemId);
|
||||
if (contentList == null)
|
||||
throw new BusinessException(message: "当前子系统下未找到任何可用的轨迹内容!");
|
||||
|
||||
//如果订单给了获取模板code,则进一步根据模板code进行过滤
|
||||
if (!string.IsNullOrEmpty(order.TemplateCodes))
|
||||
{
|
||||
var currentCodes = order.TemplateCodes.Split(",");
|
||||
var template = await _trackTemplateRepository.GetContentByTemplateCodes(currentCodes, input.SystemId);
|
||||
contentList = contentList.Where(m => template.Contains(m.Code)).ToList();
|
||||
}
|
||||
|
||||
var res = new UnifyResultDto<List<GetAvailableContentOutput>>(true)
|
||||
{
|
||||
|
||||
@ -180,6 +180,12 @@ public class OrderEntity : IFullAuditedBasicEntitys, IAggregateRoot
|
||||
[SugarColumn(ColumnName = "DestinationTimeZone")]
|
||||
public float? DestinationTimeZone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模板code
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "TemplateCodes")]
|
||||
public string? TemplateCodes { get; set; }
|
||||
|
||||
[SugarColumn(IsIgnore = true)] public List<OrderFlightEntity> OrderFlights { get; set; }
|
||||
|
||||
[SugarColumn(IsIgnore = true)] public List<OrderPullStatusEntity> OrderPullStatus { get; set; }
|
||||
|
||||
@ -29,4 +29,5 @@ public interface ITrackDetailsEsRepository : IElasticsearchClientService<TrackDe
|
||||
|
||||
Task DeleteTrackByIdAsync(string id, string indexName);
|
||||
Task<List<TrackDetailsIndex>> GetDataByIds(string[] ids);
|
||||
Task<TrackDetailsIndex> GetDetailAsync(string orderNo, string trackCode, int orderType, int subSystemId, DateTime trackTime);
|
||||
}
|
||||
|
||||
@ -45,4 +45,5 @@ public interface ITrackTemplateRepository : IBasicRepository<TrackTemplateEntity
|
||||
Expression<Func<TrackTemplateContentEntity, bool>> whereExpression);
|
||||
|
||||
Task<List<TrackTemplateOutputVo>> GetTrackTemplateListAsync(GetTrackTemplateListInputVo input);
|
||||
Task<List<string>> GetContentByTemplateCodes(string[] codes, int systemId);
|
||||
}
|
||||
|
||||
@ -440,4 +440,39 @@ public class TrackDetailsEsRepository : ElasticSearchContextAbstract<TrackDetail
|
||||
|
||||
return res.ToIdList();
|
||||
}
|
||||
|
||||
public async Task<TrackDetailsIndex> GetDetailAsync(string orderNo, string trackCode, int orderType, int subSystemId, DateTime trackTime)
|
||||
{
|
||||
var res = await Context.SearchAsync<TrackDetailsIndex>(s => s
|
||||
.Index("sjzy_track_details")
|
||||
.Query(q => q
|
||||
.Bool(b => b
|
||||
.Must(mu => mu
|
||||
.Terms(t => t
|
||||
.Field(f => f.OrderNo.Suffix("keyword"))
|
||||
.Terms(orderNo)),
|
||||
mu => mu
|
||||
.Terms(t => t
|
||||
.Field(f => f.TrackCode.Suffix("keyword"))
|
||||
.Terms(trackCode)),
|
||||
mu => mu
|
||||
.Terms(t => t
|
||||
.Field(f => f.OrderType)
|
||||
.Terms(orderType)),
|
||||
mu => mu
|
||||
.Terms(t => t
|
||||
.Field(f => f.SubSystemId)
|
||||
.Terms(subSystemId)),
|
||||
mu => mu
|
||||
.Terms(t => t
|
||||
.Field(f => f.TrackTime)
|
||||
.Terms(trackTime)) // 注意:这里你重复了OrderType的查询,你可能需要移除重复的查询
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return res.Documents.FirstOrDefault();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
|
||||
using SJZY.Track.Domain.Dtos.TrackTemplate;
|
||||
using SJZY.Track.Domain.Enums;
|
||||
using SJZY.Track.Domain.VEntities;
|
||||
using SJZY.Expand.ABP.Core.SqlSugar.Tools;
|
||||
|
||||
namespace SJZY.Track.Repository.Repositories;
|
||||
|
||||
@ -225,4 +226,26 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
|
||||
return templates;
|
||||
}
|
||||
|
||||
public async Task<List<string>> GetContentByTemplateCodes(string[] codes, int systemId)
|
||||
{
|
||||
|
||||
var sql = @$"
|
||||
select
|
||||
distinct
|
||||
c.Code
|
||||
from t_track_template a
|
||||
left join t_track_template_content b on a.id = b.TrackTemplateId and b.IsDeleted = 0
|
||||
left join t_track_content c on b.TrackContentId = c.Id and c.IsDeleted = 0
|
||||
where
|
||||
a.SubSystemId = {systemId}
|
||||
and a.Code in (@codes)
|
||||
and a.IsDeleted = 0
|
||||
";
|
||||
|
||||
|
||||
var list = Context.Ado.SqlQuery<string>(sql, new {codes = codes}).ToList();
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user