Browse Source

[CI SKIP]

master
学 赵 1 year ago
parent
commit
bcc433d318
  1. 71
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
  2. 42
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs
  3. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs
  4. 21
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
  5. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs
  6. 40
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs
  7. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  8. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs
  9. 374
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionDelService.cs
  10. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs
  11. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs

71
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs

@ -9,6 +9,7 @@ using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using SettleAccount.Bases; using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using SettleAccount.Job.Services; using SettleAccount.Job.Services;
using Shouldly; using Shouldly;
using System; using System;
@ -35,6 +36,7 @@ using Win.Sfs.SettleAccount.Entities.TaskJobs;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
namespace Win.Sfs.SettleAccount.Bases namespace Win.Sfs.SettleAccount.Bases
{ {
@ -50,10 +52,10 @@ namespace Win.Sfs.SettleAccount.Bases
protected readonly VmiAppService _vimservice; protected readonly VmiAppService _vimservice;
protected readonly INormalEfCoreRepository<TEntity, Guid> _repository; protected readonly INormalEfCoreRepository<TEntity, Guid> _repository;
protected readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository; protected readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
protected readonly INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> _bbacSecRepository; protected readonly INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> _bbacSecRepository;
protected readonly INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> _hbpoSecRepository; protected readonly INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> _hbpoSecRepository;
protected readonly INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> _pubSecRepository; protected readonly INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> _pubSecRepository;
protected readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _invRepository;
private readonly TaskJobService _service; private readonly TaskJobService _service;
public PD_SERVICE( public PD_SERVICE(
@ -66,7 +68,8 @@ namespace Win.Sfs.SettleAccount.Bases
INormalEfCoreRepository<TEntity, Guid> repository, INormalEfCoreRepository<TEntity, Guid> repository,
VmiAppService vimservice, VmiAppService vimservice,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository, INormalEfCoreRepository<TEntityDetail, Guid> detailRepository,
TaskJobService service TaskJobService service,
INormalEfCoreRepository<INVOICE_GRP, Guid> invRepository
) : base(excelImportService, snowflakeIdGenerator, commonManager) ) : base(excelImportService, snowflakeIdGenerator, commonManager)
{ {
_service = service; _service = service;
@ -76,6 +79,7 @@ namespace Win.Sfs.SettleAccount.Bases
_bbacSecRepository = bbacSecRepository; _bbacSecRepository = bbacSecRepository;
_pubSecRepository = pubSecRepository; _pubSecRepository = pubSecRepository;
_hbpoSecRepository = hbpoSecRepository; _hbpoSecRepository = hbpoSecRepository;
_invRepository = invRepository;
} }
/// <summary> /// <summary>
@ -136,30 +140,59 @@ namespace Win.Sfs.SettleAccount.Bases
[UnitOfWork(false)] [UnitOfWork(false)]
public virtual async Task<string> ApprovalPassed(List<string> p_list) public virtual async Task<string> ApprovalPassed(List<string> p_list)
{ {
var bussinessType=p_list.FirstOrDefault();
return await InvokePD(p_list, _service); return await InvokePD(p_list, _service);
} }
[HttpPost] [HttpPost]
[UnitOfWork(false)] [UnitOfWork(false)]
public virtual async Task<string> RejectAsync(List<string> p_list) public virtual async Task<string> RejectAsync(List<string> p_list)
{ {
return await InvokePD(p_list, _service); var invlist = _repository.Where(p => p_list.Contains(p.BillNum)).ToList();
var states = invlist.Select(p => p.State).Distinct().ToList();
if (states.Count > 1)
{
throw new UserFriendlyException($"发票不是同一状态", "400");
}
var first = invlist.FirstOrDefault();//发票状态
if (first.State == SettleBillState.)
{
//var _taskid = await _service.ExportEnqueueAsync($"{first.BillNum}待扣减删除任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) =>
//{
//});
var pdList = _repository.Where(p => p_list.Contains(p.BillNum)).ToList();//扣减单内容
var pdDetailList = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList();//扣减单内容
var pdinvList = _invRepository.Where(p => p_list.Contains(p.InvbillNum)).ToList();
if (pdList.Count > 0)
{
await _repository.DbContext.BulkDeleteAsync(pdList);//删除待扣减
await _repository.DbContext.BulkDeleteAsync(pdDetailList);
foreach (var itm in pdinvList)
{
itm.State = SettleBillState.;
}
await _repository.DbContext.BulkUpdateAsync(pdinvList);//更新发票为关联发票
}
return "OK";
}
else
{
return await InvokePD(p_list, _service);
}
} }
/// <summary>
/// 调用扣减
/// </summary>
/// <param name="p_list"></param>
/// <param name="p_service"></param> /// <summary>
/// <param name="isback"></param> /// 调用扣减
/// <returns></returns> /// </summary>
/// <exception cref="UserFriendlyException"></exception> /// <param name="p_list"></param>
[UnitOfWork(false)] /// <param name="p_service"></param>
/// <param name="isback"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
[UnitOfWork(false)]
protected async Task<string> InvokePD(List<string> p_list, TaskJobService p_service, bool isback=false) protected async Task<string> InvokePD(List<string> p_list, TaskJobService p_service, bool isback=false)
{ {
var invlist=_repository.Where(p=>p_list.Contains(p.BillNum)).ToList(); var invlist=_repository.Where(p=>p_list.Contains(p.BillNum)).ToList();
@ -174,6 +207,8 @@ namespace Win.Sfs.SettleAccount.Bases
{ {
throw new UserFriendlyException($"当前发票状态不是【客户已收票】或【已扣减状态】不能进行出库扣减或撤销扣减操作", "400"); throw new UserFriendlyException($"当前发票状态不是【客户已收票】或【已扣减状态】不能进行出库扣减或撤销扣减操作", "400");
} }
if (first.State == SettleBillState.) if (first.State == SettleBillState.)
{ {
isback = false; isback = false;

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

@ -349,6 +349,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName = result }); return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName = result });
} }
var invBilllist = new List<INVOICE_WAIT_DETAIL_DTO>(); var invBilllist = new List<INVOICE_WAIT_DETAIL_DTO>();
var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list); var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list);
if (adjlist == null && adjlist.Count == 0) if (adjlist == null && adjlist.Count == 0)
@ -364,6 +365,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组 //var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组
var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false); var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false);
if (inv == null)
{
throw new UserFriendlyException($"无原发票记录!", "400");
}
if (inv.InvoiceState == InvoiceBillState.)
{
throw new UserFriendlyException($"已经报废发票不能再次报废!", "400");
}
if ( inv.State!= SettleBillState.
&& inv.State!=SettleBillState.QAD
&& inv.State!=SettleBillState.
&& inv.State != SettleBillState.
)
{
throw new UserFriendlyException($"发票只有在财务已审核、客户已收票、已扣减、已提交QAD状态下可以报废!", "400");
}
var settle = await _bbacMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false); var settle = await _bbacMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false);
if (settle == null) if (settle == null)
@ -503,6 +524,27 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组 //var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组
var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false); var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false);
if (inv == null)
{
throw new UserFriendlyException($"无原发票记录!", "400");
}
if (inv.InvoiceState == InvoiceBillState.)
{
throw new UserFriendlyException($"已经报废发票不能再次报废!", "400");
}
if (inv.State != SettleBillState.
&& inv.State != SettleBillState.QAD
&& inv.State != SettleBillState.
&& inv.State != SettleBillState.
)
{
throw new UserFriendlyException($"发票只有在财务已审核、客户已收票、已扣减、已提交QAD状态下可以报废!", "400");
}
var settle = await _bbacMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false); var settle = await _bbacMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false);
if (settle == null) if (settle == null)

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs

