wanggang 1 year ago
parent
commit
a9c06d9744
  1. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs
  2. 34
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/JisSaSeCompareRequestDto.cs
  3. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
  4. 87
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  5. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs
  6. 16
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs
  7. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_DETAIL_SERVICE.cs
  8. 16
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs
  9. 22
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_DETAIL_SERVICE.cs
  10. 24
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  11. 15
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs
  12. 48
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs
  13. 83
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs
  14. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs
  15. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs
  16. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SE_EDI.cs
  17. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_SE_EDI.cs
  18. 29
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs
  19. 24
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs
  20. 599
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  21. 90
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs
  22. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Temp/TempClass.cs
  23. 5404
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230811013305_202308110001.Designer.cs
  24. 44
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230811013305_202308110001.cs
  25. 5413
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230814052555_20230814-1.Designer.cs
  26. 67
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230814052555_20230814-1.cs
  27. 5407
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230814073646_20230814-2.Designer.cs
  28. 56
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230814073646_20230814-2.cs
  29. 10
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs

@ -58,7 +58,7 @@ public class Startup
app.UseEndpoints(endpoints => endpoints.MapHub<PageHub>("/api/hub"));
app.ApplicationServices.UseScheduler(scheduler =>
{
scheduler.Schedule<JisBBACSeEdiCompareAppService>().EverySeconds(10);
//scheduler.Schedule<JisBBACSeEdiCompareAppService>().EverySeconds(10);
//scheduler.Schedule<JisHBPOSeEdiCompareAppService>().EverySeconds(10);
});
var contentTypeProvider = new FileExtensionContentTypeProvider();

34
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/JisSaSeCompareRequestDto.cs

@ -14,40 +14,34 @@ public class JisSaSeCompareRequestDto
[Display(Name = "期间")]
[Required(ErrorMessage = "{0}不能为空")]
public string Version { get; set; }
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
public string LU { get; set; }
/// <summary>
/// 通用码
/// </summary>
[Display(Name = "通用码")]
public string PN { get; set; }
/// <summary>
/// 发运开始时间
/// </summary>
[Display(Name = "发运开始时间")]
public DateTime SeStartDateTime { get; set; }
public DateTime? SeStartDateTime { get; set; }
/// <summary>
/// 发运结束时间
/// </summary>
[Display(Name = "发运结束时间")]
public DateTime SeEndDateTime { get; set; }
public DateTime? SeEndDateTime { get; set; }
/// <summary>
/// 下线开始时间
/// </summary>
[Display(Name = "下线开始时间")]
public DateTime DownLineStartDateTime { get; set; }
public DateTime? DownLineStartDateTime { get; set; }
/// <summary>
/// 下线结束时间
/// </summary>
[Display(Name = "下线结束时间")]
public DateTime DownLineEndDateTime { get; set; }
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
public string LU { get; set; }
/// <summary>
/// 通用码
/// </summary>
[Display(Name = "通用码")]
public string PN { get; set; }
public DateTime? DownLineEndDateTime { get; set; }
}

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs

@ -71,6 +71,7 @@ namespace Win.Sfs.SettleAccount.Bases
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository,
BBAC_CAN_SA_MNG bbacMng,
HBPO_CAN_SA_MNG hbpoMng,
PUB_CAN_SA_MNG pubMng,
@ -204,7 +205,7 @@ namespace Win.Sfs.SettleAccount.Bases
}
[HttpPost]
[UnitOfWork(false)]
public virtual async Task<string> ReceivedAsync(List<string> p_ins)
{

87
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs

@ -84,9 +84,6 @@ namespace Win.Sfs.SettleAccount.Bases
var totalCount = await _detailRepository.GetCountByFilterAsync(input.Filters);
var dtos = ObjectMapper.Map<List<TEntityDetail>, List<TEntityDetailDto>>(entitys);
return new PagedResultDto<TEntityDetailDto>(totalCount, dtos);
}
/// <summary>
@ -164,10 +161,51 @@ namespace Win.Sfs.SettleAccount.Bases
/// <param name="p_version">版本号</param>
/// <param name="p_InvGroupNum">发票分组</param>
/// <param name="p_parentInvBillNum">原发票号</param>
protected async Task<bool> SecInvoice<TDetail>(List<TDetail> p_list,List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> p_tmplist, int p_version, string p_InvGroupNum, string p_parentInvBillNum,EnumBusinessType businessType) where TDetail : SA_CAN_BASE
protected async Task<bool> SecInvoice<TDetail>(List<TDetail> p_list,List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum,EnumBusinessType businessType) where TDetail : SA_CAN_BASE
{
var ls= await _invmng.SecInvoice(p_list,p_adjlist,p_tmplist,p_version, p_InvGroupNum, p_parentInvBillNum, businessType);
if (ls.Count > 0)
List<string> invlist = new List<string>();
switch (businessType)
{
case EnumBusinessType.MaiDanJianHBPO:
invlist = await _invmng.MakeInvoice(p_list, p_adjlist, dtos, p_version, p_InvGroupNum, string.Empty, businessType, true);
break;
case EnumBusinessType.MaiDanJianBBAC:
invlist = await _invmng.MakeInvoice(p_list, p_adjlist, dtos, p_version, p_InvGroupNum, string.Empty, businessType, true);
break;
case EnumBusinessType.ZhiGongJianBBAC:
invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_InvGroupNum, string.Empty, businessType, true);//重开可以变多张发票
break;
case EnumBusinessType.ZhiGongJianHBPO:
invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_InvGroupNum, string.Empty, businessType, true);//重开可以变多张发票
break;
case EnumBusinessType.BeiJian:
invlist = await _invmng.BJInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_InvGroupNum, string.Empty, businessType, true);
break;
case EnumBusinessType.JisBBAC:
invlist = await _invmng.SecInvoice(p_list, p_adjlist, dtos, p_version, p_InvGroupNum, string.Empty, businessType);
break;
case EnumBusinessType.JisHBPO:
invlist = await _invmng.SecInvoice(p_list, p_adjlist, dtos, p_version, p_InvGroupNum, string.Empty, businessType);
break;
case EnumBusinessType.YinDuJian:
invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_InvGroupNum, string.Empty, businessType, true);//重开可以变多张发票
break;
}
//var ls= await _invmng.SecInvoice(p_list,p_adjlist,p_tmplist,p_version, p_InvGroupNum, p_parentInvBillNum, businessType);
if (invlist.Count > 0)
{
return true;
}
@ -186,11 +224,42 @@ namespace Win.Sfs.SettleAccount.Bases
/// <param name="p_parentInvBillNum"></param>
/// <param name="businessType"></param>
/// <returns></returns>
protected async Task<bool> FirstInvoice<TDetail>(List<TDetail> p_list,List<PUB_ADJ_DETAIL> p_adjlist ,List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) where TDetail : SA_CAN_BASE
protected async Task<bool> FirstInvoice<TDetail>(List<TDetail> p_list,List<PUB_ADJ_DETAIL> p_adjlist ,List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_invGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) where TDetail : SA_CAN_BASE
{
List<string> invlist = new List<string>();
switch (businessType)
{
case EnumBusinessType.MaiDanJianHBPO:
invlist = await _invmng. MakeInvoice(p_list, p_adjlist, dtos, p_version, p_invGroupNum, string.Empty, businessType, true);
break;
case EnumBusinessType.MaiDanJianBBAC:
invlist = await _invmng.MakeInvoice(p_list, p_adjlist, dtos, p_version, p_invGroupNum, string.Empty, businessType, true);
break;
case EnumBusinessType.ZhiGongJianBBAC:
invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_invGroupNum, string.Empty, businessType, true);//重开可以变多张发票
break;
case EnumBusinessType.ZhiGongJianHBPO:
invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_invGroupNum, string.Empty, businessType, true);//重开可以变多张发票
break;
case EnumBusinessType.BeiJian:
invlist = await _invmng.BJInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_invGroupNum, string.Empty, businessType, true);
break;
case EnumBusinessType.JisBBAC:
invlist = await _invmng.FirstInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_invGroupNum, string.Empty, businessType);//重开可以变多张发票
break;
case EnumBusinessType.JisHBPO:
invlist = await _invmng.FirstInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_invGroupNum, string.Empty, businessType);//重开可以变多张发票
break;
case EnumBusinessType.YinDuJian:
invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_invGroupNum, string.Empty, businessType, true);//重开可以变多张发票
break;
}
var ls = await _invmng.FirstInvoice(p_list,p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType);
if (ls.Count > 0)
if (invlist.Count > 0)
{
return true;
}

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs

