You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1074 lines
44 KiB
C#

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;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public SeaExportTestService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
config = serviceProvider.GetRequiredService<Microsoft.Extensions.Configuration.IConfiguration>();
hostEnvironment = serviceProvider.GetRequiredService<IWebHostEnvironment>();
}
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 { 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 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 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 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 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<ZySeaExportMain> List { get; set; }
}
public class CtnGoods
{
public List<ZySeaExportCtnGoods> List { get; set; }
}
public class MainGoods
{
public List<ZySeaExportGoodsInfo> List { get; set; }
}
public class MainCtns
{
public List<ZySeaExportCtnInfo> List { get; set; }
}
public class MainBooks
{
public List<ZySeaExportBookInfo> List { get; set; }
}
public class MainFees
{
public List<ZySeaExportFeeInfo> List { get; set; }
}
/// <summary>
/// 海运出口主单导出
/// </summary>
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<BusinessCtnPrice>().Filter(null, true).ToListAsync();
var contactList = await tenantDb.Queryable<BusinessOrderContact>().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync();
var remarkList = await tenantDb.Queryable<SeaExportRemark>().Filter(null, true).ToListAsync();
var data = await tenantDb.Queryable<SeaExport>().Filter(null, true).Where(x => !x.Deleted && x.IsRefund == false && x.IsChangeETD == false)
.LeftJoin<BusinessFeeStatus>((x, y) => x.Id == y.BusinessId)
.Select((x, y) => new ZySeaExportMain
{
Id =x.Id,
= x.BLType,
code = x.CustomerNo,
= x.CustomerNum,
= 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.Laner,
= x.OperatorName,
= x.CustomerServiceName,
= 2,
= x.ETD,
= x.ATA,
= 0,
= x.CntrTotal,
= x.ATD,
= "",
= x.GoodsCompleteTime,
ATA = x.ATA,
= x.LoadPortCode,
= x.DischargePortCode,
=x.ShipperCn,
= x.ContractNo
}).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 remark1 = remarkList.FirstOrDefault(a => a.Pid == item.Id && a.RemarkType =="1" );
if (remark1.IsNotNull())
{
item. = remark1.Remark;
}
var remark2 = remarkList.FirstOrDefault(a => a.Pid == item.Id && a.RemarkType == "2");
if (remark2.IsNotNull())
{
item. = remark2.Remark;
}
var remark3 = remarkList.FirstOrDefault(a => a.Pid == item.Id && a.RemarkType == "3");
if (remark3.IsNotNull())
{
item. = remark3.Remark;
}
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();
}
/// <summary>
/// 海运出口品名信息导出
/// </summary>
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<OpCtnGoods>().Filter(null, true).Where(x => !x.Deleted )
.InnerJoin<SeaExport>((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.CustomerNo,
= x.CreateUserName,
= x.CreateTime,
= x.UpdateTime,
}).ToListAsync();
model.List = data;
await MiniExcel.SaveAsByTemplateAsync(savePath, path, model);
}
/// <summary>
/// 海运出口订单货物信息导出
/// </summary>
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<BusinessCtnPrice>().Filter(null, true).ToListAsync();
var contactList = await tenantDb.Queryable<BusinessOrderContact>().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync();
var data = await tenantDb.Queryable<SeaExport>().Filter(null, true).Where(x => !x.Deleted && x.IsRefund == false && x.IsChangeETD == false)
.Select(x => new ZySeaExportGoodsInfo
{
Id = x.Id,
= x.CustomerNo,
= x.Marks,
= x.GoodsName,
= x.Description,
= 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,
= x.MBLNO,
}).ToListAsync();
model.List = data;
//MemoryStream ms = new();
await MiniExcel.SaveAsByTemplateAsync(savePath, path, model);
//string base64Str = Convert.ToBase64String(ms.ToArray());
//ms.Dispose();
}
/// <summary>
/// 海运出口订单集装箱信息导出
/// </summary>
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<BusinessCtnPrice>().Filter(null, true).ToListAsync();
var contactList = await tenantDb.Queryable<BusinessOrderContact>().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync();
var data = await tenantDb.Queryable<OpCtn>().Filter(null, true).Where(x => !x.Deleted)
.InnerJoin<SeaExport>((x, y) => x.BSNO == y.Id.ToString() && y.IsRefund == false && y.IsChangeETD == false)
.Select((x, y) => new ZySeaExportCtnInfo
{
Id = x.Id,
= y.CustomerNo,
= 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);
}
/// <summary>
/// 海运出口订单订舱信息导出
/// </summary>
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<BusinessCtnPrice>().Filter(null, true).ToListAsync();
var contactList = await tenantDb.Queryable<BusinessOrderContact>().Filter(null, true).ToListAsync();
var data = await tenantDb.Queryable<SeaExport>().Filter(null, true).Where(x => !x.Deleted && x.IsRefund == false && x.IsChangeETD == false)
.Select(x => new ZySeaExportBookInfo
{
Id = x.Id,
= x.CustomerNo,
= x.BookingNo,
= x.Vessel,
= string.IsNullOrEmpty(x.Voyno)?x.InnerVoyno: x.Voyno,
= x.Service,
= x.MBLFrt,
= 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.MBLNO,
= x.CreateUserName,
= x.CreateTime,
= x.UpdateUserName,
= x.UpdateTime,
= 0,
}).ToListAsync();
foreach (var item in data)
{
var yard = contactList.FirstOrDefault(a => a.BusinessId == item.Id && a.CustomerType == "yard");
if (yard.IsNotNull())
{
item. = yard.Name;
item. = yard.Tel;
}
var booking = contactList.FirstOrDefault(a => a.BusinessId == item.Id && a.CustomerType == "booking");
if (booking.IsNotNull())
{
item. = booking.Name;
item. = booking.Tel;
item. = booking.Email;
//item.订舱电话 =
}
var agent = contactList.FirstOrDefault(a => a.BusinessId == item.Id && a.CustomerType == "agent");
if (agent.IsNotNull())
{
item. = agent.Name;
item. = agent.Tel;
}
}
model.List = data;
//MemoryStream ms = new();
await MiniExcel.SaveAsByTemplateAsync(savePath, path, model);
//string base64Str = Convert.ToBase64String(ms.ToArray());
//ms.Dispose();
}
/// <summary>
/// 海运出口订单费用信息导出
/// </summary>
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<FeeRecord>().Filter(null, true).Where(x => !x.Deleted)
.InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id && y.IsRefund == false && y.IsChangeETD == false)
.Select((x, y) => new ZySeaExportFeeInfo
{
Id = x.Id,
= y.CustomerNo,
= 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();
}
/// <summary>
/// 海运出口导出-分单
/// </summary>
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<BusinessCtnPrice>().Filter(null, true).ToListAsync();
var contactList = await tenantDb.Queryable<BusinessOrderContact>().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync();
var remarkList = await tenantDb.Queryable<SeaExportRemark>().Filter(null, true).ToListAsync();
var data = await tenantDb.Queryable<SeaExportBillManage>().Filter(null, true).Where(x => !x.Deleted)
.InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
.LeftJoin<BusinessFeeStatus>((x, y,z) => z.BusinessId == y.Id)
.Select((x, y,z) => new ZySeaExportMain
{
Id = x.Id,
= "分单",
code = y.CustomerNo,
= y.CustomerNum,
= 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.Laner,
= y.OperatorName,
= y.CustomerServiceName,
= 2,
= y.ETD,
= y.ATA,
= 0,
= x.CntrTotal,
= x.ATD,
= "",
= y.GoodsCompleteTime,
ATA = y.ATA,
= y.LoadPortCode,
= y.DischargePortCode,
= x.ShipperCn,
= y.ContractNo,
= x.HBLNO
}).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 remark1 = remarkList.FirstOrDefault(a => a.Pid == item.Id && a.RemarkType == "1");
if (remark1.IsNotNull())
{
item. = remark1.Remark;
}
var remark2 = remarkList.FirstOrDefault(a => a.Pid == item.Id && a.RemarkType == "2");
if (remark2.IsNotNull())
{
item. = remark2.Remark;
}
var remark3 = remarkList.FirstOrDefault(a => a.Pid == item.Id && a.RemarkType == "3");
if (remark3.IsNotNull())
{
item. = remark3.Remark;
}
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();
}
///// <summary>
///// 海运出口品名信息导出-分单
///// </summary>
//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<SeaExportBillManageCtn>().Filter(null, true).Where(x => !x.Deleted)
// .InnerJoin<SeaExportBillManage>((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);
//}
///// <summary>
///// 海运出口订单货物信息导出-分单
///// </summary>
//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<BusinessCtnPrice>().Filter(null, true).ToListAsync();
// var contactList = await tenantDb.Queryable<BusinessOrderContact>().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync();
// var data = await tenantDb.Queryable<SeaExportBillManage>().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();
//}
/// <summary>
/// 海运出口订单集装箱信息导出-分单
/// </summary>
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<BusinessCtnPrice>().Filter(null, true).ToListAsync();
var contactList = await tenantDb.Queryable<BusinessOrderContact>().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync();
var data = await tenantDb.Queryable<SeaExportBillManageCtn>().Filter(null, true).Where(x => !x.Deleted)
.InnerJoin<SeaExportBillManage>((x, y) => x.Pid == y.Id )
.LeftJoin<SeaExport>((x, y,z) => z.Id == y.BusinessId)
.Select((x, y,z) => new ZySeaExportCtnInfo
{
Id = x.Id,
= z.CustomerNo,
= 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);
}
///// <summary>
///// 海运出口订单订舱信息导出-分单
///// </summary>
//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<BusinessCtnPrice>().Filter(null, true).ToListAsync();
// var contactList = await tenantDb.Queryable<BusinessOrderContact>().Filter(null, true).Where(x => x.CustomerType == "controller").ToListAsync();
// var data = await tenantDb.Queryable<SeaExport>().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();
//}
/// <summary>
/// 海运出口订单费用信息导出-分单
/// </summary>
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<FeeRecord>().Filter(null, true).Where(x => !x.Deleted)
.InnerJoin<SeaExportBillManage>((x, y) => x.BusinessId == y.Id )
.LeftJoin<SeaExport>((x, y, z) => z.Id == y.BusinessId)
.Select((x, y,z) => new ZySeaExportFeeInfo
{
Id = x.Id,
= z.CustomerNo,
= 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();
}
}
}