Browse Source

箱号回退修改SQL,SMT报表上传

callm 1 year ago
parent
commit
b0227f497d

+ 74 - 47
UAS_MES_LGDZ/FunctionCode/Query/Query_SpecialReport.Designer.cs

@@ -30,31 +30,17 @@
         {
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Query_SpecialReport));
             this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
-            this.XYFilePath = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.label5 = new System.Windows.Forms.Label();
             this.ExportFileDialog = new System.Windows.Forms.FolderBrowserDialog();
-            this.XY = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.ImportExcel1 = new System.Windows.Forms.OpenFileDialog();
-            this.pr_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
             this.label1 = new System.Windows.Forms.Label();
+            this.Process = new System.Windows.Forms.Label();
+            this.pr_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
+            this.XY = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
+            this.XYFilePath = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.label2 = new System.Windows.Forms.Label();
             this.SuspendLayout();
             // 
-            // XYFilePath
-            // 
-            this.XYFilePath.AllPower = null;
-            this.XYFilePath.BackColor = System.Drawing.Color.White;
-            this.XYFilePath.ID = null;
-            this.XYFilePath.Location = new System.Drawing.Point(434, 149);
-            this.XYFilePath.Margin = new System.Windows.Forms.Padding(6);
-            this.XYFilePath.Name = "XYFilePath";
-            this.XYFilePath.Power = null;
-            this.XYFilePath.Size = new System.Drawing.Size(445, 35);
-            this.XYFilePath.Str = null;
-            this.XYFilePath.Str1 = null;
-            this.XYFilePath.Str2 = null;
-            this.XYFilePath.TabIndex = 12;
-            this.XYFilePath.TextChanged += new System.EventHandler(this.inoutno_TextChanged);
-            // 
             // label5
             // 
             this.label5.AutoSize = true;
@@ -66,29 +52,31 @@
             this.label5.TabIndex = 11;
             this.label5.Text = "原始坐标文件";
             // 
-            // XY
-            // 
-            this.XY.AllPower = null;
-            this.XY.BackColor = System.Drawing.Color.Transparent;
-            this.XY.DownImage = ((System.Drawing.Image)(resources.GetObject("XY.DownImage")));
-            this.XY.Image = null;
-            this.XY.IsShowBorder = true;
-            this.XY.Location = new System.Drawing.Point(434, 223);
-            this.XY.Margin = new System.Windows.Forms.Padding(6);
-            this.XY.MoveImage = ((System.Drawing.Image)(resources.GetObject("XY.MoveImage")));
-            this.XY.Name = "XY";
-            this.XY.NormalImage = ((System.Drawing.Image)(resources.GetObject("XY.NormalImage")));
-            this.XY.Power = null;
-            this.XY.Size = new System.Drawing.Size(177, 56);
-            this.XY.TabIndex = 187;
-            this.XY.Text = "导入原始坐标";
-            this.XY.UseVisualStyleBackColor = false;
-            this.XY.Click += new System.EventHandler(this.XY_Click);
-            // 
             // ImportExcel1
             // 
             this.ImportExcel1.FileName = "ImportExcel";
             // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(212, 74);
+            this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(146, 41);
+            this.label1.TabIndex = 240;
+            this.label1.Text = "产品编号";
+            // 
+            // Process
+            // 
+            this.Process.AutoSize = true;
+            this.Process.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Process.Location = new System.Drawing.Point(1028, 149);
+            this.Process.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.Process.Name = "Process";
+            this.Process.Size = new System.Drawing.Size(0, 41);
+            this.Process.TabIndex = 241;
+            // 
             // pr_code
             // 
             this.pr_code.AllPower = "ifall";
@@ -110,22 +98,59 @@
             this.pr_code.Tag = "";
             this.pr_code.TextBoxEnable = false;
             // 
-            // label1
+            // XY
             // 