@ -93,7 +93,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
foreach (var itm in adjlist)
{
bbaclist.Add(new BBAC_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
guid: itm.Id,
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.InvGroupNum,
@ -118,7 +118,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
//var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).ToList();//不能结算
var priceList = _priceRepository.ToList();//价格单
var errorList =await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType);
if (errorList.Count() > 0)
@ -131,6 +130,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime//客户零件号
select new TEMP_CAN_SA_DETAIL
{
Id=d.Id,
SettleBillNum = d.SettleBillNum,
Site = d.Site,
Version = d.Version,

16
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs

@ -1,6 +1,7 @@
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NetTaste;
using SettleAccount.Domain.BQ;
using System;
using System.Collections.Generic;
@ -17,6 +18,7 @@ using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ
@ -49,7 +51,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
await _bbacNotMng.GenerateSettlementOrder(entitys);
var errors=await _bbacNotMng.GenerateSettlementOrder(entitys);
if (errors.Count > 0)
{
List<ERR_EXP_DTO> errorlist = new List<ERR_EXP_DTO>();
foreach (var itm in errors)
{
errorlist.Add(new ERR_EXP_DTO() { Message = itm });
}
return await ExportErrorReportAsync(errorlist);
}
return ApplicationConsts.SuccessStr;
}

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_DETAIL_SERVICE.cs

@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.LinqAsync;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Shouldly;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Caching;
using Win.Abp.Snowflakes;

16
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs

@ -2,6 +2,7 @@ using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NetTaste;
using SettleAccount.Domain.BQ;
using System;
using System.Collections.Generic;
@ -17,6 +18,7 @@ using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ
@ -49,7 +51,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public override async Task<string> GenerateSettlementOrder(HBPO_NOT_SA_DETAIL_REQ_DTO input)
{
var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
await _hbpoNotMng.GenerateSettlementOrder(entitys);
var errors=await _hbpoNotMng.GenerateSettlementOrder(entitys);
if (errors.Count > 0)
{
List<ERR_EXP_DTO> errorlist = new List<ERR_EXP_DTO>();
foreach (var itm in errors)
{
errorlist.Add(new ERR_EXP_DTO() { Message = itm });
}
return await ExportErrorReportAsync(errorlist);
}
return ApplicationConsts.SuccessStr;
}

22
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_DETAIL_SERVICE.cs

@ -1,12 +1,13 @@
using System;
using System.Collections.Generic;
using System.LinqAsync;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using SettleAccount.Job.Services.Report;
using Shouldly;
using Volo.Abp;
using TaskJob.EventArgs;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Caching;
using Win.Abp.Snowflakes;
@ -96,8 +97,21 @@ public class HBPO_SA_DETAIL_SERVICE : SettleAccountApplicationBase<HBPO_SA_DETAI
[HttpPost]
public async Task<string> HBPOSaSeCompare(JisSaSeCompareRequestDto jisSaSeCompareRequestDto)
{
await Task.CompletedTask;
throw new NotImplementedException();
var projectName = $"JisHBPO结算与发运数据对比";
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "Version", Value = jisSaSeCompareRequestDto.Version });
customConditionList.Add(new CustomCondition() { Name = "LU", Value = jisSaSeCompareRequestDto.LU });
customConditionList.Add(new CustomCondition() { Name = "PN", Value = jisSaSeCompareRequestDto.PN });
customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = projectName });
customConditionList.Add(new CustomCondition() { Name = "SeStartDateTime", Value = jisSaSeCompareRequestDto.SeStartDateTime?.ToString("yyyy-MM-dd 00:00:00") });
customConditionList.Add(new CustomCondition() { Name = "SeEndDateTime", Value = jisSaSeCompareRequestDto.SeEndDateTime?.ToString("yyyy-MM-dd 23:59:59") });
var _taskid = "";
//var _taskid = await _taskJobService.ExportEnqueueAsync(projectName, ExportExtentsion.Excel, jisSaSeCompareRequestDto.Version, string.Empty, CurrentUser, typeof(JisHBPOSaSeCompareExportService), customConditionList, (rs) =>
//{
//}).ConfigureAwait(false);
return _taskid;
}
#endregion
}

24
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs

