From 00c5659409541a4c952b0f6f011492889473da90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Sat, 12 Oct 2024 11:08:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B4=B9=E7=94=A8=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E8=AE=BE=E7=BD=AE=E4=BB=BB=E5=8A=A1=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Info/Method/ClientInfoService.cs | 1 + .../Op/Method/TaskInteraction/TaskService.cs | 115 +++++++++++------- 2 files changed, 71 insertions(+), 45 deletions(-) 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 4412cecd..249ba1eb 100644 --- a/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs +++ b/ds-wms-service/DS.WMS.Core/Info/Method/ClientInfoService.cs @@ -574,6 +574,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService var result = DataResult.Failed("客户信息已存在,请检查客户全称/简称是否重复!", MultiLanguageConst.ClientInfoExist); result.Code = ResultCode.Fail; result.Data = client; + return result; } TenantDb.QueryFilter.Restore(); 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 092e7fa5..310c8df9 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 @@ -3,7 +3,7 @@ using DS.Module.Core; using DS.Module.Core.Data; using DS.Module.Core.Helpers; using DS.Module.DjyRulesEngine; -using DS.WMS.Core.Application.Dtos; +using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Flow.Dtos; using DS.WMS.Core.Flow.Entity; using DS.WMS.Core.Flow.Interface; @@ -24,7 +24,6 @@ using Masuit.Tools; using Masuit.Tools.Systems; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Newtonsoft.Json; using SqlSugar; namespace DS.WMS.Core.Op.Method.TaskInteraction @@ -46,6 +45,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction /// static readonly TaskBaseTypeEnum[] AuditTaskTypesManualReject; + internal static readonly TaskBaseTypeEnum[] FeeTypes = [TaskBaseTypeEnum.FEE_AUDIT, TaskBaseTypeEnum.FEE_MODIFY_AUDIT, TaskBaseTypeEnum.FEE_DELETE_AUDIT]; + static readonly ApiFox Api; static TaskService() @@ -331,9 +332,35 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction } info.Main.TaskDesp = info.Main.TaskDesp ?? info.Main.TaskTitle; - result = await ManagerService.InitTaskJob(info); - if (!result.Succeeded) - return result; + //费用审核且多个接收人需拆分任务 + if (FeeTypes.Contains(request.TaskType) && info.Main.RecvUserInfoList.Count > 1) + { + var fee = await TenantDb.Queryable().Where(x => x.Id == request.BusinessId) + .Select(x => new + { + x.BusinessId, + x.BusinessType + }).FirstAsync(); + var recvUserList = new List(info.Main.RecvUserInfoList); //复制接收人列表 + foreach (var item in recvUserList) + { + var copiedInfo = info.DeepClone(); + copiedInfo.Head.BSNO = fee.BusinessId; //替换为费用关联的订单ID + + copiedInfo.Main.RecvUserInfoList.Clear(); + copiedInfo.Main.RecvUserInfoList.Add(item); + + result = await ManagerService.InitTaskJob(info); + if (!result.Succeeded) + return result; + } + } + else + { + result = await ManagerService.InitTaskJob(info); + if (!result.Succeeded) + return result; + } task = new BusinessTask { @@ -492,10 +519,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction //if (task.TaskStatus == TaskStatusEnum.Cancel) // return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCancelled)); - var result = await ManagerService.SetTaskStatusWithBsno(request.BusinessId, request.TaskType, request.TaskStatus, DateTime.Now, request.TaskDesc); - if (!result.Succeeded) - return DataResult.Failed(result.Message, result.MultiCode); - //触发任务状态变更通知 if (task.TaskStatus != request.TaskStatus) await OnTaskStatusChanged(request); @@ -505,6 +528,43 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction task.TaskStatus = request.TaskStatus; await TenantDb.Updateable(task).UpdateColumns(x => new { x.TaskStatus, x.RejectReason }).ExecuteCommandAsync(); + DataResult result; + if (FeeTypes.Contains(request.TaskType)) + { + var fee = await TenantDb.Queryable().Where(x => x.Id == request.BusinessId) + .Select(x => new + { + x.BusinessId, + x.BusinessType + }).FirstAsync(); + + var relativeTasks = await TenantDb.Queryable() + .InnerJoin((t, f) => t.BusinessId == f.Id) + .Where((t, f) => f.BusinessId == fee.BusinessId && f.BusinessType == fee.BusinessType && FeeTypes.Contains(t.TaskType) && t.RecvUsers.Contains(User.UserId)) + .Select((t, f) => new + { + t.Id, + t.BusinessId, + t.TaskType, + t.TaskStatus, + t.RecvUsers + }).ToListAsync(); + + var groups = relativeTasks.GroupBy(x => x.TaskStatus).Select(x => x.Key).ToList(); + if (groups.Count == 1 && groups.All(x => x == request.TaskStatus)) + { + result = await ManagerService.SetTaskStatusWithBsno(request.BusinessId, request.TaskType, request.TaskStatus, DateTime.Now, request.TaskDesc); + if (!result.Succeeded) + return DataResult.Failed(result.Message, result.MultiCode); + } + } + else + { + result = await ManagerService.SetTaskStatusWithBsno(request.BusinessId, request.TaskType, request.TaskStatus, DateTime.Now, request.TaskDesc); + if (!result.Succeeded) + return DataResult.Failed(result.Message, result.MultiCode); + } + if (task.TaskStatus == TaskStatusEnum.Complete && task.NextType.HasValue && request.AutoCreateNext) { //存在下一任务,则继续创建 @@ -612,7 +672,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction } /// - /// 发起任务审核 + /// 重新发起任务审核 /// /// /// 是否使用事务 @@ -845,28 +905,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction //根据审批结果更新任务状态 await SetTaskStatusAsync(req); - ////终审通过且任务类型为审单,则生成费用 - //if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT && instance.IsCompleted) - //{ - // UriBuilder builder = new(configuration["FeeService:BaseUrl"]) - // { - // Path = configuration["FeeService:GenerateFees"] - // }; - // string url = builder.ToString(); - // if (string.IsNullOrEmpty(url)) - // { - // await LogService.WriteLogAsync(req, "未在配置文件中配置费用服务URL,无法根据费用模板生成费用"); - // continue; - // } - - // string json = JsonConvert.SerializeObject(new BizItem - // { - // Id = req.BusinessId, - // BusinessType = req.BusinessType.GetValueOrDefault() - // }); - // Api.SendRequestAsync(HttpMethod.Post, url, json); - //} - if (instance.FlowStatus == FlowStatusEnum.Reject) result.Message = MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskRejected)); @@ -1064,19 +1102,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction .WhereIF(taskTypes != null && taskTypes.Length > 0, x => taskTypes.Contains(x.TaskType)); } - /// - /// 获取指定业务ID的任务 - /// - /// 任务类型 - /// 业务类型 - /// 业务ID - /// - protected internal ISugarQueryable GetQuery(TaskBaseTypeEnum taskType, BusinessType? businessType, params long[] ids) - { - return TenantDb.Queryable().Where(x => x.TaskType == taskType && ids.Contains(x.BusinessId)) - .WhereIF(businessType.HasValue, x => x.BusinessType == businessType); - } - /// /// 从任务配置中获取接收用户列表 /// From ace1d26afd73e4ebc218cbbf0bb003c5223521d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Sat, 12 Oct 2024 11:27:49 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E5=B9=B2=E7=B3=BB=E4=BA=BA=E5=B9=B6=E6=8F=90=E4=BA=A4=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interface/IClientStakeholderService.cs | 7 +++++++ .../Info/Method/ClientStakeholderService.cs | 10 ++++++++++ .../ClientStakeholderController.cs | 20 +++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/ds-wms-service/DS.WMS.Core/Info/Interface/IClientStakeholderService.cs b/ds-wms-service/DS.WMS.Core/Info/Interface/IClientStakeholderService.cs index f898787c..2f687e88 100644 --- a/ds-wms-service/DS.WMS.Core/Info/Interface/IClientStakeholderService.cs +++ b/ds-wms-service/DS.WMS.Core/Info/Interface/IClientStakeholderService.cs @@ -59,5 +59,12 @@ namespace DS.WMS.Core.Info.Interface /// 干系人 /// Task EditAsync(InfoClientStakeholder stakeholder); + + /// + /// 创建客户干系人并提交审核 + /// + /// 干系人 + /// + Task AddSubmitAsync(InfoClientStakeholder stakeholder); } } diff --git a/ds-wms-service/DS.WMS.Core/Info/Method/ClientStakeholderService.cs b/ds-wms-service/DS.WMS.Core/Info/Method/ClientStakeholderService.cs index 78b6110e..ffafae2b 100644 --- a/ds-wms-service/DS.WMS.Core/Info/Method/ClientStakeholderService.cs +++ b/ds-wms-service/DS.WMS.Core/Info/Method/ClientStakeholderService.cs @@ -271,5 +271,15 @@ namespace DS.WMS.Core.Info.Method return result; } + /// + /// 创建客户干系人并提交审核 + /// + /// 干系人 + /// + public async Task AddSubmitAsync(InfoClientStakeholder stakeholder) + { + await TenantDb.Insertable(stakeholder).ExecuteCommandAsync(); + return await SubmitAuditAsync(new IdModel { Id = stakeholder.Id.ToString(), Ids = [stakeholder.Id] }); + } } } diff --git a/ds-wms-service/DS.WMS.MainApi/Controllers/ClientStakeholderController.cs b/ds-wms-service/DS.WMS.MainApi/Controllers/ClientStakeholderController.cs index 3581d1e3..60b87482 100644 --- a/ds-wms-service/DS.WMS.MainApi/Controllers/ClientStakeholderController.cs +++ b/ds-wms-service/DS.WMS.MainApi/Controllers/ClientStakeholderController.cs @@ -103,6 +103,26 @@ namespace DS.WMS.MainApi.Controllers return await _invokeService.GetAsync(id); } + /// + /// 创建客户干系人并提交审核 + /// + /// 客户ID + /// + [HttpPost, Route("CreateSubmit")] + public async Task AddSubmitAsync(long clientId) + { + var date = DateTime.Now.Date; + return await _invokeService.AddSubmitAsync(new InfoClientStakeholder + { + ClientId = clientId, + CreateBy = long.Parse(_user.UserId), + CreateByName = _user.UserName, + StartDate = date, + EndDate = date.AddMonths(4), + Status = StakeholderStatus.Uncommitted + }); + } + /// /// 新增客户干系人 ///