This commit is contained in:
moyongzhen 2024-03-02 09:10:04 +08:00
commit e4da002a82
20 changed files with 483 additions and 47 deletions

View File

@ -0,0 +1,41 @@
namespace SJZY.Track.Application.Contract.Dtos.TrackContents;
public class EditTrackContentMapInput
{
public int? Id { get; set; }
/// <summary>
/// 映射子系统id
/// </summary>
public int MapSubSystemId { get; set; }
/// <summary>
/// 映射轨迹内容代码
/// </summary>
public string MapTrackContentCode { get; set; }
/// <summary>
/// 映射轨迹内容id
/// </summary>
public int MapTrackContentId { get; set; }
/// <summary>
/// 操作类型
/// </summary>
public OptionTypeNoNull Options { get; set; }
/// <summary>
/// 源子系统id
/// </summary>
public int SubSystemId { get; set; }
/// <summary>
/// 源轨迹内容代码
/// </summary>
public string TrackContentCode { get; set; }
/// <summary>
/// 源轨迹内容id
/// </summary>
public int TrackContentId { get; set; }
}

View File

@ -37,27 +37,27 @@ public class EditTrackPullConfigInput
/// <summary>
/// 拉取轨迹时区
/// </summary>
public string TackTimeZoneName { get; set; }
public string? TackTimeZoneName { get; set; }
/// <summary>
/// 拉取轨迹内容代码
/// </summary>
public string TrackContentCodeName { get; set; }
public string? TrackContentCodeName { get; set; }
/// <summary>
/// 拉取轨迹内容
/// </summary>
public string TrackContentName { get; set; }
public string? TrackContentName { get; set; }
/// <summary>
/// 拉取轨迹发生地
/// </summary>
public string TrackPlaceName { get; set; }
public string? TrackPlaceName { get; set; }
/// <summary>
/// 拉取轨迹状态
/// </summary>
public string TrackStatusName { get; set; }
public string? TrackStatusName { get; set; }
/// <summary>
/// 轨迹模板id
@ -67,5 +67,5 @@ public class EditTrackPullConfigInput
/// <summary>
/// 拉取轨迹发生时间
/// </summary>
public string TrackTimeName { get; set; }
public string? TrackTimeName { get; set; }
}

View File

@ -0,0 +1,5 @@
namespace SJZY.Track.Application.Contract.Dtos.TrackPush;
public class SortTrackPushContentInput
{
}

View File

@ -15,6 +15,7 @@ namespace SJZY.Track.Application.AutoMapper
CreateMap<GetTrackContentListVO, GetTrackContentListDto>(MemberList.None);
CreateMap<UnifyPageResultDto<GetTrackContentListVO>, UnifyPageResultDto<GetTrackContentListDto>>(
MemberList.None);
CreateMap<EditTrackContentMapInput, TrackContentMapEntity>(MemberList.None);
}
}
}

View File

