Browse Source

更新版本

master
zhaoxinyu 9 months ago
parent
commit
830980ce99
  1. 25
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
  2. 20
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
  3. 31
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  4. 132
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MakeCanSettlementService.cs

25
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs

@ -18,6 +18,7 @@ using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.CodeSettings;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
@ -67,6 +68,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary>
private readonly INormalEfCoreRepository<PriceList, Guid> _priceListRepository;
private readonly INormalEfCoreRepository<CodeSetting, Guid> _codeRepository;
/// <summary>
/// 客户零件关系仓储
/// </summary>
@ -97,6 +101,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
IDistributedCache<BBAC_SA> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
INormalEfCoreRepository<CodeSetting, Guid> codeRepository,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
@ -109,6 +114,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
_priceListRepository = priceListRepository;
_materialRelationshipRepository = materialRelationshipRepository;
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository;
_codeRepository = codeRepository;
}
/// <summary>
@ -183,12 +192,20 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//结算分组号
var bbacSaGroupNums = importBBACSaDetails.Select(t => t.GroupNum).Distinct();
//已存在的结算分组号
var havBBACSaGroupNums = (await _bbacSaDetailRepository.GetListAsync(t => bbacSaGroupNums.Contains(t.GroupNum)).ConfigureAwait(false)).Select(t => t.GroupNum).Distinct();
if (havBBACSaGroupNums.Any() == true)
var _first=_codeRepository.FirstOrDefault(p => p.Project == "组验证开启" && p.Value == "是");
if (_first!=null)
{
foreach (var item in havBBACSaGroupNums)
var havBBACSaGroupNums = (await _bbacSaDetailRepository.GetListAsync(t => bbacSaGroupNums.Contains(t.GroupNum)).ConfigureAwait(false)).Select(t => t.GroupNum).Distinct();
if (havBBACSaGroupNums.Any() == true)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty));
foreach (var item in havBBACSaGroupNums)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty));
}
}
}

20
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs

@ -18,6 +18,7 @@ using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.CodeSettings;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
@ -72,6 +73,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// 替换件关系仓储
/// </summary>
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _tbRePartsRelationshipRepository;
private readonly INormalEfCoreRepository<CodeSetting, Guid> _codeRepository;
/// <summary>
/// 构造
@ -84,6 +87,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
INormalEfCoreRepository<PriceList, Guid> priceListRepository,
INormalEfCoreRepository<MaterialRelationship, Guid> materialRelationshipRepository,
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository,
INormalEfCoreRepository<CodeSetting, Guid> codeRepository,
IDistributedCache<HBPO_SA> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
@ -98,6 +102,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
_priceListRepository = priceListRepository;
_materialRelationshipRepository = materialRelationshipRepository;
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository;
_codeRepository = codeRepository;
}
/// <summary>
@ -507,12 +512,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//结算分组号
var saGroupNums = hbpoSaDetails.Select(t => t.GroupNum).Distinct();
//已存在的结算分组号
var havPubSaGroupNums = (await _hbpoSaDetailRepository.GetListAsync(t => saGroupNums.Contains(t.GroupNum)).ConfigureAwait(false)).Select(t => t.GroupNum).Distinct();
if (havPubSaGroupNums.Any() == true)
var _first = _codeRepository.FirstOrDefault(p => p.Project == "组验证开启" && p.Value == "是");
if (_first != null)
{
foreach (var item in havPubSaGroupNums)
var havPubSaGroupNums = (await _hbpoSaDetailRepository.GetListAsync(t => saGroupNums.Contains(t.GroupNum)).ConfigureAwait(false)).Select(t => t.GroupNum).Distinct();
if (havPubSaGroupNums.Any() == true)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty));
foreach (var item in havPubSaGroupNums)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty));
}
}
}

31
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs

@ -20,6 +20,7 @@ using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.CodeSettings;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
@ -80,6 +81,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary>
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _tbRePartsRelationshipRepository;
private readonly INormalEfCoreRepository<CodeSetting, Guid> _codeRepository;
/// <summary>
/// 构造
/// </summary>
@ -94,6 +98,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
INormalEfCoreRepository<PriceListYinDu, Guid> priceYinDuListRepository,
INormalEfCoreRepository<MaterialRelationship, Guid> materialRelationshipRepository,
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository,
INormalEfCoreRepository<CodeSetting, Guid> codeRepository,
IDistributedCache<PUB_SA> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
@ -111,6 +116,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
_priceYinDuListRepository = priceYinDuListRepository;
_materialRelationshipRepository = materialRelationshipRepository;
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository;
_codeRepository = codeRepository;
}
/// <summary>
@ -317,12 +323,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//结算分组号
var pubSaGroupNums = importPubSaDetails.Select(t => t.GroupNum).Distinct();
//已存在的结算分组号
var havPubSaGroupNums = (await _pubSaDetailRepository.GetListAsync(t => t.Place == place && pubSaGroupNums.Contains(t.GroupNum)).ConfigureAwait(false)).Select(t => t.GroupNum).Distinct();
if (havPubSaGroupNums.Any() == true)
var _first = _codeRepository.FirstOrDefault(p => p.Project == "组验证开启" && p.Value == "是");
if (_first != null)
{
foreach (var item in havPubSaGroupNums)
var havPubSaGroupNums = (await _pubSaDetailRepository.GetListAsync(t => t.Place == place && pubSaGroupNums.Contains(t.GroupNum)).ConfigureAwait(false)).Select(t => t.GroupNum).Distinct();
if (havPubSaGroupNums.Any() == true)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty));
foreach (var item in havPubSaGroupNums)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty));
}
}
}
@ -420,12 +431,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//结算分组号
var pubSaGroupNums = pubSaDetails.Select(t => t.GroupNum).Distinct();
//已存在的结算分组号
var havPubSaGroupNums = (await _pubSaDetailRepository.GetListAsync(t => pubSaGroupNums.Contains(t.GroupNum)).ConfigureAwait(false)).Select(t => t.GroupNum).Distinct();
if (havPubSaGroupNums.Any() == true)
var _first = _codeRepository.FirstOrDefault(p => p.Project == "组验证开启" && p.Value == "是");
if (_first != null)
{
foreach (var item in havPubSaGroupNums)
var havPubSaGroupNums = (await _pubSaDetailRepository.GetListAsync(t => pubSaGroupNums.Contains(t.GroupNum)).ConfigureAwait(false)).Select(t => t.GroupNum).Distinct();
if (havPubSaGroupNums.Any() == true)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty));
foreach (var item in havPubSaGroupNums)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty));
}
}
}

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

