init: 潍柴发动机线 中央控制程序 项目首次入库
This commit is contained in:
208
SCADA/WebAPI/AnalysisMsg.cs
Normal file
208
SCADA/WebAPI/AnalysisMsg.cs
Normal file
@@ -0,0 +1,208 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SlMesDbIterface;
|
||||
using System.Net.Mail;
|
||||
using PLMTEST;
|
||||
using System.Collections;
|
||||
using System.Drawing.Imaging;
|
||||
using DataLinkMesWork;
|
||||
using MesWork;
|
||||
|
||||
|
||||
namespace WebApi
|
||||
{
|
||||
|
||||
public class msgResHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// 任务ID
|
||||
/// </summary>
|
||||
public string taskId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回结果
|
||||
/// </summary>
|
||||
public string code
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回消息
|
||||
/// </summary>
|
||||
public string msg
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回消息2
|
||||
/// </summary>
|
||||
public string message
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回结果集
|
||||
/// </summary>
|
||||
public string returnData
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
public class syncOrderReq
|
||||
{
|
||||
/// <summary>
|
||||
/// 指令类型
|
||||
/// </summary>
|
||||
public string type
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 工位号
|
||||
/// </summary>
|
||||
public string opName
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 数值
|
||||
/// </summary>
|
||||
public string value
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
public class AnalysisMsg
|
||||
{
|
||||
/// <summary>
|
||||
/// UUID生成
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string UuidUtil()
|
||||
{
|
||||
string result = Guid.NewGuid().ToString();
|
||||
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 重新判断是否申请上线
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
public static string MisFunction(string url, string str)
|
||||
{
|
||||
var result = new msgResHeader();
|
||||
result.taskId = UuidUtil();
|
||||
result.code = "0";
|
||||
result.msg = "";
|
||||
result.returnData = "";
|
||||
|
||||
string errorMessage = "";
|
||||
try
|
||||
{
|
||||
/*
|
||||
15 系统健康
|
||||
5 传递机型(AMS)
|
||||
66 允许PLC工作(AMS)
|
||||
34 发动机上线报警标志
|
||||
20 AMS保存完数据(AMS)
|
||||
112 发动机上线报警代码
|
||||
73 机型标志(AMS)
|
||||
74 变速箱总成编号(AMS)
|
||||
75 产品型号(AMS)
|
||||
116 缸体打印码
|
||||
117 订单号
|
||||
|
||||
14 系统健康(PLC)
|
||||
2 工件到位(PLC)
|
||||
43 申请零件编号(PLC)
|
||||
44 传递机型(PLC)
|
||||
63 禁用MES(PLC)
|
||||
9 机型标志(PLC)
|
||||
10 变速箱总成编号(PLC)
|
||||
11 产品型号(PLC)
|
||||
80 托盘编号(PLC)
|
||||
22 0空托盘,1合格件,2不合格件(PLC)
|
||||
19 质量数据可以读数据(PLC)
|
||||
21 质量数据工位合格标志(PLC)
|
||||
23 0正常件,1返修件(PLC)
|
||||
39 缸体打印码(PLC)
|
||||
40 订单号(PLC)
|
||||
120 上线缸体码(PLC)
|
||||
*/
|
||||
// 解析订单内容,存储数据库,根据实际业务来写
|
||||
syncOrderReq BaseData = JsonHelper.JsonDeserialize<syncOrderReq>(str);
|
||||
string OpName = BaseData.opName;
|
||||
switch (BaseData.type)
|
||||
{
|
||||
case "1": // 重新申请上线
|
||||
// 判断是否有工件到位与申请上线 与 没有MES传递机型
|
||||
int workStart = Convert.ToInt32(MesWorkForm.ReadPLC(2, OpName));
|
||||
int partLoad = Convert.ToInt32(MesWorkForm.ReadPLC(43, OpName));
|
||||
int MESEngineType = Convert.ToInt32(MesWorkForm.ReadPLC(5, OpName));
|
||||
if (workStart == 1 && partLoad == 1 && MESEngineType == 0)
|
||||
{
|
||||
// 符合条件写入 e 重新调用 申请上线
|
||||
OpcData.CustomeEvetnArgs e = new OpcData.CustomeEvetnArgs();
|
||||
//MesWorkForm.UseMisFuntion(e);
|
||||
e.TagID = 111;
|
||||
e.OpName = OpName;
|
||||
e.TagTypeID = 11;
|
||||
e.IsFirstValue = "0";
|
||||
e.TagTypeCodeID = 43;
|
||||
e.TagValue = "1";
|
||||
MesWorkForm mewForm = new MesWorkForm();
|
||||
mewForm.UseMisFuntion(e);
|
||||
|
||||
result.message = "写入数据成功";
|
||||
result.code = "200";
|
||||
result.returnData = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
result.message = "当前不满足触发条件 workStart:" + workStart + " partLoad:" + partLoad + " MESEngineType:" + MESEngineType;
|
||||
result.code = "201";
|
||||
result.returnData = "";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (errorMessage != "")
|
||||
{
|
||||
result.message = errorMessage;
|
||||
result.code = "501";
|
||||
result.returnData = "ERROR";
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
result.message = "501";
|
||||
result.msg = err.Message;
|
||||
result.returnData = "ERROR";
|
||||
}
|
||||
return JsonConvert.SerializeObject(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user