Merge remote-tracking branch 'origin/S01-轨迹中台' into S01-轨迹中台

This commit is contained in:
李鹏军 2024-03-01 17:50:25 +08:00
commit 38f69d0dc5
19 changed files with 263 additions and 35 deletions

View File

@ -1,7 +1,7 @@
{ {
"Configuration": { "Configuration": {
"UseLocalConfiguration": true, // 是否使用本地配置文件 "UseLocalConfiguration": true, //是否使用本地配置文件
"ConfiguraFileName": "appsettings.Development.json", //指定配置文件名称,开启 UseLocalConfiguration 时生效 "ConfiguraFileName": "appsettings.Development.json", //指定配置文件名称,开启UseLocalConfiguration时生效
"Apollo": { "Apollo": {
"AppId": "SJZY.Track.Configuration", "AppId": "SJZY.Track.Configuration",
"Env": "DEV", "Env": "DEV",

View File

@ -10,7 +10,7 @@
/// <summary> /// <summary>
/// 关键字 /// 关键字
/// </summary> /// </summary>
public string Keywords { get; set; } = ""; public string? Keywords { get; set; }
} }
public class GetTrackContentListDto public class GetTrackContentListDto

View File

@ -55,6 +55,11 @@
/// </summary> /// </summary>
public int SubSystemId { get; set; } public int SubSystemId { get; set; }
/// <summary>
/// 选中的轨迹标记id
/// </summary>
public List<int>? SelectIds { get; set; }
///// <summary> ///// <summary>
///// 关键字 ///// 关键字
///// </summary> ///// </summary>

View File

@ -0,0 +1,81 @@
namespace SJZY.Track.Application.Contract.Dtos.TrackPush;
public class EditTrackPushConfigInput
{
/// <summary>
/// 客户id
/// </summary>
public int CustomId { get; set; }
/// <summary>
/// 推送扩展字段
/// </summary>
public string ExpandFieldsName { get; set; }
public int? Id { get; set; }
/// <summary>
/// 是否自动推送
/// </summary>
public bool IsAutoPush { get; set; }
/// <summary>
/// 操作类型
/// </summary>
public OptionTypeNoNull Options { get; set; }
/// <summary>
/// 推送轨迹订单号
/// </summary>
public string OrderNoName { get; set; }
/// <summary>
/// 服务商id
/// </summary>
public int ServiceProviderId { get; set; }
/// <summary>
/// 子系统id
/// </summary>
public int SubSystemId { get; set; }
/// <summary>
/// 推送轨迹时区
/// </summary>
public string TackTimeZoneName { get; set; }
/// <summary>
/// 推送轨迹内容代码
/// </summary>
public string TrackContentCodeName { get; set; }
/// <summary>
/// 推送轨迹内容
/// </summary>
public string TrackContentName { get; set; }
/// <summary>
/// 推送轨迹内容英文
/// </summary>
public string TrackEnContentName { get; set; }
/// <summary>
/// 推送轨迹发生地
/// </summary>
public string TrackPlaceName { get; set; }
/// <summary>
/// 推送轨迹状态
/// </summary>
public string TrackStatusName { get; set; }
/// <summary>
/// 轨迹模板id
/// </summary>
public List<int> TrackTemplateIds { get; set; }
/// <summary>
/// 推送轨迹发生时间
/// </summary>
public string TrackTimeName { get; set; }
}

View File

@ -64,6 +64,11 @@
/// <summary> /// <summary>
/// 关键字 /// 关键字
/// </summary> /// </summary>
public string Keywords { get; set; } = ""; public string? Keywords { get; set; }
/// <summary>
/// 选中的轨迹状态id
/// </summary>
public List<int>? SelectIds { get; set;}
} }
} }

View File

@ -13,11 +13,16 @@
/// <summary> /// <summary>
/// 关键字 /// 关键字
/// </summary> /// </summary>
public string Keywords { get; set; } = ""; public string? Keywords { get; set; }
///// <summary>
///// 轨迹模版id,轨迹映射的查询使用
///// </summary>
//public int TrackTemplateId { get; set; }
/// <summary> /// <summary>
/// 轨迹模版id,轨迹映射的查询使用 /// 选中的轨迹模版id
/// </summary> /// </summary>
public int TrackTemplateId { get; set; } public List<int>? SelectIds { get; set; }
} }
} }

