Browse Source

update

master
mahao 1 year ago
parent
commit
d1e99e6594
  1. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs
  2. 13
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js
  3. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/invoice/invoice_map_group.js
  4. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/job-item.js
  5. 16
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/job-log.js
  6. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/job-service.js
  7. 9
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/base-data.js
  8. 32
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs
  9. 19
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobItemAppService.cs
  10. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  11. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/JobItem.cs
  12. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/JobLog.cs
  13. 4920
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230728013132_vmi6.Designer.cs
  14. 56
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230728013132_vmi6.cs
  15. 11
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

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

@ -18,11 +18,11 @@ 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>();
services.AddHostedService(o => o.GetRequiredService<JobHostdService>()); services.AddHostedService(o => o.GetRequiredService<JobHostdService>());
services.AddScheduler();
services.AddTransient<HBPOSeSyncAppService>(); services.AddTransient<HBPOSeSyncAppService>();
services.AddTransient<BBACSeSyncAppService>(); services.AddTransient<BBACSeSyncAppService>();
services.AddTransient<ZhiGongBBACSeSyncAppService>(); services.AddTransient<ZhiGongBBACSeSyncAppService>();

13
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;

4
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: "结算分组号",
@ -22,7 +24,7 @@ const schema = {
title: "金额", title: "金额",
type: "decimal", type: "decimal",
}, },
state , state,
taxAmt: { taxAmt: {
title: "税额", title: "税额",
type: "decimal", type: "decimal",

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,
},
},
], ],
}, },
}, },

32
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,22 @@ 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);
} }
try try
{ {
jobService.Invoke(); jobService.Invoke();
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);
} }
} }
} }
@ -118,7 +121,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 +129,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 +137,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 +145,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);
log.End = DateTime.Now; if (log != null)
log.Success = true; {
log.End = DateTime.Now;
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 +163,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)

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

@ -1,16 +1,9 @@
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.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Omu.ValueInjecter; using Omu.ValueInjecter;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
@ -21,7 +14,6 @@ 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
{ {
@ -103,4 +95,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;
}
} }

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

@ -22,6 +22,7 @@ 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;
@ -51,7 +52,8 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
private readonly INormalEfCoreRepository<VmiSnapshot, Guid> _snapshotRepository; private readonly INormalEfCoreRepository<VmiSnapshot, Guid> _snapshotRepository;
private readonly IBlobContainer<MyFileContainer> _fileContainer; private readonly IBlobContainer<MyFileContainer> _fileContainer;
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)
@ -67,6 +69,7 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
/// 定时备份 /// 定时备份
/// </summary> /// </summary>
[HttpPost] [HttpPost]
[UnitOfWork]
public void Invoke() public void Invoke()
{ {
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files/vmi")); Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files/vmi"));

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; }
} }

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