mahao
1 year ago
16 changed files with 935 additions and 220 deletions
@ -0,0 +1,111 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.OpenApi.Extensions; |
|||
using SettleAccount.Job.Services.Report; |
|||
using TaskJob.EventArgs; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Services; |
|||
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
|||
using Win.Sfs.SettleAccount.Entities.TaskJobs; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Entities.BQ; |
|||
|
|||
/// <summary>
|
|||
/// 对比服务
|
|||
/// </summary>
|
|||
[AllowAnonymous] |
|||
[Route("api/settleaccount/[controller]/[action]")]
|
|||
public class CompareService : ApplicationService |
|||
{ |
|||
/// <summary>
|
|||
/// 任务服务
|
|||
/// </summary>
|
|||
private readonly TaskJobService _taskJobService; |
|||
|
|||
public CompareService(TaskJobService taskJobService) |
|||
{ |
|||
_taskJobService = taskJobService; |
|||
} |
|||
|
|||
#region Edi与发运比对
|
|||
/// <summary>
|
|||
/// Edi与发运比对
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
public async Task<string> EdiSeCompare(EdiSeCompareRequestDto ediSeCompareRequestDto) |
|||
{ |
|||
var businessTypeDisplayName = ediSeCompareRequestDto.BusinessType.ToString(); |
|||
var attributeOfType = ediSeCompareRequestDto.BusinessType.GetAttributeOfType<DisplayAttribute>(); |
|||
if (attributeOfType != null) |
|||
{ |
|||
businessTypeDisplayName = attributeOfType.Name; |
|||
} |
|||
var projectName = $"{businessTypeDisplayName}EDI与发运数据对比"; |
|||
|
|||
var customConditionList = new List<CustomCondition>(); |
|||
customConditionList.Add(new CustomCondition() { Name = "Version", Value = ediSeCompareRequestDto.Version }); |
|||
customConditionList.Add(new CustomCondition() { Name = "LU", Value = ediSeCompareRequestDto.LU }); |
|||
customConditionList.Add(new CustomCondition() { Name = "PN", Value = ediSeCompareRequestDto.PN }); |
|||
customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = projectName }); |
|||
customConditionList.Add(new CustomCondition() { Name = "SeStartDateTime", Value = ediSeCompareRequestDto.SeStartDateTime?.ToString("yyyy-MM-dd 00:00:00") }); |
|||
customConditionList.Add(new CustomCondition() { Name = "SeEndDateTime", Value = ediSeCompareRequestDto.SeEndDateTime?.ToString("yyyy-MM-dd 23:59:59") }); |
|||
|
|||
var jobMoudle = ediSeCompareRequestDto.BusinessType switch |
|||
{ |
|||
EnumBusinessType.JisBBAC => typeof(JisBBACEdiSeCompareExportService), |
|||
EnumBusinessType.JisHBPO => typeof(JisHBPOEdiSeCompareExportService), |
|||
_ => throw new NotImplementedException() |
|||
}; |
|||
|
|||
var _taskid = await _taskJobService.ExportEnqueueAsync(projectName, ExportExtentsion.Excel, ediSeCompareRequestDto.Version, string.Empty, CurrentUser, jobMoudle, customConditionList, (rs) => |
|||
{ |
|||
}).ConfigureAwait(false); |
|||
return _taskid; |
|||
} |
|||
#endregion
|
|||
|
|||
#region 结算与发运比对
|
|||
/// <summary>
|
|||
/// 结算与发运比对
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
public async Task<string> SaSeCompare(SaSeCompareRequestDto saSeCompareRequestDto) |
|||
{ |
|||
var businessTypeDisplayName = saSeCompareRequestDto.BusinessType.ToString(); |
|||
var attributeOfType = saSeCompareRequestDto.BusinessType.GetAttributeOfType<DisplayAttribute>(); |
|||
if (attributeOfType != null) |
|||
{ |
|||
businessTypeDisplayName = attributeOfType.Name; |
|||
} |
|||
var projectName = $"{businessTypeDisplayName}结算与发运数据对比"; |
|||
|
|||
var customConditionList = new List<CustomCondition>(); |
|||
customConditionList.Add(new CustomCondition() { Name = "Version", Value = saSeCompareRequestDto.Version }); |
|||
customConditionList.Add(new CustomCondition() { Name = "LU", Value = saSeCompareRequestDto.LU }); |
|||
customConditionList.Add(new CustomCondition() { Name = "PN", Value = saSeCompareRequestDto.PN }); |
|||
customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = projectName }); |
|||
customConditionList.Add(new CustomCondition() { Name = "SeStartDateTime", Value = saSeCompareRequestDto.SeStartDateTime?.ToString("yyyy-MM-dd 00:00:00") }); |
|||
customConditionList.Add(new CustomCondition() { Name = "SeEndDateTime", Value = saSeCompareRequestDto.SeEndDateTime?.ToString("yyyy-MM-dd 23:59:59") }); |
|||
|
|||
var jobMoudle = saSeCompareRequestDto.BusinessType switch |
|||
{ |
|||
EnumBusinessType.ZhiGongJianBBAC => typeof(PubSaSeCompareExportService), |
|||
EnumBusinessType.ZhiGongJianHBPO => typeof(PubSaSeCompareExportService), |
|||
EnumBusinessType.MaiDanJianBBAC => typeof(MaiDanBBACSaSeCompareExportService), |
|||
EnumBusinessType.MaiDanJianHBPO => typeof(MaiDanHBPOSaSeCompareExportService), |
|||
EnumBusinessType.BeiJian => typeof(PubSaSeCompareExportService), |
|||
EnumBusinessType.YinDuJian => typeof(PubSaSeCompareExportService), |
|||
_ => throw new UserFriendlyException($"{nameof(saSeCompareRequestDto.BusinessType)}参数值无效", "403") |
|||
}; |
|||
|
|||
var _taskid = await _taskJobService.ExportEnqueueAsync(projectName, ExportExtentsion.Excel, saSeCompareRequestDto.Version, string.Empty, CurrentUser, jobMoudle, customConditionList, (rs) => |
|||
{ |
|||
}).ConfigureAwait(false); |
|||
return _taskid; |
|||
} |
|||
#endregion
|
|||
} |
@ -1,78 +0,0 @@ |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.OpenApi.Extensions; |
|||
using SettleAccount.Job.Services.Report; |
|||
using TaskJob.EventArgs; |
|||
using Volo.Abp.Application.Services; |
|||
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
|||
using Win.Sfs.SettleAccount.Entities.TaskJobs; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Entities.BQ; |
|||
|
|||
/// <summary>
|
|||
/// Edi与发运对比服务
|
|||
/// </summary>
|
|||
[AllowAnonymous] |
|||
[Route("api/settleaccount/[controller]/[action]")]
|
|||
public class EdiSeCompareService : ApplicationService |
|||
{ |
|||
/// <summary>
|
|||
/// 任务服务
|
|||
/// </summary>
|
|||
private readonly TaskJobService _taskJobService; |
|||
|
|||
public EdiSeCompareService(TaskJobService taskJobService) |
|||
{ |
|||
_taskJobService = taskJobService; |
|||
} |
|||
|
|||
#region 对比
|
|||
/// <summary>
|
|||
/// BBACEdi与发运比对
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
public async Task<string> BBACEdiSeCompare(JisEdiSeCompareRequestDto jisEdiSeCompareRequestDto) |
|||
{ |
|||
var projectName = $"JisBBACEDI与发运数据对比"; |
|||
|
|||
List<CustomCondition> customConditionList = new List<CustomCondition>(); |
|||
customConditionList.Add(new CustomCondition() { Name = "Version", Value = jisEdiSeCompareRequestDto.Version }); |
|||
customConditionList.Add(new CustomCondition() { Name = "LU", Value = jisEdiSeCompareRequestDto.LU }); |
|||
customConditionList.Add(new CustomCondition() { Name = "PN", Value = jisEdiSeCompareRequestDto.PN }); |
|||
customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = projectName }); |
|||
customConditionList.Add(new CustomCondition() { Name = "SeStartDateTime", Value = jisEdiSeCompareRequestDto.SeStartDateTime?.ToString("yyyy-MM-dd 00:00:00") }); |
|||
customConditionList.Add(new CustomCondition() { Name = "SeEndDateTime", Value = jisEdiSeCompareRequestDto.SeEndDateTime?.ToString("yyyy-MM-dd 23:59:59") }); |
|||
|
|||
var _taskid = await _taskJobService.ExportEnqueueAsync(projectName, ExportExtentsion.Excel, jisEdiSeCompareRequestDto.Version, string.Empty, CurrentUser, typeof(JisBBACEdiSeCompareExportService), customConditionList, (rs) => |
|||
{ |
|||
}).ConfigureAwait(false); |
|||
return _taskid; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// HBPOEdi与发运比对
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
public async Task<string> HBPOEdiSeCompare(JisEdiSeCompareRequestDto jisEdiSeCompareRequestDto) |
|||
{ |
|||
var projectName = $"JisHBPOEDI与发运数据对比结算与发运数据对比"; |
|||
|
|||
List<CustomCondition> customConditionList = new List<CustomCondition>(); |
|||
customConditionList.Add(new CustomCondition() { Name = "Version", Value = jisEdiSeCompareRequestDto.Version }); |
|||
customConditionList.Add(new CustomCondition() { Name = "LU", Value = jisEdiSeCompareRequestDto.LU }); |
|||
customConditionList.Add(new CustomCondition() { Name = "PN", Value = jisEdiSeCompareRequestDto.PN }); |
|||
customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = projectName }); |
|||
customConditionList.Add(new CustomCondition() { Name = "SeStartDateTime", Value = jisEdiSeCompareRequestDto.SeStartDateTime?.ToString("yyyy-MM-dd 00:00:00") }); |
|||
customConditionList.Add(new CustomCondition() { Name = "SeEndDateTime", Value = jisEdiSeCompareRequestDto.SeEndDateTime?.ToString("yyyy-MM-dd 23:59:59") }); |
|||
|
|||
var _taskid = await _taskJobService.ExportEnqueueAsync(projectName, ExportExtentsion.Excel, jisEdiSeCompareRequestDto.Version, string.Empty, CurrentUser, typeof(JisHBPOEdiSeCompareExportService), customConditionList, (rs) => |
|||
{ |
|||
}).ConfigureAwait(false); |
|||
return _taskid; |
|||
} |
|||
#endregion
|
|||
|
|||
} |
@ -0,0 +1,183 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
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 |
|||
{ |
|||
/// <summary>
|
|||
/// BBAC结算、Edi、发运对比导出服务
|
|||
/// </summary>
|
|||
public class JisBBACSaEdiSeCompareExportService : ITransientDependency, IExportJob |
|||
{ |
|||
/// <summary>
|
|||
/// HubContext
|
|||
/// </summary>
|
|||
private readonly IHubContext<PageHub> _hubContext; |
|||
/// <summary>
|
|||
/// 文件容器
|
|||
/// </summary>
|
|||
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
|||
/// <summary>
|
|||
/// DbContext
|
|||
/// </summary>
|
|||
private readonly SettleAccountDbContext _settleAccountDbContext; |
|||
|
|||
/// <summary>
|
|||
/// 构造
|
|||
/// </summary>
|
|||
public JisBBACSaEdiSeCompareExportService( |
|||
IHubContext<PageHub> hubContext, |
|||
IBlobContainer<MyFileContainer> fileContainer, |
|||
IObjectMapper objectMapper, |
|||
SettleAccountDbContext settleAccountDbContext) |
|||
{ |
|||
_hubContext = hubContext; |
|||
_fileContainer = fileContainer; |
|||
_settleAccountDbContext = settleAccountDbContext; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 导出
|
|||
/// </summary>
|
|||
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) |
|||
{ |
|||
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<BBAC_SE_EDI>().Where(t => t.IsHaveSeData == false) |
|||
.GroupBy(t => new { t.LU, t.PN }) |
|||
.Select(t => new JisBBACEidSeCompareExport() |
|||
{ |
|||
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<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == false) |
|||
.GroupBy(t => new { t.LU, t.PN }) |
|||
.Select(t => new JisBBACEidSeCompareExport() |
|||
{ |
|||
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), |
|||
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<BBAC_SE_EDI>() |
|||
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<BBAC_SE_DETAIL>() |
|||
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), |
|||
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 } |
|||
//where edi.IsDeleted == false && edi.IsHaveSeData == true && se.IsHaveEdiData == true
|
|||
select new JisBBACEidSeCompareExport() |
|||
{ |
|||
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, |
|||
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, $"BBACEDI数据和发货对比") |
|||
.SeparateBySheet() |
|||
.Append(notHaveEdiHaveSeList, $"BBAC发货和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
|
|||
} |
|||
} |
@ -0,0 +1,183 @@ |
|||
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 Win.Sfs.BaseData.ImportExcelCommon; |
|||
using Win.Sfs.SettleAccount; |
|||
using Win.Sfs.SettleAccount.Reports; |
|||
|
|||
namespace SettleAccount.Job.Services.Report |
|||
{ |
|||
/// <summary>
|
|||
/// HBPO结算、Edi、发运对比导出服务
|
|||
/// </summary>
|
|||
public class JisHBPOSaEdiSeCompareExportService : ITransientDependency, IExportJob |
|||
{ |
|||
/// <summary>
|
|||
/// HubContext
|
|||
/// </summary>
|
|||
private readonly IHubContext<PageHub> _hubContext; |
|||
/// <summary>
|
|||
/// 文件容器
|
|||
/// </summary>
|
|||
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
|||
/// <summary>
|
|||
/// DbContext
|
|||
/// </summary>
|
|||
private readonly SettleAccountDbContext _settleAccountDbContext; |
|||
|
|||
/// <summary>
|
|||
/// 构造
|
|||
/// </summary>
|
|||
public JisHBPOSaEdiSeCompareExportService( |
|||
IBlobContainer<MyFileContainer> fileContainer, |
|||
SettleAccountDbContext settleAccountDbContext) |
|||
{ |
|||
_fileContainer = fileContainer; |
|||
_settleAccountDbContext = settleAccountDbContext; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 导出
|
|||
/// </summary>
|
|||
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) |
|||
{ |
|||
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<BBAC_SE_EDI>().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<BBAC_SE_DETAIL>().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<BBAC_SE_EDI>() |
|||
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<BBAC_SE_DETAIL>() |
|||
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
|
|||
} |
|||
} |
@ -0,0 +1,183 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
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 |
|||
{ |
|||
/// <summary>
|
|||
/// 买单件BBAC结算、发运对比导出服务
|
|||
/// </summary>
|
|||
public class MaiDanBBACSaSeCompareExportService : ITransientDependency, IExportJob |
|||
{ |
|||
/// <summary>
|
|||
/// HubContext
|
|||
/// </summary>
|
|||
private readonly IHubContext<PageHub> _hubContext; |
|||
/// <summary>
|
|||
/// 文件容器
|
|||
/// </summary>
|
|||
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
|||
/// <summary>
|
|||
/// DbContext
|
|||
/// </summary>
|
|||
private readonly SettleAccountDbContext _settleAccountDbContext; |
|||
|
|||
/// <summary>
|
|||
/// 构造
|
|||
/// </summary>
|
|||
public MaiDanBBACSaSeCompareExportService( |
|||
IHubContext<PageHub> hubContext, |
|||
IBlobContainer<MyFileContainer> fileContainer, |
|||
IObjectMapper objectMapper, |
|||
SettleAccountDbContext settleAccountDbContext) |
|||
{ |
|||
_hubContext = hubContext; |
|||
_fileContainer = fileContainer; |
|||
_settleAccountDbContext = settleAccountDbContext; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 导出
|
|||
/// </summary>
|
|||
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) |
|||
{ |
|||
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<BBAC_SE_EDI>().Where(t => t.IsHaveSeData == false) |
|||
.GroupBy(t => new { t.LU, t.PN }) |
|||
.Select(t => new JisBBACEidSeCompareExport() |
|||
{ |
|||
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<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == false) |
|||
.GroupBy(t => new { t.LU, t.PN }) |
|||
.Select(t => new JisBBACEidSeCompareExport() |
|||
{ |
|||
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), |
|||
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<BBAC_SE_EDI>() |
|||
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<BBAC_SE_DETAIL>() |
|||
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), |
|||
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 } |
|||
//where edi.IsDeleted == false && edi.IsHaveSeData == true && se.IsHaveEdiData == true
|
|||
select new JisBBACEidSeCompareExport() |
|||
{ |
|||
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, |
|||
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, $"BBACEDI数据和发货对比") |
|||
.SeparateBySheet() |
|||
.Append(notHaveEdiHaveSeList, $"BBAC发货和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
|
|||
} |
|||
} |
@ -0,0 +1,183 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
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 |
|||
{ |
|||
/// <summary>
|
|||
/// 买单件HBPO结算、发运对比导出服务
|
|||
/// </summary>
|
|||
public class MaiDanHBPOSaSeCompareExportService : ITransientDependency, IExportJob |
|||
{ |
|||
/// <summary>
|
|||
/// HubContext
|
|||
/// </summary>
|
|||
private readonly IHubContext<PageHub> _hubContext; |
|||
/// <summary>
|
|||
/// 文件容器
|
|||
/// </summary>
|
|||
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
|||
/// <summary>
|
|||
/// DbContext
|
|||
/// </summary>
|
|||
private readonly SettleAccountDbContext _settleAccountDbContext; |
|||
|
|||
/// <summary>
|
|||
/// 构造
|
|||
/// </summary>
|
|||
public MaiDanHBPOSaSeCompareExportService( |
|||
IHubContext<PageHub> hubContext, |
|||
IBlobContainer<MyFileContainer> fileContainer, |
|||
IObjectMapper objectMapper, |
|||
SettleAccountDbContext settleAccountDbContext) |
|||
{ |
|||
_hubContext = hubContext; |
|||
_fileContainer = fileContainer; |
|||
_settleAccountDbContext = settleAccountDbContext; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 导出
|
|||
/// </summary>
|
|||
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) |
|||
{ |
|||
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<BBAC_SE_EDI>().Where(t => t.IsHaveSeData == false) |
|||
.GroupBy(t => new { t.LU, t.PN }) |
|||
.Select(t => new JisBBACEidSeCompareExport() |
|||
{ |
|||
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<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == false) |
|||
.GroupBy(t => new { t.LU, t.PN }) |
|||
.Select(t => new JisBBACEidSeCompareExport() |
|||
{ |
|||
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), |
|||
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<BBAC_SE_EDI>() |
|||
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<BBAC_SE_DETAIL>() |
|||
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), |
|||
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 } |
|||
//where edi.IsDeleted == false && edi.IsHaveSeData == true && se.IsHaveEdiData == true
|
|||
select new JisBBACEidSeCompareExport() |
|||
{ |
|||
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, |
|||
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, $"BBACEDI数据和发货对比") |
|||
.SeparateBySheet() |
|||
.Append(notHaveEdiHaveSeList, $"BBAC发货和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
|
|||
} |
|||
} |
Loading…
Reference in new issue