学 赵 1 year ago
parent
commit
96d7c06574
  1. 18
      code/WebApp/vue3/package-lock.json
  2. 4
      code/WebApp/vue3/package.json
  3. 3
      code/WebApp/vue3/src/main.js
  4. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj
  5. 14
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs
  6. 10
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json
  7. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/start.cmd
  8. 14
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js
  9. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/index.html
  10. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/invoice/invoice_map_group.js
  11. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/job-item.js
  12. 16
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/job-log.js
  13. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/job-service.js
  14. 9
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/base-data.js
  15. 17
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/job-item.js
  16. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  17. 41
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs
  18. 33
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobItemAppService.cs
  19. 38
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BeiSeSyncAppService.cs
  20. 97
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs
  21. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncConfig.cs
  22. 38
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/YinDuSeSyncAppService.cs
  23. 88
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongBBACSeSyncAppService.cs
  24. 38
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongHBPOSeSyncAppService.cs
  25. 19
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  26. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  27. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/IJobService.cs
  28. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/JobItem.cs
  29. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/JobLog.cs
  30. 19
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBusinessType.cs
  31. 4920
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230728013132_vmi6.Designer.cs
  32. 56
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230728013132_vmi6.cs
  33. 11
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

18
code/WebApp/vue3/package-lock.json

@ -38,7 +38,9 @@
"vue-echarts": "^6.6.0", "vue-echarts": "^6.6.0",
"vue-i18n": "^9.2.2", "vue-i18n": "^9.2.2",
"vue-router": "^4.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": { "devDependencies": {
"@iconify/json": "^2.2.83", "@iconify/json": "^2.2.83",
@ -13223,6 +13225,15 @@
"vue": "^3.2.0" "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": { "node_modules/webpack-sources": {
"version": "3.2.3", "version": "3.2.3",
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz",
@ -13475,6 +13486,11 @@
"integrity": "sha512-GojqklwG8gpzOVEVki5KudKNoq7MbbjYZCbyWzEz7tyPA7eleiE0+ePwOWQQRb5fm86rD3S8Tc0tSFf3AOv50w==", "integrity": "sha512-GojqklwG8gpzOVEVki5KudKNoq7MbbjYZCbyWzEz7tyPA7eleiE0+ePwOWQQRb5fm86rD3S8Tc0tSFf3AOv50w==",
"dev": true "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": { "node_modules/xml-name-validator": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz",

4
code/WebApp/vue3/package.json

@ -71,7 +71,9 @@
"vue-echarts": "^6.6.0", "vue-echarts": "^6.6.0",
"vue-i18n": "^9.2.2", "vue-i18n": "^9.2.2",
"vue-router": "^4.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": { "devDependencies": {
"@iconify/json": "^2.2.83", "@iconify/json": "^2.2.83",

3
code/WebApp/vue3/src/main.js

@ -1,7 +1,8 @@
import './style.css'; import './style.css';
import { createApp } from 'vue'; import { createApp } from 'vue';
import VXETable from 'vxe-table';
import App from './App.vue'; import App from './App.vue';
createApp(App).mount('#app'); createApp(App).use(VXETable).mount('#app');

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj

@ -11,7 +11,7 @@
<DockerfileContext>..\..\..\..</DockerfileContext> <DockerfileContext>..\..\..\..</DockerfileContext>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile> <GenerateDocumentationFile>True</GenerateDocumentationFile>
<SatelliteResourceLanguages>en;zh-Hans</SatelliteResourceLanguages>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles> <ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>

14
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs

@ -1,4 +1,5 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Coravel;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ApplicationModels; using Microsoft.AspNetCore.Mvc.ApplicationModels;
@ -17,6 +18,7 @@ public class Startup
{ {
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddScheduler();
services.AddSignalR(o => o.EnableDetailedErrors = true); services.AddSignalR(o => o.EnableDetailedErrors = true);
JobHostdService.AddService(services); JobHostdService.AddService(services);
services.AddSingleton<JobHostdService>(); services.AddSingleton<JobHostdService>();
@ -24,6 +26,9 @@ public class Startup
services.AddTransient<HBPOSeSyncAppService>(); services.AddTransient<HBPOSeSyncAppService>();
services.AddTransient<BBACSeSyncAppService>(); services.AddTransient<BBACSeSyncAppService>();
services.AddTransient<ZhiGongBBACSeSyncAppService>(); services.AddTransient<ZhiGongBBACSeSyncAppService>();
services.AddTransient<ZhiGongHBPOSeSyncAppService>();
services.AddTransient<BeiSeSyncAppService>();
services.AddTransient<YinDuSeSyncAppService>();
services.AddRouting(options => options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer)); services.AddRouting(options => options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer));
services.AddMvc(options => options.Conventions.Add(new RouteTokenTransformerConvention(new SlugifyParameterTransformer()))); services.AddMvc(options => options.Conventions.Add(new RouteTokenTransformerConvention(new SlugifyParameterTransformer())));
services.AddApplication<SettleAccountHttpApiHostModule>(); services.AddApplication<SettleAccountHttpApiHostModule>();
@ -44,6 +49,15 @@ public class Startup
{ {
app.UseRouting(); app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapHub<PageHub>("/api/hub")); app.UseEndpoints(endpoints => endpoints.MapHub<PageHub>("/api/hub"));
app.ApplicationServices.UseScheduler(scheduler =>
{
//scheduler.Schedule<HBPOSeSyncAppService>().EveryMinute();
//scheduler.Schedule<BBACSeSyncAppService>().EveryMinute();
scheduler.Schedule<ZhiGongBBACSeSyncAppService>().EveryMinute();
scheduler.Schedule<ZhiGongHBPOSeSyncAppService>().EveryMinute();
scheduler.Schedule<BeiSeSyncAppService>().EveryMinute();
scheduler.Schedule<YinDuSeSyncAppService>().EveryMinute();
});
var contentTypeProvider = new FileExtensionContentTypeProvider(); var contentTypeProvider = new FileExtensionContentTypeProvider();
contentTypeProvider.Mappings.Add(".mjs", "text/javascript"); contentTypeProvider.Mappings.Add(".mjs", "text/javascript");
app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = contentTypeProvider }); app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = contentTypeProvider });

10
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json

@ -69,7 +69,7 @@
"AuthServer": { "AuthServer": {
"Authority": "http://*:10582", "Authority": "http://localhost:10582",
"ClientId": "basic-web", "ClientId": "basic-web",
"ClientSecret": "1q2w3e*" "ClientSecret": "1q2w3e*"
}, },
@ -79,11 +79,5 @@
}, },
"DefaultBranchId": "3FA85F64-5717-4562-B3FC-2C963F66AFA6", "DefaultBranchId": "3FA85F64-5717-4562-B3FC-2C963F66AFA6",
"AllowedHosts": "*", "AllowedHosts": "*"
"ElasticSearch": {
"Url": "http://localhost:9200"
}
} }

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/start.cmd

