You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
240 lines
8.8 KiB
C#
240 lines
8.8 KiB
C#
using Dapper;
|
|
using Estsh.Core.Base;
|
|
using Estsh.Core.Model.EnumUtil;
|
|
using Estsh.Core.Models;
|
|
using Estsh.Core.Services;
|
|
using Estsh.Core.Wms.IRepositories;
|
|
using Estsh.Core.Wms.IServices;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Estsh.Core.Wms.Services
|
|
{
|
|
/// <summary>
|
|
/// 销售配料
|
|
/// </summary>
|
|
public class SaleBatchService : BaseService<BaseEntity>, ISaleBatchService
|
|
{
|
|
private readonly ISaleBatchRepository repository;
|
|
public SaleBatchService(ISaleBatchRepository _repository) : base(_repository)
|
|
{
|
|
repository = _repository;
|
|
}
|
|
public SetObjectDetail GetSaleBatchOrderList(string orderNo)
|
|
{
|
|
SetObjectDetail rfInfo = new SetObjectDetail();//返回消息
|
|
|
|
List<WmsOutstock> wmsMoves = repository.GetSaleBatchOrderList(orderNo);
|
|
|
|
if (wmsMoves.Count > 0)
|
|
{
|
|
rfInfo.type = "PASS";
|
|
rfInfo.message = "成功";
|
|
rfInfo.wmsObjectDetail = wmsMoves.ConvertAll(s => (object)s);
|
|
}
|
|
else
|
|
{
|
|
rfInfo.type = "FAIL";
|
|
rfInfo.message = "未查询到数据,请检查!";
|
|
}
|
|
return rfInfo;
|
|
}
|
|
public SetObjectDetail GetSaleBatchOrderListByOrderNo(string orderNo)
|
|
{
|
|
SetObjectDetail rfInfo = new SetObjectDetail();//返回消息
|
|
List<WmsOutstockDetail> wmsMoves = repository.GetSaleBatchOrderListByOrderNo(orderNo);
|
|
|
|
if (wmsMoves.Count > 0)
|
|
{
|
|
rfInfo.type = "PASS";
|
|
rfInfo.message = "成功";
|
|
rfInfo.wmsObjectDetail = wmsMoves.ConvertAll(s => (object)s);
|
|
}
|
|
else
|
|
{
|
|
rfInfo.type = "FAIL";
|
|
rfInfo.message = "未查询到数据,请检查!";
|
|
}
|
|
return rfInfo;
|
|
}
|
|
|
|
public SetObjectDetail CheckStockByCartonAlocate(string cartonNo, string orderNo, string isSplit)
|
|
{
|
|
SetObjectDetail rfInfo = new SetObjectDetail();//返回消息
|
|
//配料列表
|
|
List<WmsOutstockDetail> details = repository.CheckMoveDetail(orderNo, (int)WmsEnumUtil.StockStatus.INSTOCKED);
|
|
//扫描到的箱条码
|
|
SysStock Stock = repository.GetCartonInfo(cartonNo);
|
|
|
|
if (Stock == null)
|
|
{
|
|
rfInfo.type = "FAIL";
|
|
rfInfo.message = "[" + cartonNo + "]:箱条码不存在,请检查!";
|
|
return rfInfo;
|
|
}
|
|
if (Stock.Enabled.Equals("N"))
|
|
{
|
|
rfInfo.type = "FAIL";
|
|
rfInfo.message = "[" + cartonNo + "]:箱条码已被冻结,请检查!";
|
|
return rfInfo;
|
|
}
|
|
else if (Stock.Status != (int)WmsEnumUtil.StockStatus.INSTOCKED)
|
|
{
|
|
rfInfo.type = "FAIL";
|
|
rfInfo.message = "[" + cartonNo + "]:是" + Stock.StockStatus + "状态,请检查!";
|
|
return rfInfo;
|
|
}
|
|
if (Stock.Qty < 1)
|
|
{
|
|
rfInfo.type = "FAIL";
|
|
rfInfo.message = "[" + cartonNo + "]:箱条码数量不足,无法拆分!";
|
|
return rfInfo;
|
|
}
|
|
|
|
List<WmsOutstockDetail> ifScan = details.Where(a => a.PartId == Stock.PartId).ToList();
|
|
if (ifScan.Count == 0)
|
|
{
|
|
rfInfo.type = "FAIL";
|
|
rfInfo.message = "[" + cartonNo + "]:不在销售发运单中,请检查!";
|
|
return rfInfo;
|
|
}
|
|
|
|
if (ifScan[0].FactoryId != Stock.FactoryId)
|
|
{
|
|
rfInfo.type = "FAIL";
|
|
rfInfo.message = "[" + cartonNo + "]:与销售发运单不在同工厂,请检查!";
|
|
return rfInfo;
|
|
}
|
|
|
|
if (ifScan[0].PickQty >= ifScan[0].Qty)
|
|
{
|
|
rfInfo.type = "FAIL";
|
|
rfInfo.message = "[" + ifScan[0].PartNo + "]:已完成配料!";
|
|
return rfInfo;
|
|
}
|
|
|
|
////获取零件号 最早批次列表
|
|
//List<SysStock> PartByFIFO = repository.GetPartByFIFO(Stock.PartId.ToString());
|
|
//List<SysStock> isSure = PartByFIFO.Where(a => a.CartonNo == Stock.CartonNo).ToList();
|
|
//if (isSure.Count == 0)
|
|
//{
|
|
// rfInfo.type = "FAIL";
|
|
// rfInfo.message = "[" + cartonNo + "]:箱条码不是最早批次,请扫描[" + PartByFIFO[0].CartonNo + "]";
|
|
// return rfInfo;
|
|
//}
|
|
|
|
if ((ifScan[0].PickQty + Stock.Qty) > ifScan[0].Qty && isSplit == "False")
|
|
{
|
|
rfInfo.type = "FAIL";
|
|
rfInfo.message = "[" + cartonNo + "]:箱条码为尾箱超出配料数,请开启拆分进行扫描!";
|
|
return rfInfo;
|
|
}
|
|
|
|
rfInfo.type = "PASS";
|
|
rfInfo.message = "扫描成功,请扫描客户条码";
|
|
return rfInfo;
|
|
|
|
|
|
}
|
|
|
|
public SetObjectDetail doSaleBatch(string cartonNo, string orderNo, string groupNo, string isSplit, string loginId, string customBarcode)
|
|
{
|
|
SetObjectDetail rfInfo = new SetObjectDetail();//返回消息
|
|
|
|
//扫描到的箱条码
|
|
SysStock Stock = repository.GetCartonInfo(cartonNo);
|
|
if (Stock.CartonNoCustomer == customBarcode && customBarcode !="")
|
|
{
|
|
rfInfo.type = "FAIL";
|
|
rfInfo.message = "零件号[" + Stock.PartNo + "]已扫描,请重新扫描!";
|
|
return rfInfo;
|
|
}
|
|
|
|
SysCustomerPart customerPart = repository.GetCustomerPart(Stock.PartNo);
|
|
if (customerPart == null)
|
|
{
|
|
rfInfo.type = "FAIL";
|
|
rfInfo.message = "找不到零件号[" + Stock.PartNo + "]对应的客户零件号!";
|
|
return rfInfo;
|
|
}
|
|
if (!customBarcode.Contains(customerPart.CustPartNo))
|
|
{
|
|
rfInfo.type = "FAIL";
|
|
rfInfo.message = "[" + Stock.PartNo + "]对应的客户零件号[" + customerPart.CustPartNo + "]与扫描的不一致!";
|
|
return rfInfo;
|
|
}
|
|
|
|
//配料列表
|
|
List<WmsOutstockDetail> details = repository.CheckMoveDetail(orderNo, (int)WmsEnumUtil.StockStatus.INSTOCKED);
|
|
|
|
|
|
List<WmsOutstockDetail> ifScan = details.Where(a => a.PartId == Stock.PartId).ToList();
|
|
|
|
if (isSplit == "True")
|
|
{
|
|
//尾箱拆分
|
|
decimal needNum = ifScan[0].Qty - ifScan[0].PickQty; //需要拆的数量
|
|
if (needNum >= Stock.Qty)
|
|
{
|
|
//不需要拆
|
|
}
|
|
else
|
|
{
|
|
//原条码
|
|
decimal oldQty = Stock.Qty - needNum;
|
|
CheckMaterialSplit(Stock.CartonNo, Convert.ToInt32(oldQty), loginId, 1);
|
|
//更新拆分后数据
|
|
Stock = repository.GetCartonInfo(cartonNo);
|
|
return repository.UpdteStatus(orderNo, ifScan, Stock, groupNo, loginId, customBarcode);
|
|
}
|
|
}
|
|
|
|
return repository.UpdteStatus(orderNo, ifScan, Stock, groupNo, loginId, customBarcode);
|
|
}
|
|
|
|
public SetObjectDetail CheckMaterialSplit(string cartonNo, int splitNum, string loginId, int splitCount)
|
|
{
|
|
|
|
SetObjectDetail det = new SetObjectDetail();
|
|
//需要拆分的箱条码信息
|
|
List<SysStock> MaterialInfo = repository.GetMaterialInfo(cartonNo);
|
|
if (MaterialInfo.Count == 0)
|
|
{
|
|
det.type = "NO";
|
|
det.message = "[" + cartonNo + "]:箱条码不存在,请检查!";
|
|
return det;
|
|
}
|
|
if (MaterialInfo[0].Enabled.Equals("N"))
|
|
{
|
|
det.type = "NO";
|
|
det.message = "[" + cartonNo + "]:箱条码已被冻结,请检查!";
|
|
return det;
|
|
}
|
|
if (MaterialInfo[0].Qty < 1)
|
|
{
|
|
det.type = "NO";
|
|
det.message = "[" + cartonNo + "]:箱条码数量不足,无法拆分!";
|
|
return det;
|
|
}
|
|
|
|
|
|
List<SysStock> NewStock = repository.CheckMaterialSplit(MaterialInfo, splitNum, loginId, splitCount);
|
|
if (NewStock == null || NewStock.Count == 0)
|
|
{
|
|
det.type = "NO";
|
|
det.message = "执行失败!请重试!";
|
|
}
|
|
else
|
|
{
|
|
det.type = "OK";
|
|
det.wmsObjectDetail = NewStock.ConvertAll(s => (object)s);
|
|
}
|
|
return det;
|
|
}
|
|
|
|
}
|
|
}
|