init: 导入项目到 meswork Gitea
This commit is contained in:
412
MisDataFun/SendMessageToWebMqtt/SendMessage.cs
Normal file
412
MisDataFun/SendMessageToWebMqtt/SendMessage.cs
Normal file
@@ -0,0 +1,412 @@
|
||||
using bizFacade;
|
||||
using MesWorkMqtt;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MesServerFunctions
|
||||
{
|
||||
/// <summary>
|
||||
/// 命令
|
||||
///显示托盘信息√ case "ShowMoby":
|
||||
///显示操作指南√ case "ProcessList":
|
||||
///显示物料√ case "MaterialList":
|
||||
///显示操作图片√ case "PicShow":
|
||||
///显示拧紧位置√ case "ShaftPosition":
|
||||
///实时显示质量数据√ case "ShowTimelyQuality":
|
||||
///手动拧紧实时显示质量数据√case "ShowTimelyQuality_Tight":
|
||||
///√ case "OrderFormList":
|
||||
///弹窗消息√ case "Notice":
|
||||
///LED消息提醒√ case "ScrollNotice":
|
||||
///物料检测初始化√ case "MaterialCheckPosition":
|
||||
///返修质量数据显示√ case "RepairQuality"
|
||||
///
|
||||
/// </summary>
|
||||
public class SendMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// MES/InstantMessaging/BQ
|
||||
/// </summary>
|
||||
public static string MqttTargetTopic = ConfigurationManager.AppSettings["MqttTargetTopic"];
|
||||
/// <summary>
|
||||
/// WEB/InstantMessaging/BQ/MisServer
|
||||
/// </summary>
|
||||
public static string MqttTargetTopicWEB = ConfigurationManager.AppSettings["MqttTargetTopicWEB"];
|
||||
/// <summary>
|
||||
/// BAR/InstantMessaging/BQ
|
||||
/// </summary>
|
||||
public static string MqttTargetTopicBAR = ConfigurationManager.AppSettings["MqttTargetTopicBAR"];
|
||||
|
||||
public static void SendMessageBARToMES(string opName, string msgText)
|
||||
{
|
||||
var topic = $"{MqttTargetTopicBAR}";
|
||||
|
||||
if (msgText.Length > 0)
|
||||
{
|
||||
Task.Run(() => Mqtt.Publish(topic, msgText));
|
||||
}
|
||||
SendMessageMESToWEB(opName, msgText);
|
||||
}
|
||||
public static void SendMessageMESToWEB(string opName, string msgText)
|
||||
{
|
||||
var topic = $"{MqttTargetTopic}/{opName}";
|
||||
|
||||
if (msgText.Length > 0)
|
||||
{
|
||||
Task.Run(() => Mqtt.Publish(topic, msgText));
|
||||
}
|
||||
}
|
||||
public static void SendMessageWEBToMES(string msgText)
|
||||
{
|
||||
var topic = $"{MqttTargetTopicWEB}";
|
||||
|
||||
if (msgText.Length > 0)
|
||||
{
|
||||
Task.Run(() => Mqtt.Publish(topic, msgText));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 5 显示订单、机型信息
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
public static void ShowMoby(string opName)
|
||||
{
|
||||
var topic = $"{MqttTargetTopic}/{opName}";
|
||||
var responseStr = ShowMoby_String(opName);
|
||||
string cmd = "ShowMoby";
|
||||
if (responseStr.Length > 0)
|
||||
{
|
||||
Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}"));
|
||||
}
|
||||
}
|
||||
public static void MaterialList_Dif(string opName,string msgText)
|
||||
{
|
||||
var topic = $"{MqttTargetTopic}/{opName}";
|
||||
string cmd = "MaterialList_Dif";
|
||||
if (msgText.Length > 0)
|
||||
{
|
||||
Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{msgText}"));
|
||||
}
|
||||
}
|
||||
public static void AsyncSendMessage_Notice(string opname, string notice)
|
||||
{
|
||||
//通知Web界面
|
||||
BaseDataSystemMES.Web_Notice_Insert(opname, notice);
|
||||
Notice(opname);
|
||||
}
|
||||
public static void Notice(string opName)
|
||||
{
|
||||
var topic = $"{MqttTargetTopic}/{opName}";
|
||||
var responseStr = Notice_String(opName);
|
||||
string cmd = "Notice";
|
||||
if (responseStr.Length > 0)
|
||||
{
|
||||
Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}"));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 1(直接在界面通过选择机型确认工序内容)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
public static void ProcessList(string opName)
|
||||
{
|
||||
var topic = $"{MqttTargetTopic}/{opName}";
|
||||
var responseStr = ProcessList_String(opName);
|
||||
string cmd = "ProcessList";
|
||||
if (responseStr.Length > 0)
|
||||
{
|
||||
Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}"));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 2显示物料
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
public static void MaterialList(string opName)
|
||||
{
|
||||
var topic = $"{MqttTargetTopic}/{opName}";
|
||||
var responseStr = MaterialList_String(opName);
|
||||
string cmd = "MaterialList";
|
||||
if (responseStr.Length > 0)
|
||||
{
|
||||
Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}"));
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 3显示操作指导图片
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
public static void PicShow(string opName)
|
||||
{
|
||||
var topic = $"{MqttTargetTopic}/{opName}";
|
||||
var responseStr = PicShow_String(opName);
|
||||
string cmd = "PicShow";
|
||||
if (responseStr.Length > 0)
|
||||
{
|
||||
Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}"));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 4订单完工模块刷新完成数量
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
public static void OrderFormList(string opName)
|
||||
{
|
||||
var topic = $"{MqttTargetTopic}/{opName}";
|
||||
var responseStr = OrderFormList_String();
|
||||
string cmd = "OrderFormList";
|
||||
if (responseStr.Length > 0)
|
||||
{
|
||||
Task.Run(() => Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}"));
|
||||
}
|
||||
}
|
||||
|
||||
//实时显示质量数据√
|
||||
public static void ShowTimelyQuality(string opName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void SendActuallyCount(string OpName, int tagValue)
|
||||
{
|
||||
//当工件离开时,更新在线产量、在线节拍
|
||||
if (tagValue == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
int opNameCount = 0;//在线产量
|
||||
int opNameCountTime = 0;//在线节拍
|
||||
|
||||
BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime); //基本数据_工作日历_班次产量查询_New
|
||||
|
||||
SendInfomation("ActuallyCount", opNameCount.ToString() + "&" + opNameCountTime.ToString(), OpName);
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "Function01:SendActuallyCount");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void SendInfomation(string Command, string Value, string OpName)
|
||||
{
|
||||
|
||||
string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value;
|
||||
AsyncSendMessage(SendMessage);
|
||||
}
|
||||
|
||||
private static void AsyncSendMessage(string Message)
|
||||
{
|
||||
//lock (locker)
|
||||
{
|
||||
//"MES|MachinePlan|OpName|Value
|
||||
var array = Message.Split('|');
|
||||
var cmd = array[1];
|
||||
var opName = array[2];
|
||||
var topic = $"{MqttTargetTopic}/{opName}";
|
||||
Task.Run(() => Mqtt.Publish(topic, Message));
|
||||
|
||||
}
|
||||
}
|
||||
private static string ProcessList_String(string OpName)
|
||||
{
|
||||
string jsonStr_Process = "";
|
||||
try
|
||||
{
|
||||
string orderNum = "";
|
||||
int EngineTypeID = 0;
|
||||
string EngineType = "";
|
||||
string EngineID = "";
|
||||
string PartPallet_Code = "";
|
||||
int IsrepairBarcode = 0;
|
||||
string repairBarcode = "";
|
||||
DataTable dt_Proccess;
|
||||
|
||||
MES1.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode);
|
||||
|
||||
MES.Process_Select(OpName, EngineTypeID, EngineType, out dt_Proccess);
|
||||
if (dt_Proccess != null)
|
||||
{
|
||||
if (dt_Proccess.Rows.Count > 0)
|
||||
{
|
||||
jsonStr_Process = JsonHelper.CreateJsonParameters(dt_Proccess);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ProcessList");
|
||||
}
|
||||
return jsonStr_Process;
|
||||
}
|
||||
private static string PicShow_String(string OpName)
|
||||
{
|
||||
string data = "";
|
||||
try
|
||||
{
|
||||
string orderNum = "";
|
||||
int EngineTypeID = 0;
|
||||
string EngineType = "";
|
||||
string EngineID = "";
|
||||
string PartPallet_Code = "";
|
||||
int IsrepairBarcode = 0;
|
||||
string repairBarcode = "";
|
||||
byte[] imgBytesIn;
|
||||
MES1.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode);
|
||||
BaseDataSystemMES.GetImageFile(OpName, EngineTypeID.ToString(), out imgBytesIn);
|
||||
if (imgBytesIn == null)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
data = Convert.ToBase64String(imgBytesIn);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:PictureShow");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private static string ShowMoby_String(string OpName)
|
||||
{
|
||||
string data = "";
|
||||
try
|
||||
{
|
||||
string orderNum = "";
|
||||
int EngineTypeID = 0;
|
||||
string EngineType = "";
|
||||
string EngineID = "";
|
||||
string PartPallet_Code = "";
|
||||
int IsrepairBarcode = 0;
|
||||
string repairBarcode = "";
|
||||
MES1.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode);
|
||||
data = orderNum + "&" + EngineTypeID + "&" + EngineType + "&" + EngineID + "&" + PartPallet_Code + "&" + IsrepairBarcode + "&" + repairBarcode;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MobySelect");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private static string MaterialList_String(string OpName)
|
||||
{
|
||||
string jsonStr_Materail = "";
|
||||
try
|
||||
{
|
||||
string orderNum = "";
|
||||
int EngineTypeID = 0;
|
||||
string EngineType = "";
|
||||
string EngineID = "";
|
||||
string PartPallet_Code = "";
|
||||
int IsrepairBarcode = 0;
|
||||
string repairBarcode = "";
|
||||
|
||||
MES1.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode);
|
||||
DataTable dt_Material;
|
||||
|
||||
MES.PartMaterialVerify_Select(OpName, EngineTypeID, EngineType, out dt_Material);
|
||||
if (dt_Material != null)
|
||||
{
|
||||
if (dt_Material.Rows.Count > 0)
|
||||
{
|
||||
jsonStr_Materail = JsonHelper.CreateJsonParameters(dt_Material);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:MaterialList");
|
||||
}
|
||||
return jsonStr_Materail;
|
||||
}
|
||||
|
||||
private static string ShowTimelyQuality_String(string OpName)
|
||||
{
|
||||
string text = "";
|
||||
try
|
||||
{
|
||||
string orderNum = "";
|
||||
int EngineTypeID = 0;
|
||||
string EngineType = "";
|
||||
string EngineID = "";
|
||||
string PartPallet_Code = "";
|
||||
int IsrepairBarcode = 0;
|
||||
string repairBarcode = "";
|
||||
DataTable dt;
|
||||
|
||||
MES1.Moby_Select(OpName, out orderNum, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code, out IsrepairBarcode, out repairBarcode);
|
||||
MES.QualitySelect(OpName, EngineID, out dt);
|
||||
if (dt != null)
|
||||
{
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
text = JsonHelper.CreateJsonParameters(dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Quality_Select");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static string OrderFormList_String()
|
||||
{
|
||||
string enginetypelist = "";
|
||||
try
|
||||
{
|
||||
System.Data.DataTable dt = null;
|
||||
ShaftPosition.EngineType_Select(out dt);
|
||||
if (dt != null)
|
||||
{
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
enginetypelist = JsonHelper.DataTableToJson(dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:Orderenginetypeselect");
|
||||
}
|
||||
return enginetypelist;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 消息提醒
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static string Notice_String(string opname)
|
||||
{
|
||||
string text = "";
|
||||
try
|
||||
{
|
||||
System.Data.DataTable dt = null;
|
||||
MES.ShowWindowNotice(opname, out dt);
|
||||
if (dt != null)
|
||||
{
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
text = JsonHelper.DataTableToJson(dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
////ApplicationLog.WriteLog(err, "MesWebFun_baseFun:ShowWindowNotice");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user