callm 6 дней назад
Родитель
Сommit
b18310ee9a

+ 99 - 68
UAS_MES_YDCY/FunctionCode/Warehouse/Warehouse_FinishedProductOutSumNEW.Designer.cs

@@ -57,6 +57,13 @@
             this.PrintLabel = new UAS_MES_NEW.CustomControl.ComBoxWithFocus.ComboxWithTip(this.components);
             this.Printlab = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.Prodiodetail = new UAS_MES_NEW.CustomControl.DataGrid_View.DataGridViewWithSerialNum();
+            this.pd_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_cartons = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_detail1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_spec1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.OperateResult = new UAS_MES_NEW.CustomControl.RichText.RichTextAutoBottom();
             this.Clean = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.cancel = new UAS_MES_NEW.CustomControl.CustomCheckBox.CustomCheckBox();
@@ -80,13 +87,8 @@
             this.pa_packageqty_label = new System.Windows.Forms.Label();
             this.StartWeight = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.RefreshWeigh = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
-            this.pd_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_cartons = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_detail1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_spec1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.ComList = new System.Windows.Forms.Label();
+            this.Baurate = new System.Windows.Forms.Label();
             this.panel1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.Prodiodetail)).BeginInit();
@@ -128,6 +130,8 @@
             // panel1
             // 
             this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.panel1.Controls.Add(this.Baurate);
+            this.panel1.Controls.Add(this.ComList);
             this.panel1.Controls.Add(this.sumpalletweight);
             this.panel1.Controls.Add(this.label1);
             this.panel1.Controls.Add(this.weight);
@@ -419,6 +423,73 @@
             this.Prodiodetail.TabIndex = 242;
             this.Prodiodetail.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.Prodiodetail_CellClick);
             // 
+            // pd_pdno
+            // 
+            this.pd_pdno.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pd_pdno.DataPropertyName = "pd_pdno";
+            this.pd_pdno.HeaderText = "序号";
+            this.pd_pdno.MinimumWidth = 10;
+            this.pd_pdno.Name = "pd_pdno";
+            this.pd_pdno.Width = 200;
+            // 
+            // pd_cartons
+            // 
+            this.pd_cartons.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pd_cartons.DataPropertyName = "pd_cartons";
+            this.pd_cartons.HeaderText = "栈板数量";
+            this.pd_cartons.MinimumWidth = 10;
+            this.pd_cartons.Name = "pd_cartons";
+            this.pd_cartons.Visible = false;
+            this.pd_cartons.Width = 160;
+            // 
+            // pd_id
+            // 
+            this.pd_id.DataPropertyName = "pd_id";
+            this.pd_id.HeaderText = "ID";
+            this.pd_id.MinimumWidth = 10;
+            this.pd_id.Name = "pd_id";
+            this.pd_id.Visible = false;
+            this.pd_id.Width = 10;
+            // 
+            // pd_prodcode
+            // 
+            this.pd_prodcode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
+            this.pd_prodcode.DataPropertyName = "pd_prodcode";
+            this.pd_prodcode.HeaderText = "物料编号";
+            this.pd_prodcode.MinimumWidth = 2;
+            this.pd_prodcode.Name = "pd_prodcode";
+            this.pd_prodcode.ReadOnly = true;
+            this.pd_prodcode.Width = 2;
+            // 
+            // dataGridViewTextBoxColumn2
+            // 
+            this.dataGridViewTextBoxColumn2.DataPropertyName = "pd_outqty";
+            this.dataGridViewTextBoxColumn2.HeaderText = "出货数量";
+            this.dataGridViewTextBoxColumn2.MinimumWidth = 10;
+            this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
+            this.dataGridViewTextBoxColumn2.ReadOnly = true;
+            this.dataGridViewTextBoxColumn2.Width = 200;
+            // 
+            // pr_detail1
+            // 
+            this.pr_detail1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
+            this.pr_detail1.DataPropertyName = "pr_detail";
+            this.pr_detail1.HeaderText = "名称";
+            this.pr_detail1.MinimumWidth = 10;
+            this.pr_detail1.Name = "pr_detail1";
+            this.pr_detail1.ReadOnly = true;
+            this.pr_detail1.Width = 10;
+            // 
+            // pr_spec1
+            // 
+            this.pr_spec1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
+            this.pr_spec1.DataPropertyName = "pr_spec";
+            this.pr_spec1.HeaderText = "规格";
+            this.pr_spec1.MinimumWidth = 200;
+            this.pr_spec1.Name = "pr_spec1";
+            this.pr_spec1.ReadOnly = true;
+            this.pr_spec1.Width = 200;
+            // 
             // OperateResult
             // 
             this.OperateResult.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@@ -705,6 +776,7 @@
             this.StartWeight.TabIndex = 252;
             this.StartWeight.Text = "开始称量";
             this.StartWeight.UseVisualStyleBackColor = true;
