Przeglądaj źródła

添加中盒缓存,修改生成条码使用视图

章政 8 lat temu
rodzic
commit
055e9e510f

+ 3 - 3
UAS-出货标签管理/PublicMethod/LogManager.cs

@@ -7,9 +7,9 @@ namespace UAS_LabelMachine.PublicMethod
     {
         public static void DoLog(string Message)
         {
-            StreamWriter sw = File.AppendText("Log/" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
-            sw.WriteLine("\n" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + Message + "\n");
-            sw.Close();
+            //StreamWriter sw = File.AppendText("Log/" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
+            //sw.WriteLine("\n" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + Message + "\n");
+            //sw.Close();
         }
     }
 }

+ 27 - 28
UAS-出货标签管理/UAS_出货标签管理.Designer.cs

@@ -782,7 +782,7 @@
             // 
             this.Capacity.AutoSize = true;
             this.Capacity.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Capacity.Location = new System.Drawing.Point(80, 85);
+            this.Capacity.Location = new System.Drawing.Point(80, 83);
             this.Capacity.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.Capacity.Name = "Capacity";
             this.Capacity.Size = new System.Drawing.Size(0, 20);
@@ -792,7 +792,7 @@
             // 
             this.Process_midboxcode.AutoSize = true;
             this.Process_midboxcode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process_midboxcode.Location = new System.Drawing.Point(80, 140);
+            this.Process_midboxcode.Location = new System.Drawing.Point(80, 138);
             this.Process_midboxcode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.Process_midboxcode.Name = "Process_midboxcode";
             this.Process_midboxcode.Size = new System.Drawing.Size(18, 20);
@@ -803,7 +803,7 @@
             // 
             this.Process_outboxcode.AutoSize = true;
             this.Process_outboxcode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process_outboxcode.Location = new System.Drawing.Point(80, 110);
+            this.Process_outboxcode.Location = new System.Drawing.Point(80, 108);
             this.Process_outboxcode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.Process_outboxcode.Name = "Process_outboxcode";
             this.Process_outboxcode.Size = new System.Drawing.Size(18, 20);
@@ -815,7 +815,7 @@
             this.TotalCount.AutoSize = true;
             this.TotalCount.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.TotalCount.ForeColor = System.Drawing.Color.Blue;
-            this.TotalCount.Location = new System.Drawing.Point(125, 25);
+            this.TotalCount.Location = new System.Drawing.Point(125, 23);
             this.TotalCount.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.TotalCount.Name = "TotalCount";
             this.TotalCount.Size = new System.Drawing.Size(18, 20);
@@ -826,7 +826,7 @@
             // 
             this.label17.AutoSize = true;
             this.label17.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label17.Location = new System.Drawing.Point(108, 25);
+            this.label17.Location = new System.Drawing.Point(108, 23);
             this.label17.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label17.Name = "label17";
             this.label17.Size = new System.Drawing.Size(15, 20);
@@ -838,7 +838,7 @@
             this.CollectedCount.AutoSize = true;
             this.CollectedCount.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.CollectedCount.ForeColor = System.Drawing.Color.Red;
-            this.CollectedCount.Location = new System.Drawing.Point(84, 25);
+            this.CollectedCount.Location = new System.Drawing.Point(84, 23);
             this.CollectedCount.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.CollectedCount.Name = "CollectedCount";
             this.CollectedCount.Size = new System.Drawing.Size(18, 20);
@@ -849,7 +849,7 @@
             // 
             this.label14.AutoSize = true;
             this.label14.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label14.Location = new System.Drawing.Point(13, 111);
+            this.label14.Location = new System.Drawing.Point(13, 109);
             this.label14.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label14.Name = "label14";
             this.label14.Size = new System.Drawing.Size(39, 20);
@@ -860,7 +860,7 @@
             // 
             this.label11.AutoSize = true;
             this.label11.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label11.Location = new System.Drawing.Point(13, 140);
+            this.label11.Location = new System.Drawing.Point(13, 138);
             this.label11.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label11.Name = "label11";
             this.label11.Size = new System.Drawing.Size(39, 20);
