|
@@ -40,6 +40,7 @@ using System.Net.Http;
|
|
|
using static MainForm.ClassFile.XiaomiAPI_MES.XiaomiMESHttp_UpLoadFile;
|
|
|
using MathNet.Numerics.Statistics;
|
|
|
using System.Runtime.Remoting.Contexts;
|
|
|
+using System.Collections;
|
|
|
|
|
|
/*
|
|
|
* 注:本源码对外提供,所以有些地方使用中文命名方法及变量
|
|
@@ -1203,10 +1204,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 fileName, string bucket, Dictionary<Guid, string> uuidDictionary)
|
|
|
{
|
|
|
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, fileName, bucket,uuidDictionary);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -1224,7 +1225,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 fileName,string bucket, Dictionary<Guid, string> uuidDictionary)
|
|
|
{
|
|
|
int upload = 0;
|
|
|
int result = 0;
|
|
@@ -1274,6 +1275,19 @@ namespace MainForm
|
|
|
}); // 设备数据 - 部件码
|
|
|
}
|
|
|
|
|
|
+ //图片上传的uuid
|
|
|
+ foreach (var entry in uuidDictionary)
|
|
|
+ {
|
|
|
+ Guid uuid = entry.Key; // 获取 UUID
|
|
|
+ outRequest_Body.unitData.fileData.Add(
|
|
|
+ new XmMES_StationOutRequest_Body.XmStationOut_FileData()
|
|
|
+ {
|
|
|
+ fileName = fileName,
|
|
|
+ fileId= uuid.ToString(),
|
|
|
+ bucket = bucket
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
string jsonstr1 = JsonConvert.SerializeObject(outRequest_Body);
|
|
|
|
|
|
if (GlobalContext.IsSendProcessData)
|
|
@@ -1331,14 +1345,18 @@ namespace MainForm
|
|
|
/// <param name="stationName"></param>
|
|
|
private void SaveDBbyFileInfo(OP40_MesData_t stPLC_MesData, string stationCode, string stationName)
|
|
|
{
|
|
|
- string path = GlobalContext.UpFilePath;
|
|
|
+ //string path = GlobalContext.UpFilePath;
|
|
|
+ string path = "D:\\TempNew";
|
|
|
string leftPath = path + "\\Left";
|
|
|
string rightPath = path + "\\Right";
|
|
|
+ string toPath = "D:\\Temp";
|
|
|
string sql = "";
|
|
|
Guid guid;
|
|
|
int result = 0;
|
|
|
var formData = new MultipartFormDataContent();
|
|
|
|
|
|
+ // 创建一个字典,键为 UUID
|
|
|
+ Dictionary<Guid, string> uuidDictionary = new Dictionary<Guid, string>();
|
|
|
// 获取所有图片文件
|
|
|
List<string> imageFiles_L = GetAllImageFiles(leftPath);
|
|
|
List<string> imageFiles_R = GetAllImageFiles(rightPath);
|
|
@@ -1347,7 +1365,7 @@ namespace MainForm
|
|
|
foreach (string imageFile in imageFiles_L)
|
|
|
{
|
|
|
guid = Guid.NewGuid();
|
|
|
- //formData = MultipartbyFile(imageFile);
|
|
|
+ uuidDictionary[guid] = "";
|
|
|
sql = string.Format("INSERT INTO [dbo].[DataFiles](stationCode,stationName,CarrierBarcode,ProductBarcode,bucket,fileName,fileContext,uuid,fileUrl,status,submitTime,createTime) " +
|
|
|
"VALUES('{0}','{1}','{2}' ,'{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')"
|
|
|
, stationCode
|
|
@@ -1364,11 +1382,48 @@ namespace MainForm
|
|
|
, DateTime.Now
|
|
|
);
|
|
|
string ret = SQLHelper_New.ExecuteNonQuery(sql, null);
|
|
|
- sendPostFile(path, Path.GetFileName(imageFile), guid.ToString(), "");
|
|
|
+
|
|
|
+
|
|
|
+ FileUpload_X5 fileUpload_X5 = new FileUpload_X5();
|
|
|
+ string bucket = string.Empty;
|
|
|
+ bucket = "IMAGE/IMAGE/N3/debug/online/PASS/M0002PA-0001/P320N000006B/382f55e9-c2bb";
|
|
|
+ fileUpload_X5.bucket = bucket;
|
|
|
+ fileUpload_X5.name = imageFile;
|
|
|
+ fileUpload_X5.md5 = "";
|
|
|
+ fileUpload_X5.uploadCloud = true;
|
|
|
+ fileUpload_X5.informMqtt = true;
|
|
|
+
|
|
|
+ FileMqttPayload fileMqttPayload = new FileMqttPayload();
|
|
|
+ fileMqttPayload.factory = "";
|
|
|
+ fileMqttPayload.project_name = "";
|
|
|
+ fileMqttPayload.product_mode = "";
|
|
|
+ fileMqttPayload.line_no = "";
|
|
|
+ fileMqttPayload.work_station_no = "";
|
|
|
+ fileMqttPayload.equipment_no = "";
|
|
|
+ fileMqttPayload.station_no = "";
|
|
|
+ fileMqttPayload.file_id = "";
|
|
|
+ fileMqttPayload.file_name = "";
|
|
|
+ fileMqttPayload.sn = "";
|
|
|
+ fileMqttPayload.opt_time = "";
|
|
|
+ fileMqttPayload.file_type = "";
|
|
|
+ fileMqttPayload.file_category = "";
|
|
|
+ fileMqttPayload.tag = "";
|
|
|
+ fileMqttPayload.pass_station_id = "";
|
|
|
+
|
|
|
+ //FileUpload_X5 fileUpload_X5 = new FileUpload_X5();
|
|
|
+ //FileMqttPayload fileMqttPayload = new FileMqttPayload();
|
|
|
+ //fileUpload_X5.bucket = "IMAGE/IMAGE/N3/debug/online/PASS/M0002PA-0001/P320N000006B/382f55e9-c2bb";
|
|
|
+ //fileUpload_X5.name = "test";
|
|
|
+ //fileUpload_X5.md5 = "";
|
|
|
+ //fileUpload_X5.uploadCloud = true;
|
|
|
+ //fileUpload_X5.informMqtt = true;
|
|
|
+
|
|
|
+ var fileresult = XiaomiMESHttp_UpLoadFile.FileUoladToMes(imageFile, fileUpload_X5, fileMqttPayload, toPath);
|
|
|
}
|
|
|
foreach (string imageFile in imageFiles_R)
|
|
|
{
|
|
|
- //formData = MultipartbyFile(imageFile);
|
|
|
+ guid = Guid.NewGuid();
|
|
|
+ uuidDictionary[guid] = "";
|
|
|
sql = string.Format("INSERT INTO [dbo].[DataFiles](stationCode,stationName,CarrierBarcode,ProductBarcode,bucket,fileName,fileContext,uuid,fileUrl,status,submitTime,createTime) " +
|
|
|
"VALUES('{0}','{1}','{2}' ,'{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')"
|
|
|
, stationCode
|
|
@@ -1440,69 +1495,6 @@ namespace MainForm
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public int sendPostFile(string bucket, string filename,string guid, string context)
|
|
|
- {
|
|
|
- int result = 0;
|
|
|
-
|
|
|
- XmMES_UpFile_Request_Body inRequest_Body = new XmMES_UpFile_Request_Body();
|
|
|
- inRequest_Body.bucket = bucket;
|
|
|
- inRequest_Body.name = filename;
|
|
|
- inRequest_Body.uuid = guid;
|
|
|
- inRequest_Body.file = context;
|
|
|
-
|
|
|
- string json_Body = JsonConvert.SerializeObject(inRequest_Body);
|
|
|
- //await Task.Delay(200);
|
|
|
- // 上传MES
|
|
|
- if (GlobalContext.IsSendStationIn)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- XmMES_UpFile_Response response = new XmMES_UpFile_Response();
|
|
|
- string mesRet = string.Empty;
|
|
|
- int i = 0;
|
|
|
- while (i < 2) // 1009会多次尝试上传
|
|
|
- {
|
|
|
- response = XiaomiMESHttp_UpLoadFile.UpFilePost(inRequest_Body);
|
|
|
- if (response != null && response.header.code == "200")
|
|
|
- break;
|
|
|
- else if (!mesRet.Contains("1009")) // 1009是未知错误
|
|
|
- i++;
|
|
|
-
|
|
|
- i++;
|
|
|
-
|
|
|
- mesRet = $"[{response?.header?.code}]{response?.header?.desc}";
|
|
|
- // 记录失败原因
|
|
|
- OnMessage(LogType.Error, "上传出站数据到MES服务器---失败!正在重新上传!接口报错信息:" + mesRet + "参数:" + json_Body);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (response?.header?.code == "200")
|
|
|
- {
|
|
|
- //string sql_Upd = stationIn.ToStringUpdateStatusByID(1);
|
|
|
- //string ret_Upd = SQLHelper_New.ExecuteNonQuery(sql_Upd, null);
|
|
|
- //result = ret_Upd == "成功" ? 1 : 6;
|
|
|
- //AddMessage(LogType.Info, $"【进站数据 SN {stationIn.Sn}】上传MES服务器---成功");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- result = 5;
|
|
|
- //AddMessage(LogType.Info, $"【进站数据 SN {stationIn.Sn}】上传MES服务器---失败!接口报错信息:" + mesRet);
|
|
|
- }
|
|
|
- //string sql_response = stationIn.ToStringUpdateStationInReturn_body(JsonConvert.SerializeObject(response));
|
|
|
- //SQLHelper_New.ExecuteNonQuery(sql_response, null);
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- result = 6;
|
|
|
- string str = ex.StackTrace;
|
|
|
- //AddMessage_Station(stationNameStr, LogType.Error, $"PLC上传进站数据MES报错!错误信息:" + ex.Message.ToString() + ";异常位置:" + str.Substring(str.LastIndexOf("\\") + 1, str.Length - str.LastIndexOf("\\") - 1));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
//private void CollectAndProcessDataLeft(string sn, string direction, string ip, string port, int connectTimeOut, int sendDataTimeOut)
|
|
|
//{
|
|
|
// Stopwatch stopwatch = new Stopwatch();
|
|
@@ -2108,7 +2100,7 @@ namespace MainForm
|
|
|
|
|
|
//出站接口
|
|
|
int 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, "", "", "", null);
|
|
|
|
|
|
byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
|
|
|
|
|
@@ -2403,7 +2395,7 @@ namespace MainForm
|
|
|
|
|
|
|
|
|
int result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem
|
|
|
- , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, PartBarcode);
|
|
|
+ , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, PartBarcode, "", "", null);
|
|
|
|
|
|
byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
|
|
|
|
|
@@ -2790,7 +2782,7 @@ namespace MainForm
|
|
|
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, "", "", "", null);
|
|
|
}
|
|
|
|
|
|
byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
|
|
@@ -3073,6 +3065,142 @@ namespace MainForm
|
|
|
sn = strProductBarcode;
|
|
|
AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn}");
|
|
|
|
|
|
+ //图片上传,这个地方之后可以放到一个方法里,uuid先 生成传进去就好
|
|
|
+ string path = GlobalContext.UpFilePath;
|
|
|
+ string leftPath = path + "\\Left";
|
|
|
+ string rightPath = path + "\\Right";
|
|
|
+ string toPath = "D:\\MESFile\\ImageLog"; //这个参数之后写GlobalContext和那些log的地址参数放一起,全局搜WorkLogDir可以找到
|
|
|
+ DateTime now = DateTime.Now;
|
|
|
+ //复制图片的地址
|
|
|
+ string fullToPath = Path.Combine(
|
|
|
+ toPath,
|
|
|
+ $"{now:yyyy-MM-dd}", // 年月日
|
|
|
+ $"{sn}_{now:HHmmss}" // SN 加上时间(小时分钟秒)
|
|
|
+ );
|
|
|
+ string sql = "";
|
|
|
+ string fileName = string.Empty;
|
|
|
+ string bucket = string.Empty;
|
|
|
+ Guid guid;
|
|
|
+
|
|
|
+ // 创建一个字典,这个字段之后作为参数传给出站接口
|
|
|
+ Dictionary<Guid, string> uuidDictionary = new Dictionary<Guid, string>();
|
|
|
+ // 获取所有图片文件
|
|
|
+ List<string> imageFiles_L = GetAllImageFiles(leftPath);
|
|
|
+ List<string> imageFiles_R = GetAllImageFiles(rightPath);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ foreach (string imageFile in imageFiles_L)
|
|
|
+ {
|
|
|
+ guid = Guid.NewGuid();
|
|
|
+ uuidDictionary[guid] = "";
|
|
|
+ fileName = Path.GetFileName(imageFile);
|
|
|
+ sql = string.Format("INSERT INTO [dbo].[DataFiles](stationCode,stationName,CarrierBarcode,ProductBarcode,bucket,fileName,fileContext,uuid,fileUrl,status,submitTime,createTime) " +
|
|
|
+ "VALUES('{0}','{1}','{2}' ,'{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')"
|
|
|
+ , stationCode
|
|
|
+ , stationName
|
|
|
+ , stPLC_MesData.BarcodeSet.strCarrierBarcode
|
|
|
+ , stPLC_MesData.BarcodeSet.strProductBarcode
|
|
|
+ , "/mesCommToPC/pic/left"
|
|
|
+ , fileName
|
|
|
+ , ""
|
|
|
+ , guid.ToString()
|
|
|
+ , ""
|
|
|
+ , 0
|
|
|
+ , ""
|
|
|
+ , DateTime.Now
|
|
|
+ );
|
|
|
+ string ret = SQLHelper_New.ExecuteNonQuery(sql, null);
|
|
|
+
|
|
|
+
|
|
|
+ FileUpload_X5 fileUpload_X5 = new FileUpload_X5();
|
|
|
+ //这个字段现在随便写写,有几个参数不确认拿什么值
|
|
|
+ bucket = "IMAGE/IMAGE/N3/debug/online/PASS/M0002PA-0001/P320N000006B/382f55e9-c2bb";
|
|
|
+ fileUpload_X5.bucket = bucket;
|
|
|
+ fileUpload_X5.name = imageFile;
|
|
|
+ fileUpload_X5.md5 = "";
|
|
|
+ fileUpload_X5.uploadCloud = true;
|
|
|
+ fileUpload_X5.informMqtt = true;
|
|
|
+
|
|
|
+ //这边有的值不确定,写了的值也再检查下
|
|
|
+ FileMqttPayload fileMqttPayload = new FileMqttPayload();
|
|
|
+ fileMqttPayload.factory = GlobalContext.Factory_Code; ;
|
|
|
+ fileMqttPayload.project_name = "";
|
|
|
+ fileMqttPayload.product_mode = "";
|
|
|
+ fileMqttPayload.line_no = "";
|
|
|
+ fileMqttPayload.work_station_no = "";
|
|
|
+ fileMqttPayload.equipment_no = MachineId;
|
|
|
+ fileMqttPayload.station_no = StationId;
|
|
|
+ fileMqttPayload.file_id = guid.ToString();
|
|
|
+ fileMqttPayload.file_name = fileName;
|
|
|
+ fileMqttPayload.sn = sn;
|
|
|
+ fileMqttPayload.opt_time = "";
|
|
|
+ fileMqttPayload.file_type = "IMAGE";
|
|
|
+ fileMqttPayload.file_category = "IMAGE";
|
|
|
+ fileMqttPayload.tag = "";
|
|
|
+ fileMqttPayload.pass_station_id = "";
|
|
|
+
|
|
|
+ var fileresult = XiaomiMESHttp_UpLoadFile.FileUoladToMes(imageFile, fileUpload_X5, fileMqttPayload, toPath);
|
|
|
+
|
|
|
+ }
|
|
|
+ foreach (string imageFile in imageFiles_R)
|
|
|
+ {
|
|
|
+ guid = Guid.NewGuid();
|
|
|
+ uuidDictionary[guid] = "";
|
|
|
+ fileName = Path.GetFileName(imageFile);
|
|
|
+ sql = string.Format("INSERT INTO [dbo].[DataFiles](stationCode,stationName,CarrierBarcode,ProductBarcode,bucket,fileName,fileContext,uuid,fileUrl,status,submitTime,createTime) " +
|
|
|
+ "VALUES('{0}','{1}','{2}' ,'{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')"
|
|
|
+ , stationCode
|
|
|
+ , stationName
|
|
|
+ , stPLC_MesData.BarcodeSet.strCarrierBarcode
|
|
|
+ , stPLC_MesData.BarcodeSet.strProductBarcode
|
|
|
+ , "/mesCommToPC/pic/right"
|
|
|
+ , fileName
|
|
|
+ , ""
|
|
|
+ , ""
|
|
|
+ , ""
|
|
|
+ , 0
|
|
|
+ , ""
|
|
|
+ , DateTime.Now
|
|
|
+ );
|
|
|
+ string ret = SQLHelper_New.ExecuteNonQuery(sql, null);
|
|
|
+
|
|
|
+ FileUpload_X5 fileUpload_X5 = new FileUpload_X5();
|
|
|
+ //这个字段现在随便写写,有几个参数不确认拿什么值
|
|
|
+ bucket = "IMAGE/IMAGE/N3/debug/online/PASS/M0002PA-0001/P320N000006B/382f55e9-c2bb";
|
|
|
+ fileUpload_X5.bucket = bucket;
|
|
|
+ fileUpload_X5.name = imageFile;
|
|
|
+ fileUpload_X5.md5 = "";
|
|
|
+ fileUpload_X5.uploadCloud = true;
|
|
|
+ fileUpload_X5.informMqtt = true;
|
|
|
+
|
|
|
+ //这边有的值不确定,写了的值也再检查下
|
|
|
+ FileMqttPayload fileMqttPayload = new FileMqttPayload();
|
|
|
+ fileMqttPayload.factory = GlobalContext.Factory_Code; ;
|
|
|
+ fileMqttPayload.project_name = "";
|
|
|
+ fileMqttPayload.product_mode = "";
|
|
|
+ fileMqttPayload.line_no = "";
|
|
|
+ fileMqttPayload.work_station_no = "";
|
|
|
+ fileMqttPayload.equipment_no = MachineId;
|
|
|
+ fileMqttPayload.station_no = StationId;
|
|
|
+ fileMqttPayload.file_id = guid.ToString();
|
|
|
+ fileMqttPayload.file_name = fileName;
|
|
|
+ fileMqttPayload.sn = sn;
|
|
|
+ fileMqttPayload.opt_time = "";
|
|
|
+ fileMqttPayload.file_type = "IMAGE";
|
|
|
+ fileMqttPayload.file_category = "IMAGE";
|
|
|
+ fileMqttPayload.tag = "";
|
|
|
+ fileMqttPayload.pass_station_id = "";
|
|
|
+
|
|
|
+ var fileresult = XiaomiMESHttp_UpLoadFile.FileUoladToMes(imageFile, fileUpload_X5, fileMqttPayload, toPath);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ AddMessage_Station(stationName, LogType.Error, $"图片保存失败!载具码:{stPLC_MesData.BarcodeSet.strCarrierBarcode}产品码{stPLC_MesData.BarcodeSet.strProductBarcode}");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
List<TestItem> items = new List<TestItem>();
|
|
|
items.Add(new TestItem()
|
|
|
{
|
|
@@ -3088,7 +3216,7 @@ namespace MainForm
|
|
|
});
|
|
|
|
|
|
int 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, "", fileName,bucket, uuidDictionary);
|
|
|
|
|
|
byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
|
|
|
|
|
@@ -3377,7 +3505,7 @@ namespace MainForm
|
|
|
});
|
|
|
|
|
|
int result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem
|
|
|
- , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, PartBarcode);
|
|
|
+ , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, PartBarcode,"", "", null);
|
|
|
|
|
|
byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
|
|
|
|
|
@@ -3664,7 +3792,7 @@ namespace MainForm
|
|
|
});
|
|
|
|
|
|
int 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, "", "", "", null);
|
|
|
|
|
|
byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
|
|
|
|
|
@@ -4041,7 +4169,7 @@ namespace MainForm
|
|
|
if (direction == "Right")
|
|
|
{
|
|
|
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, "", "", "", null);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -4356,7 +4484,7 @@ namespace MainForm
|
|
|
});
|
|
|
|
|
|
int 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, "", "", "", null);
|
|
|
|
|
|
byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
|
|
|
|
|
@@ -4636,7 +4764,7 @@ namespace MainForm
|
|
|
});
|
|
|
|
|
|
int 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, "", "", "", null);
|
|
|
|
|
|
byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
|
|
|
|
|
@@ -5293,142 +5421,7 @@ namespace MainForm
|
|
|
AddMessage(LogType.Info, stationNameStr + "_上料进站校验;总用时" + stopwatch1.ElapsedMilliseconds + "ms;调用MES用时" + stopwatch2.ElapsedMilliseconds + "ms");
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// [S1] Tray盘上料装备(板测)- 出站接口
|
|
|
- /// </summary>
|
|
|
- /// <param name="plcNo"></param>
|
|
|
- /// <param name="stationCode"></param>
|
|
|
- /// <param name="stationName"></param>
|
|
|
- private void S1出站接口(int plcNo, string stationCode, string stationName)
|
|
|
- {
|
|
|
- Stopwatch stopwatch1 = new Stopwatch();
|
|
|
- Stopwatch stopwatch2 = new Stopwatch();
|
|
|
-
|
|
|
- string equipmentCode = GlobalContext.LineCode + "-" + stationCode; // 设备编号
|
|
|
- string stationNameStr = stationCode + stationName;
|
|
|
- string processItem = stationName; // 测试项目
|
|
|
- try
|
|
|
- {
|
|
|
- stopwatch1.Start();
|
|
|
-
|
|
|
- string workorder_code = GlobalContext.WorkOrderCode; // 工单号
|
|
|
- //string batch_num = GlobalContext.BatchNumber; // 批次号
|
|
|
- string mtltmrk = GlobalContext.Mtltmrk; // 产品型号
|
|
|
- //string plcDate_YMD = DateTime.Now.ToString("yyyyMMdd");
|
|
|
-
|
|
|
- string sn = (string)s1PLCData["a1ProductSN"]; // 产品SN(载具SN码)
|
|
|
- sn = sn.Replace("\0", "");
|
|
|
- string partNo1 = (string)s1PLCData["a1PartNo1"]; // 物料码1(穴位1)
|
|
|
- partNo1 = partNo1.Replace("\0", "");
|
|
|
- string partNo2 = (string)s1PLCData["a1PartNo2"]; // 物料码2(穴位2)
|
|
|
- partNo2 = partNo2.Replace("\0", "");
|
|
|
- int a1Result = (int)s1PLCData["a1Result"]; // 产品结果
|
|
|
- bool pass = a1Result == 1;
|
|
|
-
|
|
|
- stopwatch2.Start();
|
|
|
- // 产品1
|
|
|
- List<TestItem> items = new List<TestItem>();
|
|
|
- items.Add(new TestItem()
|
|
|
- {
|
|
|
- Parameter_name = "载具码",
|
|
|
- Parameter_value = sn,
|
|
|
- Parameter_unit = ""
|
|
|
- });
|
|
|
- items.Add(new TestItem()
|
|
|
- {
|
|
|
- Parameter_name = "载具穴号",
|
|
|
- Parameter_value = "1",
|
|
|
- Parameter_unit = ""
|
|
|
- });
|
|
|
- items.Add(new TestItem()
|
|
|
- {
|
|
|
- Parameter_name = "产品结果",
|
|
|
- Parameter_value = a1Result == 1 ? "OK" : "NG",
|
|
|
- Parameter_unit = ""
|
|
|
- });
|
|
|
- int result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem
|
|
|
- , workorder_code, mtltmrk, partNo1, pass, sn, "1");
|
|
|
-
|
|
|
- // 产品2
|
|
|
- items = new List<TestItem>();
|
|
|
- items.Add(new TestItem()
|
|
|
- {
|
|
|
- Parameter_name = "载具码",
|
|
|
- Parameter_value = sn,
|
|
|
- Parameter_unit = ""
|
|
|
- });
|
|
|
- items.Add(new TestItem()
|
|
|
- {
|
|
|
- Parameter_name = "载具穴号",
|
|
|
- Parameter_value = "2",
|
|
|
- Parameter_unit = ""
|
|
|
- });
|
|
|
- items.Add(new TestItem()
|
|
|
- {
|
|
|
- Parameter_name = "产品结果",
|
|
|
- Parameter_value = a1Result == 1 ? "OK" : "NG",
|
|
|
- Parameter_unit = ""
|
|
|
- });
|
|
|
- int result2 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem
|
|
|
- , workorder_code, mtltmrk, partNo2, pass, sn, "2");
|
|
|
-
|
|
|
- short result = 0;
|
|
|
- List<int> results = new List<int>() { result1, result2 };
|
|
|
- if (result1 == 1 && result2 == 1)
|
|
|
- result = 1;
|
|
|
- else if (results.Contains(3))
|
|
|
- result = 3;
|
|
|
- else if (results.Contains(2))
|
|
|
- result = 2;
|
|
|
- else if (results.Contains(4))
|
|
|
- result = 4;
|
|
|
- else
|
|
|
- result = 4;
|
|
|
- stopwatch2.Stop();
|
|
|
-
|
|
|
- #region 存储绑定数据到 边线MES系统中
|
|
|
- if (result == 1)
|
|
|
- {
|
|
|
- string data = string.Concat(partNo1, ".", partNo2);
|
|
|
- int resultMesR = XiaomiMES_RouteCommunication.SNBindData(sn, data);
|
|
|
- if (resultMesR != 0)
|
|
|
- {
|
|
|
- result = 4;
|
|
|
- AddMessage_Station(stationNameStr, LogType.Error, $"PLC{plcNo}_[{equipmentCode}]{processItem}过站失败!MES边线程序返回:{resultMesR}");
|
|
|
- }
|
|
|
- }
|
|
|
- #endregion 存储绑定数据到 边线MES系统中
|
|
|
-
|
|
|
- // MES_Flag 为MES报错
|
|
|
- // 上位机发送1代表OK;2代表上传客户MES失败;3代表上位机保存数据失败;4代表上位机报警;
|
|
|
- //Funs[plcNo].WriteMultipleRegisters<short>(2109, result); // 4代表上位机报警
|
|
|
- WriteToPLC_Flag writeToPLC_Flag = new WriteToPLC_Flag(); // MES_Flag
|
|
|
- writeToPLC_Flag.Name = "a1MES_FLAG";
|
|
|
- writeToPLC_Flag.Adress = 2109;
|
|
|
- writeToPLC_Flag.Value = result;
|
|
|
- SxPLCWriteData_Add(ref s1PLCWriteData, "a1MES_FLAG", writeToPLC_Flag);
|
|
|
-
|
|
|
- OnMessage(LogType.Debug, $"PLC{plcNo}_[{equipmentCode}]{processItem}-Write" + (result == 1 ? "成功!" : "失败!"));
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- stopwatch2.Restart();
|
|
|
- // MES_Flag 为4上位机报错
|
|
|
- //Funs[plcNo].WriteMultipleRegisters<short>(2109, (short)4); // 4代表上位机报警
|
|
|
- WriteToPLC_Flag writeToPLC_Flag = new WriteToPLC_Flag(); // MES_Flag
|
|
|
- writeToPLC_Flag.Name = "a1MES_FLAG";
|
|
|
- writeToPLC_Flag.Adress = 2109;
|
|
|
- writeToPLC_Flag.Value = (short)4;
|
|
|
- SxPLCWriteData_Add(ref s1PLCWriteData, "a1MES_FLAG", writeToPLC_Flag);
|
|
|
- stopwatch2.Stop();
|
|
|
-
|
|
|
- string str = ex.StackTrace;
|
|
|
- AddMessage_Station(stationNameStr, LogType.Error, $"PLC{plcNo}_[{equipmentCode}]{processItem}上传加工报错!错误信息:" + ex.Message.ToString() + ";异常位置:" + str.Substring(str.LastIndexOf("\\") + 1, str.Length - str.LastIndexOf("\\") - 1));
|
|
|
- }
|
|
|
-
|
|
|
- stopwatch1.Stop();
|
|
|
- AddMessage(LogType.Info, stationNameStr + "_出站接口;总用时" + stopwatch1.ElapsedMilliseconds + "ms;上传接口用时" + stopwatch2.ElapsedMilliseconds + "ms");
|
|
|
- }
|
|
|
+
|
|
|
//// 上传点检数据_ [S1] Tray盘上料装备(板测)
|
|
|
//private void DoOneCheckData_Tray盘上料装备(int plcNo, string stationCode, string stationName)
|
|
|
//{
|