Преглед на файлове

50站PCB进出站修改

WIN-GH9CEESPLTB\Administrator преди 1 месец
родител
ревизия
7a6f11433d
променени са 1 файла, в които са добавени 113 реда и са изтрити 84 реда
  1. 113 84
      MainForm/FaForm/Form_Home.cs

+ 113 - 84
MainForm/FaForm/Form_Home.cs

@@ -2167,7 +2167,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(CarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
                 sn = strProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn}");
@@ -2379,7 +2379,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
                 //这个地方之后PLC可能会返回SN码,到时用返回的和数据库中的比较下对错,结果faalse怎么办现在不知道
                 //if (sn != strProductBarcode)
@@ -2455,7 +2455,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(CarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
                 sn = strProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn}");
@@ -2769,7 +2769,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
                 sn = strProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{strProductBarcode};产品码:{sn}");
@@ -2849,7 +2849,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(CarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
                 sn = strProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn}");
@@ -3082,7 +3082,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
 
                 sn = strProductBarcode;
@@ -3153,7 +3153,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(CarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
                 sn = strProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn}");
@@ -3269,22 +3269,23 @@ namespace MainForm
                         else
                         {
                             #region PCB出站
-                            //stPLC_MesData.BarcodeSet.strPCBBarcode = "A1507V000239";
-                            pcbBarcode = stPLC_MesData.BarcodeSet.strPCBBarcode;
-                            if (pcbBarcode!= pcbBarcodeOld)
-                            {
-                                isPCBStation = true;
-                            }
-                            if (isPCBStation)
-                            {
-                                var r = S5_PCB进出站(stPLC_MesData, plcNo, stationNameStr, tagBaseName, tagMesCommName);
-                                if (r > 0)
-                                {
-                                    isPCBStation = false;
-                                    pcbBarcodeOld = pcbBarcode;
-                                }
-                            }
-                            //stPLC_MesData.BarcodeSet.strCarrierBarcode = "A123456";
+                            stPLC_MesData.BarcodeSet.strPCBBarcode = "A1507V000239";
+                            stPLC_MesData.BarcodeSet.strCarrierBarcode = "A123456";
+
+                            //pcbBarcode = stPLC_MesData.BarcodeSet.strPCBBarcode;
+                            //if (pcbBarcode!= pcbBarcodeOld)
+                            //{
+                            //    isPCBStation = true;
+                            //}
+                            //if (isPCBStation)
+                            //{
+                            //    var r = S5_PCB进出站(stPLC_MesData, plcNo, stationNameStr, tagBaseName, tagMesCommName);
+                            //    if (r > 0)
+                            //    {
+                            //        isPCBStation = false;
+                            //        pcbBarcodeOld = pcbBarcode;
+                            //    }
+                            //}
                             #endregion
                         }
                         #endregion 一次性读取所有数据
@@ -3299,9 +3300,14 @@ namespace MainForm
                                 {
                                     if (!ProgressState)
                                     {
-                                        ProgressState = true;
-                                        isPCBStation = true;//开启PCB进出站
-                                        Task.Run(() => S5进站(plcNo, stationNameStr, stPLC_MesData, tagBaseName + "." + tagMesCommName, tagBaseName + "." + tagBarsetName, out ProgressState));
+                                        string PCBBarcode = stPLC_MesData.BarcodeSet.strPCBBarcode.Replace("\r", "");
+                                        stPLC_MesData.BarcodeSet.strPCBBarcode = PCBBarcode;//特殊字符处理
+                                        if (PCBBarcode != "ERROR" && !string.IsNullOrEmpty(PCBBarcode))
+                                        {
+                                            ProgressState = true;
+                                            Task.Run(() => S5进站(plcNo, stationNameStr, stPLC_MesData, tagBaseName + "." + tagMesCommName, tagBaseName + "." + tagBarsetName, out ProgressState));
+
+                                        }
                                     }
                                 }
                             }
@@ -3324,7 +3330,8 @@ namespace MainForm
                                     if (!ProgressState)
                                     {
                                         ProgressState = true;
-                                        Task.Run(() => S5出站(plcNo, stationNameStr, stPLC_MesData, tagBaseName + "." + tagMesCommName, stationCode, stationName, out ProgressState));
+                                        Task.Run(() => S5出站(plcNo, stationNameStr, stPLC_MesData, tagBaseName + "." + tagMesCommName
+                                                                , stationCode, stationName, out ProgressState));
                                         stPLC_MesData.mesCommFrmPLC.cmd = 0;
                                     }
                                 }