View File

@ -1,4 +1,8 @@
using AutoMapper; using AutoMapper;
using SJZY.Track.Application.Contract.Dtos.TrackPush;
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
using Volo.Abp.AutoMapper;
namespace SJZY.Track.Application.AutoMapper; namespace SJZY.Track.Application.AutoMapper;
@ -6,5 +10,9 @@ public class TrackPushAutoMapperProfile : Profile
{ {
public TrackPushAutoMapperProfile() public TrackPushAutoMapperProfile()
{ {
CreateMap<EditTrackPushConfigInput, TrackPushConfigEntity>(MemberList.None)
.ForMember(dest => dest.TrackTemplateId, opt => opt.MapFrom(source => string.Join(',', source.TrackTemplateIds)));
CreateMap<EditTrackPushConfigInput, TrackPushPullParamsConfigEntity>(MemberList.None).Ignore(dest => dest.Id)
.ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => true));
} }
} }

View File

@ -1,8 +1,15 @@
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using SJZY.Expand.ABP.Core.Localization;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.Track.Application.Contract.Dtos.TrackPush;
using SJZY.Track.Application.Localization; using SJZY.Track.Application.Localization;
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
using SJZY.Track.Domain.Aggregates.TrackPushAggregate; using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
using SJZY.Track.Domain.Dtos.Common; using SJZY.Track.Domain.Dtos.Common;
using SJZY.Track.Domain.Dtos.TrackPush; using SJZY.Track.Domain.Dtos.TrackPush;
using SqlSugar;
using System.Linq.Expressions;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace SJZY.Track.Application.Services.TrackPush; namespace SJZY.Track.Application.Services.TrackPush;
@ -16,13 +23,19 @@ public class TrackPushService : ApplicationService, ITransientDependency
{ {
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer; private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
private readonly ITrackPushConfigRepository _trackPushConfigRepository; private readonly ITrackPushConfigRepository _trackPushConfigRepository;
private readonly ITrackTemplateRepository _trackTemplateRepository;
private readonly ITrackPullConfigRepository _trackPullConfigRepository;
public TrackPushService( public TrackPushService(
IStringLocalizer<TrackLocalizationResource> stringLocalizer, IStringLocalizer<TrackLocalizationResource> stringLocalizer,
ITrackPushConfigRepository trackPushConfigRepository) ITrackPushConfigRepository trackPushConfigRepository,
ITrackTemplateRepository trackTemplateRepository,
ITrackPullConfigRepository trackPullConfigRepository)
{ {
_stringLocalizer = stringLocalizer; _stringLocalizer = stringLocalizer;
_trackPushConfigRepository = trackPushConfigRepository; _trackPushConfigRepository = trackPushConfigRepository;
_trackTemplateRepository = trackTemplateRepository;
_trackPullConfigRepository = trackPullConfigRepository;
} }
/// <summary> /// <summary>
@ -53,9 +66,18 @@ public class TrackPushService : ApplicationService, ITransientDependency
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet("GetDetail")] [HttpGet("GetDetail")]
public async Task<GetTrackPushConfigDetailOutputVO> GetDetailAsync(int id) public async Task<GetTrackPushConfigDetailOutputVO?> GetDetailAsync(int id)
{ {
return await _trackPushConfigRepository.GetDetailAsync(id); var res = await _trackPushConfigRepository.GetDetailAsync(id);
if (res is null) return null;
List<int> trackTemplateIds = res.TrackTemplateId.Split(',').Select(int.Parse).ToList();
var trackTemplateEntities = await _trackTemplateRepository.GetListAsync(x => trackTemplateIds.Contains(x.Id));
trackTemplateEntities.ForEach(item => { (res.TrackTemplate ??= new()).Add(new() { Value = item.Id, Key = item.Name }); });
return res;
} }
/// <summary> /// <summary>
@ -68,4 +90,86 @@ public class TrackPushService : ApplicationService, ITransientDependency
{ {
return await _trackPushConfigRepository.GetContentDetailAsync(id); return await _trackPushConfigRepository.GetContentDetailAsync(id);
} }
/// <summary>
/// 轨迹推送配置编辑
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("Edit")]
public async Task<bool> EditAsync([FromBody] EditTrackPushConfigInput input)
{
if (input.Options != OptionTypeNoNull.删除)
{
Expression<Func<TrackPushConfigEntity, bool>> isAnyExp = x =>
x.SubSystemId == input.SubSystemId && x.CustomId == input.CustomId && x.ServiceProviderId == input.ServiceProviderId;
if (input.Options == OptionTypeNoNull.修改) isAnyExp.And(x => x.Id != input.Id);
var trackTemplateIdExp = Expressionable.Create<TrackPushConfigEntity>();
foreach (var trackTemplateId in input.TrackTemplateIds) { trackTemplateIdExp.Or(x => SqlFunc.SplitIn(x.TrackTemplateId, trackTemplateId.ToString())); }
if (await _trackPushConfigRepository.IsAnyAsync(isAnyExp.And(trackTemplateIdExp.ToExpression())))
throw new BusinessException(message: _stringLocalizer["IsTrackPushConfigAny"]);
}
switch (input.Options)
{
case OptionTypeNoNull.新增:
{
var trackPushEntity = ObjectMapper.Map<EditTrackPushConfigInput, TrackPushConfigEntity>(input);
var trackPushParamsEntity = ObjectMapper.Map<EditTrackPushConfigInput, TrackPushPullParamsConfigEntity>(input);
using (var ts = TransactionScopeHelper.Create())
{
int id = await _trackPushConfigRepository.InsertReturnIdentityAsync(trackPushEntity);
trackPushParamsEntity.PullOrPushConfigId = id;
await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
ts.Complete();
}
}
break;
case OptionTypeNoNull.修改:
{
var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
var oldTrackPushParamsEntity =
await _trackPullConfigRepository.GetParamsSingleAsync(x =>
x.PullOrPushConfigId == input.Id && x.IsPush);
ObjectMapper.Map(input, oldTrackPushEntity);
ObjectMapper.Map(input, oldTrackPushParamsEntity);
using (var ts = TransactionScopeHelper.Create())
{
await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity);
await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
ts.Complete();
}
}
break;
case OptionTypeNoNull.删除:
using (var ts = TransactionScopeHelper.Create())
{
await _trackPushConfigRepository.SoftDeleteAsync(x => x.Id == input.Id);
await _trackPullConfigRepository.SoftDeleteParamsAsync(x =>
x.PullOrPushConfigId == input.Id && x.IsPush);
await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id);
ts.Complete();
}
break;
default:
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
nameof(EditTrackPushConfigInput.Options)]);
}
return true;
}
} }

