Hcsy hace 8 años
padre
commit
eecf23ea40

+ 163 - 36
UAS-MES/FunctionCode/Warehouse/Warehouse_FinishedProductOut.cs

@@ -97,7 +97,7 @@ namespace UAS_MES.Warehouse
                     sql.Append("select pim_type,pim_outboxcode from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and NVL(PIM_OUTBOXCODE,' ')<>' ' AND pim_type ='BOX' GROUP BY pim_outboxcode,pim_type");
                     DataTable dtout = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                     boxqtycount += dtout.Rows.Count;
-                    boxqtycount += int.Parse(dh.getFieldDataByCondition("package", "nvl(sum(pa_packageqty),0)", " pa_outboxcode in (select pim_outboxcode from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and NVL(PIM_OUTBOXCODE,' ')<>' ' AND  pim_type ='PALLET' GROUP BY pim_outboxcode)").ToString());
+                    boxqtycount += int.Parse(dh.getFieldDataByCondition("package", "count(1)", " pa_mothercode in (select pim_outboxcode from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and NVL(PIM_OUTBOXCODE,' ')<>' ' AND  pim_type ='PALLET' GROUP BY pim_outboxcode) and pa_outno is null").ToString());
                     boxqty.Text = boxqtycount.ToString();
                 }
                 pi_type_check.Checked = true;
@@ -115,7 +115,7 @@ namespace UAS_MES.Warehouse
                     sql.Append("select pim_type,pim_outboxcode from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and NVL(PIM_OUTBOXCODE,' ')<>' ' AND pim_type ='BOX' GROUP BY pim_outboxcode,pim_type");
                     DataTable dtout = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                     boxqtycount += dtout.Rows.Count;
-                    boxqtycount += int.Parse(dh.getFieldDataByCondition("package", "nvl(sum(pa_packageqty),0)", " pa_outboxcode in (select pim_outboxcode from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and NVL(PIM_OUTBOXCODE,' ')<>' ' AND  pim_type ='PALLET' GROUP BY pim_outboxcode)").ToString());
+                    boxqtycount += int.Parse(dh.getFieldDataByCondition("package", "count(1)", " pa_mothercode in (select pim_outboxcode from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and NVL(PIM_OUTBOXCODE,' ')<>' ' AND  pim_type ='PALLET' GROUP BY pim_outboxcode) and pa_outno is null").ToString());
                     boxqty.Text = boxqtycount.ToString();
                 }
                 pi_type_check.Checked = false;