@ -5,7 +5,9 @@ using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Migrations;
using SettleAccount.Domain.BQ;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
@ -43,6 +45,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly INormalEfCoreRepository<PriceListBJ, Guid> _pricebjRepository;
public PUB_CAN_SA_SERVICE
(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
@ -121,27 +126,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
if (input.BillNum.Substring(0, 1) == "C")//一次开票
{
if (main.BusinessType == EnumBusinessType.MaiDanJianHBPO || main.BusinessType == EnumBusinessType.BeiJian)
{
var strs=await _invmng.MakeInvoice(entitys,new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, true);
}
else
{
await FirstInvoice(entitys,new List<PUB_ADJ_DETAIL>(), dtos, new List<TEMP_NOT_SA_DETAIL>(), main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, new List<TEMP_NOT_SA_DETAIL>(), main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
else//二次开票
{
if (main.BusinessType == EnumBusinessType.MaiDanJianHBPO || main.BusinessType==EnumBusinessType.BeiJian )
{
var strs=await _invmng.MakeInvoice(entitys,new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, true);
}
else
{
await SecInvoice(entitys,new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
}
}
}
}

15
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_NOT_SA_SERVICE.cs

@ -17,6 +17,7 @@ using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ
@ -44,7 +45,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public override async Task<string> GenerateSettlementOrder(PUB_NOT_SA_DETAIL_REQ_DTO input)
{
var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
_pubNotMng.GenerateSettlementOrder(entitys);
var errors=await _pubNotMng.GenerateSettlementOrder(entitys);
if (errors.Count > 0)
{
List<ERR_EXP_DTO> errorlist= new List<ERR_EXP_DTO>();
foreach (var itm in errors)
{
errorlist.Add(new ERR_EXP_DTO() { Message = itm });
}
return await ExportErrorReportAsync(errorlist);
}
return ApplicationConsts.SuccessStr;
}

48
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs

@ -28,22 +28,21 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
/// </summary>
public async Task Invoke()
{
using var serviceScope = _serviceProvider.CreateScope();
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
await HandDelEdiDataAsync().ConfigureAwait(false);
//using var serviceScope = _serviceProvider.CreateScope();
//var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
//var query = db.Set<BBAC_SE_DETAIL>().Join(db.Set<BBAC_SE_EDI>(), a => new { a.PN, a.LU, a.Qty }, b => new { b.PN, b.LU, b.Qty }, (se, edi) => new { se, edi }).Where(t => t.se.IsHaveEdiData == false && t.edi.IsHaveSeData == false && t.edi.IsDeleted == false);
//query.ForEach(t =>
//{
// t.edi.SeId = t.se.Id;
// t.edi.IsHaveSeData = true;
// t.se.IsHaveEdiData = true;
//});
//var ses = query.Select(t => t.se);
//var edis = query.Select(t => t.edi);
//db.Set<BBAC_SE_DETAIL>().UpdateRange(ses);
//db.Set<BBAC_SE_EDI>().UpdateRange(edis);
//await db.SaveChangesAsync().ConfigureAwait(false);
var seDetailGroup = db.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, Qty = t.Sum(t => t.Qty) });
var ediDetailGroup = db.Set<BBAC_SE_EDI>().Where(t => t.IsHaveSeData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU, Qty = t.Sum(t => t.Qty) });
var keyCodes = seDetailGroup.Join(ediDetailGroup, a => new { a.PN, a.LU, a.Qty }, b => new { b.PN, b.LU, b.Qty }, (se, edi) => new { se.PN, se.LU });
var seDetails = db.Set<BBAC_SE_DETAIL>().Where(t => keyCodes.Contains(new { t.PN, t.LU }));
var ediDetails = db.Set<BBAC_SE_EDI>().Where(t => keyCodes.Contains(new { t.PN, t.LU }));
seDetails.ForEach(t => t.IsHaveEdiData = true);
ediDetails.ForEach(t => t.IsHaveSeData = true);
db.Set<BBAC_SE_DETAIL>().UpdateRange(seDetails);
db.Set<BBAC_SE_EDI>().UpdateRange(ediDetails);
await db.SaveChangesAsync().ConfigureAwait(false);
}
/// <summary>
@ -59,18 +58,15 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
*/
using var serviceScope = _serviceProvider.CreateScope();
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var query = db.Set<BBAC_SE_EDI>().Join(db.Set<BBAC_SE_DETAIL>(), a => a.SeId, b => b.Id, (edi, se) => new { se, edi }).Where(t => t.edi.IsDeleted == true && t.edi.IsHaveSeData == true);
//query.ForEach(t =>
//{
// t.edi.SeId = default;
// t.edi.IsHaveSeData = false;
// t.se.IsHaveEdiData = false;
//});
//var ses = query.Select(t => t.se);
//var edis = query.Select(t => t.edi);
//Edi 删除的数据(有发运数据)
var ediDelKeyCodes = db.Set<BBAC_SE_EDI>().Where(t => t.IsDeleted == true && t.IsHaveSeData == true).Select(t => new { t.PN, t.LU }).Distinct();
//db.Set<BBAC_SE_DETAIL>().UpdateRange(ses);
//db.Set<BBAC_SE_EDI>().UpdateRange(edis);
//await db.SaveChangesAsync().ConfigureAwait(false);
var seDetails = db.Set<BBAC_SE_DETAIL>().Where(t => ediDelKeyCodes.Contains(new { t.PN, t.LU }));
var ediDetails = db.Set<BBAC_SE_EDI>().Where(t => ediDelKeyCodes.Contains(new { t.PN, t.LU }));
seDetails.ForEach(t => t.IsHaveEdiData = false);
ediDetails.ForEach(t => t.IsHaveSeData = false);
db.Set<BBAC_SE_DETAIL>().UpdateRange(seDetails);
db.Set<BBAC_SE_EDI>().UpdateRange(ediDetails);
await db.SaveChangesAsync().ConfigureAwait(false);
}
}

83
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;
using Coravel.Invocable;
using LinqToDB;
@ -48,36 +49,47 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
Debug.WriteLine($"执行了:{this.GetType()}");
using var serviceScope = _serviceProvider.CreateScope();
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
//var query = from se in db.Set<HBPO_SE_DETAIL>()
// join edi in db.Set<HBPO_SE_EDI>() on new
// {
// se.LU,
// se.PN,
// se.Qty
// } equals new
// {
// edi.LU,
// edi.PN,
// edi.Qty
// }
// where se.IsHaveEdiData == false && edi.IsHaveSeData == false
// select new
// {
// se,
// edi
// };
var query = db.Set<HBPO_SE_DETAIL>().Join(db.Set<HBPO_SE_EDI>(), a => new { a.PN, a.LU, a.Qty }, b => new { b.PN, b.LU, b.Qty }, (se, edi) => new { se, edi }).Where(t => t.se.IsHaveEdiData == false && t.edi.IsHaveSeData == false && t.edi.IsDeleted == false);
var ses = query.Select(t => t.se);
var edis = query.Select(t => t.edi);
ses.ForEach(t => t.IsHaveEdiData = true);
edis.ForEach(t => t.IsHaveSeData = true);
await HandDelEdiDataAsync().ConfigureAwait(false);
db.Set<HBPO_SE_DETAIL>().UpdateRange(ses);
db.Set<HBPO_SE_EDI>().UpdateRange(edis);
var seDetailGroup = from se in db.Set<HBPO_SE_DETAIL>()
where se.IsHaveEdiData == false
group se by new { se.PN, se.LU }
into a
select new { a.Key.PN, a.Key.LU, Qty = a.Sum(t => t.Qty) };
var ediDetailGroup = from edi in db.Set<HBPO_SE_EDI>()
where edi.IsHaveSeData == false
group edi by new { edi.PN, edi.LU }
into a
select new { a.Key.PN, a.Key.LU, Qty = a.Sum(t => t.Qty) };
var keyCodes = from se in seDetailGroup
join edi in ediDetailGroup on new
{
se.PN,
se.LU,
se.Qty
} equals new
{
edi.PN,
edi.LU,
edi.Qty
}
select new { se.PN, se.LU };
//var seDetailGroup2 = db.Set<HBPO_SE_DETAIL>().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU, Qty = t.Sum(t => t.Qty) });
//var ediDetailGroup2 = db.Set<HBPO_SE_EDI>().Where(t => t.IsHaveSeData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU, Qty = t.Sum(t => t.Qty) });
//var keyCodes2 = seDetailGroup2.Join(ediDetailGroup2, a => new { a.PN, a.LU, a.Qty }, b => new { b.PN, b.LU, b.Qty }, (se, edi) => new { se.PN, se.LU });
var seDetails = db.Set<HBPO_SE_DETAIL>().Where(t => keyCodes.Contains(new { t.PN, t.LU }));
var ediDetails = db.Set<HBPO_SE_EDI>().Where(t => keyCodes.Contains(new { t.PN, t.LU }));
seDetails.ForEach(t => t.IsHaveEdiData = true);
ediDetails.ForEach(t => t.IsHaveSeData = true);
db.Set<HBPO_SE_DETAIL>().UpdateRange(seDetails);
db.Set<HBPO_SE_EDI>().UpdateRange(ediDetails);
await db.SaveChangesAsync().ConfigureAwait(false);
Debug.WriteLine($"处理数量:{query.Count()}");
Debug.WriteLine($"处理数量:{keyCodes.Count()}");
}
/// <summary>
@ -87,18 +99,15 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
{
using var serviceScope = _serviceProvider.CreateScope();
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var query = db.Set<HBPO_SE_EDI>().Join(db.Set<HBPO_SE_DETAIL>(), a => a.SeId, b => b.Id, (edi, se) => new { se, edi }).Where(t => t.edi.IsDeleted == true && t.edi.IsHaveSeData == true);
query.ForEach(t =>
{
t.edi.SeId = default;
t.edi.IsHaveSeData = false;
t.se.IsHaveEdiData = false;
});
var ses = query.Select(t => t.se);
var edis = query.Select(t => t.edi);
//Edi 删除的数据(有发运数据)
var ediDelKeyCodes = db.Set<HBPO_SE_EDI>().Where(t => t.IsDeleted == true && t.IsHaveSeData == true).Select(t => new { t.PN, t.LU }).Distinct();
db.Set<HBPO_SE_DETAIL>().UpdateRange(ses);
db.Set<HBPO_SE_EDI>().UpdateRange(edis);
var seDetails = db.Set<HBPO_SE_DETAIL>().Where(t => ediDelKeyCodes.Contains(new { t.PN, t.LU }));
var ediDetails = db.Set<HBPO_SE_EDI>().Where(t => ediDelKeyCodes.Contains(new { t.PN, t.LU }));
seDetails.ForEach(t => t.IsHaveEdiData = false);
ediDetails.ForEach(t => t.IsHaveSeData = false);
db.Set<HBPO_SE_DETAIL>().UpdateRange(seDetails);
db.Set<HBPO_SE_EDI>().UpdateRange(ediDetails);
await db.SaveChangesAsync().ConfigureAwait(false);
}
}

