学 赵 1 year ago
parent
commit
6502c43bf5
  1. 19
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Program.cs
  2. 42
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccountHttpApiHostModule.cs
  3. 5
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/compare/compare.js
  4. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HandSeSyncAppService.cs
  5. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncAppService.cs
  6. 202
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs
  7. 11
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncAppService.cs
  8. 198
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs
  9. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs
  10. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MaiDanBBACSeSyncAppService.cs
  11. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MaiDanHBPOSeSyncAppService.cs
  12. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs
  13. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs
  14. 126
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  15. 40
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs
  16. 11
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs
  17. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs
  18. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiBalance.cs
  19. 15
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs
  20. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiMessage.cs
  21. 9
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs
  22. 5820
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230831024215_vmi19.Designer.cs
  23. 228
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230831024215_vmi19.cs
  24. 37
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs
  25. 1
      code/src/Shared/Win.Sfs.Shared/Win.Sfs.Shared.csproj

19
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Program.cs

@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Settings.Configuration;
namespace Win.Sfs.SettleAccount;
@ -13,21 +12,13 @@ public class Program
{
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true, reloadOnChange: true)
.Build();
//try
//{
// new InfluxHelper(configuration).Start();
//}
//catch (Exception ex)
//{
// Console.Write("时序数据库启动失败");
// Console.Write(ex.ToString());
// //throw;
//}
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true, reloadOnChange: true);
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration, ConfigurationAssemblySource.AlwaysScanDllFiles)
.WriteTo.Async(c => c.File("Logs/logs.txt"
, rollingInterval: RollingInterval.Day
, rollOnFileSizeLimit: true
, fileSizeLimitBytes: 30 * 1024 * 1024))
.WriteTo.Async(c => c.Console())
.CreateLogger();

42
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccountHttpApiHostModule.cs

@ -1,25 +1,26 @@
using System;
using System.IO;
using System.Linq;
using System.Text.Json;
using AuthServer.Host;
using BaseService;
using Hangfire;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using StackExchange.Redis;
using Swashbuckle.AspNetCore.SwaggerUI;
using System;
using System.IO;
using System.Linq;
using System.Text.Json;
using Volo.Abp;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Autofac;
@ -37,7 +38,6 @@ using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.Threading;
using Volo.Abp.VirtualFileSystem;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.ImportExcelCommon;
using Win.Sfs.Shared.Constant;
using Win.Utils;
@ -258,6 +258,17 @@ namespace Win.Sfs.SettleAccount
{
//将错误明细发送给客户端
Configure<AbpExceptionHandlingOptions>(options => { options.SendExceptionsDetailsToClients = true; });
Configure<MvcOptions>(options =>
{
var index = options.Filters.ToList().FindIndex(filter => filter is ServiceFilterAttribute attr && attr.ServiceType.Equals(typeof(AbpExceptionFilter)));
if (index > -1)
{
options.Filters.RemoveAt(index);
}
options.Filters.Add(typeof(CustomExceptionFilter));
});
}
private void ConfigureMultiTenancy()
@ -476,4 +487,21 @@ namespace Win.Sfs.SettleAccount
});
}
}
public class CustomExceptionFilter : IExceptionFilter
{
private readonly ILogger<CustomExceptionFilter> logger;
public CustomExceptionFilter(ILogger<CustomExceptionFilter> logger)
{
this.logger = logger;
}
public void OnException(ExceptionContext context)
{
logger.LogError(new EventId(context.Exception.HResult), context.Exception, context.Exception.Message);
var message = context.Exception.InnerException?.InnerException?.Message ?? context.Exception.Message;
context.Result = new JsonResult(new { code = 400, message });
context.ExceptionHandled = true;
}
}
}

5
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/compare/compare.js

@ -10,6 +10,11 @@ const defaultCompareSchema = {
title: "发运日期",
type: "array",
input: "datetimerange",
rules: [
{
required: true,
},
],
},
downLineDateTime: {
title: "下线日期",

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

@ -32,7 +32,7 @@ public class HandSeSyncAppService : ApplicationService
public virtual async Task SyncAsync([FromBody] EnumBusinessType businessType)
{
using var scope = this._applicationServices.CreateScope();
IInvocable jitSeSyncAppService = businessType switch
IInvocable seSyncAppService = businessType switch
{
EnumBusinessType.JisBBAC => scope.ServiceProvider.GetRequiredService<JisBBACSeSyncAppService>(),
EnumBusinessType.JisHBPO => scope.ServiceProvider.GetRequiredService<JisHBPOSeSyncAppService>(),
@ -44,6 +44,6 @@ public class HandSeSyncAppService : ApplicationService
EnumBusinessType.YinDuJian => scope.ServiceProvider.GetRequiredService<YinDuSeSyncAppService>(),
_ => throw new ArgumentOutOfRangeException(nameof(businessType), $"Not expected direction value: {businessType}"),
};
await jitSeSyncAppService.Invoke().ConfigureAwait(false);
await seSyncAppService.Invoke().ConfigureAwait(false);
}
}

12
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncAppService.cs