View File

@ -12,4 +12,6 @@ public interface ITrackPushConfigRepository : IBasicRepository<TrackPushConfigEn
Task<GetTrackPushConfigDetailOutputVO> GetDetailAsync(int id); Task<GetTrackPushConfigDetailOutputVO> GetDetailAsync(int id);
Task<GetTrackPushContentDetailOutputVO> GetContentDetailAsync(int id); Task<GetTrackPushContentDetailOutputVO> GetContentDetailAsync(int id);
Task<bool> SoftDeleteContentAsync(Expression<Func<TrackPushContentConfigEntity, bool>> whereExpression);
} }

View File

@ -16,7 +16,7 @@ namespace SJZY.Track.Domain.Dtos.TrackContents
/// <summary> /// <summary>
/// 关键字 /// 关键字
/// </summary> /// </summary>
public string Keywords { get; set; } public string? Keywords { get; set; }
} }
public class GetTrackContentListVO public class GetTrackContentListVO

View File

@ -13,6 +13,11 @@ namespace SJZY.Track.Domain.Dtos.TrackFlags
/// </summary> /// </summary>
public int SubSystemId { get; set; } public int SubSystemId { get; set; }
/// <summary>
/// 选中的轨迹标记id
/// </summary>
public List<int>? SelectIds { get; set; }
///// <summary> ///// <summary>
///// 关键字 ///// 关键字
///// </summary> ///// </summary>

View File