@@ -3378,31 +3385,34 @@ namespace MainForm
             {
                 stopwatch1.Start();
                 AddMessage(LogType.Info, stationNameStr + "_进站开始");
-                string sn = (string)stPLC_MesData.BarcodeSet.strProductBarcode;  // 产品SN(物料码)
+                //string sn = (string)stPLC_MesData.BarcodeSet.strProductBarcode;  // 产品SN(物料码)
                 //sn = sn.Substring(sn.Length - 11, 4) + sn.Substring(sn.Length - 5, 5);
 
                 string MachineId = GlobalContext.S5_MachineId;  // 装备ID(可配置)
                 string StationId = GlobalContext.S5_StationId;  // 工位ID(可配置)
-                string strCarrierBarcode = (string)stPLC_MesData.BarcodeSet.strCarrierBarcode;  // 载具条码
+                string strPCBBarcode = (string)stPLC_MesData.BarcodeSet.strPCBBarcode;
+                AddMessage(LogType.Info, $"ADD板编码(PCB码):{strPCBBarcode}");
+
+                //string strCarrierBarcode = (string)stPLC_MesData.BarcodeSet.strCarrierBarcode;  // 载具条码
                 //载具码验证产品码                                                                              //载具码验证产品码 
-                string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
+                //string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
 
-                if (string.IsNullOrEmpty(strProductBarcode))
-                {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
-                }
+                //if (string.IsNullOrEmpty(strProductBarcode))
+                //{
+                //    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
+                //}
 
-                sn = strProductBarcode;
-                AddMessage(LogType.Info, $"载具码:{strCarrierBarcode};产品码:{sn}");
+                //sn = strProductBarcode;
+                //AddMessage(LogType.Info, $"载具码:{strCarrierBarcode};产品码:{sn}");
 
                 // 产品SN(物料码)校验
                 List<TestItem> item = new List<TestItem>();
                 stopwatch2.Start();
-                int result = SaveStationInData(stationNameStr, GlobalContext.WorkOrderCode, GlobalContext.Mtltmrk, sn, item, MachineId, StationId);
+                int result = SaveStationInData(stationNameStr, GlobalContext.WorkOrderCode, GlobalContext.Mtltmrk, strPCBBarcode, item, MachineId, StationId);
                 stopwatch2.Stop();
 
                 //指令执行结果 1:OK   110:失败
-                byte mesResultFrmWeb = (byte)(result == 1 ? 1 : 110);
+                byte mesResultFrmWeb = (byte)(result == 1 ? 2 : 120);
 
                 //进站结果写入PLC
                 CommandFromPLC resultToPlC = new CommandFromPLC();
@@ -3438,7 +3448,6 @@ namespace MainForm
             Stopwatch stopwatch1 = new Stopwatch();
             Stopwatch stopwatch2 = new Stopwatch();
 
-
             try
             {
                 stopwatch1.Start();
@@ -3459,12 +3468,20 @@ namespace MainForm
                 string StationId = GlobalContext.S5_StationId;  // ⼯位ID(可配置)  // ZS
                 int a1Result = (int)stPLC_MesData.iotData.testStatus;          // 产品结果
                 bool pass = a1Result == 1;
+                CommandFromPLC resultToPlC = new CommandFromPLC();
 
                 //根据载具码获取产品码
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(CarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
+                    ProgressState=false;
+                    //写入PLC
+                    resultToPlC.cmd = 0;
+                    resultToPlC.cmdParam = 0; //指令参数
+                    resultToPlC.cmdResult = 110;
+                    WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, resultToPlC);
+                    return;
                 }
                 sn = strProductBarcode;
                 //数据库绑定载具和PCB
@@ -3472,7 +3489,9 @@ namespace MainForm
                 message = SQLHelper.PCBCarrierBind(CarrierBarcode, pcbBarcode);
                 if (message.result == false)
                 {
-                    AddMessage(LogType.Error, stationNameStr + "_载具码与产品码绑定失败,错误:" + message.text);
+                    AddMessage(LogType.Error, stationNameStr + "_PCB码数据库绑定失败,错误:" + message.text);
+                    ProgressState = true;//防止循环报错
+                    return;
                 }
                 AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn};PCB码:{pcbBarcode}");
 
@@ -3489,40 +3508,50 @@ namespace MainForm
                     Parameter_value = sn,
                     Parameter_unit = ""
                 });
+                items.Add(new TestItem()
+                {
+                    Parameter_name = "PCB码",
+                    Parameter_value = pcbBarcode,
+                    Parameter_unit = ""
+                });
                 string paramJson = JsonConvert.SerializeObject(stPLC_MesData.mesData);
-                int result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem
-   , workorder_code, batch_num, mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, PartBarcode, paramJson);
 
-                byte mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
+                int result1 = 0;
+                byte mesResultFrmWeb = 0;
+                if (stPLC_MesData.mesCommFrmPLC.cmdParam == 2) {
+                    result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem, workorder_code, batch_num
+                        , mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "1", MachineId, StationId, PartBarcode, paramJson);
+                }
+                else if (stPLC_MesData.mesCommFrmPLC.cmdParam == 1) {
+                    result1=PCBStationOutData(stPLC_MesData.BarcodeSet, stPLC_MesData.iotData);
+                }
+                mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);
 
