mahao 1 year ago
parent
commit
d2a65e4774
  1. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/detail.js
  2. 4
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/vmi.js
  3. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_CAN_SA_DTO.cs
  4. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_NOT_SA_DTO.cs
  5. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_CAN_SA_DTO.cs
  6. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_NOT_SA_DTO.cs
  7. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs
  8. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs
  9. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  10. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs
  11. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs
  12. 60
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  13. 52
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs
  14. 27
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs
  15. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs
  16. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiBalance.cs
  17. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs
  18. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiMessage.cs
  19. 3
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs
  20. 5771
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230901084349_vmi20.Designer.cs
  21. 176
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230901084349_vmi20.cs
  22. 29
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/detail.js

@ -80,7 +80,7 @@ export default function (businessType, type) {
} else {
if (businessType === "JisBBAC") {
service = "bbac_can_sa_service";
} else if (businessType === "JisHBPO") {
} else if (businessType === "JisHBPO" || businessType === "MaiDanJianHBPO") {
service = "hbpo_can_sa_service";
} else {
service = "pub_can_sa_service";

4
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/vmi.js

@ -135,12 +135,14 @@ function useLogSchema() {
},
changedType: {
title: "变动类型",
type: "string",
type: "number",
input: "select",
options: [
{
value: 0,
label: "入库",
},
{
value: 1,
label: "出库",
},

8
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_CAN_SA_DTO.cs

@ -52,9 +52,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public DateTime SettleDate { get; set; }
[ExporterHeader(DisplayName = "发票号")] //全部业务都显示
public string InvBillNum { get; set; }
[ExporterHeader(DisplayName = "厂内零件号")] //全部业务都显示
[ExporterHeader(DisplayName = "客户零件号")] //全部业务都显示
public string LU { get; set; }
[ExporterHeader(DisplayName = "客户零件号")] //全部业务都显示 (查询条件)
[ExporterHeader(DisplayName = "厂内零件号")] //全部业务都显示 (查询条件)
public string PartCode { get; set; }
[ExporterHeader(DisplayName = "零件描述")] //全部业务都显示
public string MaterialDesc { get; set; }
@ -106,9 +106,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public DateTime SettleDate { get; set; }
[ExporterHeader(DisplayName = "发票号")] //全部业务都显示
public string InvBillNum { get; set; }
[ExporterHeader(DisplayName = "厂内零件号")] //全部业务都显示
[ExporterHeader(DisplayName = "客户零件号")] //全部业务都显示
public string LU { get; set; }
[ExporterHeader(DisplayName = "客户零件号")] //全部业务都显示 (查询条件)
[ExporterHeader(DisplayName = "厂内零件号")] //全部业务都显示 (查询条件)
public string PartCode { get; set; }
[ExporterHeader(DisplayName = "零件描述")] //全部业务都显示
public string MaterialDesc { get; set; }

4
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_NOT_SA_DTO.cs

@ -105,7 +105,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public DateTime SettleDate { get; set; }
[ExporterHeader(DisplayName = "发票分组号")]
public string InvGroupNum { get; set; }
[ExporterHeader(DisplayName = "LU")]
[ExporterHeader(DisplayName = "客户零件")]
public string LU { get; set; }
[ExporterHeader(DisplayName = "物料描述")]
public string MaterialDesc { get; set; }
@ -121,7 +121,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// <summary>
/// 客户零件号
/// </summary>
[ExporterHeader(DisplayName = "何苦零件号")]
[ExporterHeader(DisplayName = "厂内零件号")]
public string PartCode { get; set; }
}

4
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_CAN_SA_DTO.cs

@ -144,7 +144,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public DateTime SettleDate { get; set; }
[ExporterHeader(DisplayName = "发票分组号")]
public string InvGroupNum { get; set; }
[ExporterHeader(DisplayName = "零件号")]
[ExporterHeader(DisplayName = "客户零件号")]
public string LU { get; set; }
[ExporterHeader(DisplayName = "物料描述")]
@ -160,7 +160,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// <summary>
/// 客户零件号
/// </summary>
[ExporterHeader(DisplayName = "客户零件号")]
[ExporterHeader(DisplayName = "厂内零件号")]
public string PartCode { get; set; }
}

4
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_NOT_SA_DTO.cs

@ -102,7 +102,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public DateTime SettleDate { get; set; }
[ExporterHeader(DisplayName = "发票分组号")]
public string InvGroupNum { get; set; }
[ExporterHeader(DisplayName = "零件号(LU)")]
[ExporterHeader(DisplayName = "客户零件号")]
public string LU { get; set; }
[ExporterHeader(DisplayName = "物料描述")]
@ -116,7 +116,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
[ExporterHeader(DisplayName = "结算分组号")]
public string GroupNum { get; set; }
[ExporterHeader(DisplayName = "客户零件号")]
[ExporterHeader(DisplayName = "厂内零件号")]
public string PartCode { get; set; }

9
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs

@ -35,9 +35,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
BBAC_NOT_SA_DETAIL_REQ_DTO,
BBAC_NOT_SA_DETAIL_EXP_DTO>
{
private readonly BBAC_NOT_SA_MNG _bbacNotMng;
public BBAC_NOT_SA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager, INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> detailRepository, BBAC_NOT_SA_MNG bbacNotMng) :
@ -45,32 +43,25 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
_bbacNotMng = bbacNotMng;
}
[HttpPost]
public override async Task<IActionResult> GenerateSettlementOrder(BBAC_NOT_SA_DETAIL_REQ_DTO input)
{
List<ERR_EXP_DTO> errorlist = new List<ERR_EXP_DTO>();
var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
if (entitys == null )
{
errorlist.Add(new ERR_EXP_DTO() { Message = "查询条件无记录" });
}
else
{
var errors = await _bbacNotMng.GenerateSettlementOrder(entitys);
if (errors.Count > 0)
{
foreach (var itm in errors)
{
errorlist.Add(new ERR_EXP_DTO() { Message = itm });
}
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = await ExportErrorReportAsync(errorlist) });
}
}
return new JsonResult(new { Code = 200, Message = "生成成功" });

