mahao 1 year ago
parent
commit
f19ee4e22a
  1. 6
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/job-item.js
  2. 23
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/job-item.js
  3. 136
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
  4. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  5. 23
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs
  6. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  7. 41
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
  8. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  9. 42
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs
  10. 44
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs
  11. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  12. 26
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  13. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs
  14. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs
  15. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_CAN_SA.cs
  16. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs
  17. 11
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_CAN_SA_MNG.cs
  18. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs
  19. 67
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_PD_MNG.cs
  20. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs
  21. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs
  22. 776
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  23. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PD_MNG.cs
  24. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs
  25. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs
  26. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_CAN_SA.cs
  27. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/JobItem.cs
  28. 54
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs
  29. 5051
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230807063408_vmi10.Designer.cs
  30. 38
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230807063408_vmi10.cs
  31. 5057
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230807064336_202308070001.Designer.cs
  32. 58
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230807064336_202308070001.cs
  33. 5279
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230808023302_202308080001.Designer.cs
  34. 106
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230808023302_202308080001.cs
  35. 233
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs
  36. 103
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/PendingDeduction/PendingDeductionDapperRepository.cs
  37. 35
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/PD_SERVICE.cs
  38. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

6
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/job-item.js

@ -23,6 +23,12 @@ const schema = {
type: "boolean",
readOnly: true,
},
heartBeat: {
title: "心跳",
type: "string",
input: "datetime",
readOnly: true,
},
},
};

23
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/job-item.js

@ -1,31 +1,24 @@
import AppList from "../../components/list/index.js";
import html from "html";
import useConfig from "../../models/job-item.js";
import { ref, nextTick, onMounted, onUnmounted } from "vue";
import { ref, onMounted, onUnmounted } from "vue";
import useConfig2 from "../../models/job-log.js";
export default {
components: { AppList },
template: html`<app-list v-if="refresh" :config="config" @command="onCommand" />`,
template: html`<app-list ref="appListRef" :config="config" @command="onCommand" />`,
setup() {
const config = useConfig();
const onCommand = async (item, rows, load, showList) => {
console.log(item.path, item, rows);
console.log(showList);
const config = useConfig2();
config.query.schema.properties.filters.default[0].value = rows[0].id;
showList({ test: "test" }, "/base-data/job-log", config);
};
const refresh = ref(true);
onMounted(async () => {
PubSub.subscribe("JobItem", () => {
refresh.value = false;
nextTick(() => (refresh.value = true));
});
});
onUnmounted(() => {
PubSub.unsubscribe(onMonitor);
});
return { config, onCommand, refresh };
//
const appListRef = ref(null);
const event = "JobItem";
onMounted(() => PubSub.subscribe(event, async () => await appListRef.value.load()));
onUnmounted(() => PubSub.unsubscribe(event));
return { config, onCommand, appListRef };
},
};

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

@ -29,6 +29,7 @@ using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.CommonManagers;
@ -63,25 +64,28 @@ namespace Win.Sfs.SettleAccount.Bases
protected BA_SERVICE(
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository,
protected BA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> pubRepository,
INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository,
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository,
IExcelImportAppService excelImportService,
HBPO_CAN_SA_MNG hbpoMng,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository,
BBAC_CAN_SA_MNG bbacMng,
HBPO_CAN_SA_MNG hbpoMng,
PUB_CAN_SA_MNG pubMng,
INV_MNG invMng,
TaskJobService service
//INormalEfCoreRepository<TEntityDetail, Guid> detailRepository
)
) :
base(excelImportService, snowflakeIdGenerator, commonManager)
{
_service= service;
_service = service;
_repository = repository;
_wRepository = wRepository;
_mRepository = mRepository;
@ -91,28 +95,6 @@ namespace Win.Sfs.SettleAccount.Bases
_bbacMng = bbacMng;
_hbpoMng = hbpoMng;
_invMng = invMng;
}
protected BA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> pubRepository,
INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository,
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository,
BBAC_CAN_SA_MNG pubMng,
HBPO_CAN_SA_MNG bbacMng,
PUB_CAN_SA_MNG hbpoMng,
INV_MNG invMng
) :
base(excelImportService, snowflakeIdGenerator, commonManager)
{
}
/// <summary>
/// 审核通过
@ -222,58 +204,52 @@ namespace Win.Sfs.SettleAccount.Bases
[HttpPost]
public virtual async Task<string> RejectAsync(INVOICE_GRP_REQ_DTO input)
{
await _invMng.Reject(input.InvGroupNum);
return ApplicationConsts.SuccessStr;
}
[HttpPost]
public virtual async Task<string> ReceivedAsync(INVOICE_GRP_REQ_DTO input)
[UnitOfWork(false)]
public virtual async Task<string> ReceivedAsync(List<string> p_ins)
{
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)
{
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.)
{
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.客户已收票);
//}
}
await _invMng.ReceivedAsync(p_ins);
//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)
//{
// List<CustomCondition> customConditionList = new List<CustomCondition>();
// customConditionList.Add(new CustomCondition() { Name = "InvGroupNum", Value = entity.InvGroupNum?? string.Empty });
// var invlist= _repository.Where(p => p.InvGroupNum == entity.InvGroupNum).ToList();
// foreach (var inv in invlist) {
// if (inv.InvoiceState != InvoiceBillState.报废)
// {
// 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;
//}
return ApplicationConsts.SuccessStr;
}
protected virtual async Task<List<INVOICE_MAP_GROUP_DTO>> GetMapGroupAsync(INVOICE_GRP_REQ_DTO input)
@ -353,9 +329,9 @@ namespace Win.Sfs.SettleAccount.Bases
/// <param name="p_version">版本号</param>
/// <param name="p_InvGroupNum">发票分组</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<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_adjlist,List<TEMP_CAN_SA_DETAIL> p_tmplist, int p_version, string p_parentInvBillNum) where TDetail : SA_CAN_BASE
{
var flag=await _invMng.ReissueSecInvoice(p_list, p_adjlist, p_parentInvBillNum, p_version);
var flag=await _invMng.ReissueSecInvoice(p_list,p_adjlist, p_tmplist, p_parentInvBillNum, p_version);
if (flag)
{
return true;
@ -376,10 +352,10 @@ namespace Win.Sfs.SettleAccount.Bases
/// <param name="p_parentInvBillNum">要作废的发票号</param>
/// <param name="businessType"></param>
/// <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<TDetail>(List<TDetail> p_list,List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_parentInvBillNum) where TDetail : SA_CAN_BASE
{
var flag = await _invMng.ReissueFirstInvoice(dtos, p_adjlist, p_parentInvBillNum, p_version);
var flag = await _invMng.ReissueFirstInvoice(p_list,p_adjlist,dtos, p_parentInvBillNum, p_version);
if (flag==true)
{
return true;

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

@ -164,9 +164,9 @@ namespace Win.Sfs.SettleAccount.Bases
/// <param name="p_version">版本号</param>
/// <param name="p_InvGroupNum">发票分组</param>
/// <param name="p_parentInvBillNum">原发票号</param>
protected async Task<bool> SecInvoice(List<TEMP_CAN_SA_DETAIL> p_list, int p_version, string p_InvGroupNum, string p_parentInvBillNum,EnumBusinessType businessType)
protected async Task<bool> SecInvoice<TDetail>(List<TDetail> p_list,List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> p_tmplist, int p_version, string p_InvGroupNum, string p_parentInvBillNum,EnumBusinessType businessType) where TDetail : SA_CAN_BASE
{
var ls= await _invmng.SecInvoice(p_list, p_version, p_InvGroupNum, p_parentInvBillNum, businessType);
var ls= await _invmng.SecInvoice(p_list,p_adjlist,p_tmplist,p_version, p_InvGroupNum, p_parentInvBillNum, businessType);
if (ls.Count > 0)
{
return true;
@ -186,10 +186,10 @@ namespace Win.Sfs.SettleAccount.Bases
/// <param name="p_parentInvBillNum"></param>
/// <param name="businessType"></param>
/// <returns></returns>
protected async Task<bool> FirstInvoice(List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
protected async Task<bool> FirstInvoice<TDetail>(List<TDetail> p_list,List<PUB_ADJ_DETAIL> p_adjlist ,List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) where TDetail : SA_CAN_BASE
{
var ls = await _invmng.FirstInvoice(dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType);
var ls = await _invmng.FirstInvoice(p_list,p_adjlist, dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType);
if (ls.Count > 0)
{
return true;

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

@ -21,6 +21,7 @@ using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.Entities.TaskJobs;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ
@ -34,6 +35,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
private readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _adjRepository;
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
public BBAC_BA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
@ -42,16 +44,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository,
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository,
BBAC_CAN_SA_MNG pubMng,
HBPO_CAN_SA_MNG bbacMng,
PUB_CAN_SA_MNG hbpoMng,
INV_MNG invMng,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository,
BBAC_CAN_SA_MNG bbacMng,
HBPO_CAN_SA_MNG hbpoMng,
PUB_CAN_SA_MNG pubMng,
INV_MNG invMng,
TaskJobService service,
INormalEfCoreRepository<PriceList, Guid> priceRepository
) : base(excelImportService, snowflakeIdGenerator, commonManager, pubRepository, repository, wRepository, sRepository, mRepository, pubMng, bbacMng, hbpoMng, invMng)
) : base(excelImportService, snowflakeIdGenerator, commonManager, pubRepository, repository, wRepository, sRepository, mRepository, adjRepository, bbacMng, hbpoMng, pubMng, invMng, service)
{
_adjRepository = adjRepository;
_priceRepository = priceRepository;
}
@ -105,7 +108,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
contactid: itm.Extend1//生产号
contactid: itm.Extend1,//生产号
invbillnum:string.Empty
));
}
}
@ -148,11 +153,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
if (p_invbillnum.Substring(0, 3) == "INV")//一次开票重开
{
await ReissueFirstInvoice(dtos,adjlist ,version, p_invbillnum);
await ReissueFirstInvoice(bbaclist,adjlist,dtos,version, p_invbillnum);
}
else//二次开票
{
await ReissueSecInvoice(dtos,adjlist,version, p_invbillnum);
await ReissueSecInvoice(bbaclist,adjlist,dtos,version, p_invbillnum);
}
}
}

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

@ -149,11 +149,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
ContractDocID = string.Empty
}).ToList();//不能结算
await FirstInvoice(dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
await FirstInvoice(entitys,new List<PUB_ADJ_DETAIL>(),dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
else//二次开票
{
await SecInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
await SecInvoice(entitys,new List<PUB_ADJ_DETAIL>(),dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
}
}

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

@ -19,6 +19,7 @@ using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.Entities.TaskJobs;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ
@ -27,30 +28,27 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[Route("api/settleaccount/[controller]/[action]")]
public class HBPO_BA_SERVICE : BA_SERVICE
{
private readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _adjRepository;
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
public HBPO_BA_SERVICE(
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> pubRepository,
INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository,
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository,
BBAC_CAN_SA_MNG pubMng,
HBPO_CAN_SA_MNG bbacMng,
PUB_CAN_SA_MNG hbpoMng,
INV_MNG invMng,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository,
public HBPO_BA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> pubRepository, INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository, BBAC_CAN_SA_MNG bbacMng,
HBPO_CAN_SA_MNG hbpoMng, PUB_CAN_SA_MNG pubMng, INV_MNG invMng,
TaskJobService service,
INormalEfCoreRepository<PriceList, Guid> priceRepository
) : base(excelImportService, snowflakeIdGenerator, commonManager, pubRepository, repository, wRepository, sRepository, mRepository, pubMng, bbacMng, hbpoMng, invMng)
)
: base(excelImportService, snowflakeIdGenerator, commonManager, pubRepository, repository, wRepository, sRepository, mRepository, adjRepository, bbacMng, hbpoMng, pubMng, invMng, service)
{
_adjRepository = adjRepository;
_priceRepository = priceRepository;
_priceRepository= priceRepository;
}
/// <summary>
/// 发票重开
/// </summary>
@ -97,7 +95,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum
invGroupNum: itm.InvGroupNum,
invbillnum: string.Empty
));
}
}
@ -139,12 +138,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
if (p_invbillnum.Substring(0, 3) == "INV")//一次开票重开
{
await ReissueFirstInvoice(dtos,adjlist, version, p_invbillnum);
await ReissueFirstInvoice(hbpolist,adjlist ,dtos, version, p_invbillnum);
}
else//二次开票
{
await ReissueSecInvoice(dtos,adjlist, version, p_invbillnum);
await ReissueSecInvoice(hbpolist,adjlist ,dtos, version, p_invbillnum);
}
}
}

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