@ -30,8 +30,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
BBAC_PD_DETAIL, BBAC_PD_DETAIL_DTO, BBAC_PD_REQ_DTO, BBAC_PD_DETAIL, BBAC_PD_DETAIL_DTO, BBAC_PD_REQ_DTO,
BBAC_PD_DETAIL_REQ_DTO, BBAC_PD_DETAIL_EXP_DTO> BBAC_PD_DETAIL_REQ_DTO, BBAC_PD_DETAIL_EXP_DTO>
{ {
public BBAC_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<BBAC_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<BBAC_PD_DETAIL, Guid> detailRepository, TaskJobService service, INormalEfCoreRepository<INVOICE_GRP, Guid> invRepository) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository, service, invRepository)
public BBAC_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<BBAC_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<BBAC_PD_DETAIL, Guid> detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository, service)
{ {
} }
} }

21
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs

@ -325,6 +325,27 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var invbillnum = first.InvBillNum; var invbillnum = first.InvBillNum;
var version = int.Parse(DateTime.Now.ToString("yyyymm")); var version = int.Parse(DateTime.Now.ToString("yyyymm"));
var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false); var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false);
if (inv == null)
{
throw new UserFriendlyException($"无原发票记录!", "400");
}
if (inv.InvoiceState == InvoiceBillState.)
{
throw new UserFriendlyException($"已经报废发票不能再次报废!", "400");
}
if (inv.State != SettleBillState.
&& inv.State != SettleBillState.QAD
&& inv.State != SettleBillState.
&& inv.State != SettleBillState.
)
{
throw new UserFriendlyException($"发票只有在财务已审核、客户已收票、已扣减、已提交QAD状态下可以报废!", "400");
}
var settle = await _hbpoMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false); var settle = await _hbpoMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false);
if (settle == null) if (settle == null)
{ {

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

@ -25,7 +25,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
HBPO_PD_DETAIL, HBPO_PD_DETAIL_DTO, HBPO_PD_REQ_DTO, HBPO_PD_DETAIL, HBPO_PD_DETAIL_DTO, HBPO_PD_REQ_DTO,
HBPO_PD_DETAIL_REQ_DTO, HBPO_PD_DETAIL_EXP_DTO> HBPO_PD_DETAIL_REQ_DTO, HBPO_PD_DETAIL_EXP_DTO>
{ {
public HBPO_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<HBPO_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<HBPO_PD_DETAIL, Guid> detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository, service) public HBPO_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<HBPO_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<HBPO_PD_DETAIL, Guid> detailRepository, TaskJobService service, INormalEfCoreRepository<INVOICE_GRP, Guid> invRepository) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository, service, invRepository)
{ {
} }
} }

