|
|
@@ -146,7 +146,7 @@ namespace UAS_MES_NEW.Warehouse
|
|
|
{
|
|
|
sql.Clear();
|
|
|
sql.Append("select pa_outboxcode,PA_TOTALQTY,pa_prodcode,pr_detail,pr_spec from package ");
|
|
|
- sql.Append("left join product on pr_code=pa_prodcode where pa_outno='" + pi_inoutno.Text + "' order by pa_outboxcode asc");
|
|
|
+ sql.Append("left join product on pr_code=pa_prodcode where pa_outno='" + pi_inoutno.Text + "' and pa_type=3 order by pa_outboxcode asc");
|
|
|
DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
BaseUtil.FillDgvWithDataTable(InOutDetailDGV, dt);
|
|
|
if (Combine.Checked)
|
|
|
@@ -250,7 +250,7 @@ namespace UAS_MES_NEW.Warehouse
|
|
|
OperateResult.AppendText("当前栈板数量" + PA_TOTALQTY + ",超出待采集数量\n", Color.Red, input);
|
|
|
return;
|
|
|
}
|
|
|
- if (!checkinsertprodiomac("栈板号"))
|
|
|
+ if (!checkinsertprodiomac("栈板号", input.Text))
|
|
|
return;
|
|
|
//更新箱号对应的出货单号
|
|
|
dh.UpdateByCondition("package", "pa_outno = '" + pi_inoutno.Text + "'", "pa_outboxcode = '" + input.Text + "'");
|
|
|
@@ -272,19 +272,23 @@ namespace UAS_MES_NEW.Warehouse
|
|
|
string pa_makecode = "";
|
|
|
string pa_prodcode = "";
|
|
|
string pr_packrule = "";
|
|
|
+ string pa_salecode = "";
|
|
|
+ string pa_mothercode = "";
|
|
|
if (outboxcode != "")
|
|
|
{
|
|
|
input.Text = outboxcode;
|
|
|
}
|
|
|
sql.Clear();
|
|
|
- sql.Append("select pa_id,pr_palletqty,pr_packrule,pa_outboxcode,pa_makecode,pa_status,nvl(pa_iostatus,0) pa_iostatus,nvl(pa_downstatus,0)pa_downstatus,pa_prodcode,pa_outno, pa_mothercode from package left join product on pr_code=pa_prodcode where pa_outboxcode='" + input.Text + "' and pa_type in(1,2)");
|
|
|
+ sql.Append("select pa_id,pr_palletqty,pr_packrule,pa_salecode,pa_outboxcode,pa_mothercode,pa_makecode,pa_status,nvl(pa_iostatus,0) pa_iostatus,nvl(pa_downstatus,0)pa_downstatus,pa_prodcode,pa_outno, pa_mothercode from package left join product on pr_code=pa_prodcode 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();
|
|
|
pa_prodcode = dt.Rows[0]["pa_prodcode"].ToString();
|
|
|
- pa_standardqty.Text= dt.Rows[0]["pr_palletqty"].ToString();
|
|
|
- pr_packrule= dt.Rows[0]["pr_packrule"].ToString();
|
|
|
+ pa_standardqty.Text = dt.Rows[0]["pr_palletqty"].ToString();
|
|
|
+ pr_packrule = dt.Rows[0]["pr_packrule"].ToString();
|
|
|
+ pa_salecode = dt.Rows[0]["pa_salecode"].ToString();
|
|
|
+ pa_mothercode = dt.Rows[0]["pa_mothercode"].ToString();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -296,23 +300,30 @@ namespace UAS_MES_NEW.Warehouse
|
|
|
pa_outboxcode.Text = LogicHandler.GetOutBoxCode("PALLET", pa_makecode, pa_prodcode, User.UserCode);
|
|
|
}
|
|
|
//插入新的栈板号和箱号
|
|
|
- string pa_id=dh.GetSEQ("package_seq");
|
|
|
- dh.ExecuteSql("insert into package(PA_ID, PA_OUTBOXCODE,PA_PRODCODE,PA_LEVEL,PA_PACKAGEQTY,PA_TOTALQTY,PA_MAKECODE,PA_STATUS,PA_INDATE,PA_SALECODE,PA_TYPE,PA_CURRENTQTY,PA_PACKTYPE,PA_STANDARDQTY,PA_SCCODE)values" +
|
|
|
- "("+ pa_id + ",'"+ pa_outboxcode .Text+ "',case when nvl('"+ pr_packrule + "',' ')<>'MIX' then '"+ pa_prodcode + "' ELSE''END,3,0,0,case when '"+ pr_packrule + "'='MAKE' THEN '"+pa_makecode+"' ELSE '' END, 0,SYSDATE,case when '"+pr_packrule+"'='SALE' " +
|
|
|
- "then v_ms_salecode else ''end,1,0,"+ pr_packrule + ","+ pa_standardqty.Text + ",v_i_sourcecode)", "insert");
|
|
|
+ string pa_id = dh.getFieldDataByCondition("package", "pa_id", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString();
|
|
|
+ if (pa_id == "")
|
|
|
+ {
|
|
|
+ pa_id = dh.GetSEQ("package_seq");
|
|
|
+ dh.ExecuteSql("insert into package(PA_ID, PA_OUTBOXCODE,PA_PRODCODE,PA_LEVEL,PA_PACKAGEQTY,PA_TOTALQTY,PA_MAKECODE,PA_STATUS,PA_INDATE,PA_SALECODE,PA_TYPE,PA_CURRENTQTY,PA_PACKTYPE,PA_STANDARDQTY,PA_SCCODE,PA_OUTNO)values" +
|
|
|
+ "(" + pa_id + ",'" + pa_outboxcode.Text + "',case when nvl('" + pr_packrule + "',' ')<>'MIX' then '" + pa_prodcode + "' ELSE''END,3,0,0,case when '" + pr_packrule + "'='MAKE' THEN '" + pa_makecode + "' ELSE '' END, 0,SYSDATE,case when '" + pr_packrule + "'='SALE' " +
|
|
|
+ "then '" + pa_salecode + "' else ''end,3,0,'" + pr_packrule + "'," + pa_standardqty.Text + ",'" + User.UserSourceCode + "','"+pi_inoutno.Text+"')", "insert");
|
|
|
+ }
|
|
|
sql.Clear();
|
|
|
sql.Append("insert into packagedetail(pd_id, pd_paid, pd_outboxcode,pd_makecode,pd_prodcode,pd_innerboxcode, pd_innerqty,pd_builddate)");
|
|
|
sql.Append("select packagedetail_seq.nextval,'" + pa_id + "','" + pa_outboxcode.Text + "','" + pa_makecode + "','" + pa_prodcode + "','" + input.Text + "' ");
|
|
|
sql.Append(",(select nvl(sum(pd_innerqty),0) from packagedetail left join package on pa_id=pd_paid where pa_outboxcode=");
|
|
|
sql.Append("'" + input.Text + "'),sysdate from package where pa_outboxcode='" + input.Text + "'");
|
|
|
dh.ExecuteSql(sql.GetString(), "insert");
|
|
|
- //从之前的栈板号里面移除出来
|
|
|
- dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + pa_outboxcode.Text + "' and pd_innerboxcode='" + input.Text + "'","delete");
|
|
|
- //减少箱内容量
|
|
|
- dh.ExecuteSql("update package set pa_packageqty=pa_packageqty-1,pa_totalqty=pa_totalqty-(select pa_totalqty from package where pa_outboxcode='" + input.Text + "'),pa_currentqty=pa_currentqty-1,pa_status=0 where pa_outboxcode='" + pa_outboxcode.Text + "'","update");
|
|
|
- dh.ExecuteSql("update package set pa_mothercode='' where pa_outboxcode='" + input.Text + "'","update");
|
|
|
-
|
|
|
- if (!checkinsertprodiomac("箱号"))
|
|
|
+ dh.ExecuteSql("update package set pa_packageqty=pa_packageqty+1,pa_totalqty=pa_totalqty+(select pa_totalqty from package where pa_outboxcode='" + input.Text + "'),pa_currentqty=pa_currentqty+1,pa_status=1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
|
|
|
+ if (pa_mothercode != "")
|
|
|
+ {
|
|
|
+ //从之前的栈板号里面移除出来
|
|
|
+ dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + pa_mothercode + "' and pd_innerboxcode='" + input.Text + "'", "delete");
|
|
|
+ //减少箱内容量
|
|
|
+ dh.ExecuteSql("update package set pa_packageqty=pa_packageqty-1,pa_totalqty=pa_totalqty-(select pa_totalqty from package where pa_outboxcode='" + input.Text + "'),pa_currentqty=pa_currentqty-1,pa_status=0 where pa_outboxcode='" + pa_mothercode + "'", "update");
|
|
|
+ dh.ExecuteSql("update package set pa_mothercode='" + pa_outboxcode.Text + "' where pa_outboxcode='" + input.Text + "'", "update");
|
|
|
+ }
|
|
|
+ if (!checkinsertprodiomac("栈板", pa_outboxcode.Text))
|
|
|
return;
|
|
|
//更新箱号对应的出货单号
|
|
|
dh.UpdateByCondition("package", "pa_outno = '" + pi_inoutno.Text + "'", "pa_outboxcode = '" + input.Text + "'");
|
|
|
@@ -513,7 +524,7 @@ namespace UAS_MES_NEW.Warehouse
|
|
|
}
|
|
|
|
|
|
//插入prodiomac表
|
|
|
- private void insertprodiomac(string type)
|
|
|
+ private void insertprodiomac(string type, string iBox)
|
|
|
{
|
|
|
string pib_type = "";
|
|
|
if (type == "栈板号")
|
|
|
@@ -524,14 +535,17 @@ namespace UAS_MES_NEW.Warehouse
|
|
|
{
|
|
|
pib_type = "BOX";
|
|
|
}
|
|
|
+ if (type == "箱号") {
|
|
|
+ }
|
|
|
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,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");
|
|
|
+ sql.Append("select prodiomac_seq.nextval,'" + pi_inoutno.Text + "','" + pi_id.Text + "',v_prodcode,ms_sncode,sysdate,'" + User.UserCode + "','" + pib_type + "','" + iBox + "','OUT','出货'" +
|
|
|
+ " from mes_package_view left join makeserial on ms_sncode=v_barcode and ms_makecode=v_makecode where v_outboxcode='" + iBox + "' and ms_outno is null");
|
|
|
dh.ExecuteSql(sql.GetString(), "insert");
|
|
|
}
|
|
|
|
|
|
|
|
|
- private Boolean checkinsertprodiomac(string type)
|
|
|
+ private Boolean checkinsertprodiomac(string type, string iBox)
|
|
|
{
|
|
|
sql.Clear();
|
|
|
sql.Append("select wm_concat(v_barcode)data,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 + "' and nvl(ms_status,0)<>2 and rownum<20");
|
|
|
@@ -552,7 +566,7 @@ namespace UAS_MES_NEW.Warehouse
|
|
|
sql.Append("and ms_outno is null 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 1=1 where ms_prodcode<>pd_prodcode or ms_salecode<>pd_ordercode or (cn>nvl(ungetqty,0))");
|
|
|
DataTable dtAA = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
- insertprodiomac(type);
|
|
|
+ insertprodiomac(type, iBox);
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
@@ -562,13 +576,13 @@ namespace UAS_MES_NEW.Warehouse
|
|
|
sql.Append("and ms_outno is null group by ms_prodcode) left join (select 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_prodcode,sum(pd_outqty)outqty from prodiodetail where pd_piid=" + pi_id.Text + " group by pd_prodcode)) on 1=1 where ms_prodcode<>pd_prodcode or (cn>nvl(ungetqty,0))");
|
|
|
DataTable dtAA = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
- insertprodiomac(type);
|
|
|
+ insertprodiomac(type, iBox);
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
else if (dta.Rows[0]["pi_type"].ToString() == "自由出货")
|
|
|
{
|
|
|
- insertprodiomac(type);
|
|
|
+ insertprodiomac(type, iBox);
|
|
|
return true;
|
|
|
}
|
|
|
|