Browse Source

更新版本

master
zhaoxinyu 6 months ago
parent
commit
d74ccaed05
  1. 37
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  2. 38
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  3. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  4. 34
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  5. 43
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MakeCanSettlementService.cs
  6. 553
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs

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

@ -4,13 +4,16 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using DocumentFormat.OpenXml.Bibliography; using DocumentFormat.OpenXml.Bibliography;
using EFCore.BulkExtensions;
using LinqToDB; using LinqToDB;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Omu.ValueInjecter;
using Org.BouncyCastle.Asn1.Ocsp; using Org.BouncyCastle.Asn1.Ocsp;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using SettleAccount.Job.Services; using SettleAccount.Job.Services;
using TaskJob.EventArgs; using TaskJob.EventArgs;
using Volo.Abp;
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;
@ -125,7 +128,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
List<CustomCondition> customConditionList = new List<CustomCondition>(); List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "BillNum", Value = invbillNum }); customConditionList.Add(new CustomCondition() { Name = "BillNum", Value = invbillNum });
customConditionList.Add(new CustomCondition() { Name = "BussinessType", Value = main.BusinessType.ToString() }); customConditionList.Add(new CustomCondition() { Name = "BussinessType", Value = main.BusinessType.ToString() });
await _bbacMng.SetWaitingState(invbillNum); await _bbacMng.SetWaitingState(invbillNum).ConfigureAwait(false);
var _taskid = await _service.ExportEnqueueAsync("生成发票任务", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(GenerateJisInvoiceService), customConditionList, (rs) => var _taskid = await _service.ExportEnqueueAsync("生成发票任务", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(GenerateJisInvoiceService), customConditionList, (rs) =>
{ {
}).ConfigureAwait(false); }).ConfigureAwait(false);
@ -139,5 +142,37 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
} }
} }
[HttpPost]
[UnitOfWork(false)]
public virtual async Task<IActionResult> BackCanSettlement([FromBody] string selttleBilNum)
{
if (selttleBilNum.Substring(0, 1) == "N")
{
List<BBAC_NOT_SA_DETAIL> notList = new List<BBAC_NOT_SA_DETAIL>();
var entites = _repository.Where(p => p.BillNum == selttleBilNum).ToList();
var main = _repository.Where(p => p.BillNum == selttleBilNum).ToList();
foreach (var itm in entites)
{
var detail = new BBAC_NOT_SA_DETAIL();
detail.InjectFrom(itm);
notList.Add(detail);
}
var dbcontext = await _repository.GetDbContextAsync().ConfigureAwait(false);
await dbcontext.BulkDeleteAsync(main).ConfigureAwait(false);
await dbcontext.BulkDeleteAsync(entites).ConfigureAwait(false);
await dbcontext.BulkInsertAsync(notList).ConfigureAwait(false);
return new JsonResult(new { Code = 200, Message = "退回成功" });
}
else
{
throw new UserFriendlyException("单据不是从不可结算单生成", "400");
}
}
} }
} }

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

@ -2,11 +2,14 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Omu.ValueInjecter;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using SettleAccount.Job.Services; using SettleAccount.Job.Services;
using TaskJob.EventArgs; using TaskJob.EventArgs;
using Volo.Abp;
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;
@ -176,7 +179,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
} }
else else
{ {
await _hbpoMng.SetWaitingState(invbillnum); await _hbpoMng.SetWaitingState(invbillnum).ConfigureAwait(false);
var _taskid = await _service.ExportEnqueueAsync("生成发票任务", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(GenerateJisInvoiceService), customConditionList, (rs) => var _taskid = await _service.ExportEnqueueAsync("生成发票任务", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(GenerateJisInvoiceService), customConditionList, (rs) =>
{ {
}).ConfigureAwait(false); }).ConfigureAwait(false);
@ -189,5 +192,38 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
return new JsonResult(new { Code = 400, Message = "不存在可结算单记录" }); return new JsonResult(new { Code = 400, Message = "不存在可结算单记录" });
} }
} }
[HttpPost]
[UnitOfWork(false)]
public virtual async Task<IActionResult> BackCanSettlement([FromBody] string selttleBilNum)
{
if (selttleBilNum.Substring(0, 1) == "N")
{
List<HBPO_NOT_SA_DETAIL> notList = new List<HBPO_NOT_SA_DETAIL>();
var entites = _repository.Where(p => p.BillNum == selttleBilNum).ToList();
var main = _repository.Where(p => p.BillNum == selttleBilNum).ToList();
foreach (var itm in entites)
{
var detail = new HBPO_NOT_SA_DETAIL();
detail.InjectFrom(itm);
notList.Add(detail);
}
var dbcontext = await _repository.GetDbContextAsync().ConfigureAwait(false);
await dbcontext.BulkDeleteAsync(main).ConfigureAwait(false);
await dbcontext.BulkDeleteAsync(entites).ConfigureAwait(false);
await dbcontext.BulkInsertAsync(notList).ConfigureAwait(false);
return new JsonResult(new { Code = 200, Message = "退回成功" });
}
else
{
throw new UserFriendlyException("单据不是从不可结算单生成", "400");
}
}
} }
} }

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

