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. 499
      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();

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

@ -105,49 +105,8 @@ 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)
{
var ls = p_list.Select(p => p.GroupNum).Distinct().ToList();
var notlist = p_list;//JIT_ASN整发
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)
{
var subqueryA = (from a in notlist
where a.BusinessType == first.BusinessType
group a by new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } into groupedData
select new
{
Number = groupedData.Count(),
groupedData.Key.GroupNum,
groupedData.Key.SettleBillNum,
groupedData.Key.Version,
groupedData.Key.Site
}).AsQueryable();
var subqueryB = (from a in notlist
join b in priceList on new { LU = a.LU, Site = a.Site } equals new { LU = b.LU, Site = b.ClientCode }
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
select new
{
Number = groupedData.Count(),
groupedData.Key.GroupNum,
groupedData.Key.SettleBillNum,
groupedData.Key.Version,
groupedData.Key.Site
}).AsQueryable();
var result = from tmp1 in notlist
join tmp2 in (from a in subqueryA
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 a.Number == b.Number
select new
{
a.GroupNum,
a.SettleBillNum,
a.Version,
a.Number
})
on new { tmp1.GroupNum, tmp1.SettleBillNum } equals new { tmp2.GroupNum, tmp2.SettleBillNum }
select tmp1;//不可结
List<PriceList> priceLists = new List<PriceList>(); List<PriceList> priceLists = new List<PriceList>();
var notlist = p_list;//JIT_ASN整发
foreach (var itm in notlist) foreach (var itm in notlist)
{ {
var priceListEntity = priceList.Where(p => p.IsCancel == false) var priceListEntity = priceList.Where(p => p.IsCancel == false)
@ -165,10 +124,56 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
itm.Price = 0; itm.Price = 0;
} }
} }
var result1 = notlist.Where(p=>p.Price!=0); var result1 = notlist.Where(p => p.Price != 0);
//if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.YinDuJian || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO)
//{
// var ls = p_list.Select(p => p.GroupNum).Distinct().ToList();
//if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)
//{
//var subqueryA = (from a in notlist
// where a.BusinessType == first.BusinessType
// group a by new { a.GroupNum, a.SettleBillNum, a.Version, a.Site } into groupedData
// select new
// {
// Number = groupedData.Count(),
// groupedData.Key.GroupNum,
// groupedData.Key.SettleBillNum,
// groupedData.Key.Version,
// groupedData.Key.Site
// }).AsQueryable();
//var subqueryB = (from a in notlist
// join b in priceList on new { LU = a.LU, Site = a.Site } equals new { LU = b.LU, Site = b.ClientCode }
// 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
// select new
// {
// Number = groupedData.Count(),
// groupedData.Key.GroupNum,
// groupedData.Key.SettleBillNum,
// groupedData.Key.Version,
// groupedData.Key.Site
// }).AsQueryable();
//var result = from tmp1 in notlist
// join tmp2 in (from a in subqueryA
// 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 a.Number == b.Number
// select new
// {
// a.GroupNum,
// a.SettleBillNum,
// a.Version,
// a.Number
// })
// on new { tmp1.GroupNum, tmp1.SettleBillNum } equals new { tmp2.GroupNum, tmp2.SettleBillNum }
// select tmp1;//不可结
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();
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"); deletenotList.AddRange(jit4);
var bbac_sa = new PUB_CAN_SA(); var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
bbac_sa.SetId(Guid.NewGuid()); var entity = new PUB_CAN_SA();
bbac_sa.BillNum = billNum; entity.SetId(Guid.NewGuid());
bbac_sa.InvGroupNum = billNum; entity.BillNum = billNumber;
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); entity.InvGroupNum = billNumber;
bbac_sa.State = SettleBillState.; entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
bbac_sa.SettleBillNum = string.Empty; entity.State = SettleBillState.;
bbac_sa.Site = "104T"; entity.SettleBillNum = string.Empty;
bbac_sa.BusinessType = EnumBusinessType.JisBBAC; entity.BusinessType = first.BusinessType;
billList.Add(bbac_sa); entity.Site = "104T";
foreach (var itm2 in details) billList.Add(entity);
foreach (var itm in jit4)
{ {
itm2.SetBillNum(billNum); var detailEntity = new PUB_CAN_SA_DETAIL(
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(), guid: GuidGenerator.Create(),
keyCode: itm1.KeyCode, keyCode: itm.KeyCode,
version: itm1.Version, version: itm.Version,
billNum: string.Empty, billNum: billNumber,
settleBillNum: itm1.SettleBillNum, settleBillNum: itm.SettleBillNum,
lU: itm1.LU, lU: itm.LU,
pN: itm1.PN, pN: itm.PN,
site: itm1.Site, site: itm.Site,
qty: itm1.Qty, qty: itm.Qty,
price: itm1.Price, price: priceList.FirstOrDefault(p => itm.SettleDate >= p.BeginTime && itm.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "104T").Price,
businessType: itm1.BusinessType, businessType: itm.BusinessType,
settleDate: itm1.SettleDate, settleDate: itm.SettleDate,
groupNum: itm1.GroupNum, groupNum: itm.GroupNum,
invGroupNum: string.Empty, invGroupNum: billNumber,
invbillnum: string.Empty, invbillnum: string.Empty,
partcode: itm1.PartCode, partcode: itm.PartCode,
pobillnum: itm1.PoBillNum pobillnum: string.Empty
); );
_detailEntity.RealPartCode = itm1.RealPartCode;
details.Add(_detailEntity); foreach (var extra in itm.ExtraProperties)
}
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); detailEntity.ExtraProperties.Add(extra.Key, extra.Value);
detail.SetGroupNum(billNum1);
billDetails.Add(detail);
} }
detailEntity.IndexNum = itm.IndexNum;
detailEntity.RealPartCode = itm.RealPartCode;
entityList.Add(detailEntity);
} }
} }
if (part_group_small.Count > 0) if (jit5.Count > 0)
{ {
var partlist = part_group_small.Select(p => p.LU).ToList(); deletenotList.AddRange(jit5);
var ls = pub_can_list.Where(p => partlist.Contains(p.LU)).ToList(); var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
var billNum = OrderNumberGenerator.GenerateOrderNumber("N"); var entity = new PUB_CAN_SA();
var bbac_sa = new PUB_CAN_SA(); entity.SetId(Guid.NewGuid());
bbac_sa.SetId(Guid.NewGuid()); entity.BillNum = billNumber;
bbac_sa.BillNum = billNum; entity.InvGroupNum = billNumber;
bbac_sa.InvGroupNum = billNum; entity.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM")); entity.State = SettleBillState.;
bbac_sa.State = SettleBillState.; entity.SettleBillNum = string.Empty;
bbac_sa.SettleBillNum = string.Empty; entity.BusinessType = first.BusinessType;
bbac_sa.Site = "104T"; entity.Site = "1049";
bbac_sa.BusinessType = EnumBusinessType.JisBBAC; billList.Add(entity);
billList.Add(bbac_sa); foreach (var itm in jit5)
foreach (var itm1 in ls)
{ {
var _detailEntity = new PUB_CAN_SA_DETAIL( var detailEntity = new PUB_CAN_SA_DETAIL(
guid: GuidGenerator.Create(), guid: GuidGenerator.Create(),
keyCode: itm1.KeyCode, keyCode: itm.KeyCode,
version: itm1.Version, version: itm.Version,
billNum: billNum, billNum: billNumber,
settleBillNum: itm1.SettleBillNum, settleBillNum: itm.SettleBillNum,
lU: itm1.LU, lU: itm.LU,
pN: itm1.PN, pN: itm.PN,
site: itm1.Site, site: itm.Site,
qty: itm1.Qty, qty: itm.Qty,
price: itm1.Price, price: priceList.FirstOrDefault(p => itm.SettleDate >= p.BeginTime && itm.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "104T").Price,
businessType: itm1.BusinessType, businessType: itm.BusinessType,
settleDate: itm1.SettleDate, settleDate: itm.SettleDate,
groupNum: itm1.GroupNum, groupNum: itm.GroupNum,
invGroupNum: billNum, invGroupNum: billNumber,
invbillnum: string.Empty, invbillnum: string.Empty,
partcode: itm1.PartCode, partcode: itm.PartCode,
pobillnum:itm1.PoBillNum pobillnum: string.Empty
); );
_detailEntity.RealPartCode = itm1.RealPartCode;
billDetails.Add(_detailEntity); foreach (var extra in itm.ExtraProperties)
{
detailEntity.ExtraProperties.Add(extra.Key, extra.Value);
}
detailEntity.IndexNum = itm.IndexNum;
detailEntity.RealPartCode = itm.RealPartCode;
entityList.Add(detailEntity);
} }
} }
await _repository.DbContext.BulkDeleteAsync(notList).ConfigureAwait(false); await _repository.DbContext.BulkDeleteAsync(deletenotList).ConfigureAwait(false);
await _repository.DbContext.BulkInsertAsync(billList).ConfigureAwait(false); await _repository.DbContext.BulkInsertAsync(billList).ConfigureAwait(false);
await _repository.DbContext.BulkInsertAsync(entityList).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