@ -8,4 +8,4 @@ if %errorlevel% == 0 (
%1 start mshta vbscript:createobject("wscript.shell").run("""%~0"" ::",0)(window.close)&&exit %1 start mshta vbscript:createobject("wscript.shell").run("""%~0"" ::",0)(window.close)&&exit
start /b SettleAccount.HttpApi.Host.exe --urls http://dev.ccwin-in.com:10582 start /b SettleAccount.HttpApi.Host.exe --urls http://*:10582

14
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js

@ -103,6 +103,13 @@ export default {
</template> </template>
</el-table-column> </el-table-column>
</template> </template>
<template v-else-if="item.link">
<el-table-column :prop="key" :label="item.title">
<template #default="scope">
<el-link type="primary" @click="click({path:key},[scope.row])"> {{scope.row[key]}} </el-link>
</template>
</el-table-column>
</template>
<template v-else> <template v-else>
<template v-if="showColumn(item,key)"> <template v-if="showColumn(item,key)">
<el-table-column <el-table-column
@ -151,7 +158,6 @@ export default {
<el-row> <el-row>
<el-col> <el-col>
<el-pagination <el-pagination
v-if="pageModel.pageSize<pageModel.total"
v-model:currentPage="pageModel.pageIndex" v-model:currentPage="pageModel.pageIndex"
v-model:page-size="pageModel.pageSize" v-model:page-size="pageModel.pageSize"
:total="pageModel.total" :total="pageModel.total"
@ -495,7 +501,10 @@ export default {
} }
}; };
const onPageIndexChange = async () => await load(); const onPageIndexChange = async () => await load();
const onPageSizeChange = async () => await load(); const onPageSizeChange = async () => {
pageModel.pageIndex = 1;
await load();
};
const click = async (item, rows) => { const click = async (item, rows) => {
editFormloading.value = true; editFormloading.value = true;
editFormMode.value = item.path ?? item; editFormMode.value = item.path ?? item;
@ -856,7 +865,6 @@ export default {
await load(); await load();
} }
}); });
context.expose({ load });
return { return {
load, load,
config, config,

1
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/index.html

@ -64,6 +64,7 @@
"nprogress": "./lib/nprogress/nprogress.vite-esm.js", "nprogress": "./lib/nprogress/nprogress.vite-esm.js",
"echarts/core": "./lib/echarts/echarts.esm.min.js", "echarts/core": "./lib/echarts/echarts.esm.min.js",
"vue-echarts": "./lib/vue-echarts/index.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", "resize-detector": "./lib/resize-detector/index.js",
"@vue-office/excel": "./lib/@vue-office/excel/vue-office-excel.mjs", "@vue-office/excel": "./lib/@vue-office/excel/vue-office-excel.mjs",
"@vue/devtools-api": "./lib/@vue/devtools-api/shim.js", "@vue/devtools-api": "./lib/@vue/devtools-api/shim.js",

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/invoice/invoice_map_group.js

@ -9,10 +9,12 @@ const schema = {
invbillNum: { invbillNum: {
title: "系统生成发票号", title: "系统生成发票号",
type: "string", type: "string",
link: true,
}, },
invGroupNum: { invGroupNum: {
title: "发票分组号", title: "发票分组号",
type: "string", type: "string",
link: true,
}, },
settleGroupNum: { settleGroupNum: {
title: "结算分组号", title: "结算分组号",

1
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/job-item.js

@ -85,7 +85,6 @@ export default function () {
table: { table: {
schema: schema, schema: schema,
}, },
edit: { edit: {
createUrl, createUrl,
updateUrl, updateUrl,

16
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/job-log.js

@ -12,11 +12,14 @@ const schema = {
type: "string", type: "string",
input: "datetime", input: "datetime",
}, },
success: { success: {
title: "成功", title: "成功",
type: "boolean", type: "boolean",
}, },
host: {
title: "主机",
type: "string",
},
exception: { exception: {
title: "异常", title: "异常",
type: "string", type: "string",
@ -25,7 +28,9 @@ const schema = {
}; };
const queryUrl = "settleaccount/job-log/get-list"; const queryUrl = "settleaccount/job-log/get-list";
const deleteUrl = "settleaccount/job-log/delete-list";
const queryMethod = "POST"; const queryMethod = "POST";
const deleteMethod = "POST";
export default function () { export default function () {
return { return {
@ -33,7 +38,7 @@ export default function () {
url: queryUrl, url: queryUrl,
method: queryMethod, method: queryMethod,
schema: { schema: {
title: "定时任务", title: "定时任务日志",
type: "object", type: "object",
properties: { properties: {
filters: { filters: {
@ -82,11 +87,12 @@ export default function () {
}, },
}, },
table: { table: {
schema: schema, schema,
}, },
edit: { edit: {
schema: schema, schema,
deleteUrl,
deleteMethod,
}, },
}; };
} }

1
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/job-service.js

@ -54,7 +54,6 @@ export default function () {
query: { query: {
url: queryUrl, url: queryUrl,
method: queryMethod, method: queryMethod,
autoSubmit: true, autoSubmit: true,
disableQueryOnLoad: true, disableQueryOnLoad: true,
schema: { schema: {

9
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/base-data.js

@ -548,6 +548,15 @@ export default [
isTop: true, isTop: true,
}, },
}, },
{
path: "delete",
meta: {
type: "button",
title: "删除",
icon: "file",
isTop: true,
},
},
], ],
}, },
}, },

17
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 AppList from "../../components/list/index.js";
import html from "html"; import html from "html";
import useConfig from "../../models/job-item.js"; 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"; import useConfig2 from "../../models/job-log.js";
export default { export default {
components: { AppList }, components: { AppList },
template: html`<app-list :config="config" @command="onCommand" ref="appListRef" />`, template: html`<app-list v-if="refresh" :config="config" @command="onCommand" />`,
setup() { setup() {
const config = useConfig(); const config = useConfig();
const appListRef = ref(null);
const onCommand = async (item, rows, showList) => { const onCommand = async (item, rows, showList) => {
console.log(item.path, item, rows); console.log(item.path, item, rows);
console.log(showList); console.log(showList);
@ -17,6 +16,16 @@ export default {
config.query.schema.properties.filters.default[0].value = rows[0].id; config.query.schema.properties.filters.default[0].value = rows[0].id;
showList({ test: "test" }, "/base-data/job-log", config); 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 };
}, },
}; };

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs

@ -146,7 +146,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
case EnumBusinessType.ZhiGongJianHBPO: case EnumBusinessType.ZhiGongJianHBPO:
await _pubMng.SetNewState(input.InvGroupNum); await _pubMng.SetNewState(input.InvGroupNum);
break; break;
case EnumBusinessType.YingDuJian: case EnumBusinessType.YinDuJian:
await _pubMng.SetNewState(input.InvGroupNum); await _pubMng.SetNewState(input.InvGroupNum);
break; break;
case EnumBusinessType.JisBBAC: case EnumBusinessType.JisBBAC:

41
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs

@ -3,17 +3,19 @@ using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Net;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Cronos; using Cronos;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Volo.Abp.Application.Services;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi; using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
namespace Win.Sfs.SettleAccount.Entities.BQ; namespace Win.Sfs.SettleAccount.Entities.BQ;
public class JobHostdService : BackgroundService public class JobHostdService : BackgroundService, IApplicationService
{ {
private readonly object _lockObj = new object(); private readonly object _lockObj = new object();
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
@ -72,21 +74,25 @@ public class JobHostdService : BackgroundService
if (!job.IsDisabled) if (!job.IsDisabled)
{ {
var jobItem = this.GetJobItem(job.Id); var jobItem = this.GetJobItem(job.Id);
Guid? jobLogId = null;
if (!jobItem.IsRunning) if (!jobItem.IsRunning)
{ {
this.JobItemStart(job.Id); jobLogId = this.JobItemStart(job.Id);
} if (jobLogId.HasValue)
{
try try
{ {
jobService.Invoke(); await jobService.Invoke().ConfigureAwait(false);
this.JobItemSuccess(job.Id); this.JobItemSuccess(job.Id, jobLogId.Value);
Debug.WriteLine($"{job.Name} 定时任务执行成功"); Debug.WriteLine($"{job.Name} 定时任务执行成功");
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine($"{job.Name} 定时任务执行失败:{ex.Message}"); Debug.WriteLine($"{job.Name} 定时任务执行失败:{ex.Message}");
Console.WriteLine(ex.ToString()); Console.WriteLine(ex.ToString());
this.JobItemFaild(job.Id, ex); this.JobItemFaild(job.Id, jobLogId.Value, ex);
}
}
} }
} }
} }
@ -102,8 +108,10 @@ public class JobHostdService : BackgroundService
{ {
Console.WriteLine(ex.ToString()); Console.WriteLine(ex.ToString());
} }
}); })
thread.IsBackground = true; {
IsBackground = true
};
if (this.Jobs.TryAdd(job, new Tuple<CancellationTokenSource, Thread>(source, thread))) if (this.Jobs.TryAdd(job, new Tuple<CancellationTokenSource, Thread>(source, thread)))
{ {
thread.Start(); thread.Start();
@ -118,7 +126,7 @@ public class JobHostdService : BackgroundService
} }
} }
private void JobItemFaild(Guid id, Exception ex) private void JobItemFaild(Guid id, Guid jobLogId, Exception ex)
{ {
using var scope = this._serviceProvider.CreateScope(); using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>(); var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
@ -126,7 +134,7 @@ public class JobHostdService : BackgroundService
if (entity != null) if (entity != null)
{ {
entity.IsRunning = false; entity.IsRunning = false;
var log = db.Set<JobLog>().FirstOrDefault(o => o.JobId == id); var log = db.Set<JobLog>().FirstOrDefault(o => o.Id == jobLogId);
log.End = DateTime.Now; log.End = DateTime.Now;
log.Success = false; log.Success = false;
log.Exception = ex.ToString(); log.Exception = ex.ToString();
@ -134,7 +142,7 @@ public class JobHostdService : BackgroundService
} }
} }
private void JobItemSuccess(Guid id) private void JobItemSuccess(Guid id, Guid jobLogId)
{ {
using var scope = this._serviceProvider.CreateScope(); using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>(); var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
@ -142,14 +150,17 @@ public class JobHostdService : BackgroundService
if (entity != null) if (entity != null)
{ {
entity.IsRunning = false; entity.IsRunning = false;
var log = db.Set<JobLog>().FirstOrDefault(o => o.JobId == id); var log = db.Set<JobLog>().FirstOrDefault(o => o.Id == jobLogId);
if (log != null)
{
log.End = DateTime.Now; log.End = DateTime.Now;
log.Success = true; log.Success = true;
}
db.SaveChanges(); db.SaveChanges();
} }
} }
private void JobItemStart(Guid id) private Guid? JobItemStart(Guid id)
{ {
using var scope = this._serviceProvider.CreateScope(); using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>(); var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
@ -157,9 +168,11 @@ public class JobHostdService : BackgroundService
if (entity != null) if (entity != null)
{ {
entity.IsRunning = true; entity.IsRunning = true;
var log = db.Set<JobLog>().Add(new JobLog { Start = DateTime.Now, JobId = entity.Id }); var log = db.Set<JobLog>().Add(new JobLog { Start = DateTime.Now, JobId = entity.Id, Host = Dns.GetHostName() });
db.SaveChanges(); db.SaveChanges();
return log.Entity.Id;
} }
return null;
} }
private JobItem GetJobItem(Guid id) private JobItem GetJobItem(Guid id)

33
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobItemAppService.cs

@ -1,17 +1,12 @@
using System; using System;
using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Linq.Dynamic.Core; using System.Linq.Dynamic.Core;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Cronos;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Omu.ValueInjecter; using Omu.ValueInjecter;
using SettleAccount.Job.SignalR;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
@ -21,17 +16,18 @@ using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ; namespace Win.Sfs.SettleAccount.Entities.BQ;
[Route("api/settleaccount/[controller]/[action]")] [Route("api/settleaccount/[controller]/[action]")]
public class JobItemAppService : ApplicationService, ITransientDependency public class JobItemAppService : ApplicationService, ITransientDependency
{ {
private readonly INormalEfCoreRepository<JobItem, Guid> _repository; private readonly INormalEfCoreRepository<JobItem, Guid> _repository;
private readonly JobHostdService _jobHostdService; private readonly JobHostdService _jobHostdService;
private readonly IHubContext<PageHub> _hubContext;
public JobItemAppService(INormalEfCoreRepository<JobItem, Guid> repository, JobHostdService jobHostdService) public JobItemAppService(INormalEfCoreRepository<JobItem, Guid> repository, JobHostdService jobHostdService, IHubContext<PageHub> hubContext)
{ {
this._repository = repository; this._repository = repository;
this._jobHostdService = jobHostdService; this._jobHostdService = jobHostdService;
this._hubContext = hubContext;
} }
[HttpPost] [HttpPost]
@ -39,6 +35,7 @@ public class JobItemAppService : ApplicationService, ITransientDependency
{ {
var entity = await _repository.InsertAsync(input).ConfigureAwait(false); var entity = await _repository.InsertAsync(input).ConfigureAwait(false);
this._jobHostdService.AddJob(entity); this._jobHostdService.AddJob(entity);
this.Notify();
return entity; return entity;
} }
@ -51,6 +48,7 @@ public class JobItemAppService : ApplicationService, ITransientDependency
await _repository.DeleteAsync(item).ConfigureAwait(false); await _repository.DeleteAsync(item).ConfigureAwait(false);
this._jobHostdService.RemoveJob(item); this._jobHostdService.RemoveJob(item);
} }
this.Notify();
return entites.Count > 0; return entites.Count > 0;
} }
@ -81,8 +79,14 @@ public class JobItemAppService : ApplicationService, ITransientDependency
this._jobHostdService.RemoveJob(entity); this._jobHostdService.RemoveJob(entity);
this._jobHostdService.AddJob(entity); this._jobHostdService.AddJob(entity);
} }
this.Notify();
return input; return input;
} }
private void Notify()
{
this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", "");
}
} }
[Route("api/settleaccount/[controller]/[action]")] [Route("api/settleaccount/[controller]/[action]")]
@ -103,4 +107,15 @@ public class JobLogAppService : ApplicationService, ITransientDependency
var totalCount = await _repository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false); var totalCount = await _repository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
return new PagedResultDto<JobLog>(totalCount, entities); return new PagedResultDto<JobLog>(totalCount, entities);
} }
[HttpPost]
public async Task<bool> DeleteListAsync(List<Guid> ids)
{
var entites = _repository.Where(p => ids.Contains(p.Id)).ToList();
foreach (var item in entites)
{
await _repository.DeleteAsync(item).ConfigureAwait(false);
}
return entites.Count > 0;
}
} }

