Browse Source

更新版本

master
zhaoxinyu 10 months ago
parent
commit
6e40d285d0
  1. 153
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MakeCanSettlementService.cs
  2. 151
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs
  3. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_CAN_SA.cs

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

@ -52,8 +52,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
bbacquery = bbacquery.Where(filers.ToLambda<BBAC_NOT_SA_DETAIL>()); bbacquery = bbacquery.Where(filers.ToLambda<BBAC_NOT_SA_DETAIL>());
} }
var p_list = bbacquery.ToList(); var p_list = bbacquery.ToList();
if (p_list.Count == 0)
{
var ls = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "BBAC_NOT" && p.Value == "True").ToList();
if (ls.Any())
{
_dbcontext.BulkDelete(ls);
}
}
var jis1 = p_list.Where(p => p.Site == "1040").ToList(); var jis1 = p_list.Where(p => p.Site == "1040").ToList();
var jis2 = p_list.Where(p => p.Site == "1046").ToList(); var jis2 = p_list.Where(p => p.Site == "1046").ToList();
List<BBAC_NOT_SA_DETAIL> notlist = new List<BBAC_NOT_SA_DETAIL>(); List<BBAC_NOT_SA_DETAIL> notlist = new List<BBAC_NOT_SA_DETAIL>();
@ -107,6 +113,28 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
List<BBAC_CAN_SA_DETAIL> details = new List<BBAC_CAN_SA_DETAIL>(); List<BBAC_CAN_SA_DETAIL> details = new List<BBAC_CAN_SA_DETAIL>();
foreach (var itm1 in ls) foreach (var itm1 in ls)
{ {
var _detailEntity = new BBAC_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,
category: itm1.BusinessType,
isReturn: itm1.IsReturn,
settleDate: itm1.SettleDate,
groupNum: itm1.GroupNum,
invGroupNum: string.Empty,
contactid: itm1.ContractDocID,
invbillnum: string.Empty,
partcode: itm1.PartCode
);
_detailEntity.RealPartCode = itm1.RealPartCode;
details.Add(_detailEntity);
sum += (itm1.Qty * itm1.Price); sum += (itm1.Qty * itm1.Price);
if (sum > 10000000) if (sum > 10000000)
{ {
@ -130,29 +158,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
details = new List<BBAC_CAN_SA_DETAIL>(); details = new List<BBAC_CAN_SA_DETAIL>();
sum = 0; sum = 0;
} }
var _detailEntity = new BBAC_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,
category: itm1.BusinessType,
isReturn: itm1.IsReturn,
settleDate: itm1.SettleDate,
groupNum: itm1.GroupNum,
invGroupNum: string.Empty,
contactid: itm1.ContractDocID,
invbillnum: string.Empty,
partcode: itm1.PartCode
);
_detailEntity.RealPartCode = itm1.RealPartCode;
details.Add(_detailEntity);
} }
var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N"); var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N");
var bbac_sa1 = new BBAC_CAN_SA(); var bbac_sa1 = new BBAC_CAN_SA();
@ -265,6 +270,28 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
List<BBAC_CAN_SA_DETAIL> details = new List<BBAC_CAN_SA_DETAIL>(); List<BBAC_CAN_SA_DETAIL> details = new List<BBAC_CAN_SA_DETAIL>();
foreach (var itm1 in ls) foreach (var itm1 in ls)
{ {
var _detailEntity = new BBAC_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,
category: itm1.BusinessType,
isReturn: itm1.IsReturn,
settleDate: itm1.SettleDate,
groupNum: itm1.GroupNum,
invGroupNum: string.Empty,
contactid: itm1.ContractDocID,
invbillnum: string.Empty,
partcode: itm1.PartCode
);
_detailEntity.RealPartCode = itm1.RealPartCode;
details.Add(_detailEntity);
sum += (itm1.Qty * itm1.Price); sum += (itm1.Qty * itm1.Price);
if (sum > 10000000) if (sum > 10000000)
{ {
@ -287,30 +314,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
} }
details = new List<BBAC_CAN_SA_DETAIL>(); details = new List<BBAC_CAN_SA_DETAIL>();
sum = 0; sum = 0;
} }
var _detailEntity = new BBAC_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,
category: itm1.BusinessType,
isReturn: itm1.IsReturn,
settleDate: itm1.SettleDate,
groupNum: itm1.GroupNum,
invGroupNum: string.Empty,
contactid: itm1.ContractDocID,
invbillnum: string.Empty,
partcode: itm1.PartCode
);
_detailEntity.RealPartCode = itm1.RealPartCode;
details.Add(_detailEntity);
} }
var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N"); var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N");
var bbac_sa1 = new BBAC_CAN_SA(); var bbac_sa1 = new BBAC_CAN_SA();
@ -439,6 +443,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
bbacquery = bbacquery.Where(filers.ToLambda<HBPO_NOT_SA_DETAIL>()); bbacquery = bbacquery.Where(filers.ToLambda<HBPO_NOT_SA_DETAIL>());
} }
var p_list = bbacquery.ToList(); var p_list = bbacquery.ToList();
if (p_list.Count == 0)
{
var ls = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "BBAC_NOT" && p.Value == "True").ToList();
if (ls.Any())
{
_dbcontext.BulkDelete(ls);
}
}
var jis1 = p_list.Where(p => p.Site == "104T").ToList(); var jis1 = p_list.Where(p => p.Site == "104T").ToList();
if (jis1.Count > 0) if (jis1.Count > 0)
{ {
@ -488,6 +502,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
List<HBPO_CAN_SA_DETAIL> details = new List<HBPO_CAN_SA_DETAIL>(); List<HBPO_CAN_SA_DETAIL> details = new List<HBPO_CAN_SA_DETAIL>();
foreach (var itm1 in ls) 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;
details.Add(_detailEntity);
sum += (itm1.Qty * itm1.Price); sum += (itm1.Qty * itm1.Price);
if (sum > 10000000) if (sum > 10000000)
{ {
@ -511,26 +545,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
details = new List<HBPO_CAN_SA_DETAIL>(); details = new List<HBPO_CAN_SA_DETAIL>();
sum = 0; sum = 0;
} }
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;
details.Add(_detailEntity);
} }
var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N"); var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N");
var bbac_sa1 = new HBPO_CAN_SA(); var bbac_sa1 = new HBPO_CAN_SA();

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

