Browse Source

修改上料采集上条码对应的物料

章政 8 years ago
parent
commit
83f529a11e

+ 31 - 46
UAS-MES/FunctionCode/Make/Make_ColorBoxLoadPrint.cs

@@ -28,12 +28,10 @@ namespace UAS_MES.Make
         //当前提示的索引
         int RemainIndex = 0;
 
-        List<string> RemindItem = new List<string>();
+        List<string> TSN = new List<string>();
 
         string ErrorMessage = "";
 
-        List<string> TSN = new List<string>();
-
         System.DateTime[] indate;
 
         string ms_firstsn = "";
@@ -134,25 +132,20 @@ namespace UAS_MES.Make
                                 code.Text = "";
                             }
                             sql.Clear();
-                            sql.Append("select sp_id,sp_barcoderule,sp_ifuseregex,sp_ifforsn,sp_length,sp_soncode");
-                            sql.Append(",pr_detail,sp_type,sp_prefix,sp_regex,sp_fsoncode from stepproduct left join product on pr_code=sp_soncode where ");
-                            sql.Append("sp_bomversion='" + ma_bomversion.Text + "' and sp_craftcode='" + ma_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode + "'");
-                            sql.Append("And sp_mothercode ='" + pr_code.Text + "' and sp_tracekind =1 and not exists (select 1 from ");
-                            sql.Append("craftmaterial where (cm_sncode='" + ms_firstsn + "' or cm_sncode in (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) order by SP_DETNO asc");
+                            sql.Append("select max(sp_id)sp_id,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='" + ma_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode + "' ");
+                            sql.Append("And sp_mothercode ='" + pr_code.Text + "' and sp_tracekind=1 and not exists(select 1 from craftmaterial where (cm_sncode='" + ms_firstsn + "' or ");
+                            sql.Append("cm_sncode in (select sn from makesnrelation where firstsn='" + ms_firstsn + "')) and cm_makecode='" + ma_code.Text + "' and cm_soncode=");
+                            sql.Append("sp_soncode and cm_status=0) group by sp_fsoncode order by SP_DETNO asc");
                             ListA = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                             //获取对应 产品的机身标的打印模板
                             if (ListA.Rows.Count > 0)
                             {
-                                string fsoncode = ListA.Rows[RemainIndex]["sp_fsoncode"].ToString();
+                                string soncode = ListA.Rows[RemainIndex]["sp_soncode"].ToString();
                                 string prdetail = ListA.Rows[RemainIndex]["pr_detail"].ToString();
-                                string soncode = "";
-                                RemindItem.Add(fsoncode);
-                                for (int i = 0; i < ListA.Rows.Count; i++)
-                                {
-                                    if (fsoncode == ListA.Rows[i]["sp_fsoncode"].ToString())
-                                        soncode += ListA.Rows[i]["sp_soncode"].ToString() + ",";
-                                }
                                 OperateResult.AppendText("<<请采集" + soncode + "(" + prdetail + ")的物料数据\n", Color.Black);
                                 code.Clear();
                             }
