Browse Source

上料采集修改

callm 3 months ago
parent
commit
e7f03b4dc4

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

@@ -158,7 +158,7 @@ namespace UAS_MES.Make
                                 code.Text = "";
                             }
                             sql.Clear();
-                            sql.Append("select max(sp_id)sp_id,max(sp_detno)sp_detno,min(sp_ifrepeat)sp_ifrepeat,max(sp_checkbarcode)sp_checkbarcode,min(sp_checksalecode)sp_checksalecode,sp_fsoncode,max(sp_barcoderule)");
+                            sql.Append("select max(sp_repcode)sp_repcode,max(sp_id)sp_id,max(sp_detno)sp_detno,min(sp_ifrepeat)sp_ifrepeat,max(sp_checkbarcode)sp_checkbarcode,min(sp_checksalecode)sp_checksalecode,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)sp_regex,max(sp_instr)sp_instr");
                             sql.Append(",max(pr_detail)pr_detail from stepproduct left join product on pr_code=sp_fsoncode where ");
@@ -233,13 +233,15 @@ 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_repcode = ListA.Rows[RemainIndex]["sp_repcode"].ToString();
                         string sp_ifrepeat = ListA.Rows[RemainIndex]["sp_ifrepeat"].ToString();
                         string sp_ifforsn = ListA.Rows[RemainIndex]["sp_ifforsn"].ToString();
                         string sp_barcoderule = ListA.Rows[RemainIndex]["sp_barcoderule"].ToString();
                         string sp_checkbarcode = ListA.Rows[RemainIndex]["sp_checkbarcode"].ToString();
                         string sp_checksalecode = ListA.Rows[RemainIndex]["sp_checksalecode"].ToString();
                         string sp_instr = ListA.Rows[RemainIndex]["sp_instr"].ToString();
-                        if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_instr, sp_checksalecode, out ErrorMessage))
+                        string userprodcode = "";
+                        if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_repcode, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_instr, sp_checksalecode, out ErrorMessage, out userprodcode ))
                         {
                             //判断采集的条码和本次采集的也不能重复
                             if (CollectData.Contains(code.Text) && sp_ifrepeat != "-1")
@@ -270,7 +272,7 @@ namespace UAS_MES.Make
                             }
                             CollectData.Add(code.Text.Substring(0, code.Text.Length > 40 ? 40 : code.Text.Length));
                             SPID.Add(sp_id);
-                            CollectDataSonCode.Add(sp_soncode);
+                            CollectDataSonCode.Add(userprodcode==""?sp_soncode: userprodcode);
                             if (!CheckBarcode.ContainsKey(sp_fsoncode))
                             {
                                 CheckBarcode.Add(sp_fsoncode, code.Text.Substring(0, code.Text.Length > 40 ? 40 : code.Text.Length));

+ 6 - 4
UAS-MES/FunctionCode/Make/Make_Decompose.cs

@@ -253,7 +253,7 @@ namespace UAS_MES.Make
                             dt1 = new DataTable();
                             sql.Clear();
                             sql.Append("select nvl(ms_bomversion,ma_bomversion) ms_bomversion,ms_craftcode,ms_prodcode from makeserial left join make on ma_code=ms_makecode ");
-                            sql.Append("left join product on ms_prodcode=pr_code where ms_makecode='" + LabelDataGridView.Rows[i].Cells["cm_makecode"].Value + "' order by ms_id desc");
+                            sql.Append("left join product on ms_prodcode=pr_code where ms_makecode='" + LabelDataGridView.Rows[i].Cells["cm_makecode"].Value + "' and ms_sncode='"+ms_sncode.Text+"' order by ms_id desc");
                             dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                             if (dt1.Rows.Count > 0)
                             {
@@ -263,14 +263,14 @@ namespace UAS_MES.Make
                             }
                             dtbar = new DataTable();
                             sql.Clear();
-                            sql.Append("select max(sp_id)sp_id,max(sp_detno)sp_detno,max(sp_instr)sp_instr,min(sp_ifrepeat)sp_ifrepeat,sp_fsoncode,max(sp_barcoderule)");
+                            sql.Append("select max(sp_repcode)sp_repcode,max(sp_id)sp_id,max(sp_detno)sp_detno,max(sp_instr)sp_instr,min(sp_ifrepeat)sp_ifrepeat,sp_fsoncode,max(sp_barcoderule)");
                             sql.Append("sp_barcoderule, min(sp_checksalecode)sp_checksalecode,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='" + ms_bomversion + "' and  sp_craftcode='" + ms_craftcode_ + "'and sp_mothercode ='" + ms_prodcode_ + "'");
                             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 + "'");
