Browse Source

Merge branch 'master' of ssh://10.10.100.21/source/mes-client

Hcsy 7 years ago
parent
commit
d956f4f22c

+ 60 - 18
PLCDataReader/ClassFile/ModeBusTCPServer.cs

@@ -14,7 +14,6 @@ namespace ClassFile
 
         Thread threadWatch = null; //负责监听客户端的线程
         Socket socketWatch = null; //负责监听客户端的套接字
-        Socket socConnection;
 
         public bool IsOpen
         {
@@ -99,26 +98,68 @@ namespace ClassFile
 
         private void WatchConnecting()
         {
+            Socket connection = null;
+            while (true)  //持续不断监听客户端发来的请求
+            {
+                try
+                {
+                    connection = socketWatch.Accept();
+                }
+                catch (Exception)
+                {
+                    break;
+                }
+                //获取客户端的IP和端口号  
+                IPAddress clientIP = (connection.RemoteEndPoint as IPEndPoint).Address;
+                int clientPort = (connection.RemoteEndPoint as IPEndPoint).Port;
+
+                //让客户显示"连接成功的"的信息  
+                string sendmsg = "连接服务端成功!\r\n" + "本地IP:" + clientIP + ",本地端口" + clientPort.ToString();
+                byte[] arrSendMsg = Encoding.UTF8.GetBytes(sendmsg);
+                connection.Send(arrSendMsg);
+
+                //客户端网络结点号  
+                string remoteEndPoint = connection.RemoteEndPoint.ToString();
+                //显示与客户端连接情况
+                richtext.AppendText("成功与" + remoteEndPoint + "客户端建立连接!\t\n");
+
+                //IPEndPoint netpoint = new IPEndPoint(clientIP,clientPort); 
+                IPEndPoint netpoint = connection.RemoteEndPoint as IPEndPoint;
+
+                //创建一个通信线程      
+                ParameterizedThreadStart pts = new ParameterizedThreadStart(recv);
+                Thread thread = new Thread(pts);
+                //设置为后台线程,随着主线程退出而退出 
+                thread.IsBackground = true;
+                //启动线程     
+                thread.Start(connection);
+            }
+        }
+
+        void recv(object socketclientpara)
+        {
+            Socket socketServer = socketclientpara as Socket;
             while (true)
             {
-                socConnection = socketWatch.Accept();
-                while (true)  //持续不断监听客户端发来的请求
+                //创建一个内存缓冲区,其大小为1024*1024字节  即1M     
+                byte[] arrServerRecMsg = new byte[1024 * 1024];
+                //将接收到的信息存入到内存缓冲区,并返回其字节数组的长度    
+                try
                 {
-                    byte[] data = new byte[1024];
-                    socConnection.Receive(data);
-                    if (data[0] == 0)
-                    {
-                        break;
-                    }
-                    int length = data[5];
-                    byte[] datashow = new byte[length + 6];
-                    for (int i = 0; i <= length + 5; i++)
-                    {
-                        datashow[i] = data[i];
-                    }
-                    string str = Encoding.ASCII.GetString(datashow);
-                    richtext.AppendText("来自" + socConnection.RemoteEndPoint.ToString() + "的消息:" + str + "\n");
-                    LogManager.DoLog(str);
+                    int length = socketServer.Receive(arrServerRecMsg);
+                    //将机器接受到的字节数组转换为人可以读懂的字符串     
+                    string strSRecMsg = Encoding.UTF8.GetString(arrServerRecMsg, 0, length);
+                    //将发送的字符串信息附加到文本框txtMsg上     
+                    richtext.AppendText("客户端:" + socketServer.RemoteEndPoint + ",\r\n" + strSRecMsg + "\r\n\n");
+                    socketServer.Send(Encoding.UTF8.GetBytes("ReturnData"));
+                }
+                catch (Exception ex)
+                {
+                    //提示套接字监听异常  
+                    richtext.AppendText("客户端" + socketServer.RemoteEndPoint + "已经中断连接" + "\r\n" + ex.Message + "\r\n" + ex.StackTrace + "\r\n");
+                    //关闭之前accept出来的和客户端进行通信的套接字 
+                    socketServer.Close();
+                    break;
                 }
             }
         }
@@ -132,6 +173,7 @@ namespace ClassFile
 
         public void SendOrder(string Code)
         {
+
             switch (Code)
             {
                 default:

+ 0 - 1
UAS-出货标签管理/UAS-出货标签管理.csproj

@@ -227,7 +227,6 @@
     <Compile Include="PublicMethod\AutoSizeFormClass.cs" />
     <Compile Include="PublicMethod\BaseUtil.cs" />
     <Compile Include="PublicMethod\DataHelper.cs" />
-    <Compile Include="PublicMethod\DataRetriever.cs" />
     <Compile Include="PublicMethod\ExcelHandler.cs" />
     <Compile Include="PublicMethod\ftpOperater.cs" />
     <Compile Include="PublicMethod\GlobalEventsHandler.cs" />

+ 10 - 2
UAS-出货标签管理/UAS_出货标签管理.cs

@@ -493,7 +493,11 @@ namespace UAS_LabelMachine
                     DataTable dt = (DataTable)MidSource.DataSource;
                     if (CollectionUnit.Text == "盒")
                     {
-                        string la_id = SingleLabelCombox.SelectedValue.ToString().Split('#')[0];
+                        string la_id = "";
+                        if (SingleLabelCombox.SelectedValue != null)
+                        {
+                            la_id = SingleLabelCombox.SelectedValue.ToString().Split('#')[0];
+                        }
                         string cl_labelname = SingleLabelCombox.Text;
                         string LabelUrl = dh.getFieldDataByCondition("label left join customerlabel on la_code=cl_labelcode", "cl_labelurl", "la_id='" + la_id + "' and cl_labelname='" + cl_labelname + "'").ToString();
                         for (int i = 0; i < LabelInf.RowCount; i++)
@@ -519,7 +523,11 @@ namespace UAS_LabelMachine
                                 //当前行的索引随循环增长
                                 CurrentRowIndex = i;
                                 if (SingleLabelAutoPrint.Checked)
-                                    AutoPrintSingleLabel(la_id, LabelUrl);
+                                {
+                                    if (la_id != "")
+                                        AutoPrintSingleLabel(la_id, LabelUrl);
+                                    else MessageBox.Show("未维护单盘标签");
+                                }
                                 if (MidLabelAutoPrint.Checked)
                                     AutoPrintMidLabel();
                                 SetOutBoxCode2(true);

+ 31 - 29
UAS-出货标签管理/生成条码.Designer.cs

@@ -41,6 +41,8 @@
             this.GenerateBarCode = new UAS_LabelMachine.CustomControl.NormalButton();
             this.Screen = new UAS_LabelMachine.CustomControl.NormalButton();
             this.ProdIoInfDGV = new UAS_LabelMachine.CustomControl.DataGridViewWithSerialNum();
+            this.pi_inoutno = new UAS_LabelMachine.CustomControl.EnterTextBox();
+            this.ResetSerialNum = new UAS_LabelMachine.CustomControl.NormalButton();
             this.Choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.pd_orderdetno = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -58,8 +60,6 @@
             this.mid_qty = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.mid_num = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.mid_remain = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pi_inoutno = new UAS_LabelMachine.CustomControl.EnterTextBox();
-            this.ResetSerialNum = new UAS_LabelMachine.CustomControl.NormalButton();
             ((System.ComponentModel.ISupportInitialize)(this.ProdIoInfDGV)).BeginInit();
             this.SuspendLayout();
             // 
@@ -205,11 +205,35 @@
             this.ProdIoInfDGV.Location = new System.Drawing.Point(0, 125);
             this.ProdIoInfDGV.Name = "ProdIoInfDGV";
             this.ProdIoInfDGV.RowTemplate.Height = 23;
-            this.ProdIoInfDGV.Size = new System.Drawing.Size(964, 350);
+            this.ProdIoInfDGV.Size = new System.Drawing.Size(1200, 427);
             this.ProdIoInfDGV.TabIndex = 151;
             this.ProdIoInfDGV.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.ProdIoInfDGV_CellEndEdit);
             this.ProdIoInfDGV.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.ProdIoInfDGV_CellPainting);
             // 
+            // pi_inoutno
+            // 
+            this.pi_inoutno.ID = null;
+            this.pi_inoutno.Location = new System.Drawing.Point(128, 29);
+            this.pi_inoutno.Name = "pi_inoutno";
+            this.pi_inoutno.Size = new System.Drawing.Size(121, 21);
+            this.pi_inoutno.Str = null;
+            this.pi_inoutno.Str1 = null;
+            this.pi_inoutno.Str2 = null;
+            this.pi_inoutno.TabIndex = 149;
+            this.pi_inoutno.Tag = "cu_name";
+            this.pi_inoutno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.bi_inoutno_KeyDown);
+            // 
+            // ResetSerialNum
+            // 
+            this.ResetSerialNum.Image = ((System.Drawing.Image)(resources.GetObject("ResetSerialNum.Image")));
+            this.ResetSerialNum.Location = new System.Drawing.Point(529, 78);
+            this.ResetSerialNum.Name = "ResetSerialNum";
+            this.ResetSerialNum.Size = new System.Drawing.Size(64, 24);
+            this.ResetSerialNum.TabIndex = 161;
+            this.ResetSerialNum.Text = "流水重置";
+            this.ResetSerialNum.UseVisualStyleBackColor = true;
+            this.ResetSerialNum.Click += new System.EventHandler(this.ResetSerialNum_Click);
+            // 
             // Choose
             // 
             this.Choose.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
@@ -219,9 +243,11 @@
             // 
             // pd_orderdetno
             // 
+            this.pd_orderdetno.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
             this.pd_orderdetno.DataPropertyName = "pd_orderdetno";
             this.pd_orderdetno.HeaderText = "订单序号";
             this.pd_orderdetno.Name = "pd_orderdetno";
+            this.pd_orderdetno.Width = 78;
             // 
             // pd_pdno
             // 
@@ -326,35 +352,11 @@
             this.mid_remain.Name = "mid_remain";
             this.mid_remain.ReadOnly = true;
             // 
-            // pi_inoutno
-            // 
-            this.pi_inoutno.ID = null;
-            this.pi_inoutno.Location = new System.Drawing.Point(128, 29);
-            this.pi_inoutno.Name = "pi_inoutno";
-            this.pi_inoutno.Size = new System.Drawing.Size(121, 21);
-            this.pi_inoutno.Str = null;
-            this.pi_inoutno.Str1 = null;
-            this.pi_inoutno.Str2 = null;
-            this.pi_inoutno.TabIndex = 149;
-            this.pi_inoutno.Tag = "cu_name";
-            this.pi_inoutno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.bi_inoutno_KeyDown);
-            // 
-            // ResetSerialNum
-            // 
-            this.ResetSerialNum.Image = ((System.Drawing.Image)(resources.GetObject("ResetSerialNum.Image")));
-            this.ResetSerialNum.Location = new System.Drawing.Point(529, 78);
-            this.ResetSerialNum.Name = "ResetSerialNum";
-            this.ResetSerialNum.Size = new System.Drawing.Size(64, 24);
-            this.ResetSerialNum.TabIndex = 161;
-            this.ResetSerialNum.Text = "流水重置";
-            this.ResetSerialNum.UseVisualStyleBackColor = true;
-            this.ResetSerialNum.Click += new System.EventHandler(this.ResetSerialNum_Click);
-            // 
             // 生成条码
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(965, 477);
+            this.ClientSize = new System.Drawing.Size(1201, 554);
             this.Controls.Add(this.ResetSerialNum);
             this.Controls.Add(this.SetMidCapacity);
             this.Controls.Add(this.MidCapacity);
