Browse Source

睿兴元数据抓取项目提交

callm 2 weeks ago
parent
commit
7b6f10e78a

+ 47 - 6
FileWatcher/AutoAnalysisXml.Designer.cs

@@ -54,6 +54,9 @@
             this.sc_code_label = new System.Windows.Forms.Label();
             this.em_code = new System.Windows.Forms.TextBox();
             this.label5 = new System.Windows.Forms.Label();
+            this.button1 = new System.Windows.Forms.Button();
+            this.BackUpFolderPath = new System.Windows.Forms.TextBox();
+            this.bei = new System.Windows.Forms.Label();
             ((System.ComponentModel.ISupportInitialize)(this.XmlWatcher)).BeginInit();
             this.SuspendLayout();
             // 
@@ -241,7 +244,7 @@
             // 
             this.MAC.AutoSize = true;
             this.MAC.Checked = true;
-            this.MAC.Location = new System.Drawing.Point(216, 465);
+            this.MAC.Location = new System.Drawing.Point(210, 507);
             this.MAC.Name = "MAC";
             this.MAC.Size = new System.Drawing.Size(77, 28);
             this.MAC.TabIndex = 21;
@@ -252,7 +255,7 @@
             // SN
             // 
             this.SN.AutoSize = true;
-            this.SN.Location = new System.Drawing.Point(332, 465);
+            this.SN.Location = new System.Drawing.Point(326, 507);
             this.SN.Name = "SN";
             this.SN.Size = new System.Drawing.Size(65, 28);
             this.SN.TabIndex = 22;
@@ -266,7 +269,7 @@
             // 
             // sc_code
             // 
-            this.sc_code.Location = new System.Drawing.Point(218, 370);
+            this.sc_code.Location = new System.Drawing.Point(218, 426);
             this.sc_code.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.sc_code.Name = "sc_code";
             this.sc_code.Size = new System.Drawing.Size(158, 35);
@@ -276,7 +279,7 @@
             // 
             this.sc_code_label.AutoSize = true;
             this.sc_code_label.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.sc_code_label.Location = new System.Drawing.Point(48, 370);
+            this.sc_code_label.Location = new System.Drawing.Point(48, 426);
             this.sc_code_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.sc_code_label.Name = "sc_code_label";
             this.sc_code_label.Size = new System.Drawing.Size(133, 38);
@@ -285,7 +288,7 @@
             // 
             // em_code
             // 
-            this.em_code.Location = new System.Drawing.Point(594, 370);
+            this.em_code.Location = new System.Drawing.Point(594, 426);
             this.em_code.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.em_code.Name = "em_code";
             this.em_code.Size = new System.Drawing.Size(158, 35);
@@ -295,18 +298,53 @@
             // 
             this.label5.AutoSize = true;
             this.label5.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label5.Location = new System.Drawing.Point(424, 370);
+            this.label5.Location = new System.Drawing.Point(424, 426);
             this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label5.Name = "label5";
             this.label5.Size = new System.Drawing.Size(104, 38);
             this.label5.TabIndex = 25;
             this.label5.Text = "用户名";
             // 
+            // button1
+            // 
+            this.button1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.button1.Location = new System.Drawing.Point(686, 350);
+            this.button1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(156, 48);
+            this.button1.TabIndex = 32;
+            this.button1.Text = "选择文件夹";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // BackUpFolderPath
+            // 
+            this.BackUpFolderPath.Enabled = false;
+            this.BackUpFolderPath.Location = new System.Drawing.Point(218, 354);
+            this.BackUpFolderPath.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.BackUpFolderPath.Name = "BackUpFolderPath";
+            this.BackUpFolderPath.Size = new System.Drawing.Size(436, 35);
+            this.BackUpFolderPath.TabIndex = 31;
+            // 
+            // bei
+            // 
+            this.bei.AutoSize = true;
+            this.bei.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.bei.Location = new System.Drawing.Point(48, 354);
+            this.bei.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.bei.Name = "bei";
+            this.bei.Size = new System.Drawing.Size(162, 38);
+            this.bei.TabIndex = 30;
+            this.bei.Text = "备份文件夹";
+            // 
             // AutoAnalysisXml
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1443, 640);
+            this.Controls.Add(this.button1);
+            this.Controls.Add(this.BackUpFolderPath);
+            this.Controls.Add(this.bei);
             this.Controls.Add(this.em_code);
             this.Controls.Add(this.label5);
             this.Controls.Add(this.sc_code);
