银行流水,进项发票

dev
douhandong 1 month ago
parent 345479d530
commit e9b78eecbf

@ -16,7 +16,7 @@ namespace DS.Module.QuartzModuleInstall
{
// 配置 Quartz
q.UseMicrosoftDependencyInjectionJobFactory();
q.AddJob<InInvoiceJob>(opts => opts.WithIdentity(jobKey));
q.AddTrigger(opts => opts
.ForJob(jobKey)
@ -27,21 +27,22 @@ namespace DS.Module.QuartzModuleInstall
});
//打印时间 使用cron表达式
//var TimeJobjobKey = new JobKey("TimeJob");
//获取银行流水
var BankStatementKey = new JobKey("BankStatement");
//services.AddQuartz(q =>
//{
// // 配置 Quartz
// q.UseMicrosoftDependencyInjectionJobFactory();
services.AddQuartz(q =>
{
// 配置 Quartz
q.UseMicrosoftDependencyInjectionJobFactory();
// q.AddJob<TimeJob>(opts => opts.WithIdentity(TimeJobjobKey));
// q.AddTrigger(opts => opts
// .ForJob(TimeJobjobKey)
// .WithIdentity("Time-trigger")
// .WithCronSchedule("0 0/1 * 1/1 * ? *"));
//});
q.AddJob<BankStatementJob>(opts => opts.WithIdentity(BankStatementKey));
q.AddTrigger(opts => opts
.ForJob(BankStatementKey)
.WithIdentity("BankStatement-trigger")
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(60)
.RepeatForever()));
});
// 添加 Quartz 主机服务

@ -0,0 +1,241 @@
using DS.Module.Core.Data;
using DS.Module.Core;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Fee.Entity
{
/// <summary>
/// 银行流水
/// </summary>
[SqlSugar.SugarTable("bank_statement", "银行流水")]
public class BankStatement : BaseModel<long>
{
/// <summary>
/// 客户名
/// </summary>
public string Custom { get; set; }
/// <summary>
/// 银行名
/// </summary>
public string BankName { get; set; }
/// <summary>
/// 账户名
/// </summary>
public string AccountName { get; set; }
/// <summary>
/// 账户id
/// </summary>
public string AccountId { get; set; }
/// <summary>
/// 交易类型
/// </summary>
public string TransactionType { get; set; }
/// <summary>
/// 业务类型
/// </summary>
public string BusinessType { get; set; }
/// <summary>
/// 付款人开户行号
/// </summary>
public string AccountHoldingBankNumberOfPayer { get; set; }
/// <summary>
/// 付款人开户行名
/// </summary>
public string PayerAccountBank { get; set; }
/// <summary>
/// 付款人账号
/// </summary>
public string PayerAccountNumber { get; set; }
/// <summary>
/// 付款人名称
/// </summary>
public string PayerName { get; set; }
/// <summary>
/// 收款人开户行行号
/// </summary>
public string AccountHoldingBankNumberOfPayee { get; set; }
/// <summary>
/// 收款人开户行名
/// </summary>
public string PayeeAccountBank { get; set; }
/// <summary>
/// 收款人账号
/// </summary>
public string PayeeAccountNumber { get; set; }
/// <summary>
/// 收款人名称
/// </summary>
public string PayeeName { get; set; }
/// <summary>
/// 交易日期
/// </summary>
public string TransactionDate { get; set; }
/// <summary>
/// 交易时间
/// </summary>
public string TransactionTime { get; set; }
/// <summary>
/// 交易货币
/// </summary>
public string TradeCurrency { get; set; }
/// <summary>
/// 交易金额
/// </summary>
public string TradeAmount { get; set; }
/// <summary>
/// 交易后余额
/// </summary>
public string AfterTransactionBalance { get; set; }
/// <summary>
/// 起息日期
/// </summary>
public string ValueDate { get; set; }
/// <summary>
/// 汇率
/// </summary>
public string ExchangeRate { get; set; }
/// <summary>
/// 交易流水号
/// </summary>
public string TransactionReferenceNumber { get; set; }
/// <summary>
/// 客户申请号
/// </summary>
public string OnlineBankingTransactionRef { get; set; }
/// <summary>
/// 客户业务编号
/// </summary>
public string CustomerTransactionRef { get; set; }
/// <summary>
/// 凭证类型
/// </summary>
public string VoucherType { get; set; }
/// <summary>
/// 凭证号码
/// </summary>
public string VoucherNumber { get; set; }
/// <summary>
/// 记录标识号
/// </summary>
public string RecordID { get; set; }
/// <summary>
/// 摘要
/// </summary>
public string Reference { get; set; }
/// <summary>
/// 用途
/// </summary>
public string Purpose { get; set; }
/// <summary>
/// 交易附言
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remarks { get; set; }
/// <summary>
/// 预留项1
/// </summary>
public string Reserve1 { get; set; }
/// <summary>
/// 预留项2
/// </summary>
public string Reserve2 { get; set; }
/// <summary>
/// 预留项3
/// </summary>
public string Reserve3 { get; set; }
/// <summary>
/// 名义付款人开户行行号
/// </summary>
public string OpeningBankNumberOfNominalPayer { get; set; }
/// <summary>
/// 名义付款人开户行名
/// </summary>
public string OpeningBankNameOfNominalPayer { get; set; }
/// <summary>
/// 名义付款人账号
/// </summary>
public string AccountNumberOfNominalPayer { get; set; }
/// <summary>
/// 名义付款人名称
/// </summary>
public string NameOfNominalPayer { get; set; }
/// <summary>
/// 名义收款人开户行行号
/// </summary>
public string OpeningBankNumberOfNominalPayee { get; set; }
/// <summary>
/// 名义收款人开户行名
/// </summary>
public string OpeningBankNameOfNominalPayee { get; set; }
/// <summary>
/// 名义收款人账号
/// </summary>
public string AccountNumberOfNominalPayee { get; set; }
/// <summary>
/// 名义收款人名称
/// </summary>
public string NameOfNominalPayee { get; set; }
/// <summary>
/// nas盘文件路径
/// </summary>
public string FilePaths { get; set; }
/// <summary>
/// 机构Id
/// </summary>
public long OrgId { get; set; }
}
}