@ -1,8 +1,14 @@
using Microsoft.Extensions.Localization;
using SJZY.Expand.ABP.Core.Common.Dto;
using SJZY.Expand.ABP.Core.Localization;
using SJZY.Expand.ABP.Core.PublicMethords;
using SJZY.Track.Application.Contract.Dtos.TrackContents;
using SJZY.Track.Application.Contract.Dtos.TrackPull;
using SJZY.Track.Application.Localization;
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
using SJZY.Track.Domain.Dtos.TrackContents;
using System.Linq.Expressions;
using Volo.Abp.DependencyInjection;
namespace SJZY.Track.Application.Services.TrackContents
@ -93,7 +99,7 @@ namespace SJZY.Track.Application.Services.TrackContents
throw new BusinessException(message: _stringLocalizer["TrackContentExist"]);
}
#endregion
#endregion 业务逻辑校验
var entity = ObjectMapper.Map<EditTrackContentInput, TrackContentEntity>(input);
var isTrue = await _trackContentRepository.InsertAsync(entity);
@ -104,6 +110,7 @@ namespace SJZY.Track.Application.Services.TrackContents
private async Task<UnifyResultDto> UpdateAsync(EditTrackContentInput input)
{
#region 业务逻辑校验
var trackContentEntity = await _trackContentRepository.GetFirstAsync(a => a.Id != input.Id &&
a.SubSystemId == input.SubSystemId && (a.Code == input.Code ||
a.Content == input.Content || a.EnContent == input.EnContent));
@ -111,11 +118,38 @@ namespace SJZY.Track.Application.Services.TrackContents
{
throw new BusinessException(message: _stringLocalizer["TrackContentExist"]);
}
#endregion
#endregion 业务逻辑校验
//更新的时候需要覆盖内容映射轨迹代码
var templateEntity = await _trackContentRepository.GetFirstAsync(a => a.Id == input.Id);
ObjectMapper.Map(input, templateEntity);
var isTrue = await _trackContentRepository.UpdateAsync(templateEntity);
bool isTrue = false;
using (var ts = TransactionScopeHelper.Create())
{
// 如果轨迹内容的子系统和code发生变化,同步到轨迹映射表
if (templateEntity.SubSystemId != input.SubSystemId || templateEntity.Code != input.Code)
{
await _trackContentRepository.UpdateMapAsync(x => new TrackContentMapEntity
{
SubSystemId = input.SubSystemId,
TrackContentCode = input.Code
}, x => x.TrackContentId == input.Id);
await _trackContentRepository.UpdateMapAsync(x => new TrackContentMapEntity
{
MapSubSystemId = input.SubSystemId,
MapTrackContentCode = input.Code
}, x => x.MapTrackContentId == input.Id);
}
ObjectMapper.Map(input, templateEntity);
isTrue = await _trackContentRepository.UpdateAsync(templateEntity);
ts.Complete();
}
return new UnifyResultDto("200", "修改成功", isTrue);
}
@ -123,13 +157,88 @@ namespace SJZY.Track.Application.Services.TrackContents
private async Task<UnifyResultDto> DeleteAsync(EditTrackContentInput input)
{
#region 业务校验
//需要加个判断,存在内容映射,则出提示
#endregion
#endregion 业务校验
var isTrue = await _trackContentRepository.SoftDeleteAsync(x => x.Id == input.Id);
return new UnifyResultDto("200", "删除成功", isTrue);
}
#endregion
#endregion 私有方法
/// <summary>
/// 轨迹内容映射列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("GetMapPage")]
public async Task<UnifyPageResultDto<GetTrackContentMapPageOutputVO>> GetMapPageAsync([FromBody] GetTrackContentMapPageInputVO input)
{
return await _trackContentRepository.GetMapPageAsync(input);
}
/// <summary>
/// 轨迹内容映射详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("GetMapDetail")]
public async Task<GetTrackContentMapDetailOutputVO> GetMapDetailAsync(int id)
{
return await _trackContentRepository.GetMapDetailAsync(id);
}
/// <summary>
/// 轨迹内容映射编辑
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("EditMap")]
public async Task<bool> EditMapAsync([FromBody] EditTrackContentMapInput input)
{
if (input.Options != OptionTypeNoNull.删除)
{
Expression<Func<TrackContentMapEntity, bool>> isMapAnyExp = x =>
x.TrackContentId == input.TrackContentId && x.MapTrackContentId == input.MapTrackContentId;
if (input.Options == OptionTypeNoNull.修改) isMapAnyExp.And(x => x.Id != input.Id);
if (await _trackContentRepository.IsMapAnyAsync(isMapAnyExp))
throw new BusinessException(message: _stringLocalizer["IsTrackContentMapAny"]);
}
switch (input.Options)
{
case OptionTypeNoNull.新增:
{
var trackContentMapEntity = ObjectMapper.Map<EditTrackContentMapInput, TrackContentMapEntity>(input);
await _trackContentRepository.InsertMapAsync(trackContentMapEntity);
}
break;
case OptionTypeNoNull.修改:
{
var oldTrackContentMapEntity = await _trackContentRepository.GetMapByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
ObjectMapper.Map(input, oldTrackContentMapEntity);
await _trackContentRepository.UpdateMapAsync(oldTrackContentMapEntity);
}
break;
case OptionTypeNoNull.删除:
await _trackContentRepository.SoftDeleteMapAsync(x => x.Id == input.Id);
break;
default:
throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum,
nameof(EditTrackContentMapInput.Options)]);
}
return true;
}
}
}

