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 cf5f9781..cf8014ff 100644 --- a/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs +++ b/ds-wms-service/DS.WMS.Core/TaskPlat/Method/TaskManageService.cs @@ -2077,7 +2077,9 @@ namespace DS.WMS.Core.TaskPlat.Method bc.PROCESS_DATE, bc.PRICE_CALCULATION_DATE }).Distinct(); +#if DEBUG var sql = queryableTemp.ToSqlString(); +#endif result = await queryableTemp.ToQueryPageAsync(querySearch.PageCondition); return result; @@ -2620,9 +2622,9 @@ namespace DS.WMS.Core.TaskPlat.Method s.CntrTotal, }).Distinct(); - +#if DEBUG var sql = queryableTemp.ToSqlString(); - +#endif result = await queryableTemp.ToQueryPageAsync(querySearch.PageCondition); return result; @@ -2723,21 +2725,28 @@ namespace DS.WMS.Core.TaskPlat.Method var taskTypeStr = taskType.ToString(); var taskStatusStr = TaskStatusEnum.Cancel.ToString(); - long? parentId = null; + List? orderParentIdList = null; if (!string.IsNullOrEmpty(queryDto.BusinessNo)) { - var parentIdTemp = await queryable.Context.Queryable().ClearFilter(typeof(IOrgId)).Where(x => x.HBLNO == queryDto.BusinessNo).Select(x => x.ParentId).FirstAsync(); - parentId = parentIdTemp == 0 ? null : parentIdTemp; + orderParentIdList = (await queryable.Context.Queryable() + .ClearFilter(typeof(IOrgId)) + .Where(x => x.ParentId != 0 && x.HBLNO.Contains(queryDto.BusinessNo)) + .Select(x => x.ParentId) + .ToListAsync()) + .Distinct().ToList(); ; } + var isHasOrderParentIdList = orderParentIdList != null; + queryable.Where(whereList) .Where((t, a) => t.STATUS != taskStatusStr && t.Deleted == false) .WhereIF(taskType != null, (t, a) => t.TASK_TYPE == taskTypeStr) - .WhereIF(!string.IsNullOrEmpty(queryDto.BusinessNo), (t, a, bc, s) => ((t.MBL_NO != null && queryDto.BusinessNo == t.MBL_NO) || (s.MBLNO != null && queryDto.BusinessNo == s.MBLNO)) - || queryDto.BusinessNo == s.CustomerNo - || queryDto.BusinessNo == s.BookingNo - || queryDto.BusinessNo == s.CustomerNum - || (parentId != null && s.Id == parentId)) + .WhereIF(!string.IsNullOrEmpty(queryDto.BusinessNo), (t, a, bc, s) => ((!string.IsNullOrEmpty(s.MBLNO) && s.MBLNO.Contains(queryDto.BusinessNo)) || (string.IsNullOrEmpty(s.MBLNO) && t.MBL_NO.Contains(queryDto.BusinessNo))) // 如果订单提单号不为空使用订单提单号查询,否则使用任务上的提单号查询 + || s.CustomerNo.Contains(queryDto.BusinessNo) + || s.BookingNo.Contains(queryDto.BusinessNo) + || s.CustomerNum.Contains(queryDto.BusinessNo) + || t.TASK_NO.Contains(queryDto.BusinessNo) + || (isHasOrderParentIdList == true && orderParentIdList!.Contains(s.Id))) .WhereIF(taskStatLevel == TaskStatLevelEnum.PUBLIC, (t, a) => t.IS_PUBLIC == 1 && t.STATUS == queryDto.Status) .WhereIF(taskStatLevel == TaskStatLevelEnum.PERSON, (t, a) => t.IS_PUBLIC == 0 && (a.UserId == userId) // 2024-8-14 只显示自己需要审批的任务,自己创建的任务不显示,所以去掉t.CreateBy == userId || @@ -2787,25 +2796,31 @@ namespace DS.WMS.Core.TaskPlat.Method var userId = long.Parse(user.UserId); queryable.ClearFilter(typeof(IOrgId)); - long? parentId = null; + List? orderParentIdList = null; var taskTypeStr = taskType.ToString(); var taskStatusStr = TaskStatusEnum.Cancel.ToString(); if (!string.IsNullOrEmpty(queryDto.BusinessNo)) { - var parentIdTemp = await queryable.Context.Queryable().ClearFilter(typeof(IOrgId)).Where(x => x.HBLNO == queryDto.BusinessNo).Select(x => x.ParentId).FirstAsync(); - parentId = parentIdTemp == 0 ? null : parentIdTemp; + orderParentIdList = (await queryable.Context.Queryable() + .ClearFilter(typeof(IOrgId)) + .Where(x => x.ParentId != 0 && x.HBLNO.Contains(queryDto.BusinessNo)) + .Select(x => x.ParentId) + .ToListAsync()) + .Distinct().ToList(); } + var isHasOrderParentIdList = orderParentIdList != null; queryable.Where(whereList) .Where((t, a) => t.STATUS != taskStatusStr && t.Deleted == false) .WhereIF(taskType != null, (t, a) => t.TASK_TYPE == taskTypeStr) - .WhereIF(!string.IsNullOrEmpty(queryDto.BusinessNo), (t, a, s) => ((!string.IsNullOrEmpty(s.MBLNO) && queryDto.BusinessNo == s.MBLNO) || (string.IsNullOrEmpty(s.MBLNO) && queryDto.BusinessNo == t.MBL_NO)) - || queryDto.BusinessNo == s.CustomerNo - || queryDto.BusinessNo == s.CustomerNum - || queryDto.BusinessNo == s.BookingNo - || (parentId != null && s.Id == parentId)) + .WhereIF(!string.IsNullOrEmpty(queryDto.BusinessNo), (t, a, s) => ((!string.IsNullOrEmpty(s.MBLNO) && s.MBLNO.Contains(queryDto.BusinessNo)) || (string.IsNullOrEmpty(s.MBLNO) && t.MBL_NO.Contains(queryDto.BusinessNo))) // 如果订单提单号不为空使用订单提单号查询,否则使用任务上的提单号查询 + || s.CustomerNo.Contains(queryDto.BusinessNo) + || s.CustomerNum.Contains(queryDto.BusinessNo) + || s.BookingNo.Contains(queryDto.BusinessNo) + || t.TASK_NO.Contains(queryDto.BusinessNo) + || (isHasOrderParentIdList == true && orderParentIdList!.Contains(s.Id))) .WhereIF(!string.IsNullOrEmpty(queryDto.PortLoadCode), (t, a, s) => queryDto.PortLoadCode == s.LoadPortCode) .WhereIF(!string.IsNullOrEmpty(queryDto.PortDischargeCode), (t, a, s) => queryDto.PortDischargeCode == s.DischargePortCode) @@ -2913,12 +2928,17 @@ namespace DS.WMS.Core.TaskPlat.Method var userId = long.Parse(user.UserId); var cancelStr = TaskStatusEnum.Cancel.ToString(); - long? parentId = null; + List? orderParentIdList = null; if (!string.IsNullOrEmpty(queryDto.OtherQueryCondition.BusinessNo)) { - var parentIdTemp = await tenantDb.Queryable().ClearFilter(typeof(IOrgId)).Where(x => x.HBLNO == queryDto.OtherQueryCondition.BusinessNo).Select(x => x.ParentId).FirstAsync(); - parentId = parentIdTemp == 0 ? null : parentIdTemp; + orderParentIdList = (await tenantDb.Queryable() + .ClearFilter(typeof(IOrgId)) + .Where(x => x.ParentId != 0 && x.HBLNO.Contains(queryDto.OtherQueryCondition.BusinessNo)) + .Select(x => x.ParentId) + .ToListAsync()) + .Distinct().ToList(); } + var isHasOrderParentIdList = orderParentIdList != null; long[]? portLoadTaskIdList = []; if (!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortLoadCode)) @@ -2974,11 +2994,12 @@ namespace DS.WMS.Core.TaskPlat.Method .LeftJoin((a, t, s) => t.OUT_BS_NO == s.Id) .Where(whereList) .WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.BusinessNo), - (a, t, s) => ((!string.IsNullOrEmpty(s.MBLNO) && queryDto.OtherQueryCondition.BusinessNo == s.MBLNO) || (string.IsNullOrEmpty(s.MBLNO) && queryDto.OtherQueryCondition.BusinessNo == t.MBL_NO)) - || queryDto.OtherQueryCondition.BusinessNo == s.CustomerNo - || queryDto.OtherQueryCondition.BusinessNo == s.BookingNo - || queryDto.OtherQueryCondition.BusinessNo == s.CustomerNum - || (parentId != null && s.Id == parentId)) + (a, t, s) => ((!string.IsNullOrEmpty(s.MBLNO) && s.MBLNO.Contains(queryDto.OtherQueryCondition.BusinessNo)) || (string.IsNullOrEmpty(s.MBLNO) && t.MBL_NO.Contains(queryDto.OtherQueryCondition.BusinessNo))) // 如果订单提单号不为空使用订单提单号查询,否则使用任务上的提单号查询 + || s.CustomerNo.Contains(queryDto.OtherQueryCondition.BusinessNo) + || s.BookingNo.Contains(queryDto.OtherQueryCondition.BusinessNo) + || s.CustomerNum.Contains(queryDto.OtherQueryCondition.BusinessNo) + || t.TASK_NO.Contains(queryDto.OtherQueryCondition.BusinessNo) + || (isHasOrderParentIdList == true && orderParentIdList!.Contains(s.Id))) .WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortLoadCode), (t, a, s) => queryDto.OtherQueryCondition.PortLoadCode == s.LoadPortCode || portLoadTaskIdList.Contains(t.Id)) .WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortDischargeCode), (t, a, s) => queryDto.OtherQueryCondition.PortDischargeCode == s.DischargePortCode || portDischargeTaskIdList.Contains(t.Id)) .GroupBy((a, t) => new { t.TASK_TYPE, t.STATUS, a.Status, }) @@ -2989,7 +3010,9 @@ namespace DS.WMS.Core.TaskPlat.Method TStatus = t.STATUS, AStatus = a.Status }); +#if DEBUG var sql2 = underlingQueryable.ToSqlString(); +#endif underlingGroupList = await underlingQueryable.ToListAsync(); #region 下属 @@ -3069,16 +3092,16 @@ namespace DS.WMS.Core.TaskPlat.Method .LeftJoin((t, a, s) => t.OUT_BS_NO == s.Id) .Where(whereList) .Where((t, a) => t.STATUS != cancelStr && t.Deleted == false) - .Where((t, a) => t.IS_PUBLIC == 1 || (t.IS_PUBLIC == 0 && a.Status != null && (a.UserId == userId))) // 2024-8-14 只显示自己需要审批的任务,自己创建的任务不显示,所以去掉t.CreateBy == userId || + .Where((t, a) => t.IS_PUBLIC == 1 || (t.IS_PUBLIC == 0 && a.UserId == userId)) // 2024-8-14 只显示自己需要审批的任务,自己创建的任务不显示,所以去掉t.CreateBy == userId || .WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.BusinessNo), - (t, a, s) => ((!string.IsNullOrEmpty(s.MBLNO) && queryDto.OtherQueryCondition.BusinessNo == s.MBLNO) || (string.IsNullOrEmpty(s.MBLNO) && queryDto.OtherQueryCondition.BusinessNo == t.MBL_NO)) - || queryDto.OtherQueryCondition.BusinessNo == s.CustomerNo - || queryDto.OtherQueryCondition.BusinessNo == s.BookingNo - || queryDto.OtherQueryCondition.BusinessNo == s.CustomerNum - || (parentId != null && s.Id == parentId)) + (t, a, s) => ((!string.IsNullOrEmpty(s.MBLNO) && s.MBLNO.Contains(queryDto.OtherQueryCondition.BusinessNo)) || (string.IsNullOrEmpty(s.MBLNO) && t.MBL_NO.Contains(queryDto.OtherQueryCondition.BusinessNo))) // 如果订单提单号不为空使用订单提单号查询,否则使用任务上的提单号查询 + || s.CustomerNo.Contains(queryDto.OtherQueryCondition.BusinessNo) + || s.BookingNo.Contains(queryDto.OtherQueryCondition.BusinessNo) + || s.CustomerNum.Contains(queryDto.OtherQueryCondition.BusinessNo) + || t.TASK_NO.Contains(queryDto.OtherQueryCondition.BusinessNo) + || (isHasOrderParentIdList == true && orderParentIdList!.Contains(s.Id))) .WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortLoadCode), (t, a, s) => queryDto.OtherQueryCondition.PortLoadCode == s.LoadPortCode || portLoadTaskIdList.Contains(t.Id)) .WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortDischargeCode), (t, a, s) => queryDto.OtherQueryCondition.PortDischargeCode == s.DischargePortCode || portDischargeTaskIdList.Contains(t.Id)) - .GroupBy((t, a) => new { t.TASK_TYPE, t.STATUS, a.Status, t.IS_PUBLIC }) .Select((t, a) => new TaskGroupTotal() { @@ -3089,8 +3112,9 @@ namespace DS.WMS.Core.TaskPlat.Method //IsExcept = t.IS_EXCEPT, IsPublic = t.IS_PUBLIC }); - +#if DEBUG var sql = queryable.ToSqlString(); +#endif var groupList = await queryable.ToListAsync(); //var exceptList = groupList