金蝶同步wms
This commit is contained in:
104
src/WMS.Web.Domain/Services/OutStockTaskService.cs
Normal file
104
src/WMS.Web.Domain/Services/OutStockTaskService.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
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.Dto.Erp.Purchase;
|
||||
using WMS.Web.Core.Dto.Login;
|
||||
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;
|
||||
using WMS.Web.Domain.Values;
|
||||
|
||||
namespace WMS.Web.Domain.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 出库任务
|
||||
/// </summary>
|
||||
public class OutStockTaskService: IOutStockTaskService
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IErpService _erpService;
|
||||
private readonly ILoginService _loginService;
|
||||
private readonly ITransactionRepositories _transactionRepositories;
|
||||
private readonly IOutStockRepositories _outStockRepositories;
|
||||
private readonly IOutStockTaskRepositories _outStockTaskRepositories;
|
||||
public OutStockTaskService(IMapper mapper, IErpService erpService, ILoginService loginService,
|
||||
ITransactionRepositories transactionRepositories,
|
||||
IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_erpService = erpService;
|
||||
_loginService = loginService;
|
||||
_transactionRepositories = transactionRepositories;
|
||||
_outStockRepositories = outStockRepositories;
|
||||
_outStockTaskRepositories = outStockTaskRepositories;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 出库任务作废
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> Repeal(OperateRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
var list = await _outStockTaskRepositories.GetEntityList(dto.Ids);
|
||||
foreach (var entity in list)
|
||||
{
|
||||
//作废
|
||||
entity.Repeal(loginInfo.UserInfo.StaffId);
|
||||
}
|
||||
var isSuccess = await _outStockTaskRepositories.EditEntityList(list, true);
|
||||
if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 出库任务合并
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> merge(OperateRequest dto, LoginInDto loginInfo)
|
||||
{
|
||||
var list = await _outStockTaskRepositories.GetEntityList(dto.Ids);
|
||||
// 2:符合合并数据逻辑:出库状态为”待拣货”+出库类型为:销售出库+发货组织一致+收货客户一致+发货仓库一致
|
||||
OutStockTask entity = new OutStockTask();
|
||||
var res = entity.Merge(list, loginInfo.UserInfo.StaffId);
|
||||
if (!res.IsSuccess) return res;
|
||||
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool isRollback = false;
|
||||
bool isSuccess = true;
|
||||
entity = await _outStockTaskRepositories.Add(entity, false);
|
||||
if (entity == null) isRollback = true;
|
||||
isSuccess = await _outStockTaskRepositories.DeleteEntityList(list.Select(s => s.Id).ToList(), false);
|
||||
if (isSuccess == false) isRollback = true;
|
||||
//提交事务
|
||||
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
/// <summary>
|
||||
/// 发货通知单同步数据
|
||||
/// </summary>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result> SsynDeliveryNoticeOutStock(bool isTransaction)
|
||||
{
|
||||
//1.获取金蝶数据:采购订单数据
|
||||
var erp_result = await _erpService.BillQueryForPurchaseInStock();
|
||||
if (!erp_result.IsSuccess)
|
||||
return Result.ReFailure(erp_result.Message, erp_result.Status);
|
||||
var erp_list = erp_result.Data;
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user