Browse Source

添加Vmi配置

master
wanggang 1 year ago
parent
commit
de33458cfa
  1. 21
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs
  2. 6
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json
  3. 4
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountEntityFrameworkCoreModule.cs
  4. 4259
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230719032116_vmi.Designer.cs
  5. 173
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230719032116_vmi.cs
  6. 221
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs
  7. 6
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/appsettings.json

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

@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.StaticFiles; using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Volo.Abp.Domain.Repositories; using NUglify.Helpers;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi; using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
namespace Win.Sfs.SettleAccount; namespace Win.Sfs.SettleAccount;
@ -19,6 +19,9 @@ public class Startup
{ {
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
AppDomain.CurrentDomain.GetAssemblies().SelectMany(o => o.GetTypes())
.Where(o => o.IsClass && !o.IsAbstract && o.IsAssignableTo(typeof(IJobService)))
.ForEach(o => services.AddTransient(o));
services.AddScheduler(); services.AddScheduler();
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())));
@ -41,7 +44,7 @@ public class Startup
app.ApplicationServices.UseScheduler(scheduler => app.ApplicationServices.UseScheduler(scheduler =>
{ {
using var scope = app.ApplicationServices.CreateScope(); using var scope = app.ApplicationServices.CreateScope();
var jobs = scope.ServiceProvider.GetService<IRepository<JobItem>>()?.ToList(); var jobs = scope.ServiceProvider.GetService<SettleAccountDbContext>().Set<JobItem>().ToList();
jobs?.ForEach(job => jobs?.ForEach(job =>
{ {
var jobId = job.Id; var jobId = job.Id;
@ -51,13 +54,15 @@ public class Startup
{ {
if (scope.ServiceProvider.GetService(serviceType) is IJobService jobService) if (scope.ServiceProvider.GetService(serviceType) is IJobService jobService)
{ {
scheduler.Schedule(() => { scheduler.Schedule(() =>
{
using var scope = app.ApplicationServices.CreateScope(); using var scope = app.ApplicationServices.CreateScope();
var jobItemRepository = scope.ServiceProvider.GetRequiredService<IRepository<JobItem>>(); var db = scope.ServiceProvider.GetService<SettleAccountDbContext>();
var jobLogRepository = scope.ServiceProvider.GetRequiredService<IRepository<JobLog>>(); var jobItemRepository = db.Set<JobItem>();
var jobLogRepository = db.Set<JobLog>();
var jobItem = jobItemRepository.FirstOrDefault(o => o.Id == jobId); var jobItem = jobItemRepository.FirstOrDefault(o => o.Id == jobId);
jobItem.IsRunning = true; jobItem.IsRunning = true;
jobItemRepository.UpdateAsync(jobItem).Wait(); db.SaveChanges();
var jobLog = new JobLog { JobId = jobId, Start = DateTime.Now }; var jobLog = new JobLog { JobId = jobId, Start = DateTime.Now };
try try
{ {
@ -72,9 +77,9 @@ public class Startup
finally finally
{ {
jobLog.End = DateTime.Now; jobLog.End = DateTime.Now;
jobLogRepository.InsertAsync(jobLog).Wait(); jobLogRepository.Add(jobLog);
jobItem.IsRunning = false; jobItem.IsRunning = false;
jobItemRepository.UpdateAsync(jobItem).Wait(); db.SaveChanges();
} }
}).Cron(job.Cron); }).Cron(job.Cron);
} }

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

@ -3,10 +3,8 @@
"CorsOrigins": "https://*.abc.com,http://localhost:9527,http://149.223.116.5:8088" "CorsOrigins": "https://*.abc.com,http://localhost:9527,http://149.223.116.5:8088"
}, },
"ConnectionStrings": { "ConnectionStrings": {
//"Default": "Server=dev.ccwin-in.com,13319;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True", "Default": "Server=dev.ccwin-in.com,13319;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True",
//"SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;" "SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;"
"SettleAccountService": "Server=localhost;Database=BQ_SA;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True",
"Default": "Server=localhost;Database=BJABP;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True"
}, },
"Serilog": { "Serilog": {
"Using": [], "Using": [],

4
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountEntityFrameworkCoreModule.cs

@ -1,4 +1,4 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Dapper; using Volo.Abp.Dapper;
@ -153,4 +153,4 @@ namespace Win.Sfs.SettleAccount
}); });
} }
} }
} }

4259
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230719032116_vmi.Designer.cs

File diff suppressed because it is too large

173
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230719032116_vmi.cs

@ -0,0 +1,173 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class vmi : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Set_JobItem",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Cron = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Service = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
IsRunning = table.Column<bool>(type: "bit", nullable: false),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Set_JobItem", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Set_VmiBalance",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LU = table.Column<string>(type: "nvarchar(450)", nullable: false),
PN = table.Column<string>(type: "nvarchar(450)", nullable: false),
PNType = table.Column<int>(type: "int", nullable: false),
Type = table.Column<string>(type: "nvarchar(max)", nullable: true),
Qty = table.Column<decimal>(type: "decimal(18,2)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Set_VmiBalance", x => x.Id);
table.UniqueConstraint("AK_Set_VmiBalance_PN_LU", x => new { x.PN, x.LU });
});
migrationBuilder.CreateTable(
name: "Set_VmiCategory",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Type = table.Column<int>(type: "int", nullable: false),
Number = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Set_VmiCategory", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Set_VmiSnapshot",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
Path = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Set_VmiSnapshot", x => x.Id);
});
migrationBuilder.CreateTable(
name: "JobLog",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
JobId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Start = table.Column<DateTime>(type: "datetime2", nullable: false),
End = table.Column<DateTime>(type: "datetime2", nullable: false),
Success = table.Column<bool>(type: "bit", nullable: false),
Exception = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_JobLog", x => x.Id);
table.ForeignKey(
name: "FK_JobLog_Set_JobItem_JobId",
column: x => x.JobId,
principalTable: "Set_JobItem",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "Set_VmiLog",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CategoryId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
BalanceId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
SessionId = table.Column<string>(type: "nvarchar(max)", nullable: true),
Type = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Set_VmiLog", x => x.Id);
table.ForeignKey(
name: "FK_Set_VmiLog_Set_VmiBalance_BalanceId",
column: x => x.BalanceId,
principalTable: "Set_VmiBalance",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Set_VmiLog_Set_VmiCategory_CategoryId",
column: x => x.CategoryId,
principalTable: "Set_VmiCategory",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "Set_JobItem",
columns: new[] { "Id", "ConcurrencyStamp", "Cron", "IsRunning", "Name", "Service" },
values: new object[] { new Guid("a6d57042-e087-421e-a086-dfb34c6bfe80"), null, "0 0 8 26 *", false, "库存快照", "Win.Sfs.SettleAccount.Entities.BQ.VmiService" });
migrationBuilder.CreateIndex(
name: "IX_JobLog_JobId",
table: "JobLog",
column: "JobId");
migrationBuilder.CreateIndex(
name: "IX_Set_JobItem_Name",
table: "Set_JobItem",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Set_VmiCategory_Number",
table: "Set_VmiCategory",
column: "Number",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Set_VmiLog_BalanceId",
table: "Set_VmiLog",
column: "BalanceId");
migrationBuilder.CreateIndex(
name: "IX_Set_VmiLog_CategoryId",
table: "Set_VmiLog",
column: "CategoryId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "JobLog");
migrationBuilder.DropTable(
name: "Set_VmiLog");
migrationBuilder.DropTable(
name: "Set_VmiSnapshot");
migrationBuilder.DropTable(
name: "Set_JobItem");
migrationBuilder.DropTable(
name: "Set_VmiBalance");
migrationBuilder.DropTable(
name: "Set_VmiCategory");
}
}
}

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

