Jelajahi Sumber

修改贴标机对接

callm 6 tahun lalu
induk
melakukan
e107aafac1

+ 1 - 25
UAS-出货标签管理(吉利通)/PublicMethod/BaseUtil.cs

@@ -35,31 +35,7 @@ namespace UAS_LabelMachine
             }
         }
 
-        public static char GetSplitChar(string Str)
-        {
-            char[] splitchar = new char[] { ',', '@', '#', '|', '&',' ','、' };
-            char[] arr = Str.ToCharArray();
-            char split = new char();
-            int Count = 0;
-            for (int i = 0; i < splitchar.Length; i++)
-            {
-                int Count1 = 0;
-                for (int j = 0; j < arr.Length; j++)
-                {
-                    if (arr[j] == splitchar[i])
-                    {
-                        Count1 = Count1 + 1;
-                    }
-                }
-                if (Count1 > Count)
-                {
-                    Count = Count1;
-                    split = splitchar[i];
-                }
-            }
-            return split;
-        }
-
+    
         public static string SysDisc1
         {
             get

+ 29 - 35
UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

@@ -221,15 +221,16 @@ namespace UAS_LabelMachine
                 switch (port.Tag)
                 {
                     case "PLC1":
-                        //返回的指令和设备执行的动作对应
-                        foreach (var item in instruct)
-                        {
-                            //接收到的数据和指令的对应则
-                            if (item.Value == msg)
-                            {
-
-                            }
-                        }
+                        MessageLog.AppendText(msg, Color.Blue);
+                        ////返回的指令和设备执行的动作对应
+                        //foreach (var item in instruct)
+                        //{
+                        //    //接收到的数据和指令的对应则
+                        //    if (item.Value == msg)
+                        //    {
+
+                        //    }
+                        //}
                         break;
                     case "PLC2":
                         break;
@@ -298,10 +299,6 @@ namespace UAS_LabelMachine
                 string sg_id = ScanGroup.Rows[i]["sg_id"].ToString();
                 reg = new Regex(sg_script);
                 Match matchs1 = reg.Match(msg);
-                //自动获取分隔符号,分割解析到的数据
-                char Splitor = BaseUtil.GetSplitChar(matchs1.Value.ToString());
-                string[] sgarr = sg_script.Split(Splitor);
-                string[] arr = matchs1.Value.Split(Splitor);
                 DataTable dt = BaseUtil.filterDataTable(ScanItem, "sg_id=" + sg_id);
                 if (matchs1.Success)
                 {
@@ -613,8 +610,15 @@ namespace UAS_LabelMachine
                     //直接验证两个值相等
                     if (Equal.Checked)
                     {
-                        if (msgArr[i] == LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString())
+                        string pibid = adh.getFieldDataByCondition("prodiobarcode", "min(pib_id)", "pib_inoutno='" + pi_inoutno.Text + "' and pd_custprodcode='" + msgArr[i] + "'").ToString();
+                        if (pibid != "")
                         {
+                            DataRow[] dr = LabelInfDataTable.Select("pib_id=" + pibid);
+                            if (dr.Length > 0)
+                            {
+                                dr[0]["pib_ifpick"] = -1;
+                            }
+                            adh.ExecuteSql("update prodiobarcode set pib_ifpick=-1 where pib_id=" + pibid, "update");
                             CheckItem.Remove("客户料号");
                             checkItemCount = checkItemCount + 1;
                         }
@@ -642,8 +646,15 @@ namespace UAS_LabelMachine
                         CheckItem.Add("唯一条码");
                         CheckItem.Add("原厂型号");
                     }
-                    if (msgArr[i] == LabelInf.Rows[CurrentRowIndex].Cells["pib_custbarcode"].Value.ToString())
+                    string pibid = adh.getFieldDataByCondition("prodiobarcode", "min(pib_id)", "pib_inoutno='" + pi_inoutno.Text + "' and pib_custbarcode='" + msgArr[i] + "'").ToString();
+                    if (pibid != "")
                     {
+                        DataRow[] dr = LabelInfDataTable.Select("pib_id=" + pibid);
+                        if (dr.Length > 0)
+                        {
+                            dr[0]["pib_ifpick"] = -1;
+                        }
+                        adh.ExecuteSql("update prodiobarcode set pib_ifpick=-1 where pib_id=" + pibid, "update");
                         CheckItem.Remove("唯一条码");
                         checkItemCount = checkItemCount + 1;
                     }
@@ -1430,6 +1441,7 @@ namespace UAS_LabelMachine
         int PageSize = 500;
         int DataSize = 0;
         int MaxPageSize = 0;
+        DataTable LabelInfDataTable;
         /// <summary>
         /// 自定义函数  加载明细行的数据,多处使用添加进函数
         /// </summary>
@@ -1445,7 +1457,7 @@ namespace UAS_LabelMachine
                 sql.Append(" and pib_pdno between " + DetailRange1.Value + " and " + DetailRange2.Value);
             }
             sql.Append(" order by rownum");
-            DataTable LabelInfDataTable = (DataTable)adh.ExecuteSql(sql.ToString(), "select");
+            LabelInfDataTable = (DataTable)adh.ExecuteSql(sql.ToString(), "select");
             if (LabelInfDataTable.Rows.Count == 0)
             {
                 //嵌套查询重置RowNum
@@ -1885,7 +1897,7 @@ namespace UAS_LabelMachine
                     PLC1.Open();
                 }
                 LogicHandler.SendDataToPLC(PLC1, PLCInstruct.DeviceStart);
-                MessageLog.AppendText("PLC启动成功", Color.Blue);
+                MessageLog.AppendText("PLC启动成功\n", Color.Blue);
             }
         }
 
@@ -1893,24 +1905,6 @@ namespace UAS_LabelMachine
         {
             LogicHandler.SendDataToPLC(PLC1, PLCInstruct.DeviceStop);
             MessageLog.AppendText("PLC暂停成功", Color.Blue);
-
-            Regex regex = new Regex(@"(P)(?<pn>[\s\S]*),(Q)(?<qty>\d+),(9D)(?<datecode>\d{4}),([\s\S]*),(?<lotno>[\s\S]*)$");
-            Match result = regex.Match("P1231231,Q12313,9D1111,1111,11111");
-
-            if (result.Success)
-            {
-                StringBuilder sb = new StringBuilder();
-                foreach (var groupName in regex.GetGroupNames())
-                {
-                    sb.AppendLine(String.Format("<{0}>{1}", groupName,
-                        result.Groups[regex.GroupNumberFromName(groupName)].Value));
-                }
-                Console.WriteLine(sb.ToString());
-            }
-            else
-            {
-                MessageBox.Show("匹配失败");
-            }
         }
 
         private void ButtonCollectPass_Click(object sender, EventArgs e)