diff --git a/ds-wms-service/DS.WMS.Core/Op/Interface/ISeaExportServiceTest.cs b/ds-wms-service/DS.WMS.Core/Op/Interface/ISeaExportServiceTest.cs new file mode 100644 index 00000000..04d01628 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Op/Interface/ISeaExportServiceTest.cs @@ -0,0 +1,74 @@ +using DS.Module.Core; +using DS.Module.Core.Data; +using DS.Module.DjyRulesEngine; +using DS.WMS.Core.Op.Dtos; +using DS.WMS.Core.Op.Dtos.VGM; +using DS.WMS.Core.Op.EDI; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; + +namespace DS.WMS.Core.Op.Interface; + +public interface ISeaExportTestService +{ + /// + /// 导出海运出口主表 + /// + /// + public Task SeaExportExport(); + + /// + /// 海运出口品名信息导出 + /// + public Task SeaExportExportCtnGoods(); + + /// + /// 海运出口订单货物信息导出 + /// + public Task SeaExportExportMainGood(); + + /// + /// 海运出口订单集装箱信息导出 + /// + public Task SeaExportExportMainCtn(); + + /// + /// 海运出口订单订舱信息导出 + /// + public Task SeaExportExportMainBook(); + /// + /// 海运出口订单费用信息导出 + /// + public Task SeaExportExportMainFee(); + + /// + /// 导出海运出口分单 + /// + /// + public Task SeaExportExportPart(); + + ///// + ///// 海运出口品名信息导出分单 + ///// + //public Task SeaExportExportCtnGoodsPart(); + + ///// + ///// 海运出口订单货物信息导出分单 + ///// + //public Task SeaExportExportPartGoodPart(); + + /// + /// 海运出口订单集装箱信息导出分单 + /// + public Task SeaExportExportPartCtn(); + + ///// + ///// 海运出口订单订舱信息导出分单 + ///// + //public Task SeaExportExportPartBook(); + /// + /// 海运出口订单费用信息导出分单 + /// + public Task SeaExportExportPartFee(); +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportTestService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportTestService.cs new file mode 100644 index 00000000..d5591971 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportTestService.cs @@ -0,0 +1,999 @@ +using Amazon.Runtime.Internal.Util; +using AngleSharp.Dom; +using DS.Module.Core; +using DS.Module.Core.Data; +using DS.Module.Core.Extensions; +using DS.Module.SqlSugar; +using DS.Module.UserModule; +using DS.WMS.Core.Code.Entity; +using DS.WMS.Core.Fee.Entity; +using DS.WMS.Core.Map.Entity; +using DS.WMS.Core.Op.Dtos; +using DS.WMS.Core.Op.EDI; +using DS.WMS.Core.Op.Entity; +using DS.WMS.Core.Op.Interface; +using DS.WMS.Core.Sys.Entity; +using Mapster; +using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.DependencyInjection; +using SqlSugar; +using NLog; +using Logger = NLog.Logger; +using Newtonsoft.Json.Linq; +using DS.Module.Core.Helpers; +using Org.BouncyCastle.Ocsp; +using Microsoft.Extensions.Hosting; +using MiniExcelLibs; +using Microsoft.AspNetCore.Hosting; +using DS.WMS.Core.HangfireJob.Dtos; +using NPOI.SS.Formula.Functions; +using ZstdSharp.Unsafe; +using static DS.WMS.Core.Op.Method.SeaExportTestService; + +namespace DS.WMS.Core.Op.Method +{ + public class SeaExportTestService: ISeaExportTestService + { + + private readonly IServiceProvider _serviceProvider; + private readonly ISqlSugarClient db; + private readonly IUser user; + private readonly ISaasDbService saasService; + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); + Microsoft.Extensions.Configuration.IConfiguration config; + IWebHostEnvironment hostEnvironment; + /// + /// + /// + /// + public SeaExportTestService(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + db = _serviceProvider.GetRequiredService(); + saasService = _serviceProvider.GetRequiredService(); + config = serviceProvider.GetRequiredService(); + hostEnvironment = serviceProvider.GetRequiredService(); + } + + public class ZySeaExportMain + { + public long Id { get; set; } + public string 订单类别 { get; set; } + public string 订单code { get; set; } + public string 分单编号 { get; set; } + public string 改配订单code { get; set; } + + + public string 客户编号 { get; set; } + public string 货源 { get; set; } + public string 入货通知备注 { get; set; } + public string 订单备注 { get; set; } + public string 客户联系人 { get; set; } + public string 客户电话 { get; set; } + public string 客户邮箱 { get; set; } + public string 客户职务 { get; set; } + public string 客户qq { get; set; } + public string 客户联系方式 { get; set; } + public string 客户 { get; set; } + public string 状态 { get; set; } + + public int 优先级 { get; set; } + public int 是否锁单 { get; set; } + public string 约主 { get; set; } + public string 创建者 { get; set; } + public DateTime? 创建时间 { get; set; } + public string 更新者 { get; set; } + public DateTime? 更新时间 { get; set; } + public int 是否删除 { get; set; } + public string 商务 { get; set; } + public string 操作 { get; set; } + + public string 客服 { get; set; } + public int? 委托状态 { get; set; } + + public DateTime? 离港时间 { get; set; } + + public DateTime? 到港时间 { get; set; } + public int 汇率 { get; set; } + public string 订单箱子名称与数量 { get; set; } + public int? 底单价 { get; set; } + + public int? 卖单价 { get; set; } + public DateTime? 实际离港时间 { get; set; } + public string 操作完结 { get; set; } + public DateTime? 货好时间 { get; set; } + public DateTime? ATA { get; set; } + + public string 起运港 { get; set; } + + public string 目的港 { get; set; } + + + } + + + public class ZySeaExportCtnGoods + { + public long Id { get; set; } + public string 品名 { get; set; } + + public string 海关编码 { get; set; } + public string 订单编号 { get; set; } + public string 分单编号 { get; set; } + public string 创建者 { get; set; } + public DateTime? 创建时间 { get; set; } + public DateTime? 更新时间 { get; set; } + } + + public class ZySeaExportGoodsInfo + { + public long Id { get; set; } + public string 订单编号 { get; set; } + public string 分单编号 { get; set; } + public string 货物类别 { get; set; } + + public string 唛头 { get; set; } + + public string 货物中文名 { get; set; } + public int? 货物件数 { get; set; } + + public string 包装类型 { get; set; } + public string 单位 { get; set; } + public decimal? 毛重 { get; set; } + public decimal? 体积 { get; set; } + public string 商品海关编码 { get; set; } + public string 危品分类 { get; set; } + public string 危险品属性 { get; set; } + public string 危险品包装类型 + { get; set; } + public string 危险页码 { get; set; } + public string 危险品标签 { get; set; } + public string 危险品编号 { get; set; } + public string 应急联系电话 { get; set; } + + public string 设置单位 { get; set; } + public string 最低温度 { get; set; } + public string 最高温度 { get; set; } + public string 设置温度 { get; set; } + public string 通风设置 { get; set; } + + public string 创建者 { get; set; } + public int 是否删除 { get; set; } + public string 更新者 { get; set; } + public DateTime? 创建时间 { get; set; } + public DateTime? 更新时间 { get; set; } + } + public class ZySeaExportCtnInfo + { + public long Id { get; set; } + public string 订单编号 { get; set; } + public string 分单编号 { get; set; } + public string 箱型 { get; set; } + + public string 箱号 { get; set; } + + public int? 箱量 { get; set; } + + public string 箱封号 { get; set; } + + public int? 件数 { get; set; } + + public string 包装 { get; set; } + public decimal? 重量 { get; set; } + public decimal? 体积 { get; set; } + + public decimal? VGM重量 { get; set; } + public decimal? 箱重 { get; set; } + + public decimal? 毛重 { get; set; } + + public string 创建者 { get; set; } + public int 是否删除 { get; set; } + public string 更新者 { get; set; } + public DateTime? 创建时间 { get; set; } + public DateTime? 更新时间 { get; set; } + } + + public class ZySeaExportBookInfo + { + public long Id { get; set; } + public string 订单编号 { get; set; } + public string 分单编号 { get; set; } + public string 订舱号 { get; set; } + + public string 船名 { get; set; } + + public string 航次 { get; set; } + + + public string 运输条款 { get; set; } + + public string 运费条款 { get; set; } + public string 船公司 { get; set; } + public string 约号 { get; set; } + public string 签单方式{ get; set; } + public string 签单份数 { get; set; } + public string 提单号 { get; set; } + public string 签发地 { get; set; } + public DateTime? 签发时间 { get; set; } + public string 订舱代理 { get; set; } + public string 海外代理 { get; set; } + public DateTime? 开港时间 { get; set; } + public DateTime? 截港时间 { get; set; } + public DateTime? 截单时间 { get; set; } + + public DateTime? 截关时间 { get; set; } + public string 船代 { get; set; } + public string 场站联系人 { get; set; } + public string 场站联系电话 { get; set; } + public string 场站 { get; set; } + public string 箱使需求 { get; set; } + + public string 订舱代理联人 { get; set; } + + public string 海外代理联系人 { get; set; } + + public string 海外代理联系方式 { get; set; } + public string 订舱邮箱 { get; set; } + + public string 创建者 { get; set; } + public int 是否删除 { get; set; } + public string 更新者 { get; set; } + public DateTime? 创建时间 { get; set; } + public DateTime? 更新时间 { get; set; } + } + + public class ZySeaExportFeeInfo + { + public long Id { get; set; } + public string 订单编号 { get; set; } + + public string 分单编号 { get; set; } + public string 费用名称 { get; set; } + public string 结算单位 { get; set; } + public int 费用类型 { get; set; } + + public string 币种 { get; set; } + + + public decimal? 数量 { get; set; } + + public string 单位 { get; set; } + public decimal? 单价 { get; set; } + public decimal? 总价 { get; set; } + + public string 创建者 { get; set; } + public int 是否删除 { get; set; } + public string 更新者 { get; set; } + public DateTime? 创建时间 { get; set; } + public DateTime? 更新时间 { get; set; } + } + public class Main { + + public List List { get; set; } + } + public class CtnGoods + { + + public List List { get; set; } + } + public class MainGoods + { + + public List List { get; set; } + } + public class MainCtns + { + + public List List { get; set; } + } + + public class MainBooks + { + + public List List { get; set; } + } + + public class MainFees + { + + public List List { get; set; } + } + /// + /// 海运出口主单导出 + /// + public async Task SeaExportExport() + { + var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); + string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "海运出口主单.xlsx"); + FileInfo templateFile = new(path); + if (!templateFile.Exists) + { + var ex = new ApplicationException("未能在下列路径找到模板文件:" + path); + throw ex; + } + var model = new Main(); + + + string savePath = Path.Combine(hostEnvironment.WebRootPath, "templates", "海运出口主单" + NumUtil.GetNo() + ".xlsx"); + var ctnpriceList = await tenantDb.Queryable().Filter(null, true).ToListAsync(); + var contactList = await tenantDb.Queryable().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync(); + + var data = await tenantDb.Queryable().Filter(null, true).Where(x => !x.Deleted && x.IsRefund == false && x.IsChangeETD == false) + .LeftJoin((x, y) => x.Id == y.BusinessId) + .Select((x, y) => new ZySeaExportMain + { + Id =x.Id, + 订单类别 = x.BLType, + 订单code = x.MBLNO, + 客户编号 = x.CustomerNo, + 货源 = x.SourceCode, + 入货通知备注 = "", + 订单备注 = x.Remark, + + 客户qq = "", + + 客户 = x.CustomerName, + 状态 = x.BusinessStatusName, + 优先级 = 1, + 是否锁单 = (bool)y.IsBusinessLocking ? 1 : 0, + 约主 = x.ContractClientName, + 创建者 = x.CreateUserName, + 创建时间 = x.CreateTime, + 更新者 = x.UpdateUserName, + 更新时间 = x.UpdateTime, + 是否删除 = 0, + 商务 = x.Sale, + 操作 = x.OperatorName, + 客服 = x.CustomerServiceName, + 委托状态 = 2, + 离港时间 = x.ETD, + 到港时间 = x.ATA, + 汇率 = 0, + 订单箱子名称与数量 = x.CntrTotal, + 实际离港时间 = x.ATD, + 操作完结 = "", + 货好时间 = x.GoodsCompleteTime, + ATA = x.ATA, + 起运港 = x.LoadPortCode, + 目的港 = x.DischargePortCode, + + }).ToListAsync(); + + foreach (var item in data) + { + var ctnprice = ctnpriceList.FirstOrDefault(a => a.BusinessId == item.Id); + if (ctnprice.IsNotNull()) + { + item.底单价 = ctnprice.FloorPrice; + item.卖单价 = ctnprice.QuotePrice; + } + + var contact = contactList.FirstOrDefault(a => a.BusinessId == item.Id); + if (contact.IsNotNull()) + { + item.客户联系人 = contact.Name; + item.客户电话 = contact.Tel; + item.客户邮箱 = contact.Email; + item.客户职务 = contact.Job; + item.客户联系方式 = contact.Mobile; + } + + } + model.List = data; + //MemoryStream ms = new(); + await MiniExcel.SaveAsByTemplateAsync(savePath, path, model); + //string base64Str = Convert.ToBase64String(ms.ToArray()); + //ms.Dispose(); + } + + + /// + /// 海运出口品名信息导出 + /// + public async Task SeaExportExportCtnGoods() + { + var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); + string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "货物中文品名信息.xlsx"); + FileInfo templateFile = new(path); + if (!templateFile.Exists) + { + var ex = new ApplicationException("未能在下列路径找到模板文件:" + path); + throw ex; + } + var model = new CtnGoods(); + + + string savePath = Path.Combine(hostEnvironment.WebRootPath, "templates", "货物中文品名信息" + NumUtil.GetNo() + ".xlsx"); + + var data = await tenantDb.Queryable().Filter(null, true).Where(x => !x.Deleted ) + .InnerJoin((x, y) => x.BusinessId == y.Id && y.IsRefund == false && y.IsChangeETD == false) + .Select((x, y) => new ZySeaExportCtnGoods + { + Id = x.Id, + 品名 = x.GoodsName, + 海关编码 = x.HSCode, + 订单编号 = y.MBLNO, + 创建者 = x.CreateUserName, + 创建时间 = x.CreateTime, + 更新时间 = x.UpdateTime, + + }).ToListAsync(); + model.List = data; + await MiniExcel.SaveAsByTemplateAsync(savePath, path, model); + } + + /// + /// 海运出口订单货物信息导出 + /// + public async Task SeaExportExportMainGood() + { + var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); + string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单货物信息.xlsx"); + FileInfo templateFile = new(path); + if (!templateFile.Exists) + { + var ex = new ApplicationException("未能在下列路径找到模板文件:" + path); + throw ex; + } + var model = new MainGoods(); + + + string savePath = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单货物信息" + NumUtil.GetNo() + ".xlsx"); + var ctnpriceList = await tenantDb.Queryable().Filter(null, true).ToListAsync(); + var contactList = await tenantDb.Queryable().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync(); + + var data = await tenantDb.Queryable().Filter(null, true).Where(x => !x.Deleted && x.IsRefund == false && x.IsChangeETD == false) + .Select(x => new ZySeaExportGoodsInfo + { + Id = x.Id, + 订单编号 = x.MBLNO, + 唛头 = x.Marks, + 货物中文名 = x.GoodsName, + 货物件数 = x.PKGS, + 包装类型 = x.KindPkgsName, + + 毛重 = x.KGS, + + 体积 = x.CBM, + 商品海关编码 = x.HSCode, + + 创建者 = x.CreateUserName, + 创建时间 = x.CreateTime, + 更新者 = x.UpdateUserName, + 更新时间 = x.UpdateTime, + 是否删除 = 0, + 危品分类 = x.DangerClass, + //危 = x.DangerAttn, + 危险品标签 = x.DangerLabel, + 危险页码 = x.DangerNo, + 危险品编号 = x.DangerPage, + 应急联系电话 = x.DangerTel, + 设置温度 = x.TemperatureSet, + 最高温度 = x.TemperatureMax, + 最低温度 = x.TemperatureMin, + 设置单位 = x.TemperatureUnit, + 通风设置 = x.ReeferQuantity, + + }).ToListAsync(); + + model.List = data; + //MemoryStream ms = new(); + await MiniExcel.SaveAsByTemplateAsync(savePath, path, model); + //string base64Str = Convert.ToBase64String(ms.ToArray()); + //ms.Dispose(); + } + + + /// + /// 海运出口订单集装箱信息导出 + /// + public async Task SeaExportExportMainCtn() + { + var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); + string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单集装箱信息.xlsx"); + FileInfo templateFile = new(path); + if (!templateFile.Exists) + { + var ex = new ApplicationException("未能在下列路径找到模板文件:" + path); + throw ex; + } + var model = new MainCtns(); + + + string savePath = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单集装箱信息" + NumUtil.GetNo() + ".xlsx"); + var ctnpriceList = await tenantDb.Queryable().Filter(null, true).ToListAsync(); + var contactList = await tenantDb.Queryable().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync(); + + var data = await tenantDb.Queryable().Filter(null, true).Where(x => !x.Deleted) + .InnerJoin((x, y) => x.BSNO == y.Id.ToString() && y.IsRefund == false && y.IsChangeETD == false) + .Select((x, y) => new ZySeaExportCtnInfo + { + Id = x.Id, + 订单编号 = y.MBLNO, + 箱型 = x.Ctn, + 箱号 = x.CntrNo, + 箱量 = x.CtnNum, + 箱封号 = x.SealNo, + 件数 = x.PKGS, + 包装 = x.KindPkgsName, + 体积 = x.CBM, + VGM重量 = x.WeightKGS, + 毛重 = x.KGS, + 箱重 = x.TareWeight, + 创建者 = x.CreateUserName, + 更新者 = x.UpdateUserName, + 创建时间 = x.CreateTime, + 更新时间 = x.UpdateTime, + + }).ToListAsync(); + + model.List = data; + //MemoryStream ms = new(); + await MiniExcel.SaveAsByTemplateAsync(savePath, path, model); + } + + + /// + /// 海运出口订单订舱信息导出 + /// + public async Task SeaExportExportMainBook() + { + var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); + string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单订舱信息.xlsx"); + FileInfo templateFile = new(path); + if (!templateFile.Exists) + { + var ex = new ApplicationException("未能在下列路径找到模板文件:" + path); + throw ex; + } + var model = new MainBooks(); + + + string savePath = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单订舱信息" + NumUtil.GetNo() + ".xlsx"); + var ctnpriceList = await tenantDb.Queryable().Filter(null, true).ToListAsync(); + var contactList = await tenantDb.Queryable().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync(); + + var data = await tenantDb.Queryable().Filter(null, true).Where(x => !x.Deleted && x.IsRefund == false && x.IsChangeETD == false) + .Select(x => new ZySeaExportBookInfo + { + Id = x.Id, + 订单编号 = x.MBLNO, + 订舱号 = x.BookingNo, + 船名 = x.Vessel, + 航次 = x.Voyno, + 运输条款 = x.Service, + 船公司 = x.Carrier, + 约号 = x.ContractNo, + 签单方式 = x.IssueType, + 签单份数 = x.NoBill, + 签发地 = x.IssuePlace, + 签发时间 = x.IssueDate, + 订舱代理 = x.Forwarder, + 海外代理 = x.Agent, + 开港时间 = x.ETD, + 截港时间 = x.ClosingDate, + 截单时间 = x.CloseDocDate, + 船代 = x.ShipAgency, + 场站联系人 = x.YardATTN, + 场站联系电话 = x.YardTel, + 场站 = x.Yard, + 箱使需求 = x.ApplyCtnRemark, + + + 创建者 = x.CreateUserName, + 创建时间 = x.CreateTime, + 更新者 = x.UpdateUserName, + 更新时间 = x.UpdateTime, + 是否删除 = 0, + + + }).ToListAsync(); + + model.List = data; + //MemoryStream ms = new(); + await MiniExcel.SaveAsByTemplateAsync(savePath, path, model); + //string base64Str = Convert.ToBase64String(ms.ToArray()); + //ms.Dispose(); + } + + + /// + /// 海运出口订单费用信息导出 + /// + public async Task SeaExportExportMainFee() + { + var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); + string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单费用信息.xlsx"); + FileInfo templateFile = new(path); + if (!templateFile.Exists) + { + var ex = new ApplicationException("未能在下列路径找到模板文件:" + path); + throw ex; + } + var model = new MainFees(); + + + string savePath = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单费用信息" + NumUtil.GetNo() + ".xlsx"); + + + var data = await tenantDb.Queryable().Filter(null, true).Where(x => !x.Deleted) + .InnerJoin((x, y) => x.BusinessId == y.Id && y.IsRefund == false && y.IsChangeETD == false) + .Select((x, y) => new ZySeaExportFeeInfo + { + Id = x.Id, + 订单编号 = y.MBLNO, + 费用名称 = x.FeeName, + 结算单位= x.CustomerName, + 费用类型 = x.FeeType == FeeType.Receivable ? 215 : 214, + 币种 = x.Currency, + 数量 = x.Quantity, + 单位 = x.UnitText, + 单价 = x.UnitPrice, + 总价 = x.Amount, + + 创建者 = x.CreateUserName, + 更新者 = x.UpdateUserName, + 创建时间 = x.CreateTime, + 更新时间 = x.UpdateTime, + + }).ToListAsync(); + + model.List = data; + //MemoryStream ms = new(); + await MiniExcel.SaveAsByTemplateAsync(savePath, path, model); + //string base64Str = Convert.ToBase64String(ms.ToArray()); + //ms.Dispose(); + } + + + + /// + /// 海运出口导出-分单 + /// + public async Task SeaExportExportPart() + { + var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); + string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "海运出口主单.xlsx"); + FileInfo templateFile = new(path); + if (!templateFile.Exists) + { + var ex = new ApplicationException("未能在下列路径找到模板文件:" + path); + throw ex; + } + var model = new Main(); + + + string savePath = Path.Combine(hostEnvironment.WebRootPath, "templates", "海运出口-分单 " + NumUtil.GetNo() + ".xlsx"); + var ctnpriceList = await tenantDb.Queryable().Filter(null, true).ToListAsync(); + var contactList = await tenantDb.Queryable().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync(); + + var data = await tenantDb.Queryable().Filter(null, true).Where(x => !x.Deleted) + .InnerJoin((x, y) => x.BusinessId == y.Id) + .LeftJoin((x, y,z) => z.BusinessId == y.Id) + .Select((x, y,z) => new ZySeaExportMain + { + Id = x.Id, + 订单类别 = "分单", + 订单code = x.MBLNO, + 客户编号 = y.CustomerNo, + 货源 = y.SourceCode, + 入货通知备注 = "", + 订单备注 = x.Remark, + + 客户qq = "", + + 客户 = y.CustomerName, + 状态 = y.BusinessStatusName, + 优先级 = 1, + 是否锁单 = (bool)y.IsBusinessLocking ? 1 : 0, + 约主 = y.ContractClientName, + 创建者 = x.CreateUserName, + 创建时间 = x.CreateTime, + 更新者 = x.UpdateUserName, + 更新时间 = x.UpdateTime, + 是否删除 = 0, + 商务 = y.Sale, + 操作 = y.OperatorName, + 客服 = y.CustomerServiceName, + 委托状态 = 2, + 离港时间 = y.ETD, + 到港时间 = y.ATA, + 汇率 = 0, + 订单箱子名称与数量 = x.CntrTotal, + 实际离港时间 = x.ATD, + 操作完结 = "", + 货好时间 = y.GoodsCompleteTime, + ATA = y.ATA, + 起运港 = y.LoadPortCode, + 目的港 = y.DischargePortCode, + + }).ToListAsync(); + + foreach (var item in data) + { + var ctnprice = ctnpriceList.FirstOrDefault(a => a.BusinessId == item.Id); + if (ctnprice.IsNotNull()) + { + item.底单价 = ctnprice.FloorPrice; + item.卖单价 = ctnprice.QuotePrice; + } + + var contact = contactList.FirstOrDefault(a => a.BusinessId == item.Id); + if (contact.IsNotNull()) + { + item.客户联系人 = contact.Name; + item.客户电话 = contact.Tel; + item.客户邮箱 = contact.Email; + item.客户职务 = contact.Job; + item.客户联系方式 = contact.Mobile; + } + + } + model.List = data; + //MemoryStream ms = new(); + await MiniExcel.SaveAsByTemplateAsync(savePath, path, model); + //string base64Str = Convert.ToBase64String(ms.ToArray()); + //ms.Dispose(); + } + + + ///// + ///// 海运出口品名信息导出-分单 + ///// + //public async Task SeaExportExportCtnGoodsPart() + //{ + // var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); + // string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "货物中文品名信息.xlsx"); + // FileInfo templateFile = new(path); + // if (!templateFile.Exists) + // { + // var ex = new ApplicationException("未能在下列路径找到模板文件:" + path); + // throw ex; + // } + // var model = new CtnGoods(); + + + // string savePath = Path.Combine(hostEnvironment.WebRootPath, "templates", "货物中文品名信息-分单" + NumUtil.GetNo() + ".xlsx"); + + // var data = await tenantDb.Queryable().Filter(null, true).Where(x => !x.Deleted) + // .InnerJoin((x, y) => x.Pid == y.Id) + // .Select((x, y) => new ZySeaExportCtnGoods + // { + // Id = x.Id, + // 品名 = x.GoodsName, + // 海关编码 = x.HSCode, + // 订单编号 = y.MBLNO, + // 创建者 = x.CreateUserName, + // 创建时间 = x.CreateTime, + // 更新时间 = x.UpdateTime, + + // }).ToListAsync(); + // model.List = data; + // await MiniExcel.SaveAsByTemplateAsync(savePath, path, model); + //} + + ///// + ///// 海运出口订单货物信息导出-分单 + ///// + //public async Task SeaExportExportMainGoodPart() + //{ + // var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); + // string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单货物信息.xlsx"); + // FileInfo templateFile = new(path); + // if (!templateFile.Exists) + // { + // var ex = new ApplicationException("未能在下列路径找到模板文件:" + path); + // throw ex; + // } + // var model = new MainGoods(); + + + // string savePath = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单货物信息" + NumUtil.GetNo() + ".xlsx"); + // var ctnpriceList = await tenantDb.Queryable().Filter(null, true).ToListAsync(); + // var contactList = await tenantDb.Queryable().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync(); + + // var data = await tenantDb.Queryable().Filter(null, true).Where(x => !x.Deleted) + // .Select(x => new ZySeaExportGoodsInfo + // { + // Id = x.Id, + // 订单编号 = x.MBLNO, + // 唛头 = x.Marks, + // 货物中文名 = x.GoodsName, + // 货物件数 = x.PKGS, + // 包装类型 = x.KindPkgsName, + + // 毛重 = x.KGS, + + // 体积 = x.CBM, + // 商品海关编码 = x.HSCode, + + // 创建者 = x.CreateUserName, + // 创建时间 = x.CreateTime, + // 更新者 = x.UpdateUserName, + // 更新时间 = x.UpdateTime, + // 是否删除 = 0, + // 危品分类 = x.DangerClass, + // //危 = x.DangerAttn, + // 危险品标签 = x.DangerLabel, + // 危险页码 = x.DangerNo, + // 危险品编号 = x.DangerPage, + // 应急联系电话 = x.DangerTel, + // 设置温度 = x.TemperatureSet, + // 最高温度 = x.TemperatureMax, + // 最低温度 = x.TemperatureMin, + // 设置单位 = x.TemperatureUnit, + // 通风设置 = x.ReeferQuantity, + + // }).ToListAsync(); + + // model.List = data; + // //MemoryStream ms = new(); + // await MiniExcel.SaveAsByTemplateAsync(savePath, path, model); + // //string base64Str = Convert.ToBase64String(ms.ToArray()); + // //ms.Dispose(); + //} + + + /// + /// 海运出口订单集装箱信息导出-分单 + /// + public async Task SeaExportExportPartCtn() + { + var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); + string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单集装箱信息.xlsx"); + FileInfo templateFile = new(path); + if (!templateFile.Exists) + { + var ex = new ApplicationException("未能在下列路径找到模板文件:" + path); + throw ex; + } + var model = new MainCtns(); + + + string savePath = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单集装箱信息-分单 " + NumUtil.GetNo() + ".xlsx"); + var ctnpriceList = await tenantDb.Queryable().Filter(null, true).ToListAsync(); + var contactList = await tenantDb.Queryable().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync(); + + var data = await tenantDb.Queryable().Filter(null, true).Where(x => !x.Deleted) + .InnerJoin((x, y) => x.Pid == y.Id ) + .Select((x, y) => new ZySeaExportCtnInfo + { + Id = x.Id, + 订单编号 = y.MBLNO, + 箱型 = x.Ctn, + 箱号 = x.CntrNo, + 箱量 = x.CtnNum, + 箱封号 = x.SealNo, + 件数 = x.PKGS, + 包装 = x.KindPkgsName, + 体积 = x.CBM, + //VGM重量 = x.WeightKGS, + 毛重 = x.KGS, + 箱重 = x.TareWeight, + 创建者 = x.CreateUserName, + 更新者 = x.UpdateUserName, + 创建时间 = x.CreateTime, + 更新时间 = x.UpdateTime, + + }).ToListAsync(); + + model.List = data; + //MemoryStream ms = new(); + await MiniExcel.SaveAsByTemplateAsync(savePath, path, model); + } + + + ///// + ///// 海运出口订单订舱信息导出-分单 + ///// + //public async Task SeaExportExportPartBook() + //{ + // var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); + // string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单订舱信息.xlsx"); + // FileInfo templateFile = new(path); + // if (!templateFile.Exists) + // { + // var ex = new ApplicationException("未能在下列路径找到模板文件:" + path); + // throw ex; + // } + // var model = new MainBooks(); + + + // string savePath = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单订舱信息" + NumUtil.GetNo() + ".xlsx"); + // var ctnpriceList = await tenantDb.Queryable().Filter(null, true).ToListAsync(); + // var contactList = await tenantDb.Queryable().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync(); + + // var data = await tenantDb.Queryable().Filter(null, true).Where(x => !x.Deleted && x.IsRefund == false && x.IsChangeETD == false) + // .Select(x => new ZySeaExportBookInfo + // { + // Id = x.Id, + // 订单编号 = x.MBLNO, + // 订舱号 = x.BookingNo, + // 船名 = x.Vessel, + // 航次 = x.Voyno, + // 运输条款 = x.Service, + // 船公司 = x.Carrier, + // 约号 = x.ContractNo, + // 签单方式 = x.IssueType, + // 签单份数 = x.NoBill, + // 签发地 = x.IssuePlace, + // 签发时间 = x.IssueDate, + // 订舱代理 = x.Forwarder, + // 海外代理 = x.Agent, + // 开港时间 = x.ETD, + // 截港时间 = x.ClosingDate, + // 截单时间 = x.CloseDocDate, + // 船代 = x.ShipAgency, + // 场站联系人 = x.YardATTN, + // 场站联系电话 = x.YardTel, + // 场站 = x.Yard, + // 箱使需求 = x.ApplyCtnRemark, + + + // 创建者 = x.CreateUserName, + // 创建时间 = x.CreateTime, + // 更新者 = x.UpdateUserName, + // 更新时间 = x.UpdateTime, + // 是否删除 = 0, + + + // }).ToListAsync(); + + // model.List = data; + // //MemoryStream ms = new(); + // await MiniExcel.SaveAsByTemplateAsync(savePath, path, model); + // //string base64Str = Convert.ToBase64String(ms.ToArray()); + // //ms.Dispose(); + //} + + + /// + /// 海运出口订单费用信息导出-分单 + /// + public async Task SeaExportExportPartFee() + { + var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); + string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单费用信息.xlsx"); + FileInfo templateFile = new(path); + if (!templateFile.Exists) + { + var ex = new ApplicationException("未能在下列路径找到模板文件:" + path); + throw ex; + } + var model = new MainFees(); + + + string savePath = Path.Combine(hostEnvironment.WebRootPath, "templates", "订单费用信息-分单 " + NumUtil.GetNo() + ".xlsx"); + + + var data = await tenantDb.Queryable().Filter(null, true).Where(x => !x.Deleted) + .InnerJoin((x, y) => x.BusinessId == y.Id ) + .Select((x, y) => new ZySeaExportFeeInfo + { + Id = x.Id, + 订单编号 = y.MBLNO, + 费用名称 = x.FeeName, + 结算单位 = x.CustomerName, + 费用类型 = x.FeeType == FeeType.Receivable ? 215 : 214, + 币种 = x.Currency, + 数量 = x.Quantity, + 单位 = x.UnitText, + 单价 = x.UnitPrice, + 总价 = x.Amount, + + 创建者 = x.CreateUserName, + 更新者 = x.UpdateUserName, + 创建时间 = x.CreateTime, + 更新时间 = x.UpdateTime, + + }).ToListAsync(); + + model.List = data; + //MemoryStream ms = new(); + await MiniExcel.SaveAsByTemplateAsync(savePath, path, model); + //string base64Str = Convert.ToBase64String(ms.ToArray()); + //ms.Dispose(); + } + } +} diff --git a/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportTestController.cs b/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportTestController.cs new file mode 100644 index 00000000..6af44f28 --- /dev/null +++ b/ds-wms-service/DS.WMS.OpApi/Controllers/SeaExportTestController.cs @@ -0,0 +1,125 @@ +using DS.Module.Core; +using DS.Module.Core.Data; +using DS.WMS.Core.Code.Dtos; +using DS.WMS.Core.Code.Interface; +using DS.WMS.Core.Op.Dtos; +using DS.WMS.Core.Op.Interface; +using Microsoft.AspNetCore.Mvc; + +namespace DS.WMS.OpApi.Controllers; + +/// +/// 集装箱信息服务 +/// +public class SeaExportTestController : ApiController +{ + private readonly ISeaExportTestService _invokeService; + + /// + /// 构造函数 + /// + /// + public SeaExportTestController(ISeaExportTestService invokeService) + { + _invokeService = invokeService; + } + + + /// + /// 导出主表 + /// + /// + [HttpGet] + [Route("SeaExportExport")] + public async Task SeaExportExport() + { + await _invokeService.SeaExportExport(); + } + + /// + /// 海运出口品名信息导出 + /// + /// + [HttpGet] + [Route("SeaExportExportCtnGoods")] + public async Task SeaExportExportCtnGoods() + { + await _invokeService.SeaExportExportCtnGoods(); + } + + + /// + /// 海运出口订单货物信息导出 + /// + /// + [HttpGet] + [Route("SeaExportExportMainGood")] + public async Task SeaExportExportMainGood() + { + await _invokeService.SeaExportExportMainGood(); + } + + /// + /// 海运出口订单集装箱信息导出 + /// + /// + [HttpGet] + [Route("SeaExportExportMainCtn")] + public async Task SeaExportExportMainCtn() + { + await _invokeService.SeaExportExportMainCtn(); + } + /// + /// 海运出口订单订舱信息导出 + /// + /// + [HttpGet] + [Route("SeaExportExportMainBook")] + public async Task SeaExportExportMainBook() + { + await _invokeService.SeaExportExportMainBook(); + } + /// + /// 海运出口订单费用信息导出 + /// + /// + [HttpGet] + [Route("SeaExportExportMainFee")] + public async Task SeaExportExportMainFee() + { + await _invokeService.SeaExportExportMainFee(); + } + + + /// + /// 导出 -分单 + /// + /// + [HttpGet] + [Route("SeaExportExportPart")] + public async Task SeaExportExportPart() + { + await _invokeService.SeaExportExportPart(); + } + + /// + /// 海运出口订单集装箱信息导出-分单 + /// + /// + [HttpGet] + [Route("SeaExportExportPartCtn")] + public async Task SeaExportExportPartCtn() + { + await _invokeService.SeaExportExportPartCtn(); + } + /// + /// 海运出口订单费用信息导出-分单 + /// + /// + [HttpGet] + [Route("SeaExportExportPartFee")] + public async Task SeaExportExportPartFee() + { + await _invokeService.SeaExportExportPartFee(); + } +} \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj index 94f47436..beef5ed5 100644 --- a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj +++ b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj @@ -9,6 +9,14 @@ bin\Debug\net8.0\Api.xml + + + + + + + + diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/海运出口-分单 241108191442847706.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/海运出口-分单 241108191442847706.xlsx new file mode 100644 index 00000000..f6098e3c Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/海运出口-分单 241108191442847706.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/海运出口主单.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/海运出口主单.xlsx new file mode 100644 index 00000000..ce9771b6 Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/海运出口主单.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/海运出口主单241108184849162541.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/海运出口主单241108184849162541.xlsx new file mode 100644 index 00000000..dcf14b2d Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/海运出口主单241108184849162541.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单订舱信息.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单订舱信息.xlsx new file mode 100644 index 00000000..bb4e4cb9 Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单订舱信息.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单订舱信息241108184233237457.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单订舱信息241108184233237457.xlsx new file mode 100644 index 00000000..740c742b Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单订舱信息241108184233237457.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单货物信息.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单货物信息.xlsx new file mode 100644 index 00000000..f3ab18cd Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单货物信息.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单货物信息241108184433107635.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单货物信息241108184433107635.xlsx new file mode 100644 index 00000000..4e733a0a Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单货物信息241108184433107635.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单费用信息-分单 241108191454483488.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单费用信息-分单 241108191454483488.xlsx new file mode 100644 index 00000000..3ff62b6a Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单费用信息-分单 241108191454483488.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单费用信息.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单费用信息.xlsx new file mode 100644 index 00000000..89be717d Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单费用信息.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单费用信息241108184124920113.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单费用信息241108184124920113.xlsx new file mode 100644 index 00000000..cf4199f8 Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单费用信息241108184124920113.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单集装箱信息-分单 241108191449628574.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单集装箱信息-分单 241108191449628574.xlsx new file mode 100644 index 00000000..e3eda7c1 Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单集装箱信息-分单 241108191449628574.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单集装箱信息.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单集装箱信息.xlsx new file mode 100644 index 00000000..4e15a01d Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单集装箱信息.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单集装箱信息241108184324853130.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单集装箱信息241108184324853130.xlsx new file mode 100644 index 00000000..64aa766b Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/订单集装箱信息241108184324853130.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/货物中文品名信息.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/货物中文品名信息.xlsx new file mode 100644 index 00000000..8c267ce4 Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/货物中文品名信息.xlsx differ diff --git a/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/货物中文品名信息241108184454790815.xlsx b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/货物中文品名信息241108184454790815.xlsx new file mode 100644 index 00000000..7864db2b Binary files /dev/null and b/ds-wms-service/DS.WMS.OpApi/wwwroot/templates/货物中文品名信息241108184454790815.xlsx differ