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 2fcd600e..4f9c0726 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 @@ -82,7 +82,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Display(Name = "Material")] [Required(ErrorMessage = "{0}不能为空")] [ImporterHeader(Name = "Material")] - public string PartCode { get; set; } + public string LU { get; set; } /// /// 生产号 @@ -126,7 +126,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Display(Name = "零件号")] [Required(ErrorMessage = "{0}不能为空")] [ImporterHeader(Name = "零件号")] - public string PartCode { get; set; } + public string LU { get; set; } /// /// 生产号 @@ -170,7 +170,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Display(Name = "零件号")] [Required(ErrorMessage = "{0}不能为空")] [ImporterHeader(Name = "零件号")] - public string PartCode { get; set; } + public string LU { get; set; } /// /// 生产号 @@ -205,7 +205,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos /// 结算日期 /// [Display(Name = "结算日期")] - [ImporterHeader(Name = "开票日期")] + [ImporterHeader(Name = "零件时间")] public DateTime SettleDate { set; get; } /// @@ -214,7 +214,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Display(Name = "零件号")] [Required(ErrorMessage = "{0}不能为空")] [ImporterHeader(Name = "零件号")] - public string PartCode { get; set; } + public string LU { get; set; } /// /// 生产号 @@ -265,6 +265,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [ImporterHeader(Name = "发票号")] public string InvoiceNumber { set; get; } + /// + /// 开票日期 + /// + [Display(Name = "开票日期")] + [ImporterHeader(Name = "开票日期")] + public DateTime? MakeDate { set; get; } + /// /// 供应商代码 /// @@ -305,28 +312,28 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos /// [Display(Name = "价格")] [ImporterHeader(Name = "价格")] - public decimal Price { set; get; } + public decimal? Price { set; get; } /// /// 金额 /// [Display(Name = "金额")] [ImporterHeader(Name = "金额")] - public decimal Amount { set; get; } + public decimal? Amount { set; get; } /// /// 税额 /// [Display(Name = "税额")] [ImporterHeader(Name = "税额")] - public decimal Tallage { set; get; } + public decimal? Tallage { set; get; } /// /// 价税合计 /// [Display(Name = "价税合计")] [ImporterHeader(Name = "价税合计")] - public decimal Total { set; get; } + public decimal? Total { set; get; } /// /// 协议编号 @@ -368,7 +375,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [Display(Name = "Material")] [Required(ErrorMessage = "{0}不能为空")] [ImporterHeader(Name = "Material")] - public string PartCode { get; set; } + public string LU { get; set; } /// /// 生产号 @@ -392,6 +399,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos [ImporterHeader(Name = "External Delivery ID")] [Required(ErrorMessage = "{0}不能为空")] public string GroupNum { get; set; } + + /// + /// Supplier + /// + [Display(Name = "Supplier")] + [ImporterHeader(Name = "Supplier")] + public string Supplier { get; set; } } /// 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 9ff57b96..4d2d1422 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 @@ -112,9 +112,9 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase /// 导入 /// [HttpPost] - public async Task ImportByBusinessTypeAsync([FromForm] PUB_SAImportRequestDto pubSaImportRequestDto) + public async Task ImportAsync([FromForm] PUB_SAImportRequestDto pubSaImportRequestDto) { - IActionResult result = new JsonResult(null); + IActionResult result = new JsonResult(new { Code = 400 }); _version = pubSaImportRequestDto.Version; switch (pubSaImportRequestDto.BusinessType) { @@ -288,11 +288,16 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase var importPubSaDetails = ObjectMapper.Map, List>(importResults); #endregion + if (!importPubSaDetails.Any()) + { + return new JsonResult(new { Code = 200, Message = "导入成功" }); + } + #region 数据校验 var checkList = await CheckAsync(importPubSaDetails).ConfigureAwait(false); if (checkList.Count > 0) { - string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); ; + string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); } #endregion @@ -318,6 +323,11 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase var importPubSaDetails = ObjectMapper.Map, List>(importResults); #endregion + if (!importPubSaDetails.Any()) + { + return new JsonResult(new { Code = 200, Message = "导入成功" }); + } + #region 数据校验 var checkList = await CheckAsync(importPubSaDetails); if (checkList.Count > 0) @@ -347,6 +357,11 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase var importPubSaDetails = ObjectMapper.Map, List>(importResults); #endregion + if (!importPubSaDetails.Any()) + { + return new JsonResult(new { Code = 200, Message = "导入成功" }); + } + #region 数据校验 var checkList = await CheckAsync(importPubSaDetails); if (checkList.Count > 0) @@ -370,6 +385,11 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase var importPubSaDetails = ObjectMapper.Map, List>(importResults); #endregion + if (!importPubSaDetails.Any()) + { + return new JsonResult(new { Code = 200, Message = "导入成功" }); + } + #region 数据校验 var checkList = await CheckAsync(importPubSaDetails).ConfigureAwait(false); if (checkList.Count > 0) @@ -390,11 +410,17 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase #region 导入数据转换 ExportImporter _exportImporter = new ExportImporter(); var importResults = await _exportImporter.UploadExcelImport(files, _excelImportService); + importResults = importResults.FindAll(t => t.Supplier == "15663496"); var importPubSaDetails = ObjectMapper.Map, List>(importResults); #endregion + if (!importPubSaDetails.Any()) + { + return new JsonResult(new { Code = 200, Message = "导入成功" }); + } + #region 数据校验 - var checkList = await CheckAsync(importPubSaDetails).ConfigureAwait(false); + var checkList = await CheckAsync(importPubSaDetails).ConfigureAwait(false); if (checkList.Count > 0) { string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); @@ -463,7 +489,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase //导入的零件号集合 var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct(); - var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); ; + var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); /* diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SE_DETAIL.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SE_DETAIL.cs index 3dc4d02e..2a875296 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SE_DETAIL.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SE_DETAIL.cs @@ -263,4 +263,10 @@ public class BBAC_SE_DETAIL:SE_BASE { } + + public BBAC_SE_DETAIL SetQty(decimal qty) + { + this.Qty = qty; + return this; + } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SE_EDI.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SE_EDI.cs index b152d1ad..4aa313eb 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SE_EDI.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SE_EDI.cs @@ -74,5 +74,9 @@ public class BBAC_SE_EDI:FullAuditedAggregateRoot Extend4 = extend4; } - + public BBAC_SE_EDI SetQty(decimal qty) + { + this.Qty = qty; + return this; + } } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACEdiSeCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACEdiSeCompareExportService.cs index 1f281c73..2c158994 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACEdiSeCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACEdiSeCompareExportService.cs @@ -1,11 +1,9 @@ using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; using System.Linq.Dynamic.Core; using Magicodes.ExporterAndImporter.Excel; using Microsoft.AspNetCore.SignalR; -using Microsoft.Extensions.DependencyInjection; using SettleAccount.Domain.BQ; using SettleAccount.Job.SignalR; using Shouldly; @@ -16,8 +14,6 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.ObjectMapping; using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.SettleAccount; -using Win.Sfs.SettleAccount.Entities.BQ; -using Win.Sfs.SettleAccount.Enums; using Win.Sfs.SettleAccount.Reports; namespace SettleAccount.Job.Services.Report @@ -74,22 +70,122 @@ namespace SettleAccount.Job.Services.Report var seEndDateTime = property.Where(p => p.Name == "SeEndDateTime").FirstOrDefault().Value; //有EDI的发运数据 - var haveEidSes = _settleAccountDbContext.Set().Where(t => t.IsHaveEdiData == true); + // var haveEidSesGroup = _settleAccountDbContext.Set().Where(t => t.IsHaveEdiData == true).GroupBy(t => new { t.PN, t.LU }).Select(t => + //t.First().SetQty(t.Sum(q => q.Qty))).ToList(); + var seDetailGroup = _settleAccountDbContext.Set().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU }).ToList(); + + // var haveEidSesGroup = _settleAccountDbContext.Set().Where(t => t.IsHaveEdiData == true).GroupBy(t => new { t.PN, t.LU }).Select(t => + //t.FirstOrDefault()).ToList(); + + var dddd = new JisBBACEidSeCompareExport() + { + Category = default, + WmsBillNum = default, + CarModeCode = default, + LineStationcode = default, + SequenceNumber = default, + ParType = default, + MESConfigCode = default, + ShippingDate = default, + PN = default, + 序列号 = default, + PJIS日顺序号 = default, + MaterialNumber = default, + MaterialDes = default, + SEQty = default, + EdiQty = default, + DiffQty = default, + AssemblyDate = default, + MatchNumber = default, + InjectionCode = default, + MateType = default, + DiffDesc = default + }; + + var haveEidSesGroup = _settleAccountDbContext.Set().Where(t => t.IsHaveEdiData == true).GroupBy(t => new { t.PN, t.LU }).Select(t => new JisBBACEidSeCompareExport() + { + Category = default, + WmsBillNum = default, + CarModeCode = default, + LineStationcode = default, + SequenceNumber = default, + ParType = default, + MESConfigCode = default, + ShippingDate = default, + PN = default, + 序列号 = default, + PJIS日顺序号 = default, + MaterialNumber = default, + MaterialDes = default, + SEQty = default, + EdiQty = default, + DiffQty = default, + AssemblyDate = default, + MatchNumber = default, + InjectionCode = default, + MateType = default, + DiffDesc = default + }).ToList(); + + var haveEidSesGroup22 = _settleAccountDbContext.Set().Where(t => t.IsHaveEdiData == true)?.GroupBy(t => new { t.PN, t.LU }).Select(t => +t.FirstOrDefault()).ToList(); + //有发运的EDI数据 - //var haveSeEids = _settleAccountDbContext.Set().Where(t => t.IsDeleted == false && t.IsHaveSeData == true && haveEidSes.Select(t => new { t.PN, t.LU }).Contains(new { t.PN, t.LU })); - var haveSeEids = _settleAccountDbContext.Set().Where(t => t.IsDeleted == false && t.IsHaveSeData == true).Join(haveEidSes, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (edi, se) => edi); - //无EDI的发运数据 - var notHaveEidSes = _settleAccountDbContext.Set().Where(t => t.IsHaveEdiData == false); - //无发运的EDI数据 - var notHaveSeEids = _settleAccountDbContext.Set().Where(t => t.IsDeleted == false && t.IsHaveSeData == false); - - //有EDI有发运 - var haveEdiHaveSes = haveEidSes.ToList(); - var dsdddd = haveSeEids.ToList(); - //有EDI无发运 - var haveEdiNotHaveSes = notHaveEidSes.ToList(); - //无EDI有发运 - var notHaveEdiHaveSes = notHaveSeEids.ToList(); + //var haveSeEidsGroup = _settleAccountDbContext.Set().Where(t => t.IsDeleted == false && t.IsHaveSeData == true).GroupBy(t => new { t.PN, t.LU }).Select(t => t.First().SetQty(t.Sum(q => q.Qty))).ToList(); + //var haveSeEidsGroup = _settleAccountDbContext.Set().Where(t => t.IsDeleted == false && t.IsHaveSeData == true).GroupBy(t => new { t.PN, t.LU }).Select(t => t.First()).ToList(); + + //var haveEidHaveSes = from se in haveEidSesGroup + // join edi in haveSeEidsGroup + // on new { se.PN, se.LU } equals new { edi.PN, edi.LU } + // select new JisBBACEidSeCompareExport() + // { + // Category = default, + // WmsBillNum = default, + // CarModeCode = default, + // LineStationcode = default, + // SequenceNumber = default, + // ParType = default, + // MESConfigCode = default, + // ShippingDate = default, + // PN = default, + // 序列号 = default, + // PJIS日顺序号 = default, + // MaterialNumber = default, + // MaterialDes = default, + // SEQty = default, + // EdiQty = default, + // DiffQty = default, + // AssemblyDate = default, + // MatchNumber = default, + // InjectionCode = default, + // MateType = default, + // DiffDesc = default + // }; + + ////无EDI的发运数据 + //var notHaveEidSes = _settleAccountDbContext.Set().Where(t => t.IsHaveEdiData == false); + ////无发运的EDI数据 + //var notHaveSeEids = _settleAccountDbContext.Set().Where(t => t.IsDeleted == false && t.IsHaveSeData == false); + + //var jisBBACEidSeCompareExports = new List(); + ////有EDI无发运 + //var haveEdiNotHaveSeCompareExports = haveEidHaveSes.ToList(); + ////无EDI有发运 + //var notHaveEdiHaveSeCompareExports = haveEidHaveSes.ToList(); + + //ExcelExporter excelExporter = new ExcelExporter(); + //excelExporter + // .Append(haveEdiNotHaveSeCompareExports, $"BBACEDI数据和发货对比") + // .SeparateBySheet() + // .Append(notHaveEdiHaveSeCompareExports, $"BBAC发货和EDI数据对比") + // .SeparateBySheet(); + + //var result = excelExporter.ExportAppendDataAsByteArray(); + //result.ShouldNotBeNull(); + ////_fileContainer.SaveAsync(filename, result.Result, true); + + //Notify(); + return id.ToString(); var ids = id.ToString(); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs index f6349073..ac93419d 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs @@ -8,9 +8,20 @@ namespace SettleAccount.Job { public SettleAccountJobAutoMapperProfile() { + CreateMapBBACEdiSeCompare(); CreateMapPubSaSeCompare(); } + /// + /// BBAC EDI与发运对比 + /// + public void CreateMapBBACEdiSeCompare() + { + //CreateMap() + // .ForMember(x => x.ReplaceLU, y => y.MapFrom(y => y.ReplaceLU)); + + } + /// /// Pub结算与发运对比 ///