jianghaiqing 5 days ago
commit d6a630a47c

@ -67,14 +67,15 @@ namespace DS.WMS.Core.Application.Method
Email = x.Email,
CellPhoneNO = x.CellPhoneNO,
InvoiceRemark = x.InvoiceRemark, //开票要求
CreateByName = x.CreateUserName,
ApplyAmountRMB = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => x.Id == y.ApplicationId && y.Currency == FeeCurrency.RMB_CODE).Sum(y => y.ApplyAmount),
ApplyAmountUSD = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => x.Id == y.ApplicationId && y.Currency == FeeCurrency.USD_CODE).Sum(y => y.ApplyAmount),
//原币金额
OriginalAmountList = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => x.Id == y.ApplicationId)
.GroupBy(y => y.OriginalCurrency).ToList(y => new CurrencyAmount { Currency = y.OriginalCurrency, Amount = y.OriginalAmount })
.GroupBy(y => y.OriginalCurrency).ToList(y => new CurrencyAmount { Currency = y.OriginalCurrency, Amount = SqlFunc.AggregateSum(y.OriginalAmount) })
}).ToQueryPageAsync(request.PageCondition);
if (result.Data.Count > 0)
if (result.Data?.Count > 0)
{
var ids = result.Data.Select(x => x.Id);
var fees = await TenantDb.Queryable<FeeRecord>()
@ -88,9 +89,6 @@ namespace DS.WMS.Core.Application.Method
f.SettlementAmount,
}).ToListAsync();
//关联用户名称
var userIds = result.Data.Select(x => x.CreateBy).Distinct();
var users = await Db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
foreach (var item in result.Data)
{
item.UnsettledList = fees.Where(x => x.ApplicationId == item.Id).GroupBy(x => x.Currency)
@ -99,7 +97,6 @@ namespace DS.WMS.Core.Application.Method
Currency = x.Key,
Amount = x.Sum(y => y.Amount - y.SettlementAmount)
}).ToList();
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
}
//result.AdditionalData = new Dictionary<string, object>

@ -37,9 +37,13 @@ namespace DS.WMS.Core.Invoice.Method
SqlFunc.Subqueryable<ApplicationDetail>().Where(d => d.ApplicationId == a.Id && d.Category == DetailCategory.InvoiceApplication && (d.OriginalAmount - d.OriginalProcessedAmount) != 0).Any())
.Select(a => new InvoiceApplicationDto
{
CreateByName = a.CreateUserName,
AmountRMB = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => a.Id == y.ApplicationId && y.Currency == FeeCurrency.RMB_CODE).Sum(y => y.ApplyAmount - y.ProcessedAmount),
AmountUSD = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => a.Id == y.ApplicationId && y.Currency == FeeCurrency.USD_CODE).Sum(y => y.ApplyAmount - y.ProcessedAmount),
AmountOther = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => a.Id == y.ApplicationId && y.Currency != FeeCurrency.RMB_CODE && y.Currency != FeeCurrency.USD_CODE).Sum(y => y.ApplyAmount - y.ProcessedAmount),
//申请金额
ApplyAmountRMB = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => a.Id == y.ApplicationId && y.Currency == FeeCurrency.RMB_CODE).Sum(y => y.ApplyAmount),
ApplyAmountUSD = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => a.Id == y.ApplicationId && y.Currency == FeeCurrency.USD_CODE).Sum(y => y.ApplyAmount),
//原币金额
OriginalAmountList = SqlFunc.Subqueryable<ApplicationDetail>().Where(y => a.Id == y.ApplicationId)
.GroupBy(y => y.OriginalCurrency).ToList(y => new CurrencyAmount { Currency = y.OriginalCurrency, Amount = SqlFunc.AggregateSum(y.OriginalAmount) })
@ -50,9 +54,6 @@ namespace DS.WMS.Core.Invoice.Method
if (result.Data?.Count > 0)
{
var userIds = result.Data.Select(x => x.CreateBy).Distinct();
var users = await Db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
var orgIds = result.Data.Where(x => x.SaleDeptId.HasValue).Select(x => x.SaleDeptId)
.Union(result.Data.Where(x => x.OrgId.HasValue).Select(x => x.OrgId))
.Distinct();
@ -64,8 +65,6 @@ namespace DS.WMS.Core.Invoice.Method
foreach (var item in result.Data)
{
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
item.SaleDeptName = orgs.Find(x => x.Id == item.SaleDeptId)?.OrgName;
item.OrgName = orgs.Find(x => x.Id == item.OrgId)?.OrgName;

@ -4,6 +4,8 @@ using DS.Module.UserModule;
using DS.WMS.Core.Flow.Entity;
using DS.WMS.Core.Sys.Interface;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Layouts;
using SqlSugar;
namespace DS.WMS.Core
@ -47,6 +49,11 @@ namespace DS.WMS.Core
}
}
/// <summary>
/// 日志记录对象
/// </summary>
public Lazy<ILogger<ServiceBase>> Logger { get; private set; }
/// <summary>
/// 初始化
/// </summary>
@ -58,6 +65,7 @@ namespace DS.WMS.Core
Db = serviceProvider.GetRequiredService<ISqlSugarClient>();
SaasService = serviceProvider.GetRequiredService<ISaasDbService>();
commonService = new Lazy<ICommonService>(serviceProvider.GetRequiredService<ICommonService>());
Logger = new Lazy<ILogger<ServiceBase>>(serviceProvider.GetRequiredService<ILogger<ServiceBase>>());
}
/// <summary>

