From 842bd7427cef8e5794429d8320c579b19ce37f91 Mon Sep 17 00:00:00 2001 From: wet <1034391973@qq.com> Date: Mon, 27 Mar 2023 10:04:42 +0800 Subject: [PATCH] 1 --- .../BookingOrder/BookingOrderService.cs | 86 ++++++++++++++----- .../Service/BookingOrder/Dto/GoodsStatus.cs | 2 +- 2 files changed, 66 insertions(+), 22 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 6a8fa836..5feae6d3 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -1289,10 +1289,11 @@ namespace Myshipping.Application var userid = _rep.Where(x => x.Id == bookingId).Select(x => x.CreatedUserId).First(); if (userid != null) { - - var list= await _goodsStatusConfig.AsQueryable().LeftJoin(_goodsStatus.AsQueryable(), (config, goods) => config.Id == goods.ConfigId).Where((config, goods) => config.CreatedUserId == userid). - OrderBy((config, goods) => config.Sort). - Select((config, goods) => new GoodsStatusQuery + + var list= await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(), + ( goods,config) => config.Id == goods.ConfigId).Where((goods,config ) => config.CreatedUserId == userid&& goods.bookingId==bookingId). + OrderBy((goods, config) => config.Sort). + Select((goods, config) => new GoodsStatusQuery { ConfigId = config.Id, SystemCode = config.SystemCode, @@ -1306,7 +1307,27 @@ namespace Myshipping.Application }).ToListAsync(); - return list.DistinctBy(x => x.ConfigId); + var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().Select(config => new GoodsStatusQuery + { + + ConfigId = config.Id, + SystemCode = config.SystemCode, + StatusName = config.StatusName, + FinishTime = null, + FinishUser = null, + FinishUserId = null, + IsPublic = false, + ExtData = null, + Remark = null + }).ToList(); + + foreach (var item in list) + { + config.RemoveAll(x => x.ConfigId==item.ConfigId); + } + + + return list.Union(config); } return null; @@ -4963,25 +4984,48 @@ namespace Myshipping.Application if (userid != null) { _GoodsConfig.InitGoodsStatusConfig(); - List Goodslist = new List(); - Goodslist = await _goodsStatusConfig.AsQueryable().LeftJoin(_goodsStatus.AsQueryable(), (config, goods) => config.Id == goods.ConfigId).Where((config, goods) => config.CreatedUserId == userid). - OrderBy((config, goods) => config.Sort). - Select((config, goods) => new GoodsStatusQuery - { - ConfigId = config.Id, - SystemCode = config.SystemCode, - StatusName = config.StatusName, - FinishTime = goods.FinishTime, - FinishUser = goods.FinishUser, - FinishUserId = goods.FinishUserId, - IsPublic = goods.IsPublic, - ExtData = goods.ExtData, - Remark = goods.Remark - }).ToListAsync(); + var GoodsStatus = await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(), + (goods, config) => config.Id == goods.ConfigId).Where((goods, config) => config.CreatedUserId == userid && goods.bookingId == bookingId). + OrderBy((goods, config) => config.Sort). + Select((goods, config) => new GoodsStatusQuery + { + ConfigId = config.Id, + SystemCode = config.SystemCode, + StatusName = config.StatusName, + FinishTime = goods.FinishTime, + FinishUser = goods.FinishUser, + FinishUserId = goods.FinishUserId, + IsPublic = goods.IsPublic, + ExtData = goods.ExtData, + Remark = goods.Remark + + }).ToListAsync(); + + var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().Select(config => new GoodsStatusQuery + { + + ConfigId = config.Id, + SystemCode = config.SystemCode, + StatusName = config.StatusName, + FinishTime = null, + FinishUser = null, + FinishUserId = null, + IsPublic = false, + ExtData = null, + Remark = null + }).ToList(); + + foreach (var item in GoodsStatus) + { + config.RemoveAll(x => x.ConfigId == item.ConfigId); + } + + + - allData.GoodsStatus = Goodslist; + allData.GoodsStatus= GoodsStatus.Union(config).ToList(); } diff --git a/Myshipping.Application/Service/BookingOrder/Dto/GoodsStatus.cs b/Myshipping.Application/Service/BookingOrder/Dto/GoodsStatus.cs index 165c7b47..7cb8e731 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/GoodsStatus.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/GoodsStatus.cs @@ -56,7 +56,7 @@ namespace Myshipping.Application.Service.BookingOrder.Dto public class GoodsStatusQuery { - + /// /// 货物状态配置ID 雪花id