Эх сурвалжийг харах

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

Hcsy 8 жил өмнө
parent
commit
9b45caf99a

+ 14 - 9
UAS-MES/FunctionCode/Make/Make_BigBoxCollection.cs

@@ -255,7 +255,7 @@ namespace UAS_MES.Make
                         string error;
                         if (int.Parse(pa_totalqty.Text == "" ? "0" : pa_totalqty.Text) > 0)
                         {
-                            if (!LogicHandler.CheckPackRule(pr_packrule.Text, pa_outboxcode.Text, outboxcode.Text, pa_makecode.Text, pa_custcode.Text, pa_prodcode.Text, "大箱", out error))
+                            if (!LogicHandler.CheckPackRule(pr_packrule.Text, pa_outboxcode.Text, outboxcode.Text, pa_makecode.Text, pa_salecode.Text, pa_prodcode.Text, "大箱", out error))
                             {
                                 OperateResult.AppendText(">>" + error + "\n", Color.Red, outboxcode);
                                 return;
@@ -299,12 +299,12 @@ namespace UAS_MES.Make
                                         pa_makecode.Text = carton_macode;
                                         dh.ExecuteSql("update package set pa_makecode='" + carton_macode + "' where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
                                     }
-                                  
+
                                     //如果是线内并且下一工序等于当前岗位资源工序
                                     if (pa_nextstep != "" && pa_nextstep == User.CurrentStepCode)
                                     {
                                         LogicHandler.OutBoxStepPass(outboxcode.Text, pa_makecode.Text, User.UserSourceCode, User.UserCode, "栈板采集成功,栈板号:" + pa_outboxcode.Text, "栈板采集");
-                                    }                
+                                    }
                                     //更新箱号的NextStepCode
                                     if (pa_totalqty.Text == "1")
                                     {
@@ -320,8 +320,11 @@ namespace UAS_MES.Make
                                     {
                                         dh.ExecuteSql("update package set pa_status=1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
                                         OperateResult.AppendText("大箱" + pa_outboxcode.Text + "已装满,封箱成功");
-                                        pa_outboxcode.Focus();
-                                        pa_outboxcode.SelectAll();
+                                        if (!AutoOutBoxCode.Checked)
+                                        {
+                                            pa_outboxcode.Focus();
+                                            pa_outboxcode.SelectAll();
+                                        }
                                         if (AutoPrint.Checked)
                                         {
                                             OperateResult.AppendText(">>箱已装满,自动打印!\n", Color.Green);
@@ -429,8 +432,7 @@ namespace UAS_MES.Make
             {
                 if (dh.getFieldDataByCondition("package", "pa_status", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString() == "1")
                 {
-                   // doc = lbl.Documents.Open(ftpOperater.DownLoadTo + PrintLabel.Text);
-                    if (Print.CodeSoft(Tag.ToString(),ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), pa_makecode.Text, pa_prodcode.Text, "大箱标", "0", out ErrorMessage))
+                    if (Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), pa_makecode.Text, pa_prodcode.Text, "大箱标", "0", out ErrorMessage))
                     {
                         OperateResult.AppendText(">>打印箱号" + pa_outboxcode.Text + "\n", Color.Black);
                     }
@@ -438,8 +440,11 @@ namespace UAS_MES.Make
                     {
                         OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
                     }
-                    pa_outboxcode.Focus();
-                    pa_outboxcode.SelectAll();
+                    if (!AutoOutBoxCode.Checked)
+                    {
+                        pa_outboxcode.Focus();
+                        pa_outboxcode.SelectAll();
+                    }
                 }
                 else OperateResult.AppendText(">>必须封箱才能进行打印\n", Color.Red);
             }

+ 42 - 4
UAS-MES/FunctionCode/Make/Make_PackageCollection.cs

@@ -281,7 +281,7 @@ namespace UAS_MES.Make
                             return;
                         }
                         sql.Clear();
-                        sql.Append("select nvl(pa_iostatus,0)pa_iostatus,pa_outno,pa_mothercode from package where pa_outboxcode='" + pa_outboxcode.Text + "'");
+                        sql.Append("select nvl(pa_iostatus,0)pa_iostatus,pa_outno,pa_mothercode,pa_type from package where pa_outboxcode='" + pa_outboxcode.Text + "'");
                         dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                         string MotherBoxCode = "";
                         if (dt.Rows.Count > 0)
@@ -367,10 +367,29 @@ namespace UAS_MES.Make
                                     LoadGridData();
                                     LoadCheckQTY();
                                     dh.ExecuteSql("update packagedetail set pd_innerqty=(select pa_packageqty from package where pa_outboxcode='" + pa_outboxcode.Text + "') where pd_innerboxcode='" + pa_outboxcode.Text + "'", "update");
-                                    //如果母箱号不为空,需要更新总数
                                     if (MotherBoxCode != "")
                                     {
-                                        dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "' and pa_type=3", "update");
+                                        dt = (DataTable)dh.ExecuteSql("select pa_mothercode,pa_type from package where pa_outboxcode='" + MotherBoxCode + "'", "select");
+                                        //如果母箱号不为空,需要更新总数
+                                        if (dt.Rows.Count > 0)
+                                        {
+                                            if (dt.Rows[0]["pa_type"].ToString() == "2")
+                                            {
+                                                string MotherCode2 = dt.Rows[0]["pa_mothercode"].ToString();
+                                                //更新大箱数量
+                                                dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "'", "update");
+                                                //外层有栈板则更新栈板数量
+                                                if (MotherCode2 != "")
+                                                {
+                                                    dh.ExecuteSql("update packagedetail set pd_innerqty=(select sum(pd_innerqty) from packagedetail where pd_outboxcode='" + MotherBoxCode + "') where pd_innerboxcode='" + MotherBoxCode + "'", "update");
+                                                    dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherCode2 + "') where pa_outboxcode='" + MotherCode2 + "'", "update");
+                                                }
+                                            }
+                                            if (dt.Rows[0]["pa_type"] == "3")
+                                            {
+                                                dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "'", "update");
+                                            }
+                                        }
                                     }
                                     //采集完后如果是第一个装的序列号,把序列号的NextStepCode赋值给箱号
                                     if (pa_currentqty.Text == "1")
