Browse Source

SOP支持按照机型维护数据

callm 1 year ago
parent
commit
4e391b757e
3 changed files with 177 additions and 50 deletions
  1. 86 12
      FileWatcher/SOP.Designer.cs
  2. 79 38
      FileWatcher/SOP.cs
  3. 12 0
      FileWatcher/SOP.resx

+ 86 - 12
FileWatcher/SOP.Designer.cs

@@ -45,6 +45,13 @@
             this.pr_spec = new System.Windows.Forms.RichTextBox();
             this.li_code = new System.Windows.Forms.TextBox();
             this.label5 = new System.Windows.Forms.Label();
+            this.SendDGV = new System.Windows.Forms.DataGridView();
+            this.ChooseALL = new System.Windows.Forms.Button();
+            this.CheckColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.fp_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.fp_path = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.issend = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            ((System.ComponentModel.ISupportInitialize)(this.SendDGV)).BeginInit();
             this.SuspendLayout();
             // 
             // richTextBox1
@@ -99,7 +106,7 @@
             // 
             // pr_code
             // 
-            this.pr_code.Location = new System.Drawing.Point(218, 152);
+            this.pr_code.Location = new System.Drawing.Point(218, 361);
             this.pr_code.Name = "pr_code";
             this.pr_code.Size = new System.Drawing.Size(582, 35);
             this.pr_code.TabIndex = 11;
@@ -110,17 +117,17 @@
             // 
             this.label2.AutoSize = true;
             this.label2.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label2.Location = new System.Drawing.Point(19, 147);
+            this.label2.Location = new System.Drawing.Point(19, 356);
             this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(146, 41);
+            this.label2.Size = new System.Drawing.Size(82, 41);
             this.label2.TabIndex = 10;
-            this.label2.Text = "产品编号";
+            this.label2.Text = "机型";
             // 
             // OperatResult
             // 
-            this.OperatResult.Location = new System.Drawing.Point(823, 32);
+            this.OperatResult.Location = new System.Drawing.Point(865, 525);
             this.OperatResult.Name = "OperatResult";
-            this.OperatResult.Size = new System.Drawing.Size(1110, 874);
+            this.OperatResult.Size = new System.Drawing.Size(1068, 381);
             this.OperatResult.TabIndex = 12;
             this.OperatResult.Text = "";
             this.OperatResult.TextChanged += new System.EventHandler(this.OperatResult_TextChanged);
@@ -139,30 +146,33 @@
             // 
             this.label3.AutoSize = true;
             this.label3.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label3.Location = new System.Drawing.Point(19, 240);
+            this.label3.Location = new System.Drawing.Point(19, 22);
             this.label3.Name = "label3";
             this.label3.Size = new System.Drawing.Size(146, 41);
             this.label3.TabIndex = 14;
             this.label3.Text = "产品名称";
+            this.label3.Visible = false;
             // 
             // label4
             // 
             this.label4.AutoSize = true;
             this.label4.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label4.Location = new System.Drawing.Point(19, 333);
+            this.label4.Location = new System.Drawing.Point(19, 115);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(146, 41);
             this.label4.TabIndex = 15;
             this.label4.Text = "产品规格";
+            this.label4.Visible = false;
             // 
             // pr_detail
             // 
             this.pr_detail.AutoSize = true;
             this.pr_detail.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.pr_detail.Location = new System.Drawing.Point(211, 240);
+            this.pr_detail.Location = new System.Drawing.Point(211, 22);
             this.pr_detail.Name = "pr_detail";
             this.pr_detail.Size = new System.Drawing.Size(0, 41);
             this.pr_detail.TabIndex = 16;
+            this.pr_detail.Visible = false;
             // 
             // JPG
             // 
@@ -179,16 +189,16 @@
             // pr_spec
             // 
             this.pr_spec.Enabled = false;
