206 lines
11 KiB
C#
206 lines
11 KiB
C#
using System;
|
||
using System.Data;
|
||
using System.Threading;
|
||
using System.Xml.Linq;
|
||
using bizFacade;
|
||
|
||
//using SystemFramework;
|
||
using MesServerWork;
|
||
|
||
namespace MesServerFunctions
|
||
{
|
||
partial class FunctionMES
|
||
{
|
||
object lockBarcode = new object();
|
||
|
||
///第一步,判断条码类型,根据条码类型,执行对应的存储过程
|
||
///第二步,条码类型(将扫描的条码保存到对应的表中)
|
||
///第三步,扫描完成之后给出允许工作信号
|
||
/// 处理页面扫描条码
|
||
/// </summary>
|
||
/// <param name="OpName"></param>
|
||
/// <param name="barcode"></param>
|
||
public void Barcode(object e)
|
||
{
|
||
lock(lockBarcode)
|
||
{
|
||
try
|
||
{
|
||
DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
|
||
string OpName = Convert.ToString(msgEvent.OpName);
|
||
//+*************DbName*****************
|
||
string DbName = Convert.ToString(msgEvent.OpName);
|
||
string barcode = Convert.ToString(msgEvent.TagValue);
|
||
SendMessageFun.SendInfomation("BarCodeData", barcode, OpName); // 将扫码值发送给前端
|
||
|
||
int EngineTypeID;//机型代码
|
||
string EngineType;//机型
|
||
string EngineID;//工件编号
|
||
bool isShowBarNGTipBox;
|
||
|
||
string OrderForm;
|
||
|
||
bool IsNotRepeatedNumber = false;
|
||
//1:获得申请上线信息后,扫描条码才处理业务
|
||
bool ispartload;
|
||
|
||
// 判断是否存在异常导致不允许工作 输出msg到前端
|
||
DataTable OpNameIsWorkDt = BaseDataSystemMES.OpNameIsAllowWork(OpName);
|
||
if (Convert.ToInt32(OpNameIsWorkDt.Rows[0]["提示类型"]) == 3)
|
||
{
|
||
SendMessageFun.SendInfomation("ShowTipBox", OpNameIsWorkDt.Rows[0]["提示文本"].ToString(), OpName);
|
||
return;
|
||
}
|
||
|
||
//判断工件是否到位
|
||
MIS_BASE.Read_WorkStart(OpName, out ispartload);
|
||
if (!ispartload)
|
||
{
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否到位(DBX500.1=1)");
|
||
isShowBarNGTipBox = BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 1);
|
||
if (isShowBarNGTipBox) SendMessageFun.SendInfomation("ShowTipBox", "多次扫描条码失败,请检查扫码位置是否正确!", OpName);
|
||
return;
|
||
}
|
||
//判断设备是否申请上线
|
||
//MIS_BASE.Read_UpdatePalletOK(OpName, out ispartload);
|
||
//if (!ispartload)
|
||
//{
|
||
// SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否申请上线(DBX500.3=1)");
|
||
// return;
|
||
//}
|
||
// 判读条码是变速器序列号条码号还是物料号 小机型*日月年* 流水号(给起始号 + 数量)
|
||
// 选小机型 从北汽福田BOM中选 得先维护BOM
|
||
// 变速器序列号 '1333 050 062*16012023*30000001'
|
||
|
||
|
||
//如果工件流水号、机型等信息没有写入PLC,扫描的条码按工件流水号进行验证
|
||
//否则按装配物料进行验证
|
||
MIS_BASE.Read_EngineTypeID(OpName, out EngineTypeID);
|
||
if (EngineTypeID == 2 || EngineTypeID == 4) {
|
||
if ( !(barcode.Split(';').Length > 2 || barcode.Split(';').Length > 2 || barcode.Split('*').Length > 2))
|
||
{
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "此条码非前壳码,请确认!");
|
||
isShowBarNGTipBox = BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 1);
|
||
if (isShowBarNGTipBox) SendMessageFun.SendInfomation("ShowTipBox", "多次扫描条码失败,请检查扫码位置是否正确!", OpName);
|
||
return;
|
||
}
|
||
}
|
||
|
||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.WorkStartIn, DateTime.Now.ToString());
|
||
|
||
if (OpName == "J07PA080")
|
||
{
|
||
// PA070 与 PA080 扫码模式不同 使用两种数据来源
|
||
DataTable LineOutWorkEngineDt = BaseDataSystemMES.newSelectWorkOrder("J07MA020", barcode);
|
||
if (LineOutWorkEngineDt.Rows.Count > 0)
|
||
{
|
||
|
||
EngineTypeID = Convert.ToInt32(LineOutWorkEngineDt.Rows[0]["机型代码"]);
|
||
EngineType = LineOutWorkEngineDt.Rows[0]["机型号"].ToString();
|
||
EngineID = LineOutWorkEngineDt.Rows[0]["主线总成号"].ToString();
|
||
OrderForm = LineOutWorkEngineDt.Rows[0]["订单号"].ToString();
|
||
|
||
// 校验是否存在于生产订单中
|
||
// 先判断是否为返修件 若是的话就不校验生产订单
|
||
//判断是否返修件 若不是返修件则要校验是否在当前计划中
|
||
DataTable backWorkDt = BaseDataSystemMES.Get_IsBarCodeBackWork(OpName, EngineID);
|
||
if (Convert.ToInt32(backWorkDt.Rows[0]["Count"]) == 0)
|
||
{
|
||
DataTable BarCodeDt;
|
||
BarCodeDt = BaseDataSystemMES.GetMainLineNowWorkOrderData(OpName, EngineID);
|
||
if (BarCodeDt.Rows.Count == 0)
|
||
{
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "当前工位订单可上线条码中不存在此条码,请在当前计划模块中查看!");
|
||
isShowBarNGTipBox = BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 1);
|
||
if (isShowBarNGTipBox) SendMessageFun.SendInfomation("ShowTipBox", "多次扫描条码失败,请检查扫码位置是否正确!", OpName);
|
||
return;
|
||
}
|
||
}
|
||
|
||
MIS_BASE.WritePLC(32, OpName, false);
|
||
}
|
||
else
|
||
{
|
||
MIS_BASE.WritePLC(32, OpName, true);
|
||
SendMessage.AsyncSendMessage_Notice(OpName, "当前前壳未与装配线订单绑定!请绑定后再进行工作");
|
||
isShowBarNGTipBox = BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 1);
|
||
if (isShowBarNGTipBox) SendMessageFun.SendInfomation("ShowTipBox", "多次扫描条码失败,请检查扫码位置是否正确!", OpName);
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 先判断是否有扫的前壳码是重复的,如果有则去用重复前壳码对应的数据,反之继续使用从订单队列取出的订单
|
||
//PA070 的5S
|
||
DataTable dt;
|
||
dt = BaseDataSystemMES.GetNowWorkOrderData(OpName, 0);
|
||
if (dt.Rows.Count > 0)
|
||
{
|
||
if (Convert.ToInt32(dt.Rows[0]["线首是否完成工作"]) == 4)
|
||
{
|
||
MIS_BASE.WritePLC(32, OpName, true);
|
||
SendMessage.AsyncSendMessage_Notice(OpName, "该订单所有总成号已在MA040工作完毕,不允许继续工作,请联系班长进行修改完工状态!");
|
||
isShowBarNGTipBox = BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 1);
|
||
if (isShowBarNGTipBox) SendMessageFun.SendInfomation("ShowTipBox", "多次扫描条码失败,请检查扫码位置是否正确!", OpName);
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
EngineTypeID = Convert.ToInt32(dt.Rows[0]["机型代码"]);
|
||
EngineType = dt.Rows[0]["零件号"].ToString();
|
||
EngineID = dt.Rows[0]["变速箱总成号"].ToString();
|
||
OrderForm = dt.Rows[0]["订单号"].ToString();
|
||
MIS_BASE.WritePLC(32, OpName, false);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MIS_BASE.WritePLC(32, OpName, true);
|
||
SendMessage.AsyncSendMessage_Notice(OpName, "该订单已生产完毕或无选中的生产订单,请选择其他订单进行生产!");
|
||
isShowBarNGTipBox = BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 1);
|
||
if (isShowBarNGTipBox) SendMessageFun.SendInfomation("ShowTipBox", "多次扫描条码失败,请检查扫码位置是否正确!", OpName);
|
||
return;
|
||
}
|
||
}
|
||
|
||
|
||
// 将扫码结果计入总分线记录表中
|
||
BaseDataSystemMES.BusPartLine_Add(EngineID, barcode, OpName, OrderForm, EngineType);
|
||
|
||
SendMessageFun.SendInfomation("BindRecordRefresh", "1", OpName);
|
||
|
||
// 将产品信息写入PLC
|
||
MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID);
|
||
MIS_BASE.Write_EngineType_MES(OpName, EngineType);
|
||
if (OpName == "J07PA080")
|
||
{
|
||
MIS_BASE.Write_EngineID_MES(OpName, EngineID); // 将壳体码作为总成号来工作,到时候保存也存这个
|
||
}
|
||
else
|
||
{
|
||
MIS_BASE.Write_EngineID_MES(OpName, barcode); // 将壳体码作为总成号来工作,到时候保存也存这个
|
||
}
|
||
MIS_BASE.Write_OrderForm_MES(OpName, OrderForm);
|
||
|
||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID);
|
||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType_MES, EngineType);
|
||
//SendMessageFun.SendMessage("1235", "1111", OpName);
|
||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true);
|
||
//MIS_BASE.Write_FixAllow(OpName, true);
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "扫码完成!");
|
||
BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 2);
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
// 保存出错日志 1.申请上线 2.传递机型 3.允许保存 4.扫码
|
||
MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(4, e, "Fun1059", err);
|
||
////ApplicationLog.WriteLog(err, "Function08:Barcode");
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
}
|
||
}
|