View File

@ -1,8 +1,10 @@
using Microsoft.Extensions.Localization;
using SJZY.Expand.ABP.Core;
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.Domain.Aggregates.DemoAggregate;
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
using SJZY.Track.Domain.Aggregates.TrackPushAggregate;
using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate;
@ -66,7 +68,7 @@ public class TrackPushService : ApplicationService, ITransientDependency
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("GetDetail")]
public async Task<GetTrackPushConfigDetailOutputVO?> GetDetailAsync(int id)
public async Task<GetTrackPushConfigDetailOutputVO> GetDetailAsync(int id)
{
var res = await _trackPushConfigRepository.GetDetailAsync(id);
if (res is null) return null;
@ -126,6 +128,8 @@ public class TrackPushService : ApplicationService, ITransientDependency
trackPushParamsEntity.PullOrPushConfigId = id;
await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity);
if (input.IsAutoPush) await RedisHelper.Client.SAddAsync(GlobalConst.AutoPushRosterRedisKey, input.CustomId);
ts.Complete();
}
}
@ -135,6 +139,8 @@ public class TrackPushService : ApplicationService, ITransientDependency
{
var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
int oldCustomId = oldTrackPushEntity.CustomId;
var oldTrackPushParamsEntity =
await _trackPullConfigRepository.GetParamsSingleAsync(x =>
x.PullOrPushConfigId == input.Id && x.IsPush);
@ -147,22 +153,30 @@ public class TrackPushService : ApplicationService, ITransientDependency
await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity);
await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity);
await RedisHelper.Client.SRemAsync(GlobalConst.AutoPushRosterRedisKey, oldCustomId);
if (input.IsAutoPush) await RedisHelper.Client.SAddAsync(GlobalConst.AutoPushRosterRedisKey, input.CustomId);
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);
var oldTrackPushEntity = await _trackPushConfigRepository.GetFirstAsync(x => x.Id == input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]);
ts.Complete();
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);
await RedisHelper.Client.SRemAsync(GlobalConst.AutoPushRosterRedisKey, oldTrackPushEntity.CustomId);
ts.Complete();
}
}
break;
default:
@ -223,4 +237,15 @@ public class TrackPushService : ApplicationService, ITransientDependency
return true;
}
/// <summary>
/// 轨迹推送配置内容排序
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("SortContent")]
public async Task<bool> SortContentAsync([FromBody] SortTrackPushContentInput input)
{
return true;
}
}

View File

