init: CATL电池线SCADA首次入库
This commit is contained in:
519
DT_SCADA/webApi/Analysis_MOM_Msg.cs
Normal file
519
DT_SCADA/webApi/Analysis_MOM_Msg.cs
Normal file
@@ -0,0 +1,519 @@
|
||||
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 System.Net.Mail;
|
||||
using PLMTEST;
|
||||
using DataLinkMesWork;
|
||||
using System.Collections;
|
||||
using System.Drawing.Imaging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Web.Http;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
using System.Windows.Forms;
|
||||
using NPOI.SS.Formula;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Resources;
|
||||
using System.Runtime.Versioning;
|
||||
using NPOI.SS.UserModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Remoting.Metadata.W3cXsd2001;
|
||||
using System.Xml.Linq;
|
||||
using Adapters;
|
||||
using System.Security.Policy;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public class Analysis_MOM_Msg
|
||||
{
|
||||
/// <summary>
|
||||
/// UUID生成
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string UuidUtil()
|
||||
{
|
||||
string result = Guid.NewGuid().ToString();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取时间戳
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Int64 GetTimeStamp()
|
||||
{
|
||||
TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
return Convert.ToInt64(ts.TotalSeconds);
|
||||
}
|
||||
/// <summary>
|
||||
/// 接收检测数据
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
public static string OnlineCheckData(string url, [FromBody] JObject jobj)
|
||||
{
|
||||
var result = new msgResHeader();
|
||||
result.MsgId = "";
|
||||
result.Message = "";
|
||||
result.Code = "200";
|
||||
result.Data = "";
|
||||
|
||||
string errorMessage = "";
|
||||
string parentID = "";
|
||||
int AID = -1;
|
||||
|
||||
|
||||
int isError = 0;
|
||||
string str = jobj.ToString();
|
||||
try
|
||||
{
|
||||
//存储日志
|
||||
var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
//Event_MOM_Log_Insert,@创建时间,@内容
|
||||
var param = new SqlParameter[] {
|
||||
new SqlParameter("@接口地址",url),
|
||||
new SqlParameter("@接口类型",2), // 1. 主动调用接口 2. 被调用接口
|
||||
new SqlParameter("@请求内容",str),
|
||||
new SqlParameter("@请求时间",CreateTime)
|
||||
};
|
||||
|
||||
DataLinkMesWork.SQLCommon.ExecuteStoredProcedure("接口_IOT接口交互日志_请求记录", MesWorkForm.ConnectionString, ref param, out DataTable dt, out errorMessage);
|
||||
|
||||
if (jobj == null)
|
||||
{
|
||||
result.Code = "500";
|
||||
result.Message = "参数格式不正确!";
|
||||
string retString1 = JsonConvert.SerializeObject(result);
|
||||
MW_Log.LoggerHelper.Info("接收检测数据_res", retString1);
|
||||
return retString1;
|
||||
}
|
||||
|
||||
// 解析订单内容,存储数据库,根据实际业务来写
|
||||
OnlineCheckData onlineCheckData = JsonConvert.DeserializeObject<OnlineCheckData>(str);
|
||||
if (onlineCheckData.MsgId == "")
|
||||
{
|
||||
throw new Exception("参数MsgId为空!");
|
||||
}
|
||||
result.MsgId = onlineCheckData.MsgId;
|
||||
if (onlineCheckData.OpCode == "")
|
||||
{
|
||||
throw new Exception("参数OpCode为空!");
|
||||
}
|
||||
if (onlineCheckData.ProductionCode == "")
|
||||
{
|
||||
throw new Exception("参数ProductionCode为空!");
|
||||
}
|
||||
int Id_tagCF = 0;
|
||||
SqlParameter[] param1 = new SqlParameter[6];
|
||||
param1[0] = new SqlParameter("@EngineID", onlineCheckData.ProductionCode);
|
||||
param1[1] = new SqlParameter("@工位号", onlineCheckData.OpCode);
|
||||
param1[2] = new SqlParameter("@操作者工号", onlineCheckData.CheckPerson);
|
||||
param1[3] = new SqlParameter("@扫码时间", onlineCheckData.ScanTime);
|
||||
param1[4] = new SqlParameter("@合格标志", onlineCheckData.QualityMark);
|
||||
param1[5] = new SqlParameter("@Id_tagCF", Id_tagCF);
|
||||
param1[5].Direction = ParameterDirection.Output;
|
||||
|
||||
DataLinkMesWork.SQLCommon.ExecuteStoredProcedure("CATL_测量数据合格索引_增加_测试设备", MesWorkForm.ConnectionString, ref param1, out errorMessage);
|
||||
if (errorMessage != "")
|
||||
{
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
Id_tagCF = Convert.ToInt32(param1[5].Value.ToString());
|
||||
|
||||
|
||||
List<OnlineCheckData_CheckData> onlineCheckData_CheckDataList = onlineCheckData.CheckData;
|
||||
|
||||
for (int i = 0;i < onlineCheckData_CheckDataList.Count;i++)
|
||||
{
|
||||
OnlineCheckData_CheckData onlineCheckData_CheckData = onlineCheckData_CheckDataList[i];
|
||||
|
||||
var param2 = new SqlParameter[] {
|
||||
new SqlParameter("@Id_tagCF", Id_tagCF),
|
||||
new SqlParameter("@EngineID", onlineCheckData.ProductionCode),
|
||||
new SqlParameter("@TagID",onlineCheckData_CheckData.CheckCode),
|
||||
new SqlParameter("@TagValue",onlineCheckData_CheckData.CheckValue),
|
||||
new SqlParameter("@IsGoodBad",onlineCheckData_CheckData.QualityMark),
|
||||
new SqlParameter("@工位号",onlineCheckData.OpCode),
|
||||
new SqlParameter("@理论值",onlineCheckData_CheckData.StandardValue),
|
||||
new SqlParameter("@上限值",onlineCheckData_CheckData.MaxValue),
|
||||
new SqlParameter("@下限值",onlineCheckData_CheckData.MinValue),
|
||||
new SqlParameter("@测量项目",onlineCheckData_CheckData.CheckName),
|
||||
new SqlParameter("@测量单位",onlineCheckData_CheckData.Unit),
|
||||
};
|
||||
DataLinkMesWork.SQLCommon.ExecuteStoredProcedure("CATL_测量数据合格_增加_测试设备", MesWorkForm.ConnectionString, ref param2, out errorMessage);
|
||||
if (errorMessage != "")
|
||||
{
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
result.Code = "500";
|
||||
result.Message = err.Message;
|
||||
}
|
||||
string retString = JsonConvert.SerializeObject(result);
|
||||
MW_Log.LoggerHelper.Info("接收检测数据_res", retString);
|
||||
return retString;
|
||||
}
|
||||
/// <summary>
|
||||
/// 接收查询检测次数
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
public static string OnlineCheckDataCount(string url, [FromBody] JObject jobj)
|
||||
{
|
||||
var result = new msgResHeader2();
|
||||
result.MsgId = "";
|
||||
result.Message = "";
|
||||
result.Code = "200";
|
||||
result.Data = new checkCountData();
|
||||
result.Data.CheckCountOk = 0;
|
||||
result.Data.CheckCountNg = 0;
|
||||
string errorMessage = "";
|
||||
string parentID = "";
|
||||
int AID = -1;
|
||||
|
||||
if (jobj == null)
|
||||
{
|
||||
result.Code = "500";
|
||||
result.Message = "参数格式不正确!";
|
||||
string retString1 = JsonConvert.SerializeObject(result);
|
||||
MW_Log.LoggerHelper.Info("接收查询检测次数_res", retString1);
|
||||
return retString1;
|
||||
}
|
||||
int isError = 0;
|
||||
string str = jobj.ToString();
|
||||
try
|
||||
{
|
||||
//存储日志
|
||||
var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
//Event_MOM_Log_Insert,@创建时间,@内容
|
||||
var param = new SqlParameter[] {
|
||||
new SqlParameter("@接口地址",url),
|
||||
new SqlParameter("@接口类型",2), // 1. 主动调用接口 2. 被调用接口
|
||||
new SqlParameter("@请求内容",str),
|
||||
new SqlParameter("@请求时间",CreateTime)
|
||||
};
|
||||
|
||||
DataLinkMesWork.SQLCommon.ExecuteStoredProcedure("接口_IOT接口交互日志_请求记录", MesWorkForm.ConnectionString, ref param, out DataTable dt, out errorMessage);
|
||||
|
||||
// 解析订单内容,存储数据库,根据实际业务来写
|
||||
OnlineCheckData onlineCheckData = JsonConvert.DeserializeObject<OnlineCheckData>(str);
|
||||
if (onlineCheckData.MsgId == "")
|
||||
{
|
||||
throw new Exception("参数MsgId为空!");
|
||||
}
|
||||
result.MsgId = onlineCheckData.MsgId;
|
||||
if (onlineCheckData.OpCode == "")
|
||||
{
|
||||
throw new Exception("参数OpCode为空!");
|
||||
}
|
||||
if (onlineCheckData.ProductionCode == "")
|
||||
{
|
||||
throw new Exception("参数ProductionCode为空!");
|
||||
}
|
||||
|
||||
SqlParameter[] param1 = new SqlParameter[2];
|
||||
param1[0] = new SqlParameter("@EngineID", onlineCheckData.ProductionCode);
|
||||
param1[1] = new SqlParameter("@工位号", onlineCheckData.OpCode);
|
||||
|
||||
DataLinkMesWork.SQLCommon.ExecuteStoredProcedure("CATL_测量数据合格_查询测试次数_测试设备", MesWorkForm.ConnectionString, ref param1, out DataTable dt1, out errorMessage);
|
||||
if (errorMessage != "")
|
||||
{
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
|
||||
if (dt1 != null && dt1.Rows.Count > 0)
|
||||
{
|
||||
result.Data.CheckCountOk = Convert.ToInt32(dt1.Rows[0]["OK"]);
|
||||
result.Data.CheckCountNg = Convert.ToInt32(dt1.Rows[0]["NG"]);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
result.Code = "500";
|
||||
result.Message = err.Message;
|
||||
}
|
||||
string retString = JsonConvert.SerializeObject(result);
|
||||
MW_Log.LoggerHelper.Info("接收查询检测次数_res", retString);
|
||||
return retString;
|
||||
}
|
||||
/// <summary>
|
||||
/// 接收查询检测次数
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
public static string OnlineCheckDataCountBool(string url, [FromBody] JObject jobj)
|
||||
{
|
||||
var result = new msgResHeader3();
|
||||
result.MsgId = "";
|
||||
result.Message = "";
|
||||
result.Code = "200";
|
||||
result.Data = new checkCountBoolData();
|
||||
result.Data.isCheck = false;
|
||||
string errorMessage = "";
|
||||
string parentID = "";
|
||||
int AID = -1;
|
||||
|
||||
if (jobj == null)
|
||||
{
|
||||
result.Code = "500";
|
||||
result.Message = "参数格式不正确!";
|
||||
string retString1 = JsonConvert.SerializeObject(result);
|
||||
MW_Log.LoggerHelper.Info("接收查询检测次数Bool_res", retString1);
|
||||
return retString1;
|
||||
}
|
||||
int isError = 0;
|
||||
string str = jobj.ToString();
|
||||
try
|
||||
{
|
||||
//存储日志
|
||||
var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
//Event_MOM_Log_Insert,@创建时间,@内容
|
||||
var param = new SqlParameter[] {
|
||||
new SqlParameter("@接口地址",url),
|
||||
new SqlParameter("@接口类型",2), // 1. 主动调用接口 2. 被调用接口
|
||||
new SqlParameter("@请求内容",str),
|
||||
new SqlParameter("@请求时间",CreateTime)
|
||||
};
|
||||
|
||||
DataLinkMesWork.SQLCommon.ExecuteStoredProcedure("接口_IOT接口交互日志_请求记录", MesWorkForm.ConnectionString, ref param, out DataTable dt, out errorMessage);
|
||||
|
||||
// 解析订单内容,存储数据库,根据实际业务来写
|
||||
OnlineCheckData onlineCheckData = JsonConvert.DeserializeObject<OnlineCheckData>(str);
|
||||
if (onlineCheckData.MsgId == "")
|
||||
{
|
||||
throw new Exception("参数MsgId为空!");
|
||||
}
|
||||
result.MsgId = onlineCheckData.MsgId;
|
||||
if (onlineCheckData.OpCode == "")
|
||||
{
|
||||
throw new Exception("参数OpCode为空!");
|
||||
}
|
||||
if (onlineCheckData.ProductionCode == "")
|
||||
{
|
||||
throw new Exception("参数ProductionCode为空!");
|
||||
}
|
||||
|
||||
SqlParameter[] param1 = new SqlParameter[2];
|
||||
param1[0] = new SqlParameter("@EngineID", onlineCheckData.ProductionCode);
|
||||
param1[1] = new SqlParameter("@工位号", onlineCheckData.OpCode);
|
||||
|
||||
DataLinkMesWork.SQLCommon.ExecuteStoredProcedure("CATL_测量数据合格_查询测试次数_测试设备", MesWorkForm.ConnectionString, ref param1, out DataTable dt1, out errorMessage);
|
||||
if (errorMessage != "")
|
||||
{
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
|
||||
if (dt1 != null && dt1.Rows.Count > 0)
|
||||
{
|
||||
if(Convert.ToInt32(dt1.Rows[0]["OK"]) > 0 || Convert.ToInt32(dt1.Rows[0]["NG"]) > 0)
|
||||
{
|
||||
result.Data.isCheck = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
result.Code = "500";
|
||||
result.Message = err.Message;
|
||||
}
|
||||
string retString = JsonConvert.SerializeObject(result);
|
||||
MW_Log.LoggerHelper.Info("接收查询检测次数_res", retString);
|
||||
return retString;
|
||||
}
|
||||
/// <summary>
|
||||
/// 接收打印任务
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
public static string ReceivePrintTask(string url, [FromBody] JObject jobj)
|
||||
{
|
||||
var result = new msgResHeader();
|
||||
result.MsgId = "";
|
||||
result.Message = "";
|
||||
result.Code = "200";
|
||||
result.Data = "";
|
||||
|
||||
string errorMessage = "";
|
||||
string parentID = "";
|
||||
int AID = -1;
|
||||
|
||||
if (jobj == null)
|
||||
{
|
||||
result.Code = "500";
|
||||
result.Message = "参数格式不正确!";
|
||||
string retString1 = JsonConvert.SerializeObject(result);
|
||||
MW_Log.LoggerHelper.Info("接收打印任务_res", retString1);
|
||||
return retString1;
|
||||
}
|
||||
|
||||
string str = jobj.ToString();
|
||||
try
|
||||
{
|
||||
//存储日志
|
||||
var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
//Event_MOM_Log_Insert,@创建时间,@内容
|
||||
var param = new SqlParameter[] {
|
||||
new SqlParameter("@接口地址",url),
|
||||
new SqlParameter("@接口类型",2), // 1. 主动调用接口 2. 被调用接口
|
||||
new SqlParameter("@请求内容",str),
|
||||
new SqlParameter("@请求时间",CreateTime)
|
||||
};
|
||||
|
||||
DataLinkMesWork.SQLCommon.ExecuteStoredProcedure("接口_IOT接口交互日志_请求记录", MesWorkForm.ConnectionString, ref param, out DataTable dt, out errorMessage);
|
||||
|
||||
|
||||
|
||||
// 解析订单内容,存储数据库,根据实际业务来写
|
||||
PrintTaskData printTaskData = JsonConvert.DeserializeObject<PrintTaskData>(str);
|
||||
if (printTaskData.printTemplete == "")
|
||||
{
|
||||
throw new Exception("参数printTemplete为空!");
|
||||
}
|
||||
|
||||
if (printTaskData.productCode == "")
|
||||
{
|
||||
throw new Exception("参数productCode为空!");
|
||||
}
|
||||
if (printTaskData.printDate == "")
|
||||
{
|
||||
throw new Exception("参数printDate为空!");
|
||||
}
|
||||
string msg = $"MARK|{printTaskData.printTemplete}|{printTaskData.productCode},{printTaskData.printDate}";
|
||||
|
||||
// 连接打印机
|
||||
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
try
|
||||
{
|
||||
socket.Connect(MesWorkForm.MarkingMachine_Ip, int.Parse(MesWorkForm.MarkingMachine_Port));
|
||||
}
|
||||
catch(Exception err)
|
||||
{
|
||||
throw new Exception("连接打印机失败:" + err.Message);
|
||||
}
|
||||
// 发送数据
|
||||
try
|
||||
{
|
||||
if (socket.Connected)
|
||||
{
|
||||
byte[] decBytes = System.Text.Encoding.UTF8.GetBytes(msg);
|
||||
//socket.Send(decBytes);
|
||||
socket.Send(decBytes, 0, decBytes.Length, SocketFlags.None);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("连接打印机失败");
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
throw new Exception("发送打印数据失败:" + err.Message);
|
||||
}
|
||||
// 关闭
|
||||
try
|
||||
{
|
||||
if (socket.Connected)
|
||||
{
|
||||
socket.Shutdown(SocketShutdown.Both);
|
||||
socket.Close(100);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
result.Code = "500";
|
||||
result.Message = err.Message;
|
||||
}
|
||||
string retString = JsonConvert.SerializeObject(result);
|
||||
MW_Log.LoggerHelper.Info("接收打印任务_res", retString);
|
||||
return retString;
|
||||
}
|
||||
|
||||
public static string GetCharData(string url, [FromBody] JObject jobj)
|
||||
{
|
||||
var result = new CharData();
|
||||
result.reqId = "";
|
||||
result.msg = "";
|
||||
result.errorDetail = "";
|
||||
result.code = "0";
|
||||
result.data = new List<TestResult>();
|
||||
|
||||
string errorMessage = "";
|
||||
string parentID = "";
|
||||
int AID = -1;
|
||||
|
||||
if (jobj == null)
|
||||
{
|
||||
result.code = "500";
|
||||
result.msg = "参数格式不正确!";
|
||||
string retString1 = JsonConvert.SerializeObject(result);
|
||||
MW_Log.LoggerHelper.Info("接收充电数据查询_res", retString1);
|
||||
return retString1;
|
||||
}
|
||||
|
||||
string str = jobj.ToString();
|
||||
try
|
||||
{
|
||||
//存储日志
|
||||
var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
//Event_MOM_Log_Insert,@创建时间,@内容
|
||||
var param = new SqlParameter[] {
|
||||
new SqlParameter("@接口地址",url),
|
||||
new SqlParameter("@接口类型",2), // 1. 主动调用接口 2. 被调用接口
|
||||
new SqlParameter("@请求内容",str),
|
||||
new SqlParameter("@请求时间",CreateTime)
|
||||
};
|
||||
if (MesWorkForm.charDataToken == "")
|
||||
{
|
||||
throw new Exception("未获取到Token!");
|
||||
}
|
||||
DataLinkMesWork.SQLCommon.ExecuteStoredProcedure("接口_IOT接口交互日志_请求记录", MesWorkForm.ConnectionString, ref param, out DataTable dt, out errorMessage);
|
||||
CharDataSearchPrams charDataSearchPrams = JsonConvert.DeserializeObject<CharDataSearchPrams>(str);
|
||||
|
||||
List<TestResult> testResultList = MesWorkForm.GetCharData_Details(charDataSearchPrams, out string code, out string errorDetail);
|
||||
//string syncTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
//for (int i = 0; i < testResultList.Count; i++)
|
||||
//{
|
||||
// string vin = testResultList[i].deviceId;
|
||||
// string testCode = testResultList[i].testCode;
|
||||
// string testStatus = testResultList[i].testStatus;
|
||||
// string testBeginTime = testResultList[i].testBeginTime;
|
||||
// string testEndTime = testResultList[i].testEndTime;
|
||||
// string faultInfo = testResultList[i].faultInfo;
|
||||
// B_DB_Opera.BaseData_tagTable_CharData_Insert(vin, testCode, testStatus, testBeginTime, testEndTime, faultInfo, syncTime, out string errMsg);
|
||||
//}
|
||||
|
||||
result.data = testResultList;
|
||||
result.code = code;
|
||||
result.msg = errorDetail;
|
||||
result.errorDetail = errorDetail;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
result.code = "500";
|
||||
result.msg = err.Message;
|
||||
result.errorDetail = err.Message;
|
||||
}
|
||||
string retString = JsonConvert.SerializeObject(result);
|
||||
MW_Log.LoggerHelper.Info("接收充电数据查询_res", retString);
|
||||
return retString;
|
||||
}
|
||||
}
|
||||
}
|
||||
51
DT_SCADA/webApi/CharData.cs
Normal file
51
DT_SCADA/webApi/CharData.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public class CharData
|
||||
{
|
||||
public string code { get; set; }
|
||||
public string msg { get; set; }
|
||||
public string errorDetail { get; set; }
|
||||
public string reqId { get; set; }
|
||||
public long timestamp { get; set; }
|
||||
public List<TestResult> data { get; set; }
|
||||
}
|
||||
|
||||
public class TestResult
|
||||
{
|
||||
public string vin { get; set; }
|
||||
public string testCode { get; set; }
|
||||
public string testStatus { get; set; }
|
||||
public string testBeginTime { get; set; }
|
||||
public string testEndTime { get; set; }
|
||||
public string faultInfo { get; set; }
|
||||
}
|
||||
|
||||
public class CharData_Token
|
||||
{
|
||||
public string code { get; set; }
|
||||
public string msg { get; set; }
|
||||
public string errorDetail { get; set; }
|
||||
public string reqId { get; set; }
|
||||
public long timestamp { get; set; }
|
||||
public Token data { get; set; }
|
||||
}
|
||||
public class Token
|
||||
{
|
||||
public string token { get; set; }
|
||||
public long expireTime { get; set; }
|
||||
}
|
||||
|
||||
public class CharDataSearchPrams
|
||||
{
|
||||
public string beginDate { get; set; }
|
||||
public string endDate { get; set; }
|
||||
public string vin { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
74
DT_SCADA/webApi/Controller/IpcController.cs
Normal file
74
DT_SCADA/webApi/Controller/IpcController.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using System.Collections.Concurrent;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
|
||||
public class IpcController : ApiController
|
||||
{
|
||||
readonly string headUrl = "Project/";
|
||||
|
||||
[HttpPost]
|
||||
[Route("OnlineCheckData")]
|
||||
public HttpResponseMessage ReceiveMomPlanData([FromBody] JObject jobj)
|
||||
{
|
||||
|
||||
return new HttpResponseMessage
|
||||
{
|
||||
Content = new StringContent(Analysis_MOM_Msg.OnlineCheckData(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json")
|
||||
};
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("OnlineCheckDataCount")]
|
||||
public HttpResponseMessage OnlineCheckDataCount([FromBody] JObject jobj)
|
||||
{
|
||||
|
||||
return new HttpResponseMessage
|
||||
{
|
||||
Content = new StringContent(Analysis_MOM_Msg.OnlineCheckDataCount(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json")
|
||||
};
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("OnlineCheckDataCountBool")]
|
||||
public HttpResponseMessage OnlineCheckDataCountBool([FromBody] JObject jobj)
|
||||
{
|
||||
|
||||
return new HttpResponseMessage
|
||||
{
|
||||
Content = new StringContent(Analysis_MOM_Msg.OnlineCheckDataCountBool(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json")
|
||||
};
|
||||
}
|
||||
[HttpPost]
|
||||
[Route("ReceivePrintTask")]
|
||||
public HttpResponseMessage ReceivePrintTask([FromBody] JObject jobj)
|
||||
{
|
||||
|
||||
return new HttpResponseMessage
|
||||
{
|
||||
Content = new StringContent(Analysis_MOM_Msg.ReceivePrintTask(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json")
|
||||
};
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("GetCharData")]
|
||||
public HttpResponseMessage GetCharData([FromBody] JObject jobj)
|
||||
{
|
||||
return new HttpResponseMessage
|
||||
{
|
||||
Content = new StringContent(Analysis_MOM_Msg.GetCharData(headUrl + System.Reflection.MethodBase.GetCurrentMethod().Name, jobj), Encoding.GetEncoding("UTF-8"), "application/json")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
68
DT_SCADA/webApi/InitServer.cs
Normal file
68
DT_SCADA/webApi/InitServer.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Formatting;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.Cors;
|
||||
using System.Web.Http.SelfHost;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
|
||||
|
||||
public class InitServer
|
||||
{
|
||||
HttpSelfHostConfiguration config = null;
|
||||
HttpSelfHostServer server = null;
|
||||
public InitServer(string Url_WebApi)
|
||||
{
|
||||
// var Url_WebApi = System.Configuration.ConfigurationManager.AppSettings["Url_WebApi"];
|
||||
Init(Url_WebApi);
|
||||
}
|
||||
public void Init(string url)
|
||||
{
|
||||
config = new HttpSelfHostConfiguration(url);
|
||||
|
||||
// 启用跨域
|
||||
config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
|
||||
// 启用特性路由
|
||||
config.MapHttpAttributeRoutes();
|
||||
|
||||
//config.Routes.MapHttpRoute(
|
||||
// name: "DefaultApi",
|
||||
// routeTemplate: "api/{controller}/{id}",
|
||||
// defaults: new { id = RouteParameter.Optional }
|
||||
//);
|
||||
|
||||
// 自定义路由匹配到action
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "API Default",
|
||||
routeTemplate: "api/{controller}/{action}/{id}",
|
||||
defaults: new { id = RouteParameter.Optional }
|
||||
);
|
||||
|
||||
|
||||
|
||||
server = new HttpSelfHostServer(config);
|
||||
|
||||
server.OpenAsync().Wait();
|
||||
|
||||
|
||||
}
|
||||
public class JsonContentNegotiator : IContentNegotiator
|
||||
{
|
||||
private readonly JsonMediaTypeFormatter _jsonFormatter;
|
||||
|
||||
public JsonContentNegotiator(JsonMediaTypeFormatter formatter)
|
||||
{
|
||||
_jsonFormatter = formatter;
|
||||
}
|
||||
public ContentNegotiationResult Negotiate(Type type, HttpRequestMessage request, IEnumerable<MediaTypeFormatter> formatters)
|
||||
{
|
||||
var result = new ContentNegotiationResult(_jsonFormatter, new MediaTypeHeaderValue("application/json"));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
103
DT_SCADA/webApi/OnlineCheckData.cs
Normal file
103
DT_SCADA/webApi/OnlineCheckData.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static NPOI.HSSF.Util.HSSFColor;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
/// <summary>
|
||||
/// OnlineCheckData
|
||||
/// </summary>
|
||||
|
||||
public class OnlineCheckData
|
||||
{
|
||||
/// <summary>
|
||||
/// MsgId
|
||||
/// </summary>
|
||||
public string MsgId { get; set; } = "";
|
||||
/// <summary>
|
||||
/// OpCode
|
||||
/// </summary>
|
||||
public string OpCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// ProductionCode
|
||||
/// </summary>
|
||||
public string ProductionCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// CheckTime
|
||||
/// </summary>
|
||||
public string ScanTime { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// CheckPerson
|
||||
/// </summary>
|
||||
public string CheckPerson { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// QualityMark
|
||||
/// </summary>
|
||||
public int QualityMark { get; set; } = 1;
|
||||
|
||||
public List<OnlineCheckData_CheckData> CheckData { get; set; } = new List<OnlineCheckData_CheckData>();
|
||||
}
|
||||
|
||||
public class OnlineCheckData_CheckData
|
||||
{
|
||||
/// <summary>
|
||||
/// CheckCode
|
||||
/// </summary>
|
||||
public string CheckCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// CheckName
|
||||
/// </summary>
|
||||
public string CheckName { get; set; } = "";
|
||||
/// <summary>
|
||||
/// ProductionCode
|
||||
/// </summary>
|
||||
public string Unit { get; set; }
|
||||
/// <summary>
|
||||
/// StandardValue
|
||||
/// </summary>
|
||||
public string StandardValue { get; set; } = "";
|
||||
/// <summary>
|
||||
/// MinValue
|
||||
/// </summary>
|
||||
public string MinValue { get; set; } = "";
|
||||
/// <summary>
|
||||
/// MaxValue
|
||||
/// </summary>
|
||||
public string MaxValue { get; set; } = "";
|
||||
/// <summary>
|
||||
/// CheckValue
|
||||
/// </summary>
|
||||
public string CheckValue { get; set; } = "";
|
||||
/// <summary>
|
||||
/// QualityMark
|
||||
/// </summary>
|
||||
public int QualityMark { get; set; } = 1;
|
||||
}
|
||||
public class PrintTaskData
|
||||
{
|
||||
/// string msg = $"MARK|{printTemplete}|{productCode},{printDate}";
|
||||
|
||||
/// <summary>
|
||||
/// printTemplete
|
||||
/// </summary>
|
||||
public string printTemplete { get; set; } = "";
|
||||
/// <summary>
|
||||
/// productCode
|
||||
/// </summary>
|
||||
public string productCode { get; set; } = "";
|
||||
/// <summary>
|
||||
/// printDate
|
||||
/// </summary>
|
||||
public string printDate { get; set; } = "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
147
DT_SCADA/webApi/msgResHeader.cs
Normal file
147
DT_SCADA/webApi/msgResHeader.cs
Normal file
@@ -0,0 +1,147 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public class msgResHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// 任务ID
|
||||
/// </summary>
|
||||
public string MsgId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回结果
|
||||
/// </summary>
|
||||
public string Code
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回消息
|
||||
/// </summary>
|
||||
public string Message
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回数据
|
||||
/// </summary>
|
||||
public string Data
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
public class msgResHeader2
|
||||
{
|
||||
/// <summary>
|
||||
/// 任务ID
|
||||
/// </summary>
|
||||
public string MsgId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回结果
|
||||
/// </summary>
|
||||
public string Code
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回消息
|
||||
/// </summary>
|
||||
public string Message
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回数据
|
||||
/// </summary>
|
||||
public checkCountData Data
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
public class msgResHeader3
|
||||
{
|
||||
/// <summary>
|
||||
/// 任务ID
|
||||
/// </summary>
|
||||
public string MsgId
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回结果
|
||||
/// </summary>
|
||||
public string Code
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回消息
|
||||
/// </summary>
|
||||
public string Message
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回数据
|
||||
/// </summary>
|
||||
public checkCountBoolData Data
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
public class checkCountData
|
||||
{
|
||||
/// <summary>
|
||||
/// 检测次数
|
||||
/// </summary>
|
||||
public int CheckCountOk
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 检测次数
|
||||
/// </summary>
|
||||
public int CheckCountNg
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
public class checkCountBoolData
|
||||
{
|
||||
/// <summary>
|
||||
/// 检测次数
|
||||
/// </summary>
|
||||
public bool isCheck
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user