|
|
@ -1,7 +1,6 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Globalization; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
@ -22,8 +21,6 @@ using Microsoft.EntityFrameworkCore; |
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.OpenApi.Extensions; |
|
|
|
using Omu.ValueInjecter; |
|
|
|
using Polly; |
|
|
|
using RestSharp.Extensions; |
|
|
|
using SettleAccount.Job.SignalR; |
|
|
|
using SqlSugar; |
|
|
@ -36,7 +33,6 @@ using Volo.Abp.Validation; |
|
|
|
using Win.Sfs.BaseData.ImportExcelCommon; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Vmi; |
|
|
|
using Win.Sfs.SettleAccount.influxdb; |
|
|
|
using Win.Sfs.Shared.Filter; |
|
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
|
|
|
|
@ -121,36 +117,6 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen |
|
|
|
return this.ImportInternal<PUB_ADJ_DETAIL_IMP_DTO>(ms.ToArray()); |
|
|
|
} |
|
|
|
|
|
|
|
private List<T> ImportInternal<T>(byte[] data) |
|
|
|
{ |
|
|
|
var list = new List<T>(); |
|
|
|
using var workbook = new XLWorkbook(new MemoryStream(data)); |
|
|
|
var properties = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty) |
|
|
|
.Where(o => o.GetAttributes<ImporterHeaderAttribute>().Any()) |
|
|
|
.ToDictionary(o => o.GetAttribute<ImporterHeaderAttribute>().Name, o => o); |
|
|
|
var ws = workbook.Worksheets.FirstOrDefault(); |
|
|
|
for (int rowIndex = 2; rowIndex <= ws.RowsUsed().Count(); rowIndex++) |
|
|
|
{ |
|
|
|
var row = ws.Row(rowIndex); |
|
|
|
var model = Activator.CreateInstance<T>(); |
|
|
|
list.Add(model); |
|
|
|
for (var columnIndex = 1; columnIndex < ws.ColumnsUsed().Count(); columnIndex++) |
|
|
|
{ |
|
|
|
var cell = row.Cell(columnIndex); |
|
|
|
var headerName = ws.Cell(1, columnIndex).Value.ToString().Trim(); |
|
|
|
if (properties.TryGetValue(headerName, out var property)) |
|
|
|
{ |
|
|
|
var value = cell.Value.ToString(); |
|
|
|
if (!string.IsNullOrEmpty(value)) |
|
|
|
{ |
|
|
|
property.SetValue(model, Convert.ChangeType(value, property.PropertyType)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 定时备份:0 0 8 26 * ?
|
|
|
|
/// </summary>
|
|
|
@ -212,165 +178,6 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 发运入库\反结入库\调整入库
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="logType">库存事务类型</param>
|
|
|
|
/// <param name="changedNumber">关联单号</param>
|
|
|
|
/// <param name="data">入库数据</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost] |
|
|
|
public async Task In(VmiLogType logType, string changedNumber, VmiBalance data) |
|
|
|
{ |
|
|
|
await Policy.Handle<Exception>().WaitAndRetryAsync(5, o => TimeSpan.FromSeconds(o), (e, i) => |
|
|
|
{ |
|
|
|
Console.WriteLine($"入库类型:{logType.GetDisplayName()},重试次数:{i},异常信息:{e.Message}"); |
|
|
|
}).ExecuteAsync(async () => |
|
|
|
{ |
|
|
|
using var scope = _serviceProvider.CreateScope(); |
|
|
|
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>(); |
|
|
|
|
|
|
|
var balance = db.Set<VmiBalance>().FirstOrDefault( |
|
|
|
o => o.DeliverBillType == data.DeliverBillType && |
|
|
|
o.CodeType == data.CodeType && |
|
|
|
o.DeliverBillType == data.DeliverBillType && |
|
|
|
o.VinCode == data.VinCode && |
|
|
|
o.ErpToLoc == data.ErpToLoc && |
|
|
|
o.OrderNum == data.OrderNum && |
|
|
|
o.factory == data.factory && |
|
|
|
o.Configcode == data.Configcode); |
|
|
|
|
|
|
|
var log = new VmiLog(GuidGenerator.Create()) |
|
|
|
{ |
|
|
|
LogType = logType, |
|
|
|
ChangedType = VmiType.In, |
|
|
|
ChangedNumber = changedNumber, |
|
|
|
ChangedTime = DateTime.Now, |
|
|
|
ChangedBy = _currentUser.UserName, |
|
|
|
ChangedQty = data.Qty, |
|
|
|
}; |
|
|
|
|
|
|
|
if (balance == null) |
|
|
|
{ |
|
|
|
balance = new VmiBalance(GuidGenerator.Create()); |
|
|
|
balance.InjectFrom(data); |
|
|
|
await db.Set<VmiBalance>().AddAsync(balance).ConfigureAwait(false); |
|
|
|
//新建库存,库存事务种库存备份的初始库存为0
|
|
|
|
log.InjectFrom(balance); |
|
|
|
log.Qty = 0; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//已有库存,直接备份
|
|
|
|
log.InjectFrom(balance); |
|
|
|
var qty = balance.Qty + data.Qty; |
|
|
|
if (logType == VmiLogType.Type100) |
|
|
|
{ |
|
|
|
//发运入库,只更新库存
|
|
|
|
} |
|
|
|
else if (logType == VmiLogType.Type300) |
|
|
|
{ |
|
|
|
//反结入库,只更新库存
|
|
|
|
} |
|
|
|
else if (logType == VmiLogType.Type500) |
|
|
|
{ |
|
|
|
//调整入库,更新库存和其他字段
|
|
|
|
balance.InjectFrom(data); |
|
|
|
} |
|
|
|
// 加库存
|
|
|
|
balance.Qty = qty; |
|
|
|
if (balance.Qty == decimal.Zero) |
|
|
|
{ |
|
|
|
db.Set<VmiBalance>().Remove(balance); |
|
|
|
} |
|
|
|
if (logType == VmiLogType.Type100 && balance.Qty < decimal.Zero && data.Qty > 0) |
|
|
|
{ |
|
|
|
log.IsReplenished = true; |
|
|
|
} |
|
|
|
} |
|
|
|
await db.Set<VmiLog>().AddAsync(log).ConfigureAwait(false); |
|
|
|
await db.SaveChangesAsync().ConfigureAwait(false); |
|
|
|
}).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 结算出库\退货出库\调整出库
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="logType"></param>
|
|
|
|
/// <param name="changedNumber"></param>
|
|
|
|
/// <param name="data"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost] |
|
|
|
public async Task Out(VmiLogType logType, string changedNumber, VmiLog data) |
|
|
|
{ |
|
|
|
await Policy.Handle<Exception>().WaitAndRetryAsync(5, o => TimeSpan.FromSeconds(o), (e, i) => |
|
|
|
{ |
|
|
|
Console.WriteLine($"出库类型:{logType.GetDisplayName()},重试次数:{i},异常信息:{e.Message}"); |
|
|
|
}).ExecuteAsync(async () => |
|
|
|
{ |
|
|
|
using var scope = _serviceProvider.CreateScope(); |
|
|
|
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>(); |
|
|
|
var balance = db.Set<VmiBalance>().FirstOrDefault( |
|
|
|
o => o.DeliverBillType == data.DeliverBillType && |
|
|
|
o.CodeType == data.CodeType && |
|
|
|
o.DeliverBillType == data.DeliverBillType && |
|
|
|
o.VinCode == data.VinCode && |
|
|
|
o.ErpToLoc == data.ErpToLoc && |
|
|
|
o.OrderNum == data.OrderNum && |
|
|
|
o.factory == data.factory && |
|
|
|
o.Configcode == data.Configcode); |
|
|
|
var log = new VmiLog(GuidGenerator.Create()) |
|
|
|
{ |
|
|
|
LogType = logType, |
|
|
|
ChangedType = VmiType.Out, |
|
|
|
ChangedNumber = changedNumber, |
|
|
|
ChangedTime = DateTime.Now, |
|
|
|
ChangedBy = _currentUser.UserName, |
|
|
|
ChangedQty = data.Qty, |
|
|
|
}; |
|
|
|
|
|
|
|
if (balance == null) |
|
|
|
{ |
|
|
|
//负库存出库
|
|
|
|
balance = new VmiBalance(GuidGenerator.Create()); |
|
|
|
balance.InjectFrom(data); |
|
|
|
//新建库存,库存事务种库存备份的初始库存为0
|
|
|
|
log.InjectFrom(data); |
|
|
|
log.Qty = 0; |
|
|
|
// 负库存
|
|
|
|
balance.Qty = -data.Qty; |
|
|
|
await db.Set<VmiBalance>().AddAsync(balance).ConfigureAwait(false); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//已有库存,直接备份
|
|
|
|
log.InjectFrom(data);//更新附加字段
|
|
|
|
log.InjectFrom(balance);//备份库存
|
|
|
|
// 减库存
|
|
|
|
balance.Qty -= data.Qty; ; |
|
|
|
if (logType == VmiLogType.Type200) |
|
|
|
{ |
|
|
|
//结算出库,只更新库存
|
|
|
|
} |
|
|
|
else if (logType == VmiLogType.Type400) |
|
|
|
{ |
|
|
|
//退货出库,只更新库存
|
|
|
|
} |
|
|
|
else if (logType == VmiLogType.Type600) |
|
|
|
{ |
|
|
|
//调整出库,更新库存和其他字段
|
|
|
|
balance.InjectFrom(data); |
|
|
|
} |
|
|
|
if (balance.Qty == decimal.Zero) |
|
|
|
{ |
|
|
|
db.Set<VmiBalance>().Remove(balance); |
|
|
|
} |
|
|
|
} |
|
|
|
await db.Set<VmiLog>().AddAsync(log).ConfigureAwait(false); |
|
|
|
await db.SaveChangesAsync().ConfigureAwait(false); |
|
|
|
}).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 1.库存余额查询
|
|
|
|
/// </summary>
|
|
|
@ -379,33 +186,9 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen |
|
|
|
[HttpPost] |
|
|
|
public async Task<PagedResultDto<VmiBalance>> Balance(RequestDto input) |
|
|
|
{ |
|
|
|
var db = GetSqlSugarDbClient(); |
|
|
|
var query = db.Queryable<VmiBalance>().AS("Set_VmiBalance").Where(input.Filters.ToLambda<VmiBalance>()); |
|
|
|
var totalCount = query.Count(); |
|
|
|
query = string.IsNullOrEmpty(input.Sorting) ? query : query.OrderBy(input.Sorting); |
|
|
|
var entities = await query.Skip(input.SkipCount).Take(input.MaxResultCount).ToListAsync().ConfigureAwait(false); |
|
|
|
var entities = await _balanceRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false); |
|
|
|
var totalCount = await _balanceRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false); |
|
|
|
return new PagedResultDto<VmiBalance>(totalCount, entities); |
|
|
|
//var entities = await _balanceRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false);
|
|
|
|
//var totalCount = await _balanceRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
|
|
|
|
//return new PagedResultDto<VmiBalance>(totalCount, entities);
|
|
|
|
} |
|
|
|
|
|
|
|
private SqlSugarClient GetSqlSugarDbClient() |
|
|
|
{ |
|
|
|
return new SqlSugarClient(new ConnectionConfig() |
|
|
|
{ |
|
|
|
ConnectionString = this._cfg.GetConnectionString("SettleAccountService"), |
|
|
|
DbType = DbType.SqlServer, |
|
|
|
IsAutoCloseConnection = true, |
|
|
|
MoreSettings = new ConnMoreSettings |
|
|
|
{ |
|
|
|
IsWithNoLockQuery = true |
|
|
|
}, |
|
|
|
}, db => { |
|
|
|
db.Aop.OnLogExecuted = (sql,args)=> { |
|
|
|
Debug.WriteLine(sql); |
|
|
|
}; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -429,18 +212,24 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen |
|
|
|
[HttpPost] |
|
|
|
public async Task<PagedResultDto<VmiLog>> Log(LogRequestDto input) |
|
|
|
{ |
|
|
|
var db = GetSqlSugarDbClient(); |
|
|
|
var query = db.Queryable<VmiLog>().AS("Set_VmiLog").Where(input.Filters.ToLambda<VmiLog>()); |
|
|
|
using var scope = this._serviceProvider.CreateScope(); |
|
|
|
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>(); |
|
|
|
var format = "yyyy-MM-dd HH:mm:ssT"; |
|
|
|
var startValue = input.Filters.FirstOrDefault(o => o.Column == "billTime" && o.Action == EnumFilterAction.BiggerThanOrEqual).Value; |
|
|
|
var endValue = input.Filters.FirstOrDefault(o => o.Column == "billTime" && o.Action == EnumFilterAction.BiggerThanOrEqual).Value; |
|
|
|
var start = DateTime.Parse(startValue); |
|
|
|
var end = DateTime.Parse(endValue); |
|
|
|
var sql = $"select * from Set_VmiLog"; |
|
|
|
var query = db.Set<VmiLog>().FromSqlRaw(sql); |
|
|
|
var filters = input.Filters.ToLambda<VmiLog>(); |
|
|
|
if (input.Filters.Count > 0) |
|
|
|
{ |
|
|
|
query = query.Where(input.Filters.ToLambda<VmiLog>()); |
|
|
|
} |
|
|
|
var totalCount = query.Count(); |
|
|
|
query = string.IsNullOrEmpty(input.Sorting) ? query : query.OrderBy(input.Sorting); |
|
|
|
var entities = await query.Skip(input.SkipCount).Take(input.MaxResultCount).ToListAsync().ConfigureAwait(false); |
|
|
|
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting); |
|
|
|
var entities = await query.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false); |
|
|
|
return new PagedResultDto<VmiLog>(totalCount, entities); |
|
|
|
//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);
|
|
|
|
|
|
|
|
// GetSqlSugarDbClient().Queryable<VmiLog>().SplitTable()
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -462,7 +251,6 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen |
|
|
|
[HttpPost] |
|
|
|
public async Task<string> ReplenishedExportAsync(RequestDto input) |
|
|
|
{ |
|
|
|
//input.Filters.Add(new FilterCondition { Logic = EnumFilterLogic.And, Action = EnumFilterAction.NotEqual, Column = "IsReplenished", Value = "null" });
|
|
|
|
var entities = await _logRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false); |
|
|
|
//IQueryable<VmiLog> query = _logRepository.WhereIf(input.Filters?.Count != 0, input.Filters.ToLambda<VmiLog>());
|
|
|
|
var fileName = $"补货数据_{DateTime.Now.ToString("yyyy-MM-dd_HH:mm:ss")}.xlsx"; |
|
|
@ -471,33 +259,6 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen |
|
|
|
return fileName; |
|
|
|
} |
|
|
|
|
|
|
|
private PagedResultDto<VmiLog> QueryLogFromTSDb(RequestDto input) |
|
|
|
{ |
|
|
|
var query = new InfluxHelper(_cfg).Query<VmiLog>().Where(input.Filters.ToLambda<VmiLog>()); |
|
|
|
var count = query.Count(); |
|
|
|
input.Sorting?.Split(',').Select(o => o.Trim()).Where(o => !string.IsNullOrEmpty(o)).ForEach(o => |
|
|
|
{ |
|
|
|
var values = o.Split(' ').Select(o => o.Trim()).Where(o => !string.IsNullOrEmpty(o)).ToArray(); |
|
|
|
if (values.Length == 1) |
|
|
|
{ |
|
|
|
query = query.OrderBy(values[0]); |
|
|
|
} |
|
|
|
else if (values.Length == 2) |
|
|
|
{ |
|
|
|
if (values[1].ToLowerInvariant() == "desc") |
|
|
|
{ |
|
|
|
query = query.OrderByPropertyName(values[0], SqlSugar.OrderByType.Desc); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
query = query.OrderBy(values[0]); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
var entities = query.Skip(input.SkipCount).Take(input.MaxResultCount).ToList(); |
|
|
|
return new PagedResultDto<VmiLog>(count, entities); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 4.寄售库存调整
|
|
|
|
/// </summary>
|
|
|
@ -506,21 +267,20 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen |
|
|
|
[HttpPost] |
|
|
|
public async Task EditBalance(VmiLog log) |
|
|
|
{ |
|
|
|
if (log.Qty >= decimal.Zero) |
|
|
|
log.SetId(GuidGenerator.Create()); |
|
|
|
if (log.ChangedQty >= decimal.Zero) |
|
|
|
{ |
|
|
|
log.Qty = log.ChangedQty; |
|
|
|
log.LogType = VmiLogType.Type500; |
|
|
|
log.ChangedType = VmiType.In; |
|
|
|
var data = new VmiBalance(); |
|
|
|
data.InjectFrom(log); |
|
|
|
await In(VmiLogType.Type500, null, data).ConfigureAwait(false); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
log.Qty = -log.Qty; |
|
|
|
log.LogType = VmiLogType.Type600; |
|
|
|
log.ChangedType = VmiType.Out; |
|
|
|
log.Qty = -log.Qty; |
|
|
|
await this.Out(VmiLogType.Type600, null, log).ConfigureAwait(false); |
|
|
|
} |
|
|
|
log.ChangedBy = this._currentUser.UserName; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -555,26 +315,20 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen |
|
|
|
[HttpPost] |
|
|
|
public async Task<PagedResultDto<VmiBalance>> Backup(BackupListRequest input) |
|
|
|
{ |
|
|
|
var db = GetSqlSugarDbClient(); |
|
|
|
var query = db.Queryable<VmiBalance>().AS(input.Name).Where(input.Filters.ToLambda<VmiBalance>()); |
|
|
|
using var scope = this._serviceProvider.CreateScope(); |
|
|
|
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>(); |
|
|
|
var name = input.Name; |
|
|
|
var sql = $"select * from {name}"; |
|
|
|
var query = db.Set<VmiBalance>().FromSqlRaw(sql); |
|
|
|
var filters = input.Filters.ToLambda<VmiBalance>(); |
|
|
|
if (input.Filters.Count > 0) |
|
|
|
{ |
|
|
|
query = query.Where(input.Filters.ToLambda<VmiBalance>()); |
|
|
|
} |
|
|
|
var totalCount = query.Count(); |
|
|
|
query = string.IsNullOrEmpty(input.Sorting) ? query : query.OrderBy(input.Sorting); |
|
|
|
var entities = await query.Skip(input.SkipCount).Take(input.MaxResultCount).ToListAsync().ConfigureAwait(false); |
|
|
|
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting); |
|
|
|
var entities = await query.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false); |
|
|
|
return new PagedResultDto<VmiBalance>(totalCount, entities); |
|
|
|
//using var scope = this._serviceProvider.CreateScope();
|
|
|
|
//var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
|
|
|
|
//var name = input.Name;
|
|
|
|
//var sql = $"select * from {name}";
|
|
|
|
//var query = db.Set<VmiBalance>().FromSqlRaw(sql);
|
|
|
|
//var filters = input.Filters.ToLambda<VmiBalance>();
|
|
|
|
//if (input.Filters.Count > 0)
|
|
|
|
//{
|
|
|
|
// query = query.Where(input.Filters.ToLambda<VmiBalance>());
|
|
|
|
//}
|
|
|
|
//var totalCount = query.Count();
|
|
|
|
//query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
|
|
|
|
//var entities = await query.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false);
|
|
|
|
//return new PagedResultDto<VmiBalance>(totalCount, entities);
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -602,6 +356,36 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen |
|
|
|
return fileName; |
|
|
|
} |
|
|
|
|
|
|
|
private List<T> ImportInternal<T>(byte[] data) |
|
|
|
{ |
|
|
|
var list = new List<T>(); |
|
|
|
using var workbook = new XLWorkbook(new MemoryStream(data)); |
|
|
|
var properties = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty) |
|
|
|
.Where(o => o.GetAttributes<ImporterHeaderAttribute>().Any()) |
|
|
|
.ToDictionary(o => o.GetAttribute<ImporterHeaderAttribute>().Name, o => o); |
|
|
|
var ws = workbook.Worksheets.FirstOrDefault(); |
|
|
|
for (int rowIndex = 2; rowIndex <= ws.RowsUsed().Count(); rowIndex++) |
|
|
|
{ |
|
|
|
var row = ws.Row(rowIndex); |
|
|
|
var model = Activator.CreateInstance<T>(); |
|
|
|
list.Add(model); |
|
|
|
for (var columnIndex = 1; columnIndex < ws.ColumnsUsed().Count(); columnIndex++) |
|
|
|
{ |
|
|
|
var cell = row.Cell(columnIndex); |
|
|
|
var headerName = ws.Cell(1, columnIndex).Value.ToString().Trim(); |
|
|
|
if (properties.TryGetValue(headerName, out var property)) |
|
|
|
{ |
|
|
|
var value = cell.Value.ToString(); |
|
|
|
if (!string.IsNullOrEmpty(value)) |
|
|
|
{ |
|
|
|
property.SetValue(model, Convert.ChangeType(value, property.PropertyType)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
private byte[] GetContent<TExport>(List<TExport> entities, string name = "sheet1") |
|
|
|
{ |
|
|
|
using var workbook = new XLWorkbook(); |
|
|
@ -672,6 +456,11 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal Task Out(VmiLogType type200, string v, VmiLog vmiLog) |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
} |
|
|
|
|
|
|
|
//private void SetPropertyValue(PropertyInfo property, VmiLog entity, string value)
|
|
|
|
//{
|
|
|
|
// try
|
|
|
|