mahao 1 year ago
parent
commit
51ef589d9e
  1. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/form/form-input.js
  2. 3
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js
  3. 26
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/vmi/backup.js
  4. 15
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  5. 2
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/form/form-input.js

@ -15,7 +15,7 @@ export default {
<template v-else-if="schema.input==='datetime'">{{dayjs(model[prop]).format('YYYY-MM-DD HH:mm:ss')}}</template> <template v-else-if="schema.input==='datetime'">{{dayjs(model[prop]).format('YYYY-MM-DD HH:mm:ss')}}</template>
<template v-else-if="schema.input==='password'">******</template> <template v-else-if="schema.input==='password'">******</template>
<template v-else-if="schema.input==='select'||schema.input==='tabs'">{{options.find(o=>o.value==model[prop])?.label??model[prop]}}</template> <template v-else-if="schema.input==='select'||schema.input==='tabs'">{{options.find(o=>o.value==model[prop])?.label??model[prop]}}</template>
<template v-else>{{model[prop]}}</template> <template v-else><pre>{{model[prop]}}</pre></template>
</template> </template>
</template> </template>
<template v-else> <template v-else>

3
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/request/index.js

@ -29,6 +29,7 @@ async function getResult(response) {
[204, "无返回值"], [204, "无返回值"],
[400, "请求参数错误"], [400, "请求参数错误"],
[401, "未登录"], [401, "未登录"],
[415, "不支持的内容类型"],
[403, "权限不足"], [403, "权限不足"],
[500, "服务器异常"], [500, "服务器异常"],
[503, "服务不可用"], [503, "服务不可用"],
@ -57,7 +58,7 @@ async function getResult(response) {
console.log(error); console.log(error);
} }
if (!result.errors) { if (!result.errors) {
result.errors = result.message; result.errors = result.message ?? result.status;
} }
} }
return result; return result;

26
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/vmi/backup.js

@ -1,15 +1,35 @@
import AppList from "../../../components/list/index.js"; import AppList from "../../../components/list/index.js";
import html from "html"; import html from "html";
import { ref, nextTick } from "vue";
import useConfig from "../../../models/vmi/backup.js"; import useConfig from "../../../models/vmi/backup.js";
import { useAppStore } from "../../store/index.js";
import request from "../../request/index.js";
export default { export default {
components: { AppList }, components: { AppList },
template: html`<app-list :config="config" @command="onCommand" />`, template: html`<app-list ref="appListRef" :config="config" @command="onCommand" />`,
setup() { setup() {
const appListRef = ref(null);
const config = useConfig(); const config = useConfig();
const appStore = useAppStore();
const onCommand = async (item, rows) => { const onCommand = async (item, rows) => {
console.log(item.path, item, rows); if (item.path === "invoke") {
const url = "settleaccount/vmi/vmi-backup/invoke";
await appListRef.value.onClick(
async () => {
const result = await request(url, null, { method: "POST" }, true);
if (!result.errors) {
appStore.isRefreshing = true;
nextTick(() => {
appStore.isRefreshing = false;
});
}
},
`是否手动进行备份?`,
false
);
}
}; };
return { config, onCommand }; return { appListRef, config, onCommand };
}, },
}; };

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

@ -8,7 +8,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Dynamic.Core; using System.Linq.Dynamic.Core;
using System.Reflection; using System.Reflection;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using ClosedXML.Excel; using ClosedXML.Excel;
using LinqToDB.Data; using LinqToDB.Data;
@ -44,7 +43,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ;
[Route("api/settleaccount/[controller]/[action]")] [Route("api/settleaccount/[controller]/[action]")]
public class VmiAppService : ApplicationService, IJobService, ITransientDependency public class VmiAppService : ApplicationService, IJobService, ITransientDependency
{ {
public static SemaphoreSlim backupLock = new SemaphoreSlim(1); public static object backupLock = new object();
private readonly IConfiguration _cfg; private readonly IConfiguration _cfg;
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
private readonly INormalEfCoreRepository<VmiBalance, Guid> _balanceRepository; private readonly INormalEfCoreRepository<VmiBalance, Guid> _balanceRepository;
@ -159,25 +158,19 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
/// </summary> /// </summary>
[HttpPost("invoke")] [HttpPost("invoke")]
[DisableValidation] [DisableValidation]
public virtual async Task<IActionResult> VmiBackup() public virtual IActionResult VmiBackup()
{ {
if (backupLock.CurrentCount == 1) lock (backupLock)
{ {
return new JsonResult(new { Code = 500, Message = "备份程序正在运行" });
}
await backupLock.WaitAsync().ConfigureAwait(false);
try try
{ {
await Invoke(_serviceProvider).ConfigureAwait(false); Invoke(_serviceProvider).Wait();
return new JsonResult(new { Code = 200, Message = "备份成功" }); return new JsonResult(new { Code = 200, Message = "备份成功" });
} }
catch (Exception ex) catch (Exception ex)
{ {
return new JsonResult(new { Code = 500, Message = ex.Message, Data = ex.ToString() }); return new JsonResult(new { Code = 500, Message = ex.Message, Data = ex.ToString() });
} }
finally
{
backupLock.Release();
} }
} }

2
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs

@ -1327,7 +1327,7 @@ namespace Win.Sfs.SettleAccount
o.Configcode o.Configcode
})).IsUnique(); })).IsUnique();
})); }));
builder.Entity<VmiBalance>().HasData(new VmiBalance(Guid.NewGuid()) { DeliverBillType = EnumDeliverBjBmpBillType.JIS件, RealPartCode = "PartCode", VinCode = "VinCode", ErpToLoc = "ErpToLoc", OrderNum = "OrderNum" }); //builder.Entity<VmiBalance>().HasData(new VmiBalance(Guid.NewGuid()) { DeliverBillType = EnumDeliverBjBmpBillType.JIS件, RealPartCode = "PartCode", VinCode = "VinCode", ErpToLoc = "ErpToLoc", OrderNum = "OrderNum" });
builder.Entity<VmiLog>(b => builder.Entity<VmiLog>(b =>
{ {

Loading…
Cancel
Save