Browse Source

导入

master
mahao 1 year ago
parent
commit
a443f15b27
  1. 34
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  2. 36
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  3. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SE_DETAIL.cs
  4. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SE_EDI.cs
  5. 134
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACEdiSeCompareExportService.cs
  6. 11
      code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs

34
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; }
/// <summary>
/// 生产号
@ -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; }
/// <summary>
/// 生产号
@ -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; }
/// <summary>
/// 生产号
@ -205,7 +205,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// 结算日期
/// </summary>
[Display(Name = "结算日期")]
[ImporterHeader(Name = "开票日期")]
[ImporterHeader(Name = "零件时间")]
public DateTime SettleDate { set; get; }
/// <summary>
@ -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; }
/// <summary>
/// 生产号
@ -265,6 +265,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
[ImporterHeader(Name = "发票号")]
public string InvoiceNumber { set; get; }
/// <summary>
/// 开票日期
/// </summary>
[Display(Name = "开票日期")]
[ImporterHeader(Name = "开票日期")]
public DateTime? MakeDate { set; get; }
/// <summary>
/// 供应商代码
/// </summary>
@ -305,28 +312,28 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// </summary>
[Display(Name = "价格")]
[ImporterHeader(Name = "价格")]
public decimal Price { set; get; }
public decimal? Price { set; get; }
/// <summary>
/// 金额
/// </summary>
[Display(Name = "金额")]
[ImporterHeader(Name = "金额")]
public decimal Amount { set; get; }
public decimal? Amount { set; get; }
/// <summary>
/// 税额
/// </summary>
[Display(Name = "税额")]
[ImporterHeader(Name = "税额")]
public decimal Tallage { set; get; }
public decimal? Tallage { set; get; }
/// <summary>
/// 价税合计
/// </summary>
[Display(Name = "价税合计")]
[ImporterHeader(Name = "价税合计")]
public decimal Total { set; get; }
public decimal? Total { set; get; }
/// <summary>
/// 协议编号
@ -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; }
/// <summary>
/// 生产号
@ -392,6 +399,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
[ImporterHeader(Name = "External Delivery ID")]
[Required(ErrorMessage = "{0}不能为空")]
public string GroupNum { get; set; }
/// <summary>
/// Supplier
/// </summary>
[Display(Name = "Supplier")]
[ImporterHeader(Name = "Supplier")]
public string Supplier { get; set; }
}
/// <summary>

36
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs

@ -112,9 +112,9 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
/// 导入
/// </summary>
[HttpPost]
public async Task<IActionResult> ImportByBusinessTypeAsync([FromForm] PUB_SAImportRequestDto pubSaImportRequestDto)
public async Task<IActionResult> 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<PUB_SA>
var importPubSaDetails = ObjectMapper.Map<List<ZhiGongJianBBACImportDto>, List<PUB_SA_DETAIL>>(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<PUB_SA>
var importPubSaDetails = ObjectMapper.Map<List<ZhiGongJianHBPOImportDto>, List<PUB_SA_DETAIL>>(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<PUB_SA>
var importPubSaDetails = ObjectMapper.Map<List<MaiDanJianHBPOImportDto>, List<PUB_SA_DETAIL>>(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<PUB_SA>
var importPubSaDetails = ObjectMapper.Map<List<BeiJianImportDto>, List<PUB_SA_DETAIL>>(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<PUB_SA>
#region 导入数据转换
ExportImporter _exportImporter = new ExportImporter();
var importResults = await _exportImporter.UploadExcelImport<YinDuJianImportDto>(files, _excelImportService);
importResults = importResults.FindAll(t => t.Supplier == "15663496");
var importPubSaDetails = ObjectMapper.Map<List<YinDuJianImportDto>, List<PUB_SA_DETAIL>>(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<PUB_SA>
//导入的零件号集合
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();
/*

6
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;
}
}

6
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SE_EDI.cs

@ -74,5 +74,9 @@ public class BBAC_SE_EDI:FullAuditedAggregateRoot<Guid>
Extend4 = extend4;
}
public BBAC_SE_EDI SetQty(decimal qty)
{
this.Qty = qty;
return this;
}
}

134
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<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == true);
// var haveEidSesGroup = _settleAccountDbContext.Set<BBAC_SE_DETAIL>().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<BBAC_SE_DETAIL>().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<BBAC_SE_DETAIL>().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<BBAC_SE_DETAIL>().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<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == true)?.GroupBy(t => new { t.PN, t.LU }).Select(t =>
t.FirstOrDefault()).ToList();
//有发运的EDI数据
//var haveSeEids = _settleAccountDbContext.Set<BBAC_SE_EDI>().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<BBAC_SE_EDI>().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<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == false);
//无发运的EDI数据
var notHaveSeEids = _settleAccountDbContext.Set<BBAC_SE_EDI>().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<BBAC_SE_EDI>().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<BBAC_SE_EDI>().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<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == false);
////无发运的EDI数据
//var notHaveSeEids = _settleAccountDbContext.Set<BBAC_SE_EDI>().Where(t => t.IsDeleted == false && t.IsHaveSeData == false);
//var jisBBACEidSeCompareExports = new List<JisBBACEidSeCompareExport>();
////有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();

11
code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs

@ -8,9 +8,20 @@ namespace SettleAccount.Job
{
public SettleAccountJobAutoMapperProfile()
{
CreateMapBBACEdiSeCompare();
CreateMapPubSaSeCompare();
}
/// <summary>
/// BBAC EDI与发运对比
/// </summary>
public void CreateMapBBACEdiSeCompare()
{
//CreateMap<PubSaSeCompareDiff, JisBBACEidSeCompareExport>()
// .ForMember(x => x.ReplaceLU, y => y.MapFrom(y => y.ReplaceLU));
}
/// <summary>
/// Pub结算与发运对比
/// </summary>

Loading…
Cancel
Save