-            this.pr_spec.Location = new System.Drawing.Point(218, 341);
+            this.pr_spec.Location = new System.Drawing.Point(218, 123);
             this.pr_spec.Name = "pr_spec";
             this.pr_spec.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
             this.pr_spec.Size = new System.Drawing.Size(580, 94);
             this.pr_spec.TabIndex = 19;
             this.pr_spec.Text = "";
+            this.pr_spec.Visible = false;
             // 
             // li_code
             // 
-            this.li_code.Enabled = false;
             this.li_code.Location = new System.Drawing.Point(218, 585);
             this.li_code.Name = "li_code";
             this.li_code.Size = new System.Drawing.Size(582, 35);
@@ -204,11 +214,68 @@
             this.label5.TabIndex = 20;
             this.label5.Text = "线别";
             // 
+            // SendDGV
+            // 
+            this.SendDGV.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.SendDGV.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+            this.CheckColumn,
+            this.fp_name,
+            this.fp_path,
+            this.issend});
+            this.SendDGV.Location = new System.Drawing.Point(865, 32);
+            this.SendDGV.Name = "SendDGV";
+            this.SendDGV.RowHeadersWidth = 82;
+            this.SendDGV.RowTemplate.Height = 37;
+            this.SendDGV.Size = new System.Drawing.Size(1068, 466);
+            this.SendDGV.TabIndex = 22;
+            // 
+            // ChooseALL
+            // 
+            this.ChooseALL.Location = new System.Drawing.Point(957, 51);
+            this.ChooseALL.Name = "ChooseALL";
+            this.ChooseALL.Size = new System.Drawing.Size(80, 42);
+            this.ChooseALL.TabIndex = 23;
+            this.ChooseALL.Text = "全选";
+            this.ChooseALL.UseVisualStyleBackColor = true;
+            this.ChooseALL.Click += new System.EventHandler(this.ChooseALL_Click);
+            // 
+            // CheckColumn
+            // 
+            this.CheckColumn.DataPropertyName = "CheckColumn";
+            this.CheckColumn.HeaderText = "勾选";
+            this.CheckColumn.MinimumWidth = 100;
+            this.CheckColumn.Name = "CheckColumn";
+            // 
+            // fp_name
+            // 
+            this.fp_name.DataPropertyName = "fp_name";
+            this.fp_name.HeaderText = "文件名";
+            this.fp_name.MinimumWidth = 10;
+            this.fp_name.Name = "fp_name";
+            // 
+            // fp_path
+            // 
+            this.fp_path.DataPropertyName = "fp_path";
+            this.fp_path.HeaderText = "路径";
+            this.fp_path.MinimumWidth = 10;
+            this.fp_path.Name = "fp_path";
+            this.fp_path.Width = 200;
+            // 
+            // issend
+            // 
+            this.issend.DataPropertyName = "issend";
+            this.issend.HeaderText = "是否成功发送";
+            this.issend.MinimumWidth = 10;
+            this.issend.Name = "issend";
+            this.issend.Width = 200;
+            // 
             // SOP
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1945, 934);
+            this.Controls.Add(this.ChooseALL);
+            this.Controls.Add(this.SendDGV);
             this.Controls.Add(this.li_code);
             this.Controls.Add(this.label5);
             this.Controls.Add(this.pr_spec);
@@ -225,11 +292,12 @@
             this.Controls.Add(this.FilePath);
             this.Controls.Add(this.label1);
             this.Controls.Add(this.richTextBox1);
-            this.MaximizeBox = false;
             this.Name = "SOP";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Text = "SOP管理";
+            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
             this.Load += new System.EventHandler(this.Form3_Load);