@@ -871,7 +871,7 @@
             // 
             this.label13.AutoSize = true;
             this.label13.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label13.Location = new System.Drawing.Point(13, 60);
+            this.label13.Location = new System.Drawing.Point(13, 58);
             this.label13.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label13.Name = "label13";
             this.label13.Size = new System.Drawing.Size(54, 20);
@@ -882,7 +882,7 @@
             // 
             this.Installed.AutoSize = true;
             this.Installed.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Installed.Location = new System.Drawing.Point(80, 60);
+            this.Installed.Location = new System.Drawing.Point(80, 58);
             this.Installed.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.Installed.Name = "Installed";
             this.Installed.Size = new System.Drawing.Size(0, 20);
@@ -892,7 +892,7 @@
             // 
             this.Process.AutoSize = true;
             this.Process.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process.Location = new System.Drawing.Point(13, 25);
+            this.Process.Location = new System.Drawing.Point(13, 23);
             this.Process.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.Process.Name = "Process";
             this.Process.Size = new System.Drawing.Size(54, 20);
@@ -1012,8 +1012,7 @@
             this.pib_id1.DataPropertyName = "pib_id";
             this.pib_id1.HeaderText = "pib_id";
             this.pib_id1.Name = "pib_id1";
-            this.pib_id1.Visible = false;
-            this.pib_id1.Width = 66;
+            this.pib_id1.Width = 84;
             // 
             // pib_pdno
             // 
@@ -1079,7 +1078,7 @@
             this.DateCode1.HeaderText = "DateCode1";
             this.DateCode1.Name = "DateCode1";
             this.DateCode1.Visible = false;
-            this.DateCode1.Width = 84;
+            this.DateCode1.Width = 108;
             // 
             // pib_qty
             // 
@@ -1178,7 +1177,7 @@
             // 
             this.ViVoPlate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.ViVoPlate.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ViVoPlate.Location = new System.Drawing.Point(106, 205);
+            this.ViVoPlate.Location = new System.Drawing.Point(122, 203);
             this.ViVoPlate.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.ViVoPlate.Name = "ViVoPlate";
             this.ViVoPlate.Size = new System.Drawing.Size(91, 33);
@@ -1200,7 +1199,7 @@
             // 
             this.SingleLabelPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.SingleLabelPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabelPrint.Location = new System.Drawing.Point(106, 252);
+            this.SingleLabelPrint.Location = new System.Drawing.Point(122, 250);
             this.SingleLabelPrint.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.SingleLabelPrint.Name = "SingleLabelPrint";
             this.SingleLabelPrint.Size = new System.Drawing.Size(91, 33);
@@ -1213,7 +1212,7 @@
             // 
             this.SingleLabelAutoPrint.AutoSize = true;
             this.SingleLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(9, 135);
+            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(9, 133);
             this.SingleLabelAutoPrint.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.SingleLabelAutoPrint.Name = "SingleLabelAutoPrint";
             this.SingleLabelAutoPrint.Size = new System.Drawing.Size(91, 24);
@@ -1271,7 +1270,7 @@
             // 
             this.label5.AutoSize = true;
             this.label5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label5.Location = new System.Drawing.Point(8, 211);
+            this.label5.Location = new System.Drawing.Point(8, 209);
             this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label5.Name = "label5";
             this.label5.Size = new System.Drawing.Size(39, 20);
@@ -1282,7 +1281,7 @@
             // 
             this.label4.AutoSize = true;
             this.label4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label4.Location = new System.Drawing.Point(7, 173);
+            this.label4.Location = new System.Drawing.Point(7, 171);
             this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(39, 20);
@@ -1302,7 +1301,7 @@
             // 
             this.label15.AutoSize = true;
             this.label15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label15.Location = new System.Drawing.Point(119, 175);
+            this.label15.Location = new System.Drawing.Point(119, 173);
             this.label15.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label15.Name = "label15";
             this.label15.Size = new System.Drawing.Size(24, 20);
@@ -1334,7 +1333,7 @@
             // 
             this.MidLabelAutoPrint.AutoSize = true;
             this.MidLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.MidLabelAutoPrint.Location = new System.Drawing.Point(12, 135);