@@ -199,6 +199,18 @@ namespace UAS_MES.Warehouse
                         }
                         else
                         {
+                            sql.Clear();
+                            sql.Append("select DISTINCT pd_outboxcode from PACKAGEDETAIL where pd_barcode in (select pim_mac from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and pim_inorout='OUT' and PIM_TYPE = ' ')");
+                            DataTable datatable = (DataTable)dh.ExecuteSql(sql.GetString(),"select");
+                            if (datatable.Rows.Count > 0)
+                            {
+                                for (int i = 0; i < datatable.Rows.Count; i++)
+                                {
+                                    if (dh.getFieldDataByCondition("makeserial left join PACKAGEDETAIL on pd_barcode = ms_sncode and pd_makecode = ms_makecode", "count(1)", "pd_outboxcode = '" + datatable.Rows[i]["pd_outboxcode"].ToString() + "' and ms_outno is null").ToString() == "0") {
+                                        dh.UpdateByCondition("package", "pa_iostatus=2", "pa_outboxcode = '"+ datatable.Rows[i]["pd_outboxcode"].ToString() + "'");
+                                    }
+                                }
+                            }
                             List<String> ExeSQL = new List<string>();
                             ExeSQL.Add("update package set pa_iostatus=2 where exists (select 1 from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and pim_outboxcode=pa_outboxcode and ((pim_type='PALLET' AND PA_TYPE=3) OR (PIM_TYPE='BOX' AND PA_TYPE IN(1,2)))) AND PA_OUTNO='" + pi_inoutno.Text + "'");
                             ExeSQL.Add("update makeserial set ms_iostatus=2 where ms_outno='" + pi_inoutno.Text + "' and exists(select 1 from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and pim_mac=ms_sncode and pim_inorout='OUT')");
@@ -249,7 +261,7 @@ namespace UAS_MES.Warehouse
                             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                             if (dt.Rows.Count > 0)
                             {
-                                if (!checkinput(dt, "栈板号"))
+                                if (!checkinput(dt, "栈板号", input.Text))
                                     return;
                                 pa_makecode = dt.Rows[0]["pa_makecode"].ToString();
                             }
@@ -262,28 +274,92 @@ namespace UAS_MES.Warehouse
                                 return;
                             //更新箱号对应的出货单号
                             dh.UpdateByCondition("package", "pa_outno = '" + pi_inoutno.Text + "'", "pa_outboxcode = '" + input.Text + "'");
+                            //.UpdateByCondition("makeserial", "ms_outno='" + pi_inoutno.Text + "'", "ms_id in (select max(ms_id)  from makeserial where ms_sncode in (select v_barcode from MES_PACKAGE_VIEW where v_outboxcode = '" + input.Text + "') and ms_outno is null GROUP BY ms_sncode)");
+                            List<string> v_barcode = new List<string>();
+                            List<string> v_makecode = new List<string>();
+                            DataTable datatable = (DataTable)dh.ExecuteSql("select v_makecode,v_barcode from MES_PACKAGE_VIEW where v_outboxcode = '" + input.Text + "'", "select");
+                            for (int i = 0; i < datatable.Rows.Count; i++)
+                            {
+                                v_barcode.Add(datatable.Rows[i]["v_barcode"].ToString());
+                                v_makecode.Add(datatable.Rows[i]["v_makecode"].ToString());
+                            }
+                            dh.BatchInsert("update makeserial set ms_outno='" + pi_inoutno.Text + "' where ms_sncode = :v_barcode and ms_makecode = :v_makecode and ms_outno is null", new string[] { "v_barcode", "v_makecode" }, v_barcode.ToArray(), v_makecode.ToArray());
                             LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode, User.UserLineCode, User.UserSourceCode, "栈板" + input.Text + "出货备货", "栈板" + input.Text + "出货备货成功", "", input.Text);
                         }
                         else if (bigboxBtn.Checked)
                         {
                             string outboxcode = dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_sncode = '" + input.Text + "'").ToString();
                             string pa_makecode = "";
+                            string pa_mothercode = "";
+                            string pa_id = "";
                             if (outboxcode != "")
                             {
                                 input.Text = outboxcode;
                             }
                             sql.Clear();
-                            sql.Append("select pa_outboxcode,pa_makecode,pa_status,nvl(pa_iostatus,0) pa_iostatus,nvl(pa_downstatus,0)pa_downstatus,pa_outno, pa_mothercode from package where pa_outboxcode='" + input.Text + "' and pa_type in(1,2)");
+                            sql.Append("select pa_id,pa_outboxcode,pa_makecode,pa_status,nvl(pa_iostatus,0) pa_iostatus,nvl(pa_downstatus,0)pa_downstatus,pa_outno, pa_mothercode from package where pa_outboxcode='" + input.Text + "' and pa_type in(1,2)");
                             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                             if (dt.Rows.Count > 0)
                             {
                                 pa_makecode = dt.Rows[0]["pa_makecode"].ToString();
-                                if (dt.Rows[0]["pa_mothercode"].ToString() != "")
+                                pa_mothercode = dt.Rows[0]["pa_mothercode"].ToString();
+                                pa_id = dt.Rows[0]["pa_id"].ToString();
+                                if (pa_mothercode != "")
                                 {
-                                    OperateResult.AppendText("箱号" + input.Text + "已经装大箱或者栈板" + dt.Rows[0]["pa_mothercode"].ToString() + ",不允许单独出货\n", Color.Red, input);
-                                    return;
+                                    sql.Clear();
+                                    sql.Append("select pa_outboxcode,pa_status,pa_type,nvl(pa_iostatus,0) pa_iostatus,pa_makecode,pa_mothercode,nvl(pa_downstatus,0)pa_downstatus,pa_outno from package where pa_outboxcode='" + pa_mothercode + "'");
+                                    DataTable dtpall = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                                    if (dtpall.Rows.Count > 0)
+                                    {
+                                        if (dtpall.Rows[0]["pa_mothercode"].ToString() == "")
+                                        {
+                                            if (dtpall.Rows[0]["pa_type"].ToString() == "2")
+                                            {
+                                                if (!checkinput(dtpall, "箱号", pa_mothercode))
+                                                    return;
+                                            }
+                                            else if (dtpall.Rows[0]["pa_type"].ToString() == "3")
+                                            {
+                                                if (!checkinput(dtpall, "栈板", pa_mothercode))
+                                                    return;
+                                            }
+                                        }
+                                        else
+                                        {
+                                            sql.Clear();
+                                            sql.Append("select pa_outboxcode,pa_status,pa_type,nvl(pa_iostatus,0) pa_iostatus,pa_makecode,pa_mothercode,nvl(pa_downstatus,0)pa_downstatus,pa_outno from package where pa_outboxcode='" + dtpall.Rows[0]["pa_mothercode"].ToString() + "'");
+                                            DataTable dtpalltwo = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                                            if (dtpalltwo.Rows.Count > 0)
+                                            {
+                                                if (dtpalltwo.Rows[0]["pa_type"].ToString() == "2")
+                                                {
+                                                    if (!checkinput(dtpalltwo, "箱号", dtpall.Rows[0]["pa_mothercode"].ToString()))
+                                                        return;
+                                                }
+                                                else if (dtpalltwo.Rows[0]["pa_type"].ToString() == "3")
+                                                {
+                                                    if (!checkinput(dtpalltwo, "栈板", dtpall.Rows[0]["pa_mothercode"].ToString()))
+                                                        return;
+                                                }
+                                            }
+                                            else
+                                            {
+                                                OperateResult.AppendText("箱号" + input.Text + "已装大箱或栈板" + pa_mothercode + "不存在,出货失败\n", Color.Red, input);
+                                                return;
+                                            }
+                                        }
+                                        if (needMakeIn != "0")
+                                        {
+                                            dh.UpdateByCondition("package", "pa_iostatus = 1", "pa_outboxcode = '" + input.Text + "'");
+                                        }
+                                    }
+                                    else
+                                    {
+                                        OperateResult.AppendText("箱号" + input.Text + "已装大箱或栈板" + pa_mothercode + "不存在,出货失败\n", Color.Red, input);
+                                        return;
+                                    }
                                 }
-                                if (!checkinput(dt, "箱号"))
+                                if (!checkinput(dt, "箱号", input.Text))
                                     return;
                             }
                             else
@@ -295,6 +371,15 @@ namespace UAS_MES.Warehouse
                                 return;
                             //更新箱号对应的出货单号
                             dh.UpdateByCondition("package", "pa_outno = '" + pi_inoutno.Text + "'", "pa_outboxcode = '" + input.Text + "'");
+                            List<string> v_barcode = new List<string>();
+                            List<string> v_makecode = new List<string>();
+                            DataTable datatable = (DataTable)dh.ExecuteSql("select v_makecode,v_barcode from MES_PACKAGE_VIEW where v_outboxcode = '" + input.Text + "'", "select");
+                            for (int i = 0; i < datatable.Rows.Count; i++)
+                            {
+                                v_barcode.Add(datatable.Rows[i]["v_barcode"].ToString());
+                                v_makecode.Add(datatable.Rows[i]["v_makecode"].ToString());
+                            }
+                            dh.BatchInsert("update makeserial set ms_outno='" + pi_inoutno.Text + "' where ms_sncode = :v_barcode and ms_makecode = :v_makecode and ms_outno is null", new string[] { "v_barcode", "v_makecode" }, v_barcode.ToArray(), v_makecode.ToArray());
                             LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode, User.UserLineCode, User.UserSourceCode, "箱号" + input.Text + "出货备货", "箱号" + input.Text + "出货备货成功", "", input.Text);
                         }
                         else if (serBtn.Checked)