+                            DataRow[] dtrows = dtbar.Select("sp_soncode like '" + LabelDataGridView.Rows[i].Cells["cm_soncode"].Value + "' or sp_repcode like '"+ LabelDataGridView.Rows[i].Cells["cm_soncode"].Value + "'");
                             dtbar = BaseUtil.ToDataTable(dtrows);
                             if (dtbar.Rows.Count > 0)
                             {
@@ -279,15 +279,17 @@ namespace UAS_MES.Make
                                 string sp_soncode = dtbar.Rows[0]["sp_soncode"].ToString();
                                 string sp_prefix = dtbar.Rows[0]["sp_prefix"].ToString();
                                 string sp_fsoncode = dtbar.Rows[0]["sp_fsoncode"].ToString();
+                                string sp_repcode = dtbar.Rows[0]["sp_repcode"].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();
                                 string sp_checksalecode = dtbar.Rows[0]["sp_checksalecode"].ToString();
                                 string sp_instr = dtbar.Rows[0]["sp_instr"].ToString();
+                                string userprodcode = "";
                                 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, sp_ifrepeat, sp_instr, sp_checksalecode, out ErrorMessage))
+                                    if (!LogicHandler.CheckSNBeforeLoad(LabelDataGridView.Rows[i].Cells["cm_makecode"].Value.ToString(), LabelDataGridView.Rows[i].Cells["New_BarCode"].Value.ToString(), sp_repcode, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_instr, sp_checksalecode, out ErrorMessage,out userprodcode))
                                     {
                                         OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
                                         LoadData(sncode_1, sender, new KeyEventArgs(Keys.Enter));

+ 4 - 2
UAS-MES/FunctionCode/Make/Make_Decompose_Ex.cs

@@ -263,7 +263,7 @@ namespace UAS_MES.Make
                             }
                             dtbar = new DataTable();
                             sql.Clear();
-                            sql.Append("select max(sp_id)sp_id,max(sp_detno)sp_detno,max(sp_instr)sp_instr,min(sp_ifrepeat)sp_ifrepeat,sp_fsoncode,max(sp_barcoderule)");
+                            sql.Append("select max(sp_repcode)sp_repcode,max(sp_id)sp_id,max(sp_detno)sp_detno,max(sp_instr)sp_instr,min(sp_ifrepeat)sp_ifrepeat,sp_fsoncode,max(sp_barcoderule)");
                             sql.Append("sp_barcoderule, min(sp_checksalecode)sp_checksalecode,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 ");
@@ -280,14 +280,16 @@ 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_repcode = dtbar.Rows[0]["sp_repcode"].ToString();
                                 string sp_ifrepeat = dtbar.Rows[0]["sp_ifrepeat"].ToString();
                                 string sp_barcoderule = dtbar.Rows[0]["sp_barcoderule"].ToString();
                                 string sp_checksalecode = dtbar.Rows[0]["sp_checksalecode"].ToString();
                                 string sp_instr = dtbar.Rows[0]["sp_instr"].ToString();
+                                string userprodcode = "";
                                 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, sp_ifrepeat, sp_instr, sp_checksalecode, out ErrorMessage))
