diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/InvoiceSyncQadDto.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/InvoiceSyncQadDto.cs new file mode 100644 index 00000000..779e5718 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/InvoiceSyncQadDto.cs @@ -0,0 +1,131 @@ +using System; +using System.ComponentModel.DataAnnotations; +using Magicodes.ExporterAndImporter.Core; +using Volo.Abp.Application.Dtos; + +namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos +{ + /// + /// 发票同步Qad + /// + public class InvoiceSyncQadDto : AuditedEntityDto + { + /// + /// 状态 + /// + [Display(Name = "状态")] + public int TaskState { get; set; } + /// + /// 任务ID + /// + [Display(Name = "任务ID")] + public Guid TaskID { get; set; } + /// + /// 表名 + /// + [Display(Name = "表名")] + public string TaskName { get; set; } + /// + /// 信息 + /// + [Display(Name = "信息")] + public string Failedinfo { get; set; } + /// + /// 域 + /// + [Display(Name = "域")] + public string Domain { get; set; } + /// + /// 地点 + /// + [Display(Name = "地点")] + public string Site { get; set; } + /// + /// 金税发票号 + /// + [Display(Name = "金税发票号")] + public string InvoiceNumber { get; set; } + /// + /// 结算发票号 + /// + [Display(Name = "结算发票号")] + public string SaslnvoiceNumber { get; set; } + /// + /// 客户 + /// + [Display(Name = "客户")] + public string Customer { get; set; } + /// + /// 凭证号 + /// + [Display(Name = "凭证号")] + public string Voucher { get; set; } + } + + /// + /// 导出 + /// + public class InvoiceSyncQadExportDto + { + /// + /// 状态 + /// + [Display(Name = "状态")] + [ExporterHeader(DisplayName = "状态")] + public int TaskState { get; set; } + /// + /// 任务ID + /// + [Display(Name = "任务ID")] + [ExporterHeader(DisplayName = "任务ID")] + public Guid TaskID { get; set; } + /// + /// 表名 + /// + [Display(Name = "表名")] + [ExporterHeader(DisplayName = "表名")] + public string TaskName { get; set; } + /// + /// 信息 + /// + [Display(Name = "信息")] + [ExporterHeader(DisplayName = "信息")] + public string Failedinfo { get; set; } + /// + /// 域 + /// + [Display(Name = "域")] + [ExporterHeader(DisplayName = "域")] + public string Domain { get; set; } + /// + /// 地点 + /// + [Display(Name = "地点")] + [ExporterHeader(DisplayName = "地点")] + public string Site { get; set; } + /// + /// 金税发票号 + /// + [Display(Name = "金税发票号")] + [ExporterHeader(DisplayName = "金税发票号")] + public string InvoiceNumber { get; set; } + /// + /// 结算发票号 + /// + [Display(Name = "结算发票号")] + [ExporterHeader(DisplayName = "结算发票号")] + public string SaslnvoiceNumber { get; set; } + /// + /// 客户 + /// + [Display(Name = "客户")] + [ExporterHeader(DisplayName = "客户")] + public string Customer { get; set; } + /// + /// 凭证号 + /// + [Display(Name = "凭证号")] + [ExporterHeader(DisplayName = "凭证号")] + public string Voucher { get; set; } + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs index 52dd4a22..7eddfbfb 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs @@ -470,9 +470,9 @@ namespace Win.Sfs.SettleAccount.Entities.Prices } /// - /// 印度价格导出 + /// 印度件价格导出 /// - [Display(Name = "备件价格")] + [Display(Name = "印度件价格")] public class PriceListYinDuExportDto { /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs index 82f4a8e4..59e79342 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs @@ -50,6 +50,8 @@ using static LinqToDB.Sql; using Win.Sfs.Shared.Filter; using Polly; using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing; +using Microsoft.Extensions.Logging; +using Castle.Core.Logging; namespace Win.Sfs.SettleAccount.Entities.BQ { @@ -57,6 +59,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ [Route("api/settleaccount/[controller]/[action]")] public class INVOICE_SERVICE : BASE_SERVICE { + private readonly ILogger _logger; /// /// 数据上下文 /// @@ -81,6 +84,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly INV_MNG _invMng; private readonly BaseDomainService _baseservice; public INVOICE_SERVICE( + ILogger logger, SettleAccountDbContext settleAccountDbContext, WMSBJBMPTDbContext wmsBJBMPTContext, ExChangeCenterDbContext exChangeCenterDbContext, @@ -100,6 +104,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ ) : base(excelImportService, snowflakeIdGenerator, commonManager) { + _logger = logger; _settleAccountDbContext = settleAccountDbContext; _wmsBJBMPTContext = wmsBJBMPTContext; _exChangeCenterDbContext = exChangeCenterDbContext; @@ -221,7 +226,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ TimeSpan.FromSeconds(5) }, (exception, timeSpan, retryCount, context) => { - Console.WriteLine($"执行失败,第 {retryCount} 次重试"); + _logger.LogError($"提交到QAD,修改发票状态执行失败,第 {retryCount} 次重试"); }); await retryPolicyAsync.ExecuteAsync(async () => await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false)).ConfigureAwait(false); } @@ -294,6 +299,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } } + /// + /// 构建发票同步Qad状态表数据 + /// + [HttpPost] + public async Task InvoiceSyncQad(string invbillNum) + { + var invoiceSyncQad = new InvoiceSyncQad(GuidGenerator.Create(), "", ""); + await _settleAccountDbContext.Set().AddAsync(invoiceSyncQad).ConfigureAwait(false); + await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false); + } + /// /// 通过审核 /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/InvoiceSyncQadService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/InvoiceSyncQadService.cs new file mode 100644 index 00000000..29f7ca8a --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/InvoiceSyncQadService.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using SettleAccount.Domain.BQ; +using Shouldly; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Caching; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Entities.BQ.Dtos; +using Win.Sfs.SettleAccount.ExcelImporter; +using Win.Sfs.Shared.RepositoryBase; + +namespace Win.Sfs.SettleAccount.Entities.BQ +{ + /// + /// 发票同步Qad + /// + [AllowAnonymous] + [Route("api/settleaccount/[controller]/[action]")] + public class InvoiceSyncQadService : SettleAccountApplicationBase + { + private readonly ILogger _logger; + private readonly INormalEfCoreRepository _repository; + + public InvoiceSyncQadService( + ILogger logger, + INormalEfCoreRepository repository, + IDistributedCache cache, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager + ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) + { + _logger = logger; + _repository = repository; + } + + #region 导入、导出 + /// + /// 导出 + /// + [HttpPost] + public async Task ExportAsync(RequestDto input) + { + var fileName = $"Qad发票同步状态_{Guid.NewGuid()}.xlsx"; + var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false); + var dtos = ObjectMapper.Map, List>(entities); + + var exportImporter = new ExportImporter(); + var result = await exportImporter.ExcelExporter(dtos).ConfigureAwait(false); + result.ShouldNotBeNull(); + + await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }).ConfigureAwait(false); + return fileName; + } + #endregion + + #region CURD + /// + /// 获取列表 + /// + [HttpPost] + public async Task> GetListAsync(RequestDto input) + { + var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false); + var totalCount = await _repository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false); + var dtos = ObjectMapper.Map, List>(entities); + return new PagedResultDto(totalCount, dtos); + } + #endregion + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs index 13ace9f7..416d75d2 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs @@ -106,6 +106,7 @@ namespace Win.Sfs.SettleAccount CreateMapPriceListBJ(); CreateMapPriceListYinDu(); + CreateMapInvoiceSyncQad(); #endregion #region 派格 CreateMapInvoice(); @@ -520,6 +521,14 @@ namespace Win.Sfs.SettleAccount CreateMap().ReverseMap(); } + /// + /// 印度价格 + /// + private void CreateMapInvoiceSyncQad() + { + CreateMap(); + } + private void CreateMapInvoiceSettledDiff() { diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/InvoiceSyncQad.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/InvoiceSyncQad.cs index 4c4e7395..14b3b11b 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/InvoiceSyncQad.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/InvoiceSyncQad.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel.DataAnnotations; using Volo.Abp.Domain.Entities.Auditing; @@ -13,7 +13,7 @@ namespace SettleAccount.Domain.BQ /// 状态 /// [Display(Name = "状态")] - public int TaskState { get; set; } + public int TaskState { get; protected set; } /// /// 任务ID /// @@ -67,5 +67,27 @@ namespace SettleAccount.Domain.BQ [Display(Name = "凭证号")] [MaxLength(64)] public string Voucher { get; set; } + + protected InvoiceSyncQad() + { + + } + + public InvoiceSyncQad(Guid taskID, string invoiceNumber, string saslnvoiceNumber) + { + TaskID = taskID; + InvoiceNumber = invoiceNumber; + SaslnvoiceNumber = saslnvoiceNumber; + } + + public void UpdateTaskState(int taskState) + { + TaskState = taskState; + } + + public void UpdateFailedinfo(string failedinfo) + { + Failedinfo = failedinfo; + } } }