@@ -324,8 +409,33 @@ namespace UAS_MES.Warehouse
                                 }
                                 if (ms_outboxcode != "")
                                 {
-                                    OperateResult.AppendText("序列号" + input.Text + "有外箱号,不允许单独出货\n", Color.Red, input);
-                                    return;
+                                    //OperateResult.AppendText("序列号" + input.Text + "有外箱号,不允许单独出货\n", Color.Red, input);
+                                    //return;
+                                    string outpackcode = dh.getFieldDataByCondition("MES_PACKAGE_VIEW", "max(v_outboxcode)", "V_BARCODE = '" + input.Text + "'").ToString();
+                                    sql.Clear();
+                                    sql.Append("select pa_outboxcode,pa_status,pa_type,nvl(pa_iostatus,0) pa_iostatus,pa_makecode,pa_mothercode,nvl(pa_downstatus,0)pa_downstatus,pa_outno from package where pa_outboxcode='" + outpackcode + "'");
+                                    DataTable dtpall = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                                    if (dtpall.Rows.Count > 0)
+                                    {
+                                        if (dtpall.Rows[0]["pa_mothercode"].ToString() == "")
+                                        {
+                                            if (dtpall.Rows[0]["pa_type"].ToString() == "2")
+                                            {
+                                                if (!checkinput(dtpall, "箱号", outpackcode))
+                                                    return;
+                                            }
+                                            else if (dtpall.Rows[0]["pa_type"].ToString() == "3")
+                                            {
+                                                if (!checkinput(dtpall, "栈板", outpackcode))
+                                                    return;
+                                            }
+                                        }
+                                    }
+                                    else
+                                    {
+                                        OperateResult.AppendText("序列号" + input.Text + "已装箱或栈板" + outpackcode + "不存在,出货失败\n", Color.Red, input);
+                                        return;
+                                    }
                                 }
                                 if (ms_downstatus != "0")
                                 {
@@ -448,6 +558,16 @@ namespace UAS_MES.Warehouse
                                     OperateResult.AppendText("栈板号" + input.Text + "所属出货单号" + pa_outno + "与当前所选出货单号" + pi_inoutno.Text + "\n", Color.Red, input);
                                     return;
                                 }
