185 lines
9.3 KiB
C#
185 lines
9.3 KiB
C#
using System;
|
||
using System.Data;
|
||
using System.Windows.Forms;
|
||
using bizFacade;
|
||
//using SystemFramework;
|
||
using MesServerWork;
|
||
|
||
namespace MesServerFunctions
|
||
{
|
||
partial class FunctionMES
|
||
{
|
||
/// <summary>
|
||
///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域
|
||
///2.扫描料箱标签/看板卡,用于追溯物料批次信息
|
||
///3.扫描零件条码,根据零件图号进行防错
|
||
///第一步,判断条码类型,根据条码类型,执行对应的存储过程
|
||
///第二步,条码类型(将扫描的条码保存到对应的表中)
|
||
///第三步,扫描完成之后给出允许工作信号
|
||
/// 处理页面扫描条码
|
||
/// </summary>
|
||
/// <param name="OpName"></param>
|
||
/// <param name="barcode"></param>
|
||
public void Barcode(object e)
|
||
{
|
||
|
||
{
|
||
try
|
||
{
|
||
DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
|
||
string OpName = Convert.ToString(msgEvent.OpName);
|
||
string barcode = Convert.ToString(msgEvent.TagValue);
|
||
SendMessageFun.SendInfomation("BarCodeData", barcode, OpName); // 将扫码值发送给前端
|
||
string AlarmStr = "";
|
||
bool isShowBarNGTipBox;
|
||
|
||
int IsAllowWork;
|
||
bool IsSuccess = false;
|
||
bool EngineGetOver_PLC_NextWorkStep;
|
||
|
||
// 判断是否存在异常导致不允许工作 输出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_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep);
|
||
if (!EngineGetOver_PLC_NextWorkStep)
|
||
{
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型");
|
||
isShowBarNGTipBox = BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 1);
|
||
if (isShowBarNGTipBox) SendMessageFun.SendInfomation("ShowTipBox", "多次扫描条码失败,请检查扫码位置是否正确!", OpName);
|
||
return;
|
||
}
|
||
|
||
if (barcode == "" || barcode.Length <= 5)
|
||
{
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "前壳码内容不能为空,请重试");
|
||
isShowBarNGTipBox = BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 1);
|
||
if (isShowBarNGTipBox) SendMessageFun.SendInfomation("ShowTipBox", "多次扫描条码失败,请检查扫码位置是否正确!", OpName);
|
||
return;
|
||
}
|
||
|
||
MIS_BASE.Read_EngineTypeID(OpName, out int 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;
|
||
}
|
||
}
|
||
|
||
|
||
//读取 设备线外工位到位信号
|
||
//工件到位信号:DBX500.2=1 (3) 暂时不用判断
|
||
//var tagValue = MIS_BASE.ReadPLC(3, OpName);
|
||
//if(tagValue.ToString()=="0")
|
||
//{
|
||
// SendMessageFun.AsyncSendMessage_Notice(OpName, "线外工位工件没有到位");
|
||
// return;
|
||
//}
|
||
//订单号
|
||
string orderForm = MIS_BASE.ReadPLC(39, OpName).ToString();
|
||
//主线总成号
|
||
string EngineID = MIS_BASE.ReadPLC(10, OpName).ToString();
|
||
//机型号
|
||
string EngineType = MIS_BASE.ReadPLC(11, OpName).ToString();
|
||
//物料保存
|
||
|
||
// 判断所扫前壳码是否存在重复
|
||
DataTable checkDt = BaseDataSystemMES.BusPartLine_BarCodeCheck(EngineID, barcode, OpName);
|
||
if (Convert.ToInt32(checkDt.Rows[0]["result"]) != 1)
|
||
{
|
||
// 发送给前端类型与提示文本
|
||
SendMessageFun.SendInfomation("BarCodeCheckNG", checkDt.Rows[0]["msg"].ToString() + '&' + EngineID + '&' + barcode + '&' + orderForm + '&' + EngineType, OpName);
|
||
MIS_BASE.WritePLC(35, OpName, true);
|
||
return;
|
||
}
|
||
BaseDataSystemMES.Set_TempData(OpName, "码值", barcode);
|
||
DataTable dt = BaseDataSystemMES.BusPartLine_Add(EngineID, barcode, OpName, orderForm, EngineType);
|
||
if(Convert.ToInt32(dt.Rows[0]["result"]) != 1)
|
||
{
|
||
// 发送给前端类型与提示文本
|
||
SendMessageFun.SendInfomation("BarCodeCheckNG", checkDt.Rows[0]["msg"].ToString() + '&' + EngineID + '&' + barcode + '&' + orderForm + '&' + EngineType, OpName);
|
||
return;
|
||
}
|
||
MIS_BASE.Write_FixAllow(OpName, true);
|
||
// 写入扫码成功点
|
||
MIS_BASE.WritePLC(64, OpName, true);
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "前壳扫码完成,请开始工作");
|
||
BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 2);
|
||
|
||
////暂时改为保存主分线关系完毕即可允许工作
|
||
//DataTable dt = BaseDataSystemMES.BusPartLine_Add(EngineID, barcode,OpName ,orderForm, EngineType);
|
||
//if (Convert.ToInt32(dt.Rows[0]["result"]) == 1){
|
||
// MIS_BASE.Write_FixAllow(OpName, true);
|
||
// // 写入扫码成功点
|
||
// MIS_BASE.WritePLC(64, OpName, true);
|
||
// SendMessageFun.AsyncSendMessage_Notice(OpName, "前壳扫码完成,请开始工作");
|
||
// BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 2);
|
||
//} else {
|
||
// SendMessageFun.AsyncSendMessage_Notice(OpName, dt.Rows[0]["msg"].ToString());
|
||
//}
|
||
|
||
SendMessageFun.SendInfomation("BindRecordRefresh", "1", OpName);
|
||
//if (!IsSuccess)
|
||
//{
|
||
// SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认");
|
||
// return;
|
||
//}
|
||
//else
|
||
//{
|
||
// SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息
|
||
//}
|
||
|
||
////获取是否允许工作
|
||
//BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork);
|
||
|
||
////此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况
|
||
//if (IsAllowWork == 1)
|
||
//{
|
||
// //BaseDataSystemMES.Material_Insert(OpName, 1);
|
||
|
||
// //更新订单完工数量及物料
|
||
// SendMessageFun.SendMessage("24", "11", OpName);
|
||
// MIS_BASE.Write_FixAllow(OpName, true);
|
||
// //工作完成
|
||
// //MIS_BASE.Write_MaterialVerifyOver(OpName, true);
|
||
// //if (!BaseDataSystemMES.QualityVerifyStatusOutline(OpName, out AlarmStr))
|
||
// //{
|
||
// // SendInfomation("LineoutAlert", AlarmStr, OpName);
|
||
// // return;
|
||
// //}
|
||
// //通知PLC允许工作,允许工作在保存完成时清空
|
||
// //线外工位MES允许PLC工作DBX11.0=1(34)
|
||
// //MES允许PLC工作线外工位
|
||
// MIS_BASE.WritePLC(34, OpName, true);
|
||
//}
|
||
//else
|
||
//{
|
||
// SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!");
|
||
//}
|
||
|
||
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
// 保存出错日志 1.申请上线 2.传递机型 3.允许保存 4.扫码
|
||
MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(4, e, "Fun1054", err);
|
||
////ApplicationLog.WriteLog(err, "Function02:Barcode");
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
}
|
||
}
|