1
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs

@ -128,7 +128,6 @@ namespace Win.Sfs.SettleAccount.Bases.DomainServices
}
if (p_config.IsMaterial == true)
{
var materialList = await _materialRepository.ToListAsync();
var query = from itm in partList
join itm1 in materialList on itm equals itm1.MaterialCode

6
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs

@ -383,7 +383,11 @@ namespace SettleAccount.Bases
public class SA_CAN_BASE : AuditedAggregateRoot<Guid>, ISA_BASE
{
protected SA_CAN_BASE() { }
public SA_CAN_BASE(Guid id) : base(id) { }
public SA_CAN_BASE(Guid id) : base(id) { Id = id; }
/// <summary>
/// 期间

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

@ -50,12 +50,6 @@ public class BBAC_SE_EDI:FullAuditedAggregateRoot<Guid>
[Display(Name = "是否有发运数据")]
public bool IsHaveSeData { get; set; }
/// <summary>
/// 发运Id
/// </summary>
[Display(Name = "是否有发运数据")]
public Guid SeId { get; set; }
public BBAC_SE_EDI()
{ }
public BBAC_SE_EDI(Guid guid, string keyCode, string version, string lU, string pN, string seqNumber, string assemblyCode, string injectionCode, decimal qty, DateTime beginDate

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

@ -53,12 +53,6 @@ public class HBPO_SE_EDI :FullAuditedAggregateRoot<Guid>
[Display(Name = "是否有发运数据")]
public bool IsHaveSeData { get; set; }
/// <summary>
/// 发运Id
/// </summary>
[Display(Name = "是否有发运数据")]
public Guid SeId { get; set; }
public HBPO_SE_EDI(Guid guid ,string keyCode, int version, string lU, string pN, string seqNumber, string assemblyCode, string injectionCode, decimal qty, DateTime beginDate, string site, string extend1, string extend2, string extend3, string extend4)
{
Id = guid;

29
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs

@ -10,6 +10,7 @@ using Win.Sfs.Shared.RepositoryBase;
using Win.Sfs.SettleAccount.Bases;
using EFCore.BulkExtensions;
using SettleAccount.Domain.BQ;
using Win.Sfs.SettleAccount.Bases.DomainServices;
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
@ -25,12 +26,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
private readonly INormalEfCoreRepository<BBAC_CAN_SA, Guid> _repository;
private readonly INormalEfCoreRepository<BBAC_CAN_SA_DETAIL, Guid> _detailRepository;
private readonly INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> _notRepository;
private readonly BaseDomainService _service;
public BBAC_NOT_SA_MNG()
{
}
public BBAC_NOT_SA_MNG
(
BaseDomainService service,
INormalEfCoreRepository<BBAC_CAN_SA, Guid> repository,
INormalEfCoreRepository<BBAC_CAN_SA_DETAIL, Guid> detailRepository,
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository
@ -39,9 +41,30 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
_repository = repository;
_detailRepository = detailRepository;
_notRepository = notRepository;
_service = service;
}
public virtual async Task<List<string>> GenerateSettlementOrder(List<BBAC_NOT_SA_DETAIL> p_list)
{
List<string> errors = new List<string>();
var priceErrors = await _service.CheckPriceList(p_list);
if (priceErrors.Count > 0)
{
foreach (var itm in priceErrors)
{
errors.Add($"发货单号或交付识别号零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据");
}
}
public virtual async Task<bool> GenerateSettlementOrder(List<BBAC_NOT_SA_DETAIL> p_list)
if (errors.Count > 0)
{
return errors;
}
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
var _entity = new BBAC_CAN_SA();
_entity.BillNum = billNumber;
@ -80,7 +103,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
await _repository.DbContext.BulkDeleteAsync(p_list);
await _repository.DbContext.BulkInsertAsync(new List<BBAC_CAN_SA>() { _entity });
await _repository.DbContext.BulkInsertAsync(_entityList);
return true;
return errors;
}

24
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs

@ -10,6 +10,7 @@ using Win.Sfs.Shared.RepositoryBase;
using Win.Sfs.SettleAccount.Bases;
using EFCore.BulkExtensions;
using SettleAccount.Domain.BQ;
using Win.Sfs.SettleAccount.Bases.DomainServices;
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
@ -27,6 +28,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
private readonly INormalEfCoreRepository<HBPO_CAN_SA, Guid> _repository;
private readonly INormalEfCoreRepository<HBPO_CAN_SA_DETAIL, Guid> _detailRepository;
private readonly INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> _notRepository;
private readonly BaseDomainService _service;
public HBPO_NOT_SA_MNG()
{
@ -36,16 +38,30 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
(
INormalEfCoreRepository<HBPO_CAN_SA, Guid> repository,
INormalEfCoreRepository<HBPO_CAN_SA_DETAIL, Guid> detailRepository,
INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> notRepository
INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> notRepository,
BaseDomainService service
)
{
_repository = repository;
_detailRepository = detailRepository;
_notRepository = notRepository;
_service = service;
}
public virtual async Task<bool> GenerateSettlementOrder(List<HBPO_NOT_SA_DETAIL> p_list)
public virtual async Task<List<string>> GenerateSettlementOrder(List<HBPO_NOT_SA_DETAIL> p_list)
{
List<string> errors = new List<string>();
var priceErrors = await _service.CheckPriceList(p_list);
if (priceErrors.Count > 0)
{
foreach (var itm in priceErrors)
{
errors.Add($"发货单号或交付识别号零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据");
}
}
if (errors.Count > 0)
{
return errors;
}
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
var _entity = new HBPO_CAN_SA();
@ -81,7 +97,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
await _notRepository.DbContext.BulkDeleteAsync(p_list);
await _repository.DbContext.BulkInsertAsync(new List<HBPO_CAN_SA>() { _entity });
await _repository.DbContext.BulkInsertAsync(_entityList);
return true;
return errors;
}

599
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs

@ -17,6 +17,7 @@ using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Auditing;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;
@ -533,7 +534,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
return true;
}
else if (inv.BusinessType == EnumBusinessType.JisHBPO)
{
var pdlist = _pdhbpoRepository.Where(p => p_invs.Contains(p.BillNum)).ToList();//包含发票号的代扣减单
@ -889,6 +889,39 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
return true;
}
//public INVOICE_GRP FindAncestor(List<INVOICE_GRP> p_list,INVOICE_GRP currentNode, string invbillNum)
//{
// if (currentNode == null || currentNode.InvbillNum == invbillNum)
// {
// return currentNode;
// }
// var parentNode=p_list.Where(p => p.InvbillNum == currentNode.InvbillNum).FirstOrDefault();
// return FindAncestor(p_list, parentNode, invbillNum);
//}
//public virtual async Task<bool> IsSplittingMultipleInvoices(List<string> invs, string p_invbillnum)
//{
// _repository.Where(p=>)
//}
/// <summary>
/// 返回到财务审核状态
/// </summary>
@ -1049,7 +1082,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var query = from itm in dtos
join itm1 in ls
on new { itm.LU,itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU,itm1.PartCode, itm1.BeginDate, itm1.EndDate }
join itm2 in p_list on new { itm.PartCode, itm.SettleDate } equals new { itm2.PartCode, itm2.SettleDate }
join itm2 in p_list on new { itm.PartCode,itm.PN, itm.SettleDate } equals new { itm2.PartCode,itm2.PN, itm2.SettleDate }
select itm2;
foreach (var itm in query)
{
@ -1062,7 +1095,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var query1 = from itm in dtos
join itm1 in ls
on new { itm.LU,itm.PartCode ,itm.BeginDate, itm.EndDate } equals new { itm1.LU,itm1.PartCode, itm1.BeginDate, itm1.EndDate }
join itm2 in p_ajdlist on new { itm.PartCode, itm.SettleDate } equals new { itm2.PartCode, itm2.SettleDate }
join itm2 in p_ajdlist on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate }
select itm2;
foreach (var itm in query1)
@ -1167,11 +1200,217 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
public async Task<List<string>> FirstInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
where TDetail : SA_CAN_BASE
{
List<string> _invls = new List<string>();
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) });
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
Dictionary<string, decimal> copyDic = new Dictionary<string, decimal>();//变换数组副本
foreach (var itm in _query.ToList())
{
dic.Add(itm.GroupNum, itm.Amt);
copyDic.Add(itm.GroupNum, itm.Amt);
}
Dictionary<string, List<string>> invoiceMap = new Dictionary<string, List<string>>();
foreach (var itm in dic)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额
// List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类
if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组
{
foreach (var _itm1 in copyDic)
{
if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
{
invoiceGroupNumList.Add(itm.Key);
continue;
}
//var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU).Distinct().ToList();//每项LU种类
//luList.AddRange(grouplist);
//luList = luList.Distinct().ToList();
//if (luList.Count > 20)//累加零件不超过20种
//{
// continue;
//}
sum += _itm1.Value;
if (sum > 10000000)
{
break;
}
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
}
invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
foreach (var rem in invoiceGroupNumList)//移除
{
copyDic.Remove(rem);
}
}
}
if (invoiceMap.Keys.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
var salist = new List<TDetail>();
var adjlist = new List<PUB_ADJ_DETAIL>();
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
//反向查找结算数据
var invdetails = p_list.Where(p => ls.Contains(p.GroupNum)).ToList();
foreach (var detail in invdetails)
{
detail.InvbillNum = key;
salist.Add(detail);
}
if (!string.IsNullOrEmpty(p_parentInvBillNum))
{
//反向查找调整数据
var adjdetails = p_adjlist.Where(p => ls.Contains(p.GroupNum)).ToList();
foreach (var detail in adjdetails)
{
detail.InvBillNum = key;
adjdetails.Add(detail);
}
}
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID })
.Select(itm => new
{
PartCode = itm.Key.PartCode,
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.PartCode,
ContactDocID = itm.Key.ContractDocID,
Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),
Qty = itm.Sum(k => k.Qty),
BeginDate = itm.Key.BeginDate,
EndDate = itm.Key.EndDate
})
.ToList();
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2);
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: p_version,
invbillNum: key,
invGroupNum: p_InvGroupNum,
settleGroupNum: groupnum,
amt: 0,
extend1: string.Empty,
extend2: string.Empty
)
);
}
if (mapList.Count > 0)
{
groupList.AddRange(mapList);
}
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in detailDtos)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: p_version,
invbillNum: key,
invGroupNum: p_InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: businessType,
amt: detail.Amt,
pRICE: detail.Price,
extend1: string.Empty,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate,
partcode: detail.PartCode
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
var innotls = new List<INVOICE_NOT_SETTLE>();
if (p_notlist != null && p_notlist.Count > 0)
{
var notls = p_notlist.GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
foreach (var nitm in notls)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: p_version,
invGroupNum: p_InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: string.Empty,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: businessType,
invGroupNum: p_InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: string.Empty,
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
realAmt: 0
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
if (salist.Count > 0)
{
await _repository.DbContext.BulkUpdateAsync(salist);
}
if (adjlist.Count > 0)
{
await _repository.DbContext.BulkUpdateAsync(adjlist);
}
if (notDetialList.Count > 0)
{
await _repository.DbContext.BulkInsertAsync(notDetialList);
}
_invls = invlist.Select(p => p.InvbillNum).ToList();
}
return _invls;
}
/// <summary>
/// hbpojis,备件
/// hbpojis
/// </summary>
/// <param name="dtos">可结算明细列表</param>
/// <param name="p_version">版本号</param>
@ -1287,7 +1526,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var query = from itm in dtos
join itm1 in ls
on new { LU=itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate }
join itm2 in details on new { itm.LU,itm.PartCode, itm.SettleDate } equals new { itm2.LU,itm2.PartCode,itm2.SettleDate }
join itm2 in details on new { itm.LU,itm.PartCode,itm.PN, itm.SettleDate } equals new { itm2.LU,itm2.PartCode,itm2.PN,itm2.SettleDate }
select itm2;
foreach (var itm in query)
{
@ -1411,7 +1650,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <param name="p_parentInvBillNum"></param>
/// <param name="businessType"></param>
/// <returns></returns>
public async Task<List<string>> FirstInvoice<TDetail>(List<TDetail> p_list,List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
public async Task<List<string>> JITInvoice<TDetail>(List<TDetail> p_list,List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType,bool p_first)
where TDetail:SA_CAN_BASE
{
List<string> _invls = new List<string>();
@ -1426,7 +1665,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
Dictionary<string, List<string>> invoiceMap = new Dictionary<string, List<string>>();
foreach (var itm in dic)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
string invoiceBillNum = string.Empty;
if (p_first == true)
{
invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
}
else
{
invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV");
}
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额
@ -1618,6 +1866,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
return _invls;
}
/// <summary>
/// 重开一次开票
/// </summary>
@ -1644,15 +1896,53 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
inv.InvoiceState = InvoiceBillState.;
List<string> invlist = new List<string>();
if (inv.BusinessType == EnumBusinessType.MaiDanJianHBPO || inv.BusinessType == EnumBusinessType.BeiJian)
{
invlist = await MakeInvoice(p_list,p_adjlist, dtos, p_version, inv.InvGroupNum, string.Empty, inv.BusinessType, true);
}
else
switch (inv.BusinessType)
{
invlist = await FirstInvoice(p_list,p_adjlist,dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);//重开可以变多张发票
case EnumBusinessType.MaiDanJianHBPO:
invlist = await MakeInvoice(p_list, p_adjlist, dtos, p_version, inv.InvGroupNum, string.Empty, inv.BusinessType, true);
break;
case EnumBusinessType.MaiDanJianBBAC:
invlist = await MakeInvoice(p_list, p_adjlist, dtos, p_version, inv.InvGroupNum, string.Empty, inv.BusinessType, true);
break;
case EnumBusinessType.ZhiGongJianBBAC:
invlist = await JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, true);//重开可以变多张发票
break;
case EnumBusinessType.ZhiGongJianHBPO:
invlist = await JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, true);//重开可以变多张发票
break;
case EnumBusinessType.BeiJian:
invlist = await BJInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum,inv.InvbillNum, inv.BusinessType, true);
break;
case EnumBusinessType.JisBBAC:
invlist = await FirstInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);//重开可以变多张发票
break;
case EnumBusinessType.JisHBPO:
invlist = await FirstInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);//重开可以变多张发票
break;
case EnumBusinessType.YinDuJian:
invlist = await JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, true);//重开可以变多张发票
break;
}
//if (inv.BusinessType == EnumBusinessType.MaiDanJianHBPO)
//{
// invlist = await MakeInvoice(p_list,p_adjlist, dtos, p_version, inv.InvGroupNum, string.Empty, inv.BusinessType, true);
//}
//if (inv.BusinessType == EnumBusinessType.BeiJian)
//{
// invlist = await BJInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, string.Empty, inv.BusinessType, true);
//}
//else
//{
// invlist = await FirstInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);//重开可以变多张发票
//}
if (invlist.Count == 0)
{
return false;
@ -1670,6 +1960,255 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
return false;
}
public async Task<List<string>> BJInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType,bool p_first=true)
where TDetail : SA_CAN_BASE
{
List<string> _invls = new List<string>();
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) });
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
Dictionary<string, decimal> copyDic = new Dictionary<string, decimal>();//变换数组副本
foreach (var itm in _query.ToList())
{
dic.Add(itm.GroupNum, itm.Amt);
copyDic.Add(itm.GroupNum, itm.Amt);
}
Dictionary<string, List<string>> invoiceMap = new Dictionary<string, List<string>>();
foreach (var itm in dic)
{
string invoiceBillNum = string.Empty;
if (p_first == true)
{
invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
}
else
{
invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV");
}
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额
// List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类
if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组
{
foreach (var _itm1 in copyDic)
{
if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
{
invoiceGroupNumList.Add(itm.Key);
continue;
}
//var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU).Distinct().ToList();//每项LU种类
//luList.AddRange(grouplist);
//luList = luList.Distinct().ToList();
//if (luList.Count > 20)//累加零件不超过20种
//{
// continue;
//}
sum += _itm1.Value;
if (sum > 10000000)
{
break;
}
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
}
invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
foreach (var rem in invoiceGroupNumList)//移除
{
copyDic.Remove(rem);
}
}
}
if (invoiceMap.Keys.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
var salist = new List<TDetail>();
var adjlist = new List<PUB_ADJ_DETAIL>();
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
//反向查找结算数据
var invdetails = p_list.Where(p => ls.Contains(p.GroupNum)).ToList();
foreach (var detail in invdetails)
{
detail.InvbillNum = key;
salist.Add(detail);
}
if (!string.IsNullOrEmpty(p_parentInvBillNum))
{
//反向查找调整数据
var adjdetails = p_adjlist.Where(p => ls.Contains(p.GroupNum)).ToList();
foreach (var detail in adjdetails)
{
detail.InvBillNum = key;
adjdetails.Add(detail);
}
}
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID })
.Select(itm => new
{
PartCode = itm.Key.PartCode,
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.PartCode,
ContactDocID = itm.Key.ContractDocID,
Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),
Qty = itm.Sum(k => k.Qty),
BeginDate = itm.Key.BeginDate,
EndDate = itm.Key.EndDate
})
.ToList();
var query = from inv1 in invdetails
join dto1 in dtos on
new { inv1.LU, inv1.PN } equals new { dto1.LU, dto1.PN }
select new
{
PartCode = inv1.PartCode,
InvGroupNum = inv1.InvGroupNum,
LU = inv1.LU,
GroupNum=inv1.GroupNum,
Price = inv1.Price,
Amt = dto1.Amt,
Qty = dto1.Qty,
BeginDate = dto1.BeginDate,
EndDate = dto1.EndDate,
DeliveryNumber = inv1.GetProperty("DeliveryNumber", ""),//交货号
InvoiceNumber = inv1.GetProperty("InvoiceNumber", ""),//发票号
VendorCode = inv1.GetProperty("VendorCode", ""),//供应商代码
VendorName = inv1.GetProperty("VendorName", ""),//供应商名称
PurchaseOrderNumber = inv1.GetProperty("PurchaseOrderNumber", ""),//采购订单号
DeliveryIndexNumber = inv1.GetProperty("DeliveryIndexNumber", ""),//交付索引号
PartName = inv1.GetProperty("PartName", ""),//零件名称
};
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2);
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: p_version,
invbillNum: key,
invGroupNum: p_InvGroupNum,
settleGroupNum: groupnum,
amt: 0,
extend1: string.Empty,
extend2: string.Empty
)
);
}
if (mapList.Count > 0)
{
groupList.AddRange(mapList);
}
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in query.ToList())
{
var entity = new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: p_version,
invbillNum: key,
invGroupNum: p_InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: businessType,
amt: detail.Amt,
pRICE: detail.Price,
extend1: detail.GroupNum,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate,
partcode: detail.PartCode);
entity.SetProperty("DeliveryNumber", detail.DeliveryIndexNumber);//交货号
entity.SetProperty("VendorCode", detail.VendorCode);//供应商代码
entity.SetProperty("VendorName", detail.VendorName);//供应商名称
entity.SetProperty("PurchaseOrderNumber", "");//采购订单号
entity.SetProperty("DeliveryIndexNumber", "");//交付索引号
entity.SetProperty("PartName", "");//零件名称
_entityDetailList.Add( entity
);
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
//var innotls = new List<INVOICE_NOT_SETTLE>();
//if (p_notlist != null && p_notlist.Count > 0)
//{
// var notls = p_notlist.GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
// foreach (var nitm in notls)
// {
// innotls.Add(new INVOICE_NOT_SETTLE(
// guid: GuidGenerator.Create(),
// version: p_version,
// invGroupNum: p_InvGroupNum,
// settleGroupNum: nitm.GroupNum,
// lU: string.Empty,
// lU1: nitm.LU,
// extend1: string.Empty,
// extend2: string.Empty,
// qty: nitm.Qty
// ));
// }
// if (innotls.Count > 0)
// {
// notDetialList.AddRange(innotls);
// }
//}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: businessType,
invGroupNum: p_InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: string.Empty,
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
realAmt: 0
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
if (salist.Count > 0)
{
await _repository.DbContext.BulkUpdateAsync(salist);
}
if (adjlist.Count > 0)
{
await _repository.DbContext.BulkUpdateAsync(adjlist);
}
if (notDetialList.Count > 0)
{
await _repository.DbContext.BulkInsertAsync(notDetialList);
}
_invls = invlist.Select(p => p.InvbillNum).ToList();
}
return _invls;
}
/// <summary>
/// 重开二次开票
/// </summary>
@ -1696,14 +2235,36 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
inv.InvoiceState = InvoiceBillState.;
List<string> invlist = new List<string>();
if (inv.BusinessType == EnumBusinessType.MaiDanJianHBPO || inv.BusinessType == EnumBusinessType.BeiJian)
{
invlist = await MakeInvoice(p_list,p_adjlist, dtos, p_version, inv.InvGroupNum, string.Empty, inv.BusinessType, false);
}
else
switch (inv.BusinessType)
{
invlist = await SecInvoice(p_list,p_adjlist,dtos,p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);
case EnumBusinessType.MaiDanJianHBPO:
invlist = await MakeInvoice(p_list, p_adjlist, dtos, p_version, inv.InvGroupNum, string.Empty, inv.BusinessType, false);
break;
case EnumBusinessType.MaiDanJianBBAC:
invlist = await MakeInvoice(p_list, p_adjlist, dtos, p_version, inv.InvGroupNum, string.Empty, inv.BusinessType, false);
break;
case EnumBusinessType.ZhiGongJianBBAC:
invlist = await JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType,false);//重开可以变多张发票
break;
case EnumBusinessType.ZhiGongJianHBPO:
invlist = await JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, false);//重开可以变多张发票
break;
case EnumBusinessType.BeiJian:
invlist = await BJInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, false);
break;
case EnumBusinessType.JisBBAC:
invlist = await SecInvoice(p_list, p_adjlist, dtos, p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);
break;
case EnumBusinessType.JisHBPO:
invlist = await SecInvoice(p_list, p_adjlist, dtos, p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);
break;
case EnumBusinessType.YinDuJian:
invlist = await JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, false);//重开可以变多张发票
break;
}
if (invlist.Count == 0)
{
return false;

90
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs

@ -10,6 +10,8 @@ using Win.Sfs.Shared.RepositoryBase;
using Win.Sfs.SettleAccount.Bases;
using EFCore.BulkExtensions;
using SettleAccount.Domain.BQ;
using System.Security.Cryptography;
using Win.Sfs.SettleAccount.Bases.DomainServices;
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
@ -27,6 +29,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
private readonly INormalEfCoreRepository<PUB_CAN_SA, Guid> _repository;
private readonly INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> _detailRepository;
private readonly INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> _notRepository;
private readonly BaseDomainService _service;
public PUB_NOT_SA_MNG()
{
@ -36,14 +39,85 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
(
INormalEfCoreRepository<PUB_CAN_SA, Guid> repository,
INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> detailRepository,
INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> notRepository
INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> notRepository,
BaseDomainService service
)
{
_service = service;
_repository = repository;
_detailRepository = detailRepository;
_notRepository = notRepository;
}
public virtual async Task<bool> GenerateSettlementOrder(List<PUB_NOT_SA_DETAIL> p_list)
public virtual async Task<List<string>> GenerateSettlementOrder(List<PUB_NOT_SA_DETAIL> p_list)
{
List<string> errors = new List<string>();
var query = p_list.Select(p => p.BusinessType).Distinct();
foreach (var itm in query.ToList())
{
errors.Add("选择项有不在同一业务的数据!");
}
if (errors.Count > 0)
{
return errors;
}
var first= p_list.FirstOrDefault();
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO
|| first.BusinessType == EnumBusinessType.BeiJian
)
{
var ls = p_list.Select(p => p.GroupNum).Distinct().ToList();
var notlist = _notRepository.Where(p => ls.Contains(p.GroupNum)).ToList();//JIT_ASN整发
var priceErrors = await _service.CheckPriceList(notlist);
if (priceErrors.Count > 0)
{
foreach (var itm in priceErrors)
{
errors.Add($"发货单号或交付识别号零件{itm.LU}结算日期{itm.SettleDate}无价格区间数据");
}
}
if (errors.Count > 0)
{
return errors;
}
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
var _entity = new PUB_CAN_SA();
_entity.BillNum = billNumber;
_entity.InvGroupNum = billNumber;
_entity.Version = DateTime.Now.Year + DateTime.Now.Month;
_entity.State = SettleBillState.;
_entity.SettleBillNum = string.Empty;
var _entityList = new List<PUB_CAN_SA_DETAIL>();
foreach (var itm in notlist)
{
var _detailEntity = new PUB_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: billNumber,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: itm.Price,
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: billNumber,
invbillnum: string.Empty,
partcode: itm.PartCode
);
_entityList.Add(_detailEntity);
}
await _notRepository.DbContext.BulkDeleteAsync(p_list);
await _repository.DbContext.BulkInsertAsync(new List<PUB_CAN_SA>() { _entity });
await _repository.DbContext.BulkInsertAsync(_entityList);
}
else
{
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
var _entity = new PUB_CAN_SA();
@ -71,7 +145,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
groupNum: itm.GroupNum,
invGroupNum: billNumber,
invbillnum: string.Empty,
partcode:itm.PartCode
partcode: itm.PartCode
);
_entityList.Add(_detailEntity);
@ -79,7 +153,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
await _notRepository.DbContext.BulkDeleteAsync(p_list);
await _repository.DbContext.BulkInsertAsync(new List<PUB_CAN_SA>() { _entity });
await _repository.DbContext.BulkInsertAsync(_entityList);
return true;
}
return errors;
}

