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)
{
services.AddScheduler();
services.AddSignalR(o => o.EnableDetailedErrors = true);
JobHostdService.AddService(services);
services.AddSingleton<JobHostdService>();
services.AddHostedService(o => o.GetRequiredService<JobHostdService>());
services.AddScheduler();
services.AddTransient<HBPOSeSyncAppService>();
services.AddTransient<BBACSeSyncAppService>();
services.AddTransient<ZhiGongBBACSeSyncAppService>();

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

@ -103,6 +103,13 @@ export default {
</template>
</el-table-column>
</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-if="showColumn(item,key)">
<el-table-column
@ -151,7 +158,6 @@ export default {
<el-row>
<el-col>
<el-pagination
v-if="pageModel.pageSize<pageModel.total"
v-model:currentPage="pageModel.pageIndex"
v-model:page-size="pageModel.pageSize"
:total="pageModel.total"
@ -495,7 +501,10 @@ export default {
}
};
const onPageIndexChange = async () => await load();
const onPageSizeChange = async () => await load();
const onPageSizeChange = async () => {
pageModel.pageIndex = 1;
await load();
};
const click = async (item, rows) => {
editFormloading.value = true;
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: {
title: "系统生成发票号",
type: "string",
link: true,
},
invGroupNum: {
title: "发票分组号",
type: "string",
link: true,
},
settleGroupNum: {
title: "结算分组号",
@ -22,7 +24,7 @@ const schema = {
title: "金额",
type: "decimal",
},
state ,
state,
taxAmt: {
title: "税额",
type: "decimal",

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

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

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

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

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

@ -548,6 +548,15 @@ export default [
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.Diagnostics;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Cronos;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Volo.Abp.Application.Services;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
namespace Win.Sfs.SettleAccount.Entities.BQ;
public class JobHostdService : BackgroundService
public class JobHostdService : BackgroundService, IApplicationService
{
private readonly object _lockObj = new object();
private readonly IServiceProvider _serviceProvider;
@ -72,21 +74,22 @@ public class JobHostdService : BackgroundService
if (!job.IsDisabled)
{
var jobItem = this.GetJobItem(job.Id);
Guid? jobLogId = null;
if (!jobItem.IsRunning)
{
this.JobItemStart(job.Id);
jobLogId = this.JobItemStart(job.Id);
}
try
{
jobService.Invoke();
this.JobItemSuccess(job.Id);
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, 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();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
@ -126,7 +129,7 @@ public class JobHostdService : BackgroundService
if (entity != null)
{
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.Success = false;
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();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
@ -142,14 +145,17 @@ public class JobHostdService : BackgroundService
if (entity != null)
{
entity.IsRunning = false;
var log = db.Set<JobLog>().FirstOrDefault(o => o.JobId == id);
log.End = DateTime.Now;
log.Success = true;
var log = db.Set<JobLog>().FirstOrDefault(o => o.Id == jobLogId);
if (log != null)
{
log.End = DateTime.Now;
log.Success = true;
}
db.SaveChanges();
}
}
private void JobItemStart(Guid id)
private Guid? JobItemStart(Guid id)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
@ -157,9 +163,11 @@ public class JobHostdService : BackgroundService
if (entity != null)
{
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();
return log.Entity.Id;
}
return null;
}
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.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading;
using System.Threading.Tasks;
using Cronos;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Omu.ValueInjecter;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
@ -21,7 +14,6 @@ using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ;
[Route("api/settleaccount/[controller]/[action]")]
public class JobItemAppService : ApplicationService, ITransientDependency
{
@ -103,4 +95,15 @@ public class JobLogAppService : ApplicationService, ITransientDependency
var totalCount = await _repository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
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.BlobStoring;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Uow;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
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 IBlobContainer<MyFileContainer> _fileContainer;
public VmiAppService(IConfiguration cfg, INormalEfCoreRepository<VmiBalance, Guid> balanceRepository,
public VmiAppService(IConfiguration cfg,
INormalEfCoreRepository<VmiBalance, Guid> balanceRepository,
INormalEfCoreRepository<VmiLog, Guid> logRepository,
INormalEfCoreRepository<VmiSnapshot, Guid> snapshotRepository,
IBlobContainer<MyFileContainer> fileContainer)
@ -67,6 +69,7 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
/// 定时备份
/// </summary>
[HttpPost]
[UnitOfWork]
public void Invoke()
{
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;
public class JobItem : Entity<Guid>, IHasConcurrencyStamp
public class JobItem : Entity<Guid>
{
public JobItem(Guid id)
{
@ -23,5 +23,7 @@ public class JobItem : Entity<Guid>, IHasConcurrencyStamp
public string Service { get; set; }
public bool IsRunning { get; set; }
[Timestamp]
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 Guid JobId { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
public DateTime? End { get; set; }
public bool Success { get; set; }
public string Host { 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")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)")
.HasColumnName("ConcurrencyStamp");
.HasColumnType("nvarchar(50)");
b.Property<string>("Cron")
.IsRequired()
@ -3730,7 +3730,7 @@ namespace Win.Sfs.SettleAccount.Migrations
IsDisabled = false,
IsRunning = false,
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()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("End")
b.Property<DateTime?>("End")
.HasColumnType("datetime2");
b.Property<string>("Exception")
.HasColumnType("nvarchar(max)");
b.Property<string>("Host")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("JobId")
.HasColumnType("uniqueidentifier");

Loading…
Cancel
Save