+            this.MidLabelAutoPrint.Location = new System.Drawing.Point(12, 133);
             this.MidLabelAutoPrint.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.MidLabelAutoPrint.Name = "MidLabelAutoPrint";
             this.MidLabelAutoPrint.Size = new System.Drawing.Size(91, 24);
@@ -1384,7 +1383,7 @@
             // LogingOut
             // 
             this.LogingOut.AutoSize = true;
-            this.LogingOut.Location = new System.Drawing.Point(166, 12);
+            this.LogingOut.Location = new System.Drawing.Point(166, 10);
             this.LogingOut.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.LogingOut.Name = "LogingOut";
             this.LogingOut.Size = new System.Drawing.Size(52, 27);
@@ -1422,7 +1421,7 @@
             // 
             this.label10.AutoSize = true;
             this.label10.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label10.Location = new System.Drawing.Point(11, 215);
+            this.label10.Location = new System.Drawing.Point(11, 213);
             this.label10.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label10.Name = "label10";
             this.label10.Size = new System.Drawing.Size(39, 20);
@@ -1446,7 +1445,7 @@
             // 
             this.label9.AutoSize = true;
             this.label9.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label9.Location = new System.Drawing.Point(120, 255);
+            this.label9.Location = new System.Drawing.Point(120, 253);
             this.label9.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label9.Name = "label9";
             this.label9.Size = new System.Drawing.Size(39, 20);
@@ -1470,7 +1469,7 @@
             // 
             this.label8.AutoSize = true;
             this.label8.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label8.Location = new System.Drawing.Point(11, 255);
+            this.label8.Location = new System.Drawing.Point(11, 253);
             this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label8.Name = "label8";
             this.label8.Size = new System.Drawing.Size(39, 20);
@@ -1481,7 +1480,7 @@
             // 
             this.label6.AutoSize = true;
             this.label6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label6.Location = new System.Drawing.Point(8, 171);
+            this.label6.Location = new System.Drawing.Point(8, 169);
             this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label6.Name = "label6";
             this.label6.Size = new System.Drawing.Size(39, 20);
@@ -1539,7 +1538,7 @@
             // 
             this.OutBoxLabelAutoPrint.AutoSize = true;
             this.OutBoxLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.OutBoxLabelAutoPrint.Location = new System.Drawing.Point(12, 131);
+            this.OutBoxLabelAutoPrint.Location = new System.Drawing.Point(12, 129);
             this.OutBoxLabelAutoPrint.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.OutBoxLabelAutoPrint.Name = "OutBoxLabelAutoPrint";
             this.OutBoxLabelAutoPrint.Size = new System.Drawing.Size(91, 24);
@@ -1742,6 +1741,7 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn22;
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn23;
         private System.Windows.Forms.BindingSource MidSource;
+        private System.Windows.Forms.Button ChooseAll;
         private System.Windows.Forms.DataGridViewCheckBoxColumn Choose;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_id1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_pdno;
@@ -1761,6 +1761,5 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode2;
         private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifpick;
         private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifprint;
-        private System.Windows.Forms.Button ChooseAll;
     }
 }

+ 164 - 47
UAS-出货标签管理/UAS_出货标签管理.cs

@@ -36,7 +36,10 @@ namespace UAS_LabelMachine
         /// </summary>
         List<string> PrintedVivoOutboxCode = new List<string>();
         StringBuilder sql = new StringBuilder();
-
+        /// <summary>
+        /// 中盒缓存数据
+        /// </summary>
+        DataTable MidBoxCacheData;
         /// <summary>
         /// CodeSoft新建打印机引擎
         /// </summary>
@@ -94,6 +97,7 @@ namespace UAS_LabelMachine
 
         Dictionary<string, string> CollectData;
 
+        Dictionary<string, string> MidIDAndOutboxcode = new Dictionary<string, string>();
         /// <summary>
         /// 全部采集
         /// </summary>
@@ -116,6 +120,8 @@ namespace UAS_LabelMachine
         ArrayList<ArrayList<string>> ScanData;
         ArrayList<string> GetData;
 