1
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs

@ -49,7 +49,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[UnitOfWork(false)]
public override async Task<string> ApprovalPassed(List<string> p_list)
{
var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList();
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value =string.Join(",",p_list) });

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs

@ -71,15 +71,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public async Task<IActionResult> GenerateInvoice( [FromBody] string billnum)
{
var main = await _pubMng.GetMainAsync(billnum);
if (main != null)
{
if (main.State != SettleBillState.)
{
return new JsonResult(new { Code = 400, Message = "已创建发票不能重复创建" });
}
if (await _pubMng.SetForwardState(main, SettleBillState.))
{
var entitys = await _pubMng.GetDetalListAsync(billnum);

1
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs

@ -47,7 +47,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public override async Task<IActionResult> GenerateSettlementOrder(PUB_NOT_SA_DETAIL_REQ_DTO input)
{
var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
List<ERR_EXP_DTO> errorlist = new List<ERR_EXP_DTO>();
if (entitys == null)
{

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

@ -102,6 +102,8 @@ public class PendingDeductionService : ApplicationService, ITransientDependency,
public void Sync<T>(List<T> p_ls, EnumDeliverBjBmpBillType bussinessType, bool flag=true) where T : PD_BASE,new()
{
var query = from itm in p_ls
select new VmiLog()
{

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

@ -12,7 +12,7 @@ using System.Text.Json;
using System.Threading.Tasks;
using ClosedXML.Excel;
using DocumentFormat.OpenXml;
using LinqToDB.Data;
using EFCore.BulkExtensions;
using LinqToDB.EntityFrameworkCore;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Core.Extension;
@ -113,7 +113,7 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
db.Set<VmiSnapshot>().Add(snapshot);
db.SaveChanges();
db.Database.ExecuteSqlRaw($"select * into {table} from Set_VmiBalance;");
db.Database.ExecuteSqlRaw($"create clustered index IX_{table}_BillTime on {table} (BillTime)");
db.Database.ExecuteSqlRaw($"create clustered index IX_{table}_BillTime on {table} (Id)");
db.Database.ExecuteSqlRaw($"alter table {table} add constraint PK_{table} primary key (Id);");
snapshot.End = DateTime.Now;
transaction.Commit();
@ -121,7 +121,7 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
}
throw new UserFriendlyException("备份程序正在运行", "500");
}
catch(Exception ex)
catch (Exception ex)
{
transaction.Rollback();
throw new UserFriendlyException(ex.ToString(), "500");
@ -182,9 +182,7 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
public ListResultDto<VmiSnapshot> Snapshot()
{
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
using var connection = new SqlConnection(connectionString);
connection.Open();
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connection).Options;
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
using var db = new SettleAccountDbContext(options);
var list = db.Set<VmiSnapshot>().AsNoTracking().OrderByDescending(o => o.Start).ToList();
return new ListResultDto<VmiSnapshot>(list);
@ -196,8 +194,9 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
[HttpPost]
public async Task<PagedResultDto<VmiBalance>> Backup(BackupListRequest input)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
using var db = new SettleAccountDbContext(options);
var name = input.Name;
var sql = $"select * from {name}";
var query = db.Set<VmiBalance>().FromSqlRaw(sql);
@ -218,8 +217,9 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
[HttpPost]
public async Task<string> BackupExport(BackupListRequest input)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
using var db = new SettleAccountDbContext(options);
var name = input.Name;
var sql = $"select * from {name}";
var query = db.Set<VmiBalance>().FromSqlRaw(sql);
@ -249,7 +249,6 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
var start = DateTime.Parse(input.Filters.FirstOrDefault(o => o.Column == "changedTime" && o.Action == EnumFilterAction.BiggerThanOrEqual).Value);
var end = DateTime.Parse(input.Filters.FirstOrDefault(o => o.Column == "changedTime" && o.Action == EnumFilterAction.SmallThan).Value);
var tables = new List<string>();
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
using var connection = new SqlConnection(connectionString);
connection.Open();
@ -271,7 +270,7 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
}
}
}
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connection).Options;
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
using var db = new SettleAccountDbContext(options);
var sql = string.Empty;
if (tables.Any())
@ -353,7 +352,6 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
}
catch (Exception ex)
{
transaction.Rollback();
this._logger.LogError(ex.ToString());
return new JsonResult(new { code = 400, data = ex.ToString(), message = ex.Message }); ;
}
@ -361,7 +359,7 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
private void Update(VmiLog log)
{
log.ChangedTime = log.Id.ToDateTime().Value;
log.ChangedTime = log.Id.ToDateTime().Value.ToLocalTime();
if (log.ChangedQty >= decimal.Zero)
{
log.Qty = log.ChangedQty;
@ -384,8 +382,6 @@ 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();
@ -412,20 +408,30 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
await this._fileContainer.SaveAsync(fileName, stream, true).ConfigureAwait(false);
return new JsonResult(new { code = 400, message = "输入异常", fileName });
}
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 messageList = list.Select(log => new VmiMessage { Message = JsonSerializer.Serialize(log) }).ToList();
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
using var context = new SettleAccountDbContext(options);
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}分钟");
try
{
using var transaction = context.Database.BeginTransaction();
await context.BulkInsertAsync(list).ConfigureAwait(false);
await context.BulkInsertAsync(messageList).ConfigureAwait(false);
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex.ToString());
return new JsonResult(new { code = 500, message = ex.ToString() });
}
finally
{
st.Stop();
this._logger.LogInformation($"事务结束,耗时 ${st.ElapsedMilliseconds / 1000 / 60}分钟");
}
return new JsonResult(new { code = 200, message = "ok" });
}
catch (Exception ex)

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

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
@ -51,11 +52,12 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi
public async Task Invoke(IServiceProvider serviceProvider)
{
var batchSize = 1000;
var fetchSize = 0;
var connectionString = serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
for (var i = 0; i < 1000; i++)
{
var sw = new Stopwatch();
sw.Start();
var connectionString = serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
using var connection = new SqlConnection(connectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
@ -66,20 +68,26 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connection).Options;
using var context = new SettleAccountDbContext(options);
context.Database.UseTransaction(transaction);
if (!context.Set<VmiMessage>().Any(o => !o.isConsumed))
var vmiMessageRepo = context.Set<VmiMessage>();
var vmiLogRepo = context.Set<VmiLog>();
var vmiBalanceRepo = context.Set<VmiBalance>();
var vmiReplenishedRepo = context.Set<VmiReplenished>();
if (!vmiMessageRepo.Any(o => !o.isConsumed))
{
transaction.Commit();
break;
}
var messages = context.Set<VmiMessage>()
//.AsNoTracking()
.Where(o => !o.isConsumed).OrderBy(o => o.Number).Take(batchSize).ToList();
var repo = context.Set<VmiBalance>();
foreach (var message in messages)
var messages = vmiMessageRepo.Where(o => !o.isConsumed).OrderBy(o => o.Number).Take(batchSize).ToList();
fetchSize=messages.Count;
var list = messages.Select(o =>
{
var log = JsonSerializer.Deserialize<VmiLog>(o.Message);
log.SetId(Guid.Parse(JsonSerializer.Deserialize<JsonElement>(o.Message).GetProperty("Id").GetString()));
return new KeyValuePair<VmiMessage, VmiLog>(o, log);
}).ToDictionary(o => o.Key, o => o.Value);
var tables = list.Values.Select(o => $"Set_VmiLog_{o.ChangedTime.Year}_{(o.ChangedTime.Month - 1) / 3 + 1}").Distinct().ToList();
foreach (var table in tables)
{
var log = JsonSerializer.Deserialize<VmiLog>(message.Message);
log.SetId(Guid.Parse(JsonSerializer.Deserialize<JsonElement>(message.Message).GetProperty("Id").GetString()));
//插入分表
var table = $"Set_VmiLog_{log.ChangedTime.Year}_{(log.ChangedTime.Month - 1) / 3 + 1}";
command.CommandText = $"select OBJECT_ID('{table}', 'U')";
var result = command.ExecuteScalar().ToString();
if (result == string.Empty)
@ -91,11 +99,18 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi
command.CommandText = $"alter table {table} add constraint PK_{table} primary key (Id);";
command.ExecuteNonQuery();
}
}
foreach (var keyValue in list)
{
var message = keyValue.Key;
var log = keyValue.Value;
//获取分表名
var table = $"Set_VmiLog_{log.ChangedTime.Year}_{(log.ChangedTime.Month - 1) / 3 + 1}";
//插入到分表
command.CommandText = $"insert into {table} select * from Set_VmiLog where id ='{log.Id}'";
command.ExecuteNonQuery();
//插入库存
var balance = context.Set<VmiBalance>().FirstOrDefault(
var balance = vmiBalanceRepo.FirstOrDefault(
o => o.DeliverBillType == log.DeliverBillType &&
o.CodeType == log.CodeType &&
o.DeliverBillType == log.DeliverBillType &&
@ -110,7 +125,7 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi
balance = new VmiBalance();
if (log.LogType == VmiLogType.Type300)
{//反结算入库,重建库存
var logHistory = context.Set<VmiLog>().AsNoTracking().FirstOrDefault(
var logHistory = vmiLogRepo.AsNoTracking().FirstOrDefault(
o => o.LogType == VmiLogType.Type100 &&
o.DeliverBillType == log.DeliverBillType &&
o.CodeType == log.CodeType &&
@ -134,7 +149,7 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi
balance.InjectFrom(log);
}
balance.Qty = log.ChangedQty;
await repo.AddAsync(balance).ConfigureAwait(false);
await vmiBalanceRepo.AddAsync(balance).ConfigureAwait(false);
}
else
{//存在库存记录
@ -162,31 +177,30 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi
//添加负库存补货记录
var log2 = new VmiReplenished();
log2.InjectFrom(log);
await context.Set<VmiReplenished>().AddAsync(log2).ConfigureAwait(false);
await vmiReplenishedRepo.AddAsync(log2).ConfigureAwait(false);
}
// 更新库存
balance.Qty = currentQty + log.ChangedQty;
if (balance.Qty == decimal.Zero)
{
//删除0库存
repo.Remove(balance);
vmiBalanceRepo.Remove(balance);
}
}
message.isConsumed = true;
context.SaveChanges();
}
context.SaveChanges();
transaction.Commit();
}
catch (Exception ex)
{
this._logger.LogError(ex.ToString());
transaction.Rollback();
throw new UserFriendlyException(ex.ToString(), "500");
}
finally
{
sw.Stop();
this._logger.LogInformation($"处理{batchSize}条,耗时 {sw.ElapsedMilliseconds / 1000 / 60}分钟,{sw.ElapsedMilliseconds / 1000}秒");
this._logger.LogInformation($"处理{fetchSize}条,耗时 {sw.ElapsedMilliseconds / 1000 / 60}分钟,{sw.ElapsedMilliseconds / 1000}秒");
}
}
}

