|
|
@@ -1293,12 +1293,12 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
|
|
|
|
//获取产品编码
|
|
|
- _productService.CurrentProductCode = plc.ReadNode<string>(string.Format(addressConfig.In_Code.Address, 0));
|
|
|
- //如果产品编码为空,则以当前的时间戳作为编码
|
|
|
- if (string.IsNullOrEmpty(_productService.CurrentProductCode))
|
|
|
- {
|
|
|
- _productService.CurrentProductCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");
|
|
|
- }
|
|
|
+ //_productService.CurrentProductCode = plc.ReadNode<string>(string.Format(addressConfig.In_Code.Address, 0));
|
|
|
+ ////如果产品编码为空,则以当前的时间戳作为编码
|
|
|
+ //if (string.IsNullOrEmpty(_productService.CurrentProductCode))
|
|
|
+ //{
|
|
|
+ // _productService.CurrentProductCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");
|
|
|
+ //}
|
|
|
|
|
|
// 触发下相机拍照
|
|
|
if (addressConfig.In_DowmCameraExe.Address.Contains(tuple.nodeId))
|
|
|
@@ -1781,7 +1781,6 @@ namespace TeamAAS_VP.Core
|
|
|
var headRecord = await _systemDatabaseService.GetLatestHeadChangeRecordAsync();
|
|
|
//最后一次的披头编号
|
|
|
string headNumber = headRecord != null ? headRecord.HeadBatchNumber : "N/A";
|
|
|
- var cdata = _configService.GetCTQDataInfo();//获取ctq数据参数
|
|
|
|
|
|
await Task.Delay(60);
|
|
|
//获取电批结果
|
|
|
@@ -1862,100 +1861,6 @@ namespace TeamAAS_VP.Core
|
|
|
await plc.WriteNodeAsync(addressConfig.In_WorkDone.Address, (Int16)0);
|
|
|
// 停止采集压力并保存
|
|
|
await StopAndSavePressureCollectionAsync(currentProduct.Name, _productService.CurrentProductCode, positionIndex);
|
|
|
-
|
|
|
- try
|
|
|
- {
|
|
|
- #region 数据
|
|
|
- DFC.Clear();
|
|
|
- bool torqueRes, turnRes, pressureRes;
|
|
|
- if (lockResult.LockTorque >= lockResult.TargetTorqueLowerLimit && lockResult.LockTorque <= lockResult.TargetTorqueUpperLimit)
|
|
|
- {
|
|
|
- torqueRes = true;
|
|
|
- }
|
|
|
- else torqueRes = false;
|
|
|
- if (lockResult.Pressure >= cdata.CTQ_LSL_Pressure && lockResult.Pressure <= cdata.CTQ_USL_Pressure)
|
|
|
- {
|
|
|
- pressureRes = true;
|
|
|
- }
|
|
|
- else pressureRes = false;
|
|
|
- if (lockResult.LockTurns >= lockResult.TargetTurnsLowerLimit && lockResult.LockTurns <= lockResult.TargetTurnsUpperLimit)
|
|
|
- {
|
|
|
- turnRes = true;
|
|
|
- }
|
|
|
- else turnRes = false;
|
|
|
- DFC.Add(new DataFormCtq
|
|
|
- {
|
|
|
- PPID = productSn,
|
|
|
- PROCESS_NAME = cdata.PROCESS_NAME,
|
|
|
- PROCESS_START_TIME = StartScrewTime.ToString(),
|
|
|
- CTQ_NAME = "Torque",
|
|
|
- CTQ_VALUE = lockResult.LockTorque,
|
|
|
- CTQ_LSL = lockResult.TargetTorqueLowerLimit,
|
|
|
- CTQ_USL = lockResult.TargetTorqueUpperLimit,
|
|
|
- PROCESS_END_TIME = DateTime.Now.ToString(),
|
|
|
- SUPPLIER_NAME = cdata.SUPPLIER_NAME,
|
|
|
- COMMODITY_TYPE = cdata.COMMODITY_TYPE,
|
|
|
- REVISION = cdata.REVISION,
|
|
|
- WO = wo,
|
|
|
- MFG_LOT = cdata.MFG_LOT,
|
|
|
- MFG_ASSY_LINE = cdata.MFG_ASSY_LINE,
|
|
|
- PROCESS_OUTCOME = torqueRes ? "PASS" : "FAIL",
|
|
|
- PROCESS_MACHINE_ID = cdata.PROCESS_MACHINE_ID,
|
|
|
- CTQ_UNIT_OF_MEASURE = "kgf.cm",
|
|
|
- ERROR_MESSAGE = torqueRes ? "" : "Torque_Spec OOS"
|
|
|
- });
|
|
|
- DFC.Add(new DataFormCtq
|
|
|
- {
|
|
|
- PPID = productSn,
|
|
|
- PROCESS_NAME = cdata.PROCESS_NAME,
|
|
|
- PROCESS_START_TIME = StartScrewTime.ToString(),
|
|
|
- CTQ_NAME = "Turn",
|
|
|
- CTQ_VALUE = lockResult.LockTurns,
|
|
|
- CTQ_LSL = lockResult.TargetTurnsLowerLimit,
|
|
|
- CTQ_USL = lockResult.TargetTurnsUpperLimit,
|
|
|
- PROCESS_END_TIME = DateTime.Now.ToString(),
|
|
|
- SUPPLIER_NAME = cdata.SUPPLIER_NAME,
|
|
|
- COMMODITY_TYPE = cdata.COMMODITY_TYPE,
|
|
|
- REVISION = cdata.REVISION,
|
|
|
- WO = wo,
|
|
|
- MFG_LOT = cdata.MFG_LOT,
|
|
|
- MFG_ASSY_LINE = cdata.MFG_ASSY_LINE,
|
|
|
- PROCESS_OUTCOME = turnRes ? "PASS" : "FAIL",
|
|
|
- PROCESS_MACHINE_ID = cdata.PROCESS_MACHINE_ID,
|
|
|
- CTQ_UNIT_OF_MEASURE = "圈",
|
|
|
- ERROR_MESSAGE = turnRes ? "" : "Turn_Spec OOS"
|
|
|
- });
|
|
|
- DFC.Add(new DataFormCtq
|
|
|
- {
|
|
|
- PPID = productSn,
|
|
|
- PROCESS_NAME = cdata.PROCESS_NAME,
|
|
|
- PROCESS_START_TIME = StartScrewTime.ToString(),
|
|
|
- CTQ_NAME = "Pressure",
|
|
|
- CTQ_VALUE = lockResult.Pressure,
|
|
|
- CTQ_LSL = cdata.CTQ_LSL_Pressure,
|
|
|
- CTQ_USL = cdata.CTQ_USL_Pressure,
|
|
|
- PROCESS_END_TIME = DateTime.Now.ToString(),
|
|
|
- SUPPLIER_NAME = cdata.SUPPLIER_NAME,
|
|
|
- COMMODITY_TYPE = cdata.COMMODITY_TYPE,
|
|
|
- REVISION = cdata.REVISION,
|
|
|
- WO = wo,
|
|
|
- MFG_LOT = cdata.MFG_LOT,
|
|
|
- MFG_ASSY_LINE = cdata.MFG_ASSY_LINE,
|
|
|
- PROCESS_OUTCOME = pressureRes ? "PASS" : "FAIL",
|
|
|
- PROCESS_MACHINE_ID = cdata.PROCESS_MACHINE_ID,
|
|
|
- CTQ_UNIT_OF_MEASURE = "N",
|
|
|
- ERROR_MESSAGE = pressureRes ? "" : "Pressure_Spec OOS"
|
|
|
- });
|
|
|
- foreach (var item in DFC)
|
|
|
- {
|
|
|
- FileHelper.WriteDataToCSV(item);
|
|
|
- }
|
|
|
- #endregion
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- SendTaskMessage("CTQ数据存储时出错" + ex.Message, MessageLevel.Error);
|
|
|
- }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -2162,7 +2067,7 @@ namespace TeamAAS_VP.Core
|
|
|
var _cts = new CancellationTokenSource();
|
|
|
|
|
|
await _remoteCommandService.SetLightBeforePhoto(qrCodeProcess);
|
|
|
- var qrCodeResult = _remoteCommandService.ExecutePhoto(qrCodeProcess, out CogToolBlockTerminalCollection outputCollection);
|
|
|
+ var qrCodeResult = _remoteCommandService.ExecutePhoto(i + 1, qrCodeProcess, out CogToolBlockTerminalCollection outputCollection);
|
|
|
|
|
|
if (qrCodeResult && outputCollection.Contains("QR"))
|
|
|
{
|
|
|
@@ -2243,6 +2148,10 @@ namespace TeamAAS_VP.Core
|
|
|
if (snItem != null)
|
|
|
{
|
|
|
ProductMainSN[i] = snItem.Replace("sn=", "").Trim();
|
|
|
+ if (i == 0)
|
|
|
+ {
|
|
|
+ _productService.CurrentProductCode = ProductMainSN[i];
|
|
|
+ }
|
|
|
SendTaskMessage($"产品主sn:{ProductMainSN[i]}", MessageLevel.Info);
|
|
|
}
|
|
|
if (woItem != null)
|
|
|
@@ -2300,6 +2209,10 @@ namespace TeamAAS_VP.Core
|
|
|
if (snItem != null)
|
|
|
{
|
|
|
ProductMainSN[i] = snItem.Replace("sn=", "").Trim();
|
|
|
+ if (i == 0)
|
|
|
+ {
|
|
|
+ _productService.CurrentProductCode = ProductMainSN[i];
|
|
|
+ }
|
|
|
SendTaskMessage($"产品主sn:{ProductMainSN[i]}", MessageLevel.Info);
|
|
|
}
|
|
|
if (woItem != null)
|
|
|
@@ -2330,6 +2243,8 @@ namespace TeamAAS_VP.Core
|
|
|
// 上传本站数据
|
|
|
else if (state == 2)
|
|
|
{
|
|
|
+ DFC.Clear();
|
|
|
+
|
|
|
//获取当前工位的配置
|
|
|
var stationConfig = _configService.GetDeviceInfo(i);
|
|
|
SendTaskMessage($"收到{i}:{stationConfig.DeviceName}上传本站数据请求...", MessageLevel.Debug);
|
|
|
@@ -2388,17 +2303,117 @@ namespace TeamAAS_VP.Core
|
|
|
bool recordResult = false;
|
|
|
if (i == 0)
|
|
|
{
|
|
|
- recordResult = RecordLockResult(i, lockResultsAll, ProductMainSN[i], serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds, _LastMesCheckTime[i], stationConfig.SaveCsvPath);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Dictionary<string,string> dataItems = new Dictionary<string, string>();
|
|
|
- //结果
|
|
|
- dataItems.Add("Result", resultIndex == 1 ? "OK" : "NG");
|
|
|
- //压力值
|
|
|
- //dataItems.Add("Pressure", pressure);
|
|
|
- recordResult = RecordOtherStationResult(i, dataItems, ProductMainSN[i], serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds, _LastMesCheckTime[i], stationConfig.SaveCsvPath);
|
|
|
+ foreach (var lockResult in lockResultsAll)
|
|
|
+ {
|
|
|
+ bool torqueRes, turnRes, pressureRes;
|
|
|
+ if (lockResult.LockTorque >= lockResult.TargetTorqueLowerLimit && lockResult.LockTorque <= lockResult.TargetTorqueUpperLimit)
|
|
|
+ {
|
|
|
+ torqueRes = true;
|
|
|
+ }
|
|
|
+ else torqueRes = false;
|
|
|
+ if (lockResult.Pressure >= stationConfig.DataInfo.CTQ_LSL_Pressure && lockResult.Pressure <= stationConfig.DataInfo.CTQ_USL_Pressure)
|
|
|
+ {
|
|
|
+ pressureRes = true;
|
|
|
+ }
|
|
|
+ else pressureRes = false;
|
|
|
+ if (lockResult.LockTurns >= lockResult.TargetTurnsLowerLimit && lockResult.LockTurns <= lockResult.TargetTurnsUpperLimit)
|
|
|
+ {
|
|
|
+ turnRes = true;
|
|
|
+ }
|
|
|
+ else turnRes = false;
|
|
|
+ DFC.Add(new DataFormCtq
|
|
|
+ {
|
|
|
+ PPID = ProductMainSN[i],
|
|
|
+ PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
|
|
|
+ PROCESS_START_TIME = _LastMesCheckTime[i].ToString(),
|
|
|
+ CTQ_NAME = "Torque",
|
|
|
+ CTQ_VALUE = lockResult.LockTorque,
|
|
|
+ CTQ_LSL = lockResult.TargetTorqueLowerLimit,
|
|
|
+ CTQ_USL = lockResult.TargetTorqueUpperLimit,
|
|
|
+ PROCESS_END_TIME = serverTimeResult.Now.ToString(),
|
|
|
+ SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
+ COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
+ REVISION = stationConfig.DataInfo.REVISION,
|
|
|
+ WO = wo,
|
|
|
+ MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
+ MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
+ PROCESS_OUTCOME = torqueRes ? "PASS" : "FAIL",
|
|
|
+ PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
|
|
|
+ CTQ_UNIT_OF_MEASURE = "kgf.cm",
|
|
|
+ ERROR_MESSAGE = torqueRes ? "" : "Torque_Spec OOS"
|
|
|
+ });
|
|
|
+ DFC.Add(new DataFormCtq
|
|
|
+ {
|
|
|
+ PPID = ProductMainSN[i],
|
|
|
+ PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
|
|
|
+ PROCESS_START_TIME = _LastMesCheckTime[i].ToString(),
|
|
|
+ CTQ_NAME = "Turn",
|
|
|
+ CTQ_VALUE = lockResult.LockTurns,
|
|
|
+ CTQ_LSL = lockResult.TargetTurnsLowerLimit,
|
|
|
+ CTQ_USL = lockResult.TargetTurnsUpperLimit,
|
|
|
+ PROCESS_END_TIME = serverTimeResult.Now.ToString(),
|
|
|
+ SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
+ COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
+ REVISION = stationConfig.DataInfo.REVISION,
|
|
|
+ WO = wo,
|
|
|
+ MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
+ MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
+ PROCESS_OUTCOME = turnRes ? "PASS" : "FAIL",
|
|
|
+ PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
|
|
|
+ CTQ_UNIT_OF_MEASURE = "圈",
|
|
|
+ ERROR_MESSAGE = turnRes ? "" : "Turn_Spec OOS"
|
|
|
+ });
|
|
|
+ DFC.Add(new DataFormCtq
|
|
|
+ {
|
|
|
+ PPID = ProductMainSN[i],
|
|
|
+ PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
|
|
|
+ PROCESS_START_TIME = _LastMesCheckTime[i].ToString(),
|
|
|
+ CTQ_NAME = "Pressure",
|
|
|
+ CTQ_VALUE = lockResult.Pressure,
|
|
|
+ CTQ_LSL = stationConfig.DataInfo.CTQ_LSL_Pressure,
|
|
|
+ CTQ_USL = stationConfig.DataInfo.CTQ_USL_Pressure,
|
|
|
+ PROCESS_END_TIME = serverTimeResult.Now.ToString(),
|
|
|
+ SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
+ COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
+ REVISION = stationConfig.DataInfo.REVISION,
|
|
|
+ WO = wo,
|
|
|
+ MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
+ MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
+ PROCESS_OUTCOME = pressureRes ? "PASS" : "FAIL",
|
|
|
+ PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
|
|
|
+ CTQ_UNIT_OF_MEASURE = "N",
|
|
|
+ ERROR_MESSAGE = pressureRes ? "" : "Pressure_Spec OOS"
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // DFC.Add(new DataFormCtq
|
|
|
+ // {
|
|
|
+ // PPID = ProductMainSN[i],
|
|
|
+ // PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
|
|
|
+ // PROCESS_START_TIME = _LastMesCheckTime[i].ToString(),
|
|
|
+ // CTQ_NAME = "Pressure",
|
|
|
+ // CTQ_VALUE = lockResult.Pressure,
|
|
|
+ // CTQ_LSL = stationConfig.DataInfo.CTQ_LSL_Pressure,
|
|
|
+ // CTQ_USL = stationConfig.DataInfo.CTQ_USL_Pressure,
|
|
|
+ // PROCESS_END_TIME = serverTimeResult.Now.ToString(),
|
|
|
+ // SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
+ // COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
+ // REVISION = stationConfig.DataInfo.REVISION,
|
|
|
+ // WO = wo,
|
|
|
+ // MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
+ // MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
+ // PROCESS_OUTCOME = pressureRes ? "PASS" : "FAIL",
|
|
|
+ // PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
|
|
|
+ // CTQ_UNIT_OF_MEASURE = "N",
|
|
|
+ // ERROR_MESSAGE = pressureRes ? "" : "Pressure_Spec OOS"
|
|
|
+ // });
|
|
|
+ // //压力值
|
|
|
+ // //dataItems.Add("Pressure", pressure);
|
|
|
+ // recordResult = RecordOtherStationResult(i, dataItems, ProductMainSN[i], serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds, _LastMesCheckTime[i], stationConfig.SaveCsvPath);
|
|
|
+ //}
|
|
|
+ recordResult = RecordStationResult(i, DFC, ProductMainSN[i], serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds, _LastMesCheckTime[i], stationConfig.SaveCsvPath);
|
|
|
if (recordResult)
|
|
|
{
|
|
|
SendTaskMessage($"{i}:{stationConfig.DeviceName}产品记录保存成功", MessageLevel.Debug);
|
|
|
@@ -2927,6 +2942,87 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 记录工位的结果,其他工位要存储的数据项按照键值对集合的形式传入,键为数据项名称,值为数据项的值
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="stationIndex"></param>
|
|
|
+ /// <param name="dfcs"></param>
|
|
|
+ /// <param name="productMainSN"></param>
|
|
|
+ /// <param name="ct"></param>
|
|
|
+ /// <param name="timestamp"></param>
|
|
|
+ /// <param name="savePath"></param>
|
|
|
+ /// <param name="isFirstEnter"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool RecordStationResult(int stationIndex, IEnumerable<DataFormCtq> dfcs, string productMainSN, double ct, DateTime timestamp, string savePath, bool isFirstEnter = true)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //获取当前工位的配置
|
|
|
+ var stationConfig = _configService.GetDeviceInfo(stationIndex);
|
|
|
+ if (stationConfig == null) return false;
|
|
|
+ //如果保存路径为空,则不保存
|
|
|
+ if (string.IsNullOrEmpty(savePath)) return false;
|
|
|
+ string fullPath = savePath;
|
|
|
+ //如果保存路径是一个文件路径,则直接保存,否则按照工位和日期进行保存
|
|
|
+ if (File.Exists(savePath) || Path.HasExtension(savePath))
|
|
|
+ {
|
|
|
+ fullPath = savePath;
|
|
|
+ //如果路径不存在,则创建
|
|
|
+ // 创建目录
|
|
|
+ string directory = Path.GetDirectoryName(fullPath);
|
|
|
+ if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(directory);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //结果保存至CSV文件,文件名格式:savePath\yyyy-MM\工位编号_工位名称_yyyy-MM-dd.csv
|
|
|
+ string datePath = timestamp.ToString("yyyy-MM") + "\\";
|
|
|
+ string dirPath = Path.Combine(savePath, datePath);
|
|
|
+ if (!Directory.Exists(dirPath)) Directory.CreateDirectory(dirPath);
|
|
|
+ string fileName = $"{stationIndex}_{stationConfig.DeviceName}_{timestamp.ToString("yyyy-MM-dd")}.csv";
|
|
|
+ fullPath = Path.Combine(dirPath, fileName);
|
|
|
+ }
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ if (!File.Exists(fullPath))
|
|
|
+ {
|
|
|
+ sb.Append("PPID,PROCESS_NAME,PROCESS_START_TIME,CTQ_NAME,CTQ_VALUE,CTQ_LSL,CTQ_USL,PROCESS_END_TIME,SUPPLIER_NAME,COMMODITY_TYPE,REVISION,WO#,MFG_LOT#," +
|
|
|
+ "MFG_ASSY_LINE,PROCESS_OUTCOME,PROCESS_MACHINE_ID,CTQ_UNIT_OF_MEASURE,ERROR_MESSAGE");
|
|
|
+ sb.AppendLine();
|
|
|
+ }
|
|
|
+ if (dfcs == null || dfcs.Count() == 0)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ foreach (var dfc in dfcs)
|
|
|
+ {
|
|
|
+ sb.Append($"{dfc.PPID},{dfc.PROCESS_NAME},{dfc.PROCESS_START_TIME},{dfc.CTQ_NAME},{dfc.CTQ_VALUE:F3},{dfc.CTQ_LSL:F3},{dfc.CTQ_USL:F3},{dfc.PROCESS_END_TIME},{dfc.SUPPLIER_NAME},{dfc.COMMODITY_TYPE},{dfc.REVISION},{dfc.WO},{dfc.MFG_LOT},{dfc.MFG_ASSY_LINE},{dfc.PROCESS_OUTCOME},{dfc.PROCESS_MACHINE_ID},{dfc.CTQ_UNIT_OF_MEASURE},{dfc.ERROR_MESSAGE}");
|
|
|
+ sb.AppendLine();
|
|
|
+ }
|
|
|
+ // 使用 StreamWriter 以追加模式打开文件
|
|
|
+ StreamWriter sw = new StreamWriter(fullPath, true, Encoding.UTF8);
|
|
|
+ sw.Write(sb.ToString());
|
|
|
+ sw.Close();
|
|
|
+ sw.Dispose();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ if (!isFirstEnter)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ LogHelper.WriteLogError("记录其他工位结果时出错!", ex);
|
|
|
+ //我希望在这里生成一个临时文件来保存这次的记录,因为如果本地文件被打开时可能会导致无法写入,如果不保存的话可能会丢失这次的记录,所以我想在这里生成一个临时文件来保存这次的记录
|
|
|
+ //生成临时文件的路径,格式为savePath\yyyy-MM\工位编号_yyyy-MM-dd_temp\工位编号_yyyy-MM-dd_HH-mm-ss-fff_temp.csv
|
|
|
+ string datePath = timestamp.ToString("yyyy-MM") + "\\";
|
|
|
+ string tempDirPath = Path.Combine(savePath, datePath, $"{stationIndex}_{timestamp.ToString("yyyy-MM-dd")}_temp");
|
|
|
+ string tempFileName = $"{stationIndex}_{timestamp.ToString("yyyy-MM-dd_HH-mm-ss-fff")}_temp.csv";
|
|
|
+ RecordStationResult(stationIndex, dfcs, productMainSN, ct, timestamp, tempFileName, false);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|