@ -137,11 +137,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
ContractDocID = string.Empty
}).ToList();//不能结算
var falg= await FirstInvoice(dtos, notlist, main.Version, main.InvGroupNum, string.Empty,main.BusinessType);
var falg= await FirstInvoice(entitys,new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty,main.BusinessType);
}
else//二次开票
{
var flag=await SecInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
var flag=await SecInvoice(entitys,new List<PUB_ADJ_DETAIL>(),dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
}

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

@ -7,9 +7,11 @@ using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Cronos;
using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SettleAccount.Job.SignalR;
using Volo.Abp.Application.Services;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
@ -83,13 +85,20 @@ public class JobHostdService : BackgroundService, IApplicationService
{
var jobItem = this.GetJobItem(job.Id);
Guid? jobLogId = null;
if (jobItem.IsRunning && (DateTime.Now - jobItem.HeartBeat.Value).TotalSeconds > 20)
{
JobItemStop(jobItem.Id);
}
if (!jobItem.IsRunning)
{
jobLogId = this.JobItemStart(job.Id);
using var timer = new System.Timers.Timer(10000);
if (jobLogId.HasValue)
{
try
{
timer.Elapsed += (s, e) => JobItemHeartBeat(job.Id);
scope.ServiceProvider.GetRequiredService<IHubContext<PageHub>>().Clients.All.ServerToClient("JobItem", "refresh", "");
await jobService.Invoke(scope.ServiceProvider).ConfigureAwait(false);
this.JobItemSuccess(job.Id, jobLogId.Value);
Debug.WriteLine($"{job.Name} 定时任务执行成功");
@ -100,6 +109,11 @@ public class JobHostdService : BackgroundService, IApplicationService
Console.WriteLine(ex.ToString());
this.JobItemFaild(job.Id, jobLogId.Value, ex);
}
finally
{
timer.Stop();
scope.ServiceProvider.GetRequiredService<IHubContext<PageHub>>().Clients.All.ServerToClient("JobItem", "refresh", "");
}
}
}
}
@ -169,6 +183,21 @@ public class JobHostdService : BackgroundService, IApplicationService
}
}
private void JobItemStop(Guid id)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var entity = db.Set<JobItem>().FirstOrDefault(o => o.Id == id);
if (entity != null)
{
entity.IsRunning = false;
var log = db.Set<JobLog>().Where(o => o.JobId == id && o.End == null).OrderByDescending(o => o.Start).FirstOrDefault();
log.Success = false;
log.Exception = "心跳超时,自动停止";
db.SaveChanges();
}
}
private Guid? JobItemStart(Guid id)
{
using var scope = this._serviceProvider.CreateScope();
@ -177,6 +206,7 @@ public class JobHostdService : BackgroundService, IApplicationService
if (entity != null)
{
entity.IsRunning = true;
entity.HeartBeat = DateTime.Now;
var log = db.Set<JobLog>().Add(new JobLog { Start = DateTime.Now, JobId = entity.Id, Host = Dns.GetHostName() });
db.SaveChanges();
return log.Entity.Id;
@ -190,6 +220,18 @@ public class JobHostdService : BackgroundService, IApplicationService
return scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>().Set<JobItem>().AsNoTracking().FirstOrDefault(o => o.Id == id);
}
private void JobItemHeartBeat(Guid id)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var entity = db.Set<JobItem>().FirstOrDefault(o => o.Id == id);
if (entity != null)
{
entity.HeartBeat = DateTime.Now;
db.SaveChanges();
}
}
public void RemoveJob(JobItem item)
{
lock (_lockObj)

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

@ -18,6 +18,7 @@ using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.Entities.TaskJobs;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ
@ -27,27 +28,25 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public class PUB_BA_SERVICE : BA_SERVICE
{
private readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _adjRepository;
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
public PUB_BA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> pubRepository,
INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository,
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository,
BBAC_CAN_SA_MNG pubMng,
HBPO_CAN_SA_MNG bbacMng,
PUB_CAN_SA_MNG hbpoMng,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository,
INormalEfCoreRepository<PriceList, Guid> priceRepository,
INV_MNG invMng) : base(excelImportService, snowflakeIdGenerator, commonManager, pubRepository, repository, wRepository, sRepository, mRepository, pubMng, bbacMng, hbpoMng, invMng)
public PUB_BA_SERVICE(IExcelImportAppService excelImportService, ISnowflakeIdGenerator snowflakeIdGenerator, ICommonManager commonManager, INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> pubRepository, INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository, BBAC_CAN_SA_MNG bbacMng, HBPO_CAN_SA_MNG hbpoMng, PUB_CAN_SA_MNG pubMng, INV_MNG invMng,
TaskJobService service, INormalEfCoreRepository<PriceList, Guid> priceRepository
) : base(excelImportService, snowflakeIdGenerator, commonManager, pubRepository, repository, wRepository, sRepository, mRepository, adjRepository, bbacMng, hbpoMng, pubMng, invMng, service)
{
_adjRepository = adjRepository;
_priceRepository = priceRepository;
}
// <summary>
/// 发票重开
/// </summary>
@ -76,13 +75,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
throw new BusinessException("8989", $"选择发票:{p_invbillnum}状态为报废状态不能重开!");
}
var hbpolist = await _pubMng.GetContainsAsync(inv.InvbillNum, gList);//结算分组对应结算零件
var publist = await _pubMng.GetContainsAsync(inv.InvbillNum, gList);//结算分组对应结算零件
var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
hbpolist.Add(new PUB_CAN_SA_DETAIL(
publist.Add(new PUB_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
@ -96,12 +95,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum
invGroupNum: itm.InvGroupNum,
invbillnum: string.Empty
));
}
}
var entitys = hbpolist;//合并库存调整单和就发票可结算明细数据
var entitys = publist;//合并库存调整单和就发票可结算明细数据
var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
//var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).ToList();//不能结算
@ -140,11 +140,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
if (p_invbillnum.Substring(0, 3) == "INV")//一次开票重开
{
await ReissueFirstInvoice(dtos,adjlist, version, p_invbillnum);
await ReissueFirstInvoice(publist,adjlist,dtos, version, p_invbillnum);
}
else//二次开票
{
await ReissueSecInvoice(dtos,adjlist, version, p_invbillnum);
await ReissueSecInvoice(publist,adjlist, dtos, version, p_invbillnum);
}
}
}

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

