昭阳导出EXCEL修改

dev
cjy 2 weeks ago
parent 9b0d2a1209
commit 78054040cb

@ -1,4 +1,6 @@
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System.Globalization;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace DS.Module.Core.Extensions; namespace DS.Module.Core.Extensions;
@ -32,7 +34,24 @@ public static class DateTimeExtension
var week = new string[] { "周日", "周一", "周二", "周三", "周四", "周五", "周六" }; var week = new string[] { "周日", "周一", "周二", "周三", "周四", "周五", "周六" };
return week[day]; return week[day];
} }
public static int GetWeekOfYear(this DateTime dt, CultureInfo ci)
{
// 获取与当前环境区域性相关的 CultureInfo 对象,或者你可以使用特定的区域性,例如 "zh-CN"
CultureInfo cultureInfo = new CultureInfo("zh-CN");
// 从 CultureInfo 对象获取 Calendar 对象
Calendar calendar = ci.Calendar;
// 定义 CalendarWeekRule通常是使用当前文化的 DateTimeFormat
CalendarWeekRule calendarWeekRule = cultureInfo.DateTimeFormat.CalendarWeekRule;
// 一周的第一天
DayOfWeek firstDayOfWeek = cultureInfo.DateTimeFormat.FirstDayOfWeek;
// 获取指定日期在一年中的周数
int weekOfYear = calendar.GetWeekOfYear(dt, calendarWeekRule, firstDayOfWeek);
return weekOfYear;
}
/// <summary> /// <summary>
/// 获取datetime值 /// 获取datetime值
/// </summary> /// </summary>

@ -18,13 +18,119 @@ namespace DS.WMS.Core.QuarztJobs.Dtos
public class WSLWeeklyItem public class WSLWeeklyItem
{ {
public long CustomerId { get; set; } /// <summary>
/// 状态
/// </summary>
public string? BusinessStatusName { get; set; }
/// <summary>
/// 船公司
/// </summary>
public string Carrier { get; set; }
/// <summary>
/// 货代公司(订舱口)
/// </summary>
public string Forwarder { get; set; }
/// <summary>
/// 约主名称
/// </summary>
public string ContractClientName { get; set; }
/// <summary>
/// 运费协议号(约号)
/// </summary>
public string ContractNo { get; set; }
/// <summary>
/// 主提单号
/// </summary>
public string? MBLNO { get; set; } public string? MBLNO { get; set; }
/// <summary>
/// 委托编号
/// </summary>
public string? CustomerNo { get; set; } public string? CustomerNo { get; set; }
/// <summary>
/// ETD
/// </summary>
public string? ETD { get; set; } public string? ETD { get; set; }
public string? Status { get; set; }
/// <summary>
/// 周数
/// </summary>
public int? Weeks { get; set; }
/// <summary>
/// 装货港 起运港
/// </summary>
public string LoadPort { get; set; }
/// <summary>
/// 卸货港 目的港
/// </summary>
public string DischargePort { get; set; }
/// <summary>
/// Desc:MBL付费方式 t_code_frt
/// </summary>
public string MBLFrt { get; set; }
/// <summary>
/// Desc:单证人员
/// </summary>
public string DocName { get; set; }
/// <summary>
/// 操作员名称
/// </summary>
public string OperatorName { get; set; }
/// <summary>
/// 客服名称
/// </summary>
public string CustomerServiceName { get; set; }
/// <summary>
/// 揽货人
/// </summary>
public string Sale { get; set; }
/// <summary>
/// 航线人员名称 商务
/// </summary>
public string Laner { get; set; }
/// <summary>
/// 船名 t_code_vessel
/// </summary>
public string Vessel { get; set; }
/// <summary>
/// 航次
/// </summary>
public string Voyno { get; set; }
/// <summary>
/// 发货人 t_info_client CUSTNAME
/// </summary>
public string Shipper { get; set; }
/// <summary>
/// 收货人 t_info_client CUSTNAME
/// </summary>
public string Consignee { get; set; }
/// <summary>
/// 通知人 t_info_client CUSTNAME
/// </summary>
public string NotifyParty { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public string? CreateTime { get; set; }
} }
} }

@ -9,6 +9,9 @@ using Microsoft.Extensions.Logging;
using MiniExcelLibs; using MiniExcelLibs;
using Quartz; using Quartz;
using SqlSugar; using SqlSugar;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.Threading;
namespace DS.WMS.Core.QuarztJobs namespace DS.WMS.Core.QuarztJobs
{ {
@ -43,13 +46,13 @@ namespace DS.WMS.Core.QuarztJobs
public async Task Execute(IJobExecutionContext context) public async Task Execute(IJobExecutionContext context)
{ {
logger.LogInformation("开始生成【WSLWeekly报表服务】..."); logger.LogInformation("开始生成【SUNNINESS-CARGOO REPORT报表服务】...");
string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "CargooWeeklyReport.xlsx"); string path = Path.Combine(hostEnvironment.WebRootPath, "templates", "CargooWeeklyReport.xlsx");
FileInfo templateFile = new(path); FileInfo templateFile = new(path);
if (!templateFile.Exists) if (!templateFile.Exists)
{ {
var ex = new ApplicationException("【WSLWeekly报表服务】未能在下列路径找到模板文件:" + path); var ex = new ApplicationException("【SUNNINESS-CARGOO REPORT报表服务】未能在下列路径找到模板文件:" + path);
await ex.LogAsync(db); await ex.LogAsync(db);
throw ex; throw ex;
} }
@ -91,10 +94,17 @@ namespace DS.WMS.Core.QuarztJobs
.OrderBy(x=>x.ETD) .OrderBy(x=>x.ETD)
.Select(x => new WSLWeeklyItem() .Select(x => new WSLWeeklyItem()
{ {
BusinessStatusName = x.BusinessStatusName,
Carrier = x.Carrier,
Forwarder = x.Forwarder,
ContractClientName = x.ContractClientName,
ContractNo = x.ContractNo,
MBLNO = x.MBLNO,
CustomerNo = x.CustomerNo, CustomerNo = x.CustomerNo,
MBLNO = x.MBLNO, ETD = x.ETD.HasValue ? x.ETD.Value.ToString("yyyy-MM-dd") : string.Empty,
ETD = x.ETD.HasValue? x.ETD.Value.ToString("yyyy-MM-dd") : string.Empty, //Weeks = x.ETD.HasValue ? x.ETD.Value.GetWeekOfYear(CultureInfo.CurrentCulture),
Status = x.IsRefund == true? "已退舱":"",
}).ToListAsync(); }).ToListAsync();
@ -126,9 +136,9 @@ namespace DS.WMS.Core.QuarztJobs
var mailResult = await api.SendRequestAsync(HttpMethod.Post, config["TaskMail:MailApiUrl"], mailParams); var mailResult = await api.SendRequestAsync(HttpMethod.Post, config["TaskMail:MailApiUrl"], mailParams);
if (mailResult.IsSuccessStatusCode) if (mailResult.IsSuccessStatusCode)
logger.LogInformation("已发送【WSLWeekly报表服务】..."); logger.LogInformation("已发送【SUNNINESS-CARGOO REPORT报表服务】...");
else else
logger.LogInformation("发送【WSLWeekly报表服务】失败!"); logger.LogInformation("发送【SUNNINESS-CARGOO REPORT报表服务】失败!");
} }
} }
catch (Exception ex) catch (Exception ex)

Loading…
Cancel
Save