38
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BeiSeSyncAppService.cs

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
/// <summary>
/// 备件发运同步
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class BeiSeSyncAppService : JitSeSyncAppService
{
/// <summary>
/// 构造
/// </summary>
public BeiSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<PUB_SE_DETAIL, Guid> pubSeDetailRepository
) : base(wmsBJBMPTContext, syncPositionFlagRepository, pubSeDetailRepository)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{
SyncTableName = "BeiSeSync",
SyncDeliverBillType = EnumDeliverBjBmpBillType.4S备件,
SyncDeliverSubBillTypes = new List<EnumDeliverSubBillType>
{
EnumDeliverSubBillType.
},
BusinessType = EnumBusinessType.BeiJian
};
}
}

97
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Coravel.Invocable;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Volo.Abp.Application.Services;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
/// <summary>
/// Jit发运数据同步
/// </summary>
[ApiExplorerSettings(IgnoreApi = true)]
public class JitSeSyncAppService : ApplicationService, IInvocable
{
/// <summary>
/// WMS数据上下文
/// </summary>
private readonly WMSBJBMPTDbContext _wmsBJBMPTContext;
/// <summary>
/// 同步位置标记
/// </summary>
private readonly INormalEfCoreRepository<SyncPositionFlag, Guid> _syncPositionFlagRepository;
/// <summary>
/// Jit发运数据仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_SE_DETAIL, Guid> _pubSeDetailRepository;
/// <summary>
/// 构造
/// </summary>
public JitSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<PUB_SE_DETAIL, Guid> pubSeDetailRepository)
{
_wmsBJBMPTContext = wmsBJBMPTContext;
_syncPositionFlagRepository = syncPositionFlagRepository;
_pubSeDetailRepository = pubSeDetailRepository;
}
/// <summary>
/// 发运同步配置
/// </summary>
public SeSyncConfig SeSyncConfigInfo { get; set; }
[HttpPost]
public async Task Invoke()
{
//同步表名称
var syncTableName = SeSyncConfigInfo.SyncTableName;
//同步发运主类型
var deliverBillType = SeSyncConfigInfo.SyncDeliverBillType;
//同步发运子类型
var deliverSubBillTypes = SeSyncConfigInfo.SyncDeliverSubBillTypes;
//业务类别
var businessType = SeSyncConfigInfo.BusinessType;
Expression<Func<TM_BJBMPT_OTHER_RECORD, bool>> predicate = (t) => t.DeliverBillType == deliverBillType && (!deliverSubBillTypes.Any() || deliverSubBillTypes.Contains(t.DeliverSubBillType));
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName);
if (syncPositionFlag != null)
{
predicate = (t) => t.DeliverBillType == deliverBillType && t.UID > int.Parse(syncPositionFlag.Position) && (!deliverSubBillTypes.Any() || deliverSubBillTypes.Contains(t.DeliverSubBillType));
}
//WMS发运记录
var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_OTHER_RECORD.Where(predicate).OrderBy(b => b.UID).ToList();
var pubSeDetails = ObjectMapper.Map<List<TM_BJBMPT_OTHER_RECORD>, List<PUB_SE_DETAIL>>(wmsSeRecords);
if (pubSeDetails.Any())
{
pubSeDetails.ForEach(t => t.BusinessType = businessType);
await _pubSeDetailRepository.InsertManyAsync(pubSeDetails);
if (syncPositionFlag != null)
{
syncPositionFlag.Position = wmsSeRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag);
}
else
{
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = wmsSeRecords.Last().UID.ToString()
};
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag);
}
}
}
}

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncConfig.cs

