Browse Source

[CI SKIP]

master
学 赵 1 year ago
parent
commit
f7f6ae1da7
  1. 140
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  2. 139
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  3. 93
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs
  4. 17
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs

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

@ -101,85 +101,83 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) });
}
//List<CustomCondition> customConditionList = new List<CustomCondition>();
//customConditionList.Add(new CustomCondition() { Name = "BillNum", Value = invbillNum });
//customConditionList.Add(new CustomCondition() { Name = "BussinessType", Value = main.BusinessType.ToString() });
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "BillNum", Value = invbillNum });
customConditionList.Add(new CustomCondition() { Name = "BussinessType", Value = main.BusinessType.ToString() });
await _bbacMng.SetWaitingState(invbillNum);
var _taskid = await _service.ExportEnqueueAsync("生成发票任务", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(GenerateJisInvoiceService), customConditionList, (rs) =>
{
}).ConfigureAwait(false);
return new JsonResult(new { Code = 200, Message = "生成发票任务" });
//await _bbacMng.SetWaitingState(invbillNum);
//var _taskid = await _service.ExportEnqueueAsync("生成发票任务", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(GenerateJisInvoiceService), customConditionList, (rs) =>
//if (await _bbacMng.SetForwardState(main, SettleBillState.已开票).ConfigureAwait(false))
//{
//}).ConfigureAwait(false);
if (await _bbacMng.SetForwardState(main, SettleBillState.).ConfigureAwait(false))
{
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
var notQuery = await _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToListAsync().ConfigureAwait(false);
var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s
join p in priceList on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == main.Site
select new TEMP_CAN_SA_DETAIL
{
SettleBillNum = d.SettleBillNum,
Site = d.Site,
Version = d.Version,
Price = p.Price,
BillNum = d.BillNum,
SettleDate = d.SettleDate,
InvGroupNum = d.InvGroupNum,
LU = d.LU,
MaterialDesc = d.MaterialDesc,
PN = d.PN,
Qty = d.Qty,
GroupNum = d.GroupNum,
Amt = Math.Round(d.Qty * p.Price, 2),
ContractDocID = d.ContractDocID,
BeginDate = p.BeginTime,
EndDate = p.EndTime,
PartCode = d.PartCode
};
var dtos = q.ToList();
if (dtos != null && dtos.Count > 0)
{
if (invbillNum.Substring(0, 1) == "C")//一次开票
{
var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL
{
KeyCode = p.KeyCode,
Version = p.Version,
SettleBillNum = p.SettleBillNum,
LU = p.LU,
PN = p.PN,
Site = p.Site,
Qty = p.Qty,
Price = p.Price,
BusinessType = p.BusinessType,
IsReturn = "",
InvGroupNum = p.InvGroupNum,
SettleDate = p.SettleDate,
GroupNum = p.GroupNum,
ContractDocID = string.Empty,
PartCode = p.PartCode
}).ToList();//不能结算
await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
}
else//二次开票
{
await SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
}
}
}
// var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
// var notQuery = await _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToListAsync().ConfigureAwait(false);
// var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
// var q = from d in dto1s
// join p in priceList on d.LU equals p.LU
// where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == main.Site
// select new TEMP_CAN_SA_DETAIL
// {
// SettleBillNum = d.SettleBillNum,
// Site = d.Site,
// Version = d.Version,
// Price = p.Price,
// BillNum = d.BillNum,
// SettleDate = d.SettleDate,
// InvGroupNum = d.InvGroupNum,
// LU = d.LU,
// MaterialDesc = d.MaterialDesc,
// PN = d.PN,
// Qty = d.Qty,
// GroupNum = d.GroupNum,
// Amt = Math.Round(d.Qty * p.Price, 2),
// ContractDocID = d.ContractDocID,
// BeginDate = p.BeginTime,
// EndDate = p.EndTime,
// PartCode = d.PartCode
// };
// var dtos = q.ToList();
// if (dtos != null && dtos.Count > 0)
// {
// if (invbillNum.Substring(0, 1) == "C")//一次开票
// {
// var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL
// {
// KeyCode = p.KeyCode,
// Version = p.Version,
// SettleBillNum = p.SettleBillNum,
// LU = p.LU,
// PN = p.PN,
// Site = p.Site,
// Qty = p.Qty,
// Price = p.Price,
// BusinessType = p.BusinessType,
// IsReturn = "",
// InvGroupNum = p.InvGroupNum,
// SettleDate = p.SettleDate,
// GroupNum = p.GroupNum,
// ContractDocID = string.Empty,
// PartCode = p.PartCode
// }).ToList();//不能结算
// await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
// }
// else//二次开票
// {
// await SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
// }
// }
//}
}
else
{
return new JsonResult(new { Code = 400, Message = "不存在可结算单记录" });
}
return new JsonResult(new { Code = 200, Message = "生成成功" });
}
}
}

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