+            this.StartWeight.Click += new System.EventHandler(this.StartWeight_Click);
             // 
             // RefreshWeigh
             // 
@@ -726,70 +798,27 @@
             this.RefreshWeigh.Text = "刷新重量";
             this.RefreshWeigh.UseVisualStyleBackColor = true;
             // 
-            // pd_pdno
-            // 
-            this.pd_pdno.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pd_pdno.DataPropertyName = "pd_pdno";
-            this.pd_pdno.HeaderText = "序号";
-            this.pd_pdno.MinimumWidth = 10;
-            this.pd_pdno.Name = "pd_pdno";
-            // 
-            // pd_cartons
-            // 
-            this.pd_cartons.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pd_cartons.DataPropertyName = "pd_cartons";
-            this.pd_cartons.HeaderText = "栈板数量";
-            this.pd_cartons.MinimumWidth = 10;
-            this.pd_cartons.Name = "pd_cartons";
-            this.pd_cartons.Width = 160;
-            // 
-            // pd_id
-            // 
-            this.pd_id.DataPropertyName = "pd_id";
-            this.pd_id.HeaderText = "ID";
-            this.pd_id.MinimumWidth = 10;
-            this.pd_id.Name = "pd_id";
-            this.pd_id.Visible = false;
-            this.pd_id.Width = 10;
-            // 
-            // pd_prodcode
-            // 
-            this.pd_prodcode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
-            this.pd_prodcode.DataPropertyName = "pd_prodcode";
-            this.pd_prodcode.HeaderText = "物料编号";
-            this.pd_prodcode.MinimumWidth = 2;
-            this.pd_prodcode.Name = "pd_prodcode";
-            this.pd_prodcode.ReadOnly = true;
-            this.pd_prodcode.Width = 2;
+            // ComList
             // 
-            // dataGridViewTextBoxColumn2
+            this.ComList.AutoSize = true;
+            this.ComList.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ComList.Location = new System.Drawing.Point(275, 173);
+            this.ComList.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.ComList.Name = "ComList";
+            this.ComList.Size = new System.Drawing.Size(0, 41);
+            this.ComList.TabIndex = 251;
+            this.ComList.Visible = false;
             // 
-            this.dataGridViewTextBoxColumn2.DataPropertyName = "pd_outqty";
-            this.dataGridViewTextBoxColumn2.HeaderText = "出货数量";
-            this.dataGridViewTextBoxColumn2.MinimumWidth = 10;
-            this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
-            this.dataGridViewTextBoxColumn2.ReadOnly = true;
-            this.dataGridViewTextBoxColumn2.Width = 200;
-            // 
-            // pr_detail1
+            // Baurate
             // 