@ -1,6 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using DocumentFormat.OpenXml.Office2010.ExcelAc;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs; namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
@ -25,7 +23,7 @@ public class SeSyncConfig
public List<EnumDeliverSubBillType> SyncDeliverSubBillTypes { get; set; } public List<EnumDeliverSubBillType> SyncDeliverSubBillTypes { get; set; }
/// <summary> /// <summary>
/// /// 业务类别
/// </summary> /// </summary>
public EnumBusinessType BusinessType { get; set; } public EnumBusinessType BusinessType { get; set; }
} }

38
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/YinDuSeSyncAppService.cs

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
/// <summary>
/// 印度件发运同步
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class YinDuSeSyncAppService : JitSeSyncAppService
{
/// <summary>
/// 构造
/// </summary>
public YinDuSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<PUB_SE_DETAIL, Guid> pubSeDetailRepository
) : base(wmsBJBMPTContext, syncPositionFlagRepository, pubSeDetailRepository)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{
SyncTableName = "YinDuSeSync",
SyncDeliverBillType = EnumDeliverBjBmpBillType.,
SyncDeliverSubBillTypes = new List<EnumDeliverSubBillType>
{
EnumDeliverSubBillType.
},
BusinessType = EnumBusinessType.YinDuJian
};
}
}