@ -94,16 +94,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
PartCode = d.PartCode,
Qty = d.Qty
},
b=d
b = d
};
var bbac_can_list= query.Select(p => p.a).ToList();
var bbac_not_list= query.Select(p => p.b).ToList();
if(bbac_can_list.Count>0)
var bbac_can_list = query.Select(p => p.a).ToList();
var bbac_not_list = query.Select(p => p.b).ToList();
if (bbac_can_list.Count > 0)
{
notlist.AddRange(bbac_not_list);
var t1 = bbac_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();
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)
@ -133,39 +133,33 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
itm2.SetGroupNum(billNum);
billDetails.Add(itm2);
}
var test = details.Sum(p => p.Price * p.Qty);
var count = details.Count;
details = new List<BBAC_CAN_SA_DETAIL>();
sum = itm1.Qty * itm1.Price;
}
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 _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 bbac_sa1 = new BBAC_CAN_SA();
@ -183,7 +177,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
detail.SetBillNum(billNum1);
detail.SetGroupNum(billNum1);
billDetails.Add(detail);
}
}
}
}
if (part_group_small.Count > 0)
@ -238,28 +232,28 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == "1046"
select new
{
a =new BBAC_CAN_SA_DETAIL()
{
ContractDocID = d.ContractDocID,
IsMaiDan = d.IsMaiDan,
Version = d.Version,
KeyCode = d.KeyCode,
Site = "1046",
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
a = new BBAC_CAN_SA_DETAIL()
{
ContractDocID = d.ContractDocID,
IsMaiDan = d.IsMaiDan,
Version = d.Version,
KeyCode = d.KeyCode,
Site = "1046",
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 bbac_can_list = query.Select(p => p.a).ToList();
var bbac_not_list = query.Select(p => p.b).ToList();
@ -268,7 +262,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
notlist.AddRange(bbac_not_list);
var t1 = bbac_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();
var part_group_small = t1.Where(p => p.Amt < 10000000).ToList();
if (part_group_big.Count > 0)
{
foreach (var itm in part_group_big)
@ -279,7 +273,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
foreach (var itm1 in ls)
{
sum += (itm1.Qty * itm1.Price);
if (sum > 10000000)
{
var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
@ -299,14 +292,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
itm2.SetGroupNum(billNum);
billDetails.Add(itm2);
}
var test = details.Sum(p => p.Price * p.Qty);
details = new List<BBAC_CAN_SA_DETAIL>();
sum = itm1.Qty * itm1.Price;
}
var _detailEntity = new BBAC_CAN_SA_DETAIL(
guid: GuidGenerator.Create(),
keyCode: itm1.KeyCode,
@ -329,7 +317,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
);
_detailEntity.RealPartCode = itm1.RealPartCode;
details.Add(_detailEntity);
}
var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N");
var bbac_sa1 = new BBAC_CAN_SA();
@ -353,7 +340,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
if (part_group_small.Count > 0)
{
var partlist = part_group_small.Select(p => p.LU).ToList();
var ls=bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList();
var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList();
var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
var bbac_sa = new BBAC_CAN_SA();
bbac_sa.SetId(Guid.NewGuid());
@ -404,7 +391,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
_dbcontext.BulkInsert(billDetails);//插入可结主表
_dbcontext.BulkInsert(billList);//插入可结明细
}
var ls = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "BBAC_NOT" && p.Value=="True").ToList();
var ls = _dbcontext.Set<CodeSetting>().Where(p => p.Project == "BBAC_NOT" && p.Value == "True").ToList();
if (ls.Any())
{
_dbcontext.BulkDelete(ls);
@ -447,7 +434,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
}
}
}
if (businesstype == "JisHBPO" || businesstype== "MaiDanJianHBPO")
if (businesstype == "JisHBPO" || businesstype == "MaiDanJianHBPO")
{
List<HBPO_NOT_SA_DETAIL> notlist = new List<HBPO_NOT_SA_DETAIL>();
List<HBPO_CAN_SA> billList = new List<HBPO_CAN_SA>();
@ -509,7 +496,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
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 = hbpo_can_list.Where(p => p.LU == itm.LU).ToList();
@ -551,10 +537,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
site: itm1.Site,
qty: itm1.Qty,
price: itm1.Price,
businessType: itm1.BusinessType,
businessType: itm1.BusinessType,
settleDate: itm1.SettleDate,
groupNum: itm1.GroupNum,
invGroupNum: string.Empty,
invGroupNum: string.Empty,
invbillnum: string.Empty,
partcode: itm1.PartCode
);
@ -620,7 +606,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
}
}
}
}
}
bool issucess = true;
using (var transaction = _dbcontext.Database.BeginTransaction())
{
@ -641,7 +627,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
}
catch (Exception)
{
issucess = false;// 回滚事务
transaction.Rollback();
}

Loading…
Cancel
Save