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.

69 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.Sys.Entity;
using DS.WMS.Core.Sys.Interface;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Linq;
using Org.BouncyCastle.Ocsp;
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>
/// 获取Json打印信息
/// </summary>
[Fact]
public void GetExportExcleInfo()
{
List<UserColumnSet> set = new List<UserColumnSet>();
set.Add(new UserColumnSet
{
DataIndex = "stlCode",
Title = "结算方式代码",
});
set.Add(new UserColumnSet
{
DataIndex = "stlName",
Title = "结算方式",
});
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\":\"汇款\",\"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];
var info = new Dictionary<string, object>();
for (int n = 0; n < set.Count; n++)
{
var columnSet = set[n];
var key = columnSet.DataIndex;
info.Add(columnSet.Title, temp[key]);
}
values.Add(info);
}
Console.WriteLine(values);
Assert.True(true);
}
}