Browse Source

价格单按照合同日期匹配

master
mahao 1 year ago
parent
commit
fd50c46bb9
  1. 18
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs
  2. 14
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
  3. 19
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
  4. 23
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  5. 50
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs
  6. 49
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs
  7. 20
      code/src/Modules/SettleAccount/src/SettleAccount.Domain.Shared/Enums/EnumWMSSend.cs
  8. 44
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/SaSeEdiCompareDiff.cs

18
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs

@ -122,14 +122,12 @@ public class PriceListImportDto
[ImporterHeader(IsIgnore = true)]
[ExcelImporterHeadDesc(Row = 1, Cell = 1)]
public string Date { get; set; }
/// <summary>
/// 合同号
/// </summary>
[ImporterHeader(IsIgnore = true)]
[ExcelImporterHeadDesc(Row = 2, Cell = 1)]
public string ContractNo { get; set; }
/// <summary>
/// 零件号
/// </summary>
@ -137,30 +135,36 @@ public class PriceListImportDto
[Required(ErrorMessage = "{0}是必填项")]
[ImporterHeader(Name = "*Part No.")]
public string PartNo { get; set; }
/// <summary>
/// 价格
/// </summary>
[ImporterHeader(Name = "Total Price (Old)")]
public string TotalPrice { get; set; }
public decimal TotalPrice { get; set; }
/// <summary>
/// 开始时间
/// </summary>
[ImporterHeader(Name = "*Valid From")]
public DateTime ValidFrom { get; set; }
/// <summary>
/// 结束时间
/// </summary>
[ImporterHeader(Name = "*Valid To")]
public DateTime ValidTo { get; set; }
/// <summary>
/// 客户编码
/// </summary>
[ImporterHeader(Name = "*Plant")]
public string Plant { get; set; }
/// <summary>
/// ES1
/// </summary>
[ImporterHeader(Name = "ES1")]
public string ES1 { get; set; }
/// <summary>
/// ES2
/// </summary>
[ImporterHeader(Name = "ES2")]
public string ES2 { get; set; }
}
public class PriceListRequestDto : PagedAndSortedResultRequestDto

14
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs

@ -324,13 +324,13 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
{
bbacSaDetails.ForEach(bbacSaDetail =>
{
var lus = bbacSaDetail.LU.Split(" ").ToList();
var lus = bbacSaDetail.LU.Split(new string(' ', 4)).ToList();
bbacSaDetail.LU = lus[0].Replace(" ", "");
if (lus.Count > 1)
{
lus.RemoveAt(0);
var luAssemble = lus.Select(t => t.Replace(" ", ""));
bbacSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index);
bbacSaDetail.LU += luAssemble.Aggregate(new string(' ', 6), (current, index) => current + index);
}
});
@ -404,10 +404,16 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
bbacSaDetails.ForEach(bbacSaDetail =>
{
//根据物料号、结算日期获取价格
var priceListEntity = priceListEntitys.FirstOrDefault(t => t.LU == bbacSaDetail.LU && bbacSaDetail.SettleDate >= t.BeginTime && bbacSaDetail.SettleDate <= t.EndTime);
//根据物料号、结算日期获取价格
var priceListEntity = priceListEntitys
.Where(t => t.LU == bbacSaDetail.LU)
.Where(t => bbacSaDetail.SettleDate >= t.BeginTime && bbacSaDetail.SettleDate <= t.EndTime)
.OrderByDescending(t => t.Date)
.ThenByDescending(t => t.CreationTime)
.FirstOrDefault();
bbacSaDetail.Price = priceListEntity?.Price ?? 0;
bbacSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == bbacSaDetail.LU)?.ErpMaterialCode ?? bbacSaDetail.LU.Replace(" ", "-");
bbacSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == bbacSaDetail.LU)?.ErpMaterialCode ?? bbacSaDetail.LU.Replace(new string(' ', 6), "-");
});
#endregion

19
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs

