金蝶即时库存

This commit is contained in:
18942506660
2024-10-17 17:39:29 +08:00
parent ea8ac33a56
commit 46817280e7
9 changed files with 162 additions and 62 deletions

View File

@@ -45,9 +45,53 @@ namespace WMS.Web.Domain.Services
}
public Task<Result> Erp()
public async Task<Result> Erp()
{
throw new NotImplementedException();
//获取单点配置
var r = await _basicsRepositories.GetUcStockByHeadOfficeAsync("", 1);
var codes = r.Where(w =>
w.ManagementSystem == 1 || w.ManagementSystem == 4).Select(s => (s.Code, s.ErpOrgCode)).ToList();
var res = await _erpService.BillQueryForInventory(codes);
if (!res.IsSuccess) return res;
List<ProductInventory> inventoryList = new List<ProductInventory>();
foreach (var item in res.Data)
{
var entity = new ProductInventory()
{
Type = ProductInventoryType.JinDie,
MaterialNumber = item.MaterialNumber,
Customer = item.Erp_SubStockName,
OrgCode = item.OrgCode,
StockCode = item.StockCode,
Qty = item.Qty,
BeforeQty = item.BeforeQty
};
inventoryList.Add(entity);
}
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
Result res_Rollback = Result.ReSuccess();
bool isSuccess = true;
//修改库存
//先删除之前的再添加
if (res_Rollback.IsSuccess)
{
isSuccess = await _repositories.Delete(ProductInventoryType.JinDie, false);
if (isSuccess == false) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError);
}
if (res_Rollback.IsSuccess)
{
isSuccess = await _repositories.AddRange(inventoryList, false);
if (isSuccess == false) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError);
}
//提交事务
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction);
if (!res_Rollback.IsSuccess) return res_Rollback;
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
return Result.ReSuccess();
}
public Task<Result> JuShuiTan()
@@ -95,7 +139,7 @@ namespace WMS.Web.Domain.Services
var stock = r.FirstOrDefault(f => f.WarehouseCodeOfLingxing.Equals(l_stock.Name));
if (stock == null) continue;
//店铺
var seller = sellerList.Data.FirstOrDefault(f=>f.Id== item.Key.SellerId);
var seller = sellerList.Data.FirstOrDefault(f => f.Id == item.Key.SellerId);
if (seller == null) continue;
var pList = resInventory.Data.Where(w => w.SKU == item.Key.SKU
&& w.StockId == item.Key.StockId && w.SellerId == item.Key.SellerId).ToList();