@ -89,7 +89,7 @@ public class GetTrackPushConfigDetailOutputVO
/// <summary> /// <summary>
/// 轨迹模板id /// 轨迹模板id
/// </summary> /// </summary>
public int TrackTemplateId { get; set; } public string TrackTemplateId { get; set; }
/// <summary> /// <summary>
/// 推送轨迹发生时间 /// 推送轨迹发生时间

View File

@ -10,5 +10,10 @@ public class GetPageTrackStatusVO : PageInfoInput
/// <summary> /// <summary>
/// 关键字 /// 关键字
/// </summary> /// </summary>
public string Keywords { get; set; } public string? Keywords { get; set; }
/// <summary>
/// 选中的轨迹状态id
/// </summary>
public List<int>? SelectIds { get; set; }
} }

View File

@ -10,15 +10,9 @@ public class GetPageTrackTemplateVO : PageInfoInput
/// <summary> /// <summary>
/// 关键字 /// 关键字
/// </summary> /// </summary>
public string Keywords { get; set; } public string? Keywords { get; set; }
///// <summary> /// 选中的轨迹模版id
///// 是否置顶
///// </summary>
//public bool IsTop { get; set; }=false;
/// <summary>
/// 轨迹模版id
/// </summary> /// </summary>
public int TrackTemplateId { get; set; } public List<int>? SelectIds { get; set; }
} }

View File

@ -62,6 +62,7 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
(a, b, c, d, e, f) => a.Code.Contains(input.Keywords) || a.Content.Contains(input.Keywords) (a, b, c, d, e, f) => a.Code.Contains(input.Keywords) || a.Content.Contains(input.Keywords)
|| a.EnContent.Contains(input.Keywords) || a.EnContent.Contains(input.Keywords)
) )
.OrderByDescending((a, b, c, d, e, f) => a.CreateTime)
.Select((a, b, c, d, e, f) => new GetTrackContentListVO .Select((a, b, c, d, e, f) => new GetTrackContentListVO
{ {
Id = a.Id, Id = a.Id,

View File

@ -46,6 +46,8 @@ public class TrackFlagRepository : BasicRepository<TrackFlagEntity>, ITrackFlagR
.LeftJoin<VUserEntity>((a, b, c) => a.CreateUserId == c.Id) .LeftJoin<VUserEntity>((a, b, c) => a.CreateUserId == c.Id)
.LeftJoin<VUserEntity>((a, b, c, d) => a.UpdateUserId == d.Id) .LeftJoin<VUserEntity>((a, b, c, d) => a.UpdateUserId == d.Id)
.WhereIF(input.SubSystemId > 0, (a, b, c, d) => a.SubSystemId == input.SubSystemId) .WhereIF(input.SubSystemId > 0, (a, b, c, d) => a.SubSystemId == input.SubSystemId)
.OrderByIF(input.SelectIds.IsNullOrEmpty(), (a, b, c, d) => a.CreateTime, OrderByType.Desc)
.OrderByIF(!input.SelectIds.IsNullOrEmpty(), (a, b, c, d) => SqlFunc.IIF(input.SelectIds.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), a.CreateTime), OrderByType.Desc)
.Select((a, b, c, d) => new GetTrackFlagListVO .Select((a, b, c, d) => new GetTrackFlagListVO
{ {
Id = a.Id, Id = a.Id,
@ -56,8 +58,7 @@ public class TrackFlagRepository : BasicRepository<TrackFlagEntity>, ITrackFlagR
CreateTime = a.CreateTime, CreateTime = a.CreateTime,
CreateUser = c.Name, CreateUser = c.Name,
UpdateTime = a.UpdateTime, UpdateTime = a.UpdateTime,
UpdateUser = d.Name, UpdateUser = d.Name
}) })
.ToPagedListAsync(input.PageIndex, input.PageSize); .ToPagedListAsync(input.PageIndex, input.PageSize);

View File

@ -6,6 +6,7 @@ using SJZY.Track.Domain.Dtos.Common;
using SJZY.Track.Domain.Dtos.TrackPush; using SJZY.Track.Domain.Dtos.TrackPush;
using SJZY.Track.Domain.VEntities; using SJZY.Track.Domain.VEntities;
using SJZY.Track.Repository.VData.Entitys; using SJZY.Track.Repository.VData.Entitys;
using System.Linq.Expressions;
namespace SJZY.Track.Repository.Repositories; namespace SJZY.Track.Repository.Repositories;
@ -82,4 +83,12 @@ public class TrackPushConfigRepository : BasicRepository<TrackPushConfigEntity>,
}, true) }, true)
.SingleAsync(); .SingleAsync();
} }
public async Task<bool> SoftDeleteContentAsync(Expression<Func<TrackPushContentConfigEntity, bool>> whereExpression)
{
return await Context.Updateable<TrackPushContentConfigEntity>()
.Where(whereExpression)
.SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true)
.ExecuteCommandHasChangeAsync();
}
} }