@ -3,11 +3,9 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
@ -24,11 +22,8 @@ public class JisBBACSeSyncAppService : JisBBACSeSyncBaseAppService, IJobService
public JisBBACSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<BBAC_SE_DETAIL, Guid> jisSeDetailRepository,
MaterialRelationshipManager materialRelationshipManager,
VmiAppService vmiService
) : base(wmsBJBMPTContext, settleAccountDbContext, syncPositionFlagRepository, jisSeDetailRepository, materialRelationshipManager, vmiService)
SeSyncExtendManager syncExtendManager
) : base(wmsBJBMPTContext, settleAccountDbContext, syncExtendManager)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{
@ -43,6 +38,7 @@ public class JisBBACSeSyncAppService : JisBBACSeSyncBaseAppService, IJobService
};
}
[UnitOfWork(IsDisabled = true)]
public async Task Invoke(IServiceProvider serviceProvider)
{
await this.Invoke().ConfigureAwait(false);

202
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs

@ -1,14 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Coravel.Invocable;
using EFCore.BulkExtensions;
using LinqToDB;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Volo.Abp.Application.Services;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.RepositoryBase;
@ -25,28 +24,14 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable
/// WMS数据上下文
/// </summary>
private readonly WMSBJBMPTDbContext _wmsBJBMPTContext;
/// <summary>
/// 数据上下文
/// </summary>
private readonly SettleAccountDbContext _settleAccountDbContext;
/// <summary>
/// 同步位置标记
/// 发运同步扩展
/// </summary>
private readonly INormalEfCoreRepository<SyncPositionFlag, Guid> _syncPositionFlagRepository;
/// <summary>
/// Jis发运数据仓储
/// </summary>
private readonly INormalEfCoreRepository<BBAC_SE_DETAIL, Guid> _jisSeDetailRepository;
/// <summary>
/// 客户零件关系领域
/// </summary>
private readonly MaterialRelationshipManager _materialRelationshipManager;
//private readonly IVmiService _vmiService;
private readonly SeSyncExtendManager _syncExtendManager;
/// <summary>
/// 构造
@ -54,17 +39,11 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable
public JisBBACSeSyncBaseAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<BBAC_SE_DETAIL, Guid> jisSeDetailRepository,
MaterialRelationshipManager materialRelationshipManager,
VmiAppService vmiService)
SeSyncExtendManager syncExtendManager)
{
_wmsBJBMPTContext = wmsBJBMPTContext;
_settleAccountDbContext = settleAccountDbContext;
_syncPositionFlagRepository = syncPositionFlagRepository;
_jisSeDetailRepository = jisSeDetailRepository;
_materialRelationshipManager = materialRelationshipManager;
//_vmiService = vmiService;
_syncExtendManager = syncExtendManager;
}
/// <summary>
@ -80,7 +59,6 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable
return;
}
await SyncJitRecordAsync().ConfigureAwait(false);
await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false);
await SyncJisRecordAsync().ConfigureAwait(false);
}
@ -97,53 +75,27 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable
var deliverSubBillTypes = SeSyncConfigInfo.SyncDeliverSubBillTypes;
//业务类别
var businessType = SeSyncConfigInfo.BusinessType;
Expression<Func<TM_BJBMPT_JIT_RECORD, bool>> predicate = (t) => t.DeliverBillType == deliverBillType && deliverSubBillTypes.Contains(t.DeliverSubBillType);
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName).ConfigureAwait(false);
if (syncPositionFlag != null)
{
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == deliverBillType && deliverSubBillTypes.Contains(t.DeliverSubBillType);
}
//WMS发运记录
var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD.Where(predicate).OrderBy(b => b.UID).Take(100000).ToList();
var jisSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<BBAC_SE_DETAIL>>(wmsSeRecords);
if (jisSeDetails.Any())
var seed = 0;
while (seed < 10)
{
//客户零件号和厂内零件号
var luRePartCodes = jisSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList();
if (luRePartCodes.Any())
seed++;
var syncPositionFlag = await _settleAccountDbContext.Set<SyncPositionFlag>().FirstOrDefaultAsync(t => t.TableName == syncTableName).ConfigureAwait(false);
var syncPosition = syncPositionFlag?.Position ?? "0";
//WMS发运记录
var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD
.Where(t => t.UID > int.Parse(syncPosition))
.Where(t => t.DeliverBillType == deliverBillType)
.Where(t => deliverSubBillTypes.Contains(t.DeliverSubBillType))
.OrderBy(b => b.UID).Take(100_000).ToList();
var jisSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<BBAC_SE_DETAIL>>(wmsSeRecords);
if (jisSeDetails.Any())
{
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.FactoryPartCode, "", t.LU, businessType));
await this.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
}
jisSeDetails.ForEach(t =>
{
t.SetId(GuidGenerator.Create());
t.BusinessType = businessType;
t.CustomerPartCodeNoSpace = t.LU.Replace(" ", "");
t.KeyCode = t.PN + t.LU;
if (t.BillTime != null)
{
t.Version = int.Parse(t.BillTime?.ToString("yyyyMM"));
}
});
await _settleAccountDbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);
if (syncPositionFlag != null)
{
syncPositionFlag.Position = wmsSeRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag).ConfigureAwait(false);
await SeDataPutInStorageAsync(jisSeDetails, false).ConfigureAwait(false);
}
else
{
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = wmsSeRecords.Last().UID.ToString()
};
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag).ConfigureAwait(false);
break;
}
}
}
@ -161,74 +113,90 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable
var deliverSubBillTypes = SeSyncConfigInfo.SyncDeliverSubBillTypes;
//业务类别
var businessType = SeSyncConfigInfo.BusinessType;
var seed = 0;
while (seed < 10)
{
seed++;
var syncPositionFlag = await _settleAccountDbContext.Set<SyncPositionFlag>().FirstOrDefaultAsync(t => t.TableName == syncTableName).ConfigureAwait(false);
var syncPosition = syncPositionFlag?.Position ?? "0";
//WMS发运记录
var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD
.Where(t => t.UID > int.Parse(syncPosition))
.Where(t => t.DeliverBillType == deliverBillType)
.Where(t => deliverSubBillTypes.Contains(t.DeliverSubBillType))
.OrderBy(b => b.UID).Take(100_000).ToList();
var jisSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIS_RECORD>, List<BBAC_SE_DETAIL>>(wmsSeRecords);
if (jisSeDetails.Any())
{
await SeDataPutInStorageAsync(jisSeDetails, true).ConfigureAwait(false);
}
else
{
break;
}
}
}
/// <summary>
/// 发运数据入库
/// </summary>
private async Task SeDataPutInStorageAsync(List<BBAC_SE_DETAIL> seDetails, bool isJisTable)
{
//同步表名称
var syncTableName = isJisTable ? SeSyncConfigInfo.SyncTableName +
"_Jis" : SeSyncConfigInfo.SyncTableName + "_Jit";
//业务类别
var businessType = SeSyncConfigInfo.BusinessType;
Expression<Func<TM_BJBMPT_JIS_RECORD, bool>> predicate = (t) => t.DeliverBillType == deliverBillType && deliverSubBillTypes.Contains(t.DeliverSubBillType);
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName).ConfigureAwait(false);
if (syncPositionFlag != null)
//客户零件号和厂内零件号
var luRePartCodes = seDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList();
if (luRePartCodes.Any())
{
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == deliverBillType && deliverSubBillTypes.Contains(t.DeliverSubBillType);
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.FactoryPartCode, "", t.LU, businessType));
await _syncExtendManager.AddNewMaterialRelationshipsAsync(materialRelationships).ConfigureAwait(false);
}
//WMS发运数据
var wmsRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD.Where(predicate).OrderBy(b => b.UID).Take(100000).ToList();
var jisSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIS_RECORD>, List<BBAC_SE_DETAIL>>(wmsRecords);
if (jisSeDetails.Any())
seDetails.ForEach(t =>
{
//客户零件号和厂内零件号
var luRePartCodes = jisSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList();
if (luRePartCodes.Any())
t.SetId(GuidGenerator.Create());
t.BusinessType = businessType;
t.CustomerPartCodeNoSpace = t.LU.Replace(" ", "");
t.KeyCode = t.PN + t.LU;
if (t.BillTime != null)
{
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.FactoryPartCode, "", t.LU, businessType));
await this.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
t.Version = int.Parse(t.BillTime?.ToString("yyyyMM"));
}
});
var syncPosition = seDetails.Last().UID.ToString();
jisSeDetails.ForEach(t =>
{
t.SetId(GuidGenerator.Create());
t.BusinessType = businessType;
t.CustomerPartCodeNoSpace = t.LU.Replace(" ", "");
t.KeyCode = t.PN + t.LU;
if (t.BillTime != null)
{
t.Version = int.Parse(t.BillTime?.ToString("yyyyMM"));
}
});
await _settleAccountDbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);
using var transaction = await _settleAccountDbContext.Database.BeginTransactionAsync().ConfigureAwait(false);
try
{
var syncPositionFlag = await _settleAccountDbContext.Set<SyncPositionFlag>().FirstOrDefaultAsync(t => t.TableName == syncTableName).ConfigureAwait(false);
if (syncPositionFlag != null)
{
syncPositionFlag.Position = wmsRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag).ConfigureAwait(false);
syncPositionFlag.Position = syncPosition;
_settleAccountDbContext.Update<SyncPositionFlag>(syncPositionFlag);
}
else
{
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = wmsRecords.Last().UID.ToString()
Position = syncPosition
};
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag).ConfigureAwait(false); ;
_settleAccountDbContext.Add<SyncPositionFlag>(syncPositionFlag);
}
await _settleAccountDbContext.BulkInsertAsync(seDetails).ConfigureAwait(false);
await _syncExtendManager.JisSeDetailsSaveConsignAsync<BBAC_SE_DETAIL>(seDetails, isJisTable).ConfigureAwait(false);
await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false);
await transaction.CommitAsync().ConfigureAwait(false);
}
}
/// <summary>
/// 添加零件关系
/// </summary>
public async Task AddNewMaterialRelationships(IEnumerable<MaterialRelationship> materialRelationships)
{
//新客户零件号和厂内零件号
var noHaveLuRePartCodes = from item1 in materialRelationships
join item2 in _settleAccountDbContext.Set<MaterialRelationship>()
on new { item1.ErpMaterialCode, item1.SettleMaterialCode } equals new { item2.ErpMaterialCode, item2.SettleMaterialCode }
into temp
from item3 in temp.DefaultIfEmpty()
where item3 == null
select item1;
if (noHaveLuRePartCodes.Any())
catch (Exception)
{
await _settleAccountDbContext.BulkInsertAsync(noHaveLuRePartCodes.ToList()).ConfigureAwait(false);
await transaction.RollbackAsync().ConfigureAwait(false);
throw;
}
}
}