@ -30,7 +30,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
{
_stringLocalizer = stringLocalizer;
_trackTemplateRepository = trackTemplateRepository;
_trackPullConfigRepository=trackPullConfigRepository;
_trackPullConfigRepository = trackPullConfigRepository;
}
/// <summary>
@ -100,7 +100,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
throw new BusinessException("轨迹代码重复");
}
#endregion
#endregion 业务校验
var entity = ObjectMapper.Map<EditTrackTemplateInput, TrackTemplateEntity>(input);
var isTrue = await _trackTemplateRepository.InsertAsync(entity);
@ -111,13 +111,15 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
private async Task<UnifyResultDto> UpdateAsync(EditTrackTemplateInput input)
{
#region 业务校验
var isExist = await _trackTemplateRepository.GetFirstAsync(a =>
a.Id != input.Id && a.SubSystemId == input.SubSystemId && a.Code == input.Code);
if (isExist != null)
{
throw new BusinessException(message: _stringLocalizer["TemplateExist"]);
}
#endregion
#endregion 业务校验
var templateEntity = await _trackTemplateRepository.GetFirstAsync(a => a.Id == input.Id);
ObjectMapper.Map(input, templateEntity);
@ -129,13 +131,15 @@ public class TrackTemplateService : ApplicationService, ITransientDependency
private async Task<UnifyResultDto> DeleteAsync(EditTrackTemplateInput input)
{
#region 业务校验
//查询看看在轨迹拉取里面有没有被占用
var isExisistTrackPullConfig = await _trackPullConfigRepository.GetFirstAsync(a => a.TrackTemplateId==input.Id);
if (isExisistTrackPullConfig!=null)
var isExisistTrackPullConfig = await _trackPullConfigRepository.GetFirstAsync(a => a.TrackTemplateId == input.Id);
if (isExisistTrackPullConfig != null)
{
throw new BusinessException(message: _stringLocalizer["IsExistTrackPullConfig"]);
}
#endregion
#endregion 业务校验
var isTrue = await _trackTemplateRepository.SoftDeleteAsync(x => x.Id == input.Id);

View File

@ -1,10 +1,26 @@
using SJZY.Track.Domain.Dtos.TrackContents;
using SJZY.Track.Domain.Dtos.TrackStatus;
namespace SJZY.Track.Domain.Aggregates.TrackContentAggregate;
public interface ITrackContentRepository : IBasicRepository<TrackContentEntity>
{
Task<GetTrackContentDetailVO?> GetDetailAsync(int id);
Task<UnifyPageResultDto<GetTrackContentListVO>> GetPageTrackContent(GetPageTrackContentVO input);
Task<UnifyPageResultDto<GetTrackContentMapPageOutputVO>> GetMapPageAsync(GetTrackContentMapPageInputVO input);
Task<GetTrackContentMapDetailOutputVO> GetMapDetailAsync(int id);
Task<bool> IsMapAnyAsync(Expression<Func<TrackContentMapEntity, bool>> whereExpression);
Task<bool> InsertMapAsync(TrackContentMapEntity insertObj);
Task<TrackContentMapEntity> GetMapByIdAsync(int id);
Task<bool> UpdateMapAsync(TrackContentMapEntity updateObj);
Task<bool> SoftDeleteMapAsync(Expression<Func<TrackContentMapEntity, bool>> whereExpression);
Task<bool> UpdateMapAsync(Expression<Func<TrackContentMapEntity, TrackContentMapEntity>> columns, Expression<Func<TrackContentMapEntity, bool>> whereExpression);
}

View File

@ -15,5 +15,5 @@ public class KeywordsInputVO : PageInfoInput
/// <summary>
/// 选中项
/// </summary>
public int? SelectedId { get; set; }
public List<int>? SelectedId { get; set; }
}

View File

@ -0,0 +1,56 @@
namespace SJZY.Track.Domain.Dtos.TrackContents;
public class GetTrackContentMapDetailOutputVO
{
public int Id { get; set; }
/// <summary>
/// 映射子系统
/// </summary>
public string MapSubSystem { get; set; }
/// <summary>
/// 映射子系统id
/// </summary>
public int MapSubSystemId { get; set; }
/// <summary>
/// 映射轨迹内容
/// </summary>
public string MapTrackContent { get; set; }
/// <summary>
/// 映射轨迹内容id
/// </summary>
public int MapTrackContentId { get; set; }
/// <summary>
/// 子系统
/// </summary>
public string SubSystem { get; set; }
/// <summary>
/// 子系统id
/// </summary>
public int SubSystemId { get; set; }
/// <summary>
/// 源轨迹内容
/// </summary>
public string TrackContent { get; set; }
/// <summary>
/// 源轨迹内容id
/// </summary>
public int TrackContentId { get; set; }
/// <summary>
/// 源轨迹内容代码
/// </summary>
public string TrackContentCode { get; set; }
/// <summary>
/// 映射轨迹内容代码
/// </summary>
public string MapTrackContentCode { get; set; }
}

View File

@ -0,0 +1,11 @@
using SJZY.Track.Domain.Dtos.Common;
namespace SJZY.Track.Domain.Dtos.TrackContents;
public class GetTrackContentMapPageInputVO : KeywordsInputVO
{
/// <summary>
/// 映射子系统id
/// </summary>
public int? MapSubSystemId { get; set; }
}

View File

@ -0,0 +1,56 @@
namespace SJZY.Track.Domain.Dtos.TrackContents;
public class GetTrackContentMapPageOutputVO
{
/// <summary>
/// 轨迹内容代码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 轨迹内容
/// </summary>
public string Content { get; set; }
/// <summary>
/// 轨迹内容英文
/// </summary>
public string EnContent { get; set; }
public int Id { get; set; }
/// <summary>
/// 映射轨迹内容代码
/// </summary>
public string MapCode { get; set; }
/// <summary>
/// 映射内容
/// </summary>
public string MapContent { get; set; }
/// <summary>
/// 映射内容英文
/// </summary>
public string MapEnContent { get; set; }
/// <summary>
/// 映射子系统
/// </summary>
public string MapSubSystem { get; set; }
/// <summary>
/// 映射轨迹状态
/// </summary>
public string MapTrackStatus { get; set; }
/// <summary>
/// 子系统
/// </summary>
public string SubSystem { get; set; }
/// <summary>
/// 轨迹状态
/// </summary>
public string TrackStatus { get; set; }
}

View File

@ -91,6 +91,11 @@ public class GetTrackPushConfigDetailOutputVO
/// </summary>
public string TrackTemplateId { get; set; }
/// <summary>
/// 轨迹模板ids
/// </summary>
public List<int> TrackTemplateIds { get; set; }
/// <summary>
/// 推送轨迹发生时间
/// </summary>

View File

@ -23,4 +23,14 @@ public class GetTrackPushConfigPageOutputVO
/// 模板名称
/// </summary>
public string TrackTemplate { get; set; }
/// <summary>
/// 轨迹模板id
/// </summary>
public string TrackTemplateId { get; set; }
/// <summary>
/// 轨迹模板ids
/// </summary>
public List<int> TrackTemplateIds { get; set; }
}