+
+                                List<string> pim_mac = new List<string>();
+                                List<string> pim_prodcode = new List<string>();
+                                DataTable datatable = (DataTable)dh.ExecuteSql("select pim_prodcode,pim_mac from  prodiomac where pim_outboxcode = '" + input.Text + "' and pim_type='PALLET' and pim_inorout='OUT'  AND pim_class='出货'", "select");
+                                for (int i = 0; i < datatable.Rows.Count; i++)
+                                {
+                                    pim_mac.Add(datatable.Rows[i]["pim_mac"].ToString());
+                                    pim_prodcode.Add(datatable.Rows[i]["pim_prodcode"].ToString());
+                                }
+                                dh.BatchInsert("update makeserial set ms_outno='' where ms_sncode = :pim_mac and ms_prodcode = :pim_prodcode and ms_outno = '" + pi_inoutno.Text + "'", new string[] { "pim_mac", "pim_prodcode" }, pim_mac.ToArray(), pim_prodcode.ToArray());
                                 dh.ExecuteSql("delete from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and pim_outboxcode='" + input.Text + "' and pim_type='PALLET' and pim_inorout='OUT'  AND pim_class='出货'", "delete");
                                 dh.UpdateByCondition("package", "pa_outno=''", "pa_outboxcode='" + input.Text + "'");
                                 OperateResult.AppendText("栈板号" + input.Text + "取消备货成功\n", Color.Black, input);
@@ -492,13 +612,22 @@ namespace UAS_MES.Warehouse
                                     OperateResult.AppendText("箱号" + input.Text + "所属出货单号" + pa_outno + "与当前所选出货单号" + pi_inoutno.Text + "\n", Color.Red, input);
                                     return;
                                 }