-            this.label1.AutoSize = true;
-            this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label1.Location = new System.Drawing.Point(212, 74);
-            this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(146, 41);
-            this.label1.TabIndex = 240;
-            this.label1.Text = "产品编号";
+            this.XY.AllPower = null;
+            this.XY.BackColor = System.Drawing.Color.Transparent;
+            this.XY.DownImage = ((System.Drawing.Image)(resources.GetObject("XY.DownImage")));
+            this.XY.Image = null;
+            this.XY.IsShowBorder = true;
+            this.XY.Location = new System.Drawing.Point(434, 223);
+            this.XY.Margin = new System.Windows.Forms.Padding(6);
+            this.XY.MoveImage = ((System.Drawing.Image)(resources.GetObject("XY.MoveImage")));
+            this.XY.Name = "XY";
+            this.XY.NormalImage = ((System.Drawing.Image)(resources.GetObject("XY.NormalImage")));
+            this.XY.Power = null;
+            this.XY.Size = new System.Drawing.Size(177, 56);
+            this.XY.TabIndex = 187;
+            this.XY.Text = "导入原始坐标";
+            this.XY.UseVisualStyleBackColor = false;
+            this.XY.Click += new System.EventHandler(this.XY_Click);
+            // 
+            // XYFilePath
+            // 
+            this.XYFilePath.AllPower = null;
+            this.XYFilePath.BackColor = System.Drawing.Color.White;
+            this.XYFilePath.ID = null;
+            this.XYFilePath.Location = new System.Drawing.Point(434, 149);
+            this.XYFilePath.Margin = new System.Windows.Forms.Padding(6);
+            this.XYFilePath.Name = "XYFilePath";
+            this.XYFilePath.Power = null;
+            this.XYFilePath.Size = new System.Drawing.Size(445, 35);
+            this.XYFilePath.Str = null;
+            this.XYFilePath.Str1 = null;
+            this.XYFilePath.Str2 = null;
+            this.XYFilePath.TabIndex = 12;
+            this.XYFilePath.TextChanged += new System.EventHandler(this.inoutno_TextChanged);
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label2.Location = new System.Drawing.Point(891, 149);
+            this.label2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(82, 41);
+            this.label2.TabIndex = 242;
+            this.label2.Text = "进度";
             // 
             // Query_SpecialReport
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1494, 1075);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.Process);
             this.Controls.Add(this.label1);
             this.Controls.Add(this.pr_code);
             this.Controls.Add(this.XY);
@@ -151,5 +176,7 @@
         private System.Windows.Forms.OpenFileDialog ImportExcel1;
         private CustomControl.TextBoxWithIcon.SearchTextBox pr_code;
         private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label Process;
+        private System.Windows.Forms.Label label2;
     }
 }

+ 41 - 8
UAS_MES_LGDZ/FunctionCode/Query/Query_SpecialReport.cs

@@ -1,9 +1,11 @@
 using DevExpress.Printing.Core.PdfExport.Metafile;
+using DevExpress.XtraCharts.Native;
 using LabelManager2;
 using NPOI.HSSF.UserModel;
 using NPOI.SS.Formula.Functions;
 using NPOI.SS.UserModel;
 using System;
+using System.Collections.Generic;
 using System.Data;
 using System.IO;
 using System.Linq;
@@ -51,27 +53,58 @@ namespace UAS_MES_NEW.Query
         {
 
         }
