3.25 测试
改端子扫码,产线页面,主页
This commit is contained in:
1 parent
bd70f38e1a
commit
083c4ec3ac
16 files changed
+1016
-877
No files matched your search
@@ -17,6 +17,8 @@ using System.Security.Cryptography;
|
||||
using Newtonsoft.Json;
|
||||
using HslCommunication.BasicFramework;
|
||||
using System.IO;
|
||||
using static WindowsFormsApp1.server.ApiClient;
|
||||
using System.Security.Policy;
|
||||
|
||||
namespace WindowsFormsApp1.server
|
||||
{
|
||||
@@ -28,6 +30,9 @@ namespace WindowsFormsApp1.server
|
||||
private readonly string _stationID;
|
||||
private readonly string _machineID;
|
||||
private readonly string _opID;
|
||||
private readonly string _mold;
|
||||
private readonly string _token;
|
||||
private readonly string _fixsn;
|
||||
|
||||
public ApiClient()
|
||||
{
|
||||
@@ -36,14 +41,24 @@ namespace WindowsFormsApp1.server
|
||||
_httpClient.Timeout = TimeSpan.FromSeconds(10);
|
||||
|
||||
SQLiteHelper<t_interface> helper = new db.SQLiteHelper<t_interface>();
|
||||
var apiList = helper.QueryAll().Data.ToList();
|
||||
var apiList = helper.QueryAll().Data.Select(x => new { x.code, url = x.url + x.code }).ToList();
|
||||
apiUrlDict = apiList.ToDictionary(x => x.code, x => x.url);
|
||||
|
||||
// 从配置中读取通用参数
|
||||
_line = "Testline";
|
||||
_stationID = "TestStation";
|
||||
_machineID = "TestMachine";
|
||||
_opID = "";
|
||||
_line = Init.t_Line.lineremark1;
|
||||
_stationID = Init.t_Line.lineremark2;
|
||||
_machineID = Init.t_Line.lineremark3;
|
||||
_token = Init.t_Line.lineremark4;
|
||||
_fixsn = Init.t_Line.lineremark5;
|
||||
_mold = Init.t_Line.lineremark6;
|
||||
|
||||
_opID = Init.t_User.username;
|
||||
|
||||
|
||||
//线别.Text = "线别:" + Init.t_Line.linename;
|
||||
//段别.Text = "段别:" + Init.t_Line.linemode;
|
||||
//机台编号.Text = "机台编号:" + Init.t_Line.linecode;
|
||||
//操作人员ID.Text = "操作人员ID:" + Init.t_User.username;
|
||||
}
|
||||
|
||||
// 通用API调用方法,减少代码重复
|
||||
@@ -59,14 +74,35 @@ namespace WindowsFormsApp1.server
|
||||
try
|
||||
{
|
||||
// 测试
|
||||
LogExecute.logNet.WriteDebug($"{eventName} 接口请求成功\n请求:{jsonPayload}");
|
||||
LogExecute.logNet.WriteDebug($"{eventName} 接口请求模拟测试成功\n请求:{jsonPayload}");
|
||||
|
||||
// 回写对应PLC
|
||||
if (statusCode > 0)
|
||||
PlcData.Write_Status = (short)statusCode;
|
||||
if (eventName == "SN_Release")
|
||||
PlcData.Write_stSN = "testsn";
|
||||
if(eventName == "Glue_CheckOut")
|
||||
{
|
||||
var station = Init.t_Line.lineremark2.ToLower();
|
||||
switch (station)
|
||||
{
|
||||
case "Potting"://灌胶
|
||||
case "ThermalPaste"://点胶&CCD检测
|
||||
case "UVCoating"://三防漆涂覆
|
||||
case "Sealant"://点密封胶&CCD
|
||||
break;
|
||||
default:
|
||||
var power = Init.t_Keyvalues.First(x => x.key == "Power");
|
||||
power.value = DateTime.Now.Millisecond.ToString();
|
||||
SQLiteHelper<t_keyvalue> kvHelper = new db.SQLiteHelper<t_keyvalue>();
|
||||
kvHelper.Update(power);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ApiFormResult.Sucess(mesresult.PASS, false, "", PlcData, DateTime.Now);
|
||||
|
||||
#region 测试不用
|
||||
/*
|
||||
var response = _httpClient.PostAsync(url, httpContent).Result;
|
||||
// 检查响应状态码
|
||||
@@ -93,12 +129,20 @@ namespace WindowsFormsApp1.server
|
||||
// 回写对应PLC
|
||||
if (statusCode > 0)
|
||||
PlcData.Write_Status = (short)statusCode;
|
||||
if(eventName == "SN_Release")
|
||||
if (eventName == "SN_Release")
|
||||
PlcData.Write_stSN = res.SN.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 判断此站是否有胶水。返回fail,执行胶水下线
|
||||
if (eventName == "SN_FeedingCheck")
|
||||
{
|
||||
//执行胶水下线操作
|
||||
}
|
||||
}
|
||||
return result
|
||||
? ApiFormResult.Sucess(mesresult.PASS, false, res.MSG.Value, PlcData, DateTime.Now)
|
||||
: ApiFormResult.Sucess(mesresult.FAIL, true, res.MSG.Value, PlcData, DateTime.Now);
|
||||
? ApiFormResult.Sucess(mesresult.PASS, false, res.MSG.Value, PlcData, DateTime.Now)
|
||||
: ApiFormResult.Sucess(mesresult.FAIL, true, res.MSG.Value, PlcData, DateTime.Now);
|
||||
}
|
||||
else if (res.IsSuccess != null) // 打印 mes不返回result
|
||||
{
|
||||
@@ -116,13 +160,14 @@ namespace WindowsFormsApp1.server
|
||||
throw new Exception($"请求失败,状态码:{response.StatusCode}");
|
||||
}
|
||||
*/
|
||||
#endregion 测试不用
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogExecute.logNet.WriteError($"{eventName} 接口请求失败: {ex.Message}");
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
//return ApiFormResult.Sucess(mesresult.PASS, false, "", PlcData, DateTime.Now);
|
||||
return ApiFormResult.Sucess(mesresult.PASS, false, "", PlcData, DateTime.Now);
|
||||
}
|
||||
|
||||
public ApiFormResult SN_CheckIN(string url, plcdata PlcData, otherdata OtherData)
|
||||
@@ -135,16 +180,23 @@ namespace WindowsFormsApp1.server
|
||||
StationID = _stationID,
|
||||
MachineID = _machineID,
|
||||
OPID = _opID,
|
||||
Token = "",
|
||||
FixSN = "",
|
||||
Token = _token,
|
||||
FixSN = _fixsn,
|
||||
SN = PlcData.Read_MaterialCode1,
|
||||
CarrierID = "",
|
||||
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
||||
};
|
||||
|
||||
// 1对4 有部分不需要 callapi todo
|
||||
return CallApi(url, request, "SN_CheckIN", PlcData, PLC_Status.SN_CheckIN);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 核对载具合法性
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="PlcData"></param>
|
||||
/// <param name="OtherData"></param>
|
||||
/// <returns></returns>
|
||||
public ApiFormResult Carrier_Check(string url, plcdata PlcData, otherdata OtherData)
|
||||
{
|
||||
// 组装 request json
|
||||
@@ -155,8 +207,8 @@ namespace WindowsFormsApp1.server
|
||||
StationID = _stationID,
|
||||
MachineID = _machineID,
|
||||
OPID = _opID,
|
||||
Token = "",
|
||||
FixSN = "",
|
||||
Token = _token,
|
||||
FixSN = _fixsn,
|
||||
CarrierID = PlcData.Read_MaterialCode1,
|
||||
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
||||
};
|
||||
@@ -164,6 +216,13 @@ namespace WindowsFormsApp1.server
|
||||
return CallApi(url, request, "Carrier_Check", PlcData, PLC_Status.Carrier_Check);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 核对材料,核对胶水寿命
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="PlcData"></param>
|
||||
/// <param name="OtherData"></param>
|
||||
/// <returns></returns>
|
||||
public ApiFormResult SN_FeedingCheck(string url, plcdata PlcData, otherdata OtherData)
|
||||
{
|
||||
// 组装 request json
|
||||
@@ -174,15 +233,31 @@ namespace WindowsFormsApp1.server
|
||||
StationID = _stationID,
|
||||
MachineID = _machineID,
|
||||
OPID = _opID,
|
||||
Token = "",
|
||||
FixSN = "",
|
||||
Token = _token,
|
||||
FixSN = _fixsn,
|
||||
SN = OtherData.JS_SN,//扫码
|
||||
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
||||
};
|
||||
|
||||
return CallApi(url, request, "SN_FeedingCheck", PlcData, PLC_Status.SN_FeedingCheck);
|
||||
var result = CallApi(url, request, "SN_FeedingCheck", PlcData, PLC_Status.SN_FeedingCheck);
|
||||
if (result.Success && result.Mesresult != mesresult.PASS)
|
||||
{
|
||||
// 判断是否是胶水站,FAIL 直接下线 todo
|
||||
return CallFunctionByName("Glue_CheckOut", PlcData, OtherData);
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 追溯码+材料绑定
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="PlcData"></param>
|
||||
/// <param name="OtherData"></param>
|
||||
/// <returns></returns>
|
||||
public ApiFormResult Link_Comp(string url, plcdata PlcData, otherdata OtherData)
|
||||
{
|
||||
// 组装 request json
|
||||
@@ -193,8 +268,15 @@ namespace WindowsFormsApp1.server
|
||||
StationID = _stationID,
|
||||
MachineID = _machineID,
|
||||
OPID = _opID,
|
||||
Token = "",
|
||||
FixSN = "",
|
||||
CompList = new List<CompListItem>()
|
||||
{
|
||||
new CompListItem()
|
||||
{
|
||||
// 安装主板 端子
|
||||
CompID = OtherData.JS_SN ?? Init.ScanString,
|
||||
Qty = "1"
|
||||
}
|
||||
},
|
||||
SN = OtherData.JS_SN,
|
||||
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
||||
};
|
||||
@@ -202,6 +284,13 @@ namespace WindowsFormsApp1.server
|
||||
return CallApi(url, request, "Link_Comp", PlcData, PLC_Status.Link_Comp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫描机壳码,返回MES SN号,写入PLC
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="PlcData"></param>
|
||||
/// <param name="OtherData"></param>
|
||||
/// <returns></returns>
|
||||
public ApiFormResult SN_Release(string url, plcdata PlcData, otherdata OtherData)
|
||||
{
|
||||
// 组装 request json
|
||||
@@ -212,9 +301,9 @@ namespace WindowsFormsApp1.server
|
||||
StationID = _stationID,
|
||||
MachineID = _machineID,
|
||||
OPID = _opID,
|
||||
Token = "",
|
||||
FixSN = "",
|
||||
SN = Init.ScanString,
|
||||
Token = _token,
|
||||
FixSN = _fixsn,
|
||||
SN = OtherData.JS_SN,
|
||||
CarrierID = "",
|
||||
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
||||
};
|
||||
@@ -222,25 +311,56 @@ namespace WindowsFormsApp1.server
|
||||
return CallApi(url, request, "SN_Release", PlcData, PLC_Status.SN_Release);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 胶水、三防漆,材料 上下线
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="PlcData"></param>
|
||||
/// <param name="OtherData"></param>
|
||||
/// <returns></returns>
|
||||
public ApiFormResult Glue_CheckOut(string url, plcdata PlcData, otherdata OtherData)
|
||||
{
|
||||
// 组装 request json
|
||||
//判断站
|
||||
var station = Init.t_Line.lineremark2.ToLower();
|
||||
var fixsn_1 = "";
|
||||
var locationindex = 1;
|
||||
switch (station)
|
||||
{
|
||||
case "Potting"://灌胶
|
||||
case "ThermalPaste"://点胶&CCD检测
|
||||
case "UVCoating"://三防漆涂覆
|
||||
case "Sealant"://点密封胶&CCD
|
||||
break;
|
||||
default:
|
||||
fixsn_1 = "CompPN";
|
||||
locationindex = OtherData.locationindex;
|
||||
break;
|
||||
}
|
||||
|
||||
var request = new
|
||||
{
|
||||
EventID = "Glue_CheckOut",
|
||||
Line = _line,
|
||||
StationID = _stationID,
|
||||
MachineID = _machineID,
|
||||
OPID = "",//判断站,胶水不用传
|
||||
Token = "",//判断站,胶水不用传
|
||||
FixSN = "",//判断站,胶水不用传
|
||||
SN = PlcData.Read_MaterialCode0,
|
||||
OPID = OtherData.opindex,
|
||||
Token = locationindex.ToString(),//判断站,胶水不用传
|
||||
FixSN = fixsn_1,//判断站,胶水不用传
|
||||
SN = OtherData.JS_SN,
|
||||
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
||||
};
|
||||
|
||||
return CallApi(url, request, "Glue_CheckOut", PlcData, PLC_Status.Glue_CheckOut);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 压力曲线 扭力曲线
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="PlcData"></param>
|
||||
/// <param name="OtherData"></param>
|
||||
/// <returns></returns>
|
||||
public ApiFormResult Data_Collection(string url, plcdata PlcData, otherdata OtherData)
|
||||
{
|
||||
// 组装 request json
|
||||
@@ -293,8 +413,38 @@ namespace WindowsFormsApp1.server
|
||||
return CallApi(url, request, "Alarm", PlcData, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 视频、图片上传
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="PlcData"></param>
|
||||
/// <param name="OtherData"></param>
|
||||
/// <returns></returns>
|
||||
public ApiFormResult SN_FileUpload(string url, plcdata PlcData, otherdata OtherData)
|
||||
{
|
||||
// 准备文件 视频/图片
|
||||
var month = DateTime.Now.ToString("yyyyMM");
|
||||
var day = DateTime.Now.ToString("dd");
|
||||
var monthDay = DateTime.Now.ToString("MMdd");
|
||||
var time = DateTime.Now.ToString("HHmmss");
|
||||
var result = PlcData.Read_Result == 1 ? "OK" : "NG";
|
||||
|
||||
var sourceDirectory = @"";
|
||||
var targetDirectory = $"{OtherData.FileUploadAddress}\\{_line.Substring(0, 2)}\\{month}\\{day}\\line{_line.Substring(_line.Length - 2)}\\{_stationID}\\{_machineID}\\{result}";
|
||||
var fileName = $"{month}{day}_{_stationID}_{result}_{PlcData.Write_stSN}_{monthDay}_{time}_{_machineID}_Original01.png";
|
||||
// 查找源文件 可能会有多张照片或视频
|
||||
string sourceFile = Path.Combine(sourceDirectory, "source.png");
|
||||
//string targetDir = Path.Combine(targetDirectory, "target");
|
||||
// 执行复制
|
||||
try
|
||||
{
|
||||
CopyFileToDirectory(sourceFile, targetDirectory, fileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiFormResult.Error(mesresult.FAIL, false, ex.Message, PlcData, DateTime.Now);
|
||||
}
|
||||
|
||||
// 组装 request json
|
||||
var request = new
|
||||
{
|
||||
@@ -309,26 +459,49 @@ namespace WindowsFormsApp1.server
|
||||
SN = OtherData.JS_SN,
|
||||
FileInfo = new List<dynamic>()
|
||||
{
|
||||
new
|
||||
{
|
||||
FileName = OtherData.FileUploadAddress,
|
||||
FilePath = OtherData.FileUploadAddress
|
||||
}
|
||||
//new
|
||||
//{
|
||||
// FileName = OtherData.FileUploadAddress,
|
||||
// FilePath = OtherData.FileUploadAddress
|
||||
//}
|
||||
}
|
||||
}
|
||||
},
|
||||
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
||||
};
|
||||
|
||||
// 多个视频或图片
|
||||
// 动态添加 FileInfo
|
||||
/*
|
||||
var newFileInfo = new
|
||||
{
|
||||
FileName = "NewFileName.txt",
|
||||
FilePath = "C:\\path\\to\\newfile.txt"
|
||||
};
|
||||
|
||||
// 获取 SNList 的第一个元素(假设只有一个 SN 元素)
|
||||
dynamic snElement = request.SNList[0];
|
||||
|
||||
// 将 newFileInfo 添加到 FileInfo 列表中
|
||||
snElement.FileInfo.Add(newFileInfo);
|
||||
*/
|
||||
|
||||
return CallApi(url, request, "SN_FileUpload", PlcData, PLC_Status.SN_FileUpload);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 触发MES打印
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="PlcData"></param>
|
||||
/// <param name="OtherData"></param>
|
||||
/// <returns></returns>
|
||||
public ApiFormResult CodeSoftPrint(string url, plcdata PlcData, otherdata OtherData)
|
||||
{
|
||||
// 组装 request json
|
||||
var request = new
|
||||
{
|
||||
Line = "CodeSoftPrint", // 特殊值,不使用_line
|
||||
Line = _line, // 特殊值,不使用_line
|
||||
StationID = _stationID,
|
||||
MachineID = _machineID,
|
||||
SN = PlcData.Read_MaterialCode0
|
||||
@@ -341,7 +514,10 @@ namespace WindowsFormsApp1.server
|
||||
{
|
||||
// 根据不同的lineCode构建不同的请求
|
||||
var lineCode = Init.t_Line.linecode;
|
||||
var stationid = Init.t_Line.lineremark2;
|
||||
|
||||
var result = PlcData.Read_Result == 1 ? "PASS" : "FAIL";
|
||||
var logresult = PlcData.Read_Result == 1 ? "OK" : "NG";
|
||||
// 基础请求对象
|
||||
var request = new CheckOutObject()
|
||||
{
|
||||
@@ -355,89 +531,125 @@ namespace WindowsFormsApp1.server
|
||||
new SNInfoItem()
|
||||
{
|
||||
SN = PlcData.Read_MaterialCode0,
|
||||
Result = PlcData.Read_Result == 1 ? "PASS" : "FAIL",
|
||||
DC_INFO = new List<DCInfoItem>()
|
||||
{
|
||||
new DCInfoItem()
|
||||
{
|
||||
Item = PlcData.Read_MaterialCode2,
|
||||
Value = PlcData.Read_UploadData1.ToString(),
|
||||
Result = PlcData.Read_Result == 1 ? "PASS" : "FAIL"
|
||||
}
|
||||
},
|
||||
Result = result,
|
||||
DC_INFO = new List<DCInfoItem>(),
|
||||
CompList = new List<CompListItem>()
|
||||
{
|
||||
new CompListItem()
|
||||
{
|
||||
CompID = "",
|
||||
Qty = "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Qty = "",
|
||||
CarrierID = PlcData.Read_MaterialCode1,
|
||||
Mold = "",
|
||||
Token = "",
|
||||
FixSN = "",
|
||||
Mold = _mold,
|
||||
Token = _token,
|
||||
FixSN = _fixsn,
|
||||
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
||||
};
|
||||
|
||||
//LogExecute.logNet.WriteDebug($"checkout:{request}");
|
||||
|
||||
// 根据不同的lineCode可以在这里扩展request对象
|
||||
switch (lineCode)
|
||||
var dcInfo = new DCInfoItem();
|
||||
var sninfo = request.SNInfo[0];
|
||||
var compListItem = new CompListItem();
|
||||
|
||||
//气密
|
||||
if ("SWAT".Contains(stationid))
|
||||
{
|
||||
case "OP1060": // 追溯码+载具,默认(todo)
|
||||
case "OP1120":
|
||||
case "OP1170":
|
||||
case "OP1190":
|
||||
case "OP1220":
|
||||
case "OP1250":
|
||||
break;
|
||||
|
||||
sninfo.DC_INFO.Add(new DCInfoItem
|
||||
{
|
||||
Item = OutItem.充气压力,
|
||||
Value = Init.airtight.Airtight_Value,
|
||||
Result = result
|
||||
});
|
||||
sninfo.DC_INFO.Add(new DCInfoItem
|
||||
{
|
||||
Item = OutItem.泄漏量,
|
||||
Value = Init.airtight.Leak_Value,
|
||||
Result = result
|
||||
});
|
||||
|
||||
case "OP1010":// 传气密
|
||||
case "OP1330":
|
||||
var dcInfo = new DCInfoItem();
|
||||
dcInfo.Item = PlcData.Read_MaterialCode2;
|
||||
dcInfo.Value = "气密测试值";
|
||||
dcInfo.Result = "PASS";
|
||||
//request.SNInfo
|
||||
break;
|
||||
|
||||
case "OP1050":// 胶水码
|
||||
case "OP1210":// 三防漆码
|
||||
break;
|
||||
|
||||
case "OP1070":// 传螺丝 角度,扭力,【扭力曲线(datacollection)】
|
||||
case "OP1080":
|
||||
case "OP1090":
|
||||
case "OP1100":
|
||||
case "OP1130":
|
||||
case "OP1260":
|
||||
break;
|
||||
|
||||
case "OP1140"://压力值,压力曲线
|
||||
break;
|
||||
|
||||
case "OP1160"://加热,冷却温度
|
||||
break;
|
||||
|
||||
case "OP1110"://CCD检测结果
|
||||
case "OP1200"://AOI检测结果
|
||||
case "OP1240"://CCD检测结果
|
||||
case "OP1340"://CCD检测结果
|
||||
break;
|
||||
|
||||
case "OP1360"://产品码
|
||||
break;
|
||||
|
||||
case "OP1230"://AOI检测结果,三防漆涂胶胶宽
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
LogExecute.SNlogNet.WriteDebug($"{PlcData.Read_MaterialCode0},{Init.airtight.Airtight_Value},{Init.airtight.Leak_Value}");
|
||||
}
|
||||
//扭力,角度
|
||||
if ("ScrewE,Assy2,Assy3,ScrewS,ScrewM".Contains(stationid))
|
||||
{
|
||||
var AngleCount = 1;
|
||||
foreach (var item in OtherData.FinalAngleValue.Where(x => x > 0))
|
||||
{
|
||||
//角度
|
||||
dcInfo = new DCInfoItem();
|
||||
dcInfo.Item = $"{Init.t_Line.lineremark2}_Angle{AngleCount}";
|
||||
dcInfo.Value = item.ToString();
|
||||
dcInfo.Result = result;
|
||||
|
||||
sninfo.DC_INFO.Add(dcInfo);
|
||||
AngleCount++;
|
||||
}
|
||||
var TorqueCount = 1;
|
||||
foreach (var item in OtherData.FinalTorqueValue.Where(x => x > 0))
|
||||
{
|
||||
//扭力
|
||||
dcInfo = new DCInfoItem();
|
||||
dcInfo.Item = $"{Init.t_Line.lineremark2}_Torque{TorqueCount}";
|
||||
dcInfo.Value = item.ToString();
|
||||
dcInfo.Result = result;
|
||||
|
||||
sninfo.DC_INFO.Add(dcInfo);
|
||||
TorqueCount++;
|
||||
}
|
||||
}
|
||||
|
||||
//CCD
|
||||
if ("Assy2,Assy3,AOI,Assy5,Sealant,CCD,PrintLabel".Contains(stationid))
|
||||
{
|
||||
dcInfo.Item = stationid == "CCD"? "CCD" : $"{Init.t_Line.lineremark2}_CCD";
|
||||
dcInfo.Value = PlcData.Read_UploadData0.ToString();
|
||||
dcInfo.Result = result;
|
||||
sninfo.DC_INFO.Add(dcInfo);
|
||||
|
||||
LogExecute.SNlogNet.WriteDebug($"追溯码:{PlcData.Read_MaterialCode0},检测结果:{logresult}");
|
||||
}
|
||||
//抽真空 压力
|
||||
if ("Vacuum".Contains(stationid))
|
||||
{
|
||||
|
||||
}
|
||||
//固化 时间
|
||||
if ("Curing".Contains(stationid))
|
||||
{
|
||||
|
||||
}
|
||||
//胶重
|
||||
if ("Potting,ThermalPaste,Sealant".Contains(stationid))
|
||||
{
|
||||
dcInfo.Item = $"{stationid}_Weight";
|
||||
dcInfo.Value = PlcData.Read_UploadData0.ToString();
|
||||
dcInfo.Result = result;
|
||||
sninfo.DC_INFO.Add(dcInfo);
|
||||
}
|
||||
//胶宽
|
||||
if ("Sealant".Contains(stationid))
|
||||
{
|
||||
dcInfo.Item = $"{stationid}_Width";
|
||||
dcInfo.Value = PlcData.Read_UploadData1.ToString();
|
||||
dcInfo.Result = result;
|
||||
sninfo.DC_INFO.Add(dcInfo);
|
||||
}
|
||||
//胶水 材料码
|
||||
if ("Potting,ThermalPaste,Sel_Soldering,UVCoating,Sealant".Contains(stationid))
|
||||
{
|
||||
compListItem.CompID = OtherData.JS_SN;
|
||||
compListItem.Qty = "1";
|
||||
|
||||
sninfo.CompList.Add(compListItem);
|
||||
|
||||
LogExecute.SNlogNet.WriteDebug($"{PlcData.Read_MaterialCode0},胶水码:{OtherData.JS_SN},胶重:{PlcData.Read_UploadData0}");
|
||||
}
|
||||
else //其他不传
|
||||
{
|
||||
compListItem.CompID = "";
|
||||
compListItem.Qty = "1";
|
||||
|
||||
sninfo.CompList.Add(compListItem);
|
||||
}
|
||||
return CallApi(url, request, "SN_Checkout", PlcData, PLC_Status.SN_Checkout);
|
||||
}
|
||||
|
||||
@@ -581,6 +793,22 @@ namespace WindowsFormsApp1.server
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// checkout dcinfo item
|
||||
/// </summary>
|
||||
public sealed class OutItem
|
||||
{
|
||||
public const string 充气压力 = "Set_Fill";
|
||||
public const string 泄漏量 = "Leakage_Rate";
|
||||
public const string 灌胶重量 = "Glue_Weight";
|
||||
public const string 点胶重量 = "ThermalPaste_Weight";
|
||||
public const string 腔体压力 = "Chamber_Pressure";
|
||||
public const string 保压时间 = "Hold_Time";
|
||||
public const string 固化温度 = "Cure_Temperature";
|
||||
public const string 固化时间 = "Curing_Time";
|
||||
public const string 重量 = "Sealant_Weight";
|
||||
public const string 宽度 = "Sealant_Width";
|
||||
}
|
||||
public sealed class PLC_Status
|
||||
{
|
||||
public const int SN_CheckIN = 10;
|
||||
@@ -606,7 +834,8 @@ namespace WindowsFormsApp1.server
|
||||
public const int Fail = 1001;
|
||||
}
|
||||
|
||||
//checkout class
|
||||
|
||||
#region checkout class
|
||||
// 根对象类
|
||||
public class CheckOutObject
|
||||
{
|
||||
@@ -647,5 +876,36 @@ namespace WindowsFormsApp1.server
|
||||
public string CompID { get; set; }
|
||||
public string Qty { get; set; }
|
||||
}
|
||||
#endregion checkout class
|
||||
|
||||
// 文件copy方法
|
||||
public bool CopyFileToDirectory(string sourceFilePath, string targetDirectory, string fileName)
|
||||
{
|
||||
// 检查源文件是否存在
|
||||
if (!File.Exists(sourceFilePath))
|
||||
{
|
||||
throw new FileNotFoundException("源文件不存在", sourceFilePath);
|
||||
}
|
||||
|
||||
// 如果目标目录不存在,则创建
|
||||
if (!Directory.Exists(targetDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(targetDirectory);
|
||||
}
|
||||
|
||||
string targetPath = Path.Combine(targetDirectory, fileName);
|
||||
|
||||
try
|
||||
{
|
||||
// 复制文件
|
||||
File.Copy(sourceFilePath, targetPath, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user