Files
602_FD/JinYuan.ControlCenter/MES/MESDataCombin.cs.bak
T
2025-09-17 20:04:00 +08:00

1349 lines
62 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using JinYuan.VirtualDataLibrary;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using JinYuan.Helper;
using JinYuan.MES;
using JinYuan.MES.Models;
using JinYuan.MES.Enums;
using JinYuan.Models;
namespace JinYuan.ControlCenters
{
public class MESDataCombin
{
#region 1、员工验证
public static string LoginEnyity(string userName, string passWord)
{
DateTime nowTime = DateTime.Now;
string resJson = string.Empty;
string josnTxtMsg = string.Empty;
try
{
JObject jo = new JObject();
jo.Add("siteCode", CommonMethods.mesConfig.siteCode);
jo.Add("lineCode", CommonMethods.mesConfig.lineCode);
jo.Add("equipNum", CommonMethods.mesConfig.equipNum);
jo.Add("userName", userName);
jo.Add("passWord", passWord);
var sw = new Stopwatch();
sw.Start();
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.LoginMesUrl, jo.ToString());
sw.Stop();
josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用员工权限校验接口:{CommonMethods.mesConfig.LoginMesUrl},请求数据为:{jo.ToString()}\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\员工权限校验\{nowTime.ToString("HH")}.txt", josnTxtMsg);
}
catch (Exception ex)
{
LogHelper.Instance.WriteEX("调用员工权限校验接口", ex);
}
return resJson;
}
#endregion
#region 2、设备参数设定值请求
/// <summary>
/// 设备参数设定值请求
/// </summary>
/// <returns></returns>
public static string ParamSetRequestData()
{
var result = new ParamReturnData();
string resJson = string.Empty;
string josnTxtMsg = string.Empty;
try
{
var model = new
{
siteCode = CommonMethods.mesConfig.siteCode,
lineCode = CommonMethods.mesConfig.lineCode,
equipNum = CommonMethods.mesConfig.equipNum,
materialCode = CommonMethods.mesConfig.MaterialCode,
userName = CommonMethods.mesConfig.mesUserName
};
var nowDate = DateTime.Now;
var postcontent = JsonConvert.SerializeObject(model);
var sw = new Stopwatch();
sw.Start();
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.ParamSetpointRequestMesUrl, postcontent);
sw.Stop();
josnTxtMsg = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用设备参数设定值请求接口:{CommonMethods.mesConfig.ParamSetpointRequestMesUrl},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowDate.ToString("yyyyMMdd")}\设备参数设定值请求\{nowDate.ToString("HH")}.txt", josnTxtMsg);
}
catch (Exception ex)
{
LogHelper.Instance.WriteEX("调用设备参数设定值请求接口", ex);
}
return resJson;
}
#endregion
#region 3、设备参数设定值变更
/// <summary>
/// 设备参数设定值变更
/// </summary>
/// <returns></returns>
public string ParamChangeData()
{
DateTime nowTime = DateTime.Now;
string resJson = string.Empty;
string josnTxtMsg = string.Empty;
try
{
ParamChange paramChange = new ParamChange();
List<TagListItem> tagListItems = new List<TagListItem>();
TagListItem listItem = new TagListItem();
listItem.tagCode = "";
listItem.unitBefore = "";
listItem.standardValueBefore = "";
listItem.trueValueBefore = "";
listItem.falseValueBefore = "";
listItem.minValueBefore = 0;
listItem.maxValueBefore = 100;
listItem.unitAfter = "";
listItem.standardValueAfter = "";
listItem.trueValueAfter = "";
listItem.falseValueBefore = "";
listItem.minValueAfter = 0;
listItem.maxValueAfter = 1000;
tagListItems.Add(listItem);
paramChange.siteCode = CommonMethods.mesConfig.siteCode;
paramChange.lineCode = CommonMethods.mesConfig.lineCode;
paramChange.equipNum = CommonMethods.mesConfig.equipNum;
paramChange.materialCode = CommonMethods.mesConfig.MaterialCode;
paramChange.userName = CommonMethods.mesConfig.mesUserName;
paramChange.changeTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
paramChange.tagGroupCode = "";
paramChange.tagGroupDescription = "";
paramChange.tagList = tagListItems;
string SendJosn = JsonConvert.SerializeObject(paramChange);
var sw = new Stopwatch();
sw.Start();
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.ChangeParamSetValueMesUrl, SendJosn);
sw.Stop();
josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用参数设定值变更接口:{CommonMethods.mesConfig.ParamSetpointRequestMesUrl},请求数据为:{SendJosn},\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\参数设定值变更\{nowTime.ToString("HH")}.txt", josnTxtMsg);
}
catch (Exception ex)
{
LogHelper.Instance.WriteEX("调用参数设定值变更接口", ex);
}
return resJson;
}
#endregion
#region 4、原材料投入信息
#endregion
#region 5、产品进站信息(组装)
/// <summary>
/// 产品进站信息(组装)
/// </summary>
/// <param name="m"></param>
/// <returns></returns>
public string Inboundinformation(List<string> listRFID, ref long outTime, ref string strTimeOut)
{
DateTime nowTime = DateTime.Now;
string resJson = string.Empty;
string josnTxtMsg = string.Empty;
strTimeOut = string.Empty;
outTime = 0;
try
{
JObject jo = new JObject();
jo.Add("siteCode", CommonMethods.mesConfig.siteCode);
jo.Add("lineCode", CommonMethods.mesConfig.lineCode);
jo.Add("equipNum", CommonMethods.mesConfig.equipNum);
jo.Add("materialCode", CommonMethods.mesConfig.MaterialCode);
jo.Add("userName", CommonMethods.mesConfig.mesUserName);
jo.Add("identification", "");
jo.Add("productType", "");
//条码list
JArray ja = new JArray();
jo.Add("identificationList", ja);
//托杯码List
JArray ja2 = new JArray();
for (int i = 0; i < listRFID.Count; i++)
{
ja2.Add(listRFID[i]);
}
jo.Add("containerCodeList", ja2);
var sw = new Stopwatch();
sw.Start();
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.InPutStationMesUrl, jo.ToString());
sw.Stop();
outTime = sw.ElapsedMilliseconds;
if (outTime > 200)
{
strTimeOut = $"卷芯进站PC<=>MES上传耗时:{outTime}ms,RFID:{listRFID[0]}";
}
josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品进站信息(组装)接口:{CommonMethods.mesConfig.InPutStationMesUrl},请求数据为:{jo.ToString()},\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\产品进站信息(组装)\{nowTime.ToString("HH")}.txt", josnTxtMsg);
}
catch (Exception ex)
{
LogHelper.Instance.WriteEX("调用产品进站信息(组装)接口", ex);
}
return resJson;
}
#endregion
#region 5.1 产品进站信息多个上传
/// <summary>
/// 产品进站信息多个上传
/// </summary>
/// <param name="listBar"></param>
/// <param name="MesMessage"></param>
/// <param name="mesResType"></param>
/// <returns></returns>
public static bool Inboundinformations(string CellCode, ref string MesMessage, ref MesResType mesResType)
{
DateTime nowTime = DateTime.Now;
MesMessage = "调用进站接口返回失败!";
mesResType = MesResType.B;
string resJson = "";
bool res = false;
try
{
var model = new ManyCellInStation
{
siteCode = CommonMethods.mesConfig.siteCode,
lineCode = CommonMethods.mesConfig.lineCode,
equipNum = CommonMethods.mesConfig.equipNum,
materialCode = CommonMethods.mesConfig.MaterialCode,
userName = CommonMethods.mesConfig.mesUserName,
identification = CellCode,
productType = "OK"
};
var nowDate = DateTime.Now;
var postcontent = JsonConvert.SerializeObject(model);
var sw = new Stopwatch();
sw.Start();
string result = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.InPutStationMesUrl, postcontent);
sw.Stop();
long outTime = sw.ElapsedMilliseconds;
if (outTime > 1000)
{
LogHelper.Instance.WriteLog($"电池进站PC<=>MES上传耗时:{outTime}ms,条码:{CellCode}", "MESTime");
}
if (string.IsNullOrEmpty(result))
{
string resData = result == "" ? "" : result;
resJson = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品进站信息(组装)接口:{CommonMethods.mesConfig.InPutStationMesUrl},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resData}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowDate.ToString("yyyyMMdd")}\产品进站信息(组装)\{nowDate.ToString("HH")}.txt", resJson);
return res;
}
var res1 = ReturnMesInMsg(result);
if (res1.success)
{
res = true;
GetInMesResType(res1, CellCode, ref MesMessage, ref mesResType);
resJson = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品进站信息(组装)接口:{CommonMethods.mesConfig.InPutStationMesUrl},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{result}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowDate.ToString("yyyyMMdd")}\产品进站信息(组装)\{nowDate.ToString("HH")}.txt", resJson);
}
else
{
var resData = res1 == null ? "" : result;
resJson = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品进站信息(组装)接口:{CommonMethods.mesConfig.InPutStationMesUrl},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resData}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowDate.ToString("yyyyMMdd")}\产品进站信息(组装)\{nowDate.ToString("HH")}.txt", resJson);
}
}
catch (Exception ex)
{
resJson = $"产品进站信息(组装)接口发生异常:{ex.Message}";
LogHelper.Instance.WriteEX("产品进站信息(组装)接口", ex);
}
return res;
}
/// <summary>
/// 进站结果分类
/// </summary>
/// <param name="res1"></param>
/// <param name="listBar"></param>
/// <param name="MesMessage"></param>
/// <param name="mesResType"></param>
private static void GetInMesResType(MesResponseIn res1, string listBar, ref string MesMessage, ref MesResType mesResType)
{
if (res1 != null)
{
if (res1.success)
{
mesResType = MesResType.D;
MesMessage = " MES进站成功!";
}
else
{
if (res1.category == null)
{
mesResType = MesResType.B;
MesMessage = res1.message;
}
else
{
switch (res1.category)
{
case "A":
mesResType = MesResType.A;
MesMessage = res1.message;
break;
case "B":
mesResType = MesResType.B;
MesMessage = res1.message;
break;
case "C":
mesResType = MesResType.C;
MesMessage = res1.message;
break;
default:
mesResType = MesResType.UnKnow;
MesMessage = " MES进站失败!";
break;
}
}
}
}
}
private static MesResponseIn ReturnMesInMsg(string ret)
{
MesResponseIn obj = new MesResponseIn();
try
{
obj = JsonConvert.DeserializeObject<MesResponseIn>(ret);
return obj;
}
catch (System.Exception ex)
{
return obj;
}
}
#endregion
#region 6、设备过程加工参数
/// <summary>
/// 设备过程加工参数
/// </summary>
/// <returns></returns>
#endregion
#region 7、产品结果加工参数
/// <summary>
/// 产品结果加工参数
/// </summary>
/// <param name="m"></param>
/// <returns></returns>
public static string ProductResultParameters(BGearEntity m, MesUploadType unloadType)
{
DateTime nowTime = DateTime.Now;
string resJson = string.Empty;
string josnTxtMsg = string.Empty;
bool res = false;
try
{
var nowDate = DateTime.Now;
string sNowDate = nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff");
var model = new ProductResultParameters
{
equipNum = CommonMethods.mesConfig.equipNum,
type = unloadType.ToString(),
};
// 查询进站时间
var BGearList = CommonMethods.db.QuerySqlList<AGearEntity>(CommonMethods.dBSQL.GetInStationTop1Sql(m.BarCode));
switch (unloadType)
{
case MesUploadType.DD:
var payload1 = new Payload1
{
siteCode = CommonMethods.mesConfig.siteCode,
lineCode = CommonMethods.mesConfig.lineCode,
userName = CommonMethods.mesConfig.mesUserName,
materialCode = CommonMethods.mesConfig.MaterialCode,
carCode = "",
collection = "JS",
recordDate = sNowDate,
qty = 1,
containerCode = "",
};
//参数列
var tagDataVOList = new List<TagDataVOList>();
tagDataVOList.Add(new TagDataVOList
{
tagCode = "CODE_BM",
tagValue = m.BarCode.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯条码"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "SCANNING_TIME_BM",
tagValue = m.BarCode.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯扫码时间"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "SURFACE_DETECTION_RESULT",
tagValue = m.AreaCheckResult.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯大面检测结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "PET_TENSION_SETTING_BM",
tagValue = m.PETtensionSet.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "PET膜张力设定值(N)"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "PET_TENSION_BM",
tagValue = m.PETtensionReal.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "PET膜张力实际值(N)"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "BASE_PLATE_DETECTION_RESULT",
tagValue = m.bassPosNegCheckResult.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "底托片正反检测结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "SURFACE_TO_TOP_COVER_DISTANCE1",
tagValue = m.BigFaceBassDistance1.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯大面上边缘与顶盖底面距离(mm)1"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "SURFACE_TO_TOP_COVER_DISTANCE2",
tagValue = m.BigFaceBassDistance2.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯大面上边缘与顶盖底面距离(mm)2"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "SIDE_TO_TOP_COVER_DISTANCE1",
tagValue = m.SideFaceBassDistance1.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯侧面上边缘与顶盖底面距离(mm)1"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "SIDE_TO_TOP_COVER_DISTANCE2",
tagValue = m.SideFaceBassDistance2.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯侧面上边缘与顶盖底面距离(mm)2"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "SURFACE_APPEARANCE_DETECTION",
tagValue = m.BigFaceCheckResult.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯大面外观检测结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "LONG_EDGE_MAX_SETTING",
tagValue = m.LengthSetMax.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯包膜后尺寸(mm)长边设定值最大值"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "LONG_EDGE_MIN_SETTING",
tagValue = m.LengthSetMin.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯包膜后尺寸(mm)长边设定值最小值"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "SHORT_EDGE_MAX_SETTING",
tagValue = m.ShortSetMax.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯包膜后尺寸(mm)短边设定值最大值"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "SHORT_EDGE_MIN_SETTING",
tagValue = m.ShortSetMin.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯包膜后尺寸(mm)短边设定值最小值"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "LONG_EDGE_VALUE",
tagValue = m.LengthReal.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯包膜后尺寸(mm)长边实际值"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "SHORT_EDGE_VALUE",
tagValue = m.ShortReal.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯包膜后尺寸(mm)短边实际值"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "SIZE_DETECTION_JUDGE_RESULT",
tagValue = m.SideCheckResult.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯包膜后尺寸检测判定结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "BASE_PLATE_POSITION_DETECTION_RESULT",
tagValue = m.PositionCherkResult.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "电芯底托片位置检测结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "PROCESS_NAME_BM",
tagValue = m.ProcessName.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "工序名"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "FRONTLINE_SCAN_1_RESULTS_BM",
tagValue = m.FrontlineSweep1Result.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜前线扫1结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "FRONTLINE_SCAN_2_RESULTS_BM",
tagValue = m.FrontlineSweep2Result.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜前线扫2结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "FRONTLINE_SCAN_3_RESULTS_BM",
tagValue = m.FrontlineSweep3Result.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜前线扫3结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "BOTTOM_CCD_RESULTS_(AREA_ARRAY)_BM",
tagValue = m.ButtonCCDResult.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "底托CCD结果(面阵)"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "SCAN_1_RESULT_OF_THE_REAR_SURFACE_LINE_BM",
tagValue = m.bigArealineSweepResult.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜后大面线扫1结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "REAR_SIDE_LINE_SCAN_1_RESULT_BM",
tagValue = m.SideLineSweep1Result.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜后侧面线扫1结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "REAR_SIDE_LINE_SCAN_2_RESULTS_BM",
tagValue = m.SideLineSweep2Result.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜后侧面线扫2结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "2D_CAMERA_1_RESULTS_FOR_REAR_LARGE_AREA_INSPECTION_BM",
tagValue = m.BigAreaCheck12DResult.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜后大面检测2D相机1结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "2D_CAMERA_2_RESULTS_FOR_REAR_LARGE_AREA_INSPECTION_BM",
tagValue = m.BigAreaCheck22DResult.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜后大面检测2D相机2结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "BOTTOM_SUPPORT_NEGATIVE_PRESSURE_BM",
tagValue = m.ProcessName.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "底托负压"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "1_UPPER_CUTTER_BM",
tagValue = m.CutterLife1.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜1上切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "1_CUTTING_BLADE_BM",
tagValue = m.CutterLife2.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜1下切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "1_BACKUP_ROLL_1_UPPER_CUTTER_BM",
tagValue = m.CutterLife3.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜1备卷1上切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "1_BACKUP_ROLL_1_LOWER_CUTTING_KNIFE_BM",
tagValue = m.CutterLife4.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜1备卷1下切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "1_BACKUP_ROLL_2_CUTTING_KNIFE_ON_TOP_BM",
tagValue = m.CutterLife5.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜1备卷2上切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "1_BACKUP_ROLL_2_LOWER_CUTTING_KNIFE_BM",
tagValue = m.CutterLife6.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜1备卷2下切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "2_UPPER_KNIVES_BM",
tagValue = m.CutterLife7.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜2上切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "2_CUTTING_KNIVES_BM",
tagValue = m.CutterLife8.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜2下切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "2_BACKUP_ROLLS_AND_1_UPPER_CUTTER_BM",
tagValue = m.CutterLife9.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜2备卷1上切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "2_BACKUP_ROLLS_AND_1_LOWER_CUTTING_KNIFE_BM",
tagValue = m.CutterLife10.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜2备卷1下切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "2_BACKUP_ROLLS_2_UPPER_CUTTERS_BM",
tagValue = m.CutterLife11.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜2备卷2上切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "2_BACKUP_ROLLS_2_LOWER_CUTTERS_BM",
tagValue = m.CutterLife12.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "包膜2备卷2下切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "CORNER_CUTTING_1_LEFT_CUTTING_KNIFE_BM",
tagValue = m.CutterLife13.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "切角1左切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "CORNER_CUTTING_1_RIGHT_CUTTING_KNIFE_BM",
tagValue = m.CutterLife14.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "切角1右切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "CORNER_2_LEFT_CUTTER_BM",
tagValue = m.CutterLife15.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "切角2左切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "CORNER_2_RIGHT_CUTTING_KNIFE_BM",
tagValue = m.CutterLife16.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "切角2右切刀"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "STATION_ENTRY_TIME_BM",
tagValue = BGearList[0].InStationTime.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "进站时间"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "EXIT_TIME_BM",
tagValue = m.OutStationTime.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "出站时间"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "OUTBOUND_JUDGMENT_RESULT_BM",
tagValue = m.CellResult.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "出站判定结果"
});
tagDataVOList.Add(new TagDataVOList
{
tagCode = "ABNORMAL_FEEDBACK_INFORMATION_BM",
tagValue = m.Remark.ToString(),
tagTime = m.OutStationTime,
tagCalculateResult = "Y",
tagRemark = "异常反馈信息"
});
//payload1.identification = new List<Identification>();
Identification identification = new Identification()
{
identification = m.BarCode,
qualityStatus = m.CellResult,
};
payload1.identification = identification;
payload1.tagDataVOList = tagDataVOList;
model.payload = JsonConvert.SerializeObject(payload1);
break;
}
var postcontent = JsonConvert.SerializeObject(model);
var sw = new Stopwatch();
sw.Start();
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.ResultProcessParamMesUrl, postcontent);
sw.Stop();
josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品结果加工参数接口:{CommonMethods.mesConfig.ResultProcessParamMesUrl},请求数据为:{postcontent},\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\调用产品结果加工参数\{nowTime.ToString("HH")}.txt", josnTxtMsg);
}
catch (Exception ex)
{
LogHelper.Instance.WriteEX("调用产品结果加工参数接口", ex);
}
return resJson;
}
#endregion
#region 8、产品出站信息(组装)
/// <summary>
/// 产品出站信息(组装)
/// </summary>
/// <param name="m"></param>
/// <returns></returns>
public string OutboundInformation(BGearEntity m, ref string strTimeOut)
{
DateTime nowTime = DateTime.Now;
string resJson = "";
string josnTxtMsg = string.Empty;
#region 多电芯上传屏蔽
//JArray jaContainerCode = new JArray(); //containerCodeAndIdentificationList
//foreach (BGearEntity m in list)
//{
// JArray jaMaterialLotCodeList = new JArray(); //materialLotCodeList
// JObject jo4 = new JObject();
// jo4.Add("materialLotCode", "");
// jo4.Add("materialLotCodeLocator", CommonMethods.mesConfig.materialLotCodeLocator);
// jaMaterialLotCodeList.Add(jo4);
// JArray jaIdentiftyList = new JArray();//identiftyList
// JObject jo3 = new JObject();
// jo3.Add("identification", m.BarCode); //卷心码
// jo3.Add("qualityStatus", m.Result);
// jo3.Add("qrCode", ""); //
// jo3.Add("ngMessage", m.Remark);
// jo3.Add("materialLotList", jaMaterialLotCodeList);
// jaIdentiftyList.Add(jo3);
// JObject jo2 = new JObject();
// jo2.Add("containerCode","");//托杯码
// jo2.Add("identiftyList", jaIdentiftyList);
// jaContainerCode.Add(jo2);
//}
//JObject jo1 = new JObject();
//jo1.Add("siteCode", CommonMethods.mesConfig.siteCode);
//jo1.Add("lineCode", CommonMethods.mesConfig.lineCode);
//jo1.Add("equipNum", CommonMethods.mesConfig.equipNum);
//jo1.Add("userName", CommonMethods.mesConfig.mesUserName);
//jo1.Add("productType", "");
//jo1.Add("completeQty", "");
//jo1.Add("type", 1); //追溯标识替换
//jo1.Add("materialCode", CommonMethods.mesConfig.MaterialCode);
//jo1.Add("containerCodeAndIdentificationList", jaContainerCode);
#endregion
//strTimeOut = string.Empty;
//try
//{
// JArray jaMaterialLotCodeList = new JArray(); //materialLotCodeList
// JObject jo4 = new JObject();
// jo4.Add("materialLotCode", "");
// jo4.Add("materialLotCodeLocator", "");
// jaMaterialLotCodeList.Add(jo4);
// JArray jaIdentiftyList = new JArray();//identiftyList
// JObject jo3 = new JObject();
// jo3.Add("identification", m.BarCode); //卷心码
// jo3.Add("qualityStatus", m.Result);
// jo3.Add("qrCode", ""); //
// jo3.Add("ngMessage", m.Remark);
// jo3.Add("materialLotList", jaMaterialLotCodeList);
// jaIdentiftyList.Add(jo3);
// JArray jaContainerCode = new JArray(); //containerCodeAndIdentificationList
// JObject jo2 = new JObject();
// jo2.Add("containerCode", m.RFID);//托杯码
// jo2.Add("identiftyList", jaIdentiftyList);
// jaContainerCode.Add(jo2);
// JObject jo1 = new JObject();
// jo1.Add("siteCode", CommonMethods.mesConfig.siteCode);
// jo1.Add("lineCode", CommonMethods.mesConfig.lineCode);
// jo1.Add("equipNum", CommonMethods.mesConfig.equipNum);
// jo1.Add("materialCode", CommonMethods.mesConfig.MaterialCode);
// jo1.Add("userName", CommonMethods.mesConfig.mesUserName);
// jo1.Add("productType", "");
// jo1.Add("completeQty", "");
// jo1.Add("type", 1); //追溯标识替换
// jo1.Add("containerCodeAndIdentificationList", jaContainerCode);
// sw.Restart();
// resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.OutStationMesUrl, jo1.ToString());
// sw.Stop();
// long outTime = sw.ElapsedMilliseconds;
// if (outTime > 150)
// {
// strTimeOut = $"卷芯进站PC<=>MES上传耗时{outTime}ms,{m.RFID},{m.BarCode},{m.SteelShellCode}";
// }
// josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用出站信息(组装)接口:{CommonMethods.mesConfig.OutStationMesUrl},请求数据为:{jo1.ToString()},\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{outTime}ms,返回结果:{resJson}";
// TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\产品出站信息(组装)\{nowTime.ToString("HH")}.txt", josnTxtMsg);
//}
//catch (Exception ex)
//{
// LogHelper.Instance.WriteEx("调用出站信息(组装)接口", ex);
//}
return resJson;
}
/// <summary>
/// 单个电芯上传
/// </summary>
/// <param name="m"></param>
/// <returns></returns>
public static bool OutboundInformations(BGearEntity m, ref string MesMessage, ref MesResType mesResType)
{
DateTime nowDate = DateTime.Now;
string resJson = "";
bool res = false;
MesMessage = "MES出站失败";
mesResType = MesResType.B;
try
{
JArray jaNGCode = new JArray(); //materialLotCodeList
JObject jo4 = new JObject();
jaNGCode.Add(jo4);
JArray jaMaterialLotList = new JArray(); //materialLotCodeList
JObject jo3 = new JObject();
jo3.Add("materialLotCode", "");
jo3.Add("materialLotCodeLocator", CommonMethods.mesConfig.materialLotCodeLocator);
jaMaterialLotList.Add(jo3);
JArray jaIdentiftyList = new JArray();//identiftyList
JObject jo2 = new JObject();
jo2.Add("identification", m.BarCode); //产品条码
jo2.Add("qualityStatus", m.CellResult); //状态
//jo2.Add("qualityStatus", "OK"); //状态
jo2.Add("qrCode", "");
jo2.Add("ngMessage", m.NGMessage);
jo2.Add("ngCode", jaNGCode);
jo2.Add("materialLotList", jaMaterialLotList);
jaIdentiftyList.Add(jo2);
JObject jo1 = new JObject();
jo1.Add("siteCode", CommonMethods.mesConfig.siteCode);
jo1.Add("lineCode", CommonMethods.mesConfig.lineCode);
jo1.Add("equipNum", CommonMethods.mesConfig.equipNum);
jo1.Add("userName", CommonMethods.mesConfig.mesUserName);
jo1.Add("productType", CommonMethods.mesConfig.ModelName);
jo1.Add("completeQty", "");
jo1.Add("containerCode", "");
jo1.Add("type", 1); //追溯标识替换
jo1.Add("materialCode", CommonMethods.mesConfig.MaterialCode);
jo1.Add("identiftyList", jaIdentiftyList);
var postcontent = JsonConvert.SerializeObject(jo1);
var sw = new Stopwatch();
sw.Start();
string result = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.OutStationMesUrl, postcontent);
sw.Stop();
long outTime = sw.ElapsedMilliseconds;
if (outTime > 1000)
{
LogHelper.Instance.WriteLog($"电芯出站PC<=>MES上传耗时:{outTime}ms,电芯码:{m.BarCode}", "MESTime");
}
if (string.IsNullOrEmpty(result))
{
string resData = result == "" ? "" : result;
resJson = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品出站信息(组装)接口:{CommonMethods.mesConfig.InPutStationMesUrl},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resData}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowDate.ToString("yyyyMMdd")}\产品出站信息(组装)\{nowDate.ToString("HH")}.txt", resJson);
return res;
}
var res1 = ReturnMesOutMsg(result);
if (res1.success)
{
res = true;
GetOutMesResType(res1, m.BarCode, ref MesMessage, ref mesResType);
resJson = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品出站信息(组装)接口:{CommonMethods.mesConfig.InPutStationMesUrl},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{result}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowDate.ToString("yyyyMMdd")}\产品出站信息(组装)\{nowDate.ToString("HH")}.txt", resJson);
}
else
{
var resData = res1 == null ? "" : result;
resJson = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用产品出站信息(组装)接口:{CommonMethods.mesConfig.InPutStationMesUrl},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resData}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowDate.ToString("yyyyMMdd")}\产品出站信息(组装)\{nowDate.ToString("HH")}.txt", resJson);
}
}
catch (Exception ex)
{
LogHelper.Instance.WriteEX("调用出站信息(组装)接口", ex);
}
return res;
}
/// <summary>
/// 进站结果分类
/// </summary>
/// <param name="res1">MES返回信息</param>
/// <param name="cell">电池数据</param>
/// <param name="index">电池编号</param>
/// <param name="MesMessage"></param>
/// <param name="mesResType"></param>
private static void GetOutMesResType(MesResponseOut res1, string cell, ref string MesMessage, ref MesResType mesResType)
{
if (res1 != null)
{
if (res1.success)
{
mesResType = MesResType.D;
MesMessage = "MES出站成功!";
}
else
{
if (res1.category == null)
{
mesResType = MesResType.B;
MesMessage = res1.message;
}
else
{
switch (res1.category)
{
case "A":
mesResType = MesResType.A;
MesMessage = res1.message;
break;
case "B":
mesResType = MesResType.B;
MesMessage = res1.message;
break;
case "C":
mesResType = MesResType.C;
MesMessage = res1.message;
break;
default:
mesResType = MesResType.UnKnow;
MesMessage = "MES出站失败!";
break;
}
}
}
}
}
private static MesResponseOut ReturnMesOutMsg(string ret)
{
MesResponseOut obj = new MesResponseOut();
try
{
obj = JsonConvert.DeserializeObject<MesResponseOut>(ret);
return obj;
}
catch (System.Exception ex)
{
return obj;
}
}
#endregion
#region 9、报警信息
/// <summary>
/// 报警信息
/// </summary>
/// <param name="alarmObj"></param>
/// <returns></returns>
public static string EquAlarm(string strGuid, List<AlarmData> alarmObj)
{
DateTime nowTime = DateTime.Now;
string resJson = "";
string josnTxtMsg = string.Empty;
try
{
if (alarmObj.Count > 0)
{
UploadAlarmParam alarmParam = new UploadAlarmParam();
alarmParam.siteCode = CommonMethods.mesConfig.siteCode;
alarmParam.lineCode = CommonMethods.mesConfig.lineCode;
alarmParam.equipNum = CommonMethods.mesConfig.equipNum;
alarmParam.materialCode = CommonMethods.mesConfig.MaterialCode;
alarmParam.userName = CommonMethods.mesConfig.mesUserName;
alarmParam.recordDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
alarmParam.guid = strGuid;
alarmParam.seatId = "";
List<AlarmLineListItem> alarmLineList = new List<AlarmLineListItem>();
for (int j = 0; j < alarmObj.Count; j++)
{
AlarmLineListItem alarmList = new AlarmLineListItem();
alarmList.alarmEndTime = alarmObj[j].EndTime.ToString();
alarmList.alarmType = alarmObj[j].AlarmType;
alarmList.alarmName = alarmObj[j].AlarmContent;
alarmList.alarmStartTime = alarmObj[j].StartTime.ToString();
alarmList.faultCode = alarmObj[j].AlarmCode;
alarmLineList.Add(alarmList);
}
alarmParam.alarmLineList = alarmLineList;
string SendJosn = JsonConvert.SerializeObject(alarmParam);
var sw = new Stopwatch();
sw.Start();
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.AlarmCurrencyMesUrl, SendJosn);
sw.Stop();
josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用MES设备报警接口:{CommonMethods.mesConfig.AlarmCurrencyMesUrl},请求数据为:{SendJosn},\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\设备报警\{nowTime.ToString("HH")}.txt", josnTxtMsg);
}
}
catch (Exception ex)
{
LogHelper.Instance.WriteEX("调用MES设备报警接口", ex);
}
return resJson;
}
#endregion
#region 10、设备状态
/// <summary>
/// 设备状态
/// </summary>
/// <param name="strStatus"></param>
/// <returns></returns>
public static string EqpStatusParam(string strStatus, string StartDate, string strGuid, List<FaultCodeList> FaultCodeLists = null)
{
var nowTime = DateTime.Now;
string resJson = "";
string josnTxtMsg = string.Empty;
string Date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
try
{
EqpStatusParam statusParam = new EqpStatusParam();
statusParam.siteCode = CommonMethods.mesConfig.siteCode;
statusParam.lineCode = CommonMethods.mesConfig.lineCode;
statusParam.equipNum = CommonMethods.mesConfig.equipNum;
statusParam.userName = CommonMethods.mesConfig.mesUserName;
statusParam.seatId = "";
statusParam.recordDate = StartDate;
statusParam.statusCode = strStatus;
statusParam.uploadTime = Date;
statusParam.guid = strGuid;
statusParam.faultCodeList = FaultCodeLists;
string SendJosn = JsonConvert.SerializeObject(statusParam);
var sw = new Stopwatch();
sw.Start();
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.StatusMesUrl, SendJosn);
sw.Stop();
josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用MES设备运行状态接口:{CommonMethods.mesConfig.StatusMesUrl},请求数据为:{SendJosn},\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\设备运行状态\{nowTime.ToString("HH")}.txt", josnTxtMsg);
}
catch (Exception ex)
{
LogHelper.Instance.WriteEX("调用MES设备运行状态接口", ex);
}
return resJson;
}
#endregion
#region 11、能耗上传
/// <summary>
/// 能耗数据
/// </summary>
/// <param name="strStatus"></param>
/// <returns></returns>
public static string WattHourMeterParam(List<WattrMeter> meterParams)
{
DateTime nowTime = DateTime.Now;
string resJson = "";
string josnTxtMsg = string.Empty;
try
{
string SendJosn = JsonConvert.SerializeObject(meterParams);
var sw = new Stopwatch();
sw.Start();
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.WattrMeterUrl, SendJosn);
sw.Stop();
josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用设备能耗信息接口:{CommonMethods.mesConfig.WattrMeterUrl},请求数据为:{SendJosn},\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\能耗信息\{nowTime.ToString("HH")}.txt", josnTxtMsg);
}
catch (Exception ex)
{
LogHelper.Instance.WriteEX("调用设备能耗信息接口", ex);
}
return resJson;
}
#endregion
#region 12、风速值上传
/// <summary>
/// 设备风速接口
/// </summary>
/// <param name="collectData"></param>
/// <returns></returns>
public static string UploadDeviceCollectData()
{
var nowTime = DateTime.Now;
string resJson = "";
string josnTxtMsg = string.Empty;
try
{
if (CommonMethods.AntiDustAirSpeed == null) { return ""; }
UploadDeviceCollectData uploadDevice = new UploadDeviceCollectData();
uploadDevice.appid = "e1012966a936170c6fcab98e24042d10";
List<Collect_code_value_list> list = new List<Collect_code_value_list>();
for (int i = 0; i < CommonMethods.AntiDustAirSpeed.Count; i++)
{
Collect_code_value_list _Value_List = new Collect_code_value_list();
_Value_List.target_code = 5;
_Value_List.target_value = CommonMethods.AntiDustAirSpeed[i].ToString();
_Value_List.target_value_tag = CommonMethods.mesConfig.listAntiDustAirSpeedNum[i];
list.Add(_Value_List);
}
uploadDevice.collect_code_value_list = list;
uploadDevice.collect_time = GetUnixTimestamp();
uploadDevice.device_code = CommonMethods.mesConfig.equipNum;
string SendJosn = JsonConvert.SerializeObject(uploadDevice);
var sw = new Stopwatch();
sw.Start();
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.CollectData, SendJosn);
sw.Stop();
josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用风速接口:{CommonMethods.mesConfig.CollectData},请求数据为:{SendJosn},\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\风速信息\{nowTime.ToString("HH")}.txt", josnTxtMsg);
}
catch (Exception ex)
{
LogHelper.Instance.WriteEX("调用设备能耗信息接口", ex);
}
return resJson;
}
/// <summary>
/// Tag标签
/// </summary>
/// <param name="Num"></param>
/// <returns></returns>
public static string GetTag(int Num)
{
if (Num == 0)
Num = 1;
switch (Num.ToString().Length)
{
case 1:
return $"FSY-4A-{Num}";
case 2:
return $"00{Num}";
case 3:
return $"0{Num}";
default:
return $"{Num}";
}
}
/// <summary>
///本地时间为Unix时间戳
/// </summary>
/// <returns></returns>
public static long GetUnixTimestamp()
{
return (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
}
#endregion
public static List<MesResType> GetMesType(int Num)
{
List<MesResType> mesResTypes = new List<MesResType>();
for (int i = 0; i < Num; i++)
{
mesResTypes.Add(MesResType.B);
}
return mesResTypes;
}
public static List<string> GetListString(int Num, string str)
{
List<string> mesResTypes = new List<string>();
for (int i = 0; i < Num; i++)
{
mesResTypes.Add(str);
}
return mesResTypes;
}
}
}