+                                    if (!LogicHandler.CheckSNBeforeLoad(LabelDataGridView.Rows[i].Cells["cm_makecode"].Value.ToString(), LabelDataGridView.Rows[i].Cells["New_BarCode"].Value.ToString(), sp_repcode, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_instr, sp_checksalecode, out ErrorMessage,out userprodcode))
                                     {
                                         OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
                                         LoadData(sncode_1, sender, new KeyEventArgs(Keys.Enter));

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

@@ -198,12 +198,14 @@ namespace UAS_MES.Make
                             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_repcode = dt1.Rows[RemainIndex]["sp_repcode"].ToString();
                             string sp_ifforsn = dt1.Rows[RemainIndex]["sp_ifforsn"].ToString();
                             string sp_barcoderule = dt1.Rows[RemainIndex]["sp_barcoderule"].ToString();
                             string sp_checkbarcode = dt1.Rows[RemainIndex]["sp_checkbarcode"].ToString();
                             string sp_checksalecode = dt1.Rows[RemainIndex]["sp_checksalecode"].ToString();
                             string sp_instr = dt1.Rows[RemainIndex]["sp_instr"].ToString();
-                            if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_instr, sp_checksalecode, out ErrorMessage))
+                            string userprodcode = "";
+                            if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_repcode, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_instr, sp_checksalecode, out ErrorMessage,out userprodcode))
                             {
                                 //判断采集的条码和本次采集的也不能重复
                                 if (CollectData.Contains(code.Text) && sp_ifrepeat != "-1")
@@ -232,7 +234,7 @@ namespace UAS_MES.Make
                                 {
                                     sp_soncode = ErrorMessage;
                                 }
-                                Save_OtherCode(sp_fsoncode, sp_soncode, make_code, sn_code.Text, sp_id);
+                                Save_OtherCode(sp_fsoncode, userprodcode==""? sp_soncode: userprodcode, make_code, sn_code.Text, sp_id);
                             }
                             else
                             {
@@ -412,7 +414,7 @@ namespace UAS_MES.Make
             //单独用一个DataTable存储一个
             dt1 = new DataTable();
             sql.Clear();
-            sql.Append("select max(sp_id)sp_id,max(sp_detno)sp_detno,min(sp_ifrepeat)sp_ifrepeat,max(sp_checkbarcode)sp_checkbarcode,min(sp_instr)sp_instr,min(sp_checksalecode)sp_checksalecode,");
+            sql.Append("select max(sp_repcode)sp_repcode,max(sp_id)sp_id,max(sp_detno)sp_detno,min(sp_ifrepeat)sp_ifrepeat,max(sp_checkbarcode)sp_checkbarcode,min(sp_instr)sp_instr,min(sp_checksalecode)sp_checksalecode,");
             sql.Append("sp_fsoncode,max(sp_barcoderule)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,max(substr(pr_spec,0,20))pr_spec from stepproduct left join product on pr_code=sp_fsoncode where ");

+ 5 - 3
UAS-MES/FunctionCode/Make/Make_FeedingCollectionCombineFix.cs

@@ -240,8 +240,10 @@ namespace UAS_MES.Make
                                             string sp_checkbarcode = dt1.Rows[RemainIndex]["sp_checkbarcode"].ToString();
                                             string sp_checksalecode = dt1.Rows[RemainIndex]["sp_checksalecode"].ToString();
                                             string sp_ifbeforhandle = dt1.Rows[RemainIndex]["sp_ifbeforhandle"].ToString();
+                                            string sp_repcode = dt1.Rows[RemainIndex]["sp_repcode"].ToString();
                                             string sp_instr = dt1.Rows[RemainIndex]["sp_instr"].ToString();
-                                            if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_instr, sp_checksalecode, out ErrorMessage))
+                                            string userprodcode = "";
+                                            if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_repcode, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_instr, sp_checksalecode, out ErrorMessage,out userprodcode))
                                             {
                                                 if (sp_ifbeforhandle == "是")
                                                 {
@@ -258,7 +260,7 @@ namespace UAS_MES.Make
                                                     OperateResult.AppendText(">>条码" + code.Text + "已经上料\n", Color.Red, code);
                                                     return;
                                                 }
-                                                CollectDataSonCode.Add(sp_soncode);
+                                                CollectDataSonCode.Add(userprodcode==""?sp_soncode: userprodcode);
                                                 SPID.Add(sp_id);
                                                 CollectData.Add(code.Text.Substring(0, code.Text.Length > 80 ? 80 : code.Text.Length));
                                                 LabelDataGridView.Rows[RemainIndex].Cells["BarCode"].Value = code.Text;
@@ -508,7 +510,7 @@ namespace UAS_MES.Make
             //单独用一个DataTable存储一个
             dt1 = new DataTable();
             sql.Clear();
-            sql.Append("select max(case when sp_ifbeforhandle= -1 then '是' else '否' end)sp_ifbeforhandle,max(sp_id)sp_id,min(sp_instr)sp_instr,max(sp_detno)sp_detno,min(sp_ifrepeat)sp_ifrepeat,max(sp_checkbarcode)sp_checkbarcode,min(sp_checksalecode)sp_checksalecode,");
+            sql.Append("select max(sp_repcode)sp_repcode,max(case when sp_ifbeforhandle= -1 then '是' else '否' end)sp_ifbeforhandle,max(sp_id)sp_id,min(sp_instr)sp_instr,max(sp_detno)sp_detno,min(sp_ifrepeat)sp_ifrepeat,max(sp_checkbarcode)sp_checkbarcode,min(sp_checksalecode)sp_checksalecode,");
             sql.Append("sp_fsoncode,max(sp_barcoderule)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,max(substr(pr_spec,0,20))pr_spec from stepproduct left join product on pr_code=sp_fsoncode where ");

+ 4 - 2
UAS-MES/FunctionCode/Make/Make_PreFeedingCollection.cs

@@ -125,6 +125,7 @@ namespace UAS_MES.Make
                                 GetMainCode = false;
                             }
                             string sp_soncode = "";
