Browse Source

更新信息更新sninfo表

shim 8 years ago
parent
commit
35a492dbaf

+ 40 - 1
UAS-MES/FunctionCode/Make/Make_SeqProgramTransform.cs

@@ -56,6 +56,12 @@ namespace UAS_MES.Make
         string oMakecode = "";
         string oMsid = "";
         bool onlyPass = false;
+
+        StringBuilder insertSninfoFields;//存插入sninfo的字段
+
+        StringBuilder insertSninfoValues;//存插入sninfo的值
+
+        StringBuilder toSi;//存更新sninfo的值
         public Make_SeqProgramTransform()
         {
             InitializeComponent();
@@ -259,6 +265,9 @@ namespace UAS_MES.Make
                                 }
                                 //step+1
                                 step = 2;
+                                insertSninfoFields = new StringBuilder();
+                                insertSninfoValues = new StringBuilder();
+                                toSi = new StringBuilder();
                             }
                             else
                             {
@@ -397,6 +406,9 @@ namespace UAS_MES.Make
                     //通过校验,将包含IMEI的值拼接
                     imei.Append("'" + code.Text + "',");
                     s1.Append("MS_" + type + " = '" + code.Text + "',");
+                    insertSninfoFields.Append("si_" + type + ",");
+                    insertSninfoValues.Append("'"+code.Text+"',");
+                    toSi.Append("si_" + type + " = '" + code.Text + "',");
                     break;
                 case "BT":
                 case "MAC":
@@ -409,6 +421,9 @@ namespace UAS_MES.Make
                     }
                     //通过校验,将包含IMEI的值拼接
                     s1.Append("MS_" + type + " = '" + code.Text + "',");
+                    insertSninfoFields.Append("si_" + type + ",");
+                    insertSninfoValues.Append("'" + code.Text + "',");
+                    toSi.Append("si_" + type + " = '" + code.Text + "',");
                     break;
             }
             //满足规则,则采集
@@ -470,7 +485,8 @@ namespace UAS_MES.Make
                         LogicHandler.DoCommandLog(Tag.ToString(),User.UserCode,oMakecode,User.UserLineCode,User.UserSourceCode,"序列烧录转换","转换成功",TSN,"");
                         //完成该道工序 setFinish
                         LogicHandler.SetStepResult( ms_macode.Text, User.UserSourceCode, SN, "序列烧录转换", "序列烧录转换成功", User.UserCode, out errorMessage);
-
+                        //写入sninfo表
+                        insert2Sninfo(TSN);
                         //输出提示用户“>>序列号转换成功”,“>>关联采集成功”
                         //获取剩余数,刷新页面
                         sql.Clear();
@@ -728,5 +744,28 @@ namespace UAS_MES.Make
                 OperateResult.AppendText("<<请输入TSN号\n", Color.Black);
             }
         }
+        private void insert2Sninfo(string sn)
+        {
+            //查询是否有记录
+            string siid = dh.getFieldDataByCondition("sninfo", "max(si_id) si_id", "si_sn='" + sn + "' or si_sn in(select sn from makesnrelation where sn='" + sn + "' or beforesn = '" + sn + "' )").ToString();
+            //是否为空
+            if (siid == "")
+            {
+                //插入新的数据
+                sql.Clear();
+                sql.Append("insert into sninfo(si_id,si_sn," + insertSninfoFields.ToString().Substring(0, insertSninfoFields.ToString().Length - 1) + ") values ");
+                sql.Append("(sninfo_seq.nextval,'"+sn+"'," + insertSninfoValues.ToString().Substring(0, insertSninfoValues.ToString().Length - 1) + ")");
+                dh.ExecuteSql(sql.GetString(), "insert");
+            }
+            else
+            {
+                //更新sninfo
+                sql.Clear();
+                sql.Append("update sninfo set ");
+                sql.Append(toSi.ToString().Substring(0, toSi.ToString().Length - 1));
+                sql.Append(" where si_id='" + siid + "'");
+                dh.ExecuteSql(sql.GetString(), "update");
+            }
+        }
     }
 }

+ 42 - 2
UAS-MES/FunctionCode/Make/Make_UpdateCollectCode.cs

@@ -31,7 +31,13 @@ namespace UAS_MES.Make
 
         string ms_id = "";
 
-        StringBuilder sb;
+        StringBuilder sb;//存更新makeserial表的数据
+
+        StringBuilder toSi;//存储更新sninfo的数据
+
+        StringBuilder insertSninfoFields;
+
+        StringBuilder insertSninfoValues;
 
         string sncode = "";
         StringBuilder oldData;
@@ -129,8 +135,11 @@ namespace UAS_MES.Make
                     step = 1;
                     OperateResult.AppendText("<<请输入" + ((CheckBox)list[0]).Text + "\n", Color.Green, inputValue);
                     sb = new StringBuilder();
