From 173fc6e75de4c18941f396a4a595e8526a6ebaa2 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Mon, 26 Aug 2024 17:59:23 +0800 Subject: [PATCH 1/4] =?UTF-8?q?TaskService=E7=A1=AE=E4=BF=9D=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E4=BA=A4=E4=BA=92=E6=A8=A1=E5=9D=97=E5=B7=B2=E6=8E=88?= =?UTF-8?q?=E6=9D=83Where=E6=9D=A1=E4=BB=B6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 bd770d20..945cffac 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 @@ -440,8 +440,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction protected virtual async Task EnsureModuleAuthorized() { long tid = long.Parse(User.TenantId); - var authStr = await Db.Queryable().Where(x => x.PermissionId == PERMISSION_ID && x.TenantId == tid && - SqlFunc.Subqueryable().Where(spt => spt.PermissionId == x.PermissionId).Any()) + var authStr = await Db.Queryable().ClearFilter(typeof(ITenantId)).Where(x => x.PermissionId == PERMISSION_ID && x.TenantId == tid && + SqlFunc.Subqueryable().Where(spt => spt.PermissionId == x.PermissionId && spt.TenantId == tid).Any()) .Select(x => x.AuthNum).FirstAsync(); if (authStr.IsNullOrEmpty()) return false; From a31a6d5019bb3809dbf206fe16d17b3cc1c908d6 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Mon, 26 Aug 2024 18:02:01 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=BB=93=E6=9D=9FBC=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=B9=B6=E5=88=9B=E5=BB=BA=E4=B8=8B=E4=B8=80=E6=AD=A5=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskPlat/Entity/TaskFlowConfig.cs | 14 ------- .../Interface/ITaskManageBCService.cs | 5 +++ .../TaskPlat/Method/TaskManageBCService.cs | 38 ++++++++++++++++++- .../TaskPlat/Method/TaskManageService.cs | 23 ++++++----- .../TaskPlat/Other/TaskFlowRuner.cs | 2 +- 5 files changed, 57 insertions(+), 25 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowConfig.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowConfig.cs index dfe4f160..e8fcefde 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowConfig.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Entity/TaskFlowConfig.cs @@ -9,7 +9,6 @@ namespace DS.WMS.Core.TaskPlat.Entity [SugarTable("task_flow_config", "任务编排流程表")] public class TaskFlowConfig : BaseModelV2 { - /// /// 流程名称 /// @@ -46,12 +45,6 @@ namespace DS.WMS.Core.TaskPlat.Entity [SugarColumn(ColumnDescription = "下一流程主键", IsNullable = true, Length = 255)] public string? NextConfigId { get; set; } - ///// - ///// 父项流程主键 - ///// - //[SugarColumn(ColumnDescription = "父项流程主键", IsNullable = true)] - //public long? ParentConfigId { get; set; } - /// /// 当执行过程中发生异常时是否继续执行下一个节点 /// @@ -63,12 +56,5 @@ namespace DS.WMS.Core.TaskPlat.Entity /// [SugarColumn(ColumnDescription = "当无匹配的执行流程时是否作为默认的执行流程", IsNullable = false, Length = 1)] public bool IsUnMatchDefault { get; set; } - - /// - /// 当匹配到多项执行流程时是否作为默认的执行流程 - /// - [SugarColumn(ColumnDescription = "当匹配到多项执行流程时是否作为默认的执行流程", IsNullable = false, Length = 1)] - public bool IsMoreMatchDefault { get; set; } } - } \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs index 4af728ad..fb2da657 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageBCService.cs @@ -80,5 +80,10 @@ namespace DS.WMS.Core.TaskPlat.Interface /// 任务主键 /// BC文件 Task UploadBcThenRunTask(string carrierCode, long taskId, IFormFile file); + + /// + /// 结束BC任务并创建下一步任务 + /// + Task BCTaskCompleteThenNext(TaskFlowDataContext dataContext); } } diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs index 5881983c..5bf718d1 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBCService.cs @@ -36,6 +36,8 @@ using System.Net.Http.Headers; using System.Text.RegularExpressions; using System.Text; using System.ComponentModel.DataAnnotations; +using DS.WMS.Core.Op.Interface.TaskInteraction; +using DS.WMS.Core.Op.Dtos.TaskInteraction; namespace DS.WMS.Core.TaskPlat.Method { @@ -1343,7 +1345,7 @@ namespace DS.WMS.Core.TaskPlat.Method var result = await BcMatchSeaExport(taskBcInfo); if (result.Succeeded && result.Data != null) { - dataContext.Set(TaskFlowDataNameConst.BusinessId, result.Data!); + dataContext.Set(TaskFlowDataNameConst.BusinessId, result.Data.Id!); await tenantDb.Updateable() .SetColumns(x => x.BOOKING_ORDER_ID == result.Data.Id) @@ -2760,5 +2762,39 @@ namespace DS.WMS.Core.TaskPlat.Method return DataResult.Successed("上传完成,请审核相关任务及订单状态", MultiLanguageConst.UploadBcThenRunTaskSuccess); } + + /// + /// 结束BC任务并创建下一步任务 + /// + /// 数据上下文 + public async Task BCTaskCompleteThenNext(TaskFlowDataContext dataContext) + { + var businessId = dataContext.Get(TaskFlowDataNameConst.BusinessId); + if (businessId == null || businessId == 0) + { + Logger.Log(NLog.LogLevel.Info, $"执行BCTaskCompleteThenNext时,未获取到businessId:{businessId}"); + return DataResult.Failed("未获取到订单Id"); + } + else + { + var taskService = serviceProvider.GetRequiredService(); + var rlt = await taskService.SetTaskStatusAsync(new TaskUpdateRequest() + { + AutoCreateNext = true, + BusinessId = (long)businessId, + BusinessType = BusinessType.OceanShippingExport, + TaskStatus = TaskStatusEnum.Complete, + TaskTypeName = TaskBaseTypeEnum.WAIT_BC.ToString() + }); + if (rlt.Succeeded) + { + return DataResult.Successed("BC任务已完成,并创建下一步任务"); + } + else + { + return DataResult.Failed(rlt.Message); + } + } + } } } 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 89482c76..ccc93eda 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs @@ -296,7 +296,6 @@ namespace DS.WMS.Core.TaskPlat.Method .WhereIF(info.Main.IsCheckExistsByTaskType, t => t.TASK_TYPE == info.Main.TaskType.ToString()) .OrderByDescending(a => a.Id) .FirstAsync(); - } // 只要任务最后一次处理任务的状态是已取消、已完成,就可以重入新的任务 @@ -2843,17 +2842,23 @@ namespace DS.WMS.Core.TaskPlat.Method var order = await tenantDb.Queryable().Select().FirstAsync(x => x.Id == 1816649497120477184); TaskFlowDataContext dataContext = new( (TaskFlowDataNameConst.Business, order) + //("hasCabin", "false") ); TaskFlowRuner runer = new TaskFlowRuner(tenantDb, serviceProvider); - var result1 = await runer.GetWorkFlowNextConfigByTaskType(TaskBaseTypeEnum.WORK_FLOW_MAIN, dataContext, null); // 首位 - //var result2 = await runer.GetWorkFlowNextConfigByTaskType(TaskBaseTypeEnum.WORK_FLOW_MAIN, dataContext, 20001); // 正常 - //var result3 = await runer.GetWorkFlowNextConfigByTaskType(TaskBaseTypeEnum.WORK_FLOW_MAIN, dataContext, 20002); // 分支判断 - //var result4 = await runer.GetWorkFlowNextConfigByTaskType(TaskBaseTypeEnum.WORK_FLOW_MAIN, dataContext, 20003); // 分支结尾判断 - //var result5 = await runer.GetWorkFlowNextConfigByTaskType(TaskBaseTypeEnum.WORK_FLOW_MAIN, dataContext, 20008); // 末位 - - //var result12 = await runer.GetWorkFlowNextConfigByTaskType(TaskBaseTypeEnum.WORK_FLOW_MAIN, dataContext, null); // 首位 - //var result22 = await runer.GetWorkFlowNextConfigByTaskType(TaskBaseTypeEnum.WORK_FLOW_MAIN, dataContext, TaskBaseTypeEnum.WAIT_BOOKING); // 正常 + + var result22 = await runer.GetWorkFlowNextConfigByTaskType(TaskBaseTypeEnum.WORK_FLOW_MAIN, dataContext, TaskBaseTypeEnum.WAIT_BOOKING); // 正常 + break; + } + + // 结束BC任务并创建下一步任务测试 + case 4: + { + //TaskFlowDataContext dataContext2 = new( + // (TaskFlowDataNameConst.BusinessId, 31232312) + //); + //TaskFlowRuner taskFlow = new TaskFlowRuner(tenantDb, serviceProvider); + //await taskFlow.Run(TaskBaseTypeEnum., taskId, dataContext); break; } } diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs index 14aa8307..7f4c4f26 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Other/TaskFlowRuner.cs @@ -216,7 +216,7 @@ namespace DS.WMS.Core.TaskPlat dataContext.Set(paramItem.FieldName!, paramItem.FieldValue!); } - if (executeConfig.ExecuteModuleId == 0) + if (executeConfig.ExecuteModuleId == 0 || executeConfig.ExecuteModuleId == null) { flowLogDetail.ElapsedMillisecond = 0; flowLogDetail.IsComplete = true; From 1b34462320ff5ab6f6a33308775e2b94a762f910 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Mon, 26 Aug 2024 18:04:14 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9VOLTA=E8=AE=A2=E8=88=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Op/Method/SeaExportBookingOrClosingEDIService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportBookingOrClosingEDIService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportBookingOrClosingEDIService.cs index 7b8762a4..ce8f0dca 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportBookingOrClosingEDIService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportBookingOrClosingEDIService.cs @@ -1245,7 +1245,7 @@ namespace DS.WMS.Core.Op.Method #endregion //INTTRA 订舱时改用交货地来填写到目的地 - if (ediRouteEnum == EDIRouteEnum.INTTRA) + if (ediRouteEnum == EDIRouteEnum.INTTRA || ediRouteEnum == EDIRouteEnum.YT) { #region 目的地 //目的地 From d90258eb2ce0d78c11c6e41ac0ab63efa6f5f8d2 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Tue, 27 Aug 2024 09:13:03 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=A7=9F=E6=88=B7Id=E5=8F=96=E5=80=BC?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DS.Module.SqlSugar/SaasDbService.cs | 2 +- .../DS.Module.SqlSugar/SqlsugarHelper.cs | 2 +- .../DS.Module.SqlSugar/SqlsugarInstall.cs | 24 +++++++++---------- .../Op/Method/TaskInteraction/TaskService.cs | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs b/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs index 4556396e..d8dd61b5 100644 --- a/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs +++ b/ds-wms-service/DS.Module.SqlSugar/SaasDbService.cs @@ -39,7 +39,7 @@ public class SaasDbService : ISaasDbService /// public ISqlSugarClient GetBizDb() { - var tenantId = user.GetTenantId().ToString(); + var tenantId = user.TenantId; if (!db.IsAnyConnection(tenantId)) { diff --git a/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs b/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs index 49724342..c3a1be1e 100644 --- a/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs +++ b/ds-wms-service/DS.Module.SqlSugar/SqlsugarHelper.cs @@ -43,7 +43,7 @@ namespace DS.Module.SqlSugar { var tenantId = ((dynamic)entityInfo.EntityValue).TenantId; if (tenantId == null || tenantId == 0) - entityInfo.SetValue(user.GetTenantId()); + entityInfo.SetValue(user.TenantId); } if (entityInfo.PropertyName == "TenantName") { diff --git a/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs b/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs index 07794e21..60e18c1b 100644 --- a/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs +++ b/ds-wms-service/DS.Module.SqlSugar/SqlsugarInstall.cs @@ -56,7 +56,7 @@ public static class SqlsugarInstall { dbList.Add(item); } - var _serviceProvider =services.GetService(); + var _serviceProvider = services.GetService(); ICacheService myCache = new SqlSugarCsRedisCache(_serviceProvider); var connectConfigList = SqlsugarHelper.ReturnConnectionConfig(dbList, myCache); @@ -97,7 +97,7 @@ public static class SqlsugarInstall OrgId = 1288018625843826688 }; } - + //全局上下文生效 SqlSugarScope sqlSugar = new SqlSugarScope(connectConfigList, db => @@ -108,7 +108,7 @@ public static class SqlsugarInstall foreach (var c in connectConfigList) { var dbProvider = db.GetConnectionScope((string)c.ConfigId); - + // var user = services.GetService(); //单例参数配置,所有上下文生效 @@ -178,7 +178,7 @@ public static class SqlsugarInstall { var tenantId = ((dynamic)entityInfo.EntityValue).TenantId; if (tenantId == null || tenantId == 0) - entityInfo.SetValue(user.GetTenantId()); + entityInfo.SetValue(user.TenantId); } if (entityInfo.PropertyName == "TenantName") { @@ -215,7 +215,7 @@ public static class SqlsugarInstall } } if (entityInfo.PropertyName == "Deleted") - entityInfo.SetValue(false); + entityInfo.SetValue(false); } // 更新操作 @@ -234,7 +234,7 @@ public static class SqlsugarInstall entityInfo.SetValue(user.UserId); if (entityInfo.PropertyName == "DeleteUserName" && user != null) entityInfo.SetValue(user.UserName); - } + } }; dbProvider.Aop.OnDiffLogEvent = it => @@ -253,13 +253,13 @@ public static class SqlsugarInstall var time = it.Time; var diffType = it.DiffType; //enum insert 、update and delete - var diffData = SqlSugarDiffUtil.GetDiff(editBeforeData,editAfterData); - + var diffData = SqlSugarDiffUtil.GetDiff(editBeforeData, editAfterData); + var auditData = new SysLogAudit() { - KeyId =Convert.ToInt64(diffData.Id), + KeyId = Convert.ToInt64(diffData.Id), Sql = it.Sql, - Param = JsonConvert.SerializeObject(it.Parameters), + Param = JsonConvert.SerializeObject(it.Parameters), OperateType = diffType.ToString(), OldValue = JsonConvert.SerializeObject(editBeforeData), NewValue = JsonConvert.SerializeObject(editAfterData), @@ -270,10 +270,10 @@ public static class SqlsugarInstall db.GetConnection(1288018625843826680).Insertable(auditData).ExecuteCommand(); #endregion } - + }; //全局过滤租户 - dbProvider.QueryFilter.AddTableFilter(m => m.TenantId == user.GetTenantId()); + dbProvider.QueryFilter.AddTableFilter(m => m.TenantId == long.Parse(user.TenantId)); //全局过滤机构Id dbProvider.QueryFilter.AddTableFilter(m => m.OrgId == user.OrgId); //全局软删除过滤 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 c5b0ad03..ad912ad0 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 @@ -448,8 +448,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction protected virtual async Task EnsureModuleAuthorized() { long tid = long.Parse(User.TenantId); - var authStr = await Db.Queryable().ClearFilter(typeof(ITenantId)).Where(x => x.PermissionId == PERMISSION_ID && x.TenantId == tid && - SqlFunc.Subqueryable().Where(spt => spt.PermissionId == x.PermissionId && spt.TenantId == tid).Any()) + var authStr = await Db.Queryable().Where(x => x.PermissionId == PERMISSION_ID && x.TenantId == tid && + SqlFunc.Subqueryable().Where(spt => spt.PermissionId == x.PermissionId).Any()) .Select(x => x.AuthNum).FirstAsync(); if (authStr.IsNullOrEmpty()) return false;