@ -6,6 +6,7 @@ using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Volo.Abp.Domain.Entities;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases;
@ -120,22 +121,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
if (main.BusinessType == EnumBusinessType.MaiDanJianHBPO || main.BusinessType == EnumBusinessType.BeiJian)
{
var strs=await _invmng.MakeInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, true);
var strs=await _invmng.MakeInvoice(entitys,new List<PUB_ADJ_DETAIL>(), 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(entitys,new List<PUB_ADJ_DETAIL>(), dtos, new List<TEMP_NOT_SA_DETAIL>(), main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
}
else//二次开票
{
if (main.BusinessType == EnumBusinessType.MaiDanJianHBPO || main.BusinessType==EnumBusinessType.BeiJian )
{
var strs=await _invmng.MakeInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, true);
var strs=await _invmng.MakeInvoice(entitys,new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, true);
}
else
{
await SecInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
await SecInvoice(entitys,new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
}

26
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -128,7 +128,7 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
[DisableValidation]
public virtual Task Invoke(IServiceProvider serviceProvider)
{
this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", "");
//this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", "");
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files/vmi"));
var date = DateTime.Now.ToString("yyyyMMddHH");
var connectionString = $"Data Source=wwwroot/files/vmi/{date}.db";
@ -166,7 +166,7 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
throw;
}
}
this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", "");
//this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", "");
return Task.CompletedTask;
}
@ -208,7 +208,18 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
var qty = balance.Qty + data.Qty;
balance.InjectFrom(data);
balance.Qty = qty;
this._balanceRepository.UpdateAsync(balance).Wait();
if (balance.Qty == decimal.Zero)
{
await this._balanceRepository.DeleteAsync(balance).ConfigureAwait(false);
}
else
{
await this._balanceRepository.UpdateAsync(balance).ConfigureAwait(false);
}
if (logType == VmiLogType.Type100 && balance.Qty < decimal.Zero && data.Qty > 0)
{
log.IsReplenished = true;
}
}
await _logRepository.InsertAsync(log).ConfigureAwait(false);
}
@ -253,7 +264,14 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
{
var qty = balance.Qty - data.Qty;
balance.Qty = qty;
this._balanceRepository.UpdateAsync(balance).Wait();
if (balance.Qty == decimal.Zero)
{
await this._balanceRepository.DeleteAsync(balance).ConfigureAwait(false);
}
else
{
await this._balanceRepository.UpdateAsync(balance).ConfigureAwait(false);
}
}
await _logRepository.InsertAsync(log).ConfigureAwait(false);
}

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

@ -391,7 +391,7 @@ namespace SettleAccount.Bases
/// </summary>
public decimal Price { set; get; }
/// <summary>
/// 可出库结算单
/// 发票字段
/// </summary>
public string BillNum { set; get; }
/// <summary>
@ -427,6 +427,9 @@ namespace SettleAccount.Bases
/// </summary>
public string SettleBillNum { get; set; }
public string InvbillNum { get; set; }
//public SA_CAN_BASE(int version, decimal price, string billNum, DateTime settleDate, string invGroupNum, string lU, string pN, string keyCode, decimal qty, string groupNum)
//{
// Version = version;

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