27
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs

@ -49,6 +49,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
public virtual async Task<List<string>> GenerateSettlementOrder(List<HBPO_NOT_SA_DETAIL> p_list)
{
var first=p_list.FirstOrDefault();
List<string> errors = new List<string>();
var priceErrors = await _service.CheckPriceList(p_list);
if (priceErrors.Count > 0)
@ -58,16 +59,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
errors.Add($"生产号{itm.PN}零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据");
}
}
var ls=p_list.Select(p => p.Site.Substring(0, 3)).Distinct().ToList();
if(ls.Count>1)
if (first.BusinessType == EnumBusinessType.JisHBPO)
{
errors.Add($"生成结算数据有多个地点数据{string.Join(",",ls)}");
}
if (errors.Count > 0)
{
return errors;
}
var ls = p_list.Select(p => p.Site.Substring(0, 3)).Distinct().ToList();
if (ls.Count > 1)
{
errors.Add($"生成结算数据有多个地点数据{string.Join(",", ls)}");
}
if (errors.Count > 0)
{
return errors;
}
}
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
var _entity = new HBPO_CAN_SA();
_entity.BillNum = billNumber;
@ -96,7 +102,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
settleDate: itm.SettleDate,
site: itm.Site,
invbillnum: string.Empty,
partcode:itm.PartCode
partcode: itm.PartCode
);
_detailEntity.RealPartCode = itm.RealPartCode;
_entityList.Add(_detailEntity);
@ -104,6 +110,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
await _notRepository.DbContext.BulkDeleteAsync(p_list);
await _repository.DbContext.BulkInsertAsync(new List<HBPO_CAN_SA>() { _entity });
await _repository.DbContext.BulkInsertAsync(_entityList);
return errors;
}

