Browse Source

上料采集修改为按BOMVersion关联

章政 8 years ago
parent
commit
40c6a18414

+ 17 - 17
UAS-MES/FunctionCode/Make/Make_FeedingCollection.Designer.cs

@@ -76,7 +76,7 @@
             this.panel2.Controls.Add(this.label1);
             this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
             this.panel2.Location = new System.Drawing.Point(0, 0);
-            this.panel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.panel2.Margin = new System.Windows.Forms.Padding(4);
             this.panel2.Name = "panel2";
             this.panel2.Size = new System.Drawing.Size(1197, 36);
             this.panel2.TabIndex = 31;
@@ -166,7 +166,7 @@
             this.Loading.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.Loading.ForeColor = System.Drawing.Color.Blue;
             this.Loading.Location = new System.Drawing.Point(24, 540);
-            this.Loading.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Loading.Margin = new System.Windows.Forms.Padding(4);
             this.Loading.Name = "Loading";
             this.Loading.Size = new System.Drawing.Size(73, 31);
             this.Loading.TabIndex = 62;
@@ -180,7 +180,7 @@
             this.UnLoading.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.UnLoading.ForeColor = System.Drawing.Color.Blue;
             this.UnLoading.Location = new System.Drawing.Point(131, 540);
-            this.UnLoading.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.UnLoading.Margin = new System.Windows.Forms.Padding(4);
             this.UnLoading.Name = "UnLoading";
             this.UnLoading.Size = new System.Drawing.Size(73, 31);
             this.UnLoading.TabIndex = 63;
@@ -215,7 +215,7 @@
             this.iflastsn.Enabled = false;
             this.iflastsn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.iflastsn.Location = new System.Drawing.Point(385, 588);
-            this.iflastsn.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.iflastsn.Margin = new System.Windows.Forms.Padding(4);
             this.iflastsn.Name = "iflastsn";
             this.iflastsn.Size = new System.Drawing.Size(142, 31);
             this.iflastsn.TabIndex = 72;
@@ -229,7 +229,7 @@
             this.ma_softversion_label.CheckState = System.Windows.Forms.CheckState.Checked;
             this.ma_softversion_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.ma_softversion_label.Location = new System.Drawing.Point(907, 226);
-            this.ma_softversion_label.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.ma_softversion_label.Margin = new System.Windows.Forms.Padding(4);
             this.ma_softversion_label.Name = "ma_softversion_label";
             this.ma_softversion_label.Size = new System.Drawing.Size(114, 31);
             this.ma_softversion_label.TabIndex = 74;
@@ -243,7 +243,7 @@
             this.ma_ecncode_label.CheckState = System.Windows.Forms.CheckState.Checked;
             this.ma_ecncode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.ma_ecncode_label.Location = new System.Drawing.Point(907, 278);
-            this.ma_ecncode_label.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.ma_ecncode_label.Margin = new System.Windows.Forms.Padding(4);
             this.ma_ecncode_label.Name = "ma_ecncode_label";
             this.ma_ecncode_label.Size = new System.Drawing.Size(94, 31);
             this.ma_ecncode_label.TabIndex = 75;
@@ -255,7 +255,7 @@
             this.ClearSn_code.Cursor = System.Windows.Forms.Cursors.Hand;
             this.ClearSn_code.Image = global::UAS_MES.Properties.Resources.bindingNavigatorDeleteItem_Image;
             this.ClearSn_code.Location = new System.Drawing.Point(351, 591);
-            this.ClearSn_code.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.ClearSn_code.Margin = new System.Windows.Forms.Padding(4);
             this.ClearSn_code.Name = "ClearSn_code";
             this.ClearSn_code.Size = new System.Drawing.Size(21, 20);
             this.ClearSn_code.TabIndex = 138;
@@ -414,7 +414,7 @@
             // 
             this.OperateResult.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.OperateResult.Location = new System.Drawing.Point(17, 160);
-            this.OperateResult.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.OperateResult.Margin = new System.Windows.Forms.Padding(4);
             this.OperateResult.Name = "OperateResult";
             this.OperateResult.Size = new System.Drawing.Size(856, 362);
             this.OperateResult.TabIndex = 94;
@@ -428,7 +428,7 @@
             this.Clean.Image = ((System.Drawing.Image)(resources.GetObject("Clean.Image")));
             this.Clean.IsShowBorder = true;
             this.Clean.Location = new System.Drawing.Point(789, 541);
-            this.Clean.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Clean.Margin = new System.Windows.Forms.Padding(4);
             this.Clean.MoveImage = ((System.Drawing.Image)(resources.GetObject("Clean.MoveImage")));
             this.Clean.Name = "Clean";
             this.Clean.NormalImage = ((System.Drawing.Image)(resources.GetObject("Clean.NormalImage")));