@ -1098,7 +1098,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
sainv.InvoiceNetAmount = -sainv.InvoiceNetAmount; sainv.InvoiceNetAmount = -sainv.InvoiceNetAmount;
sainv.InvoiceTaxAmount = -sainv.InvoiceTaxAmount; sainv.InvoiceTaxAmount = -sainv.InvoiceTaxAmount;
} }
// 批量插入TEA_TASK_SUB记录 // 批量插入TEA_TASK_SUB记录
await _exChangeCenterDbContext.BulkInsertAsync(new List<TEA_TASK_SUB>() { teaTaskSub }).ConfigureAwait(false); await _exChangeCenterDbContext.BulkInsertAsync(new List<TEA_TASK_SUB>() { teaTaskSub }).ConfigureAwait(false);
// 批量插入TED_SAS_INVOICE记录 // 批量插入TED_SAS_INVOICE记录
@ -1215,9 +1214,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
sainv.InvoiceTaxAmount = -sainv.InvoiceTaxAmount; sainv.InvoiceTaxAmount = -sainv.InvoiceTaxAmount;
} }
await _exChangeCenterDbContext.BulkInsertAsync(new List<TEA_TASK_SUB>() { teaTaskSub }).ConfigureAwait(false); await _exChangeCenterDbContext.BulkInsertAsync(new List<TEA_TASK_SUB>() { teaTaskSub }).ConfigureAwait(false);
await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false); await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false);
invoice.State = SettleBillState.QAD; invoice.State = SettleBillState.QAD;
@ -1310,10 +1306,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
sainv.InvoiceNetAmount = -sainv.InvoiceNetAmount; sainv.InvoiceNetAmount = -sainv.InvoiceNetAmount;
sainv.InvoiceTaxAmount = -sainv.InvoiceTaxAmount; sainv.InvoiceTaxAmount = -sainv.InvoiceTaxAmount;
} }
await _exChangeCenterDbContext.BulkInsertAsync(new List<TEA_TASK_SUB>() { teaTaskSub }).ConfigureAwait(false); await _exChangeCenterDbContext.BulkInsertAsync(new List<TEA_TASK_SUB>() { teaTaskSub }).ConfigureAwait(false);
await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false); await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false);
invoice.State = SettleBillState.QAD; invoice.State = SettleBillState.QAD;
@ -1480,9 +1472,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
bj.DeliveryNumber = itm.GetProperty("DeliveryNumber", "");//交货号; bj.DeliveryNumber = itm.GetProperty("DeliveryNumber", "");//交货号;
bj.PN = itm.GetProperty("PN", "");// bj.PN = itm.GetProperty("PN", "");//
bj.PO = itm.GetProperty("PO", ""); bj.PO = itm.GetProperty("PO", "");
bj.PartDesc = itm.GetProperty("PartName", ""); bj.PartDesc = itm.GetProperty("PartName", "");
bj.ProductionGroup = itm.GetProperty("PartGroup", ""); bj.ProductionGroup = itm.GetProperty("PartGroup", "");
bj.SettleDate=DateTime.Parse(itm.GetProperty("SettleDate", "")); bj.SettleDate=DateTime.Parse(itm.GetProperty("SettleDate", ""));
bj.LineCode = itm.LineCode; bj.LineCode = itm.LineCode;

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

