|
@@ -1166,41 +1166,55 @@ namespace MainForm
|
|
|
}
|
|
|
|
|
|
|
|
|
- public Dictionary<string, string> GetLastLineCompensation()
|
|
|
+ public Dictionary<string, string> GetLastLineCompensation(string path,string direction,string sn)
|
|
|
{
|
|
|
// 创建字典存储补偿点及其对应的值
|
|
|
Dictionary<string, string> compensationDict = new Dictionary<string, string>();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- string path = "D:\\TempNew";
|
|
|
+ //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 = lines[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(',');
|
|
|
-
|
|
|
- // 提取“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;
|
|
|
- }
|
|
|
+ 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
|
|
@@ -1323,10 +1337,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>
|
|
@@ -1344,7 +1358,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;
|
|
@@ -1397,8 +1411,13 @@ 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();
|
|
|
+ Dictionary<string, string> compensationDict = GetLastLineCompensation(path, direction,sn);
|
|
|
foreach (var kvp in compensationDict)
|
|
|
{
|
|
|
outRequest_Body.unitData.processData.Add(
|
|
@@ -1421,7 +1440,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++;
|
|
|
|
|
@@ -2731,6 +2753,7 @@ namespace MainForm
|
|
|
AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
|
|
|
}
|
|
|
sn = strProductBarcode;
|
|
|
+ sn = "AB123456789";
|
|
|
AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn}");
|
|
|
|
|
|
List<TestItem> items = new List<TestItem>();
|
|
@@ -2748,11 +2771,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);
|
|
|
|