-            this.pr_detail1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
-            this.pr_detail1.DataPropertyName = "pr_detail";
-            this.pr_detail1.HeaderText = "名称";
-            this.pr_detail1.MinimumWidth = 10;
-            this.pr_detail1.Name = "pr_detail1";
-            this.pr_detail1.ReadOnly = true;
-            this.pr_detail1.Width = 10;
-            // 
-            // pr_spec1
-            // 
-            this.pr_spec1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
-            this.pr_spec1.DataPropertyName = "pr_spec";
-            this.pr_spec1.HeaderText = "规格";
-            this.pr_spec1.MinimumWidth = 200;
-            this.pr_spec1.Name = "pr_spec1";
-            this.pr_spec1.ReadOnly = true;
-            this.pr_spec1.Width = 200;
+            this.Baurate.AutoSize = true;
+            this.Baurate.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Baurate.Location = new System.Drawing.Point(283, 181);
+            this.Baurate.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.Baurate.Name = "Baurate";
+            this.Baurate.Size = new System.Drawing.Size(0, 41);
+            this.Baurate.TabIndex = 252;
+            this.Baurate.Visible = false;
             // 
             // Warehouse_FinishedProductOutSumNEW
             // 
@@ -903,5 +932,7 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_detail1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec1;
+        private System.Windows.Forms.Label ComList;
+        private System.Windows.Forms.Label Baurate;
     }
 }

+ 88 - 3
UAS_MES_YDCY/FunctionCode/Warehouse/Warehouse_FinishedProductOutSumNEW.cs

@@ -3,13 +3,16 @@ using System;
 using System.Collections.Generic;
 using System.Data;
 using System.Drawing;
+using System.IO;
+using System.IO.Ports;
+using System.Text;
+using System.Text.RegularExpressions;
 using System.Threading;
 using System.Windows.Forms;
 using UAS_MES_NEW.DataOperate;
 using UAS_MES_NEW.Entity;
 using UAS_MES_NEW.PublicForm;
 using UAS_MES_NEW.PublicMethod;
-using static System.Runtime.CompilerServices.RuntimeHelpers;
 
 namespace UAS_MES_NEW.Warehouse
 {
@@ -38,6 +41,13 @@ namespace UAS_MES_NEW.Warehouse
 
         string needMakeIn;
 
+        Regex re = new Regex("\\d+.\\d+");
+
+        //创建串口实例
+        SerialPort serialPort1 = new SerialPort();
+
+        bool GetData = true;
+
         public Warehouse_FinishedProductOutSumNEW()
         {
             InitializeComponent();
@@ -61,9 +71,59 @@ namespace UAS_MES_NEW.Warehouse
             asc.controllInitializeSize(this);
             dh = SystemInf.dh;
             needMakeIn = dh.GetConfig("needMakeIn", "MESSetting").ToString();
+            thread = new Thread(getSerialData);
+            try
+            {
+                GetData = true;
+                serialPort1.PortName = ComList.Text;
+                serialPort1.BaudRate = int.Parse(Baurate.Text);
+                serialPort1.Open();
+                thread.Start();
+            }
+            catch (Exception mes)
+            {
+                if (Baurate.Text == "" || ComList.Text == "")
+                    OperateResult.AppendText(">>请先在电子秤调试界面维护波特率和串口\n", Color.Red);
+                else
+                    OperateResult.AppendText(">>" + mes.Message + "\n", Color.Red);
+            }
             input.Focus();
             OperateResult.AppendText("请输入栈板进行采集\n", Color.Black, input);
+        }
 
+        private void getSerialData()
+        {
+            if (serialPort1.IsOpen)
+            {
+                if (!SystemInf.OpenPort.Contains(serialPort1.PortName))
+                {
+                    SystemInf.OpenPort.Add(serialPort1.PortName);
+                    try
+                    {
+                        while (GetData)
+                        {
+                            try
+                            {
+                                int len = serialPort1.BytesToRead;
+                                Byte[] readBuffer = new Byte[len];
+                                serialPort1.Read(readBuffer, 0, len); //将数据读入缓存
+                                string weigh = Encoding.Default.GetString(readBuffer);
+                                if (weigh != "")
+                                {
+                                    weight.Text = re.Match(weigh).Value; ;
+                                }
+                            }
+                            catch (Exception)
+                            {
+                                GetData = false;
+                            }
+                        }
+                    }
+                    catch (IOException ex) { MessageBox.Show(ex.Message); }
+                }
+                else
+                    MessageBox.Show("端口已被占用,请关闭其他窗口");
+            }
         }
 
         //创建打印进程
@@ -388,10 +448,10 @@ namespace UAS_MES_NEW.Warehouse
                                     dh.ExecuteSql("update package set pa_mothercode='" + pa_outboxcode.Text + "' where pa_outboxcode='" + input.Text + "'", "update");
                                 }
                                 RefreshWeight(pa_prodcode, input.Text);