@ -3,9 +3,12 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.LinqAsync; using System.LinqAsync;
using System.Threading.Tasks; using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Omu.ValueInjecter;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using Volo.Abp;
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;
@ -246,5 +249,36 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
return new JsonResult(new { Code = 200, Message = "生成成功" }); return new JsonResult(new { Code = 200, Message = "生成成功" });
} }
[HttpPost]
[UnitOfWork(false)]
public virtual async Task<IActionResult> BackCanSettlement([FromBody] string selttleBilNum)
{
if (selttleBilNum.Substring(0, 1) == "N")
{
List<PUB_NOT_SA_DETAIL> notList = new List<PUB_NOT_SA_DETAIL>();
var entites = _repository.Where(p => p.BillNum == selttleBilNum).ToList();
var main = _repository.Where(p => p.BillNum == selttleBilNum).ToList();
foreach (var itm in entites)
{
var detail = new PUB_NOT_SA_DETAIL();
detail.InjectFrom(itm);
notList.Add(detail);
}
var dbcontext = await _repository.GetDbContextAsync().ConfigureAwait(false);
await dbcontext.BulkDeleteAsync(main).ConfigureAwait(false);
await dbcontext.BulkDeleteAsync(entites).ConfigureAwait(false);
await dbcontext.BulkInsertAsync(notList).ConfigureAwait(false);
return new JsonResult(new { Code = 200, Message = "退回成功" });
}
else
{
throw new UserFriendlyException("单据不是从不可结算单生成", "400");
}
}
} }
} }

43
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MakeCanSettlementService.cs