@ -139,9 +139,10 @@ public class BBAC_CAN_SA_DETAIL: SA_CAN_BASE
public BBAC_CAN_SA_DETAIL(Guid guid,string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, EnumBusinessType category, bool isReturn,
DateTime settleDate, string groupNum, string invGroupNum
,string contactid
,string contactid,string invbillnum
):base(guid)
{
InvbillNum = invbillnum;
KeyCode = keyCode;
Version = version;

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

@ -124,8 +124,9 @@ public class HBPO_CAN_SA_DETAIL:SA_CAN_BASE
/// </summary>
public EnumBusinessType BusinessType { get; set; }
public HBPO_CAN_SA_DETAIL(Guid guid ,string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, DateTime settleDate, string groupNum, string invGroupNum, EnumBusinessType businessType)
public HBPO_CAN_SA_DETAIL(Guid guid ,string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, DateTime settleDate, string groupNum, string invGroupNum, EnumBusinessType businessType, string invbillnum)
{
InvbillNum=invbillnum;
Id = guid;
KeyCode = keyCode;
Version = version;

2
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs

@ -7,7 +7,7 @@ namespace SettleAccount.Domain.BQ;
[Display(Name = "发票分组")]
public class INVOICE_GRP : FullAuditedAggregateRoot<Guid>
{
[Display(Name = "实际纸质发票号")]
[Display(Name = "金税发票号")]
public string RealnvBillNum { get; set; } = null!;
[Display(Name = "系统生成发票号")]

11
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_CAN_SA_MNG.cs

@ -254,6 +254,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
/// <summary>
/// 通过发票号获取结算数据
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<List<BBAC_CAN_SA_DETAIL>> GetDetailByInbillNumAsync(List<string> p_invs)
{
return await _detailRepository.Where(p =>p_invs.Contains(p.BillNum)).ToListAsync();
}

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

@ -69,7 +69,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: billNumber,
contactid: itm.ContractDocID
contactid: itm.ContractDocID,
invbillnum: string.Empty
);
_entityList.Add(_detailEntity);

67
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_PD_MNG.cs

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers;
public class BBAC_PD_MNG:DomainService
{
private readonly INormalEfCoreRepository<BBAC_PD, Guid> _repository;
private readonly INormalEfCoreRepository<BBAC_PD_DETAIL, Guid> _detailRepository;
protected BBAC_PD_MNG(
INormalEfCoreRepository<BBAC_PD, Guid> repository,
INormalEfCoreRepository<BBAC_PD_DETAIL, Guid> detailRepository
)
{
_repository = repository;
_detailRepository = detailRepository;
}
public BBAC_PD_MNG()
{
}
public virtual async Task<BBAC_PD> GetMainAsync(string billNum)
{
return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync();
}
public virtual async Task<List<BBAC_PD_DETAIL>> GetDetailAsync(string billNum)
{
return await _detailRepository.Where(p => p.InvGroupNum == billNum).ToListAsync();
}
public virtual bool InsertMain(BBAC_PD p_pd)
{
_repository.DbContext.BulkInsert(new List<BBAC_PD> { p_pd });
return true;
}
public virtual bool InsertDetail(List<BBAC_PD_DETAIL> p_list)
{
_repository.DbContext.BulkInsert(p_list);
return false;
}
}

9
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs

@ -264,6 +264,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
/// <summary>
/// 通过发票号获取结算数据
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<List<HBPO_CAN_SA_DETAIL>> GetDetailByInbillNumAsync(List<string> p_invs)
{
return await _detailRepository.Where(p => p_invs.Contains(p.BillNum)).ToListAsync();
}
}

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

@ -72,7 +72,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
businessType: itm.BusinessType,
qty: itm.Qty,
settleDate: itm.SettleDate,
site: itm.Site
site: itm.Site,
invbillnum: string.Empty
);
_entityList.Add(_detailEntity);
}

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