+                            string userprodcode = "";
                             string sp_fsoncode = "";
                             string sp_prefix = "";
                             string sp_regex = "";
@@ -156,6 +157,7 @@ namespace UAS_MES.Make
                                     sp_checkbarcode = dt1.Rows[i]["sp_checkbarcode"].ToString();
                                     sp_checksalecode = dt1.Rows[i]["sp_checksalecode"].ToString();
                                     sp_instr = dt1.Rows[i]["sp_instr"].ToString();
+                                  
                                     break;
                                 }
                             }
@@ -170,7 +172,7 @@ namespace UAS_MES.Make
                                 mainbarcode.Clear();
                                 return;
                             }
-                            if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_instr, sp_checksalecode, out ErrorMessage))
+                            if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text,"", sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_instr, sp_checksalecode, out ErrorMessage,out userprodcode))
                             {
                                 //查询条码是否存在预加工列表
                                 if (dh.CheckExist("BEFOREHANDPROCESS", "bhp_barcode='" + code.Text + "'"))
@@ -191,7 +193,7 @@ namespace UAS_MES.Make
                                 string maincode = LabelDataGridView.Rows[0].Cells["BarCode"].Value.ToString();
                                 sql.Clear();
                                 sql.Append("insert into BEFOREHANDPROCESS(bhp_id,bhp_maincode,bhp_barcode,bhp_prodcode,bhp_indate,bhp_inman)");
-                                sql.Append("values(BEFOREHANDPROCESS_seq.nextval,'" + maincode + "','" + code.Text + "','" + sp_fsoncode + "',sysdate,'" + User.UserCode + "')");
+                                sql.Append("values(BEFOREHANDPROCESS_seq.nextval,'" + maincode + "','" + code.Text + "','" + userprodcode==""? sp_fsoncode: userprodcode + "',sysdate,'" + User.UserCode + "')");
                                 dh.ExecuteSql(sql.GetString(), "insert");
                                 OperateResult.AppendText(">> 条码" + code.Text + "上料成功\n", Color.Green, code);
                                 code.Clear();

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

@@ -1227,10 +1227,16 @@ 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, string iIfRepeat, string iInstr, string iChecksalecode, out string ErrMessage)
+        public static bool CheckSNBeforeLoad(string iMakeCode, string iSN, string sp_repcode, string iFSonCode, string iSonCode, string iRule, string iPrefix, string iLength, string iIfRepeat, string iInstr, string iChecksalecode, out string ErrMessage,out string userprodcode)
         {
             DataTable dt;
             ErrMessage = "";
+            userprodcode = "";
+            if (dh.CheckExist("MaterialBanned", "MB_BARCODE='" + iSN + "'"))
+            {
+                ErrMessage = iSN + "在禁止上料清单中,不允许绑定";
+                return false;
+            }
             switch (iRule)
             {
                 case "TSN":
@@ -1253,13 +1259,14 @@ namespace UAS_MES.PublicMethod
                             return false;
                         }
                         //ms_salecode是否等于工单的SaleCode
-                        if (iSonCode != dt.Rows[0]["ms_prodcode"].ToString())
+                        if (iSonCode != dt.Rows[0]["ms_prodcode"].ToString()&& !sp_repcode.Contains(dt.Rows[0]["ms_prodcode"].ToString()))
                         {
                             ErrMessage = "序列号对应的物料不是:" + iSonCode;
                             return false;
                         }
                         else
                         {
+                            userprodcode = dt.Rows[0]["ms_prodcode"].ToString();
                             return true;
                         }
                     }
@@ -1363,6 +1370,7 @@ namespace UAS_MES.PublicMethod
                 default:
                     break;
             }
+           
             return false;
         }