chore: 初始化东安动力MES采集程序
This commit is contained in:
@@ -0,0 +1,200 @@
|
||||
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 OpName_mes = Convert.ToString(msgEvent.OpName) + "_mes";
|
||||
string barcode = Convert.ToString(msgEvent.TagValue);
|
||||
// 判断条码格式是否正确
|
||||
if (barcode.Split(';').Length > 2)
|
||||
{
|
||||
//m003000214179;p23003;x0;g|JS8C.12.825|1|22-K-255-1/组件|ZM6|20230109134927285001740003
|
||||
//[0]m003000214179
|
||||
//[1]p23003
|
||||
//[2]x0
|
||||
//[3]g
|
||||
//[4]JS8C.12.825
|
||||
//[5]1
|
||||
//[6]22-K-255-1/组件
|
||||
//[7]ZM6
|
||||
//[8]20230109134927285001740003
|
||||
|
||||
var barArray = barcode.Split (new char[] { ';', '|'});
|
||||
var orderNo = barArray[0].Substring(1); // 订单号
|
||||
var batchNo = barArray[1].Substring(1); // 批次号
|
||||
var partNo = barArray[4]; // 零件号/机型
|
||||
var partName = barArray[6].Split('/')[1]; //零件名称
|
||||
var partSort = barArray[6].Split('/')[0]; //零件类别
|
||||
var partSortType = barArray[6].Split('/')[0]; //零件类别
|
||||
var partSnNo = barArray[8]; // 零件唯一码
|
||||
|
||||
string EngineType = partNo;//机型
|
||||
string EngineID = orderNo + "_" + partSnNo;//发动机号
|
||||
|
||||
|
||||
bool IsNotRepeatedNumber = false; // 是否重号
|
||||
int IsTodayPlan = 0; // 是否是今天的计划
|
||||
|
||||
//1:获得申请上线信息后,扫描条码才处理业务
|
||||
bool ispartload = false;
|
||||
|
||||
////判断工件是否到位
|
||||
//MIS_BASE.Read_WorkStart(OpName, out ispartload);
|
||||
//if (!ispartload)
|
||||
//{
|
||||
// SendMessageFun.AsyncSendMessage_Notice(OpName, "等待放料提示信号!!");
|
||||
// return;
|
||||
//}
|
||||
|
||||
|
||||
//判断当前设备的模式:手动、自动、脉动
|
||||
//自动模式:
|
||||
|
||||
MIS_BASE.Read_TagTypeID(63, OpName, out object workModel);
|
||||
if (workModel.ToString()=="1")
|
||||
{
|
||||
string opName_db = "";
|
||||
//自动模式时,进行工位转换
|
||||
if (OpName == "OP10")
|
||||
{
|
||||
OpName_mes = "OP10_mes";
|
||||
opName_db = "OP20";
|
||||
}
|
||||
else if (OpName == "OP30")
|
||||
{
|
||||
OpName_mes = "OP30_mes";
|
||||
opName_db = "OP40";
|
||||
}
|
||||
else return;
|
||||
//为产品生成唯一标识(扫码时间戳)
|
||||
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
string Product_FlowTag = Convert.ToInt64(ts.TotalMilliseconds).ToString();
|
||||
|
||||
//判断该产品标识在该工位是否重复
|
||||
IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(Product_FlowTag, opName_db);
|
||||
if (IsNotRepeatedNumber)
|
||||
{
|
||||
// 判断是否是今天的计划
|
||||
BaseDataSystemMES.GetEngineTypeUpLoadOpName(Product_FlowTag, partNo, opName_db, orderNo, batchNo, out IsTodayPlan);
|
||||
if (IsTodayPlan == 1)
|
||||
{
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(opName_db, MobyTagType.WorkStartIn, DateTime.Now.ToString());
|
||||
|
||||
//MIS_BASE.Write_EngineID_MES(OpName_mes, EngineID);
|
||||
MIS_BASE.WritePLC(74, OpName_mes, EngineID);
|
||||
//将随工单零件号写入PLC
|
||||
//MIS_BASE.Write_EngineType_MES(OpName_mes, EngineType);
|
||||
MIS_BASE.WritePLC(75, OpName_mes, EngineType);
|
||||
//先把延时屏蔽掉看看效果如何
|
||||
//Thread.Sleep(1000);
|
||||
|
||||
// MES传递机型
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName_mes, true);
|
||||
//显示当前订单信息
|
||||
SendMessage.ShowMoby(opName_db);
|
||||
//通知web显示
|
||||
SendMessageFun.SendMessage("13", "111", opName_db);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(opName_db, "计划不匹配!!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(opName_db, "工件零件号重号,请确认!");
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//获取脉动模式:
|
||||
MIS_BASE.Read_TagTypeID(63, OpName, out object workModel_MD);
|
||||
//获取手动模式:
|
||||
MIS_BASE.Read_TagTypeID(64, OpName, out object workModel_SD);
|
||||
if (Convert.ToBoolean(workModel_MD) || Convert.ToBoolean(workModel_SD))
|
||||
{ }
|
||||
else return;
|
||||
//手动模式:
|
||||
//判断设备是否申请上线
|
||||
MIS_BASE.Read_PartLoad(OpName, out ispartload);
|
||||
if (!ispartload)
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "等待人工扫码信号!!");
|
||||
return;
|
||||
}
|
||||
|
||||
//2:从数据库判断判断是否已经扫描过这个码 IsRepeatedNumber true 不重号;false 重号;
|
||||
|
||||
IsNotRepeatedNumber = BaseDataSystemMES.EngineTypeID_IsNotRepeatedNumber(EngineID, OpName);
|
||||
if (IsNotRepeatedNumber)
|
||||
{
|
||||
// 判断是否是今天的计划
|
||||
BaseDataSystemMES.GetEngineTypeUpLoadOpName(EngineID, partNo, OpName, orderNo, batchNo, out IsTodayPlan);
|
||||
if (IsTodayPlan == 1)
|
||||
{
|
||||
//将随工单零件号写入PLC
|
||||
MIS_BASE.Write_EngineType_MES(OpName_mes, EngineType);
|
||||
Thread.Sleep(1000);
|
||||
// MES传递机型
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(OpName_mes, true);
|
||||
//显示当前订单信息
|
||||
SendMessage.ShowMoby(OpName);
|
||||
//通知web显示
|
||||
SendMessageFun.SendMessage("13", "111", OpName);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "计划不匹配!!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "工件零件号重号,请确认!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageFun.AsyncSendMessage_Notice(OpName, "工件条码格式不正确,请确认!");
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function08:Barcode");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user