+        List<string> MidBoxArgument = new List<string>();
+
         public UAS_出货标签打印()
         {
             InitializeComponent();
@@ -154,7 +160,7 @@ namespace UAS_LabelMachine
             {
                 PowerSetting.Visible = true;
             }
-
+            MidBoxCacheData = new DataTable();
             sg_code.FormName = Name;
             sg_code.SetValueField = new string[] { "sg_code" };
             sg_code.SelectField = "sg_code # 策略编号 ,sg_name # 策略名称,sg_brand # 品牌,sg_separator # 分隔符";
@@ -1098,6 +1104,7 @@ namespace UAS_LabelMachine
             dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
             if (dt.Rows.Count > 0)
             {
+                MidIDAndOutboxcode.Clear(); 
                 //获取全部的中盒号
                 Dictionary<string, bool> outboxcode1 = new Dictionary<string, bool>();
                 //判断所有盒号为该盒的是否勾选已采集
@@ -1107,40 +1114,54 @@ namespace UAS_LabelMachine
                 {
                     if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() != "True")
                         pib_id_list.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
+                    //如果不存在中盒号则进行添加
+                    if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
+                        MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
                 }
                 if (pib_id_list.ToArray().Length == 0)
                 {
-                    MessageBox.Show("必须已采集的数据才能进行打印");
+                    MessageBox.Show("选择的行未勾选采集或者已打印");
                     return;
                 }
+                //清除结构和数据
+                MidBoxArgument.Clear();
+                MidBoxCacheData.Clear();
+                BaseUtil.CleanDataTable(MidBoxCacheData);
+             
+                //开启一个进程获取中盒的数据
+                GetMidBoxData();
                 StringBuilder pib_id_string = new StringBuilder();
                 //id数组
                 string[] pib_id_arr = pib_id_list.ToArray();
                 //id个数
                 int pib_id_length = pib_id_arr.Length;
                 //将所有的列存在在这里
-                List<DataTable> AllCacheData = new List<DataTable>();
+                List<DataTable> AllSingleBoxCacheData = new List<DataTable>();
                 List<string> Argument = new List<string>();
+                //每五百条拼接一次条件
                 int fivehundred_count = pib_id_length / 500 + 1;
+                //当前打印的索引
+                int CurrentCount = 0;
                 for (int i = 0; i < fivehundred_count; i++)
                 {
-                    pib_id_string.Append("(");
+                    //本次循环的数量
                     int count = 0;
+                    pib_id_string.Append("(");
                     if (i + 1 == fivehundred_count)
                         count = pib_id_length - i * 500;
                     else
                         count = 500;
-                    for (int j = 0; j < count; j++)
+                    //当前执行的索引
+                    int LastCount = CurrentCount;
+                    for (int j = CurrentCount; j < LastCount + count - 1; j++)
                     {
-                        if (j + 1 == count)
-                            pib_id_string.Append(pib_id_arr[j]);
-                        else
-                            pib_id_string.Append(pib_id_arr[j] + ",");
+                        pib_id_string.Append(pib_id_arr[j] + ",");
+                        CurrentCount = CurrentCount + 1;
                     }
+                    pib_id_string.Append(pib_id_arr[CurrentCount]);
                     pib_id_string.Append(")");
                     if (i + 1 != fivehundred_count)
                         pib_id_string.Append(" or pib_id in ");
-
                 }
                 //缓存数据的DataTable
                 DataTable CacheData = new DataTable();
@@ -1163,11 +1184,11 @@ namespace UAS_LabelMachine
                             sql = sql.Substring(0, sql.LastIndexOf("="));
                             DataTable temp = dh.getFieldsDatasByCondition(sql + " in " + pib_id_string.ToString());
                             temp.Columns[0].ColumnName = SingleDoc.Variables.FreeVariables.Item(j + 1).Name;
-                            AllCacheData.Add(temp);
+                            AllSingleBoxCacheData.Add(temp);
                         }
                     }
                 }
-                DataTable[] Temp = AllCacheData.ToArray();
+                DataTable[] Temp = AllSingleBoxCacheData.ToArray();
                 //将所有数据写入到CacheData中
                 if (Temp.Length > 0)
                     for (int i = 0; i < Temp[0].Rows.Count; i++)
