From d0982779787b6e6a72933963c6754d65d6b7964c Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Thu, 10 Aug 2023 09:03:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=8B=E5=8A=A8=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=BA=93=E5=AD=98=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/VmiAppService.cs | 185 ++++++++++-------- 1 file changed, 102 insertions(+), 83 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs index 0709d865..32a037a0 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs @@ -30,7 +30,6 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.BlobStoring; using Volo.Abp.DependencyInjection; -using Volo.Abp.Uow; using Volo.Abp.Users; using Volo.Abp.Validation; using Win.Sfs.BaseData.ImportExcelCommon; @@ -49,7 +48,7 @@ public interface IVmiService : IApplicationService, ITransientDependency, IJobSe Task Out(VmiLogType logType, string changedNumber, VmiLog data); - Task UnDo(string groupId); + //Task UnDo(string groupId); } [AllowAnonymous] @@ -139,7 +138,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("yyyyMMddHHmmss"); + var date = DateTime.Now.ToString("yyyy-MM-dd_HH.mm.ss"); var connectionString = $"Data Source=wwwroot/files/vmi/{date}.db"; using var dbContext = new VmiSqliteContext(connectionString); if (!dbContext.GetService().Exists() && dbContext.Database.EnsureCreated()) @@ -361,41 +360,41 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran }).ConfigureAwait(false); } - /// - /// 库存事务回滚 - /// - [NonAction] - [UnitOfWork] - public async Task UnDo(string groupId) - { - var logList = this._logRepository.Where(o => o.GroupId == groupId).AsNoTracking().OrderBy(o => o.ChangedTime); - foreach (var item in logList) - { - var balance = this._balanceRepository.FirstOrDefault(o => o.BillType == item.BillType && - o.PartCode == item.PartCode && - o.VinCode == item.VinCode && - o.ErpToLoc == item.ErpToLoc && - o.OrderNum == item.OrderNum); - if (balance == null) - { - balance = new VmiBalance(GuidGenerator.Create()); - balance.InjectFrom(item); - await _balanceRepository.InsertAsync(balance).ConfigureAwait(false); - } - else - { - balance.Qty += item.ChangedQty; - this._balanceRepository.UpdateAsync(balance).Wait(); - } - var log = new VmiLog(); - log.InjectFrom(item); - log.LogType = VmiLogType.Type300; - log.ChangedType = VmiType.In; - log.ChangedTime = DateTime.Now; - log.ChangedBy = _currentUser.UserName; - await _logRepository.InsertAsync(log).ConfigureAwait(false); - } - } + ///// + ///// 库存事务回滚 + ///// + //[NonAction] + //[UnitOfWork] + //public async Task UnDo(string groupId) + //{ + // var logList = this._logRepository.Where(o => o.GroupId == groupId).AsNoTracking().OrderBy(o => o.ChangedTime); + // foreach (var item in logList) + // { + // var balance = this._balanceRepository.FirstOrDefault(o => o.BillType == item.BillType && + // o.PartCode == item.PartCode && + // o.VinCode == item.VinCode && + // o.ErpToLoc == item.ErpToLoc && + // o.OrderNum == item.OrderNum); + // if (balance == null) + // { + // balance = new VmiBalance(GuidGenerator.Create()); + // balance.InjectFrom(item); + // await _balanceRepository.InsertAsync(balance).ConfigureAwait(false); + // } + // else + // { + // balance.Qty += item.ChangedQty; + // this._balanceRepository.UpdateAsync(balance).Wait(); + // } + // var log = new VmiLog(); + // log.InjectFrom(item); + // log.LogType = VmiLogType.Type300; + // log.ChangedType = VmiType.In; + // log.ChangedTime = DateTime.Now; + // log.ChangedBy = _currentUser.UserName; + // await _logRepository.InsertAsync(log).ConfigureAwait(false); + // } + //} /// /// 库存余额查询 @@ -520,6 +519,26 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran return fileName; } + /// + /// 人工调整 + /// + /// + /// + [HttpPost] + public async Task EditBalance(VmiLog log) + { + if (log.Qty >= decimal.Zero) + { + var data = new VmiBalance(); + data.InjectFrom(log); + await In(VmiLogType.Type500, null, data).ConfigureAwait(false); + } + else + { + await this.Out(VmiLogType.Type600, null, log).ConfigureAwait(false); + } + } + private byte[] GetContent(List entities, string name = "sheet1") { using var workbook = new XLWorkbook(); @@ -590,51 +609,51 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran } } - private void SetPropertyValue(PropertyInfo property, VmiLog entity, string value) - { - try - { - object propertyValue = null; - if (!string.IsNullOrEmpty(value)) - { - propertyValue = Convert.ChangeType(value, property.PropertyType); - } - property.SetValue(entity, propertyValue, null); - } - catch (Exception) - { - throw; - } - } - - private string GetOperator(EnumFilterAction action) - { - var dictonary = new Dictionary() { - {EnumFilterAction.Equal,"={0}"}, - {EnumFilterAction.NotEqual,"!={0}"}, - {EnumFilterAction.SmallThanOrEqual,"<={0}"}, - {EnumFilterAction.Like,"~/{0}/"}, - {EnumFilterAction.NotLike,"!~/{0}/"}, - {EnumFilterAction.BiggerThan,">{0}"}, - {EnumFilterAction.BiggerThanOrEqual,">={0}"}, - {EnumFilterAction.SmallThan,"<{0}"}, - }; - return dictonary[action]; - } - - private object GetValue(PropertyInfo property, string value) - { - if (property.PropertyType == typeof(int) || - property.PropertyType == typeof(long) || - property.PropertyType == typeof(float) || - property.PropertyType == typeof(double) || - property.PropertyType == typeof(decimal) || - property.PropertyType == typeof(bool)) - { - return value; - } - return $"'{value}'"; - } + //private void SetPropertyValue(PropertyInfo property, VmiLog entity, string value) + //{ + // try + // { + // object propertyValue = null; + // if (!string.IsNullOrEmpty(value)) + // { + // propertyValue = Convert.ChangeType(value, property.PropertyType); + // } + // property.SetValue(entity, propertyValue, null); + // } + // catch (Exception) + // { + // throw; + // } + //} + + //private string GetOperator(EnumFilterAction action) + //{ + // var dictonary = new Dictionary() { + // {EnumFilterAction.Equal,"={0}"}, + // {EnumFilterAction.NotEqual,"!={0}"}, + // {EnumFilterAction.SmallThanOrEqual,"<={0}"}, + // {EnumFilterAction.Like,"~/{0}/"}, + // {EnumFilterAction.NotLike,"!~/{0}/"}, + // {EnumFilterAction.BiggerThan,">{0}"}, + // {EnumFilterAction.BiggerThanOrEqual,">={0}"}, + // {EnumFilterAction.SmallThan,"<{0}"}, + // }; + // return dictonary[action]; + //} + + //private object GetValue(PropertyInfo property, string value) + //{ + // if (property.PropertyType == typeof(int) || + // property.PropertyType == typeof(long) || + // property.PropertyType == typeof(float) || + // property.PropertyType == typeof(double) || + // property.PropertyType == typeof(decimal) || + // property.PropertyType == typeof(bool)) + // { + // return value; + // } + // return $"'{value}'"; + //} } public class BackupListRequest : RequestDto