40
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs

@ -350,6 +350,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组 //var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组
var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false); var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false);
if (inv == null)
{
throw new UserFriendlyException($"无原发票记录!", "400");
}
if (inv.InvoiceState == InvoiceBillState.)
{
throw new UserFriendlyException($"已经报废发票不能再次报废!", "400");
}
if (inv.State != SettleBillState.
&& inv.State != SettleBillState.QAD
&& inv.State != SettleBillState.
&& inv.State != SettleBillState.
)
{
throw new UserFriendlyException($"发票只有在财务已审核、客户已收票、已扣减、已提交QAD状态下可以报废!", "400");
}
var settle = await _pubMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false); var settle = await _pubMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false);
if (settle == null) if (settle == null)
@ -524,6 +544,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var version = int.Parse(DateTime.Now.ToString("yyyymm")); var version = int.Parse(DateTime.Now.ToString("yyyymm"));
//var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组 //var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组
var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false); var inv = await GetInvoiceGroupByInvBillNum(invbillnum).ConfigureAwait(false);
if (inv == null)
{
throw new UserFriendlyException($"无原发票记录!", "400");
}
if (inv.InvoiceState == InvoiceBillState.)
{
throw new UserFriendlyException($"已经报废发票不能再次报废!", "400");
}
if (inv.State != SettleBillState.
&& inv.State != SettleBillState.QAD
&& inv.State != SettleBillState.
&& inv.State != SettleBillState.
)
{
throw new UserFriendlyException($"发票只有在财务已审核、客户已收票、已扣减、已提交QAD状态下可以报废!", "400");
}
var settle = await _pubMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false); var settle = await _pubMng.GetMainAsync(inv.InvGroupNum).ConfigureAwait(false);
if (settle == null) if (settle == null)
{ {

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

@ -94,9 +94,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
} }
if (await _pubMng.SetForwardState(main, SettleBillState.).ConfigureAwait(false)) if (await _pubMng.SetForwardState(main, SettleBillState.).ConfigureAwait(false))
{ {
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
entitys = entitys.OrderBy(p => p.IndexNum).ToList(); entitys = entitys.OrderBy(p => p.IndexNum).ToList();
var dto1s = ObjectMapper.Map<List<PUB_CAN_SA_DETAIL>, List<PUB_CAN_SA_DETAIL_DTO>>(entitys); var dto1s = ObjectMapper.Map<List<PUB_CAN_SA_DETAIL>, List<PUB_CAN_SA_DETAIL_DTO>>(entitys);

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

@ -26,7 +26,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
PUB_PD_DETAIL, PUB_PD_DETAIL_DTO, PUB_PD_REQ_DTO, PUB_PD_DETAIL, PUB_PD_DETAIL_DTO, PUB_PD_REQ_DTO,
PUB_PD_DETAIL_REQ_DTO, PUB_PD_DETAIL_EXP_DTO> PUB_PD_DETAIL_REQ_DTO, PUB_PD_DETAIL_EXP_DTO>
{ {
public PUB_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<PUB_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<PUB_PD_DETAIL, Guid> detailRepository, TaskJobService service) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository, service) public PUB_PD_SERVICE(INormalEfCoreRepository<BBAC_SEC_DETAIL, Guid> bbacSecRepository, INormalEfCoreRepository<HBPO_SEC_DETAIL, Guid> hbpoSecRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSecRepository, IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<PUB_PD, Guid> repository, VmiAppService vimservice, INormalEfCoreRepository<PUB_PD_DETAIL, Guid> detailRepository, TaskJobService service, INormalEfCoreRepository<INVOICE_GRP, Guid> invRepository) : base(bbacSecRepository, hbpoSecRepository, pubSecRepository, excelImportService, snowflakeIdGenerator, commonManager, repository, vimservice, detailRepository, service, invRepository)
{ {
} }
} }