-                                if (!checkinsertprodiomac("栈板", pa_outboxcode.Text))
+                                if (!checkinsertprodiomac("栈板", pa_outboxcode.Text))
                                     return;
                                 //更新箱号对应的出货单号
-                                dh.UpdateByCondition("package", "pa_outno = '" + pi_inoutno.Text + "'", "pa_outboxcode = '" + input.Text + "'");
+                                //dh.UpdateByCondition("package", "pa_outno = '" + pi_inoutno.Text + "'", "pa_outboxcode = '" + input.Text + "'");
                                 List<string> v_barcode = new List<string>();
                                 List<string> v_makecode = new List<string>();
                                 DataTable datatable = (DataTable)dh.ExecuteSql("select v_makecode,v_barcode from MES_PACKAGE_VIEW where v_outboxcode = '" + input.Text + "'", "select");
@@ -405,6 +465,14 @@ namespace UAS_MES_NEW.Warehouse
                             }
                             else
                             {
+                                if (pa_mothercode != "")
+                                {
+                                    //从之前的栈板号里面移除出来
+                                    dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + pa_mothercode + "' and pd_innerboxcode='" + input.Text + "'", "delete");
+                                    //减少箱内容量
+                                    dh.ExecuteSql("update package set pa_packageqty=pa_packageqty-1,pa_totalqty=pa_totalqty-(select pa_totalqty from package where pa_outboxcode='" + input.Text + "'),pa_currentqty=pa_currentqty-1,pa_status=0 where pa_outboxcode='" + pa_mothercode + "'", "update");
+                                    dh.ExecuteSql("update package set pa_mothercode='" + pa_outboxcode.Text + "' where pa_outboxcode='" + input.Text + "'", "update");
+                                }
                                 RefreshWeight(pa_prodcode, input.Text);
                                 if (!checkinsertprodiomac("箱号",input.Text))
                                     return;
@@ -797,6 +865,18 @@ namespace UAS_MES_NEW.Warehouse
         Engine engine;
         private void Printlab_Click(object sender, EventArgs e)
         {
+            double ActualWeight = double.Parse(weight.Text == "" ? "0" : weight.Text.Replace("kg", "").Replace("g", "").Trim());
+            double palletWeightErrorValue = double.Parse(dh.GetConfig("palletWeightErrorValue", "MESSetting").ToString());
+            double totalweight = double.Parse(sumpalletweight.Text);
+            if ((ActualWeight >= totalweight - palletWeightErrorValue) && (ActualWeight <= totalweight + palletWeightErrorValue))
+            {
+                dh.ExecuteSql("update package set PA_WEIGHT='" + weight.Text + "',pa_printcount=pa_printcount+1,pa_remark='" + PrintLabel.Text + "' where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
+            }
+            else
+            {
+                OperateResult.AppendText(">>重量不符合" + pa_outboxcode.Text + "\n", Color.Black);
+                return;
+            }
             if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, PDID, PrintPrcode, int.Parse(PrintNum.Text), PdPDNO, PrintPrcode, "出货标", "0", out ErrorMessage))
             {
                 OperateResult.AppendText(">>打印料号" + PrintPrcode + "\n", Color.Black);
@@ -833,5 +913,10 @@ namespace UAS_MES_NEW.Warehouse
                 }
             }
         }
+
+        private void StartWeight_Click(object sender, EventArgs e)
+        {
+
+        }
     }
 }

+ 21 - 0
UAS_MES_YDCY/FunctionCode/Warehouse/Warehouse_FinishedProductOutSumNEW.resx

@@ -273,6 +273,27 @@
   <metadata name="pr_spec1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="pd_pdno.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="pd_cartons.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="pd_id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="pd_prodcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="dataGridViewTextBoxColumn2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="pr_detail1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="pr_spec1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <data name="Clean.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
         iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m