@ -231,6 +231,7 @@ namespace DS.WMS.Core.Settlement.Method
.InnerJoin<ApplicationDetail>((a, d) => a.Id == d.ApplicationId && d.ApplyAmount - d.ProcessedAmount != 0)
.InnerJoin<FeeRecord>((a, d, f) => d.RecordId == f.Id)
.InnerJoin<SeaExport>((a, d, f, s) => f.BusinessId == s.Id && f.BusinessType == BusinessType.OceanShippingExport)
.Where(request.GetConditionalModels(Db))
.GroupBy((a, d) => a.Id);
if (request.OtherQueryCondition != null)
@ -246,7 +247,6 @@ namespace DS.WMS.Core.Settlement.Method
query = query.Where(a => a.Status == PaymentApplicationStatus.AuditPassed || a.Status == PaymentApplicationStatus.PartialSettlement || a.Status == PaymentApplicationStatus.SettlementCompleted);
}
var whereList = request.GetConditionalModels(Db);
var result = await query.Select(a => new PaymentApplicationDtoV2
{
AmountRMB = a.AmountRMB == null ? 0 : a.AmountRMB.Value, //RMB申请金额
@ -262,7 +262,7 @@ namespace DS.WMS.Core.Settlement.Method
UnSettledOther = SqlFunc.Subqueryable<ApplicationDetail>().Where(d => d.ApplicationId == a.Id && d.Currency != FeeCurrency.RMB_CODE && d.Currency != FeeCurrency.USD_CODE)
.Select(d => SqlFunc.AggregateSum(d.ApplyAmount - d.ProcessedAmount)),
SettlementTypeName = a.SettlementType.StlName, //结算方式
}, true).MergeTable().Where(whereList).ToQueryPageAsync(request.PageCondition);
}, true).MergeTable().ToQueryPageAsync(request.PageCondition);
if (result.Data?.Count > 0)
{

@ -19,7 +19,7 @@ namespace DS.WMS.Core.TaskInteraction.Entity
/// 数据源程序类型名
/// </summary>
[SugarColumn(ColumnDescription = "数据源程序类型名", Length = 100, IsNullable = true)]
public string TypeName { get; set; } = string.Empty;
public string? TypeName { get; set; }
/// <summary>
/// 数据源名称
@ -39,12 +39,6 @@ namespace DS.WMS.Core.TaskInteraction.Entity
[SugarColumn(ColumnDescription = "数据源内容", IsNullable = true)]
public string? Content { get; set; }
/// <summary>
/// 数据源类型
/// </summary>
[SugarColumn(ColumnDescription = "数据源类型")]
public DataProviderType Type { get; set; }
/// <summary>
/// 创建人
/// </summary>
@ -57,34 +51,4 @@ namespace DS.WMS.Core.TaskInteraction.Entity
[SugarColumn(ColumnDescription = "创建时间", IsNullable = false)]
public DateTime CreateTime { get; set; }
}
/// <summary>
/// 数据源类型
/// </summary>
public enum DataProviderType
{
/// <summary>
/// 自定义
/// </summary>
[Description("自定义")]
Custom = 0,
/// <summary>
/// 固定
/// </summary>
[Description("固定")]
Fixed = 1,
/// <summary>
/// 数据库
/// </summary>
[Description("数据库")]
Database = 2,
/// <summary>
/// 网络
/// </summary>
[Description("网络")]
Network = 3
}
}

