diff --git a/code/WebApp/vue3/package-lock.json b/code/WebApp/vue3/package-lock.json index eae2d142..768e9e01 100644 --- a/code/WebApp/vue3/package-lock.json +++ b/code/WebApp/vue3/package-lock.json @@ -38,7 +38,9 @@ "vue-echarts": "^6.6.0", "vue-i18n": "^9.2.2", "vue-router": "^4.2.2", - "wsmock-js": "^1.1.1" + "vxe-table": "^4.5.0-beta.16", + "wsmock-js": "^1.1.1", + "xe-utils": "^3.5.11" }, "devDependencies": { "@iconify/json": "^2.2.83", @@ -13223,6 +13225,15 @@ "vue": "^3.2.0" } }, + "node_modules/vxe-table": { + "version": "4.5.0-beta.16", + "resolved": "https://registry.npmjs.org/vxe-table/-/vxe-table-4.5.0-beta.16.tgz", + "integrity": "sha512-rSChkgl1cIJzEr99WS2YZyqkOm3bqMtD2d2RrCSB3VVepWJe7B7jMYazGi6L32Y0J3ZM8rNOipFyB3W0j96mHA==", + "peerDependencies": { + "vue": "^3.2.28", + "xe-utils": "^3.5.0" + } + }, "node_modules/webpack-sources": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", @@ -13475,6 +13486,11 @@ "integrity": "sha512-GojqklwG8gpzOVEVki5KudKNoq7MbbjYZCbyWzEz7tyPA7eleiE0+ePwOWQQRb5fm86rD3S8Tc0tSFf3AOv50w==", "dev": true }, + "node_modules/xe-utils": { + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/xe-utils/-/xe-utils-3.5.11.tgz", + "integrity": "sha512-lyKc/lTBga1Zb63p+FED8mtxLnYIjSS8PVJM1N64NGdCu/3d1XubaVeke2p91RHssP0ExVAl2LUqZYperoz76Q==" + }, "node_modules/xml-name-validator": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", diff --git a/code/WebApp/vue3/package.json b/code/WebApp/vue3/package.json index 5666aae9..59d499fe 100644 --- a/code/WebApp/vue3/package.json +++ b/code/WebApp/vue3/package.json @@ -71,7 +71,9 @@ "vue-echarts": "^6.6.0", "vue-i18n": "^9.2.2", "vue-router": "^4.2.2", - "wsmock-js": "^1.1.1" + "vxe-table": "^4.5.0-beta.16", + "wsmock-js": "^1.1.1", + "xe-utils": "^3.5.11" }, "devDependencies": { "@iconify/json": "^2.2.83", diff --git a/code/WebApp/vue3/src/main.js b/code/WebApp/vue3/src/main.js index 376dc23c..371d8919 100644 --- a/code/WebApp/vue3/src/main.js +++ b/code/WebApp/vue3/src/main.js @@ -1,7 +1,8 @@ import './style.css'; import { createApp } from 'vue'; +import VXETable from 'vxe-table'; import App from './App.vue'; -createApp(App).mount('#app'); +createApp(App).use(VXETable).mount('#app'); diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js index e56b30bb..6011f956 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js @@ -865,7 +865,6 @@ export default { await load(); } }); - context.expose({ load }); return { load, config, diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/index.html b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/index.html index 3c7db250..e6025cc3 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/index.html +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/index.html @@ -64,6 +64,7 @@ "nprogress": "./lib/nprogress/nprogress.vite-esm.js", "echarts/core": "./lib/echarts/echarts.esm.min.js", "vue-echarts": "./lib/vue-echarts/index.esm.min.js", + "xe-echarts": "./lib/vue-echarts/index.esm.min.js", "resize-detector": "./lib/resize-detector/index.js", "@vue-office/excel": "./lib/@vue-office/excel/vue-office-excel.mjs", "@vue/devtools-api": "./lib/@vue/devtools-api/shim.js", diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/job-item.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/job-item.js index bff1c136..0ccf2818 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/job-item.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/job-item.js @@ -1,15 +1,14 @@ import AppList from "../../components/list/index.js"; import html from "html"; import useConfig from "../../models/job-item.js"; -import { defineAsyncComponent, ref, reactive, onMounted, watch } from "vue"; +import { ref, nextTick, onMounted, onUnmounted } from "vue"; import useConfig2 from "../../models/job-log.js"; export default { components: { AppList }, - template: html``, + template: html``, setup() { const config = useConfig(); - const appListRef = ref(null); const onCommand = async (item, rows, showList) => { console.log(item.path, item, rows); console.log(showList); @@ -17,6 +16,16 @@ export default { config.query.schema.properties.filters.default[0].value = rows[0].id; showList({ test: "test" }, "/base-data/job-log", config); }; - return { config, onCommand }; + const refresh = ref(true); + onMounted(async () => { + PubSub.subscribe("JobItem", () => { + refresh.value = false; + nextTick(() => (refresh.value = true)); + }); + }); + onUnmounted(() => { + PubSub.unsubscribe(onMonitor); + }); + return { config, onCommand, refresh }; }, }; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs index 4b0476aa..99540e8d 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs @@ -78,18 +78,21 @@ public class JobHostdService : BackgroundService, IApplicationService if (!jobItem.IsRunning) { jobLogId = this.JobItemStart(job.Id); - } - try - { - jobService.Invoke(); - this.JobItemSuccess(job.Id, jobLogId.Value); - Debug.WriteLine($"{job.Name} 定时任务执行成功"); - } - catch (Exception ex) - { - Debug.WriteLine($"{job.Name} 定时任务执行失败:{ex.Message}"); - Console.WriteLine(ex.ToString()); - this.JobItemFaild(job.Id, jobLogId.Value, ex); + if (jobLogId.HasValue) + { + try + { + await jobService.Invoke().ConfigureAwait(false); + this.JobItemSuccess(job.Id, jobLogId.Value); + Debug.WriteLine($"{job.Name} 定时任务执行成功"); + } + catch (Exception ex) + { + Debug.WriteLine($"{job.Name} 定时任务执行失败:{ex.Message}"); + Console.WriteLine(ex.ToString()); + this.JobItemFaild(job.Id, jobLogId.Value, ex); + } + } } } } @@ -105,8 +108,10 @@ public class JobHostdService : BackgroundService, IApplicationService { Console.WriteLine(ex.ToString()); } - }); - thread.IsBackground = true; + }) + { + IsBackground = true + }; if (this.Jobs.TryAdd(job, new Tuple(source, thread))) { thread.Start(); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobItemAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobItemAppService.cs index e2e1dbbb..0a71ef90 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobItemAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobItemAppService.cs @@ -4,7 +4,9 @@ using System.Linq; using System.Linq.Dynamic.Core; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.SignalR; using Omu.ValueInjecter; +using SettleAccount.Job.SignalR; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.DependencyInjection; @@ -19,11 +21,13 @@ public class JobItemAppService : ApplicationService, ITransientDependency { private readonly INormalEfCoreRepository _repository; private readonly JobHostdService _jobHostdService; + private readonly IHubContext _hubContext; - public JobItemAppService(INormalEfCoreRepository repository, JobHostdService jobHostdService) + public JobItemAppService(INormalEfCoreRepository repository, JobHostdService jobHostdService, IHubContext hubContext) { this._repository = repository; this._jobHostdService = jobHostdService; + this._hubContext = hubContext; } [HttpPost] @@ -31,6 +35,7 @@ public class JobItemAppService : ApplicationService, ITransientDependency { var entity = await _repository.InsertAsync(input).ConfigureAwait(false); this._jobHostdService.AddJob(entity); + this.Notify(); return entity; } @@ -43,6 +48,7 @@ public class JobItemAppService : ApplicationService, ITransientDependency await _repository.DeleteAsync(item).ConfigureAwait(false); this._jobHostdService.RemoveJob(item); } + this.Notify(); return entites.Count > 0; } @@ -73,8 +79,14 @@ public class JobItemAppService : ApplicationService, ITransientDependency this._jobHostdService.RemoveJob(entity); this._jobHostdService.AddJob(entity); } + this.Notify(); return input; } + + private void Notify() + { + this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", ""); + } } [Route("api/settleaccount/[controller]/[action]")] 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 d0037a24..534a3689 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 @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; @@ -13,11 +12,13 @@ using InfluxDB.LineProtocol.Client; using Magicodes.ExporterAndImporter.Core.Extension; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.SignalR; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.Configuration; using Microsoft.OpenApi.Extensions; +using SettleAccount.Job.SignalR; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.BlobStoring; @@ -51,18 +52,21 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran private readonly INormalEfCoreRepository _logRepository; private readonly INormalEfCoreRepository _snapshotRepository; private readonly IBlobContainer _fileContainer; + private readonly IHubContext _hubContext; public VmiAppService(IConfiguration cfg, INormalEfCoreRepository balanceRepository, INormalEfCoreRepository logRepository, INormalEfCoreRepository snapshotRepository, - IBlobContainer fileContainer) + IBlobContainer fileContainer, + IHubContext hubContext) { this._cfg = cfg; this._balanceRepository = balanceRepository; this._logRepository = logRepository; this._snapshotRepository = snapshotRepository; this._fileContainer = fileContainer; + this._hubContext = hubContext; } /// @@ -70,8 +74,9 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran /// [HttpPost] [UnitOfWork] - public void Invoke() + public virtual Task Invoke() { + this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", ""); Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files/vmi")); var date = DateTime.Now.ToString("yyyyMMddHH"); var connectionString = $"Data Source=wwwroot/files/vmi/{date}.db"; @@ -87,7 +92,8 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran var snapshot = new VmiSnapshot { Name = date, Path = connectionString }; this._snapshotRepository.InsertAsync(snapshot).Wait(); } - Debug.WriteLine($"{nameof(VmiAppService)}:{DateTime.Now}"); + this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", ""); + return Task.CompletedTask; } /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/IJobService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/IJobService.cs index 4a2d165e..3f9f8793 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/IJobService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/IJobService.cs @@ -1,6 +1,8 @@ +using System.Threading.Tasks; + namespace Win.Sfs.SettleAccount.Entities.BQ.Vmi; public interface IJobService { - void Invoke(); + Task Invoke(); }