374
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionDelService.cs

@ -0,0 +1,374 @@
using System;
using System.Collections.Generic;
using System.Linq;
using EFCore.BulkExtensions;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using TaskJob.EventArgs;
using TaskJob.Interfaces;
using Volo.Abp.Application.Services;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Emailing;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.Entities.CodeSettings;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
{
public class PendingDeductionDelService : ApplicationService, ITransientDependency, IExportJob
{
protected readonly SettleAccountDbContext _dbcontext;
private readonly IEmailSender _emailSender;
public PendingDeductionDelService(
SettleAccountDbContext dbcontext,
IEmailSender emailSender
)
{
_emailSender = emailSender;
_dbcontext = dbcontext;
}
[UnitOfWork(false)]
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property)
{
var billList = property.Where(p => p.Name == "BillNumList").FirstOrDefault().Value;
var type = property.Where(p => p.Name == "Type").FirstOrDefault().Value;
var isout = property.Where(p => p.Name == "IsOut").FirstOrDefault().Value;
var email = string.Empty;
// property.Where(p => p.Name == "CurrentUserEmail").FirstOrDefault().Value;
var list = billList.Split(",");
var projectList = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "库位");
if (type == "JisBBAC" || type == "ZhiGongJianBBAC" || type == "MaiDanJianBBAC" || type == "BeiJian")
{
var jisdetail = _dbcontext.Set<BBAC_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.JisBBAC);//jis
if (jisdetail != null && jisdetail.Count() > 0)
{
foreach (var itm in jisdetail)
{
if (itm.Site == "1040" && string.IsNullOrEmpty(itm.Extend2))
{
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description;
}
else
{
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC顺义").Description;
}
}
Sync(jisdetail.ToList(), EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false);
}
var mdetail = _dbcontext.Set<BBAC_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.MaiDanJianBBAC);//买单件
if (mdetail != null && mdetail.Count() > 0)
{
foreach (var itm in jisdetail)
{
if (itm.Site == "1040" && string.IsNullOrEmpty(itm.Extend2))
{
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC").Description;
}
else
{
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "JisBBAC顺义").Description;
}
}
Sync(mdetail.ToList(), EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false);
}
var detailist1 = _dbcontext.Set<PUB_PD_DETAIL>().Where(p => list.Contains(p.BillNum)).ToList();
if (detailist1.Count > 0)
{
var zgbbaclist = detailist1.Where(p => p.BusinessType == EnumBusinessType.ZhiGongJianBBAC).ToList();
foreach (var itm in zgbbaclist)
{
if (itm.Site == "1040" && string.IsNullOrEmpty(itm.Extend2))
{
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "ZhiGongJianBBAC").Description;
}
else
{
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "ZhiGongJianBBAC顺义").Description;
}
}
Sync(zgbbaclist, EnumDeliverBjBmpBillType.JIT直供件, email, isout == "out" ? true : false);
var ydlist = detailist1.Where(p => p.BusinessType == EnumBusinessType.YinDuJian).ToList();
if (ydlist.Count > 0)
{
foreach (var itm in zgbbaclist)
{
if (string.IsNullOrEmpty(itm.Extend2))
{
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "YinDuJian").Description;
}
}
Sync(ydlist, EnumDeliverBjBmpBillType., email, isout == "out" ? true : false);
}
var bjlist = detailist1.Where(p => p.BusinessType == EnumBusinessType.BeiJian).ToList();
if (bjlist.Count > 0)
{
foreach (var itm in bjlist)
{
if (string.IsNullOrEmpty(itm.Extend2))
{
itm.Extend2 = projectList.FirstOrDefault(p => p.Value == "BeiJian").Description;
}
}
Sync(bjlist, EnumDeliverBjBmpBillType.4S备件, email, isout == "out" ? true : false);
}
}
}
else if (type == "JisHBPO" || type == "ZhiGongJianHBPO" || type == "MaiDanJianHBPO")
{
var detailist = _dbcontext.Set<HBPO_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.JisHBPO).ToList();
foreach (var itm in detailist)
{
if (string.IsNullOrEmpty(itm.Extend2))
{
itm.Extend2 = "CC017";
}
}
if(detailist.Count>0)
{
Sync(detailist, EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false);
}
var mdetail = _dbcontext.Set<HBPO_PD_DETAIL>().Where(p => list.Contains(p.BillNum) && p.BusinessType == EnumBusinessType.MaiDanJianHBPO).ToList();//买单件
foreach (var itm in mdetail)
{
if (string.IsNullOrEmpty(itm.Extend2))
{
itm.Extend2 = "CC017";
}
}
if (mdetail.Count > 0)
{
Sync(mdetail.ToList(), EnumDeliverBjBmpBillType.JIS件, email, isout == "out" ? true : false);
}
var detailist1 = _dbcontext.Set<PUB_PD_DETAIL>().Where(p => list.Contains(p.BillNum)).ToList();
var zgbbaclist = detailist1.Where(p => p.BusinessType == EnumBusinessType.ZhiGongJianHBPO).ToList();
foreach (var itm in zgbbaclist)
{
if (string.IsNullOrEmpty(itm.Extend2))
{
itm.Extend2 = "CC017";
}
}
if (zgbbaclist.Count > 0)
{
Sync(zgbbaclist, EnumDeliverBjBmpBillType.JIT直供件, email, isout == "out" ? true : false);
}
}
return id.ToString();
}
//public List<T> GetPagedData<T>(List<T> dataList, int pageNumber, int pageSize)
//{
// int startIndex = (pageNumber - 1) * pageSize;
// return dataList.Skip(startIndex).Take(pageSize).ToList();
//}
//public int CalculatePageCount(int totalCount, int pageSize)
//{
// int pageCount = totalCount / pageSize;
// if (totalCount % pageSize != 0)
// {
// pageCount += 1;
// }
// return pageCount;
//}
[UnitOfWork(false)]
public void Sync<T>(List<T> p_ls, EnumDeliverBjBmpBillType bussinessType, string p_email, bool flag = true) where T : PD_BASE, new()
{
var query = from itm in p_ls
select new VmiLog()
{
CodeType = string.Empty,
BillTime = DateTime.Now,
ChangedTime = DateTime.Now,
Qty = itm.Qty,
RealPartCode = itm.RELU,//替换件 结算数据 RealPartCode->RELU
RealCode = itm.RELU,
LogType = Entities.BQ.Vmi.VmiLogType.Type200,
ChangedQty = (flag == true) ? -itm.Qty : itm.Qty,
ChangedType = VmiType.Out,
//SubBillType = EnumDeliverSubBillType.小件BBAC,
//BillType = EnumDeliverBjBmpBillType.JIS件,
CustPartCode = itm.LU,
SettlementVinCode = itm.PN,
DeliverBillType = bussinessType,
VinCode = itm.PN,
OrderNum = itm.GroupNum,
ErpToLoc = itm.Extend2, //寄售库
};
var ls = query.ToList();
foreach (var itm in ls)
{
itm.SetId(GuidGenerator.Create());
}
var _first = p_ls.FirstOrDefault();
bool issucess = true;
using (var transaction = _dbcontext.Database.BeginTransaction())
{
try
{
// 执行批量数据操作
if (ls != null && ls.Count > 0)
{
var messagelist = new List<VmiMessage>();
foreach (var item in ls)
{
var message = new VmiMessage
{
Message = System.Text.Json.JsonSerializer.Serialize(item),
};
messagelist.Add(message);
}
_dbcontext.BulkInsert(messagelist);
_dbcontext.BulkInsert(ls, new BulkConfig() { });
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList();//同步数据的发票号
var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList();//扣减单内容
var pdinvList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList();
if (pdList.Count > 0)
{
if (flag == true)
{
foreach (var item in pdList)
{
item.State = SettleBillState.;
}
foreach (var item in pdinvList)
{
item.State = SettleBillState.;
}
_dbcontext.BulkUpdate(pdList);
_dbcontext.BulkUpdate(pdinvList);
}
else
{
_dbcontext.BulkDelete(pdList);
_dbcontext.BulkDelete(p_ls);
}
}
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
var bbacinvList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList();
if (bbacList.Count > 0)
{
if (flag == true)
{
foreach (var item in bbacList)
{
item.State = SettleBillState.;
}
foreach (var item in bbacinvList)
{
item.State = SettleBillState.;
}
_dbcontext.BulkUpdate(bbacList);
_dbcontext.BulkUpdate(bbacinvList);
}
else
{
_dbcontext.BulkDelete(pdList);
_dbcontext.BulkDelete(p_ls);
}
}
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
var hbpoinvList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList();//发票
if (hbpoList.Count > 0)
{
if (flag == true)
{
foreach (var item in hbpoList)
{
item.State = SettleBillState.;
}
foreach (var item in hbpoinvList)
{
item.State = SettleBillState.;
}
_dbcontext.BulkUpdate(hbpoList);
_dbcontext.BulkUpdate(hbpoinvList);
}
else
{
_dbcontext.BulkDelete(pdList);
_dbcontext.BulkDelete(p_ls);
}
}
}
// _emailSender.SendAsync(e)
// 提交事务
transaction.Commit();
}
catch (Exception)
{
issucess = false;
// 回滚事务
transaction.Rollback();
}
}
if (issucess ==false)
{
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList();
var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
if (pdList.Count > 0)
{
foreach (var item in pdList)
{
if (flag == true)
{
item.State = SettleBillState.;
}
else
{
item.State = SettleBillState.;
}
}
_dbcontext.BulkUpdate(pdList);
}
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
if (bbacList.Count > 0)
{
foreach (var item in bbacList)
{
if (flag == true)
{
item.State = SettleBillState.;
}
else
{
item.State = SettleBillState.;
}
}
_dbcontext.BulkUpdate(bbacList);
}
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
if (hbpoList.Count > 0)
{
foreach (var item in hbpoList)
{
if (flag == true)
{
item.State = SettleBillState.;
}
else
{
item.State = SettleBillState.;
}
}
_dbcontext.BulkUpdate(hbpoList);
}
}
}
}
}