@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Bibliography;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
@ -286,13 +284,13 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
hbpoSaDetails.ForEach(hbpoSaDetail =>
{
hbpoSaDetail.SetId(GuidGenerator.Create());
var lus = hbpoSaDetail.LU.Split(" ").ToList();
var lus = hbpoSaDetail.LU.Split(new string(' ', 4)).ToList();
hbpoSaDetail.LU = lus[0].Replace(" ", "");
if (lus.Count > 1)
{
lus.RemoveAt(0);
var luAssemble = lus.Select(t => t.Replace(" ", ""));
hbpoSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index);
hbpoSaDetail.LU += luAssemble.Aggregate(new string(' ', 6), (current, index) => current + index);
}
hbpoSaDetail.CustomerPartCodeNoSpace = hbpoSaDetail.LU.Replace(" ", "");
hbpoSaDetail.Version = Version;
@ -354,13 +352,13 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
hbpoSaDetails.ForEach(hbpoSaDetail =>
{
hbpoSaDetail.SetId(GuidGenerator.Create());
List<string> lus = hbpoSaDetail.LU.Split(" ").ToList();
List<string> lus = hbpoSaDetail.LU.Split(new string(' ', 4)).ToList();
hbpoSaDetail.LU = lus[0].Replace(" ", "");
if (lus.Count > 1)
{
lus.RemoveAt(0);
var luAssemble = lus.Select(t => t.Replace(" ", ""));
hbpoSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index);
hbpoSaDetail.LU += luAssemble.Aggregate(new string(' ', 6), (current, index) => current + index);
}
hbpoSaDetail.BillNum = hbpoSaBillNum;
@ -376,10 +374,15 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
hbpoSaDetails.ForEach(hbpoSaDetail =>
{
//根据物料号、结算日期获取价格
var priceListEntity = priceListEntitys.FirstOrDefault(t => t.LU == hbpoSaDetail.LU && hbpoSaDetail.SettleDate >= t.BeginTime && hbpoSaDetail.SettleDate <= t.EndTime);
var priceListEntity = priceListEntitys
.Where(t => t.LU == hbpoSaDetail.LU)
.Where(t => hbpoSaDetail.SettleDate >= t.BeginTime && hbpoSaDetail.SettleDate <= t.EndTime)
.OrderByDescending(t => t.Date)
.ThenByDescending(t => t.CreationTime)
.FirstOrDefault();
hbpoSaDetail.Price = priceListEntity?.Price ?? 0;
hbpoSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == hbpoSaDetail.LU)?.ErpMaterialCode ?? hbpoSaDetail.LU.Replace(" ", "-");
hbpoSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == hbpoSaDetail.LU)?.ErpMaterialCode ?? hbpoSaDetail.LU.Replace(new string(' ', 6), "-");
});
#endregion

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

@ -5,12 +5,10 @@ using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Core.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using OfficeOpenXml;
using SettleAccount.Domain.BQ;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
@ -25,7 +23,6 @@ using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ;
@ -398,13 +395,13 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
{
pubSaDetails.ForEach(pubSaDetail =>
{
var lus = pubSaDetail.LU.Split(" ").ToList();
var lus = pubSaDetail.LU.Split(new string(' ', 4)).ToList();
pubSaDetail.LU = lus[0].Replace(" ", "");
if (lus.Count > 1)
{
lus.RemoveAt(0);
var luAssemble = lus.Select(t => t.Replace(" ", ""));
pubSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index);
pubSaDetail.LU += luAssemble.Aggregate(new string(' ', 6), (current, index) => current + index);
}
});
@ -440,7 +437,6 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
importPubSaDetail.KeyCode = importPubSaDetail.PN + importPubSaDetail.LU;
importPubSaDetail.Version = _version;
importPubSaDetail.BusinessType = businessType;
importPubSaDetail.Site = "工厂";
});
var lus = pubSaDetails.Select(t => t.LU).Distinct().ToList();
if (businessType == EnumBusinessType.BeiJian)
@ -450,7 +446,12 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
pubSaDetails.ForEach(importPubSaDetail =>
{
//根据物料号、结算日期获取价格
var priceListEntity = priceListEntitys.Find(t => t.LU == importPubSaDetail.LU && importPubSaDetail.SettleDate >= t.BeginDate && importPubSaDetail.SettleDate <= t.EndDate);
var priceListEntity = priceListEntitys
.Where(t => t.LU == importPubSaDetail.LU)
.Where(t => importPubSaDetail.SettleDate >= t.BeginDate && importPubSaDetail.SettleDate <= t.EndDate)
.OrderByDescending(t => t.Date)
.ThenByDescending(t => t.CreationTime)
.FirstOrDefault();
importPubSaDetail.Price = priceListEntity?.Price ?? 0;
});
}
@ -461,7 +462,11 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
pubSaDetails.ForEach(importPubSaDetail =>
{
//根据物料号、结算日期获取价格
var priceListEntity = priceListEntitys.FirstOrDefault(t => t.LU == importPubSaDetail.LU && importPubSaDetail.SettleDate >= t.BeginTime && importPubSaDetail.SettleDate <= t.EndTime);
var priceListEntity = priceListEntitys
.Where(t => t.LU == importPubSaDetail.LU)
.Where(t => importPubSaDetail.SettleDate >= t.BeginTime && importPubSaDetail.SettleDate <= t.EndTime)
.OrderByDescending(t => t.Date)
.FirstOrDefault();
importPubSaDetail.Price = priceListEntity?.Price ?? 0;
});
}
@ -473,7 +478,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
var seAllMaterialRelationships = materialRelationshipEntitys.Union(materialRelationships);
pubSaDetails.ForEach(pubSaDetail =>
{
pubSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == pubSaDetail.LU)?.ErpMaterialCode ?? pubSaDetail.LU.Replace(" ", "-");
pubSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == pubSaDetail.LU)?.ErpMaterialCode ?? pubSaDetail.LU.Replace(new string(' ', 6), "-");
});
#endregion

