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.
254 lines
9.1 KiB
254 lines
9.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using MESClassLibrary.BLL;
|
|
using MESClassLibrary.BLL.Log;
|
|
using MESClassLibrary.EFModel;
|
|
using MESClassLibrary.Enum;
|
|
using MESClassLibrary.Model;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
namespace MESClassLibrary.DAL.Injection
|
|
{
|
|
public class WmsDAL
|
|
{
|
|
#region 注塑
|
|
/// <summary>
|
|
/// wms注塑中间表tb_Injectionn_Interface批量插入箱码,注塑码数据
|
|
/// </summary>
|
|
/// <param name="barCodeTable"></param>
|
|
/// <returns></returns>
|
|
public string SaveInterface(DataTable barCodeTable,string badReason,string station)
|
|
{
|
|
LocalDBService local = new LocalDBService(SqlHelper.GetConnSting());
|
|
try
|
|
{
|
|
local.BeginTrans();
|
|
foreach (DataRow dr in barCodeTable.Rows)
|
|
{
|
|
try
|
|
{
|
|
string sql = $" insert into tb_Injectionn_Interface(PackageCode,OneBarCode,BarCode,Remark,QaRst,Describe,BadReason,Station)" +
|
|
$" values ('{dr["BoxNo"]}','{dr["OneBarCode"]}','{dr["BarCode"]}','','0','{dr["PartName"]}','{badReason}','{station}')";
|
|
local.Exec_NonQuery(sql);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
if (ex.Message.Contains("重复键"))
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
}
|
|
local.Commit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (local != null)
|
|
{
|
|
local.Rollback();
|
|
}
|
|
return ex.Message;
|
|
}
|
|
finally
|
|
{
|
|
if (local != null)
|
|
{
|
|
local.EndTrans();
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public bool SaveInterface(LocalDBService local, BarCodeModel bcm,string badReason,string station)
|
|
{
|
|
|
|
string sql = $" insert into tb_Injectionn_Interface(PackageCode,OneBarCode,BarCode,Remark,QaRst,Describe,BadReason,Station)" +
|
|
$" values ('{bcm.BoxNo}','{bcm.OneBarCode}','{bcm.BarCode}','{bcm.Remark}','{bcm.IsBad}','{bcm.Des1}','{badReason}','{station}')";
|
|
return local.Exec_NonQuery(sql);
|
|
|
|
}
|
|
public bool DeleteInterface(LocalDBService local, string oneBarCode)
|
|
{
|
|
try
|
|
{
|
|
string column1 = "OneBarCode";
|
|
if (oneBarCode.Contains("."))
|
|
{
|
|
column1 = "BarCode";
|
|
}
|
|
string sql2 = $"select * from tb_Injectionn_Interface where {column1}='{oneBarCode}' and WmsRead = 1";
|
|
DataTable dt = local.Exec_DataSet(sql2).Tables[0];
|
|
if(dt.Rows.Count > 0)
|
|
{
|
|
return false;
|
|
}
|
|
string sql = $"delete from tb_Injectionn_Interface where {column1}='{oneBarCode}'";
|
|
local.Exec_NonQuery(sql);
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// wms注塑中间表tb_Injectionn_Interface 单条插入箱码,注塑码数据
|
|
/// </summary>
|
|
/// <param name="localDB"></param>
|
|
/// <param name="boxNo"></param>
|
|
/// <param name="oneBarCode"></param>
|
|
/// <param name="barCode"></param>
|
|
/// <returns></returns>
|
|
public bool AddRecord(LocalDBService localDB, string boxNo, string oneBarCode, string barCode,string isBad,string desc,string badReason,string station)
|
|
{
|
|
|
|
string sql = $"insert into tb_Injectionn_Interface(PackageCode,OneBarCode,BarCode,Remark,QaRst,Describe,BadReason,Station) " +
|
|
$"values ('{boxNo}','{oneBarCode}','{barCode}','','{isBad}','{desc}','{badReason}','{station}')";
|
|
localDB.Exec_NonQuery(sql);
|
|
return true;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 删除一条WMS中间表数据. 装箱过程中发现一条报废产品,删除.
|
|
/// </summary>
|
|
/// <param name="localDB"></param>
|
|
/// <param name="boxNo"></param>
|
|
/// <param name="oneBarCode"></param>
|
|
/// <param name="barCode"></param>
|
|
/// <returns></returns>
|
|
public bool DeleteRecord(LocalDBService localDB, string boxNo, string oneBarCode, string barCode)
|
|
{
|
|
string sql = $"delete from tb_Injectionn_Interface where PackageCode='{boxNo}' and OneBarCode='{oneBarCode}' and BarCode='{barCode}'";
|
|
localDB.Exec_NonQuery(sql);
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 箱码是否已传递到wms
|
|
/// </summary>
|
|
/// <param name="pacakgCode"></param>
|
|
/// <returns></returns>
|
|
public bool IsSendPackageCode(string pacakgCode)
|
|
{
|
|
try
|
|
{
|
|
string sql = $" select * from tb_Injectionn_Interface where PackageCode='{pacakgCode}'";
|
|
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
|
|
|
|
return dt.Rows.Count > 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// wms 是否已读
|
|
/// </summary>
|
|
/// <param name="pacakgCode"></param>
|
|
/// <returns></returns>
|
|
public bool IsReadBoxInWms(string pacakgCode)
|
|
{
|
|
try
|
|
{
|
|
string sql = $" select * from tb_Injectionn_Interface where PackageCode='{pacakgCode}' and WmsRead =1";
|
|
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
|
|
|
|
return dt.Rows.Count > 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|
|
public bool IsReadBarCodeInWms(string barCode)
|
|
{
|
|
try
|
|
{
|
|
string sql = string.Empty;
|
|
if (barCode.Contains("."))
|
|
{
|
|
sql = $" select * from tb_Injectionn_Interface where BarCode='{barCode}' and WmsRead =1";
|
|
}
|
|
else
|
|
{
|
|
sql = $" select * from tb_Injectionn_Interface where OneBarCode='{barCode}' and WmsRead =1";
|
|
}
|
|
|
|
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
|
|
|
|
return dt.Rows.Count > 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public bool DelRecordByBox(string boxNo)
|
|
{
|
|
try
|
|
{
|
|
string sql = $" select * from tb_Injectionn_Interface where PackageCode='{boxNo}' and WmsRead =1";
|
|
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
|
|
|
|
if( dt.Rows.Count > 0)
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
string sql2 = $"delete from tb_Injectionn_Interface where PackageCode='{boxNo}' and WmsRead =0";
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql2, null);
|
|
return true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return true;
|
|
}
|
|
|
|
}
|
|
public bool DelRecordByBox(LocalDBService localDB, string boxNo)
|
|
{
|
|
|
|
string sql = $" select * from tb_Injectionn_Interface where PackageCode='{boxNo}' and WmsRead =1";
|
|
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
|
|
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
string sql2 = $"delete from tb_Injectionn_Interface where PackageCode='{boxNo}' and WmsRead =0";
|
|
localDB.Exec_NonQuery(sql2);
|
|
// SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql2, null);
|
|
return true;
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 喷涂
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|