@ -141,6 +141,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
contactid: itm1.ContractDocID, contactid: itm1.ContractDocID,
invbillnum: string.Empty, invbillnum: string.Empty,
partcode: itm1.PartCode partcode: itm1.PartCode
); );
_detailEntity.RealPartCode = itm1.RealPartCode; _detailEntity.RealPartCode = itm1.RealPartCode;
billDetails.Add(_detailEntity); billDetails.Add(_detailEntity);
@ -715,6 +716,48 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
var part_group_small = t1.Where(p => p.Amt < 10000000).ToList(); var part_group_small = t1.Where(p => p.Amt < 10000000).ToList();
if (part_group_big.Count > 0) if (part_group_big.Count > 0)
{ {
var partlist = part_group_big.Select(p => p.LU).ToList();
var ls = hbpo_can_list.Where(p => partlist.Contains(p.LU)).ToList();
var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
var hbpo_sa = new HBPO_CAN_SA();
hbpo_sa.SetId(Guid.NewGuid());
hbpo_sa.BillNum = billNum;
hbpo_sa.InvGroupNum = billNum;
hbpo_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
hbpo_sa.State = SettleBillState.;
hbpo_sa.SettleBillNum = string.Empty;
hbpo_sa.Site = "104T";
hbpo_sa.BusinessType = EnumBusinessType.JisBBAC;
billList.Add(hbpo_sa);
foreach (var itm1 in ls)
{
var _detailEntity = new HBPO_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm1.KeyCode,
version: itm1.Version,
billNum: string.Empty,
settleBillNum: itm1.SettleBillNum,
lU: itm1.LU,
pN: itm1.PN,
site: itm1.Site,
qty: itm1.Qty,
price: itm1.Price,
businessType: itm1.BusinessType,
settleDate: itm1.SettleDate,
groupNum: itm1.GroupNum,
invGroupNum: string.Empty,
invbillnum: string.Empty,
partcode: itm1.PartCode
);
_detailEntity.RealPartCode = itm1.RealPartCode;
billDetails.Add(_detailEntity);
}
//foreach (var itm in part_group_big) //foreach (var itm in part_group_big)
//{ //{
// var ls = hbpo_can_list.Where(p => p.LU == itm.LU).ToList(); // var ls = hbpo_can_list.Where(p => p.LU == itm.LU).ToList();

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

@ -105,70 +105,75 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{ {
priceList = _priceRepository.Where(p => p.IsCancel == false).ToList();//价格单 priceList = _priceRepository.Where(p => p.IsCancel == false).ToList();//价格单
} }
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.YinDuJian) List<PriceList> priceLists = new List<PriceList>();
var notlist = p_list;//JIT_ASN整发
foreach (var itm in notlist)
{ {
var ls = p_list.Select(p => p.GroupNum).Distinct().ToList(); var priceListEntity = priceList.Where(p => p.IsCancel == false)
var notlist = p_list;//JIT_ASN整发 .Where(t => t.LU == itm.LU)
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC) .Where(t => itm.SettleDate >= t.BeginTime && itm.SettleDate <= t.EndTime && t.ClientCode == itm.Site)
.OrderByDescending(t => t.Date)
.ThenByDescending(t => t.CreationTime)
.FirstOrDefault();
if (priceListEntity != null)
{ {
var subqueryA = (from a in notlist itm.Price = priceListEntity.Price;
where a.BusinessType == first.BusinessType }
group a by new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } into groupedData else
select new {
{ itm.Price = 0;
Number = groupedData.Count(), }
groupedData.Key.GroupNum, }
groupedData.Key.SettleBillNum, var result1 = notlist.Where(p => p.Price != 0);
groupedData.Key.Version,
groupedData.Key.Site //if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.YinDuJian || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO)
}).AsQueryable(); //{
var subqueryB = (from a in notlist // var ls = p_list.Select(p => p.GroupNum).Distinct().ToList();
join b in priceList on new { LU = a.LU, Site = a.Site } equals new { LU = b.LU, Site = b.ClientCode } //if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)
where a.SettleDate >= b.BeginTime && a.SettleDate <= b.EndTime && b.IsCancel == false //{
group a by new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } into groupedData //var subqueryA = (from a in notlist
select new // where a.BusinessType == first.BusinessType
{ // group a by new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } into groupedData
Number = groupedData.Count(), // select new
groupedData.Key.GroupNum, // {
groupedData.Key.SettleBillNum, // Number = groupedData.Count(),
groupedData.Key.Version, // groupedData.Key.GroupNum,
groupedData.Key.Site // groupedData.Key.SettleBillNum,
}).AsQueryable(); // groupedData.Key.Version,
var result = from tmp1 in notlist // groupedData.Key.Site
join tmp2 in (from a in subqueryA // }).AsQueryable();
join b in subqueryB on new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } equals new { b.GroupNum, b.SettleBillNum, b.Version, b.Site } //var subqueryB = (from a in notlist
where a.Number == b.Number // join b in priceList on new { LU = a.LU, Site = a.Site } equals new { LU = b.LU, Site = b.ClientCode }
select new // where a.SettleDate >= b.BeginTime && a.SettleDate <= b.EndTime && b.IsCancel == false
{ // group a by new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } into groupedData
a.GroupNum, // select new
a.SettleBillNum, // {
a.Version, // Number = groupedData.Count(),
a.Number // groupedData.Key.GroupNum,
}) // groupedData.Key.SettleBillNum,
on new { tmp1.GroupNum, tmp1.SettleBillNum } equals new { tmp2.GroupNum, tmp2.SettleBillNum } // groupedData.Key.Version,
select tmp1;//不可结 // groupedData.Key.Site
List<PriceList> priceLists = new List<PriceList>(); // }).AsQueryable();
foreach (var itm in notlist) //var result = from tmp1 in notlist
{ // join tmp2 in (from a in subqueryA
var priceListEntity = priceList.Where(p => p.IsCancel == false) // join b in subqueryB on new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } equals new { b.GroupNum, b.SettleBillNum, b.Version, b.Site }
.Where(t => t.LU == itm.LU) // where a.Number == b.Number
.Where(t => itm.SettleDate >= t.BeginTime && itm.SettleDate <= t.EndTime && t.ClientCode == itm.Site) // select new
.OrderByDescending(t => t.Date) // {
.ThenByDescending(t => t.CreationTime) // a.GroupNum,
.FirstOrDefault(); // a.SettleBillNum,
if (priceListEntity != null) // a.Version,
{ // a.Number
itm.Price = priceListEntity.Price; // })
} // on new { tmp1.GroupNum, tmp1.SettleBillNum } equals new { tmp2.GroupNum, tmp2.SettleBillNum }
else // select tmp1;//不可结
{
itm.Price = 0;
}
}
var result1 = notlist.Where(p=>p.Price!=0);
var jit1 = result1.Where(p => p.Site == "1040").ToList(); var jit1 = result1.Where(p => p.Site == "1040").ToList();
var jit2 = result1.Where(p => p.Site == "1046").ToList(); var jit2 = result1.Where(p => p.Site == "1046").ToList();
var jit3 = result.Where(p => p.Site == "1041").ToList(); var jit3 = result1.Where(p => p.Site == "1041").ToList();
var jit4= result1.Where(p => p.Site == "104T").ToList();
var jit5 = result1.Where(p => p.Site == "1049").ToList();
if (jit1.Count > 0) if (jit1.Count > 0)
{ {
deletenotList.AddRange(jit1); deletenotList.AddRange(jit1);
@ -181,6 +186,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
entity.State = SettleBillState.; entity.State = SettleBillState.;
entity.SettleBillNum = string.Empty; entity.SettleBillNum = string.Empty;
entity.BusinessType = first.BusinessType; entity.BusinessType = first.BusinessType;
entity.Site = "1040"; entity.Site = "1040";
billList.Add(entity); billList.Add(entity);
foreach (var itm in jit1) foreach (var itm in jit1)
@ -204,6 +210,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
partcode: itm.PartCode, partcode: itm.PartCode,
pobillnum: string.Empty pobillnum: string.Empty
); );
foreach (var extra in itm.ExtraProperties)
{
detailEntity.ExtraProperties.Add(extra.Key, extra.Value);
}
detailEntity.IndexNum = itm.IndexNum; detailEntity.IndexNum = itm.IndexNum;
detailEntity.RealPartCode = itm.RealPartCode; detailEntity.RealPartCode = itm.RealPartCode;
entityList.Add(detailEntity); entityList.Add(detailEntity);
@ -246,6 +256,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
); );
detailEntity.IndexNum = itm.IndexNum; detailEntity.IndexNum = itm.IndexNum;
detailEntity.RealPartCode = itm.RealPartCode; detailEntity.RealPartCode = itm.RealPartCode;
foreach (var extra in itm.ExtraProperties)
{
detailEntity.ExtraProperties.Add(extra.Key, extra.Value);
}
entityList.Add(detailEntity); entityList.Add(detailEntity);
} }
} }
@ -284,180 +298,281 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
partcode: itm.PartCode, partcode: itm.PartCode,
pobillnum: string.Empty pobillnum: string.Empty
); );
foreach (var extra in itm.ExtraProperties)
{
detailEntity.ExtraProperties.Add(extra.Key, extra.Value);
}
detailEntity.IndexNum = itm.IndexNum; detailEntity.IndexNum = itm.IndexNum;
detailEntity.RealPartCode = itm.RealPartCode; detailEntity.RealPartCode = itm.RealPartCode;
entityList.Add(detailEntity); entityList.Add(detailEntity);
} }
} }
await _repository.DbContext.BulkDeleteAsync(deletenotList).ConfigureAwait(false);
await _repository.DbContext.BulkInsertAsync(billList).ConfigureAwait(false); if (jit4.Count > 0)
await _repository.DbContext.BulkInsertAsync(entityList).ConfigureAwait(false);
}
}
else
{
if (first.BusinessType == EnumBusinessType.ZhiGongJianHBPO)
{
var _first = p_list.FirstOrDefault();
var pricelist = priceList.Where(p => p.ClientCode == "104T" && p.IsCancel == false).ToList();
var query1 = from d in p_list
join p in pricelist
on d.LU equals p.LU
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "104T"
select
new
{
a = new PUB_CAN_SA_DETAIL()
{
Version = d.Version,
KeyCode = d.KeyCode,
Site = "104T",
BusinessType = d.BusinessType,
ErpLoc = d.ErpLoc,
CreationTime = d.CreationTime,
GroupNum = d.GroupNum,
InvGroupNum = d.InvGroupNum,
LU = d.LU,
PN = d.PN,
SettleBillNum = d.SettleBillNum,
Price = p.Price,
SettleDate = d.SettleDate,
RealPartCode = d.RealPartCode,
PartCode = d.PartCode,
Qty = d.Qty
},
b = d
};
var pub_can_list = query1.Select(p => p.a).ToList();
var pub_not_list = query1.Select(p => p.b).ToList();
if (pub_can_list.Count > 0)
{ {
var t1 = pub_can_list.GroupBy(p => p.LU).Select(p => new { LU = p.Key, Amt = p.Sum(itm => itm.Qty * itm.Price) }).OrderByDescending(p => p.Amt).ToList(); deletenotList.AddRange(jit4);
var part_group_big = t1.Where(p => p.Amt >= 10000000).ToList(); var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
var part_group_small = t1.Where(p => p.Amt < 10000000).ToList(); var entity = new PUB_CAN_SA();
if (part_group_big.Count > 0) entity.SetId(Guid.NewGuid());
entity.BillNum = billNumber;
entity.InvGroupNum = billNumber;
entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
entity.State = SettleBillState.;
entity.SettleBillNum = string.Empty;
entity.BusinessType = first.BusinessType;
entity.Site = "104T";
billList.Add(entity);
foreach (var itm in jit4)
{ {
foreach (var itm in part_group_big) var detailEntity = new PUB_CAN_SA_DETAIL(
{ guid: GuidGenerator.Create(),
var ls = pub_can_list.Where(p => p.LU == itm.LU).ToList(); keyCode: itm.KeyCode,
decimal sum = 0; version: itm.Version,
List<PUB_CAN_SA_DETAIL> details = new List<PUB_CAN_SA_DETAIL>(); billNum: billNumber,
foreach (var itm1 in ls) settleBillNum: itm.SettleBillNum,
{ lU: itm.LU,
sum += (itm1.Qty * itm1.Price); pN: itm.PN,
if (sum > 10000000) site: itm.Site,
{ qty: itm.Qty,
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); price: priceList.FirstOrDefault(p => itm.SettleDate >= p.BeginTime && itm.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "104T").Price,
var bbac_sa = new PUB_CAN_SA(); businessType: itm.BusinessType,
bbac_sa.SetId(Guid.NewGuid()); settleDate: itm.SettleDate,
bbac_sa.BillNum = billNum; groupNum: itm.GroupNum,
bbac_sa.InvGroupNum = billNum; invGroupNum: billNumber,
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); invbillnum: string.Empty,
bbac_sa.State = SettleBillState.; partcode: itm.PartCode,
bbac_sa.SettleBillNum = string.Empty; pobillnum: string.Empty
bbac_sa.Site = "104T"; );
bbac_sa.BusinessType = EnumBusinessType.JisBBAC;
billList.Add(bbac_sa);
foreach (var itm2 in details)
{
itm2.SetBillNum(billNum);
itm2.SetGroupNum(billNum);
billDetails.Add(itm2);
}
details = new List<PUB_CAN_SA_DETAIL>();
sum = (itm1.Qty * itm1.Price);
}
var _detailEntity = new PUB_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm1.KeyCode,
version: itm1.Version,
billNum: string.Empty,
settleBillNum: itm1.SettleBillNum,
lU: itm1.LU,
pN: itm1.PN,
site: itm1.Site,
qty: itm1.Qty,
price: itm1.Price,
businessType: itm1.BusinessType,
settleDate: itm1.SettleDate,
groupNum: itm1.GroupNum,
invGroupNum: string.Empty,
invbillnum: string.Empty,
partcode: itm1.PartCode,
pobillnum: itm1.PoBillNum
); foreach (var extra in itm.ExtraProperties)
_detailEntity.RealPartCode = itm1.RealPartCode;
details.Add(_detailEntity);
}
var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N");
var bbac_sa1 = new PUB_CAN_SA();
bbac_sa1.SetId(Guid.NewGuid());
bbac_sa1.BillNum = billNum1;
bbac_sa1.InvGroupNum = billNum1;
bbac_sa1.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
bbac_sa1.State = SettleBillState.;
bbac_sa1.SettleBillNum = string.Empty;
bbac_sa1.Site = "104T";
bbac_sa1.BusinessType = EnumBusinessType.JisBBAC;
billList.Add(bbac_sa1);
foreach (var detail in details)
{
detail.SetBillNum(billNum1);
detail.SetGroupNum(billNum1);
billDetails.Add(detail);
}
}
}
if (part_group_small.Count > 0)
{
var partlist = part_group_small.Select(p => p.LU).ToList();
var ls = pub_can_list.Where(p => partlist.Contains(p.LU)).ToList();
var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
var bbac_sa = new PUB_CAN_SA();
bbac_sa.SetId(Guid.NewGuid());
bbac_sa.BillNum = billNum;
bbac_sa.InvGroupNum = billNum;
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
bbac_sa.State = SettleBillState.;
bbac_sa.SettleBillNum = string.Empty;
bbac_sa.Site = "104T";
bbac_sa.BusinessType = EnumBusinessType.JisBBAC;
billList.Add(bbac_sa);
foreach (var itm1 in ls)
{ {
var _detailEntity = new PUB_CAN_SA_DETAIL( detailEntity.ExtraProperties.Add(extra.Key, extra.Value);
guid: GuidGenerator.Create(),
keyCode: itm1.KeyCode,
version: itm1.Version,
billNum: billNum,
settleBillNum: itm1.SettleBillNum,
lU: itm1.LU,
pN: itm1.PN,
site: itm1.Site,
qty: itm1.Qty,
price: itm1.Price,
businessType: itm1.BusinessType,
settleDate: itm1.SettleDate,
groupNum: itm1.GroupNum,
invGroupNum: billNum,
invbillnum: string.Empty,
partcode: itm1.PartCode,
pobillnum:itm1.PoBillNum
);
_detailEntity.RealPartCode = itm1.RealPartCode;
billDetails.Add(_detailEntity);
} }
detailEntity.IndexNum = itm.IndexNum;
detailEntity.RealPartCode = itm.RealPartCode;
entityList.Add(detailEntity);
} }
}
if (jit5.Count > 0)
{
deletenotList.AddRange(jit5);
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
var entity = new PUB_CAN_SA();
entity.SetId(Guid.NewGuid());
entity.BillNum = billNumber;
entity.InvGroupNum = billNumber;
entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
entity.State = SettleBillState.;
entity.SettleBillNum = string.Empty;
entity.BusinessType = first.BusinessType;
entity.Site = "1049";
billList.Add(entity);
foreach (var itm in jit5)
{
var detailEntity = new PUB_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm.KeyCode,
version: itm.Version,
billNum: billNumber,
settleBillNum: itm.SettleBillNum,
lU: itm.LU,
pN: itm.PN,
site: itm.Site,
qty: itm.Qty,
price: priceList.FirstOrDefault(p => itm.SettleDate >= p.BeginTime && itm.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "104T").Price,
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: billNumber,
invbillnum: string.Empty,
partcode: itm.PartCode,
pobillnum: string.Empty
);
foreach (var extra in itm.ExtraProperties)
await _repository.DbContext.BulkDeleteAsync(notList).ConfigureAwait(false); {
await _repository.DbContext.BulkInsertAsync(billList).ConfigureAwait(false); detailEntity.ExtraProperties.Add(extra.Key, extra.Value);
await _repository.DbContext.BulkInsertAsync(entityList).ConfigureAwait(false); }
detailEntity.IndexNum = itm.IndexNum;
detailEntity.RealPartCode = itm.RealPartCode;
entityList.Add(detailEntity);
} }
} }
}
await _repository.DbContext.BulkDeleteAsync(deletenotList).ConfigureAwait(false);
await _repository.DbContext.BulkInsertAsync(billList).ConfigureAwait(false);
await _repository.DbContext.BulkInsertAsync(entityList).ConfigureAwait(false);
//}
//}
//else
//{
//if (first.BusinessType == EnumBusinessType.ZhiGongJianHBPO)
//{
// var _first = p_list.FirstOrDefault();
// var pricelist = priceList.Where(p => p.ClientCode == "104T" && p.IsCancel == false).ToList();
// var query1 = from d in p_list
// join p in pricelist
// on d.LU equals p.LU
// where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "104T"
// select
// new
// {
// a = new PUB_CAN_SA_DETAIL()
// {
// Version = d.Version,
// KeyCode = d.KeyCode,
// Site = "104T",
// BusinessType = d.BusinessType,
// ErpLoc = d.ErpLoc,
// CreationTime = d.CreationTime,
// GroupNum = d.GroupNum,
// InvGroupNum = d.InvGroupNum,
// LU = d.LU,
// PN = d.PN,
// SettleBillNum = d.SettleBillNum,
// Price = p.Price,
// SettleDate = d.SettleDate,
// RealPartCode = d.RealPartCode,
// PartCode = d.PartCode,
// Qty = d.Qty
// },
// b = d
// };
// var pub_can_list = query1.Select(p => p.a).ToList();
// var pub_not_list = query1.Select(p => p.b).ToList();
// if (pub_can_list.Count > 0)
// {
// var t1 = pub_can_list.GroupBy(p => p.LU).Select(p => new { LU = p.Key, Amt = p.Sum(itm => itm.Qty * itm.Price) }).OrderByDescending(p => p.Amt).ToList();
// var part_group_big = t1.Where(p => p.Amt >= 10000000).ToList();
// var part_group_small = t1.Where(p => p.Amt < 10000000).ToList();
// if (part_group_big.Count > 0)
// {
// foreach (var itm in part_group_big)
// {
// var ls = pub_can_list.Where(p => p.LU == itm.LU).ToList();
// decimal sum = 0;
// List<PUB_CAN_SA_DETAIL> details = new List<PUB_CAN_SA_DETAIL>();
// foreach (var itm1 in ls)
// {
// sum += (itm1.Qty * itm1.Price);
// if (sum > 10000000)
// {
// var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
// var bbac_sa = new PUB_CAN_SA();
// bbac_sa.SetId(Guid.NewGuid());
// bbac_sa.BillNum = billNum;
// bbac_sa.InvGroupNum = billNum;
// bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
// bbac_sa.State = SettleBillState.未结状态;
// bbac_sa.SettleBillNum = string.Empty;
// bbac_sa.Site = "104T";
// bbac_sa.BusinessType = EnumBusinessType.JisBBAC;
// billList.Add(bbac_sa);
// foreach (var itm2 in details)
// {
// itm2.SetBillNum(billNum);
// itm2.SetGroupNum(billNum);
// billDetails.Add(itm2);
// }
// details = new List<PUB_CAN_SA_DETAIL>();
// sum = (itm1.Qty * itm1.Price);
// }
// var _detailEntity = new PUB_CAN_SA_DETAIL(
// guid: GuidGenerator.Create(),
// keyCode: itm1.KeyCode,
// version: itm1.Version,
// billNum: string.Empty,
// settleBillNum: itm1.SettleBillNum,
// lU: itm1.LU,
// pN: itm1.PN,
// site: itm1.Site,
// qty: itm1.Qty,
// price: itm1.Price,
// businessType: itm1.BusinessType,
// settleDate: itm1.SettleDate,
// groupNum: itm1.GroupNum,
// invGroupNum: string.Empty,
// invbillnum: string.Empty,
// partcode: itm1.PartCode,
// pobillnum: itm1.PoBillNum
// );
// _detailEntity.RealPartCode = itm1.RealPartCode;
// details.Add(_detailEntity);
// }
// var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N");
// var bbac_sa1 = new PUB_CAN_SA();
// bbac_sa1.SetId(Guid.NewGuid());
// bbac_sa1.BillNum = billNum1;
// bbac_sa1.InvGroupNum = billNum1;
// bbac_sa1.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
// bbac_sa1.State = SettleBillState.未结状态;
// bbac_sa1.SettleBillNum = string.Empty;
// bbac_sa1.Site = "104T";
// bbac_sa1.BusinessType = EnumBusinessType.JisBBAC;
// billList.Add(bbac_sa1);
// foreach (var detail in details)
// {
// detail.SetBillNum(billNum1);
// detail.SetGroupNum(billNum1);
// billDetails.Add(detail);
// }
// }
// }
// if (part_group_small.Count > 0)
// {
// var partlist = part_group_small.Select(p => p.LU).ToList();
// var ls = pub_can_list.Where(p => partlist.Contains(p.LU)).ToList();
// var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
// var bbac_sa = new PUB_CAN_SA();
// bbac_sa.SetId(Guid.NewGuid());
// bbac_sa.BillNum = billNum;
// bbac_sa.InvGroupNum = billNum;
// bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
// bbac_sa.State = SettleBillState.未结状态;
// bbac_sa.SettleBillNum = string.Empty;
// bbac_sa.Site = "104T";
// bbac_sa.BusinessType = EnumBusinessType.JisBBAC;
// billList.Add(bbac_sa);
// foreach (var itm1 in ls)
// {
// var _detailEntity = new PUB_CAN_SA_DETAIL(
// guid: GuidGenerator.Create(),
// keyCode: itm1.KeyCode,
// version: itm1.Version,
// billNum: billNum,
// settleBillNum: itm1.SettleBillNum,
// lU: itm1.LU,
// pN: itm1.PN,
// site: itm1.Site,
// qty: itm1.Qty,
// price: itm1.Price,
// businessType: itm1.BusinessType,
// settleDate: itm1.SettleDate,
// groupNum: itm1.GroupNum,
// invGroupNum: billNum,
// invbillnum: string.Empty,
// partcode: itm1.PartCode,
// pobillnum:itm1.PoBillNum
// );
// _detailEntity.RealPartCode = itm1.RealPartCode;
// foreach (var extra in itm1.ExtraProperties)
// {
// _detailEntity.ExtraProperties.Add(extra.Key, extra.Value);
// }
// billDetails.Add(_detailEntity);
// }
// }
// await _repository.DbContext.BulkDeleteAsync(notList).ConfigureAwait(false);
// await _repository.DbContext.BulkInsertAsync(billList).ConfigureAwait(false);
// await _repository.DbContext.BulkInsertAsync(entityList).ConfigureAwait(false);
// }
//}
//}
return errors; return errors;
} }
} }

Loading…
Cancel
Save