@ -1,4 +1,5 @@
using EFCore.BulkExtensions;
using EmptyFiles;
using Hangfire;
using Microsoft.AspNetCore.SignalR;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@ -8,8 +9,10 @@ using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
@ -31,9 +34,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
private readonly INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> _groupRepository;
private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _detailRepository;
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _notRepository;
private readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _adjRepository;
private readonly INormalEfCoreRepository<BBAC_PD, Guid> _pdbbacRepository;
private readonly INormalEfCoreRepository<HBPO_PD, Guid> _pdhbpoRepository;
private readonly INormalEfCoreRepository<PUB_PD, Guid> _pdpubRepository;
private readonly PUB_CAN_SA_MNG _pubMng;
private readonly BBAC_CAN_SA_MNG _bbacMng;
private readonly HBPO_CAN_SA_MNG _hbpoMng;
@ -42,13 +47,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
PUB_CAN_SA_MNG pubMng,
BBAC_CAN_SA_MNG bbacMng,
HBPO_CAN_SA_MNG hbpoMng,
INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
INormalEfCoreRepository<BBAC_PD, Guid> pdbbacRepository,
INormalEfCoreRepository<HBPO_PD, Guid> pdhbpoRepository,
INormalEfCoreRepository<PUB_PD, Guid> pdpubRepository,
INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> groupRepository,
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> detailRepository,
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> notRepository,
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository
)
{
//_canRepository = canRepository;
_repository = repository;
_detailRepository = detailRepository;
@ -58,6 +67,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
_pubMng = pubMng;
_bbacMng = bbacMng;
_hbpoMng = hbpoMng;
_pdbbacRepository=pdbbacRepository;
_pdhbpoRepository=pdhbpoRepository;
_pdpubRepository =pdpubRepository;
}
public INV_MNG()
@ -234,21 +246,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
break;
}
var flag = await SetSettleState(p_entiy, p_State, false);
//var flag = await SetSettleState(p_entiy, p_State, false);
if (flag == true)
{
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);
//if (flag == true)
//{
// 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(p_entiy);
return true;
}
//}
return false;
}
@ -289,172 +302,444 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
/// <summary>
/// 客户已收票
/// </summary>
/// <param name="p_groupbillnum">发票分组号</param>
/// <returns></returns>
public virtual async Task<bool> ReceivedAsync(string p_groupbillnum)
public virtual async Task<bool> ReceivedAsync(List<string> p_invs)
{
var invList = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList();//所有提交发票信息
int count = invList.Select(p => p.InvGroupNum).Distinct().Count();
if (count > 1)
{
throw new UserFriendlyException($"发票不属于一个发票分组");
}
var lostlist = invList.Where(p => p.InvoiceState == InvoiceBillState.).ToList();
if (lostlist.Count > 0)
{
var invs=lostlist.Select(p => p.InvbillNum).ToList();
throw new UserFriendlyException($"发票{string.Join(",",invs)}");
}
var inv = invList.FirstOrDefault();
if (inv.BusinessType == EnumBusinessType.JisBBAC)
{
var pdlist = _pdbbacRepository.Where(p => p_invs.Contains(p.BillNum)).ToList();//包含发票号的代扣减单
if (pdlist != null && pdlist.Count > 0)
{
var invs = pdlist.Select(p => p.BillNum).ToList();
throw new UserFriendlyException($"发票{string.Join(",", invs)}已经生成待扣减过不能再次提交");
}
var parentList = invList.Select(p => p.ParentInvbillNum).ToList();//所有发票存在父发票号
List<string> oldinvs = new List<string>();
oldinvs.AddRange(p_invs);
if (parentList != null && parentList.Count > 0)
{
oldinvs.AddRange(parentList);
}
List<string> oldlist = new List<string>();//以前提交过的发票
List<string> newlist = new List<string>();//没有提交过的发票
var pdoldlist = pdlist.Where(p => oldinvs.Contains(p.BillNum)).ToList();
if (pdoldlist != null && pdoldlist.Count > 0)
{
oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号
}
newlist = p_invs.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号
//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)
// {
List<BBAC_CAN_SA_DETAIL> entityList = new List<BBAC_CAN_SA_DETAIL>();//结算明细
var namelist = invList.Select(p => p.InvbillNum).ToList();
if (oldlist.Count > 0)
{
var involdList= invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList();
var involdname=involdList.Select(p => p.InvbillNum);
var adjlist=_adjRepository.Where(p => involdname.Contains(p.InvBillNum));
// 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;
// }
// }
//}
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
entityList.Add(new BBAC_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.InvGroupNum,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
category: itm.BusinessType,
isReturn: itm.Qty > 0 ? false : true,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
contactid: itm.Extend1,//生产号
invbillnum: itm.InvBillNum
));
}
}
}
if (newlist.Count > 0)
{
var entitys = invList.Where(p => newlist.Contains(p.InvbillNum)).ToList();
var entityDetail = await _bbacMng.GetDetailByInbillNumAsync(newlist);//结算明细
var adjlist = _adjRepository.Where(p => newlist.Contains(p.InvBillNum)).ToList();//发票关联调整表明细
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
entityDetail.Add(new BBAC_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.InvGroupNum,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
category: itm.BusinessType,
isReturn: itm.Qty > 0 ? false : true,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
contactid: itm.Extend1,//生产号
invbillnum: itm.InvBillNum
));
}
}
entityList.AddRange(entityDetail);
}
var bbacmainlist = new List<BBAC_PD>();
foreach (var itm in invList)
{
var bbac = new BBAC_PD(
guid: itm.Id,
version:int.Parse(DateTime.Now.ToString("yyyyMM")),
billNum: itm.InvbillNum,
settleBillNum: itm.InvGroupNum,
state: SettleBillState.,
invGroupNum: itm.InvGroupNum,
site: string.Empty
);
bbacmainlist.Add( bbac );
}
var bbacDetail = new List<BBAC_PD_DETAIL>();
foreach (var itm in entityList)
{
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: 0,
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(bbacmainlist);
await _repository.DbContext.BulkInsertAsync(bbacDetail);
return true;
}
else if (inv.BusinessType == EnumBusinessType.JisHBPO)
{
var pdlist = _pdhbpoRepository.Where(p => p_invs.Contains(p.BillNum)).ToList();//包含发票号的代扣减单
if (pdlist != null && pdlist.Count > 0)
{
var invs = pdlist.Select(p => p.BillNum).ToList();
throw new UserFriendlyException($"发票{string.Join(",", invs)}已经生成待扣减过不能再次提交");
}
var parentList = invList.Select(p => p.ParentInvbillNum).ToList();//所有发票存在父发票号
List<string> oldinvs = new List<string>();
oldinvs.AddRange(p_invs);
if (parentList != null && parentList.Count > 0)
{
oldinvs.AddRange(parentList);
}
List<string> oldlist = new List<string>();//以前提交过的发票
List<string> newlist = new List<string>();//没有提交过的发票
var pdoldlist = pdlist.Where(p => oldinvs.Contains(p.BillNum)).ToList();
if (pdoldlist != null && pdoldlist.Count > 0)
{
oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号
}
newlist = p_invs.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号
List<HBPO_CAN_SA_DETAIL> entityList = new List<HBPO_CAN_SA_DETAIL>();//结算明细
var namelist = invList.Select(p => p.InvbillNum).ToList();
if (oldlist.Count > 0)
{
var involdList = invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList();
var involdname = involdList.Select(p => p.InvbillNum);
var adjlist = _adjRepository.Where(p => involdname.Contains(p.InvBillNum));
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
entityList.Add(new HBPO_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.InvGroupNum,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: itm.InvBillNum
));
}
}
}
if (newlist.Count > 0)
{
var entitys = invList.Where(p => newlist.Contains(p.InvbillNum)).ToList();
var entityDetail = await _hbpoMng.GetDetailByInbillNumAsync(newlist);//结算明细
var adjlist = _adjRepository.Where(p => newlist.Contains(p.InvBillNum)).ToList();//发票关联调整表明细
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
entityDetail.Add(new HBPO_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.InvGroupNum,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: itm.InvBillNum
));
}
}
entityList.AddRange(entityDetail);
}
var bbacmainlist = new List<HBPO_PD>();
foreach (var itm in invList)
{
var bbac = new HBPO_PD(
guid: itm.Id,
version: int.Parse(DateTime.Now.ToString("yyyyMM")),
billNum: itm.InvbillNum,
settleBillNum: itm.InvGroupNum,
state: SettleBillState.,
invGroupNum: itm.InvGroupNum,
site: string.Empty
);
bbacmainlist.Add(bbac);
}
var bbacDetail = new List<HBPO_PD_DETAIL>();
foreach (var itm in entityList)
{
bbacDetail.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: 0,
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(bbacmainlist);
await _repository.DbContext.BulkInsertAsync(bbacDetail);
return true;
}
else
{
var pdlist = _pdpubRepository.Where(p => p_invs.Contains(p.BillNum)).ToList();//包含发票号的代扣减单
if (pdlist != null && pdlist.Count > 0)
{
var invs = pdlist.Select(p => p.BillNum).ToList();
throw new UserFriendlyException($"发票{string.Join(",", invs)}已经生成待扣减过不能再次提交");
}
var parentList = invList.Select(p => p.ParentInvbillNum).ToList();//所有发票存在父发票号
List<string> oldinvs = new List<string>();
oldinvs.AddRange(p_invs);
if (parentList != null && parentList.Count > 0)
{
oldinvs.AddRange(parentList);
}
List<string> oldlist = new List<string>();//以前提交过的发票
List<string> newlist = new List<string>();//没有提交过的发票
var pdoldlist = pdlist.Where(p => oldinvs.Contains(p.BillNum)).ToList();
if (pdoldlist != null && pdoldlist.Count > 0)
{
oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号
}
newlist = p_invs.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号
List<PUB_CAN_SA_DETAIL> entityList = new List<PUB_CAN_SA_DETAIL>();//结算明细
var namelist = invList.Select(p => p.InvbillNum).ToList();
if (oldlist.Count > 0)
{
var involdList = invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList();
var involdname = involdList.Select(p => p.InvbillNum);
var adjlist = _adjRepository.Where(p => involdname.Contains(p.InvBillNum));
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
entityList.Add(new PUB_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.InvGroupNum,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: itm.InvBillNum
));
}
}
}
if (newlist.Count > 0)
{
var entitys = invList.Where(p => newlist.Contains(p.InvbillNum)).ToList();
var entityDetail = await _pubMng.GetDetailByInbillNumAsync(newlist);//结算明细
var adjlist = _adjRepository.Where(p => newlist.Contains(p.InvBillNum)).ToList();//发票关联调整表明细
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
{
entityDetail.Add(new PUB_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: itm.InvGroupNum,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: 0,
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: itm.InvBillNum
));
}
}
entityList.AddRange(entityDetail);
}
var bbacmainlist = new List<PUB_PD>();
foreach (var itm in invList)
{
var pub = new PUB_PD(
guid: itm.Id,
version: int.Parse(DateTime.Now.ToString("yyyyMM")),
billNum: itm.InvbillNum,
settleBillNum: itm.InvGroupNum,
state: SettleBillState.,
invGroupNum: itm.InvGroupNum,
site: string.Empty
);
bbacmainlist.Add(pub);
}
var bbacDetail = new List<PUB_PD_DETAIL>();
foreach (var itm in entityList)
{
bbacDetail.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: 0,
businessType:itm.BusinessType,
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(bbacmainlist);
await _repository.DbContext.BulkInsertAsync(bbacDetail);
return true;
}
return false;
}
public virtual async Task<bool> Reject(INVOICE_GRP p_entity)
@ -572,7 +857,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <param name="p_version">版本号</param>
/// <param name="p_InvGroupNum">发票分组</param>
/// <param name="p_parentInvBillNum">原发票号</param>
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<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_ajdlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
where TDetail : SA_CAN_BASE
{
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
@ -634,7 +921,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
tempList.Add(group1);
}
invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1
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
@ -654,15 +941,46 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
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>();
var salist = new List<TDetail>();
var adjlist = new List<PUB_ADJ_DETAIL>();
foreach (var group in invoiceMap)
{
var key = group.Key;//发票票号
var ls = group.Value;//发票明细
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
var query = from itm in dtos
join itm1 in ls
on new { itm.LU, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate }
join itm2 in p_list on new { itm.LU, itm.SettleDate } equals new { itm2.LU, itm2.SettleDate }
select itm2;
foreach (var itm in query)
{
itm.InvbillNum = key;
salist.Add(itm);
}
if (!string.IsNullOrEmpty(p_parentInvBillNum))
{
var query1 = from itm in dtos
join itm1 in ls
on new { itm.LU, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate }
join itm2 in p_ajdlist on new { itm.LU, itm.SettleDate } equals new { itm2.LU, itm2.SettleDate }
select itm2;
foreach (var itm in query1)
{
itm.InvBillNum = key;
adjlist.Add(itm);
}
}
List < INVOICE_WAIT_DETAIL > _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in ls)
{
_entityDetailList.Add(
@ -730,9 +1048,20 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
if(salist.Count>0)
{
await _repository.DbContext.BulkUpdateAsync(salist);
}
if (adjlist.Count > 0)
{
await _repository.DbContext.BulkUpdateAsync(adjlist);
}
//await _repository.DbContext.BulkInsertAsync(notDetialList);
_invls = invlist.Select(p => p.InvbillNum).ToList();
}
@ -750,7 +1079,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <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)
public async Task<List<string>> MakeInvoice<TDetail>(List<TDetail> details,List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType, bool p_first) where TDetail : SA_CAN_BASE
{
List<string> _invls = new List<string>();
var groups1 = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV
@ -792,7 +1121,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV");
}
List<TMEP_INV> tempList = new List<TMEP_INV>();
decimal sum = group.Amt;//初始合计金额
int partCount = 0;
@ -845,10 +1173,39 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
var salist = new List<TDetail>();
var adjlist = new List<PUB_ADJ_DETAIL>();
foreach (var group in invoiceMap)
{
var key = group.Key;//发票票号
var ls = group.Value;//发票明细
//更新结算记录更新
var query = from itm in dtos
join itm1 in ls
on new { itm.LU, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate }
join itm2 in details on new { itm.LU, itm.SettleDate } equals new { itm2.LU, itm2.SettleDate }
select itm2;
foreach (var itm in query)
{
itm.InvbillNum = key;
salist.Add(itm);
}
if (!string.IsNullOrEmpty(p_parentInvBillNum))
{
var query1 = from itm in dtos
join itm1 in ls
on new { itm.LU, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate }
join itm2 in p_adjlist on new { itm.LU, itm.SettleDate } equals new { itm2.LU, itm2.SettleDate }
select itm2;
foreach (var itm in query1)
{
itm.InvBillNum = key;
adjlist.Add(itm);
}
}
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in ls)
{
@ -920,6 +1277,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
await _repository.DbContext.BulkInsertAsync(invlist);
//await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
if (salist.Count > 0)
{
await _repository.DbContext.BulkUpdateAsync(salist);
}
if (adjlist.Count > 0)
{
await _repository.DbContext.BulkUpdateAsync(adjlist);
}
//await _repository.DbContext.BulkInsertAsync(notDetialList);
_invls = invlist.Select(p => p.InvbillNum).ToList();
}
@ -942,7 +1307,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <param name="p_parentInvBillNum"></param>
/// <param name="businessType"></param>
/// <returns></returns>
public async Task<List<string>> FirstInvoice(List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
public async Task<List<string>> FirstInvoice<TDetail>(List<TDetail> p_list,List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
where TDetail:SA_CAN_BASE
{
List<string> _invls = new List<string>();
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) });
@ -998,14 +1364,29 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
var salist = new List<TDetail>();
var adjlist = new List<PUB_ADJ_DETAIL>();
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
//if(businessType==EnumBusinessType.JisBBAC)
//{
var invdetails = p_list.Where(p => ls.Contains(p.GroupNum)).ToList();
foreach (var detail in invdetails)
{
detail.InvbillNum = key;
salist.Add(detail);
}
if (!string.IsNullOrEmpty(p_parentInvBillNum))
{
var adjdetails = p_adjlist.Where(p => ls.Contains(p.GroupNum)).ToList();
foreach (var detail in adjdetails)
{
detail.InvBillNum = key;
adjdetails.Add(detail);
}
}
//}
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID })
.Select(itm => new
{
@ -1106,10 +1487,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
if(salist.Count>0)
{
await _repository.DbContext.BulkUpdateAsync(salist);
}
if (adjlist.Count > 0)
{
await _repository.DbContext.BulkUpdateAsync(adjlist);
}
if (notDetialList.Count > 0)
{
await _repository.DbContext.BulkInsertAsync(notDetialList);
}
_invls = invlist.Select(p => p.InvbillNum).ToList();
}
@ -1124,7 +1516,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <param name="p_version"></param>
/// <returns></returns>
/// <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<TDetail>(List<TDetail> p_list,List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, string p_OldInvBillNum, int p_version)
where TDetail:SA_CAN_BASE
{
if (!string.IsNullOrEmpty(p_OldInvBillNum))
{
@ -1143,11 +1536,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
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);
invlist = await MakeInvoice(p_list,p_adjlist, 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);//重开可以变多张发票
invlist = await FirstInvoice(p_list,p_adjlist,dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);//重开可以变多张发票
}
if (invlist.Count == 0)
@ -1155,12 +1548,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
return false;
}
foreach (var adj in p_adjlist)
{
adj.InvBillNum = string.Join(",", invlist);//调整单更新发票信息
}
//foreach (var adj in p_adjlist)
//{
// adj.InvBillNum = string.Join(",", invlist);//调整单更新发票信息
//}
_repository.DbContext.BulkUpdate(p_adjlist);
//_repository.DbContext.BulkUpdate(p_adjlist);
_repository.DbContext.BulkUpdate(new List<INVOICE_GRP> { inv });
return true;
@ -1175,7 +1568,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <param name="p_version"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public async Task<bool> ReissueSecInvoice(List<TEMP_CAN_SA_DETAIL> dtos, List<PUB_ADJ_DETAIL> p_adjlist, string p_OldInvBillNum, int p_version)
public async Task<bool> ReissueSecInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, string p_OldInvBillNum, int p_version)
where TDetail : SA_CAN_BASE
{
if (!string.IsNullOrEmpty(p_OldInvBillNum))
{
@ -1194,14 +1588,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
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);
invlist = await MakeInvoice(p_list,p_adjlist, dtos, p_version, inv.InvGroupNum, string.Empty, inv.BusinessType, false);
}
else
{
invlist = await SecInvoice(dtos, p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);
invlist = await SecInvoice(p_list,p_adjlist,dtos,p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);
}
if (invlist.Count == 0)
{
return false;
@ -1209,11 +1601,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
_repository.DbContext.BulkUpdate(new List<INVOICE_GRP> { inv });
foreach (var adj in p_adjlist)
{
adj.InvBillNum = string.Join(",", invlist);
}
_repository.DbContext.BulkUpdate(p_adjlist);
//foreach (var adj in p_adjlist)
//{
// adj.InvBillNum = string.Join(",", invlist);
//}
//_repository.DbContext.BulkUpdate(p_adjlist);
return true;
}
return false;