View File

@ -45,6 +45,8 @@ public class TrackStatusRepository : BasicRepository<TrackStatusEntity>, ITrackS
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(), .WhereIF(!input.Keywords.IsNullOrWhiteSpace(),
(a, b, c, d) => a.Status.Contains(input.Keywords) || a.EnStatus.Contains(input.Keywords) || (a, b, c, d) => a.Status.Contains(input.Keywords) || a.EnStatus.Contains(input.Keywords) ||
a.Code.Contains(input.Keywords)) a.Code.Contains(input.Keywords))
.OrderByIF(input.SelectIds.IsNullOrEmpty(), (a, b, c, d) => a.CreateTime, OrderByType.Desc)
.OrderByIF(!input.SelectIds.IsNullOrEmpty(), (a, b, c, d) => SqlFunc.IIF(input.SelectIds.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), a.CreateTime), OrderByType.Desc)
.Select((a, b, c, d) => new GetTrackStatusListVO .Select((a, b, c, d) => new GetTrackStatusListVO
{ {
Id = a.Id, Id = a.Id,

View File

@ -24,13 +24,13 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
.Where((a, b) => a.Id == id) .Where((a, b) => a.Id == id)
.Select((a, b) => new .Select((a, b) => new
GetTrackTemplateDetailVO GetTrackTemplateDetailVO
{ {
Id = a.Id, Id = a.Id,
Code = a.Code, Code = a.Code,
Name = a.Name, Name = a.Name,
SubSystemId = a.SubSystemId, SubSystemId = a.SubSystemId,
SubSystem = b.CnName SubSystem = b.CnName
}).FirstAsync(); }).FirstAsync();
return detail; return detail;
} }
@ -47,9 +47,8 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
.WhereIF(input.SubSystemId > 0, (a, b) => a.SubSystemId == input.SubSystemId) .WhereIF(input.SubSystemId > 0, (a, b) => a.SubSystemId == input.SubSystemId)
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(), .WhereIF(!input.Keywords.IsNullOrWhiteSpace(),
(a, b) => a.Name.Contains(input.Keywords) || a.Code.Contains(input.Keywords)) (a, b) => a.Name.Contains(input.Keywords) || a.Code.Contains(input.Keywords))
.OrderByIF(input.TrackTemplateId > 0, .OrderByIF(input.SelectIds.IsNullOrEmpty(), (a, b) => a.CreateTime,OrderByType.Desc)
(a, b) => SqlFunc.IIF(a.Id == input.TrackTemplateId, SqlFunc.DateAdd(SqlFunc.GetDate(), 1), .OrderByIF(!input.SelectIds.IsNullOrEmpty(), (a, b) => SqlFunc.IIF(input.SelectIds.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), a.CreateTime), OrderByType.Desc)
a.CreateTime), OrderByType.Desc)
.Select((a, b) => new GetTrackTemplateListVO .Select((a, b) => new GetTrackTemplateListVO
{ {
Id = a.Id, Id = a.Id,
@ -59,7 +58,9 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
SubSystem = b.CnName SubSystem = b.CnName
}) })
.ToPagedListAsync(input.PageIndex, input.PageSize); .ToPagedListAsync(input.PageIndex, input.PageSize);
//.OrderByIF(input.TrackTemplateId > 0,
// (a, b) => SqlFunc.IIF(a.Id == input.TrackTemplateId, SqlFunc.DateAdd(SqlFunc.GetDate(), 1),
//a.CreateTime), OrderByType.Desc)
return pagedList; return pagedList;
} }