diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/bei-jian.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/bei-jian.js index 027a40c6..aa02e8a0 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/bei-jian.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/bei-jian.js @@ -24,7 +24,7 @@ const schema = { }, date: { title: "合同签订时间", - type: "DateTime", + type: "string", }, contractNo: { title: "合同号", diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/xiao-shou.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/xiao-shou.js index 17fb8522..8bcd6d6d 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/xiao-shou.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/base-data/xiao-shou.js @@ -27,7 +27,7 @@ const schema = { date: { title: "合同签订时间", type: "string", - input: "datetime", + input: "string", }, contractNo: { title: "合同号", diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SA_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SA_DTO.cs index be39022a..2924d546 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SA_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SA_DTO.cs @@ -86,7 +86,7 @@ public class BBAC_SA_DETAIL_DTO : EntityDto /// /// 结算日期 /// - public DateTime SettleDate { set; get; } + public string SettleDate { set; get; } /// /// 单价 /// diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_SA_DTO.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_SA_DTO.cs index 9ef68a97..4f5ce291 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_SA_DTO.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_SA_DTO.cs @@ -86,7 +86,7 @@ public class HBPO_SA_DETAIL_DTO : EntityDto /// /// 结算日期 /// - public DateTime SettleDate { set; get; } + public string SettleDate { set; get; } /// /// 单价 /// 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 bd73ae49..e805ef29 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 @@ -447,7 +447,7 @@ public class PUB_SA_DETAIL_DTO : AuditedAggregateRoot /// /// 结算日期 /// - public DateTime SettleDate { set; get; } + public string SettleDate { set; get; } /// /// 单价 /// 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 1e83bb59..15b30dd3 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 @@ -414,6 +414,18 @@ public class TB_PRICE_LISTDto : AuditedEntityDto /// [Display(Name = "版本")] public string Version { set; get; } + + /// + /// 合同签订时间 + /// + [Display(Name = "合同签订时间")] + public string Date { get; set; } + + /// + /// 合同号 + /// + [Display(Name = "合同号")] + public string ContractNo { 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 dda887ca..ba69f89a 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 @@ -231,15 +231,15 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase public async Task DeleteListAsync(List ids) { //结算主表 - List pubSas = new List(); + var pubSas = new List(); //结算明细 - List pubSaDetails = new List(); + var pubSaDetails = new List(); //可结算主表 - List pubCanSas = new List(); + var pubCanSas = new List(); //可结算明细 - List pubCanSaDetails = new List(); + var pubCanSaDetails = new List(); //不可结算 - List pubNotSaDetails = new List(); + var pubNotSaDetails = new List(); foreach (var id in ids) { @@ -649,18 +649,17 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase private async Task<(List pubSas, List pubSaDetails, List pubCanSas, List pubCanSaDetails, List pubNotSaDetails)> GetPubSaDelItemsAsync(Guid id) { //结算主表 - List pubSas = new List(); + var pubSas = new List(); //结算明细 - List pubSaDetails = new List(); + var pubSaDetails = new List(); //可结算主表 - List pubCanSas = new List(); + var pubCanSas = new List(); //可结算明细 - List pubCanSaDetails = new List(); + var pubCanSaDetails = new List(); //不可结算 - List pubNotSaDetails = new List(); + var pubNotSaDetails = new List(); - var pubSaEntity = await _repository.FirstOrDefaultAsync(t => t.Id.Equals(id)).ConfigureAwait(false); - //var pubSaEntity = await _repository.FindAsync(id).ConfigureAwait(false); + var pubSaEntity = await _repository.FindAsync(id).ConfigureAwait(false); if (pubSaEntity != null) { //结算单据 diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs index 3a9f674f..053ef7f3 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs @@ -174,150 +174,5 @@ public class PriceListAppService : SettleAccountApplicationBase return await _priceListManager.DeleteListAsync(ids); } #endregion - #region 原方法(废弃) - // /// - // /// 获取总数 - // /// - // private async Task GetCountAsync(PriceListRequestDto input) - // { - // return await _priceListManager.GetCountAsync(input.Filters, GuidGenerator.Create()); - // } - - - // /// - // /// 结算总成和ERP总成价格对比 - // /// - // /// 上传的文件(前端已经限制只能上传一个附件) - // /// - // [HttpGet] - // [Route("BomDiffPrice-Make")] - // [DisableRequestSizeLimit] - // [Authorize(SettleAccountPermissions.PriceLists.Default)] - - // public async Task SettledPartAndErpPartPriceDiffMake(string version, string customerCode) - // { - - // List customConditionList = new List(); - - // customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "Bom定价差异明细" }); - // customConditionList.Add(new CustomCondition() { Name = "Version", Value = string.IsNullOrEmpty(version) ? string.Empty : version }); - // customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = string.IsNullOrEmpty(customerCode) ? string.Empty : customerCode }); - - // var _taskid = await _service.ExportEnqueueAsync("Bom定价差异明细", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(SettledPartAndErpPartPriceDiffExportService), customConditionList, (rs) => - // { - - // }); - // return _taskid; - // } - - // [HttpPost] - // [Route("job/list")] - // [Authorize(SettleAccountPermissions.PriceLists.Default)] - // [UnitOfWork(false)] - // virtual public async Task> GetListAsync(JobRequestDto input) - // { - // return await _service.GetListAsync(input); - // } - - // /// - // /// 按ID获取唯一实体 - // /// - // /// - // /// 返回实体全部属性 - // /// - // /// ID - // /// 实体DTO - - // [HttpGet] - // [Route("{id}")] - // /// [Authorize(SettleAccountPermissions.PriceLists.Default)] - // virtual public async Task GetAsync(Guid id) - // { - // var result = await _priceListManager.GetAsync(id); ; - // var dto = ObjectMapper.Map(result); - // return dto; - - // } - - - - - - // /// - // /// 根据筛选条件获取实体列表 - // /// - // /// - // /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码 - // /// - // /// 请求条件 - // /// 实体DTO列表 - // [HttpPost] - // [Route("versionlist")] - //// [Authorize(SettleAccountPermissions.PriceLists.Default)] - // virtual public async Task> GetVersionListAsync(PriceListRequestDto input) - // { - - - // var entities = await _priceListManager.GetVersionListAsync(input.Filters, input.Sorting, input.MaxResultCount,input.SkipCount); - // var totalCount = await GetCountAsync(input); - // var dtos = ObjectMapper.Map, List>(entities); - // return new PagedResultDto(totalCount, dtos); - // } - - - - - - - // /// - // /// 获取实体总数 - // /// - // /// 实体总数 - // [HttpGet] - // [Route("count")] - // //[Authorize(SettleAccountPermissions.PriceLists.Default)] - // virtual public async Task GetTotalCountAsync(Guid branchId) - // { - // return await _priceListManager.GetCountAsync(new List(), branchId); - // } - - // /// - // /// 获取全部实体列表 - // /// - // /// 实体DTO列表 - // [HttpGet] - // [Route("all")] - // //[Authorize(SettleAccountPermissions.PriceLists.Default)] - // virtual public async Task> GetAllAsync(Guid branchId) - // { - // var entities = await _priceListManager.GetAllAsync(branchId); - // var dtos = ObjectMapper.Map, List>(entities); - // return new ListResultDto(dtos); - // } - - - // /// - // /// 修改实体 - // /// - // /// ID - // /// 修改实体DTO - // /// 实体DTO - // [HttpPut] - // [Route("{id}")] - // [Authorize(SettleAccountPermissions.PriceLists.Update)] - // virtual public async Task UpdateAsync(Guid id, PriceListDto input) - // { - // var entity = new PriceList( - - // ); - - // var _ent = await _priceListManager.UpdateAsync(id, entity); - - - // var dto = ObjectMapper.Map(_ent); - // return dto; - // } - #endregion - } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs index 26d0c106..23e97577 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs @@ -542,7 +542,8 @@ namespace Win.Sfs.SettleAccount /// private void CreateMapPriceList() { - CreateMap(); + CreateMap() + .ForMember(x => x.Date, y => y.MapFrom(d => d.Date.ToString("yyyy-MM-dd"))); CreateMap() .ForMember(x => x.LU, y => y.MapFrom(y => y.PartNo)) .ForMember(x => x.Price, y => y.MapFrom(y => y.TotalPrice)) @@ -1016,7 +1017,8 @@ namespace Win.Sfs.SettleAccount /// private void CreateMapBBAC_SA_DETAIL() { - CreateMap(); + CreateMap() + .ForMember(x => x.SettleDate, y => y.MapFrom(d => d.SettleDate.ToString("yyyy-MM-dd"))); CreateMap() .ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum)); CreateMap() @@ -1057,7 +1059,8 @@ namespace Win.Sfs.SettleAccount /// private void CreateMapHBPO_SA_DETAIL() { - CreateMap(); + CreateMap() + .ForMember(x => x.SettleDate, y => y.MapFrom(d => d.SettleDate.ToString("yyyy-MM-dd"))); CreateMap() .ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum)); CreateMap() @@ -1089,8 +1092,8 @@ namespace Win.Sfs.SettleAccount /// private void CreateMapPUB_SA_DETAIL() { - - CreateMap(); + CreateMap() + .ForMember(x => x.SettleDate, y => y.MapFrom(d => d.SettleDate.ToString("yyyy-MM-dd"))); CreateMap() .ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum)); CreateMap() diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisHBPOEidSeCompareReport.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisHBPOEidSeCompareReport.cs new file mode 100644 index 00000000..a5df9a65 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisHBPOEidSeCompareReport.cs @@ -0,0 +1,165 @@ +using System; +using System.ComponentModel.DataAnnotations; +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; + +namespace Win.Sfs.SettleAccount.Reports; + +/// +/// JisHBPO Edi与发运对比 +/// +public class JisHBPOEidSeCompareReport +{ +} + +/// +/// JisHBPO Edi与发运对比导出 +/// +[ExcelExporter(MaxRowNumberOnASheet = 900000)] +public class JisHBPOEidSeCompareExport +{ + /// + /// 类别 + /// + [Display(Name = "类别")] + [ExporterHeader(DisplayName = "类别")] + public string Category { get; set; } + /// + /// 交货单号 + /// + [Display(Name = "交货单号")] + [ExporterHeader(DisplayName = "交货单号")] + public string WmsBillNum { get; set; } + /// + /// CarModeCode + /// + [Display(Name = "CarModeCode")] + [ExporterHeader(DisplayName = "CarModeCode")] + public string CarModeCode { get; set; } + /// + /// LineStationcode + /// + [Display(Name = "LineStationcode")] + [ExporterHeader(DisplayName = "LineStationcode")] + public string LineStationcode { get; set; } + /// + /// SequenceNumber + /// + [Display(Name = "SequenceNumber")] + [ExporterHeader(DisplayName = "SequenceNumber")] + public string SequenceNumber { get; set; } + /// + /// ParType + /// + [Display(Name = "ParType")] + [ExporterHeader(DisplayName = "ParType")] + public string ParType { get; set; } + /// + /// 配置码 + /// + [Display(Name = "配置码")] + [ExporterHeader(DisplayName = "配置码")] + public string MESConfigCode { get; set; } + /// + /// 发货日期 + /// + [Display(Name = "发货日期")] + [ExporterHeader(DisplayName = "发货日期", Format = "yyyy-MM-dd")] + public DateTime? ShippingDate { get; set; } + /// + /// 实际发货生产号 + /// + [Display(Name = "实际发货生产号")] + [ExporterHeader(DisplayName = "实际发货生产号")] + public string RealCode { get; set; } + /// + /// 生产码 + /// + [Display(Name = "生产码")] + [ExporterHeader(DisplayName = "生产码")] + public string PN { get; set; } + /// + /// 序列号 + /// + [Display(Name = "序列号")] + [ExporterHeader(DisplayName = "序列号")] + public string Seq { get; set; } + /// + /// PJIS日顺序号 + /// + [Display(Name = "PJIS日顺序号")] + [ExporterHeader(DisplayName = "PJIS日顺序号")] + public string PjsNum { get; set; } + /// + /// WMS目标库位 + /// + [Display(Name = "WMS目标库位")] + [ExporterHeader(DisplayName = "WMS目标库位")] + public string ToLoc { get; set; } + /// + /// ERP目标库位 + /// + [Display(Name = "ERP目标库位")] + [ExporterHeader(DisplayName = "ERP目标库位")] + public string ErpToLoc { get; set; } + /// + /// 物料号 + /// + [Display(Name = "物料号")] + [ExporterHeader(DisplayName = "物料号")] + public string MaterialNumber { get; set; } + /// + /// 物料描述 + /// + [Display(Name = "物料描述")] + [ExporterHeader(DisplayName = "物料描述")] + public string MaterialDes { get; set; } + /// + /// WMS发货数量 + /// + [Display(Name = "WMS发货数量")] + [ExporterHeader(DisplayName = "WMS发货数量")] + public decimal SEQty { get; set; } + /// + /// EDI数量 + /// + [Display(Name = "EDI数量")] + [ExporterHeader(DisplayName = "EDI数量")] + public decimal EdiQty { get; set; } + /// + /// WMS发货与EDI数量差 + /// + [Display(Name = "WMS发货与EDI数量差")] + [ExporterHeader(DisplayName = "WMS发货与EDI数量差")] + public decimal DiffQty => SEQty - EdiQty; + /// + /// 客户下线时间 + /// + [Display(Name = "客户下线时间")] + [ExporterHeader(DisplayName = "客户下线时间")] + public DateTime? AssemblyDate { get; set; } + /// + /// 小总成号 + /// + [Display(Name = "小总成号")] + [ExporterHeader(DisplayName = "小总成号")] + public string MatchNumber { get; set; } + /// + /// 注塑码 + /// + [Display(Name = "注塑码")] + [ExporterHeader(DisplayName = "注塑码")] + public string InjectionCode { get; set; } + /// + /// 是否完全匹配 + /// + [Display(Name = "是否完全匹配")] + [ExporterHeader(DisplayName = "是否完全匹配")] + public string MateType { get; set; } + /// + /// 差异说明 + /// + [Display(Name = "差异说明")] + [ExporterHeader(DisplayName = "差异说明")] + public string DiffDesc { get; set; } +} 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 301fb464..99b7bb55 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 @@ -27,19 +27,12 @@ namespace SettleAccount.Job.Services.Report /// HubContext /// private readonly IHubContext _hubContext; - /// /// 文件容器 /// private readonly IBlobContainer _fileContainer; - - /// - /// AutoMapper - /// - private readonly IObjectMapper _objectMapper; - /// - /// AutoMapper + /// DbContext /// private readonly SettleAccountDbContext _settleAccountDbContext; @@ -54,7 +47,6 @@ namespace SettleAccount.Job.Services.Report { _hubContext = hubContext; _fileContainer = fileContainer; - _objectMapper = objectMapper; _settleAccountDbContext = settleAccountDbContext; } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOEdiSeCompareExportService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOEdiSeCompareExportService.cs index d18eadd5..ec4159ac 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOEdiSeCompareExportService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOEdiSeCompareExportService.cs @@ -1,11 +1,18 @@ using System; using System.Collections.Generic; +using System.Linq; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.SignalR; +using SettleAccount.Domain.BQ; +using SettleAccount.Job.SignalR; +using Shouldly; using TaskJob.EventArgs; using TaskJob.Interfaces; using Volo.Abp.BlobStoring; using Volo.Abp.DependencyInjection; -using Volo.Abp.ObjectMapping; using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount; +using Win.Sfs.SettleAccount.Reports; namespace SettleAccount.Job.Services.Report { @@ -14,25 +21,28 @@ namespace SettleAccount.Job.Services.Report /// public class JisHBPOEdiSeCompareExportService : ITransientDependency, IExportJob { + /// + /// HubContext + /// + private readonly IHubContext _hubContext; /// /// 文件容器 /// private readonly IBlobContainer _fileContainer; - /// - /// AutoMapper + /// DbContext /// - private readonly IObjectMapper _objectMapper; + private readonly SettleAccountDbContext _settleAccountDbContext; /// /// 构造 /// public JisHBPOEdiSeCompareExportService( IBlobContainer fileContainer, - IObjectMapper objectMapper) + SettleAccountDbContext settleAccountDbContext) { _fileContainer = fileContainer; - _objectMapper = objectMapper; + _settleAccountDbContext = settleAccountDbContext; } /// @@ -40,7 +50,134 @@ namespace SettleAccount.Job.Services.Report /// public string ExportFile(Guid id, List exportName, List property) { - return ""; + var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value; + var lu = property.Where(p => p.Name == "LU").FirstOrDefault().Value; + var pn = property.Where(p => p.Name == "PN").FirstOrDefault().Value; + var strSeStartDateTime = property.Where(p => p.Name == "SeStartDateTime").FirstOrDefault().Value; + var strSeEndDateTime = property.Where(p => p.Name == "SeEndDateTime").FirstOrDefault().Value; + + var seStartDateTime = DateTime.Parse(strSeStartDateTime); + var seEndDateTime = DateTime.Parse(strSeEndDateTime); + var filename = exportName.FirstOrDefault(); + + //有EDI无发运 + var haveEdiNotHaveSeList = _settleAccountDbContext.Set().Where(t => t.IsHaveSeData == false) + .GroupBy(t => new { t.LU, t.PN }) + .Select(t => new JisHBPOEidSeCompareExport() + { + Category = "JIS", + CarModeCode = default, + LineStationcode = default, + SequenceNumber = t.Max(t => t.SeqNumber), + ParType = "01", + EdiQty = t.Sum(t => t.Qty), + AssemblyDate = default, + MatchNumber = default, + MateType = "否", + DiffDesc = "WMS漏发货EDI有订单" + }).ToList(); + //无EDI有发运 + var notHaveEdiHaveSeList = _settleAccountDbContext.Set().Where(t => t.IsHaveEdiData == false) + .GroupBy(t => new { t.LU, t.PN }) + .Select(t => new JisHBPOEidSeCompareExport() + { + Category = "JIS", + WmsBillNum = t.Max(t => t.BillNum), + MESConfigCode = t.Max(t => t.MESConfigCode), + ShippingDate = t.Max(t => t.BillTime), + PN = t.Max(t => t.PN), + Seq = t.Max(t => t.Seq), + PjsNum = t.Max(t => t.PjsNum), + ToLoc = t.Max(t => t.ToLoc), + ErpToLoc = t.Max(t => t.ErpToLoc), + MaterialNumber = t.Max(t => t.CustPartCode), + MaterialDes = t.Max(t => t.PartDesc), + SEQty = t.Sum(t => t.Qty), + InjectionCode = t.Max(t => t.InjectionCode), + MateType = "否", + DiffDesc = "WMS有发货EDI无订单" + }).ToList(); + //有EDI有发运 + var ediGroup = from edi in _settleAccountDbContext.Set() + where edi.IsDeleted == false && edi.IsHaveSeData == true + group edi by new { edi.PN, edi.LU } into groupItem + select new + { + groupItem.Key.PN, + groupItem.Key.LU, + Qty = groupItem.Sum(t => t.Qty), + SeqNumber = groupItem.Max(t => t.SeqNumber) + }; + var seGroup = from se in _settleAccountDbContext.Set() + where se.IsHaveEdiData == true && se.AssembleData >= seStartDateTime && se.AssembleData <= seEndDateTime + group se by new { se.PN, se.LU } into groupItem + select new + { + groupItem.Key.PN, + groupItem.Key.LU, + Qty = groupItem.Sum(t => t.Qty), + BillNum = groupItem.Max(t => t.BillNum), + MESConfigCode = groupItem.Max(t => t.MESConfigCode), + BillTime = groupItem.Max(t => t.BillTime), + Seq = groupItem.Max(t => t.Seq), + PjsNum = groupItem.Max(t => t.PjsNum), + ToLoc = groupItem.Max(t => t.ToLoc), + ErpToLoc = groupItem.Max(t => t.ErpToLoc), + CustPartCode = groupItem.Max(t => t.CustPartCode), + PartDesc = groupItem.Max(t => t.PartDesc), + InjectionCode = groupItem.Max(t => t.InjectionCode) + }; + var haveEdiHaveSeList = (from edi in ediGroup + join se in seGroup + on new { edi.PN, edi.LU } equals new { se.PN, se.LU } + select new JisHBPOEidSeCompareExport() + { + Category = "JIS", + WmsBillNum = se.BillNum, + CarModeCode = default, + LineStationcode = default, + SequenceNumber = edi.SeqNumber, + ParType = "01", + MESConfigCode = se.MESConfigCode, + ShippingDate = se.BillTime, + PN = se.PN, + Seq = se.Seq, + PjsNum = se.PjsNum, + ToLoc = se.ToLoc, + ErpToLoc = se.ErpToLoc, + MaterialNumber = se.CustPartCode, + MaterialDes = se.PartDesc, + SEQty = se.Qty, + EdiQty = edi.Qty, + AssemblyDate = default, + MatchNumber = default, + InjectionCode = se.InjectionCode, + MateType = se.Qty == edi.Qty ? "是" : "否", + DiffDesc = "WMS有发货EDI有订单" + }).ToList(); + + haveEdiNotHaveSeList.AddRange(haveEdiHaveSeList); + notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList); + + ExcelExporter excelExporter = new ExcelExporter(); + excelExporter + .Append(haveEdiNotHaveSeList, $"HBPOEDI数据和发货对比") + .SeparateBySheet() + .Append(notHaveEdiHaveSeList, $"HBPO发货和EDI数据对比"); + + var result = excelExporter.ExportAppendDataAsByteArray(); + result.ShouldNotBeNull(); + _fileContainer.SaveAsync(filename, result.Result, true); + + Notify(); + return id.ToString(); + } + + #region 私有方法 + private void Notify() + { + this._hubContext.Clients.All.ServerToClient("SaSeCompare", "refresh", ""); } + #endregion } }