导出昭阳数据

dev
cjy 2 weeks ago
parent 7e149240df
commit 9c465fce4c

@ -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
{
/// <summary>
/// 导出海运出口主表
/// </summary>
/// <returns></returns>
public Task SeaExportExport();
/// <summary>
/// 海运出口品名信息导出
/// </summary>
public Task SeaExportExportCtnGoods();
/// <summary>
/// 海运出口订单货物信息导出
/// </summary>
public Task SeaExportExportMainGood();
/// <summary>
/// 海运出口订单集装箱信息导出
/// </summary>
public Task SeaExportExportMainCtn();
/// <summary>
/// 海运出口订单订舱信息导出
/// </summary>
public Task SeaExportExportMainBook();
/// <summary>
/// 海运出口订单费用信息导出
/// </summary>
public Task SeaExportExportMainFee();
/// <summary>
/// 导出海运出口分单
/// </summary>
/// <returns></returns>
public Task SeaExportExportPart();
///// <summary>
///// 海运出口品名信息导出分单
///// </summary>
//public Task SeaExportExportCtnGoodsPart();
///// <summary>
///// 海运出口订单货物信息导出分单
///// </summary>
//public Task SeaExportExportPartGoodPart();
/// <summary>
/// 海运出口订单集装箱信息导出分单
/// </summary>
public Task SeaExportExportPartCtn();
///// <summary>
///// 海运出口订单订舱信息导出分单
///// </summary>
//public Task SeaExportExportPartBook();
/// <summary>
/// 海运出口订单费用信息导出分单
/// </summary>
public Task SeaExportExportPartFee();
}

@ -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;
/// <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 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<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 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.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();
}
/// <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.MBLNO,
= 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.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 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.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);
}
/// <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).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 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.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();
}
/// <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 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 = 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();
}
///// <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 )
.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);
}
///// <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 )
.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();
}
}
}

@ -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;
/// <summary>
/// 集装箱信息服务
/// </summary>
public class SeaExportTestController : ApiController
{
private readonly ISeaExportTestService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public SeaExportTestController(ISeaExportTestService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 导出主表
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("SeaExportExport")]
public async Task SeaExportExport()
{
await _invokeService.SeaExportExport();
}
/// <summary>
/// 海运出口品名信息导出
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("SeaExportExportCtnGoods")]
public async Task SeaExportExportCtnGoods()
{
await _invokeService.SeaExportExportCtnGoods();
}
/// <summary>
/// 海运出口订单货物信息导出
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("SeaExportExportMainGood")]
public async Task SeaExportExportMainGood()
{
await _invokeService.SeaExportExportMainGood();
}
/// <summary>
/// 海运出口订单集装箱信息导出
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("SeaExportExportMainCtn")]
public async Task SeaExportExportMainCtn()
{
await _invokeService.SeaExportExportMainCtn();
}
/// <summary>
/// 海运出口订单订舱信息导出
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("SeaExportExportMainBook")]
public async Task SeaExportExportMainBook()
{
await _invokeService.SeaExportExportMainBook();
}
/// <summary>
/// 海运出口订单费用信息导出
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("SeaExportExportMainFee")]
public async Task SeaExportExportMainFee()
{
await _invokeService.SeaExportExportMainFee();
}
/// <summary>
/// 导出 -分单
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("SeaExportExportPart")]
public async Task SeaExportExportPart()
{
await _invokeService.SeaExportExportPart();
}
/// <summary>
/// 海运出口订单集装箱信息导出-分单
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("SeaExportExportPartCtn")]
public async Task SeaExportExportPartCtn()
{
await _invokeService.SeaExportExportPartCtn();
}
/// <summary>
/// 海运出口订单费用信息导出-分单
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("SeaExportExportPartFee")]
public async Task SeaExportExportPartFee()
{
await _invokeService.SeaExportExportPartFee();
}
}

@ -9,6 +9,14 @@
<DocumentationFile>bin\Debug\net8.0\Api.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Content Remove="wwwroot\templates\海运出口主单.xlsx" />
</ItemGroup>
<ItemGroup>
<None Include="wwwroot\templates\海运出口主单.xlsx" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DS.Module.AutofacModule\DS.Module.AutofacModule.csproj" />
<ProjectReference Include="..\DS.Module.Core\DS.Module.Core.csproj" />

Loading…
Cancel
Save