@@ -367,6 +405,9 @@
         private System.Windows.Forms.Label label5;
         private System.Windows.Forms.TextBox sc_code;
         private System.Windows.Forms.Label sc_code_label;
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.TextBox BackUpFolderPath;
+        private System.Windows.Forms.Label bei;
     }
 }
 

+ 82 - 96
FileWatcher/AutoAnalysisXml.cs

@@ -15,7 +15,7 @@ namespace FileWatcher
     public partial class AutoAnalysisXml : Form
     {
 
-        DataHelper dh;
+        DataHelper dh = new DataHelper();
 
         DataTable dt;
 
@@ -139,21 +139,21 @@ namespace FileWatcher
                     return;
                 }
             }
-            for (int i = 0; i < DB.Rows.Count; i++)
-            {
-                if (Master.Text == DB.Rows[i]["ma_user"].ToString())
-                {
-                    DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=HUAG;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=113.98.196.181)(PORT=1520)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
-                    dh = new DataHelper();
-                    LogicHandler.dh = new DataHelper();
-                }
-            }
+            //for (int i = 0; i < DB.Rows.Count; i++)
+            //{
+            //    if (Master.Text == DB.Rows[i]["ma_user"].ToString())
+            //    {
+            //        DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=HUAG;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=113.98.196.181)(PORT=1520)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+            //        dh = new DataHelper();
+            //        LogicHandler.dh = new DataHelper();
+            //    }
+            //}
             //存在工单必须是已下放状态
