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.
2464 lines
109 KiB
2464 lines
109 KiB
using DBUtility;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Reflection;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using MESClassLibrary.BLL.Log;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
using Tools;
|
|
using WebService.Model;
|
|
|
|
namespace Webservice
|
|
{
|
|
public class Function
|
|
{
|
|
public static readonly string app_id = "9b38d8d9-af87-49d2-a0a1-87516c86f254";
|
|
public static readonly string app_secret = "422f5bd0-0393-408b-9024-a98f8c6367a4";
|
|
|
|
/// <summary>
|
|
/// 判断AppID是否合法
|
|
/// </summary>
|
|
/// <param name="app_id"></param>
|
|
/// <returns></returns>
|
|
public static bool AppIDIsRight(string app_id)
|
|
{
|
|
if (app_id.Trim() != Function.app_id.Trim())
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public static string MD5Encryption(string str)
|
|
{
|
|
try
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(str))
|
|
{
|
|
byte[] result = Encoding.Default.GetBytes(str); //tbPass为输入密码的文本框
|
|
MD5 md5 = new MD5CryptoServiceProvider();
|
|
byte[] output = md5.ComputeHash(result);
|
|
return BitConverter.ToString(output).Replace("-", "");
|
|
}
|
|
else
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
return string.Empty;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 传入的参数是否合法
|
|
/// </summary>
|
|
/// <param name="param"></param>
|
|
/// <param name="sign"></param>
|
|
/// <returns></returns>
|
|
public static bool signIsRight(string[] param, string sign)
|
|
{
|
|
bool res;
|
|
string str = "";
|
|
if (param.Length > 0)
|
|
{
|
|
foreach (string s in param)
|
|
{
|
|
str += s.Trim();
|
|
}
|
|
}
|
|
string getMd5 = MD5Encryption(str);
|
|
if (getMd5 != sign)
|
|
{
|
|
res = false;
|
|
}
|
|
else
|
|
{
|
|
res = true;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static DataTable GetInfoByParticles(string stockNo, string partNo, out string errorReason)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(stockNo))
|
|
{
|
|
string sql = @"
|
|
select * from tb_Product where StockNo = '" + stockNo + @"'
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
}
|
|
else if (!string.IsNullOrWhiteSpace(partNo))
|
|
{
|
|
string sql = @"
|
|
select * from tb_Product where PartNo = '" + partNo + @"'
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static bool QueryIsBind(string particleCode, string drumCode, out string errorReason)
|
|
{
|
|
try
|
|
{
|
|
string sql = " SELECT * FROM tb_StationAndCylinder WHERE CylinderID = ( SELECT CylinderID from tb_Cylinder WHERE CylinderNo = ('" + drumCode + "') ) and Time2 is null ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
errorReason = " 料筒" + drumCode + "已绑定了塑料粒子与注塑机,请先做解绑操作!";
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
string sql_2 = " update tb_CylinderAndRaw set Time2 = getdate() where DrumBarCode = '" + drumCode.Trim() + "' and Time2 is null ";
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql_2, null);
|
|
errorReason = "";
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
errorReason = ex.ToString();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public static bool UnBindParticleAndDrum(string drumCode, out string errorReason)
|
|
{
|
|
bool res = false;
|
|
errorReason = "";
|
|
try
|
|
{
|
|
string sql = @"
|
|
insert into tb_JbCylinderAndRaw([CylinderID]
|
|
,[DrumBarCode]
|
|
,[BarCode]
|
|
,[Time1])
|
|
select [CylinderID]
|
|
,[DrumBarCode]
|
|
,[BarCode]
|
|
,[Time1]
|
|
from tb_CylinderAndRaw
|
|
where DrumBarCode = '" + drumCode + @"';
|
|
delete from tb_CylinderAndRaw where DrumBarCode = '" + drumCode + @"';
|
|
";
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
res = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
errorReason = ex.ToString();
|
|
res = false;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定塑料粒子与料筒
|
|
/// </summary>
|
|
/// <param name="particleCode">塑料粒子</param>
|
|
/// <param name="drumCode">料筒</param>
|
|
/// <param name="errorReason"></param>
|
|
/// <returns></returns>
|
|
public static int BindparticleCodeAndDrum(string particleCode, string drumCode, out string errorReason)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"
|
|
insert into tb_CylinderAndRaw(ID, CylinderID, DrumBarCode, BarCode, Time1)
|
|
values((select newid()),(select CylinderID from tb_Cylinder where CylinderNo = '" + drumCode + @"'),'" + drumCode + @"',
|
|
'" + particleCode + @"', (select getdate()))
|
|
";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 注塑机号(即工位号)
|
|
/// </summary>
|
|
/// <param name="machineCode"></param>
|
|
/// <param name="errorReason"></param>
|
|
/// <returns></returns>
|
|
public static DataTable GetPlan(string machineCode, out string errorReason)
|
|
{
|
|
errorReason = "";
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
#region 注销
|
|
//// string sql = @"
|
|
//// select top 1 ProductName as [Plan] from tb_Product where StockNo in (
|
|
//// select top 1 StockNo from tb_InjectionPlan where StationID = (
|
|
//// select StationID from tb_Station where StationNo = '" + machineCode + @"' )
|
|
//// AND (IsFinish IS NULL OR IsFinish = 0)
|
|
//// ORDER BY BeginTime ASC
|
|
//// )
|
|
//// ";
|
|
// string sql = @"
|
|
// select top 1 ProductName as [Plan] from tb_Product where StockNo in (
|
|
//
|
|
// select REPLACE(SUBSTRING((select top 1 StockNo from tb_InjectionPlan where StationID = (
|
|
// select StationID from tb_Station where StationNo = 'IM01' )
|
|
// AND (IsFinish IS NULL OR IsFinish = 0)
|
|
// ORDER BY BeginTime ASC),1,charindex(',',(select top 1 StockNo from tb_InjectionPlan where StationID = (
|
|
// select StationID from tb_Station where StationNo = 'IM01' )
|
|
// AND (IsFinish IS NULL OR IsFinish = 0)
|
|
// ORDER BY BeginTime ASC))),',',''))
|
|
// ";
|
|
// res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
// if (res == null || res.Rows.Count < 1)
|
|
// {
|
|
//// string sql2 = @" select top 1 ProductName as [Plan] from tb_Product where PartNo in (
|
|
//// select top 1 PartNo from tb_InjectionPlan where StationID = (
|
|
//// select StationID from tb_Station where StationNo = '" + machineCode + @"' )
|
|
//// AND (IsFinish IS NULL OR IsFinish = 0)
|
|
//// ORDER BY BeginTime ASC
|
|
//// )
|
|
//// ";
|
|
// string sql2 = @"
|
|
// select top 1 ProductName as [Plan] from tb_Product where PartNo in (
|
|
//
|
|
// select REPLACE(SUBSTRING((select top 1 PartNo from tb_InjectionPlan where StationID = (
|
|
// select StationID from tb_Station where StationNo = 'IM01' )
|
|
// AND (IsFinish IS NULL OR IsFinish = 0)
|
|
// ORDER BY BeginTime ASC),1,charindex(',',(select top 1 StockNo from tb_InjectionPlan where StationID = (
|
|
// select StationID from tb_Station where StationNo = 'IM01' )
|
|
// AND (IsFinish IS NULL OR IsFinish = 0)
|
|
// ORDER BY BeginTime ASC))),',',''))
|
|
// ";
|
|
// res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql2, null);
|
|
// }
|
|
#endregion
|
|
|
|
string ssql = @"
|
|
select top 1 StockNo,PartNo from tb_InjectionPlan where StationID = (
|
|
select StationID from tb_Station where StationNo = '" + machineCode + @"' )
|
|
AND (IsFinish IS NULL OR IsFinish = 0)
|
|
ORDER BY BeginTime ASC
|
|
";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, ssql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
string stockNos = dt.Rows[0]["StockNo"].ToString();
|
|
string partNos = dt.Rows[0]["PartNo"].ToString();
|
|
if (stockNos.Contains(",") || partNos.Contains(","))
|
|
{
|
|
//计划生产两个产品
|
|
string[] stocks = { "", "" };
|
|
string[] parts = { "", "" };
|
|
if (stockNos.Contains(","))
|
|
{
|
|
stocks = stockNos.Split(',');
|
|
}
|
|
if (partNos.Contains(","))
|
|
{
|
|
parts = partNos.Split(',');
|
|
}
|
|
string sql = @" select top 1 a.ProductName+'|'+b.ProductName as [Plan], stuff((select ','+PartNo2 from tb_Bom where PartNo1 = '" + parts[0] + @"' FOR xml PATH('')), 1, 1, '') as Material from
|
|
( select ProductName from tb_Product where StockNo in ('" + stocks[0] + @"','" + stocks[1] + @"') or partNo in ('" + parts[0] + @"','" + parts[1] + @"') ) a,
|
|
( select ProductName from tb_Product where StockNo in ('" + stocks[0] + @"','" + stocks[1] + @"') or partNo in ('" + parts[0] + @"','" + parts[1] + @"') ) b
|
|
where a.ProductName != b.ProductName ";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
else
|
|
{
|
|
//计划只生产一个产品
|
|
string sql = @" select top 1 ProductName as [Plan], stuff((select ','+PartNo2 from tb_Bom where PartNo1 = '" + partNos + @"' FOR xml PATH('')), 1, 1, '') as Material from tb_Product where PartNo = '" + partNos + "' ";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errorReason = "根据注塑机号查询不到信息,请查看是否维护生产计划";
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static DataTable GetMaterialInfo(string drumCode, out string errorReason)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"
|
|
select top 1 BarCode from tb_CylinderAndRaw where DrumBarCode = '" + drumCode + @"' and Time2 is null order by Time1 desc
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定注塑机与料筒
|
|
/// </summary>
|
|
/// <param name="machineCode">注塑机(实际传的是工位号,一个工位就是一个注塑机)</param>
|
|
/// <param name="drumCode">料筒</param>
|
|
/// <param name="errorReason"></param>
|
|
/// <returns></returns>
|
|
public static int BindMachineAndDrum(string machineCode, string drumCode, out string errorReason)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
#region 查询当前注塑机计划生产的产品与料筒中的原料是否有对应关系,如果不匹配则不能绑定
|
|
|
|
string particlePartNo = "";
|
|
string productPartNo = "";
|
|
|
|
string sqlGetproductPartNo = @"
|
|
select top 1 partNo from tb_InjectionPlan WHERE StationID = (
|
|
SELECT StationID FROM tb_Station WHERE StationNo = '" + machineCode + @"'
|
|
)
|
|
AND (IsFinish IS NULL OR IsFinish = 0)
|
|
ORDER BY BeginTime
|
|
";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sqlGetproductPartNo, null);
|
|
if (aa != null)
|
|
{
|
|
productPartNo = aa.ToString();
|
|
}
|
|
|
|
string sqlGetparticlePartNo = @"
|
|
SELECT TOP 1 BarCode
|
|
FROM tb_CylinderAndRaw
|
|
WHERE DrumBarCode = '" + drumCode + @"'
|
|
AND Time2 IS NULL
|
|
ORDER BY Time1 DESC
|
|
|
|
";
|
|
object bb = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sqlGetparticlePartNo, null);
|
|
if (bb != null)
|
|
{
|
|
string stockNo = "";
|
|
string partNo = "";
|
|
string batchNo = "";
|
|
GetCode(bb.ToString(), out stockNo, out batchNo, out partNo);
|
|
particlePartNo = partNo;
|
|
}
|
|
|
|
DataTable dt = new DataTable();
|
|
if (productPartNo.Contains(","))
|
|
{
|
|
string[] zz = productPartNo.Split(',');
|
|
|
|
string sqlGetProductAndMetiral = @" SELECT * FROM tb_Bom WHERE PartNo1 = '" + zz[0] + @"' AND PartNo2 = '" + particlePartNo + @"' ";
|
|
dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqlGetProductAndMetiral, null);
|
|
}
|
|
else
|
|
{
|
|
string sqlGetProductAndMetiral = @" SELECT * FROM tb_Bom WHERE PartNo1 = '" + productPartNo + @"' AND PartNo2 = '" + particlePartNo + @"' ";
|
|
dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqlGetProductAndMetiral, null);
|
|
}
|
|
|
|
|
|
LogHelper.WriteSysLogBase("APP【绑定注塑机与料筒】machineCode:" + machineCode + ",drumCode:" + drumCode + ",产品:" + productPartNo + ",原料:" + particlePartNo, MethodBase.GetCurrentMethod().Name);
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
#region 20200927注销:先解绑之前的注塑机与料筒
|
|
|
|
// string sql_unBind = " update tb_StationAndCylinder set Time2 = getdate() where StationID = (select StationID from tb_Station where StationNo = '" + machineCode + @"') ";
|
|
// SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql_unBind, null);
|
|
|
|
// string sql_unBind2 = @" update tb_StationAndCylinder set Time2 = getdate() where CylinderID = ( SELECT top 1 CylinderID
|
|
// FROM tb_CylinderAndRaw
|
|
// WHERE DrumBarCode = '"+ drumCode +@"'
|
|
// AND Time2 IS NULL
|
|
// ORDER BY Time1 DESC ) ";
|
|
// SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql_unBind2, null);
|
|
|
|
#endregion
|
|
|
|
#region 绑定注塑机与料筒
|
|
string sql = @"
|
|
insert into tb_StationAndCylinder(ID, StationID, CylinderID, Time1, StationNo, CylinderNo)
|
|
values((select newid()), (select StationID from tb_Station where StationNo = '" + machineCode + @"'),
|
|
(select CylinderID from tb_Cylinder where CylinderNo = '" + drumCode + @"'),
|
|
(select getdate()), '" + machineCode + @"','" + drumCode + @"' )
|
|
";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
errorReason = "";
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
res = 0;
|
|
errorReason = "当前注塑机生产产品与料筒的原料不匹配";
|
|
}
|
|
|
|
#endregion
|
|
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定注塑机与料筒(双料筒)
|
|
/// </summary>
|
|
/// <param name="machineCode">注塑机(实际传的是工位号,一个工位就是一个注塑机)</param>
|
|
/// <param name="drumCode">料筒</param>
|
|
/// <param name="errorReason"></param>
|
|
/// <returns></returns>
|
|
public static int BindMachineAndDrum2(string machineCode, string drumCode1, string drumCode2, out string errorReason)
|
|
{
|
|
int res = 0;
|
|
errorReason = "";
|
|
try
|
|
{
|
|
#region 查产品(一个或两个,逗号分隔)
|
|
|
|
string productpartNo = "";
|
|
string sqlGetproductPartNo = @"
|
|
select top 1 partNo from tb_InjectionPlan WHERE StationID = (
|
|
SELECT StationID FROM tb_Station WHERE StationNo = '" + machineCode + @"'
|
|
)
|
|
AND (IsFinish IS NULL OR IsFinish = 0)
|
|
ORDER BY BeginTime
|
|
";
|
|
object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sqlGetproductPartNo, null);
|
|
if (aa != null)
|
|
{
|
|
productpartNo = aa.ToString();
|
|
}
|
|
else
|
|
{
|
|
errorReason = "根据当前机台查找不到计划生产的产品,请查看生产计划";
|
|
return res;
|
|
}
|
|
#endregion
|
|
|
|
#region 查原料(两个)
|
|
|
|
string meaa = @"
|
|
SELECT TOP 1 BarCode
|
|
FROM tb_CylinderAndRaw
|
|
WHERE DrumBarCode = '" + drumCode1 + @"'
|
|
AND Time2 IS NULL
|
|
ORDER BY Time1 DESC
|
|
";
|
|
object bb = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, meaa, null);
|
|
if (bb != null)
|
|
{
|
|
string stockNo = "";
|
|
string partNo = "";
|
|
string batchNo = "";
|
|
GetCode(bb.ToString(), out stockNo, out batchNo, out partNo);
|
|
string particlePartNo = partNo;
|
|
|
|
string sqlGetProductAndMetiral = @" SELECT * FROM tb_Bom WHERE PartNo1 = '" + productpartNo + @"' AND PartNo2 = '" + particlePartNo + @"' ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqlGetProductAndMetiral, null);
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
string mebb = @"
|
|
SELECT TOP 1 BarCode
|
|
FROM tb_CylinderAndRaw
|
|
WHERE DrumBarCode = '" + drumCode2 + @"'
|
|
AND Time2 IS NULL
|
|
ORDER BY Time1 DESC
|
|
";
|
|
object cc = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, mebb, null);
|
|
if (cc != null)
|
|
{
|
|
string stockNo2 = "";
|
|
string partNo2 = "";
|
|
string batchNo2 = "";
|
|
GetCode(cc.ToString(), out stockNo2, out batchNo2, out partNo2);
|
|
particlePartNo = partNo2;
|
|
|
|
string sqlGetProductAndMetiral2 = @" SELECT * FROM tb_Bom WHERE PartNo1 = '" + productpartNo + @"' AND PartNo2 = '" + particlePartNo + @"' ";
|
|
DataTable dt2 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqlGetProductAndMetiral, null);
|
|
|
|
if (dt2 != null && dt2.Rows.Count > 0)
|
|
{
|
|
#region 先解绑之前的注塑机与料筒
|
|
|
|
string sql_unBind = " update tb_StationAndCylinder2 set Time2 = getdate() where StationID = (select StationID from tb_Station where StationNo = '" + machineCode + @"') ";
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql_unBind, null);
|
|
|
|
string sql_unBind2 = @" update tb_StationAndCylinder2 set Time2 = getdate() where CylinderID = ( SELECT top 1 CylinderID
|
|
FROM tb_CylinderAndRaw
|
|
WHERE DrumBarCode = '" + drumCode1 + @"'
|
|
AND Time2 IS NULL
|
|
ORDER BY Time1 DESC ) ";
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql_unBind2, null);
|
|
|
|
string sql_unBind3 = @" update tb_StationAndCylinder2 set Time2 = getdate() where CylinderID = ( SELECT top 1 CylinderID
|
|
FROM tb_CylinderAndRaw
|
|
WHERE DrumBarCode = '" + drumCode2 + @"'
|
|
AND Time2 IS NULL
|
|
ORDER BY Time1 DESC ) ";
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql_unBind3, null);
|
|
|
|
#endregion
|
|
|
|
#region 绑定注塑机与料筒
|
|
string sql = @"
|
|
insert into tb_StationAndCylinder2(ID, StationID, CylinderID1, CylinderID2, Time1)
|
|
values((select newid()), (select StationID from tb_Station where StationNo = '" + machineCode + @"'),
|
|
(select CylinderID from tb_Cylinder where CylinderNo = '" + drumCode1 + @"'),
|
|
(select CylinderID from tb_Cylinder where CylinderNo = '" + drumCode2 + @"'),
|
|
(select getdate()))
|
|
";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
errorReason = "";
|
|
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
errorReason = "当前注塑机生产产品" + productpartNo + "与料筒的原料" + particlePartNo + "不匹配";
|
|
return res;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errorReason = "根据当前料筒号" + drumCode2 + "查找不到原料,请进行绑定操作";
|
|
return res;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errorReason = "当前注塑机生产产品" + productpartNo + "与料筒的原料" + particlePartNo + "不匹配";
|
|
return res;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errorReason = "根据当前料筒号" + drumCode2 + "查找不到原料,请进行绑定操作";
|
|
return res;
|
|
}
|
|
|
|
#endregion
|
|
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 解绑料筒的绑定关系
|
|
/// </summary>
|
|
/// <param name="drumCode"></param>
|
|
/// <param name="errorReason"></param>
|
|
/// <returns></returns>
|
|
public static int ClearDrum(string drumCode, out string errorReason)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = @"
|
|
update tb_CylinderAndRaw set Time2 = (select getdate())
|
|
where CylinderID = (select CylinderID from tb_Cylinder where CylinderNo = '" + drumCode + @"')
|
|
and Time2 is null;
|
|
update tb_StationAndCylinder set Time2 = (select getdate())
|
|
where CylinderID = (select CylinderID from tb_Cylinder where CylinderNo = '" + drumCode + @"')
|
|
and Time2 is null;
|
|
";
|
|
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static bool UnBindStationAndCylinder(string machineCode, string drumCode, out string errorReason)
|
|
{
|
|
errorReason = "";
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = @"
|
|
insert into tb_JbStationAndCylinder([StationID]
|
|
,[CylinderID]
|
|
,[Time1]
|
|
,[StationNo]
|
|
,[CylinderNo])
|
|
select [StationID]
|
|
,[CylinderID]
|
|
,[Time1]
|
|
,[StationNo]
|
|
,[CylinderNo]
|
|
from tb_StationAndCylinder
|
|
where StationNo = '" + machineCode + @"' and CylinderNo = '" + drumCode + @"';
|
|
delete from tb_StationAndCylinder where StationNo = '" + machineCode + @"' and CylinderNo = '" + drumCode + @"';
|
|
";
|
|
int i = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (i >= 1)
|
|
{
|
|
res = true;
|
|
}
|
|
else
|
|
{
|
|
res = false;
|
|
errorReason = "料筒与机台未进行绑定,无需解绑";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
errorReason = ex.Message;
|
|
res = false;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
#region 工具
|
|
|
|
/// <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];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
stockNo = ""; //存货代码
|
|
batchNo = ""; //批次
|
|
partNo = ""; //零件号
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 转换字符串编码
|
|
/// </summary>
|
|
/// <param name="str"></param>
|
|
/// <returns></returns>
|
|
public static string EncodingStr(String str)
|
|
{
|
|
Encoding utf8 = Encoding.UTF8;
|
|
Encoding defaultCode = Encoding.Default;
|
|
byte[] utf8Bytes = defaultCode.GetBytes(str);
|
|
byte[] defaultBytes = Encoding.Convert(utf8, defaultCode, utf8Bytes);
|
|
char[] defaultChars = new char[defaultCode.GetCharCount(defaultBytes, 0, defaultBytes.Length)];
|
|
defaultCode.GetChars(defaultBytes, 0, defaultBytes.Length, defaultChars, 0);
|
|
return new string(defaultChars);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region WMS接口
|
|
|
|
|
|
/// <summary>
|
|
/// 根据条码查询产线ID
|
|
/// lx 20190610
|
|
/// </summary>
|
|
/// <param name="barcode"></param>
|
|
/// <returns></returns>
|
|
public static DataTable GetLineIDByBarcode(string barcode)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @" SELECT [StationID]
|
|
,[LineID]
|
|
FROM tb_Station
|
|
WHERE StationID = ( SELECT TOP 1 StationID
|
|
FROM tb_BarCode
|
|
WHERE BarCode = '" + barcode + @"' ) ";
|
|
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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据产线ID查询工厂ID
|
|
/// lx 20190610
|
|
/// </summary>
|
|
/// <param name="lineID"></param>
|
|
/// <returns></returns>
|
|
public static DataTable GetFactoryIDByLineId(string lineID)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @" SELECT FactoryID
|
|
FROM tb_Place
|
|
WHERE PlaceID = (
|
|
SELECT PlaceID FROM tb_Line WHERE LineID = '" + lineID + @"'
|
|
) ";
|
|
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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据id查询指定值
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="name"></param>
|
|
/// <returns></returns>
|
|
public static string GetNoByID(string id, string name)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string queryName = "";
|
|
string tableName = "";
|
|
switch (name.ToLower().Trim())
|
|
{
|
|
case "lineid":
|
|
queryName = " LineName ";
|
|
tableName = " tb_Line ";
|
|
break;
|
|
case "factoryid":
|
|
queryName = " FactoryName ";
|
|
tableName = " tb_Factory ";
|
|
break;
|
|
}
|
|
string sql = @" select " + queryName + " from " + tableName + " where " + name + " = '" + id + "' ";
|
|
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>
|
|
/// <param name="isPass"></param>
|
|
/// <param name="stcokNo"></param>
|
|
/// <param name="partNo"></param>
|
|
/// <param name="batchNo"></param>
|
|
/// <returns></returns>
|
|
public static string WMSSpraying(string barcode, int isPass, string stcokNo, string partNo, string batchNo)
|
|
{
|
|
JsonModel<NoModel> model = new JsonModel<NoModel>();
|
|
model.Result = "0";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = "";
|
|
model.DataList = null;
|
|
string lu_code = "";
|
|
int repaint = 0;
|
|
|
|
try
|
|
{
|
|
#region 目前全部存储一维码,将二维码转换为一维码
|
|
|
|
if (barcode.Contains("."))
|
|
{
|
|
barcode = Function.TransToBarCodeOne(barcode);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 查看是否已入库,已入库的不允许再入库 融合入AllowSendToWms
|
|
//融合入AllowSendToWms
|
|
//if (IsStockIn(barcode))
|
|
//{
|
|
// model.Result = "0";
|
|
// model.ResultType = "Result";
|
|
// model.ResultRowsCount = "0";
|
|
// model.ErrReason = "已入库,不能再次入库";
|
|
|
|
// return JSONTools.ScriptSerialize<JsonModel<NoModel>>(model);
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region 根据条码查找喷涂线,看线上是否出现过此条码,没有则返回错误--注销 20190728
|
|
//if (!barcode.Contains(".") && barcode.Length > 4)
|
|
//{
|
|
// string strCode = barcode.Substring(barcode.Length - 4, 4);
|
|
// int num = 0;
|
|
// Int32.TryParse(strCode, out num);
|
|
// if (num < 7000)
|
|
// {
|
|
// if (!ExistInLine(barcode))
|
|
// {
|
|
// model.Result = "0";
|
|
// model.ResultType = "Result";
|
|
// model.ResultRowsCount = "0";
|
|
// model.ErrReason = "喷涂上线查找不到该条码,无法进行质量判定,请补打条码";
|
|
|
|
// return JSONTools.ScriptSerialize<JsonModel<NoModel>>(model);
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region 没有进行质量判定,不允许入库 融合入AllowSendToWms
|
|
//融合入AllowSendToWms
|
|
//if (!exsitInspectResult(barcode))
|
|
//{
|
|
// model.Result = "0";
|
|
// model.ResultType = "Result";
|
|
// model.ResultRowsCount = "0";
|
|
// model.ErrReason = "没有进行质量判定,不能入库";
|
|
|
|
// return JSONTools.ScriptSerialize<JsonModel<NoModel>>(model);
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region 合格状态下,查看记录是否一致,若是不合格,不合格的不允许入库 融合入AllowSendToWms
|
|
//融合入AllowSendToWms
|
|
//if (isPass == 1)
|
|
//{
|
|
// if (!barcodeStatus(barcode))
|
|
// {
|
|
// model.Result = "0";
|
|
// model.ResultType = "Result";
|
|
// model.ResultRowsCount = "0";
|
|
// model.ErrReason = "产品检验不合格,不能入库";
|
|
|
|
// return JSONTools.ScriptSerialize<JsonModel<NoModel>>(model);
|
|
// }
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region 是否允许发送给wms 返喷判断 合格或不合格同检测记录是否一致,报废转合格,已报工校验, 读取返喷状态和颜色状态
|
|
|
|
if (string.IsNullOrWhiteSpace(stcokNo))
|
|
{
|
|
model.Result = "0";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = barcode + "的存货代码为空,请维护基础信息!";
|
|
model.DataList = null;
|
|
|
|
return JSONTools.ScriptSerialize<JsonModel<NoModel>>(model);
|
|
}
|
|
|
|
|
|
string msg = string.Empty;
|
|
if(AllowSendToWms(barcode,isPass, ref repaint,ref msg,ref lu_code) == false)
|
|
{
|
|
model.Result = "0";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = msg;
|
|
|
|
return JSONTools.ScriptSerialize<JsonModel<NoModel>>(model);
|
|
}
|
|
#endregion
|
|
|
|
#region 转换零件号,并查找油漆件的零件号
|
|
|
|
LogHelper.WriteSysLogBase("【转换零件号】:barcode:" + barcode, MethodBase.GetCurrentMethod().Name);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(stcokNo))
|
|
{
|
|
#region 通过塑件存货代码和颜色查找对应油漆件零件号 融合入AllowSendToWms
|
|
|
|
//lu_code = Function.GetPaintCoe(barcode);
|
|
|
|
#endregion
|
|
|
|
if (string.IsNullOrWhiteSpace(lu_code))
|
|
{
|
|
model.Result = "0";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = barcode + "的油漆件的零件号不存在!";
|
|
model.DataList = null;
|
|
|
|
return JSONTools.ScriptSerialize<JsonModel<NoModel>>(model);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
model.Result = "0";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = barcode + "的零件号为空,请维护零件号!";
|
|
model.DataList = null;
|
|
|
|
return JSONTools.ScriptSerialize<JsonModel<NoModel>>(model);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 组织参数
|
|
|
|
List<WMS03Model> list = new List<WMS03Model>();
|
|
WMS03Model wmsM = new WMS03Model();
|
|
wmsM.BarCode = barcode;
|
|
wmsM.WmsBarCode = "";
|
|
wmsM.LU_Code = lu_code;
|
|
wmsM.Batch = batchNo;
|
|
wmsM.Q_level = "";
|
|
wmsM.CreationTime = DateTime.Now;
|
|
wmsM.IsOk = isPass;
|
|
wmsM.Ok_Status = isPass.ToString();
|
|
wmsM.FactoryId = 0;
|
|
wmsM.LineId = 0;
|
|
wmsM.WmsRead = 1;
|
|
wmsM.ReadTime = null;
|
|
wmsM.Remark = "";
|
|
wmsM.Repaint = repaint.ToString();
|
|
#region 产线及工厂ID
|
|
|
|
LogHelper.WriteSysLogBase("【添加产线ID】barcode:" + barcode, MethodBase.GetCurrentMethod().Name);
|
|
|
|
string lineid = ConfigurationManager.AppSettings["LineID"].ToString().Trim();
|
|
int lineId = 0;
|
|
Int32.TryParse(lineid, out lineId);
|
|
wmsM.LineId = lineId;
|
|
|
|
#endregion
|
|
|
|
list.Add(wmsM);
|
|
|
|
#endregion
|
|
|
|
#region 调用WMS接口前记录数据
|
|
|
|
string sql_bf = @" INSERT INTO [tb_StockIn_beif]
|
|
([ID]
|
|
,[barcode]
|
|
,[pass]
|
|
,[createTime])
|
|
VALUES
|
|
((select newid())
|
|
,'" + barcode + @"'
|
|
,'" + isPass.ToString() + @"'
|
|
,(select getdate())) ";
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql_bf, null);
|
|
|
|
#endregion
|
|
|
|
#region 调用WMS Web Service
|
|
|
|
WebService.WebReference.JsonService webService = new WebService.WebReference.JsonService();
|
|
webService.Url = ConfigurationManager.AppSettings["WMSWebServiceURL"].ToString();
|
|
webService.Timeout = 1200000;
|
|
|
|
string jsonParam = " [{\"ServiceType\":\"AddMesData\",\"OperName\":\"ADMIN\"}]";
|
|
string strJson = "[25," + JSONTools.ScriptSerialize<List<WMS03Model>>(list) + "]";
|
|
|
|
#endregion
|
|
|
|
#region 调用,返回结果
|
|
|
|
string res = webService.AddData(jsonParam, strJson);
|
|
LogHelper.WriteSysLogBase("条码:" + barcode + "调用WMS入库接口,参数:strJson = " + strJson + "返回结果:" + res, MethodBase.GetCurrentMethod().Name);
|
|
|
|
#region 调用是否成功,若成功则存入数据库,WMS调用成功则无返回结果
|
|
|
|
if (res.ToUpper() == "TRUE")
|
|
{
|
|
string sql = @" INSERT INTO [tb_StockIn]
|
|
([ID]
|
|
,[barcode]
|
|
,[pass]
|
|
,[createTime])
|
|
VALUES
|
|
((select newid())
|
|
,'" + barcode + @"'
|
|
,'" + isPass.ToString() + @"'
|
|
,(select getdate())) ";
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
model.Result = "1";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = " 成功";
|
|
}
|
|
else
|
|
{
|
|
model.Result = "0";
|
|
model.ResultType = "Result";
|
|
model.ResultRowsCount = "0";
|
|
model.ErrReason = res;
|
|
}
|
|
#endregion
|
|
|
|
return JSONTools.ScriptSerialize<JsonModel<NoModel>>(model);
|
|
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
model.ErrReason = ex.Message;
|
|
return JSONTools.ScriptSerialize<JsonModel<NoModel>>(model);
|
|
}
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="oneBarCode"></param>
|
|
/// <param name="state">0-不合格;1-合格</param>
|
|
/// <returns></returns>
|
|
static bool AllowSendToWms(string oneBarCode, int state,ref int pRepaint,ref string errorMssg ,ref string paintColor)
|
|
{
|
|
if (string.IsNullOrEmpty(oneBarCode)) return false;
|
|
|
|
DataTable inspectTable = GetInspectResultTable($"barcode='{oneBarCode}'",ref paintColor);
|
|
if (inspectTable.Rows.Count == 0)
|
|
{
|
|
errorMssg = "没有进行质量判定,不能入库";
|
|
return false;
|
|
}
|
|
paintColor = GetPaintLU(oneBarCode.Substring(0, 10), inspectTable.Rows[0]["remark1"].ToString());
|
|
|
|
int rePaint = 0; //0:未返喷,1:喷涂线边判断返喷 2:物流仓库判定返喷
|
|
List<DataRow> paintRows = inspectTable.AsEnumerable().Where(p => p.Field<string>("inspectResult").Contains("打磨")).ToList();
|
|
if (paintRows.Count > 0)
|
|
{
|
|
List<DataRow> wmsPaintRows = paintRows.Where(p => p.Field<string>("inspectResult").Contains("WMS打磨")).ToList();
|
|
if(wmsPaintRows.Count > 0)
|
|
{
|
|
rePaint = 2;
|
|
}
|
|
else
|
|
{
|
|
rePaint = 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
rePaint = 0;
|
|
}
|
|
pRepaint = rePaint;
|
|
//不合格 返喷=0 有报工记录不能重发
|
|
if (state == 0)
|
|
{
|
|
if (inspectTable.Rows[0]["inspectResult"].ToString().Contains("报废") == false)
|
|
{
|
|
errorMssg = $"条码[{oneBarCode}]质检记录是[{inspectTable.Rows[0]["inspectResult"].ToString()}]状态,无法报废报工.";
|
|
return false;
|
|
}
|
|
if (rePaint == 0)
|
|
{
|
|
if (IsStockInAll(oneBarCode))
|
|
{
|
|
errorMssg = $"条码[{oneBarCode}]已报工,不能重新报工.";
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
//合格 返喷=0 最近一条是报废记录,可以重发. 否则不可以.
|
|
else if (state == 1)
|
|
{
|
|
if(inspectTable.Rows[0]["inspectResult"].ToString().Contains("合格") ==false)
|
|
{
|
|
errorMssg = $"条码[{oneBarCode}]质检记录是[{inspectTable.Rows[0]["inspectResult"].ToString()}]状态,无法合格报工.";
|
|
return false;
|
|
}
|
|
if (rePaint == 0)
|
|
{
|
|
if (IsStockInAll(oneBarCode))
|
|
{
|
|
string lastRst = inspectTable.Rows[0]["inspectResult"].ToString();
|
|
if (lastRst.Contains("报废")) //允许报废转合格
|
|
{
|
|
return true;
|
|
}
|
|
errorMssg = $"条码[{oneBarCode}]已报工,不能重新报工.";
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
/// <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();
|
|
}
|
|
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 IsStockIn(string barcode)
|
|
{
|
|
try
|
|
{
|
|
string sql = @" select * from tb_StockIn where barcode = '" + barcode + "' and pass = '1' ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static bool IsStockInAll(string barcode)
|
|
{
|
|
try
|
|
{
|
|
string sql = @" select * from tb_StockIn where barcode = '" + barcode + "' ";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询检验结果,最终是否合格
|
|
/// </summary>
|
|
/// <param name="barcode"></param>
|
|
/// <returns></returns>
|
|
public static bool barcodeStatus(string barcode)
|
|
{
|
|
try
|
|
{
|
|
DataTable dt = new DataTable();
|
|
string sql = "";
|
|
if (barcode.Contains("."))
|
|
{
|
|
string barcodeOne = TransToBarCodeOne(barcode);
|
|
sql = @" select * from (SELECT * from (select TOP 1 * from tb_InspectResult where barcode = '" + barcode + @"' or barcode = '" + barcodeOne + @"' AND InspectTimes = '1' ORDER BY createTime DESC) aa
|
|
UNION
|
|
SELECT * from (select TOP 1 * from tb_InspectResult where barcode = '" + barcode + @"' or barcode = '" + barcodeOne + @"' AND InspectTimes = '2' ORDER BY createTime DESC) bb
|
|
UNION
|
|
SELECT * from (select TOP 1 * from tb_InspectResult where barcode = '" + barcode + @"' or barcode = '" + barcodeOne + @"' AND InspectTimes = '3' ORDER BY createTime DESC) cc) dd order by createTime DESC ";
|
|
}
|
|
else
|
|
{
|
|
// 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 ";
|
|
sql = @" select top 1 * from tb_InspectResult where barcode='" + barcode + @"' order by ID desc";
|
|
}
|
|
|
|
dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
LogHelper.WriteSysLogBase("质量判定结果--" + sql + " : " + dt.ToString(), MethodBase.GetCurrentMethod().Name); //查询质量判定结果
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
string inspectResult = dt.Rows[0]["inspectResult"].ToString().Trim();
|
|
if ("[合格]" == inspectResult) //合格报工
|
|
{
|
|
return true;
|
|
}
|
|
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询是否进行了质量判定
|
|
/// </summary>
|
|
/// <param name="barcode"></param>
|
|
/// <returns></returns>
|
|
public static bool exsitInspectResult(string barcode)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = "";
|
|
if (barcode.Contains("."))
|
|
{
|
|
string barcodeOne = TransToBarCodeOne(barcode);
|
|
sql = @" select * from tb_InspectResult where barcode = '" + barcode.Trim() + "' or barcode = '" + barcodeOne + @"' ";
|
|
}
|
|
else
|
|
{
|
|
sql = @" select * from tb_InspectResult where barcode = '" + barcode.Trim() + "'";
|
|
}
|
|
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
LogHelper.WriteSysLogBase("是否进行过质量判定--" + sql + " : " + dt.ToString(), MethodBase.GetCurrentMethod().Name); //查询是否进行过质量判定
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
else
|
|
{
|
|
res = false;
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 根据塑件码查询所有检验记录
|
|
/// </summary>
|
|
/// <param name="oneBarCode"></param>
|
|
/// <returns></returns>
|
|
static DataTable GetInspectResultTable(string oneBarCode, ref string paintCode )
|
|
{
|
|
string sql = "";
|
|
if (oneBarCode.Contains("."))
|
|
{
|
|
string barcodeOne = TransToBarCodeOne(oneBarCode);
|
|
sql = @" select * from tb_InspectResult where barcode = '" + oneBarCode.Trim() + "' or barcode = '" + barcodeOne + @"' order by id desc ";
|
|
}
|
|
else
|
|
{
|
|
sql = @" select * from tb_InspectResult where barcode = '" + oneBarCode.Trim() + "' order by id desc";
|
|
}
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
return dt;
|
|
}
|
|
static string GetPaintLU(string stockNo, string color)
|
|
{
|
|
string sql = @"select * from tb_PaintColorInfo where StockNo='" + stockNo + @"' and Color='" +
|
|
color + @"'";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
return dt.Rows[0]["Paint_No"].ToString();
|
|
}
|
|
return "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询条码是否曾经上喷涂线
|
|
/// </summary>
|
|
/// <param name="barcode"></param>
|
|
/// <returns></returns>
|
|
public static bool ExistInLine(string barcode)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = @"
|
|
DECLARE @barcode varchar(30);
|
|
SET @barcode = '" + barcode + @"';
|
|
SELECT 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
|
|
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
|
|
";
|
|
string sqlConnString = ConfigurationManager.ConnectionStrings["SqlConnStringForeign"].ConnectionString;
|
|
DataTable dt = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
else
|
|
{
|
|
// string sql2 = @"
|
|
// DECLARE @barcode varchar(30);
|
|
// SET @barcode = '" + barcode + @"';
|
|
// SELECT 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
|
|
// 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
|
|
// ";
|
|
// DataTable dt2 = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, sql2, null);
|
|
// if (dt2 != null && dt2.Rows.Count > 0)
|
|
// {
|
|
// res = true;
|
|
// }
|
|
// else
|
|
// {
|
|
// res = false;
|
|
// }
|
|
|
|
res = false;
|
|
}
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static bool AddStockInBarcode(string barcode, out string errorReason)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = @"
|
|
INSERT INTO tb_StockIn
|
|
([ID]
|
|
,[barcode]
|
|
,[pass]
|
|
,[createTime])
|
|
VALUES
|
|
((select newid())
|
|
,'" + barcode + @"'
|
|
,'1'
|
|
,(select getdate()))
|
|
";
|
|
int result = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (result > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
else
|
|
{
|
|
res = false;
|
|
}
|
|
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
errorReason = ex.ToString();
|
|
return res;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据条码和颜色查找对应油漆件的零件号
|
|
/// </summary>
|
|
/// <param name="barcode"></param>
|
|
/// <returns></returns>
|
|
public static string GetPaintCoe(string barcode)
|
|
{
|
|
try
|
|
{
|
|
string res = "", color = "";
|
|
|
|
string sql = @"select top 1 * from tb_InspectResult where barcode='" + barcode + @"'";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
color = dt.Rows[0]["remark1"].ToString();
|
|
}
|
|
|
|
sql = @"select * from tb_PaintColorInfo where StockNo='" + barcode.Substring(0, 10) + @"' and Color='" +
|
|
color + @"'";
|
|
dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0]["Paint_No"].ToString();
|
|
}
|
|
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return "";
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 加漆防错接口
|
|
/// <summary>
|
|
/// 查询油漆是否存在或在用
|
|
/// </summary>
|
|
/// <param name="PaintCode"></param>
|
|
/// <param name="errorReason"></param>
|
|
/// <returns></returns>
|
|
public static DataTable GetPaintInfoIsUsing(string PaintCode, out string errorReason)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"
|
|
select * from tb_PaintInfo where IsUsing=1 and PaintCode = '" + PaintCode + @"'
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询油漆信息
|
|
/// </summary>
|
|
/// <param name="PaintCode"></param>
|
|
/// <param name="errorReason"></param>
|
|
/// <returns></returns>
|
|
public static DataTable GetPaintInfo(string PaintCode, out string errorReason)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"
|
|
select * from tb_PaintInfo where PaintCode = '" + PaintCode + @"'
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static DataTable IsMatch(string PaintCode, string DrumCode, out string errorReason)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"SELECT dbo.tb_BucketInfo.BucketCode, dbo.tb_PaintInfo.PaintCode
|
|
FROM dbo.tb_BucketInfo INNER JOIN
|
|
dbo.tb_Paint_Bucket ON dbo.tb_BucketInfo.ID = dbo.tb_Paint_Bucket.BucketID INNER JOIN
|
|
dbo.tb_PaintInfo ON dbo.tb_Paint_Bucket.PaintID = dbo.tb_PaintInfo.ID where dbo.tb_BucketInfo.BucketCode='" + DrumCode + "' and dbo.tb_PaintInfo.PaintCode = '" + PaintCode + @"'
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static DataTable IsEmpty(string bucketCode, out string errorReason)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"select top 1 PaintCode from tb_AddColorRecord where BucketCode='" + bucketCode + @"' order by ID desc";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static DataTable IsExitBucketCode(string bucketCode, out string errorReason)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"select ID from tb_BucketInfo where BucketCode='" + bucketCode + @"'";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int AddPaint(string PaintCode, string DrumCode, int state, out string errorReason)
|
|
{
|
|
int res = 0;
|
|
|
|
try
|
|
{
|
|
string sql = @"IF EXISTS (SELECT ID FROM dbo.tb_AddColorRecord WHERE BucketCode='" + DrumCode + @"') UPDATE dbo.tb_AddColorRecord SET PaintCode='" + PaintCode + @"',State=" + state + @",CreateTime=GETDATE() WHERE BucketCode='" + DrumCode + @"';
|
|
IF NOT EXISTS (SELECT ID FROM dbo.tb_AddColorRecord WHERE BucketCode='" + DrumCode + @"') INSERT INTO dbo.tb_AddColorRecord (BucketCode,PaintCode,State) VALUES('" + DrumCode + @"','" + PaintCode + @"'," + state + @");";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int ClearBucket(string bucketCode, out string errorReason)
|
|
{
|
|
int res = 0;
|
|
|
|
try
|
|
{
|
|
string sql = @"update dbo.tb_AddColorRecord SET PaintCode='',State=0,CreateTime=GETDATE() WHERE BucketCode='" +
|
|
bucketCode + @"'";
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static bool IsExitPaintCode(string paintCode)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
string sql = @"select ID from tb_AddColorRecord where PaintCode='" + paintCode + @"'";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
res=false;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static int IsPaint(string paintCode)
|
|
{
|
|
int res = 1;
|
|
|
|
try
|
|
{
|
|
string sql = @"select IsPaint from tb_PaintInfo where PaintCode='" + paintCode + @"'";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = int.Parse(dt.Rows[0]["IsPaint"].ToString());
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
public static DataTable GetPaintRecord(out string errorReason)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
//string sql = @"
|
|
// select PaintCode,BucketCode,CreateTime, CASE [State] WHEN 0 THEN '空闲' WHEN 1 THEN '绑定' WHEN 2 THEN '清洗' END AS BucketState
|
|
// from tb_AddColorRecord order by BucketCode
|
|
// ";
|
|
string sql = @"select a.PaintCode,a.BucketCode,a.CreateTime, CASE a.[State] WHEN 0 THEN '空闲' WHEN 1 THEN '绑定' WHEN 2 THEN '清洗' END AS BucketState,ISNULL(b.PaintName,'') AS PaintName
|
|
from tb_AddColorRecord a LEFT OUTER JOIN dbo.tb_PaintInfo b ON a.PaintCode=b.PaintCode
|
|
ORDER by BucketCode ";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 质检判定
|
|
|
|
/// <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;
|
|
}
|
|
}
|
|
|
|
/// <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 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
|
|
";
|
|
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 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
|
|
";
|
|
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 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
|
|
";
|
|
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 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
|
|
";
|
|
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="barcode"></param>
|
|
/// <returns></returns>
|
|
public static string GetProductInfo(string barcode)
|
|
{
|
|
string res = "";
|
|
try
|
|
{
|
|
string sql = @"
|
|
DECLARE @barcode varchar(30);
|
|
SET @barcode = '" + barcode + @"';
|
|
SELECT 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
|
|
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
|
|
";
|
|
string sqlConnString = ConfigurationManager.ConnectionStrings["SqlConnStringForeign"].ToString();
|
|
object aa = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql, null);
|
|
string colorNo = "";
|
|
if (aa != null)
|
|
{
|
|
colorNo = aa.ToString();
|
|
}
|
|
|
|
//根据颜色代码查颜色
|
|
string colorInfo = "";
|
|
if (!string.IsNullOrWhiteSpace(colorNo))
|
|
{
|
|
DataTable dt = new DataTable();
|
|
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();
|
|
}
|
|
}
|
|
|
|
//根据条码查询产品信息
|
|
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="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="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;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 247防错
|
|
|
|
public static DataTable IsMatchDeviceAndPart(string DeviceNo, string PartNo, out string errorReason)
|
|
{
|
|
DataTable res = new DataTable();
|
|
try
|
|
{
|
|
string sql = @"SELECT * from tb_Mistake_247
|
|
where [DeviceNo]='" + DeviceNo + "' and PartNo = '" + PartNo + @"'
|
|
";
|
|
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
//public static int InsertInspect(InspectModel model)
|
|
|
|
#endregion
|
|
|
|
#region 装配
|
|
|
|
public static bool WMSInterfaceStockIn(string barcode, string partNo, string batchNo, int isPass, int LineId)
|
|
{
|
|
bool res = false;
|
|
try
|
|
{
|
|
List<WMS03Model> list = new List<WMS03Model>();
|
|
WMS03Model wmsM = new WMS03Model();
|
|
wmsM.BarCode = barcode;
|
|
wmsM.WmsBarCode = "";
|
|
wmsM.LU_Code = partNo;
|
|
wmsM.Batch = batchNo;
|
|
wmsM.Q_level = "";
|
|
wmsM.CreationTime = DateTime.Now;
|
|
wmsM.IsOk = isPass;
|
|
wmsM.Ok_Status = isPass.ToString();
|
|
wmsM.FactoryId = 0;
|
|
wmsM.LineId = LineId;
|
|
wmsM.WmsRead = 1;
|
|
wmsM.ReadTime = null;
|
|
wmsM.Remark = "";
|
|
|
|
string lineid = ConfigurationManager.AppSettings["LineID"].ToString().Trim();
|
|
int lineId = 0;
|
|
Int32.TryParse(lineid, out lineId);
|
|
wmsM.LineId = lineId;
|
|
|
|
list.Add(wmsM);
|
|
|
|
#region 调用WMS接口前记录数据
|
|
|
|
string sql_bf = @" INSERT INTO [tb_StockIn_beif]
|
|
([ID]
|
|
,[barcode]
|
|
,[pass]
|
|
,[createTime])
|
|
VALUES
|
|
((select newid())
|
|
,'" + barcode + @"'
|
|
,'" + isPass.ToString() + @"'
|
|
,(select getdate())) ";
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql_bf, null);
|
|
|
|
#endregion
|
|
|
|
#region 调用WMS Web Service
|
|
|
|
WebService.WebReference.JsonService webService = new WebService.WebReference.JsonService();
|
|
webService.Url = ConfigurationManager.AppSettings["WMSWebServiceURL"].ToString();
|
|
webService.Timeout = 1200000;
|
|
|
|
string jsonParam = " [{\"ServiceType\":\"AddMesData\",\"OperName\":\"ADMIN\"}]";
|
|
//string strJson = "[55," + JSONTools.ScriptSerialize<List<WMS03Model>>(list) + "]";
|
|
|
|
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
|
|
//这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
|
|
timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";
|
|
//timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
|
|
string strJson = "[55," + JsonConvert.SerializeObject(list, Formatting.Indented, timeConverter) + "]";
|
|
|
|
#endregion
|
|
|
|
#region 调用,返回结果
|
|
|
|
LogHelper.WriteSysLogBase("条码:" + barcode + "调用WMS入库接口,参数:strJson = " + strJson + "调入时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), MethodBase.GetCurrentMethod().Name);
|
|
string resStr = webService.AddData(jsonParam, strJson);
|
|
LogHelper.WriteSysLogBase("条码:" + barcode + "调用WMS入库接口,参数:strJson = " + strJson + "返回结果:" + resStr + "返回结果时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), MethodBase.GetCurrentMethod().Name);
|
|
//LogHelper.WriteSysLogBase("条码:" + barcode + "调用WMS入库接口,参数:strJson = " + strJson + "返回结果:" + resStr, MethodBase.GetCurrentMethod().Name);
|
|
if (resStr.ToLower() == "true")
|
|
{
|
|
res = true;
|
|
}
|
|
|
|
return res;
|
|
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region TruckBox
|
|
|
|
public static bool CheckPart(string partName)
|
|
{
|
|
bool res = false;
|
|
|
|
try
|
|
{
|
|
string sql = @"select ID from tb_AddPartInfo where PartName ='" + partName + @"'";
|
|
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = true;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteErrLogBase(ex.ToString(),MethodBase.GetCurrentMethod().Name);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static int SavePart(string partName, string bucketNo,string batchNo, out string errorReason)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql ="";
|
|
|
|
if (string.IsNullOrWhiteSpace(bucketNo))
|
|
{
|
|
sql = @"
|
|
update tb_AddPartInfo set BatchNo ='" + batchNo + @"',Des1='" + batchNo + @"' where PartName ='" + partName +
|
|
@"'
|
|
";
|
|
}
|
|
else
|
|
{
|
|
if (bucketNo.Contains("1"))
|
|
{
|
|
sql = @"
|
|
update tb_AddPartInfo set BatchNo ='" + batchNo + @"',Des1='" + batchNo + @"' where PartName ='" + partName +
|
|
@"'
|
|
";
|
|
}
|
|
else
|
|
{
|
|
sql = @"
|
|
update tb_AddPartInfo set BatchNo ='" + batchNo + @"',Des2='" + batchNo + @"' where PartName ='" + partName +
|
|
@"'
|
|
";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
errorReason = "";
|
|
return res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogManager(ex);
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
errorReason = ex.Message;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public static DataTable GetPartInfo()
|
|
{
|
|
DataTable res = null;
|
|
|
|
try
|
|
{
|
|
string sql = "select PartName from tb_AddPartInfo order by ID";
|
|
|
|
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 bool IsAdd(string address)
|
|
{
|
|
bool res = false;
|
|
|
|
try
|
|
{
|
|
string sql=@"select RealValue from tb_Address_tx where Address='"+ address +@"'";
|
|
DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
res = dt.Rows[0]["RealValue"].ToString().ToLower() == "true" ? true : false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新加注完成
|
|
/// </summary>
|
|
/// <param name="id">id</param>
|
|
/// <param name="time1">失效时间</param>
|
|
/// <param name="time2">保质期</param>
|
|
/// <returns></returns>
|
|
public static int UpdateDone(int id, string time1, string time2)
|
|
{
|
|
int res = 0;
|
|
try
|
|
{
|
|
string sql = "";
|
|
if (id == 59)
|
|
{
|
|
sql = @"
|
|
update tb_Address_tx set RealValue='" + time1 + @"' where ID=54;
|
|
update tb_Address_tx set RealValue='" + time2 + @"' where ID=55;
|
|
update tb_Address_tx set RealValue='True' where ID=59;";
|
|
}
|
|
else if (id == 60)
|
|
{
|
|
sql = @"
|
|
update tb_Address_tx set RealValue='" + time1 + @"' where ID=56;
|
|
update tb_Address_tx set RealValue='" + time2 + @"' where ID=57;
|
|
update tb_Address_tx set RealValue='True' where ID=60;";
|
|
}
|
|
res = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, CommandType.Text, sql, null);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine(e);
|
|
throw;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|