diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs index 05c823fd..a45bb22d 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs @@ -179,7 +179,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Display(Name = "结算日期")] [ImporterHeader(Name = "零件时间")] public DateTime SettleDate { set; get; } - /// /// 客户零件号 /// @@ -187,7 +186,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Required(ErrorMessage = "{0}不能为空")] [ImporterHeader(Name = "零件号")] public string LU { get; set; } - /// /// 生产号 /// @@ -195,14 +193,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [ImporterHeader(Name = "交付识别号")] [Required(ErrorMessage = "{0}不能为空")] public string PN { get; set; } - /// /// 数量 /// [Display(Name = "数量")] [ImporterHeader(Name = "数量")] public decimal Qty { get; set; } - /// /// 结算分组号 /// @@ -210,7 +206,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [ImporterHeader(Name = "凭证号")] [Required(ErrorMessage = "{0}不能为空")] public string GroupNum { get; set; } - /// /// 采购订单号 /// @@ -230,91 +225,78 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Display(Name = "交货号")] [ImporterHeader(Name = "交货号")] public string DeliveryNumber { set; get; } - /// /// 发票号 /// [Display(Name = "发票号")] [ImporterHeader(Name = "发票号")] public string InvoiceNumber { set; get; } - /// /// 开票日期 /// [Display(Name = "开票日期")] [ImporterHeader(Name = "开票日期")] public DateTime? MakeDate { set; get; } - /// /// 供应商代码 /// [Display(Name = "供应商代码")] [ImporterHeader(Name = "供应商代码")] public string VendorCode { set; get; } - /// /// 供应商名称 /// [Display(Name = "供应商名称")] [ImporterHeader(Name = "供应商名称")] public string VendorName { set; get; } - /// /// 交付索引号 /// [Display(Name = "交付索引号")] [ImporterHeader(Name = "交付索引号")] public string DeliveryIndexNumber { set; get; } - /// /// 零件名称 /// [Display(Name = "零件名称")] [ImporterHeader(Name = "零件名称")] public string PartName { set; get; } - /// /// 价格 /// [Display(Name = "价格")] [ImporterHeader(Name = "价格")] public decimal? Price { set; get; } - /// /// 金额 /// [Display(Name = "金额")] [ImporterHeader(Name = "金额")] public decimal? Amount { set; get; } - /// /// 税额 /// [Display(Name = "税额")] [ImporterHeader(Name = "税额")] public decimal? Tallage { set; get; } - /// /// 价税合计 /// [Display(Name = "价税合计")] [ImporterHeader(Name = "价税合计")] public decimal? Total { set; get; } - /// /// 协议编号 /// [Display(Name = "协议编号")] [ImporterHeader(Name = "协议编号")] public string ProtocolNumber { set; get; } - /// /// 备注 /// [Display(Name = "备注")] [ImporterHeader(Name = "备注")] public string Remark { set; get; } - /// /// 商品组 /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs index cdb8b58a..b80129eb 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs @@ -113,6 +113,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// 导入 /// + /// + /// JisHBPO、买单件HBPO结算数据导入 + /// [HttpPost] public async Task ImportAsync([FromForm] HBPOSaImportRequestDto hbpoSaImportRequestDto) { @@ -152,6 +155,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// 删除 /// + /// + /// 同时删除 + /// 结算主表、明细表 + /// 可结算主表、明细表 + /// 不可结算明细表(不可结算没主表) + /// [HttpPost] public async Task DeleteListAsync(List ids) { @@ -311,6 +320,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// Insert结算数据 /// + /// + /// 匹配价格 + /// * 根据客户编码、业务、零件号、时间匹配价格 + /// 匹配对应的厂内零件号 + /// 结算数据入库 + /// * 入库 结算主表、结算明细表、可结算主表、可结算明细表、不可结算明细表 + /// private async Task InsertSaDataAsync(List hbpoSaDetails, string place) { var site = "104T"; @@ -425,6 +441,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// 获取结算关联项 /// + /// + /// 根据结算主表Id获取关联的结算主表、结算明细表、可结算主表、可结算明细表、不可结算明细表要删除的数据 + /// 验证可结算主表状态 + /// 只有可结算主表状态为未结状态时才可以删除结算数据 + /// private async Task<(List hbpoSas, List hbpoSaDetails, List hbpoCanSas, List hbpoCanSaDetails, List hbpoNotSaDetails)> GetHBPOSaDelItemsAsync(Guid id) { //结算主表 @@ -463,6 +484,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// 数据校验 /// + /// + /// 验证结算分组号是否已存在 + /// 验证导入的零件号在客户-厂内零件号关系表中是否存在 + /// private async Task> CheckAsync(List hbpoSaDetails) { #region 数据校验 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs index 1416d7de..769db98b 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs @@ -176,7 +176,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// 同时删除 /// 结算主表、明细表 /// 可结算主表、明细表 - /// 不可结算明细表(不可结算又没主表) + /// 不可结算明细表(不可结算没主表) /// [HttpPost] public async Task DeleteListAsync(List ids) @@ -243,7 +243,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// 导入数据过滤 /// * 筛选 Vendor 为15663496的数据 - /// HandleSaDetails方法处理导入的数据 /// private async Task ImportZhiGongJianBBACAsync([FromForm] IFormFileCollection files) { @@ -276,6 +275,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// 直供件HBPO导入 /// + /// + /// 截取结算分组号前8位为结算日期 + /// private async Task ImportZhiGongJianHBPOAsync([FromForm] IFormFileCollection files) { #region 导入数据转换 @@ -343,6 +345,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// 印度件导入 /// + /// + /// 导入数据过滤 + /// * 筛选 Supplier 为15663496的数据 + /// private async Task ImportYinDuJianAsync([FromForm] IFormFileCollection files) { #region 导入数据转换 @@ -376,7 +382,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// /// 验证结算分组号是否已存在 - /// 验证 + /// 验证导入的零件号在客户-厂内零件号关系表中是否存在 /// private async Task> CheckAsync(List pubSaDetails) { @@ -460,21 +466,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// Insert结算数据 /// + /// + /// 匹配价格 + /// * 根据客户编码、业务、零件号、时间匹配价格 + /// 匹配对应的厂内零件号 + /// private async Task InsertSaDataAsync(List pubSaDetails, EnumBusinessType businessType) { #region 处理结算数据 - for (var i = 0; i < pubSaDetails.Count; i++) - { - var pubSaDetail = pubSaDetails[i]; - pubSaDetail.SetId(GuidGenerator.Create()); - pubSaDetail.CustomerPartCodeNoSpace = pubSaDetail.LU.Replace(" ", ""); - pubSaDetail.KeyCode = pubSaDetail.PN + pubSaDetail.LU; - pubSaDetail.Version = version; - pubSaDetail.BusinessType = businessType; - pubSaDetail.IndexNum = i; - } + //导入的零件号集合 var lus = pubSaDetails.Select(t => t.LU).Distinct().ToList(); + #region 匹配价格 var clientCode = businessType switch { EnumBusinessType.ZhiGongJianBBAC => site, @@ -520,16 +523,25 @@ namespace Win.Sfs.SettleAccount.Entities.BQ .FirstOrDefault(); importPubSaDetail.Price = priceListEntity?.Price ?? 0; }); - } + } + #endregion - //导入的零件号集合 - var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct(); - var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => t.BusinessType == businessType && importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); + // 客户-厂内零件号关系 + var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => t.BusinessType == businessType && lus.Contains(t.SettleMaterialCode)).ConfigureAwait(false); - pubSaDetails.ForEach(pubSaDetail => + for (var i = 0; i < pubSaDetails.Count; i++) { + var pubSaDetail = pubSaDetails[i]; + pubSaDetail.SetId(GuidGenerator.Create()); + //去掉空格的客户零件号(比对需要) + pubSaDetail.CustomerPartCodeNoSpace = pubSaDetail.LU.Replace(" ", ""); + pubSaDetail.KeyCode = pubSaDetail.PN + pubSaDetail.LU; + pubSaDetail.Version = version; + pubSaDetail.BusinessType = businessType; + //记录结算数据导入文件中的顺序(发票需要) + pubSaDetail.IndexNum = i; pubSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == pubSaDetail.LU)?.ErpMaterialCode; - }); + } #endregion #region 添加入库 @@ -542,6 +554,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ /// /// 结算数据入库 /// + /// + /// 入库 结算主表、结算明细表、可结算主表、可结算明细表、不可结算明细表 + /// private async Task SeDataEntryAsync(List pubSaDetails) { //业务类型