Browse Source

更新服务

master
学 赵 1 year ago
parent
commit
3fb6a4b0de
  1. 39
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs
  2. 22
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs
  3. 46
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs
  4. 81
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
  5. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  6. 33
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
  7. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  8. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_NOT_SA_SERVICE.cs
  9. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs
  10. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
  11. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  12. 32
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs
  13. 19
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  14. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs
  15. 16
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  16. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Jobs/TaskJobService.cs
  17. 13
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  18. 269
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/CAN_SA_MNG.cs
  19. 563
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  20. 89
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/NOT_SA_MNG.cs
  21. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_ADJ_DETAIL.cs
  22. 13
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Temp/TempClass.cs
  23. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs
  24. 370
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/PendingDeduction/PendingDeductionDapperRepository.cs
  25. 117
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/PD_SERVICE.cs
  26. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs
  27. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleDoorPanelExportService.cs
  28. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnInvoiceSettledDetailDiffExportService.cs

39
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs

@ -14,7 +14,6 @@ using Win.Sfs.Shared.Filter;
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
{ {
public class INVOICE_GRP_DTO : EntityDto<Guid> public class INVOICE_GRP_DTO : EntityDto<Guid>
{ {
[Display(Name = "期间")] [Display(Name = "期间")]
public int Version { set; get; } public int Version { set; get; }
@ -61,11 +60,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
} }
public class INVOICE_GRP_EXP_DTO public class INVOICE_GRP_EXP_DTO
{ {
/// <summary> /// <summary>
///实际纸质发票号 ///实际纸质发票号
/// </summary> /// </summary>
@ -92,9 +88,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
[ExporterHeader(DisplayName = "税后金额")] [ExporterHeader(DisplayName = "税后金额")]
public decimal TaxAmt { get; set; } public decimal TaxAmt { get; set; }
} }
public class INVOICE_GRP_IMP_DTO public class INVOICE_GRP_IMP_DTO
@ -126,10 +119,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public class INVOICE_GRP_REQ_DTO : RequestInputBase public class INVOICE_GRP_REQ_DTO : RequestInputBase
{ {
[Display(Name = "实际纸质发票号")] [Display(Name = "实际纸质发票号")]
public string RealnvBillNum { get; set; } public string RealnvBillNum { get; set; }
[Display(Name = "未税金额")] [Display(Name = "未税金额")]
public decimal Amt { get; set; } public decimal Amt { get; set; }
[Display(Name = "税后金额")] [Display(Name = "税后金额")]
@ -142,19 +133,31 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public int State { set; get; } public int State { set; get; }
[Display(Name = "业务类别")] [Display(Name = "业务类别")]
public EnumBusinessType BusinessType { get; set; } public EnumBusinessType BusinessType { get; set; }
} }
/// <summary>
/// 结算明细
/// </summary>
public class INVOICE_GRP_DETAIL_DTO : EntityDto<Guid> public class INVOICE_GRP_DETAIL_DTO : EntityDto<Guid>
{ {
/// <summary>
/// 发票明细
/// </summary>
public List<INVOICE_WAIT_DETAIL_DTO> INVOICE_WAIT_DETAIL { get; set; } public List<INVOICE_WAIT_DETAIL_DTO> INVOICE_WAIT_DETAIL { get; set; }
/// <summary>
/// 发票和结算分组对应关系
/// </summary>
public List<INVOICE_MAP_GROUP_DTO> INVOICE_MAP_GROUP { get; set; } public List<INVOICE_MAP_GROUP_DTO> INVOICE_MAP_GROUP { get; set; }
/// <summary>
/// 已结分组包含不可结算零件
/// </summary>
public List<INVOICE_NOT_SETTLE_DTO> INVOICE_NOT_SETTLE { get; set; } public List<INVOICE_NOT_SETTLE_DTO> INVOICE_NOT_SETTLE { get; set; }
/// <summary>
/// 发票调整明细
/// </summary>
public List<PUB_ADJ_DETAIL_DTO> ADJ_DETAIL { get; set; } public List<PUB_ADJ_DETAIL_DTO> ADJ_DETAIL { get; set; }
@ -239,11 +242,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
} }
public class INVOICE_MAP_GROUP_DTO : EntityDto<Guid> public class INVOICE_MAP_GROUP_DTO : EntityDto<Guid>
{ {
@ -290,9 +288,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public class INVOICE_MAP_GROUP_EXP_DTO public class INVOICE_MAP_GROUP_EXP_DTO
{ {
/// <summary> /// <summary>
///期间 ///期间
/// </summary> /// </summary>
@ -329,7 +325,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
[ExporterHeader(DisplayName = "扩展字段2")] [ExporterHeader(DisplayName = "扩展字段2")]
public string Extend2 { get; set; } public string Extend2 { get; set; }
} }
@ -408,7 +403,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
} }

22
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs

@ -10,13 +10,14 @@ using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.Shared.Filter; using Win.Sfs.Shared.Filter;
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos; namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos;
public class PUB_ADJ_DETAIL_DTO : EntityDto<Guid>
{ public class PUB_ADJ_DETAIL_DTO : EntityDto<Guid>
/// <summary> {
///作废发票号 ///// <summary>
/// </summary> /////作废发票号
[Display(Name = "作废发票号")] ///// </summary>
public string OldInvBillNum { get; set; } //[Display(Name = "作废发票号")]
//public string OldInvBillNum { get; set; }
/// <summary> /// <summary>
///发票号 ///发票号
/// </summary> /// </summary>
@ -29,8 +30,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos;
[Display(Name = "下线日期")] [Display(Name = "下线日期")]
public DateTime SettleDate { get; set; } public DateTime SettleDate { get; set; }
[Display(Name = "发票分组号")] //[Display(Name = "发票分组号")]
public string InvGroupNum { get; set; } //public string InvGroupNum { get; set; }
[Display(Name = "零件号")] [Display(Name = "零件号")]
public string LU { get; set; } public string LU { get; set; }
[Display(Name = "标识号")] [Display(Name = "标识号")]
@ -39,8 +40,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos;
public decimal Qty { get; set; } public decimal Qty { get; set; }
[Display(Name = "结算分组")] [Display(Name = "结算分组")]
public string GroupNum { get; set; } public string GroupNum { get; set; }
}
}
public class PUB_ADJ_DETAIL_EXP_DTO public class PUB_ADJ_DETAIL_EXP_DTO
{ {
/// <summary> /// <summary>

46
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using DocumentFormat.OpenXml.Office2010.Excel;
using EFCore.BulkExtensions; using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
@ -17,6 +18,7 @@ using Win.Sfs.SettleAccount.Bases.DomainServices;
using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
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;
@ -31,15 +33,20 @@ public class ADJ_SERVICE : BASE_SERVICE
{ {
protected readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _repository; protected readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _repository;
protected readonly BaseDomainService _baseDomainService; protected readonly BaseDomainService _baseDomainService;
protected readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _invRepository;
public ADJ_SERVICE( public ADJ_SERVICE(
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> repository, INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> repository,
BaseDomainService baseDomainService, BaseDomainService baseDomainService,
IExcelImportAppService excelImportService, IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator, ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager ICommonManager commonManager,
INormalEfCoreRepository<INVOICE_GRP, Guid> invRepository
) )
: base(excelImportService, snowflakeIdGenerator, commonManager) : base(excelImportService, snowflakeIdGenerator, commonManager)
{ {
_invRepository = invRepository;
_repository = repository; _repository = repository;
_baseDomainService = baseDomainService; _baseDomainService = baseDomainService;
} }
@ -74,12 +81,19 @@ public class ADJ_SERVICE : BASE_SERVICE
{ {
throw new BusinessException("8989", "导入数据记录为0条"); throw new BusinessException("8989", "导入数据记录为0条");
} }
var deletels = _repository.Where(p => p.OldInvBillNum == result.FirstOrDefault().OldInvBillNum).ToList(); var invs=result.Select(p => p.OldInvBillNum).ToList();//所有发票号
var first = deletels.FirstOrDefault(); var deletels = _repository.Where(p =>invs.Contains(p.OldInvBillNum) ).ToList();//所有关联发票号的调整表
if (!string.IsNullOrEmpty(first.InvBillNum)) var invlist= _invRepository.Where(p => invs.Contains(p.InvbillNum)).ToList();//所有发票
var dlists= deletels.Where(p=>string.IsNullOrEmpty(p.InvBillNum)).ToList();//所有新发票号不为空的调整记录
foreach (var itm in dlists)
{ {
throw new BusinessException("8989", $"调整记录已经新发票号:{first.InvBillNum}"); errorList.Add(new ErrorExportDto() { ItemCode = $"{itm.LU}", Message = $"客户零件号{itm.LU}标识号{itm.PN}下线日期{itm.SettleDate}记录已经被重新开票,新发票号为:{itm.InvBillNum}" });
} }
//var first = deletels.FirstOrDefault();
//if (!string.IsNullOrEmpty(first.InvBillNum))
//{
// throw new BusinessException("8989", $"调整记录已经生成新发票号:{first.InvBillNum}");
//}
var entityList = ObjectMapper.Map<List<PUB_ADJ_DETAIL_IMP_DTO>, List<PUB_ADJ_DETAIL>>(result); var entityList = ObjectMapper.Map<List<PUB_ADJ_DETAIL_IMP_DTO>, List<PUB_ADJ_DETAIL>>(result);
var codelist = entityList.Select(p => p.LU).ToList(); var codelist = entityList.Select(p => p.LU).ToList();
var errors = await _baseDomainService.CheckBase(codelist, new BASE_CONF() { IsRelationShip = true }); var errors = await _baseDomainService.CheckBase(codelist, new BASE_CONF() { IsRelationShip = true });
@ -96,8 +110,28 @@ public class ADJ_SERVICE : BASE_SERVICE
errorList.Add(new ErrorExportDto() { ItemCode = $"{itm.LU}", Message = $"客户零件号{itm.LU}标识号{itm.PN}下线日期{itm.SettleDate}不存在价格单记录" }); errorList.Add(new ErrorExportDto() { ItemCode = $"{itm.LU}", Message = $"客户零件号{itm.LU}标识号{itm.PN}下线日期{itm.SettleDate}不存在价格单记录" });
} }
} }
var query = from itm in entityList
join itm1 in invlist
on itm.InvBillNum equals itm1.InvbillNum
select new PUB_ADJ_DETAIL(
id: GuidGenerator.Create(),
keyCode: itm.PN + itm.LU,
version: itm.Version,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
extend1: string.Empty,
price: 0,
invGroupNum: itm1.InvGroupNum,
settleDate: itm.SettleDate,
businessType: itm1.BusinessType,
groupNum: itm.GroupNum,
oldinv: itm.InvBillNum,
inv: string.Empty);
await _repository.DbContext.BulkDeleteAsync(deletels);//删除发票下所有调整明细 await _repository.DbContext.BulkDeleteAsync(deletels);//删除发票下所有调整明细
await _repository.DbContext.BulkInsertAsync(entityList); await _repository.DbContext.BulkInsertAsync(query.ToList());
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }

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