1
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Temp/TempClass.cs

@ -30,6 +30,7 @@ public class TMEP_INV
public class TEMP_CAN_SA_DETAIL
{
public Guid Id { set; get; }
/// <summary>
///关联结算单号
/// </summary>

5404
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230811013305_202308110001.Designer.cs

File diff suppressed because it is too large

44
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230811013305_202308110001.cs

@ -0,0 +1,44 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202308110001 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("824c911a-6915-42a3-8bb2-bcb4aca93545"));
migrationBuilder.AddColumn<string>(
name: "PartCode",
table: "Set_INVOICE_WAIT_DETAIL",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.InsertData(
table: "Set_VmiBalance",
columns: new[] { "Id", "BackupTime", "BillTime", "BillType", "CodeType", "ConcurrencyStamp", "Configcode", "CustomerPartCode", "DeliverTime", "ErpToLoc", "MatchNumber", "OrderNum", "PartCode", "PjsNum", "Qty", "ReMark", "RealCode", "Seq", "SubBillType", "UniqueCode", "VinCode", "factory" },
values: new object[] { new Guid("427dcb95-130f-40c7-8e7e-bf9cc2749dec"), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, null, "a20e124c6b89416ba16a2c424034dd37", null, null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "ErpToLoc", null, "OrderNum", "PartCode", null, 0m, null, null, null, 0, null, "VinCode", null });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("427dcb95-130f-40c7-8e7e-bf9cc2749dec"));
migrationBuilder.DropColumn(
name: "PartCode",
table: "Set_INVOICE_WAIT_DETAIL");
migrationBuilder.InsertData(
table: "Set_VmiBalance",
columns: new[] { "Id", "BackupTime", "BillTime", "BillType", "CodeType", "ConcurrencyStamp", "Configcode", "CustomerPartCode", "DeliverTime", "ErpToLoc", "MatchNumber", "OrderNum", "PartCode", "PjsNum", "Qty", "ReMark", "RealCode", "Seq", "SubBillType", "UniqueCode", "VinCode", "factory" },
values: new object[] { new Guid("824c911a-6915-42a3-8bb2-bcb4aca93545"), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, null, "1d0093aa74814ffd982671a5ac362c52", null, null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "ErpToLoc", null, "OrderNum", "PartCode", null, 0m, null, null, null, 0, null, "VinCode", null });
}
}
}

