diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageService.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageService.cs index e21ee3c1..a9c38ee5 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageService.cs @@ -122,5 +122,12 @@ namespace DS.WMS.Core.TaskPlat.Interface /// 获取任务是否生成的配置列表 /// Task>> GetCreateTaskConfigList(); + /// + /// 工作流设置任务对象属性(批量) + /// + /// 主任务业务主键列表 + /// 主任务业务类型 + /// 要修改的列 + Task SetTaskBaseInfoPropertyWithBsno(List bsnoList, TaskBaseTypeEnum taskBaseTypeEnum, params Expression>[] columns); } } 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 96f1dc25..335e5a4f 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs @@ -33,6 +33,8 @@ using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SqlSugar; +using System.Collections.Generic; +using System.Linq; using System.Linq.Expressions; @@ -452,6 +454,54 @@ namespace DS.WMS.Core.TaskPlat.Method return DataResult.Successed("操作成功"); } + + /// + /// 工作流设置任务对象属性(批量) + /// + /// 主任务业务主键列表 + /// 主任务业务类型 + /// 要修改的列 + public async Task SetTaskBaseInfoPropertyWithBsno(List bsnoList, TaskBaseTypeEnum taskBaseTypeEnum, params Expression>[] columns) + { + bsnoList = bsnoList ?? []; + + var bsnoStr = string.Join(',', bsnoList ?? []); + + logger.LogInformation($"SetTaskBaseInfoPropertyWithBsno 批量 bsno={bsnoStr};taskBaseTypeEnum={taskBaseTypeEnum};"); + SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId); + + var taskTypeStr = taskBaseTypeEnum.ToString(); + + var taskInfoIdList = await tenantDb.Queryable().ClearFilter(typeof(IOrgId)) + .OrderByDescending(a => a.Id) + .Where(t => bsnoList.Contains((long)t.OUT_BS_NO!) && t.TASK_TYPE == taskTypeStr) + .Select(t => t.Id) + .ToListAsync(); + + if (taskInfoIdList == null || taskInfoIdList.Count == 0) + { + logger.LogInformation($"根据bsno列表:【{string.Join(',', bsnoList ?? [])}】,TaskBaseTypeEnum:【{taskBaseTypeEnum}】未查询到任务"); + return DataResult.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.DataQueryNoData))); + } + else + { + logger.LogInformation($"根据bsno列表:【{bsnoStr}】,查询出taskInfoId=【{(string.Join(',', taskInfoIdList))}】"); + } + + var updateable = tenantDb.Updateable(); + foreach (var item in columns) + { + updateable.SetColumns(item); + } + updateable.SetColumns(x => x.UpdateBy == long.Parse(user.UserId)) + .SetColumns(x => x.UpdateTime == DateTime.Now) + .SetColumns(x => x.UpdateUserName == user.UserName); + + await updateable.Where(x => taskInfoIdList.Contains(x.Id)) + .ExecuteCommandAsync(); + + return DataResult.Successed("操作成功"); + } #endregion @@ -4423,7 +4473,13 @@ namespace DS.WMS.Core.TaskPlat.Method { //await serviceProvider.GetRequiredService var taskTypeEnum = (TaskBaseTypeEnum)Enum.Parse(typeof(TaskBaseTypeEnum), taskType); - await SetTaskBaseInfoPropertyWithBsno(taskId, taskTypeEnum, null, null, x => x.TASK_DESP == content); + //await SetTaskBaseInfoPropertyWithBsno(taskId, taskTypeEnum, null, null, x => x.TASK_DESP == content); + await SetTaskBaseInfoPropertyWithBsno(new List() { 111, 222 }, taskTypeEnum, x => x.TASK_DESP == content); + break; + } + case 9: + { + break; } }