|
|
@ -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<IRelationalDatabaseCreator>().Exists() && dbContext.Database.EnsureCreated()) |
|
|
@ -361,41 +360,41 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran |
|
|
|
}).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 库存事务回滚
|
|
|
|
/// </summary>
|
|
|
|
[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); |
|
|
|
} |
|
|
|
} |
|
|
|
///// <summary>
|
|
|
|
///// 库存事务回滚
|
|
|
|
///// </summary>
|
|
|
|
//[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);
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 库存余额查询
|
|
|
@ -520,6 +519,26 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran |
|
|
|
return fileName; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 人工调整
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="log"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[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<TExport>(List<TExport> 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, string>() { |
|
|
|
{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, string>() {
|
|
|
|
// {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 |
|
|
|