diff --git a/Myshipping.Application/Entity/BookingExcelTemplate.cs b/Myshipping.Application/Entity/BookingExcelTemplate.cs index e934ee4e..ef40c6ca 100644 --- a/Myshipping.Application/Entity/BookingExcelTemplate.cs +++ b/Myshipping.Application/Entity/BookingExcelTemplate.cs @@ -5,27 +5,32 @@ using Myshipping.Core.Entity; namespace Myshipping.Application.Entity { /// - /// EXCEl打印模板 + /// 订舱状态 /// [SugarTable("booking_exceltemplate")] - [Description("EXCEl打印模板")] - public class BookingExcelTemplate : DBEntityTenant + [Description("EXCEL模板明细")] + public class BookingExcelTemplate : PrimaryKeyEntity { - /// - /// 模板名称 + /// 父键 /// - public string Name { get; set; } - + public long Pid { get; set; } /// - /// 分类 + /// 字段名称 /// - public string Type { get; set; } - + public string Field { get; set; } + /// + /// 行 + /// + public int Row { get; set; } /// - /// 模板id + /// 列 /// - public string TemplateId { get; set; } + public int Column { get; set; } + /// + /// 默认内容 + /// + public string Describe { get; set; } } } \ No newline at end of file diff --git a/Myshipping.Application/Entity/BookingExcelTemplateSub.cs b/Myshipping.Application/Entity/BookingExcelTemplateSub.cs deleted file mode 100644 index 248d8305..00000000 --- a/Myshipping.Application/Entity/BookingExcelTemplateSub.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using SqlSugar; -using System.ComponentModel; -using Myshipping.Core.Entity; -namespace Myshipping.Application.Entity -{ - /// - /// 订舱状态 - /// - [SugarTable("booking_exceltemplate_sub")] - [Description("EXCEL模板明细")] - public class BookingExcelTemplateSub : PrimaryKeyEntity - { - /// - /// 父键 - /// - public long? Pid { get; set; } - /// - /// 字段名称 - /// - public string Field { get; set; } - /// - /// 行 - /// - public int Row { get; set; } - /// - /// 列 - /// - public int Column { get; set; } - - /// - /// 默认内容 - /// - public string Describe { get; set; } - } -} \ No newline at end of file diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 744181aa..323f1191 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -3463,6 +3463,70 @@ namespace Myshipping.Application await _repBookingStatus.UpdateAsync(bookSta); } } + + + /// + /// 下拉获取字段名称 + /// + /// + [HttpGet("/BookingOrder/GetFieldName")] + public async Task GetFieldName() + { + BookingOrder order = new BookingOrder(); + BookingCtn ctn = new BookingCtn(); + BookingEDIExt ext = new BookingEDIExt(); + List> list = new List>(); + + ////bookingorder + Dictionary dic = new Dictionary(); + 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 dic1 = new Dictionary(); + 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 dic2 = new Dictionary(); + 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 } } diff --git a/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs b/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs index 686c6e98..b1d359e7 100644 --- a/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs +++ b/Myshipping.Application/Service/BookingPrintTemplate/BookingPrintTemplateService.cs @@ -21,6 +21,7 @@ using Myshipping.Application.Enum; using System.Collections.Generic; using Myshipping.Application.Service.BookingPrintTemplate.Dto; using Myshipping.Core.Entity; +using Myshipping.Application.Service.BookingTemplate.Dto; namespace Myshipping.Application { @@ -34,13 +35,15 @@ namespace Myshipping.Application private readonly SqlSugarRepository _repRight; private readonly SqlSugarRepository _repUser; private readonly ILogger _logger; + private readonly SqlSugarRepository _excelrep; - public BookingPrintTemplateService(SqlSugarRepository rep, SqlSugarRepository repRight, SqlSugarRepository repUser, ILogger logger) + public BookingPrintTemplateService(SqlSugarRepository rep, SqlSugarRepository repRight, SqlSugarRepository repUser, SqlSugarRepository excelrep, ILogger logger) { _rep = rep; _repRight = repRight; _repUser = repUser; _logger = logger; + _excelrep = excelrep; } /// @@ -430,6 +433,35 @@ namespace Myshipping.Application } + /// + /// 新增编辑excel模板 + /// + /// + /// + [HttpPost("/BookingTemplate/AddOrUpdateExcelTemplate")] + public async Task AddOrUpdateExcelTemplate(BookingExcelTemplateDto dto) + { + + + await _excelrep.DeleteAsync(x => x.Pid == dto.Pid); + foreach (var item in dto.children) + { + var entity = item.Adapt(); + + await _excelrep.InsertAsync(entity); + } + return null; + } + /// + /// 获取excel模板详情 + /// + /// 模板ID + /// + [HttpGet("/BookingTemplate/BookingExcelTemplateList")] + public async Task BookingExcelTemplateList(long Id) + { + return await _excelrep.AsQueryable().Where(x => x.Pid == Id).ToListAsync(); + } } } diff --git a/Myshipping.Application/Service/BookingPrintTemplate/Dto/BookingExcelTemplateDto.cs b/Myshipping.Application/Service/BookingPrintTemplate/Dto/BookingExcelTemplateDto.cs new file mode 100644 index 00000000..5d0a499b --- /dev/null +++ b/Myshipping.Application/Service/BookingPrintTemplate/Dto/BookingExcelTemplateDto.cs @@ -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 children { get; set; } + } +} diff --git a/Myshipping.Application/Service/BookingTemplate/BookingTemplateService.cs b/Myshipping.Application/Service/BookingTemplate/BookingTemplateService.cs index a01517f3..e4351222 100644 --- a/Myshipping.Application/Service/BookingTemplate/BookingTemplateService.cs +++ b/Myshipping.Application/Service/BookingTemplate/BookingTemplateService.cs @@ -34,15 +34,14 @@ namespace Myshipping.Application { private readonly SqlSugarRepository _rep; private readonly SqlSugarRepository _repOrder; - private readonly SqlSugarRepository _excelrep; - private readonly SqlSugarRepository _excelsubrep; + private readonly SqlSugarRepository _repPrintTemplate; private readonly ILogger _logger; - public BookingTemplateService(SqlSugarRepository rep, SqlSugarRepository repOrder, SqlSugarRepository excelrep, SqlSugarRepository excelsubrep, SqlSugarRepository repPrintTemplate, ILogger logger) + public BookingTemplateService(SqlSugarRepository rep, SqlSugarRepository repOrder, SqlSugarRepository repPrintTemplate, ILogger 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); } - /// - /// 下拉获取字段名称 - /// - /// - [HttpGet("/BookingTemplate/GetFieldName")] - public async Task GetFieldName() - { - BookingOrder order = new BookingOrder(); - BookingCtn ctn = new BookingCtn(); - BookingEDIExt ext = new BookingEDIExt(); - List> list = new List>(); - - ////bookingorder - Dictionary dic = new Dictionary(); - 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 dic1 = new Dictionary(); - 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 dic2 = new Dictionary(); - 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; - } - - /// - /// 新增编辑excel模板 - /// - /// - /// - [HttpPost("/BookingTemplate/AddOrUpdateExcelTemplate")] - public async Task 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(); - entity.Pid = bookingExcel.Id; - await _excelsubrep.InsertAsync(entity); - } - } - else - { - var entity = dto.Adapt(); - 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(); - ent.Pid = dto.Id; - await _excelsubrep.InsertAsync(ent); - } - } - return null; - } - - - /// - /// 获取excel模板 - /// - /// 模板名称 - /// - [HttpGet("/BookingTemplate/BookingExcelTemplateList")] - public async Task BookingExcelTemplateList(string Name) - { - return await _excelrep.AsQueryable().WhereIF(!string.IsNullOrWhiteSpace(Name), x => x.Name.Contains(Name)).ToListAsync(); - } - /// - /// 获取excel模板详情 - /// - /// 模板名称 - /// - [HttpGet("/BookingTemplate/BookingExcelTemplateDetailList")] - public async Task BookingExcelTemplateDetailList(long Id) - { - return await _excelsubrep.AsQueryable().Where(x => x.Pid == Id).ToListAsync(); - } /// diff --git a/Myshipping.Application/Service/BookingTemplate/Dto/BookingExcelTemplateDto.cs b/Myshipping.Application/Service/BookingTemplate/Dto/BookingExcelTemplateDto.cs deleted file mode 100644 index 82c0fb52..00000000 --- a/Myshipping.Application/Service/BookingTemplate/Dto/BookingExcelTemplateDto.cs +++ /dev/null @@ -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 - { - /// - /// 业务id - /// - public long Id { get; set; } - /// - /// 模板名称 - /// - public string Name { get; set; } - - /// - /// 分类 - /// - public string Type { get; set; } - - - public List children { get; set; } - } -}