chore: 初始化北汽福田MES采集程序
This commit is contained in:
@@ -0,0 +1,321 @@
|
||||
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;//工件编号
|
||||
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;
|
||||
//(123) 加有量检测线上线工位扫描总成条码,根据BOM,查出
|
||||
float addOil;
|
||||
//(124) 上线法兰凹凸 -- 5s 1 凸 2 凹 6s 4凸 8 凹
|
||||
int flange;
|
||||
//(17) 上线细一轴
|
||||
int Slender;
|
||||
//(35) 分泵推杆
|
||||
int Putters;
|
||||
|
||||
bool isShowBarNGTipBox = false;
|
||||
|
||||
// 判断是否存在异常导致不允许工作 输出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_PartLoad(OpName, out ispartload);
|
||||
if (!ispartload)
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "请检查设备是否申请上线(DBX500.3=1)");
|
||||
isShowBarNGTipBox = BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 1);
|
||||
if (isShowBarNGTipBox) SendMessageFun.SendInfomation("ShowTipBox", "多次扫描条码失败,请检查扫码位置是否正确!", OpName);
|
||||
return;
|
||||
}
|
||||
// 判读条码是变速器序列号条码号还是物料号 小机型*日月年* 流水号(给起始号 + 数量)
|
||||
// 选小机型 从北汽福田BOM中选 得先维护BOM
|
||||
// 变速器序列号 '1333 050 062*16012023*30000001'
|
||||
|
||||
//扫描完变速器序列号条码号 true
|
||||
//扫描完变速器序列号条码号 true
|
||||
bool isGetOver_PLC = false;
|
||||
//判断上线工位,MES 是否将工件流水号、机型等信息已经写入到PLC了
|
||||
MIS_BASE.Read_EngineGetOver_PLC(OpName, out isGetOver_PLC);
|
||||
|
||||
//如果工件流水号、机型等信息没有写入PLC,扫描的条码按工件流水号进行验证
|
||||
//否则按装配物料进行验证
|
||||
if (!isGetOver_PLC)
|
||||
{
|
||||
|
||||
if (barcode.Split('*').Length > 2)
|
||||
{
|
||||
//2: 判断是否重号, 从数据库获得机型、机型代码等信息
|
||||
string partSn = barcode;
|
||||
EngineID = barcode;
|
||||
|
||||
//判断是否返修件 若不是返修件则要校验是否在当前计划中
|
||||
DataTable backWorkDt = BaseDataSystemMES.Get_IsBarCodeBackWork(OpName, EngineID);
|
||||
if (Convert.ToInt32(backWorkDt.Rows[0]["Count"]) == 0)
|
||||
{
|
||||
// 判断扫的码是否在当前生产订单中
|
||||
if (OpName == "J07MA005")
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID);
|
||||
|
||||
//Db.GetEngineType( partSn, out EngineTypeID, out EngineType, out EngineID, out IsRepeatedNumber);
|
||||
//Db.GetEngineType( partSn, out EngineTypeID, out EngineType, out EngineID, out IsRepeatedNumber);
|
||||
|
||||
//IsRepeatedNumber true 不重号;false 重号;
|
||||
IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(partSn);
|
||||
if (IsNotRepeatedNumber)
|
||||
{
|
||||
bool isData = BaseDataSystemMES.GetEngineTypeUpLoadOpName(partSn, OpName, out EngineTypeID, out EngineType, out OrderForm, out Recipe1, out Recipe2);
|
||||
if (!isData)
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "生产订单中无此条码,请在当前计划模块中查看确认!");
|
||||
isShowBarNGTipBox = BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 1);
|
||||
if (isShowBarNGTipBox) SendMessageFun.SendInfomation("ShowTipBox", "多次扫描条码失败,请检查扫码位置是否正确!", OpName);
|
||||
return;
|
||||
}
|
||||
//MIS_BASE.Write_EngineID_MES(OpName, EngineID);
|
||||
//MIS_BASE.Write_EngineTypeID_MES(OpName, EngineTypeID);
|
||||
//MIS_BASE.Write_EngineType_MES(OpName, EngineType);
|
||||
//MIS_BASE.Write_OrderForm_MES(OpName, OrderForm);
|
||||
|
||||
BaseDataSystemMES.UpLoadPTO(EngineType, out PTO, out NgearSwitch, out RgearSwitch, out SpeedSensor, out PartTypeMid, out Tcu_V,out addOil,out flange,out Slender,out Putters);
|
||||
//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);
|
||||
//注油量
|
||||
MIS_BASE.WritePLC(123, OpName, addOil);
|
||||
// 法兰编号
|
||||
if(OpName == "J07ET010") MIS_BASE.WritePLC(124, OpName, flange);
|
||||
|
||||
// 写入是否存在PKB
|
||||
bool isExistPKB = BaseDataSystemMES.Get_IsExistPKB(EngineType);
|
||||
MIS_BASE.WritePLC(64, OpName, isExistPKB);
|
||||
|
||||
//细一轴
|
||||
MIS_BASE.WritePLC(17, OpName, Slender);
|
||||
|
||||
//分泵推杆
|
||||
MIS_BASE.WritePLC(35, OpName, Putters);
|
||||
|
||||
string tagStartAdr;//= "DB411.10";
|
||||
|
||||
// 先查询配方号 根据工位号 去moby表查配方号
|
||||
// 根据配方号 去配方表查配方数据
|
||||
// 写入配方数据
|
||||
BaseDataSystemMES.PLCRcipeCurrent(OpName, out byte[] bytes, out tagStartAdr);
|
||||
MIS_BASE.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.EngineTypeID_MES, EngineTypeID.ToString());
|
||||
//BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineType_MES, EngineType);
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID);
|
||||
//BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.OrderForm_MES, OrderForm);
|
||||
|
||||
|
||||
// 工位号],[订单号],[产品型号代码],[变速器序列号],[发动机型号],[机型基本代码],[变速器总成号] ,[托盘号]
|
||||
// [产品型号代码_MES],[变速器序列号_MES],[发动机型号_MES]
|
||||
// [机床上电],[循环开始],[机床故障],[上料无件],[下料堵塞],[工件到位]
|
||||
// [传递机型],[申请上件],[允许保存],[保存完成],[合格标志],[前序合格]
|
||||
// [工号],[班次],[是否返修件],[合格放行],[不合格放行],[扫描条码]
|
||||
|
||||
//BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, "产品型号代码_MES", EngineTypeID.ToString());
|
||||
//BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, "发动机型号_MES", EngineType);
|
||||
|
||||
// 获取左置右置 只有测试线传
|
||||
if(OpName == "J07ET010")
|
||||
{
|
||||
int LeftRightData = 0;
|
||||
DataTable LeftRightDt = BaseDataSystemMES.Get_IsExistLeftRight(EngineType);
|
||||
LeftRightData = Convert.ToInt32(LeftRightDt.Rows[0]["type"]);
|
||||
MIS_BASE.WritePLC(114, OpName, LeftRightData);
|
||||
}
|
||||
|
||||
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName, true);
|
||||
|
||||
//Thread.Sleep(5000);
|
||||
//MIS_BASE.Write_EngineTypeGetOver_MES(OpName, false);
|
||||
|
||||
//等待PLC将数据写入RFID;写入PLC的DB块,通知MES验证RFID机型数据是否正确传递
|
||||
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "扫码成功,请开始工作!");
|
||||
BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 2);
|
||||
//通知web显示
|
||||
SendMessage.ShowMoby(OpName);
|
||||
//SendMessageFun.SendMessage("1235", "1111", OpName);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.SendInfomation("EngineIDRepeat", "partSn", OpName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "变速器序列号格式不正确,请确认!");
|
||||
isShowBarNGTipBox = BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 1);
|
||||
if (isShowBarNGTipBox) SendMessageFun.SendInfomation("ShowTipBox", "多次扫描条码失败,请检查扫码位置是否正确!", 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, "条码无效,请确认");
|
||||
isShowBarNGTipBox = BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 1);
|
||||
if (isShowBarNGTipBox) SendMessageFun.SendInfomation("ShowTipBox", "多次扫描条码失败,请检查扫码位置是否正确!", 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("24", "11", OpName);
|
||||
|
||||
//物料验证完成,通知PLC允许工作,允许工作在保存完成时清空
|
||||
MIS_BASE.Write_FixAllow(OpName, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//SendMessageFun.AsyncSendMessage_Notice(OpName, "");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage.AsyncSendMessage_Notice(OpName, "产品上线后,PLC获得变速器序列号后,再验证物料!");
|
||||
isShowBarNGTipBox = BaseDataSystemMES.Check_BarCodeNGTemp(OpName, 1);
|
||||
if (isShowBarNGTipBox) SendMessageFun.SendInfomation("ShowTipBox", "多次扫描条码失败,请检查扫码位置是否正确!", OpName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
// 保存出错日志 1.申请上线 2.传递机型 3.允许保存 4.扫码
|
||||
MisDataSaveDate.FuntionMesRead.Alarm_SaveFileLog4Error(4, e, "Fun1051", err);
|
||||
////ApplicationLog.WriteLog(err, "Function08:Barcode");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user