221 lines
11 KiB
C#
221 lines
11 KiB
C#
using System;
|
||
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);
|
||
string barcode = Convert.ToString(msgEvent.TagValue);
|
||
|
||
int EngineTypeID;//机型代码
|
||
string EngineType;//机型
|
||
string EngineID;//工件编号
|
||
|
||
string OrderForm;
|
||
int Recipe1;
|
||
int Recipe2;
|
||
|
||
bool IsNotRepeatedNumber = false;
|
||
//1:获得申请上线信息后,扫描条码才处理业务
|
||
bool ispartload;
|
||
//(115)
|
||
int PTO;
|
||
//(118)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出
|
||
int NgearSwitch;
|
||
//(119)0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出
|
||
int RgearSwitch;
|
||
//(120)0=不检测;1=检测。检测线上线工位扫描总成条码,根据BOM,查出
|
||
int SpeedSensor;
|
||
//(121)例如:5S 400。检测线上线工位扫描总成条码,根据BOM,查出
|
||
string PartTypeMid;
|
||
//(122) 0=不检测;1=24V,2=12V。检测线上线工位扫描总成条码,根据BOM,查出
|
||
int Tcu_V;
|
||
//判断工件是否到位
|
||
MIS_BASE.Read_WorkStart(OpName, out ispartload);
|
||
if (!ispartload)
|
||
{
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否到位(DBX500.1=1)");
|
||
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'
|
||
|
||
//扫描完变速器序列号条码号 true
|
||
bool isGetOver_MES = false;
|
||
//判断上线工位,MES 是否将工件流水号、机型等信息已经写入到PLC了
|
||
//MIS_BASE.Read_EngineTypeGetOver_MES(OpName, out isGetOver_MES);
|
||
MIS_BASE.Read_EngineGetOver_PLC(OpName, out isGetOver_MES);
|
||
//如果工件流水号、机型等信息没有写入PLC,扫描的条码按工件流水号进行验证
|
||
//否则按装配物料进行验证
|
||
if (!isGetOver_MES)
|
||
{
|
||
|
||
if (barcode.Split(';').Length > 2 || barcode.Split('*').Length > 2)
|
||
{
|
||
|
||
string partSn = barcode;
|
||
EngineID = barcode;
|
||
|
||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID);
|
||
SendMessage.ShowMoby(OpName);
|
||
|
||
//2: 判断是否重号
|
||
//IsRepeatedNumber true 不重号;false 重号;
|
||
IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(partSn);
|
||
if (IsNotRepeatedNumber)
|
||
{
|
||
// 从数据库获得机型、机型代码等信息
|
||
BaseDataSystemMES.GetEngineTypeUpLoadOpName(partSn, OpName, out EngineTypeID, out EngineType, out OrderForm, out Recipe1, out Recipe2);
|
||
// 从数据库获得PTO等信息
|
||
BaseDataSystemMES.UpLoadPTO(partSn, out PTO, out NgearSwitch, out RgearSwitch, out SpeedSensor, out PartTypeMid, out Tcu_V);
|
||
//PTO
|
||
MIS_BASE.WritePLC(115, OpName, PTO);
|
||
//空挡开关检测
|
||
MIS_BASE.WritePLC(95, OpName, NgearSwitch);
|
||
//倒挡开关检测
|
||
MIS_BASE.WritePLC(96, OpName, RgearSwitch);
|
||
//里程表检测
|
||
MIS_BASE.WritePLC(97, OpName, SpeedSensor);
|
||
//大机型扩展
|
||
MIS_BASE.WritePLC(98, OpName, PartTypeMid);
|
||
//TCU
|
||
MIS_BASE.WritePLC(122, OpName, Tcu_V);
|
||
// 先查询配方号 根据工位号 去moby表查配方号
|
||
// 根据配方号 去配方表查配方数据 写入配方数据
|
||
string tagStartAdr;//= "DB411.10";
|
||
BaseDataSystemMES.PLCRcipeCurrent(OpName, out byte[] bytes, out tagStartAdr);
|
||
DtWebApi.ReadWritePLC.Write_TagValueByTagTypeID("94", OpName, System.Text.Encoding.ASCII.GetString(bytes));
|
||
// 将产品信息写入PLC
|
||
MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID);
|
||
MIS_BASE.Write_EngineType_MES(OpName, EngineType);
|
||
MIS_BASE.Write_EngineID_MES(OpName, EngineID);
|
||
MIS_BASE.Write_OrderForm_MES(OpName, OrderForm);
|
||
|
||
// 写入到数据库的[北汽福田工位状态监控MOBY]表中
|
||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID);
|
||
SendMessage.ShowMoby(OpName);
|
||
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "总成码扫码完成,请扫描后壳码!");
|
||
|
||
|
||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true);
|
||
|
||
//Thread.Sleep(1000);
|
||
//// 临时增加 清除MES的传递机型
|
||
//MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false);
|
||
|
||
}
|
||
else
|
||
{
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号 重号,请确认!");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号格式不正确,请确认!");
|
||
|
||
}
|
||
}
|
||
else//验证物料
|
||
{
|
||
//物料号
|
||
{
|
||
//读取PLC的传递机型信号
|
||
bool tagValue;
|
||
MIS_BASE.Read_EngineGetOver_PLC(OpName, out tagValue);
|
||
if (tagValue)
|
||
{
|
||
//验证物料
|
||
BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out bool IsSuccess);
|
||
if (!IsSuccess)//????
|
||
{
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "条码无效,请确认");
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
SendMessageFun.SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息
|
||
}
|
||
//判断物料是否验证完成
|
||
BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out int IsAllowWork);
|
||
|
||
|
||
if (IsSuccess)
|
||
{
|
||
if (IsAllowWork == 1)
|
||
{
|
||
//移到允许保存信号中
|
||
//BaseDataSystemMES.Material_Insert(OpName, 1);
|
||
|
||
////更新订单完工数量及物料
|
||
SendMessageFun.SendMessage("245", "111", OpName);
|
||
|
||
// 写入到数据库的[北汽福田工位状态监控MOBY]表中
|
||
SendMessage.ShowMoby(OpName);
|
||
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "扫码完成,请开始工作!");
|
||
|
||
//物料验证完成,通知PLC允许工作,允许工作在保存完成时清空
|
||
MIS_BASE.Write_FixAllow(OpName, true);
|
||
}
|
||
else
|
||
{
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, "PLC未传递机型");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
SendMessage.AsyncSendMessage_Notice(OpName, "产品上线后,PLC获得变速器序列号后,再验证物料!");
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
////ApplicationLog.WriteLog(err, "Function08:Barcode");
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
}
|
||
}
|