-            if ((!dh.CheckExist("make", "ma_statuscode='STARTED' and ma_code='" + ma_code.Text + "'") || ma_code.Text == "") && Device.Text == "AOI设备")
-            {
-                OperateResult.AppendText("工单不存在或者未下放\n");
-                return;
-            }
+            //if ((!dh.CheckExist("make", "ma_statuscode='STARTED' and ma_code='" + ma_code.Text + "'") || ma_code.Text == "") && Device.Text == "AOI设备")
+            //{
+            //    OperateResult.AppendText("工单不存在或者未下放\n");
+            //    return;
+            //}
             if (sc_code.Text == "" || em_code.Text == "")
             {
                 OperateResult.AppendText("用户名和岗位资源不能为空\n");
@@ -310,116 +310,97 @@ namespace FileWatcher
                         {
                             string Result = "";
                             string makecode = ma_code.Text;
-                            string oErrMessage = "";
-                            string oMSID = "";
-                            string ms_sncode = dh.getFieldDataByCondition("makeserial", "ms_sncode", "substr(ms_sncode,0,12)='" + SN + "' order by ms_id").ToString();
-                            isource = sc_code.Text;
-                            iusercode = em_code.Text;
-                            DataTable dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode,st_badgroupcode from source left join step on sc_stepcode=st_code where sc_code='" + isource + "'", "select");
-                            if (dt.Rows.Count > 0)
+
+                            string ms_sncode = dh.getFieldDataByCondition("steppassed", "sp_sncode", "substr(sp_sncode,0,12)='" + SN + "' order by sp_id").ToString();
+                            if (ms_sncode == "")
                             {
-                                ilinecode = dt.Rows[0]["sc_linecode"].ToString();
-                                istepcode = dt.Rows[0]["sc_stepcode"].ToString();
-                                ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
+                                OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
                             }
-                            if (LogicHandler.CheckStepSNAndMacode("", isource, ms_sncode, iusercode, out makecode, out oMSID, out oErrMessage))
+                            else
                             {
+                                isource = sc_code.Text;
+                                iusercode = em_code.Text;
+                                DataTable dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode,st_badgroupcode from source left join step on sc_stepcode=st_code where sc_code='" + isource + "'", "select");
+                                if (dt.Rows.Count > 0)
+                                {
+                                    ilinecode = dt.Rows[0]["sc_linecode"].ToString();
+                                    istepcode = dt.Rows[0]["sc_stepcode"].ToString();
+                                    ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
+                                }
                                 ma_code.Text = makecode;
-                                if (LogicHandler.SetStepResult(makecode, isource, ms_sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
+                                try
                                 {
-                                    try
+                                    string ftppath = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
+                                    ftp.UpLoadFile(folderpath, SN + ".txt", ftppath, "");
+                                    int num = int.Parse(dh.ExecuteSql("insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class)select STEPTESTDETAIL_seq.nextval,ms_sncode,ms_makecode,sysdate,'http://113.98.196.181:8099/ftp" + ftppath + SN + ".txt" + "' from makeserial where substr(ms_sncode,0,12)='" + SN + "'", "insert").ToString());
+                                    if (num > 0)
                                     {
-                                        string ftppath = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
-                                        ftp.UpLoadFile(folderpath, SN + ".txt", ftppath, "");
-                                        int num = int.Parse(dh.ExecuteSql("insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class)select STEPTESTDETAIL_seq.nextval,ms_sncode,ms_makecode,sysdate,'http://113.98.196.181:8099/ftp" + ftppath + SN + ".txt" + "' from makeserial where substr(ms_sncode,0,12)='" + SN + "'", "insert").ToString());
-                                        if (num > 0)
-                                        {
-                                            OperateResult.AppendText("序列号:" + SN + "上传成功\n");
-                                            SafeDeleteFile(FileName);
-                                        }
-                                        else
-                                        {
-                                            OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
-                                            MessageBox.Show("序列号: " + ms_sncode + "前工段未扫描", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
-                                        }
+                                        OperateResult.AppendText("序列号:" + SN + "上传成功\n");
+                                        if (BackUpFolderPath.Text != "") 
+                                        File.Move(filename, BackUpFolderPath.Text);
+                                        //SafeDeleteFile(FileName);
                                     }
-                                    catch (Exception ex)
+                                    else
                                     {
-                                        Console.WriteLine(ex.Message);
+                                        OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
+                                        MessageBox.Show("序列号: " + ms_sncode + "前工段未扫描", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                                     }
                                 }
-                                else
+                                catch (Exception ex)
                                 {
-                                    OperateResult.AppendText(oErrMessage + "\n");
-                                    tipform.startthread(oErrMessage, Result);
-
+                                    Console.WriteLine(ex.Message);
                                 }
                                 tipform.startthread("序列号 " + ms_sncode + "通过检测", Result);
                             }
-                            else
-                            {
-                                OperateResult.AppendText(oErrMessage + "\n");
-                                tipform.startthread(oErrMessage, Result);
-                            }
                         }
                         else
                         {
                             string Result = "";
                             string makecode = ma_code.Text;
-                            string oErrMessage = "";
-                            string oMSID = "";
-                            string ms_sncode = dh.getFieldDataByCondition("makeserial", "ms_sncode", "ms_sncode='" + SN + "' order by ms_id").ToString();
+                            string ms_sncode = dh.getFieldDataByCondition("steppassed", "sp_sncode", "sp_sncode='" + SN + "' order by sp_id").ToString();
                             isource = sc_code.Text;
                             iusercode = em_code.Text;
-                            DataTable dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode,st_badgroupcode from source left join step on sc_stepcode=st_code where sc_code='" + isource + "'", "select");
-                            if (dt.Rows.Count > 0)
+                            if (ms_sncode == "")
                             {
-                                ilinecode = dt.Rows[0]["sc_linecode"].ToString();
-                                istepcode = dt.Rows[0]["sc_stepcode"].ToString();
-                                ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
+                                OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
                             }
-                            if (LogicHandler.CheckStepSNAndMacode("", isource, ms_sncode, iusercode, out makecode, out oMSID, out oErrMessage))
+                            else
                             {
+                                DataTable dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode,st_badgroupcode from source left join step on sc_stepcode=st_code where sc_code='" + isource + "'", "select");
+                                if (dt.Rows.Count > 0)
+                                {
+                                    ilinecode = dt.Rows[0]["sc_linecode"].ToString();
+                                    istepcode = dt.Rows[0]["sc_stepcode"].ToString();
+                                    ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
+                                }
                                 ma_code.Text = makecode;
-                                if (LogicHandler.SetStepResult(makecode, isource, ms_sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
+                                try
                                 {
-                                    try
+                                    string ftppath = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
+                                    OperateResult.AppendText(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff") + "\n");
+                                    ftp.UpLoadFile(folderpath, SN + ".txt", ftppath, "");
+                                    OperateResult.AppendText(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff") + "\n");
+                                    int num = int.Parse(dh.ExecuteSql("insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class)select STEPTESTDETAIL_seq.nextval,ms_sncode,ms_makecode,sysdate,'http://113.98.196.181:8099/ftp" + ftppath + SN + ".txt" + "' from makeserial where ms_sncode='" + SN + "'", "insert").ToString());
+                                    if (num > 0)
                                     {
-                                        string ftppath = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
-                                        OperateResult.AppendText(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff")+"\n");
-                                        ftp.UpLoadFile(folderpath, SN + ".txt", ftppath, "");
-                                        OperateResult.AppendText(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff") + "\n");
-                                        int num = int.Parse(dh.ExecuteSql("insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class)select STEPTESTDETAIL_seq.nextval,ms_sncode,ms_makecode,sysdate,'http://113.98.196.181:8099/ftp" + ftppath + SN + ".txt" + "' from makeserial where ms_sncode='" + SN + "'", "insert").ToString());
-                                        if (num > 0)
-                                        {
-                                            OperateResult.AppendText("序列号:" + SN + "上传成功\n");
-                                            SafeDeleteFile(FileName);
-                                        }
-                                        else
-                                        {
-                                            OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
-                                            MessageBox.Show("序列号: " + ms_sncode + "前工段未扫描", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
-                                        }
+                                        OperateResult.AppendText("序列号:" + SN + "上传成功\n");
+                                        if (BackUpFolderPath.Text != "")
+                                            File.Move(filename, BackUpFolderPath.Text);
+                                        //SafeDeleteFile(FileName);
                                     }
-                                    catch (Exception ex)
+                                    else
                                     {
-                                        Console.WriteLine(ex.Message);
+                                        OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
+                                        MessageBox.Show("序列号: " + ms_sncode + "前工段未扫描", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                                     }
-
                                 }
-                                else
+                                catch (Exception ex)
                                 {
-                                    OperateResult.AppendText(oErrMessage + "\n");
-                                    tipform.startthread(oErrMessage, Result);
-
+                                    Console.WriteLine(ex.Message);
                                 }
+
                                 tipform.startthread("序列号 " + ms_sncode + "通过检测", Result);
                             }
-                            else
-                            {
-                                OperateResult.AppendText(oErrMessage + "\n");
-                                tipform.startthread(oErrMessage, Result);
-                            }
                         }
                         OperateResult.AppendText("解析成功:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n" + FileName + "\n");
                     }
@@ -519,13 +500,7 @@ namespace FileWatcher
 
         private void ChooseBackUpFolder_Click(object sender, EventArgs e)
         {
-            FolderBrowserDialog folder = new FolderBrowserDialog();
-            folder.Description = "选择备份文件夹";
-            DialogResult result = folder.ShowDialog();
-            if (result == DialogResult.OK)
-            {
 
-            }
         }
 
         private void Form1_FormClosing(object sender, FormClosingEventArgs e)
@@ -587,5 +562,16 @@ namespace FileWatcher
                 TxtHandleProcess(Xml);
             }
         }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            FolderBrowserDialog folder = new FolderBrowserDialog();
+            folder.Description = "选择备份文件夹";
+            DialogResult result = folder.ShowDialog();
+            if (result == DialogResult.OK)
+            {
+                BackUpFolderPath.Text = folder.SelectedPath;
+            }
+        }
     }
 }

+ 2 - 2
FileWatcher/DataHelper.cs

@@ -41,9 +41,9 @@ namespace FileWatcher
         ////用户选择的数据库的连接字符串
         //public static string DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=172.22.100.2)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
 
-        //private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=39.165.240.186)(PORT=61521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        //private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=GHKJ;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=113.98.196.181)(PORT=1520)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
         ////用户选择的数据库的连接字符串
-        //public static string DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=39.165.240.186)(PORT=61521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        //public static string DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=GHKJ;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=113.98.196.181)(PORT=1520)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
 
 
         public static OracleConnection connection = null;

+ 1 - 1
FileWatcher/Program.cs

@@ -48,7 +48,7 @@ namespace FileWatcher
                 {
                     //Application.Run(new UploadMakePlan());
                     //Application.Run(new AutoAnalysisXmlByStep());
-                    Application.Run(new AutoMakeQTY());
+                    Application.Run(new AutoSMTRXY());
                 }
                 else
                 {