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.
1688 lines
86 KiB
1688 lines
86 KiB
6 months ago
|
using DBUtility;
|
||
|
using PaintingPC.Model;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Configuration;
|
||
|
using System.Data;
|
||
|
using System.Drawing;
|
||
|
using System.IO;
|
||
|
using System.Linq;
|
||
|
using System.Reflection;
|
||
|
using System.Text;
|
||
|
using System.Threading.Tasks;
|
||
|
using System.Windows.Forms;
|
||
|
|
||
|
namespace PaintingPC
|
||
|
{
|
||
|
public class Function
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 解析条码(一维码返回存货代码,二维码返回零件号)
|
||
|
/// </summary>
|
||
|
/// <param name="code">条码</param>
|
||
|
/// <param name="stockNo">存货代码</param>
|
||
|
/// <param name="batchNo">批次</param>
|
||
|
/// /// <param name="partNo">零件号</param>
|
||
|
public static void GetCode(string code, out string stockNo, out string batchNo, out string partNo)
|
||
|
{
|
||
|
//解析塑料粒子条码,长度为20的为一维码22000000821906090201,否则为二维码
|
||
|
//二维码样例Z-340.180411.000001;5000;S35001;20180411;P1710401.[#Line#];180411;
|
||
|
//第一个分号之前的数据,即Z-340.180411.000001; Z-340为零件号,180411为批次号,000001为流水号
|
||
|
//一维码前十位为零件号,tb_Product PartNo,11~16位为批次
|
||
|
|
||
|
stockNo = ""; //存货代码
|
||
|
batchNo = ""; //批次
|
||
|
partNo = ""; //零件号
|
||
|
try
|
||
|
{
|
||
|
if (code.Contains(".") == false)
|
||
|
{
|
||
|
//一维码
|
||
|
if (code.Length > 9)
|
||
|
{
|
||
|
stockNo = code.Substring(0, 10);
|
||
|
batchNo = code.Substring(10, 6);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//二维码
|
||
|
string[] strs = code.Split(';');
|
||
|
if (strs.Length > 0)
|
||
|
{
|
||
|
string str = strs[0];
|
||
|
string[] props = str.Split('.');
|
||
|
if (props.Length >= 3)
|
||
|
{
|
||
|
partNo = props[0];
|
||
|
batchNo = props[1];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
LogHelper.WriteSysLogBase("[入参]:code=" + code + "; [出参:]stockNo=" + stockNo + ",batchNo=" + batchNo + ",partNo=" + partNo, MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据存货代码获得零件名称、颜色名称
|
||
|
/// </summary>
|
||
|
/// <param name="stockNo"></param>
|
||
|
/// <param name="partName"></param>
|
||
|
/// <param name="colorName"></param>
|
||
|
public static void GetInfoByStockNo(string stockNo, string partNo, out string partName)
|
||
|
{
|
||
|
partName = "";
|
||
|
string sql = "";
|
||
|
try
|
||
|
{
|
||
|
DataTable dt = new DataTable();
|
||
|
if (!string.IsNullOrWhiteSpace(stockNo))
|
||
|
{
|
||
|
sql = " select ProductName from tb_Product where StockNo = '" + stockNo + @"' ";
|
||
|
dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
}
|
||
|
else if (!string.IsNullOrWhiteSpace(partNo))
|
||
|
{
|
||
|
sql = @" select ProductName from tb_Product where PartNo = '" + partNo + @"' ";
|
||
|
dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
}
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
partName = dt.Rows[0]["ProductName"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
partName = "";
|
||
|
}
|
||
|
LogHelper.WriteSysLogBase("[入参]:stockNo=" + stockNo + ",partNo=" + partNo + "; [出参:]partName=" + partName + ";[sql:] + sql", MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据条码获取图片地址
|
||
|
/// </summary>
|
||
|
/// <param name="barcode"></param>
|
||
|
/// <returns></returns>
|
||
|
public static DataTable SearchInfoByBarCode(string barcode)
|
||
|
{
|
||
|
DataTable res = new DataTable();
|
||
|
try
|
||
|
{
|
||
|
string stockNo = "";
|
||
|
string batchNo = "";
|
||
|
string partNo = "";
|
||
|
GetCode(barcode, out stockNo, out batchNo, out partNo);
|
||
|
|
||
|
string sql = "";
|
||
|
if (!string.IsNullOrWhiteSpace(stockNo))
|
||
|
{
|
||
|
sql = " select * from tb_Product where StockNo = '" + stockNo.Trim() + @"'";
|
||
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
}
|
||
|
else if (!string.IsNullOrWhiteSpace(partNo))
|
||
|
{
|
||
|
sql = " select * from tb_Product where PartNo = '" + partNo.Trim() + @"'";
|
||
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
}
|
||
|
LogHelper.WriteSysLogBase("[入参:]barcode=" + barcode+"[sql:]"+ sql, MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static DataTable SearchDefectInfo(string stationNo)
|
||
|
{
|
||
|
DataTable res = new DataTable();
|
||
|
try
|
||
|
{
|
||
|
string sql = @" select * from tb_Defect where LineID = (select LineID from tb_Station where StationNo = '"+ stationNo +@"') ";
|
||
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
LogHelper.WriteSysLogBase("[入参:]stationNo=" + stationNo + "[sql:]" + sql, MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 从远程服务器下载文件到本地
|
||
|
/// </summary>
|
||
|
/// <param name="src">远程服务器文件夹路径</param>
|
||
|
/// <param name="dst">要保存到本地的文件夹路径</param>
|
||
|
/// <param name="fileName">远程服务器src路径下的文件名</param>
|
||
|
public static void TransportRemoteToLocal(string src, string dst, string fileName) //src:远程服务器文件夹路径 dst:要保存到本地的文件路径 fileName:远程服务器src路径下的文件名
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
FileStream inFileStream = new FileStream(src, FileMode.Open); //远程服务器文件 此处假定远程服务器共享文件夹下确实包含本文件,否则程序报错
|
||
|
|
||
|
if (!Directory.Exists(dst))
|
||
|
{
|
||
|
Directory.CreateDirectory(dst);
|
||
|
}
|
||
|
dst = dst + fileName;
|
||
|
FileStream outFileStream = new FileStream(dst, FileMode.OpenOrCreate); //从远程服务器下载到本地的文件
|
||
|
byte[] buf = new byte[inFileStream.Length];
|
||
|
int byteCount;
|
||
|
while ((byteCount = inFileStream.Read(buf, 0, buf.Length)) > 0)
|
||
|
{
|
||
|
outFileStream.Write(buf, 0, byteCount);
|
||
|
}
|
||
|
inFileStream.Flush();
|
||
|
inFileStream.Close();
|
||
|
outFileStream.Flush();
|
||
|
outFileStream.Close();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 保存检验结果
|
||
|
/// </summary>
|
||
|
/// <param name="model"></param>
|
||
|
/// <returns></returns>
|
||
|
public static int InsertInspect(InspectModel model)
|
||
|
{
|
||
|
int res = 0;
|
||
|
try
|
||
|
{
|
||
|
string sql = @" INSERT INTO [dbo].[tb_InspectResult]
|
||
|
([ID]
|
||
|
,[barcode]
|
||
|
,[side]
|
||
|
,[position]
|
||
|
,[stationNo]
|
||
|
,[workClass]
|
||
|
,[inspectResult]
|
||
|
,[damnPosition]
|
||
|
,[defectID]
|
||
|
,[reason]
|
||
|
,[productInfo]
|
||
|
,[productOption]
|
||
|
,[createTime]
|
||
|
,[InspectTimes]
|
||
|
)
|
||
|
VALUES
|
||
|
('" + model.ID +@"'
|
||
|
,'" + model.barcode +@"'
|
||
|
,'" + model.side +@"'
|
||
|
,'"+ model.position +@"'
|
||
|
,'"+ model.stationNo +@"'
|
||
|
,'"+ model.workClass +@"'
|
||
|
,'" + model.inspectResult + @"'
|
||
|
,'" + model.damnPosition + @"'
|
||
|
,'" + model.defectID + @"'
|
||
|
,'" + model.reason + @"'
|
||
|
,'" + model.productInfo + @"'
|
||
|
,'" + model.productOption + @"'
|
||
|
,(select getdate()), '"+ model.InspectTimes +@"'
|
||
|
) ";
|
||
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
LogHelper.WriteSysLogBase( "[sql:]" + sql ,MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据条码获取检验信息
|
||
|
/// </summary>
|
||
|
/// <param name="barcode"></param>
|
||
|
/// <returns></returns>
|
||
|
public static DataTable GetInspectInfoByBarCode(string barcode)
|
||
|
{
|
||
|
DataTable res = new DataTable();
|
||
|
try
|
||
|
{
|
||
|
string sql = @" select * from (SELECT * from (select TOP 1 * from tb_InspectResult where barcode = '"+ barcode +@"' AND InspectTimes = '1' ORDER BY createTime DESC) aa
|
||
|
UNION
|
||
|
SELECT * from (select TOP 1 * from tb_InspectResult where barcode = '" + barcode + @"' AND InspectTimes = '2' ORDER BY createTime DESC) bb
|
||
|
UNION
|
||
|
SELECT * from (select TOP 1 * from tb_InspectResult where barcode = '" + barcode + @"' AND InspectTimes = '3' ORDER BY createTime DESC) cc) dd order by createTime DESC ";
|
||
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
LogHelper.WriteSysLogBase("[sql:]" + sql, MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取国外数据库数据--暂时不用此方法
|
||
|
/// </summary>
|
||
|
/// <param name="skidNo"></param>
|
||
|
/// <returns></returns>
|
||
|
public static DataTable GetForeignData(string skidNo)
|
||
|
{
|
||
|
DataTable res = new DataTable();
|
||
|
try
|
||
|
{
|
||
|
string sqlConnString = ConfigurationManager.ConnectionStrings["SqlConnStringForeign"].ToString();
|
||
|
|
||
|
#region 查国外下线数据库
|
||
|
string sql = @" select top 1 *
|
||
|
from Paintline_Proddata where LTrim(RTrim(Skid_No)) = '" + skidNo + @"' order by TimeStamp desc ";
|
||
|
res = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, sql, null);
|
||
|
LogHelper.WriteSysLogBase("[sql:]" + sql, MethodBase.GetCurrentMethod().Name);
|
||
|
#endregion
|
||
|
|
||
|
#region 线下没查到条码,查国外上线数据库
|
||
|
|
||
|
string indexName1 = ConfigurationManager.AppSettings["FrmFirstCheckLeftSide"];
|
||
|
string indexName2 = ConfigurationManager.AppSettings["FrmFirstCheckRightSide"];
|
||
|
|
||
|
if (res == null || res.Rows.Count < 1 || string.IsNullOrWhiteSpace(res.Rows[0][indexName1].ToString()) || string.IsNullOrWhiteSpace(res.Rows[0][indexName2].ToString()))
|
||
|
{
|
||
|
string sql_2 = " select top 1 * from Paintline_Loadingdata where LTrim(RTrim(Skid_No)) = '" + skidNo + @"' order by TimeStamp desc ";
|
||
|
res = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, sql_2, null);
|
||
|
LogHelper.WriteSysLogBase("[sql:]" + sql_2, MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 查询外国数据库获取颜色码
|
||
|
/// </summary>
|
||
|
/// <param name="key"></param>
|
||
|
/// <param name="skidNo"></param>
|
||
|
/// <returns></returns>
|
||
|
public static string GetForeignDataColor(string skidNo, out string colorInfo)
|
||
|
{
|
||
|
string res = "";
|
||
|
colorInfo = "";
|
||
|
try
|
||
|
{
|
||
|
string colorNo = "";
|
||
|
string colorQQNo = "";
|
||
|
string colorPRNo = "";
|
||
|
string sqlConnString = ConfigurationManager.ConnectionStrings["SqlConnStringForeign"].ToString();
|
||
|
|
||
|
string sql = " select top 1 Setvalue_BC_Color_No, Setvalue_CC_Color_No, Setvalue_PR_Color_No from Paintline_Proddata where LTrim(RTrim(Skid_No)) = '" + skidNo + @"' order by TimeStamp desc ";
|
||
|
DataTable dtC = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, sql, null);
|
||
|
if (dtC != null && dtC.Rows.Count > 0)
|
||
|
{
|
||
|
colorNo = dtC.Rows[0]["Setvalue_BC_Color_No"].ToString();
|
||
|
colorQQNo = dtC.Rows[0]["Setvalue_CC_Color_No"].ToString();
|
||
|
colorPRNo = dtC.Rows[0]["Setvalue_PR_Color_No"].ToString();
|
||
|
}
|
||
|
|
||
|
#region 注销-不要
|
||
|
//if (string.IsNullOrWhiteSpace(colorNo))
|
||
|
//{
|
||
|
// string sql_2 = " select top 1 Setvalue_BC_Color_No from Paintline_Loadingdata where LTrim(RTrim(Skid_No)) = '" + skidNo + @"' order by TimeStamp desc ";
|
||
|
// object aa = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql_2, null);
|
||
|
// if (aa != null)
|
||
|
// {
|
||
|
// colorNo = aa.ToString();
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
|
||
|
if (!string.IsNullOrWhiteSpace(colorNo))
|
||
|
{
|
||
|
DataTable dt = new DataTable();
|
||
|
|
||
|
if (colorNo.Trim() == "BC37" && colorQQNo.Trim() == "CC04")
|
||
|
{
|
||
|
#region 单独修改亚光山脉灰
|
||
|
string sql_c = @" select * from tb_Color where ColorCode = '" + colorNo + "' and ColorQQCode = '" + colorQQNo + "' ";
|
||
|
dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_c, null);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
res = dt.Rows[0]["Des"].ToString();
|
||
|
colorInfo = dt.Rows[0]["Des"].ToString().Trim() + "," + dt.Rows[0]["ColorCode"].ToString().Trim() + "," + dt.Rows[0]["ColorNo"].ToString().Trim();
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string sql_c = "";
|
||
|
if (!string.IsNullOrWhiteSpace(colorQQNo) && !string.IsNullOrWhiteSpace(colorPRNo))
|
||
|
{
|
||
|
sql_c = @" select * from tb_Color where ColorCode = '" + colorNo + "' and ColorQQCode = '" + colorQQNo + "' and ColorDQCode = '" + colorPRNo + "' ";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sql_c = @" select * from tb_Color where ColorCode = '" + colorNo + "'";
|
||
|
}
|
||
|
//string sql_c = @" select * from tb_Color where ColorCode = '" + colorNo + "'";
|
||
|
dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_c, null);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
res = dt.Rows[0]["Des"].ToString();
|
||
|
colorInfo = dt.Rows[0]["Des"].ToString().Trim() + "," + dt.Rows[0]["ColorCode"].ToString().Trim() + "," + dt.Rows[0]["ColorNo"].ToString().Trim();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
LogHelper.WriteSysLogBase("[入参:]skidNo=" + skidNo + ";[出参:]colorInfo=" + colorInfo, MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取班次,规定早8至晚8为A班
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public static string GetWorkClass()
|
||
|
{
|
||
|
bool classA = IsBetweenTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "2019-06-12 08:00:00", "2019-06-12 20:00:00");
|
||
|
if (classA)
|
||
|
{
|
||
|
return "A班";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return "B班";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 判断传入时间是否在工作时间段内
|
||
|
/// </summary>
|
||
|
/// <param name="timeStr"></param>
|
||
|
/// <param name="startTime"></param>
|
||
|
/// <param name="endTime"></param>
|
||
|
/// <returns></returns>
|
||
|
public static bool IsBetweenTime(string timeStr, string startTime, string endTime)
|
||
|
{
|
||
|
//判断传入时间是否在工作时间段内
|
||
|
try
|
||
|
{
|
||
|
TimeSpan startSpan = DateTime.Parse(startTime).TimeOfDay;
|
||
|
TimeSpan endSpan = DateTime.Parse(endTime).TimeOfDay;
|
||
|
|
||
|
DateTime t1 = Convert.ToDateTime(timeStr);
|
||
|
TimeSpan dspNow = t1.TimeOfDay;
|
||
|
if (dspNow > startSpan && dspNow < endSpan)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static DataTable GetAllColor()
|
||
|
{
|
||
|
DataTable res = new DataTable();
|
||
|
try
|
||
|
{
|
||
|
// string sql = @" SELECT [ID]
|
||
|
// ,[ColorCode]
|
||
|
// ,[ColorNo]
|
||
|
// ,[Des]
|
||
|
// FROM [tb_Color]
|
||
|
// ORDER BY ColorCode ";
|
||
|
string sql = @" SELECT distinct
|
||
|
[ColorNo]
|
||
|
,[Des]
|
||
|
FROM [tb_Color]
|
||
|
ORDER BY ColorNo ";
|
||
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static string GetBcColorByNo(string colorNo)
|
||
|
{
|
||
|
string res = "";
|
||
|
try
|
||
|
{
|
||
|
string sql = @"select top 1 ColorCode from tb_Color where ColorNo='" + colorNo + @"'";
|
||
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
if (aa != null)
|
||
|
{
|
||
|
res = aa.ToString();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据滑撬号查询第side个条码号
|
||
|
/// </summary>
|
||
|
/// <param name="skidNo"></param>
|
||
|
/// <param name="side"></param>
|
||
|
/// <returns></returns>
|
||
|
public static string GetForeignBarCode(string skidNo, string side, int circle, out string ordernumber)
|
||
|
{
|
||
|
string res = "";
|
||
|
ordernumber = "";
|
||
|
try
|
||
|
{
|
||
|
string sqlConnString = ConfigurationManager.ConnectionStrings["SqlConnStringForeign"].ToString();
|
||
|
|
||
|
if (!string.IsNullOrWhiteSpace(side))
|
||
|
{
|
||
|
if (circle > 1)
|
||
|
{
|
||
|
#region 查国外下线数据库
|
||
|
|
||
|
#region 2019-10-30注销
|
||
|
// string sql = @" select top 1 " + side + @"
|
||
|
// from Paintline_Proddata where LTrim(RTrim(Skid_No)) = '" + skidNo + @"' and " + side + " like '%00000%' order by TimeStamp desc ";
|
||
|
// object bb = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql, null);
|
||
|
// if (bb != null)
|
||
|
// {
|
||
|
// res = bb.ToString();
|
||
|
// return res;
|
||
|
// }
|
||
|
// LogHelper.WriteSysLogBase("[sql:]" + sql, MethodBase.GetCurrentMethod().Name);
|
||
|
#endregion
|
||
|
|
||
|
string color = "";
|
||
|
string sql_color_xia = @" select top 1 Setvalue_BC_Color_No from Paintline_Proddata where LTrim(RTrim(Skid_No)) = '" + skidNo + @"' order by TimeStamp desc ";
|
||
|
object aa = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql_color_xia, null);
|
||
|
if (aa != null)
|
||
|
{
|
||
|
color = aa.ToString();
|
||
|
}
|
||
|
|
||
|
// string sql = @" select top 1 " + side + @" from (select top 2 " + side + @",TimeStamp
|
||
|
// from Paintline_Proddata where LTrim(RTrim(Skid_No)) = '" + skidNo + @"' order by TimeStamp desc) aa order by TimeStamp asc ";
|
||
|
//object bb = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql, null);
|
||
|
//if (bb != null)
|
||
|
//{
|
||
|
// res = bb.ToString();
|
||
|
// return res;
|
||
|
//}
|
||
|
|
||
|
string sql = @" select top 1 " + side + @",Ordernumber from (select top 2 " + side + @",TimeStamp
|
||
|
from Paintline_Proddata where LTrim(RTrim(Skid_No)) = '" + skidNo + @"' order by TimeStamp desc) aa order by TimeStamp asc ";
|
||
|
DataTable dt = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, sql, null);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
res = dt.Rows[0][0].ToString().Trim();
|
||
|
ordernumber = dt.Rows[0][1].ToString().Trim();
|
||
|
}
|
||
|
|
||
|
LogHelper.WriteSysLogBase("[sql:]" + sql, MethodBase.GetCurrentMethod().Name);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
#region 查国外下线数据库
|
||
|
|
||
|
// string sql = @" select top 1 " + side + @"
|
||
|
// from Paintline_Proddata where LTrim(RTrim(Skid_No)) = '" + skidNo + @"' order by TimeStamp desc ";
|
||
|
// object bb = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql, null);
|
||
|
// if (bb != null)
|
||
|
// {
|
||
|
// res = bb.ToString();
|
||
|
// return res;
|
||
|
// }
|
||
|
|
||
|
string sql = @" select top 1 " + side + @",Ordernumber
|
||
|
from Paintline_Proddata where LTrim(RTrim(Skid_No)) = '" + skidNo + @"' order by TimeStamp desc ";
|
||
|
DataTable dt = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, sql, null);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
res = dt.Rows[0][0].ToString().Trim();
|
||
|
ordernumber = dt.Rows[0][1].ToString().Trim();
|
||
|
}
|
||
|
|
||
|
LogHelper.WriteSysLogBase("[sql:]" + sql, MethodBase.GetCurrentMethod().Name);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static string GetForeignShangBarCode(string skidNo, string side,string ordernumber)
|
||
|
{
|
||
|
string sqlConnString = ConfigurationManager.ConnectionStrings["SqlConnStringForeign"].ToString();
|
||
|
string res = "";
|
||
|
try
|
||
|
{
|
||
|
string sql = @"
|
||
|
select "+ side +@"
|
||
|
from Paintline_Loadingdata
|
||
|
where Ordernumber = '"+ ordernumber +@"' and skid_no = '"+ skidNo +@"'
|
||
|
";
|
||
|
object aa = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql, null);
|
||
|
if (aa != null)
|
||
|
{
|
||
|
res = aa.ToString();
|
||
|
}
|
||
|
}
|
||
|
catch(Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据条码获取要取的层数及BC0几
|
||
|
/// </summary>
|
||
|
/// <param name="no"></param>
|
||
|
/// <param name="title"></param>
|
||
|
public static string GetForeignBCString(string no, string title)
|
||
|
{
|
||
|
string res = "";
|
||
|
try
|
||
|
{
|
||
|
string stockNo = "";
|
||
|
string batchNo = "";
|
||
|
string partNo = "";
|
||
|
GetCode(no, out stockNo, out batchNo, out partNo);
|
||
|
string layer = Function.GetProductLayer(stockNo, partNo);
|
||
|
string floor = "";
|
||
|
string side = "";
|
||
|
|
||
|
if (!string.IsNullOrWhiteSpace(title))
|
||
|
{
|
||
|
string[] strs = title.Split(' ');
|
||
|
if (strs.Length >0)
|
||
|
{
|
||
|
for (int i = 0; i < strs.Length; i++)
|
||
|
{
|
||
|
if (strs[i].Contains("侧"))
|
||
|
{
|
||
|
side = strs[i].Replace("侧","").Trim();
|
||
|
}
|
||
|
if (strs[i].Contains("支架"))
|
||
|
{
|
||
|
floor = strs[i].Replace("支架", "").Trim();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
string sql = @" select des from tb_LayerAndBC where layer = " + layer + " and floor = '" + floor + "' and side = '" + side + "' ";
|
||
|
res = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null).ToString();
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
catch(Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据条码查询支架位置,即:上、中、下支架
|
||
|
/// </summary>
|
||
|
/// <param name="barCode">条码</param>
|
||
|
/// <returns></returns>
|
||
|
public static string GetPosition(string barCode)
|
||
|
{
|
||
|
string res = "";
|
||
|
|
||
|
try
|
||
|
{
|
||
|
string stockNo = "";
|
||
|
string batchNo = "";
|
||
|
string partNo = "";
|
||
|
string columnName = "";
|
||
|
|
||
|
string sqlConnString = ConfigurationManager.ConnectionStrings["SqlConnStringForeign"].ToString();
|
||
|
|
||
|
GetCode(barCode, out stockNo, out batchNo, out partNo);
|
||
|
|
||
|
string layer = GetProductLayer(stockNo, partNo);
|
||
|
|
||
|
#region 判断在哪列
|
||
|
|
||
|
string strSql1 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC01)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt1 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql1, null);
|
||
|
if (dt1 != null && dt1.Rows.Count > 0)
|
||
|
{
|
||
|
columnName ="Side_1_BC01";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql2 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC02)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt2 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql2, null);
|
||
|
if (dt2 != null && dt2.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_1_BC02";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql3 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC03)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt3 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql3, null);
|
||
|
if (dt3 != null && dt3.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_1_BC03";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql4 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC04)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt4 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql4, null);
|
||
|
if (dt4 != null && dt4.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_1_BC04";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql5 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC05)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt5 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql5, null);
|
||
|
if (dt5 != null && dt5.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_1_BC05";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql6 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC06)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt6 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql6, null);
|
||
|
if (dt6 != null && dt6.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_1_BC06";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql7 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC07)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt7 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql7, null);
|
||
|
if (dt7 != null && dt7.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_1_BC07";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql8 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC08)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt8 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql8, null);
|
||
|
if (dt8 != null && dt8.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_1_BC08";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql9 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC09)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt9 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql9, null);
|
||
|
if (dt9 != null && dt9.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_1_BC09";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql10 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC10)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt10 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql10, null);
|
||
|
if (dt10 != null && dt10.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_1_BC10";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql11 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC11)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt11 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql11, null);
|
||
|
if (dt11 != null && dt11.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_1_BC11";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql12 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC12)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt12 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql12, null);
|
||
|
if (dt12 != null && dt12.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_1_BC12";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql13 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC01)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt13 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql13, null);
|
||
|
if (dt13 != null && dt13.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_2_BC01";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql14 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC02)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt14 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql14, null);
|
||
|
if (dt14 != null && dt14.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_2_BC02";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql15 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC03)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt15 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql15, null);
|
||
|
if (dt15 != null && dt15.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_2_BC03";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql16 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC04)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt16 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql16, null);
|
||
|
if (dt16 != null && dt16.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_2_BC04";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql17 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC05)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt17 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql17, null);
|
||
|
if (dt17 != null && dt17.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_2_BC05";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql18 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC06)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt18 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql18, null);
|
||
|
if (dt18 != null && dt18.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_2_BC06";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql19 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC07)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt19 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql19, null);
|
||
|
if (dt19 != null && dt19.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_2_BC07";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql20 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC08)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt20 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql20, null);
|
||
|
if (dt20 != null && dt20.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_2_BC08";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql21 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC09)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt21 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql21, null);
|
||
|
if (dt21 != null && dt21.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_2_BC09";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql22 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC10)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt22 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql22, null);
|
||
|
if (dt22 != null && dt22.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_2_BC10";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql23 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC11)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt23 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql23, null);
|
||
|
if (dt23 != null && dt23.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_2_BC11";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string strSql24 = @"select top 1 TimeStamp FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC12)) = '" + barCode + @"' order by TimeStamp desc";
|
||
|
|
||
|
DataTable dt24 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, strSql24, null);
|
||
|
if (dt24 != null && dt24.Rows.Count > 0)
|
||
|
{
|
||
|
columnName = "Side_2_BC12";
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
string sql = @"select floor from tb_LayerAndBC where des like '%" + columnName +
|
||
|
@"%' and layer=" + layer;
|
||
|
|
||
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
res = dt.Rows[0]["floor"] + "支架";
|
||
|
}
|
||
|
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据条码获取层数
|
||
|
/// </summary>
|
||
|
/// <param name="stockNo"></param>
|
||
|
/// <param name="partNo"></param>
|
||
|
/// <returns></returns>
|
||
|
public static string GetProductLayer(string stockNo, string partNo)
|
||
|
{
|
||
|
string res = "";
|
||
|
try
|
||
|
{
|
||
|
if (!string.IsNullOrWhiteSpace(stockNo))
|
||
|
{
|
||
|
string sql = @" select Layers from tb_Product where StockNo = '" + stockNo.Trim() + "' ";
|
||
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
if (aa != null)
|
||
|
{
|
||
|
res = aa.ToString();
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
if (!string.IsNullOrWhiteSpace(partNo))
|
||
|
{
|
||
|
string sql = @" select Layers from tb_Product where PartNo = '" + partNo.Trim() + "' ";
|
||
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
if (aa != null)
|
||
|
{
|
||
|
res = aa.ToString();
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 手动换班
|
||
|
/// </summary>
|
||
|
/// <param name="label"></param>
|
||
|
public static void ChangeWorkClass(Label label)
|
||
|
{
|
||
|
if (label.Text.Trim() == "A班")
|
||
|
{
|
||
|
label.Text = "B班";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
label.Text = "A班";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据条码在老外库里查询颜色信息
|
||
|
/// </summary>
|
||
|
/// <param name="barcode"></param>
|
||
|
/// <returns></returns>
|
||
|
public static string GetProductInfo(string barcode)
|
||
|
{
|
||
|
string res = "";
|
||
|
try
|
||
|
{
|
||
|
string sql = @"
|
||
|
DECLARE @barcode varchar(30);
|
||
|
SET @barcode = '" + barcode + @"';
|
||
|
SELECT top 1 Setvalue_BC_Color_No, Setvalue_CC_Color_No, Setvalue_PR_Color_No
|
||
|
FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC01)) = @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC02))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC03))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC04))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC05))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC06))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC07))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC08))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC09))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC10))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC11))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC12))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC01)) = @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC02))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC03))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC04))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC05))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC06))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC07))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC08))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC09))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC10))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC11))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC12))= @barcode
|
||
|
ORDER BY TimeStamp DESC
|
||
|
";
|
||
|
string sqlConnString = ConfigurationManager.ConnectionStrings["SqlConnStringForeign"].ToString();
|
||
|
//object aa = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql, null);
|
||
|
DataTable dtColor = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, sql, null);
|
||
|
string colorNo = "";
|
||
|
string colorQQNo = "";
|
||
|
string colorPRNo = "";
|
||
|
//if (aa != null)
|
||
|
//{
|
||
|
// colorNo = aa.ToString();
|
||
|
//}
|
||
|
if (dtColor != null && dtColor.Rows.Count > 0)
|
||
|
{
|
||
|
colorNo = dtColor.Rows[0]["Setvalue_BC_Color_No"].ToString();
|
||
|
colorQQNo = dtColor.Rows[0]["Setvalue_CC_Color_No"].ToString();
|
||
|
colorPRNo = dtColor.Rows[0]["Setvalue_PR_Color_No"].ToString();
|
||
|
}
|
||
|
|
||
|
//根据颜色代码查颜色
|
||
|
string colorInfo = "";
|
||
|
if (!string.IsNullOrWhiteSpace(colorNo))
|
||
|
{
|
||
|
DataTable dt = new DataTable();
|
||
|
//string sql_c = @" select * from tb_Color where ColorCode = '" + colorNo + "' ";
|
||
|
string sql_c = "";
|
||
|
if (!string.IsNullOrWhiteSpace(colorQQNo) && !string.IsNullOrWhiteSpace(colorPRNo))
|
||
|
{
|
||
|
sql_c = @" select * from tb_Color where ColorCode = '" + colorNo + "' and ColorQQCode = '" + colorQQNo + "' and ColorDQCode = '" + colorPRNo + "' ";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sql_c = @" select * from tb_Color where ColorCode = '" + colorNo + "'";
|
||
|
}
|
||
|
dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_c, null);
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
res = dt.Rows[0]["Des"].ToString();
|
||
|
colorInfo = dt.Rows[0]["Des"].ToString().Trim() + "," + dt.Rows[0]["ColorCode"].ToString().Trim() + "," + dt.Rows[0]["ColorNo"].ToString().Trim();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//根据条码查询产品信息
|
||
|
string stockNo = "";
|
||
|
string batchNo = "";
|
||
|
string partNo = "";
|
||
|
Function.GetCode(barcode, out stockNo, out batchNo, out partNo);
|
||
|
|
||
|
string productName = "";
|
||
|
Function.GetInfoByStockNo(stockNo, partNo, out productName);
|
||
|
colorInfo = colorInfo + "," + productName;
|
||
|
|
||
|
res = colorInfo;
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 查询补打条码信息
|
||
|
/// </summary>
|
||
|
/// <param name="barcode"></param>
|
||
|
/// <returns></returns>
|
||
|
public static string GetReprintInfo(string barcode)
|
||
|
{
|
||
|
string res = "";
|
||
|
try
|
||
|
{
|
||
|
if (!string.IsNullOrWhiteSpace(barcode))
|
||
|
{
|
||
|
string sql = @"
|
||
|
SELECT ProductID, StockNo, ColorDes,(SELECT ProductName FROM tb_Product WHERE ProductID =(SELECT top 1 ProductID FROM tb_PaintBarCode WHERE OneBarCode = '" + barcode + "')) ProductName FROM tb_PaintBarCode WHERE OneBarCode = '" + barcode + "' ";
|
||
|
DataTable aa = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
if (aa != null && aa.Rows.Count > 0)
|
||
|
{
|
||
|
res = aa.Rows[0]["ColorDes"].ToString() + "," + aa.Rows[0]["ProductName"].ToString();
|
||
|
}
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据滑撬号获取圈数
|
||
|
/// </summary>
|
||
|
/// <param name="skidNo"></param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetCircle(string skidNo)
|
||
|
{
|
||
|
int res = 0;
|
||
|
try
|
||
|
{
|
||
|
string sqlConnString = ConfigurationManager.ConnectionStrings["SqlConnStringForeign"].ToString();
|
||
|
string sql_color_xia = @" select top 1 Setvalue_BC_Color_No from Paintline_Proddata where LTrim(RTrim(Skid_No)) = '" + skidNo + @"' order by TimeStamp desc ";
|
||
|
object bb = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql_color_xia, null);
|
||
|
if (bb != null)
|
||
|
{
|
||
|
string color = bb.ToString();
|
||
|
|
||
|
res = GetCircleByColor(color);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//string sql_color = @" select top 1 Setvalue_BC_Color_No from Paintline_Loadingdata where LTrim(RTrim(Skid_No)) = '" + skidNo + @"' order by TimeStamp desc ";
|
||
|
//object aa = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql_color, null);
|
||
|
//if (aa != null)
|
||
|
//{
|
||
|
// string color = aa.ToString();
|
||
|
// res = GetCircleByColor(color);
|
||
|
//}
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据颜色号获取圈数
|
||
|
/// </summary>
|
||
|
/// <param name="colorCode"></param>
|
||
|
/// <returns></returns>
|
||
|
public static int GetCircleByColor(string colorCode)
|
||
|
{
|
||
|
int res = 0;
|
||
|
try
|
||
|
{
|
||
|
string sql = @" select isnull(Circle,0) from tb_Color where ColorCode = '" + colorCode + "' ";
|
||
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
if (aa != null)
|
||
|
{
|
||
|
Int32.TryParse(aa.ToString(), out res);
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据条码号获取AB侧
|
||
|
/// </summary>
|
||
|
/// <param name="?"></param>
|
||
|
/// <returns></returns>
|
||
|
public static string GetSide(string barcode)
|
||
|
{
|
||
|
string res = "";
|
||
|
try
|
||
|
{
|
||
|
//有一检结果的
|
||
|
string sql = @" select top 1 side from tb_InspectResult where barcode = '" + barcode + "' and InspectTimes = '1' order by createTime desc ";
|
||
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
if (aa != null)
|
||
|
{
|
||
|
res = aa.ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (string.IsNullOrWhiteSpace(res))
|
||
|
{
|
||
|
//没有一检结果,查询老外数据库
|
||
|
string sql_foreign = @"
|
||
|
DECLARE @barcode varchar(30);
|
||
|
SET @barcode = '" + barcode + @"';
|
||
|
SELECT top 1 Setvalue_BC_Color_No
|
||
|
FROM [PRODUCTION_DATA].[dbo].[Paintline_Loadingdata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC01)) = @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC02))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC03))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC04))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC05))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC06))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC07))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC08))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC09))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC10))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC11))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC12))= @barcode
|
||
|
ORDER BY TimeStamp DESC
|
||
|
";
|
||
|
string sqlConnString = ConfigurationManager.ConnectionStrings["SqlConnStringForeign"].ToString();
|
||
|
object bb = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql_foreign, null);
|
||
|
string colorNo = "";
|
||
|
if (bb != null)
|
||
|
{
|
||
|
colorNo = bb.ToString();
|
||
|
if (!string.IsNullOrWhiteSpace(colorNo))
|
||
|
{
|
||
|
res = "A侧";
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string sql_foreign2 = @"
|
||
|
DECLARE @barcode varchar(30);
|
||
|
SET @barcode = '" + barcode + @"';
|
||
|
SELECT top 1 Setvalue_BC_Color_No
|
||
|
FROM [PRODUCTION_DATA].[dbo].[Paintline_Loadingdata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC01)) = @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC02))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC03))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC04))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC05))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC06))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC07))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC08))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC09))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC10))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC11))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC12))= @barcode
|
||
|
ORDER BY TimeStamp DESC
|
||
|
";
|
||
|
object cc = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql_foreign2, null);
|
||
|
string colorNo2 = "";
|
||
|
if (cc != null)
|
||
|
{
|
||
|
colorNo2 = cc.ToString();
|
||
|
if (!string.IsNullOrWhiteSpace(colorNo2))
|
||
|
{
|
||
|
res = "B侧";
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string sql_foreign3 = @"
|
||
|
DECLARE @barcode varchar(30);
|
||
|
SET @barcode = '" + barcode + @"';
|
||
|
SELECT top 1 Setvalue_BC_Color_No
|
||
|
FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_2_BC01)) = @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC02))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC03))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC04))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC05))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC06))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC07))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC08))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC09))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC10))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC11))= @barcode
|
||
|
OR LTrim(RTrim(Side_2_BC12))= @barcode
|
||
|
ORDER BY TimeStamp DESC
|
||
|
";
|
||
|
object dd = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql_foreign3, null);
|
||
|
string colorNo3 = "";
|
||
|
if (dd != null)
|
||
|
{
|
||
|
colorNo3 = dd.ToString();
|
||
|
if (!string.IsNullOrWhiteSpace(colorNo3))
|
||
|
{
|
||
|
res = "B侧";
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string sql_foreign4 = @"
|
||
|
DECLARE @barcode varchar(30);
|
||
|
SET @barcode = '" + barcode + @"';
|
||
|
SELECT top 1 Setvalue_BC_Color_No
|
||
|
FROM [PRODUCTION_DATA].[dbo].[Paintline_Proddata]
|
||
|
WHERE LTrim(RTrim(Side_1_BC01)) = @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC02))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC03))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC04))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC05))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC06))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC07))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC08))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC09))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC10))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC11))= @barcode
|
||
|
OR LTrim(RTrim(Side_1_BC12))= @barcode
|
||
|
ORDER BY TimeStamp DESC
|
||
|
";
|
||
|
object ee = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql_foreign4, null);
|
||
|
string colorNo4 = "";
|
||
|
if (ee != null)
|
||
|
{
|
||
|
colorNo4 = ee.ToString();
|
||
|
if (!string.IsNullOrWhiteSpace(colorNo4))
|
||
|
{
|
||
|
res = "A侧";
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据一检结果显示一检时的位置
|
||
|
/// </summary>
|
||
|
/// <param name="dt"></param>
|
||
|
/// <returns></returns>
|
||
|
public static string GetFirstInsPosition(DataTable dt)
|
||
|
{
|
||
|
string res = "";
|
||
|
try
|
||
|
{
|
||
|
if (dt != null && dt.Rows.Count > 0)
|
||
|
{
|
||
|
DataRow[] dr = dt.Select(" InspectTimes = '1' ");
|
||
|
if (dr != null && dr.Length > 0)
|
||
|
{
|
||
|
string position = dr[0]["position"].ToString();
|
||
|
|
||
|
string sql = @" select value from tb_Config where name = 'RemoveStr' ";
|
||
|
object objStr = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
if (objStr != null)
|
||
|
{
|
||
|
res = position.Replace(objStr.ToString(), "").Trim();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 判断条码有效性
|
||
|
/// </summary>
|
||
|
/// <param name="barcode"></param>
|
||
|
/// <returns></returns>
|
||
|
public static bool BarCodeValid(string barcode)
|
||
|
{
|
||
|
bool res = false;
|
||
|
if (!string.IsNullOrWhiteSpace(barcode))
|
||
|
{
|
||
|
if (barcode.Contains("."))
|
||
|
{
|
||
|
res = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (barcode.Length == 20)
|
||
|
{
|
||
|
res = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 将二维码转换成相应一维码
|
||
|
/// </summary>
|
||
|
/// <param name="barcode"></param>
|
||
|
/// <returns></returns>
|
||
|
public static string TransToBarCodeOne(string barcode)
|
||
|
{
|
||
|
string res = "";
|
||
|
try
|
||
|
{
|
||
|
string sql = @"
|
||
|
SELECT TOP 1 OneBarCode FROM tb_BarCode WHERE BarCode = '" + barcode + @"'
|
||
|
";
|
||
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
if (aa != null)
|
||
|
{
|
||
|
res = aa.ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
string sqll = @"
|
||
|
select OneBarCode
|
||
|
from [10.60.101.60].[BBMPT1].[dbo].[v_Code]
|
||
|
where barcode = '"+ barcode +@"'
|
||
|
";
|
||
|
object bb = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sqll, null);
|
||
|
if (bb != null)
|
||
|
{
|
||
|
res = bb.ToString();
|
||
|
}
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 将传入条码统一变成一维码
|
||
|
/// </summary>
|
||
|
/// <param name="barcode"></param>
|
||
|
/// <returns></returns>
|
||
|
public static string UniteBarCodeToOne(string barcode)
|
||
|
{
|
||
|
string res = barcode;
|
||
|
if (!string.IsNullOrWhiteSpace(barcode))
|
||
|
{
|
||
|
if (barcode.Contains("."))
|
||
|
{
|
||
|
res = TransToBarCodeOne(barcode);
|
||
|
}
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
public static DataTable GetMesBarCode(string title, string sideNo, out string bcStrs)
|
||
|
{
|
||
|
DataTable res = new DataTable();
|
||
|
bcStrs = "";
|
||
|
try
|
||
|
{
|
||
|
string sql = @" select top 1 Layer from tb_SkidInfo where SkidNo = '" + sideNo + "' order by CreateTime desc ";
|
||
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
if (aa != null)
|
||
|
{
|
||
|
string layer = aa.ToString(); //层数
|
||
|
|
||
|
string szx = ""; //上中下
|
||
|
if (title.Contains("上"))
|
||
|
{
|
||
|
szx = "上";
|
||
|
}
|
||
|
else if (title.Contains("中"))
|
||
|
{
|
||
|
szx = "中";
|
||
|
}
|
||
|
else if (title.Contains("下"))
|
||
|
{
|
||
|
szx = "下";
|
||
|
}
|
||
|
|
||
|
string side = "";
|
||
|
if (title.Contains("A"))
|
||
|
{
|
||
|
side = "A";
|
||
|
}
|
||
|
else if (title.Contains("B"))
|
||
|
{
|
||
|
side = "B";
|
||
|
}
|
||
|
|
||
|
string sqlQuery = @" SELECT des FROM tb_LayerAndBC WHERE layer = '" + layer + "' AND [floor] = '" + szx + "' AND side = '" + side + "' ";
|
||
|
object bb = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sqlQuery, null);
|
||
|
if(bb != null)
|
||
|
{
|
||
|
bcStrs = bb.ToString();
|
||
|
|
||
|
#region 拼接查询时的列条件
|
||
|
string[] bcStr = bcStrs.Split(';');
|
||
|
string sqlBcStr = "";
|
||
|
for (int i = 0; i < bcStr.Length; i++)
|
||
|
{
|
||
|
sqlBcStr += bcStr[i] + ",";
|
||
|
}
|
||
|
sqlBcStr = sqlBcStr.Remove(sqlBcStr.Length - 1);
|
||
|
#endregion
|
||
|
|
||
|
string sqlGetBarCode = @" select top 1 ColorInfo, " + sqlBcStr + " from tb_SkidInfo order by CreateTime desc ";
|
||
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqlGetBarCode, null);
|
||
|
}
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static DataTable SearchWaitAddPro()
|
||
|
{
|
||
|
DataTable dt = new DataTable();
|
||
|
try
|
||
|
{
|
||
|
string sql = @"
|
||
|
SELECT distinct barcode
|
||
|
FROM tb_InspectResult
|
||
|
where (productinfo = '' or (productinfo is null))
|
||
|
and len(barcode) = 20
|
||
|
";
|
||
|
dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
return dt;
|
||
|
}
|
||
|
|
||
|
public static void AddProColInfo(string barcode, string productInfo)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = @"
|
||
|
update tb_InspectResult
|
||
|
set productinfo = '"+ productInfo +@"'
|
||
|
where barcode = '"+ barcode + @"'
|
||
|
and (productinfo = '' or (productinfo is null))
|
||
|
";
|
||
|
SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static string GetImgPath()
|
||
|
{
|
||
|
string res = "";
|
||
|
try
|
||
|
{
|
||
|
string sql_imgPath = " select top 1 value from tb_Config where name = 'ImgPath' ";
|
||
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql_imgPath, null);
|
||
|
if (aa != null)
|
||
|
{
|
||
|
res = aa.ToString();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
public static int GetskidMax()
|
||
|
{
|
||
|
int res = 305;
|
||
|
try
|
||
|
{
|
||
|
string sql = " select [value] from [tb_Config] where [name] = 'SkidNoMax' ";
|
||
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
if (aa != null)
|
||
|
{
|
||
|
res = Tools.NumericParse.StringToInt(aa.ToString());
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
public static int SaveChangColor(string Barcode,string resultStr,string name)
|
||
|
{
|
||
|
int res = 0;
|
||
|
try
|
||
|
{
|
||
|
string sql = @"INSERT INTO [tb_StockInColor]
|
||
|
([ID]
|
||
|
,[Barcode]
|
||
|
,[ColorInfo],CreateBy)
|
||
|
VALUES
|
||
|
((select newid())
|
||
|
,'" + Barcode + @"'
|
||
|
,'" + resultStr + @"',
|
||
|
'"+ name +@"');";
|
||
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
}
|