|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using Estsh.Core.Base;
|
|
|
using Estsh.Core.Wms.IRepositories;
|
|
|
using Estsh.Core.Wms.IServices;
|
|
|
using Estsh.Core.Model.Result;
|
|
|
using Estsh.Core.Services;
|
|
|
using Estsh.Core.Repositories;
|
|
|
using Estsh.Core.Models;
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
using static Estsh.Core.Model.EnumUtil.WmsEnumUtil;
|
|
|
using Estsh.Core.Model.EnumUtil;
|
|
|
|
|
|
namespace Estsh.Core.Wms.Services
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 移动单服务类
|
|
|
/// </summary>
|
|
|
public class MoveOrderService : BaseService<WmsMoveHeader>, IMoveOrderService
|
|
|
{
|
|
|
private readonly IMoveOrderRepository repository;
|
|
|
private readonly IStockRepository stockRepository;
|
|
|
|
|
|
public MoveOrderService(IMoveOrderRepository _repository,
|
|
|
IStockRepository _stockRepository) : base(_repository)
|
|
|
{
|
|
|
this.repository = _repository;
|
|
|
this.stockRepository = _stockRepository;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取正在创建中的单据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public List<WmsMoveHeader> GetCreateingList()
|
|
|
{
|
|
|
return repository.GetCreateingList();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 处理扫描的箱条码
|
|
|
/// </summary>
|
|
|
/// <param name="cartonNo"></param>
|
|
|
/// <param name="orderNo"></param>
|
|
|
/// <param name="loginId"></param>
|
|
|
/// <returns></returns>
|
|
|
public WmsResponseResult DoCarton(string cartonNo, string orderNo, string remarks, int orderType, string loginId)
|
|
|
{
|
|
|
SysStock cartonInfo = stockRepository.GetCartonInfo(cartonNo);
|
|
|
WmsResponseResult result = new WmsResponseResult();
|
|
|
|
|
|
if (cartonInfo == null)
|
|
|
{
|
|
|
result.Msg = "包装条码不存在,请检查!";
|
|
|
return result;
|
|
|
}
|
|
|
if (cartonInfo.Enabled.Equals(Enabled.N))
|
|
|
{
|
|
|
result.Msg = "包装条码已被冻结,不允许此操作!";
|
|
|
return result;
|
|
|
}
|
|
|
if (cartonInfo.Qty <=0)
|
|
|
{
|
|
|
result.Msg = "包装条码数量为0,不允许此操作!";
|
|
|
return result;
|
|
|
}
|
|
|
if (cartonInfo.Status != (int)StockStatus.NC_INSTOCK &&
|
|
|
(orderType == (int)MoveOrderType.NC_SCRAP
|
|
|
|| orderType == (int)MoveOrderType.NC_CONCESSION
|
|
|
|| orderType == (int)MoveOrderType.SUPPLIER_RETURN
|
|
|
|| orderType == (int)MoveOrderType.NC_MOVE
|
|
|
))
|
|
|
{
|
|
|
result.Msg = "包装条码状态不是NC入库状态,不允许此操作!";
|
|
|
return result;
|
|
|
}
|
|
|
if (orderType == (int)MoveOrderType.SUPPLIER_RETURN)
|
|
|
{
|
|
|
if (cartonInfo.ErpWarehouse != "9002")
|
|
|
{
|
|
|
result.Msg = "包装条码不在退货库,不允许此操作!";
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (cartonInfo.Status != (int)StockStatus.INSTOCKED && cartonInfo.Status != (int)StockStatus.ONLINED && orderType == (int)MoveOrderType.NC_IN_STOCK )
|
|
|
{
|
|
|
result.Msg = "包装条码状态不是在库/上线状态,不允许此操作!";
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
WmsMoveDetail moveDetail = null;
|
|
|
if (!string.IsNullOrEmpty(orderNo))
|
|
|
{
|
|
|
moveDetail = repository.GetMoveDetail(orderNo, cartonInfo.PartNo);
|
|
|
if (moveDetail != null && cartonInfo.ZoneId != moveDetail.SrcZoneId)
|
|
|
{
|
|
|
result.Msg = "包装条码对应的存储区与订单中此零件的源存储区不一致!";
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
WmsMoveSn moveSn = repository.GetMoveSn(orderNo, cartonInfo.CartonNo);
|
|
|
|
|
|
if (moveSn != null)
|
|
|
{
|
|
|
result.Msg = "订单中包含此包装条码,不允许此操作!";
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
string resOrderNo = repository.DoCarton(cartonInfo, orderNo, remarks, orderType, loginId, moveDetail);
|
|
|
|
|
|
if (!string.IsNullOrEmpty(resOrderNo))
|
|
|
{
|
|
|
//result = this.SubmitOrder(orderNo, loginId);
|
|
|
result.Msg = "SCAN_OK";
|
|
|
result.Data = resOrderNo;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Msg = "操作失败,请重新尝试!";
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 提交单据
|
|
|
/// </summary>
|
|
|
/// <param name="orderNo"></param>
|
|
|
/// <param name="loginId"></param>
|
|
|
/// <returns></returns>
|
|
|
public WmsResponseResult SubmitOrder(string orderNo, string loginId)
|
|
|
{
|
|
|
WmsResponseResult result = new WmsResponseResult();
|
|
|
// 完成单据并提交接口
|
|
|
if (repository.OrderCreated(orderNo, loginId))
|
|
|
{
|
|
|
result.Msg = "SCAN_OK";
|
|
|
result.Data = orderNo;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Msg = "操作失败,请重新尝试!";
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据单据类型获取此类型待处理的单据列表,如果单据类型为空,则获取全部类型
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public List<WmsMoveHeader> GetMoveOrderList(int? orderType)
|
|
|
{
|
|
|
return repository.GetMoveOrderList(orderType);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据单据号获取单据明细列表
|
|
|
/// </summary>
|
|
|
/// <param name="orderNo"></param>
|
|
|
/// <returns></returns>
|
|
|
public List<WmsMoveDetail> GetMoveDetailList(string orderNo)
|
|
|
{
|
|
|
return repository.GetMoveDetailList(orderNo);
|
|
|
}
|
|
|
}
|
|
|
}
|