@ -46,6 +46,12 @@ namespace DS.WMS.Core.TaskInteraction.Entity
[SugarColumn(ColumnDescription = "是否业务邮件")]
public bool IsBusiness { get; set; }
/// <summary>
/// 数据源类型
/// </summary>
[SugarColumn(ColumnDescription = "数据源类型")]
public DataProviderType Type { get; set; }
/// <summary>
/// 数据源提供程序ID
/// </summary>
@ -129,5 +135,47 @@ namespace DS.WMS.Core.TaskInteraction.Entity
/// </summary>
[Description("费用确认")]
CostConfirmation = 6,
/// <summary>
/// 账单
/// </summary>
[Description("账单")]
Bill = 7,
}
/// <summary>
/// 数据源类型
/// </summary>
public enum DataProviderType
{
/// <summary>
/// 默认
/// </summary>
[Description("默认")]
Default = 0,
/// <summary>
/// 自定义
/// </summary>
[Description("自定义")]
Custom = 1,
/// <summary>
/// 固定
/// </summary>
[Description("固定")]
Fixed = 2,
/// <summary>
/// 数据库
/// </summary>
[Description("数据库")]
Database = 3,
/// <summary>
/// 网络
/// </summary>
[Description("网络")]
Network = 4
}
}

@ -0,0 +1,39 @@
using DS.Module.Core;
using DS.WMS.Core.TaskInteraction.Dtos;
using DS.WMS.Core.TaskInteraction.Interface;
using Newtonsoft.Json;
namespace DS.WMS.Core.TaskInteraction.Method.DataProvider
{
/// <summary>
/// 默认网络提供程序
/// </summary>
public class DefaultNetworkProvider : ServiceBase, IDataProvider
{
/// <summary>
/// 初始化
/// </summary>
/// <param name="provider"></param>
public DefaultNetworkProvider(IServiceProvider provider) : base(provider)
{
}
/// <summary>
/// 执行网络请求
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public async Task FetchDataAsync(DataFetchContext context)
{
using (ApiFox api = new())
{
var response = await api.SendRequestAsync(HttpMethod.Get, context.Content);
if (response.IsSuccessStatusCode)
{
var json = await response.Content.ReadAsStringAsync();
context.Data = JsonConvert.DeserializeObject(json);
}
}
}
}
}

@ -1,16 +1,45 @@
using DS.WMS.Core.TaskInteraction.Dtos;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.TaskInteraction.Dtos;
using DS.WMS.Core.TaskInteraction.Entity;
using DS.WMS.Core.TaskInteraction.Interface;
using Microsoft.Extensions.Logging;
namespace DS.WMS.Core.TaskInteraction.Method.Jobs
{
/// <summary>
/// 账单发送定时任务
/// </summary>
public class BillSendingTaskJob : ITaskJob
public class BillSendingTaskJob : ServiceBase, ITaskJob
{
const string BILL_MAIL_TEMPLATE = "BILL_MAIL_TEMPLATE";
/// <summary>
/// 初始化
/// </summary>
/// <param name="serviceProvider"></param>
public BillSendingTaskJob(IServiceProvider serviceProvider) : base(serviceProvider)
{
}
/// <summary>
/// 账单发送
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public async Task ExecuteAsync(TaskJobContext context)
{
var config = await Db.Queryable<SysConfig>().Where(x => x.Code == BILL_MAIL_TEMPLATE).FirstAsync();
if (config == null)
{
Logger.Value.LogWarning("未配置账单邮件模板");
return;
}
long id = long.Parse(config.Value);
var mailTemplate = await TenantDb.Queryable<BusinessTaskMail>().FirstAsync(x => x.Id == id);
MailGenerator generator = new(ServiceProvider);
var model = await generator.GetBusinessModelAsync(mailTemplate, context.JobInfo.BusinessId, context.JobInfo.BusinessType);
await generator.SendAsync(mailTemplate, model);
}
}
}

