|
|
@ -23,6 +23,7 @@ using Microsoft.Extensions.Configuration; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.OpenApi.Extensions; |
|
|
|
using Omu.ValueInjecter; |
|
|
|
using SettleAccount.Domain.BQ; |
|
|
|
using SettleAccount.Job.SignalR; |
|
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
using Volo.Abp.Application.Services; |
|
|
@ -133,7 +134,7 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran |
|
|
|
{ |
|
|
|
//this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", "");
|
|
|
|
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"; |
|
|
|
using var dbContext = new VmiSqliteContext(connectionString); |
|
|
|
if (!dbContext.GetService<IRelationalDatabaseCreator>().Exists() && dbContext.Database.EnsureCreated()) |
|
|
@ -217,6 +218,8 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran |
|
|
|
{ |
|
|
|
balance = new VmiBalance(); |
|
|
|
balance.InjectFrom(data); |
|
|
|
// 初始化库存
|
|
|
|
balance.Qty = data.Qty; |
|
|
|
balance.SetId(); |
|
|
|
await _balanceRepository.InsertAsync(balance).ConfigureAwait(false); |
|
|
|
} |
|
|
@ -224,6 +227,7 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran |
|
|
|
{ |
|
|
|
var qty = balance.Qty + data.Qty; |
|
|
|
balance.InjectFrom(data); |
|
|
|
// 加库存
|
|
|
|
balance.Qty = qty; |
|
|
|
if (balance.Qty == decimal.Zero) |
|
|
|
{ |
|
|
@ -274,13 +278,15 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran |
|
|
|
{ |
|
|
|
balance = new VmiBalance(); |
|
|
|
balance.InjectFrom(data); |
|
|
|
// 负库存
|
|
|
|
balance.Qty = -data.Qty; |
|
|
|
balance.SetId(); |
|
|
|
await _balanceRepository.InsertAsync(balance).ConfigureAwait(false); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var qty = balance.Qty - data.Qty; |
|
|
|
balance.Qty = qty; |
|
|
|
// 减库存
|
|
|
|
balance.Qty -= data.Qty; ; |
|
|
|
if (balance.Qty == decimal.Zero) |
|
|
|
{ |
|
|
|
await this._balanceRepository.DeleteAsync(balance).ConfigureAwait(false); |
|
|
@ -369,6 +375,14 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran |
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost] |
|
|
|
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 count = query.Count(); |
|
|
|