You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.4 KiB
C#

using System.Reflection;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.ExcelModule.Model;
using DS.Module.SqlSugar;
using DS.WMS.Core.Code.Interface;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Linq;
using SqlSugar;
using SqlSugar.IOC;
using Xunit;
namespace Ds.WMS.Test;
public class ExcelTest
{
private readonly IServiceProvider _serviceProvider;
private readonly SqlSugarScope db;
private readonly ISaasDbService saasService;
//private readonly IExcelService _ExcelService;
public ExcelTest(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = (SqlSugarScope)_serviceProvider.GetRequiredService<ISqlSugarClient>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
//_ExcelService = _serviceProvider.GetRequiredService<IExcelService>();
}
/// <summary>
/// <20><>ȡJson<6F><6E>ӡ<EFBFBD><D3A1>Ϣ
/// </summary>
[Fact]
public void GetExportExcleInfo()
{
List<UserColumnSet> set = new List<UserColumnSet>();
set.Add(new UserColumnSet
{
DataIndex = "stlCode",
Title = "<22><><EFBFBD>ʽ<E3B7BD><CABD><EFBFBD><EFBFBD>",
});
set.Add(new UserColumnSet
{
DataIndex = "stlName",
Title = "<22><><EFBFBD>ʽ",
});
string JsonDataStr = "[{\"id\":\"1767428411736854528\",\"stlCode\":\"1\",\"stlName\":\"֧Ʊ\",\"enName\":\"Check\",\"financeSoftCode\":\"01\",\"status\":0,\"note\":\"\",\"createTime\":\"2024-03-12 13:52:25\"},{\"id\":\"1767428557304369152\",\"stlCode\":\"2\",\"stlName\":\"<22><><EFBFBD><EFBFBD>\",\"enName\":\"Remittance\",\"financeSoftCode\":\"02\",\"status\":0,\"note\":\"\",\"createTime\":\"2024-03-12 13:53:00\"}]";
var values = new List<Dictionary<string, object>>();
var data = JArray.Parse(JsonDataStr);
for (int i = 0; i < data.Count; i++)
{
var temp = data[i];
for (int n = 0; n < set.Count; n++)
{
var columnSet = set[n];
var key = columnSet.DataIndex;
var info = new Dictionary<string, object>
{
{ columnSet.Title, temp[key] },
};
values.Add(info);
}
}
Console.WriteLine(values);
Assert.True(true);
}
}