|
|
|
@ -34,15 +34,14 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<BookingTemplate> _rep;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrder> _repOrder;
|
|
|
|
|
private readonly SqlSugarRepository<BookingExcelTemplate> _excelrep;
|
|
|
|
|
private readonly SqlSugarRepository<BookingExcelTemplateSub> _excelsubrep;
|
|
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<BookingPrintTemplate> _repPrintTemplate;
|
|
|
|
|
private readonly ILogger<BookingTemplate> _logger;
|
|
|
|
|
|
|
|
|
|
public BookingTemplateService(SqlSugarRepository<BookingTemplate> rep, SqlSugarRepository<BookingOrder> repOrder, SqlSugarRepository<BookingExcelTemplate> excelrep, SqlSugarRepository<BookingExcelTemplateSub> excelsubrep, SqlSugarRepository<BookingPrintTemplate> repPrintTemplate, ILogger<BookingTemplate> logger)
|
|
|
|
|
public BookingTemplateService(SqlSugarRepository<BookingTemplate> rep, SqlSugarRepository<BookingOrder> repOrder, SqlSugarRepository<BookingPrintTemplate> repPrintTemplate, ILogger<BookingTemplate> logger)
|
|
|
|
|
{
|
|
|
|
|
_excelrep = excelrep;
|
|
|
|
|
_excelsubrep = excelsubrep;
|
|
|
|
|
|
|
|
|
|
_repOrder = repOrder;
|
|
|
|
|
_rep = rep;
|
|
|
|
|
_logger = logger;
|
|
|
|
@ -124,127 +123,8 @@ namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下拉获取字段名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingTemplate/GetFieldName")]
|
|
|
|
|
public async Task<dynamic> GetFieldName()
|
|
|
|
|
{
|
|
|
|
|
BookingOrder order = new BookingOrder();
|
|
|
|
|
BookingCtn ctn = new BookingCtn();
|
|
|
|
|
BookingEDIExt ext = new BookingEDIExt();
|
|
|
|
|
List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
|
|
|
|
|
|
|
|
|
|
////bookingorder
|
|
|
|
|
Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
|
|
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(order))
|
|
|
|
|
{
|
|
|
|
|
string name = descriptor.Name;
|
|
|
|
|
if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName")
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(descriptor.Description))
|
|
|
|
|
{
|
|
|
|
|
dic.Add(descriptor.Name, descriptor.Description);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
list.Add(dic);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, string> dic1 = new Dictionary<string, string>();
|
|
|
|
|
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(ctn))
|
|
|
|
|
{
|
|
|
|
|
string name = descriptor.Name;
|
|
|
|
|
if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName")
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(descriptor.Description))
|
|
|
|
|
{
|
|
|
|
|
dic1.Add(descriptor.Name, descriptor.Description);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
list.Add(dic1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, string> dic2 = new Dictionary<string, string>();
|
|
|
|
|
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(ext))
|
|
|
|
|
{
|
|
|
|
|
string name = descriptor.Name;
|
|
|
|
|
if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName")
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(descriptor.Description))
|
|
|
|
|
{
|
|
|
|
|
dic2.Add(descriptor.Name, descriptor.Description);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
list.Add(dic2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 新增编辑excel模板
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dto"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingTemplate/AddOrUpdateExcelTemplate")]
|
|
|
|
|
public async Task<dynamic> AddOrUpdateExcelTemplate(BookingExcelTemplateDto dto)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (dto.Id == 0)
|
|
|
|
|
{
|
|
|
|
|
BookingExcelTemplate bookingExcel = new BookingExcelTemplate();
|
|
|
|
|
bookingExcel.Name = dto.Name;
|
|
|
|
|
bookingExcel.Type = dto.Type;
|
|
|
|
|
await _excelrep.InsertAsync(bookingExcel);
|
|
|
|
|
foreach (var item in dto.children)
|
|
|
|
|
{
|
|
|
|
|
var entity = item.Adapt<BookingExcelTemplateSub>();
|
|
|
|
|
entity.Pid = bookingExcel.Id;
|
|
|
|
|
await _excelsubrep.InsertAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var entity = dto.Adapt<BookingExcelTemplate>();
|
|
|
|
|
await _excelrep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
await _excelsubrep.DeleteAsync(x => x.Pid == dto.Id);
|
|
|
|
|
foreach (var item in dto.children)
|
|
|
|
|
{
|
|
|
|
|
var ent = item.Adapt<BookingExcelTemplateSub>();
|
|
|
|
|
ent.Pid = dto.Id;
|
|
|
|
|
await _excelsubrep.InsertAsync(ent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取excel模板
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Name">模板名称</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingTemplate/BookingExcelTemplateList")]
|
|
|
|
|
public async Task<dynamic> BookingExcelTemplateList(string Name)
|
|
|
|
|
{
|
|
|
|
|
return await _excelrep.AsQueryable().WhereIF(!string.IsNullOrWhiteSpace(Name), x => x.Name.Contains(Name)).ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取excel模板详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id">模板名称</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingTemplate/BookingExcelTemplateDetailList")]
|
|
|
|
|
public async Task<dynamic> BookingExcelTemplateDetailList(long Id)
|
|
|
|
|
{
|
|
|
|
|
return await _excelsubrep.AsQueryable().Where(x => x.Pid == Id).ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|