@ -1,22 +0,0 @@
using DS.WMS.Core.HangfireJob.Interface;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Jobs
{
public class TimeJob : IJob
{
public async Task Execute(IJobExecutionContext context)
{
Console.WriteLine($"当前时间: {DateTime.Now}");
}
}
}

@ -0,0 +1,38 @@
using DS.WMS.Core.QuarztJobs.Interface;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Jobs
{
/// <summary>
/// 定时任务-获取银行流水
/// </summary>
public class BankStatementJob : IJob
{
private readonly IBankStatementService _bank;
public BankStatementJob(IBankStatementService bank)
{
_bank = bank;
}
public async Task Execute(IJobExecutionContext context)
{
//定时获取银行流水
try
{
await _bank.GetBankStatement();
Console.WriteLine($"定时获取银行流水: {DateTime.Now}");
}
catch (Exception ex)
{
Console.WriteLine($"定时获取银行流水报错: {DateTime.Now};错误内容{ex.Message}");
}
}
}
}

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.QuarztJobs.Dtos
{
public class BankStatementModel
{
}
public class GetBankStatementPost
{
/// <summary>
/// 公司名称
/// </summary>
public string AccountName { get; set; }
/// <summary>
/// 公司识别码
/// </summary>
public string AccountKey { get; set; }
/// <summary>
/// 开始时间
/// </summary>
public string BeginDate { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public string EndDate { get; set; }
}
public class GetBankStatementPostOutput
{
public List<BankStatementData> result { get; set; }
}
public class BankStatementData
{
public string Custom { get; set; }
public string BankName { get; set; }
public string AccountName { get; set; }
public string AccountId { get; set; }
public string TransactionType { get; set; }
public string BusinessType { get; set; }
public string AccountHoldingBankNumberOfPayer { get; set; }
public string PayerAccountBank { get; set; }
public string PayerAccountNumber { get; set; }
public string PayerName { get; set; }
public string AccountHoldingBankNumberOfPayee { get; set; }
public string PayeeAccountBank { get; set; }
public string PayeeAccountNumber { get; set; }
public string PayeeName { get; set; }
public string TransactionDate { get; set; }
public string TransactionTime { get; set; }
public string TradeCurrency { get; set; }
public string TradeAmount { get; set; }
public string AfterTransactionBalance { get; set; }
public string ValueDate { get; set; }
public string ExchangeRate { get; set; }
public string TransactionReferenceNumber { get; set; }
public string OnlineBankingTransactionRef { get; set; }
public string CustomerTransactionRef { get; set; }
public string VoucherType { get; set; }
public string VoucherNumber { get; set; }
public string RecordID { get; set; }
public string Reference { get; set; }
public string Purpose { get; set; }
public string Remark { get; set; }
public string Remarks { get; set; }
public string Reserve1 { get; set; }
public string Reserve2 { get; set; }
public string Reserve3 { get; set; }
public string OpeningBankNumberOfNominalPayer { get; set; }
public string OpeningBankNameOfNominalPayer { get; set; }
public string AccountNumberOfNominalPayer { get; set; }
public string NameOfNominalPayer { get; set; }
public string OpeningBankNumberOfNominalPayee { get; set; }
public string OpeningBankNameOfNominalPayee { get; set; }
public string AccountNumberOfNominalPayee { get; set; }
public string NameOfNominalPayee { get; set; }
public DateTime CreateTime { get; set; }
public string FilePaths { get; set; }
}
}

@ -4,12 +4,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.HangfireJob.Dtos
{
public class InInvoiceModel
{
}
namespace DS.WMS.Core.QuarztJobs.Dtos
{
/// <summary>
/// 请求获取进项发票接口参数
/// </summary>

@ -1,4 +1,4 @@
using DS.WMS.Core.HangfireJob.Interface;
using DS.WMS.Core.QuarztJobs.Interface;
using Quartz;
namespace DS.WMS.Core.Jobs

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.QuarztJobs.Interface
{
public interface IBankStatementService
{
/// <summary>
/// 定时获取银行流水数据
/// </summary>
/// <param name="Id"></param>
/// <param name="tenantDb"></param>
/// <returns></returns>
Task GetBankStatement();
}
}

@ -7,7 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.HangfireJob.Interface
namespace DS.WMS.Core.QuarztJobs.Interface
{
public interface IInInvoiceJobService
{

@ -0,0 +1,141 @@
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Invoice.Entity;
using DS.WMS.Core.QuarztJobs.Dtos;
using DS.WMS.Core.QuarztJobs.Interface;
using DS.WMS.Core.QuarztJobs.Other;
using DS.WMS.Core.Sys.Entity;
using Masuit.Tools;
using Microsoft.AspNet.SignalR.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.QuarztJobs.Method
{
/// <summary>
/// 银行流水
/// </summary>
public class BankStatementService : IBankStatementService
{
private static readonly HttpClient _httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };
ISqlSugarClient? db;
public BankStatementService(IServiceProvider serviceProvider)
{
db = serviceProvider.GetRequiredService<ISqlSugarClient>();
}
public async Task GetBankStatement()
{
//获取组织机构请求授权列表
if (db == null)
{
return;
}
var orgauthlist = db.Queryable<SysOrgAuth>().ClearFilter().Where(t => t.Deleted == false && t.Type == "BankStatement").ToList();
//遍历授权数据集
foreach (var item in orgauthlist)
{
//组织请求远程接口api数据
GetBankStatementPost model = new GetBankStatementPost();
model.AccountName = item.Key; // "青岛东胜伟业软件有限公司";
model.AccountKey = item.Secret;// "bbb4ce881f31c954e4d18018b41126d4";
model.BeginDate = DateTime.Now.AddDays(-1).ToString("yyyyMMdd"); //往前查24小时的银行流水数据
model.EndDate = DateTime.Now.ToString("yyyyMMdd");
var result = await HttpHellp.PostAsync("http://47.104.90.170:9876/sync", JsonConvert.SerializeObject(model));
List<BankStatement> datalist = new List<BankStatement>();
//处理返回结果
var info = JsonConvert.DeserializeObject<GetBankStatementPostOutput>(result);
if (info != null && info.result != null)
{
var dbLink = await db.Queryable<Module.SqlSugar.SysTenantLink>().ClearFilter().Where(t => t.TenantId == item.TenantId).FirstAsync();
SqlSugarClient? tenantDb = null;
//查询租户数据库中是否有当前数据
tenantDb = new SqlSugarClient(new ConnectionConfig
{
ConfigId = dbLink.Id,
ConnectionString = dbLink.Connection,
DbType = dbLink.DbType,
IsAutoCloseConnection = true
});
var listdt = info.result.Select(t => t.TransactionReferenceNumber).ToList();
var ininviceinfo = tenantDb.Queryable<BankStatement>().Where(x =>listdt .Contains(x.TransactionReferenceNumber)).ToList();
foreach (var itemdata in info.result)
{
//数据库中银行流水为空,则添加银行流水数据数据
if (ininviceinfo.Where(t => t.TransactionReferenceNumber == itemdata.TransactionReferenceNumber).Count() == 0)
{
BankStatement bs = new BankStatement();
bs.Id = SnowFlakeSingle.Instance.NextId();
bs.OrgId = item.OrgId;
bs.Custom = itemdata.Custom;
bs.BankName = itemdata.BankName;
bs.AccountName = itemdata.AccountName;
bs.AccountId = itemdata.AccountId;
bs.TransactionType = itemdata.TransactionType;
bs.BusinessType = itemdata.BusinessType;
bs.AccountHoldingBankNumberOfPayer = itemdata.AccountHoldingBankNumberOfPayer;
bs.PayerAccountBank = itemdata.PayerAccountBank;
bs.PayerAccountNumber = itemdata.PayerAccountNumber;
bs.PayerName = itemdata.PayerName;
bs.AccountHoldingBankNumberOfPayee = itemdata.AccountHoldingBankNumberOfPayee;
bs.PayeeAccountBank = itemdata.PayeeAccountBank;
bs.PayeeAccountNumber = itemdata.PayeeAccountNumber;
bs.PayeeName = itemdata.PayeeName;
bs.TransactionDate = itemdata.TransactionDate;
bs.TransactionTime = itemdata.TransactionTime;
bs.TradeCurrency = itemdata.TradeCurrency;
bs.TradeAmount = itemdata.TradeAmount;
bs.AfterTransactionBalance = itemdata.AfterTransactionBalance;
bs.ValueDate = itemdata.ValueDate;
bs.ExchangeRate = itemdata.ExchangeRate;
bs.TransactionReferenceNumber = itemdata.TransactionReferenceNumber;
bs.OnlineBankingTransactionRef = itemdata.OnlineBankingTransactionRef;
bs.CustomerTransactionRef = itemdata.CustomerTransactionRef;
bs.VoucherType = itemdata.VoucherType;
bs.VoucherNumber = itemdata.VoucherNumber;
bs.RecordID = itemdata.RecordID;
bs.Reference = itemdata.Reference;
bs.Purpose = itemdata.Purpose;
bs.Remark = itemdata.Remark;
bs.Remarks = itemdata.Remarks;
bs.Reserve1 = itemdata.Reserve1;
bs.Reserve2 = itemdata.Reserve2;
bs.Reserve3 = itemdata.Reserve3;
bs.OpeningBankNumberOfNominalPayer = itemdata.OpeningBankNumberOfNominalPayer;
bs.OpeningBankNameOfNominalPayer = itemdata.OpeningBankNameOfNominalPayer;
bs.AccountNumberOfNominalPayer = itemdata.AccountNumberOfNominalPayer;
bs.NameOfNominalPayer = itemdata.NameOfNominalPayer;
bs.OpeningBankNumberOfNominalPayee = itemdata.OpeningBankNumberOfNominalPayee;
bs.OpeningBankNameOfNominalPayee = itemdata.OpeningBankNameOfNominalPayee;
bs.AccountNumberOfNominalPayee = itemdata.AccountNumberOfNominalPayee;
bs.NameOfNominalPayee = itemdata.NameOfNominalPayee;
bs.FilePaths = itemdata.FilePaths;
bs.CreateTime = DateTime.Now;
//await tenantDb.Insertable(bs).ExecuteCommandAsync();
datalist.Add(bs);
}
}
await tenantDb.Insertable(datalist).ExecuteCommandAsync();
}
}
}
}
}

@ -1,31 +1,21 @@
using DS.Module.Core.Enums;
using DS.WMS.Core.HangfireJob.Dtos;
using DS.WMS.Core.HangfireJob.Interface;
using DS.WMS.Core.Invoice.Entity;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Invoice.Entity;
using DS.WMS.Core.QuarztJobs.Dtos;
using DS.WMS.Core.QuarztJobs.Interface;
using DS.WMS.Core.QuarztJobs.Other;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.TaskPlat.Dtos;
using Google.Api.Gax.ResourceNames;
using LanguageExt.Common;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.HangfireJob.Method
namespace DS.WMS.Core.QuarztJobs.Method
{
/// <summary>
/// 进项发票相关
/// </summary>
public class InInvoiceService : IInInvoiceJobService
{
private static readonly HttpClient _httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };
ISqlSugarClient? db;
public InInvoiceService(IServiceProvider serviceProvider)
{
@ -63,7 +53,7 @@ namespace DS.WMS.Core.HangfireJob.Method
//model.kprqks = "2024-09-01 00:00:00";// DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"); //往前查24小时的进项发票数据
//model.kprqjs = "2024-09-07 00:00:00"; //DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
var result = await PostAsync("http://47.105.115.105:26650/api/XSD/GetInInvoiceDataList", JsonConvert.SerializeObject(model), header);
var result = await HttpHellp.PostAsync("http://47.105.115.105:26650/api/XSD/GetInInvoiceDataList", JsonConvert.SerializeObject(model), header);
//处理返回结果
var info= JsonConvert.DeserializeObject<InInvoicePostOutput>(result);
@ -90,7 +80,7 @@ namespace DS.WMS.Core.HangfireJob.Method
{
GetInInvoiceDataInfo gidi = new GetInInvoiceDataInfo();
gidi.fphm = itemdata.fphm;
var resultinfo = await PostAsync("http://47.105.115.105:26650/api/XSD/GetInInvoiceDataInfo", JsonConvert.SerializeObject(gidi), header);
var resultinfo = await HttpHellp.PostAsync("http://47.105.115.105:26650/api/XSD/GetInInvoiceDataInfo", JsonConvert.SerializeObject(gidi), header);
var Iinfo = JsonConvert.DeserializeObject<InInvoiceDataInfoOutput>(resultinfo);
if (Iinfo.code == 0) //调整
{
@ -194,46 +184,6 @@ namespace DS.WMS.Core.HangfireJob.Method
}
}
}
/// <summary>
/// post请求
/// </summary>
/// <param name="serviceAddress">请求地址</param>
/// <param name="requestJson">请求参数</param>
/// <param name="headers">请求头</param>
/// <returns></returns>
public static async Task<string> PostAsync(string serviceAddress, string requestJson = null, Dictionary<string, string> headers = null)
{
try
{
string result = string.Empty;
Uri postUrl = new Uri(serviceAddress);
using (HttpContent httpContent = new StringContent(requestJson))
{
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
if (headers != null)
{
foreach (var header in headers)
{
httpContent.Headers.Add(header.Key, header.Value);
}
}
var response = await _httpClient.PostAsync(serviceAddress, httpContent);
result = await response.Content.ReadAsStringAsync();
}
return result;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return null;
}
}
}

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.QuarztJobs.Other
{
public class HttpHellp
{
private static readonly HttpClient _httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };
/// <summary>
/// post请求
/// </summary>
/// <param name="serviceAddress">请求地址</param>
/// <param name="requestJson">请求参数</param>
/// <param name="headers">请求头</param>
/// <returns></returns>
public static async Task<string> PostAsync(string serviceAddress, string requestJson = null, Dictionary<string, string> headers = null)
{
try
{
string result = string.Empty;
Uri postUrl = new Uri(serviceAddress);
using (HttpContent httpContent = new StringContent(requestJson))
{
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
if (headers != null)
{
foreach (var header in headers)
{
httpContent.Headers.Add(header.Key, header.Value);
}
}
var response = await _httpClient.PostAsync(serviceAddress, httpContent);
result = await response.Content.ReadAsStringAsync();
}
return result;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return null;
}
}
}

@ -48,7 +48,7 @@ builder.Services.AddMultiLanguageInstall();//
builder.Services.AddDjyModuleInstall();//Djy服务
builder.Services.AddRuleEngineModuleInstall();//Djy规则引擎校验服务
builder.Services.AddHangfireFeeInstall();//Hangfire·þÎñ
//builder.Services.AddHangfireFeeInstall();//Hangfire·þÎñ
// 使用自定义的 Quartz 配置// 添加 Quartz 服务
builder.Services.AddQuartzModuleInstall();
@ -59,8 +59,8 @@ var app = builder.Build();
app.UsePublicMiddlewares();
app.UseHangfireServer();
app.UseJobMiddlewares();
//app.UseHangfireServer();
//app.UseJobMiddlewares();
//JobMiddleware.RegisterJob<IFeeCustTemplateJobService>(j => j.GenerateFeesAsync(), Cron.Daily(23, 30));

Loading…
Cancel
Save