|
@@ -1241,6 +1241,73 @@ namespace MainForm
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public Dictionary<string, string> GetLastLineCompensation(string path,string direction,string sn)
|
|
|
+ {
|
|
|
+ // 创建字典存储补偿点及其对应的值
|
|
|
+ Dictionary<string, string> compensationDict = new Dictionary<string, string>();
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //string path = GlobalContext.MESLaserRPath;
|
|
|
+ // 获取当前日期并格式化为 "yyyy-MM-dd" 格式
|
|
|
+ string currentDate = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
+ string filename = $"Laser-{currentDate}-W0.txt";
|
|
|
+ // 拼接完整路径
|
|
|
+ string fullPath = Path.Combine(path, filename);
|
|
|
+ string lastNonEmptyLine = "";
|
|
|
+
|
|
|
+ // 判断文件是否存在
|
|
|
+ if (File.Exists(fullPath))
|
|
|
+ {
|
|
|
+ //读取文件内容
|
|
|
+ string[] lines = File.ReadAllLines(fullPath);
|
|
|
+
|
|
|
+ // 获取最后一行数据(忽略标题行)
|
|
|
+ if (lines.Length > 1)
|
|
|
+ {
|
|
|
+ string lastLine = "";
|
|
|
+ for (int i = lines.Length - 1; i > 0; i--)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(lines[i]))
|
|
|
+ {
|
|
|
+ lastLine = lines[i];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 将最后一行按逗号分隔
|
|
|
+ string[] values = lastLine.Split(',');
|
|
|
+ values[1] = sn;
|
|
|
+
|
|
|
+ string key = "三点激光_"+ direction; // 构造键名
|
|
|
+ string value = string.Join(",", values); // 获取值并去除多余空格
|
|
|
+ compensationDict[key] = value;
|
|
|
+
|
|
|
+ //// 提取“1点补偿”到“6点补偿”的值
|
|
|
+ //for (int i = 2; i <= 7 && i < values.Length; i++) // 从索引2开始,最多提取6个值
|
|
|
+ //{
|
|
|
+ // string key = $"{i - 1}点补偿"; // 构造键名
|
|
|
+ // string value = values[i].Trim(); // 获取值并去除多余空格
|
|
|
+ // compensationDict[key] = value;
|
|
|
+ //}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Console.WriteLine($"文件不存在: {fullPath}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ // 捕获异常并输出错误信息
|
|
|
+ Console.WriteLine($"发生错误: {ex.Message}");
|
|
|
+ }
|
|
|
+
|
|
|
+ return compensationDict;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 调用进站接口并保存进站数据
|
|
|
/// </summary>
|
|
@@ -1346,10 +1413,10 @@ namespace MainForm
|
|
|
/// <returns>上传成功时返回1;失败返回0</returns>
|
|
|
private int SwitctProcessData(string stationNameStr, List<TestItem> items, string equipmentCode, string processItem,
|
|
|
string workorder_code, string batch_num, string mtltmrk, string proDate,
|
|
|
- string supplierCode, string sn, bool pass, string vehicleSn, string vehicleSlot, string MachineId, string StationId, string PartBarcode)
|
|
|
+ string supplierCode, string sn, bool pass, string vehicleSn, string vehicleSlot, string MachineId, string StationId, string PartBarcode,string direction="")
|
|
|
{
|
|
|
return SaveProcessDataByDB(stationNameStr, items, equipmentCode, processItem, workorder_code, batch_num, mtltmrk,
|
|
|
- proDate, supplierCode, sn, pass, vehicleSn, vehicleSlot, MachineId, StationId, PartBarcode);
|
|
|
+ proDate, supplierCode, sn, pass, vehicleSn, vehicleSlot, MachineId, StationId, PartBarcode, direction);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -1367,7 +1434,7 @@ namespace MainForm
|
|
|
/// <returns>上传成功时返回1;失败返回0</returns>
|
|
|
public int SaveProcessDataByDB(string stationNameStr, List<TestItem> items, string equipmentCode,
|
|
|
string processItem, string workorder_code, string batch_num, string mtltmrk,
|
|
|
- string proDate, string supplierCode, string sn, bool pass, string vehicleSn, string vehicleSlot, string machineId, string stationId, string partBarcode)
|
|
|
+ string proDate, string supplierCode, string sn, bool pass, string vehicleSn, string vehicleSlot, string machineId, string stationId, string partBarcode,string direction="")
|
|
|
{
|
|
|
int upload = 0;
|
|
|
int result = 0;
|
|
@@ -1417,6 +1484,27 @@ namespace MainForm
|
|
|
}); // 设备数据 - 部件码
|
|
|
}
|
|
|
|
|
|
+ //OP30站读txt数据
|
|
|
+ if (stationNameStr.Contains("OP30"))
|
|
|
+ {
|
|
|
+ string path = "";
|
|
|
+ if (direction == "Left")
|
|
|
+ path = GlobalContext.MESLaserLPath;
|
|
|
+ else
|
|
|
+ path= GlobalContext.MESLaserRPath;
|
|
|
+ //字典存储数据
|
|
|
+ Dictionary<string, string> compensationDict = GetLastLineCompensation(path, direction,sn);
|
|
|
+ foreach (var kvp in compensationDict)
|
|
|
+ {
|
|
|
+ outRequest_Body.unitData.processData.Add(
|
|
|
+ new XmMES_StationOutRequest_Body.XmStationOut_ProcessData()
|
|
|
+ {
|
|
|
+ dataName = kvp.Key.ToString(),
|
|
|
+ dataValue = kvp.Value.ToString()
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
string jsonstr1 = JsonConvert.SerializeObject(outRequest_Body);
|
|
|
|
|
|
if (GlobalContext.IsSendProcessData)
|
|
@@ -1428,7 +1516,10 @@ namespace MainForm
|
|
|
{
|
|
|
response = XiaomiMESHttp_StationOutbound.StationOut(outRequest_Body);
|
|
|
if (response != null && response.header.code == "200")
|
|
|
+ {
|
|
|
+ OnMessage(LogType.Error, "上传出站数据到MES服务器---成功!请求信息:" + jsonstr1 + "返回信息:" + JsonConvert.SerializeObject(response.body));
|
|
|
break;
|
|
|
+ }
|
|
|
else if (!mesRet.Contains("1009")) // 1009是未知错误
|
|
|
i++;
|
|
|
|
|
@@ -2776,6 +2867,7 @@ namespace MainForm
|
|
|
AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
|
|
|
}
|
|
|
sn = strProductBarcode;
|
|
|
+ sn = "AB123456789";
|
|
|
AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn}");
|
|
|
|
|
|
List<TestItem> items = new List<TestItem>();
|
|
@@ -2793,11 +2885,12 @@ namespace MainForm
|
|
|
});
|
|
|
|
|
|
int result1 = 1;
|
|
|
- if (direction == "Right")
|
|
|
- {
|
|
|
+ //if (direction == "Right")
|
|
|
+ //{
|
|
|
result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem
|
|
|
- , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, "");
|
|
|
- }
|
|
|
+ , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, "", direction);
|
|
|
+ //}
|
|
|
+
|
|
|
|
|
|
byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
|
|
|
|