一厂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.

614 lines
18 KiB

3 months ago
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL;
3 months ago
using MESClassLibrary.DAL.BasicInfo;
using MESClassLibrary.DAL.Injection;
3 months ago
using MESClassLibrary.Model;
namespace MESClassLibrary.BLL.BasicInfo
{
public class BarCodeBLL
{
private BarCodeDAl db = new BarCodeDAl();
private WmsDAL wmsDal = new WmsDAL();
private BadInjectionDAL badDb = new BadInjectionDAL();
private InjectionBoxDAL _injectionBoxDAL = new InjectionBoxDAL();
3 months ago
public DataTable SearchInfoByStock(string StockNo)
{
try
{
return db.SearchInfoByStock(StockNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
throw ex;
//return null;
}
}
public DataTable SearchInfoByPartNo(string partNo)
{
try
{
return db.SearchInfoByPartNo(partNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
throw ex;
}
}
public DataTable SearchInfoByPartNo1(string partNo)
{
try
{
return db.SearchInfoByPartNo1(partNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
throw ex;
//return null;
}
}
public DataTable searchBarCode(string barcode, int flag)
{
try
{
return db.searchBarCode(barcode, flag);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool Add_Info(BarCodeModel md)
{
try
{
return db.AddInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool Add_Info_New(BarCodeModel md,string tableName)
{
try
{
return db.AddInfoNew(md,tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool Add_Info_New(LocalDBService local, BarCodeModel md, string tableName)
{
try
{
return db.AddInfoNew(md, tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 补打
/// </summary>
/// <param name="md"></param>
/// <param name="tableName"></param>
/// <param name="oldOneBarCode"></param>
/// <param name="oldBarCode"></param>
/// <returns></returns>
public string ReprintSave(BarCodeModel md, string tableName,string oldOneBarCode,string oldBarCode,string station)
{
LocalDBService local = new LocalDBService(SqlHelper.GetConnSting());
try
{
local.BeginTrans();
//tb_barCode 更新 isDel=1
db.DelBarCode(local, oldOneBarCode, tableName,$",Des5='条码补打,新条码[{md.OneBarCode}]'");
//tb_barCode 插入 printType=2 补打
db.AddInfoNew(local, md, tableName);
if(!string.IsNullOrEmpty(md.BoxNo))
{
//根据箱码删除接口表tb_Injectionn_Interface中数据
wmsDal.DeleteRecord(local, md.BoxNo, oldOneBarCode, oldBarCode);
}
else
{
//根据旧条码删除接口tb_Injectionn_Interface中数据
wmsDal.DeleteInterface(local, oldOneBarCode);
}
md.Remark = "补打,原塑件码:" + oldOneBarCode;
wmsDal.SaveInterface(local, md, "", station);
local.Commit();
return "";
}
catch (Exception ex)
{
if (local != null)
{
local.Rollback();
}
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return ex.Message;
}
finally
{
if (local != null)
{
local.EndTrans();
}
}
}
3 months ago
public DataTable SearchInfo(string stationNo)
{
try
{
return db.SearchInfo(stationNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
3 months ago
public DataTable SearchInfoAll()
{
try
{
return db.SearchInfoAll();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCode()
{
try
{
return db.SearchBarCode();
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCodeByOne(string OneBarCode)
{
try
{
return db.SearchBarCodeByOne(OneBarCode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCodeByTwo(string BarCode)
{
try
{
return db.SearchBarCodeByTwo(BarCode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchSerialNoByBarCode(string Code)
{
try
{
return db.SearchSerialNoByBarCode(Code);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchSerialNoByBarCodeNew(string Code,string tableName)
{
try
{
return db.SearchSerialNoByBarCodeNew(Code, tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
throw ex;
//return null;
}
}
public DataTable SearchSerialNoByBarCodeNew1(string Code)
{
try
{
return db.SearchSerialNoByBarCodeNew1(Code);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByBarCode(string BarCode)
{
try
{
return db.SearchInfoByBarCode(BarCode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchInfoByBarCodeNew(string BarCode,string tableName)
{
try
{
return db.SearchInfoByBarCodeNew(BarCode, tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool Update_Info(BarCodeModel md)
{
try
{
return db.UpdateInfo(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool DelBarCode(BarCodeModel md)
{
try
{
return db.DelBarCode(md);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool DelBarCode_New(BarCodeModel md,string tableName)
{
try
{
return db.DelBarCode_New(md,tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
/// <summary>
/// 条码删除 --wms中间表未读数据,删除中间表,tb_barcode中IsDel=1
/// </summary>
/// <param name="barCode"></param>
/// <param name="tableName"></param>
/// <returns></returns>
public string DelBarCode(string barCode, string tableName,bool isBox,string boxCode)
{
LocalDBService localDB = new LocalDBService(SqlHelper.GetConnSting());
try
{
localDB.BeginTrans();
bool wms = wmsDal.DeleteInterface(localDB, barCode);
if (wms == false)
{
throw new Exception($"条码在wms库已报工,无法删除!");
}
db.DelBarCode(localDB, barCode, tableName);
if (isBox)
{
//箱码需要更新箱单实际数量
_injectionBoxDAL.UpdateInfo(localDB, boxCode, -1, false);
}
localDB.Commit();
return "";
}
catch (Exception ex)
{
if (localDB != null)
{
localDB.Rollback();
}
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return ex.Message;
}
finally
{
if (localDB != null)
{
localDB.EndTrans();
}
}
}
3 months ago
public DataTable SearchBoxIsNull(string partNo, string StationID, string tableName, string ProductNature)
{
try
{
return db.SearchBoxIsNull(partNo, StationID, tableName, ProductNature);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable IsHave(string partNo, string StationID, string tableName)
{
try
{
return db.IsHave(partNo, StationID, tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 箱码中单个条码替换
/// </summary>
/// <param name="tableName"></param>
/// <param name="boxCode"></param>
/// <param name="oldID"></param>
/// <param name="newID"></param>
/// <param name="model"></param>
/// <returns></returns>
public bool BarCodeReplace(string oldtableName, string newtableName, string boxCode,string oldID,string newID,string newOneBarCode,string newBarCode, BadInjectionModel model,string station)
{
LocalDBService localDB = new LocalDBService(SqlHelper.GetConnSting());
try
{
localDB.BeginTrans();
db.UpdateBoxNoByID(localDB, newtableName, boxCode, newID); //更新新条码在tb_barcode中的箱码
db.UpdateBoxNoNull(localDB, oldtableName, oldID, newBarCode); //更新就条码在tb_barcode中的箱码为空 记录一下被替代的新条码
//badDb.AddInfo(localDB, model);//不直接报废,所以不插入tb_Bad_Injection
//删除旧的条码
wmsDal.DeleteRecord(localDB, boxCode, model.OneBarCode, model.BarCode);
//保存新条码
wmsDal.AddRecord(localDB, boxCode, newOneBarCode, newBarCode,"0", model.Desc,"",station);
localDB.Commit();
return true;
}
catch (Exception ex)
{
if(localDB != null)
{
localDB.Rollback();
}
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
finally
{
if (localDB != null)
{
localDB.EndTrans();
}
}
}
3 months ago
public bool UpdateBoxNo(string tableName, string boxNo, string partNo)
{
try
{
return db.UpdateBoxNo(tableName, boxNo, partNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
3 months ago
public DataTable SearchCountByBox(string boxNo, string tableName)
{
try
{
return db.SearchCountByBox(boxNo, tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public bool UpdateIsBad(string tableName, string onebarcode, string barcode)
{
try
{
return db.UpdateIsBad(tableName, onebarcode, barcode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateIsBad(LocalDBService localDB, string tableName, string onebarcode, string barcode)
{
return db.UpdateIsBad(localDB,tableName, onebarcode, barcode);
}
public bool UpdateIsBadByBoxCode(string tableName, string boxNo)
{
try
{
return db.UpdateIsBadByBoxCode(tableName, boxNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public bool UpdateIsBadByBoxCode(LocalDBService localDB, string tableName, string boxNo)
{
try
{
return db.UpdateIsBadByBoxCode(localDB,tableName, boxNo);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
3 months ago
public DataTable SearchBarCode(string boxNo, string tableName, string row)
{
try
{
DataTable dt = null;
if (string.IsNullOrEmpty(tableName))
{
dt = db.SearchInfoByBox(boxNo);
}
else
{
dt = db.SearchBarCode(boxNo, tableName, row);
}
return dt;
3 months ago
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable SearchBarCodeByWhere(string whereStr, string tableName, string row)
{
try
{
return db.SearchBarCodeByWhere(whereStr, tableName, row);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
3 months ago
public bool updateProductNature(string tableName, string barcode)
{
try
{
return db.updateProductNature(tableName, barcode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
public DataTable SeachInfoByOne(string barCode, string tableName,int flag)
{
try
{
return db.SeachInfoByOne(barCode, tableName, flag);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public string LastBarCode(string tableName)
{
try
{
return db.LastBarCode(tableName);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
public bool IsExist(string barCode)
{
try
{
return db.IsExist(barCode);
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
return false;
}
}
}
}