|
@ -62,6 +62,7 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
Console.WriteLine($"调用WMS 接口数据:{wmsCtrlList.Count.ToString()}"); |
|
|
Console.WriteLine($"调用WMS 接口数据:{wmsCtrlList.Count.ToString()}"); |
|
|
foreach (var wmsCtrl in wmsCtrlList) |
|
|
foreach (var wmsCtrl in wmsCtrlList) |
|
|
{ |
|
|
{ |
|
|
|
|
|
int state = 0; |
|
|
if (tableNameList.All(p => p.Name != wmsCtrl.xxwms_table)) continue; |
|
|
if (tableNameList.All(p => p.Name != wmsCtrl.xxwms_table)) continue; |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
@ -88,6 +89,7 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
Console.WriteLine($"发现 WMS 接口数据:{wmsCtrl.xxwms_table}:{wmsCtrl.xxwms_table_qty}"); |
|
|
Console.WriteLine($"发现 WMS 接口数据:{wmsCtrl.xxwms_table}:{wmsCtrl.xxwms_table_qty}"); |
|
|
AddMaterialReceive(idb, wdb, wmsCtrl.xxwms_seq, 0);//xxwms_seq:流水号
|
|
|
AddMaterialReceive(idb, wdb, wmsCtrl.xxwms_seq, 0);//xxwms_seq:流水号
|
|
|
AddMaterialReturn_RC(idb, wdb, wmsCtrl.xxwms_seq, 1);//xxwms_seq:流水号
|
|
|
AddMaterialReturn_RC(idb, wdb, wmsCtrl.xxwms_seq, 1);//xxwms_seq:流水号
|
|
|
|
|
|
state = 1; |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case WmsTableName.xxwms_rt_det: |
|
|
case WmsTableName.xxwms_rt_det: |
|
@ -125,8 +127,12 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wmsCtrl.xxwms_scm = ((int)UniApiState.成功).ToString(); |
|
|
wmsCtrl.xxwms_scm = ((int)UniApiState.成功).ToString(); |
|
|
EntitiesFactory.SaveDb(wdb); |
|
|
EntitiesFactory.SaveDb(wdb); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
{ |
|
|
{ |
|
@ -154,6 +160,11 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
finally |
|
|
finally |
|
|
{ |
|
|
{ |
|
|
EntitiesFactory.SaveDb(idb); |
|
|
EntitiesFactory.SaveDb(idb); |
|
|
|
|
|
if (wmsCtrl.xxwms_scm == "1" && state==1) |
|
|
|
|
|
{ |
|
|
|
|
|
UpdateReceive(wmsCtrl.xxwms_seq); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -195,6 +206,49 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
Console.WriteLine($"更新 原料库存 数据:{wmsld_detList.Count}"); |
|
|
Console.WriteLine($"更新 原料库存 数据:{wmsld_detList.Count}"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void UpdateReceive(string p_seq) |
|
|
|
|
|
{ |
|
|
|
|
|
ScpEntities scpdb = EntitiesFactory.CreateScpInstance(); |
|
|
|
|
|
UniApiEntities idb = EntitiesFactory.CreateUniApiInstance(); |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
string _sql = "Update TB_ASN_DETAIL set extend1=recqty from tb_asn_detail D inner join\n" + |
|
|
|
|
|
" (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" + |
|
|
|
|
|
" 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" + |
|
|
|
|
|
" where a.AsnBillNum in ({0})\n" + |
|
|
|
|
|
" GROUP BY a.AsnBillNum, a.PoLine, a.PartCode, a.PoBillNum,a.Batch) AS C on D.AsnBillNum = C.AsnBillNum AND D.PoLine = C.PoLine AND\n" + |
|
|
|
|
|
" D.PartCode = C.PartCode AND D.PoBillNum = C.PoBillNum and D.Batch=C.Batch"; |
|
|
|
|
|
|
|
|
|
|
|
var qadRcvDetailList = idb.xxwms_rc_det.Where(p => p.xxwms_rc_seq == p_seq && p.xxwms_rc_qty_total >= 0).ToList(); |
|
|
|
|
|
var _lst = qadRcvDetailList.Select(p => p.xxwms_rc_ps_nbr).ToList().Distinct(); |
|
|
|
|
|
if (_lst.Count() > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
var _list = new List<string>(); |
|
|
|
|
|
foreach (var itm in _lst) |
|
|
|
|
|
{ |
|
|
|
|
|
_list.Add(string.Format("'{0}'", itm)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scpdb.Database.ExecuteSqlCommand(_sql, string.Join(",", _list)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception e) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
finally |
|
|
|
|
|
{ |
|
|
|
|
|
EntitiesFactory.SaveDb(idb); |
|
|
|
|
|
|
|
|
|
|
|
EntitiesFactory.SaveDb(scpdb); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
///接收收货单
|
|
|
///接收收货单
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
@ -204,26 +258,11 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
/// <param name="billtype">0:收货,1:退货</param>
|
|
|
/// <param name="billtype">0:收货,1:退货</param>
|
|
|
private static void AddMaterialReceive(UniApiEntities idb, ScpEntities wdb, string seq, int billtype) |
|
|
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 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 scpRcvList = new List<TB_RECEIVE>(); |
|
|
var scpRcveDetailList = new List<TB_RECEIVE_DETAIL>(); |
|
|
var scpRcveDetailList = new List<TB_RECEIVE_DETAIL>(); |
|
|
|
|
|
|
|
|
//根据xxwms_rc_po_nbr采购单字段去重
|
|
|
//根据xxwms_rc_po_nbr采购单字段去重
|
|
|
var qadReceiveNbrList = qadRcvDetailList.Select(p => p.xxwms_rc_nbr.ToUpper()).DistinctBy(p => p); |
|
|
var qadReceiveNbrList = qadRcvDetailList.Select(p => p.xxwms_rc_nbr.ToUpper()).DistinctBy(p => p); |
|
|
|
|
|
|
|
|
foreach (var qadRcvNbrList in qadReceiveNbrList) |
|
|
foreach (var qadRcvNbrList in qadReceiveNbrList) |
|
|
{ |
|
|
{ |
|
|
//qadRcvDetailList同一xxqad_prh_receiver所有记录
|
|
|
//qadRcvDetailList同一xxqad_prh_receiver所有记录
|
|
@ -232,18 +271,15 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
{ |
|
|
{ |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var firstqadData = qadDataList[0]; |
|
|
var firstqadData = qadDataList[0]; |
|
|
List<TB_RECEIVE_QTY> _lsQty = new List<TB_RECEIVE_QTY>(); |
|
|
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); |
|
|
var scpRcv = wdb.TB_RECEIVE.SingleOrDefault(p => p.RecvBillNum != null && p.RecvBillNum == qadRcvNbrList && p.Site==firstqadData.xxwms_rc_domain); |
|
|
|
|
|
|
|
|
//判断0100工厂的收货自动审核是否为允许
|
|
|
//判断0100工厂的收货自动审核是否为允许
|
|
|
bool isRerviceOk = false; |
|
|
bool isRerviceOk = false; |
|
|
if (!string.IsNullOrEmpty(firstqadData.xxwms_rc_domain)) |
|
|
if (!string.IsNullOrEmpty(firstqadData.xxwms_rc_domain)) |
|
|
{ |
|
|
{ |
|
|
string site = firstqadData.xxwms_rc_domain;//0100
|
|
|
string site = firstqadData.xxwms_rc_domain;//0100
|
|
|
List<TA_FACTORY_CONFIG> configs = wdb.TA_FACTORY_CONFIG.Where(p => p.FactoryId == site).ToList(); |
|
|
List<TA_FACTORY_CONFIG> configs = wdb.TA_FACTORY_CONFIG.Where(p => p.FactoryId == site).ToList(); |
|
|
|
|
|
|
|
|
foreach (TA_FACTORY_CONFIG cfg in configs) |
|
|
foreach (TA_FACTORY_CONFIG cfg in configs) |
|
|
{ |
|
|
{ |
|
|
TA_CONFIG tacfg = wdb.TA_CONFIG.Where(p => p.UID == cfg.ConfigId).SingleOrDefault(); |
|
|
TA_CONFIG tacfg = wdb.TA_CONFIG.Where(p => p.UID == cfg.ConfigId).SingleOrDefault(); |
|
@ -279,13 +315,6 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
BillType = billtype |
|
|
BillType = billtype |
|
|
}; |
|
|
}; |
|
|
scpRcvList.Add(scpRcv); |
|
|
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.PoBillNum = firstqadData.xxwms_rc_po_nbr;//采购单
|
|
|
scpRcv.AsnBillNum = firstqadData.xxwms_rc_ps_nbr;//发货单号
|
|
|
scpRcv.AsnBillNum = firstqadData.xxwms_rc_ps_nbr;//发货单号
|
|
@ -293,7 +322,6 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
scpRcv.VendId = firstqadData.xxwms_rc_vend;//供货商名称
|
|
|
scpRcv.VendId = firstqadData.xxwms_rc_vend;//供货商名称
|
|
|
scpRcv.ShipTime = firstqadData.xxwms_rc_date_ship;//收货日期
|
|
|
scpRcv.ShipTime = firstqadData.xxwms_rc_date_ship;//收货日期
|
|
|
scpRcv.SubSite = !string.IsNullOrEmpty(firstqadData.xxwms_rc_site)? firstqadData.xxwms_rc_site: firstqadData.xxwms_rc_domain; |
|
|
scpRcv.SubSite = !string.IsNullOrEmpty(firstqadData.xxwms_rc_site)? firstqadData.xxwms_rc_site: firstqadData.xxwms_rc_domain; |
|
|
|
|
|
|
|
|
//var scpAsn = wdb.TF_ASN.FirstOrDefault(p => p.BillNum == scpRcv.AsnBillNum);
|
|
|
//var scpAsn = wdb.TF_ASN.FirstOrDefault(p => p.BillNum == scpRcv.AsnBillNum);
|
|
|
var scpAsn = wdb.TB_ASN.Where(p => p.AsnBillNum== scpRcv.AsnBillNum && p.IsDeleted==false).ToList();//发货单主表订单号==收货单主表发货单号
|
|
|
var scpAsn = wdb.TB_ASN.Where(p => p.AsnBillNum== scpRcv.AsnBillNum && p.IsDeleted==false).ToList();//发货单主表订单号==收货单主表发货单号
|
|
|
if (scpAsn != null && scpAsn.Count>0) |
|
|
if (scpAsn != null && scpAsn.Count>0) |
|
@ -361,50 +389,9 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
BillType = billtype |
|
|
BillType = billtype |
|
|
}; |
|
|
}; |
|
|
scpRcveDetailList.Add(scpRcvDetail); |
|
|
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!=null?_fs.RecQty.Value:0 + qadData.xxwms_rc_qty_total).ToString();
|
|
|
|
|
|
// wdb.TB_ASN_DETAIL.AddOrUpdate(_first);
|
|
|
|
|
|
//}
|
|
|
|
|
|
} |
|
|
} |
|
|
//var scpPoDetail =
|
|
|
|
|
|
// wdb.TB_PO_DETAIL.FirstOrDefault(
|
|
|
|
|
|
// p => p.PoBillNum == qadData.xxwms_rc_po_nbr && p.PoLine == poLineNum);
|
|
|
|
|
|
//if (scpPoDetail != null)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// //订单明细ReceivedQty已收数量 += 收货明细Qty已结束量
|
|
|
|
|
|
// scpPoDetail.ReceivedQty += scpRcvDetail.Qty;
|
|
|
|
|
|
//}
|
|
|
|
|
|
//var scpPo = wdb.TB_PO.FirstOrDefault(p => p.ErpBillNum == qadData.xxwms_rc_po_nbr);
|
|
|
|
|
|
//if (scpPo != null)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// //订单明细
|
|
|
|
|
|
// var scpPoDetails = wdb.TB_PO_DETAIL.Where(p => p.PoBillNum == qadData.xxwms_rc_po_nbr);
|
|
|
|
|
|
// //if (scpPoDetails.All(p => p.BillQty == p.ReceivedQty))
|
|
|
|
|
|
// // scpPo.State = (int)PlanState.Complete;
|
|
|
|
|
|
// if (scpPoDetails.All(p => p.PlanQty == p.ReceivedQty))//订货数量==已收数量
|
|
|
|
|
|
// {
|
|
|
|
|
|
// scpPo.State = (int)PlanState.Complete;
|
|
|
|
|
|
// //var _detail = wdb.TB_ASK_DETAIL.Where(p => p.PoBillNum == qadData.xxwms_rc_po_nbr && p.PoLine == poLineNum );
|
|
|
|
|
|
// //if (_detail!=null && _detail.Count() > 0)
|
|
|
|
|
|
// //{
|
|
|
|
|
|
// // var _qty=_detail.Sum(p=>p.AskQty);
|
|
|
|
|
|
// // if(_qty== p.ReceivedQty)
|
|
|
|
|
|
// //}
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
qadData.xxwms_rc_wmsread = ((int)UniApiState.成功).ToString(); |
|
|
qadData.xxwms_rc_wmsread = ((int)UniApiState.成功).ToString(); |
|
|
} |
|
|
} |
|
|
catch (Exception ex) |
|
|
catch (Exception ex) |
|
|