-                stopwatch2.Start();
                 //进站结果写入PLC
-                CommandFromPLC resultToPlC = new CommandFromPLC();
                 resultToPlC.cmd = 0;
                 resultToPlC.cmdParam = 0; //指令参数
                 resultToPlC.cmdResult = mesResultFrmWeb;
                 WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, resultToPlC);
-                stopwatch2.Stop();
                 AddMessage(LogType.Info, stationNameStr + "_出站结束");
 
                 //保存PLC返回MES数据到本地
                 //ResponseMessage message = new ResponseMessage();
-                message = SQLHelper.InsertOp50Data(CarrierBarcode, sn, stPLC_MesData.mesData.nIsAddPCBAsmOK,
-                    stPLC_MesData.mesData.nHaveAddPCB, stPLC_MesData.mesData.fForceAddPCB, stPLC_MesData.mesData.nRemainCount, "");
-                if (message.result == false)
-                {
-                    AddMessage(LogType.Info, stationNameStr + "_保存加工数据到本地失败");
-                }
-                //保存部件码信息
-                if (!string.IsNullOrEmpty(PartBarcode))
-                {
-                    message = SQLHelper.InsertOp50Product(CarrierBarcode, sn, PartBarcode);
-                    if (message.result == false)
-                    {
-                        AddMessage(LogType.Info, stationNameStr + "_保存部件码信息失败");
-                    }
-                }
-                AddMessage(LogType.Info, stationNameStr + "_保存加工数据到本地成功");
+                //message = SQLHelper.InsertOp50Data(CarrierBarcode, sn, stPLC_MesData.mesData.nIsAddPCBAsmOK,
+                //    stPLC_MesData.mesData.nHaveAddPCB, stPLC_MesData.mesData.fForceAddPCB, stPLC_MesData.mesData.nRemainCount, "");
+                //if (message.result == false)
+                //{
+                //    AddMessage(LogType.Info, stationNameStr + "_保存加工数据到本地失败");
+                //}
+                ////保存部件码信息
+                //if (!string.IsNullOrEmpty(PartBarcode))
+                //{
+                //    message = SQLHelper.InsertOp50Product(CarrierBarcode, sn, PartBarcode);
+                //    if (message.result == false)
+                //    {
+                //        AddMessage(LogType.Info, stationNameStr + "_保存部件码信息失败");
+                //    }
+                //}
+                //AddMessage(LogType.Info, stationNameStr + "_保存加工数据到本地成功");
             }
             catch (Exception ex)
             {
@@ -3555,19 +3584,19 @@ namespace MainForm
 
                 if (GlobalContext.IsSendStationIn)
                 {
-                    #region 
-                    int res1 = PCBStationInData(stPLC_MesData.BarcodeSet, stPLC_MesData.iotData);
-                    if (res1 == 1)
-                    {
-                        resultToPlC.cmdResult = 2;//OK
-                        WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagMesCommName, 1, resultToPlC);
-                    }
-                    else
-                    {
-                        resultToPlC.cmdResult = 120;
-                        WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagMesCommName, 1, resultToPlC);
-                        return 2;
-                    }
+                    #region 
+                    //int res1 = PCBStationInData(stPLC_MesData.BarcodeSet, stPLC_MesData.iotData);
+                    //if (res1 == 1)
+                    //{
+                    //    resultToPlC.cmdResult = 2;//OK
+                    //    WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagMesCommName, 1, resultToPlC);
+                    //}
+                    //else
+                    //{
+                    //    resultToPlC.cmdResult = 120;
+                    //    WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagMesCommName, 1, resultToPlC);
+                    //    return 2;
+                    //}
                     #endregion
 
                     #region 出站
@@ -3743,7 +3772,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
 
                 sn = strProductBarcode;
@@ -3834,7 +3863,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(CarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
                 sn = strProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn}");
@@ -4106,7 +4135,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
                 sn = strProductBarcode;
                 atlasSn= strProductBarcode;
@@ -4210,7 +4239,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(CarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
                 sn = strProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn}");
@@ -4461,7 +4490,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
                 sn = strProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{strCarrierBarcode};产品码:{sn}");
@@ -4530,7 +4559,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(CarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
                 sn = strProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn}");
@@ -4740,7 +4769,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(strCarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
                 sn = strProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{strCarrierBarcode};产品码:{sn}");
@@ -4811,7 +4840,7 @@ namespace MainForm
                 string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(CarrierBarcode);
                 if (string.IsNullOrEmpty(strProductBarcode))
                 {
-                    AddMessage(LogType.Error, $"{stationNameStr}_未能查到已绑定的载具信息,无法进行载具绑定产品验证");
+                    AddMessage(LogType.Error, $"{stationNameStr}_数据库未查询到该载具绑定信息!");
                 }
                 sn = strProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn}");