11
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncAppService.cs

@ -1,14 +1,10 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
@ -24,11 +20,8 @@ public class JisHBPOSeSyncAppService : JisHBPOSeSyncBaseAppService, IJobService
public JisHBPOSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> jisSeDetailRepository,
MaterialRelationshipManager materialRelationshipManager,
SeSyncExtendManager syncExtendManager
) : base(wmsBJBMPTContext, settleAccountDbContext, syncPositionFlagRepository, jisSeDetailRepository, materialRelationshipManager, syncExtendManager)
) : base(wmsBJBMPTContext, settleAccountDbContext, syncExtendManager)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{
@ -43,7 +36,7 @@ public class JisHBPOSeSyncAppService : JisHBPOSeSyncBaseAppService, IJobService
};
}
[UnitOfWork(IsDisabled = false)]
[UnitOfWork(IsDisabled = true)]
public virtual async Task Invoke(IServiceProvider serviceProvider)
{
await this.Invoke().ConfigureAwait(false);

198
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs

@ -1,17 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.LinqAsync;
using System.Threading.Tasks;
using Coravel.Invocable;
using EFCore.BulkExtensions;
using LinqToDB;
using Microsoft.AspNetCore.Mvc;
using Org.BouncyCastle.Asn1.Cmp;
using SettleAccount.Domain.BQ;
using Volo.Abp.Application.Services;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.MaterialRelationships;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.RepositoryBase;
@ -28,26 +24,10 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
/// WMS数据上下文
/// </summary>
private readonly WMSBJBMPTDbContext _wmsBJBMPTContext;
/// <summary>
/// 数据上下文
/// </summary>
private readonly SettleAccountDbContext _settleAccountDbContext;
/// <summary>
/// 同步位置标记
/// </summary>
private readonly INormalEfCoreRepository<SyncPositionFlag, Guid> _syncPositionFlagRepository;
/// <summary>
/// Jis发运数据仓储
/// </summary>
private readonly INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> _jisSeDetailRepository;
/// <summary>
/// 客户零件关系领域
/// </summary>
private readonly MaterialRelationshipManager _materialRelationshipManager;
/// <summary>
/// 发运同步扩展
/// </summary>
@ -59,17 +39,12 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
public JisHBPOSeSyncBaseAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> jisSeDetailRepository,
MaterialRelationshipManager materialRelationshipManager,
SeSyncExtendManager syncExtendManager)
{
_wmsBJBMPTContext = wmsBJBMPTContext;
_settleAccountDbContext = settleAccountDbContext;
_syncPositionFlagRepository = syncPositionFlagRepository;
_jisSeDetailRepository = jisSeDetailRepository;
_materialRelationshipManager = materialRelationshipManager;
_syncExtendManager = syncExtendManager;
_syncExtendManager._settleAccountDbContext = settleAccountDbContext;
}
/// <summary>
@ -78,7 +53,7 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
public SeSyncConfig SeSyncConfigInfo { get; set; }
[HttpPost]
public async Task Invoke()
public virtual async Task Invoke()
{
if (SeSyncConfigInfo == null)
{
@ -101,64 +76,27 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
var deliverSubBillTypes = SeSyncConfigInfo.SyncDeliverSubBillTypes;
//业务类别
var businessType = SeSyncConfigInfo.BusinessType;
var syncPositionFlag = await _settleAccountDbContext.Set<SyncPositionFlag>().FirstOrDefaultAsync(t => t.TableName == syncTableName).ConfigureAwait(false);
var syncPosition = syncPositionFlag?.Position ?? "0";
Expression<Func<TM_BJBMPT_JIT_RECORD, bool>> predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == deliverBillType && deliverSubBillTypes.Contains(t.DeliverSubBillType);
//WMS发运记录
var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD.Where(predicate).OrderBy(b => b.UID).Take(100_000).ToList();
var jisSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<HBPO_SE_DETAIL>>(wmsSeRecords);
if (jisSeDetails.Any())
var seed = 0;
while (seed < 10)
{
//客户零件号和厂内零件号
var luRePartCodes = jisSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList();
if (luRePartCodes.Any())
seed++;
var syncPositionFlag = await _settleAccountDbContext.Set<SyncPositionFlag>().FirstOrDefaultAsync(t => t.TableName == syncTableName).ConfigureAwait(false);
var syncPosition = syncPositionFlag?.Position ?? "0";
//WMS发运记录
var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD
.Where(t => t.UID > int.Parse(syncPosition))
.Where(t => t.DeliverBillType == deliverBillType)
.Where(t => deliverSubBillTypes.Contains(t.DeliverSubBillType))
.OrderBy(b => b.UID).Take(100_000).ToList();
var jisSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<HBPO_SE_DETAIL>>(wmsSeRecords);
if (jisSeDetails.Any())
{
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.FactoryPartCode, "", t.LU, businessType));
await _syncExtendManager.AddNewMaterialRelationshipsAsync(materialRelationships).ConfigureAwait(false);
await SeDataPutInStorageAsync(jisSeDetails, false).ConfigureAwait(false);
}
jisSeDetails.ForEach(t =>
{
t.SetId(GuidGenerator.Create());
t.BusinessType = businessType;
t.CustomerPartCodeNoSpace = t.LU.Replace(" ", "");
t.KeyCode = t.PN + t.LU;
if (t.BillTime != null)
{
t.Version = int.Parse(t.BillTime?.ToString("yyyyMM"));
}
});
var syncPositionNew = jisSeDetails.Last().UID.ToString();
using var transaction = await _settleAccountDbContext.Database.BeginTransactionAsync().ConfigureAwait(false);
try
{
if (syncPositionFlag != null)
{
syncPositionFlag.Position = syncPositionNew;
_settleAccountDbContext.Update<SyncPositionFlag>(syncPositionFlag);
}
else
{
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = syncPositionNew
};
_settleAccountDbContext.Add<SyncPositionFlag>(syncPositionFlag);
}
await _settleAccountDbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);
await _syncExtendManager.JisSeDetailsSaveConsignAsync(jisSeDetails, false).ConfigureAwait(false);
await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false);
await transaction.CommitAsync().ConfigureAwait(false);
}
catch (Exception)
else
{
await transaction.RollbackAsync().ConfigureAwait(false);
throw;
break;
}
}
}
@ -176,54 +114,90 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
var deliverSubBillTypes = SeSyncConfigInfo.SyncDeliverSubBillTypes;
//业务类别
var businessType = SeSyncConfigInfo.BusinessType;
var seed = 0;
while (seed < 10)
{
seed++;
var syncPositionFlag = await _settleAccountDbContext.Set<SyncPositionFlag>().FirstOrDefaultAsync(t => t.TableName == syncTableName).ConfigureAwait(false);
var syncPosition = syncPositionFlag?.Position ?? "0";
//WMS发运记录
var wmsRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD
.Where(t => t.UID > int.Parse(syncPosition))
.Where(t => t.DeliverBillType == deliverBillType)
.Where(t => deliverSubBillTypes.Contains(t.DeliverSubBillType))
.OrderBy(b => b.UID).Take(100_000).ToList();
var jisSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIS_RECORD>, List<HBPO_SE_DETAIL>>(wmsRecords);
if (jisSeDetails.Any())
{
await SeDataPutInStorageAsync(jisSeDetails, true).ConfigureAwait(false);
}
else
{
break;
}
}
}
Expression<Func<TM_BJBMPT_JIS_RECORD, bool>> predicate = (t) => t.DeliverBillType == deliverBillType && deliverSubBillTypes.Contains(t.DeliverSubBillType);
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName).ConfigureAwait(false);
if (syncPositionFlag != null)
/// <summary>
/// 发运数据入库
/// </summary>
private async Task SeDataPutInStorageAsync(List<HBPO_SE_DETAIL> seDetails, bool isJisTable)
{
//同步表名称
var syncTableName = isJisTable ? SeSyncConfigInfo.SyncTableName +
"_Jis" : SeSyncConfigInfo.SyncTableName + "_Jit";
//业务类别
var businessType = SeSyncConfigInfo.BusinessType;
//客户零件号和厂内零件号
var luRePartCodes = seDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList();
if (luRePartCodes.Any())
{
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == deliverBillType && deliverSubBillTypes.Contains(t.DeliverSubBillType);
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.FactoryPartCode, "", t.LU, businessType));
await _syncExtendManager.AddNewMaterialRelationshipsAsync(materialRelationships).ConfigureAwait(false);
}
//WMS发运数据
var wmsRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD.Where(predicate).OrderBy(b => b.UID).Take(100000).ToList();
var jisSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIS_RECORD>, List<HBPO_SE_DETAIL>>(wmsRecords);
if (jisSeDetails.Any())
seDetails.ForEach(t =>
{
//客户零件号和厂内零件号
var luRePartCodes = jisSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList();
if (luRePartCodes.Any())
t.SetId(GuidGenerator.Create());
t.BusinessType = businessType;
t.CustomerPartCodeNoSpace = t.LU.Replace(" ", "");
t.KeyCode = t.PN + t.LU;
if (t.BillTime != null)
{
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.FactoryPartCode, "", t.LU, businessType));
await _syncExtendManager.AddNewMaterialRelationshipsAsync(materialRelationships).ConfigureAwait(false);
t.Version = int.Parse(t.BillTime?.ToString("yyyyMM"));
}
});
var syncPosition = seDetails.Last().UID.ToString();
jisSeDetails.ForEach(t =>
{
t.SetId(GuidGenerator.Create());
t.BusinessType = businessType;
t.CustomerPartCodeNoSpace = t.LU.Replace(" ", "");
t.KeyCode = t.PN + t.LU;
if (t.BillTime != null)
{
t.Version = int.Parse(t.BillTime?.ToString("yyyyMM"));
}
});
await _settleAccountDbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);
using var transaction = await _settleAccountDbContext.Database.BeginTransactionAsync().ConfigureAwait(false);
try
{
var syncPositionFlag = await _settleAccountDbContext.Set<SyncPositionFlag>().FirstOrDefaultAsync(t => t.TableName == syncTableName).ConfigureAwait(false);
if (syncPositionFlag != null)
{
syncPositionFlag.Position = wmsRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag).ConfigureAwait(false);
syncPositionFlag.Position = syncPosition;
_settleAccountDbContext.Update<SyncPositionFlag>(syncPositionFlag);
}
else
{
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = wmsRecords.Last().UID.ToString()
Position = syncPosition
};
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag).ConfigureAwait(false);
_settleAccountDbContext.Add<SyncPositionFlag>(syncPositionFlag);
}
await _settleAccountDbContext.BulkInsertAsync(seDetails).ConfigureAwait(false);
await _syncExtendManager.JisSeDetailsSaveConsignAsync<HBPO_SE_DETAIL>(seDetails, isJisTable).ConfigureAwait(false);
await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false);
await transaction.CommitAsync().ConfigureAwait(false);
}
catch (Exception)
{
await transaction.RollbackAsync().ConfigureAwait(false);
throw;
}
}
}

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