@@ -394,6 +396,7 @@
         private System.Windows.Forms.Label MidCapacity_label;
         private CustomControl.NumOnlyTextBox MidCapacity;
         private CustomControl.NormalButton SetMidCapacity;
+        private CustomControl.NormalButton ResetSerialNum;
         private System.Windows.Forms.DataGridViewCheckBoxColumn Choose;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_orderdetno;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_pdno;
@@ -411,6 +414,5 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn mid_qty;
         private System.Windows.Forms.DataGridViewTextBoxColumn mid_num;
         private System.Windows.Forms.DataGridViewTextBoxColumn mid_remain;
-        private CustomControl.NormalButton ResetSerialNum;
     }
 }

+ 14 - 2
UAS-出货标签管理/生成条码.cs

@@ -199,7 +199,16 @@ namespace UAS_LabelMachine
                     //最小包装数
                     int pr_zxbzs = int.Parse(ProdIoInfDGV.Rows[i].Cells["pr_zxbzs"].FormattedValue.ToString());
                     //中盒容量
-                    int mid_qty = int.Parse(ProdIoInfDGV.Rows[i].Cells["mid_qty"].FormattedValue.ToString());
+                    int mid_qty;
+                    try
+                    {
+                        mid_qty = int.Parse(ProdIoInfDGV.Rows[i].Cells["mid_qty"].FormattedValue.ToString());
+                    }
+                    catch (Exception)
+                    {
+                        MessageBox.Show("请检查中盒容量");
+                        return;
+                    }
                     //如果中盘盒数量为1且有尾数则表示一箱未装满
                     int mid_num = int.Parse(ProdIoInfDGV.Rows[i].Cells["mid_num"].FormattedValue.ToString());
                     //中盒尾数