@@ -429,7 +448,26 @@ namespace UAS_MES.Make
                                 //如果母箱号不为空,需要更新总数
                                 if (MotherBoxCode != "")
                                 {
-                                    dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "' and pa_type=3", "update");
+                                    DataTable dt = (DataTable)dh.ExecuteSql("select pa_mothercode,pa_type from package where pa_outboxcode='" + MotherBoxCode + "'", "select");
+                                    if (dt.Rows.Count > 0)
+                                    {
+                                        if (dt.Rows[0]["pa_type"].ToString() == "2")
+                                        {
+                                            string MotherCode2 = dt.Rows[0]["pa_mothercode"].ToString();
+                                            //更新大箱数量
+                                            dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "'", "update");
+                                            //外层有栈板则更新栈板数量
+                                            if (MotherCode2 != "")
+                                            {
+                                                dh.ExecuteSql("update packagedetail set pd_innerqty=(select sum(pd_innerqty) from packagedetail where pd_outboxcode='" + MotherBoxCode + "') where pd_innerboxcode='" + MotherBoxCode + "'", "update");
+                                                dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherCode2 + "') where pa_outboxcode='" + MotherCode2 + "'", "update");
+                                            }
+                                        }
+                                        if (dt.Rows[0]["pa_type"] == "3")
+                                        {
+                                            dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "'", "update");
+                                        }
+                                    }
                                 }
                                 LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "卡通箱采集", "卡通箱" + pa_outboxcode.Text + "取消采集成功", sn_code.Text, "");
                                 LoadGridData();

+ 40 - 2
UAS-MES/FunctionCode/Make/Make_PackageCollectionWeigh.cs

@@ -401,7 +401,26 @@ namespace UAS_MES.Make
                                     //如果母箱号不为空,需要更新总数
                                     if (MotherBoxCode != "")
                                     {
-                                        dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "' and pa_type=3", "update");
+                                        DataTable dt = (DataTable)dh.ExecuteSql("select pa_mothercode,pa_type from package where pa_outboxcode='" + MotherBoxCode + "'", "select");
+                                        if (dt.Rows.Count > 0)
+                                        {
+                                            if (dt.Rows[0]["pa_type"].ToString() == "2")
+                                            {
+                                                string MotherCode2 = dt.Rows[0]["pa_mothercode"].ToString();
+                                                //更新大箱数量
+                                                dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "'", "update");
+                                                //外层有栈板则更新栈板数量
+                                                if (MotherCode2 != "")
+                                                {
+                                                    dh.ExecuteSql("update packagedetail set pd_innerqty=(select sum(pd_innerqty) from packagedetail where pd_outboxcode='" + MotherBoxCode + "') where pd_innerboxcode='" + MotherBoxCode + "'", "update");
+                                                    dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherCode2 + "') where pa_outboxcode='" + MotherCode2 + "'", "update");
+                                                }
+                                            }
+                                            if (dt.Rows[0]["pa_type"] == "3")
+                                            {
+                                                dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "'", "update");
+                                            }
+                                        }
                                     }
                                     //采集完后如果是第一个装的序列号,把序列号的NextStepCode赋值给箱号
                                     if (pa_currentqty.Text == "1")