@ -78,7 +78,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
BusinessType = bsType
};
if (taskMail.Provider == null)
if (taskMail.Type == DataProviderType.Default)
{
actionManager ??= ServiceProvider.GetRequiredService<IActionManagerService>();
model.Primary = await actionManager.GetBusinessDataAsync(bsId, bsType.GetValueOrDefault());
@ -86,19 +86,35 @@ namespace DS.WMS.Core.TaskInteraction.Method
else
{
IDataProvider? dataProvider = null;
switch (taskMail.Provider.Type)
BusinessDataProvider? provider1 = null;
switch (taskMail.Type)
{
case DataProviderType.Custom:
if (string.IsNullOrEmpty(taskMail.Provider.TypeName))
if (taskMail.ProviderId == null)
return model;
var type = Type.GetType(taskMail.Provider.TypeName, true);
provider1 = await TenantDb.Queryable<BusinessDataProvider>().Where(x => x.Id == taskMail.ProviderId)
.Select(x => new BusinessDataProvider
{
TypeName = x.TypeName,
Content = x.Content
}).FirstAsync();
var type = Type.GetType(provider1.TypeName, true);
dataProvider = ConstructorExtensions.CreateInstance(type, [ServiceProvider]) as IDataProvider;
dataProvider ??= ConstructorExtensions.CreateInstance(type) as IDataProvider;
break;
case DataProviderType.Fixed:
model.Primary = JsonConvert.DeserializeObject<dynamic>(taskMail.Content!);
if (taskMail.ProviderId == null)
return model;
provider1 = await TenantDb.Queryable<BusinessDataProvider>().Where(x => x.Id == taskMail.ProviderId)
.Select(x => new BusinessDataProvider
{
TypeName = x.TypeName,
Content = x.Content
}).FirstAsync();
model.Primary = JsonConvert.DeserializeObject<dynamic>(provider1.Content);
break;
case DataProviderType.Database:
@ -106,7 +122,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
break;
case DataProviderType.Network:
dataProvider = new DefaultNetworkProvider(ServiceProvider);
break;
}
@ -117,7 +133,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
ServiceProvider = ServiceProvider,
BusinessId = bsId,
BusinessType = bsType,
Content = taskMail.Content,
Content = provider1.Content,
};
await dataProvider.FetchDataAsync(context);
model.Primary = context.Data;
@ -367,12 +383,14 @@ namespace DS.WMS.Core.TaskInteraction.Method
long tenantId = long.Parse(User.TenantId);
string requestUrl = config["TaskMail:FileBaseUrl"] + config["TaskMail:SQLPrint"];
object? obj = templateModel.GetPropertyValue(nameof(MailTemplateModel.Primary), Flags.InstancePublic);
string json = JsonConvert.SerializeObject(obj ??= new { Id = templateModel.BusinessId });
foreach (var item in mailConfig.Attachments)
{
object? obj = templateModel.GetPropertyValue(nameof(MailTemplateModel.Primary), Flags.InstancePublic);
var req = new OpenPrintReq
{
ParamJsonStr = JsonConvert.SerializeObject(obj),
ParamJsonStr = json,
PrintType = ((int)FileFormat.PDF).ToString(),
TemplateId = item.TemplateId,
TenantId = tenantId

@ -3264,8 +3264,8 @@ namespace DS.WMS.Core.TaskPlat.Method
|| s.CustomerNum.Contains(queryDto.OtherQueryCondition.BusinessNo)
|| t.TASK_NO.Contains(queryDto.OtherQueryCondition.BusinessNo)
|| (isHasOrderParentIdList == true && orderParentIdList!.Contains(s.Id)))
.WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortLoadCode), (t, a, s) => queryDto.OtherQueryCondition.PortLoadCode == s.LoadPortCode || portLoadTaskIdList.Contains(t.Id))
.WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortDischargeCode), (t, a, s) => queryDto.OtherQueryCondition.PortDischargeCode == s.DischargePortCode || portDischargeTaskIdList.Contains(t.Id))
.WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortLoadCode), (a, t, s) => queryDto.OtherQueryCondition.PortLoadCode == s.LoadPortCode || portLoadTaskIdList.Contains(t.Id))
.WhereIF(!string.IsNullOrEmpty(queryDto.OtherQueryCondition.PortDischargeCode), (a, t, s) => queryDto.OtherQueryCondition.PortDischargeCode == s.DischargePortCode || portDischargeTaskIdList.Contains(t.Id))
.GroupBy((a, t) => new { t.TASK_TYPE, t.STATUS, a.Status, })
.Select((a, t) => new TaskGroupTotal()
{

Loading…
Cancel
Save