88
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongBBACSeSyncAppService.cs

@ -1,13 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Coravel.Invocable;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using Volo.Abp.Application.Services;
using Win.Sfs.SettleAccount.EntityFrameworkCore; using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
@ -36,87 +31,8 @@ public class ZhiGongBBACSeSyncAppService : JitSeSyncAppService
SyncDeliverSubBillTypes = new List<EnumDeliverSubBillType> SyncDeliverSubBillTypes = new List<EnumDeliverSubBillType>
{ {
EnumDeliverSubBillType.JIT直供件BBAC EnumDeliverSubBillType.JIT直供件BBAC
} },
}; BusinessType = EnumBusinessType.ZhiGongJianBBAC
}
}
/// <summary>
/// Jit发运数据同步
/// </summary>
public class JitSeSyncAppService : ApplicationService, IInvocable
{
/// <summary>
/// WMS数据上下文
/// </summary>
private readonly WMSBJBMPTDbContext _wmsBJBMPTContext;
/// <summary>
/// 同步位置标记
/// </summary>
private readonly INormalEfCoreRepository<SyncPositionFlag, Guid> _syncPositionFlagRepository;
/// <summary>
/// Jit发运数据仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_SE_DETAIL, Guid> _pubSeDetailRepository;
/// <summary>
/// 构造
/// </summary>
public JitSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<PUB_SE_DETAIL, Guid> pubSeDetailRepository)
{
_wmsBJBMPTContext = wmsBJBMPTContext;
_syncPositionFlagRepository = syncPositionFlagRepository;
_pubSeDetailRepository = pubSeDetailRepository;
}
public SeSyncConfig SeSyncConfigInfo { get; set; }
[HttpPost]
public async Task Invoke()
{
//同步表名称
var syncTableName = SeSyncConfigInfo.SyncTableName;
//同步发运主类型
var deliverBillType = SeSyncConfigInfo.SyncDeliverBillType;
//同步发运子类型
var deliverSubBillTypes = SeSyncConfigInfo.SyncDeliverSubBillTypes;
Expression<Func<TM_BJBMPT_OTHER_RECORD, bool>> predicate = (t) => t.DeliverBillType == deliverBillType && (!deliverSubBillTypes.Any() || deliverSubBillTypes.Contains(t.DeliverSubBillType));
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName);
if (syncPositionFlag != null)
{
Expression<Func<TM_BJBMPT_OTHER_RECORD, bool>> expression = (t) => t.UID > int.Parse(syncPositionFlag.Position);
var body = expression.Body;
predicate = Expression.Lambda<Func<TM_BJBMPT_OTHER_RECORD, bool>>(Expression.And(predicate.Body, body), predicate.Parameters);
}
var jitRecords = _wmsBJBMPTContext.TM_BJBMPT_OTHER_RECORD.Where(predicate).OrderBy(b => b.UID)?.ToList();
var pubSeDetails = ObjectMapper.Map<List<TM_BJBMPT_OTHER_RECORD>, List<PUB_SE_DETAIL>>(jitRecords);
if (pubSeDetails.Any())
{
await _pubSeDetailRepository.InsertManyAsync(pubSeDetails);
if (syncPositionFlag != null)
{
syncPositionFlag.Position = jitRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag);
}
else
{
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = jitRecords.Last().UID.ToString()
}; };
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag);
}
}
await Task.CompletedTask;
} }
} }