@@ -471,7 +490,26 @@ namespace UAS_MES.Make
                                 //如果母箱号不为空,需要更新总数
                                 if (MotherBoxCode != "")
                                 {
-                                    dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "' and pa_type=3", "update");
+                                    DataTable dt = (DataTable)dh.ExecuteSql("select pa_mothercode,pa_type from package where pa_outboxcode='" + MotherBoxCode + "'", "select");
+                                    if (dt.Rows.Count > 0)
+                                    {
+                                        if (dt.Rows[0]["pa_type"].ToString() == "2")
+                                        {
+                                            string MotherCode2 = dt.Rows[0]["pa_mothercode"].ToString();
+                                            //更新大箱数量
+                                            dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "'", "update");
+                                            //外层有栈板则更新栈板数量
+                                            if (MotherCode2 != "")
+                                            {
+                                                dh.ExecuteSql("update packagedetail set pd_innerqty=(select sum(pd_innerqty) from packagedetail where pd_outboxcode='" + MotherBoxCode + "') where pd_innerboxcode='" + MotherBoxCode + "'", "update");
+                                                dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherCode2 + "') where pa_outboxcode='" + MotherCode2 + "'", "update");
+                                            }
+                                        }
+                                        if (dt.Rows[0]["pa_type"] == "3")
+                                        {
+                                            dh.ExecuteSql("update package set PA_TOTALQTY=(select sum(pd_innerqty) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode='" + MotherBoxCode + "') where pa_outboxcode='" + MotherBoxCode + "'", "update");
+                                        }
+                                    }
                                 }
                                 LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "卡通箱采集", "卡通箱" + pa_outboxcode.Text + "取消采集成功", sn_code.Text, "");
                                 LoadGridData();

+ 9 - 4
UAS_MesInterface(4.0)/MesHelper.cs

@@ -41,7 +41,7 @@ namespace BenQGuru.eMES.DLLService
         //用于存放批量执行的SQL
         List<string> sqls = new List<string>();
         //系统默认的的连接字符串
-        private string ConnectionStrings = "Data Source=192.168.230.200/orcl;User ID=MES;PassWord=select!#%*(;";
+        private string ConnectionStrings = "Data Source=117.25.180.218/orcl;User ID=MES_TEST;PassWord=select!#%*(;";
         //用户选择的数据库的连接字符串
         private OracleConnection connection;
         //用户选择的数据库的连接字符串
@@ -72,7 +72,7 @@ namespace BenQGuru.eMES.DLLService
             string[] ParamName = new string[] { "v_i_macode", "v_i_sourcecode", "v_i_sncode", "v_i_usercode", "v_o_macode", "v_o_msid", "v_o_errmsg" };
             CallProcedure("CS_CHECKSTEPSNANDMACODE", ParamName, ref param);
             oErrMessage = param[6];
-            DataTable dt = (DataTable)ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSN + "')", "select");
+            DataTable dt = (DataTable)ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_id=(  select max(ms_id) from makeserial where ms_sncode  in ( select '" + iSN + "' from dual union select sn from makesnrelation where beforesn='" + iSN + "' and sn<>' '  union select beforesn from makesnrelation where sn='" + iSN + "' and beforesn<>' '))", "select");
             string ms_status = "";
             string ms_stepcode = "";
             string ms_nextstepcode = "";
@@ -83,6 +83,11 @@ namespace BenQGuru.eMES.DLLService
                 ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
             }
             string stepcode = GetStepCodeBySource(iResCode);
+            if (ms_nextstepcode != "" && ms_nextstepcode != stepcode)
+            {
+                oErrMessage = "当前序列号下一工序" + ms_nextstepcode;
+                return false;
+            }
             if (oErrMessage == "" || oErrMessage == null || oErrMessage == "null" || (ms_status == "3" && stepcode == ms_stepcode))
             {
                 if (ms_status == "3")
@@ -362,8 +367,8 @@ namespace BenQGuru.eMES.DLLService
             }
             oErrMessage = "";
             sql.Clear();
-            sql.Append("select max(ms_id) from makeserial where ms_sncode in (select '" + iSN + "' from dual union select ");
-            sql.Append("beforesn from makesnrelation where sn='" + iSN + "' and beforesn<>' ')");
+            sql.Append("select max(ms_id) from makeserial where ms_sncode in (select '" + iSN + "' from dual union select sn from ");
+            sql.Append("makesnrelation where beforesn='" + iSN + "' and sn<>' '  union select beforesn from makesnrelation where sn='" + iSN + "' and beforesn<>' ')");
             DataTable dt = (DataTable)ExecuteSql(sql.ToString(), "select");
             string ms_id = dt.Rows[0][0].ToString();
             oMoCode = getFieldDataByCondition("MakeSerial", "ms_makecode", "ms_id='" + ms_id + "'").ToString();