From 40e2f684a7bfb670da1c56b24e39c8719cb9ff55 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Mon, 24 Jul 2023 15:38:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E8=A7=A6=E5=8F=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrackingSystem/StatusTriggerBaseInfo.cs | 5 + .../Enum/StatusTriggerOperTypeEnum.cs | 62 ++++ .../Dtos/QueryStatusTriggerBaseDto.cs | 54 ++- .../Dtos/StatusTriggerBaseDto.cs | 5 + .../Interface/IStatusTriggerBaseService.cs | 26 +- .../TrackingSystem/ServiceProjectService.cs | 2 +- .../TrackingSystem/StatusSkuBaseService.cs | 2 +- .../StatusTriggerBaseService.cs | 341 ++++++++++++++++++ 8 files changed, 487 insertions(+), 10 deletions(-) create mode 100644 Myshipping.Application/Enum/StatusTriggerOperTypeEnum.cs create mode 100644 Myshipping.Application/Service/TrackingSystem/StatusTriggerBaseService.cs diff --git a/Myshipping.Application/Entity/TrackingSystem/StatusTriggerBaseInfo.cs b/Myshipping.Application/Entity/TrackingSystem/StatusTriggerBaseInfo.cs index c533d40b..4f6d14a7 100644 --- a/Myshipping.Application/Entity/TrackingSystem/StatusTriggerBaseInfo.cs +++ b/Myshipping.Application/Entity/TrackingSystem/StatusTriggerBaseInfo.cs @@ -35,6 +35,11 @@ namespace Myshipping.Application.Entity /// public string STATUS_TRIGGER_NAME { get; set; } + /// + /// 触发器说明 + /// + public string STATUS_TRIGGER_NOTE { get; set; } + /// /// 是否启用 /// diff --git a/Myshipping.Application/Enum/StatusTriggerOperTypeEnum.cs b/Myshipping.Application/Enum/StatusTriggerOperTypeEnum.cs new file mode 100644 index 00000000..93b3eb36 --- /dev/null +++ b/Myshipping.Application/Enum/StatusTriggerOperTypeEnum.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 状态触发器操作类型枚举 + /// + public enum StatusTriggerOperTypeEnum + { + /// + /// 等于 + /// + [Description("等于")] + EQUALS, + /// + /// 不等于 + /// + [Description("不等于")] + DOES_NOT_EQUAL, + /// + /// 大于 + /// + [Description("大于")] + GREATER_THAN, + /// + /// 大于等于 + /// + [Description("大于等于")] + GREATER_THEN_EQUAL, + /// + /// 小于 + /// + [Description("小于")] + LESS_THAN, + /// + /// 小于等于 + /// + [Description("小于等于")] + LESS_THAN_EQUAL, + /// + /// 或者 + /// + [Description("或者")] + LOGICAL_OR, + /// + /// 并且 + /// + [Description("并且")] + LOGICAL_AND, + /// + /// 第(N)天后 + /// + [Description("第(N)天后")] + DATE_NEXT_DAY + + } +} diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/QueryStatusTriggerBaseDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/QueryStatusTriggerBaseDto.cs index 43aa04e1..26f26938 100644 --- a/Myshipping.Application/Service/TrackingSystem/Dtos/QueryStatusTriggerBaseDto.cs +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/QueryStatusTriggerBaseDto.cs @@ -6,7 +6,59 @@ using System.Threading.Tasks; namespace Myshipping.Application { - internal class QueryStatusTriggerBaseDto + /// + /// 触发器查询条件 + /// + public class QueryStatusTriggerBaseDto : QueryTaskManageBaseDto { + /// + /// 创建日期起始 + /// + /// + public string CreateBegin { get; set; } + + /// + /// 创建日期结束 + /// + /// + public string CreateEnd { get; set; } + + /// + /// 更新日期起始 + /// + /// + public string UpdateBegin { get; set; } + + /// + /// 更新日期结束 + /// + /// + public string UpdateEnd { get; set; } + + /// + /// 创建人 + /// + public string CreateUser { get; set; } + + /// + /// 更新人 + /// + public string UpdateUser { get; set; } + + /// + /// 是否启用 1-已启用 2-未启用 + /// + /// + public string IsEnable { get; set; } + + /// + /// 触发器名称 + /// + public string StatusTriggerName { get; set; } + + /// + /// 触发器说明 + /// + public string StatusTriggerNote { get; set; } } } diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/StatusTriggerBaseDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/StatusTriggerBaseDto.cs index 68c5d14c..91eef99a 100644 --- a/Myshipping.Application/Service/TrackingSystem/Dtos/StatusTriggerBaseDto.cs +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/StatusTriggerBaseDto.cs @@ -26,6 +26,11 @@ namespace Myshipping.Application /// public string StatusTriggerName { get; set; } + /// + /// 触发器说明 + /// + public string StatusTriggerNote { get; set; } + /// /// 触发条件 /// diff --git a/Myshipping.Application/Service/TrackingSystem/Interface/IStatusTriggerBaseService.cs b/Myshipping.Application/Service/TrackingSystem/Interface/IStatusTriggerBaseService.cs index 236da161..c3e3b3e7 100644 --- a/Myshipping.Application/Service/TrackingSystem/Interface/IStatusTriggerBaseService.cs +++ b/Myshipping.Application/Service/TrackingSystem/Interface/IStatusTriggerBaseService.cs @@ -10,7 +10,7 @@ namespace Myshipping.Application /// /// 状态触发器 /// - internal interface IStatusTriggerBaseService + public interface IStatusTriggerBaseService { /// /// 保存 @@ -29,23 +29,23 @@ namespace Myshipping.Application /// /// 启用 /// - /// 状态触发器主键 + /// 状态触发器主键数组 /// 返回回执 - Task SetEnable(string pkId); + Task SetEnable(string[] pkIds); /// /// 取消启用 /// - /// 状态触发器主键 + /// 状态触发器主键数组 /// 返回回执 - Task SetUnEnable(string pkId); + Task SetUnEnable(string[] pkIds); /// /// 删除 /// - /// 状态触发器主键 + /// 状态触发器主键数组 /// 返回回执 - Task Delete(string pkId); + Task Delete(string[] pkIds); /// /// 获取状态触发器详情 @@ -69,5 +69,17 @@ namespace Myshipping.Application /// 返回结果 Task> GetPageAsync(QueryStatusTriggerBaseDto QuerySearch); + /// + /// 获取状态触发器操作类型列表 + /// + /// 返回回执 + Task GetTriggerOperTypeList(); + + /// + /// 生成LIQUID表达式 + /// + /// 状态触发器条件详情 + /// 返回回执 + Task CreateLiquidExpression(StatusTriggerConditionDto info); } } diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceProjectService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceProjectService.cs index 9c14cf4f..7d06cd3d 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceProjectService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceProjectService.cs @@ -612,7 +612,7 @@ namespace Myshipping.Application //这里因为返回给前端的台账数据是DTO,所以这里排序时候需要转换成Entity对应的字段 if (!string.IsNullOrWhiteSpace(QuerySearch.SortField)) - entityOrderCol = MapsterExtHelper.GetAdaptProperty(QuerySearch.SortField); + entityOrderCol = MapsterExtHelper.GetAdaptProperty(QuerySearch.SortField); var entities = await _serviceProjectBaseInfoRepository.AsQueryable() .WhereIF(createBegin != DateTime.MinValue, t => t.CreatedTime >= createBegin) diff --git a/Myshipping.Application/Service/TrackingSystem/StatusSkuBaseService.cs b/Myshipping.Application/Service/TrackingSystem/StatusSkuBaseService.cs index bc87e862..80dff0eb 100644 --- a/Myshipping.Application/Service/TrackingSystem/StatusSkuBaseService.cs +++ b/Myshipping.Application/Service/TrackingSystem/StatusSkuBaseService.cs @@ -613,7 +613,7 @@ namespace Myshipping.Application //这里因为返回给前端的台账数据是DTO,所以这里排序时候需要转换成Entity对应的字段 if (!string.IsNullOrWhiteSpace(QuerySearch.SortField)) - entityOrderCol = MapsterExtHelper.GetAdaptProperty(QuerySearch.SortField); + entityOrderCol = MapsterExtHelper.GetAdaptProperty(QuerySearch.SortField); var entities = await _statusSkuBaseInfoRepository.AsQueryable() .WhereIF(createBegin != DateTime.MinValue, t => t.CreatedTime >= createBegin) diff --git a/Myshipping.Application/Service/TrackingSystem/StatusTriggerBaseService.cs b/Myshipping.Application/Service/TrackingSystem/StatusTriggerBaseService.cs new file mode 100644 index 00000000..a5e242de --- /dev/null +++ b/Myshipping.Application/Service/TrackingSystem/StatusTriggerBaseService.cs @@ -0,0 +1,341 @@ +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Furion.FriendlyException; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Myshipping.Application.Entity; +using Myshipping.Application.Helper; +using Myshipping.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// 触发器管理 + /// + [ApiDescriptionSettings("Application", Name = "StatusTriggerBase", Order = 20)] + public class StatusTriggerBaseService: IStatusTriggerBaseService, IDynamicApiController, ITransient + { + private readonly SqlSugarRepository _statusTriggerBaseInfoRepository; + private readonly SqlSugarRepository _statusTriggerConditionInfoRepository; + + private readonly ILogger _logger; + + public StatusTriggerBaseService(SqlSugarRepository statusTriggerBaseInfoRepository, + SqlSugarRepository statusTriggerConditionInfoRepository, + ILogger logger) + { + _statusTriggerBaseInfoRepository = statusTriggerBaseInfoRepository; + _statusTriggerConditionInfoRepository = statusTriggerConditionInfoRepository; + + _logger = logger; + + } + /// + /// 保存 + /// + /// 状态触发器详情 + /// 返回回执 + public async Task Save(StatusTriggerBaseDto info) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + //var id = await InnerSave(info); + + result.succ = true; + result.msg = "保存成功"; + //result.ext = id; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"保存服务项目异常,原因:{ex.Message}"; + } + + return result; + } + + /// + /// 保存并启用 + /// + /// 状态触发器详情 + /// 返回回执 + public async Task SaveAndEnable(StatusTriggerBaseDto info) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + //var id = await InnerSave(info); + + result.succ = true; + result.msg = "保存成功"; + //result.ext = id; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"保存服务项目异常,原因:{ex.Message}"; + } + + return result; + } + + /// + /// 启用 + /// + /// 状态触发器主键数组 + /// 返回回执 + public async Task SetEnable(string[] pkIds) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + //var id = await InnerSave(info); + + result.succ = true; + result.msg = "保存成功"; + //result.ext = id; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"保存服务项目异常,原因:{ex.Message}"; + } + + return result; + } + + /// + /// 取消启用 + /// + /// 状态触发器主键数组 + /// 返回回执 + public async Task SetUnEnable(string[] pkIds) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + //var id = await InnerSave(info); + + result.succ = true; + result.msg = "保存成功"; + //result.ext = id; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"保存服务项目异常,原因:{ex.Message}"; + } + + return result; + } + + /// + /// 删除 + /// + /// 状态触发器主键数组 + /// 返回回执 + public async Task Delete(string[] pkIds) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + //var id = await InnerSave(info); + + result.succ = true; + result.msg = "保存成功"; + //result.ext = id; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"保存服务项目异常,原因:{ex.Message}"; + } + + return result; + } + + /// + /// 获取状态触发器详情 + /// + /// 状态触发器主键 + /// 返回回执 + public async Task GetInfo(string pkId) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + //var id = await InnerSave(info); + + result.succ = true; + result.msg = "保存成功"; + //result.ext = id; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"保存服务项目异常,原因:{ex.Message}"; + } + + return result; + } + + /// + /// 检索状态触发器列表 + /// + /// 检索值 + /// 最大返回行数(默认15) + /// 返回回执 + public async Task QueryList(string queryItem, int topNum = 15) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + //var id = await InnerSave(info); + + result.succ = true; + result.msg = "保存成功"; + //result.ext = id; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"保存服务项目异常,原因:{ex.Message}"; + } + + return result; + } + + /// + /// 状态触发器台账查询 + /// + /// 状态触发器台账查询请求 + /// 返回结果 + public async Task> GetPageAsync(QueryStatusTriggerBaseDto QuerySearch) + { + //制单日期 + DateTime createBegin = DateTime.MinValue; + DateTime createEnd = DateTime.MinValue; + //更新日期 + DateTime updateBegin = DateTime.MinValue; + DateTime updateEnd = DateTime.MinValue; + + //制单日期 + if (!string.IsNullOrWhiteSpace(QuerySearch.CreateBegin)) + { + if (!DateTime.TryParse(QuerySearch.CreateBegin, out createBegin)) + throw Oops.Oh($"创建起始日期格式错误,{QuerySearch.CreateBegin}"); + } + + if (!string.IsNullOrWhiteSpace(QuerySearch.CreateEnd)) + { + if (!DateTime.TryParse(QuerySearch.CreateEnd, out createEnd)) + throw Oops.Oh($"创建结束日期格式错误,{QuerySearch.CreateEnd}"); + + createEnd = createEnd.AddDays(1); + } + + //更新日期 + if (!string.IsNullOrWhiteSpace(QuerySearch.UpdateBegin)) + { + if (!DateTime.TryParse(QuerySearch.UpdateBegin, out updateBegin)) + throw Oops.Oh($"更新起始日期格式错误,{QuerySearch.UpdateBegin}"); + } + + if (!string.IsNullOrWhiteSpace(QuerySearch.UpdateEnd)) + { + if (!DateTime.TryParse(QuerySearch.UpdateEnd, out updateEnd)) + throw Oops.Oh($"更新结束日期格式错误,{QuerySearch.UpdateEnd}"); + + updateEnd = updateEnd.AddDays(1); + } + + string entityOrderCol = "CreatedTime"; + + //这里因为返回给前端的台账数据是DTO,所以这里排序时候需要转换成Entity对应的字段 + if (!string.IsNullOrWhiteSpace(QuerySearch.SortField)) + entityOrderCol = MapsterExtHelper.GetAdaptProperty(QuerySearch.SortField); + + var entities = await _statusTriggerBaseInfoRepository.AsQueryable() + .WhereIF(createBegin != DateTime.MinValue, t => t.CreatedTime >= createBegin) + .WhereIF(createEnd != DateTime.MinValue, t => t.CreatedTime < createEnd) + .WhereIF(updateBegin != DateTime.MinValue, t => t.UpdatedTime.HasValue && t.UpdatedTime.Value >= updateBegin) + .WhereIF(updateEnd != DateTime.MinValue, t => t.UpdatedTime.HasValue && t.UpdatedTime.Value < updateEnd) + .WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.IsEnable) && QuerySearch.IsEnable == "1", t => t.IS_ENABLE == 1) + .WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.IsEnable) && QuerySearch.IsEnable == "2", t => t.IS_ENABLE == 0) + .WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.StatusTriggerName), t => t.STATUS_TRIGGER_NAME.Contains(QuerySearch.StatusTriggerName) || + t.STATUS_TRIGGER_CODE.Contains(QuerySearch.StatusTriggerName)) + .WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.StatusTriggerNote), t => t.STATUS_TRIGGER_NOTE.Contains(QuerySearch.StatusTriggerNote)) + .WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.CreateUser), t => t.CreatedUserName.Contains(QuerySearch.CreateUser)) + .WhereIF(!string.IsNullOrWhiteSpace(QuerySearch.UpdateUser), t => t.UpdatedUserName.Contains(QuerySearch.UpdateUser)) + .OrderBy(entityOrderCol + (QuerySearch.descSort ? " asc " : " desc ")) + .ToPagedListAsync(QuerySearch.PageNo, QuerySearch.PageSize); + + return entities.Adapt>(); + } + + /// + /// 获取状态触发器操作类型列表 + /// + /// 返回回执 + public async Task GetTriggerOperTypeList() + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + //var id = await InnerSave(info); + + result.succ = true; + result.msg = "保存成功"; + //result.ext = id; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"保存服务项目异常,原因:{ex.Message}"; + } + + return result; + } + + /// + /// 生成LIQUID表达式 + /// + /// 状态触发器条件详情 + /// 返回回执 + public async Task CreateLiquidExpression(StatusTriggerConditionDto info) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + //var id = await InnerSave(info); + + result.succ = true; + result.msg = "保存成功"; + //result.ext = id; + } + catch (Exception ex) + { + result.succ = false; + result.msg = $"保存服务项目异常,原因:{ex.Message}"; + } + + return result; + } + } +}