Files
01-Siyuan-MesProject/MisDataFunction/MesServer.Function/Function02/OpcServer/Barcode.cs
2026-05-29 10:07:05 +08:00

109 lines
4.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Threading;
using bizFacade;
//using SystemFramework;
using MesServerWork;
namespace MesServerFunctions
{
partial class Functions_BASE_02
{
/// <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);
string AlarmStr = "";
int IsAllowWork;
bool IsSuccess = false;
bool EngineGetOver_PLC_NextWorkStep;
//工件是否到位
MIS_BASE.Read_WorkStart(OpName, out EngineGetOver_PLC_NextWorkStep);
//此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况
if (EngineGetOver_PLC_NextWorkStep)
{
//如果是20工位判断是否已经输入壳体码 输入后才能进行接下来操作
if(OpName == "OP0020")
{
string EngineID;
MIS_BASE.Read_EngineID_MES(OpName, out EngineID);
if (EngineID == null || EngineID == "")
{
AsyncSendMessage_Notice(OpName, "请先输入壳体码再进行操作");
return;
}
}
//如果传递机型后,那就更新条码
BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out IsSuccess);
if (!IsSuccess)
{
AsyncSendMessage_Notice(OpName, "条码无效,请确认");
return;
}
else
{
SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息
}
//获取是否允许工作
BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork);
// 扫描完条码并且 条码扫描成功时允许工作并且跟新页面数据
if (IsAllowWork == 1 && IsSuccess)
{
// 保存物料信息挪到允许保存那里了
// BaseDataSystemMES.Material_Insert(OpName, 1);
//通知PLC允许工作,允许工作在保存完成时清空
MIS_BASE.Write_FixAllow(OpName, true);
//更新订单完工数量及物料
Sendmessage("24", "11", OpName);
Thread.Sleep(500);
Sendmessage("24", "11", OpName);
Thread.Sleep(500);
Sendmessage("24", "11", OpName);
// 物料验证完成
MIS_BASE.Write_MaterialVerifyOver(OpName, true);
//if (!BaseDataSystemMES.QualityVerifyStatusOutline(OpName, out AlarmStr))
//{
// SendInfomation("LineoutAlert", AlarmStr, OpName);
// return;
//}
}
else
{
AsyncSendMessage_Notice(OpName, "请扫描物料!");
}
}
else
{
AsyncSendMessage_Notice(OpName, "PLC未工件到位");
}
}
catch (Exception err)
{
////ApplicationLog.WriteLog(err, "Function02:Barcode");
}
}
}
}