@@ -1205,7 +1226,6 @@ namespace UAS_LabelMachine
                 //打印所有的选中行
                 for (int i = 0; i < LabelInf.RowCount; i++)
                 {
-
                     //勾选了并且未打印
                     if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() != "True")
                     {
@@ -1240,14 +1260,14 @@ namespace UAS_LabelMachine
                             }
                             LogManager.DoLog(ParamLog.ToString());
                             //保存参数打印
-                            //SingleDoc.Save();
-                            //SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
-                            //SingleDoc.PrintDocument();
+                            SingleDoc.Save();
+                            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
+                            SingleDoc.PrintDocument();
                             LogManager.DoLog("执行打印单盘,pib_id:" + LabelInf.Rows[i].Cells["pib_id1"].Value.ToString() + ",标签地址" + LabelUrl);
                             //勾选为已打印
                             LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
                         }
-                        catch (Exception ex) { MessageBox.Show(ex.Message); }
+                        catch (Exception ex) { LogManager.DoLog(ex.Message); }
                     }
                     if (MidLabelAutoPrint.Checked && LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True")
                     {
@@ -1278,6 +1298,105 @@ namespace UAS_LabelMachine
             }
         }
 
+        /// <summary>
+        /// 获取中盒数据的线程
+        /// </summary>
+        private void GetMidBoxData()
+        {
+            StringBuilder pib_condition_string = new StringBuilder();
+            StringBuilder pib_qtycondition_string = new StringBuilder();
+            //id数组
+            string[] pib_id_arr = MidIDAndOutboxcode.Keys.ToArray();
+            string[] pib_outbox_arr = MidIDAndOutboxcode.Values.ToArray();
+            //记录一个ID用来取中盒的数量
+            string pib_id = pib_id_arr[0];
+            //id个数
+            int pib_id_length = pib_id_arr.Length;
+            //将所有的列存在在这里
+            List<DataTable> AllMidBoxCacheData = new List<DataTable>();
+            //每五百条拼接一次条件
+            int fivehundred_count = pib_id_length / 900 + 1;
+            //当前打印的索引
+            int CurrentCount = 0;
+            for (int i = 0; i < fivehundred_count; i++)
+            {
+                //本次循环的数量
+                int count = 0;
+                pib_condition_string.Append("(");
+                pib_qtycondition_string.Append("(");
+                if (i + 1 == fivehundred_count)
+                    count = pib_id_length - i * 900;
+                else
+                    count = 900;
+                //当前执行的索引
+                int LastCount = CurrentCount;
+                for (int j = LastCount; j < LastCount + count - 1; j++)
+                {
+                    pib_condition_string.Append(pib_id_arr[j] + ",");
+                    pib_qtycondition_string.Append(pib_outbox_arr[j] + ",");
+                    CurrentCount = CurrentCount + 1;
+                }
+                pib_condition_string.Append(pib_id_arr[CurrentCount]);
+                pib_qtycondition_string.Append(pib_outbox_arr[CurrentCount]);
+                pib_condition_string.Append(")");
+                pib_qtycondition_string.Append(")");
+                if (i + 1 != fivehundred_count)
+                    pib_condition_string.Append(" or pib_id in ");
+            }
+            //手动添加ID列
+            DataColumn IDColumn = new DataColumn("pib_id");
+            DataColumn OutBoxColumn = new DataColumn("pib_outboxcode1");
+            MidBoxCacheData.Columns.Add(IDColumn);
+            MidBoxCacheData.Columns.Add(OutBoxColumn);
+            string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
+            DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
+            for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
+            {
+                //将维护的模板参数和模板本身的参数名称进行比对
+                for (int k = 0; k < dt.Rows.Count; k++)
+                {
+                    if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == dt.Rows[k]["lp_name"].ToString())
+                    {
+                        DataColumn dc = new DataColumn(MidDoc.Variables.FreeVariables.Item(j + 1).Name);
+                        MidBoxCacheData.Columns.Add(dc);
+                        MidBoxArgument.Add(MidDoc.Variables.FreeVariables.Item(j + 1).Name);
+                        string sql = dt.Rows[k]["lp_sql"].ToString();
+                        if (sql.ToLower().Contains("pib_qty"))
+                        {
+                            sql = sql.Substring(0, sql.IndexOf("{")) + pib_id + sql.Substring(sql.IndexOf("}") + 1);
+                            sql = sql.Substring(0, sql.LastIndexOf("=")) + " in " + pib_qtycondition_string.ToString() + sql.Substring(sql.LastIndexOf("}") + 1);
+                        }
+                        else
+                        {
+                            sql = sql.Substring(0, sql.IndexOf("{"));
+                            sql = sql.Substring(0, sql.LastIndexOf("="));
+                            sql = sql + " in " + pib_condition_string.ToString();
+                        }
+                        DataTable temp = dh.getFieldsDatasByCondition(sql);
+                        temp.Columns[0].ColumnName = MidDoc.Variables.FreeVariables.Item(j + 1).Name;
+                        AllMidBoxCacheData.Add(temp);
+                    }
+                }
+            }
+            DataTable[] Temp = AllMidBoxCacheData.ToArray();
+            //将所有数据写入到CacheData中
+            if (Temp.Length > 0)
+            {
+                for (int i = 0; i < Temp[0].Rows.Count; i++)
+                {
+                    DataRow dr = MidBoxCacheData.NewRow();
+                    dr["pib_id"] = pib_id_arr[i];
+                    dr["pib_outboxcode1"] = pib_outbox_arr[i];
+                    //由于之前加了一个ID列和箱号,导致j从2开始
+                    for (int j = 2; j < MidBoxCacheData.Columns.Count; j++)
+                    {
+                        dr[Temp[j - 2].Columns[0].ColumnName] = Temp[j - 2].Rows[i][0].ToString();
+                    }
+                    MidBoxCacheData.Rows.Add(dr);
+                }
+            }
+        }
+
         private void SingleLabelPrint_Click(object sender, EventArgs e)
         {
             if (SingleLabelCombox.Text != "")
@@ -1337,9 +1456,7 @@ namespace UAS_LabelMachine
                 stw.ShowDialog();
             }
             else