View File

@ -5,5 +5,5 @@ public class GetTrackTemplateContentPageInputVO : PageInfoInput
/// <summary>
/// 轨迹模板id
/// </summary>
public int TrackTemplateId { get; set; }
public List<int> TrackTemplateIds { get; set; }
}

View File

@ -68,4 +68,9 @@ public class GetTrackTemplateContentPageOutputVO
/// 修改人
/// </summary>
public string UpdateUser { get; set; }
/// <summary>
/// 轨迹内容id
/// </summary>
public int TrackContentId { get; set; }
}

View File

@ -6,9 +6,14 @@ public class GlobalConst
/// 轨迹明细es索引名称
/// </summary>
public const string TrackIndex = "sjzy_track_details";
/// <summary>
/// 轨迹新增/更新cap订阅名称
/// </summary>
public const string TrackUpsertSubscribe = "SJZY.Track.Upsert";
/// <summary>
/// 自动推送名单RedisKey
/// </summary>
public const string AutoPushRosterRedisKey = "AutoPushRoster";
}

View File

@ -3,15 +3,15 @@ using SJZY.Track.Domain.Aggregates.TrackFlagAggregate;
using SJZY.Track.Domain.Aggregates.TrackStatusAggregate;
using SJZY.Track.Domain.Dtos.TrackContents;
using SJZY.Track.Domain.VEntities;
using System.Linq;
using System.Linq.Expressions;
namespace SJZY.Track.Repository.Repositories;
public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrackContentRepository, IScopedDependency
{
public TrackContentRepository()
{
}
/// <summary>
@ -24,20 +24,20 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
var detail = await Context.Queryable<TrackContentEntity>()
.LeftJoin<TrackStatusEntity>((a, b) => a.TrackStatusId == b.Id && b.IsDeleted == false)
.LeftJoin<TrackFlagEntity>((a, b, c) => a.TrackFlagId == c.Id && c.IsDeleted == false)
.LeftJoin<VSystemEntity>((a, b, c, d) => a.SubSystemId == d.Id&&d.IsDeleted==false)
.LeftJoin<VSystemEntity>((a, b, c, d) => a.SubSystemId == d.Id && d.IsDeleted == false)
.Where((a, b, c, d) => a.Id == id)
.Select((a, b, c, d) => new GetTrackContentDetailVO
{
Id = a.Id,
SubSystemId = a.SubSystemId,
SubSystem = d.CnName,
TrackStatusId=a.TrackStatusId,
TrackStatus= b.Status,
TrackStatusId = a.TrackStatusId,
TrackStatus = b.Status,
Code = a.Code,
Content = a.Content,
EnContent = a.EnContent,
TrackFlagId=a.TrackFlagId,
TrackFlag=c.Name
TrackFlagId = a.TrackFlagId,
TrackFlag = c.Name
})
.FirstAsync();
return detail;
@ -52,8 +52,8 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
{
UnifyPageResultDto<GetTrackContentListVO> pagedList = new UnifyPageResultDto<GetTrackContentListVO>();
pagedList = await Context.Queryable<TrackContentEntity>()
.LeftJoin<TrackStatusEntity>((a, b) => a.TrackStatusId==b.Id&&b.IsDeleted==false)
.LeftJoin<TrackFlagEntity>((a, b, c) => a.TrackFlagId==c.Id&&c.IsDeleted==false)
.LeftJoin<TrackStatusEntity>((a, b) => a.TrackStatusId == b.Id && b.IsDeleted == false)
.LeftJoin<TrackFlagEntity>((a, b, c) => a.TrackFlagId == c.Id && c.IsDeleted == false)
.LeftJoin<VSystemEntity>((a, b, c, d) => a.SubSystemId == d.Id && d.IsDeleted == false)
.LeftJoin<VUserEntity>((a, b, c, d, e) => a.CreateUserId == e.Id && e.IsDeleted == false)
.LeftJoin<VUserEntity>((a, b, c, d, e, f) => a.UpdateUserId == f.Id && f.IsDeleted == false)
@ -71,11 +71,11 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
Code = a.Code,
Content = a.Content,
EnContent = a.EnContent,
TrackStatus= b.Status,
TrackStatus = b.Status,
Node = SqlFunc.IF(b.Node == 1).Return("揽收").ElseIF(b.Node == 2).Return("干线").ElseIF(b.Node == 3).Return("清关")
.ElseIF(b.Node == 4).Return("中转").ElseIF(b.Node == 5).Return("派送")
.End(""),
TrackFlag= c.Name,
TrackFlag = c.Name,
CreateTime = a.CreateTime,
CreateUser = e.Name,
UpdateTime = a.UpdateTime,
@ -83,10 +83,95 @@ public class TrackContentRepository : BasicRepository<TrackContentEntity>, ITrac
})
.ToPagedListAsync(input.PageIndex, input.PageSize);
var ff = await Context.Queryable<TrackContentEntity>().Where(a => 1==1).ToListAsync();
var ff = await Context.Queryable<TrackContentEntity>().Where(a => 1 == 1).ToListAsync();
return pagedList;
}
public async Task<UnifyPageResultDto<GetTrackContentMapPageOutputVO>> GetMapPageAsync(GetTrackContentMapPageInputVO input)
{
return await Context.Queryable<TrackContentMapEntity>()
.InnerJoin<TrackContentEntity>((contentMap, sourceContent) => contentMap.TrackContentId == sourceContent.Id && !sourceContent.IsDeleted)
.InnerJoin<TrackContentEntity>((contentMap, sourceContent, targetContent) => contentMap.MapTrackContentId == targetContent.Id && !targetContent.IsDeleted)
.LeftJoin<VSystemEntity>((contentMap, sourceContent, targetContent, sourceSystem) => contentMap.SubSystemId == sourceSystem.Id && !sourceSystem.IsDeleted)
.LeftJoin<VSystemEntity>((contentMap, sourceContent, targetContent, sourceSystem, targetSystem) => contentMap.MapSubSystemId == targetSystem.Id && !targetSystem.IsDeleted)
.LeftJoin<TrackStatusEntity>((contentMap, sourceContent, targetContent, sourceSystem, targetSystem, sourceStatus) => sourceContent.TrackStatusId == sourceStatus.Id && !sourceStatus.IsDeleted)
.LeftJoin<TrackStatusEntity>((contentMap, sourceContent, targetContent, sourceSystem, targetSystem, sourceStatus, targetStatus) => targetContent.TrackStatusId == targetStatus.Id && !targetStatus.IsDeleted)
.Filter(null, true)
.Where(contentMap => !contentMap.IsDeleted)
.WhereIF(input.SubSystemId.HasValue, contentMap => contentMap.SubSystemId == input.SubSystemId)
.WhereIF(input.MapSubSystemId.HasValue, contentMap => contentMap.MapSubSystemId == input.MapSubSystemId)
.WhereIF(!input.Keywords.IsNullOrWhiteSpace(), (contentMap, sourceContent) => sourceContent.Code.Contains(input.Keywords) || sourceContent.Content.Contains(input.Keywords) || sourceContent.EnContent.Contains(input.Keywords))
.OrderByDescending(contentMap => contentMap.CreateTime)
.Select((contentMap, sourceContent, targetContent, sourceSystem, targetSystem, sourceStatus, targetStatus) => new GetTrackContentMapPageOutputVO
{
Id = contentMap.Id,
SubSystem = sourceSystem.CnName,
Code = contentMap.TrackContentCode,
TrackStatus = sourceStatus.Status,
Content = sourceContent.Content,
EnContent = sourceContent.EnContent,
MapSubSystem = targetSystem.CnName,
MapCode = contentMap.MapTrackContentCode,
MapTrackStatus = targetStatus.Status,
MapContent = targetContent.Content,
MapEnContent = targetContent.EnContent
})
.ToPagedListAsync(input.PageIndex, input.PageSize);
}
public async Task<GetTrackContentMapDetailOutputVO> GetMapDetailAsync(int id)
{
return await Context.Queryable<TrackContentMapEntity>()
.InnerJoin<TrackContentEntity>((contentMap, sourceContent) => contentMap.TrackContentId == sourceContent.Id && !sourceContent.IsDeleted)
.InnerJoin<TrackContentEntity>((contentMap, sourceContent, targetContent) => contentMap.MapTrackContentId == targetContent.Id && !targetContent.IsDeleted)
.LeftJoin<VSystemEntity>((contentMap, sourceContent, targetContent, sourceSystem) => contentMap.SubSystemId == sourceSystem.Id && !sourceSystem.IsDeleted)
.LeftJoin<VSystemEntity>((contentMap, sourceContent, targetContent, sourceSystem, targetSystem) => contentMap.MapSubSystemId == targetSystem.Id && !targetSystem.IsDeleted)
.Filter(null, true)
.Where(contentMap => !contentMap.IsDeleted)
.Select((contentMap, sourceContent, targetContent, sourceSystem, targetSystem) => new GetTrackContentMapDetailOutputVO
{
Id = contentMap.Id,
SubSystemId = contentMap.SubSystemId,
SubSystem = sourceSystem.CnName,
TrackContent = contentMap.TrackContentCode + "-" + sourceContent.Content,
MapSubSystem = targetSystem.CnName,
MapTrackContent = contentMap.MapTrackContentCode + "-" + targetContent.Content
}, true)
.SingleAsync();
}
public async Task<bool> IsMapAnyAsync(Expression<Func<TrackContentMapEntity, bool>> whereExpression)
{
return await Context.Queryable<TrackContentMapEntity>().Where(whereExpression).AnyAsync();
}
public async Task<bool> InsertMapAsync(TrackContentMapEntity insertObj)
{
return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0;
}
public async Task<TrackContentMapEntity> GetMapByIdAsync(int id)
{
return await Context.Queryable<TrackContentMapEntity>().InSingleAsync(id);
}
public async Task<bool> UpdateMapAsync(TrackContentMapEntity updateObj)
{
return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync();
}
public async Task<bool> SoftDeleteMapAsync(Expression<Func<TrackContentMapEntity, bool>> whereExpression)
{
return await Context.Updateable<TrackContentMapEntity>()
.Where(whereExpression)
.SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true)
.ExecuteCommandHasChangeAsync();
}
public async Task<bool> UpdateMapAsync(Expression<Func<TrackContentMapEntity, TrackContentMapEntity>> columns, Expression<Func<TrackContentMapEntity, bool>> whereExpression)
{
return await Context.Updateable<TrackContentMapEntity>().SetColumns(columns).Where(whereExpression)
.ExecuteCommandAsync() > 0;
}
}