@ -3276,6 +3276,183 @@ namespace Win.Sfs.SettleAccount.Migrations
b.ToTable("Set_bom"); b.ToTable("Set_bom");
}); });
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.JobItem", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Cron")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("IsRunning")
.HasColumnType("bit");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Service")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Set_JobItem");
b.HasData(
new
{
Id = new Guid("a6d57042-e087-421e-a086-dfb34c6bfe80"),
Cron = "0 0 8 26 *",
IsRunning = false,
Name = "库存快照",
Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiService"
});
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.JobLog", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("End")
.HasColumnType("datetime2");
b.Property<string>("Exception")
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("JobId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("Start")
.HasColumnType("datetime2");
b.Property<bool>("Success")
.HasColumnType("bit");
b.HasKey("Id");
b.HasIndex("JobId");
b.ToTable("JobLog");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiBalance", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("LU")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("PN")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("PNType")
.HasColumnType("int");
b.Property<decimal>("Qty")
.HasColumnType("decimal(18,2)");
b.Property<string>("Type")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasAlternateKey("PN", "LU");
b.ToTable("Set_VmiBalance");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiCategory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Number")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("Number")
.IsUnique();
b.ToTable("Set_VmiCategory");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiLog", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<Guid>("BalanceId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("CategoryId")
.HasColumnType("uniqueidentifier");
b.Property<string>("SessionId")
.HasColumnType("nvarchar(max)");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("BalanceId");
b.HasIndex("CategoryId");
b.ToTable("Set_VmiLog");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiSnapshot", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("Path")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Set_VmiSnapshot");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.Boms.BomVersion", b => modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.Boms.BomVersion", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
@ -4030,6 +4207,50 @@ namespace Win.Sfs.SettleAccount.Migrations
b.ToTable("Set_relationship"); b.ToTable("Set_relationship");
}); });
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.JobLog", b =>
{
b.HasOne("Win.Sfs.SettleAccount.Entities.BQ.Vmi.JobItem", "Job")
.WithMany("Logs")
.HasForeignKey("JobId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("Job");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiLog", b =>
{
b.HasOne("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiBalance", "Balance")
.WithMany("Logs")
.HasForeignKey("BalanceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiCategory", "Category")
.WithMany("Logs")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Balance");
b.Navigation("Category");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.JobItem", b =>
{
b.Navigation("Logs");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiBalance", b =>
{
b.Navigation("Logs");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.BQ.Vmi.VmiCategory", b =>
{
b.Navigation("Logs");
});
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }

6
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/appsettings.json

@ -9,8 +9,10 @@
"CorsOrigins": "http://localhost:9527,http://dev.ccwin-in.com:10588,http://localhost:44307" "CorsOrigins": "http://localhost:9527,http://dev.ccwin-in.com:10588,http://localhost:44307"
}, },
"ConnectionStrings": { "ConnectionStrings": {
"SettleAccountService": "Server=localhost;Database=BQ_SA;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True", "Default": "Server=dev.ccwin-in.com,13319;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True",
"Default": "Server=localhost;Database=BJABP;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True" "SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;"
//"SettleAccountService": "Server=localhost;Database=BQ_SA;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True",
//"Default": "Server=localhost;Database=BJABP;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True"
}, },
"ElasticSearch": { "ElasticSearch": {
"Url": "http://localhost:9200" "Url": "http://localhost:9200"

Loading…
Cancel
Save