-            {
                 MessageBox.Show("未维护中盒标签");
-            }
         }
 
         private void OutBoxPrint()
@@ -1416,6 +1533,7 @@ namespace UAS_LabelMachine
         private void MidBoxCodePrint(string la_id, int rowindex)
         {
             DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
+            string[] arg = MidBoxArgument.ToArray();
             for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
             {
                 //将维护的模板参数和模板本身的参数名称进行比对
@@ -1429,7 +1547,6 @@ namespace UAS_LabelMachine
                         string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
                         //获取打印执行的SQL
                         string sql = dt.Rows[k]["lp_sql"].ToString();
-                        //select * from productiobarcode where pib_id={pib_id} and pib_outboxcode1={pib_outboxcode1}
                         try
                         {
                             //获取打印执行的SQL
@@ -1440,33 +1557,33 @@ namespace UAS_LabelMachine
                             }
                             else
                             {
-                                string ExeSQL = "";
-                                if (sql.ToLower().Contains("pib_lotno"))
-                                    MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_lotno"].Value.ToString();
-                                else if (sql.ToLower().Contains("pib_datecode"))
-                                    MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_datecode"].Value.ToString();
-                                else
+                                DataRow[] dr = MidBoxCacheData.Select("pib_outboxcode1='" + pib_outboxcode1 + "'");
+                                if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode1"))
+                                {
+                                    if (LabelInf.Rows[rowindex].Cells["DateCode1"].Value != null)
+                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["DateCode1"].Value.ToString();
+                                }
+                                else if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("lotno"))
                                 {
-                                    ExeSQL = sql.Substring(0, sql.IndexOf("{")) + pib_id + sql.Substring(sql.IndexOf("}") + 1);
-                                    ExeSQL = ExeSQL.Substring(0, ExeSQL.IndexOf("{")) + pib_outboxcode1;
-                                    MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(ExeSQL).ToString();
+                                    if (LabelInf.Rows[rowindex].Cells["pib_lotno"].Value != null)
+                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_lotno"].Value.ToString();
                                 }
-                                LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + ExeSQL + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
+                                else if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode"))
+                                {
+                                    if (LabelInf.Rows[rowindex].Cells["pib_datecode"].Value != null)
+                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_datecode"].Value.ToString();
+                                }
+                                else if (arg.Contains(MidDoc.Variables.FreeVariables.Item(j + 1).Name))
+                                    MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][MidDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
+                                LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
                             }
                         }
                         catch (Exception)
                         {
-                            MessageBox.Show("SQL维护不正确,请检查SQL语句\n" + sql);
+                            LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
                             return;
                         }
                     }
