增加日志

This commit is contained in:
18942506660
2023-12-04 10:02:25 +08:00
parent cf2912173e
commit f5034b3891
4 changed files with 20 additions and 7 deletions

View File

@@ -1,5 +1,7 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -38,12 +40,13 @@ namespace WMS.Web.Domain.Services
private readonly IBoxInventoryService _boxInventoryService;
private readonly IInventoryInOutDetailsService _inventoryInOutDetailsService;
private readonly IBoxInventoryRepositories _boxInventoryRepositories;
private readonly ILogger<OutStockService> _logger;
public OutStockService(IMapper mapper, ILoginService loginService,
IBasicsRepositories transactionRepositories,
IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories,
IOutStockTaskService outStockTaskService, IErpService erpService, ISerialNumberService serialNumberService,
IBoxInventoryService boxInventoryService, IInventoryInOutDetailsService inventoryInOutDetailsService,
IBoxInventoryRepositories boxInventoryRepositories)
IBoxInventoryRepositories boxInventoryRepositories, ILogger<OutStockService> logger)
{
_mapper = mapper;
_loginService = loginService;
@@ -56,6 +59,7 @@ namespace WMS.Web.Domain.Services
_boxInventoryService = boxInventoryService;
_inventoryInOutDetailsService = inventoryInOutDetailsService;
_boxInventoryRepositories = boxInventoryRepositories;
_logger = logger;
}
/// <summary>
/// 出库单
@@ -65,6 +69,7 @@ namespace WMS.Web.Domain.Services
/// <returns></returns>
public async Task<Result> Save(SaveOutStockRequest dto, LoginInDto loginInfo)
{
_logger.LogInformation($"出库:{JsonConvert.SerializeObject(dto)} 操作人:{loginInfo.UserInfo.StaffId}");
var outStockTask = await _outStockTaskRepositories.Get(dto.TaskId);
if (outStockTask.Status == OutStockStatus.Already)
return Result.ReFailure(ResultCodes.OutStockTaskAlready);
@@ -121,7 +126,7 @@ namespace WMS.Web.Domain.Services
//循环添加erp同步明细
foreach (var c in res.Data)
{
var tErpDetail = tDetail.ErpDetails.FirstOrDefault(f => f.Erp_DetailId==c.erpDetailId);
var tErpDetail = tDetail.ErpDetails.FirstOrDefault(f => f.Erp_DetailId == c.erpDetailId);
var oErpDetail = _mapper.Map<OutStockErpDetails>(tErpDetail);
oErpDetail.Qty = c.qty;
outd.ErpDetails.Add(oErpDetail);
@@ -178,10 +183,10 @@ namespace WMS.Web.Domain.Services
var list = await _outStockRepositories.GetEntityList(dto.Ids);
foreach (var entity in list)
{
if (entity.SuccessSync!=SyncStatus.Fail) continue;
List<string> failList =entity.Details.SelectMany(s=>s.ErpDetails)
.Where(w=> w.SuccessSync== SyncStatus.Fail).GroupBy(g=>g.SourceBillNo)
.Select(s=>s.Key).ToList();//同步失败的来源单号
if (entity.SuccessSync != SyncStatus.Fail) continue;
List<string> failList = entity.Details.SelectMany(s => s.ErpDetails)
.Where(w => w.SuccessSync == SyncStatus.Fail).GroupBy(g => g.SourceBillNo)
.Select(s => s.Key).ToList();//同步失败的来源单号
//找到单据里需要同步的单据
var sourcNos = entity.Details.SelectMany(s => s.ErpDetails).GroupBy(s => s.SourceBillNo).Select(s => s.Key);
foreach (var s in failList)