215 lines
8.6 KiB
C#
215 lines
8.6 KiB
C#
using System;
|
||
using System.Data;
|
||
using bizFacade;
|
||
using MesServerWork;
|
||
|
||
namespace MesServerFunctions
|
||
{
|
||
partial class FunctionMES
|
||
{
|
||
/// <summary>
|
||
/// 正常逻辑工作(传递机型)
|
||
/// </summary>
|
||
/// <param name="OpName"></param>
|
||
/// <param name="EngineTypeID"></param>
|
||
/// <param name="EngineType"></param>
|
||
/// <param name="EngineID"></param>
|
||
/// <param name="PartPallet_Code"></param>
|
||
private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code, string OrderForm)
|
||
{
|
||
int IsAllowWork;
|
||
int RepairPartStatusPLC = 0;
|
||
int MES_QualityMask = 1;
|
||
|
||
if (EngineTypeID <= 0 || EngineID.Length == 0 || EngineType.Length == 0)
|
||
{
|
||
MIS_BASE.WritePLC(34, OpName, true);
|
||
string msg = "【" + OpName + "】" + "PLC传递机型为空!";
|
||
MyLog4Net.MyLogHelper.Error("EngineTypeGetOver", msg);
|
||
SendMessageFun.AsyncSendMessage_Notice(OpName, msg);
|
||
return;
|
||
}
|
||
|
||
MIS_BASE.Write_MesReadOver(OpName, false); //保存完成
|
||
MIS_BASE.Write_MaterialVerifyOver(OpName, false); //工作完成信号
|
||
MIS_BASE.Write_FixAllow(OpName, true); // 允许工作
|
||
|
||
//电子看板_装配零件_临时表_增加_北汽
|
||
//第二步,将零件信息转移到零件_临时表中
|
||
// BaseDataSystemMES.MesServer_Process_EngineTypeOverBQ(OpName);
|
||
|
||
//通知web显示
|
||
//SendMessageFun.SendMessage("123", "111", OpName);
|
||
//MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志 合格标志暂时改为即时响应式的
|
||
//MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志
|
||
//SendMessageFun.SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志
|
||
//SendMessageFun.SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志
|
||
|
||
|
||
|
||
//if (MES_QualityMask == 2)
|
||
//{
|
||
// 暂时先屏蔽掉
|
||
////工作完成
|
||
//MIS_BASE.Write_MaterialVerifyOver(OpName, true);
|
||
//SendMessageFun.SendInfomation("NgGO", "1", OpName);//显示不合格标志
|
||
//return;
|
||
// }
|
||
|
||
//第三步,用于工件离开后完工数量统计及工件编号追溯
|
||
//BaseDataSystemMES.MaterialPush_EngineIDStatus_Insert(OpName);//更新订单产量
|
||
|
||
//第四步,获取是否允许工作
|
||
//BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork);
|
||
|
||
//暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况
|
||
//if (IsAllowWork == 1)
|
||
//{
|
||
// MIS_BASE.Write_MesReadOver(OpName, false); //允许保存信号
|
||
// MIS_BASE.Write_MaterialVerifyOver(OpName, false); //工作完成信号
|
||
// MIS_BASE.Write_FixAllow(OpName, true);
|
||
|
||
// // 判断有没有PLC传递机型 没有就不给
|
||
// //bool isEngine = Convert.ToBoolean(MIS_BASE.ReadPLC(44, OpName));
|
||
// //if (isEngine)
|
||
// //{
|
||
// // //通知PLC允许工作,允许工作在保存完成时清空
|
||
// // MIS_BASE.Write_FixAllow(OpName, true);
|
||
// //}
|
||
// //else
|
||
// //{
|
||
// // MyLog4Net.MyLogHelper.Error($"{OpName}给允许工作时无传递机型:", $"Message:");
|
||
// //}
|
||
|
||
//}
|
||
//else
|
||
//{
|
||
// SendMessageFun.AsyncSendMessage_Notice(OpName, "请扫描物料!");
|
||
//}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 二次工作
|
||
/// </summary>
|
||
/// <param name="OpName"></param>
|
||
private void EngineTypeGetOver_PLC_Work_two(string OpName)
|
||
{
|
||
int EngineTypeID;//机型代码
|
||
int PartPallet_Code;//托盘编号
|
||
|
||
string EngineType;//机型
|
||
string EngineID;//工件编号
|
||
string OrderForm;
|
||
MIS_BASE.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out OrderForm);
|
||
EngineTypeGetOver_PLC_Work(OpName, EngineTypeID, EngineType, EngineID, Convert.ToInt32(PartPallet_Code), OrderForm);
|
||
|
||
}
|
||
/// <summary>
|
||
/// 跳过二次工作
|
||
/// </summary>
|
||
/// <param name="OpName"></param>
|
||
private void EngineTypeGetOver_PLC_Work_Skip(string OpName)
|
||
{
|
||
//MIS_BASE.Write_MesReadOver(OpName, true);
|
||
MIS_BASE.Write_MaterialVerifyOver(OpName, true);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 返修件需要工作
|
||
/// </summary>
|
||
/// <param name="OpName">工位号</param>
|
||
private void IsNeedRepaire_OK(string OpName)
|
||
{
|
||
string orderForm = "";
|
||
int engineTypeID;
|
||
string engineType = "";
|
||
string engineID = "";
|
||
string palletCode = "";
|
||
int isRepair;
|
||
string repairCode = "";
|
||
//从监控系统中查询出本工位信息
|
||
BaseDataSystemMES.OpName_MIS_Moby_Select(OpName,
|
||
out orderForm, out engineTypeID, out engineType,
|
||
out engineID, out palletCode, out isRepair, out repairCode);
|
||
|
||
EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode), orderForm);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新待上料数量
|
||
/// </summary>
|
||
/// <param name="OpName"></param>
|
||
private void UpdateWait_NUM_PLC(object e)
|
||
{
|
||
DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
|
||
|
||
string OpName = Convert.ToString(msgEvent.OpName);
|
||
int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||
// 更新待上料数量到数据库
|
||
Db.UpdateWait_NUM_PLC(OpName, tagValue);
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 空料握手plc
|
||
/// </summary>
|
||
/// <param name="OpName"></param>
|
||
private void Handshake_Fun(object e)
|
||
{
|
||
|
||
DoWhatPlc.CustomeEvetnArgs msgEvent = (DoWhatPlc.CustomeEvetnArgs)e;
|
||
string OpName = Convert.ToString(msgEvent.OpName);
|
||
int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||
|
||
if (tagValue == 1)
|
||
{
|
||
int planCount = 0; // 计划上料数量
|
||
int haveUplaodCount = 0; // 已上料数量
|
||
int remainingQuantity = 0; // 待上料数量
|
||
Db.GethandType_Order(OpName, out int EngineTypeID,
|
||
out string EngineType, out string EngineID, out string OrderForm,
|
||
out int isCheckOk, out planCount, out haveUplaodCount, out remainingQuantity);
|
||
if (isCheckOk == 2)
|
||
{
|
||
|
||
MIS_BASE.Write_EngineTypeID_MES(OpName, 0);
|
||
MIS_BASE.Write_EngineType_MES(OpName, "");
|
||
MIS_BASE.Write_EngineID_MES(OpName, "");
|
||
MIS_BASE.Write_OrderForm_MES(OpName, "");
|
||
|
||
// 写回空值
|
||
MIS_BASE.WritePLC(95, OpName, planCount);
|
||
MIS_BASE.WritePLC(96, OpName, haveUplaodCount);
|
||
MIS_BASE.WritePLC(97, OpName, remainingQuantity);
|
||
// 发送MES握手
|
||
MIS_BASE.WritePLC(35, OpName, true);
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, MobyTagType.EngineID_MES, EngineID);
|
||
|
||
// 写入机型代码 (大机型) 机型 发动机号 订单号
|
||
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);
|
||
|
||
MIS_BASE.WritePLC(95, OpName, planCount);
|
||
MIS_BASE.WritePLC(96, OpName, haveUplaodCount);
|
||
MIS_BASE.WritePLC(97, OpName, remainingQuantity);
|
||
|
||
// 发送MES握手
|
||
MIS_BASE.WritePLC(35, OpName, true);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MIS_BASE.WritePLC(35, OpName, false);
|
||
}
|
||
}
|
||
}
|
||
}
|