38
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/ZhiGongHBPOSeSyncAppService.cs

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
/// <summary>
/// 直供件HBPO发运同步
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class ZhiGongHBPOSeSyncAppService : JitSeSyncAppService
{
/// <summary>
/// 构造
/// </summary>
public ZhiGongHBPOSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<PUB_SE_DETAIL, Guid> pubSeDetailRepository
) : base(wmsBJBMPTContext, syncPositionFlagRepository, pubSeDetailRepository)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{
SyncTableName = "ZhiGongHBPOSeSync",
SyncDeliverBillType = EnumDeliverBjBmpBillType.JIT直供件,
SyncDeliverSubBillTypes = new List<EnumDeliverSubBillType>
{
EnumDeliverSubBillType.JIT直供件HBPO
},
BusinessType = EnumBusinessType.ZhiGongJianHBPO
};
}
}

19
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -13,15 +12,18 @@ using InfluxDB.LineProtocol.Client;
using Magicodes.ExporterAndImporter.Core.Extension; using Magicodes.ExporterAndImporter.Core.Extension;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Extensions;
using SettleAccount.Job.SignalR;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.BlobStoring; using Volo.Abp.BlobStoring;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Uow;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi; using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
@ -50,25 +52,31 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
private readonly INormalEfCoreRepository<VmiLog, Guid> _logRepository; private readonly INormalEfCoreRepository<VmiLog, Guid> _logRepository;
private readonly INormalEfCoreRepository<VmiSnapshot, Guid> _snapshotRepository; private readonly INormalEfCoreRepository<VmiSnapshot, Guid> _snapshotRepository;
private readonly IBlobContainer<MyFileContainer> _fileContainer; private readonly IBlobContainer<MyFileContainer> _fileContainer;
private readonly IHubContext<PageHub> _hubContext;
public VmiAppService(IConfiguration cfg, INormalEfCoreRepository<VmiBalance, Guid> balanceRepository, public VmiAppService(IConfiguration cfg,
INormalEfCoreRepository<VmiBalance, Guid> balanceRepository,
INormalEfCoreRepository<VmiLog, Guid> logRepository, INormalEfCoreRepository<VmiLog, Guid> logRepository,
INormalEfCoreRepository<VmiSnapshot, Guid> snapshotRepository, INormalEfCoreRepository<VmiSnapshot, Guid> snapshotRepository,
IBlobContainer<MyFileContainer> fileContainer) IBlobContainer<MyFileContainer> fileContainer,
IHubContext<PageHub> hubContext)
{ {
this._cfg = cfg; this._cfg = cfg;
this._balanceRepository = balanceRepository; this._balanceRepository = balanceRepository;
this._logRepository = logRepository; this._logRepository = logRepository;
this._snapshotRepository = snapshotRepository; this._snapshotRepository = snapshotRepository;
this._fileContainer = fileContainer; this._fileContainer = fileContainer;
this._hubContext = hubContext;
} }
/// <summary> /// <summary>
/// 定时备份 /// 定时备份
/// </summary> /// </summary>
[HttpPost] [HttpPost]
public void Invoke() [UnitOfWork]
public virtual Task Invoke()
{ {
this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", "");
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files/vmi")); Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files/vmi"));
var date = DateTime.Now.ToString("yyyyMMddHH"); var date = DateTime.Now.ToString("yyyyMMddHH");
var connectionString = $"Data Source=wwwroot/files/vmi/{date}.db"; var connectionString = $"Data Source=wwwroot/files/vmi/{date}.db";
@ -84,7 +92,8 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
var snapshot = new VmiSnapshot { Name = date, Path = connectionString }; var snapshot = new VmiSnapshot { Name = date, Path = connectionString };
this._snapshotRepository.InsertAsync(snapshot).Wait(); this._snapshotRepository.InsertAsync(snapshot).Wait();
} }
Debug.WriteLine($"{nameof(VmiAppService)}:{DateTime.Now}"); this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", "");
return Task.CompletedTask;
} }
/// <summary> /// <summary>