5413
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230814052555_20230814-1.Designer.cs

File diff suppressed because it is too large

67
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230814052555_20230814-1.cs

@ -0,0 +1,67 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202308141 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("427dcb95-130f-40c7-8e7e-bf9cc2749dec"));
migrationBuilder.AddColumn<Guid>(
name: "SeId",
table: "Set_HBPO_SE_EDI",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "SeId",
table: "Set_BBAC_SE_EDI",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<int>(
name: "BusinessType",
table: "Set_BBAC_SE_DETAIL",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.InsertData(
table: "Set_VmiBalance",
columns: new[] { "Id", "BackupTime", "BillTime", "BillType", "CodeType", "ConcurrencyStamp", "Configcode", "CustomerPartCode", "DeliverTime", "ErpToLoc", "MatchNumber", "OrderNum", "PartCode", "PjsNum", "Qty", "ReMark", "RealCode", "Seq", "SubBillType", "UniqueCode", "VinCode", "factory" },
values: new object[] { new Guid("8b20c772-ad8d-4733-9edc-986e1c9ba15a"), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, null, "f86cd4516dc2499a9a9aa43bb053416b", null, null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "ErpToLoc", null, "OrderNum", "PartCode", null, 0m, null, null, null, 0, null, "VinCode", null });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("8b20c772-ad8d-4733-9edc-986e1c9ba15a"));
migrationBuilder.DropColumn(
name: "SeId",
table: "Set_HBPO_SE_EDI");
migrationBuilder.DropColumn(
name: "SeId",
table: "Set_BBAC_SE_EDI");
migrationBuilder.DropColumn(
name: "BusinessType",
table: "Set_BBAC_SE_DETAIL");
migrationBuilder.InsertData(
table: "Set_VmiBalance",
columns: new[] { "Id", "BackupTime", "BillTime", "BillType", "CodeType", "ConcurrencyStamp", "Configcode", "CustomerPartCode", "DeliverTime", "ErpToLoc", "MatchNumber", "OrderNum", "PartCode", "PjsNum", "Qty", "ReMark", "RealCode", "Seq", "SubBillType", "UniqueCode", "VinCode", "factory" },
values: new object[] { new Guid("427dcb95-130f-40c7-8e7e-bf9cc2749dec"), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, null, "a20e124c6b89416ba16a2c424034dd37", null, null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "ErpToLoc", null, "OrderNum", "PartCode", null, 0m, null, null, null, 0, null, "VinCode", null });
}
}
}

