Explorar o código

支持流水进制自定义

callm hai 1 ano
pai
achega
275ded6a15

+ 29 - 1
UAS_MES_YD/FunctionCode/Make/Make_FuselageLabelPrint.cs

@@ -117,10 +117,38 @@ namespace UAS_MES_NEW.Make
                 }
                 if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out oErrorMessage))
                 {
-                    //定义临时变量
                     string oStatus = "";
                     //调用公共方法CheckStepSNAndMacode判断工序是否正确
                     string status = "";
+                    dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei1='" + sncode.Text + "' order by ms_id desc", "select");
+                    if (dt.Rows.Count > 0)
+                    {
+                        sncode.Text = dt.Rows[0]["ms_sncode"].ToString();
+                    }
+                    else
+                    {
+                        dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei2='" + sncode.Text + "' order by ms_id desc", "select");
+                        if (dt.Rows.Count > 0)
+                        {
+                            sncode.Text = dt.Rows[0]["ms_sncode"].ToString();
+                        }
+                        else
+                        {
+                            dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei1='" + sncode.Text + "' order by mil_id desc", "select");
+                            if (dt.Rows.Count > 0)
+                            {
+                                sncode.Text = dt.Rows[0]["mil_sncode"].ToString();
+                            }
+                            else
+                            {
+                                dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei2='" + sncode.Text + "' order by mil_id desc", "select");
+                                if (dt.Rows.Count > 0)
+                                {
+                                    sncode.Text = dt.Rows[0]["mil_sncode"].ToString();
+                                }
+                            }
+                        }
+                    }
                     LogicHandler.GetMakeInfo(sncode.Text, out oMakeCode, out status, out oErrorMessage);
                     if (oMakeCode == "" || oMakeCode == null)
                         oMakeCode = ma_code.Text;

+ 7 - 5
UAS_MES_YD/FunctionCode/Query/Query_SN.cs

@@ -181,11 +181,11 @@ namespace UAS_MES_NEW.Query
             }
         }
 
-        public string BarcodeMethod1(string Prefix, string Suffix, int Index, int Length, int radix)
+        public string BarcodeMethod1(string Prefix, string Suffix, int Index, int Length, int radix, string char_out)
         {
             string str = Prefix;
             //如果是流水则需要在前面加0
-            string serialcode = BaseUtil.DToAny(custserialnum, radix);
+            string serialcode = BaseUtil.DToAny(custserialnum, radix, char_out);
             for (int j = serialcode.ToString().Length; j < Length; j++)
             {
                 serialcode = "0" + serialcode;
@@ -257,10 +257,10 @@ namespace UAS_MES_NEW.Query
                 MessageBox.Show("工单号" + ma_code.Text + "生产序列号超出工单数");
                 return;
             }
-            DataTable Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_type,nrd_radix,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_code='" + pr_exbarcode + "' order by nrd_detno", "select");
+            DataTable Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_type,nrd_radix,nrd_sql,nrd_length,nrd_content from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_code='" + pr_exbarcode + "' order by nrd_detno", "select");
             //如果没有则取公共规则
             if (Nr.Rows.Count == 0)
-                Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_radix,nrd_type,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode is null and nr_isdefault <> 0 order by nrd_detno", "select");
+                Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_radix,nrd_type,nrd_sql,nrd_length,nrd_content from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode is null and nr_isdefault <> 0 order by nrd_detno", "select");
             //用于过滤参数的正则表达式
             Regex match = new Regex("{\\w+}");
             //用于存放每一项的明细的数据
@@ -272,6 +272,7 @@ namespace UAS_MES_NEW.Query
             //存放键值对
             int Radix = 10;
             string PrefixFixed = "";
+            string char_out = "";
             for (int m = 0; m < Nr.Rows.Count; m++)
             {
                 switch (Nr.Rows[m]["nrd_type"].ToString())
@@ -322,6 +323,7 @@ namespace UAS_MES_NEW.Query
                         SerialNumIndex = m;
                         SerialNumLength = int.Parse(Nr.Rows[m]["nrd_length"].ToString());
                         Radix = int.Parse(Nr.Rows[m]["nrd_radix"].ToString());
+                        char_out = Nr.Rows[m]["nrd_content"].ToString();
                         break;
                     default:
                         break;
@@ -344,7 +346,7 @@ namespace UAS_MES_NEW.Query
             ArrayList<string> custbarcode = new ArrayList<string>();
             for (int i = 0; i < int.Parse(ma_count.Text); i++)
             {
-                string data = BarcodeMethod1(PrefixFixed, Suffix, SerialNumIndex, SerialNumLength, Radix);
+                string data = BarcodeMethod1(PrefixFixed, Suffix, SerialNumIndex, SerialNumLength, Radix, char_out);
                 if (!custbarcode.Contains(data))
                     custbarcode.Add(data);
             }

+ 51 - 4
UAS_MES_YD/PublicMethod/BaseUtil.cs

@@ -32,6 +32,51 @@ namespace UAS_MES_NEW.PublicMethod
     class BaseUtil
     {
 
+        public static string DToAny(double DB, int Type, string char_out)
+        {
+            string H = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+            long D;
+            double B;
+            string tempD = "", tempB = "";
+            for (int i = 0; i < char_out.Length; i++)
+            {
+                H = H.Replace(char_out[i].ToString(), "");
+            }
+            if (Type != H.Length && Type != 16 & Type != 10)
+            {
+                ShowError("字符长度截取错误,请检查进制和去除字符");
+                return "";
+            }
+            D = (long)DB;
+            B = DB - D;
+            if (D == 0)
+            {
+                tempD = "0";
+            }
+            while (D != 0)
+            {
+                tempD = H[(((int)D % Type))] + tempD;
+                D = D / Type;
+            }
+            for (int i = 0; i < 7; i++)
+            {
+                if (B == 0)
+                {
+                    break;
+                }
+                tempB += H[((int)(B * Type))];
+                B = B * Type - (int)(B * Type);
+            }
+            if (tempB == "")
+            {
+                return tempD;
+            }
+            else
+            {
+                return tempD + "." + tempB;
+            }
+        }
+
         /// <summary>
         ///  检测TCP连接是否存在还是已经中断
         /// </summary>
@@ -42,11 +87,12 @@ namespace UAS_MES_NEW.PublicMethod
             return !((c.Client.Poll(1000, SelectMode.SelectRead) && (c.Client.Available == 0)) || !c.Client.Connected);
         }
 
-        public static Control GetControl(Control ctl,string Name) {
+        public static Control GetControl(Control ctl, string Name)
+        {
             if (ctl.Name == Name)
                 return ctl;
             else
-               return GetControl(ctl.Parent, Name);
+                return GetControl(ctl.Parent, Name);
         }
 
         public static string DToAny(double DB, int Type)
@@ -92,7 +138,8 @@ namespace UAS_MES_NEW.PublicMethod
                     return tempD + "." + tempB;
                 }
             }
-            else {
+            else
+            {
                 D = (long)DB;
                 B = DB - D;
                 if (D == 0)
@@ -123,7 +170,7 @@ namespace UAS_MES_NEW.PublicMethod
                 }
             }
         }
-        
+
         public static string GetRandomChar(string str)
         {
             byte[] buffer = Guid.NewGuid().ToByteArray();