2
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs

@ -78,7 +78,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
private async Task<bool> SetSettleState(INVOICE_GRP p_entiy, SettleBillState p_State, bool IsForward = true) private async Task<bool> SetSettleState(INVOICE_GRP p_entiy, SettleBillState p_State, bool IsForward = true)
{ {
if (p_entiy.BusinessType == EnumBusinessType.BeiJian || if (p_entiy.BusinessType == EnumBusinessType.BeiJian ||
p_entiy.BusinessType == EnumBusinessType.YingDuJian || p_entiy.BusinessType == EnumBusinessType.YinDuJian ||
p_entiy.BusinessType == EnumBusinessType.MaiDanJianBBAC || p_entiy.BusinessType == EnumBusinessType.MaiDanJianBBAC ||
p_entiy.BusinessType == EnumBusinessType.MaiDanJianHBPO || p_entiy.BusinessType == EnumBusinessType.MaiDanJianHBPO ||
p_entiy.BusinessType == EnumBusinessType.ZhiGongJianBBAC || p_entiy.BusinessType == EnumBusinessType.ZhiGongJianBBAC ||

4
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; namespace Win.Sfs.SettleAccount.Entities.BQ.Vmi;
public interface IJobService public interface IJobService
{ {
void Invoke(); Task Invoke();
} }

4
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/JobItem.cs

@ -4,7 +4,7 @@ using Volo.Abp.Domain.Entities;
namespace Win.Sfs.SettleAccount.Entities.BQ.Vmi; namespace Win.Sfs.SettleAccount.Entities.BQ.Vmi;
public class JobItem : Entity<Guid>, IHasConcurrencyStamp public class JobItem : Entity<Guid>
{ {
public JobItem(Guid id) public JobItem(Guid id)
{ {
@ -23,5 +23,7 @@ public class JobItem : Entity<Guid>, IHasConcurrencyStamp
public string Service { get; set; } public string Service { get; set; }
public bool IsRunning { get; set; } public bool IsRunning { get; set; }
[Timestamp]
public string ConcurrencyStamp { get; set; } public string ConcurrencyStamp { get; set; }
} }

3
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/JobLog.cs

@ -8,7 +8,8 @@ public class JobLog : Entity<Guid>
public JobItem Job { get; set; } public JobItem Job { get; set; }
public Guid JobId { get; set; } public Guid JobId { get; set; }
public DateTime Start { get; set; } public DateTime Start { get; set; }
public DateTime End { get; set; } public DateTime? End { get; set; }
public bool Success { get; set; } public bool Success { get; set; }
public string Host { get; set; }
public string Exception { get; set; } public string Exception { get; set; }
} }

19
code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBusinessType.cs

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Win.Sfs.SettleAccount namespace Win.Sfs.SettleAccount;
{
/// <summary> /// <summary>
/// 业务类别 /// 业务类别
/// </summary> /// </summary>
@ -59,18 +59,5 @@ namespace Win.Sfs.SettleAccount
/// 印度件 /// 印度件
/// </summary> /// </summary>
[Display(Name = "印度件")] [Display(Name = "印度件")]
YingDuJian = 8, YinDuJian = 8
///// <summary>
/////
///// </summary>
//[Display(Name = "HBPO-JIS")]
//HBPO = 5,
///// <summary>
///// 印度件
///// </summary>
//[Display(Name = "BBAC-JIS")]
//BBAC = 6
}
} }

4920
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230728013132_vmi6.Designer.cs

File diff suppressed because it is too large

56
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230728013132_vmi6.cs

@ -0,0 +1,56 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class vmi6 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "End",
table: "Set_JobLog",
type: "datetime2",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "datetime2");
migrationBuilder.AddColumn<string>(
name: "Host",
table: "Set_JobLog",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
column: "Service",
value: "Win.Sfs.SettleAccount.Entities.BQ.VmiAppService");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Host",
table: "Set_JobLog");
migrationBuilder.AlterColumn<DateTime>(
name: "End",
table: "Set_JobLog",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldNullable: true);
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
column: "Service",
value: "Win.Sfs.SettleAccount.Entities.BQ.VmiService");
}
}
}

11
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

@ -3690,9 +3690,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)") .HasColumnType("nvarchar(50)");
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Cron") b.Property<string>("Cron")
.IsRequired() .IsRequired()
@ -3730,7 +3730,7 @@ namespace Win.Sfs.SettleAccount.Migrations
IsDisabled = false, IsDisabled = false,
IsRunning = false, IsRunning = false,
Name = "库存快照", Name = "库存快照",
Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiService" Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAppService"
}); });
}); });
@ -3740,12 +3740,15 @@ namespace Win.Sfs.SettleAccount.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<DateTime>("End") b.Property<DateTime?>("End")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<string>("Exception") b.Property<string>("Exception")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("Host")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("JobId") b.Property<Guid>("JobId")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");

Loading…
Cancel
Save