@ -49,10 +49,6 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
/// 发运同步配置
/// </summary>
public SeSyncConfig SeSyncConfigInfo { get; set; }
/// <summary>
/// Seed
/// </summary>
public int Seed { get; set; }
[HttpPost]
public async Task Invoke()
@ -69,10 +65,10 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
var deliverSubBillTypes = SeSyncConfigInfo.SyncDeliverSubBillTypes;
//业务类别
var businessType = SeSyncConfigInfo.BusinessType;
while (Seed < 10)
var seed = 0;
while (seed < 10)
{
Seed++;
seed++;
var syncPositionFlag = await _settleAccountDbContext.Set<SyncPositionFlag>().FirstOrDefaultAsync(t => t.TableName == syncTableName).ConfigureAwait(false);
var syncPosition = syncPositionFlag?.Position ?? "0";

12
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MaiDanBBACSeSyncAppService.cs

@ -3,11 +3,9 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
@ -24,11 +22,8 @@ public class MaiDanBBACSeSyncAppService : JisBBACSeSyncBaseAppService, IJobServi
public MaiDanBBACSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<BBAC_SE_DETAIL, Guid> jisSeDetailRepository,
MaterialRelationshipManager materialRelationshipManager,
VmiAppService vmiService
) : base(wmsBJBMPTContext, settleAccountDbContext, syncPositionFlagRepository, jisSeDetailRepository, materialRelationshipManager, vmiService)
SeSyncExtendManager syncExtendManager
) : base(wmsBJBMPTContext, settleAccountDbContext, syncExtendManager)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{
@ -43,6 +38,7 @@ public class MaiDanBBACSeSyncAppService : JisBBACSeSyncBaseAppService, IJobServi
};
}
[UnitOfWork(IsDisabled = true)]
public async Task Invoke(IServiceProvider serviceProvider)
{
await this.Invoke().ConfigureAwait(false);

10
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MaiDanHBPOSeSyncAppService.cs

@ -2,12 +2,9 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
@ -23,11 +20,8 @@ public class MaiDanHBPOSeSyncAppService : JisHBPOSeSyncBaseAppService, IJobServi
public MaiDanHBPOSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> jisSeDetailRepository,
MaterialRelationshipManager materialRelationshipManager,
SeSyncExtendManager syncExtendManager
) : base(wmsBJBMPTContext, settleAccountDbContext, syncPositionFlagRepository, jisSeDetailRepository, materialRelationshipManager, syncExtendManager)
) : base(wmsBJBMPTContext, settleAccountDbContext, syncExtendManager)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{
@ -42,7 +36,7 @@ public class MaiDanHBPOSeSyncAppService : JisHBPOSeSyncBaseAppService, IJobServi
};
}
[UnitOfWork(IsDisabled = false)]
[UnitOfWork(IsDisabled = true)]
public async Task Invoke(IServiceProvider serviceProvider)
{
await this.Invoke().ConfigureAwait(false);

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

@ -143,9 +143,7 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
foreach (var item in lst)
{
item.SetId(GuidGenerator.Create());
var message = new VmiMessage(Guid.NewGuid())
var message = new VmiMessage
{
Message = System.Text.Json.JsonSerializer.Serialize(item),
};

12
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs

@ -37,7 +37,7 @@ public class SeSyncExtendManager : DomainService
//新客户零件号和厂内零件号
var noHaveLuRePartCodes = from item1 in materialRelationships
join item2 in _settleAccountDbContext.Set<MaterialRelationship>()
on new { item1.ErpMaterialCode, item1.SettleMaterialCode } equals new { item2.ErpMaterialCode, item2.SettleMaterialCode }
on new { item1.ErpMaterialCode, item1.SettleMaterialCode, item1.BusinessType } equals new { item2.ErpMaterialCode, item2.SettleMaterialCode, item2.BusinessType }
into temp
from item3 in temp.DefaultIfEmpty()
where item3 == null
@ -58,7 +58,7 @@ public class SeSyncExtendManager : DomainService
var returnSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.退);
var dateTimeNow = DateTime.Now;
var vmiLogList = deliverSeDetails.Select(t => new VmiLog(Guid.NewGuid())
var vmiLogList = deliverSeDetails.Select(t => new VmiLog
{
LogType = VmiLogType.Type100,
ChangedQty = t.Qty,
@ -86,7 +86,7 @@ public class SeSyncExtendManager : DomainService
VinCode = t.VinCode,
factory = t.Factory
}).ToList();
var returnVmiLogList = returnSeDetails.Select(t => new VmiLog(Guid.NewGuid())
var returnVmiLogList = returnSeDetails.Select(t => new VmiLog
{
LogType = VmiLogType.Type400,
ChangedQty = t.Qty,
@ -127,7 +127,7 @@ public class SeSyncExtendManager : DomainService
var returnSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.退);
var dateTimeNow = DateTime.Now;
var vmiLogList = deliverSeDetails.Select(t => new VmiLog(Guid.NewGuid())
var vmiLogList = deliverSeDetails.Select(t => new VmiLog
{
LogType = VmiLogType.Type100,
ChangedQty = t.Qty,
@ -146,7 +146,7 @@ public class SeSyncExtendManager : DomainService
ReMark = t.Remark,
RealPartCode = t.PartCode
}).ToList();
var returnVmiLogList = returnSeDetails.Select(t => new VmiLog(Guid.NewGuid())
var returnVmiLogList = returnSeDetails.Select(t => new VmiLog
{
LogType = VmiLogType.Type400,
ChangedQty = t.Qty,
@ -183,7 +183,7 @@ public class SeSyncExtendManager : DomainService
/// </summary>
private async Task SaveVmiMessagesAsync(List<VmiLog> vmiLogs)
{
var vmiMessages = vmiLogs.Select(t => new VmiMessage(Guid.NewGuid())
var vmiMessages = vmiLogs.Select(t => new VmiMessage
{
Message = JsonConvert.SerializeObject(t)
}).ToList();

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

@ -11,6 +11,8 @@ using System.Reflection;
using System.Text.Json;
using System.Threading.Tasks;
using ClosedXML.Excel;
using DocumentFormat.OpenXml;
using LinqToDB.Data;
using LinqToDB.EntityFrameworkCore;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Core.Extension;
@ -21,6 +23,7 @@ using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using RestSharp.Extensions;
using SettleAccount.Job.SignalR;
using SqlSugar;
@ -34,9 +37,9 @@ using Volo.Abp.Validation;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.Shared;
using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase;
using Win.Sfs.Shared;
namespace Win.Sfs.SettleAccount.Entities.BQ;
@ -53,6 +56,7 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
private readonly IBlobContainer<MyFileContainer> _fileContainer;
private readonly IHubContext<PageHub> _hubContext;
private readonly ICurrentUser _currentUser;
private readonly ILogger<VmiAppService> _logger;
public VmiAppService(IConfiguration cfg,
IServiceProvider serviceProvider,
@ -61,7 +65,8 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
INormalEfCoreRepository<VmiLog, Guid> logRepository,
IBlobContainer<MyFileContainer> fileContainer,
IHubContext<PageHub> hubContext,
ICurrentUser currentUser)
ICurrentUser currentUser,
ILogger<VmiAppService> logger)
{
this._cfg = cfg;
this._guidGenerator = guidGenerator;
@ -71,6 +76,7 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
this._fileContainer = fileContainer;
this._hubContext = hubContext;
this._currentUser = currentUser;
this._logger = logger;
LinqToDBForEFTools.Initialize();
}
@ -260,7 +266,7 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
}
else
{
Debug.WriteLine($"{tableName}不存在");
this._logger.LogInformation($"{tableName}不存在");
}
}
}
@ -270,8 +276,12 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
if (tables.Any())
{
//生成 union all 的 SQL使用 FromSqlRaw 查询,如果没有分表则使用原始表
sql = $"select * from {tables.First()}";
tables.Skip(1).ForEach(o => sql += $" union all select * from ${o}");
sql = $"select * from {tables.First()} WITH(NOLOCK)";
tables.Skip(1).ForEach(o => sql += $" union all select * from ${o} WITH(NOLOCK)");
}
else
{
sql = "select * from Set_VmiLog WITH(NOLOCK)";
}
var query = string.IsNullOrEmpty(sql) ? db.Set<VmiLog>().AsQueryable() : db.Set<VmiLog>().FromSqlRaw(sql);
var filters = input.Filters.ToLambda<VmiLog>();
@ -333,23 +343,9 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connection).Options;
using var context = new SettleAccountDbContext(options);
context.Database.UseTransaction(transaction);
log.SetId(this._guidGenerator.Create());
if (log.ChangedQty >= decimal.Zero)
{
log.Qty = log.ChangedQty;
log.LogType = VmiLogType.Type500;
log.ChangedType = VmiType.In;
}
else
{
log.Qty = -log.Qty;
log.LogType = VmiLogType.Type600;
log.ChangedType = VmiType.Out;
}
log.ChangedBy = this._currentUser.UserName;
log.ChangedTime = DateTime.Now;
Update(log);
context.Set<VmiLog>().Add(log);
context.Set<VmiMessage>().Add(new VmiMessage(this._guidGenerator.Create()) { Message = JsonSerializer.Serialize(log) });
context.Set<VmiMessage>().Add(new VmiMessage { Message = JsonSerializer.Serialize(log) });
context.SaveChanges();
transaction.Commit();
return new OkResult();
@ -357,11 +353,29 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
catch (Exception ex)
{
transaction.Rollback();
Console.WriteLine(ex.ToString());
this._logger.LogError(ex.ToString());
return new JsonResult(new { code = 400, data = ex.ToString(), message = ex.Message }); ;
}
}
private void Update(VmiLog log)
{
log.ChangedTime = log.Id.ToDateTime().Value;
if (log.ChangedQty >= decimal.Zero)
{
log.Qty = log.ChangedQty;
log.LogType = VmiLogType.Type500;
log.ChangedType = VmiType.In;
}
else
{
log.Qty = -log.Qty;
log.LogType = VmiLogType.Type600;
log.ChangedType = VmiType.Out;
}
log.ChangedBy = this._currentUser.UserName;
}
/// <summary>
/// 库存调整导入
/// </summary>
@ -369,6 +383,8 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
[HttpPost]
public async Task<IActionResult> Import(List<IFormFile> files)
{
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
using var connection = new SqlConnection(connectionString);
try
{
using var ms = new MemoryStream();
@ -381,11 +397,11 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
using var workbook = new XLWorkbook(new MemoryStream(data));
var ws = workbook.Worksheets.FirstOrDefault();
var header = ws.Row(1);
var errorIndex = ws.ColumnsUsed().Count();
var errorIndex = ws.ColumnsUsed().Count() + 1;
header.Cell(errorIndex).Value = "提示信息";
for (int i = 2; i < ws.RowsUsed().Count(); i++)
for (int i = 0; i < ws.RowsUsed().Count() - 1; i++)
{
ws.Row(2).Cell(errorIndex).Value = string.Join(',', validationResults[i - 2].Select(o => o.ErrorMessage));
ws.Row(i + 2).Cell(errorIndex).Value = string.Join(',', validationResults[i].Select(o => o.ErrorMessage));
}
SetStyle(ws);
using var stream = new MemoryStream();
@ -395,16 +411,26 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
await this._fileContainer.SaveAsync(fileName, stream, true).ConfigureAwait(false);
return new JsonResult(new { code = 400, message = "输入异常", fileName });
}
foreach (var item in list)
{
Adjust(item);
}
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connection).Options;
using var context = new SettleAccountDbContext(options);
list.ForEach(Update);
var messageList = list.Select(log => new VmiMessage { Message = JsonSerializer.Serialize(log) });
using var dc = context.CreateLinqToDBConnection();
dc.BeginTransaction();
var st = new Stopwatch();
st.Start();
this._logger.LogInformation("事务开始");
await dc.BulkCopyAsync(new BulkCopyOptions { TableName = "Set_VmiLog", MaxBatchSize = 1000 }, list).ConfigureAwait(false);
await dc.BulkCopyAsync(new BulkCopyOptions { TableName = "Set_VmiMessage", MaxBatchSize = 1000 }, messageList).ConfigureAwait(false);
dc.CommitTransaction();
st.Stop();
this._logger.LogInformation($"事务结束,耗时 ${st.ElapsedMilliseconds / 1000 / 60}分钟");
return new JsonResult(new { code = 200, message = "ok" });
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
throw;
this._logger.LogError(ex.ToString());
return new JsonResult(new { code = 500, data = ex.ToString(), message = ex.Message }); ;
}
}
@ -416,8 +442,8 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
{
using var workbook = new XLWorkbook(new MemoryStream(data));
var properties = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty)
.Where(o => o.GetAttributes<ImporterHeaderAttribute>().Any())
.ToDictionary(o => o.GetAttribute<ImporterHeaderAttribute>().Name, o => o);
.Where(o => o.GetAttributes<ImporterHeaderAttribute>().Any() || o.GetAttributes<DisplayAttribute>().Any())
.ToDictionary(o => o.GetAttribute<ImporterHeaderAttribute>()?.Name ?? o.GetAttribute<DisplayAttribute>()?.Name, o => o);
var ws = workbook.Worksheets.FirstOrDefault();
for (int rowIndex = 2; rowIndex <= ws.RowsUsed().Count(); rowIndex++)
@ -430,10 +456,38 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
var headerName = ws.Cell(1, columnIndex).Value.ToString().Trim();
if (properties.TryGetValue(headerName, out var property))
{
var propertyType = property.PropertyType;
var value = cell.Value.ToString();
if (!string.IsNullOrEmpty(value))
{
property.SetValue(model, Convert.ChangeType(value, property.PropertyType));
{//值非空
if (propertyType.IsValueType())
{//值类型
if (propertyType.IsGenericType() && propertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
{//可空值类型
propertyType = propertyType.GetGenericArguments()[0];//取原始类型
}
if (propertyType.IsEnum)
{//枚举
var enumValue = Enum.GetNames(propertyType)
.Select(o => new KeyValuePair<string, Enum>(o, (Enum)Enum.Parse(propertyType, o)))
.Where(o => o.Value.GetDisplayName() == value.ToString())
.Select(o => o.Value)
.FirstOrDefault();
property.SetValue(model, enumValue);
}
else if (propertyType == typeof(DateTime))
{
property.SetValue(model, DateTime.Parse(value));
}
else
{
property.SetValue(model, Convert.ChangeType(value, property.PropertyType));
}
}
else
{//引用类型
property.SetValue(model, Convert.ChangeType(value, property.PropertyType));
}
}
}
}
@ -446,7 +500,7 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
this._logger.LogError(ex.ToString());
throw;
}
}

40
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs

@ -1,13 +1,16 @@
using System;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Text.Json;
using System.Threading.Tasks;
using Magicodes.ExporterAndImporter.Core.Extension;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Omu.ValueInjecter;
using Volo.Abp.Application.Services;
using Volo.Abp.DependencyInjection;
@ -19,19 +22,37 @@ namespace Win.Sfs.SettleAccount.Entities.BQ;
/// <summary>
/// 异步更新库存
/// </summary>
public class VmiAsyncBalanceService : ApplicationService, IJobService, ITransientDependency
[Route("[controller]/[action]")]
public class VmiAsyncBalanceService : Controller, IApplicationService, IJobService, ITransientDependency
{
private readonly IServiceProvider _serviceProvider;
private readonly ILogger<VmiAsyncBalanceService> _logger;
public VmiAsyncBalanceService(IServiceProvider serviceProvider)
public VmiAsyncBalanceService(IServiceProvider serviceProvider, ILogger<VmiAsyncBalanceService> logger)
{
this._serviceProvider = serviceProvider;
this._logger = logger;
}
/// <summary>
/// 异步更新库存,手动测试
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<double> Test()
{
var now = DateTime.Now;
await Invoke(_serviceProvider).ConfigureAwait(false);
return (DateTime.Now - now).TotalMinutes;
}
[NonAction]
public async Task Invoke(IServiceProvider serviceProvider)
{
for (var i = 0; i < 50; i++)
for (var i = 0; i < 100; i++)
{
var sw = new Stopwatch();
sw.Start();
var connectionString = serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
using var connection = new SqlConnection(connectionString);
connection.Open();
@ -81,7 +102,7 @@ public class VmiAsyncBalanceService : ApplicationService, IJobService, ITransien
o.Configcode == log.Configcode);
if (balance == null)
{
balance = new VmiBalance(GuidGenerator.Create());
balance = new VmiBalance();
balance.InjectFrom(log);
await repo.AddAsync(balance).ConfigureAwait(false);
log.InjectFrom(balance);
@ -130,14 +151,15 @@ public class VmiAsyncBalanceService : ApplicationService, IJobService, ITransien
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
this._logger.LogError(ex.ToString());
transaction.Rollback();
throw;
}
finally
{
sw.Stop();
this._logger.LogInformation($"结束,耗时 ${sw.ElapsedMilliseconds / 1000 / 60}分钟");
}
}
}
public async Task InvokeInternal(IServiceProvider serviceProvider)
{
}
}