@ -1,5 +1,6 @@
using CodeArts.Db.Lts; using CodeArts.Db.Lts;
using DocumentFormat.OpenXml.Bibliography; using DocumentFormat.OpenXml.Bibliography;
using DocumentFormat.OpenXml.Drawing.Charts;
using EFCore.BulkExtensions; using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Csv; using Magicodes.ExporterAndImporter.Csv;
@ -7,8 +8,11 @@ using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using SettleAccount.Bases; using SettleAccount.Bases;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using SettleAccount.Job.Services;
using SettleAccount.Job.Services.Report;
using Shouldly; using Shouldly;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -18,10 +22,13 @@ using System.LinqAsync;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TaskJob.EventArgs;
using TaskJob.Services;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;
using Win.Abp.Snowflakes; using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.CommonManagers;
@ -30,6 +37,7 @@ using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Temp; using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Win.Sfs.SettleAccount.Entities.Prices; using Win.Sfs.SettleAccount.Entities.Prices;
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.SettleAccount.Migrations; using Win.Sfs.SettleAccount.Migrations;
@ -51,7 +59,7 @@ namespace Win.Sfs.SettleAccount.Bases
protected readonly BBAC_CAN_SA_MNG _bbacMng; protected readonly BBAC_CAN_SA_MNG _bbacMng;
protected readonly PUB_CAN_SA_MNG _pubMng; protected readonly PUB_CAN_SA_MNG _pubMng;
protected readonly INV_MNG _invMng; protected readonly INV_MNG _invMng;
private readonly TaskJobService _service;
@ -65,13 +73,14 @@ namespace Win.Sfs.SettleAccount.Bases
HBPO_CAN_SA_MNG hbpoMng, HBPO_CAN_SA_MNG hbpoMng,
BBAC_CAN_SA_MNG bbacMng, BBAC_CAN_SA_MNG bbacMng,
PUB_CAN_SA_MNG pubMng, PUB_CAN_SA_MNG pubMng,
INV_MNG invMng INV_MNG invMng,
TaskJobService service
//INormalEfCoreRepository<TEntityDetail, Guid> detailRepository //INormalEfCoreRepository<TEntityDetail, Guid> detailRepository
) )
{ {
_service= service;
_repository = repository; _repository = repository;
_wRepository = wRepository; _wRepository = wRepository;
@ -223,15 +232,48 @@ namespace Win.Sfs.SettleAccount.Bases
[HttpPost] [HttpPost]
public virtual async Task<string> ReceivedAsync(INVOICE_GRP_REQ_DTO input) public virtual async Task<string> ReceivedAsync(INVOICE_GRP_REQ_DTO input)
{ {
var entity = await _invMng.GetMainAsync(input.InvGroupNum); var entity = await _invMng.GetMainAsync(input.InvbillNum);
if (entity.InvoiceState == InvoiceBillState.)
{
throw new BusinessException("8989", $"发票号{entity.InvbillNum}为报废状态, 不能提交!");
}
if (entity.InvoiceState == InvoiceBillState. )
{
throw new BusinessException("8989", $"发票号{entity.InvbillNum}所在发票分组{entity.InvGroupNum}已提交过收票!");
}
if (entity.State == SettleBillState.)
{
throw new BusinessException("8989", $"发票号{entity.InvbillNum}所在发票分组{entity.InvGroupNum}不是财务已审核状态,不能收票!");
}
if (entity != null) if (entity != null)
{ {
bool flag = await _invMng.ReceivedAsync(entity.InvGroupNum);
if (flag == true) List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "InvGroupNum", Value = input.InvGroupNum ?? string.Empty });
var invlist= _repository.Where(p => p.InvGroupNum == entity.InvGroupNum).ToList();
foreach (var inv in invlist) {
if (inv.InvoiceState != InvoiceBillState.)
{ {
await _invMng.SetForwardState(entity, SettleBillState.); inv.InvoiceState = InvoiceBillState.;
} }
} }
await _repository.DbContext.BulkUpdateAsync(invlist);
var _taskid = await _service.ExportEnqueueAsync($"发票分组{entity.InvGroupNum}收票任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyymm"), string.Empty, CurrentUser, typeof(PD_SERVICE), customConditionList, (rs) =>
{
});
return _taskid;
//bool flag = await _invMng.ReceivedAsync(entity.InvGroupNum);
//if (flag == true)
//{
// await _invMng.SetForwardState(entity, SettleBillState.客户已收票);
//}
}
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }
protected virtual async Task<List<INVOICE_MAP_GROUP_DTO>> GetMapGroupAsync(INVOICE_GRP_REQ_DTO input) protected virtual async Task<List<INVOICE_MAP_GROUP_DTO>> GetMapGroupAsync(INVOICE_GRP_REQ_DTO input)
@ -259,8 +301,6 @@ namespace Win.Sfs.SettleAccount.Bases
filters.Add(new FilterCondition("InvBillNum", p_invbillNum, EnumFilterAction.Equal, EnumFilterLogic.And)); filters.Add(new FilterCondition("InvBillNum", p_invbillNum, EnumFilterAction.Equal, EnumFilterLogic.And));
return await _sRepository.GetListByFilterAsync(filters); return await _sRepository.GetListByFilterAsync(filters);
} }
protected virtual async Task<List<PUB_ADJ_DETAIL_DTO>> GetAjdmentDetail(INVOICE_GRP_REQ_DTO input) protected virtual async Task<List<PUB_ADJ_DETAIL_DTO>> GetAjdmentDetail(INVOICE_GRP_REQ_DTO input)
@ -315,8 +355,14 @@ namespace Win.Sfs.SettleAccount.Bases
/// <param name="p_parentInvBillNum">原发票号</param> /// <param name="p_parentInvBillNum">原发票号</param>
protected async Task<bool> ReissueSecInvoice(List<TEMP_CAN_SA_DETAIL> p_list, List<PUB_ADJ_DETAIL> p_adjlist, int p_version, string p_parentInvBillNum) protected async Task<bool> ReissueSecInvoice(List<TEMP_CAN_SA_DETAIL> p_list, List<PUB_ADJ_DETAIL> p_adjlist, int p_version, string p_parentInvBillNum)
{ {
var flag=await _invMng.ReissueSecInvoice(p_list, p_adjlist, p_parentInvBillNum, p_version);
if (flag)
{
return true;
}
throw new BusinessException("8989", "生成失败,请检查调整表和旧发票内容");
return await _invMng.ReissueSecInvoice(p_list,p_adjlist,p_parentInvBillNum, p_version);
} }
@ -332,7 +378,17 @@ namespace Win.Sfs.SettleAccount.Bases
/// <returns></returns> /// <returns></returns>
protected async Task<bool> ReissueFirstInvoice(List<TEMP_CAN_SA_DETAIL> dtos, List<PUB_ADJ_DETAIL> p_adjlist, int p_version, string p_parentInvBillNum) protected async Task<bool> ReissueFirstInvoice(List<TEMP_CAN_SA_DETAIL> dtos, List<PUB_ADJ_DETAIL> p_adjlist, int p_version, string p_parentInvBillNum)
{ {
return await _invMng.ReissueFirstInvoice(dtos,p_adjlist,p_parentInvBillNum,p_version);
var flag = await _invMng.ReissueFirstInvoice(dtos, p_adjlist, p_parentInvBillNum, p_version);
if (flag==true)
{
return true;
}
throw new BusinessException("8989", "生成失败,请检查调整表和旧发票内容");
} }
/// <summary> /// <summary>
@ -354,7 +410,6 @@ namespace Win.Sfs.SettleAccount.Bases
from tm in temp.DefaultIfEmpty()//校验错误项 from tm in temp.DefaultIfEmpty()//校验错误项
where tm == null where tm == null
select d; select d;
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO>(); List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO>();
string name = string.Empty; string name = string.Empty;
@ -389,9 +444,7 @@ namespace Win.Sfs.SettleAccount.Bases
name = "备件"; name = "备件";
keyname = "交付识别号"; keyname = "交付识别号";
break; break;
} }
foreach (var error in left) foreach (var error in left)
{ {
errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = $"{name}", Message = $"LU:{error.LU}{keyname}:{error.PN},下线日期:{error.SettleDate}没有对应区间销售价格表!" }); errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = $"{name}", Message = $"LU:{error.LU}{keyname}:{error.PN},下线日期:{error.SettleDate}没有对应区间销售价格表!" });

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