2
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs

@ -86,7 +86,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
foreach (var itm in priceErrors)
{
errors.Add($"{name}零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据");
errors.Add($"{name}{itm.GroupNum}零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据");
}
}
if (errors.Count > 0)

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

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

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

@ -12,7 +12,7 @@ public class VmiLog : VmiBalanceBase, IValidatableObject
public VmiLog()
{
Id = SequentialGuid.SequentialSqlGuidGenerator.Instance.NewGuid();
ChangedTime = Id.ToDateTime().Value;
ChangedTime = Id.ToDateTime().Value.ToLocalTime();
ConcurrencyStamp = Guid.NewGuid().ToString("N");
}

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

@ -8,7 +8,7 @@ public class VmiMessage : Entity<Guid>
public VmiMessage()
{
Id = SequentialGuid.SequentialSqlGuidGenerator.Instance.NewGuid();
CreatedTime = Id.ToDateTime().Value;
CreatedTime = Id.ToDateTime().Value.ToLocalTime();
ConcurrencyStamp = Guid.NewGuid().ToString("N");
}

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

@ -1314,7 +1314,6 @@ 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.Property(o => o.ConcurrencyStamp).HasMaxLength(50).IsConcurrencyToken();
b.HasIndex(o => o.BillTime).IsClustered();
b.HasIndex(o => (new
{
o.DeliverBillType,
@ -1336,7 +1335,6 @@ namespace Win.Sfs.SettleAccount
b.Property(o => o.ChangedTime).HasDefaultValueSql("getdate()").ValueGeneratedOnAdd().Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Ignore);
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);
});
@ -1344,7 +1342,6 @@ 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);
});