11
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs

@ -90,17 +90,18 @@ public class PriceListAppService : SettleAccountApplicationBase<PriceList>
var query = from item1 in entityList
join item2 in entityList
on new { item1.LU } equals new { item2.LU }
where (item1.BeginTime > item2.BeginTime && item1.EndTime < item2.EndTime) || (item2.BeginTime > item1.BeginTime && item2.EndTime < item1.EndTime)
select item1;
foreach (var item in query)
where (item1.BeginTime >= item2.BeginTime && item1.EndTime <= item2.EndTime) || (item2.BeginTime >= item1.BeginTime && item2.EndTime <= item1.EndTime)
select item1.LU;
var repeat = query.Distinct().ToList();
foreach (var item in repeat)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item.LU},时间区间存在交集", string.Empty));
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item},时间区间存在交集", string.Empty));
}
}
if (checkList.Count > 0)
{
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName });
return new JsonResult(new { code = ApplicationConsts.ImportFailCode, message = "导入失败", fileName = fileName });
}
#endregion
var lus = entityList.Select(p => p.LU);

7
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs

@ -71,16 +71,17 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
join item2 in entityList
on new { item1.LU } equals new { item2.LU }
where (item1.BeginDate > item2.BeginDate && item1.EndDate < item2.EndDate) || (item2.BeginDate > item1.BeginDate && item2.EndDate < item1.EndDate)
select item1;
select item1.LU;
var repeat = query.Distinct().ToList();
foreach (var item in query)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item.LU},时间区间存在交集", string.Empty));
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item},时间区间存在交集", string.Empty));
}
}
if (checkList.Count > 0)
{
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName });
return new JsonResult(new { code = ApplicationConsts.ImportFailCode, message = "导入失败", fileName = fileName });
}
#endregion
var lus = entityList.Select(p => p.LU);

