Browse Source

接口 删除看板明细

master
qian 1 year ago
parent
commit
7646a8cbc9
  1. 206
      UniApiGroup/Controller/OdbcApiQadController.cs

206
UniApiGroup/Controller/OdbcApiQadController.cs

@ -59,12 +59,12 @@ namespace CK.SCP.GrupUniApi.Controller
foreach (var qadCtrl in qadCtrlList)
{
try
try
{
ScpEntities wdb = EntitiesFactory.CreateScpInstance();
var authdb = EntitiesFactory.CreateAppBoxInstance();
switch (qadCtrl.tablename)
{
ScpEntities wdb = EntitiesFactory.CreateScpInstance();
var authdb = EntitiesFactory.CreateAppBoxInstance();
switch (qadCtrl.tablename)
{
case "part": //物料
if (GlobalVar.ApiConfig.Qad零件)
{
@ -145,42 +145,42 @@ namespace CK.SCP.GrupUniApi.Controller
}
}
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
}
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
{
var sb = new StringBuilder();
foreach (var error in dbEx.EntityValidationErrors.ToList())
{
var sb = new StringBuilder();
foreach (var error in dbEx.EntityValidationErrors.ToList())
error.ValidationErrors.ToList().ForEach(i =>
{
error.ValidationErrors.ToList().ForEach(i =>
{
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
});
}
//qadCtrl.xxqad_scm = ((int)UniApiState.失败).ToString();
//qadCtrl.xxqad_rmks += " SCM:" + sb.ToString();
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
});
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
{
//qadCtrl.xxqad_scm = ((int)UniApiState.失败).ToString();
//qadCtrl.xxqad_rmks += " SCM:" + ex.Message+ex.InnerException.Message;
//qadCtrl.xxqad_scm = ((int)UniApiState.失败).ToString();
//qadCtrl.xxqad_rmks += " SCM:" + sb.ToString();
}
catch (Exception ex)
{
//qadCtrl.xxqad_scm = ((int)UniApiState.失败).ToString();
//qadCtrl.xxqad_rmks += " SCM:" + ex.Message + ex.InnerException.Message;
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
{
//qadCtrl.xxqad_scm = ((int)UniApiState.失败).ToString();
//qadCtrl.xxqad_rmks += " SCM:" + ex.Message+ex.InnerException.Message;
}
finally
{
EntitiesFactory.SaveDb(idb);
}
}
catch (Exception ex)
{
//qadCtrl.xxqad_scm = ((int)UniApiState.失败).ToString();
//qadCtrl.xxqad_rmks += " SCM:" + ex.Message + ex.InnerException.Message;
UpdatePlanToAsk();
}
finally
{
EntitiesFactory.SaveDb(idb);
}
}
UpdatePlanToAsk();
}
private static void UpdatePlanToAsk()
{
@ -782,7 +782,7 @@ namespace CK.SCP.GrupUniApi.Controller
/// <param name="wdb"></param>
/// <param name="seq"></param>
private static void UpdatePurchaseOrders(UniApiEntities idb, ScpEntities wdb, xxerp_MaxbatchNO item)
{
{
try
{
var max = idb.xxDiMaxes_Po.OrderByDescending(r => r.Di_Batchno).FirstOrDefault();
@ -795,47 +795,27 @@ namespace CK.SCP.GrupUniApi.Controller
var wmsAskList = new List<TB_ASK>();
var wmsAskDetailList = new List<TB_ASK_DETAIL>();
var xxMaxbath = new List<xxDiMaxes_Po>();
var Dlist = list.Where(p=>p.ctype=="D");
var Dlist = list.Where(p => p.ctype == "D");
var Ilist = list.Where(p => p.ctype != "D");
var _li = Dlist.GroupBy(p=>p.purDocNO);
var _li = Dlist.GroupBy(p => p.purDocNO);
foreach (var _lii in _li)
{
var _liii = _lii.ToList();
var _entity = _liii.First();
var _askdetail = wdb.TB_ASK_DETAIL.Count(p => p.PoBillNum == _entity.purDocNO && p.State > -1);
if(_askdetail== _liii.Count())
{
var ask = wdb.TB_ASK.FirstOrDefault(p=>p.PoBillNum==_entity.purDocNO );
ask.State = -1;
ask.IsDeleted = true;
wmsAskList.Add(ask);
var askdetaill=wdb.TB_ASK_DETAIL.Where(p => p.PoBillNum == _entity.purDocNO).ToList();
askdetaill.ForEach(p =>
{
p.State = -1;
p.IsDeleted = true;
wmsAskDetailList.Add(p);
});
}
else
// 根据 零件号作废
var askdetaill = wdb.TB_ASK_DETAIL.Where(p => p.PoBillNum == _entity.purDocNO && p.PartCode == _entity.mtlNO).ToList();
askdetaill.ForEach(p =>
{
// 根据 零件号作废
var askdetaill = wdb.TB_ASK_DETAIL.Where(p => p.PoBillNum == _entity.purDocNO && p.PartCode == _entity.mtlNO ).ToList();
askdetaill.ForEach(p =>
{
p.State = -1;
p.IsDeleted = true;
wmsAskDetailList.Add(p);
});
}
p.State = -1;
p.IsDeleted = true;
wmsAskDetailList.Add(p);
});
}
foreach (var qadPoNbr in Ilist)
{
var qadDataList = wmsPoList.Count(p => p.PoBillNum == qadPoNbr.purDocNO);
var wmsPo1 = wdb.TB_PO.Count(p => p.PoBillNum == qadPoNbr.purDocNO);
if ( qadDataList == 0&& wmsPo1==0)
if (qadDataList == 0 && wmsPo1 == 0)
{
TB_PO wmsPo = new TB_PO
{
@ -860,7 +840,7 @@ namespace CK.SCP.GrupUniApi.Controller
var qadAskList = wmsAskList.Count(p => p.PoBillNum == qadPoNbr.purDocNO);
var wmsAs1 = wdb.TB_ASK.Count(p => p.PoBillNum == qadPoNbr.purDocNO);
if ( qadAskList == 0&& wmsAs1==0)
if (qadAskList == 0 && wmsAs1 == 0)
{
int cnt = 1;
@ -883,7 +863,7 @@ namespace CK.SCP.GrupUniApi.Controller
ErpBillNum = qadPoNbr.purDocNO,//订单号
SubSite = "W21",
};
if (qadPoNbr.returnsItem =="Y")
if (qadPoNbr.returnsItem == "Y")
{
wmsAs.State = -1;
}
@ -898,7 +878,7 @@ namespace CK.SCP.GrupUniApi.Controller
var qadASKList = wmsAskDetailList.Count(p => p.PoBillNum == qadPoNbr.purDocNO && p.PartCode == qadPoNbr.mtlNO);
var wmsAskDetail1 = wdb.TB_ASK_DETAIL.Count(p => p.PoBillNum == qadPoNbr.purDocNO && p.PartCode == qadPoNbr.mtlNO);
if (qadASKList == 0&& wmsAskDetail1==0)
if (qadASKList == 0 && wmsAskDetail1 == 0)
{
String str = "k";
TB_ASK_DETAIL wmsAskDetail = new TB_ASK_DETAIL
@ -941,10 +921,10 @@ namespace CK.SCP.GrupUniApi.Controller
var qadDataList1 = wmsPoDetailList.Count(p => p.PoBillNum == qadPoNbr.purDocNO && p.PartCode == qadPoNbr.mtlNO);
var wmsPoDetail1 =
wdb.TB_PO_DETAIL.Count(p => p.PoBillNum == qadPoNbr.purDocNO && p.PartCode == qadPoNbr.mtlNO);
if ( qadDataList1 == 0&& wmsPoDetail1==0)
if (qadDataList1 == 0 && wmsPoDetail1 == 0)
{
TB_PO_DETAIL wmsPoDetail = new TB_PO_DETAIL
TB_PO_DETAIL wmsPoDetail = new TB_PO_DETAIL
{
PoBillNum = qadPoNbr.purDocNO,//订单号
PoLine = int.Parse(qadPoNbr.purDocItemNO),
@ -959,8 +939,8 @@ namespace CK.SCP.GrupUniApi.Controller
SubSite = "W21",
CreateTime = qadPoNbr.createdDate == null ? DateTime.Now : (DateTime)qadPoNbr.createdDate,//创建日期
CreateUser = qadPoNbr.CREATEDBY,//创建用户
//if (wmsPoDetail.BillQty != 0 && wmsPoDetail.BillQty <= wmsPoDetail.ReceivedQty)
// wmsPoDetail.State = (int)FormState.关闭;
//if (wmsPoDetail.BillQty != 0 && wmsPoDetail.BillQty <= wmsPoDetail.ReceivedQty)
// wmsPoDetail.State = (int)FormState.关闭;
State = (int)FormState.,
IsDeleted = false,
GUID = System.Guid.NewGuid(),
@ -984,14 +964,14 @@ namespace CK.SCP.GrupUniApi.Controller
}
item.Remark = ((int)UniApiState.).ToString();
//item.MaxdibatchNO = item.MaxdibatchNO + list.Count;
idb.xxDiMaxes_Po.AddOrUpdate(xxMaxbath.ToArray());
wdb.TB_PO.AddOrUpdate(wmsPoList.ToArray());
wdb.TB_ASK.AddOrUpdate(wmsAskList.ToArray());
wdb.TB_PO_DETAIL.AddOrUpdate(wmsPoDetailList.ToArray());
wdb.TB_ASK_DETAIL.AddOrUpdate(wmsAskDetailList.ToArray());
Console.WriteLine($"更新 采购订单 数据:{list.Count}");
item.Remark = ((int)UniApiState.).ToString();
//item.MaxdibatchNO = item.MaxdibatchNO + list.Count;
idb.xxDiMaxes_Po.AddOrUpdate(xxMaxbath.ToArray());
wdb.TB_PO.AddOrUpdate(wmsPoList.ToArray());
wdb.TB_ASK.AddOrUpdate(wmsAskList.ToArray());
wdb.TB_PO_DETAIL.AddOrUpdate(wmsPoDetailList.ToArray());
wdb.TB_ASK_DETAIL.AddOrUpdate(wmsAskDetailList.ToArray());
Console.WriteLine($"更新 采购订单 数据:{list.Count}");
}
catch (Exception ex)
{
@ -1248,8 +1228,8 @@ namespace CK.SCP.GrupUniApi.Controller
var maxlist1 = new xxDiMaxes
{
Di_Batchno_part = 0,
Di_Batchno=0,
Di_Batchno_price=0,
Di_Batchno = 0,
Di_Batchno_price = 0,
Di_Batchno_NETprice = itm.DI_BATCHNO,
};
@ -1278,8 +1258,8 @@ namespace CK.SCP.GrupUniApi.Controller
}
idb.xxDiMaxes.AddOrUpdate(xxMaxbath.ToArray());
item.MaxdibatchNO = item.MaxdibatchNO + list.Count;
item.Remark = ((int) UniApiState.).ToString();
scpdb.TB_NetPrice.AddOrUpdate(PriceList.ToArray());
item.Remark = ((int)UniApiState.).ToString();
scpdb.TB_NetPrice.AddOrUpdate(PriceList.ToArray());
Console.WriteLine($"更新采购净价数据:{PriceList.Count}");
}
/// <summary>
@ -1293,7 +1273,7 @@ namespace CK.SCP.GrupUniApi.Controller
var max = idb.xxDiMaxes.OrderByDescending(r => r.Di_Batchno_NETprice).FirstOrDefault();
int a = max.Di_Batchno_price;
var FATCTORY = scpdb.TB_FACTORY.FirstOrDefault();
DataTable b = PriceController.GetInvBatchPrice(a,FATCTORY.FactoryId);
DataTable b = PriceController.GetInvBatchPrice(a, FATCTORY.FactoryId);
List<PURPriceDealMidTab> list = ChangKeTec.Utils.ListHelper.DataTableToList<PURPriceDealMidTab>(b);
var xxMaxbath = new List<xxDiMaxes>();
var PriceList = new List<TB_PRICE>();
@ -1304,7 +1284,7 @@ namespace CK.SCP.GrupUniApi.Controller
Di_Batchno_part = 0,
Di_Batchno = 0,
Di_Batchno_price = itm.DI_BATCHNO,
Di_Batchno_NETprice =0,
Di_Batchno_NETprice = 0,
};
xxMaxbath.Add(maxlist1);
@ -1318,7 +1298,7 @@ namespace CK.SCP.GrupUniApi.Controller
Unit = itm.ordUnit,
PartCode = itm.MTLNO,
Site = itm.plant,
StartTime =itm.validityStartPeriod,
StartTime = itm.validityStartPeriod,
EndTime = itm.validityEndPeriod,
};
_price.Amt = decimal.Parse(itm.purchasePrice);
@ -1342,7 +1322,7 @@ namespace CK.SCP.GrupUniApi.Controller
/// <param name="idb"></param>
/// <param name="wdb"></param>
/// <param name="seq"></param>
private static void UpdateVendParts(UniApiEntities idb, ScpEntities wdb,xxerp_MaxbatchNO item)
private static void UpdateVendParts(UniApiEntities idb, ScpEntities wdb, xxerp_MaxbatchNO item)
{
DataTable b = vendidpartcontroller.GetInvBatchStock(item.MaxdibatchNO.ToString());
List<PURVendorpartMid> list = ChangKeTec.Utils.ListHelper.DataTableToList<PURVendorpartMid>(b);
@ -1381,7 +1361,7 @@ namespace CK.SCP.GrupUniApi.Controller
//wmsData.VendPackQty = qadData.xxqad_vp_comment;
//wmsData.TransportationTime = qadData.xxqad_vp_vend_lead;
wmsDataList.Add(wmsData);
item.Remark = ((int)UniApiState.).ToString();
item.Remark = ((int)UniApiState.).ToString();
item.MaxdibatchNO = Convert.ToInt32(qadData.DI_BATCHNO);
}
catch (Exception ex)
@ -1407,7 +1387,7 @@ namespace CK.SCP.GrupUniApi.Controller
var max = idb.xxDiMaxes.OrderByDescending(r => r.Di_Batchno).FirstOrDefault();
int a = max.Di_Batchno;
var FATCTORY = wdb.TB_FACTORY.FirstOrDefault();
DataTable b = Vendercontroller.GetInvBatchStock(item.MaxdibatchNO, a,FATCTORY.FactoryId);
DataTable b = Vendercontroller.GetInvBatchStock(item.MaxdibatchNO, a, FATCTORY.FactoryId);
//DataTable b = Vendercontroller.GetInvBatchStock(item.MaxdibatchNO);
List<PURVendorMid> list = ChangKeTec.Utils.ListHelper.DataTableToList<PURVendorMid>(b);
var wmsDataList = new List<TA_VENDER>();
@ -1418,8 +1398,8 @@ namespace CK.SCP.GrupUniApi.Controller
{
var maxlist1 = new xxDiMaxes
{
Di_Batchno_NETprice=0,
Di_Batchno_price=0,
Di_Batchno_NETprice = 0,
Di_Batchno_price = 0,
Di_Batchno_part = 0,
Di_Batchno = qadData.DI_BATCHNO,
@ -1441,7 +1421,7 @@ namespace CK.SCP.GrupUniApi.Controller
var _vend = authdb.Roles.Where(p => p.Name == "供应商").FirstOrDefault();
var _factory = authdb.TA_FACTORY.Where(p => p.ErpDomain == ScpCache.Config.QAD域).FirstOrDefault();
//_first == null && _vend != null &&
if (_factory != null&& _first==null)
if (_factory != null && _first == null)
{
User _entity = new User();
_entity.Name = vendname;
@ -1463,7 +1443,7 @@ namespace CK.SCP.GrupUniApi.Controller
TA_FACTORY f = authdb.Set<TA_FACTORY>().Local.Where(x => x.ID == _factory.ID).FirstOrDefault();
if (f == null)
{
f = new TA_FACTORY { ID = _factory.ID };
f = new TA_FACTORY { ID = _factory.ID };
authdb.Set<TA_FACTORY>().Attach(f);
}
_entity.TA_FACTORY.Add(f);
@ -1488,7 +1468,7 @@ namespace CK.SCP.GrupUniApi.Controller
wdb.TA_VENDER.AddOrUpdate(p => new { p.VendId, p.Site }, wmsDataList.ToArray());
idb.xxDiMaxes.AddOrUpdate(xxMaxbath.ToArray());
item.MaxdibatchNO = item.MaxdibatchNO +list.Count;
item.MaxdibatchNO = item.MaxdibatchNO + list.Count;
Console.WriteLine($"更新 供应商 数据:{list.Count}");
}
@ -1554,22 +1534,22 @@ namespace CK.SCP.GrupUniApi.Controller
/// <param name="idb"></param>
/// <param name="wdb"></param>
/// <param name="seq"></param>
private static void UpdateParts(UniApiEntities idb, ScpEntities wdb, xxerp_MaxbatchNO item )
private static void UpdateParts(UniApiEntities idb, ScpEntities wdb, xxerp_MaxbatchNO item)
{
var max = idb.xxDiMaxes.OrderByDescending(r => r.Di_Batchno_part).FirstOrDefault();
int a = max.Di_Batchno_part;
var FATCTORY = wdb.TB_FACTORY.FirstOrDefault();
DataTable b = QmStockController.GetInvBatchStock(item.MaxdibatchNO,a, FATCTORY.FactoryId);
List<MMRSENDMTLDATA> list= ChangKeTec.Utils.ListHelper.DataTableToList<MMRSENDMTLDATA>(b);
DataTable b = QmStockController.GetInvBatchStock(item.MaxdibatchNO, a, FATCTORY.FactoryId);
List<MMRSENDMTLDATA> list = ChangKeTec.Utils.ListHelper.DataTableToList<MMRSENDMTLDATA>(b);
var wmsDataList = new List<TA_PART>();
var wmsDataList = new List<TA_PART>();
var xxMaxbath = new List<xxDiMaxes>();
foreach (var qadData in list)
{
var maxlist1 = new xxDiMaxes
{
Di_Batchno_NETprice=0,
Di_Batchno_price=0,
Di_Batchno_NETprice = 0,
Di_Batchno_price = 0,
Di_Batchno_part = qadData.DI_BATCHNO,
Di_Batchno = 0
@ -1581,18 +1561,18 @@ namespace CK.SCP.GrupUniApi.Controller
PartCode = qadData.MTLNO.ToString(),
ErpPartCode = qadData.MTLNO.ToString(),
};
wmsData.PartDesc1 = qadData.MTLNODES.ToString();
wmsData.PartDesc2 = qadData.sizes.ToString();
wmsData.ReceivePort = qadData.grossWeight.ToString();
wmsData.PalletSize = qadData.netWeight.ToString();
wmsData.PartGroup = qadData.MTLTYPE.ToString();
wmsData.ProjectId = qadData.MATBRAND;
wmsData.Unit = !string.IsNullOrEmpty(qadData.MEASUREBASEUNIT) ? qadData.MEASUREBASEUNIT.ToUpper() : "EA";
wmsData.Remark = qadData.stdPrice.ToString();
wmsData.ValidityDays = qadData.loadQuantity;
wmsData.State = !string.IsNullOrEmpty(qadData.SpMtlStatus) ? qadData.SpMtlStatus.ToUpper() : "A";
wmsData.Site = qadData.plant;
wmsDataList.Add(wmsData);
wmsData.PartDesc1 = qadData.MTLNODES.ToString();
wmsData.PartDesc2 = qadData.sizes.ToString();
wmsData.ReceivePort = qadData.grossWeight.ToString();
wmsData.PalletSize = qadData.netWeight.ToString();
wmsData.PartGroup = qadData.MTLTYPE.ToString();
wmsData.ProjectId = qadData.MATBRAND;
wmsData.Unit = !string.IsNullOrEmpty(qadData.MEASUREBASEUNIT) ? qadData.MEASUREBASEUNIT.ToUpper() : "EA";
wmsData.Remark = qadData.stdPrice.ToString();
wmsData.ValidityDays = qadData.loadQuantity;
wmsData.State = !string.IsNullOrEmpty(qadData.SpMtlStatus) ? qadData.SpMtlStatus.ToUpper() : "A";
wmsData.Site = qadData.plant;
wmsDataList.Add(wmsData);
}
if (wmsDataList.Count == 0)
@ -1604,10 +1584,10 @@ namespace CK.SCP.GrupUniApi.Controller
item.MaxdibatchNO = item.MaxdibatchNO + list.Count;
idb.xxDiMaxes.AddOrUpdate(xxMaxbath.ToArray());
wdb.TA_PART.AddOrUpdate(p => new { p.PartCode, p.Site }, wmsDataList.ToArray());
Console.WriteLine($"更新 零件信息 数据:{list.Count}");
Console.WriteLine($"更新 零件信息 数据:{list.Count}");
}
}
}
}

Loading…
Cancel
Save