@ -5,6 +5,8 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using SettleAccount.Job.Services;
using TaskJob.EventArgs;
using Volo.Abp.Uow;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
@ -14,8 +16,10 @@ using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Syncs;
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
@ -40,6 +44,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
private readonly INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> _notRepository;
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly HBPO_CAN_SA_MNG _hbpoMng;
private readonly TaskJobService _service;
public HBPO_CAN_SA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
@ -50,13 +57,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> notRepository,
INormalEfCoreRepository<PriceList, Guid> priceRepository,
HBPO_CAN_SA_MNG hbpoMng,
BaseDomainService baseservice
BaseDomainService baseservice,
TaskJobService service
) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng, baseservice)
{
_priceRepository = priceRepository;
_notRepository = notRepository;
_hbpoMng = hbpoMng;
_service = service;
}
/// <summary>
/// 生成发票
@ -83,68 +92,80 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) });
}
if (await _hbpoMng.SetForwardState(main, SettleBillState.).ConfigureAwait(false))
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "BillNum", Value = invbillnum });
customConditionList.Add(new CustomCondition() { Name = "BussinessType", Value = main.BusinessType.ToString() });
await _hbpoMng.SetWaitingState(invbillnum);
var _taskid = await _service.ExportEnqueueAsync("生成发票任务", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(GenerateJisInvoiceService), customConditionList, (rs) =>
{
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
var notQuery = _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToList();
var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s
join p in priceList on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == main.Site
select new TEMP_CAN_SA_DETAIL
{
SettleBillNum = d.SettleBillNum,
Site = d.Site,
Version = d.Version,
Price = p.Price,
BillNum = d.BillNum,
SettleDate = d.SettleDate,
InvGroupNum = d.InvGroupNum,
LU = d.LU,
MaterialDesc = d.MaterialDesc,
PN = d.PN,
Qty = d.Qty,
GroupNum = d.GroupNum,
Amt = Math.Round(d.Qty * p.Price, 2),
ContractDocID = "no",
BeginDate = p.BeginTime,
EndDate = p.EndTime,
PartCode = d.PartCode
}).ConfigureAwait(false);
};
var dtos = q.ToList();
if (dtos != null && dtos.Count > 0)
{
if (invbillnum.Substring(0, 1) == "C")//一次开票
{
var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL
{
KeyCode = p.KeyCode,
Version = p.Version,
SettleBillNum = p.SettleBillNum,
LU = p.LU,
PN = p.PN,
Site = p.Site,
Qty = p.Qty,
Price = p.Price,
BusinessType = p.BusinessType,
IsReturn = "",
InvGroupNum = p.InvGroupNum,
SettleDate = p.SettleDate,
GroupNum = p.GroupNum,
ContractDocID = string.Empty,
PartCode = p.PartCode
return new JsonResult(new { Code = 200, Message = "生成发票任务" });
}).ToList();//不能结算
var falg = await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
}
else//二次开票
{
var flag = await SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
}
}
}
//if (await _hbpoMng.SetForwardState(main, SettleBillState.已开票).ConfigureAwait(false))
//{
// var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
// var notQuery = _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToList();
// var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
// var q = from d in dto1s
// join p in priceList on d.LU equals p.LU
// where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == main.Site
// select new TEMP_CAN_SA_DETAIL
// {
// SettleBillNum = d.SettleBillNum,
// Site = d.Site,
// Version = d.Version,
// Price = p.Price,
// BillNum = d.BillNum,
// SettleDate = d.SettleDate,
// InvGroupNum = d.InvGroupNum,
// LU = d.LU,
// MaterialDesc = d.MaterialDesc,
// PN = d.PN,
// Qty = d.Qty,
// GroupNum = d.GroupNum,
// Amt = Math.Round(d.Qty * p.Price, 2),
// ContractDocID = "no",
// BeginDate = p.BeginTime,
// EndDate = p.EndTime,
// PartCode = d.PartCode
// };
// var dtos = q.ToList();
// if (dtos != null && dtos.Count > 0)
// {
// if (invbillnum.Substring(0, 1) == "C")//一次开票
// {
// var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL
// {
// KeyCode = p.KeyCode,
// Version = p.Version,
// SettleBillNum = p.SettleBillNum,
// LU = p.LU,
// PN = p.PN,
// Site = p.Site,
// Qty = p.Qty,
// Price = p.Price,
// BusinessType = p.BusinessType,
// IsReturn = "",
// InvGroupNum = p.InvGroupNum,
// SettleDate = p.SettleDate,
// GroupNum = p.GroupNum,
// ContractDocID = string.Empty,
// PartCode = p.PartCode
// }).ToList();//不能结算
// var falg = await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
// }
// else//二次开票
// {
// var flag = await SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
// }
// }
//}
}
else
{

93
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs

@ -11,6 +11,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using ShardingCore.Sharding.MergeContexts;
using TaskJob.EventArgs;
using TaskJob.Interfaces;
using Volo.Abp.Application.Services;
@ -35,82 +36,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
public GenerateJisInvoiceService(SettleAccountDbContext dbcontext)
{
_dbcontext = dbcontext;
}
//public string Make(string billNum)
//{
// var main = _dbcontext.Set<T>().FirstOrDefault(p => p.InvGroupNum == billNum);
// //var main = await _bbacMng.GetMainAsync(invbillNum);
// if (main != null)
// {
// var entitys = _dbcontext.Set<BBAC_CAN_SA_DETAIL>().Where(p => p.InvGroupNum == billNum).ToList();//可结算
// var priceList = _dbcontext.Set<PriceList>().Where(p => p.IsCancel == false).ToList();//价格表
// var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
// var notQuery = _dbcontext.Set<BBAC_NOT_SA_DETAIL>().Where(p => p.SettleBillNum == main.SettleBillNum);
// var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
// var q = from d in dto1s
// join p in priceList on d.LU equals p.LU
// where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == main.Site
// select new TEMP_CAN_SA_DETAIL
// {
// SettleBillNum = d.SettleBillNum,
// Site = d.Site,
// Version = d.Version,
// Price = p.Price,
// BillNum = d.BillNum,
// SettleDate = d.SettleDate,
// InvGroupNum = d.InvGroupNum,
// LU = d.LU,
// MaterialDesc = d.MaterialDesc,
// PN = d.PN,
// Qty = d.Qty,
// GroupNum = d.GroupNum,
// Amt = Math.Round(d.Qty * p.Price, 2),
// ContractDocID = d.ContractDocID,
// BeginDate = p.BeginTime,
// EndDate = p.EndTime,
// PartCode = d.PartCode
// };
// var dtos = q.ToList();
// if (dtos != null && dtos.Count > 0)
// {
// if (billNum.Substring(0, 1) == "C")//一次开票
// {
// var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL
// {
// KeyCode = p.KeyCode,
// Version = p.Version,
// SettleBillNum = p.SettleBillNum,
// LU = p.LU,
// PN = p.PN,
// Site = p.Site,
// Qty = p.Qty,
// Price = p.Price,
// BusinessType = p.BusinessType,
// IsReturn = "",
// InvGroupNum = p.InvGroupNum,
// SettleDate = p.SettleDate,
// GroupNum = p.GroupNum,
// ContractDocID = string.Empty,
// PartCode = p.PartCode
// }).ToList();//不能结算
// FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
// }
// else//二次开票
// {
// SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
// }
// }
// }
//}
}
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property)
{
var billNum = property.Where(p => p.Name == "BillNum").FirstOrDefault().Value;
@ -506,8 +433,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
return _invls;
}
[UnitOfWork(false)]
public List<string> FirstInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
public 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>();
@ -795,18 +722,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
// 执行批量数据操作
if (salist.Count > 0)
{
_dbcontext.BulkUpdateAsync(salist).ConfigureAwait(false);
_dbcontext.BulkUpdate(salist);
}
_dbcontext.BulkInsertAsync(invlist).ConfigureAwait(false);
_dbcontext.BulkInsertAsync(groupList).ConfigureAwait(false);
_dbcontext.BulkInsertAsync(detailList).ConfigureAwait(false);
_dbcontext.BulkInsert(invlist);
_dbcontext.BulkInsert(groupList);
_dbcontext.BulkInsert(detailList);
if (adjlist.Count > 0)
{
_dbcontext.BulkInsertAsync(adjlist).ConfigureAwait(false);
_dbcontext.BulkInsert(adjlist);
}
if (notDetialList.Count > 0)
{
_dbcontext.BulkInsertAsync(notDetialList).ConfigureAwait(false);
_dbcontext.BulkInsert(notDetialList);
}
// 提交事务
// transaction.Commit();

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

@ -217,6 +217,22 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
return false;
;
}
public virtual async Task<bool> SetWaitingState(string billNum)
{
var entity = await GetMainAsync(billNum).ConfigureAwait(false);
if (entity != null)
{
entity.State = SettleBillState.;
await _repository.UpdateAsync(entity).ConfigureAwait(false);
return true;
}
return false;
;
}
/// <summary>
/// 获得所有明细
/// </summary>
@ -266,6 +282,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
return await _detailRepository.Where(p => p_invs.Contains(p.InvbillNum)).ToListAsync().ConfigureAwait(false);
}
}
}

Loading…
Cancel
Save