盘盈盘亏同步
This commit is contained in:
@@ -53,9 +53,9 @@ namespace WMS.Web.Domain.Services
|
||||
/// <returns></returns>
|
||||
public async Task<Result> Save(List<SaveTakeStockRequest> dto, LoginInDto loginInfo)
|
||||
{
|
||||
TakeStock entity = new TakeStock();
|
||||
//entity.Details = _mapper.Map<List<TakeStockDetails>>(dto);
|
||||
entity.Create(loginInfo.UserInfo.StaffId);
|
||||
List<TakeStock> list = _mapper.Map<List<TakeStock>>(dto);
|
||||
foreach (var entity in list)
|
||||
entity.Create(loginInfo.UserInfo.StaffId);
|
||||
|
||||
//需要填写序列号
|
||||
//需要修改库存
|
||||
@@ -63,14 +63,18 @@ namespace WMS.Web.Domain.Services
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool isRollback = false;
|
||||
bool isSuccess = true;
|
||||
entity = await _takeStockRepositories.Add(entity, false);
|
||||
if (entity == null) isRollback = true;
|
||||
isSuccess = await _takeStockRepositories.AddRange(list, false);
|
||||
if (!isSuccess) isRollback = true;
|
||||
|
||||
//提交事务
|
||||
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
//同步金蝶
|
||||
foreach (var entity in list)
|
||||
await Loss_Profit(entity);
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
@@ -79,12 +83,17 @@ namespace WMS.Web.Domain.Services
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public Task<Result> Sync(OperateRequest dto)
|
||||
public async Task<Result> Sync(OperateRequest dto)
|
||||
{
|
||||
return Task.FromResult(Result.ReSuccess());
|
||||
var list = await _takeStockRepositories.GetEntityList(dto.Ids);
|
||||
list = list.Where(w => w.SuccessSync == false).ToList();
|
||||
foreach (var entity in list)
|
||||
await Loss_Profit(entity);
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 盘盈
|
||||
/// 作废
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
@@ -113,7 +122,7 @@ namespace WMS.Web.Domain.Services
|
||||
AfterQty = entity.AfterQty,
|
||||
FinalQty = entity.FinalQty,
|
||||
Fnote = ""
|
||||
}) ;
|
||||
});
|
||||
ErpTakeStockSaveDto dto = new ErpTakeStockSaveDto()
|
||||
{
|
||||
BillNo = entity.BillNo,
|
||||
@@ -124,14 +133,17 @@ namespace WMS.Web.Domain.Services
|
||||
};
|
||||
#endregion
|
||||
|
||||
return await _erpService.Sync<ErpTakeStockSaveDto>(dto, FormIdParam.STK_StockCountGain.ToString());
|
||||
var resSync = await _erpService.Sync<ErpTakeStockSaveDto>(dto, FormIdParam.STK_StockCountGain.ToString());
|
||||
entity.Sync(resSync.IsSuccess, resSync.Message);
|
||||
await _takeStockRepositories.Edit(entity, true);
|
||||
return res;
|
||||
}
|
||||
/// <summary>
|
||||
/// 盘亏
|
||||
/// 盘盈盘亏同步金蝶
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> Loss(TakeStock entity)
|
||||
public async Task<Result> Loss_Profit(TakeStock entity)
|
||||
{
|
||||
//获取金蝶仓库仓位编码
|
||||
var stockCode = _singleDataService.GetSingleDataCode(SingleAction.Stocks, _loginRepositories.CompanyId, entity.StockId);
|
||||
@@ -156,18 +168,22 @@ namespace WMS.Web.Domain.Services
|
||||
AfterQty = entity.AfterQty,
|
||||
FinalQty = entity.FinalQty,
|
||||
Fnote = ""
|
||||
}) ;
|
||||
});
|
||||
ErpTakeStockSaveDto dto = new ErpTakeStockSaveDto()
|
||||
{
|
||||
BillNo = entity.BillNo,
|
||||
StockOrgId = stock.OrgId.ToString(),
|
||||
Type = "PK01_SYS",
|
||||
Type = entity.ResultType == TakeStockType.Loss ? "PK01_SYS" : "PY01_SYS",
|
||||
Date = entity.Date,
|
||||
Details = detils
|
||||
};
|
||||
#endregion
|
||||
|
||||
return await _erpService.Sync<ErpTakeStockSaveDto>(dto, FormIdParam.STK_StockCountLoss.ToString());
|
||||
//判断盘盈盘亏
|
||||
string formId = entity.ResultType == TakeStockType.Loss ? FormIdParam.STK_StockCountLoss.ToString() : FormIdParam.STK_StockCountGain.ToString();
|
||||
var resSync = await _erpService.Sync<ErpTakeStockSaveDto>(dto, formId);
|
||||
entity.Sync(resSync.IsSuccess, resSync.Message);
|
||||
await _takeStockRepositories.Edit(entity, true);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user