diff --git a/src/SJZY.Track.Application/AutoMapper/TrackStatusAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackStatusAutoMapperProfile.cs new file mode 100644 index 00000000..c66d09e7 --- /dev/null +++ b/src/SJZY.Track.Application/AutoMapper/TrackStatusAutoMapperProfile.cs @@ -0,0 +1,31 @@ +using AutoMapper; +using AutoMapper.Internal.Mappers; +using SJZY.Track.Application.Dtos.Demo; +using SJZY.Track.Application.Dtos.TrackStatus; +using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; +using SJZY.Track.Domain.Dtos.TrackStatus; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.ObjectMapping; + +namespace SJZY.Track.Application.AutoMapper +{ + public class TrackStatusAutoMapperProfile : Profile + { + public TrackStatusAutoMapperProfile() + { + CreateMap(MemberList.None) + //层级不一致的场景 + .ForMember(dest => dest.Status, opt => opt.MapFrom(source => source.TrackStatus)) + .ForMember(dest => dest.EnStatus, opt => opt.MapFrom(source => source.EntrackStatus)) + .ForMember(dest => dest.Node, opt => opt.MapFrom(source => source.NodeId)); + CreateMap(MemberList.None); + CreateMap(MemberList.None); + CreateMap(MemberList.None); + CreateMap, UnifyPageResultDto>(MemberList.None); + } + } +} diff --git a/src/SJZY.Track.Application/Localization/Resources/en.json b/src/SJZY.Track.Application/Localization/Resources/en.json index 3fd41b14..7833f864 100644 --- a/src/SJZY.Track.Application/Localization/Resources/en.json +++ b/src/SJZY.Track.Application/Localization/Resources/en.json @@ -5,7 +5,7 @@ "NotFindData": "No data found under the specified number", "ParameterDemo1": "{0} in {1} to do {2}", "TemplateExist": "The template code already exists under the currently selected subsystem", - "TrackContentExist": "The trace code or trace content or trace content in the current subsystem is repeated in English" - + "TrackContentExist": "The trace code or trace content or trace content in the current subsystem is repeated in English", + "TrackStatusExist": "The trajectory status code or trajectory status or trajectory status in English is repeated under the current subsystem" } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Localization/Resources/zh.json b/src/SJZY.Track.Application/Localization/Resources/zh.json index 4692d323..7ef977fe 100644 --- a/src/SJZY.Track.Application/Localization/Resources/zh.json +++ b/src/SJZY.Track.Application/Localization/Resources/zh.json @@ -5,6 +5,7 @@ "ParameterDemo": "{0}在{1}地方做了{2}动作", "ParameterDemo1": "{0}在{1}地方做了{2}动作", "TemplateExist": "模板代码已存在于当前选择的子系统下", - "TrackContentExist": "当前子系统下轨迹代码或轨迹内容或轨迹内容英文重复" + "TrackContentExist": "当前子系统下轨迹代码或轨迹内容或轨迹内容英文重复", + "TrackStatusExist": "当前子系统下轨迹状态代码或轨迹状态或轨迹状态英文重复" } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs b/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs index 9db46c6f..7b076868 100644 --- a/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs +++ b/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs @@ -1,4 +1,6 @@ -using SJZY.Track.Application.Dtos.TrackStatus; +using Microsoft.Extensions.Localization; +using SJZY.Track.Application.Dtos.TrackStatus; +using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Dtos.TrackStatus; using Volo.Abp.DependencyInjection; @@ -12,12 +14,15 @@ namespace SJZY.Track.Application.Services.TrackStatus; [Route("/Track/Status")] public class TrackStatusService : ApplicationService, ITransientDependency { + private readonly IStringLocalizer _stringLocalizer; private readonly ITrackStatusRepository _trackStatusRepository; public TrackStatusService( + IStringLocalizer stringLocalizer, ITrackStatusRepository trackStatusRepository ) { + this._stringLocalizer=stringLocalizer; this._trackStatusRepository = trackStatusRepository; } @@ -73,9 +78,17 @@ public class TrackStatusService : ApplicationService, ITransientDependency } #region 私有方法 - private async Task AddAsync(EditTrackStatusInput input) { + #region 业务校验 + var trackStatusEntity = await _trackStatusRepository.GetFirstAsync(a => a.SubSystemId==input.SubSystemId&& (a.Code==input.Code || + a.Status==input.TrackStatus || a.EnStatus==input.EntrackStatus)); + if (trackStatusEntity!=null) + { + throw new BusinessException(message: _stringLocalizer["TrackStatusExist"]); + } + #endregion + var entity = ObjectMapper.Map(input); var isTrue = await _trackStatusRepository.InsertAsync(entity); @@ -84,6 +97,15 @@ public class TrackStatusService : ApplicationService, ITransientDependency private async Task UpdateAsync(EditTrackStatusInput input) { + #region 业务校验 + var trackStatusEntity = await _trackStatusRepository.GetFirstAsync(a => a.Id !=input.Id && a.SubSystemId==input.SubSystemId&& (a.Code==input.Code || + a.Status==input.TrackStatus || a.EnStatus==input.EntrackStatus)); + if (trackStatusEntity!=null) + { + throw new BusinessException(message: _stringLocalizer["TrackStatusExist"]); + } + #endregion + var templateEntity = await _trackStatusRepository.GetFirstAsync(a => a.Id == input.Id); ObjectMapper.Map(input, templateEntity); var isTrue = await _trackStatusRepository.UpdateAsync(templateEntity); @@ -97,6 +119,5 @@ public class TrackStatusService : ApplicationService, ITransientDependency return new UnifyResultDto("200", "删除成功", isTrue); } - #endregion } \ No newline at end of file diff --git a/src/SJZY.Track.Repository/TrackStatusRepository.cs b/src/SJZY.Track.Repository/TrackStatusRepository.cs index 7f5d88b7..9e88da35 100644 --- a/src/SJZY.Track.Repository/TrackStatusRepository.cs +++ b/src/SJZY.Track.Repository/TrackStatusRepository.cs @@ -11,7 +11,7 @@ public class TrackStatusRepository : BasicRepository, ITrackS } /// - /// 获取轨迹模版明细 + /// 获取轨迹状态明细 /// /// /// @@ -56,7 +56,10 @@ public class TrackStatusRepository : BasicRepository, ITrackS Code = a.Code, EntrackStatus = a.EnStatus, TrackStatus = a.Status, - Node = "", + NodeId = a.Node, + Node = SqlFunc.IF(a.Node == 1).Return("揽收").ElseIF(a.Node == 2).Return("干线").ElseIF(a.Node == 3).Return("清关") + .ElseIF(a.Node == 4).Return("中转").ElseIF(a.Node == 5).Return("派送") + .End(""), CreateTime = a.CreateTime, CreateUser = c.Name, UpdateTime = a.UpdateTime,