2
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiBalance.cs

@ -6,6 +6,8 @@ public class VmiBalance : VmiBalanceBase
{
public VmiBalance()
{
Id = SequentialGuid.SequentialSqlGuidGenerator.Instance.NewGuid();
CreatedTime = Id.ToDateTime().Value;
ConcurrencyStamp = Guid.NewGuid().ToString("N");
}

15
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs

@ -7,15 +7,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Vmi;
/// <summary>
/// 库存事务
/// </summary>
public class VmiLog : VmiBalanceBase,IValidatableObject
public class VmiLog : VmiBalanceBase, IValidatableObject
{
public VmiLog()
{
ConcurrencyStamp = Guid.NewGuid().ToString("N");
}
public VmiLog(Guid id) : base(id)
{
Id = SequentialGuid.SequentialSqlGuidGenerator.Instance.NewGuid();
ChangedTime = Id.ToDateTime().Value;
ConcurrencyStamp = Guid.NewGuid().ToString("N");
}
@ -26,9 +23,9 @@ public class VmiLog : VmiBalanceBase,IValidatableObject
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(string.IsNullOrEmpty(this.RealPartCode))
if (string.IsNullOrEmpty(this.RealPartCode))
{
yield return new ValidationResult("LU零件号不能为空",new string[] { nameof(this.RealPartCode)});
yield return new ValidationResult("LU零件号不能为空", new string[] { nameof(this.RealPartCode) });
}
if (string.IsNullOrEmpty(this.ErpToLoc))
{
@ -47,7 +44,7 @@ public class VmiLog : VmiBalanceBase,IValidatableObject
public string ChangedNumber { get; set; }
[Display(Name = "变动时间", Order = 2)]
public DateTime ChangedTime { get; set; } = DateTime.Now;
public DateTime ChangedTime { get; set; }
[Display(Name = "变动类型", Order = 3)]
public VmiType ChangedType { get; set; }

8
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiMessage.cs

@ -7,16 +7,14 @@ public class VmiMessage : Entity<Guid>
{
public VmiMessage()
{
Id = SequentialGuid.SequentialSqlGuidGenerator.Instance.NewGuid();
CreatedTime = Id.ToDateTime().Value;
ConcurrencyStamp = Guid.NewGuid().ToString("N");
}
public VmiMessage(Guid id) : base(id)
{
ConcurrencyStamp = Guid.NewGuid().ToString("N");
}
public long Number { get; set; }
public string Message { get; set; }
public bool isConsumed { get; set; }
public DateTime CreatedTime { get; set; } = DateTime.Now;
public DateTime CreatedTime { get; set; }
public string ConcurrencyStamp { get; set; }
}

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

@ -1326,6 +1326,7 @@ namespace Win.Sfs.SettleAccount
o.factory,
o.Configcode
})).IsUnique();
b.Property(o => o.RealPartCode).HasMaxLength(50);
}));
builder.Entity<VmiLog>(b =>
@ -1336,6 +1337,7 @@ namespace Win.Sfs.SettleAccount
b.Property(o => o.CreatedTime).HasDefaultValueSql("getdate()").ValueGeneratedOnAdd().Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Ignore);
b.Property(o => o.UpdatedTime).HasDefaultValueSql("getdate()").ValueGeneratedOnAddOrUpdate().Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Ignore);
b.HasIndex(o => o.BillTime).IsClustered();
b.Property(o => o.RealPartCode).HasMaxLength(50);
});
builder.Entity<VmiReplenished>(b =>
@ -1343,6 +1345,7 @@ namespace Win.Sfs.SettleAccount
b.ToTable($"{options.TablePrefix}_VmiReplenished", options.Schema);
b.ConfigureByConvention();
b.HasIndex(o => o.BillTime).IsClustered();
b.Property(o => o.RealPartCode).HasMaxLength(50);
});
builder.Entity<VmiSnapshot>(b =>
@ -1352,9 +1355,9 @@ namespace Win.Sfs.SettleAccount
});
//seed
builder.Entity<JobItem>().HasData(new JobItem("vmi".ToGuid()) { Name = "库存快照备份", Cron = "0 0 8 26 *", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAppService" });
builder.Entity<JobItem>().HasData(new JobItem("vmi.balance".ToGuid()) { Name = "同步结算库存", Cron = "0 0/1 * * * ?", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncBalanceService" });
builder.Entity<JobItem>().HasData(new JobItem("vmi.message".ToGuid()) { Name = "事务消息监控", Cron = "0 0/1 * * * ?", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncMessageService" });
builder.Entity<JobItem>().HasData(new JobItem("vmi".ToGuid()) { Name = "时点库存备份", Cron = "0 0 8 26 *", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAppService" });
builder.Entity<JobItem>().HasData(new JobItem("vmi.balance".ToGuid()) { Name = "库存余额同步", Cron = "0 0/1 * * * ?", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncBalanceService" });
builder.Entity<JobItem>().HasData(new JobItem("vmi.message".ToGuid()) { Name = "库存事务消息监控", Cron = "0 0/1 * * * ?", Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncMessageService" });
builder.Entity<JobItem>().HasData(new JobItem("JisBBACSeSync".ToGuid()) { Name = "JisBBAC发运数据同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.JisBBACSeSyncAppService" });
builder.Entity<JobItem>().HasData(new JobItem("JisHBPOSeSync".ToGuid()) { Name = "JisHBPO发运数据同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.JisHBPOSeSyncAppService" });
builder.Entity<JobItem>().HasData(new JobItem("MaiDanBBACSeSync".ToGuid()) { Name = "买单件BBAC发运数据同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.MaiDanBBACSeSyncAppService" });

5820
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230831024215_vmi19.Designer.cs

File diff suppressed because it is too large

228
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230831024215_vmi19.cs

@ -0,0 +1,228 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class vmi19 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "RealPartCode",
table: "Set_VmiReplenished",
type: "nvarchar(50)",
maxLength: 50,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RealPartCode",
table: "Set_VmiLog",
type: "nvarchar(50)",
maxLength: 50,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RealPartCode",
table: "Set_VmiBalance",
type: "nvarchar(50)",
maxLength: 50,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("185c5968-e02b-267e-db2f-225fccfc9716"),
columns: new[] { "ConcurrencyStamp", "Name" },
values: new object[] { "89ee40808b37440e89bc3e3c9c0312a7", "库存余额同步" });
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"),
columns: new[] { "ConcurrencyStamp", "Name" },
values: new object[] { "b9efd317f87e4288841ddcd9fef8f6a2", "库存事务消息监控" });
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"),
column: "ConcurrencyStamp",
value: "862d578df0fe406995bc827f9feaae60");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"),
column: "ConcurrencyStamp",
value: "dc1523b4145f4c60a1e9543aa36da361");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"),
column: "ConcurrencyStamp",
value: "76d675a5b6d644ef8ec3358006afcb36");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"),
column: "ConcurrencyStamp",
value: "658f74bf334f4a34a3fb10eaf00a840a");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"),
column: "ConcurrencyStamp",
value: "1f52b09ccce24e3fb30c5549b19b23e4");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"),
column: "ConcurrencyStamp",
value: "5ebb150f3f9e4ccd89d5fab0a6dde4e4");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"),
column: "ConcurrencyStamp",
value: "71311c84551343b099c049672a4c421f");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
columns: new[] { "ConcurrencyStamp", "Name" },
values: new object[] { "681ede5c262642f1a02d7a67dbd83d1b", "时点库存备份" });
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"),
column: "ConcurrencyStamp",
value: "eb2e56c9379e4cb0b0f0f5f0bc8d4292");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "RealPartCode",
table: "Set_VmiReplenished",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(50)",
oldMaxLength: 50,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RealPartCode",
table: "Set_VmiLog",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(50)",
oldMaxLength: 50,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RealPartCode",
table: "Set_VmiBalance",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(50)",
oldMaxLength: 50,
oldNullable: true);
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("185c5968-e02b-267e-db2f-225fccfc9716"),
columns: new[] { "ConcurrencyStamp", "Name" },
values: new object[] { "64c6af2dbd034e919161ff37304b57b0", "同步结算库存" });
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"),
columns: new[] { "ConcurrencyStamp", "Name" },
values: new object[] { "087376a7732a4f0caec36a83389a856d", "事务消息监控" });
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"),
column: "ConcurrencyStamp",
value: "e6a18e47a9d0467ba66dfb6a70ae8f80");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"),
column: "ConcurrencyStamp",
value: "6c08bd3ad65b4d29b613fe0a72015cc2");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"),
column: "ConcurrencyStamp",
value: "51f7bc3b725847c3b3bc7f1702e775d7");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"),
column: "ConcurrencyStamp",
value: "2a423514ae5e4c19a4524fa4b675c28e");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"),
column: "ConcurrencyStamp",
value: "11992367052c4b459c68966b7fab6b13");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"),
column: "ConcurrencyStamp",
value: "6c75a4d283954fbc895242d9405340e0");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"),
column: "ConcurrencyStamp",
value: "ecb2819e7667499295cea61d7bf4eae3");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
columns: new[] { "ConcurrencyStamp", "Name" },
values: new object[] { "466f09814b2d4da1988a382e45ce2601", "库存快照备份" });
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"),
column: "ConcurrencyStamp",
value: "1d2d6618d5644fafaab03c543f178128");
}
}
}

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

