|
@ -3,10 +3,14 @@ using System.Collections; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
using DocumentFormat.OpenXml.Bibliography; |
|
|
using LinqToDB; |
|
|
using LinqToDB; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
|
|
using Org.BouncyCastle.Asn1.Ocsp; |
|
|
using SettleAccount.Domain.BQ; |
|
|
using SettleAccount.Domain.BQ; |
|
|
|
|
|
using SettleAccount.Job.Services; |
|
|
|
|
|
using TaskJob.EventArgs; |
|
|
using Volo.Abp.Uow; |
|
|
using Volo.Abp.Uow; |
|
|
using Win.Abp.Snowflakes; |
|
|
using Win.Abp.Snowflakes; |
|
|
using Win.Sfs.BaseData.ImportExcelCommon; |
|
|
using Win.Sfs.BaseData.ImportExcelCommon; |
|
@ -16,8 +20,10 @@ using Win.Sfs.SettleAccount.CommonManagers; |
|
|
using Win.Sfs.SettleAccount.Constant; |
|
|
using Win.Sfs.SettleAccount.Constant; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Managers; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Managers; |
|
|
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Syncs; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Temp; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Temp; |
|
|
using Win.Sfs.SettleAccount.Entities.Prices; |
|
|
using Win.Sfs.SettleAccount.Entities.Prices; |
|
|
|
|
|
using Win.Sfs.SettleAccount.Entities.TaskJobs; |
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
|
|
|
|
|
|
namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
namespace Win.Sfs.SettleAccount.Entities.BQ |
|
@ -43,6 +49,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
|
|
|
|
|
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository; |
|
|
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly TaskJobService _service; |
|
|
|
|
|
|
|
|
private readonly BBAC_CAN_SA_MNG _bbacMng; |
|
|
private readonly BBAC_CAN_SA_MNG _bbacMng; |
|
|
|
|
|
|
|
|
public BBAC_CAN_SA_SERVICE(IExcelImportAppService excelImportService, |
|
|
public BBAC_CAN_SA_SERVICE(IExcelImportAppService excelImportService, |
|
@ -54,10 +63,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository, |
|
|
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository, |
|
|
INormalEfCoreRepository<PriceList, Guid> priceRepository, |
|
|
INormalEfCoreRepository<PriceList, Guid> priceRepository, |
|
|
BBAC_CAN_SA_MNG bbacMng, |
|
|
BBAC_CAN_SA_MNG bbacMng, |
|
|
BaseDomainService baseservice |
|
|
BaseDomainService baseservice, |
|
|
|
|
|
TaskJobService service |
|
|
) |
|
|
) |
|
|
: base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng, baseservice) |
|
|
: base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng, baseservice) |
|
|
{ |
|
|
{ |
|
|
|
|
|
_service = service; |
|
|
_notRepository = notRepository; |
|
|
_notRepository = notRepository; |
|
|
_bbacMng = bbacMng; |
|
|
_bbacMng = bbacMng; |
|
|
_priceRepository = priceRepository; |
|
|
_priceRepository = priceRepository; |
|
@ -89,67 +100,80 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
{ |
|
|
{ |
|
|
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) }); |
|
|
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) }); |
|
|
} |
|
|
} |
|
|
if (await _bbacMng.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() }); |
|
|
|
|
|
|
|
|
|
|
|
//main.State = SettleBillState.发票生成中;
|
|
|
|
|
|
await _bbacMng.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(); |
|
|
}).ConfigureAwait(false); |
|
|
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 |
|
|
//if (await _bbacMng.SetForwardState(main, SettleBillState.已开票).ConfigureAwait(false))
|
|
|
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == main.Site |
|
|
//{
|
|
|
select new TEMP_CAN_SA_DETAIL |
|
|
// var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
|
|
|
{ |
|
|
// var notQuery = await _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToListAsync().ConfigureAwait(false);
|
|
|
SettleBillNum = d.SettleBillNum, |
|
|
// var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
|
|
|
Site = d.Site, |
|
|
// var q = from d in dto1s
|
|
|
Version = d.Version, |
|
|
// join p in priceList on d.LU equals p.LU
|
|
|
Price = p.Price, |
|
|
// where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == main.Site
|
|
|
BillNum = d.BillNum, |
|
|
// select new TEMP_CAN_SA_DETAIL
|
|
|
SettleDate = d.SettleDate, |
|
|
// {
|
|
|
InvGroupNum = d.InvGroupNum, |
|
|
// SettleBillNum = d.SettleBillNum,
|
|
|
LU = d.LU, |
|
|
// Site = d.Site,
|
|
|
MaterialDesc = d.MaterialDesc, |
|
|
// Version = d.Version,
|
|
|
PN = d.PN, |
|
|
// Price = p.Price,
|
|
|
Qty = d.Qty, |
|
|
// BillNum = d.BillNum,
|
|
|
GroupNum = d.GroupNum, |
|
|
// SettleDate = d.SettleDate,
|
|
|
Amt = Math.Round(d.Qty * p.Price, 2), |
|
|
// InvGroupNum = d.InvGroupNum,
|
|
|
ContractDocID = d.ContractDocID, |
|
|
// LU = d.LU,
|
|
|
BeginDate = p.BeginTime, |
|
|
// MaterialDesc = d.MaterialDesc,
|
|
|
EndDate = p.EndTime, |
|
|
// PN = d.PN,
|
|
|
PartCode = d.PartCode |
|
|
// Qty = d.Qty,
|
|
|
}; |
|
|
// GroupNum = d.GroupNum,
|
|
|
var dtos = q.ToList(); |
|
|
// Amt = Math.Round(d.Qty * p.Price, 2),
|
|
|
|
|
|
// ContractDocID = d.ContractDocID,
|
|
|
if (dtos != null && dtos.Count > 0) |
|
|
// BeginDate = p.BeginTime,
|
|
|
{ |
|
|
// EndDate = p.EndTime,
|
|
|
if (invbillNum.Substring(0, 1) == "C")//一次开票
|
|
|
// PartCode = d.PartCode
|
|
|
{ |
|
|
// };
|
|
|
var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL |
|
|
// var dtos = q.ToList();
|
|
|
{ |
|
|
|
|
|
KeyCode = p.KeyCode, |
|
|
// if (dtos != null && dtos.Count > 0)
|
|
|
Version = p.Version, |
|
|
// {
|
|
|
SettleBillNum = p.SettleBillNum, |
|
|
// if (invbillNum.Substring(0, 1) == "C")//一次开票
|
|
|
LU = p.LU, |
|
|
// {
|
|
|
PN = p.PN, |
|
|
// var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL
|
|
|
Site = p.Site, |
|
|
// {
|
|
|
Qty = p.Qty, |
|
|
// KeyCode = p.KeyCode,
|
|
|
Price = p.Price, |
|
|
// Version = p.Version,
|
|
|
BusinessType = p.BusinessType, |
|
|
// SettleBillNum = p.SettleBillNum,
|
|
|
IsReturn = "", |
|
|
// LU = p.LU,
|
|
|
InvGroupNum = p.InvGroupNum, |
|
|
// PN = p.PN,
|
|
|
SettleDate = p.SettleDate, |
|
|
// Site = p.Site,
|
|
|
GroupNum = p.GroupNum, |
|
|
// Qty = p.Qty,
|
|
|
ContractDocID = string.Empty, |
|
|
// Price = p.Price,
|
|
|
PartCode = p.PartCode |
|
|
// BusinessType = p.BusinessType,
|
|
|
|
|
|
// IsReturn = "",
|
|
|
}).ToList();//不能结算
|
|
|
// InvGroupNum = p.InvGroupNum,
|
|
|
await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false); |
|
|
// SettleDate = p.SettleDate,
|
|
|
} |
|
|
// GroupNum = p.GroupNum,
|
|
|
else//二次开票
|
|
|
// ContractDocID = string.Empty,
|
|
|
{ |
|
|
// PartCode = p.PartCode
|
|
|
await SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
// }).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 |
|
|
else |
|
|
{ |
|
|
{ |
|
|