-                                if (pa_mothercode != "")
+                                //if (pa_mothercode != "")
+                                //{
+                                //    OperateResult.AppendText("箱号" + input.Text + "已经装大箱或栈板:" + pa_mothercode + ",不允许单独操作\n", Color.Red, input);
+                                //    return;
+                                //}                              
+                                dh.UpdateByCondition("package", "pa_outno=''", "pa_outboxcode='" + input.Text + "'");
+                                List<string> pim_mac = new List<string>();
+                                List<string> pim_prodcode = new List<string>();
+                                DataTable datatable = (DataTable)dh.ExecuteSql("select pim_prodcode,pim_mac from  prodiomac where pim_outboxcode = '" + input.Text + "' and pim_type='BOX' and pim_inorout='OUT'  AND pim_class='出货'", "select");
+                                for (int i = 0; i < datatable.Rows.Count; i++)
                                 {
-                                    OperateResult.AppendText("箱号" + input.Text + "已经装大箱或栈板:" + pa_mothercode + ",不允许单独操作\n", Color.Red, input);
-                                    return;
+                                    pim_mac.Add(datatable.Rows[i]["pim_mac"].ToString());
+                                    pim_prodcode.Add(datatable.Rows[i]["pim_prodcode"].ToString());
                                 }
+                                dh.BatchInsert("update makeserial set ms_outno='' where ms_sncode = :pim_mac and ms_prodcode = :pim_prodcode and ms_outno = '" + pi_inoutno.Text + "'", new string[] { "pim_mac", "pim_prodcode" }, pim_mac.ToArray(), pim_prodcode.ToArray());
                                 dh.ExecuteSql("delete from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and pim_outboxcode='" + input.Text + "' and pim_type='BOX' and pim_inorout='OUT'  AND pim_class='出货'", "delete");
-                                dh.UpdateByCondition("package", "pa_outno=''", "pa_outboxcode='" + input.Text + "'");
                                 OperateResult.AppendText("箱号" + input.Text + "取消备货成功\n", Color.Black, input);
                                 LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode, User.UserLineCode, User.UserSourceCode, "箱号" + input.Text + "取消出货备货", "箱号" + input.Text + "取消出货备货成功", "", input.Text);
                             }
@@ -541,11 +670,11 @@ namespace UAS_MES.Warehouse
                                     OperateResult.AppendText("序列号" + input.Text + "所属出货单号" + ms_outno + "与当前所选出货单号" + pi_inoutno.Text + "\n", Color.Red, input);
                                     return;
                                 }
-                                if (ms_outboxcode != "")
-                                {
-                                    OperateResult.AppendText("箱号" + input.Text + "已经装大箱:" + ms_outboxcode + ",不允许单独操作\n", Color.Red, input);
-                                    return;
-                                }
+                                //if (ms_outboxcode != "")
+                                //{
+                                //    OperateResult.AppendText("箱号" + input.Text + "已经装大箱:" + ms_outboxcode + ",不允许单独操作\n", Color.Red, input);
+                                //    return;
+                                //}
                                 dh.ExecuteSql("delete from prodiomac where pim_id in (select pim_id from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and pim_mac='" + input.Text + "' and pim_inorout='OUT' and pim_class='出货')", "delete");
                                 dh.UpdateByCondition("makeserial", " ms_outno = ''", "ms_id = '" + ms_id + "'");
                                 LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "序列号" + input.Text + "取消出货备货", "序列号" + input.Text + "取消出货备货成功", input.Text, "");
@@ -599,7 +728,7 @@ namespace UAS_MES.Warehouse
             }
             sql.Clear();
             sql.Append("insert into prodiomac(pim_id,pim_inoutno,pim_piid,pim_prodcode,pim_mac,pim_indate,pim_inman,pim_type,pim_outboxcode,pim_inorout,pim_class)");
-            sql.Append("select prodiomac_seq.nextval,'" + pi_inoutno.Text + "','" + pi_id.Text + "',v_prodcode,v_barcode,sysdate,'" + User.UserCode + "','" + pib_type + "','" + input.Text + "','OUT','出货' from mes_package_view where v_outboxcode='" + input.Text + "'");
+            sql.Append("select prodiomac_seq.nextval,'" + pi_inoutno.Text + "','" + pi_id.Text + "',v_prodcode,ms_sncode,sysdate,'" + User.UserCode + "','" + pib_type + "','" + input.Text + "','OUT','出货' from mes_package_view left join makeserial on ms_sncode=v_barcode and ms_makecode=v_makecode where v_outboxcode='" + input.Text + "' and ms_outno is null");
             dh.ExecuteSql(sql.GetString(), "insert");
         }
 
