From 749f6e6968b3d8688bd828c46bdb95ed4491f967 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Sat, 3 Aug 2024 18:55:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8F=B0=E5=8F=B0=E8=B4=A6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskPlat/Dtos/TaskManageDtos.cs | 10 +++ .../TaskPlat/Interface/ITaskManageService.cs | 3 +- .../TaskPlat/Method/TaskManageBaseService.cs | 35 +++++----- .../TaskPlat/Method/TaskManageService.cs | 64 +++++++++++-------- .../DS.WMS.MainApi/DS.WMS.MainApi.csproj.user | 2 +- .../Controllers/TaskManageController.cs | 5 +- 6 files changed, 69 insertions(+), 50 deletions(-) create mode 100644 ds-wms-service/DS.WMS.Core/TaskPlat/Dtos/TaskManageDtos.cs diff --git a/ds-wms-service/DS.WMS.Core/TaskPlat/Dtos/TaskManageDtos.cs b/ds-wms-service/DS.WMS.Core/TaskPlat/Dtos/TaskManageDtos.cs new file mode 100644 index 00000000..17750233 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Dtos/TaskManageDtos.cs @@ -0,0 +1,10 @@ +namespace DS.WMS.Core.TaskPlat.Dtos +{ + public class GetCurrentTotalStatQueryDto + { + /// + /// 查询条件 + /// + public string QueryCondition { get; set; } = string.Empty; + } +} 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 c9b59734..040efa42 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Interface/ITaskManageService.cs @@ -24,9 +24,8 @@ namespace DS.WMS.Core.TaskPlat.Interface /// /// 获取登陆人相关的任务统计信息 /// - /// 是否强制计算 /// 返回回执 - Task> GetCurrentTotalStat(bool isReCalc); + Task> GetCurrentTotalStat(GetCurrentTotalStatQueryDto querySearch); /// /// 任务台台账列表查询 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 433f84f9..5f704ab0 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBaseService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageBaseService.cs @@ -375,22 +375,25 @@ namespace DS.WMS.Core.TaskPlat.Method // 查出涉及到的订单 var seaExportList = await tenantDb.Queryable() - .Where(x => waitQuerySeaExportWithMblnoList.Contains(x.MBLNO) && x.ParentId == 0) - .Select(x => new - { - x.Id, - x.MBLNO, - x.OperatorId, - x.OperatorName, - x.Doc, - x.DocName, - x.SaleId, - x.Sale, - x.CustomerService, - x.CustomerServiceName, - x.ForeignCustomerService, - x.ForeignCustomerServiceName - }).ToListAsync(); + .Where(x => x.ParentId == 0 + && ( + (x.SplitOrMergeFlag != 0 && waitQuerySeaExportWithMblnoList.Contains(x.MBLNO)) + || (x.SplitOrMergeFlag == 1 && waitQuerySeaExportWithMblnoList.Contains(x.BookingNo)) + )).Select(x => new + { + x.Id, + x.MBLNO, + x.OperatorId, + x.OperatorName, + x.Doc, + x.DocName, + x.SaleId, + x.Sale, + x.CustomerService, + x.CustomerServiceName, + x.ForeignCustomerService, + x.ForeignCustomerServiceName + }).ToListAsync(); foreach (var item in allotData) { 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 a8aa1e4e..69514e37 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs @@ -36,6 +36,11 @@ namespace DS.WMS.Core.TaskPlat.Method // 按需构建 + /// + /// 上一次进行全局任务匹配的时间 + /// + public static DateTime LastMatchTaskTime = DateTime.Now; + public TaskManageService(IUser user, ILogger logger, ISaasDbService saasDbService, @@ -2125,45 +2130,20 @@ namespace DS.WMS.Core.TaskPlat.Method /// /// 获取登陆人相关的任务统计信息 /// - /// 是否强制计算 /// 返回回执 - public async Task> GetCurrentTotalStat(bool isReCalc) + public async Task> GetCurrentTotalStat(GetCurrentTotalStatQueryDto querySearch) { - TaskUserStatResultInfo resultInfo = new TaskUserStatResultInfo { LevelTop = new List(), LevelNext = new List(), LevelTree = new List() }; - - /* - 1、首先判断当前登陆人是否有统计记录,如果没有触发统计生成统计记录。 - 2、如果isReCalc=true,表示强制重新统计数据,并重新更新统计数据。 - 3、按照统计类型(个人/公共)、任务状态、是否异常分组汇总,并写入统计表。 - */ - - //var userTendInfo = await _sysUserRepository.AsQueryable() - // .LeftJoin((usr, ten) => usr.TenantId == ten.Id) - // .Where(usr => usr.Id == UserManager.UserId) - // .Select((usr, ten) => new { User = usr, Tend = ten }).FirstAsync(); - - //if (userTendInfo == null) - // throw Oops.Oh($"当前用户关联租户信息获取失败"); - - ////var statList = _taskStatManageInfoRepository.AsQueryable().Where(t => (t.USER_ID == userTendInfo.User.Id - ////&& t.STAT_TYPE == TaskStatLevelEnum.PERSON.ToString()) || (t.COMP_ID == userTendInfo.Tend.Id && t.STAT_TYPE == TaskStatLevelEnum.PUBLIC.ToString())).ToList(); - - ////菜单375504048771141=我的任务台账 - //List userlist = await _sysDataUserMenuService.GetDataScopeList(MenuConst.MenuTaskManage); - - //bool isAdmin = userlist == null; - var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId); + // 人员信息测试用 //var sql = tenantDb.Queryable().Where(x => x.Id > 232).ToSqlString(); - //var a = user.UserId; //var aa = user.TenantId; //var a343 = user.GetTenantId(); @@ -2171,12 +2151,40 @@ namespace DS.WMS.Core.TaskPlat.Method //var b = user.GetOrgId(); //var b232 = user.OrgId; - //await MatchTask(); + // 任务匹配 + if (LastMatchTaskTime < DateTime.Now.AddSeconds(-5)) // 效果:距上一次全局任务匹配执行如果超过5秒,才进行匹配 + { + await MatchTask(); + LastMatchTaskTime = DateTime.Now; + } + + + //序列化查询条件 + List? whereList = null; + 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; + } + } + } + } + } var userId = long.Parse(user.UserId); //任务列表分组统计 var groupList = await tenantDb.Queryable() .LeftJoin((t, a) => t.Id == a.TaskId) + .Where(whereList) .Where((t, a) => t.IS_PUBLIC == 1 || (t.IS_PUBLIC == 0 && a.Status != null && (t.CreateBy == userId || a.UserId == userId))) .GroupBy((t, a) => new { t.TASK_TYPE, t.STATUS, a.Status, t.IS_PUBLIC }) .Select((t, a) => new diff --git a/ds-wms-service/DS.WMS.MainApi/DS.WMS.MainApi.csproj.user b/ds-wms-service/DS.WMS.MainApi/DS.WMS.MainApi.csproj.user index 996c16b7..d9493e7a 100644 --- a/ds-wms-service/DS.WMS.MainApi/DS.WMS.MainApi.csproj.user +++ b/ds-wms-service/DS.WMS.MainApi/DS.WMS.MainApi.csproj.user @@ -1,6 +1,6 @@  - D:\Code\DS\ds8-solution-pro\ds-wms-service\DS.WMS.MainApi\Properties\PublishProfiles\FolderProfile.pubxml + D:\Code\ds8-solution-pro\ds-wms-service\DS.WMS.MainApi\Properties\PublishProfiles\FolderProfile1.pubxml \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageController.cs b/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageController.cs index 5b1edc8a..c4f78192 100644 --- a/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageController.cs +++ b/ds-wms-service/DS.WMS.TaskApi/Controllers/TaskManageController.cs @@ -102,11 +102,10 @@ public class TaskManageController : ApiController /// /// 获取登陆人相关的任务统计信息 /// - /// 是否强制计算 [HttpPost("GetCurrentTotalStat")] - public async Task> GetCurrentTotalStat([FromQuery] bool isReCalc = false) + public async Task> GetCurrentTotalStat(GetCurrentTotalStatQueryDto querySearch) { - var result = await taskManageService.GetCurrentTotalStat(isReCalc); + var result = await taskManageService.GetCurrentTotalStat(querySearch); return result; }