@@ -447,7 +447,7 @@
             this.ma_softversion.BackColor = System.Drawing.Color.White;
             this.ma_softversion.ID = null;
             this.ma_softversion.Location = new System.Drawing.Point(1029, 226);
-            this.ma_softversion.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.ma_softversion.Margin = new System.Windows.Forms.Padding(4);
             this.ma_softversion.Name = "ma_softversion";
             this.ma_softversion.Power = null;
             this.ma_softversion.Size = new System.Drawing.Size(140, 25);
@@ -464,7 +464,7 @@
             this.ma_ecncode.BackColor = System.Drawing.Color.White;
             this.ma_ecncode.ID = null;
             this.ma_ecncode.Location = new System.Drawing.Point(1029, 282);
-            this.ma_ecncode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.ma_ecncode.Margin = new System.Windows.Forms.Padding(4);
             this.ma_ecncode.Name = "ma_ecncode";
             this.ma_ecncode.Power = null;
             this.ma_ecncode.Size = new System.Drawing.Size(140, 25);
@@ -481,7 +481,7 @@
             this.Confirm.Image = ((System.Drawing.Image)(resources.GetObject("Confirm.Image")));
             this.Confirm.IsShowBorder = true;
             this.Confirm.Location = new System.Drawing.Point(385, 640);
-            this.Confirm.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Confirm.Margin = new System.Windows.Forms.Padding(4);
             this.Confirm.MoveImage = ((System.Drawing.Image)(resources.GetObject("Confirm.MoveImage")));
             this.Confirm.Name = "Confirm";
             this.Confirm.NormalImage = ((System.Drawing.Image)(resources.GetObject("Confirm.NormalImage")));
@@ -499,7 +499,7 @@
             this.code.BackColor = System.Drawing.Color.White;
             this.code.ID = null;
             this.code.Location = new System.Drawing.Point(131, 642);
-            this.code.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.code.Margin = new System.Windows.Forms.Padding(4);
             this.code.Name = "code";
             this.code.Power = null;
             this.code.Size = new System.Drawing.Size(212, 25);
@@ -517,7 +517,7 @@
             this.sn_code.Enabled = false;
             this.sn_code.ID = null;
             this.sn_code.Location = new System.Drawing.Point(131, 588);
-            this.sn_code.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.sn_code.Margin = new System.Windows.Forms.Padding(4);
             this.sn_code.Name = "sn_code";
             this.sn_code.Power = null;
             this.sn_code.Size = new System.Drawing.Size(212, 25);
@@ -600,16 +600,16 @@
             this.Controls.Add(this.ma_prodcode_label);
             this.Controls.Add(this.panel2);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
-            this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Margin = new System.Windows.Forms.Padding(4);
             this.Name = "Make_FeedingCollection";
             this.Tag = "Make!FeedingCollection";
             this.Text = "上料采集";
             this.Load += new System.EventHandler(this.Make_FeedingCollection_Load);
             this.SizeChanged += new System.EventHandler(this.Make_FeedingCollection_SizeChanged);
-            this.panel2.ResumeLayout(true);
+            this.panel2.ResumeLayout(false);
             this.panel2.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.ClearSn_code)).EndInit();
-            this.ResumeLayout(true);
+            this.ResumeLayout(false);
             this.PerformLayout();
 
         }

+ 24 - 16
UAS-MES/FunctionCode/Make/Make_FeedingCollection.cs

@@ -54,6 +54,8 @@ namespace UAS_MES.Make
 
         List<string> CollectDataSonCode = new List<string>();
 
+        List<string> SPBOMVERSION = new List<string>();
+
         List<string> SPID = new List<string>();
 
         public Make_FeedingCollection()
@@ -143,7 +145,8 @@ namespace UAS_MES.Make
                             string sp_prefix = dt1.Rows[RemainIndex]["sp_prefix"].ToString();
                             string sp_regex = dt1.Rows[RemainIndex]["sp_regex"].ToString();
                             string length = dt1.Rows[RemainIndex]["sp_length"].ToString();
-                            string sp_id = dt1.Rows[RemainIndex]["sp_id"].ToString();
+                            string spbomversion = dt1.Rows[RemainIndex]["sp_bomversion"].ToString();
+                            string spid = dt1.Rows[RemainIndex]["sp_id"].ToString();
                             string sp_ifforsn = dt1.Rows[RemainIndex]["sp_ifforsn"].ToString();
                             string sp_barcoderule = dt1.Rows[RemainIndex]["sp_barcoderule"].ToString();
                             if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, out ErrorMessage))
@@ -159,7 +162,7 @@ namespace UAS_MES.Make
                                 {
                                     sp_soncode = ErrorMessage;
                                 }
-                                Save_OtherCode(sp_soncode, make_code, sn_code.Text, sp_id);
+                                Save_OtherCode(sp_soncode, make_code, sn_code.Text, spid, spbomversion);
                             }
                             else
                                 OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
