Browse Source

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

Hcsy 8 years ago
parent
commit
2e45d01bfc

+ 3 - 2
UAS-MES/FunctionCode/Make/Make_ColorBoxLoadPrint.cs

@@ -135,7 +135,7 @@ namespace UAS_MES.Make
                                 code.Text = "";
                             }
                             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_detno)sp_detno,min(sp_ifrepeat)sp_ifrepeat,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,replace(wm_concat(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 ");
@@ -210,9 +210,10 @@ namespace UAS_MES.Make
                         string sp_regex = ListA.Rows[RemainIndex]["sp_regex"].ToString();
                         string length = ListA.Rows[RemainIndex]["sp_length"].ToString();
                         string sp_id = ListA.Rows[RemainIndex]["sp_id"].ToString();
+                        string sp_ifrepeat = dt.Rows[RemainIndex]["sp_ifrepeat"].ToString();
                         string sp_ifforsn = ListA.Rows[RemainIndex]["sp_ifforsn"].ToString();
                         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))
+                        if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, out ErrorMessage))
                         {
                             //判断采集的条码和本次采集的也不能重复
                             if (CollectData.Contains(code.Text))

+ 22 - 12
UAS-MES/FunctionCode/Make/Make_Decompose.cs

@@ -108,10 +108,10 @@ namespace UAS_MES.Make
             //cm_wccode
             sncode_1 = sncode;
             sql.Clear();
-            sql.Append("select cm_craftcode,cm_spid,cm_craftname,cm_firstsn,cm_makecode,cm_stepcode,cm_stepname,cm_maprodcode,cm_fsoncode,cm_wccode,cm_maid,cm_soncode,pr_detail,cm_materialtype,");
-            sql.Append("max(cm_status) cm_status,max(cm_id) cm_id from craftmaterial left join product on pr_code=cm_soncode where(cm_sncode  in (select '" + sncode_1 + "' from dual union select firstsn from makesnrelation where sn ");
+            sql.Append("select cm_craftcode,cm_spid,cm_craftname,cm_firstsn,cm_makecode,cm_stepcode,cm_stepname,cm_maprodcode,cm_fsoncode,cm_wccode,cm_maid,cm_soncode,cm_materialtype,");
+            sql.Append("max(cm_status) cm_status,max(cm_id) cm_id from craftmaterial where(cm_sncode  in (select '" + sncode_1 + "' from dual union select firstsn from makesnrelation where sn ");
             sql.Append(" ='" + sncode_1 + "'union  select sn from makesnrelation where firstsn = '" + sncode_1 + "')");
-            sql.Append(") group by cm_craftcode,cm_firstsn,cm_stepcode,cm_stepname,cm_spid,cm_makecode,cm_maprodcode,cm_maid,cm_soncode,cm_wccode,pr_detail,cm_materialtype,cm_craftname,cm_fsoncode ORDER BY cm_status DESC");
+            sql.Append(") group by cm_craftcode,cm_firstsn,cm_stepcode,cm_stepname,cm_spid,cm_makecode,cm_maprodcode,cm_maid,cm_soncode,cm_wccode,cm_materialtype,cm_craftname,cm_fsoncode ORDER BY cm_status DESC");
             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
             if (dt.Rows.Count > 0)
             {
@@ -121,7 +121,14 @@ namespace UAS_MES.Make
                     DataTable datatable =  (DataTable)dh.ExecuteSql("select cm_barcode,cm_sncode from CRAFTMATERIAL where cm_id = '" + LabelDataGridView.Rows[i].Cells["cm_id"].Value + "'","select");
                     LabelDataGridView.Rows[i].Cells["cm_barcode"].Value = datatable.Rows[0]["cm_barcode"].ToString();
                     LabelDataGridView.Rows[i].Cells["cm_sncode"].Value = datatable.Rows[0]["cm_sncode"].ToString();
-                    // LabelDataGridView.Rows[i].Cells["pr_detail_"].Value = dh.getFieldDataByCondition("product", "pr_detail", "pr_code = '" + LabelDataGridView.Rows[i].Cells["cm_soncode"].Value + "'");
+                    string[] cm_sncodedetail = LabelDataGridView.Rows[i].Cells["cm_soncode"].Value.ToString().Split(',');
+                    string pr_name = "";
+                    foreach (string item in cm_sncodedetail)
+                    {
+                        pr_name += "'"+item + "',";
+                    }
+                    pr_name = pr_name.TrimEnd(',');
+                    LabelDataGridView.Rows[i].Cells["pr_detail_"].Value = dh.getFieldDataByCondition("product", "wm_concat(pr_detail)", "pr_code in (" + pr_name + ")");
                     LabelDataGridView.Rows[i].Cells["cm_status_1"].Value = (LabelDataGridView.Rows[i].Cells["cm_status"].Value.ToString() == "-1") ? "已拆解" : "上线";
                 }
             }
