From 59cd3b52295c5b45d608d6663b84484516721902 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Mon, 29 Jul 2024 14:59:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8F=B0=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=EF=BC=8C=E8=B0=83=E6=95=B4=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8F=B0=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskPlat/Entity/TaskBaseInfo.cs | 32 ++++-- .../TaskPlat/Method/TaskManageBaseService.cs | 1 + .../TaskPlat/Method/TaskManageService.cs | 108 +++++++++++------- 3 files changed, 89 insertions(+), 52 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskBaseInfo.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskBaseInfo.cs index d8d044ff..243c8c2d 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskBaseInfo.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskBaseInfo.cs @@ -18,10 +18,16 @@ namespace DS.WMS.Core.TaskPlat.Entity public string TASK_NO { get; set; } = null!; /// - /// 任务类型 + /// 任务类型编码 /// - [SugarColumn(ColumnDescription = "任务类型", IsNullable = true, Length = 40)] - public string? TASK_TYPE { get; set; } + [SugarColumn(ColumnDescription = "任务类型编码", IsNullable = false, Length = 40)] + public string TASK_TYPE { get; set; } + + /// + /// 任务类型名称 + /// + [SugarColumn(ColumnDescription = "任务类型名称", IsNullable = true, Length = 255)] + public string? TASK_TYPE_NAME { get; set; } /// /// 任务来源 @@ -29,11 +35,17 @@ namespace DS.WMS.Core.TaskPlat.Entity [SugarColumn(ColumnDescription = "任务来源", IsNullable = true, Length = 64)] public string? TASK_SOURCE { get; set; } + /// + /// 任务来源名称 + /// + [SugarColumn(ColumnDescription = "任务来源名称", IsNullable = true, Length = 64)] + public string? TASK_SOURCE_NAME { get; set; } + /// /// 状态 Create-待处理;Retransmit-已转发;Complete-已完成;Cancel-已取消;Pending-已挂起 /// - [SugarColumn(ColumnDescription = "状态 Create-待处理;Retransmit-已转发;Complete-已完成;Cancel-已取消;Pending-已挂起", IsNullable = true, Length = 20)] - public string? STATUS { get; set; } + [SugarColumn(ColumnDescription = "状态 Create-待处理;Retransmit-已转发;Complete-已完成;Cancel-已取消;Pending-已挂起", IsNullable = false, Length = 20)] + public string STATUS { get; set; } /// /// 状态名称 @@ -71,11 +83,11 @@ namespace DS.WMS.Core.TaskPlat.Entity [SugarColumn(ColumnDescription = "外业务主键", IsNullable = true)] public long? OUT_BS_NO { get; set; } - /// - /// 基础业务类型 - /// - [SugarColumn(ColumnDescription = "基础业务类型", IsNullable = true, Length = 40)] - public string? TASK_BASE_TYPE { get; set; } + ///// + ///// 基础业务类型 + ///// + //[SugarColumn(ColumnDescription = "基础业务类型", IsNullable = true, Length = 40)] + //public string? TASK_BASE_TYPE { get; set; } /// /// 船公司代号 diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBaseService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBaseService.cs index d08bb6fc..50b67e59 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBaseService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBaseService.cs @@ -273,6 +273,7 @@ namespace DS.WMS.Core.TaskPlat.Method } if (!File.Exists(fileFullPath)) { + logger.LogError("根据任务主键获取文件信息失败:文件不存在,fileFullPath={fileFullPath}", fileFullPath); //任务主键{0} 附件下载请求失败,请确认文件是否存在 throw new Exception( string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskFileNotExists)), taskId) diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs index a2ea3acc..63e694df 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs @@ -41,7 +41,7 @@ namespace DS.WMS.Core.TaskPlat.Method TaskBaseInfo taskInfo = await tenantDb.Queryable() .OrderByDescending(a => a.CreateTime) - .FirstAsync(t => t.OUT_BS_NO == bsno && t.TASK_BASE_TYPE == taskBaseTypeEnum.ToString()); + .FirstAsync(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskBaseTypeEnum.ToString()); if (taskInfo == null) { @@ -79,7 +79,7 @@ namespace DS.WMS.Core.TaskPlat.Method try { var taskId = await tenantDb.Queryable() - .Where(t => t.OUT_BS_NO == bsno && t.TASK_BASE_TYPE == taskBaseTypeEnum.ToString()) + .Where(t => t.OUT_BS_NO == bsno && t.TASK_TYPE == taskBaseTypeEnum.ToString()) .OrderByDescending(a => a.CreateTime) .Select(t => t.Id) .FirstAsync(); @@ -180,10 +180,12 @@ namespace DS.WMS.Core.TaskPlat.Method { Id = SnowFlakeSingle.Instance.NextId(), STATUS = TaskStatusEnum.Create.ToString(), + STATUS_NAME = TaskStatusEnum.Create.EnumDescription(), IS_EXCEPT = 0, IS_COMPLETE = 0, MBL_NO = info.Main.MBlNo, - TASK_BASE_TYPE = info.Main.TaskType.ToString(), + TASK_TYPE = info.Main.TaskType.ToString(), + //TASK_BASE_TYPE = info.Main.TaskType.ToString(), CARRIER_ID = info.Main.CarrierId?.Trim(), //IS_PUBLIC = string.IsNullOrWhiteSpace(info.Main.TaskUserId) ? 1 : 0, IS_PUBLIC = 1, @@ -192,7 +194,7 @@ namespace DS.WMS.Core.TaskPlat.Method TASK_TITLE = info.Main.TaskTitle, TASK_DESP = info.Main.TaskDesp, TASK_SOURCE = info.Main.TaskSource.ToString(), - TASK_TYPE = info.Main.TaskType.ToString(), + TASK_SOURCE_NAME = info.Main.TaskSource.EnumDescription(), VESSEL_VOYNO = info.Main.VesselVoyno?.Trim(), CONTA_INFO = info.Main.ContaInfo, TASK_REQ_USERNAME = info.Main.TaskUserName, @@ -205,6 +207,10 @@ namespace DS.WMS.Core.TaskPlat.Method OUT_BS_NO = info.Head.BSNO, CreateTime = DateTime.Now, }; + if (Enum.TryParse(typeof(TaskBaseTypeEnum), taskInfo.TASK_TYPE, out object? taskTypeTemp)) + { + taskInfo.TASK_TYPE_NAME = ((TaskBaseTypeEnum)taskTypeTemp).EnumDescription(); + } // 人员字段说明: // TaskBaseInfo.CreateBy 创建人:谁创建的,只有一个人(可能是某个租户的管理员,因为任务可以由外部(邮件)创建,无法为每个人创建接口授权信息) @@ -273,37 +279,37 @@ namespace DS.WMS.Core.TaskPlat.Method string attachFileType = string.Empty; string fileCategory = string.Empty; - if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_BASE_TYPE) + if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_TYPE) { attachFileType = "bcfiles"; fileCategory = TaskFileCategoryEnum.BC.ToString(); } - else if (TaskBaseTypeEnum.BC_MODIFY.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.BC_MODIFY.ToString() == taskInfo.TASK_TYPE) { attachFileType = "bcmodifyfiles"; fileCategory = TaskFileCategoryEnum.BC_MODIFY.ToString(); } - else if (TaskBaseTypeEnum.CANCELLATION.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.CANCELLATION.ToString() == taskInfo.TASK_TYPE) { attachFileType = "bccancelfiles"; fileCategory = TaskFileCategoryEnum.BC_CANCEL.ToString(); } - else if (TaskBaseTypeEnum.DRAFT.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.DRAFT.ToString() == taskInfo.TASK_TYPE) { attachFileType = "draftfiles"; fileCategory = TaskFileCategoryEnum.DRAFT.ToString(); } - else if (TaskBaseTypeEnum.SI_FEEDBACK.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.SI_FEEDBACK.ToString() == taskInfo.TASK_TYPE) { attachFileType = "sisubmittedfiles"; fileCategory = TaskFileCategoryEnum.SI_SUBMITTED.ToString(); } - else if (TaskBaseTypeEnum.ROUTE_CUT_CHANGE.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.ROUTE_CUT_CHANGE.ToString() == taskInfo.TASK_TYPE) { attachFileType = "advisoryfiles"; @@ -333,37 +339,37 @@ namespace DS.WMS.Core.TaskPlat.Method string attachFileType = string.Empty; string fileCategory = string.Empty; - if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_BASE_TYPE) + if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_TYPE) { attachFileType = "bcfiles"; fileCategory = TaskFileCategoryEnum.BC.ToString(); } - else if (TaskBaseTypeEnum.BC_MODIFY.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.BC_MODIFY.ToString() == taskInfo.TASK_TYPE) { attachFileType = "bcmodifyfiles"; fileCategory = TaskFileCategoryEnum.BC_MODIFY.ToString(); } - else if (TaskBaseTypeEnum.CANCELLATION.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.CANCELLATION.ToString() == taskInfo.TASK_TYPE) { attachFileType = "bccancelfiles"; fileCategory = TaskFileCategoryEnum.BC_CANCEL.ToString(); } - else if (TaskBaseTypeEnum.DRAFT.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.DRAFT.ToString() == taskInfo.TASK_TYPE) { attachFileType = "draftfiles"; fileCategory = TaskFileCategoryEnum.DRAFT.ToString(); } - else if (TaskBaseTypeEnum.SI_FEEDBACK.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.SI_FEEDBACK.ToString() == taskInfo.TASK_TYPE) { attachFileType = "sisubmittedfiles"; fileCategory = TaskFileCategoryEnum.SI_SUBMITTED.ToString(); } - else if (TaskBaseTypeEnum.ROUTE_CUT_CHANGE.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.ROUTE_CUT_CHANGE.ToString() == taskInfo.TASK_TYPE) { attachFileType = "advisoryfiles"; @@ -402,16 +408,16 @@ namespace DS.WMS.Core.TaskPlat.Method string fileCategory = string.Empty; - if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_BASE_TYPE) + if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_TYPE) fileCategory = TaskFileCategoryEnum.BC_NOTICE.ToString(); - else if (TaskBaseTypeEnum.BC_MODIFY.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.BC_MODIFY.ToString() == taskInfo.TASK_TYPE) fileCategory = TaskFileCategoryEnum.BC_MODIFY_NOTICE.ToString(); - else if (TaskBaseTypeEnum.CANCELLATION.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.CANCELLATION.ToString() == taskInfo.TASK_TYPE) fileCategory = TaskFileCategoryEnum.BC_CANCEL_NOTICE.ToString(); - else if (TaskBaseTypeEnum.DRAFT.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.DRAFT.ToString() == taskInfo.TASK_TYPE) fileCategory = TaskFileCategoryEnum.DRAFT_NOTICE.ToString(); if (info.Main.FileList == null) @@ -435,26 +441,26 @@ namespace DS.WMS.Core.TaskPlat.Method string attachFileType = string.Empty; string fileCategory = string.Empty; - if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_BASE_TYPE) + if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_TYPE) { attachFileType = "bcnoticefiles"; fileCategory = TaskFileCategoryEnum.BC_NOTICE.ToString(); } - else if (TaskBaseTypeEnum.BC_MODIFY.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.BC_MODIFY.ToString() == taskInfo.TASK_TYPE) { attachFileType = "bcmodifynoticefiles"; fileCategory = TaskFileCategoryEnum.BC_MODIFY_NOTICE.ToString(); } - else if (TaskBaseTypeEnum.CANCELLATION.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.CANCELLATION.ToString() == taskInfo.TASK_TYPE) { attachFileType = "bccancelnoticefiles"; fileCategory = TaskFileCategoryEnum.BC_CANCEL_NOTICE.ToString(); } - else if (TaskBaseTypeEnum.DRAFT.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.DRAFT.ToString() == taskInfo.TASK_TYPE) { attachFileType = "draftnoticefiles"; @@ -512,12 +518,12 @@ namespace DS.WMS.Core.TaskPlat.Method if (string.IsNullOrWhiteSpace(file.FileCategory)) { - if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_BASE_TYPE) + if (TaskBaseTypeEnum.BC.ToString() == taskInfo.TASK_TYPE) { fileInfo.FILE_CATEGORY = TaskFileCategoryEnum.BC.ToString(); fileInfo.FILE_CATEGORY_NAME = TaskFileCategoryEnum.BC.EnumDescription(); } - else if (TaskBaseTypeEnum.BC_MODIFY.ToString() == taskInfo.TASK_BASE_TYPE) + else if (TaskBaseTypeEnum.BC_MODIFY.ToString() == taskInfo.TASK_TYPE) { fileInfo.FILE_CATEGORY = TaskFileCategoryEnum.BC_MODIFY.ToString(); fileInfo.FILE_CATEGORY_NAME = TaskFileCategoryEnum.BC_MODIFY.EnumDescription(); @@ -712,6 +718,20 @@ namespace DS.WMS.Core.TaskPlat.Method if (!string.IsNullOrEmpty(querySearch.QueryCondition)) { whereList = tenantDb.Utilities.JsonToConditionalModels(querySearch.QueryCondition); + + if (whereList != null) + { + foreach (var item in whereList) + { + if (item is ConditionalModel model) + { + if (!model.FieldName.StartsWith("t.")) + { + model.FieldName = "t." + model.FieldName; + } + } + } + } } // 格式化参数 @@ -740,7 +760,7 @@ namespace DS.WMS.Core.TaskPlat.Method var queryable = tenantDb.Queryable().LeftJoin((t, a) => t.Id == a.TaskId) .LeftJoin((t, a, bc) => t.Id == bc.TASK_ID); - SetCondition(queryable, whereList, taskStatLevel, userId); + SetCondition(queryable, whereList, taskType, taskStatLevel, userId); result = await queryable.Select((t, a, bc) => new { @@ -820,7 +840,7 @@ namespace DS.WMS.Core.TaskPlat.Method bc.PROCESS_DATE, bc.PRICE_CALCULATION_DATE }) - .ToQueryPageAsync(querySearch.PageCondition); + .ToQueryPageAsync(querySearch.PageCondition); return result; } case TaskBaseTypeEnum.SI_FEEDBACK: @@ -828,7 +848,7 @@ namespace DS.WMS.Core.TaskPlat.Method var queryable = tenantDb.Queryable().LeftJoin((t, a) => t.Id == a.TaskId) .LeftJoin((t, a, bc) => t.Id == bc.TASK_ID); - SetCondition(queryable, whereList, taskStatLevel, userId); + SetCondition(queryable, whereList, taskType, taskStatLevel, userId); result = await queryable.Select((t, a, bc) => new { @@ -882,7 +902,7 @@ namespace DS.WMS.Core.TaskPlat.Method var queryable = tenantDb.Queryable().LeftJoin((t, a) => t.Id == a.TaskId) .LeftJoin((t, a, bc) => t.Id == bc.TASK_PKID); - SetCondition(queryable, whereList, taskStatLevel, userId); + SetCondition(queryable, whereList, taskType, taskStatLevel, userId); result = await queryable.Select((t, a, bc) => new { @@ -906,7 +926,7 @@ namespace DS.WMS.Core.TaskPlat.Method var queryable = tenantDb.Queryable().LeftJoin((t, a) => t.Id == a.TaskId) .LeftJoin((t, a, bc) => t.Id == bc.TASK_ID); - SetCondition(queryable, whereList, taskStatLevel, userId); + SetCondition(queryable, whereList, taskType, taskStatLevel, userId); result = await queryable.Select((t, a, bc) => new { @@ -971,7 +991,7 @@ namespace DS.WMS.Core.TaskPlat.Method var queryable = tenantDb.Queryable().LeftJoin((t, a) => t.Id == a.TaskId) .LeftJoin((t, a, bc) => t.Id == bc.TASK_ID); - SetCondition(queryable, whereList, taskStatLevel, userId); + SetCondition(queryable, whereList, taskType, taskStatLevel, userId); result = await queryable.Select((t, a, bc) => new { @@ -991,7 +1011,7 @@ namespace DS.WMS.Core.TaskPlat.Method var queryable = tenantDb.Queryable().LeftJoin((t, a) => t.Id == a.TaskId) .LeftJoin((t, a, bc) => t.Id == bc.TASK_ID); - SetCondition(queryable, whereList, taskStatLevel, userId); + SetCondition(queryable, whereList, taskType, taskStatLevel, userId); result = await queryable.Select((t, a, bc) => new { @@ -1017,7 +1037,7 @@ namespace DS.WMS.Core.TaskPlat.Method var queryable = tenantDb.Queryable().LeftJoin((t, a) => t.Id == a.TaskId) .LeftJoin((t, a, bc) => t.Id == bc.TASK_ID); - SetCondition(queryable, whereList, taskStatLevel, userId); + SetCondition(queryable, whereList, taskType, taskStatLevel, userId); result = await queryable.Select((t, a, bc) => new { @@ -1040,7 +1060,7 @@ namespace DS.WMS.Core.TaskPlat.Method var queryable = tenantDb.Queryable().LeftJoin((t, a) => t.Id == a.TaskId) .LeftJoin((t, a, bc) => t.Id == bc.TASK_ID); - SetCondition(queryable, whereList, taskStatLevel, userId); + SetCondition(queryable, whereList, taskType, taskStatLevel, userId); result = await queryable.Select((t, a, bc) => new { @@ -1059,7 +1079,7 @@ namespace DS.WMS.Core.TaskPlat.Method var queryable = tenantDb.Queryable().LeftJoin((t, a) => t.Id == a.TaskId) .LeftJoin((t, a, bc) => t.Id == bc.TASK_ID); - SetCondition(queryable, whereList, taskStatLevel, userId); + SetCondition(queryable, whereList, taskType, taskStatLevel, userId); result = await queryable.Select((t, a, bc) => new { @@ -1090,7 +1110,7 @@ namespace DS.WMS.Core.TaskPlat.Method var queryable = tenantDb.Queryable().LeftJoin((t, a) => t.Id == a.TaskId) .LeftJoin((t, a, bc) => t.Id == bc.TASK_ID); - SetCondition(queryable, whereList, taskStatLevel, userId); + SetCondition(queryable, whereList, taskType, taskStatLevel, userId); result = await queryable.Select((t, a, bc) => new { @@ -1121,7 +1141,7 @@ namespace DS.WMS.Core.TaskPlat.Method { var queryable = tenantDb.Queryable().LeftJoin((t, a) => t.Id == a.TaskId); - SetCondition(queryable, whereList, taskStatLevel, userId); + SetCondition(queryable, whereList, taskType, taskStatLevel, userId); result = await queryable.Select(t => t).ToQueryPageAsync(querySearch.PageCondition); @@ -1627,28 +1647,32 @@ namespace DS.WMS.Core.TaskPlat.Method } /// - /// 公共设置条件的方法,用于 + /// 设置条件的方法,用于 /// - public void SetCondition(ISugarQueryable queryable, + private void SetCondition(ISugarQueryable queryable, List? whereList, + TaskBaseTypeEnum? taskType, TaskStatLevelEnum taskStatLevel, long userId) { queryable.Where(whereList) + .WhereIF(taskType != null, (t, a) => t.TASK_TYPE == taskType.ToString()) .WhereIF(taskStatLevel == TaskStatLevelEnum.PUBLIC, (t, a) => t.IS_PUBLIC == 1 && t.IS_EXCEPT == 0) .WhereIF(taskStatLevel == TaskStatLevelEnum.EXCPTION, (t, a) => t.IS_EXCEPT == 1) .WhereIF(taskStatLevel == TaskStatLevelEnum.PERSON, (t, a) => t.IS_PUBLIC == 0 && t.IS_EXCEPT == 0 && a.UserId == userId); } /// - /// 公共设置条件的方法,用于 + /// 设置条件的方法,用于 /// - public void SetCondition(ISugarQueryable queryable, + private void SetCondition(ISugarQueryable queryable, List? whereList, + TaskBaseTypeEnum? taskType, TaskStatLevelEnum taskStatLevel, long userId) { queryable.Where(whereList) + .WhereIF(taskType != null, (t, a) => t.TASK_TYPE == taskType.ToString()) .WhereIF(taskStatLevel == TaskStatLevelEnum.PUBLIC, (t, a) => t.IS_PUBLIC == 1 && t.IS_EXCEPT == 0) .WhereIF(taskStatLevel == TaskStatLevelEnum.EXCPTION, (t, a) => t.IS_EXCEPT == 1) .WhereIF(taskStatLevel == TaskStatLevelEnum.PERSON, (t, a) => t.IS_PUBLIC == 0 && t.IS_EXCEPT == 0 && a.UserId == userId);