+                    toSi = new StringBuilder();//初始化以备更新sninfo表
                     oldData = new StringBuilder();
                     newData = new StringBuilder();
+                    insertSninfoFields = new StringBuilder();
+                    insertSninfoValues = new StringBuilder();
                 }
                 else
                 //采集的关联采集信息
@@ -173,6 +182,9 @@ namespace UAS_MES.Make
                                 }
                                 //通过校验
                                 sb.Append("ms_" + ((CheckBox)list[step - 1]).Text.Split('/')[0] + " = '" + inputValue.Text + "',");
+                                toSi.Append("si_" + ((CheckBox)list[step - 1]).Text.Split('/')[0] + " = '" + inputValue.Text + "',");
+                                insertSninfoFields.Append("si_" + ((CheckBox)list[step - 1]).Text.Split('/')[0] + ",");
+                                insertSninfoValues.Append("'"+inputValue.Text+"',");
                                 oldData.Append("ms_" + ((CheckBox)list[step - 1]).Text.Split('/')[0] + ":" + dt.Rows[0]["ms_" + ((CheckBox)list[step - 1]).Text.Split('/')[0]].ToString() + ",");
                                 newData.Append("ms_" + ((CheckBox)list[step - 1]).Text.Split('/')[0] + ":" + inputValue.Text + ",");
                             }
@@ -194,6 +206,9 @@ namespace UAS_MES.Make
                             }
                             //通过校验
                             sb.Append("ms_" + (((CheckBox)list[step - 1]).Text == "网标" ? "NETCODE" : ((CheckBox)list[step - 1]).Text) + " = '" + inputValue.Text + "',");
+                            toSi.Append("si_" + (((CheckBox)list[step - 1]).Text == "网标" ? "NETCODE" : ((CheckBox)list[step - 1]).Text) + " = '" + inputValue.Text + "',");
+                            insertSninfoFields.Append("si_" + (((CheckBox)list[step - 1]).Text == "网标" ? "NETCODE" : ((CheckBox)list[step - 1]).Text) + ",");
+                            insertSninfoValues.Append("'"+inputValue.Text+"',");
                             oldData.Append("ms_" + (((CheckBox)list[step - 1]).Text == "网标" ? "NETCODE" : ((CheckBox)list[step - 1]).Text) + ":" + dt.Rows[0]["ms_" + (((CheckBox)list[step - 1]).Text == "网标" ? "NETCODE" : ((CheckBox)list[step - 1]).Text)].ToString() + ",");
                             newData.Append("ms_" + (((CheckBox)list[step - 1]).Text == "网标" ? "NETCODE" : ((CheckBox)list[step - 1]).Text) + ":" + inputValue.Text + ",");
                             break;
@@ -209,8 +224,10 @@ namespace UAS_MES.Make
                         dh.ExecuteSql(sql.GetString(), "update");
                         //提示烧录成功
                         OperateResult.AppendText(">>烧录成功\n", Color.Green);
+                        //更新sninfo表
+                        insert2Sninfo(sncode);
                         //记录日志
-                        LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, dt.Rows[0]["ms_makecode"].ToString(), User.UserLineCode, User.UserSourceCode, "更新烧录", "原数据:" + oldData.ToString() + "新数据:" + newData.ToString(), sncode, "");
+                        LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, dt.Rows[0]["ms_makecode"].ToString(), User.UserLineCode, User.UserSourceCode, "更新烧录","新数据:" + newData.ToString(), sncode, "");
                         step = 0;
                         //清除规则
                         BaseUtil.CleanDataTableData(info);
@@ -284,5 +301,28 @@ namespace UAS_MES.Make
                 OperateResult.AppendText(">>请采集SN\n", Color.Black);
             }
         }
+        private void insert2Sninfo(string sn)
+        {
+            //查询是否有记录
+            string siid = dh.getFieldDataByCondition("sninfo", "max(si_id) si_id", "si_sn='"+sn+"' or si_sn in(select sn from makesnrelation where sn='"+sn+"' or beforesn = '"+sn+"' )").ToString();
+            //是否为空
+            if (siid == "")
+            {
+                //插入新的数据
+                sql.Clear();
+                sql.Append("insert into sninfo(si_id,si_sn,"+ insertSninfoFields.ToString().Substring(0, insertSninfoFields.ToString().Length - 1) + ") values ");
+                sql.Append("(sninfo_seq.nextval,'"+sn+"',"+ insertSninfoValues.ToString().Substring(0, insertSninfoValues.ToString().Length - 1) + ")");
+                dh.ExecuteSql(sql.GetString(),"insert");
+            }
+            else
+            {
+                //更新sninfo
+                sql.Clear();
+                sql.Append("update sninfo set ");
+                sql.Append(toSi.ToString().Substring(0, toSi.ToString().Length - 1));
+                sql.Append(" where si_id='" + siid + "'");
+                dh.ExecuteSql(sql.GetString(), "update");
+            }
+        }
     }
 }