非采购上架接口

This commit is contained in:
tongfei
2023-11-09 14:07:49 +08:00
22 changed files with 507 additions and 150 deletions

View File

@@ -73,10 +73,12 @@ namespace WMS.Web.Domain.Entitys
/// 创建
/// </summary>
/// <param name="creatorId"></param>
public void Create(int creatorId,int taskId, OutStockType type)
public void Create(int creatorId, OutStockTask task)
{
this.TaskId = taskId;
this.Type = type;
this.TaskId = task.Id;
this.Type = task.Type;
this.DeliveryOrgId = task.DeliveryOrgId;
this.ReceiptCustomerId = task.ReceiptCustomerId;
this.CreatorId = creatorId;
this.CreateTime = DateTime.Now;
}

View File

@@ -17,7 +17,7 @@ namespace WMS.Web.Domain.IService
public interface IChangeMoveBoxService
{
//改箱保存
Task<Result> ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo);
Task<Result> ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo, bool isTransaction=true);
//移箱保存
Task<Result> MoveBoxSave(SaveMoveBoxRecordRequest dto, LoginInDto loginInfo);

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using WMS.Web.Core.Dto.Erp;
using WMS.Web.Core.Dto.Erp.Customer;
using WMS.Web.Core.Dto.Erp.Org;
using WMS.Web.Core.Dto.Erp.Supplier;
@@ -58,7 +59,14 @@ namespace WMS.Web.Domain.IService.Public
/// <param name="supplierId"></param>
/// <returns></returns>
string GetSupplierName(List<ErpSupplierDto> erpSuppliers, int supplierId);
/// <summary>
/// 获取客户名称
/// </summary>
/// <param name="erpCustomers"></param>
/// <param name="customerId"></param>
/// <returns></returns>
string GetCustomerName(List<ErpCustomerDto> erpCustomers, int customerId);
/// <summary>
/// 获取仓库名称
/// </summary>

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto.Erp;
using WMS.Web.Core.Dto.Erp.Customer;
using WMS.Web.Core.Dto.Erp.Org;
using WMS.Web.Core.Dto.Erp.OutStock;
using WMS.Web.Core.Dto.Erp.Purchase;
@@ -66,7 +67,11 @@ namespace WMS.Web.Domain.IService.Public
/// </summary>
/// <returns></returns>
Task<ResultList<ErpSupplierDto>> BillQueryForSupplier();
/// <summary>
/// 客户
/// </summary>
/// <returns></returns>
Task<ResultList<ErpCustomerDto>> BillQueryForCustomer();
/// <summary>
/// 获取仓库信息
/// </summary>

View File

@@ -19,7 +19,7 @@ namespace WMS.Web.Domain.IService.Public
/// </summary>
/// <param name="isTransaction"></param>
/// <returns></returns>
Task<Result> SsynDeliveryNoticeOutStock(bool isTransaction,List<string> sourceBillNos = null);
Task<Result> BillQueryForDeliveryNoticeOutStock(bool isTransaction,List<string> sourceBillNos = null);
/// <summary>
/// erp:单据查询-直接调拨出库
/// </summary>
@@ -44,5 +44,11 @@ namespace WMS.Web.Domain.IService.Public
Task<Result> Repeal(OperateRequest dto, LoginInDto loginInfo);
//出库任务作废
Task<Result> merge(OperateRequest dto, LoginInDto loginInfo);
/// <summary>
/// 同步金蝶数据 不传源订单号则更新所有
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
Task<Result> Ssyn(List<string> sourceBillNos = null);
}
}

View File