5771
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230901084349_vmi20.Designer.cs

File diff suppressed because it is too large

176
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230901084349_vmi20.cs

@ -0,0 +1,176 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class vmi20 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("185c5968-e02b-267e-db2f-225fccfc9716"),
column: "ConcurrencyStamp",
value: "119eda96252e4bd58016d77b0bf1f43b");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"),
column: "ConcurrencyStamp",
value: "3bd216de9cdf423ab81dc6cf014f8616");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"),
column: "ConcurrencyStamp",
value: "24fd0b376e354409a5bcdec267b72b2d");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"),
column: "ConcurrencyStamp",
value: "7884254f65f7422da2abe11929da3f6b");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"),
column: "ConcurrencyStamp",
value: "229a34c072454e7d949556e07a9f1e1f");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"),
column: "ConcurrencyStamp",
value: "313eaf08e98642ec9b7531ac5e1575c9");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"),
column: "ConcurrencyStamp",
value: "1680a6235f8d40f092e576028cde752a");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"),
column: "ConcurrencyStamp",
value: "0464f68915234385b952314fefffc134");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"),
column: "ConcurrencyStamp",
value: "45a3d39659e34ef3bee5b93bb5781412");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
column: "ConcurrencyStamp",
value: "0c40557cb16c4c079fa836f5337875ed");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"),
column: "ConcurrencyStamp",
value: "9f16199bb6f34f14a193a7ae7fa700be");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Set_VmiReplenished_ChangedTime",
table: "Set_VmiReplenished");
migrationBuilder.DropIndex(
name: "IX_Set_VmiLog_ChangedTime",
table: "Set_VmiLog");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("185c5968-e02b-267e-db2f-225fccfc9716"),
column: "ConcurrencyStamp",
value: "d12f27a181f54465b338dd2401a08b6e");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"),
column: "ConcurrencyStamp",
value: "d9f3e1d0603c46479198f5baad678663");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"),
column: "ConcurrencyStamp",
value: "20cdc48f0766480d9c7a70b390ce0f9f");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"),
column: "ConcurrencyStamp",
value: "7da7c559aba84699ae1c6c6fa0a5dc59");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"),
column: "ConcurrencyStamp",
value: "20c50e67224d4595986559438cd975ad");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"),
column: "ConcurrencyStamp",
value: "366afac45e0e485d8f43e53346442ad2");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"),
column: "ConcurrencyStamp",
value: "662702ee66444ca08ef7190b6ad1e8f3");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"),
column: "ConcurrencyStamp",
value: "8e44067496fa43c085d2cf3bc2ed8779");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"),
column: "ConcurrencyStamp",
value: "7fd5fef49685400fb7254abbfd3754a1");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
column: "ConcurrencyStamp",
value: "42aed6aa66044a06ab92e8bf2d882cb2");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"),
column: "ConcurrencyStamp",
value: "c2cbd6a620fe4fd08d3f021939d31509");
}
}
}

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

