箱信息同步

This commit is contained in:
18942506660
2023-11-08 15:10:35 +08:00
parent 04e1074acd
commit 0a3a37f316
5 changed files with 67 additions and 3 deletions

View File

@@ -1,9 +1,12 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto;
using WMS.Web.Core.Internal.Results;
using WMS.Web.Domain.Entitys;
using WMS.Web.Domain.Infrastructure;
using WMS.Web.Domain.IService;
using WMS.Web.Domain.IService.Public;
@@ -13,7 +16,7 @@ namespace WMS.Web.Domain.Services
/// <summary>
/// 箱服务信息
/// </summary>
public class BoxService: IBoxService
public class BoxService : IBoxService
{
private readonly IMapper _mapper;
private readonly ILoginService _loginService;
@@ -31,9 +34,23 @@ namespace WMS.Web.Domain.Services
_opsService = opsService;
}
public Task<Result> Sync()
public async Task<Result> Sync()
{
throw new NotImplementedException();
OpsBoxRequest request = new OpsBoxRequest(DateTime.Now.AddYears(-1), DateTime.Now);
var list = await _opsService.GetBox(request);
var nos = list.Select(s => s.BoxBillNo).ToList();
var old_nos=await _boxRepositories.GetByNos(nos);
foreach(var s in old_nos)
{
//数据库里已经存在箱信息 移除
var box = list.FirstOrDefault(f => f.BoxBillNo.Equals(s));
list.Remove(box);
}
var boxs = _mapper.Map<List<Box>>(list);
//批量添加
await _boxRepositories.AddRange(boxs,true);
//需要添加序列号记录表
return Result.ReSuccess();
}
}
}