@@ -14,7 +14,7 @@ using WMS.Web.Domain.Options;
namespace WMS.Web.Domain.QuartzJob
{
public class OutStockOrderQuartzJob : IJob
public class OutStockOrderQuartzJob : IJob
{
private readonly ILogger<OutStockOrderQuartzJob> _logger;
private readonly IServiceScopeFactory _serviceScopeFactory;
@@ -44,28 +44,11 @@ namespace WMS.Web.Domain.QuartzJob
{
try
{
//1.事务
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
bool isRollback = false;
bool isTransaction = false;
//2.记录:开始时间
var begindatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
_logger.LogInformation($"出库单-同步金蝶入库单数据:执行开始时间->{begindatetime}");
//3.同步数据
var result = await _outStockTaskService.SsynDeliveryNoticeOutStock(isTransaction);
if (!result.IsSuccess) isRollback = true;
result = await _outStockTaskService.BillQueryForTransferDirectOutStock(isTransaction);
if (!result.IsSuccess) isRollback = true;
result = await _outStockTaskService.BillQueryForTransferOutOutStock(isTransaction);
if (!result.IsSuccess) isRollback = true;
result = await _outStockTaskService.BillQueryForMisDeliveryOutStock(isTransaction);
if (!result.IsSuccess) isRollback = true;
result = await _outStockTaskService.BillQueryForAssembledAppOutStock(isTransaction);
if (!result.IsSuccess) isRollback = true;
//4.提交事务
var isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
var result = await _outStockTaskService.Ssyn(null);
//5.记录:结束时间
var enddatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
_logger.LogInformation($"出库单-同步金蝶入库单数据:执行结束时间->{begindatetime}");

View File

@@ -43,23 +43,29 @@ namespace WMS.Web.Domain.Services
/// <param name="dto"></param>
/// <param name="loginInfo"></param>
/// <returns></returns>
public async Task<Result> ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo)
public async Task<Result> ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo, bool isTransaction = false)
{
List<Box> boxList = new List<Box>();
//原箱有可能没有
var srcBox = await _boxRepositories.Get(dto.SrcBoxId);
var destBox = await _boxRepositories.Get(dto.DestBoxId);
if (srcBox == null) return Result.ReFailure(ResultCodes.BoxNoData);
//if (srcBox == null) return Result.ReFailure(ResultCodes.BoxNoData);
if (destBox == null) return Result.ReFailure(ResultCodes.BoxNoData);
var l = dto.Details.Select(s => (s.MaterialId, s.Qty, s.SerialNumbers)).ToList();
//原箱移出
var res = srcBox.Out(l);
if (!res.IsSuccess) return res;
Result res;
if (srcBox != null)
{
res = srcBox.Out(l);
if (!res.IsSuccess) return res;
}
//目标箱移入
res = destBox.In(l);
if (!res.IsSuccess) return res;
boxList.Add(srcBox);
boxList.Add(destBox);
if (srcBox != null)
boxList.Add(srcBox);
if (destBox != null)
boxList.Add(destBox);
//var entity = _mapper.Map<ChangeBoxRecord>(dto);\
List<ChangeBoxRecord> list = new List<ChangeBoxRecord>();
@@ -72,8 +78,9 @@ namespace WMS.Web.Domain.Services
//需要填写序列号
//需要修改库存
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
IDbContextTransaction _transaction = null;
if (isTransaction)
_transaction = _transactionRepositories.GetTransaction();
bool isRollback = false;
bool isSuccess = true;
isSuccess = await _changeBoxRecordRepositories.AddRange(list, false);
@@ -81,12 +88,15 @@ namespace WMS.Web.Domain.Services
isSuccess = await _boxRepositories.EditEntityList(boxList, false);
if (!isSuccess) isRollback = true;
//提交事务
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
if (isTransaction)
{
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
}
return Result.ReSuccess();
}

View File

@@ -28,15 +28,17 @@ namespace WMS.Web.Domain.Services
public readonly IBasicsRepositories _transactionRepositories;
private readonly IOutStockRepositories _outStockRepositories;
private readonly IOutStockTaskRepositories _outStockTaskRepositories;
private readonly IOutStockTaskService _outStockTaskService;
public OutStockService(IMapper mapper, ILoginService loginService,
IBasicsRepositories transactionRepositories,
IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories)
IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories, IOutStockTaskService outStockTaskService)
{
_mapper = mapper;
_loginService = loginService;
_transactionRepositories = transactionRepositories;
_outStockRepositories = outStockRepositories;
_outStockTaskRepositories = outStockTaskRepositories;
_outStockTaskService = outStockTaskService;
}
/// <summary>
/// 出库单
@@ -48,15 +50,20 @@ namespace WMS.Web.Domain.Services
{
var outStockTask = await _outStockTaskRepositories.Get(dto.TaskId);
//OutStock entity = await _outStockRepositories.GetByTaskId(dto.TaskId);
//同步该订单最新数据到wms系统
List<string> nos = new List<string>();
nos.Add(outStockTask.SourceBillNo);
var res = await _outStockTaskService.Ssyn(nos);
if (!res.IsSuccess) return Result.ReSuccess();
OutStock entity = new OutStock();
entity.Create(loginInfo.UserInfo.StaffId, outStockTask.Id, outStockTask.Type);
entity.Create(loginInfo.UserInfo.StaffId, outStockTask);
foreach (var d in dto.Details)
{
//任务单明细
var tDetail = outStockTask.Details.FirstOrDefault(f => f.MaterialId == d.MaterialId);
if (tDetail == null) continue;
var res = outStockTask.OutStock(d.MaterialId, d.Qty);
res = outStockTask.OutStock(d.MaterialId, d.Qty);
if (!res.IsSuccess) return res;
var outd = _mapper.Map<OutStockDetails>(tDetail);

View File

@@ -158,7 +158,7 @@ namespace WMS.Web.Domain.Services
/// </summary>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<Result> SsynDeliveryNoticeOutStock(bool isTransaction, List<string> sourceBillNos = null)
public async Task<Result> BillQueryForDeliveryNoticeOutStock(bool isTransaction, List<string> sourceBillNos = null)
{
//1.获取金蝶数据:采购订单数据
var erp_result = await _erpService.BillQueryForDeliveryNoticeOutStock(sourceBillNos);
@@ -204,7 +204,7 @@ namespace WMS.Web.Domain.Services
public async Task<Result> BillQueryForAssembledAppOutStock(bool isTransaction, List<string> sourceBillNos = null)
{
List<ErpDeliveryNoticeOutStockResultDto> list = new List<ErpDeliveryNoticeOutStockResultDto>();
var erp_result = await _erpService.BillQueryForAssembledAppOutStock_Dassembly(sourceBillNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status);
@@ -231,5 +231,99 @@ namespace WMS.Web.Domain.Services
return await this.SsynDate(erp_result.Data.ToList(), isTransaction);
}
/// <summary>
/// 同步金蝶数据 不传源订单号则更新所有
/// </summary>
/// <param name="sourceBillNos"></param>
/// <returns></returns>
public async Task<Result> Ssyn(List<string> sourceBillNos = null)
{
//1.事务
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
bool isRollback = false;
bool isSuccess = true;
Result result;
//定时任务更新
if (sourceBillNos == null)
{
//更新时间范围内所有
result= await BillQueryForDeliveryNoticeOutStock(false, null);
if (!result.IsSuccess) isRollback = true;
result = await BillQueryForTransferDirectOutStock(false, null);
if (!result.IsSuccess) isRollback = true;
result = await BillQueryForTransferOutOutStock(false, null);
if (!result.IsSuccess) isRollback = true;
result = await BillQueryForAssembledAppOutStock(false, null);
if (!result.IsSuccess) isRollback = true;
result = await BillQueryForMisDeliveryOutStock(false, null);
if (!result.IsSuccess) isRollback = true;
//同步成功后 更新定时开始时间
if (!isRollback)
{
}
//4.提交事务
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
return Result.ReSuccess();
}
//根据指定单号更新
List<string> DeliveryNotice_Nos = new List<string>();
List<string> TransferDirect_Nos = new List<string>();
List<string> TransferOut_Nos = new List<string>();
List<string> AssembledApp_Nos = new List<string>();
List<string> MisDeliveryOut_Nos = new List<string>();
var taskList = await _outStockTaskRepositories.GetListBySourceBillNo(sourceBillNos);
foreach (var entity in taskList)
{
if (entity.Type == OutStockType.Sal)
DeliveryNotice_Nos.Add(entity.SourceBillNo);
else if (entity.Type == OutStockType.Stkdirecttransfers)
TransferDirect_Nos.Add(entity.SourceBillNo);
else if (entity.Type == OutStockType.StktransferInst)
TransferOut_Nos.Add(entity.SourceBillNo);
else if (entity.Type == OutStockType.Assembled)
AssembledApp_Nos.Add(entity.SourceBillNo);
else if (entity.Type == OutStockType.Miscellaneous)
MisDeliveryOut_Nos.Add(entity.SourceBillNo);
}
if (DeliveryNotice_Nos.Count() > 0)
{
result= await BillQueryForDeliveryNoticeOutStock(false, DeliveryNotice_Nos);
if (!result.IsSuccess) isRollback = true;
}
if (TransferDirect_Nos.Count() > 0)
{
result = await BillQueryForDeliveryNoticeOutStock(false, TransferDirect_Nos);
if (!result.IsSuccess) isRollback = true;
}
if (TransferOut_Nos.Count() > 0)
{
result = await BillQueryForDeliveryNoticeOutStock(false, TransferOut_Nos);
if (!result.IsSuccess) isRollback = true;
}
if (AssembledApp_Nos.Count() > 0)
{
result = await BillQueryForDeliveryNoticeOutStock(false, AssembledApp_Nos);
if (!result.IsSuccess) isRollback = true;
}
if (MisDeliveryOut_Nos.Count() > 0)
{
result = await BillQueryForDeliveryNoticeOutStock(false, MisDeliveryOut_Nos);
if (!result.IsSuccess) isRollback = true;
}
//4.提交事务
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
return Result.ReSuccess();
}
}
}

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using WMS.Web.Core.Dto.Erp;
using WMS.Web.Core.Dto.Erp.Customer;
using WMS.Web.Core.Dto.Erp.Org;
using WMS.Web.Core.Dto.Erp.Supplier;
using WMS.Web.Domain.Infrastructure;
@@ -100,6 +101,17 @@ namespace WMS.Web.Domain.Services.Public
var supplier = erpSuppliers.Where(x => x.Id == supplierId).FirstOrDefault();
return supplier == null ? "" : supplier.Name;
}
/// <summary>
/// 获取客户名称
/// </summary>
/// <param name="erpCustomers"></param>
/// <param name="customerId"></param>
/// <returns></returns>
public string GetCustomerName(List<ErpCustomerDto> erpCustomers, int customerId)
{
var supplier = erpCustomers.Where(x => x.Id == customerId).FirstOrDefault();
return supplier == null ? "" : supplier.Name;
}
/// <summary>
/// 获取仓库名称
@@ -136,5 +148,7 @@ namespace WMS.Web.Domain.Services.Public
var stock = erpStocks.Where(x => x.Id == stockId).FirstOrDefault();
return stock == null ? "" : stock.Code;
}
}
}

