From ce9fb018621f251485fd8a8eebae4acd15940cff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Fri, 13 Sep 2024 14:28:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BD=9CGetNextConditionNodeId?= =?UTF-8?q?=E6=96=B9=E6=B3=95bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Constants/MultiLanguageConst.cs | 4 + .../DS.WMS.Core/Fee/Method/FeeAuditService.cs | 4 +- .../DS.WMS.Core/Flow/Method/FlowRuntime.cs | 177 +++++------------- .../DS.WMS.Core/Info/Dtos/ClientInfoRes.cs | 2 +- .../Info/Interface/IClientInfoService.cs | 6 +- .../Info/Method/ClientInfoService.cs | 14 +- .../Op/Method/TaskInteraction/TaskService.cs | 9 +- .../Controllers/ClientInfoController.cs | 7 +- 8 files changed, 69 insertions(+), 154 deletions(-) diff --git a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs index 0efe9b9f..54aa4c35 100644 --- a/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs +++ b/ds-wms-service/DS.Module.Core/Constants/MultiLanguageConst.cs @@ -1505,10 +1505,14 @@ public static class MultiLanguageConst #region 关联任务 [Description("此任务已存在,请勿重复提交")] public const string TaskExists = "Task_Exists"; + [Description("未能找到任务")] + public const string TaskNotExists = "Task_Not_Exists"; [Description("此任务已完成")] public const string TaskCompleted = "Task_Completed"; [Description("此任务已取消")] public const string TaskCancelled = "Task_Cancelled"; + [Description("任务数据与已提交数据条数不匹配")] + public const string TaskCountNotMatch = "Task_Count_Not_Match"; [Description("当前任务状态不支持此操作")] public const string TaskStatusNotSupported = "Task_Status_Not_Supported"; [Description("当前任务状态不正确,无法提交审核")] diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs index 2a4c5f82..601d3bd7 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs @@ -563,7 +563,7 @@ namespace DS.WMS.Core.Fee.Method }); if (!result.Succeeded) - list.AddRange(fees.Where(x => ids.Contains(x.Id)).Select(x => x.FeeName)); + list.Add(result.Message); } else { @@ -583,7 +583,7 @@ namespace DS.WMS.Core.Fee.Method } if (list.Count > 0) - return DataResult.Failed($"{MultiLanguageConst.Operation_Failed}:{string.Join("、", list)}"); + return DataResult.Failed(string.Join("、", list)); } return DataResult.Success; diff --git a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntime.cs b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntime.cs index a85c398a..ff5d0809 100644 --- a/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntime.cs +++ b/ds-wms-service/DS.WMS.Core/Flow/Method/FlowRuntime.cs @@ -209,8 +209,6 @@ public class FlowRuntime { return ChildNodes.Where(x => x.Id == "end").First().Id; } - - // return ChildNodes.Where(x => x.Pid == nodeId).First().Id; } } @@ -233,155 +231,66 @@ public class FlowRuntime } else { - var conditions = conditionNodes[i].Conditions; - var conditionalCollections = new List(); - if (conditions.LogicalOperator == "and") - { - var conditionList = new List>(); - foreach (var item in conditions.Conditions) - { - conditionList.Add(new KeyValuePair - (WhereType.And, - new ConditionalModel - { - FieldName = item.Field, - ConditionalType = GetConditionalType(item.Operator), - FieldValue = item.Value - }) - ); - } + var nodeSection = conditionNodes[i].Conditions; + var list = new List(); + var conditionList = new List>(nodeSection.Conditions.Count); - if (conditionList.Count > 0) - { - conditionalCollections.Add(new ConditionalCollections - { - ConditionalList = conditionList - } - ) - ; - } - - var groupList = new List>(); - foreach (var group in conditions.Groups) - { - if (group.LogicalOperator == "and") - { - foreach (var item1 in group.Conditions) - { - groupList.Add(new KeyValuePair - (WhereType.And, - new ConditionalModel - { - FieldName = item1.Field, - ConditionalType = GetConditionalType(item1.Operator), - FieldValue = item1.Value - }) - ); - } - } - else - { - foreach (var item1 in group.Conditions) + var whereType = Enum.Parse(nodeSection.LogicalOperator, true); + foreach (var item in nodeSection.Conditions) + { + conditionList.Add(new KeyValuePair + (whereType, + new ConditionalModel { - groupList.Add(new KeyValuePair - (WhereType.Or, - new ConditionalModel - { - FieldName = item1.Field, - ConditionalType = GetConditionalType(item1.Operator), - FieldValue = item1.Value - }) - ); - } - } - } + FieldName = item.Field, + ConditionalType = GetConditionalType(item.Operator), + FieldValue = item.Value + }) + ); + } - if (groupList.Count > 0) + if (conditionList.Count > 0) + { + list.Add(new ConditionalCollections { - conditionalCollections.Add(new ConditionalCollections - { - ConditionalList = groupList - } - ) - ; - } + ConditionalList = conditionList + }); } - else + + var groupList = new List>(); + foreach (var group in nodeSection.Groups) { - var conditionList = new List>(); - foreach (var item in conditions.Conditions) + WhereType whereType2 = Enum.Parse(group.LogicalOperator, true); + for (int j = 0; j < group.Conditions.Count; j++) { - conditionList.Add(new KeyValuePair - (WhereType.Or, + var item1 = group.Conditions[j]; + groupList.Add(new KeyValuePair + (j == 0 ? whereType : whereType2, new ConditionalModel { - FieldName = item.Field, - ConditionalType = GetConditionalType(item.Operator), - FieldValue = item.Value + FieldName = item1.Field, + ConditionalType = GetConditionalType(item1.Operator), + FieldValue = item1.Value }) ); } + } - if (conditionList.Count > 0) - { - conditionalCollections.Add(new ConditionalCollections - { - ConditionalList = conditionList - } - ) - ; - } - - var groupList = new List>(); - foreach (var group in conditions.Groups) - { - if (group.LogicalOperator == "and") - { - foreach (var item1 in group.Conditions) - { - groupList.Add(new KeyValuePair - (WhereType.And, - new ConditionalModel - { - FieldName = item1.Field, - ConditionalType = GetConditionalType(item1.Operator), - FieldValue = item1.Value - }) - ); - } - } - else - { - foreach (var item1 in group.Conditions) - { - groupList.Add(new KeyValuePair - (WhereType.Or, - new ConditionalModel - { - FieldName = item1.Field, - ConditionalType = GetConditionalType(item1.Operator), - FieldValue = item1.Value - }) - ); - } - } - } - - if (groupList.Count > 0) + if (groupList.Count > 0) + { + list.Add(new ConditionalCollections { - conditionalCollections.Add(new ConditionalCollections - { - ConditionalList = groupList - } - ) - ; - } + ConditionalList = groupList + }); } - var conditionalModels = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(JsonConvert.SerializeObject(conditionalCollections)); - if (conditionalModels.Count == 0) //跳过默认条件 + if (list.Count == 0) //跳过默认条件 continue; + //string json = JsonConvert.SerializeObject(list); + //db.Utilities.JsonToConditionalModels(json); + List conditionalModels = [.. list]; + ISqlSugarClient sugarClient = tenantDb ?? db; var exists = sugarClient.Queryable().AS(ColumnView).Where("Id=@Id", new { Id = BusinessId }).Where(conditionalModels).Any(); if (exists) @@ -414,7 +323,7 @@ public class FlowRuntime return ChildNodes.Where(x => x.Id == childId).First(); //下一个节点 } //todo:前端组织JSON结构有误,加入临时修复代码,待前端改正后移除 - else if (nextChild.Type == null) + else if (nextChild.Type == null) { nextChild.Id = nextChild.Type = FlowChild.END; nextChild.Name = "结束"; diff --git a/ds-wms-service/DS.WMS.Core/Info/Dtos/ClientInfoRes.cs b/ds-wms-service/DS.WMS.Core/Info/Dtos/ClientInfoRes.cs index c21625c1..07b3d9f2 100644 --- a/ds-wms-service/DS.WMS.Core/Info/Dtos/ClientInfoRes.cs +++ b/ds-wms-service/DS.WMS.Core/Info/Dtos/ClientInfoRes.cs @@ -197,7 +197,7 @@ public class ClientInfoRes /// /// 审批意见 /// - public string AuditNote { get; set; } + public string? AuditNote { get; set; } /// /// Desc:默认付费方式 diff --git a/ds-wms-service/DS.WMS.Core/Info/Interface/IClientInfoService.cs b/ds-wms-service/DS.WMS.Core/Info/Interface/IClientInfoService.cs index 118e5eda..4d0a404e 100644 --- a/ds-wms-service/DS.WMS.Core/Info/Interface/IClientInfoService.cs +++ b/ds-wms-service/DS.WMS.Core/Info/Interface/IClientInfoService.cs @@ -58,14 +58,14 @@ public interface IClientInfoService /// /// /// - Task EditClientInfoAsync(ClientInfoReq model); - + Task EditAsync(ClientInfoReq model); + /// /// 获取详情 /// /// /// - DataResult GetClientInfo(string id); + Task> GetAsync(string id); /// /// 批量删除发票抬头 diff --git a/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs b/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs index 4d900bc6..509178e6 100644 --- a/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs +++ b/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs @@ -357,7 +357,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService /// /// /// - public async Task EditClientInfoAsync(ClientInfoReq req) + public async Task EditAsync(ClientInfoReq req) { var data = req.Adapt(); data.Status = (int)StatusEnum.Disable; @@ -417,22 +417,22 @@ public class ClientInfoService : ServiceBase, IClientInfoService /// /// /// - public DataResult GetClientInfo(string id) + public async Task> GetAsync(string id) { - var entity = TenantDb.Queryable() + var entity = await TenantDb.Queryable() .Where(a => a.Id == long.Parse(id)) - .First(); + .FirstAsync(); if (entity == null) return DataResult.Success(null); var data = entity.Adapt(); data.ServiceItemCodes = entity.ServiceItem?.Split(',', StringSplitOptions.RemoveEmptyEntries); - var tag = TenantDb.Queryable().Select() - .First(a => a.ClientId == long.Parse(id)); + var tag = await TenantDb.Queryable().Select() + .FirstAsync(a => a.ClientId == long.Parse(id)); data.ClientTag = tag; - data.InvoiceHeaders ??= TenantDb.Queryable().Where(x => x.RelativeId == data.Id).ToList(); + data.InvoiceHeaders ??= await TenantDb.Queryable().Where(x => x.RelativeId == data.Id).ToListAsync(); return DataResult.Success(data, MultiLanguageConst.DataQuerySuccess); } diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs index a50c4daa..c7757341 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs @@ -163,8 +163,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction if (strList.Count == 0) return DataResult.Success; - - return DataResult.Failed(string.Format(MultiLanguageConst.OrderTaskSubmitted, string.Join("、", strList))); + + return DataResult.Failed(string.Format( + MultiLanguageConst.GetDescription(MultiLanguageConst.OrderTaskSubmitted), string.Join("、", strList))); } /// @@ -737,7 +738,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction var tasks = await TenantDb.Queryable().Where(x => x.TaskType == request.TaskType && request.Ids.Contains(x.BusinessId)) .WhereIF(request.BusinessType.HasValue, x => x.BusinessType == request.BusinessType.Value).ToListAsync(); if (tasks.Count == 0) - return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData)); + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotExists)); + if (tasks.Count != request.Ids.Length) + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCountNotMatch)); if (tasks.Exists(x => x.TaskStatus == TaskStatusEnum.Complete)) { diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/ClientInfoController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/ClientInfoController.cs index c81d34a0..909c705d 100644 --- a/ds-wms-service/DS.WMS.MainApi/Controllers/ClientInfoController.cs +++ b/ds-wms-service/DS.WMS.MainApi/Controllers/ClientInfoController.cs @@ -110,7 +110,7 @@ public class ClientInfoController : ApiController [HttpPost, Route("EditClientInfo")] public async Task EditClientInfoAsync([FromBody] ClientInfoReq req) { - var res = await _invokeService.EditClientInfoAsync(req); + var res = await _invokeService.EditAsync(req); return res; } @@ -121,10 +121,9 @@ public class ClientInfoController : ApiController /// [HttpGet] [Route("GetClientInfo")] - public DataResult GetClientInfo([FromQuery] string id) + public async Task> GetClientInfoAsync([FromQuery] string id) { - var res = _invokeService.GetClientInfo(id); - return res; + return await _invokeService.GetAsync(id); } ///