Преглед изворни кода

关键物料绑定比例设置

callm пре 5 дана
родитељ
комит
d2989657b1

+ 20 - 6
UAS_MES_YDCY/FunctionCode/Make/Make_FeedingCollection.cs

@@ -61,6 +61,10 @@ namespace UAS_MES_NEW.Make
 
         List<string> ResultStr = new List<string>();
 
+        List<string> ReturnUseRate = new List<string>();
+
+        List<string> ReturnSubFix = new List<string>();
+
         List<string> CollectDataSonCode = new List<string>();
 
         List<string> SPID = new List<string>();
@@ -169,7 +173,9 @@ namespace UAS_MES_NEW.Make
                             string sp_subnumlength = dt1.Rows[RemainIndex]["sp_subnumlength"].ToString();
                             string sp_rate = dt1.Rows[RemainIndex]["sp_rate"].ToString();
                             string resultstr = "";
-                            if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, sn_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_checksalecode, sp_subnum, sp_subnumlength, "0", sp_rate, out resultstr, out ErrorMessage))
+                            string subfix = "";
+                            string userate = "0";
+                            if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, sn_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_checksalecode, sp_subnum, sp_subnumlength, "0", sp_rate, out resultstr, out userate,out subfix, out ErrorMessage))
                             {
                                 //判断采集的条码和本次采集的也不能重复
                                 if (CollectData.Contains(code.Text) && sp_ifrepeat != "-1")
@@ -199,7 +205,7 @@ namespace UAS_MES_NEW.Make
                                     sp_soncode = ErrorMessage;
                                 }
                                 LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "上物料", sn_code.Text + "上物料" + code.Text + "料号" + sp_fsoncode, sn_code.Text, "");
-                                Save_OtherCode(sp_fsoncode, sp_soncode, make_code, sn_code.Text, sp_id, resultstr);
+                                Save_OtherCode(sp_fsoncode, sp_soncode, make_code, sn_code.Text, sp_id, resultstr, userate,subfix);
                             }
                             else
                             {
@@ -540,11 +546,13 @@ namespace UAS_MES_NEW.Make
         }
 
         //此类中通用的保存逻辑