View File

@@ -12,6 +12,7 @@ using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto.Erp;
using WMS.Web.Core.Dto.Erp.Customer;
using WMS.Web.Core.Dto.Erp.Org;
using WMS.Web.Core.Dto.Erp.OutStock;
using WMS.Web.Core.Dto.Erp.Purchase;
@@ -397,7 +398,74 @@ namespace WMS.Web.Domain.Services.Public
return ResultList<ErpSupplierDto>.ReFailure(ResultCodes.ErpSupplierError);
}
}
/// <summary>
/// 客户
/// </summary>
/// <returns></returns>
public async Task<ResultList<ErpCustomerDto>> BillQueryForCustomer()
{
try
{
//1.获取缓存中的供应商数据;
var cache_key = "erp_customer_list";
var customers = _memoryCache.Get<List<ErpCustomerDto>>(cache_key);
if (customers == null || customers.Count == 0)
{
//2.先登录金蝶-拿到token
var token_result = await this.Init();
if (!token_result.IsSuccess)
return ResultList<ErpCustomerDto>.ReFailure(token_result);
//3.获取金蝶供应商:拼接参数和条件
var query = new ErpBillQueryDto(token_result.Data);
var param = new ErpBillQueryParamDto(FormIdParam.BD_Customer.ToString());
param.FieldKeys = "FCUSTID,FNumber,FName";
param.Limit = 10000;
//查询条件:备注其中的条件值以金蝶的值为准!!!
param.FilterString = "";
//备注因为供应商数据不是很多就不能和获取物料一样循环获取组织这里就获取10000条数据就行了
var beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
_logger.LogInformation($"供应商拉取-开始时间:{beginTime}");
//4.参数json化
query.Data = JsonConvert.SerializeObject(param);
var json = JsonConvert.SerializeObject(query);
//5.请求查询接口并返回数据
var result_json = await _client.ExecuteBillQueryAsync(json);
var result = JsonConvert.DeserializeObject<List<List<string>>>(result_json);
var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
_logger.LogInformation($"供应商拉取-结束时间:{endTime}");
//6.拼装
var list = new List<ErpCustomerDto>();
foreach (var item in result)
{
var lis = new ErpCustomerDto();
lis.Id = int.Parse(item[0]);
lis.Number = item[1];
lis.Name = item[2];
list.Add(lis);
}
//5.供应商集合进行缓存
_memoryCache.Set(cache_key, list, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromHours(12)));
_logger.LogInformation($"供应商拉取-总条数:{list.Count}");
return ResultList<ErpCustomerDto>.ReSuccess(list);
}
else
{
return ResultList<ErpCustomerDto>.ReSuccess(customers);
}
}
catch (Exception)
{
return ResultList<ErpCustomerDto>.ReFailure(ResultCodes.ErpSupplierError);
}
}
/// <summary>
/// erp:仓库
/// </summary>
@@ -1006,6 +1074,8 @@ namespace WMS.Web.Domain.Services.Public
}
}
#endregion
}
}

View File

@@ -68,6 +68,10 @@ namespace WMS.Web.Domain.Values.Erp
/// <summary>
/// 分布式调出单
/// </summary>
STK_TRANSFEROUT=15
STK_TRANSFEROUT=15,
/// <summary>
/// 客户
/// </summary>
BD_Customer=16
}
}