@@ -218,15 +211,19 @@ namespace UAS_MES.Make
                         string sp_barcoderule = ListA.Rows[RemainIndex]["sp_barcoderule"].ToString();
                         if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, out ErrorMessage))
                         {
-                            CollectData.Add(code.Text);
-                            SPID.Add(sp_id);
-                            CollectDataSonCode.Add(ListA.Rows[RemainIndex]["sp_soncode"].ToString());
                             if (sp_barcoderule == "TSN")
                             {
                                 TSN.Add(code.Text);
                             }
-                            RemainIndex = RemainIndex + 1;
+                            if (sp_barcoderule == "BARCODE")
+                            {
+                                sp_soncode = ErrorMessage;
+                            }
+                            CollectData.Add(code.Text);
+                            SPID.Add(sp_id);
+                            CollectDataSonCode.Add(sp_soncode);
                             OperateResult.AppendText(">>物料" + code.Text + "采集成功\n", Color.Green, code);
+                            RemainIndex = RemainIndex + 1;
                         }
                         else
                         {
@@ -236,23 +233,9 @@ namespace UAS_MES.Make
                         code.Clear();
                         if (RemainIndex <= ListA.Rows.Count - 1)
                         {
-                            string fsoncode = ListA.Rows[RemainIndex]["sp_fsoncode"].ToString();
-                            if (RemindItem.Contains(fsoncode))
-                            {
-                                RemainIndex = RemainIndex + 1;
-                            }
-                            else
-                            {
-                                RemindItem.Add(fsoncode);
-                                string soncode = "";
-                                for (int i = 0; i < ListA.Rows.Count; i++)
-                                {
-                                    if (fsoncode == ListA.Rows[i]["sp_fsoncode"].ToString())
-                                        soncode += ListA.Rows[i]["sp_soncode"].ToString() + ",";
-                                }
-                                string prdetail = ListA.Rows[RemainIndex]["pr_detail"].ToString();
-                                OperateResult.AppendText("<<请采集" + soncode + "(" + prdetail + ")的物料数据\n", Color.Black);
-                            }
+                            string soncode = ListA.Rows[RemainIndex]["sp_soncode"].ToString();
+                            string prdetail = ListA.Rows[RemainIndex]["pr_detail"].ToString();
+                            OperateResult.AppendText("<<请采集" + soncode + "(" + prdetail + ")的物料数据\n", Color.Black);
                         }
                         if (RemainIndex == ListA.Rows.Count)
                         {
@@ -268,12 +251,13 @@ namespace UAS_MES.Make
                             //更新半成品SN已被工单使用
                             dh.BatchInsert("update makeserial set ms_nextmacode='" + ma_code.Text + "' where ms_id=(select max(ms_id) from makeserial where ms_sncode=:sncode and ms_makecode<>'" + ma_code.Text + "')", new string[] { "sncode" }, TSN.ToArray());
                             OperateResult.AppendText(">>序列号" + ms_sncode.Text + "对应的物料已经采集完成\n", Color.Green);
+                            doc = lbl.Documents.Open(ftpOperater.DownLoadTo + PrintLabel.Text);
+                            Print.CodeSoft(Tag.ToString(), doc, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, ms_sncode.Text, int.Parse(PrintNum.Text));
                             RemainIndex = 0;
-                            RemindItem.Clear();
-                            CollectData.Clear();
                             TSN.Clear();
+                            CollectData.Clear();
                             CollectDataSonCode.Clear();
-                            BaseUtil.CleanDataTableData(ListA);
+                            BaseUtil.CleanDataTable(ListA);
                             if (LogicHandler.SetTestResult(ma_code.Text, User.UserSourceCode, ms_sncode.Text, "彩盒上料打印", "彩盒上料成功", User.UserCode, out ErrorMessage))
                             {
                                 //提示正确返回时传递的信息
@@ -282,10 +266,9 @@ namespace UAS_MES.Make
                                 mcd_okqty.Text = int.Parse(mcd_okqty.Text) + 1 + "";
                                 code.Clear();
                                 LoadCollectNum();
+                                BaseUtil.CleanDataTableData(ListA);
                             }
                             else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
-                            doc = lbl.Documents.Open(ftpOperater.DownLoadTo + PrintLabel.Text);
-                            Print.CodeSoft(Tag.ToString(), doc, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, ms_sncode.Text, int.Parse(PrintNum.Text));
                             return;
                         }
                     }
@@ -326,10 +309,12 @@ namespace UAS_MES.Make
 
         private void ClearSn_code_Click(object sender, EventArgs e)
         {
-            BaseUtil.CleanDataTableData(ListA);
-            RemainIndex = 0;
+            if (ListA != null)
+                BaseUtil.CleanDataTableData(ListA);
             TSN.Clear();
-            RemindItem.Clear();
+            CollectDataSonCode.Clear();
+            CollectData.Clear();
+            RemainIndex = 0;
             code.Clear();
             OperateResult.AppendText(">>请重新采集序列号\n");
         }

+ 19 - 49
UAS-MES/FunctionCode/Make/Make_FeedingCollection.cs