-        private void Save_OtherCode(string sp_fsoncode, string sp_soncode, string ma_code, string ms_sncode, string sp_id, string resultstr)
+        private void Save_OtherCode(string sp_fsoncode, string sp_soncode, string ma_code, string ms_sncode, string sp_id, string resultstr,string userate,string subfix)
         {
             CollectDataSonCode.Add(sp_soncode);
             //采集成功提示
             ResultStr.Add(resultstr);
+            ReturnUseRate.Add(userate);
+            ReturnSubFix.Add(subfix);
             CollectData.Add(code.Text);
             if (!CheckBarcode.ContainsKey(sp_fsoncode))
             {
@@ -566,13 +574,13 @@ namespace UAS_MES_NEW.Make
             {
                 sql.Clear();
                 sql.Append("insert into Craftmaterial (cm_id ,cm_prodtype,cm_makecode,cm_maid,cm_maprodcode, cm_soncode, cm_mscode, cm_sncode, cm_stepcode, cm_stepname,cm_fsoncode,");
-                sql.Append("cm_craftcode,cm_craftname,cm_barcode,cm_inqty,cm_indate,cm_inman,cm_linecode,cm_wccode,cm_sourcecode,cm_spid,cm_status,cm_materialtype,cm_firstsn,cm_substr)");
+                sql.Append("cm_craftcode,cm_craftname,cm_barcode,cm_inqty,cm_indate,cm_inman,cm_linecode,cm_wccode,cm_sourcecode,cm_spid,cm_status,cm_materialtype,cm_firstsn,cm_substr,cm_subfix,cm_rate)");
                 sql.Append("select Craftmaterial_seq.nextval,sp_prodtype, ma_code, ma_id, ma_prodcode,:soncode,ms_code,ms_sncode,mcd_stepcode,");
                 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,:substr from make left join makecraftdetail on mcd_maid=ma_id  left join stepproduct on sp_stepcode=mcd_stepcode ");
+                sql.Append("'" + User.UserSourceCode + "',:sp_id,0,1,ms_firstsn,:substr,:subfix,:rate from make left join makecraftdetail on mcd_maid=ma_id  left join stepproduct on sp_stepcode=mcd_stepcode ");
                 sql.Append(" and sp_mothercode = ma_prodcode left join makeserial on ms_makecode=ma_code and sp_craftcode=ms_craftcode ");
                 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", "substr", "sp_id1", }, CollectDataSonCode.ToArray(), CollectData.ToArray(), SPID.ToArray(), ResultStr.ToArray(), SPID.ToArray());
+                dh.BatchInsert(sql.GetString(), new string[] { "soncode", "barcode", "sp_id", "substr", "subfix", "rate", "sp_id1", }, CollectDataSonCode.ToArray(), CollectData.ToArray(), SPID.ToArray(), ResultStr.ToArray(),ReturnSubFix.ToArray(),ReturnUseRate.ToArray(), SPID.ToArray());
                 try
                 {
                     string Log = "";
@@ -604,6 +612,9 @@ namespace UAS_MES_NEW.Make
                 CollectData.Clear();
                 TSN.Clear();
                 SPID.Clear();
+                ReturnUseRate.Clear();
+                ReturnSubFix.Clear();
+                ResultStr.Clear();
                 CheckBarcode.Clear();
                 CollectDataSonCode.Clear();
                 //采集成功,设置序列号栏目为空
@@ -641,6 +652,9 @@ namespace UAS_MES_NEW.Make
             SPID.Clear();
             TSN.Clear();
             CheckBarcode.Clear();
+            ReturnUseRate.Clear();
+            ReturnSubFix.Clear();
+            ResultStr.Clear();
             CollectData.Clear();
             CollectDataSonCode.Clear();
             if (dt1 != null)

+ 21 - 6
UAS_MES_YDCY/FunctionCode/Make/Make_FeedingCollectionReCall.cs

@@ -65,6 +65,11 @@ namespace UAS_MES_NEW.Make
 
         List<string> SPID = new List<string>();
 
+
+        List<string> ReturnUseRate = new List<string>();
+
+        List<string> ReturnSubFix = new List<string>();
+
         public Make_FeedingCollectionReCall()
         {
             InitializeComponent();
@@ -169,7 +174,9 @@ namespace UAS_MES_NEW.Make
                             string sp_subnumlength = dt1.Rows[RemainIndex]["sp_subnumlength"].ToString();
                             string sp_rate = dt1.Rows[RemainIndex]["sp_rate"].ToString();
                             string resultstr = "";
-                            if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, sn_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_checksalecode, sp_subnum, sp_subnumlength, ms_edistatus, sp_rate, out resultstr, out ErrorMessage))
+                            string subfix = "";
+                            string userate = "0";
+                            if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, sn_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_checksalecode, sp_subnum, sp_subnumlength, ms_edistatus, sp_rate, out resultstr, out userate, out subfix, out ErrorMessage))
                             {
                                 //判断采集的条码和本次采集的也不能重复
                                 if (CollectData.Contains(code.Text) && sp_ifrepeat != "-1")
@@ -199,7 +206,7 @@ namespace UAS_MES_NEW.Make
                                     sp_soncode = ErrorMessage;
                                 }
                                 LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "上物料", sn_code.Text + "上物料" + code.Text + "料号" + sp_fsoncode, sn_code.Text, "");
-                                Save_OtherCode(sp_fsoncode, sp_soncode, make_code, sn_code.Text, sp_id, resultstr);
+                                Save_OtherCode(sp_fsoncode, sp_soncode, make_code, sn_code.Text, sp_id, resultstr, userate, subfix);
                             }
                             else
                             {
@@ -540,9 +547,11 @@ namespace UAS_MES_NEW.Make
         }
 
         //此类中通用的保存逻辑