@ -166,13 +166,13 @@ namespace Win.Sfs.SettleAccount.Bases
/// <param name="p_parentInvBillNum">原发票号</param> /// <param name="p_parentInvBillNum">原发票号</param>
protected async Task<bool> SecInvoice(List<TEMP_CAN_SA_DETAIL> p_list, int p_version, string p_InvGroupNum, string p_parentInvBillNum,EnumBusinessType businessType) protected async Task<bool> SecInvoice(List<TEMP_CAN_SA_DETAIL> p_list, int p_version, string p_InvGroupNum, string p_parentInvBillNum,EnumBusinessType businessType)
{ {
var ls= await _invmng.SecInvoice(p_list, p_version, p_InvGroupNum, p_parentInvBillNum, businessType); var ls= await _invmng.SecInvoice(p_list, p_version, p_InvGroupNum, p_parentInvBillNum, businessType);
if (ls.Count > 0) if (ls.Count > 0)
{ {
return true; return true;
} }
return false;
throw new BusinessException("8989", "生成失败,请检可结算单明细数据是否结算分组存在");
} }
@ -194,7 +194,8 @@ namespace Win.Sfs.SettleAccount.Bases
{ {
return true; return true;
} }
return false; throw new BusinessException("8989", "生成失败,请检可结算单明细数据是否结算分组存在");
} }

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

@ -1,9 +1,12 @@
using AutoMapper; using AutoMapper;
using DocumentFormat.OpenXml.Bibliography;
using DocumentFormat.OpenXml.Drawing.Charts;
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Csv; using Magicodes.ExporterAndImporter.Csv;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using SettleAccount.Bases; using SettleAccount.Bases;
using Shouldly; using Shouldly;
using System; using System;
@ -13,6 +16,8 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TaskJob.EventArgs;
using TaskJob.Services;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
@ -113,6 +118,21 @@ namespace Win.Sfs.SettleAccount.Bases
//[Route("generateinvoice")] //[Route("generateinvoice")]
public virtual async Task<string> ApprovalPassed(TRequestMainInput input) public virtual async Task<string> ApprovalPassed(TRequestMainInput input)
{ {
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }
/// <summary> /// <summary>
@ -137,6 +157,19 @@ namespace Win.Sfs.SettleAccount.Bases
[HttpPost] [HttpPost]
public virtual async Task<string> RejectAsync(TRequestMainInput input) public virtual async Task<string> RejectAsync(TRequestMainInput input)
{ {
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }

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

@ -153,9 +153,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
} }
else//二次开票 else//二次开票
{ {
await SecInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType); await SecInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
} }
} }
} }

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

@ -34,12 +34,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
BBAC_NOT_SA_DETAIL_EXP_DTO> BBAC_NOT_SA_DETAIL_EXP_DTO>
{ {
private readonly BBAC_NOT_SA_MNG _bbacNotMng; private readonly BBAC_NOT_SA_MNG _bbacNotMng;
public BBAC_NOT_SA_SERVICE(IExcelImportAppService excelImportService, public BBAC_NOT_SA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator, ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager, INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> detailRepository, BBAC_NOT_SA_MNG bbacNotMng) : ICommonManager commonManager, INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> detailRepository, BBAC_NOT_SA_MNG bbacNotMng) :

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

@ -27,6 +27,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
public BBAC_PD_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<BBAC_PD, Guid> repository, INormalEfCoreRepository<BBAC_PD_DETAIL, Guid> detailRepository) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository) public BBAC_PD_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<BBAC_PD, Guid> repository, INormalEfCoreRepository<BBAC_PD_DETAIL, Guid> detailRepository) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository)
{ {
} }
} }
} }

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

@ -77,8 +77,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
throw new BusinessException("8989", $"选择发票:{p_invbillnum}状态为报废状态不能重开!"); throw new BusinessException("8989", $"选择发票:{p_invbillnum}状态为报废状态不能重开!");
} }
var hbpolist = await _hbpoMng.GetContainsAsync(inv.InvbillNum, gList);//结算分组对应结算零件 var hbpolist = await _hbpoMng.GetContainsAsync(inv.InvbillNum, gList);//结算分组对应结算零件
var adjlist = await _adjRepository.Where(p => p.InvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
if (adjlist != null && adjlist.Count() > 0) if (adjlist != null && adjlist.Count > 0)
{ {
foreach (var itm in adjlist) foreach (var itm in adjlist)
{ {
@ -98,7 +98,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
settleDate: itm.SettleDate, settleDate: itm.SettleDate,
groupNum: itm.GroupNum, groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum invGroupNum: itm.InvGroupNum
)); ));
} }
} }
@ -141,6 +140,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (p_invbillnum.Substring(0, 3) == "INV")//一次开票重开 if (p_invbillnum.Substring(0, 3) == "INV")//一次开票重开
{ {
await ReissueFirstInvoice(dtos,adjlist, version, p_invbillnum); await ReissueFirstInvoice(dtos,adjlist, version, p_invbillnum);
} }
else//二次开票 else//二次开票
{ {

6
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs

@ -59,8 +59,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> notRepository, INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> notRepository,
INormalEfCoreRepository<PriceList, Guid> priceRepository, INormalEfCoreRepository<PriceList, Guid> priceRepository,
HBPO_CAN_SA_MNG hbpoMng HBPO_CAN_SA_MNG hbpoMng
) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng) ) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng)
{ {
@ -139,11 +137,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
ContractDocID = string.Empty ContractDocID = string.Empty
}).ToList();//不能结算 }).ToList();//不能结算
await FirstInvoice(dtos, notlist, main.Version, main.InvGroupNum, string.Empty,main.BusinessType); var falg= await FirstInvoice(dtos, notlist, main.Version, main.InvGroupNum, string.Empty,main.BusinessType);
} }
else//二次开票 else//二次开票
{ {
await SecInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType); var flag=await SecInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
} }
} }

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

@ -1,3 +1,5 @@
using DocumentFormat.OpenXml.Bibliography;
using DocumentFormat.OpenXml.Drawing.Charts;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
@ -6,6 +8,8 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TaskJob.EventArgs;
using TaskJob.Services;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Win.Abp.Snowflakes; using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
@ -14,7 +18,6 @@ using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos.SettleAccount.Domain.BQ; using Win.Sfs.SettleAccount.Entities.BQ.Dtos.SettleAccount.Domain.BQ;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
[AllowAnonymous] [AllowAnonymous]
@ -25,6 +28,33 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
public HBPO_PD_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<HBPO_PD, Guid> repository, INormalEfCoreRepository<HBPO_PD_DETAIL, Guid> detailRepository) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository) public HBPO_PD_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<HBPO_PD, Guid> repository, INormalEfCoreRepository<HBPO_PD_DETAIL, Guid> detailRepository) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository)
{ {
//List<CustomCondition> customConditionList = new List<CustomCondition>();
//customConditionList.Add(new CustomCondition() { Name = "Version", Value = version ?? string.Empty });
//customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = customerCode ?? string.Empty });
//customConditionList.Add(new CustomCondition() { Name = "Year", Value = year ?? string.Empty });
//customConditionList.Add(new CustomCondition() { Name = "Period", Value = period ?? string.Empty });
//customConditionList.Add(new CustomCondition() { Name = "Factory", Value = factory ?? string.Empty });
//var _versionQuery = _versionRepository.Where(p => p.Version == version);
//if (_versionQuery.Count() > 0)
//{
// _versionQuery.BatchDelete();
//}
//var _query = _repository.Where(p => p.Version == version);
//if (_query.Count() > 0)
//{
// await _query.BatchDeleteAsync();
//}
//var _taskid = await _service.ImportEnqueueAsync<ImportTaskArgs>(files, "结算数据", CurrentUser, typeof(SettleAccountImportService), customConditionList, (rs) =>
//{
//});
} }
} }
} }

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