@@ -250,15 +257,17 @@ namespace UAS_MES.Make
                             {
                                 ma_bomversion = dt1.Rows[0][0].ToString();
                             }
-
                             dtbar = new DataTable();
                             sql.Clear();
-                            sql.Append("select sp_id,sp_tracekind,sp_barcoderule,sp_prefix,sp_ifuseregex,sp_ifforsn,sp_length,sp_description,sp_soncode,pr_detail,pr_spec,");
-                            sql.Append("sp_repcode,sp_fsoncode,pr_id,sp_type,sp_prefix,");
-                            sql.Append("sp_length,sp_regex,sp_ifforsn from stepproduct left join product on pr_code=sp_soncode where sp_bomversion='" + ma_bomversion + "' and ");
-                            sql.Append("sp_craftcode='" + LabelDataGridView.Rows[i].Cells["cm_craftcode"].Value + "'and sp_mothercode ='" + LabelDataGridView.Rows[i].Cells["cm_maprodcode"].Value + "' and sp_soncode = '" + LabelDataGridView.Rows[i].Cells["cm_soncode"].Value + "' ");
-                            sql.Append(" order by SP_DETNO asc");
+                            sql.Append("select max(sp_id)sp_id,max(sp_detno)sp_detno,min(sp_ifrepeat)sp_ifrepeat,sp_fsoncode,max(sp_barcoderule)");
+                            sql.Append("sp_barcoderule,sp_tracekind,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,replace(wm_concat(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 + "' and  sp_craftcode='" + LabelDataGridView.Rows[i].Cells["cm_craftcode"].Value + "'and sp_mothercode ='" + LabelDataGridView.Rows[i].Cells["cm_maprodcode"].Value + "'");
+                            sql.Append(" group by sp_fsoncode,sp_tracekind  order by SP_DETNO asc");
                             dtbar = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                            DataRow[] dtrows =  dtbar.Select("sp_soncode like '"+ LabelDataGridView.Rows[i].Cells["cm_soncode"].Value + "'");
+                            dtbar = BaseUtil.ToDataTable(dtrows);
                             if (dtbar.Rows.Count > 0)
                             {
                                 String ErrorMessage;
@@ -267,11 +276,12 @@ namespace UAS_MES.Make
                                 string sp_prefix = dtbar.Rows[0]["sp_prefix"].ToString();
                                 string sp_fsoncode = dtbar.Rows[0]["sp_fsoncode"].ToString();
                                 string length = dtbar.Rows[0]["sp_length"].ToString();
+                                string sp_ifrepeat = dtbar.Rows[0]["sp_ifrepeat"].ToString();
                                 string sp_barcoderule = dtbar.Rows[0]["sp_barcoderule"].ToString();
                                 if (sp_tracekind == "1")
                                 {
                                     //上料校验规则判断
-                                    if (!LogicHandler.CheckSNBeforeLoad(LabelDataGridView.Rows[i].Cells["cm_makecode"].Value.ToString(), LabelDataGridView.Rows[i].Cells["New_BarCode"].Value.ToString(), sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, out ErrorMessage))
+                                    if (!LogicHandler.CheckSNBeforeLoad(LabelDataGridView.Rows[i].Cells["cm_makecode"].Value.ToString(), LabelDataGridView.Rows[i].Cells["New_BarCode"].Value.ToString(), sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, out ErrorMessage))
                                     {
                                         OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
                                         LoadData(sncode_1, sender, new KeyEventArgs(Keys.Enter));
@@ -459,6 +469,6 @@ namespace UAS_MES.Make
 
         private void LabelDataGridView_Sorted(object sender, EventArgs e)
         {
-        }
+        } 
     }
 }

+ 3 - 2
UAS-MES/FunctionCode/Make/Make_FeedingCollection.cs

@@ -144,9 +144,10 @@ namespace UAS_MES.Make
                             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 sp_ifrepeat = dt1.Rows[RemainIndex]["sp_ifrepeat"].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))