50
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs

@ -77,57 +77,9 @@ public class PriceListAppService : SettleAccountApplicationBase<PriceList>
_checkls.Add("1046");
_checkls.Add("104T");
result = result.Where(p => _checkls.Contains(p.Plant)).ToList();
result.ForEach(t => t.PartNo = t.PartNo + new string(' ', 6) + t.ES1 + t.ES2);
var entityList = ObjectMapper.Map<List<PriceListImportDto>, List<PriceList>>(result);
entityList = entityList.GroupBy(p => new { p.LU, p.ClientCode, p.BeginTime, p.EndTime }).Select(p => p.FirstOrDefault()).ToList();
var contractNo = entityList.FirstOrDefault().ContractNo;
#region 校验
if (entityList.Any())
{
var query = from item1 in entityList
join item2 in entityList
on new { item1.LU } equals new { item2.LU }
where (item1.BeginTime > item2.BeginTime && item1.EndTime < item2.EndTime) || (item2.BeginTime > item1.BeginTime && item2.EndTime < item1.EndTime) || (item1.BeginTime == item2.BeginTime && item1.EndTime != item2.EndTime) || (item1.BeginTime != item2.BeginTime && item1.EndTime == item2.EndTime)
select item1.LU;
var repeat = query.Distinct().ToList();
foreach (var item in repeat)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item},时间区间存在交集", string.Empty));
}
}
if (checkList.Count > 0)
{
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { code = ApplicationConsts.ImportFailCode, message = "导入失败", fileName = fileName });
}
#endregion
var lus = entityList.Select(p => p.LU);
var prices = _priceListRepository.Where(t => lus.Contains(t.LU) && t.ContractNo != contractNo).ToList();
if (prices.Any())
{
var query = from item1 in entityList
join item2 in prices
on new { item1.LU } equals new { item2.LU }
where (item1.BeginTime >= item2.BeginTime && item1.EndTime <= item2.EndTime) || (item2.BeginTime >= item1.BeginTime && item2.EndTime <= item1.EndTime)
select item1.LU;
var repeat = query.Distinct().ToList();
foreach (var item in repeat)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item},时间区间与系统内数据存在交集", string.Empty));
}
}
if (checkList.Count > 0)
{
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { code = ApplicationConsts.ImportFailCode, message = "导入失败", fileName = fileName });
}
var priceListModelEntitys = _priceListRepository.Where(t => t.ContractNo == contractNo && lus.Contains(t.LU)).ToList();
if (priceListModelEntitys.Any())
{
await _priceListRepository.DeleteManyAsync(priceListModelEntitys).ConfigureAwait(false);
}
foreach (var item in entityList)
{

49
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs

@ -57,55 +57,6 @@ public class PriceListAppServiceBJ : SettleAccountApplicationBase<PriceListBJ>
var entityList = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(result);
entityList = entityList.GroupBy(p => new { p.LU, p.ClientCode, p.BeginDate, p.EndDate }).Select(p => p.FirstOrDefault()).ToList();
var contractNo = entityList.FirstOrDefault().ContractNo;
#region 校验
if (entityList.Any())
{
var query = from item1 in entityList
join item2 in entityList
on new { item1.LU } equals new { item2.LU }
where (item1.BeginDate > item2.BeginDate && item1.EndDate < item2.EndDate) || (item2.BeginDate > item1.BeginDate && item2.EndDate < item1.EndDate) || (item1.BeginDate == item2.BeginDate && item1.EndDate != item2.EndDate) || (item1.BeginDate != item2.BeginDate && item1.EndDate == item2.EndDate)
select item1.LU;
var repeat = query.Distinct().ToList();
foreach (var item in query)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item},时间区间存在交集", string.Empty));
}
}
if (checkList.Count > 0)
{
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { code = ApplicationConsts.ImportFailCode, message = "导入失败", fileName = fileName });
}
#endregion
var lus = entityList.Select(p => p.LU);
var prices = _repository.Where(t => lus.Contains(t.LU) && t.ContractNo != contractNo).ToList();
if (prices.Any())
{
var query = from item1 in entityList
join item2 in prices
on new { item1.LU } equals new { item2.LU }
where (item1.BeginDate >= item2.BeginDate && item1.EndDate <= item2.EndDate) || (item2.BeginDate >= item1.BeginDate && item2.EndDate <= item1.EndDate)
select item1.LU;
var repeat = query.Distinct().ToList();
foreach (var item in repeat)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item},时间区间与系统内数据存在交集", string.Empty));
}
}
if (checkList.Count > 0)
{
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { code = ApplicationConsts.ImportFailCode, message = "导入失败", fileName = fileName });
}
var priceListModelEntitys = _repository.Where(t => t.ContractNo == contractNo && lus.Contains(t.LU)).ToList();
if (priceListModelEntitys.Any())
{
await _repository.DeleteManyAsync(priceListModelEntitys).ConfigureAwait(false);
}
foreach (var item in entityList)
{

20
code/src/Modules/SettleAccount/src/SettleAccount.Domain.Shared/Enums/EnumWMSSend.cs

@ -0,0 +1,20 @@
using System.ComponentModel.DataAnnotations;
namespace Win.Sfs.SettleAccount.Enums;
/// <summary>
/// WMS发运
/// </summary>
public enum EnumWMSSend
{
/// <summary>
/// 未定义
/// </summary>
[Display(Name = "未定义")]
None = 0,
/// <summary>
/// WMS多发
/// </summary>
[Display(Name = "WMS多发")]
WMSRepeat = 1,
}

44
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/SaSeEdiCompareDiff.cs

@ -206,6 +206,27 @@ public class SaSeEdiCompareDetailExportJisBBAC : SaSeEdiCompareDetailExport, ISa
[ValueMapping("无结算有发运(有EDI数据)", 5)]
[ValueMapping("无结算有发运(无EDI数据)", 6)]
public EnumSaSeEdiCompareCategory Category { get; set; }
[Display(Name = "WMS多发")]
[ExporterHeader(DisplayName = "WMS多发")]
[ValueMapping("", 0)]
[ValueMapping("WMS多发", 1)]
public EnumWMSSend WMSSend
{
get
{
return (Category, SaSeQty < 0) switch
{
(EnumSaSeEdiCompareCategory.HaveSaHaveSeHaveEdi, true) => EnumWMSSend.WMSRepeat,
(EnumSaSeEdiCompareCategory.HaveSaHaveSeNotHaveEdi, true) => EnumWMSSend.WMSRepeat,
_ => EnumWMSSend.None
};
}
}
[Display(Name = "价格信息")]
[ExporterHeader(DisplayName = "价格信息")]
[ValueMapping("有价格信息", true)]
[ValueMapping("无价格信息", false)]
public bool IsHavePrice => FixPrice != null && FixPrice != 0;
/// <summary>
/// 交货单号
/// </summary>
@ -297,7 +318,7 @@ public class SaSeEdiCompareDetailExportJisBBAC : SaSeEdiCompareDetailExport, ISa
[ExporterHeader(DisplayName = "Edi数量")]
public decimal EdiQty { get; set; }
/// <summary>
/// 结算与EDI量差
/// 结算与WMS发货量差
/// </summary>
[ExporterHeader(DisplayName = "结算与WMS发货量差")]
public decimal SaSeQty => SAQty - SEQty;
@ -366,6 +387,27 @@ public class SaSeEdiCompareDetailExportJisHBPO : SaSeEdiCompareDetailExport, ISa
[ValueMapping("无结算有发运(有EDI数据)", 5)]
[ValueMapping("无结算有发运(无EDI数据)", 6)]
public EnumSaSeEdiCompareCategory Category { get; set; }
[Display(Name = "WMS多发")]
[ExporterHeader(DisplayName = "WMS多发")]
[ValueMapping("", 0)]
[ValueMapping("WMS多发", 1)]
public EnumWMSSend WMSSend
{
get
{
return (Category, SaSeQty < 0) switch
{
(EnumSaSeEdiCompareCategory.HaveSaHaveSeHaveEdi, true) => EnumWMSSend.WMSRepeat,
(EnumSaSeEdiCompareCategory.HaveSaHaveSeNotHaveEdi, true) => EnumWMSSend.WMSRepeat,
_ => EnumWMSSend.None
};
}
}
[Display(Name = "价格信息")]
[ExporterHeader(DisplayName = "价格信息")]
[ValueMapping("有价格信息", true)]
[ValueMapping("无价格信息", false)]
public bool IsHavePrice => FixPrice != null && FixPrice != 0;
/// <summary>
/// 交货单号
/// </summary>

Loading…
Cancel
Save