-        private void Save_OtherCode(string sp_fsoncode, string sp_soncode, string ma_code, string ms_sncode, string sp_id, string resultstr)
+        private void Save_OtherCode(string sp_fsoncode, string sp_soncode, string ma_code, string ms_sncode, string sp_id, string resultstr, string userate, string subfix)
         {
             CollectDataSonCode.Add(sp_soncode);
+            ReturnUseRate.Add(userate);
+            ReturnSubFix.Add(subfix);
             //采集成功提示
             ResultStr.Add(resultstr);
             CollectData.Add(code.Text);
@@ -566,13 +575,13 @@ namespace UAS_MES_NEW.Make
             {
                 sql.Clear();
                 sql.Append("insert into Craftmaterial (cm_id ,cm_prodtype,cm_makecode,cm_maid,cm_maprodcode, cm_soncode, cm_mscode, cm_sncode, cm_stepcode, cm_stepname,cm_fsoncode,");
-                sql.Append("cm_craftcode,cm_craftname,cm_barcode,cm_inqty,cm_indate,cm_inman,cm_linecode,cm_wccode,cm_sourcecode,cm_spid,cm_status,cm_materialtype,cm_firstsn,cm_substr)");
+                sql.Append("cm_craftcode,cm_craftname,cm_barcode,cm_inqty,cm_indate,cm_inman,cm_linecode,cm_wccode,cm_sourcecode,cm_spid,cm_status,cm_materialtype,cm_firstsn,cm_substr,cm_subfix,cm_rate)");
                 sql.Append("select Craftmaterial_seq.nextval,sp_prodtype, ma_code, ma_id, ma_prodcode,:soncode,ms_code,ms_sncode,mcd_stepcode,");
                 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,:substr from make left join makecraftdetail on mcd_maid=ma_id  left join stepproduct on sp_stepcode=mcd_stepcode ");
+                sql.Append("'" + User.UserSourceCode + "',:sp_id,0,1,ms_firstsn,:substr,:subfix,:rate from make left join makecraftdetail on mcd_maid=ma_id  left join stepproduct on sp_stepcode=mcd_stepcode ");
                 sql.Append(" and sp_mothercode = ma_prodcode left join makeserial on ms_makecode=ma_code and sp_craftcode=ms_craftcode ");
                 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", "substr", "sp_id1", }, CollectDataSonCode.ToArray(), CollectData.ToArray(), SPID.ToArray(), ResultStr.ToArray(), SPID.ToArray());
+                dh.BatchInsert(sql.GetString(), new string[] { "soncode", "barcode", "sp_id", "substr", "subfix", "rate", "sp_id1", }, CollectDataSonCode.ToArray(), CollectData.ToArray(), SPID.ToArray(), ResultStr.ToArray(), ReturnSubFix.ToArray(), ReturnUseRate.ToArray(), SPID.ToArray());
                 try
                 {
                     string Log = "";
@@ -605,6 +614,9 @@ namespace UAS_MES_NEW.Make
                 TSN.Clear();
                 SPID.Clear();
                 CheckBarcode.Clear();
+                ReturnUseRate.Clear();
+                ReturnSubFix.Clear();
+                ResultStr.Clear();
                 CollectDataSonCode.Clear();
                 //采集成功,设置序列号栏目为空
                 RemainIndex = 0;
@@ -642,6 +654,9 @@ namespace UAS_MES_NEW.Make
             TSN.Clear();
             CheckBarcode.Clear();
             CollectData.Clear();
+            ReturnUseRate.Clear();
+            ReturnSubFix.Clear();
+            ResultStr.Clear();
             CollectDataSonCode.Clear();
             if (dt1 != null)
                 BaseUtil.CleanDataTableData(dt1);

+ 1 - 1
UAS_MES_YDCY/FunctionCode/Make/Make_SNLabelCheckMidBox.cs

@@ -283,7 +283,7 @@ namespace UAS_MES_NEW.Make
                                 {
                                     double pr_miderror = double.Parse(dh.getFieldDataByCondition("product", "nvl(pr_miderror,0)", "pr_code='" + ma_prodcode.Text + "'").ToString());
                                     double avgweight = double.Parse(dh.getFieldDataByCondition("makeserial", "sum(ms_midboxweight)/50", " ms_makecode='" + ma_code.Text + "'").ToString());
-                                    dh.ExecuteSql("update product set PR_MIDBOXMINWEIGHT=(" + avgweight + "-" + pr_miderror + "), PR_MIDBOXMAXWEIGHT=(" + avgweight + "+" + pr_miderror + ") where pr_code=v_ms_prodcode", "update");
+                                    dh.ExecuteSql("update product set PR_MIDBOXMINWEIGHT=(" + avgweight + "-" + pr_miderror + "), PR_MIDBOXMAXWEIGHT=(" + avgweight + "+" + pr_miderror + ") where pr_code='"+ ma_prodcode .Text+ "'", "update");
                                 }
                                 sql.Clear();
                                 sql.Append("insert into labelchecklog(LCL_ID, LCL_SN, LCL_LABELTYPE, lcl_prefix,lcl_length, LCL_LABELVALUE, LCL_STEPCODE, LCL_SOURCECODE," +

+ 7 - 2
UAS_MES_YDCY/FunctionCode/Packing/Packing_PalletCollection.cs

@@ -53,7 +53,7 @@ namespace UAS_MES_NEW.Packing
         {
             try
             {
-                engine = new Engine(true);
+                //engine = new Engine(true);
             }
             catch
             {
@@ -245,6 +245,11 @@ namespace UAS_MES_NEW.Packing
                                 return;
                             }
                         }
+                        if (!LogicHandler.CheckMaterialRate("", pa_outboxcode.Text, outboxcode.Text, out ErrorMessage))
+                        {
+                            OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, outboxcode);
+                            return;
+                        }
                         dt = (DataTable)dh.ExecuteSql("select pa_totalqty,pa_mothercode,nvl(pa_status,0) pa_status from package where pa_outboxcode='" + outboxcode.Text + "'", "select");
                         if (dt.Rows.Count > 0)
                         {
@@ -474,7 +479,7 @@ namespace UAS_MES_NEW.Packing
                     {
                         List<string> SQLS = new List<string>();
                         SQLS.Add("update makeserial set ms_stepcode=(SUBSTR(ms_paststep,INSTR(ms_paststep, ',', -1, 2) + 1,INSTR(ms_paststep, ',', -1, 1) - INSTR(ms_paststep, ',', -1, 2) - 1)) where (ms_sncode,ms_makecode)" +
-                            "in(select v_barcode,v_makecode from mes_package_view where v_outboxcode='"+pa_outboxcode.Text+"')");
+                            "in(select v_barcode,v_makecode from mes_package_view where v_outboxcode='" + pa_outboxcode.Text + "')");
                         SQLS.Add("delete from packagedetail where pd_outboxcode='" + pa_outboxcode.Text + "'");
                         SQLS.Add("update package set pa_packageqty=0,pa_totalqty=0,pa_currentqty=0,pa_status=0 where pa_outboxcode='" + pa_outboxcode.Text + "'");
                         SQLS.Add("update package set pa_mothercode='' where pa_mothercode='" + pa_outboxcode.Text + "'");

+ 41 - 2
UAS_MES_YDCY/PublicMethod/LogicHandler.cs

@@ -1,4 +1,7 @@
-using LabelManager2;
+using DevExpress.XtraBars.Docking2010.Views.Widget;
+using DevExpress.XtraPrinting.Native;
+using LabelManager2;
+using NPOI.SS.Formula.Functions;
 using System;
 using System.Collections.Generic;
 using System.Data;
@@ -54,6 +57,30 @@ namespace UAS_MES_NEW.PublicMethod
             return false;
         }
 
+        public static bool CheckMaterialRate(string iMakeCode, string iPallteCode, string iBoxCode, out string ErrorMessage)
+        {
+            ErrorMessage = "";
+            DataTable dt = (DataTable)dh.ExecuteSql("select CM_SUBFIX,nvl(max(CM_RATE),0)CM_RATE,max(PA_STANDARDQTY)PA_STANDARDQTY,count(1)Packagenum from mes_package_view left join package on v_outboxcode=pa_outboxcode left join craftmaterial on cm_makecode=v_makecode" +
+                " and cm_sncode=v_barcode where v_outboxcode='" + iPallteCode + "' and CM_SUBFIX is not null group by CM_SUBFIX", "select");
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                double CM_RATE = double.Parse(dt.Rows[i]["CM_RATE"].ToString());
+                //已经装箱的序列号范围
+                double Packagenum = double.Parse(dt.Rows[i]["Packagenum"].ToString());
+                string CM_SUBFIX = dt.Rows[i]["CM_SUBFIX"].ToString();
+                double PA_STANDARDQTY = double.Parse(dt.Rows[i]["PA_STANDARDQTY"].ToString());
+
+                int row = dh.getRowCount("mes_package_view left join package on v_outboxcode=pa_outboxcode left join craftmaterial on cm_makecode=v_makecode and cm_sncode=v_barcode ", "v_outboxcode='" + iBoxCode + "' and CM_SUBFIX='" + CM_SUBFIX + "'");
+                if (Packagenum + row > PA_STANDARDQTY * CM_RATE)
+                {
+                    ErrorMessage = "后缀" + CM_SUBFIX + "已经装栈板" + Packagenum + ",当前箱号数量" + row + "超出允许装箱的比例" + (PA_STANDARDQTY * CM_RATE);
+                    return false;
+                }
+            }
+            return true;
+        }
+
+
         /// <summary>
         /// 判断工单是否已经下放
         /// </summary>
@@ -1221,11 +1248,13 @@ namespace UAS_MES_NEW.PublicMethod
             return param[4];
         }
 
-        public static bool CheckSNBeforeLoad(string iMakeCode, string iMsSncode, string iSN, string iFSonCode, string iSonCode, string iRule, string iPrefix, string iLength, string iIfRepeat, string iChecksalecode, string iSubNum, string iSubNumLength, string iEdiStatus, string iRate, out string Resultstr, out string ErrMessage)
+        public static bool CheckSNBeforeLoad(string iMakeCode, string iMsSncode, string iSN, string iFSonCode, string iSonCode, string iRule, string iPrefix, string iLength, string iIfRepeat, string iChecksalecode, string iSubNum, string iSubNumLength, string iEdiStatus, string iRate, out string Resultstr, out string UseRate, out string MatchFix, out string ErrMessage)
         {
             DataTable dt;
             ErrMessage = "";
             Resultstr = "";
+            UseRate = "0";
+            MatchFix = "";
             switch (iRule)
             {
                 case "TSN":
@@ -1350,13 +1379,18 @@ namespace UAS_MES_NEW.PublicMethod
                         {
                             int ma_qty = int.Parse(dh.getFieldDataByCondition("make", "ma_qty", "ma_code='" + iMakeCode + "'").ToString());
                             string[] kind = iRate.Split('|');
+                            //后缀是否匹配
+                            bool match = false;
                             for (int i = 0; i < kind.Length; i++)
                             {
                                 double precent = double.Parse(kind[i].Split('#')[1]);
                                 string subfix = (kind[i].Split('#')[0]);
                                 if (iSN.Substring(iSN.Length - subfix.Length) == subfix)
                                 {
+                                    match = true;
                                     double total = ma_qty * precent;
+                                    UseRate = precent.ToString();
+                                    MatchFix = subfix;
                                     int count = dh.getRowCount("craftmaterial", "cm_makecode='" + iMakeCode + "' and cm_fsoncode='" + iFSonCode + "' and cm_status=0 and substr(cm_barcode,-" + subfix.Length + ")='" + subfix + "'");
                                     if (count >= total)
                                     {
@@ -1365,6 +1399,11 @@ namespace UAS_MES_NEW.PublicMethod
                                     }
                                 }
                             }
+                            if (!match)
+                            {
+                                ErrMessage = "条码" + iSN + "后缀不匹配,不允许上料";
+                                return false;
+                            }
                         }
                     }
                     int sp_length = int.Parse(iLength != "" ? iLength : "0");