5
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PD_MNG.cs

@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;
@ -52,4 +53,8 @@ public class PD_MNG<TEntity,TEntityDetail>:DomainService
}

9
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs

@ -256,6 +256,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <summary>
/// 通过发票号获取结算数据
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<List<PUB_CAN_SA_DETAIL>> GetDetailByInbillNumAsync(List<string> p_invs)
{
return await _detailRepository.Where(p => p_invs.Contains(p.BillNum)).ToListAsync();
}
}

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

@ -70,8 +70,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: billNumber
invGroupNum: billNumber,
invbillnum: string.Empty
);
_entityList.Add(_detailEntity);

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

@ -118,8 +118,12 @@ public class PUB_CAN_SA_DETAIL : SA_CAN_BASE
//[Display(Name = "结算分组")]
//public string GroupNum { get; set; } = null!;
public PUB_CAN_SA_DETAIL(Guid guid, string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, string invGroupNum, DateTime settleDate, EnumBusinessType businessType, string groupNum)
public PUB_CAN_SA_DETAIL(Guid guid, string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, string invGroupNum, DateTime settleDate, EnumBusinessType businessType,
string groupNum,
string invbillnum
)
{
InvbillNum=invbillnum;
Id = guid;
KeyCode = keyCode;
Version = version;

1
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/JobItem.cs

@ -23,6 +23,7 @@ public class JobItem : Entity<Guid>
public string Service { get; set; }
public bool IsRunning { get; set; }
public DateTime? HeartBeat { get; set; }
[Timestamp]
public string ConcurrencyStamp { get; set; }

54
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs

@ -107,6 +107,9 @@ namespace Win.Sfs.SettleAccount
builder.ConfigurePUB_ADJ_DETAIL(options);
builder.ConfigureBBAC_ADJ_DETAIL(options);
builder.ConfigureHBPO_ADJ_DETAIL(options);
builder.ConfigureBBAC_PD(options);
builder.ConfigureHBPO_PD(options);
builder.ConfigurePUB_PD(options);
//大众发票导入
//builder.ConfigureInvoice(options);
//builder.ConfigureInvoiceVersion(options);
@ -1209,6 +1212,57 @@ namespace Win.Sfs.SettleAccount
b.Property(x => x.ConcurrencyStamp).HasMaxLength(50);
});
}
private static void ConfigureBBAC_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<BBAC_PD>(b =>
{
b.ToTable($"{options.TablePrefix}_BBAC_PD", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.BillNum).HasMaxLength(50);
b.Property(x => x.SettleBillNum).HasMaxLength(50);
b.Property(x => x.InvGroupNum).HasMaxLength(50);
b.Property(x => x.Site).HasMaxLength(50);
b.Property(x => x.ConcurrencyStamp).HasMaxLength(50);
});
}
private static void ConfigureHBPO_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<HBPO_PD>(b =>
{
b.ToTable($"{options.TablePrefix}_HBPO_PD", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.BillNum).HasMaxLength(50);
b.Property(x => x.SettleBillNum).HasMaxLength(50);
b.Property(x => x.InvGroupNum).HasMaxLength(50);
b.Property(x => x.Site).HasMaxLength(50);
b.Property(x => x.ConcurrencyStamp).HasMaxLength(50);
});
}
private static void ConfigurePUB_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<PUB_PD>(b =>
{
b.ToTable($"{options.TablePrefix}_PUB_PD", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.BillNum).HasMaxLength(50);
b.Property(x => x.SettleBillNum).HasMaxLength(50);
b.Property(x => x.InvGroupNum).HasMaxLength(50);
b.Property(x => x.Site).HasMaxLength(50);
b.Property(x => x.ConcurrencyStamp).HasMaxLength(50);
});
}
private static void ConfigureBBAC_ADJ_DETAIL(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{

5051
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230807063408_vmi10.Designer.cs

File diff suppressed because it is too large

38
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230807063408_vmi10.cs

@ -0,0 +1,38 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class vmi10 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "HeartBeat",
table: "Set_JobItem",
type: "datetime2",
nullable: true);
migrationBuilder.UpdateData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("ea936b34-ecd0-7dbd-85a9-57cd8b730873"),
column: "ConcurrencyStamp",
value: "2cc9803a5a8e420b80134104653ecde0");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "HeartBeat",
table: "Set_JobItem");
migrationBuilder.UpdateData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("ea936b34-ecd0-7dbd-85a9-57cd8b730873"),
column: "ConcurrencyStamp",
value: "887ca64c266c48ac82dca90534f64225");
}
}
}