@@ -216,6 +225,7 @@ namespace UAS_LabelMachine
                         string mid_code = dh.getFieldDataByCondition("PRODIOBARCODE", "nvl(max(to_number(PIB_OUTBOXCODE1)),0)+" + (j + 1), "PIB_INOUTNO='" + pi_inoutno.Text + "'").ToString();
                         //如果尾数不为0,并且已经遍历到了最后一箱(未装满的箱)
                         int count = 0;
+                        int AddNum = pr_zxbzs;
                         if (mid_remain != 0 && j + 1 == mid_num)
                         {
                             //剩下的尾数刚好够整数的最小包或者加上一个未装满的最小包
@@ -232,7 +242,9 @@ namespace UAS_LabelMachine
                             barcode.Add(BarcodeMethod1(pd_id, pr_id, pib_barcode));
                             custbarcode.Add(BarcodeMethod1(NrDic, SerialNumIndex, SerialNumLength));
                             midcode.Add(mid_code);
-                            pib_inqty.Add(pr_zxbzs.ToString());
+                            if (mid_remain % pr_zxbzs != 0 && k + 1 == count && j + 1 == mid_num)
+                                AddNum = mid_remain % pr_zxbzs;
+                            pib_inqty.Add(AddNum.ToString());
                         }
                     }
                     //插入条码