-                    else if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == "DateCode1")
-                    {
-                        if (LabelInf.Rows[rowindex].Cells["DateCode1"].Value != null)
-                        {
-                            MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["DateCode1"].Value.ToString();
-                        }
-                    }
                 }
             }
             //保存参数打印
@@ -1878,14 +1995,14 @@ namespace UAS_LabelMachine
         {
             if (AllCollect == false)
             {
-                for (int i = 0; i < LabelInf.RowCount; i++)
-                    LabelInf.Rows[i].Cells[CloumnCount - 2].Value = true;
+                foreach (DataGridViewRow dr in LabelInf.Rows)
+                    dr.Cells[CloumnCount - 2].Value = true;
                 AllCollect = true;
             }
             else
             {
-                for (int i = 0; i < LabelInf.RowCount; i++)
-                    LabelInf.Rows[i].Cells[CloumnCount - 2].Value = false;
+                foreach (DataGridViewRow dr in LabelInf.Rows)
+                    dr.Cells[CloumnCount - 2].Value = false;
                 AllCollect = false;
             }
         }
@@ -2082,14 +2199,14 @@ namespace UAS_LabelMachine
         {
             if (AllChecked)
             {
-                for (int i = 0; i < LabelInf.RowCount; i++)
-                    LabelInf.Rows[i].Cells[0].Value = false;
+                foreach (DataGridViewRow dr in LabelInf.Rows)
+                    dr.Cells[0].Value = false;
                 AllChecked = false;
             }
             else
             {
-                for (int i = 0; i < LabelInf.RowCount; i++)
-                    LabelInf.Rows[i].Cells[0].Value = true;
+                foreach (DataGridViewRow dr in LabelInf.Rows)
+                    dr.Cells[0].Value = true;
                 AllChecked = true;
             }
         }

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

@@ -391,13 +391,7 @@ namespace UAS_LabelMachine
                     pd_barcodeioqty = "pd_barcodeoutqty";
                 }
                 sql.Clear();
-                sql.Append("select pd_piid,pd_id,pr_id,pr_brand,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty pd_totalqty,pd_ordercode,pd_orderdetno,pd_prodcode,pd_piclass,pd_qty from (select ");
-                sql.Append("pd_piid,pd_id,pr_id,pr_brand,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty,pd_ordercode,pd_orderdetno,pd_prodcode,pd_piclass,");
-                sql.Append("outqty-nvl((select sum(nvl(pib_qty,0)) from PRODIOBARCODE where PIB_PIID=pd_piid and pib_ordercode=pd_ordercode ");
-                sql.Append("and pib_orderdetno=pd_orderdetno),0)pd_qty from (select pd_piid,min(pd_id) pd_id,sum(pd_outqty)outqty,");
-                sql.Append("pd_ordercode,pd_orderdetno,max(pd_prodcode)pd_prodcode,max(pd_piclass)pd_piclass ");
-                sql.Append("from prodiodetail where pd_piclass='出货单' group by pd_piid,pd_ordercode,pd_orderdetno)T left join product on pr_code=pd_prodcode ");
-                sql.Append("where nvl(pr_zxbzs,0)>0)  where  pd_piid='" + pi_id + "'");
+                sql.Append("select * from prodiobarcode_view where  pd_piid='" + pi_id + "'");
                 dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 BaseUtil.FillDgvWithDataTable(ProdIoInfDGV, dt);
             }