From 90503c42a5bcec475ea744530fb6a875d8f7eb4e Mon Sep 17 00:00:00 2001 From: wet <1034391973@qq.com> Date: Tue, 28 Mar 2023 15:06:11 +0800 Subject: [PATCH] 1 --- .../BookingOrder/BookingOrderService.cs | 203 +++++++++++++++--- .../Service/BookingOrder/Dto/GoodsStatus.cs | 44 ++++ .../BookingOrder/Dto/PageBookingOrder.cs | 2 + .../Service/DataSync/DataSyncService.cs | 4 + .../Service/DjyCustomer/DjyCustomerService.cs | 2 +- Myshipping.Core/Util/JsonUtil.cs | 55 +++++ 6 files changed, 275 insertions(+), 35 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index ecc12c1b..78b94667 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -111,6 +111,8 @@ namespace Myshipping.Application private readonly SqlSugarRepository _goodsStatus; private readonly SqlSugarRepository _goodsStatusConfig; private readonly SqlSugarRepository _djycustomer; + private readonly SqlSugarRepository _bookingTemplate; + private readonly SqlSugarRepository _paraGoodsInfoRepository; private readonly IHttpContextAccessor _httpContextAccessor; private readonly IBookingGoodsStatusConfigService _GoodsConfig; const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING"; @@ -121,12 +123,12 @@ namespace Myshipping.Application SqlSugarRepository bookinglog, SqlSugarRepository bookinglogdetail, SqlSugarRepository bookingremark, SqlSugarRepository bookingfile, SqlSugarRepository repUserConfig, SqlSugarRepository repPrint, SqlSugarRepository dicdata, SqlSugarRepository statuslog, SqlSugarRepository statuslogdetail, - ILogger logger, ISysCacheService cache, IDjyWebsiteAccountConfigService webAccountConfig, ISysDataUserMenu right, - SqlSugarRepository repPrintTemplate, SqlSugarRepository repLetterYard, SqlSugarRepository repUser, + ILogger logger, ISysCacheService cache, IDjyWebsiteAccountConfigService webAccountConfig, ISysDataUserMenu right, SqlSugarRepository paraGoodsInfoRepository, + SqlSugarRepository repPrintTemplate, SqlSugarRepository repLetterYard, SqlSugarRepository repUser, SqlSugarRepository bookingTemplate, SqlSugarRepository repOrderUrl, SqlSugarRepository repOrderContact, SqlSugarRepository repSampleBill, SqlSugarRepository djycustomer, SqlSugarRepository excelrep, SqlSugarRepository repUserMail, SqlSugarRepository goodsStatus, SqlSugarRepository goodsStatusConfig, SqlSugarRepository repTenant, SqlSugarRepository repBookingStatus, SqlSugarRepository bookingEDIExt, SqlSugarRepository serviceItem, - IHttpContextAccessor httpContextAccessor,IBookingGoodsStatusConfigService GoodsConfig) + IHttpContextAccessor httpContextAccessor, IBookingGoodsStatusConfigService GoodsConfig) { this._logger = logger; this._rep = rep; @@ -157,7 +159,9 @@ namespace Myshipping.Application this._serviceItem = serviceItem; this._goodsStatus = goodsStatus; this._goodsStatusConfig = goodsStatusConfig; + this._bookingTemplate = bookingTemplate; this._djycustomer = djycustomer; + this._paraGoodsInfoRepository = paraGoodsInfoRepository; _httpContextAccessor = httpContextAccessor; _GoodsConfig = GoodsConfig; } @@ -180,6 +184,8 @@ namespace Myshipping.Application var ftoday = DateTime.Now.AddDays(-15); var etoday = DateTime.Now.AddDays(15); //List userlist = await DataFilterExtensions.GetDataScopeIdList(); + + #region var entities = await _rep.AsQueryable() .WhereIF(input.firstFlag, x => x.ETD <= etoday && x.ETD >= ftoday || x.ETD == null) .WhereIF(string.IsNullOrWhiteSpace(input.HBLNO), x => x.ParentId == 0 || x.ParentId == null) @@ -329,22 +335,47 @@ namespace Myshipping.Application .OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.DescSort)) .ToPagedListAsync(input.PageNo, input.PageSize); - + #endregion var list = entities.Adapt>(); - var status = await _repBookingStatus.AsQueryable().ToListAsync(); - var remark = await _bookingremark.AsQueryable().ToListAsync(); - + var itgoodsStatus = _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(), + (goods, config) => config.Id == goods.ConfigId). + OrderBy((goods, config) => config.Sort). + Select((goods, config) => new + { + bookingid = goods.bookingId, + ConfigId = config.Id, + SystemCode = config.SystemCode, + StatusName = config.StatusName, + FinishTime = goods.FinishTime, + ExtData = goods.ExtData, + Remark = goods.Remark, + CreatedUserId = config.CreatedUserId, + Sort = config.Sort + }).ToList(); + + var itconfigs = _goodsStatusConfig.AsQueryable().Select(config => new + { + bookingid = "", + ConfigId = config.Id, + SystemCode = config.SystemCode, + StatusName = config.StatusName, + FinishTime = "", + ExtData = "", + Remark = "", + CreatedUserId = config.CreatedUserId, + Sort = config.Sort + }).ToList(); foreach (var item in list.Items) { - var sta = status.Where(x => x.BookingId == item.Id).ToList(); + var sta = _repBookingStatus.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id).ToList(); if (sta != null) { item.bookstatus = sta; } - var st = remark.Where(x => x.PId == item.Id).ToList(); + var st = _bookingremark.AsQueryable().Filter(null, true).Where(x => x.PId == item.Id).ToList(); if (st != null) { item.bookremark = st; @@ -357,6 +388,37 @@ namespace Myshipping.Application { item.ETA = Convert.ToDateTime(item.ETA).ToString("yyyy-MM-dd"); } + var itgoods = itgoodsStatus.Where(x => x.CreatedUserId == item.CreatedUserId && x.bookingid == item.Id).OrderBy(x => x.Sort). + Select(x => new GoodsStatusList + { + ConfigId = x.ConfigId, + StatusName = x.StatusName, + SystemCode = x.SystemCode, + FinishTime = x.FinishTime, + ExtData = x.ExtData, + Remark = x.Remark, + Sort = x.Sort + }).ToList(); + + var itconfig = itconfigs.Where(x => x.CreatedUserId == item.CreatedUserId).OrderBy(x => x.Sort). + Select(x => new GoodsStatusList + { + ConfigId = x.ConfigId, + StatusName = x.StatusName, + SystemCode = x.SystemCode, + FinishTime = null, + ExtData = x.ExtData, + Remark = x.Remark, + Sort=x.Sort + }).ToList(); + + foreach (var ii in itgoods) + { + itconfig.RemoveAll(x => x.ConfigId == ii.ConfigId); + } + + item.GoodsStatusList = itgoods.Union(itconfig).OrderBy(x=>x.Sort).ToList(); + } return list; @@ -766,11 +828,6 @@ namespace Myshipping.Application } - - - - - /// /// 更新订舱 /// @@ -1260,7 +1317,7 @@ namespace Myshipping.Application /// [SqlSugarUnitOfWork] [HttpPost("/BookingOrder/SaveGoodsStatus")] - public async Task SaveGoodsStatus(GoodsStatusDtoList input) + public async Task SaveGoodsStatus(GoodsStatusDtoList input) { if (input.BookingId == null || input.BookingId == 0) { @@ -1278,6 +1335,53 @@ namespace Myshipping.Application await _goodsStatus.InsertAsync(entity); } + var userid = _rep.Where(x => x.Id == input.BookingId).Select(x => x.CreatedUserId).First(); + if (userid != null) + { + + var list = await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(), + (goods, config) => config.Id == goods.ConfigId).Where((goods, config) => config.CreatedUserId == userid && goods.bookingId == input.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, + Sort = config.Sort + + }).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, + Sort = config.Sort + }).ToList(); + + foreach (var item in list) + { + config.RemoveAll(x => x.ConfigId == item.ConfigId); + } + + + return list.Union(config).OrderBy(x => x.Sort).ToList(); + + } + return null; } /// @@ -1291,9 +1395,9 @@ namespace Myshipping.Application var userid = _rep.Where(x => x.Id == bookingId).Select(x => x.CreatedUserId).First(); if (userid != null) { - - var list= await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(), - ( goods,config) => config.Id == goods.ConfigId).Where((goods,config ) => config.CreatedUserId == userid&& goods.bookingId==bookingId). + + 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 { @@ -1305,11 +1409,12 @@ namespace Myshipping.Application FinishUserId = goods.FinishUserId, IsPublic = goods.IsPublic, ExtData = goods.ExtData, - Remark = goods.Remark + Remark = goods.Remark, + Sort = config.Sort }).ToListAsync(); - var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().Select(config => new GoodsStatusQuery + var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().Select(config => new GoodsStatusQuery { ConfigId = config.Id, @@ -1320,16 +1425,17 @@ namespace Myshipping.Application FinishUserId = null, IsPublic = false, ExtData = null, - Remark = null + Remark = null, + Sort = config.Sort }).ToList(); foreach (var item in list) { - config.RemoveAll(x => x.ConfigId==item.ConfigId); + config.RemoveAll(x => x.ConfigId == item.ConfigId); } - return list.Union(config); + return list.Union(config).OrderBy(x => x.Sort).ToList(); } return null; @@ -4993,6 +5099,7 @@ namespace Myshipping.Application OrderBy((goods, config) => config.Sort). Select((goods, config) => new GoodsStatusQuery { + ConfigId = config.Id, SystemCode = config.SystemCode, StatusName = config.StatusName, @@ -5001,8 +5108,8 @@ namespace Myshipping.Application FinishUserId = goods.FinishUserId, IsPublic = goods.IsPublic, ExtData = goods.ExtData, - Remark = goods.Remark - + Remark = goods.Remark, + Sort = config.Sort }).ToListAsync(); var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().Select(config => new GoodsStatusQuery @@ -5016,7 +5123,8 @@ namespace Myshipping.Application FinishUserId = null, IsPublic = false, ExtData = null, - Remark = null + Remark = null, + Sort = config.Sort }).ToList(); foreach (var item in GoodsStatus) @@ -5025,9 +5133,9 @@ namespace Myshipping.Application } - - allData.GoodsStatus= GoodsStatus.Union(config).ToList(); + + allData.GoodsStatus = GoodsStatus.Union(config).OrderBy(x => x.Sort).ToList(); } @@ -5043,28 +5151,55 @@ namespace Myshipping.Application ///获取下拉前10条接口 /// /// - public async Task GetAllSelectData() + [HttpGet("/BookingOrder/GetAllSelectData")] + public async Task GetAllSelectData() { ////报关行 - var BGH= _djycustomer.Where(x => x.PropString == "customs_broker").Take(10).ToList(); + var BGH = _djycustomer.Where(x => x.PropString == "customs_broker").Take(10).ToList(); //车队 var CD = _djycustomer.Where(x => x.PropString == "fleet").Take(10).ToList(); //国外代理 + var GWDL = _djycustomer.Where(x => x.PropString == "out_agent").Take(10).ToList(); + //仓库 + var CK = _djycustomer.Where(x => x.PropString == "warehouse").Take(10).ToList(); + var Portload = _cache.GetAllCodePortLoad().Result.Take(10).ToList(); - return null; - } - - + var Port = _cache.GetAllCodePort().Result.Take(10).ToList(); + var Template = _bookingTemplate.AsQueryable().Take(10).ToList(); + var Customer = _djycustomer.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID).Take(10).ToList(); + var Forwarder = _cache.GetAllCodeForwarder().Result.Take(10).ToList(); + var Contractno = _paraGoodsInfoRepository.AsQueryable().OrderBy("GOODS_CODE asc").Take(50).ToList().Select(t => t.Adapt()).ToList(); + var superAdmin = UserManager.IsSuperAdmin; + var User = _repUser.AsQueryable().InnerJoin((u, e) => u.Id == e.Id) + .InnerJoin((u, e, o) => e.OrgId == o.Id) + .InnerJoin((u, e, o, t) => u.TenantId == t.Id) + .Where((u, e, o) => u.AdminType == AdminType.None) + .Select("u.*,t.Name As TenantName ").ToDataFilter("u", "Id", FilterType.User).Take(10).ToList(); + dynamic obj = new + { + BGH = BGH, + CD = CD, + GWDL = GWDL, + CK = CK, + Portload = Portload, + Port = Port, + Template = Template, + Customer = Customer, + Contractno = Contractno, + User = User + }; + return obj; + } } } diff --git a/Myshipping.Application/Service/BookingOrder/Dto/GoodsStatus.cs b/Myshipping.Application/Service/BookingOrder/Dto/GoodsStatus.cs index 7cb8e731..6848b3cf 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/GoodsStatus.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/GoodsStatus.cs @@ -95,5 +95,49 @@ namespace Myshipping.Application.Service.BookingOrder.Dto /// 备注 /// public string Remark { get; set; } + + + /// + /// 排序 + /// + public long? Sort { get; set; } + } + + + + public class GoodsStatusList + { + + + public long? ConfigId { get; set; } + /// + /// 状态名称 + /// + public string StatusName { get; set; } + /// + /// 系统编码 + /// + public string SystemCode { get; set; } + + /// + /// 完成时间 + /// + public DateTime? FinishTime { get; set; } + + + /// + /// 附加数据 + /// + public string ExtData { get; set; } + /// + /// 备注 + /// + public string Remark { get; set; } + /// + /// 排序 + /// + public long? Sort { get; set; } + + } } diff --git a/Myshipping.Application/Service/BookingOrder/Dto/PageBookingOrder.cs b/Myshipping.Application/Service/BookingOrder/Dto/PageBookingOrder.cs index dcbdea19..326f0721 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/PageBookingOrder.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/PageBookingOrder.cs @@ -817,5 +817,7 @@ namespace Myshipping.Application.Service.BookingOrder.Dto public List bookstatus { get; set; } public List bookremark { get; set; } + + public List GoodsStatusList { get; set; } } } diff --git a/Myshipping.Application/Service/DataSync/DataSyncService.cs b/Myshipping.Application/Service/DataSync/DataSyncService.cs index 14e073a3..34a3a73f 100644 --- a/Myshipping.Application/Service/DataSync/DataSyncService.cs +++ b/Myshipping.Application/Service/DataSync/DataSyncService.cs @@ -1019,6 +1019,7 @@ namespace Myshipping.Application entity.CARRIERID = _cache.GetAllCodeCarrier().Result.Where(x => x.CnName == entity.CARRIER).Select(x => x.Code).FirstOrDefault(); } + entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString(); entity.CreatedUserId = user.Result.Id; entity.CreatedUserName = user.Result.Name.ToString(); entity.CreatedTime = DateTime.Now; @@ -1147,6 +1148,7 @@ namespace Myshipping.Application fdentity.CARRIER = entity.CARRIER; fdentity.CARRIERID = _cache.GetAllCodeCarrier().Result.Where(x => x.CnName == entity.CARRIER).Select(x => x.Code).FirstOrDefault(); } + fdentity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString(); fdentity.MBLNO = entity.MBLNO; fdentity.CreatedUserId = user.Result.Id; fdentity.CreatedUserName = user.Result.Name; @@ -1289,6 +1291,7 @@ namespace Myshipping.Application } await _rep.AsUpdateable(entity).IgnoreColumns(it => new { + it.BOOKINGNO, it.ParentId, it.TenantId, it.CreatedTime, @@ -1484,6 +1487,7 @@ namespace Myshipping.Application } await _rep.AsUpdateable(fdentity).IgnoreColumns(it => new { + it.BOOKINGNO, it.ParentId, it.TenantId, it.CreatedTime, diff --git a/Myshipping.Core/Service/DjyCustomer/DjyCustomerService.cs b/Myshipping.Core/Service/DjyCustomer/DjyCustomerService.cs index 0743f3ae..1b41dcf7 100644 --- a/Myshipping.Core/Service/DjyCustomer/DjyCustomerService.cs +++ b/Myshipping.Core/Service/DjyCustomer/DjyCustomerService.cs @@ -194,7 +194,7 @@ namespace Myshipping.Core.Service [HttpGet("/DjyCustomer/Suggest")] public async Task Suggest(string keyword, string type) { - List userlist = await DataFilterExtensions.GetDataScopeIdList(); + //List userlist = await DataFilterExtensions.GetDataScopeIdList(); var entities = await _rep.AsQueryable().Filter(null, true) .Where(x => x.TenantId == UserManager.TENANT_ID) .WhereIF(!string.IsNullOrWhiteSpace(type), u => u.PropString.Contains(type)) diff --git a/Myshipping.Core/Util/JsonUtil.cs b/Myshipping.Core/Util/JsonUtil.cs index fda78d4e..c39d7c86 100644 --- a/Myshipping.Core/Util/JsonUtil.cs +++ b/Myshipping.Core/Util/JsonUtil.cs @@ -274,6 +274,61 @@ public static class JsonUtil // return "PONO存在中文字符"; //} + if (sourceVal.ToString().Length>9 && propName.ToUpper() == "VESSELID") { + + return "船舶呼号超长"; + } + if (sourceVal.ToString().Length > 5&& propName.ToUpper() == "PLACERECEIPTID") + { + + return "收货地代码超长"; + } + if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "PLACERECEIPTID") + { + + return "收货地代码超长"; + } + if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "PORTLOADID") + { + + return "起运港代码超长"; + } + if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "PORTDISCHARGEID") + { + + return "卸货港代码超长"; + } + if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "PLACEDELIVERYID") + { + + return "交货地代码超长"; + } + if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "DESTINATIONID") + { + + return "目的地代码超长"; + } + if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "NOBILL") + { + + return "提单份数超长"; + } + if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "ISSUEPLACEID") + { + + return "签单地点代码超长"; + } + if (sourceVal.ToString().Length > 1 && propName.ToUpper() == "CARGOID") + { + + return "货物标识超长"; + } + + if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "TRANSPORTID") + { + + return "中转港代码超长"; + } } }