-
+        DataTable importdata;
         private void XY_Click(object sender, EventArgs e)
         {
             ImportExcel1.Filter = "(*.xls)|*.xls";
             DialogResult result;
             result = ImportExcel1.ShowDialog();
-
-            DataTable BOM = (DataTable)dh.ExecuteSql("select * from BOMDetail LEFT JOIN bom on bd_bomid=bo_id left join " +
-                "Product ON bd_soncode=pr_code where bo_mothercode='" + pr_code + "'", "select");
             if (result == DialogResult.OK)
             {
                 XYFilePath.Text = ImportExcel1.FileName;
-                DataTable dt = ExcelToDataTable(ImportExcel1.FileName, true);
-                for (int i = 0; i < dt.Rows.Count; i++)
+                importdata = ExcelToDataTable(ImportExcel1.FileName, true);
+                ExportFileDialog.Description = "选择导出的路径";
+                DialogResult result1 = ExportFileDialog.ShowDialog();
+                if (result1 == DialogResult.OK)
                 {
-                    for (int j = 0; j < BOM.Rows.Count; j++)
+                    InitPrint = new Thread(ExportData);
+                    SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "导出贴片机数据");
+                    BaseUtil.SetFormCenter(stw);
+                    stw.ShowDialog();
+                }
+            }
+        }
+
+        private void ExportData()
+        {
+            Stream fs = new FileStream(ExportFileDialog.SelectedPath + @"\" + pr_code.Text + ".txt", FileMode.CreateNew, FileAccess.ReadWrite);
+            fs.Dispose();
+            List<string> list = new List<string>();
+            for (int i = 0; i < importdata.Rows.Count; i++)
+            {
+                string Refer = importdata.Rows[i]["Refer"].ToString();
+                DataTable bom = (DataTable)dh.ExecuteSql("select replace(wm_concat(bd_location||';'||nvl(bd_soncode,PRE_SONCODE)||' '||PRE_REPCODE),',',' ') from BOMDetail " +
+                    "LEFT JOIN bom on bd_bomid=bo_id left join Product ON bd_soncode=pr_code left join ProdReplace on pre_bdid =bd_id where " +
+                    "bo_mothercode='" + pr_code.Text + "' and instr(bd_location,'" + Refer + "')>0", "select");
+                if (bom.Rows.Count > 0)
+                {
+                    if (bom.Rows[0][0].ToString() != "")
                     {
-                        string Refer = dt.Rows[i]["Refer"].ToString();
+                        if (!list.Contains(bom.Rows[0][0].ToString()))
+                        {
+                            list.Add(bom.Rows[0][0].ToString());
+                        }
                     }
                 }
+                Process.Text = (i + 1) + "/" + importdata.Rows.Count;
+            }
+            StreamWriter sw = File.AppendText(ExportFileDialog.SelectedPath + @"\" + pr_code.Text + ".txt");
+            for (int i = 0; i < list.Count; i++)
+            {
+                Console.WriteLine(list[i]);
+                sw.WriteLine(list[i]);
             }
+            sw.Close();
         }
 
         public static DataTable ExcelToDataTable(string filePath, bool isColumnName)

+ 3 - 3
UAS_MES_LGDZ/FunctionCode/Query/Query_SpecialReport.resx

@@ -123,6 +123,9 @@
   <metadata name="ExportFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>282, 17</value>
   </metadata>
+  <metadata name="ImportExcel1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>1018, 17</value>
+  </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <data name="XY.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
@@ -162,7 +165,4 @@
         ROJSU3qXjMKwG/vjzEz/skOI3Zqgv7AAAAAASUVORK5CYII=
 </value>
   </data>
-  <metadata name="ImportExcel1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>1018, 17</value>
-  </metadata>
 </root>

+ 2 - 1
UAS_MES_LGDZ/FunctionCode/Special/Special_Reset.cs

@@ -113,7 +113,8 @@ namespace UAS_MES_NEW.Special
                             ReSN(dt2.Rows[k]["ms_sncode"].ToString(), cd_stepcode.Text);
                         }
                         dh.ExecuteSql("delete from labelprintlog where lpl_value='" + sb[i].ToString() + "'", "delete");
-                        dh.ExecuteSql("insert into PACKAGEBACKUP select * from package where pa_outboxcode='" + sb[i].ToString() + "'", "insert");
+                        dh.ExecuteSql("insert into PACKAGEBACKUP(PA_ID, PA_PRODCODE, PA_OUTBOXCODE, PA_PACKDATE, PA_LEVEL, PA_PACKAGEQTY, PA_TOTALQTY, PA_MAKECODE, PA_STATUS, PA_INDATE, PA_SALECODE, PA_PRINTCOUNT, PA_CUSTCODE, PA_TYPE, PA_WEIGHT, PA_CURRENTQTY, PA_PACKTYPE, PA_CHECKNO, PA_DOWNSTATUS, PA_STANDARDQTY, PA_SCCODE, PA_YMD, PA_MOTHERCODE, PA_CURRENTSTEP, PA_NEXTSTEP, PA_OUTNO, PA_IOSTATUS, PA_REMARK, PA_WHCODE, PA_B2BID, PA_INNO)" +
+                            " select PA_ID, PA_PRODCODE, PA_OUTBOXCODE, PA_PACKDATE, PA_LEVEL, PA_PACKAGEQTY, PA_TOTALQTY, PA_MAKECODE, PA_STATUS, PA_INDATE, PA_SALECODE, PA_PRINTCOUNT, PA_CUSTCODE, PA_TYPE, PA_WEIGHT, PA_CURRENTQTY, PA_PACKTYPE, PA_CHECKNO, PA_DOWNSTATUS, PA_STANDARDQTY, PA_SCCODE, PA_YMD, PA_MOTHERCODE, PA_CURRENTSTEP, PA_NEXTSTEP, PA_OUTNO, PA_IOSTATUS, PA_REMARK, PA_WHCODE, PA_B2BID, PA_INNO from package where pa_outboxcode='" + sb[i].ToString() + "'", "insert");
                         dh.ExecuteSql("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode='" + sb[i].ToString() + "'", "insert");
                         dh.ExecuteSql("delete from package where pa_outboxcode = '" + sb[i].ToString() + "'", "delete");
                         //删除箱的明细