Browse Source

更新寄售库存结算出库接口

master
wanggang 1 year ago
parent
commit
83423d44d7
  1. 20
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

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

@ -23,6 +23,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Extensions;
using Omu.ValueInjecter; using Omu.ValueInjecter;
using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR; using SettleAccount.Job.SignalR;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
@ -133,7 +134,7 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
{ {
//this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", ""); //this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", "");
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files/vmi")); Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files/vmi"));
var date = DateTime.Now.ToString("yyyyMMddHH"); var date = DateTime.Now.ToString("yyyyMMddHHmmss");
var connectionString = $"Data Source=wwwroot/files/vmi/{date}.db"; var connectionString = $"Data Source=wwwroot/files/vmi/{date}.db";
using var dbContext = new VmiSqliteContext(connectionString); using var dbContext = new VmiSqliteContext(connectionString);
if (!dbContext.GetService<IRelationalDatabaseCreator>().Exists() && dbContext.Database.EnsureCreated()) if (!dbContext.GetService<IRelationalDatabaseCreator>().Exists() && dbContext.Database.EnsureCreated())
@ -217,6 +218,8 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
{ {
balance = new VmiBalance(); balance = new VmiBalance();
balance.InjectFrom(data); balance.InjectFrom(data);
// 初始化库存
balance.Qty = data.Qty;
balance.SetId(); balance.SetId();
await _balanceRepository.InsertAsync(balance).ConfigureAwait(false); await _balanceRepository.InsertAsync(balance).ConfigureAwait(false);
} }
@ -224,6 +227,7 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
{ {
var qty = balance.Qty + data.Qty; var qty = balance.Qty + data.Qty;
balance.InjectFrom(data); balance.InjectFrom(data);
// 加库存
balance.Qty = qty; balance.Qty = qty;
if (balance.Qty == decimal.Zero) if (balance.Qty == decimal.Zero)
{ {
@ -274,13 +278,15 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
{ {
balance = new VmiBalance(); balance = new VmiBalance();
balance.InjectFrom(data); balance.InjectFrom(data);
// 负库存
balance.Qty = -data.Qty;
balance.SetId(); balance.SetId();
await _balanceRepository.InsertAsync(balance).ConfigureAwait(false); await _balanceRepository.InsertAsync(balance).ConfigureAwait(false);
} }
else else
{ {
var qty = balance.Qty - data.Qty; // 减库存
balance.Qty = qty; balance.Qty -= data.Qty; ;
if (balance.Qty == decimal.Zero) if (balance.Qty == decimal.Zero)
{ {
await this._balanceRepository.DeleteAsync(balance).ConfigureAwait(false); await this._balanceRepository.DeleteAsync(balance).ConfigureAwait(false);
@ -369,6 +375,14 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<PagedResultDto<VmiLog>> Log(RequestDto input) public async Task<PagedResultDto<VmiLog>> Log(RequestDto input)
{
var entities = await _logRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false);
var totalCount = await _logRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
return new PagedResultDto<VmiLog>(totalCount, entities);
//return QueryLogFromTSDb(input);
}
private PagedResultDto<VmiLog> QueryLogFromTSDb(RequestDto input)
{ {
var query = new InfluxHelper(_cfg).Query<VmiLog>().Where(input.Filters.ToLambda<VmiLog>()); var query = new InfluxHelper(_cfg).Query<VmiLog>().Where(input.Filters.ToLambda<VmiLog>());
var count = query.Count(); var count = query.Count();

Loading…
Cancel
Save