@ -4453,7 +4453,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
ConcurrencyStamp = "42aed6aa66044a06ab92e8bf2d882cb2",
ConcurrencyStamp = "0c40557cb16c4c079fa836f5337875ed",
Cron = "0 0 8 26 *",
IsDisabled = false,
IsRunning = false,
@ -4463,7 +4463,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("185c5968-e02b-267e-db2f-225fccfc9716"),
ConcurrencyStamp = "d12f27a181f54465b338dd2401a08b6e",
ConcurrencyStamp = "119eda96252e4bd58016d77b0bf1f43b",
Cron = "0 0/1 * * * ?",
IsDisabled = false,
IsRunning = false,
@ -4473,7 +4473,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"),
ConcurrencyStamp = "d9f3e1d0603c46479198f5baad678663",
ConcurrencyStamp = "3bd216de9cdf423ab81dc6cf014f8616",
Cron = "0 0/1 * * * ?",
IsDisabled = false,
IsRunning = false,
@ -4483,7 +4483,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new
{
Id = new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"),
ConcurrencyStamp = "662702ee66444ca08ef7190b6ad1e8f3",
ConcurrencyStamp = "1680a6235f8d40f092e576028cde752a",
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 = "20cdc48f0766480d9c7a70b390ce0f9f",
ConcurrencyStamp = "24fd0b376e354409a5bcdec267b72b2d",
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 = "20c50e67224d4595986559438cd975ad",
ConcurrencyStamp = "229a34c072454e7d949556e07a9f1e1f",
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 = "7da7c559aba84699ae1c6c6fa0a5dc59",
ConcurrencyStamp = "7884254f65f7422da2abe11929da3f6b",
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 = "c2cbd6a620fe4fd08d3f021939d31509",
ConcurrencyStamp = "9f16199bb6f34f14a193a7ae7fa700be",
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 = "366afac45e0e485d8f43e53346442ad2",
ConcurrencyStamp = "313eaf08e98642ec9b7531ac5e1575c9",
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 = "7fd5fef49685400fb7254abbfd3754a1",
ConcurrencyStamp = "45a3d39659e34ef3bee5b93bb5781412",
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 = "8e44067496fa43c085d2cf3bc2ed8779",
ConcurrencyStamp = "0464f68915234385b952314fefffc134",
Cron = "0 0/30 * * * ? ",
IsDisabled = false,
IsRunning = false,
@ -4683,9 +4683,6 @@ namespace Win.Sfs.SettleAccount.Migrations
b.HasKey("Id");
b.HasIndex("BillTime")
.IsClustered();
b.HasIndex("DeliverBillType", "CodeType", "RealPartCode", "VinCode", "ErpToLoc", "OrderNum", "factory", "Configcode")
.IsUnique()
.HasFilter("[DeliverBillType] IS NOT NULL AND [CodeType] IS NOT NULL AND [RealPartCode] IS NOT NULL AND [VinCode] IS NOT NULL AND [ErpToLoc] IS NOT NULL AND [OrderNum] IS NOT NULL AND [factory] IS NOT NULL AND [Configcode] IS NOT NULL");
@ -4801,7 +4798,7 @@ namespace Win.Sfs.SettleAccount.Migrations
b.HasKey("Id");
b.HasIndex("BillTime")
b.HasIndex("ChangedTime")
.IsClustered();
b.ToTable("Set_VmiLog");
@ -4939,7 +4936,7 @@ namespace Win.Sfs.SettleAccount.Migrations
b.HasKey("Id");
b.HasIndex("BillTime")
b.HasIndex("ChangedTime")
.IsClustered();
b.ToTable("Set_VmiReplenished");

Loading…
Cancel
Save