|
|
@ -15,6 +15,7 @@ using Win.Sfs.BaseData.ImportExcelCommon; |
|
|
|
using Win.Sfs.SettleAccount.CommonManagers; |
|
|
|
using Win.Sfs.SettleAccount.Constant; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
|
|
|
using Win.Sfs.SettleAccount.Entities.Prices; |
|
|
|
using Win.Sfs.SettleAccount.ExcelImporter; |
|
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
|
|
|
|
@ -37,11 +38,32 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
/// </summary>
|
|
|
|
private readonly INormalEfCoreRepository<PUB_SA_DETAIL, Guid> _pubSaDetailRepository; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// PUB可结算仓储
|
|
|
|
/// </summary>
|
|
|
|
private readonly INormalEfCoreRepository<PUB_CAN_SA, Guid> _pubCanSaRepository; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// PUB可结算明细仓储
|
|
|
|
/// </summary>
|
|
|
|
private readonly INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> _pubCanSaDetailRepository; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// PUB不可结算明细仓储
|
|
|
|
/// </summary>
|
|
|
|
private readonly INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> _pubNotSaDetailRepository; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 销售价格仓储
|
|
|
|
/// </summary>
|
|
|
|
private readonly INormalEfCoreRepository<PriceList, Guid> _priceListRepository; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 构造
|
|
|
|
/// </summary>
|
|
|
|
public PUB_SA_SERVICE(INormalEfCoreRepository<PUB_SA, Guid> repository, |
|
|
|
INormalEfCoreRepository<PUB_SA_DETAIL, Guid> pubSaDetailRepository, |
|
|
|
INormalEfCoreRepository<PriceList, Guid> priceListRepository, |
|
|
|
IDistributedCache<PUB_SA> cache, |
|
|
|
IExcelImportAppService excelImportService, |
|
|
|
ISnowflakeIdGenerator snowflakeIdGenerator, |
|
|
@ -50,6 +72,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
{ |
|
|
|
_repository = repository; |
|
|
|
_pubSaDetailRepository = pubSaDetailRepository; |
|
|
|
_priceListRepository = priceListRepository; |
|
|
|
} |
|
|
|
|
|
|
|
#region 直供件
|
|
|
@ -67,6 +90,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
var result = await _exportImporter.UploadExcelImport<ZGJ_PUB_SA_DETAIL_IMPORT_DTO>(files, _excelImportService); |
|
|
|
var _ls = ObjectMapper.Map<List<ZGJ_PUB_SA_DETAIL_IMPORT_DTO>, List<PUB_SA_DETAIL>>(result); |
|
|
|
|
|
|
|
//销售价格
|
|
|
|
var priceListEntitys = await _priceListRepository.GetAllAsync(); |
|
|
|
|
|
|
|
var billNum = GuidGenerator.Create().ToString(); |
|
|
|
var pubSa = new PUB_SA() |
|
|
|
{ |
|
|
@ -74,20 +100,41 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
State = "1" |
|
|
|
}; |
|
|
|
|
|
|
|
_ls.ForEach(s => |
|
|
|
_ls.ForEach(s => |
|
|
|
{ |
|
|
|
string[] luArr = s.LU.Split(" "); |
|
|
|
var lus = luArr.Reverse(); |
|
|
|
var result = lus.Aggregate(" ", (current, index) => current + index); |
|
|
|
|
|
|
|
//s.LU = s.LU.Replace(" ", "").Replace(" ", " ");
|
|
|
|
if (s.LU != null) |
|
|
|
{ |
|
|
|
List<string> luList = s.LU.Split(" ").ToList(); |
|
|
|
s.LU = luList[0].Replace(" ", ""); |
|
|
|
if (luList.Count > 1) |
|
|
|
{ |
|
|
|
luList.RemoveAt(0); |
|
|
|
luList.Reverse(); |
|
|
|
var luAssemble = luList.Select(t => t.Replace(" ", "")); |
|
|
|
s.LU += luAssemble.Aggregate(" ", (current, index) => current + index); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
s.LU = s.LU; |
|
|
|
s.BillNum = billNum; |
|
|
|
s.Site = "直供件"; |
|
|
|
s.KeyCode = s.LU + s.PN; |
|
|
|
|
|
|
|
var priceListEntity = priceListEntitys.Find(t => t.LU == s.LU && s.SettleDate > t.BeginTime && s.SettleDate < t.EndTime); |
|
|
|
s.Price = priceListEntity?.Price ?? 0; |
|
|
|
}); |
|
|
|
|
|
|
|
//await _repository.InsertAsync(pubSa);
|
|
|
|
//await _pubSaDetailRepository.InsertManyAsync(_ls);
|
|
|
|
//可结算
|
|
|
|
var pubCanSa = new List<string>(); |
|
|
|
//不可结算
|
|
|
|
var pubNotCanSa = new List<string>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _repository.InsertAsync(pubSa); |
|
|
|
await _pubSaDetailRepository.InsertManyAsync(_ls); |
|
|
|
return ApplicationConsts.SuccessStr; |
|
|
|
} |
|
|
|
|
|
|
|