@@ -619,7 +748,7 @@ namespace UAS_MES.Warehouse
                 sql.Clear();
                 sql.Append("select ms_prodcode,ms_salecode,cn  from (select ms_prodcode,ms_salecode,count(1)cn from mes_package_view left join makeserial on ms_sncode=v_barcode and ms_makecode=v_makecode  where v_outboxcode='" + input.Text + "' ");
                 sql.Append(" group by ms_prodcode,ms_salecode) left join (select pd_ordercode,pd_prodcode,outqty-nvl((select count(1) from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and pim_prodcode=pd_prodcode),0)ungetqty");
-                sql.Append("  from (select pd_ordercode,pd_prodcode,sum(pd_outqty)outqty from prodiodetail where pd_piid=" + pi_id.Text + " group by pd_prodcode,pd_ordercode)) on ms_prodcode=pd_prodcode where nvl(pd_prodcode,' ')<>' ' and ms_salecode<>pd_ordercode or(ms_salecode=pd_ordercode and cn>nvl(ungetqty,0))");
+                sql.Append("  from (select pd_ordercode,pd_prodcode,sum(pd_outqty)outqty from prodiodetail where pd_piid=" + pi_id.Text + " group by pd_prodcode,pd_ordercode)) on ms_prodcode=pd_prodcode where nvl(pd_prodcode,' ')<>' ' and ms_salecode<>pd_ordercode and ms_outno is null and or(ms_salecode=pd_ordercode and cn>nvl(ungetqty,0))");
                 DataTable dtAA = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                 if (dtAA.Rows.Count > 0)
                 {
@@ -647,51 +776,49 @@ namespace UAS_MES.Warehouse
             return true;
         }
 
-        private Boolean checkinput(DataTable dt, string type)
+        private Boolean checkinput(DataTable dt, string type, string inputmessage)
         {
-            if (dt.Rows[0]["pa_outno"].ToString() != "")
-            {
-                OperateResult.AppendText(type + input.Text + "已经被出货单:" + dt.Rows[0]["pa_outno"].ToString() + "采集,请重新输入\n", Color.Red, input);
-                return false;
-            }
             if (dt.Rows[0]["pa_status"].ToString() != "1")
             {
-                OperateResult.AppendText(type + input.Text + "未封装,请重新输入\n", Color.Red, input);
+                OperateResult.AppendText(type + inputmessage + "未封装,请重新输入\n", Color.Red, input);
                 return false;
             }
             else if (dt.Rows[0]["pa_status"].ToString() == "2")
             {
-                OperateResult.AppendText(type + input.Text + "已出库,请重新输入\n", Color.Red, input);
+                OperateResult.AppendText(type + inputmessage + "已出库,请重新输入\n", Color.Red, input);
                 return false;
             }
             if (dt.Rows[0]["pa_iostatus"].ToString() == "2")
             {
-                OperateResult.AppendText(type + input.Text + "已经出货\n", Color.Red, input);
+                OperateResult.AppendText(type + inputmessage + "已经出货\n", Color.Red, input);
                 return false;
             }
             if (dt.Rows[0]["pa_iostatus"].ToString() == "3")
             {
-                OperateResult.AppendText(type + input.Text + "处于销售退货状态\n", Color.Red, input);
+                OperateResult.AppendText(type + inputmessage + "处于销售退货状态\n", Color.Red, input);
                 return false;
             }
             if (needMakeIn != "0")
             {
                 if (dt.Rows[0]["pa_iostatus"].ToString() != "1")
                 {
-                    OperateResult.AppendText(type + input.Text + "必须完工入库才允许出库\n", Color.Red, input);
+                    OperateResult.AppendText(type + inputmessage + "必须完工入库才允许出库\n", Color.Red, input);
                     return false;
                 }
             }
             if (dt.Rows[0]["pa_downstatus"].ToString() != "0")
             {
-                OperateResult.AppendText(type + input.Text + "处于下地状态,若需出货,请先取消下地\n", Color.Red, input);
+                OperateResult.AppendText(type + inputmessage + "处于下地状态,若需出货,请先取消下地\n", Color.Red, input);
                 return false;
             }
 
-            if (dt.Rows[0]["pa_outno"].ToString() != "")
+            if (input.Text == inputmessage)
             {
-                OperateResult.AppendText(type + input.Text + "已经被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集\n", Color.Red, input);
-                return false;
+                if (dt.Rows[0]["pa_outno"].ToString() != "")
+                {
+                    OperateResult.AppendText(type + inputmessage + "已经被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集\n", Color.Red, input);
+                    return false;
+                }
             }
             return true;
         }