View File

@ -32,9 +32,11 @@ public class TrackPushConfigRepository : BasicRepository<TrackPushConfigEntity>,
TrackTemplate = SqlFunc.Subqueryable<TrackTemplateEntity>()
.Where(template => SqlFunc.SplitIn(trackPush.TrackTemplateId, template.Id.ToString()) && !template.IsDeleted)
.SelectStringJoin(template => template.Name, ","),
TrackTemplateId = trackPush.TrackTemplateId,
CreateTime = trackPush.CreateTime
})
.Distinct()
.Mapper(x => { x.TrackTemplateIds = x.TrackTemplateId.Split(',').Select(int.Parse).ToList(); })
.ToPagedListAsync(input.PageIndex, input.PageSize);
}
@ -68,6 +70,7 @@ public class TrackPushConfigRepository : BasicRepository<TrackPushConfigEntity>,
CustomName = externalSubject.Abbreviation,
ServiceProvider = service.Name,
}, true)
.Mapper(x => { x.TrackTemplateIds = x.TrackTemplateId.Split(',').Select(int.Parse).ToList(); })
.SingleAsync();
}

View File

@ -20,7 +20,7 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
public async Task<GetTrackTemplateDetailVO?> GetDetailAsync(int id)
{
var detail = await Context.Queryable<TrackTemplateEntity>()
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id&&b.IsDeleted==false)
.LeftJoin<VSystemEntity>((a, b) => a.SubSystemId == b.Id && b.IsDeleted == false)
.Where((a, b) => a.Id == id)
.Select((a, b) => new
GetTrackTemplateDetailVO
@ -84,8 +84,7 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
(templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) =>
templateContent.UpdateUserId == updateUser.Id && !updateUser.IsDeleted)
.Filter(null, true)
.Where(templateContent =>
templateContent.TrackTemplateId == input.TrackTemplateId && !templateContent.IsDeleted)
.Where(templateContent => input.TrackTemplateIds.Contains(templateContent.TrackTemplateId) && !templateContent.IsDeleted)
.OrderByDescending(templateContent => templateContent.CreateTime)
.Select((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) =>
new GetTrackTemplateContentPageOutputVO