添加接口null值检查

打开螺丝引导页面逻辑修改
程序重复打开命名修改
添加心跳线程
This commit is contained in:
gf zhou committed 2025-04-16 11:31:16 +08:00
1 parent 1a9f2a5bca
commit 233737bc31
4 files changed
+186 -56

No files matched your search

+100 -14
View File
@@ -225,6 +225,8 @@ namespace WindowsFormsApp1.server
}
else
{
string errorContent = response.Content.ReadAsStringAsync().Result;
LogExecute.logNet.WriteError($"请求失败,请求内容:{jsonPayload},状态码:{response.StatusCode},错误内容:{errorContent}");
throw new Exception($"请求失败,状态码:{response.StatusCode}");
}
@@ -249,9 +251,14 @@ namespace WindowsFormsApp1.server
// 换盘 老化上线 SN需要调用扫码的值 Init.Sn
var sn = "";
var stationid = Init.t_Line.lineremark2.ToLower();
if ("loadaging,exchange2,exchange1".Contains(stationid))
if ("loadaging".Contains(stationid))
{
sn = PlcData.Read_MaterialCode0 ?? OtherData.JS_SN;
sn = OtherData.JS_SN;
}
else if ("exchange2,exchange1".Contains(stationid))
{
sn = PlcData.Read_MaterialCode0;
}
else
{
@@ -267,7 +274,7 @@ namespace WindowsFormsApp1.server
OPID = _opID,
Token = _token,
FixSN = _fixsn,
SN = sn,
SN = sn ?? "",
CarrierID = "",
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
};
@@ -293,7 +300,7 @@ namespace WindowsFormsApp1.server
OPID = _opID,
Token = _token,
FixSN = _fixsn,
CarrierID = PlcData.Read_MaterialCode1,
CarrierID = PlcData.Read_MaterialCode1 ?? "",
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
};
@@ -337,7 +344,7 @@ namespace WindowsFormsApp1.server
OPID = _opID,
Token = _token,
FixSN = _fixsn,
SN = OtherData.JS_SN ?? PlcData.Read_MaterialCode2 ?? Init.DZString,//扫码
SN = OtherData.JS_SN ?? PlcData.Read_MaterialCode2 ?? Init.DZString ?? "",//扫码
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
};
@@ -389,11 +396,11 @@ namespace WindowsFormsApp1.server
new CompListItem()
{
// 安装主板 端子
CompID = OtherData.JS_SN ?? Init.DZString,
CompID = OtherData.JS_SN ?? Init.DZString ?? "",
Qty = "1"
}
},
SN = PlcData.Write_stSN,
SN = PlcData.Write_stSN ?? "",
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
};
@@ -419,7 +426,7 @@ namespace WindowsFormsApp1.server
OPID = _opID,
Token = _token,
FixSN = _fixsn,
SN = PlcData.Write_stSN,
SN = PlcData.Write_stSN ?? "",
//CarrierID = PlcData.Read_MaterialCode1,
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
};
@@ -461,9 +468,9 @@ namespace WindowsFormsApp1.server
StationID = _stationID,
MachineID = _machineID,
OPID = OtherData.opindex,
Token = locationindex.ToString(),//判断站,胶水不用传
Token = locationindex.ToString() ?? "",//判断站,胶水不用传
FixSN = fixsn_1,//判断站,胶水不用传
SN = OtherData.JS_SN,
SN = OtherData.JS_SN ?? "",
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
};
@@ -777,6 +784,7 @@ namespace WindowsFormsApp1.server
var result = PlcData.Read_Result == 1 ? "PASS" : "FAIL";
var logresult = PlcData.Read_Result == 1 ? "OK" : "NG";
// 基础请求对象
var request = new CheckOutObject()
{
@@ -789,14 +797,14 @@ namespace WindowsFormsApp1.server
{
new SNInfoItem()
{
SN = PlcData.Write_stSN,
SN = PlcData.Write_stSN ?? "",
Result = result,
DC_INFO = new List<DCInfoItem>(),
CompList = new List<CompListItem>()
}
},
Qty = "",
CarrierID = PlcData.Read_MaterialCode1,
CarrierID = PlcData.Read_MaterialCode1 ?? "",
Mold = _mold,
Token = _token,
FixSN = _fixsn,
@@ -1092,6 +1100,14 @@ namespace WindowsFormsApp1.server
public ApiFormResult OEEDataCollection(string url, plcdata PlcData, otherdata OtherData)
{
//模穴 真空站两个穴位
var model = 1;
if (_stationID.ToLower() == "vacuum")
{
model = OtherData.plcid;
}
var request = new
{
EventID = "OEEDataCollection",
@@ -1099,8 +1115,47 @@ namespace WindowsFormsApp1.server
StationID = _stationID,
MachineID = _machineID,
OPID = _opID,
SN = PlcData.Write_stSN,
CarrierID = PlcData.Read_MaterialCode1,
DC_INFO = new List<DataDCInfoItem>(),
CompList = new List<CompListItem>(),
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
};
request.DC_INFO.Add(new DataDCInfoItem()
{
Item = "Eq_Active_Rate",
Value = "0"
});
// 工位最长ct
request.DC_INFO.Add(new DataDCInfoItem()
{
Item = "Cycle_Time",
Value = "0" //跟PLC定义好值从哪里获取
});
// 机台ct
request.DC_INFO.Add(new DataDCInfoItem()
{
Item = "Takt_Time",
Value = "0" //跟PLC定义好值从哪里获取
});
var tossing = DataListManager.DataList.Any(x => x.Name == _stationID);
if (tossing)
{
var materialList = DataListManager.DataList.First(x => x.Name == _stationID).Components;
foreach(var material in materialList)
{
request.DC_INFO.Add(
new DataDCInfoItem()
{
Item = $"Tossing_{material}",
Value = "1" //跟PLC定义好值从哪里获取
}
);
}
}
return CallApi(url, request, "OEEDataCollection", PlcData, PLC_Status.OEEDataCollection);
}
@@ -1248,9 +1303,40 @@ namespace WindowsFormsApp1.server
public const int Fail = 1001;
}
#region oeedata
public class ComponentItem
{
public string Name { get; set; }
public List<string> Components { get; set; }
public ComponentItem(string name, List<string> components)
{
Name = name;
Components = components;
}
}
public class DataListManager
{
// 直接声明并赋值
public static List<ComponentItem> DataList = new List<ComponentItem>
{
new ComponentItem("Assy1", new List<string> { "EMC_PCBA" }),
new ComponentItem("ScrewE", new List<string> { "M3*10" }),
new ComponentItem("Assy2", new List<string> { "M4*14", "ST_4*12" }),
new ComponentItem("Assy3", new List<string> { "M3*10" }),
new ComponentItem("ScrewS", new List<string> { "M4*12", "M6*10" }),
new ComponentItem("Assy4", new List<string> { "MAIN_PCBA" }),
new ComponentItem("ScrewM", new List<string> { "M4*12" }),
new ComponentItem("Assy6", new List<string> { "Top_Cover" }),
new ComponentItem("ScrewTC", new List<string> { "M4*12" })
};
}
#endregion
#region checkout class
// 根对象类
public class CheckOutObject
// 根对象类
public class CheckOutObject
{
public List<SNInfoItem> SNInfo { get; set; }
public string Qty { get; set; }