5057
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230807064336_202308070001.Designer.cs

File diff suppressed because it is too large

58
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230807064336_202308070001.cs

@ -0,0 +1,58 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202308070001 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "InvbillNum",
table: "Set_PUB_CAN_SA_DETAIL",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "InvbillNum",
table: "Set_HBPO_CAN_SA_DETAIL",
type: "nvarchar(50)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "InvbillNum",
table: "Set_BBAC_CAN_SA_DETAIL",
type: "nvarchar(50)",
nullable: true);
migrationBuilder.UpdateData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("ea936b34-ecd0-7dbd-85a9-57cd8b730873"),
column: "ConcurrencyStamp",
value: "2e626de3941048399abf1f76c051f8a4");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "InvbillNum",
table: "Set_PUB_CAN_SA_DETAIL");
migrationBuilder.DropColumn(
name: "InvbillNum",
table: "Set_HBPO_CAN_SA_DETAIL");
migrationBuilder.DropColumn(
name: "InvbillNum",
table: "Set_BBAC_CAN_SA_DETAIL");
migrationBuilder.UpdateData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("ea936b34-ecd0-7dbd-85a9-57cd8b730873"),
column: "ConcurrencyStamp",
value: "887ca64c266c48ac82dca90534f64225");
}
}
}

5279
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230808023302_202308080001.Designer.cs

File diff suppressed because it is too large

106
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230808023302_202308080001.cs

@ -0,0 +1,106 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202308080001 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Set_BBAC_PD",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
Version = table.Column<int>(type: "int", nullable: false),
BillNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
SettleBillNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
State = table.Column<int>(type: "int", nullable: false),
InvGroupNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
Site = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Set_BBAC_PD", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Set_HBPO_PD",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
Version = table.Column<int>(type: "int", nullable: false),
BillNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
SettleBillNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
State = table.Column<int>(type: "int", nullable: false),
InvGroupNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
Site = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Set_HBPO_PD", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Set_PUB_PD",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
Version = table.Column<int>(type: "int", nullable: false),
BillNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
SettleBillNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
State = table.Column<int>(type: "int", nullable: false),
InvGroupNum = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
Site = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Set_PUB_PD", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Set_BBAC_PD");
migrationBuilder.DropTable(
name: "Set_HBPO_PD");
migrationBuilder.DropTable(
name: "Set_PUB_PD");
}
}
}

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