+            ((System.ComponentModel.ISupportInitialize)(this.SendDGV)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -253,5 +321,11 @@
         private System.Windows.Forms.RichTextBox pr_spec;
         private System.Windows.Forms.TextBox li_code;
         private System.Windows.Forms.Label label5;
+        private System.Windows.Forms.DataGridView SendDGV;
+        private System.Windows.Forms.Button ChooseALL;
+        private System.Windows.Forms.DataGridViewCheckBoxColumn CheckColumn;
+        private System.Windows.Forms.DataGridViewTextBoxColumn fp_name;
+        private System.Windows.Forms.DataGridViewTextBoxColumn fp_path;
+        private System.Windows.Forms.DataGridViewTextBoxColumn issend;
     }
 }

+ 79 - 38
FileWatcher/SOP.cs

@@ -11,6 +11,8 @@ using System.Web.Script.Serialization;
 using Aspose.Cells.Rendering;
 using Aspose.Cells;
 using System.Drawing.Imaging;
+using System.Drawing;
+using System.Windows.Media;
 
 namespace FileWatcher
 {
@@ -40,18 +42,17 @@ namespace FileWatcher
             DataTable dt = (DataTable)dh.ExecuteSql("select * from productsop where ps_prodcode='" + pr_code.Text + "' ", "select");
             if (dt.Rows.Count == 0)
             {
-                DataTable dt1 = (DataTable)dh.ExecuteSql("select pr_code from product where pr_code='" + pr_code.Text + "'", "select");
-                if (dt1.Rows.Count > 0)
-                {
-                    string code = LogicHandler.GetPiInoutCode("ProductSOP", "1");
-                    pr_code.Text = dt1.Rows[0]["pr_code"].ToString();
-                    dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman)values(productsop_seq.nextval,'" + code + "','" + pr_code.Text + "',sysdate,'" + usercode + "')", "insert");
-                }
-                else
-                {
-                    MessageBox.Show("产品编号" + pr_code.Text + "不存在");
-                    return;
-                }
+                //DataTable dt1 = (DataTable)dh.ExecuteSql("select pr_code from product where pr_code='" + pr_code.Text + "'", "select");
+                //if (dt1.Rows.Count > 0)
+                //{
+                string code = LogicHandler.GetPiInoutCode("ProductSOP", "1");
+                dh.ExecuteSql("insert into productsop(ps_id,ps_code,ps_prodcode,ps_indate,ps_inman)values(productsop_seq.nextval,'" + code + "','" + pr_code.Text + "',sysdate,'" + usercode + "')", "insert");
+                //}
+                //else
+                //{
+                //    MessageBox.Show("产品编号" + pr_code.Text + "不存在");
+                //    return;
+                //}
             }
             else
             {
@@ -92,6 +93,19 @@ namespace FileWatcher
                 {
                     Directory.CreateDirectory(Application.StartupPath + @"\" + pr_code.Text);
                 }
+                int width = 0;
+                int height = 0;
+                //Console.WriteLine(sheet.Name);
+                //for (int i = 0; i < sheet.Cells.Columns.Count; i++)
+                //{
+                //    width +=(int) sheet.Cells.Columns[i].Width;
+                //}
+                //for (int i = 0; i < sheet.Cells.Rows.Count; i++)
+                //{
+                //    height += (int)sheet.Cells.Rows[i].Height;
+                //}
+                //Console.WriteLine("width:"+width);
+                //Console.WriteLine("height:"+height);
                 sheet.Pictures.Add(0, 18, @"图片\电子受控章.png");
                 sheet.Pictures.Add(0, 15, @"图片\签名.png");
                 sheet.PageSetup.LeftMargin = 0;
@@ -102,15 +116,17 @@ namespace FileWatcher
                 imgOptions.ImageFormat = ImageFormat.Png;
                 imgOptions.OnePagePerSheet = true;
                 imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
+                imgOptions.SetDesiredSize(1565, 1240);
                 SheetRender sr = new SheetRender((Aspose.Cells.Worksheet)sheet, imgOptions);
                 sr.ToImage(0, Application.StartupPath + @"\" + pr_code.Text + @"\" + sheet.Name + ".jpg");
+                //// 创建一个图片
                 OperatResult.AppendText("解析图片【" + sheet.Name + ".jpg】" + "\n");
                 Dictionary<string, object> dic = new Dictionary<string, object>();
                 dic.Add("em_name", "管理员");
                 dic.Add("em_code", "ADMIN");
                 dic.Add("caller", "ProductSOP");
                 OperatResult.AppendText("上传文件【" + sheet.Name + ".jpg" + "】\n");
-                string fp_id = UploadFilesToRemoteUrl("http://mes.ubtob.net:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + pr_code.Text + @"\" + sheet.Name + ".jpg", dic);
+                string fp_id = UploadFilesToRemoteUrl("http://113.98.196.181:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + pr_code.Text + @"\" + sheet.Name + ".jpg", dic);
                 if (fp_id != "")
                 {
                     dh.ExecuteSql("update ProductSOP set ps_attachsop=ps_attachsop||" + fp_id + "||';' where ps_prodcode='" + pr_code.Text + "'", "update");
@@ -260,35 +276,34 @@ namespace FileWatcher
                 string IPAddress = "";
                 for (int i = 0; i < IpEntry.AddressList.Length; i++)
                 {
-                    if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork && IpEntry.AddressList[i].ToString().Contains("10.1"))
+                    if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork && !IpEntry.AddressList[i].ToString().Contains("10.10"))
                     {
                         IPAddress = IpEntry.AddressList[i].ToString();
                     }
                 }
                 dh.ExecuteSql("update SOPSOURCE set SS_BRDIP='" + IPAddress + "'", "update");
-                DataTable dt = (DataTable)dh.ExecuteSql("select * from productsop where ps_prodcode='" + pr_code.Text + "'", "select");
-                if (dt.Rows.Count > 0)
+                if (SendDGV.Rows.Count > 0)
                 {
                     tcpserver.Start();
-                    Thread.Sleep(5000);
+                    Thread.Sleep(8000);
                     List<Dictionary<string, string>> listr = new List<Dictionary<string, string>>();
-                    string PS_ATTACHSOP = dt.Rows[0]["PS_ATTACHSOP"].ToString();
-                    PS_ATTACHSOP = PS_ATTACHSOP.Substring(0, PS_ATTACHSOP.Length - 1).Replace(";", ",");
-                    dt = (DataTable)dh.ExecuteSql("select fp_path, fp_name from filepath where fp_id in (" + PS_ATTACHSOP + ") and nvl(fp_path, ' ') <> ' '", "select");
                     JavaScriptSerializer jss = new JavaScriptSerializer();
                     Dictionary<string, object> map1 = new Dictionary<string, object>();
                     Dictionary<string, object> map = new Dictionary<string, object>();
                     string path;
                     string pathroot = dh.GetConfig("filePathUrl", "sys").ToString();
-                    for (int i = 0; i < dt.Rows.Count; i++)
+                    for (int i = 0; i < SendDGV.Rows.Count; i++)
                     {
-                        Dictionary<string, string> dic1 = new Dictionary<string, string>();
-                        path = dt.Rows[i]["fp_path"].ToString();
-                        path = encryptBASE64(path.Replace("/app/mes/webapps/postattach", pathroot)).Replace("\\s*|\r|\n|\t", "");
-                        dic1.Add("path", path);
-                        dic1.Add("filename", dt.Rows[i]["fp_name"].ToString().Replace(" ", "").Replace("(", "").Replace(")", ""));
-                        dic1.Add("ps_prodcode", pr_code.Text);
-                        listr.Add(dic1);
+                        if (SendDGV.Rows[i].Cells["CheckColumn"].FormattedValue.ToString().ToUpper() == "TRUE")
+                        {
+                            Dictionary<string, string> dic1 = new Dictionary<string, string>();
+                            path = SendDGV.Rows[i].Cells["fp_path"].Value.ToString();
+                            path = encryptBASE64(path.Replace("/app/uas/webapps/postattach", pathroot)).Replace("\\s*|\r|\n|\t", "");
+                            dic1.Add("path", path);
+                            dic1.Add("filename", SendDGV.Rows[i].Cells["fp_name"].Value.ToString().Replace(" ", "").Replace("(", "").Replace(")", ""));
+                            dic1.Add("ps_prodcode", pr_code.Text);
+                            listr.Add(dic1);
+                        }
                     }
                     map1.Add("ps_code", "");
                     map1.Add("li_code", li_code.Text);
@@ -296,7 +311,7 @@ namespace FileWatcher
                     map.Add("success", true);
                     map.Add("data", map1);
                     tcpserver.Send(jss.Serialize(map));
-                    tcpserver.Stop();
+                    //tcpserver.Stop();
                     LogicHandler.DoCommandLog("SOP", usercode, "", "", sourcecode, "广播SOP", "广播成功", pr_code.Text, "");
                     MessageBox.Show("产品编号" + pr_code.Text + "广播成功");
                 }
@@ -345,17 +360,26 @@ namespace FileWatcher
 
         private void LoadPrCode()
         {
-            DataTable dt = (DataTable)dh.ExecuteSql("select pr_code,pr_spec,pr_detail from product where pr_code='" + pr_code.Text + "'", "select");
+            //DataTable dt = (DataTable)dh.ExecuteSql("select pr_code,pr_spec,pr_detail from product where pr_code='" + pr_code.Text + "'", "select");
+            //if (dt.Rows.Count > 0)
+            //{
+            //    pr_spec.Clear();
+            //    pr_spec.AppendText(dt.Rows[0]["pr_spec"].ToString());
+            //    pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
+            //    pr_code.Text = dt.Rows[0]["pr_code"].ToString();
+            //}
+            //else
+            //{
+            //    MessageBox.Show("产品编号" + pr_code.Text + "不存在");
+            //}
+            DataTable dt = (DataTable)dh.ExecuteSql("select * from productsop where ps_prodcode='" + pr_code.Text + "'", "select");
             if (dt.Rows.Count > 0)
             {
-                pr_spec.Clear();
-                pr_spec.AppendText(dt.Rows[0]["pr_spec"].ToString());
-                pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
-                pr_code.Text = dt.Rows[0]["pr_code"].ToString();
-            }
-            else
-            {
-                MessageBox.Show("产品编号" + pr_code.Text + "不存在");
+                List<Dictionary<string, string>> listr = new List<Dictionary<string, string>>();
+                string PS_ATTACHSOP = dt.Rows[0]["PS_ATTACHSOP"].ToString();
+                PS_ATTACHSOP = PS_ATTACHSOP.Substring(0, PS_ATTACHSOP.Length - 1).Replace(";", ",");
+                dt = (DataTable)dh.ExecuteSql("select fp_path, fp_name,'' issend from filepath where fp_id in (" + PS_ATTACHSOP + ") and nvl(fp_path, ' ') <> ' '", "select");
+                SendDGV.DataSource = dt;
             }
         }
 
@@ -368,5 +392,22 @@ namespace FileWatcher
         {
 
         }
+
+        bool AllChecked = false;
+        private void ChooseALL_Click(object sender, EventArgs e)
+        {
+            if (AllChecked)
+            {
+                foreach (DataGridViewRow dr in SendDGV.Rows)
+                    dr.Cells[0].Value = false;
+                AllChecked = false;
+            }
+            else
+            {
+                foreach (DataGridViewRow dr in SendDGV.Rows)
+                    dr.Cells[0].Value = true;
+                AllChecked = true;
+            }
+        }
     }
 }

+ 12 - 0
FileWatcher/SOP.resx

@@ -120,4 +120,16 @@
   <metadata name="ChoosePath.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>17, 17</value>
   </metadata>
+  <metadata name="CheckColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="fp_name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="fp_path.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="issend.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
 </root>