From 33cf9d286011de71155a45230cc5ebf7f9649804 Mon Sep 17 00:00:00 2001
From: wanggang <76527413@qq.com>
Date: Mon, 28 Aug 2023 16:08:35 +0800
Subject: [PATCH] up
---
.../wwwroot/views/vmi/balance.js | 24 +++++++----
.../Entities/BQ/VmiAsyncBalanceService.cs | 41 +++++++++++++++++++
2 files changed, 57 insertions(+), 8 deletions(-)
diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/vmi/balance.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/vmi/balance.js
index 4a1ca360..8db82447 100644
--- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/vmi/balance.js
+++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/vmi/balance.js
@@ -3,6 +3,7 @@ import html from "html";
import { ref, onMounted, onUnmounted } from "vue";
import { useRoute } from "vue-router";
import { ElNotification } from "element-plus";
+import request from "../../request/index.js";
export default {
components: { AppList },
@@ -13,21 +14,28 @@ export default {
const onCommand = async (item, rows) => {
console.log(item.path, item, rows);
};
+ let notify = null;
+ const showMessage = (data) => {
+ notify?.close();
+ notify = ElNotification({
+ position: "bottom-right",
+ title: "提示",
+ message: `待同步库存数量: ${data}`,
+ duration: 0,
+ });
+ };
const event = "VmiBalance";
onMounted(async () => {
const model = "vmi/balance";
const useConfig = (await import(`../../models/${model}.js`)).default;
config.value = useConfig(route.meta?.businessType, route.meta);
- let notify = null;
+ const result = await request("settleaccount/vmi-async-message/get-message-count", null, { method: "POST" });
+ if (!result.errors) {
+ showMessage(result.data);
+ }
PubSub.subscribe(event, async (_, data) => {
if (route.path === "/vmi/balance") {
- notify?.close();
- notify = ElNotification({
- position: "bottom-right",
- title: "待同步库存数量",
- message: data,
- duration: 0,
- });
+ showMessage(data);
}
});
});
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
index 265dcc6a..be57c1c2 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs
+++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs
@@ -4,11 +4,15 @@ using System.Linq;
using System.Linq.Dynamic.Core;
using System.Text.Json;
using System.Threading.Tasks;
+using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Core.Extension;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Omu.ValueInjecter;
+using SettleAccount.Job.SignalR;
using Volo.Abp.Application.Services;
using Volo.Abp.DependencyInjection;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
@@ -130,3 +134,40 @@ public class VmiAsyncBalanceService : ApplicationService, IJobService, ITransien
}
}
}
+
+///
+/// 消息表定时清理
+///
+public class VmiAsyncMessageService : Controller, IApplicationService, IJobService, ITransientDependency
+{
+ private readonly IServiceProvider _serviceProvider;
+
+ public VmiAsyncMessageService(IServiceProvider serviceProvider)
+ {
+ this._serviceProvider = serviceProvider;
+ }
+
+ [NonAction]
+ 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;
+ }
+
+ ///
+ /// 未处理消息数量
+ ///
+ ///
+ [HttpPost]
+ public int GetMessageCount()
+ {
+ using var scope = this._serviceProvider.CreateScope();
+ var db = scope.ServiceProvider.GetRequiredService();
+ var count = db.Set().Where(o => !o.isConsumed).Count();
+ return count;
+ }
+}