@@ -30,7 +30,7 @@ namespace UAS_MES.Make
         string mabomversion;
         string ErrorMessage = "";
 
-        List<string> RemindItem = new List<string>();
+        List<string> TSN = new List<string>();
 
         //用于提醒的序列B
         string[] RemainList = new string[0];
@@ -42,8 +42,6 @@ namespace UAS_MES.Make
 
         string ms_firstsn = "";
 
-        List<string> TSN = new List<string>();
-
         DataHelper dh;
         LogStringBuilder sql = new LogStringBuilder();
         DataTable DBFind;
@@ -152,6 +150,10 @@ namespace UAS_MES.Make
                                 {
                                     TSN.Add(code.Text);
                                 }
+                                if (sp_barcoderule == "BARCODE")
+                                {
+                                    sp_soncode = ErrorMessage;
+                                }
                                 Save_OtherCode(sp_soncode, make_code, sn_code.Text, sp_id);
                             }
                             else
@@ -322,12 +324,14 @@ namespace UAS_MES.Make
             //单独用一个DataTable存储一个
             dt1 = new DataTable();
             sql.Clear();
-            sql.Append("select sp_id,sp_barcoderule,pr_detail,sp_ifuseregex,sp_ifforsn,sp_length,sp_soncode,sp_repcode");
-            sql.Append(",pr_id,sp_type,sp_prefix,sp_fsoncode,sp_regex from stepproduct left join product on pr_code=sp_soncode where ");
-            sql.Append("sp_bomversion='" + mabomversion + "' and sp_craftcode='" + ms_craftcode + "' and sp_stepcode='" + User.CurrentStepCode + "'");
-            sql.Append("And sp_mothercode ='" + make_prodcode + "' and sp_tracekind =1 and not exists (select 1 ");
-            sql.Append("from craftmaterial where (cm_sncode='" + ms_firstsn + "' or cm_sncode in (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) order by SP_DETNO asc");
+            sql.Append("select max(sp_id)sp_id,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='" + 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 (cm_sncode='" + ms_firstsn + "' or ");
+            sql.Append("cm_sncode in (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");
             dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
             code.Clear();
             //用于记录提醒的数据长度
@@ -336,27 +340,15 @@ namespace UAS_MES.Make
             {
                 string soncode = dt1.Rows[i]["sp_soncode"].ToString();
                 string prdetail = dt1.Rows[i]["pr_detail"].ToString();
-                string fsoncode = dt1.Rows[i]["sp_fsoncode"].ToString();
                 RemainList[i] = soncode + "(" + prdetail + ")";
             }
             if (dt1.Rows.Count > 0)
             {
                 try
                 {
-                    CollectDataSonCode.Add(dt1.Rows[RemainIndex]["sp_soncode"].ToString());
-                    string fsoncode = dt1.Rows[RemainIndex]["sp_fsoncode"].ToString();
+                    string soncode = dt1.Rows[RemainIndex]["sp_soncode"].ToString();
                     string prdetail = dt1.Rows[RemainIndex]["pr_detail"].ToString();
-                    string soncode = "";
-                    for (int i = 0; i < dt1.Rows.Count; i++)
-                    {
-                        if (fsoncode == dt1.Rows[i]["sp_fsoncode"].ToString())
-                            soncode += dt1.Rows[i]["sp_soncode"].ToString() + ",";
-                    }
-                    if (!RemindItem.Contains(fsoncode))
-                    {
-                        RemindItem.Add(fsoncode);
-                        OperateResult.AppendText("<<请采集" + soncode + "(" + prdetail + ")的物料数据\n", Color.Black);
-                    }
+                    OperateResult.AppendText("<<请采集" + soncode + "(" + prdetail + ")的物料数据\n", Color.Black);
                 }
                 catch (Exception)
                 {
@@ -385,37 +377,17 @@ namespace UAS_MES.Make
         //此类中通用的保存逻辑
         private void Save_OtherCode(string sp_soncode, string ma_code, string ms_sncode, string sp_id)
         {
+            CollectDataSonCode.Add(sp_soncode);
             //采集成功提示
             RemainIndex = RemainIndex + 1;
-            OperateResult.SelectionColor = Color.Green;
             CollectData.Add(code.Text);
             SPID.Add(sp_id);
-            OperateResult.AppendText(">>物料" + sp_soncode + "采集成功\n");
+            OperateResult.AppendText(">>物料" + sp_soncode + "采集成功\n", Color.Green);
             code.Clear();
-            string fsoncode = "";
             //如果+1后不小于B序列的长度,则已采集完成,不需要进行提示了
             if (RemainIndex < RemainList.Length)
-                fsoncode = dt1.Rows[RemainIndex]["sp_fsoncode"].ToString();
-            if (RemindItem.Contains(fsoncode))
             {
-                RemainIndex = RemainIndex + 1;
-            }
-            if (RemainIndex < RemainList.Length)
-            {
-                fsoncode = dt1.Rows[RemainIndex]["sp_fsoncode"].ToString();
-                string prdetail = dt1.Rows[RemainIndex]["pr_detail"].ToString();
-                string soncode = "";
-                for (int i = 0; i < dt1.Rows.Count; i++)
-                {
-                    if (fsoncode == dt1.Rows[i]["sp_fsoncode"].ToString())
-                        soncode += dt1.Rows[i]["sp_soncode"].ToString() + ",";
-                }
-                if (!RemindItem.Contains(fsoncode))
-                {
-                    RemindItem.Add(fsoncode);
-                    CollectDataSonCode.Add(dt1.Rows[RemainIndex]["sp_soncode"].ToString());
-                    OperateResult.AppendText("<<请采集" + soncode + "(" + prdetail + ")的物料数据\n", Color.Black);
-                }
+                OperateResult.AppendText("<<请采集" + RemainList[RemainIndex] + "的物料数据\n", Color.Black);
             }
             else
             {
@@ -442,9 +414,8 @@ namespace UAS_MES.Make
                     sql.Append("'" + User.UserCode + "',sysdate from makeserial where ms_sncode='" + sn_code.Text + "' and ms_makecode='" + ma_code + "'");
                     dh.ExecuteSql(sql.GetString(), "insert");
                 }
-                TSN.Clear();
                 CollectData.Clear();
-                RemindItem.Clear();
+                TSN.Clear();
                 CollectDataSonCode.Clear();
                 //采集成功,设置序列号栏目为空
                 RemainIndex = 0;
@@ -469,7 +440,6 @@ namespace UAS_MES.Make
             sn_code.Clear();
             TSN.Clear();
             CollectData.Clear();
-            RemindItem.Clear();
             CollectDataSonCode.Clear();
             if (dt1 != null)
                 BaseUtil.CleanDataTableData(dt1);

+ 16 - 2
UAS-MES/PublicMethod/LogicHandler.cs

@@ -1192,10 +1192,24 @@ namespace UAS_MES.PublicMethod
                     dt = (DataTable)dh.ExecuteSql("select bar_prodcode,bar_code from barcode where bar_code='" + iSN + "'", "select");
                     if (dt.Rows.Count > 0)
                     {
-                        if (iSonCode != dt.Rows[0]["bar_prodcode"].ToString() && iFSonCode != dt.Rows[0]["bar_prodcode"].ToString())
-                            ErrMessage = "用户条码号对应的物料不是:" + iSonCode + "或" + iFSonCode;
+                        string bar_prodcode = dt.Rows[0]["bar_prodcode"].ToString();
+                        if (!iFSonCode.Contains(bar_prodcode))
+                        {
+                            if (!iSonCode.Contains(bar_prodcode))
+                            {
+                                ErrMessage = "用户条码号对应的物料不是:" + iSonCode;
+                            }
+                            else
+                            {
+                                ErrMessage = bar_prodcode;
+                                return true;
+                            }
+                        }
                         else
+                        {
+                            ErrMessage = bar_prodcode;
                             return true;
+                        }
                     }
                     else ErrMessage = "条码" + iSN + "不存在";
                     break;