|
|
@ -205,6 +205,18 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
private static void AddMaterialReceive(UniApiEntities idb, ScpEntities wdb, string seq, int billtype) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string _recvQty = "SELECT RecQty, AsnBillNum, PoLine, PartCode, PoBillNum,Batch\n" + |
|
|
|
"FROM (SELECT SUM(a.Qty) AS RecQty, a.AsnBillNum, a.PoLine, a.PartCode, a.PoBillNum,a.batch\n" + |
|
|
|
" FROM V_TB_RECEIVE_DETAIL AS a INNER JOIN\n" + |
|
|
|
" V_TB_ASN_DETAIL AS B ON a.AsnBillNum = B.AsnBillNum AND a.PoLine = B.PoLine AND\n" + |
|
|
|
" a.PartCode = B.PartCode AND a.PoBillNum = B.PoBillNum and a.Batch=b.Batch\n" + |
|
|
|
" GROUP BY a.AsnBillNum, a.PoLine, a.PartCode, a.PoBillNum) AS d\n" + |
|
|
|
"WHERE (AsnBillNum = '{0}')"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var qadRcvDetailList = idb.xxwms_rc_det.Where(p => p.xxwms_rc_seq == seq&&p.xxwms_rc_qty_total>=0).ToList(); |
|
|
|
var scpRcvList = new List<TB_RECEIVE>(); |
|
|
|
var scpRcveDetailList = new List<TB_RECEIVE_DETAIL>(); |
|
|
@ -222,7 +234,7 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
} |
|
|
|
|
|
|
|
var firstqadData = qadDataList[0]; |
|
|
|
|
|
|
|
List<TB_RECEIVE_QTY> _lsQty = new List<TB_RECEIVE_QTY>(); |
|
|
|
var scpRcv = wdb.TB_RECEIVE.SingleOrDefault(p => p.RecvBillNum != null && p.RecvBillNum == qadRcvNbrList && p.Site==firstqadData.xxwms_rc_domain); |
|
|
|
|
|
|
|
//判断0100工厂的收货自动审核是否为允许
|
|
|
@ -267,6 +279,13 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
BillType = billtype |
|
|
|
}; |
|
|
|
scpRcvList.Add(scpRcv); |
|
|
|
if (!string.IsNullOrEmpty(scpRcv.AsnBillNum)) |
|
|
|
{ |
|
|
|
_lsQty = wdb.Database.SqlQuery<TB_RECEIVE_QTY>(_recvQty, scpRcv.RecvBillNum).ToList(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
scpRcv.PoBillNum = firstqadData.xxwms_rc_po_nbr;//采购单
|
|
|
|
scpRcv.AsnBillNum = firstqadData.xxwms_rc_ps_nbr;//发货单号
|
|
|
@ -292,6 +311,7 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
}); |
|
|
|
wdb.TB_ASN_DETAIL.AddOrUpdate(scpAsnDetail.ToArray()); |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var qadData in qadDataList) |
|
|
|
{ |
|
|
|
try |
|
|
@ -304,9 +324,10 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
p.PoLine == poLineNum && |
|
|
|
p.PartCode == qadData.xxwms_rc_part && |
|
|
|
p.Batch == qadData.xxwms_rc_lot |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
); |
|
|
|
if (scpRcvDetail == null) |
|
|
|
{ |
|
|
|
int istate = 0; |
|
|
@ -340,6 +361,23 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
BillType = billtype |
|
|
|
}; |
|
|
|
scpRcveDetailList.Add(scpRcvDetail); |
|
|
|
var _first= wdb.TB_ASN_DETAIL.FirstOrDefault(p => p.AsnBillNum == scpRcv.AsnBillNum |
|
|
|
&& p.PartCode== qadData.xxwms_rc_part |
|
|
|
&& p.Batch==qadData.xxwms_rc_lot |
|
|
|
&& p.PoBillNum==qadData.xxwms_rc_po_nbr |
|
|
|
&& p.PoLine==qadData.xxwms_rc_po_line |
|
|
|
); |
|
|
|
var _fs=_lsQty.FirstOrDefault(p => p.AsnBillNum == scpRcv.AsnBillNum |
|
|
|
&& p.PartCode == qadData.xxwms_rc_part |
|
|
|
&& p.Batch == qadData.xxwms_rc_lot |
|
|
|
&& p.PoBillNum == qadData.xxwms_rc_po_nbr |
|
|
|
&& p.PoLine == qadData.xxwms_rc_po_line); |
|
|
|
|
|
|
|
if (_first != null && _fs!=null) |
|
|
|
{ |
|
|
|
_first.Extend1 = (_fs.RecQty.Value + qadData.xxwms_rc_qty_total).ToString(); |
|
|
|
wdb.TB_ASN_DETAIL.AddOrUpdate(_first); |
|
|
|
} |
|
|
|
} |
|
|
|
//var scpPoDetail =
|
|
|
|
// wdb.TB_PO_DETAIL.FirstOrDefault(
|
|
|
|