来料检验入库单接口,单据已入,待验证单据数据完整
This commit is contained in:
@@ -165,5 +165,108 @@ LEFT JOIN dbo.PUBizFlow f ON f.iFlowID = a.iflowid
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Model.Purchase.Arrival GetModelNeedCheck(string Code)
|
||||
{
|
||||
|
||||
return this.GetListNeedCheck("a.cCode=@Code", new { Code }).FirstOrDefault();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<Model.Purchase.Arrival> GetListNeedCheck(string where, object param = null)
|
||||
{
|
||||
using (var conn = U8LoginContext.Instance.Connection)
|
||||
{
|
||||
// string strSQL = @"select a.id AS ArrivalId,a.cCode as ArrivalCode,a.cpersoncode,a.cpersonname,A.cbustype AS busType,a.cptcode as PTCode,a.iTaxRate as TaxRate,a.iexchrate as Exchrate,cexch_name as ExchName,cVenCode as VenCode,a.dDate as ArrivalDate,A.cVenCode AS SupplierCode,
|
||||
// B.Autoid as id,b.ID as ArrivalID,
|
||||
// b.cInvCode AS MaterialCode,
|
||||
// b.cBatch AS BatchNo,
|
||||
// b.fvalidinquan as RealQuantity,
|
||||
// b.ccomunitcode AS UnitCode,b.ioricost as oricost,b.ioritaxcost as oritaxcost ,b.icost as cost,b.iorimoney as orimoney,b.ioritaxprice as oritaxprice,b.iorisum as orisum,b.isum as sum,
|
||||
// B.iQuantity as Quantity,b.iposid as PosId ,B.CORDERCODE as OrderCode,C.POID as Poid,b.iNum,b.ccomunitcode,b.cunitid,b.cinva_unit,b.cinvm_unit,b.inspecexchrate,
|
||||
//Pos.cPosName
|
||||
// FROM pu_ArrBody b inner join pu_ArrHead a on a.id=b.id
|
||||
// inner join (select cinvcode as cinvcode1,iId from inventory) inventory on b.cinvcode=inventory.cinvcode1
|
||||
// Left Join PO_Podetails C WITH (NOLOCK) ON B.iPOsID = C.ID ,
|
||||
//(SELECT cinvcode,
|
||||
//STUFF(
|
||||
// (
|
||||
// SELECT ','+ cPosName FROM ( select b.cPosName,a.cInvCode,a.iQuantity from InvPositionSum a WITH (NOLOCK) left join Position b WITH (NOLOCK) on a.cPosCode=b.cPosCode
|
||||
// where a.iQuantity <>0) a WHERE b.cinvcode = a.cinvcode order by a.iQuantity desc FOR XML PATH('')
|
||||
// ),1 ,1, '') cPosName
|
||||
//FROM InvPositionSum b
|
||||
//GROUP BY cinvcode
|
||||
//) Pos -- on isnull (b.cInvCode,'')=isnull(Pos.cInvCode,'')
|
||||
// Where ( (1>0) AND (1>0) ) AND ( 1>0 ) and (isnull(cbustype,'')<>'委外加工') and isnull (b.cInvCode,'')=isnull(Pos.cInvCode,'')
|
||||
// And (1=1) and isnull(b.cbcloser,N'')=N'' And isnull(a.cverifier,'')<>''
|
||||
// And a.iBillType =N'0' and isnull(b.bGsp,N'')=N'0' and (isnull(b.iQuantity,0)-isnull(b.fRefuseQuantity,0)>isnull(b.fValidInQuan,0) or (b.igrouptype=2
|
||||
// and isnull(b.inum,0)-isnull(b.frefusenum,0)>isnull(b.fvalidinnum,0))) and isnull(a.bStorageArrivalOrder,1)=1 and 1=1";
|
||||
string strSQL = @"select a.ID as ArrivalId,A.cCode as ArrivalCode,c.cpersonname,a.cPersonCode,a.cBusType as busType,
|
||||
a.cPTCode as PTCode,a.iTaxRate as TaxRate,a.iexchrate as Exchrate,a.cexch_name as ExchName,
|
||||
a.cVenCode as VenCode,a.dDate as ArrivalDate,A.cVenCode AS SupplierCode,
|
||||
B.Autoid as id,b.ID as ArrivalID,b.cInvCode AS MaterialCode, b.cBatch AS BatchNo, b.fvalidinquan as RealQuantity,
|
||||
b.ioricost as oricost,b.ioritaxcost as oritaxcost ,b.icost as cost,b.iorimoney as orimoney,b.ioritaxprice as oritaxprice,
|
||||
b.iorisum as orisum,b.isum as sum,B.iQuantity as Quantity,b.iposid as PosId ,B.CORDERCODE as OrderCode,b.iNum,
|
||||
b.cunitid,d.ccomunitcode AS UnitCode,CASE WHEN isnull(d.igrouptype, 0) = 0 THEN NULL ELSE unit2.ccomunitname END AS cinva_unit,
|
||||
Unit1.cComUnitName AS cinvm_unit,d.ccomunitcode,
|
||||
CASE WHEN isNull(b.cbcloser, '') = '' THEN 0 WHEN isNull(b.cbcloser, '')
|
||||
<> '' THEN 1 ELSE 2 END AS vouchstate, ISNULL(b.iQuantity, 0)
|
||||
- ISNULL(b.fRefuseQuantity, 0) - ISNULL(b.fValidInQuan, 0)
|
||||
- ISNULL(b.fInValidInQuan, 0) AS fininquantity, CASE WHEN isnull(d.igrouptype, 0)
|
||||
= 0 THEN NULL WHEN isnull(d.igrouptype, 0) = 1 THEN (isnull(b.iquantity, 0)
|
||||
- isnull(frefusequantity, 0) - isnull(fvalidinquan, 0) - isnull(finvalidinquan, 0))
|
||||
/ unit2.ichangrate WHEN isnull(d.igrouptype, 0) = 2 THEN (isnull(b.inum, 0) - isnull(frefusenum,
|
||||
0) - isnull(fvalidinnum, 0) - isnull(finvalidinnum, 0)) END AS fininnum, (CASE WHEN isnull(b.dPDate, '')
|
||||
= N'' AND isnull(b.imassDate, 0) = 0 THEN CONVERT(nvarchar(7), b.dvdate, 121)
|
||||
ELSE CONVERT(nvarchar(7), dateadd(month, - 1, b.dvdate), 121) END) AS dValidateDate,
|
||||
(CASE WHEN ((isnull(b.inum, 0) - isnull(b.finspectnum, 0)) = 0 OR
|
||||
isnull(b.inum, 0) IS NULL) AND isnull(d.igrouptype, 0)
|
||||
<> 1 THEN 0 ELSE (CASE WHEN isnull(d.igrouptype, 0)
|
||||
= 1 THEN unit2.ichangrate ELSE ((isnull(b.iquantity, 0) - isnull(b.finspectquantity, 0))
|
||||
/ (isnull(b.inum, 0) - isnull(b.finspectnum, 0))) END) END) AS inspecexchrate,
|
||||
e.POID as Poid,--Pos.cPosName,
|
||||
CASE WHEN isnull(f.bflowprocess, 0) = 1 THEN isnull(f.bstoragearrivalorder, 1) ELSE 1 END AS bstoragearrivalorder
|
||||
--,Pos.cPosName
|
||||
from PU_ArrivalVouch a
|
||||
|
||||
left join PU_ArrivalVouchs b on a.ID=b.ID
|
||||
left join Person c ON a.cPersonCode = c.cPersonCode
|
||||
LEFT JOIN Inventory d ON b.cInvCode =d.cInvCode
|
||||
LEFT JOIN dbo.ComputationUnit AS Unit2 ON B.cUnitID = Unit2.cComunitCode
|
||||
LEFT JOIN dbo.ComputationUnit AS Unit1 ON d.cComUnitCode = Unit1.cComunitCode
|
||||
Left Join PO_Podetails e ON B.iPOsID = e.ID
|
||||
LEFT JOIN dbo.PUBizFlow f ON f.iFlowID = a.iflowid
|
||||
|
||||
where
|
||||
(isnull(cbustype,'')<>'委外加工') --and isnull (b.cInvCode,'')=isnull(Pos.cInvCode,'')
|
||||
and isnull(b.cbcloser,'')='' And isnull(a.cverifier,'')<>''
|
||||
And a.iBillType ='0' and isnull(b.bGsp,'')='1' and (isnull(b.iQuantity,0)-isnull(b.fRefuseQuantity,0)>isnull(b.fValidInQuan,0) or (d.igrouptype=2
|
||||
and isnull(b.inum,0)-isnull(b.frefusenum,0)>isnull(b.fvalidinnum,0))) and isnull(bStorageArrivalOrder,1)=1 ";
|
||||
if (!string.IsNullOrEmpty(where))
|
||||
{
|
||||
strSQL += " and " + where;
|
||||
}
|
||||
|
||||
var lookup = new Dictionary<int, Model.Purchase.Arrival>();
|
||||
|
||||
var list = conn.Query<Model.Purchase.Arrival, Model.Purchase.ArrivalDetail, Model.Purchase.Arrival>(strSQL, (arrival, ArrivalDetail) =>
|
||||
{
|
||||
if (!lookup.TryGetValue(arrival.ArrivalId, out var _arrival))
|
||||
{
|
||||
lookup.Add(arrival.ArrivalId, arrival);
|
||||
}
|
||||
else
|
||||
{
|
||||
arrival = _arrival;
|
||||
}
|
||||
|
||||
arrival.ArrivalDtlLst.Add(ArrivalDetail);
|
||||
return arrival;
|
||||
}, param, null, true, "id", 10, System.Data.CommandType.Text);
|
||||
return lookup.Values;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,5 +126,11 @@ namespace NX.ERP.U8.Qmcheck
|
||||
return this.GetList(" ccheckcode=@Code", new { Code });
|
||||
}
|
||||
|
||||
|
||||
public Model.Qmcheck.Qmcheckvoucher GetModel(string Code)
|
||||
{
|
||||
return this.GetList(" ccheckcode=@Code", new { Code }).FirstOrDefault();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +125,87 @@ namespace NX.ERP.U8.Store
|
||||
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
|
||||
}
|
||||
}
|
||||
else if (puStoreIn.Source == "来料检验单")
|
||||
{
|
||||
var Arrival = new Purchase.ArrivalDAL().GetModelNeedCheck(puStoreIn.SourceCode);
|
||||
var Qmcheckvoucher = new Qmcheck.QmcheckDAL().GetModel(puStoreIn.Ccheckcode);
|
||||
if (Arrival == null)
|
||||
{
|
||||
throw new Exception("未知采购到货单,或到货单已经入库完成");
|
||||
}
|
||||
if (Qmcheckvoucher == null)
|
||||
{
|
||||
throw new Exception("未知质检单,或到货单已经入库完成");
|
||||
}
|
||||
headXml.setAttribute("cbustype", Arrival.BusType);
|
||||
headXml.setAttribute("iexchrate", Arrival.ExchRate);
|
||||
headXml.setAttribute("cexch_name", Arrival.ExchName);
|
||||
headXml.setAttribute("cvencode", Arrival.VenCode);
|
||||
headXml.setAttribute("carvcode", Arrival.ArrivalNo);
|
||||
headXml.setAttribute("ipurarriveid", Arrival.ArrivalId);
|
||||
headXml.setAttribute("darvdate", Arrival.ArrivalDate);
|
||||
headXml.setAttribute("itaxrate", Arrival.TaxRate);
|
||||
headXml.setAttribute("cptcode", Arrival.PTCode);
|
||||
headXml.setAttribute("cpersoncode", Arrival.CPersonCode);
|
||||
headXml.setAttribute("cpersonname", Arrival.cpersonname);
|
||||
IXMLDOMElement bodyXml;
|
||||
for (var n = 0; n < puStoreIn.Details.Count; n++)
|
||||
{
|
||||
var detail = puStoreIn.Details[n];
|
||||
var arrivalDetail = Arrival.ArrivalDtlLst.First(m => { return m.ArrivalDtlId == detail.SorceDetailId; });
|
||||
headXml.setAttribute("cordercode", arrivalDetail.OrderCode);
|
||||
bodyXml = domBody.createElement("z:row");
|
||||
if (arrivalDetail.cunitid != 0) //需要做辅助计量单位
|
||||
{
|
||||
var _inum = detail.Quantity / arrivalDetail.inspecexchrate;
|
||||
bodyXml.setAttribute("inum", _inum);
|
||||
bodyXml.setAttribute("cinva_unit", arrivalDetail.cinva_unit);
|
||||
bodyXml.setAttribute("cassunit", arrivalDetail.cunitid);
|
||||
}
|
||||
else
|
||||
{
|
||||
bodyXml.setAttribute("innum", 0);
|
||||
}
|
||||
bodyXml.setAttribute("cinvcode", detail.Invcode);
|
||||
bodyXml.setAttribute("iquantity", detail.Quantity);
|
||||
|
||||
bodyXml.setAttribute("cbvencode", "10001");
|
||||
bodyXml.setAttribute("inquantity", detail.Quantity); //应收数量,double类型
|
||||
bodyXml.setAttribute("cbatch", detail.Batch);
|
||||
bodyXml.setAttribute("cposition", detail.Position);
|
||||
bodyXml.setAttribute("cbarvcode", Arrival.ArrivalNo);
|
||||
bodyXml.setAttribute("dbarvdate", Arrival.ArrivalDate.ToString("yyyy-MM-dd"));
|
||||
bodyXml.setAttribute("ipurarriveid", Arrival.ArrivalId);
|
||||
bodyXml.setAttribute("iarrsid", detail.SorceDetailId);
|
||||
bodyXml.setAttribute("darvdate", DateTime.Today.ToShortDateString());
|
||||
bodyXml.setAttribute("editprop", "A");
|
||||
bodyXml.setAttribute("cpoid", arrivalDetail.OrderCode);
|
||||
bodyXml.setAttribute("iposid", arrivalDetail.posId);
|
||||
bodyXml.setAttribute("ccheckcode", Qmcheckvoucher.ccheckcode);
|
||||
bodyXml.setAttribute("icheckidbaks", Qmcheckvoucher.id);
|
||||
bodyXml.setAttribute("dcheckdate", Qmcheckvoucher.ddate.ToString("G"));
|
||||
bodyXml.setAttribute("ccheckpersoncode", Qmcheckvoucher.ccheckpersoncode);
|
||||
bodyXml.setAttribute("ccheckpersonname", Qmcheckvoucher.ccheckpersonname);
|
||||
bodyXml.setAttribute("itaxrate", Arrival.TaxRate);
|
||||
var info = new Account.Accinformation();
|
||||
var _oricost = (arrivalDetail.orisum / (1 + (Arrival.TaxRate / 100f)) / arrivalDetail.Qty);
|
||||
FormatHelp.GetUnitPriceByCost(detail.Quantity, _oricost /*arrivalDetail.oricost*/, Arrival.TaxRate, Arrival.ExchRate, out double iprice2, out double itaxprice2, out double isum2);
|
||||
bodyXml.setAttribute("iunitcost", arrivalDetail.cost);
|
||||
bodyXml.setAttribute("iprice", iprice2);//
|
||||
bodyXml.setAttribute("facost", arrivalDetail.cost);
|
||||
bodyXml.setAttribute("iaprice", iprice2);//
|
||||
bodyXml.setAttribute("itaxprice", itaxprice2);
|
||||
bodyXml.setAttribute("isum", isum2);
|
||||
FormatHelp.GetOriPriceByCost(detail.Quantity, _oricost /*arrivalDetail.oricost*/, Arrival.TaxRate, out double iorimoney2, out double ioritaxprice2, out double iorisum2, out double iunitcost2);
|
||||
bodyXml.setAttribute("ioricost", arrivalDetail.oricost);
|
||||
bodyXml.setAttribute("ioritaxcost", arrivalDetail.oritaxcost);
|
||||
bodyXml.setAttribute("iorimoney", iorimoney2);//
|
||||
bodyXml.setAttribute("ioritaxprice", ioritaxprice2);
|
||||
bodyXml.setAttribute("iorisum", iorisum2);
|
||||
bodyXml.setAttribute("irowno", domBody.selectSingleNode("//rs:data").childNodes.length + 1);
|
||||
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
|
||||
}
|
||||
}
|
||||
domHead.selectSingleNode("//rs:data").appendChild(headXml);
|
||||
|
||||
return AddRdVoucher(voucherParameter);
|
||||
|
||||
Reference in New Issue
Block a user