optimize
wet 2 years ago
parent 2de926c191
commit 3d95d45dd2

@ -5,27 +5,32 @@ using Myshipping.Core.Entity;
namespace Myshipping.Application.Entity namespace Myshipping.Application.Entity
{ {
/// <summary> /// <summary>
/// EXCEl打印模板 /// 订舱状态
/// </summary> /// </summary>
[SugarTable("booking_exceltemplate")] [SugarTable("booking_exceltemplate")]
[Description("EXCEl打印模板")] [Description("EXCEL模板明细")]
public class BookingExcelTemplate : DBEntityTenant public class BookingExcelTemplate : PrimaryKeyEntity
{ {
/// <summary> /// <summary>
/// 模板名称 /// 父键
/// </summary> /// </summary>
public string Name { get; set; } public long Pid { get; set; }
/// <summary> /// <summary>
/// 分类 /// 字段名称
/// </summary> /// </summary>
public string Type { get; set; } public string Field { get; set; }
/// <summary>
/// 行
/// </summary>
public int Row { get; set; }
/// <summary> /// <summary>
/// 模板id ///
/// </summary> /// </summary>
public string TemplateId { get; set; } public int Column { get; set; }
/// <summary>
/// 默认内容
/// </summary>
public string Describe { get; set; }
} }
} }

@ -1,36 +0,0 @@
using System;
using SqlSugar;
using System.ComponentModel;
using Myshipping.Core.Entity;
namespace Myshipping.Application.Entity
{
/// <summary>
/// 订舱状态
/// </summary>
[SugarTable("booking_exceltemplate_sub")]
[Description("EXCEL模板明细")]
public class BookingExcelTemplateSub : PrimaryKeyEntity
{
/// <summary>
/// 父键
/// </summary>
public long? Pid { get; set; }
/// <summary>
/// 字段名称
/// </summary>
public string Field { get; set; }
/// <summary>
/// 行
/// </summary>
public int Row { get; set; }
/// <summary>
/// 列
/// </summary>
public int Column { get; set; }
/// <summary>
/// 默认内容
/// </summary>
public string Describe { get; set; }
}
}

@ -3463,6 +3463,70 @@ namespace Myshipping.Application
await _repBookingStatus.UpdateAsync(bookSta); await _repBookingStatus.UpdateAsync(bookSta);
} }
} }
/// <summary>
/// 下拉获取字段名称
/// </summary>
/// <returns></returns>
[HttpGet("/BookingOrder/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;
}
#endregion #endregion
} }
} }

@ -21,6 +21,7 @@ using Myshipping.Application.Enum;
using System.Collections.Generic; using System.Collections.Generic;
using Myshipping.Application.Service.BookingPrintTemplate.Dto; using Myshipping.Application.Service.BookingPrintTemplate.Dto;
using Myshipping.Core.Entity; using Myshipping.Core.Entity;
using Myshipping.Application.Service.BookingTemplate.Dto;
namespace Myshipping.Application namespace Myshipping.Application
{ {
@ -34,13 +35,15 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingPrinttemplateRight> _repRight; private readonly SqlSugarRepository<BookingPrinttemplateRight> _repRight;
private readonly SqlSugarRepository<SysUser> _repUser; private readonly SqlSugarRepository<SysUser> _repUser;
private readonly ILogger<BookingPrintTemplate> _logger; private readonly ILogger<BookingPrintTemplate> _logger;
private readonly SqlSugarRepository<BookingExcelTemplate> _excelrep;
public BookingPrintTemplateService(SqlSugarRepository<BookingPrintTemplate> rep, SqlSugarRepository<BookingPrinttemplateRight> repRight, SqlSugarRepository<SysUser> repUser, ILogger<BookingPrintTemplate> logger) public BookingPrintTemplateService(SqlSugarRepository<BookingPrintTemplate> rep, SqlSugarRepository<BookingPrinttemplateRight> repRight, SqlSugarRepository<SysUser> repUser, SqlSugarRepository<BookingExcelTemplate> excelrep, ILogger<BookingPrintTemplate> logger)
{ {
_rep = rep; _rep = rep;
_repRight = repRight; _repRight = repRight;
_repUser = repUser; _repUser = repUser;
_logger = logger; _logger = logger;
_excelrep = excelrep;
} }
/// <summary> /// <summary>
@ -430,6 +433,35 @@ namespace Myshipping.Application
} }
/// <summary>
/// 新增编辑excel模板
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpPost("/BookingTemplate/AddOrUpdateExcelTemplate")]
public async Task<dynamic> AddOrUpdateExcelTemplate(BookingExcelTemplateDto dto)
{
await _excelrep.DeleteAsync(x => x.Pid == dto.Pid);
foreach (var item in dto.children)
{
var entity = item.Adapt<BookingExcelTemplate>();
await _excelrep.InsertAsync(entity);
}
return null;
}
/// <summary>
/// 获取excel模板详情
/// </summary>
/// <param name="Id">模板ID</param>
/// <returns></returns>
[HttpGet("/BookingTemplate/BookingExcelTemplateList")]
public async Task<dynamic> BookingExcelTemplateList(long Id)
{
return await _excelrep.AsQueryable().Where(x => x.Pid == Id).ToListAsync();
}
} }
} }

@ -0,0 +1,15 @@
using Myshipping.Application.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Service.BookingTemplate.Dto
{
public class BookingExcelTemplateDto
{
public long Pid { get; set; }
public List<BookingExcelTemplate> children { get; set; }
}
}

@ -34,15 +34,14 @@ namespace Myshipping.Application
{ {
private readonly SqlSugarRepository<BookingTemplate> _rep; private readonly SqlSugarRepository<BookingTemplate> _rep;
private readonly SqlSugarRepository<BookingOrder> _repOrder; private readonly SqlSugarRepository<BookingOrder> _repOrder;
private readonly SqlSugarRepository<BookingExcelTemplate> _excelrep;
private readonly SqlSugarRepository<BookingExcelTemplateSub> _excelsubrep;
private readonly SqlSugarRepository<BookingPrintTemplate> _repPrintTemplate; private readonly SqlSugarRepository<BookingPrintTemplate> _repPrintTemplate;
private readonly ILogger<BookingTemplate> _logger; 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; _excelrep = excelrep;
_excelsubrep = excelsubrep;
_repOrder = repOrder; _repOrder = repOrder;
_rep = rep; _rep = rep;
_logger = logger; _logger = logger;
@ -124,127 +123,8 @@ namespace Myshipping.Application
{ {
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); 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> /// <summary>

@ -1,29 +0,0 @@
using Myshipping.Application.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Service.BookingTemplate.Dto
{
public class BookingExcelTemplateDto
{
/// <summary>
/// 业务id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 模板名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 分类
/// </summary>
public string Type { get; set; }
public List<BookingExcelTemplateSub> children { get; set; }
}
}
Loading…
Cancel
Save