@ -125,6 +125,9 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("InvbillNum")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsReturn")
.HasMaxLength(50)
.HasColumnType("bit");
@ -261,6 +264,79 @@ namespace Win.Sfs.SettleAccount.Migrations
b.ToTable("Set_BBAC_NOT_SA_DETAIL");
});
modelBuilder.Entity("SettleAccount.Domain.BQ.BBAC_PD", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("BillNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnType("uniqueidentifier")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<string>("InvGroupNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("SettleBillNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Site")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<int>("State")
.HasColumnType("int");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Set_BBAC_PD");
});
modelBuilder.Entity("SettleAccount.Domain.BQ.BBAC_PD_DETAIL", b =>
{
b.Property<Guid>("Id")
@ -1180,6 +1256,9 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("InvbillNum")
.HasColumnType("nvarchar(max)");
b.Property<string>("KeyCode")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
@ -1305,6 +1384,79 @@ namespace Win.Sfs.SettleAccount.Migrations
b.ToTable("Set_HBPO_NOT_SA_DETAIL");
});
modelBuilder.Entity("SettleAccount.Domain.BQ.HBPO_PD", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("BillNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnType("uniqueidentifier")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<string>("InvGroupNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("SettleBillNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Site")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<int>("State")
.HasColumnType("int");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Set_HBPO_PD");
});
modelBuilder.Entity("SettleAccount.Domain.BQ.HBPO_PD_DETAIL", b =>
{
b.Property<Guid>("Id")
@ -2701,6 +2853,9 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("InvbillNum")
.HasColumnType("nvarchar(max)");
b.Property<string>("KeyCode")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
@ -2839,6 +2994,79 @@ namespace Win.Sfs.SettleAccount.Migrations
b.ToTable("Set_PUB_NOT_SA_DETAIL");
});
modelBuilder.Entity("SettleAccount.Domain.BQ.PUB_PD", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("BillNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnType("uniqueidentifier")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<string>("InvGroupNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("SettleBillNum")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Site")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<int>("State")
.HasColumnType("int");
b.Property<int>("Version")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Set_PUB_PD");
});
modelBuilder.Entity("SettleAccount.Domain.BQ.PUB_PD_DETAIL", b =>
{
b.Property<Guid>("Id")
@ -3886,6 +4114,9 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<DateTime?>("HeartBeat")
.HasColumnType("datetime2");
b.Property<bool>("IsDisabled")
.HasColumnType("bit");
@ -4040,7 +4271,7 @@ namespace Win.Sfs.SettleAccount.Migrations
Id = new Guid("ea936b34-ecd0-7dbd-85a9-57cd8b730873"),
BillTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
BillType = 1,
ConcurrencyStamp = "887ca64c266c48ac82dca90534f64225",
ConcurrencyStamp = "f0b58114c8bf4491b657f275bd0631b0",
DeliverTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
ErpToLoc = "ErpToLoc",
OrderNum = "OrderNum",

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

@ -2,6 +2,7 @@ using Dapper;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.EntityFrameworkCore;
using NPOI.HPSF;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
@ -9,17 +10,20 @@ using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Security.Policy;
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 Volo.Abp.Uow;
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;
using static System.Runtime.CompilerServices.RuntimeHelpers;
namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
{
@ -33,12 +37,16 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
: base(dbContextProvider)
{
}
[UnitOfWork(false)]
/// <summary>
/// BBAC生成待扣减
/// </summary>
/// <param name="p_invGroup"></param>
/// <returns></returns>
public Dictionary<BBAC_PD, List<BBAC_PD_DETAIL>> GenerationPendingDeductionBBAC(string p_invGroup)
public virtual Dictionary<BBAC_PD, List<BBAC_PD_DETAIL>> GenerationPendingDeductionBBAC(string p_invGroup)
{
var sqljis = "WITH t1 AS(\n" +
"SELECT\n" +
@ -90,16 +98,50 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
"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();
string str = $"select" +
" [Id] " +
",[SettleBillNum] " +
",[Site] " +
",[IsReturn] " +
",[Version] " +
",[Price] " +
",[BillNum] " +
",[SettleDate] " +
",[InvGroupNum] " +
",[LU] " +
",[PN] " +
",[KeyCode] " +
",[Qty] " +
",[GroupNum] " +
",[BusinessType] " +
",[ContractDocID] " +
$"from set_BBAC_CAN_SA_DETAIL where billNum='{p_invGroup}'";
var detail = DbConnection.Query<BBAC_CAN_SA_DETAIL>(str, null, null, true, 1200, null).ToList();
var str1 = $"select " +
" [Id] " +
" ,[Version] " +
" ,[BillNum] " +
" ,[SettleBillNum] " +
" ,[State] " +
" ,[InvGroupNum] " +
" ,[Site] " +
" ,[BusinessType] " +
$" from set_BBAC_CAN_SA where billNum='{p_invGroup}'";
var main = DbConnection.Query<BBAC_CAN_SA>(str1, null, null, true, 1200, null).FirstOrDefault();
var entity = main;
if (entity == null)
if (entity != null)
{
var templist = DbConnection.Query<TEMP_PD_SW>(string.Format(sqljis, p_invGroup));
var templist = DbConnection.Query<TEMP_PD_SW>(string.Format(sqljis, p_invGroup));//获取当前二次比对结果
var entityDetail = detail;
var bbac = new BBAC_PD(
@ -118,11 +160,11 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
from tm1 in temp1.DefaultIfEmpty()
select new BBAC_PD_DETAIL(
guid: itm.Id,
keyCode: string.IsNullOrEmpty(tm1.KeyCode) ? tm1.KeyCode : itm.KeyCode,
keyCode: tm1 != null ? tm1.KeyCode : itm.KeyCode,
version: itm.Version,
billNum: itm.BillNum,
lU: itm.LU,
rELU: string.IsNullOrEmpty(tm1.RepLU) ? tm1.RepLU : itm.LU,
rELU: tm1 != null ? tm1.RepLU : itm.LU,
pN: itm.PN,
rEPN: itm.PN,
site: itm.Site,
@ -228,11 +270,11 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
from tm1 in temp1.DefaultIfEmpty()
select new HBPO_PD_DETAIL(
guid: itm.Id,
keyCode: string.IsNullOrEmpty(tm1.KeyCode) ? tm1.KeyCode : itm.KeyCode,
keyCode: tm1!=null ? tm1.KeyCode : itm.KeyCode,
version: itm.Version,
billNum: itm.BillNum,
lU: itm.LU,
rELU: string.IsNullOrEmpty(tm1.RepLU) ? tm1.RepLU : itm.LU,
rELU: tm1!=null ? tm1.RepLU : itm.LU,
pN: itm.PN,
rEPN: itm.PN,
site: itm.Site,
@ -314,7 +356,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
"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();
var inv = GetInvoiceList(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();
@ -339,11 +381,11 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
from tm1 in temp1.DefaultIfEmpty()
select new PUB_PD_DETAIL(
guid: itm.Id,
keyCode: string.IsNullOrEmpty(tm1.KeyCode) ? tm1.KeyCode : itm.KeyCode,
keyCode: tm1!=null ? tm1.KeyCode : itm.KeyCode,
version: itm.Version,
billNum: itm.BillNum,
lU: itm.LU,
rELU: string.IsNullOrEmpty(tm1.RepLU) ? tm1.RepLU : itm.LU,
rELU: tm1==null ? tm1.RepLU : itm.LU,
pN: itm.PN,
rEPN: itm.PN,
site: itm.Site,
@ -365,6 +407,41 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
/// <summary>
/// 发票分组下所有发票
/// </summary>
/// <param name="inv_group"></param>
/// <returns></returns>
public virtual List<INVOICE_GRP> GetInvoiceList(string inv_group)
{
return DbConnection.Query<INVOICE_GRP>(string.Format("select " +
" [Id] " +
",[RealnvBillNum] " +
",[InvbillNum] " +
",[Amt] " +
",[TaxAmt] " +
",[InvGroupNum] " +
",[FileName] " +
",[BusinessType] " +
",[State] " +
",[InvoiceState] " +
",[ParentInvbillNum] " +
",[Tax] " +
"from set_INVOICE_GRP where InvGroupNum='{0}'",inv_group)).ToList();
}
/// <summary>
/// 发票
/// </summary>
/// <param name="inv_bill"></param>
/// <returns></returns>
public virtual INVOICE_GRP GetInvoice(string inv_bill)
{
return DbConnection.QueryFirst<INVOICE_GRP>(string.Format("select * from set_INVOICE_GRP where InvbillNum='{0}'",inv_bill));
}
}
}

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

@ -9,6 +9,7 @@ using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.Extensions.DependencyInjection;
using NPOI.OpenXmlFormats.Spreadsheet;
using SettleAccount.Domain.BQ;
using TaskJob.EventArgs;
@ -16,11 +17,13 @@ using TaskJob.Interfaces;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow;
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;
@ -29,17 +32,23 @@ namespace SettleAccount.Job.Services
public class PD_SERVICE : ITransientDependency, IExportJob
{
private readonly PendingDeductionDapperRepository _dapper;
private readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _invRepository;
//private readonly BBAC_PD_MNG _pdmng;
public PD_SERVICE(PendingDeductionDapperRepository dapper,
INormalEfCoreRepository<INVOICE_GRP, Guid> invRepository
IServiceProvider _serviceProvider;
public PD_SERVICE(
PendingDeductionDapperRepository dapper,
//BBAC_PD_MNG pdmng,
IServiceProvider serviceProvider
)
{
_serviceProvider = serviceProvider;
_dapper = dapper;
_invRepository = invRepository;
//_pdmng=pdmng;
}
[UnitOfWork(false)]
/// <summary>
/// 执行发票待开任务
/// </summary>
@ -49,8 +58,8 @@ namespace SettleAccount.Job.Services
/// <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();
var invgroup = customConditions.Where(p => p.Name == "InvGroupNum").FirstOrDefault().Value;//获取发票分
var ls = _dapper.GetInvoiceList(invgroup);
if (ls != null && ls.Count>0)
{
var first=ls.FirstOrDefault();
@ -63,8 +72,8 @@ namespace SettleAccount.Job.Services
{
var main = c.Key;
var detail = c.Value;
_invRepository.DbContext.BulkInsert(new List<HBPO_PD>() { main });
_invRepository.DbContext.BulkInsert(detail);
//_invRepository.GetDbContext().BulkInsert(new List<HBPO_PD>() { main });
//_invRepository.GetDbContext().BulkInsert(detail);
}
}
else
@ -81,14 +90,16 @@ namespace SettleAccount.Job.Services
{
var main = c.Key;
var detail = c.Value;
_invRepository.DbContext.BulkInsert(new List<BBAC_PD>() { main });
_invRepository.DbContext.BulkInsert(detail);
//_pdmng.InsertDetail(detail);
//_pdmng.InsertMain(main);
}
}
else
{
}
}
else
{
@ -99,8 +110,8 @@ namespace SettleAccount.Job.Services
{
var main = c.Key;
var detail = c.Value;
_invRepository.DbContext.BulkInsert(new List<PUB_PD>() { main });
_invRepository.DbContext.BulkInsert(detail);
//_invRepository.DbContext.BulkInsert(new List<PUB_PD>() { main });
//_invRepository.DbContext.BulkInsert(detail);
}
}
else

6
code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

@ -97,6 +97,12 @@ namespace Win.Sfs.SettleAccount
{
return implementationFactory.GetService<HBPOEdiSeCompareExportService>();
}
if (key.Equals(typeof(PD_SERVICE).FullName))
{
return implementationFactory.GetService<PD_SERVICE>();
}
if (key.Equals(typeof(InvoiceSettledDiffExportService).FullName))

Loading…
Cancel
Save