@@ -226,7 +229,7 @@ namespace UAS_MES.Make
                 //将录入框的值给序列号
                 sn_code.Text = code.Text;
                 sql.Clear();
-                sql.Append("select ma_prodcode,ma_ecncode,ma_softversion,ms_firstsn,ma_bomversion,ma_qty,ma_code,pr_detail,ms_status,ms_id,ms_craftcode,ms_nextstepcode");
+                sql.Append("select ma_prodcode,ma_ecncode,ma_craftcode,ma_softversion,ms_firstsn,ma_bomversion,ma_qty,ma_code,pr_detail,ms_status,ms_id,ms_craftcode,ms_nextstepcode");
                 sql.Append(",ms_prodcode,ms_makecode,ms_code,ms_stepname  from makeserial left join make on ma_code=ms_makecode ");
                 sql.Append("left join product on ms_prodcode=pr_code where ms_sncode='" + code.Text + "' order by ms_id desc");
                 dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
@@ -265,18 +268,20 @@ namespace UAS_MES.Make
                             if (dt.Rows[0]["ms_makecode"].ToString() != ma_code.Text && dt.Rows[0]["ms_status"].ToString() == "2")
                             {
                                 sql.Clear();
-                                sql.Append("select sp_id,sp_soncode from make inner join stepbom on ma_prodcode=sb_prodcode and ma_bomversion=sb_bomversion left ");
+                                sql.Append("select sp_id,sp_bomversion,sp_soncode from make inner join stepbom on ma_prodcode=sb_prodcode and ma_bomversion=sb_bomversion left ");
                                 sql.Append("join stepproduct on sp_sbid=sb_id where ma_code='" + ma_code.Text + "' and sp_craftcode='" + ms_craftcode.Text + "' ");
                                 sql.Append("and sp_stepcode='" + User.CurrentStepCode + "' and nvl(sp_ifforsn,0)<>0");
                                 dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                                 if (dt.Rows.Count > 0)
                                 {
-                                    string sp_id = dt.Rows[0]["sp_id"].ToString();
+                                    string spbomversion = dt.Rows[0]["sp_bomversion"].ToString();
+                                    string spid = dt.Rows[0]["sp_id"].ToString();
                                     string sp_soncode = dt.Rows[0]["sp_soncode"].ToString();
                                     if (!dh.CheckExist("Craftmaterial", "cm_makecode='" + ma_code.Text + "' and cm_soncode='" + make_prodcode + "' and cm_sncode='" + code.Text + "' and cm_status=0"))
                                     {
+                                        SPID.Add(spid);
                                         CollectDataSonCode.Add(sp_soncode);
-                                        SPID.Add(sp_id);
+                                        SPBOMVERSION.Add(spbomversion);
                                         CollectData.Add(code.Text.Substring(0, code.Text.Length > 40 ? 40 : code.Text.Length));
                                         sn_code.Text = code.Text;
                                         OperateResult.AppendText(">>序列号" + code.Text + ",物料" + sp_soncode + "上料成功\n", Color.Green);
@@ -302,7 +307,7 @@ namespace UAS_MES.Make
                         ms_status = dt.Rows[0]["ms_status"].ToString();
                         sn_code.Text = code.Text;
                         sql.Clear();
-                        sql.Append("select ma_code,ma_softversion,ma_ecncode,ma_prodcode,pr_detail,ma_qty from makeserial left join product ");
+                        sql.Append("select ma_code,ma_softversion,ma_craftcode,ma_ecncode,ma_prodcode,pr_detail,ma_qty,ma_craftcode from makeserial left join product ");
                         sql.Append(" on ms_prodcode=pr_code left join make on ms_makecode=ma_code left join ");
                         sql.Append("makecraftdetail on mcd_macode=ms_makecode where ms_id='" + oMsid + "'");
                         dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
@@ -326,11 +331,11 @@ namespace UAS_MES.Make
             //单独用一个DataTable存储一个
             dt1 = new DataTable();
             sql.Clear();
-            sql.Append("select max(sp_id)sp_id,max(sp_detno)sp_detno,sp_fsoncode,max(sp_barcoderule)");
+            sql.Append("select max(sp_id)sp_id,max(sp_bomversion)sp_bomversion,max(sp_detno)sp_detno,sp_fsoncode,max(sp_barcoderule)");
             sql.Append("sp_barcoderule,wm_concat(sp_soncode) sp_soncode,max(sp_ifuseregex)sp_ifuseregex,max(sp_ifforsn)");
             sql.Append("sp_ifforsn,max(sp_length)sp_length,max(sp_type)sp_type,max(sp_prefix)sp_prefix,max(sp_regex)");
             sql.Append("sp_regex,max(pr_detail)pr_detail from stepproduct left join product on pr_code=sp_fsoncode where ");
-            sql.Append("sp_bomversion='" + ma_bomversion.Text + "' and sp_craftcode='" + ms_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode + "' ");
+            sql.Append("sp_bomversion='" + ma_bomversion.Text + "' and sp_craftcode='" + ma_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode + "' ");
             sql.Append("And sp_mothercode ='" + ma_prodcode.Text + "' and sp_tracekind=1 and not exists(select 1 from craftmaterial where ");
             sql.Append("cm_sncode in (select '" + ms_firstsn + "' from dual union select sn from makesnrelation where firstsn='" + ms_firstsn + "') and cm_makecode='" + ma_code.Text + "' and cm_fsoncode=");
             sql.Append("sp_fsoncode and cm_status=0) group by sp_fsoncode order by SP_DETNO asc");
@@ -377,13 +382,14 @@ namespace UAS_MES.Make
         }
 
         //此类中通用的保存逻辑
-        private void Save_OtherCode(string sp_soncode, string ma_code, string ms_sncode, string sp_id)
+        private void Save_OtherCode(string sp_soncode, string ma_code, string ms_sncode,string spid, string spbomversion)
         {
             CollectDataSonCode.Add(sp_soncode);
             //采集成功提示
             RemainIndex = RemainIndex + 1;
             CollectData.Add(code.Text.Substring(0, code.Text.Length > 40 ? 40 : code.Text.Length));
-            SPID.Add(sp_id);
+            SPID.Add(spid);
+            SPBOMVERSION.Add(spbomversion);
             OperateResult.AppendText(">>物料" + sp_soncode + "采集成功,条码" + code.Text + "\n", Color.Green);
             code.Clear();
             //如果+1后不小于B序列的长度,则已采集完成,不需要进行提示了
@@ -400,14 +406,14 @@ namespace UAS_MES.Make
                 sql.Append("mcd_stepname,sp_fsoncode,ms_craftcode,ms_craftname,:barcode,1,sysdate,'" + User.UserCode + "','" + User.UserLineCode + "',ma_wccode,");
                 sql.Append("'" + User.UserSourceCode + "',:sp_id,0,1,ms_firstsn from make left join makecraftdetail on mcd_macode=ma_code  left join stepproduct on sp_stepcode=mcd_stepcode ");
                 sql.Append("and sp_craftcode=ma_craftcode and sp_mothercode = ma_prodcode left join makeserial on ms_makecode=ma_code ");
-                sql.Append("where ma_code='" + make_code + "'and sp_id=:sp_id1 and mcd_stepcode = '" + User.CurrentStepCode + "' and ms_sncode='" + ms_sncode + "'");
-                dh.BatchInsert(sql.GetString(), new string[] { "soncode", "barcode", "sp_id", "sp_id1" }, CollectDataSonCode.ToArray(), CollectData.ToArray(), SPID.ToArray(), SPID.ToArray());
+                sql.Append("where ma_code='" + make_code + "'and sp_bomversion=:sp_bomversion and mcd_stepcode = '" + User.CurrentStepCode + "' and ms_sncode='" + ms_sncode + "'");
+                dh.BatchInsert(sql.GetString(), new string[] { "soncode", "barcode", "sp_id", "sp_bomversion" }, CollectDataSonCode.ToArray(), CollectData.ToArray(), SPID.ToArray(), SPBOMVERSION.ToArray());
                 try
                 {
                     string Log = "";
                     for (int i = 0; i < CollectDataSonCode.Count; i++)
                     {
-                        Log += CollectDataSonCode.ToArray()[i] + " " + CollectData.ToArray()[i] + " " + SPID.ToArray()[i];
+                        Log += CollectDataSonCode.ToArray()[i] + " " + CollectData.ToArray()[i] + " " + SPBOMVERSION.ToArray()[i];
                     }
                     LogManager.DoLog(Log);
                 }
@@ -431,8 +437,9 @@ namespace UAS_MES.Make
                     dh.ExecuteSql(sql.GetString(), "insert");
                 }
                 CollectData.Clear();
-                TSN.Clear();
                 SPID.Clear();
+                TSN.Clear();
+                SPBOMVERSION.Clear();
                 CollectDataSonCode.Clear();
                 //采集成功,设置序列号栏目为空
                 RemainIndex = 0;
@@ -456,9 +463,10 @@ namespace UAS_MES.Make
         private void ClearSn_code_Click(object sender, EventArgs e)
         {
             sn_code.Clear();
-            SPID.Clear();
+            SPBOMVERSION.Clear();
             TSN.Clear();
             CollectData.Clear();
+            SPID.Clear();
             CollectDataSonCode.Clear();
             if (dt1 != null)
                 BaseUtil.CleanDataTableData(dt1);