diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/AuthServer/AuthServerHostModule.cs b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/AuthServer/AuthServerHostModule.cs index 40aeb257..5cb16f78 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/AuthServer/AuthServerHostModule.cs +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/AuthServer/AuthServerHostModule.cs @@ -1,4 +1,4 @@ -using AuthServer.Host.EntityFrameworkCore; +using AuthServer.Host.EntityFrameworkCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.DataProtection; @@ -43,7 +43,6 @@ namespace AuthServer.Host public class AuthServerHostModule : AbpModule { private const string DefaultCorsPolicyName = "Default"; - public override void ConfigureServices(ServiceConfigurationContext context) { var configuration = context.Services.GetConfiguration(); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs index 8f339f7e..280879d2 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs @@ -13,9 +13,6 @@ using Win.Sfs.Shared.Filter; namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos { - - - public class INVOICE_GRP_DTO : EntityDto { @@ -67,7 +64,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos public class INVOICE_GRP_EXP_DTO - { /// @@ -159,6 +155,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos public List INVOICE_MAP_GROUP { get; set; } public List INVOICE_NOT_SETTLE { get; set; } + public List ADJ_DETAIL { get; set; } + + + + } public class INVOICE_WAIT_DETAIL_DTO : EntityDto diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs index 10a71d46..db805fa8 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs @@ -12,17 +12,6 @@ using Win.Sfs.Shared.Filter; namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos; public class PUB_ADJ_DETAIL_DTO : EntityDto { - - /// - ///工厂地点 - /// - [Display(Name = "工厂地点")] - public string Site { get; set; } - /// - ///扩展1 - /// - [Display(Name = "扩展1")] - public string Extend1 { get; set; } /// ///作废发票号 /// @@ -33,111 +22,93 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos; /// [Display(Name = "发票号")] public string InvBillNum { get; set; } - public decimal Price { get; set; } - public int Version { get; set; } - public string SettleBillNum { get; set; } - public DateTime SettleDate { get; set; } - public string InvGroupNum { get; set; } - public string LU { get; set; } - public string PN { get; set; } - public string KeyCode { get; set; } - public decimal Qty { get; set; } - public string GroupNum { get; set; } - - } - public class PUB_ADJ_DETAIL_EXP_DTO - { - /// - ///工厂地点 - /// - [ExporterHeader(DisplayName = "工厂地点")] - public string Site { get; set; } - /// - ///扩展1 - /// - [ExporterHeader(DisplayName = "扩展1")] - public string Extend1 { get; set; } - /// - ///作废发票号 - /// - [ExporterHeader(DisplayName = "作废发票号")] - public string OldInvBillNum { get; set; } + /// - ///发票号 + /// 下线日期 /// - [ExporterHeader(DisplayName = "发票号")] - public string InvBillNum { get; set; } - public decimal Price { get; set; } - public int Version { get; set; } - public string SettleBillNum { get; set; } - public DateTime SettleDate { get; set; } + [Display(Name = "下线日期")] + public DateTime SettleDate { get; set; } + + [Display(Name = "发票分组号")] public string InvGroupNum { get; set; } + [Display(Name = "零件号")] public string LU { get; set; } + [Display(Name = "标识号")] public string PN { get; set; } - public string KeyCode { get; set; } + [Display(Name = "数量")] public decimal Qty { get; set; } + [Display(Name = "结算分组")] public string GroupNum { get; set; } - + } +public class PUB_ADJ_DETAIL_EXP_DTO +{ + /// + ///发票号 + /// + [Display(Name = "发票号")] + public string OldInvBillNum { get; set; } + [Display(Name = "新发票号")] + public string InvBillNum { get; set; } + [Display(Name = "下线日期")] + public DateTime SettleDate { get; set; } - public class PUB_ADJ_DETAIL_IMP_DTO - { - /// - ///工厂地点 - /// - [ImporterHeader(Name = "工厂地点")] - public string Site { get; set; } - /// - ///扩展1 - /// - [ImporterHeader(Name = "扩展1")] - public string Extend1 { get; set; } - /// - ///作废发票号 - /// - [ImporterHeader(Name = "作废发票号")] - public string OldInvBillNum { get; set; } - /// - ///发票号 - /// - [ImporterHeader(Name = "发票号")] - public string InvBillNum { get; set; } - public decimal Price { get; set; } - public int Version { get; set; } - public string SettleBillNum { get; set; } - public DateTime SettleDate { get; set; } - public string InvGroupNum { get; set; } - public string LU { get; set; } - public string PN { get; set; } - public string KeyCode { get; set; } - public decimal Qty { get; set; } - public string GroupNum { get; set; } - - } + [Display(Name = "零件号")] + public string LU { get; set; } + [Display(Name = "标识号")] + public string PN { get; set; } + [Display(Name = "数量")] + public decimal Qty { get; set; } + [Display(Name = "结算分组号")] + public string GroupNum { get; set; } +} + + + +public class PUB_ADJ_DETAIL_IMP_DTO +{ + /// + ///发票号 + /// + [ImporterHeader(Name = "发票号")] + public string OldInvBillNum { get; set; } + [ImporterHeader(Name = "下线日期")] + public DateTime SettleDate { get; set; } + [ImporterHeader(Name = "零件号")] + public string LU { get; set; } + [ImporterHeader(Name = "标识号")] + public string PN { get; set; } + [ImporterHeader(Name = "数量")] + public decimal Qty { get; set; } + [ImporterHeader(Name = "结算分组号")] + public string GroupNum { get; set; } +} - public class PUB_ADJ_DETAIL_REQ_DTO : RequestInputBase +public class PUB_ADJ_DETAIL_REQ_DTO : RequestInputBase { - [Display(Name = "工厂地点")] - public string Site { get; set; } - [Display(Name = "扩展1")] - public string Extend1 { get; set; } - [Display(Name = "作废发票号")] - public string OldInvBillNum { get; set; } - [Display(Name = "发票号")] - public string InvBillNum { get; set; } - public string InvGroupNum { get; set; } - public string LU { get; set; } - public string PN { get; set; } - public string KeyCode { get; set; } - public string GroupNum { get; set; } - - } + /// + ///发票号 + /// + [Display(Name = "发票号")] + public string OldInvBillNum { get; set; } + [Display(Name = "下线日期")] + public DateTime SettleDate { get; set; } + [Display(Name = "零件号")] + public string LU { get; set; } + [Display(Name = "标识号")] + public string PN { get; set; } + [Display(Name = "数量")] + public decimal Qty { get; set; } + [Display(Name = "结算分组号")] + public string GroupNum { get; set; } + +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_CAN_SA_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_CAN_SA_DTO.cs index f1c02708..258e2a82 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_CAN_SA_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_CAN_SA_DTO.cs @@ -12,59 +12,58 @@ using Win.Sfs.Shared.Filter; namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos { - - public class PUB_CAN_SA_DTO : EntityDto - { - /// - ///期间 - /// - [Display(Name = "期间")] - public int Version { get; set; } - /// - ///关联结算单号 - /// - [Display(Name = "关联结算单号")] - public string SettleBillNum { get; set; } - /// - ///结算单据 - /// - [Display(Name = "结算单据")] - public string BillNum { get; set; } - /// - ///状态 - /// - [Display(Name = "状态")] - public int State { get; set; } - /// - ///业务分类 - /// - [Display(Name = "业务分类")] - public EnumBusinessType BusinessType { get; set; } - /// - ///明细记录行数 - /// - [Display(Name = "明细记录行数")] - public string InvGroupNum { get; set; } - - } - public class PUB_CAN_SA_REQ_DTO : RequestInputBase - { - - [Display(Name = "期间")] - public int Version { get; set; } - [Display(Name = "关联结算单号")] - public string SettleBillNum { get; set; } - [Display(Name = "发票分组号")] - public string BillNum { get; set; } - [Display(Name = "状态")] - public int State { get; set; } - [Display(Name = "业务分类")] - public EnumBusinessType BusinessType { get; set; } - [Display(Name = "发票分组号")] - public string InvGroupNum { get; set; } - - - } + public class PUB_CAN_SA_DTO : EntityDto + { + /// + ///期间 + /// + [Display(Name = "期间")] + public int Version { get; set; } + /// + ///关联结算单号 + /// + [Display(Name = "关联结算单号")] + public string SettleBillNum { get; set; } + /// + ///结算单据 + /// + [Display(Name = "结算单据")] + public string BillNum { get; set; } + /// + ///状态 + /// + [Display(Name = "状态")] + public int State { get; set; } + /// + ///业务分类 + /// + [Display(Name = "业务分类")] + public EnumBusinessType BusinessType { get; set; } + /// + ///明细记录行数 + /// + [Display(Name = "明细记录行数")] + public string InvGroupNum { get; set; } + + } + public class PUB_CAN_SA_REQ_DTO : RequestInputBase + { + + [Display(Name = "期间")] + public int Version { get; set; } + [Display(Name = "关联结算单号")] + public string SettleBillNum { get; set; } + [Display(Name = "发票分组号")] + public string BillNum { get; set; } + [Display(Name = "状态")] + public int State { get; set; } + [Display(Name = "业务分类")] + public EnumBusinessType BusinessType { get; set; } + [Display(Name = "发票分组号")] + public string InvGroupNum { get; set; } + + + } public class PUB_CAN_SA_DETAIL_DTO : EntityDto { @@ -108,96 +107,89 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos public string MaterialDesc { set; get; } - + } - public class PUB_CAN_SA_DETAIL_EXP_DTO - { + public class PUB_CAN_SA_DETAIL_EXP_DTO + { - [ExporterHeader(DisplayName = "期间")] - public int Version { get; set; } - /// - ///关联结算单号 - /// - [ExporterHeader(DisplayName = "关联结算单号")] - public string SettleBillNum { get; set; } - /// - ///工厂地点 - /// - [ExporterHeader(DisplayName = "工厂地点")] - public string Site { get; set; } - /// - ///业务类别 - /// - [ExporterHeader(DisplayName = "业务类别")] - public EnumBusinessType BusinessType { get; set; } - - [ExporterHeader(DisplayName = "单价")] - public decimal Price { get; set; } - [ExporterHeader(DisplayName = "发票分组号")] - public string BillNum { get; set; } - [ExporterHeader(DisplayName = "下线日期")] - public DateTime SettleDate { get; set; } - [ExporterHeader(DisplayName = "发票分组号")] - public string InvGroupNum { get; set; } - [ExporterHeader(DisplayName = "LU")] - public string LU { get; set; } - [ExporterHeader(DisplayName = "发货单号、交付单号")] - public string PN { get; set; } + [ExporterHeader(DisplayName = "期间")] + public int Version { get; set; } + /// + ///关联结算单号 + /// + [ExporterHeader(DisplayName = "关联结算单号")] + public string SettleBillNum { get; set; } + /// + ///工厂地点 + /// + [ExporterHeader(DisplayName = "工厂地点")] + public string Site { get; set; } + /// + ///业务类别 + /// + [ExporterHeader(DisplayName = "业务类别")] + public EnumBusinessType BusinessType { get; set; } - [ExporterHeader(DisplayName = "结算数量")] - public decimal Qty { get; set; } + [ExporterHeader(DisplayName = "单价")] + public decimal Price { get; set; } + [ExporterHeader(DisplayName = "发票分组号")] + public string BillNum { get; set; } + [ExporterHeader(DisplayName = "下线日期")] + public DateTime SettleDate { get; set; } + [ExporterHeader(DisplayName = "发票分组号")] + public string InvGroupNum { get; set; } + [ExporterHeader(DisplayName = "LU")] + public string LU { get; set; } + [ExporterHeader(DisplayName = "发货单号、交付单号")] + public string PN { get; set; } + [ExporterHeader(DisplayName = "结算数量")] + public decimal Qty { get; set; } + [ExporterHeader(DisplayName = "结算分组号")] + public string GroupNum { get; set; } + } - [ExporterHeader(DisplayName = "结算分组号")] - public string GroupNum { get; set; } - - } - - public class PUB_CAN_SA_DETAIL_REQ_DTO : RequestInputBase + public class PUB_CAN_SA_DETAIL_REQ_DTO : RequestInputBase { - /// - ///关联结算单号 - /// - [Display(Name = "关联结算单号")] - public string SettleBillNum { get; set; } - /// - ///工厂地点 - /// - [Display(Name = "工厂地点")] - public string Site { get; set; } - /// - ///业务类别 - /// - [Display(Name = "业务类别")] - public EnumBusinessType BusinessType { get; set; } - /// - /// - /// - - [Display(Name = "发票分组号")] - public string BillNum { get; set; } - [Display(Name = "下线日期")] - public DateTime SettleDate { get; set; } - [Display(Name = "发票分组号")] - public string InvGroupNum { get; set; } - [Display(Name = "LU")] - public string LU { get; set; } - [Display(Name = "发货单号、交付单号")] - public string PN { get; set; } - - - - } + /// + ///关联结算单号 + /// + [Display(Name = "关联结算单号")] + public string SettleBillNum { get; set; } + /// + ///工厂地点 + /// + [Display(Name = "工厂地点")] + public string Site { get; set; } + /// + ///业务类别 + /// + [Display(Name = "业务类别")] + public EnumBusinessType BusinessType { get; set; } + /// + /// + /// + + [Display(Name = "发票分组号")] + public string BillNum { get; set; } + [Display(Name = "下线日期")] + public DateTime SettleDate { get; set; } + [Display(Name = "发票分组号")] + public string InvGroupNum { get; set; } + [Display(Name = "LU")] + public string LU { get; set; } + [Display(Name = "发货单号、交付单号")] + public string PN { get; set; } @@ -205,6 +197,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos +} + + + diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs new file mode 100644 index 00000000..12e4e116 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EFCore.BulkExtensions; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using SettleAccount.Bases; +using SettleAccount.Domain.BQ; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.Bases.DomainServices; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Constant; +using Win.Sfs.SettleAccount.Entities.BQ.Dtos; +using Win.Sfs.SettleAccount.ExcelImporter; +using Win.Sfs.SettleAccount.ExportReports; +using Win.Sfs.Shared.RepositoryBase; + +namespace Win.Sfs.SettleAccount.Bases; +/// +/// 发票明细调整表 +/// +[AllowAnonymous] +[Route("api/settleaccount/[controller]/[action]")] +public class ADJ_SERVICE : BASE_SERVICE +{ + protected readonly INormalEfCoreRepository _repository; + protected readonly BaseDomainService _baseDomainService; + public ADJ_SERVICE( + INormalEfCoreRepository repository, + BaseDomainService baseDomainService, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager + ) + : base(excelImportService, snowflakeIdGenerator, commonManager) + { + _repository = repository; + _baseDomainService = baseDomainService; + } + /// + ///查询明细 + /// + /// 明细查询条件 + /// + [HttpPost] + + public virtual async Task> DetailQueryAsync(PUB_ADJ_DETAIL_REQ_DTO input) + { + var entitys = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); + var totalCount = await _repository.GetCountByFilterAsync(input.Filters); + var dtos = ObjectMapper.Map, List>(entitys); + return new PagedResultDto(totalCount, dtos); + } + /// + /// 导入文件 + /// + /// + /// + /// + [HttpPost] + [DisableRequestSizeLimit] + public async Task ExcelImport([FromForm] IFormFileCollection files) + { + List errorList = new List(); + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + if (result.Count == 0) + { + throw new BusinessException("8989", "导入数据记录为0条"); + } + var deletels = _repository.Where(p => p.OldInvBillNum == result.FirstOrDefault().OldInvBillNum).ToList(); + var first = deletels.FirstOrDefault(); + if (!string.IsNullOrEmpty(first.InvBillNum)) + { + throw new BusinessException("8989", $"调整记录已经新发票号:{first.InvBillNum}"); + } + var entityList = ObjectMapper.Map, List>(result); + var codelist = entityList.Select(p => p.LU).ToList(); + var errors = await _baseDomainService.CheckBase(codelist, new BASE_CONF() { IsRelationShip = true }); + foreach (var itm in errors) + { + errorList.Add( + new ErrorExportDto() { ItemCode = $"{itm}", Message = $"[客户零件关系表]不存在客户零件号{itm}" }); + } + var errorEntitylist = await _baseDomainService.CheckPriceList(entityList); + if (errorEntitylist.Count > 0) + { + foreach (var itm in errorEntitylist) + { + errorList.Add(new ErrorExportDto() { ItemCode = $"{itm.LU}", Message = $"客户零件号{itm.LU}标识号{itm.PN}下线日期{itm.SettleDate}不存在价格单记录" }); + } + } + await _repository.DbContext.BulkDeleteAsync(deletels);//删除发票下所有调整明细 + await _repository.DbContext.BulkInsertAsync(entityList); + return ApplicationConsts.SuccessStr; + } + +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs index a6893f26..94ca80d4 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs @@ -313,10 +313,10 @@ namespace Win.Sfs.SettleAccount.Bases /// 版本号 /// 发票分组 /// 原发票号 - protected async Task ReissueSecInvoice(List p_list, int p_version, string p_parentInvBillNum) + protected async Task ReissueSecInvoice(List p_list, List p_adjlist, int p_version, string p_parentInvBillNum) { - return await _invMng.ReissueSecInvoice(p_list,p_parentInvBillNum, p_version); + return await _invMng.ReissueSecInvoice(p_list,p_adjlist,p_parentInvBillNum, p_version); } @@ -330,9 +330,9 @@ namespace Win.Sfs.SettleAccount.Bases /// 要作废的发票号 /// /// - protected async Task ReissueFirstInvoice(List dtos,int p_version, string p_parentInvBillNum) + protected async Task ReissueFirstInvoice(List dtos, List p_adjlist, int p_version, string p_parentInvBillNum) { - return await _invMng.ReissueFirstInvoice(dtos,p_parentInvBillNum,p_version); + return await _invMng.ReissueFirstInvoice(dtos,p_adjlist,p_parentInvBillNum,p_version); } /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs index 05636cf9..69ba186c 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs @@ -167,7 +167,12 @@ namespace Win.Sfs.SettleAccount.Bases protected async Task SecInvoice(List p_list, int p_version, string p_InvGroupNum, string p_parentInvBillNum,EnumBusinessType businessType) { - return await _invmng.SecInvoice(p_list, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); + var ls= await _invmng.SecInvoice(p_list, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); + if (ls.Count > 0) + { + return true; + } + return false; } @@ -181,9 +186,17 @@ namespace Win.Sfs.SettleAccount.Bases /// /// /// - protected async Task FirstInvoice(List dtos, List p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum,EnumBusinessType businessType) + protected async Task FirstInvoice(List dtos, List p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) { - return await _invmng.FirstInvoice(dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); + + var ls = await _invmng.FirstInvoice(dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); + if (ls.Count > 0) + { + return true; + } + return false; + + } /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs index f634c492..163a407f 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs @@ -27,19 +27,12 @@ using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Bases { public abstract class NOT_SA_SERVICE : BASE_SERVICE - where TEntityDetail : SA_NOT_BASE - where TEntityDetailDto : class, IEntityDto, new() - where TRequestDetailInput : RequestInputBase where TEntityDetailExportDto : class, new() { - - protected readonly INormalEfCoreRepository _detailRepository; - - protected NOT_SA_SERVICE( IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, @@ -49,6 +42,7 @@ namespace Win.Sfs.SettleAccount.Bases ) : base(excelImportService, snowflakeIdGenerator, commonManager) { + _detailRepository=detailRepository; } /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs index a54f18f5..16422332 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs @@ -1,7 +1,6 @@ -using DocumentFormat.OpenXml.Bibliography; + using EFCore.BulkExtensions; using Microsoft.AspNetCore.Authorization; - using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using SettleAccount.Domain.BQ; @@ -85,7 +84,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ throw new BusinessException("8989", $"选择发票:{p_invbillnum}状态为报废状态不能重开!"); } var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum, gList);//结算分组对应结算零件 - var adjlist = await _adjRepository.Where(p => p.InvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 + var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 if (adjlist != null && adjlist.Count() > 0) { foreach (var itm in adjlist) @@ -149,11 +148,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { if (p_invbillnum.Substring(0, 3) == "INV")//一次开票重开 { - await ReissueFirstInvoice(dtos, version, p_invbillnum); + await ReissueFirstInvoice(dtos,adjlist ,version, p_invbillnum); } else//二次开票 { - await ReissueSecInvoice(dtos, version, p_invbillnum); + await ReissueSecInvoice(dtos,adjlist,version, p_invbillnum); } } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs index 28636ca3..5f488907 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs @@ -140,11 +140,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { if (p_invbillnum.Substring(0, 3) == "INV")//一次开票重开 { - await ReissueFirstInvoice(dtos, version, p_invbillnum); + await ReissueFirstInvoice(dtos,adjlist, version, p_invbillnum); } else//二次开票 { - await ReissueSecInvoice(dtos, version, p_invbillnum); + await ReissueSecInvoice(dtos,adjlist, version, p_invbillnum); } } } 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 cc001ab1..afde8a3f 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 @@ -39,6 +39,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ private readonly INormalEfCoreRepository _wRepository; private readonly INormalEfCoreRepository _sRepository; private readonly INormalEfCoreRepository _mRepository; + private readonly INormalEfCoreRepository _adjRepository; private readonly PUB_CAN_SA_MNG _pubMng; private readonly BBAC_CAN_SA_MNG _bbacMng; private readonly HBPO_CAN_SA_MNG _hbpoMng; @@ -50,6 +51,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ INormalEfCoreRepository wRepository, INormalEfCoreRepository sRepository, INormalEfCoreRepository mRepository, + INormalEfCoreRepository adjRepository, PUB_CAN_SA_MNG pubMng, BBAC_CAN_SA_MNG bbacMng, HBPO_CAN_SA_MNG hbpoMng, @@ -61,6 +63,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ _wRepository = wRepository; _mRepository = mRepository; _sRepository = sRepository; + _adjRepository = adjRepository; _pubMng = pubMng; _bbacMng = bbacMng; _hbpoMng = hbpoMng; @@ -95,9 +98,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var wdtos = ObjectMapper.Map, List>(w); var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); var sdtos = ObjectMapper.Map, List>(s); + var adjs =await _adjRepository.GetListByFilterAsync(input.Filters); + var adjdtos = ObjectMapper.Map, List>(adjs); _entity.INVOICE_NOT_SETTLE = sdtos; _entity.INVOICE_WAIT_DETAIL = wdtos; _entity.INVOICE_MAP_GROUP = mdtos; + _entity.ADJ_DETAIL = adjdtos; return _entity; @@ -146,25 +152,25 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { IExporter _csv = new CsvExporter(); ExcelExporter _excel = new ExcelExporter(); - var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); var dtoDetails = ObjectMapper.Map, List>(entities); - var invdetail= await DetailQueryAsync(input); var m = invdetail.INVOICE_MAP_GROUP; var not=invdetail.INVOICE_NOT_SETTLE; var detail =invdetail.INVOICE_WAIT_DETAIL; - + var adj = invdetail.ADJ_DETAIL; var classDisplayName = typeof(INVOICE_GRP_DTO).GetCustomAttribute()?.Name ?? typeof(INVOICE_GRP_DTO).Name; string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; - - - var result = _excel.Append(dtoDetails,"发票表").SeparateBySheet() + var result = _excel + .Append(dtoDetails,"发票表") + .SeparateBySheet() .Append(m, "发票和结算分组关系") .SeparateBySheet() .Append(not, "对应未结结算分组") .SeparateBySheet() .Append(detail, "发票明细") + .SeparateBySheet() + .Append(adj,"发票调整单") .ExportAppendDataAsByteArray(); result.ShouldNotBeNull(); //保存导出文件到服务器存成二进制 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs index 41772615..d47b4640 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs @@ -140,11 +140,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ { if (p_invbillnum.Substring(0, 3) == "INV")//一次开票重开 { - await ReissueFirstInvoice(dtos, version, p_invbillnum); + await ReissueFirstInvoice(dtos,adjlist, version, p_invbillnum); } else//二次开票 { - await ReissueSecInvoice(dtos, version, p_invbillnum); + await ReissueSecInvoice(dtos,adjlist, version, p_invbillnum); } } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs index 0f57b2f5..1c11a339 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs @@ -1,4 +1,4 @@ -using SettleAccount.Bases; +using SettleAccount.Bases; using System; using System.Collections.Generic; using System.Linq; @@ -13,78 +13,76 @@ using Win.Sfs.SettleAccount.Boms; using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.Entities.ImportMap; using Win.Sfs.SettleAccount.Entities.Materials; +using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.FISes; using Win.Sfs.SettleAccount.MaterialRelationships; +using Win.Sfs.Shared.RepositoryBase; namespace Win.Sfs.SettleAccount.Bases.DomainServices { - public class BaseDomainService:DomainService, ICheck + public class BaseDomainService : DomainService { - private readonly ISettleAccountBQEfCoreRepository _materialRepository; - private readonly ISettleAccountBQEfCoreRepository _relationshipRepository; - private readonly ISettleAccountBQEfCoreRepository _bomshipRepository; + private readonly INormalEfCoreRepository _materialRepository; + private readonly INormalEfCoreRepository _relationshipRepository; + private readonly INormalEfCoreRepository _priceRepository; + private readonly INormalEfCoreRepository _pricebjRepository; + + + + private readonly INormalEfCoreRepository _bomshipRepository; public BaseDomainService( IGuidGenerator guidGenerator, IObjectMapper objectMapper, - ISettleAccountBQEfCoreRepository materialRepository, - ISettleAccountBQEfCoreRepository relationshipRepository, - ISettleAccountBQEfCoreRepository bomshipRepository - //IExcelImportAppService excelImportService, - //ISnowflakeIdGenerator snowflakeIdGenerator, - //ICommonManager commonManager + INormalEfCoreRepository materialRepository, + INormalEfCoreRepository relationshipRepository, + INormalEfCoreRepository bomshipRepository, + INormalEfCoreRepository priceRepository, + INormalEfCoreRepository pricebjRepository + //IExcelImportAppService excelImportService, + //ISnowflakeIdGenerator snowflakeIdGenerator, + //ICommonManager commonManager ) { + _pricebjRepository = pricebjRepository; + _pricebjRepository= pricebjRepository; _materialRepository = materialRepository; _relationshipRepository = relationshipRepository; _bomshipRepository = bomshipRepository; } - public async Task> CheckBase(List p_list ,BASE_CONF p_config) where TEntity : ISBASE - + + + public async Task> CheckBase(List p_list, BASE_CONF p_config) { List errorList = new List(); - var partList= p_list.Select(p=>p.LU).Distinct().ToList(); + var partList = p_list; if (p_config.IsBom == true) { - var bomList =await _bomshipRepository.ToListAsync(); - var query=from itm in partList join itm1 in bomList on itm equals itm1.ParentItemCode - into temp - from tm in temp.DefaultIfEmpty() - where tm == null - select itm; - - foreach(var itm1 in query.ToList()) - { - errorList.Add(itm1); - } - } - if (p_config.IsMaterial == true) - { - - var materialList = await _materialRepository.ToListAsync(); + var bomList = await _bomshipRepository.ToListAsync(); var query = from itm in partList - join itm1 in materialList on itm equals itm1.MaterialCode - into temp + join itm1 in bomList on itm equals itm1.ParentItemCode + into temp from tm in temp.DefaultIfEmpty() where tm == null select itm; - foreach (var partcode in query.ToList()) + + foreach (var itm1 in query.ToList()) { - errorList.Add(partcode); + errorList.Add(itm1); } } - if (p_config.IsRelationShip == true) + if (p_config.IsMaterial == true) { - var materialList =await _relationshipRepository.ToListAsync(); + + var materialList = await _materialRepository.ToListAsync(); var query = from itm in partList - join itm1 in materialList on itm equals itm1.SettleMaterialCode + join itm1 in materialList on itm equals itm1.MaterialCode into temp from tm in temp.DefaultIfEmpty() where tm == null select itm; - foreach (var partcode in query.ToList()) { errorList.Add(partcode); @@ -106,15 +104,12 @@ namespace Win.Sfs.SettleAccount.Bases.DomainServices } } - - return errorList; } - - public async Task> CheckBase(List p_list, BASE_CONF p_config) + public async Task> CheckBase(List p_list, BASE_CONF p_config) where TEntity : ISBASE { List errorList = new List(); - var partList = p_list; + var partList = p_list.Select(p => p.LU).Distinct().ToList(); if (p_config.IsBom == true) { @@ -161,19 +156,70 @@ namespace Win.Sfs.SettleAccount.Bases.DomainServices errorList.Add(partcode); } } - - + if (p_config.IsRelationShip == true) + { + var materialList = await _relationshipRepository.ToListAsync(); + var query = from itm in partList + join itm1 in materialList on itm equals itm1.SettleMaterialCode + into temp + from tm in temp.DefaultIfEmpty() + where tm == null + select itm; + foreach (var partcode in query.ToList()) + { + errorList.Add(partcode); + } + } return errorList; } + public async Task> CheckPriceList(List p_list,bool isBj=false) + where TEntity : ISA_BASE,new() + { + List errorList = new List(); + if (isBj == true) + { + var pricebjlist = _pricebjRepository.ToList(); + + var inner = from d in p_list + join p in pricebjlist on d.LU equals p.LU + where + d.SettleDate >= p.BeginDate && d.SettleDate <= p.EndDate + select d; + var left = from d in p_list + join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN } + into temp + from tm in temp.DefaultIfEmpty()//校验错误项 + where tm == null + select d; + errorList = left.ToList(); - } - public interface ICheck - { - Task> CheckBase(List p_list, BASE_CONF p_config) where TEntity : ISBASE; - } + } + else + { + var pricebjlist = _priceRepository.ToList(); + + var inner = from d in p_list + join p in pricebjlist on d.LU equals p.LU + where + d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime + select d; + var left = from d in p_list + join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN } + into temp + from tm in temp.DefaultIfEmpty()//校验错误项 + where tm == null + select d; + errorList = left.ToList(); + } + return errorList; + } + + + + } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs index 08ecc5d3..18d09699 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs @@ -127,10 +127,10 @@ namespace SettleAccount.Bases /// 单价 /// public decimal Price { set; get; } - /// - /// 结算单 - /// - public string BillNum { set; get; } + ///// + ///// 结算单 + ///// + //public string BillNum { set; get; } /// /// 结算日期 /// @@ -311,9 +311,9 @@ namespace SettleAccount.Bases /// /// 是否检查BOM /// - public bool IsBom { set; get; } + public bool IsBom { set; get; } - public bool IsPriceList { set; get; } + public bool IsPriceList { set; get; } public BASE_CONF(bool isRelationShip, bool isMaterial, bool isBom) @@ -322,6 +322,10 @@ namespace SettleAccount.Bases IsMaterial = isMaterial; IsBom = isBom; } + + public BASE_CONF() + { + } } @@ -371,15 +375,9 @@ namespace SettleAccount.Bases /// public virtual string GroupNum { get ; set ; } - - - - - - } - public class SA_CAN_BASE : AuditedAggregateRoot, ISA_CAN_BASE + public class SA_CAN_BASE : AuditedAggregateRoot, ISA_BASE { protected SA_CAN_BASE() { } public SA_CAN_BASE(Guid id) : base(id) { } @@ -443,7 +441,13 @@ namespace SettleAccount.Bases // GroupNum = groupNum; //} } - public class SA_NOT_BASE : AuditedAggregateRoot, ISA_NOT_BASE + + + + + + + public class SA_NOT_BASE : AuditedAggregateRoot, ISA_BASE { public SA_NOT_BASE() { @@ -489,6 +493,7 @@ namespace SettleAccount.Bases /// 結算分組號 /// public string GroupNum { get; set; } + //public SA_NOT_BASE(decimal price, int version, string settleBillNum, DateTime settleDate, string invGroupNum, string lU, string pN, string keyCode, decimal qty, string groupNum) //{ // Price = price; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs index 02a06670..cf99b5a9 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs @@ -276,6 +276,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers /// public virtual async Task ReceivedAsync(string p_groupbillnum) { + var inv = _repository.Where(p => p.InvGroupNum == p_groupbillnum).FirstOrDefault(); if (inv.BusinessType == EnumBusinessType.JisBBAC) { @@ -541,8 +542,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers /// 版本号 /// 发票分组 /// 原发票号 - public async Task SecInvoice(List dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) + public async Task> SecInvoice(List dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) { + List _invls = new List(); var groups1 = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV { @@ -704,10 +706,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers await _repository.DbContext.BulkInsertAsync(groupList); await _repository.DbContext.BulkInsertAsync(detailList); //await _repository.DbContext.BulkInsertAsync(notDetialList); - return true; - + _invls = invlist.Select(p => p.InvbillNum).ToList(); } - return false; + return _invls; } @@ -721,8 +722,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers /// /// /// - public async Task FirstInvoice(List dtos, List p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) + public async Task> FirstInvoice(List dtos, List p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) { + List _invls = new List(); var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }); Dictionary dic = new Dictionary();//原本 Dictionary copyDic = new Dictionary();//变换数组副本 @@ -891,8 +893,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers { await _repository.DbContext.BulkInsertAsync(notDetialList); } + _invls =invlist.Select(p => p.InvbillNum).ToList(); } - return true; + + return _invls; } /// @@ -903,7 +907,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers /// /// /// - public async Task ReissueFirstInvoice(List dtos, string p_OldInvBillNum, int p_version) + public async Task ReissueFirstInvoice(List dtos,List p_adjlist, string p_OldInvBillNum, int p_version) { if (!string.IsNullOrEmpty(p_OldInvBillNum)) { @@ -918,7 +922,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers throw new BusinessException("8989", $"选择要重开发票号{p_OldInvBillNum}已经作废不能重开"); } inv.InvoiceState = InvoiceBillState.报废; - await FirstInvoice(dtos, new List(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType); + var invlist=await FirstInvoice(dtos, new List(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);//重开可以变多张发票 + if (invlist.Count == 0) + { + return false; + } + + foreach (var adj in p_adjlist) + { + adj.InvBillNum = string.Join(",", invlist); + } + + _repository.DbContext.BulkUpdate(p_adjlist); + _repository.DbContext.BulkUpdate(new List { inv }); return true; } @@ -932,7 +948,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers /// /// /// - public async Task ReissueSecInvoice(List dtos, string p_OldInvBillNum, int p_version) + public async Task ReissueSecInvoice(List dtos, List p_adjlist, string p_OldInvBillNum, int p_version) { if (!string.IsNullOrEmpty(p_OldInvBillNum)) { @@ -948,9 +964,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers } inv.InvoiceState = InvoiceBillState.报废; - - await FirstInvoice(dtos, new List(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType); + var invlist =await SecInvoice(dtos, p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType); + if (invlist.Count == 0) + { + return false; + } + _repository.DbContext.BulkUpdate(new List { inv }); + + foreach (var adj in p_adjlist) + { + adj.InvBillNum = string.Join(",", invlist); + } + _repository.DbContext.BulkUpdate(p_adjlist); return true; } return false; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Temp/TempClass.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Temp/TempClass.cs index c16ff5d5..e33fc8de 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Temp/TempClass.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Temp/TempClass.cs @@ -10,6 +10,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Temp; public class TMEP_INV { public string LU { set; get; } + /// + /// 合同号 + /// public string ContractDocID { set; get; } public decimal Amt { set; get; } public decimal Qty { set; get; }