5
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs

@ -34,13 +34,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
[UnitOfWork(false)] [UnitOfWork(false)]
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property)
{ {
var billList = property.Where(p => p.Name == "BillNumList").FirstOrDefault().Value; var billList = property.Where(p => p.Name == "BillNumList").FirstOrDefault().Value;
var type = property.Where(p => p.Name == "Type").FirstOrDefault().Value; var type = property.Where(p => p.Name == "Type").FirstOrDefault().Value;
var isout = property.Where(p => p.Name == "IsOut").FirstOrDefault().Value; var isout = property.Where(p => p.Name == "IsOut").FirstOrDefault().Value;
var email = string.Empty; var email = string.Empty;
// property.Where(p => p.Name == "CurrentUserEmail").FirstOrDefault().Value; // property.Where(p => p.Name == "CurrentUserEmail").FirstOrDefault().Value;
var list = billList.Split(","); var list = billList.Split(",");
var projectList = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "库位"); var projectList = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "库位");
if (type == "JisBBAC" || type == "ZhiGongJianBBAC" || type == "MaiDanJianBBAC" || type == "BeiJian") if (type == "JisBBAC" || type == "ZhiGongJianBBAC" || type == "MaiDanJianBBAC" || type == "BeiJian")
{ {
@ -78,6 +78,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
} }
var detailist1 = _dbcontext.Set<PUB_PD_DETAIL>().Where(p => list.Contains(p.BillNum)).ToList(); var detailist1 = _dbcontext.Set<PUB_PD_DETAIL>().Where(p => list.Contains(p.BillNum)).ToList();
if (detailist1.Count > 0) if (detailist1.Count > 0)
{ {
var zgbbaclist = detailist1.Where(p => p.BusinessType == EnumBusinessType.ZhiGongJianBBAC).ToList(); var zgbbaclist = detailist1.Where(p => p.BusinessType == EnumBusinessType.ZhiGongJianBBAC).ToList();

6
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs

@ -81,6 +81,12 @@ namespace Win.Sfs.SettleAccount
{ {
return implementationFactory.GetService<PendingDeductionService>(); return implementationFactory.GetService<PendingDeductionService>();
} }
if (key.Equals(typeof(PendingDeductionDelService).FullName))
{
return implementationFactory.GetService<PendingDeductionDelService>();
}
else else
{ {
throw new ArgumentException($"Not Support key:{key}"); throw new ArgumentException($"Not Support key:{key}");

Loading…
Cancel
Save