From 1d4cce7c570d2c7765782fb7ab1c4601bdb745cb Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Wed, 23 Aug 2023 14:12:28 +0800 Subject: [PATCH] update --- .../wwwroot/models/settle/commerce.js | 4 + .../wwwroot/models/settle/inventory-detail.js | 137 ++++++++++++ .../wwwroot/models/settle/inventory.js | 12 +- .../wwwroot/router/business.js | 4 +- .../wwwroot/views/settle/finance.js | 2 +- .../wwwroot/views/settle/inventory.js | 2 +- .../Entities/BQ/VmiAppService.cs | 197 ------------------ .../Entities/BQ/VmiAsyncBalanceService.cs | 106 ++++++++++ .../Entities/BQ/VmiAsyncMessageService.cs | 116 +++++++++++ 9 files changed, 377 insertions(+), 203 deletions(-) create mode 100644 code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/inventory-detail.js create mode 100644 code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs create mode 100644 code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncMessageService.cs diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/commerce.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/commerce.js index e3245b91..51f184b8 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/commerce.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/commerce.js @@ -70,12 +70,14 @@ export default function (businessType, type) { const receivedUrl = `settleaccount/${service}/received`; const rejectUrl = `settleaccount/${service}/reject`; const reissueUrl = `settleaccount/${service}/reissue-invoice`; + const approvalUrl = `settleaccount/${service}/approval-passed`; const queryMethod = "POST"; const exportMethod = "POST"; const invoiceMethod = "POST"; const receivedMethod = "POST"; const rejectMethod = "POST"; const reissueMethod = "POST"; + const approvalMethod = "POST"; return { query: { url: queryUrl, @@ -143,11 +145,13 @@ export default function (businessType, type) { receivedUrl, rejectUrl, reissueUrl, + approvalUrl, exportMethod, invoiceMethod, receivedMethod, rejectMethod, reissueMethod, + approvalMethod, schema: schema, }, }; diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/inventory-detail.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/inventory-detail.js new file mode 100644 index 00000000..9ef56e43 --- /dev/null +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/inventory-detail.js @@ -0,0 +1,137 @@ +//库存扣减 +import { version, state3 } from "../_options.js"; + +const schema = { + title: "寄售库库存扣减审批", + type: "object", + properties: { + version, + state: state3, + billNum: { + title: "发票号", + type: "string", + link: true, + }, + settleBillNum: { + title: "关联结算单号", + type: "string", + }, + invGroupNum: { + title: "发票分组号", + type: "string", + link: true, + }, + site: { + title: "地点", + type: "string", + }, + }, +}; + +export default function (businessType) { + let service; + if (businessType === "JisBBAC") { + service = "b-bAC_PD_SERVICE"; + } else if (businessType === "JisHBPO") { + service = "h-bPO_PD_SERVICE"; + } else { + service = "p-uB_PD_SERVICE"; + } + + const queryUrl = `settleaccount/${service}/detail-query`; + const queryMethod = "POST"; + + return { + query: { + url: queryUrl, + method: queryMethod, + hasFilter: true, + schema: { + title: "不可结算单", + type: "object", + properties: { + filters: { + title: "项目", + type: "array", + hidden: true, + items: { + type: "object", + properties: { + logic: { + type: "int", + }, + column: { + type: "string", + }, + action: { + type: "int", + }, + value: { + type: "string", + }, + }, + }, + default: [ + { + logic: "and", + column: "version", + action: "equal", + value: null, + readOnly: true, + }, + { + logic: "and", + column: "billNum", + action: "equal", + value: null, + readOnly: true, + }, + { + logic: "and", + column: "settleBillNum", + action: "equal", + value: null, + readOnly: true, + }, + { + logic: "and", + column: "invGroupNum", + action: "equal", + value: null, + readOnly: true, + }, + { + logic: "and", + column: "state", + action: "equal", + value: null, + readOnly: true, + }, + ], + }, + skipCount: { + hidden: true, + default: 0, + }, + maxResultCount: { + hidden: true, + default: 10, + }, + sorting: { + hidden: true, + }, + businessType: { + hidden: true, + default: 0, + }, + }, + }, + }, + table: { + schema: schema, + }, + edit: { + schema: schema, + }, + }; +} diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/inventory.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/inventory.js index 23b532a7..d5bc6874 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/inventory.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/inventory.js @@ -10,7 +10,8 @@ const schema = { billNum: { title: "发票号", type: "string", - link: true, + oneToMany: "/settle/inventory-detail", + config: "/models/settle/inventory-detail.js", }, settleBillNum: { title: "关联结算单号", @@ -96,7 +97,7 @@ export default function (businessType) { }, { logic: "and", - column: "invGroupNum", + column: "settleBillNum", action: "equal", value: null, readOnly: true, @@ -108,6 +109,13 @@ export default function (businessType) { value: null, readOnly: true, }, + { + logic: "and", + column: "state", + action: "equal", + value: null, + readOnly: true, + }, ], }, skipCount: { diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js index 205a5d15..e86414c7 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js @@ -116,7 +116,7 @@ export default [ children: [createButton("query", "title=查询&isTop=true")], }, { - ...createPage("settle/vmi-detail", "title=寄售库库存扣减审批明细&isHidden=true"), + ...createPage("settle/inventory-detail", "title=寄售库库存扣减审批明细&isHidden=true"), children: [createButton("query", "title=查询&isTop=true")], }, { @@ -339,7 +339,7 @@ export default [ children: [ createButton("query", "title=查询&isTop=true"), createButton("import", "title=导入开票文件&isTop=true"), - createButton("compare", "title=财务审核通过&isTop=true"), + createButton("approval", "title=财务审核通过&isTop=true"), createButton("export-group", "title=导出发票分组&pattern=paged"), createButton("reject", "title=退回&isTop=true"), createButton("sync", "title=同步到QAD&isTop=true"), diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/finance.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/finance.js index 52e77763..f03f849b 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/finance.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/finance.js @@ -26,7 +26,7 @@ export default { ? `确认退回选中的${rows.length}行数据吗?` : `确认选中的${rows.length}行数据客户已收票吗?`; const data = item.path === "approval" ? rows.map((o) => o.invbillNum) : item.path === "reject" ? rows[0]["invGroupNum"] : rows.map((o) => o.invbillNum); - const url = item.path === "approval" ? config.edit.invoiceUrl : item.path === "reject" ? config.edit.rejectUrl : config.edit.receivedUrl; + const url = item.path === "approval" ? config.edit.approvalUrl : item.path === "reject" ? config.edit.rejectUrl : config.edit.receivedUrl; await appListRef.value.onClick(async () => await request(url, data, { method: "POST" }), message, true); } } else if (item.path === "export-group") { diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/inventory.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/inventory.js index 85e3d300..1567947e 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/inventory.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/inventory.js @@ -27,7 +27,7 @@ export default { ? `确认退回选中的${rows.length}行数据吗?` : `确认选中的${rows.length}行数据客户已收票吗?`; const data = item.path === "approval" ? rows.map((o) => o.invbillNum) : item.path === "reject" ? rows[0]["invGroupNum"] : rows.map((o) => o.invbillNum); - const url = item.path === "approval" ? config.edit.invoiceUrl : item.path === "reject" ? config.edit.rejectUrl : config.edit.receivedUrl; + const url = item.path === "approval" ? config.edit.approvalUrl : item.path === "reject" ? config.edit.rejectUrl : config.edit.receivedUrl; await appListRef.value.onClick(async () => await request(url, data, { method: "POST" }), message, true); } } else if (item.path === "export-group") { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs index 0a05c2c7..316d9ef4 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs @@ -6,11 +6,9 @@ using System.IO; using System.Linq; using System.Linq.Dynamic.Core; using System.Reflection; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; using ClosedXML.Excel; -using EFCore.BulkExtensions; using LinqToDB.Data; using LinqToDB.EntityFrameworkCore; using Magicodes.ExporterAndImporter.Core; @@ -692,198 +690,3 @@ public class LogRequestDto : RequestDto { public List LogTypes { get; set; } = new List(); } - -/// -/// 异步更新库存 -/// -public class VmiAsyncBalanceService : ApplicationService, IJobService, ITransientDependency -{ - private readonly IServiceProvider _serviceProvider; - - public VmiAsyncBalanceService(IServiceProvider serviceProvider) - { - this._serviceProvider = serviceProvider; - } - - public async Task Invoke(IServiceProvider serviceProvider) - { - using var scope = _serviceProvider.CreateScope(); - var db = scope.ServiceProvider.GetRequiredService(); - using var transaction = db.Database.BeginTransaction(); - try - { - var messages = db.Set().Where(o => !o.isConsumed).OrderBy(o => o.Number).ToList(); - var repo = db.Set(); - foreach (var message in messages) - { - var log = JsonSerializer.Deserialize(message.Message); - var balance = db.Set().FirstOrDefault( - o => o.DeliverBillType == log.DeliverBillType && - o.CodeType == log.CodeType && - o.DeliverBillType == log.DeliverBillType && - o.VinCode == log.VinCode && - o.ErpToLoc == log.ErpToLoc && - o.OrderNum == log.OrderNum && - o.factory == log.factory && - o.Configcode == log.Configcode); - if (balance == null) - { - balance = new VmiBalance(GuidGenerator.Create()); - balance.InjectFrom(log); - await repo.AddAsync(balance).ConfigureAwait(false); - log.InjectFrom(balance); - } - else - { - var logType = log.LogType; - - var qty = balance.Qty;// + log.ty - if (logType == VmiLogType.Type100) - { - //发运入库,负库存字段需要更新 - if (balance.Qty < decimal.Zero) - { - balance.InjectFrom(log); - } - } - else if (logType == VmiLogType.Type300) - { - //反结入库,只更新库存 - } - else if (logType == VmiLogType.Type500) - { - //调整入库,更新库存和其他字段 - balance.InjectFrom(log); - } - // 更新库存 - balance.Qty = qty; - if (balance.Qty == decimal.Zero) - { - //删除0库存 - repo.Remove(balance); - } - if (logType == VmiLogType.Type100 && balance.Qty < decimal.Zero && log.Qty > 0) - { - //更新补货 - var log2 = db.Set().FirstOrDefault(o => o.Id == log.Id); - if (log2 != null) - { - log2.IsReplenished = true; - } - } - } - message.isConsumed = true; - } - transaction.Commit(); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - transaction.Rollback(); - throw; - } - } -} - -/// -/// 消息表定时清理 -/// -public class VmiAsyncMessageService : ApplicationService, IJobService, ITransientDependency -{ - private readonly IServiceProvider _serviceProvider; - - public VmiAsyncMessageService(IServiceProvider serviceProvider) - { - this._serviceProvider = serviceProvider; - } - - public Task Invoke(IServiceProvider serviceProvider) - { - using var scope = _serviceProvider.CreateScope(); - var db = scope.ServiceProvider.GetRequiredService(); - db.Set().Where(o => o.isConsumed).BatchDelete(); - var count = db.Set().Where(o => !o.isConsumed).Count(); - scope.ServiceProvider.GetService>().Clients.All.ServerToClient("VmiBalance", count.ToString(), ""); - return Task.CompletedTask; - } -} - -/// -/// 库存事务定时备份 -/// -public class VmiLogbackupService : ApplicationService, IJobService, ITransientDependency -{ - private readonly IServiceProvider _serviceProvider; - - public VmiLogbackupService(IServiceProvider serviceProvider) - { - this._serviceProvider = serviceProvider; - } - - public Task Invoke(IServiceProvider serviceProvider) - { - using var scope = _serviceProvider.CreateScope(); - var db = scope.ServiceProvider.GetRequiredService(); - using var transaction = db.Database.BeginTransaction(); - try - { - var task = db.Set().FirstOrDefault(o => o.Number == "Set_VmiLog"); - if (task != null) - { - var now = DateTime.Now; - task.LastUpdate = now; - var query = db.Set().Where(o => o.UpdatedTime >= task.LastUpdate && o.UpdatedTime < now); - foreach (var item in query) - { - //同步到questdb - } - } - } - catch - { - transaction.Rollback(); - throw; - } - return Task.CompletedTask; - } -} - -/// -/// 库存余额定时备份 -/// -public class VmiLogBalanceService : ApplicationService, IJobService, ITransientDependency -{ - private readonly IServiceProvider _serviceProvider; - - public VmiLogBalanceService(IServiceProvider serviceProvider) - { - this._serviceProvider = serviceProvider; - } - - public Task Invoke(IServiceProvider serviceProvider) - { - using var scope = _serviceProvider.CreateScope(); - var db = scope.ServiceProvider.GetRequiredService(); - using var transaction = db.Database.BeginTransaction(); - try - { - var task = db.Set().FirstOrDefault(o => o.Number == "Set_VmiBalance"); - if (task != null) - { - var now = DateTime.Now; - task.LastUpdate = now; - var query = db.Set().Where(o => o.UpdatedTime >= task.LastUpdate && o.UpdatedTime < now); - foreach (var item in query) - { - //同步到questdb - } - } - } - catch - { - transaction.Rollback(); - throw; - } - return Task.CompletedTask; - } -} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs new file mode 100644 index 00000000..72848192 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs @@ -0,0 +1,106 @@ +using System; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Text.Json; +using System.Threading.Tasks; +using Magicodes.ExporterAndImporter.Core.Extension; +using Microsoft.Extensions.DependencyInjection; +using Omu.ValueInjecter; +using Volo.Abp.Application.Services; +using Volo.Abp.DependencyInjection; +using Win.Sfs.SettleAccount.Entities.BQ.Vmi; +using Win.Sfs.Shared.RepositoryBase; + +namespace Win.Sfs.SettleAccount.Entities.BQ; + +/// +/// 异步更新库存 +/// +public class VmiAsyncBalanceService : ApplicationService, IJobService, ITransientDependency +{ + private readonly IServiceProvider _serviceProvider; + + public VmiAsyncBalanceService(IServiceProvider serviceProvider) + { + this._serviceProvider = serviceProvider; + } + + public async Task Invoke(IServiceProvider serviceProvider) + { + using var scope = _serviceProvider.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + using var transaction = db.Database.BeginTransaction(); + try + { + var messages = db.Set().Where(o => !o.isConsumed).OrderBy(o => o.Number).ToList(); + var repo = db.Set(); + foreach (var message in messages) + { + var log = JsonSerializer.Deserialize(message.Message); + var balance = db.Set().FirstOrDefault( + o => o.DeliverBillType == log.DeliverBillType && + o.CodeType == log.CodeType && + o.DeliverBillType == log.DeliverBillType && + o.VinCode == log.VinCode && + o.ErpToLoc == log.ErpToLoc && + o.OrderNum == log.OrderNum && + o.factory == log.factory && + o.Configcode == log.Configcode); + if (balance == null) + { + balance = new VmiBalance(GuidGenerator.Create()); + balance.InjectFrom(log); + await repo.AddAsync(balance).ConfigureAwait(false); + log.InjectFrom(balance); + } + else + { + var logType = log.LogType; + + var qty = balance.Qty;// + log.ty + if (logType == VmiLogType.Type100) + { + //发运入库,负库存字段需要更新 + if (balance.Qty < decimal.Zero) + { + balance.InjectFrom(log); + } + } + else if (logType == VmiLogType.Type300) + { + //反结入库,只更新库存 + } + else if (logType == VmiLogType.Type500) + { + //调整入库,更新库存和其他字段 + balance.InjectFrom(log); + } + // 更新库存 + balance.Qty = qty; + if (balance.Qty == decimal.Zero) + { + //删除0库存 + repo.Remove(balance); + } + if (logType == VmiLogType.Type100 && balance.Qty < decimal.Zero && log.Qty > 0) + { + //更新补货 + var log2 = db.Set().FirstOrDefault(o => o.Id == log.Id); + if (log2 != null) + { + log2.IsReplenished = true; + } + } + } + message.isConsumed = true; + } + transaction.Commit(); + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + transaction.Rollback(); + throw; + } + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncMessageService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncMessageService.cs new file mode 100644 index 00000000..8196fc31 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncMessageService.cs @@ -0,0 +1,116 @@ +using System; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Threading.Tasks; +using EFCore.BulkExtensions; +using Microsoft.AspNetCore.SignalR; +using Microsoft.Extensions.DependencyInjection; +using SettleAccount.Job.SignalR; +using Volo.Abp.Application.Services; +using Volo.Abp.DependencyInjection; +using Win.Sfs.SettleAccount.Entities.BQ.Vmi; + +namespace Win.Sfs.SettleAccount.Entities.BQ; + +/// +/// 消息表定时清理 +/// +public class VmiAsyncMessageService : ApplicationService, IJobService, ITransientDependency +{ + private readonly IServiceProvider _serviceProvider; + + public VmiAsyncMessageService(IServiceProvider serviceProvider) + { + this._serviceProvider = serviceProvider; + } + + public Task Invoke(IServiceProvider serviceProvider) + { + using var scope = _serviceProvider.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + db.Set().Where(o => o.isConsumed).BatchDelete(); + var count = db.Set().Where(o => !o.isConsumed).Count(); + scope.ServiceProvider.GetService>().Clients.All.ServerToClient("VmiBalance", count.ToString(), ""); + return Task.CompletedTask; + } +} + +/// +/// 库存事务定时备份 +/// +public class VmiLogbackupService : ApplicationService, IJobService, ITransientDependency +{ + private readonly IServiceProvider _serviceProvider; + + public VmiLogbackupService(IServiceProvider serviceProvider) + { + this._serviceProvider = serviceProvider; + } + + public Task Invoke(IServiceProvider serviceProvider) + { + using var scope = _serviceProvider.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + using var transaction = db.Database.BeginTransaction(); + try + { + var task = db.Set().FirstOrDefault(o => o.Number == "Set_VmiLog"); + if (task != null) + { + var now = DateTime.Now; + task.LastUpdate = now; + var query = db.Set().Where(o => o.UpdatedTime >= task.LastUpdate && o.UpdatedTime < now); + foreach (var item in query) + { + //同步到questdb + } + } + } + catch + { + transaction.Rollback(); + throw; + } + return Task.CompletedTask; + } +} + +/// +/// 库存余额定时备份 +/// +public class VmiLogBalanceService : ApplicationService, IJobService, ITransientDependency +{ + private readonly IServiceProvider _serviceProvider; + + public VmiLogBalanceService(IServiceProvider serviceProvider) + { + this._serviceProvider = serviceProvider; + } + + public Task Invoke(IServiceProvider serviceProvider) + { + using var scope = _serviceProvider.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + using var transaction = db.Database.BeginTransaction(); + try + { + var task = db.Set().FirstOrDefault(o => o.Number == "Set_VmiBalance"); + if (task != null) + { + var now = DateTime.Now; + task.LastUpdate = now; + var query = db.Set().Where(o => o.UpdatedTime >= task.LastUpdate && o.UpdatedTime < now); + foreach (var item in query) + { + //同步到questdb + } + } + } + catch + { + transaction.Rollback(); + throw; + } + return Task.CompletedTask; + } +}