+ 20 - 1
UAS-MES/FunctionCode/Warehouse/Warehouse_ProductMakeIn.cs

@@ -373,7 +373,16 @@ namespace UAS_MES.Warehouse
             }
             else
                 type = "栈板";
-
+            //dh.UpdateByCondition("makeserial", "ms_iostatus=1", "ms_id in (select max(ms_id)  from makeserial where ms_sncode in (select v_barcode from MES_PACKAGE_VIEW where v_outboxcode = '"+input.Text+"') GROUP BY ms_sncode)");
+            List<string> v_barcode = new List<string>();
+            List<string> v_makecode = new List<string>();
+            DataTable datatable = (DataTable)dh.ExecuteSql("select v_makecode,v_barcode from MES_PACKAGE_VIEW where v_outboxcode = '" + input.Text + "'", "select");
+            for (int i = 0; i < datatable.Rows.Count; i++)
+            {
+                v_barcode.Add(datatable.Rows[i]["v_barcode"].ToString());
+                v_makecode.Add(datatable.Rows[i]["v_makecode"].ToString());
+            }
+            dh.BatchInsert("update makeserial set ms_iostatus=1 where ms_sncode = :v_barcode and ms_makecode = :v_makecode", new string[] { "v_barcode", "v_makecode" }, v_barcode.ToArray(), v_makecode.ToArray());
             LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode, User.UserLineCode, User.UserSourceCode, type + "号" + input.Text + "完工入库", type + "号" + input.Text + "完工入库成功", "", input.Text);
             return;
         }
@@ -436,7 +445,17 @@ namespace UAS_MES.Warehouse
             sql.Append(" pim_outboxcode='" + input.Text + "' and pim_type='" + type + "' and pim_inorout='IN' AND pim_class='完工入库' )");
             dh.ExecuteSql(sql.GetString(), "delete");
             dh.UpdateByCondition("package", "pa_iostatus=0", "pa_id='" + pa_id + "'");
+            List<string> v_barcode = new List<string>();
+            List<string> v_makecode = new List<string>();
+            DataTable datatable = (DataTable)dh.ExecuteSql("select v_makecode,v_barcode from MES_PACKAGE_VIEW where v_outboxcode = '" + input.Text + "'", "select");
+            for (int i = 0; i < datatable.Rows.Count; i++)
+            {
+                v_barcode.Add(datatable.Rows[i]["v_barcode"].ToString());
+                v_makecode.Add(datatable.Rows[i]["v_makecode"].ToString());
+            }
+            dh.BatchInsert("update makeserial set ms_iostatus=0 where ms_sncode = :v_barcode and ms_makecode = :v_makecode", new string[] { "v_barcode", "v_makecode" }, v_barcode.ToArray(), v_makecode.ToArray());
             LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode, User.UserLineCode, User.UserSourceCode, type + "号" + input.Text + "取消完工入库", type + "号" + input.Text + "取消完工入库成功", "", input.Text);
+            //dh.UpdateByCondition("makeserial", "ms_iostatus=0", "ms_id in (select max(ms_id)  from makeserial where ms_sncode in (select v_barcode from MES_PACKAGE_VIEW where v_outboxcode = '" + input.Text + "') GROUP BY ms_sncode)");
             return;
         }