@ -4453,37 +4453,37 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
ConcurrencyStamp = "466f09814b2d4da1988a382e45ce2601",
ConcurrencyStamp = "681ede5c262642f1a02d7a67dbd83d1b",
Cron = "0 0 8 26 *",
IsDisabled = false,
IsRunning = false,
Name = "库存快照备份",
Name = "时点库存备份",
Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAppService"
},
new
{
Id = new Guid("185c5968-e02b-267e-db2f-225fccfc9716"),
ConcurrencyStamp = "64c6af2dbd034e919161ff37304b57b0",
ConcurrencyStamp = "89ee40808b37440e89bc3e3c9c0312a7",
Cron = "0 0/1 * * * ?",
IsDisabled = false,
IsRunning = false,
Name = "同步结算库存",
Name = "库存余额同步",
Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncBalanceService"
},
new
{
Id = new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"),
ConcurrencyStamp = "087376a7732a4f0caec36a83389a856d",
ConcurrencyStamp = "b9efd317f87e4288841ddcd9fef8f6a2",
Cron = "0 0/1 * * * ?",
IsDisabled = false,
IsRunning = false,
Name = "事务消息监控",
Name = "库存事务消息监控",
Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiAsyncMessageService"
},
new
{
Id = new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"),
ConcurrencyStamp = "11992367052c4b459c68966b7fab6b13",
ConcurrencyStamp = "1f52b09ccce24e3fb30c5549b19b23e4",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4493,7 +4493,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"),
ConcurrencyStamp = "e6a18e47a9d0467ba66dfb6a70ae8f80",
ConcurrencyStamp = "862d578df0fe406995bc827f9feaae60",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4503,7 +4503,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"),
ConcurrencyStamp = "51f7bc3b725847c3b3bc7f1702e775d7",
ConcurrencyStamp = "76d675a5b6d644ef8ec3358006afcb36",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4513,7 +4513,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"),
ConcurrencyStamp = "6c08bd3ad65b4d29b613fe0a72015cc2",
ConcurrencyStamp = "dc1523b4145f4c60a1e9543aa36da361",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4523,7 +4523,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"),
ConcurrencyStamp = "1d2d6618d5644fafaab03c543f178128",
ConcurrencyStamp = "eb2e56c9379e4cb0b0f0f5f0bc8d4292",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4533,7 +4533,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"),
ConcurrencyStamp = "2a423514ae5e4c19a4524fa4b675c28e",
ConcurrencyStamp = "658f74bf334f4a34a3fb10eaf00a840a",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4543,7 +4543,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"),
ConcurrencyStamp = "ecb2819e7667499295cea61d7bf4eae3",
ConcurrencyStamp = "71311c84551343b099c049672a4c421f",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4553,7 +4553,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"),
ConcurrencyStamp = "6c75a4d283954fbc895242d9405340e0",
ConcurrencyStamp = "5ebb150f3f9e4ccd89d5fab0a6dde4e4",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4655,7 +4655,8 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("nvarchar(max)");
b.Property<string>("RealPartCode")
.HasColumnType("nvarchar(450)");
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Seq")
.HasColumnType("nvarchar(max)");
@ -4772,7 +4773,8 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("nvarchar(max)");
b.Property<string>("RealPartCode")
.HasColumnType("nvarchar(max)");
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Seq")
.HasColumnType("nvarchar(max)");
@ -4911,7 +4913,8 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("nvarchar(max)");
b.Property<string>("RealPartCode")
.HasColumnType("nvarchar(max)");
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Seq")
.HasColumnType("nvarchar(max)");

1
code/src/Shared/Win.Sfs.Shared/Win.Sfs.Shared.csproj

@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="SequentialGuid" Version="4.0.4" />
<PackageReference Include="Volo.Abp.Caching" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="4.3.3" />

Loading…
Cancel
Save