@ -70,6 +70,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
_invMng = invMng; _invMng = invMng;
} }
/// <summary>
/// 通过审核
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost] [HttpPost]
public virtual async Task<string> ApprovalPassed(INVOICE_GRP_REQ_DTO input) public virtual async Task<string> ApprovalPassed(INVOICE_GRP_REQ_DTO input)
{ {
@ -78,6 +87,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }
/// <summary>
/// 主表查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost] [HttpPost]
//[Route("mainquery")] //[Route("mainquery")]
public virtual async Task<PagedResultDto<INVOICE_GRP_DTO>> MainQueryAsync(INVOICE_GRP_REQ_DTO input) public virtual async Task<PagedResultDto<INVOICE_GRP_DTO>> MainQueryAsync(INVOICE_GRP_REQ_DTO input)
@ -87,6 +101,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var dtos = ObjectMapper.Map<List<INVOICE_GRP>, List<INVOICE_GRP_DTO>>(entitys); var dtos = ObjectMapper.Map<List<INVOICE_GRP>, List<INVOICE_GRP_DTO>>(entitys);
return new PagedResultDto<INVOICE_GRP_DTO>(totalCount, dtos); return new PagedResultDto<INVOICE_GRP_DTO>(totalCount, dtos);
} }
/// <summary>
/// 明细查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost] [HttpPost]
public virtual async Task<INVOICE_GRP_DETAIL_DTO> DetailQueryAsync(INVOICE_GRP_REQ_DTO input) public virtual async Task<INVOICE_GRP_DETAIL_DTO> DetailQueryAsync(INVOICE_GRP_REQ_DTO input)
{ {

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

@ -77,7 +77,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
throw new BusinessException("8989", $"选择发票:{p_invbillnum}状态为报废状态不能重开!"); throw new BusinessException("8989", $"选择发票:{p_invbillnum}状态为报废状态不能重开!");
} }
var hbpolist = await _pubMng.GetContainsAsync(inv.InvbillNum, gList);//结算分组对应结算零件 var hbpolist = await _pubMng.GetContainsAsync(inv.InvbillNum, gList);//结算分组对应结算零件
var adjlist = await _adjRepository.Where(p => p.InvBillNum == inv.InvbillNum).ToListAsync();//调整表明细 var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
if (adjlist != null && adjlist.Count() > 0) if (adjlist != null && adjlist.Count() > 0)
{ {
foreach (var itm in adjlist) foreach (var itm in adjlist)
@ -108,7 +108,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var priceList = _priceRepository.ToList();//价格单 var priceList = _priceRepository.ToList();//价格单
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType); var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType);
if (errorList.Count() > 0) if (errorList.Count > 0)
{ {
return await ExportErrorReportAsync(errorList); return await ExportErrorReportAsync(errorList);
} }

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

@ -118,13 +118,27 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
if (input.BillNum.Substring(0, 1) == "C")//一次开票 if (input.BillNum.Substring(0, 1) == "C")//一次开票
{ {
if (main.BusinessType == EnumBusinessType.MaiDanJianHBPO || main.BusinessType == EnumBusinessType.BeiJian)
{
var strs=await _invmng.MakeInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, true);
}
else
{
await FirstInvoice(dtos, new List<TEMP_NOT_SA_DETAIL>(), main.Version, main.InvGroupNum, string.Empty, main.BusinessType); await FirstInvoice(dtos, new List<TEMP_NOT_SA_DETAIL>(), main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
} }
}
else//二次开票 else//二次开票
{
if (main.BusinessType == EnumBusinessType.MaiDanJianHBPO || main.BusinessType==EnumBusinessType.BeiJian )
{
var strs=await _invmng.MakeInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, true);
}
else
{ {
await SecInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType); await SecInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
} }
}
} }
} }
} }

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Jobs/TaskJobService.cs

@ -1,4 +1,4 @@
using AutoMapper; using AutoMapper;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System; using System;
@ -199,6 +199,7 @@ namespace Win.Sfs.SettleAccount.Entities.TaskJobs
}; };
var _taskId = await _backgroundJobManager.EnqueueAsync(args,BackgroundJobPriority.Normal,TimeSpan.FromSeconds(3)); var _taskId = await _backgroundJobManager.EnqueueAsync(args,BackgroundJobPriority.Normal,TimeSpan.FromSeconds(3));
var options = new JsonSerializerOptions var options = new JsonSerializerOptions
{ {

13
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

@ -194,6 +194,10 @@ namespace Win.Sfs.SettleAccount
CreateMapPUB_ADJ_DETAIL();
@ -299,7 +303,6 @@ namespace Win.Sfs.SettleAccount
CreateMap<PUB_CAN_SA_DETAIL, PUB_CAN_SA_DETAIL_EXP_DTO>().ReverseMap(); CreateMap<PUB_CAN_SA_DETAIL, PUB_CAN_SA_DETAIL_EXP_DTO>().ReverseMap();
} }
private void CreateMapPUB_NOT_SA_DETAIL() private void CreateMapPUB_NOT_SA_DETAIL()
{ {
CreateMap<PUB_NOT_SA_DETAIL, PUB_NOT_SA_DETAIL_DTO>().ReverseMap(); CreateMap<PUB_NOT_SA_DETAIL, PUB_NOT_SA_DETAIL_DTO>().ReverseMap();
CreateMap<PUB_NOT_SA_DETAIL, PUB_NOT_SA_DETAIL_REQ_DTO>().ReverseMap(); CreateMap<PUB_NOT_SA_DETAIL, PUB_NOT_SA_DETAIL_REQ_DTO>().ReverseMap();
@ -307,7 +310,13 @@ namespace Win.Sfs.SettleAccount
CreateMap<PUB_NOT_SA_DETAIL, PUB_NOT_SA_DETAIL_EXP_DTO>().ReverseMap(); CreateMap<PUB_NOT_SA_DETAIL, PUB_NOT_SA_DETAIL_EXP_DTO>().ReverseMap();
} }
private void CreateMapPUB_ADJ_DETAIL()
{
CreateMap<PUB_ADJ_DETAIL, PUB_ADJ_DETAIL_DTO>().ReverseMap();
CreateMap<PUB_ADJ_DETAIL, PUB_ADJ_DETAIL_REQ_DTO>().ReverseMap();
CreateMap<PUB_ADJ_DETAIL, PUB_ADJ_DETAIL_IMP_DTO>().ReverseMap();
CreateMap<PUB_ADJ_DETAIL, PUB_ADJ_DETAIL_EXP_DTO>().ReverseMap();
}

269
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/CAN_SA_MNG.cs

