|
|
|
@ -18,12 +18,12 @@ namespace DS.WMS.Core.QuarztJobs.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class InInvoiceService : IInInvoiceJobService
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ISqlSugarClient? db;
|
|
|
|
|
public InInvoiceService(IServiceProvider serviceProvider)
|
|
|
|
|
{
|
|
|
|
|
db = serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -32,14 +32,14 @@ namespace DS.WMS.Core.QuarztJobs.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task GetInInvoiceData()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取组织机构请求授权列表
|
|
|
|
|
if (db==null)
|
|
|
|
|
if (db == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var orgauthlist= db.Queryable<SysOrgAuth>().ClearFilter().Where(t => t.Deleted == false&&t.Type== "InInvoice").ToList();
|
|
|
|
|
|
|
|
|
|
var orgauthlist = db.Queryable<SysOrgAuth>().ClearFilter().Where(t => t.Deleted == false && t.Type == "InInvoice").ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -57,15 +57,15 @@ namespace DS.WMS.Core.QuarztJobs.Method
|
|
|
|
|
InInvoicePost model = new InInvoicePost();
|
|
|
|
|
model.kprqks = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"); //往前查24小时的进项发票数据
|
|
|
|
|
model.kprqjs = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var result = await HttpHellp.PostAsync("http://47.105.115.105:26650/api/XSD/GetInInvoiceDataList", JsonConvert.SerializeObject(model), header);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//处理返回结果
|
|
|
|
|
var info= JsonConvert.DeserializeObject<InInvoicePostOutput>(result);
|
|
|
|
|
if (!info.success)
|
|
|
|
|
var info = JsonConvert.DeserializeObject<InInvoicePostOutput>(result);
|
|
|
|
|
if (info == null || !info.success)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (info!=null&&info.Data.data!=null)
|
|
|
|
|
if (info != null && info.Data.data != null)
|
|
|
|
|
{
|
|
|
|
|
var dbLink = await db.Queryable<Module.SqlSugar.SysTenantLink>().ClearFilter().Where(t => t.TenantId == item.TenantId).FirstAsync();
|
|
|
|
|
SqlSugarClient? tenantDb = null;
|
|
|
|
@ -83,9 +83,9 @@ namespace DS.WMS.Core.QuarztJobs.Method
|
|
|
|
|
var ininviceinfo = await tenantDb.Queryable<InInvoice>().Where(x => x.InvoiceNumber == itemdata.fphm).FirstAsync();
|
|
|
|
|
|
|
|
|
|
//数据库中发票数据为空,获取发票详情数据
|
|
|
|
|
if (ininviceinfo==null)
|
|
|
|
|
if (ininviceinfo == null)
|
|
|
|
|
{
|
|
|
|
|
GetInInvoiceDataInfo gidi = new GetInInvoiceDataInfo();
|
|
|
|
|
GetInInvoiceDataInfo gidi = new GetInInvoiceDataInfo();
|
|
|
|
|
gidi.fphm = itemdata.fphm;
|
|
|
|
|
var resultinfo = await HttpHellp.PostAsync("http://47.105.115.105:26650/api/XSD/GetInInvoiceDataInfo", JsonConvert.SerializeObject(gidi), header);
|
|
|
|
|
var Iinfo = JsonConvert.DeserializeObject<InInvoiceDataInfoOutput>(resultinfo);
|
|
|
|
@ -155,12 +155,12 @@ namespace DS.WMS.Core.QuarztJobs.Method
|
|
|
|
|
inInvoice.OrgId = item.OrgId;
|
|
|
|
|
inInvoice.CreateTime = DateTime.Now;
|
|
|
|
|
var datainv = await tenantDb.Insertable(inInvoice).ExecuteReturnEntityAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var dtl in Iinfo.data.List)
|
|
|
|
|
{
|
|
|
|
|
//添加发票详情数据
|
|
|
|
|
InInvoiceDetail inInvoicedtl = new InInvoiceDetail();
|
|
|
|
|
inInvoicedtl.Id= SnowFlakeSingle.Instance.NextId();
|
|
|
|
|
inInvoicedtl.Id = SnowFlakeSingle.Instance.NextId();
|
|
|
|
|
inInvoicedtl.PId = datainv.Id;
|
|
|
|
|
inInvoicedtl.DetailId = dtl.mxid;
|
|
|
|
|
inInvoicedtl.InvoiceCode = dtl.fpdm;
|
|
|
|
@ -187,7 +187,7 @@ namespace DS.WMS.Core.QuarztJobs.Method
|
|
|
|
|
await tenantDb.Insertable(inInvoicedtl).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -199,9 +199,9 @@ namespace DS.WMS.Core.QuarztJobs.Method
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
#region 同步发票到钉钉审批
|
|
|
|
|
var dingconfig = db.Queryable<SysOrgAuth>().Where(t => t.Type == "DingConfig" &&t.OrgId==item.OrgId).First();
|
|
|
|
|
var dingconfig = db.Queryable<SysOrgAuth>().Where(t => t.Type == "DingConfig" && t.OrgId == item.OrgId).First();
|
|
|
|
|
|
|
|
|
|
if (dingconfig!=null)
|
|
|
|
|
if (dingconfig != null)
|
|
|
|
|
{
|
|
|
|
|
//获取钉钉密钥
|
|
|
|
|
var token = DingDing.GetDingToken(dingconfig.Key, dingconfig.Secret);
|
|
|
|
@ -229,8 +229,8 @@ namespace DS.WMS.Core.QuarztJobs.Method
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|