@ -70,6 +70,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var entityList = new List<PUB_CAN_SA_DETAIL>(); var entityList = new List<PUB_CAN_SA_DETAIL>();
var notList = new List<PUB_NOT_SA_DETAIL>(); var notList = new List<PUB_NOT_SA_DETAIL>();
var billList = new List<PUB_CAN_SA>(); var billList = new List<PUB_CAN_SA>();
List<PUB_CAN_SA_DETAIL> billDetails = new List<PUB_CAN_SA_DETAIL>();
var query = p_list.Select(p => p.BusinessType).Distinct().ToList(); var query = p_list.Select(p => p.BusinessType).Distinct().ToList();
if (query.Count > 1) if (query.Count > 1)
{ {
@ -311,44 +312,126 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var pub_not_list = query1.Select(p => p.b).ToList(); var pub_not_list = query1.Select(p => p.b).ToList();
if (pub_can_list.Count > 0) 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)
{
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
notList.AddRange(pub_not_list); );
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N"); _detailEntity.RealPartCode = itm1.RealPartCode;
var entity = new PUB_CAN_SA(); details.Add(_detailEntity);
entity.SetId(Guid.NewGuid()); sum += (itm1.Qty * itm1.Price);
entity.BillNum = billNumber; if (sum > 10000000)
entity.InvGroupNum = billNumber; {
entity.Version = int.Parse(DateTime.Now.ToString("yyyymm")); var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
entity.State = SettleBillState.; var bbac_sa = new PUB_CAN_SA();
entity.SettleBillNum = string.Empty; bbac_sa.SetId(Guid.NewGuid());
entity.BusinessType = _first.BusinessType; bbac_sa.BillNum = billNum;
entity.Site = _first.Site; bbac_sa.InvGroupNum = billNum;
foreach (var itm in pub_can_list) 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 = 0;
}
}
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 _detailEntity = new PUB_CAN_SA_DETAIL( var partlist = part_group_small.Select(p => p.LU).ToList();
guid: GuidGenerator.Create(), var ls = pub_can_list.Where(p => partlist.Contains(p.LU)).ToList();
keyCode: itm.KeyCode, var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
version: itm.Version, var bbac_sa = new PUB_CAN_SA();
billNum: billNumber, bbac_sa.SetId(Guid.NewGuid());
settleBillNum: itm.SettleBillNum, bbac_sa.BillNum = billNum;
lU: itm.LU, bbac_sa.InvGroupNum = billNum;
pN: itm.PN, bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
site: itm.Site, bbac_sa.State = SettleBillState.;
qty: itm.Qty, bbac_sa.SettleBillNum = string.Empty;
price: itm.Price, bbac_sa.Site = "104T";
businessType: itm.BusinessType, bbac_sa.BusinessType = EnumBusinessType.JisBBAC;
settleDate: itm.SettleDate, billList.Add(bbac_sa);
groupNum: itm.GroupNum, foreach (var itm1 in ls)
invGroupNum: billNumber, {
invbillnum: string.Empty, var _detailEntity = new PUB_CAN_SA_DETAIL(
partcode: itm.PartCode, guid: GuidGenerator.Create(),
pobillnum: string.Empty keyCode: itm1.KeyCode,
); version: itm1.Version,
_detailEntity.RealPartCode = string.IsNullOrEmpty(itm.RealPartCode) ? itm.PartCode : itm.RealPartCode; billNum: billNum,
entityList.Add(_detailEntity); 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);
}
} }
await _repository.DbContext.BulkDeleteAsync(notList).ConfigureAwait(false); await _repository.DbContext.BulkDeleteAsync(notList).ConfigureAwait(false);
await _repository.DbContext.BulkInsertAsync(new List<PUB_CAN_SA>() { entity }).ConfigureAwait(false); await _repository.DbContext.BulkInsertAsync(billList).ConfigureAwait(false);
await _repository.DbContext.BulkInsertAsync(entityList).ConfigureAwait(false); await _repository.DbContext.BulkInsertAsync(entityList).ConfigureAwait(false);
} }
} }

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

@ -147,5 +147,15 @@ namespace SettleAccount.Domain.BQ
public PUB_CAN_SA_DETAIL() public PUB_CAN_SA_DETAIL()
{ {
} }
public void SetBillNum(string billNum)
{
BillNum = billNum;
}
public void SetGroupNum(string billNum) {
BillNum = billNum;
}
} }
} }

Loading…
Cancel
Save