@ -1,269 +0,0 @@
using EFCore.BulkExtensions;
using Hangfire.Annotations;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Bases;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Services;
using Volo.Abp.Guids;
using Volo.Abp.ObjectMapping;
using Win.Sfs.SettleAccount.Bases.DomainServices;
using Win.Sfs.SettleAccount.Boms;
using Win.Sfs.SettleAccount.Entities.Materials;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
public class CAN_SA_MNG<TEntity, TEntityDetail> : DomainService,ITransientDependency
where TEntity : SA_CAN_BASE_MAIN,new()
where TEntityDetail : SA_CAN_BASE,new()
{
private readonly INormalEfCoreRepository<TEntity, Guid> _repository;
private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
public CAN_SA_MNG
(
INormalEfCoreRepository<TEntity, Guid> repository,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository
)
{
_repository = repository;
_detailRepository = detailRepository;
}
public CAN_SA_MNG()
{
}
public virtual async Task<bool> SetForwardState(TEntity p_entiy, SettleBillState state)
{
if (await SetForwardState(p_entiy.InvGroupNum, state) == true)
{
return true;
}
return false;
}
/// <summary>
/// 向前流程
/// </summary>
/// <param name="p_billNum"></param>
/// <param name="state"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetForwardState(string p_billNum, SettleBillState state)
{
var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
if (ls != null && ls.Count > 0)
{
throw new BusinessException("8989", string.Format("不存在编号为{0}",p_billNum));
}
foreach (TEntity p_entiy in ls)
{
switch (p_entiy.State)
{
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【商务已审核】");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【未结状态】状态,无法设置成【已开票】");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[客户收票],无法设置成【财务已审核】状态");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[财务已审核],无法设置成【客户已收票】状态");
}
break;
}
await _repository.UpdateAsync(p_entiy);
return true;
}
return false;
}
/// <summary>
/// 向后流程
/// </summary>
/// <param name="p_billNum"></param>
/// <param name="state"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetBackwardState(string p_billNum, SettleBillState state)
{
var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
if (ls != null && ls.Count > 0)
{
throw new BusinessException("8989", string.Format("不存在发票分组号为{0}的可结算单", p_billNum));
}
foreach (TEntity p_entiy in ls)
{
switch (p_entiy.State)
{
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【财务已审核】,无法设置成【商务已审核】状态");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【商务已审核】状态,无法设置成【已开票】");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【未结状态】");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[财务已审核],无法设置成【财务已审核客户收票】状态");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[客户已收票],无法设置成【财务已审核】状态");
}
break;
}
await _repository.UpdateAsync(p_entiy);
return true;
}
return false;
}
public virtual async Task<bool> SetNewState(TEntity p_entiy)
{
return await SetNewState(p_entiy.BillNum);
}
public virtual async Task<bool> SetNewState(string billNum)
{
var entity= await GetMainAsync(billNum);
if (entity != null )
{
entity.State = SettleBillState.;
await _repository.UpdateAsync(entity);
return true;
}
return false;
;
}
/// <summary>
/// 获得所有明细
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<List<TEntityDetail>> GetDetalListAsync(string billNum)
{
return await _detailRepository.Where(p=>p.InvGroupNum==billNum).ToListAsync();
}
/// <summary>
/// 获得主表信息
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<TEntity> GetMainAsync(string billNum)
{
return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync();
}
}
}

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

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.SignalR;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using SettleAccount.Bases; using SettleAccount.Bases;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using System; using System;
@ -13,6 +14,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Auditing; using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services; using Volo.Abp.Domain.Services;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
@ -177,9 +179,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var flag = await SetSettleState(p_entiy, p_State, true); var flag = await SetSettleState(p_entiy, p_State, true);
if (flag == true) if (flag == true)
{ {
await _repository.UpdateAsync(p_entiy); var invlist = await _repository.Where(p => p.InvGroupNum == p_entiy.InvGroupNum).ToListAsync();//选择审批时只能整组审批
foreach (var itm in invlist)
{
itm.State = p_entiy.State;
}
await _repository.BatchUpdateAsync(invlist);
return false; return true;
} }
return false; return false;
} }
@ -228,15 +235,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
break; break;
} }
var flag = await SetSettleState(p_entiy, p_State, false); var flag = await SetSettleState(p_entiy, p_State, false);
if (flag == false)
if (flag == true)
{ {
return false; var invlist = await _repository.Where(p => p.InvGroupNum == p_entiy.InvGroupNum).ToListAsync();//选择审批时只能整组审批
foreach (var itm in invlist)
{
itm.State = p_entiy.State;
} }
await _repository.UpdateAsync(p_entiy); await _repository.BatchUpdateAsync(invlist);
return true; return true;
} }
return false;
}
@ -252,6 +266,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
return await _repository.Where(p => p.InvbillNum == p_invbillNum).FirstOrDefaultAsync(); return await _repository.Where(p => p.InvbillNum == p_invbillNum).FirstOrDefaultAsync();
} }
/// <summary>
/// 获得发票主表
/// </summary>
/// <param name="p_billNum"></param>
/// <returns></returns>
public virtual async Task<List<INVOICE_GRP>> GetMainListAsync(string p_invgroupNum)
{
return await _repository.Where(p => p.InvGroupNum == p_invgroupNum).ToListAsync();
}
/// <summary> /// <summary>
/// 获得发票主表 /// 获得发票主表
/// </summary> /// </summary>
@ -277,153 +303,158 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
public virtual async Task<bool> ReceivedAsync(string p_groupbillnum) public virtual async Task<bool> ReceivedAsync(string p_groupbillnum)
{ {
var inv = _repository.Where(p => p.InvGroupNum == p_groupbillnum).FirstOrDefault();
if (inv.BusinessType == EnumBusinessType.JisBBAC)
{
var entity = await _bbacMng.GetMainAsync(inv.InvGroupNum);
if (entity == null)
{
var entityDetail = await _bbacMng.GetDetalListAsync(inv.InvGroupNum);
var bbac = new BBAC_PD(
guid: entity.Id,
version: entity.Version,
billNum: entity.BillNum,
settleBillNum: entity.SettleBillNum,
state: SettleBillState.,
invGroupNum: entity.InvGroupNum,
site: entity.Site
);
var bbacDetail = new List<BBAC_PD_DETAIL>();
foreach (var itm in entityDetail)
{
bbacDetail.Add(
new BBAC_PD_DETAIL(
guid: itm.Id,
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.BillNum,
lU: itm.LU,
rELU: string.Empty,
pN: itm.PN,
rEPN: string.Empty,
site: itm.Site,
qty: itm.Qty,
price: itm.Price,
invGroupNum: itm.InvGroupNum,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
extend1: string.Empty,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
));
await _repository.DbContext.BulkInsertAsync(new List<BBAC_PD>() { bbac });
await _repository.DbContext.BulkInsertAsync(bbacDetail);
return true;
}
}
}
else if (inv.BusinessType == EnumBusinessType.JisHBPO)
{
var entity = await _hbpoMng.GetMainAsync(inv.InvGroupNum);
if (entity != null)
{
var entityDetail = await _hbpoMng.GetDetalListAsync(inv.InvGroupNum);
if (entityDetail != null && entityDetail.Count() > 0)
{
var hbpo = new HBPO_PD(
guid: entity.Id,
version: entity.Version,
billNum: entity.BillNum,
settleBillNum: entity.SettleBillNum,
state: SettleBillState.,
invGroupNum: entity.InvGroupNum,
site: entity.Site
);
var hbpoDetail = new List<HBPO_PD_DETAIL>();
foreach (var itm in entityDetail)
{
hbpoDetail.Add(
new HBPO_PD_DETAIL(
guid: itm.Id,
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.BillNum,
lU: itm.LU,
rELU: string.Empty,
pN: itm.PN,
rEPN: string.Empty,
site: itm.Site,
qty: itm.Qty,
price: itm.Price,
invGroupNum: itm.InvGroupNum,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
extend1: string.Empty,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
));
}
await _repository.DbContext.BulkInsertAsync(new List<HBPO_PD>() { hbpo });
await _repository.DbContext.BulkInsertAsync(hbpoDetail);
return true;
}
} //var inv = _repository.Where(p => p.InvGroupNum == p_groupbillnum).FirstOrDefault();
} //if (inv.BusinessType == EnumBusinessType.JisBBAC)
else //{
{ // var entity = await _bbacMng.GetMainAsync(inv.InvGroupNum);
var entity = await _pubMng.GetMainAsync(inv.InvGroupNum); // if (entity == null)
if (entity != null) // {
{
var entityDetail = await _pubMng.GetDetalListAsync(inv.InvGroupNum); // var entityDetail = await _bbacMng.GetDetalListAsync(inv.InvGroupNum);
if (entityDetail != null && entityDetail.Count() > 0) // var bbac = new BBAC_PD(
{ // guid: entity.Id,
var pub = new PUB_PD( // version: entity.Version,
guid: entity.Id, // billNum: entity.BillNum,
version: entity.Version, // settleBillNum: entity.SettleBillNum,
billNum: entity.BillNum, // state: SettleBillState.客户已收票,
settleBillNum: entity.SettleBillNum, // invGroupNum: entity.InvGroupNum,
state: SettleBillState., // site: entity.Site
invGroupNum: entity.InvGroupNum, // );
site: entity.Site // var bbacDetail = new List<BBAC_PD_DETAIL>();
);
var pubDetail = new List<PUB_PD_DETAIL>(); // foreach (var itm in entityDetail)
foreach (var itm in entityDetail) // {
{ // bbacDetail.Add(
pubDetail.Add( // new BBAC_PD_DETAIL(
new PUB_PD_DETAIL( // guid: itm.Id,
guid: itm.Id, // keyCode: itm.KeyCode,
keyCode: itm.KeyCode, // version: itm.Version,
version: itm.Version, // billNum: itm.BillNum,
billNum: itm.BillNum, // lU: itm.LU,
lU: itm.LU, // rELU: string.Empty,
rELU: string.Empty, // pN: itm.PN,
pN: itm.PN, // rEPN: string.Empty,
rEPN: string.Empty, // site: itm.Site,
site: itm.Site, // qty: itm.Qty,
qty: itm.Qty, // price: itm.Price,
price: itm.Price, // invGroupNum: itm.InvGroupNum,
invGroupNum: itm.InvGroupNum, // settleDate: itm.SettleDate,
settleDate: itm.SettleDate, // groupNum: itm.GroupNum,
groupNum: itm.GroupNum, // extend1: string.Empty,
extend1: string.Empty, // extend2: string.Empty,
extend2: string.Empty, // extend3: string.Empty,
extend3: string.Empty, // extend4: string.Empty
extend4: string.Empty, // ));
businessType: itm.BusinessType // await _repository.DbContext.BulkInsertAsync(new List<BBAC_PD>() { bbac });
)); // await _repository.DbContext.BulkInsertAsync(bbacDetail);
} // return true;
await _repository.DbContext.BulkInsertAsync(new List<PUB_PD>() { pub }); // }
await _repository.DbContext.BulkInsertAsync(pubDetail); // }
return true; //}
} //else if (inv.BusinessType == EnumBusinessType.JisHBPO)
} //{
} // var entity = await _hbpoMng.GetMainAsync(inv.InvGroupNum);
// if (entity != null)
// {
// var entityDetail = await _hbpoMng.GetDetalListAsync(inv.InvGroupNum);
// if (entityDetail != null && entityDetail.Count() > 0)
// {
// var hbpo = new HBPO_PD(
// guid: entity.Id,
// version: entity.Version,
// billNum: entity.BillNum,
// settleBillNum: entity.SettleBillNum,
// state: SettleBillState.客户已收票,
// invGroupNum: entity.InvGroupNum,
// site: entity.Site
// );
// var hbpoDetail = new List<HBPO_PD_DETAIL>();
// foreach (var itm in entityDetail)
// {
// hbpoDetail.Add(
// new HBPO_PD_DETAIL(
// guid: itm.Id,
// keyCode: itm.KeyCode,
// version: itm.Version,
// billNum: itm.BillNum,
// lU: itm.LU,
// rELU: string.Empty,
// pN: itm.PN,
// rEPN: string.Empty,
// site: itm.Site,
// qty: itm.Qty,
// price: itm.Price,
// invGroupNum: itm.InvGroupNum,
// settleDate: itm.SettleDate,
// groupNum: itm.GroupNum,
// extend1: string.Empty,
// extend2: string.Empty,
// extend3: string.Empty,
// extend4: string.Empty
// ));
// }
// await _repository.DbContext.BulkInsertAsync(new List<HBPO_PD>() { hbpo });
// await _repository.DbContext.BulkInsertAsync(hbpoDetail);
// return true;
// }
// }
//}
//else
//{
// var entity = await _pubMng.GetMainAsync(inv.InvGroupNum);
// if (entity != null)
// {
// var entityDetail = await _pubMng.GetDetalListAsync(inv.InvGroupNum);
// if (entityDetail != null && entityDetail.Count() > 0)
// {
// var pub = new PUB_PD(
// guid: entity.Id,
// version: entity.Version,
// billNum: entity.BillNum,
// settleBillNum: entity.SettleBillNum,
// state: SettleBillState.客户已收票,
// invGroupNum: entity.InvGroupNum,
// site: entity.Site
// );
// var pubDetail = new List<PUB_PD_DETAIL>();
// foreach (var itm in entityDetail)
// {
// pubDetail.Add(
// new PUB_PD_DETAIL(
// guid: itm.Id,
// keyCode: itm.KeyCode,
// version: itm.Version,
// billNum: itm.BillNum,
// lU: itm.LU,
// rELU: string.Empty,
// pN: itm.PN,
// rEPN: string.Empty,
// site: itm.Site,
// qty: itm.Qty,
// price: itm.Price,
// invGroupNum: itm.InvGroupNum,
// settleDate: itm.SettleDate,
// groupNum: itm.GroupNum,
// extend1: string.Empty,
// extend2: string.Empty,
// extend3: string.Empty,
// extend4: string.Empty,
// businessType: itm.BusinessType
// ));
// }
// await _repository.DbContext.BulkInsertAsync(new List<PUB_PD>() { pub });
// await _repository.DbContext.BulkInsertAsync(pubDetail);
// return true;
// }
// }
//}
return false; return false;
} }
public virtual async Task<bool> Reject(INVOICE_GRP p_entity) public virtual async Task<bool> Reject(INVOICE_GRP p_entity)
@ -445,9 +476,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
if (ls != null && ls.Count > 0) if (ls != null && ls.Count > 0)
{ {
var first = ls.FirstOrDefault(); var first = ls.FirstOrDefault();
if(first.State==SettleBillState. || first.State== SettleBillState.) if (first.State == SettleBillState. || first.State == SettleBillState.)
{ {
throw new BusinessException("8989",$"发票分组{groupbillNum}客户已经是客户已收票或已扣减状态不能退回"); throw new BusinessException("8989", $"发票分组{groupbillNum}客户已经是客户已收票或已扣减状态不能退回");
} }
foreach (var p_entity in ls) foreach (var p_entity in ls)
{ {
@ -481,7 +512,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
} }
else else
{ {
throw new BusinessException("8989",$"查询不到发票分组号为{groupbillNum}发票分组"); throw new BusinessException("8989", $"查询不到发票分组号为{groupbillNum}发票分组");
} }
return true; return true;
} }
@ -533,7 +564,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
//{ //{
//} //}
return true; return true;
} }
/// <summary> /// <summary>
/// hbpo、jit、备件等 /// hbpo、jit、备件等
@ -545,7 +575,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
public async Task<List<string>> SecInvoice(List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) public async Task<List<string>> SecInvoice(List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
{ {
List<string> _invls = new List<string>(); List<string> _invls = new List<string>();
var groups1 = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV var groups1 = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV
{ {
LU = p.Key.LU, LU = p.Key.LU,
@ -555,7 +584,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
Price = p.Key.Price, Price = p.Key.Price,
BeginDate = p.Key.BeginDate, BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate EndDate = p.Key.EndDate
}).ToList();//汇总记录不出现重复值 }).ToList();//汇总记录不出现重复值
var groups = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV var groups = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV
{ {
@ -712,6 +740,198 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
} }
/// <summary>
/// hbpojis,备件
/// </summary>
/// <param name="dtos">可结算明细列表</param>
/// <param name="p_version">版本号</param>
/// <param name="p_InvGroupNum">发票分组</param>
/// <param name="p_parentInvBillNum">原发票号</param>
public async Task<List<string>> MakeInvoice(List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType, bool p_first)
{
List<string> _invls = new List<string>();
var groups1 = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
ContractDocID = p.Key.ContractDocID,
Price = p.Key.Price,
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate
}).ToList();//汇总记录不出现重复值
var groups = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price,
ContractDocID = p.Key.ContractDocID,
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate
}).ToList();//汇总记录不出现重复值
Dictionary<string, List<TMEP_INV>> invoiceMap = new Dictionary<string, List<TMEP_INV>>();//发票和发票明细关系
foreach (var group in groups)
{
int i = groups1.Count(p => p.LU == group.LU
&& p.BeginDate == group.BeginDate
&& p.EndDate == group.EndDate
&& p.ContractDocID == group.ContractDocID
);
if (i > 0)
{
string invoiceBillNum = string.Empty;
if (p_first == true)
{
invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
}
else
{
invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV");
}
List<TMEP_INV> tempList = new List<TMEP_INV>();
decimal sum = group.Amt;//初始合计金额
int partCount = 0;
foreach (var group1 in groups1)
{
if (group.LU == group1.LU
&& group.BeginDate == group1.BeginDate
&& group.EndDate == group1.EndDate
&& group1.ContractDocID == group.ContractDocID
)
{
tempList.Add(group1);
partCount++;//符合条件加入到零件中
continue;
}
partCount++;
if (partCount > 30)
{
continue;
}
if (sum > 10000000)
{
break;
}
sum += group1.Amt;
tempList.Add(group1);
}
invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1
join itm1 in tempList
on new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID }
equals new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID } into temp
from tm in temp
where tm == null
select new TMEP_INV
{
LU = itm.LU,
Amt = itm.Amt,
Qty = itm.Qty,
BeginDate = itm.BeginDate,
ContractDocID = itm.ContractDocID,
EndDate = itm.EndDate
};
groups1 = query.ToList();
}
}
if (invoiceMap.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>();
foreach (var group in invoiceMap)
{
var key = group.Key;//发票票号
var ls = group.Value;//发票明细
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in ls)
{
_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
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
decimal amt = detailList.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailList.Sum(k => k.Amt), 2);
//var contractList = ls.Select(p => p.ContractDocID).Distinct();
//var _groupList = dtos.Where(p => contractList.Contains(p.ContractDocID)).GroupBy(p => new { p.GroupNum })
// .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct();
//var _groupList = dtos.GroupBy(p => new { p.GroupNum })
// .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct();
//List<INVOICE_MAP_GROUP> group1 = new List<INVOICE_MAP_GROUP>();
//foreach (var en in _groupList)
//{
// group1.Add(
// new INVOICE_MAP_GROUP(
// guid: GuidGenerator.Create(),
// version: p_version,
// invbillNum: key,
// invGroupNum: p_InvGroupNum,
// settleGroupNum: en.GroupNum,
// amt: en.Amt,
// extend1: string.Empty,
// extend2: string.Empty));
//}
//if (group1.Count > 0)
//{
// groupList.AddRange(group1);
//}
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: p_parentInvBillNum
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
//await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
//await _repository.DbContext.BulkInsertAsync(notDetialList);
_invls = invlist.Select(p => p.InvbillNum).ToList();
}
return _invls;
}
/// <summary> /// <summary>
/// 第一次开票 /// 第一次开票
/// </summary> /// </summary>
@ -844,10 +1064,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{ {
detailList.AddRange(_entityDetailList); detailList.AddRange(_entityDetailList);
} }
var innotls = new List<INVOICE_NOT_SETTLE>(); var innotls = new List<INVOICE_NOT_SETTLE>();
if (p_notlist != null && p_notlist.Count > 0) 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) }); 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) });
@ -893,7 +1110,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{ {
await _repository.DbContext.BulkInsertAsync(notDetialList); await _repository.DbContext.BulkInsertAsync(notDetialList);
} }
_invls =invlist.Select(p => p.InvbillNum).ToList(); _invls = invlist.Select(p => p.InvbillNum).ToList();
} }
return _invls; return _invls;
@ -907,7 +1124,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <param name="p_version"></param> /// <param name="p_version"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="BusinessException"></exception> /// <exception cref="BusinessException"></exception>
public async Task<bool> ReissueFirstInvoice(List<TEMP_CAN_SA_DETAIL> dtos,List<PUB_ADJ_DETAIL> p_adjlist, string p_OldInvBillNum, int p_version) public async Task<bool> ReissueFirstInvoice(List<TEMP_CAN_SA_DETAIL> dtos, List<PUB_ADJ_DETAIL> p_adjlist, string p_OldInvBillNum, int p_version)
{ {
if (!string.IsNullOrEmpty(p_OldInvBillNum)) if (!string.IsNullOrEmpty(p_OldInvBillNum))
{ {
@ -922,7 +1139,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
throw new BusinessException("8989", $"选择要重开发票号{p_OldInvBillNum}已经作废不能重开"); throw new BusinessException("8989", $"选择要重开发票号{p_OldInvBillNum}已经作废不能重开");
} }
inv.InvoiceState = InvoiceBillState.; inv.InvoiceState = InvoiceBillState.;
var invlist=await FirstInvoice(dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);//重开可以变多张发票
List<string> invlist = new List<string>();
if (inv.BusinessType == EnumBusinessType.MaiDanJianHBPO || inv.BusinessType == EnumBusinessType.BeiJian)
{
invlist = await MakeInvoice(dtos, p_version, inv.InvGroupNum, string.Empty, inv.BusinessType, true);
}
else
{
invlist = await FirstInvoice(dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);//重开可以变多张发票
}
if (invlist.Count == 0) if (invlist.Count == 0)
{ {
return false; return false;
@ -930,7 +1157,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
foreach (var adj in p_adjlist) foreach (var adj in p_adjlist)
{ {
adj.InvBillNum = string.Join(",", invlist); adj.InvBillNum = string.Join(",", invlist);//调整单更新发票信息
} }
_repository.DbContext.BulkUpdate(p_adjlist); _repository.DbContext.BulkUpdate(p_adjlist);
@ -964,7 +1191,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
} }
inv.InvoiceState = InvoiceBillState.; inv.InvoiceState = InvoiceBillState.;
var invlist =await SecInvoice(dtos, p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType); List<string> invlist = new List<string>();
if (inv.BusinessType == EnumBusinessType.MaiDanJianHBPO || inv.BusinessType == EnumBusinessType.BeiJian)
{
invlist = await MakeInvoice(dtos, p_version, inv.InvGroupNum, string.Empty, inv.BusinessType, false);
}
else
{
invlist = await SecInvoice(dtos, p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);
}
if (invlist.Count == 0) if (invlist.Count == 0)
{ {
return false; return false;

89
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/NOT_SA_MNG.cs

@ -1,89 +0,0 @@
using SettleAccount.Bases;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
using Volo.Abp;
using Win.Sfs.Shared.RepositoryBase;
using Win.Sfs.SettleAccount.Bases;
using EFCore.BulkExtensions;
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
/// <summary>
/// 不能結算管理
/// </summary>
/// <typeparam name="TEntity"></typeparam>
/// <typeparam name="TEntityDetail"></typeparam>
/// <typeparam name="TNOTDetail"></typeparam>
public class NOT_SA_MNG<TEntity, TEntityDetail, TNOTDetail> : DomainService
where TEntity : SA_CAN_BASE_MAIN, new()
where TEntityDetail : SA_CAN_BASE, new()
where TNOTDetail : SA_NOT_BASE
{
private readonly INormalEfCoreRepository<TEntity, Guid> _repository;
private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
private readonly INormalEfCoreRepository<TNOTDetail, Guid> _notRepository;
public NOT_SA_MNG()
{
}
public NOT_SA_MNG
(
INormalEfCoreRepository<TEntity, Guid> repository,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository,
INormalEfCoreRepository<TNOTDetail, Guid> notRepository
)
{
_repository = repository;
_detailRepository = detailRepository;
_notRepository = notRepository;
}
public virtual async Task<bool> GenerateSettlementOrder(List<TNOTDetail> p_list, Action<List<TEntityDetail>> p_action = null)
{
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
var _entity = new TEntity();
_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<TEntityDetail>();
foreach (var itm in p_list)
{
var _detailEntity = new TEntityDetail();
{
_detailEntity.SettleBillNum = itm.SettleBillNum;
_detailEntity.BillNum = billNumber;
_detailEntity.InvGroupNum = billNumber;
_detailEntity.LU = itm.LU;
_detailEntity.PN = itm.PN;
_detailEntity.GroupNum = itm.GroupNum;
_detailEntity.KeyCode = itm.KeyCode;
_detailEntity.Price = itm.Price;
_detailEntity.Version = itm.Version;
};
_entityList.Add(_detailEntity);
}
if (_entityList.Count > 0)
{
p_action(_entityList);//对不一样类型结算数据进行处理
}
await _notRepository.DbContext.BulkDeleteAsync(p_list);
await _repository.DbContext.BulkInsertAsync(new List<TEntity>() { _entity });
await _repository.DbContext.BulkInsertAsync(_entityList);
return true;
}
}
}

3
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_ADJ_DETAIL.cs

@ -71,10 +71,11 @@ public class PUB_ADJ_DETAIL : SA_NOT_BASE
public string InvBillNum { get; set; } public string InvBillNum { get; set; }
public PUB_ADJ_DETAIL(string keyCode, int version, string settleBillNum, string lU, string pN, public PUB_ADJ_DETAIL(Guid id, string keyCode, int version, string settleBillNum, string lU, string pN,
string site, decimal qty, string extend1, decimal price, string invGroupNum, DateTime settleDate, string site, decimal qty, string extend1, decimal price, string invGroupNum, DateTime settleDate,
EnumBusinessType businessType, string groupNum,string oldinv,string inv) EnumBusinessType businessType, string groupNum,string oldinv,string inv)
{ {
Id= id;
KeyCode = keyCode; KeyCode = keyCode;
Version = version; Version = version;
SettleBillNum = settleBillNum; SettleBillNum = settleBillNum;

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

@ -184,3 +184,16 @@ public class TEMP_NOT_SA_DETAIL : SA_NOT_BASE
} }
public class TEMP_PD_SW
{
public string LU { set; get; }
public string PN { set; get; }
public string RepLU { set; get; }
public string BusinessType { set; get; }
public string KeyCode { set; get; }
}

2
code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs

@ -42,6 +42,8 @@ namespace Win.Sfs.SettleAccount
[Description("替换")] [Description("替换")]
= 3, = 3,
[Description("提交")]
= 3,

370
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/PendingDeduction/PendingDeductionDapperRepository.cs

@ -0,0 +1,370 @@
using Dapper;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.EntityFrameworkCore;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Repositories.Dapper;
using Volo.Abp.EntityFrameworkCore;
using Win.Sfs.SettleAccount.Entities;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.Reports;
using Win.Sfs.SettleAccount.Reports.InvoiceSettledDiffs;
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{
/// <summary>
/// 2.大众发票与结算核对明细表-准时化
/// </summary>
public class PendingDeductionDapperRepository : DapperRepository<SettleAccountDbContext>, ITransientDependency
{
public PendingDeductionDapperRepository(IDbContextProvider<SettleAccountDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
/// <summary>
/// BBAC生成待扣减
/// </summary>
/// <param name="p_invGroup"></param>
/// <returns></returns>
public Dictionary<BBAC_PD, List<BBAC_PD_DETAIL>> GenerationPendingDeductionBBAC(string p_invGroup)
{
var sqljis = "WITH t1 AS(\n" +
"SELECT\n" +
"DISTINCT sa.KeyCode,\n" +
"sa.LU,\n" +
"sa.PN,\n" +
"sa.BusinessType\n" +
"FROM\n" +
"(\n" +
"SELECT\n" +
"keycode,\n" +
"LU,\n" +
"PN,\n" +
"BusinessType\n" +
"FROM\n" +
"Set_BBAC_CAN_SA_DETAIL\n" +
"WHERE\n" +
"InvGroupNum = '{0}'\n" +
"UNION ALL\n" +
"SELECT\n" +
"keycode,\n" +
"LU,\n" +
"PN,\n" +
"BusinessType\n" +
"FROM\n" +
"Set_PUB_ADJ_DETAIL\n" +
"WHERE\n" +
"InvGroupNum = '{0}') sa\n" +
"LEFT JOIN\n" +
"Set_BBAC_SE_DETAIL se ON\n" +
"sa.KeyCode = se.KeyCode\n" +
"WHERE\n" +
"se.PN IS NULL\n" +
")\n" +
"select tmp1.* from\n" +
"(\n" +
"SELECT\n" +
"t1.LU,\n" +
"t1.PN,\n" +
"t2.RepLU,\n" +
"t1.BusinessType,\n" +
"(t1.PN + t2.RepLU) KeyCode\n" +
"FROM\n" +
"t1\n" +
"INNER JOIN Set_TB_RePartsRelationship t2\n" +
"ON\n" +
"t1.LU = t2.LU\n" +
"AND t1.BusinessType = t2.BusinessType) tmp1\n" +
"INNER JOIN Set_BBAC_SE_DETAIL tmp2 ON\n" +
"tmp1.KeyCode = tmp2.KeyCode\n";
var inv = DbConnection.Query<INVOICE_GRP>($"select * from set_INVOICE_GRP where InvGroupNum='{p_invGroup}'").FirstOrDefault();
Dictionary<BBAC_PD, List<BBAC_PD_DETAIL>> result = new Dictionary<BBAC_PD, List<BBAC_PD_DETAIL>>();
var detail = DbConnection.Query<BBAC_CAN_SA_DETAIL>($"select * from set_BBAC_CAN_SA_DETAIL where billNum='{p_invGroup}'").ToList();
var main = DbConnection.Query<BBAC_CAN_SA>($"select * from set_BBAC_CAN_SA where billNum='{p_invGroup}'").FirstOrDefault();
var entity = main;
if (entity == null)
{
var templist = DbConnection.Query<TEMP_PD_SW>(string.Format(sqljis, p_invGroup));
var entityDetail = detail;
var bbac = new BBAC_PD(
guid: entity.Id,
version: entity.Version,
billNum: entity.BillNum,
settleBillNum: entity.SettleBillNum,
state: SettleBillState.,
invGroupNum: entity.InvGroupNum,
site: entity.Site
);
var query = from itm in detail
join itm1 in templist on itm.KeyCode equals itm1.KeyCode
into temp1
from tm1 in temp1.DefaultIfEmpty()
select new BBAC_PD_DETAIL(
guid: itm.Id,
keyCode: string.IsNullOrEmpty(tm1.KeyCode) ? tm1.KeyCode : itm.KeyCode,
version: itm.Version,
billNum: itm.BillNum,
lU: itm.LU,
rELU: string.IsNullOrEmpty(tm1.RepLU) ? tm1.RepLU : itm.LU,
pN: itm.PN,
rEPN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
invGroupNum: itm.InvGroupNum,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
extend1: string.Empty,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
);
var bbacDetail = query.ToList();
result.Add(bbac, bbacDetail);
}
return result;
}
/// <summary>
/// BBAC生成待扣减
/// </summary>
/// <param name="p_invGroup"></param>
/// <returns></returns>
public Dictionary<HBPO_PD, List<HBPO_PD_DETAIL>> GenerationPendingDeductionHBPO(string p_invGroup)
{
var sqljis = "WITH t1 AS(\n" +
"SELECT\n" +
"DISTINCT sa.KeyCode,\n" +
"sa.LU,\n" +
"sa.PN,\n" +
"sa.BusinessType\n" +
"FROM\n" +
"(\n" +
"SELECT\n" +
"keycode,\n" +
"LU,\n" +
"PN,\n" +
"BusinessType\n" +
"FROM\n" +
"Set_HBPO_CAN_SA_DETAIL\n" +
"WHERE\n" +
"InvGroupNum = '{0}'\n" +
"UNION ALL\n" +
"SELECT\n" +
"keycode,\n" +
"LU,\n" +
"PN,\n" +
"BusinessType\n" +
"FROM\n" +
"Set_PUB_ADJ_DETAIL\n" +
"WHERE\n" +
"InvGroupNum = '{0}') sa\n" +
"LEFT JOIN\n" +
"Set_HBPO_SE_DETAIL se ON\n" +
"sa.KeyCode = se.KeyCode\n" +
"WHERE\n" +
"se.PN IS NULL\n" +
")\n" +
"select tmp1.* from\n" +
"(\n" +
"SELECT\n" +
"t1.LU,\n" +
"t1.PN,\n" +
"t2.RepLU,\n" +
"t1.BusinessType,\n" +
"(t1.PN + t2.RepLU) KeyCode\n" +
"FROM\n" +
"t1\n" +
"INNER JOIN Set_TB_RePartsRelationship t2\n" +
"ON\n" +
"t1.LU = t2.LU\n" +
"AND t1.BusinessType = t2.BusinessType) tmp1\n" +
"INNER JOIN Set_HBPO_SE_DETAIL tmp2 ON\n" +
"tmp1.KeyCode = tmp2.KeyCode\n";
var inv = DbConnection.Query<INVOICE_GRP>($"select * from set_INVOICE_GRP where InvGroupNum='{p_invGroup}'").FirstOrDefault();
Dictionary<HBPO_PD, List<HBPO_PD_DETAIL>> result = new Dictionary<HBPO_PD, List<HBPO_PD_DETAIL>>();
var detail = DbConnection.Query<HBPO_CAN_SA_DETAIL>($"select * from set_HBPO_CAN_SA_DETAIL where billNum='{p_invGroup}'").ToList();
var main = DbConnection.Query<HBPO_CAN_SA>($"select * from set_HBPO_CAN_SA where billNum='{p_invGroup}'").FirstOrDefault();
var entity = main;
if (entity == null)
{
var templist = DbConnection.Query<TEMP_PD_SW>(string.Format(sqljis, p_invGroup));
var entityDetail = detail;
var bbac = new HBPO_PD(
guid: entity.Id,
version: entity.Version,
billNum: entity.BillNum,
settleBillNum: entity.SettleBillNum,
state: SettleBillState.,
invGroupNum: entity.InvGroupNum,
site: entity.Site
);
var query = from itm in detail
join itm1 in templist on itm.KeyCode equals itm1.KeyCode
into temp1
from tm1 in temp1.DefaultIfEmpty()
select new HBPO_PD_DETAIL(
guid: itm.Id,
keyCode: string.IsNullOrEmpty(tm1.KeyCode) ? tm1.KeyCode : itm.KeyCode,
version: itm.Version,
billNum: itm.BillNum,
lU: itm.LU,
rELU: string.IsNullOrEmpty(tm1.RepLU) ? tm1.RepLU : itm.LU,
pN: itm.PN,
rEPN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
invGroupNum: itm.InvGroupNum,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
extend1: string.Empty,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
);
var bbacDetail = query.ToList();
result.Add(bbac, bbacDetail);
}
return result;
}
/// <summary>
/// 其他业务生成待扣减
/// </summary>
/// <param name="p_invGroup"></param>
/// <returns></returns>
public Dictionary<PUB_PD, List<PUB_PD_DETAIL>> GenerationPendingDeductionPUB(string p_invGroup)
{
var sqljis = "WITH t1 AS(\n" +
"SELECT\n" +
"DISTINCT sa.KeyCode,\n" +
"sa.LU,\n" +
"sa.PN,\n" +
"sa.BusinessType\n" +
"FROM\n" +
"(\n" +
"SELECT\n" +
"keycode,\n" +
"LU,\n" +
"PN,\n" +
"BusinessType\n" +
"FROM\n" +
"Set_PUB_CAN_SA_DETAIL\n" +
"WHERE\n" +
"InvGroupNum = '{0}'\n" +
"UNION ALL\n" +
"SELECT\n" +
"keycode,\n" +
"LU,\n" +
"PN,\n" +
"BusinessType\n" +
"FROM\n" +
"Set_PUB_ADJ_DETAIL\n" +
"WHERE\n" +
"InvGroupNum = '{0}') sa\n" +
"LEFT JOIN\n" +
"Set_PUB_SE_DETAIL se ON\n" +
"sa.KeyCode = se.KeyCode\n" +
"WHERE\n" +
"se.PN IS NULL\n" +
")\n" +
"select tmp1.* from\n" +
"(\n" +
"SELECT\n" +
"distinct " +
"t1.LU,\n" +
"t1.PN,\n" +
"t2.RepLU,\n" +
"t1.BusinessType,\n" +
"(t1.PN + t2.RepLU) KeyCode\n" +
"FROM\n" +
"t1\n" +
"INNER JOIN Set_TB_RePartsRelationship t2\n" +
"ON\n" +
"t1.LU = t2.LU\n" +
"AND t1.BusinessType = t2.BusinessType) tmp1\n" +
"INNER JOIN Set_PUB_SE_DETAIL tmp2 ON\n" +
"tmp1.KeyCode = tmp2.KeyCode\n";
var inv = DbConnection.Query<INVOICE_GRP>($"select * from set_INVOICE_GRP where InvGroupNum='{p_invGroup}'").FirstOrDefault();
Dictionary<PUB_PD, List<PUB_PD_DETAIL>> result = new Dictionary<PUB_PD, List<PUB_PD_DETAIL>>();
var detail = DbConnection.Query<PUB_CAN_SA_DETAIL>($"select * from set_PUB_CAN_SA_DETAIL where billNum='{p_invGroup}'").ToList();
var main = DbConnection.Query<PUB_CAN_SA>($"select * from set_PUB_CAN_SA where billNum='{p_invGroup}'").FirstOrDefault();
var entity = main;
if (entity == null)
{
var templist = DbConnection.Query<TEMP_PD_SW>(string.Format(sqljis, p_invGroup));
var entityDetail = detail;
var bbac = new PUB_PD(
guid: entity.Id,
version: entity.Version,
billNum: entity.BillNum,
settleBillNum: entity.SettleBillNum,
state: SettleBillState.,
invGroupNum: entity.InvGroupNum,
site: entity.Site
);
var query = from itm in detail
join itm1 in templist on itm.KeyCode equals itm1.KeyCode
into temp1
from tm1 in temp1.DefaultIfEmpty()
select new PUB_PD_DETAIL(
guid: itm.Id,
keyCode: string.IsNullOrEmpty(tm1.KeyCode) ? tm1.KeyCode : itm.KeyCode,
version: itm.Version,
billNum: itm.BillNum,
lU: itm.LU,
rELU: string.IsNullOrEmpty(tm1.RepLU) ? tm1.RepLU : itm.LU,
pN: itm.PN,
rEPN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
invGroupNum: itm.InvGroupNum,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
extend1: string.Empty,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty,
businessType:itm.BusinessType
);
var bbacDetail = query.ToList();
result.Add(bbac, bbacDetail);
}
return result;
}
}
}

117
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/PD_SERVICE.cs

@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using NPOI.OpenXmlFormats.Spreadsheet;
using SettleAccount.Domain.BQ;
using TaskJob.EventArgs;
using TaskJob.Interfaces;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;
using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.SettleAccounts;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.Repository.SettleAccount;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
using Win.Sfs.Shared.RepositoryBase;
namespace SettleAccount.Job.Services
{
public class PD_SERVICE : ITransientDependency, IExportJob
{
private readonly PendingDeductionDapperRepository _dapper;
private readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _invRepository;
public PD_SERVICE(PendingDeductionDapperRepository dapper,
INormalEfCoreRepository<INVOICE_GRP, Guid> invRepository
)
{
_dapper = dapper;
_invRepository = invRepository;
}
/// <summary>
/// 执行发票待开任务
/// </summary>
/// <param name="id"></param>
/// <param name="exportName"></param>
/// <param name="customConditions"></param>
/// <returns></returns>
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> customConditions)
{
var invgroup = customConditions.Where(p => p.Name == "InvoiceGroupNum").FirstOrDefault().Value;
var ls = _invRepository.Where(p => p.InvGroupNum == invgroup).ToList();
if (ls != null && ls.Count>0)
{
var first=ls.FirstOrDefault();
if (first.BusinessType == EnumBusinessType.JisHBPO)
{
var pd = _dapper.GenerationPendingDeductionHBPO(invgroup);
if (pd.Count > 0)
{
foreach (var c in pd)
{
var main = c.Key;
var detail = c.Value;
_invRepository.DbContext.BulkInsert(new List<HBPO_PD>() { main });
_invRepository.DbContext.BulkInsert(detail);
}
}
else
{
}
}
else if (first.BusinessType == EnumBusinessType.JisBBAC)
{
var pd = _dapper.GenerationPendingDeductionBBAC(invgroup);
if (pd.Count > 0)
{
foreach (var c in pd)
{
var main = c.Key;
var detail = c.Value;
_invRepository.DbContext.BulkInsert(new List<BBAC_PD>() { main });
_invRepository.DbContext.BulkInsert(detail);
}
}
else
{
}
}
else
{
var pd = _dapper.GenerationPendingDeductionPUB(invgroup);
if (pd.Count > 0)
{
foreach (var c in pd)
{
var main = c.Key;
var detail = c.Value;
_invRepository.DbContext.BulkInsert(new List<PUB_PD>() { main });
_invRepository.DbContext.BulkInsert(detail);
}
}
else
{
}
}
}
return id.ToString();
}
}
}

2
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/InvoiceSettledDetailDiffExportService.cs

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;

2
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SettleDoorPanelExportService.cs

@ -1,4 +1,4 @@
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Shouldly; using Shouldly;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

2
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/UnInvoiceSettledDetailDiffExportService.cs

@ -1,4 +1,4 @@
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Shouldly; using Shouldly;
using System; using System;

Loading…
Cancel
Save