一厂MES,含注塑,喷涂,冲孔
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
4.6 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL;
using MESClassLibrary.DAL.BasicInfo;
using MESClassLibrary.DAL.Injection;
using MESClassLibrary.Enum;
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.Injection
{
public class WmsBLL
{
private WmsDAL da=new WmsDAL();
private BarCodeDAl barCodeDal = new BarCodeDAl();
public string SaveRecordAndInterface(BarCodeModel bcm,string tableName,string badReason, string station)
{
LocalDBService local = new LocalDBService(SqlHelper.GetConnSting());
try
{
local.BeginTrans();
barCodeDal.AddInfoNew(local, bcm, tableName);
da.SaveInterface(local, bcm, badReason, station);
local.Commit();
}
catch (Exception ex)
{
if (local != null)
{
local.Rollback();
}
return ex.Message;
}
finally
{
if (local != null)
{
local.EndTrans();
}
}
return null;
}
public void SaveInterface(LocalDBService local ,BarCodeModel bcm,string badReason,string station)
{
da.SaveInterface(local, bcm, badReason, station);
}
public void DeleteInterface(LocalDBService local, string oneBarCode)
{
da.DeleteInterface(local, oneBarCode);
}
/// <summary>
/// 合格保存接口
/// </summary>
/// <param name="boxNo"></param>
/// <param name="lastBoxNo1"></param>
/// <param name="lastBoxNo2"></param>
/// <param name="interfaceType"></param>
/// <returns></returns>
public string SaveInterface(string boxNo,string lastBoxNo1,string lastBoxNo2, WmsInterfaceEnum interfaceType,string station )
{
//上一个是否传递成功,没成功重新传 左侧
if (!string.IsNullOrEmpty(lastBoxNo1))
{
bool exsit = da.IsSendPackageCode(lastBoxNo1);
if(exsit == false)
{
SendToInterface(lastBoxNo1,"", station);
}
}
//上一个是否传递成功,没成功重新传 右侧侧
if (!string.IsNullOrEmpty(lastBoxNo2))
{
bool exsit = da.IsSendPackageCode(lastBoxNo2);
if (exsit == false)
{
SendToInterface(lastBoxNo2, "", station);
}
}
string rst = SendToInterface(boxNo,"", station);
if (!string.IsNullOrEmpty(rst))
{
LogErrBLL.AddInfo(rst, MethodBase.GetCurrentMethod());
}
return rst;
}
private string SendToInterface(string boxNo, string badReason,string station )
{
DataTable barCodeTable = barCodeDal.SearchInfoByBox(boxNo);
string rst = da.SaveInterface(barCodeTable, badReason, station);
return rst;
}
/// <summary>
/// 是否已传到WMS
/// </summary>
/// <param name="boxNo"></param>
/// <returns></returns>
public bool IsSendPackageCode(string pacakgCode)
{
return da.IsSendPackageCode(pacakgCode);
}
/// <summary>
/// 查询箱码在 wms中间表 是否已读
/// </summary>
/// <param name="pacakgCode"></param>
/// <returns></returns>
public bool IsReadBoxInWms(string packagCode)
{
return da.IsReadBoxInWms(packagCode);
}
/// <summary>
/// 查询注塑码或条码在 wms中间表 是否已读
/// </summary>
/// <param name="barCode"></param>
/// <returns></returns>
public bool IsReadBarCodeInWms(string barCode)
{
return da.IsReadBarCodeInWms(barCode);
}
/// <summary>
/// 根据箱码删除中间表数据 整体报废wms未读取订单 true 删除成功, false 删除失败
/// </summary>
/// <param name="boxNo"></param>
/// <returns></returns>
public bool DelRecordByBox(string boxNo)
{
return da.DelRecordByBox(boxNo);
}
public bool DelRecordByBox(LocalDBService localDB , string boxNo)
{
return da.DelRecordByBox(localDB, boxNo);
}
}
}