+                            if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, out ErrorMessage))
                             {
                                 //判断采集的条码和本次采集的也不能重复
                                 if (CollectData.Contains(code.Text))
@@ -326,7 +327,7 @@ 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_detno)sp_detno,min(sp_ifrepeat)sp_ifrepeat,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,replace(wm_concat(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 ");

+ 2 - 0
UAS-MES/FunctionCode/Make/Make_Repair.cs

@@ -883,6 +883,7 @@ namespace UAS_MES.Make
         {
             if (nr_name.Text != "")
             {
+                SaveBadLocation.Enabled = true;
                 if (nrg_name.Text == "")
                 {
                     OperatResult.AppendText(">>请先填写不良代码组\n", Color.Red);
@@ -894,6 +895,7 @@ namespace UAS_MES.Make
                         nr_code.Text = nr_name.Value;
                 }
             }
+            else SaveBadLocation.Enabled = false;
         }
 
         private void nrg_name_UserControlTextChanged(object sender, EventArgs e)

+ 28 - 1
UAS-MES/FunctionCode/Make/Make_TestCollection.cs

@@ -551,8 +551,35 @@ namespace UAS_MES.Make
                 dh.ExecuteSql("delete from makebad where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "' and nvl(mb_status,0)=0", "delete");
                 if (LogicHandler.SetTestNGDetail(ms_sncode.Text, ma_code.Text, User.UserCode, User.UserSourceCode, "检查未通过", bgcode, bccode, bgname, bcname, bcremark, out ErrorMessage))
                 {
+                    //存在的不良代码和
+                    dt = (DataTable)dh.ExecuteSql("select sr_badcode from STEPRETURN where sr_stepcode='" + User.CurrentStepCode + "'", "select");
+                    if (dt.Rows.Count > 0)
+                    {
+                        int BadCodeInStep = 0;
+                        string badname = "";
+                        for (int i = 0; i < dt.Rows.Count; i++)
+                        {
+                            for (int j = 0; j < bccode.Length; j++)
+                            {
+                                if (dt.Rows[i]["sr_badcode"].ToString() == bccode[j])
+                                {
+                                    badname += "[" + bcname[j] + "]";
+                                    BadCodeInStep += 1;
+                                }
+                            }
+                        }
+                        //选中的不良代码必须全在工序默认的不良代码中才通过判断
+                        if (BadCodeInStep == bccode.Length)
+                        {
+                            dh.UpdateByCondition("makebad", "mb_status=-1", "mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "' and mb_stepcode='" + User.CurrentStepCode + "'");
+                            dh.UpdateByCondition("makeserial", "ms_stepcode='',ms_status=1,ms_nextstepcode='" + User.CurrentStepCode + "'", "ms_id='" + oMSID + "'");
+                            LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "快速维修成功", "快速维修", "", ob_checkno.Text);
+                            OperateResult.AppendText(">>本次采集不良代码" + badname + "存在于本工序" + User.CurrentStepCode + "中,请解除故障后重新测试本站\n", Color.Black);
+                        }
+                        else OperateResult.AppendText(">>" + ms_sncode.Text + "成功采集为不良\n", Color.Green);
+                    }
+                    else OperateResult.AppendText(">>" + ms_sncode.Text + "成功采集为不良\n", Color.Green);
                     LastSncode = ms_sncode.Text;
-                    OperateResult.AppendText(">>" + ms_sncode.Text + "成功采集为不良\n", Color.Green);
                     //采集完不良,聚焦序列号
                     ms_sncode.Focus();
                     //记录操作日志

+ 10 - 0
UAS-MES/PublicMethod/BaseUtil.cs

@@ -1305,6 +1305,16 @@ namespace UAS_MES.PublicMethod
             return sourceDataTable;
         }
 
+        //将DataRow[] 转换成DataTable
+        public static DataTable ToDataTable(DataRow[] rows)
+        {
+            if (rows == null || rows.Length == 0) return null;
+            DataTable tmp = rows[0].Table.Clone();  // 复制DataRow的表结构  
+            foreach (DataRow row in rows)
+                tmp.Rows.Add(row.ItemArray);  // 将DataRow添加到DataTable中  
+            return tmp;
+        }
+
         /// <summary>
         /// 
         /// </summary>

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

@@ -1190,7 +1190,7 @@ namespace UAS_MES.PublicMethod
             return param[4];
         }
 
-        public static bool CheckSNBeforeLoad(string iMakeCode, string iSN, string iFSonCode, string iSonCode, string iRule, string iPrefix, string iLength, out string ErrMessage)
+        public static bool CheckSNBeforeLoad(string iMakeCode, string iSN, string iFSonCode, string iSonCode, string iRule, string iPrefix, string iLength, string iIfRepeat, out string ErrMessage)
         {
             DataTable dt;
             ErrMessage = "";
@@ -1229,12 +1229,15 @@ namespace UAS_MES.PublicMethod
                     else ErrMessage = "序列号" + iSN + "不存在";
                     break;
                 case "BARCODE":
-                    //判定条码是否已经上料了
-                    dt = (DataTable)dh.ExecuteSql("select cm_barcode from craftmaterial where cm_barcode='" + iSN + "' and cm_status=0", "select");
-                    if (dt.Rows.Count > 0)
+                    if (iIfRepeat != "-1")
                     {
-                        ErrMessage = "条码" + iSN + "已经上料";
-                        return false;
+                        //判定条码是否已经上料了
+                        dt = (DataTable)dh.ExecuteSql("select cm_barcode from craftmaterial where cm_barcode='" + iSN + "' and cm_status=0", "select");
+                        if (dt.Rows.Count > 0)
+                        {
+                            ErrMessage = "条码" + iSN + "已经上料";
+                            return false;
+                        }
                     }
                     dt = (DataTable)dh.ExecuteSql("select bar_prodcode,bar_code from barcode where bar_code='" + iSN + "'", "select");
                     if (dt.Rows.Count > 0)
@@ -1261,11 +1264,14 @@ namespace UAS_MES.PublicMethod
                     else ErrMessage = "条码" + iSN + "不存在";
                     break;
                 case "RULE":
-                    dt = (DataTable)dh.ExecuteSql("select cm_barcode from craftmaterial where cm_barcode='" + iSN + "' and cm_status=0", "select");
-                    if (dt.Rows.Count > 0)
+                    if (iIfRepeat != "-1")
                     {
-                        ErrMessage = "条码" + iSN + "已经上料";
-                        return false;
+                        dt = (DataTable)dh.ExecuteSql("select cm_barcode from craftmaterial where cm_barcode='" + iSN + "' and cm_status=0", "select");
+                        if (dt.Rows.Count > 0)
+                        {
+                            ErrMessage = "条码" + iSN + "已经上料";
+                            return false;
+                        }
                     }
                     int sp_length = int.Parse(iLength != "" ? iLength : "0");
                     //若有多个,以|分割