5407
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230814073646_20230814-2.Designer.cs

File diff suppressed because it is too large

56
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230814073646_20230814-2.cs

@ -0,0 +1,56 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202308142 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("8b20c772-ad8d-4733-9edc-986e1c9ba15a"));
migrationBuilder.DropColumn(
name: "SeId",
table: "Set_HBPO_SE_EDI");
migrationBuilder.DropColumn(
name: "SeId",
table: "Set_BBAC_SE_EDI");
migrationBuilder.InsertData(
table: "Set_VmiBalance",
columns: new[] { "Id", "BackupTime", "BillTime", "BillType", "CodeType", "ConcurrencyStamp", "Configcode", "CustomerPartCode", "DeliverTime", "ErpToLoc", "MatchNumber", "OrderNum", "PartCode", "PjsNum", "Qty", "ReMark", "RealCode", "Seq", "SubBillType", "UniqueCode", "VinCode", "factory" },
values: new object[] { new Guid("27b08950-27f6-42ae-aeff-c7d19315b467"), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, null, "86c4ebf001bf4993a0cca2af4216ba92", null, null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "ErpToLoc", null, "OrderNum", "PartCode", null, 0m, null, null, null, 0, null, "VinCode", null });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("27b08950-27f6-42ae-aeff-c7d19315b467"));
migrationBuilder.AddColumn<Guid>(
name: "SeId",
table: "Set_HBPO_SE_EDI",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "SeId",
table: "Set_BBAC_SE_EDI",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.InsertData(
table: "Set_VmiBalance",
columns: new[] { "Id", "BackupTime", "BillTime", "BillType", "CodeType", "ConcurrencyStamp", "Configcode", "CustomerPartCode", "DeliverTime", "ErpToLoc", "MatchNumber", "OrderNum", "PartCode", "PjsNum", "Qty", "ReMark", "RealCode", "Seq", "SubBillType", "UniqueCode", "VinCode", "factory" },
values: new object[] { new Guid("8b20c772-ad8d-4733-9edc-986e1c9ba15a"), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, null, "f86cd4516dc2499a9a9aa43bb053416b", null, null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "ErpToLoc", null, "OrderNum", "PartCode", null, 0m, null, null, null, 0, null, "VinCode", null });
}
}
}

10
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

@ -624,6 +624,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<DateTime>("BillTime")
.HasColumnType("datetime2");
b.Property<int>("BusinessType")
.HasColumnType("int");
b.Property<string>("CodeType")
.HasColumnType("nvarchar(max)");
@ -2579,6 +2582,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<decimal>("PRICE")
.HasColumnType("decimal(18,2)");
b.Property<string>("PartCode")
.HasColumnType("nvarchar(max)");
b.Property<decimal>("Qty")
.HasColumnType("decimal(18,2)");
@ -4390,10 +4396,10 @@ namespace Win.Sfs.SettleAccount.Migrations
b.HasData(
new
{
Id = new Guid("824c911a-6915-42a3-8bb2-bcb4aca93545"),
Id = new Guid("27b08950-27f6-42ae-aeff-c7d19315b467"),
BillTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
BillType = 1,
ConcurrencyStamp = "1d0093aa74814ffd982671a5ac362c52",
ConcurrencyStamp = "86c4ebf001bf4993a0cca2af4216ba92",
DeliverTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
ErpToLoc = "ErpToLoc",
OrderNum = "OrderNum",

Loading…
Cancel
Save