+ 0 - 51
UAS-出货标签管理/生成条码.resx

@@ -205,57 +205,6 @@
   <metadata name="mid_remain.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="Choose.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="pd_orderdetno.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="pr_id.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="pr_detail.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="pd_ordercode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="pr_spec.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="pr_brand.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="pr_unit.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="pd_totalqty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="pd_qty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="pr_zxbzs.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="mid_qty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="mid_num.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="mid_remain.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
   <data name="ResetSerialNum.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
         R0lGODlhUgAXAIQAAK/G1qjB1dzn6bTK2MfZ46rE1arD1/D4+/n//d/o7/X6/ez1/K7D1tLj6+Pt9ubx

+ 4 - 4
UAS_Web/tool/RequestHandler.cs

@@ -64,9 +64,8 @@ namespace UAS_Web.tool
             {
                 case "zplPrinter":
                     //弹出打印机选择列表
-                    print = new PrinterList(browser) { StartPosition = FormStartPosition.CenterScreen };
+                    print = new PrinterList(browser) { StartPosition = FormStartPosition.CenterScreen,TopMost=true };
                     print.Controls["Confirm"].Click += RequestHandler_Click;
-                    print.TopMost = true;
                     print.ShowDialog();
                     break;
                 case "zplPrint.action":
@@ -88,11 +87,12 @@ namespace UAS_Web.tool
                         {
                             PrintHelper.SendStringToPrinter(PrinterName, PrintList[i]);
                         }
+                        data.Clear();
                     }
                     else if (data.ContainsKey("exceptionInfo"))
                     {
-                        string PrintCode = data["exceptionInfo"].ToString();
-                        MessageBox.Show(PrintCode);
+                        //string PrintCode = data["exceptionInfo"].ToString();
+                        //MessageBox.Show(PrintCode);
                     }
                     break;
                 case "getPrintType.action":