Browse Source

冲压件接口 价格 净价 更新 以及scp 相应取值规则

master
qian 11 months ago
parent
commit
e22a2fbf18
  1. 43
      Controller/SCP_PO_CONTROLLER.cs
  2. 4
      UniApiGroup/Controller/NetPriceController.cs
  3. 32
      UniApiGroup/Controller/OdbcApiQadController.cs
  4. 14
      UniApiGroup/Controller/PriceController.cs

43
Controller/SCP_PO_CONTROLLER.cs

@ -1471,7 +1471,7 @@ namespace CK.SCP.Controller
{ {
ErrorList.Add(string.Format("订单编号【{0}】行号【{1}】已经存在,请更换行号!", p_excel., p_excel.)); ErrorList.Add(string.Format("订单编号【{0}】行号【{1}】已经存在,请更换行号!", p_excel., p_excel.));
} }
var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel. && p.Site == site && p.VendId == p_excel. && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList(); var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel. && p.Site == site && p.VendId == p_excel. && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime && p.Extend3 != "D").ToList();
if (checkcount.Count == 0) if (checkcount.Count == 0)
{ {
ErrorList.Add(string.Format("零件名称【{0}】供应编码【{1}】价格表没有维护信息!", p_excel., p_excel.)); ErrorList.Add(string.Format("零件名称【{0}】供应编码【{1}】价格表没有维护信息!", p_excel., p_excel.));
@ -2230,7 +2230,7 @@ namespace CK.SCP.Controller
{ {
ErrorList.Add(string.Format("物料号码{0}的BOM版本号填写错误", p_excel.)); ErrorList.Add(string.Format("物料号码{0}的BOM版本号填写错误", p_excel.));
} }
var price = db.TB_NetPrice.Count(p => p.PartCode == p_excel. && p.VendId == p_excel. && p.EndTime > DateTime.Now); var price = db.TB_NetPrice.Count(p => p.PartCode == p_excel. && p.VendId == p_excel. && p.EndTime > DateTime.Now && p.StartTime <DateTime.Now && p.Extend3 != "D");
if (price == 0) if (price == 0)
{ {
ErrorList.Add(string.Format("物料号码{0}不存在净价", p_excel.)); ErrorList.Add(string.Format("物料号码{0}不存在净价", p_excel.));
@ -2367,7 +2367,7 @@ namespace CK.SCP.Controller
{ {
ErrorList.Add(string.Format("物料号码{0}的BOM版本号填写错误", p_excel.)); ErrorList.Add(string.Format("物料号码{0}的BOM版本号填写错误", p_excel.));
} }
var price = db.TB_NetPrice.Count(p => p.PartCode == p_excel. && p.VendId == p_excel. && p.EndTime > DateTime.Now); var price = db.TB_NetPrice.Count(p => p.PartCode == p_excel. && p.VendId == p_excel. && p.EndTime > DateTime.Now && p.StartTime < DateTime.Now && p.Extend3 != "D");
if (price == 0) if (price == 0)
{ {
ErrorList.Add(string.Format("物料号码{0}不存在净价", p_excel.)); ErrorList.Add(string.Format("物料号码{0}不存在净价", p_excel.));
@ -6808,7 +6808,7 @@ namespace CK.SCP.Controller
_detail.EndTime = p_PoBillTime; _detail.EndTime = p_PoBillTime;
_detail.PlanQty = p_Qty; _detail.PlanQty = p_Qty;
_detail.CreateUser = str; _detail.CreateUser = str;
var _price = db.TB_NetPrice.Count(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId); var _price = db.TB_NetPrice.Count(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId && t.Extend3 != "D");
if (_price == 0) if (_price == 0)
{ {
var _price1 = db.TA_PART.SingleOrDefault(t => t.PartCode == _detail.PartCode.ToUpper()); var _price1 = db.TA_PART.SingleOrDefault(t => t.PartCode == _detail.PartCode.ToUpper());
@ -6816,12 +6816,11 @@ namespace CK.SCP.Controller
} }
else else
{ {
var _price2 = db.TB_NetPrice.Where(t => t.PartCode == _detail.PartCode.ToUpper()&&t.VendId==p_Po.VendId).Select(r => r.EndTime).Max();
var _price8 = db.TB_NetPrice.Where(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId).Select(r => r.StartTime).Max();
DateTime dateTime = DateTime.Now; DateTime dateTime = DateTime.Now;
if (_price2 > dateTime || _price2 == dateTime) int count = db.TB_NetPrice.Count(t => t.PartCode == _detail.PartCode.ToUpper() && t.StartTime <dateTime && t.EndTime > dateTime && t.VendId == p_Po.VendId && t.Extend3 != "D");
if (count > 0)
{ {
var _price3 = db.TB_NetPrice.FirstOrDefault(t => t.PartCode == _detail.PartCode.ToUpper() && t.StartTime == _price8 && t.VendId == p_Po.VendId); var _price3 = db.TB_NetPrice.Where(t => t.PartCode == _detail.PartCode.ToUpper() && t.StartTime < dateTime && t.EndTime > dateTime && t.VendId == p_Po.VendId && t.Extend3 != "D").OrderByDescending(u=>u.UID).FirstOrDefault();
_detail.Price = _price3.Amt; _detail.Price = _price3.Amt;
} }
else else
@ -6859,7 +6858,7 @@ namespace CK.SCP.Controller
_detail.EndTime = p_PoBillTime; _detail.EndTime = p_PoBillTime;
_detail.PlanQty = p_Qty; _detail.PlanQty = p_Qty;
_detail.CreateUser = str; _detail.CreateUser = str;
var _price = db.TB_NetPrice.Count(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId); var _price = db.TB_NetPrice.Count(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId && t.Extend3!="D");
if (_price == 0) if (_price == 0)
{ {
var _price1 = db.TA_PART.SingleOrDefault(t => t.PartCode == _detail.PartCode.ToUpper()); var _price1 = db.TA_PART.SingleOrDefault(t => t.PartCode == _detail.PartCode.ToUpper());
@ -6867,12 +6866,12 @@ namespace CK.SCP.Controller
} }
else else
{ {
var _price2 = db.TB_NetPrice.Where(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId).Select(r => r.EndTime).Max();
var _price8 = db.TB_NetPrice.Where(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId).Select(r => r.StartTime).Max();
DateTime dateTime = DateTime.Now; DateTime dateTime = DateTime.Now;
if (_price2 > dateTime || _price2 == dateTime) int count = db.TB_NetPrice.Count(t => t.PartCode == _detail.PartCode.ToUpper() && t.StartTime < dateTime && t.EndTime > dateTime && t.Extend3 != "D" && t.VendId == p_Po.VendId);
if (count > 0)
{ {
var _price3 = db.TB_NetPrice.FirstOrDefault(t => t.PartCode == _detail.PartCode.ToUpper() && t.StartTime == _price8 && t.VendId == p_Po.VendId); var _price3 = db.TB_NetPrice.Where(t => t.PartCode == _detail.PartCode.ToUpper() && t.StartTime < dateTime && t.EndTime > dateTime && t.Extend3 != "D" && t.VendId == p_Po.VendId).OrderByDescending(u=>u.UID).FirstOrDefault();
_detail.Price = _price3.Amt; _detail.Price = _price3.Amt;
} }
else else
@ -7200,7 +7199,7 @@ namespace CK.SCP.Controller
_detail.EndTime = p_PoBillTime; _detail.EndTime = p_PoBillTime;
_detail.PlanQty = p_Qty; _detail.PlanQty = p_Qty;
_detail.CreateUser = str; _detail.CreateUser = str;
var _price = db.TB_PRICE.Count(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId); var _price = db.TB_PRICE.Count(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId && t.Extend3 != "D");
if (_price == 0) if (_price == 0)
{ {
var _price1 = db.TA_PART.SingleOrDefault(t => t.PartCode == _detail.PartCode.ToUpper()); var _price1 = db.TA_PART.SingleOrDefault(t => t.PartCode == _detail.PartCode.ToUpper());
@ -7208,12 +7207,10 @@ namespace CK.SCP.Controller
} }
else else
{ {
var _price2 = db.TB_PRICE.Where(t => t.PartCode == _detail.PartCode.ToUpper()&&t.VendId==p_Po.VendId).Select(r => r.EndTime).Max(); int count1 = db.TB_PRICE.Count(t => t.PartCode == _detail.PartCode.ToUpper() && t.EndTime > DateTime.Now && t.StartTime < DateTime.Now && t.VendId == p_Po.VendId && t.Extend3 != "D");
var _price8 = db.TB_PRICE.Where(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId).Select(r => r.StartTime).Max(); if (count1 != 0)
DateTime dateTime = DateTime.Now;
if(_price2> dateTime|| _price2 ==dateTime)
{ {
var _price3 = db.TB_PRICE.Where(t => t.PartCode == _detail.PartCode.ToUpper() && t.EndTime == _price2 && t.VendId == p_Po.VendId).OrderByDescending(o => o.UID).FirstOrDefault(); //获取最新采购的价格 var _price3 = db.TB_PRICE.Where(t => t.PartCode == _detail.PartCode.ToUpper() && t.EndTime > DateTime.Now && t.StartTime < DateTime.Now && t.VendId == p_Po.VendId && t.Extend3 != "D").OrderByDescending(o => o.UID).FirstOrDefault(); //获取最新采购的价格
_detail.Price = _price3.Amt; _detail.Price = _price3.Amt;
} }
else else
@ -7248,7 +7245,7 @@ namespace CK.SCP.Controller
_detail.EndTime = p_PoBillTime; _detail.EndTime = p_PoBillTime;
_detail.PlanQty = p_Qty; _detail.PlanQty = p_Qty;
_detail.CreateUser = str; _detail.CreateUser = str;
var _price = db.TB_PRICE.Count(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId); var _price = db.TB_PRICE.Count(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId && t.Extend3!="D");
if (_price == 0) if (_price == 0)
{ {
var _price1 = db.TA_PART.SingleOrDefault(t => t.PartCode == _detail.PartCode.ToUpper()); var _price1 = db.TA_PART.SingleOrDefault(t => t.PartCode == _detail.PartCode.ToUpper());
@ -7256,12 +7253,12 @@ namespace CK.SCP.Controller
} }
else else
{ {
var _price2 = db.TB_PRICE.Where(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId).Select(r => r.EndTime).Max(); var _price2 = db.TB_PRICE.Where(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId && t.Extend3 != "D").Select(r => r.EndTime).Max();
var _price8 = db.TB_PRICE.Where(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId).Select(r => r.StartTime).Max(); var _price8 = db.TB_PRICE.Where(t => t.PartCode == _detail.PartCode.ToUpper() && t.VendId == p_Po.VendId && t.Extend3 != "D").Select(r => r.StartTime).Max();
DateTime dateTime = DateTime.Now; DateTime dateTime = DateTime.Now;
if (_price2 > dateTime || _price2 == dateTime) if (_price2 > dateTime || _price2 == dateTime)
{ {
var _price3 = db.TB_PRICE.FirstOrDefault(t => t.PartCode == _detail.PartCode.ToUpper() && t.EndTime == _price2 && t.VendId == p_Po.VendId); var _price3 = db.TB_PRICE.FirstOrDefault(t => t.PartCode == _detail.PartCode.ToUpper() && t.EndTime == _price2 && t.VendId == p_Po.VendId && t.Extend3 != "D");
_detail.Price = _price3.Amt; _detail.Price = _price3.Amt;
} }
else else

4
UniApiGroup/Controller/NetPriceController.cs

@ -60,6 +60,10 @@ namespace CK.SCP.UniApi.Controller
/// 批次 /// 批次
/// </summary> /// </summary>
/// <summary>
/// 操作类型
/// </summary>
public string DI_OPERTYPE { get; set; }
} }
} }
} }

32
UniApiGroup/Controller/OdbcApiQadController.cs

@ -1224,6 +1224,7 @@ namespace CK.SCP.GrupUniApi.Controller
List<PURSubcontractorInfoRecMid> list = ChangKeTec.Utils.ListHelper.DataTableToList<PURSubcontractorInfoRecMid>(b); List<PURSubcontractorInfoRecMid> list = ChangKeTec.Utils.ListHelper.DataTableToList<PURSubcontractorInfoRecMid>(b);
var PriceList = new List<TB_NetPrice>(); var PriceList = new List<TB_NetPrice>();
var PriceListUpdate = new List<TB_NetPrice>();
var xxMaxbath = new List<xxDiMaxes>(); var xxMaxbath = new List<xxDiMaxes>();
foreach (var itm in list) foreach (var itm in list)
{ {
@ -1250,8 +1251,19 @@ namespace CK.SCP.GrupUniApi.Controller
EndTime = itm.validityEndPeriod, EndTime = itm.validityEndPeriod,
}; };
_price.Amt = itm.netPrice; _price.Amt = itm.netPrice;
_price.Extend3 = itm.DI_OPERTYPE;
PriceList.Add(_price); PriceList.Add(_price);
} }
//存在更新
else
{
var enty = scpdb.TB_NetPrice.First(p => p.PartCode == itm.MTLNO.ToUpper() && p.VendId == itm.vendorNO
&& p.StartTime == itm.validityStartPeriod && p.EndTime == itm.validityEndPeriod);
enty.Amt = itm.netPrice;
enty.Remarks = itm.purOrg;
enty.Extend3 = itm.DI_OPERTYPE;
PriceListUpdate.Add(enty);
}
} }
if (PriceList.Count == 0) if (PriceList.Count == 0)
{ {
@ -1262,6 +1274,7 @@ namespace CK.SCP.GrupUniApi.Controller
item.MaxdibatchNO = item.MaxdibatchNO + list.Count; item.MaxdibatchNO = item.MaxdibatchNO + list.Count;
item.Remark = ((int)UniApiState.).ToString(); item.Remark = ((int)UniApiState.).ToString();
scpdb.TB_NetPrice.AddOrUpdate(PriceList.ToArray()); scpdb.TB_NetPrice.AddOrUpdate(PriceList.ToArray());
scpdb.TB_NetPrice.AddOrUpdate(u =>u.UID ,PriceListUpdate.ToArray());
Console.WriteLine($"更新采购净价数据:{PriceList.Count}"); Console.WriteLine($"更新采购净价数据:{PriceList.Count}");
} }
/// <summary> /// <summary>
@ -1272,13 +1285,14 @@ namespace CK.SCP.GrupUniApi.Controller
/// <param name="seq"></param> /// <param name="seq"></param>
private static void UpdatePrice(UniApiEntities idb, ScpEntities scpdb, xxerp_MaxbatchNO item) private static void UpdatePrice(UniApiEntities idb, ScpEntities scpdb, xxerp_MaxbatchNO item)
{ {
var max = idb.xxDiMaxes.OrderByDescending(r => r.Di_Batchno_NETprice).FirstOrDefault(); var max = idb.xxDiMaxes.OrderByDescending(r => r.Di_Batchno_price).FirstOrDefault();
int a = max.Di_Batchno_price; int a = max.Di_Batchno_price;
var FATCTORY = scpdb.TB_FACTORY.FirstOrDefault(); 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); List<PURPriceDealMidTab> list = ChangKeTec.Utils.ListHelper.DataTableToList<PURPriceDealMidTab>(b);
var xxMaxbath = new List<xxDiMaxes>(); var xxMaxbath = new List<xxDiMaxes>();
var PriceList = new List<TB_PRICE>(); var PriceList = new List<TB_PRICE>();
List<TB_PRICE> _PRICEs = new List<TB_PRICE>();
foreach (var itm in list) foreach (var itm in list)
{ {
var maxlist1 = new xxDiMaxes var maxlist1 = new xxDiMaxes
@ -1290,9 +1304,10 @@ namespace CK.SCP.GrupUniApi.Controller
}; };
xxMaxbath.Add(maxlist1); xxMaxbath.Add(maxlist1);
var _part = scpdb.TB_PRICE.Count(p => p.PartCode == itm.MTLNO.ToUpper() && p.VendId == itm.vendorNO var _part = scpdb.TB_PRICE.FirstOrDefault(p => p.PartCode == itm.MTLNO.ToUpper() && p.VendId == itm.vendorNO
&& p.StartTime == itm.validityStartPeriod && p.EndTime == itm.validityEndPeriod); && p.StartTime == itm.validityStartPeriod && p.EndTime == itm.validityEndPeriod);
if (_part == 0) // 不存在添加
if (_part == null)
{ {
var _price = new TB_PRICE var _price = new TB_PRICE
{ {
@ -1304,8 +1319,16 @@ namespace CK.SCP.GrupUniApi.Controller
EndTime = itm.validityEndPeriod, EndTime = itm.validityEndPeriod,
}; };
_price.Amt = decimal.Parse(itm.purchasePrice); _price.Amt = decimal.Parse(itm.purchasePrice);
_price.Extend3 = itm.DI_OPERTYPE;
PriceList.Add(_price); PriceList.Add(_price);
} }
// 存在判断类型进行更新
else
{
_part.Amt = decimal.Parse(itm.purchasePrice);
_part.Extend3 = itm.DI_OPERTYPE;
_PRICEs.Add(_part);
}
} }
if (PriceList.Count == 0) if (PriceList.Count == 0)
{ {
@ -1316,7 +1339,8 @@ namespace CK.SCP.GrupUniApi.Controller
item.MaxdibatchNO = item.MaxdibatchNO + list.Count; item.MaxdibatchNO = item.MaxdibatchNO + list.Count;
//item.Remark = ((int)UniApiState.失败).ToString(); //item.Remark = ((int)UniApiState.失败).ToString();
scpdb.TB_PRICE.AddOrUpdate(PriceList.ToArray()); scpdb.TB_PRICE.AddOrUpdate(PriceList.ToArray());
Console.WriteLine($"更新采购价格数据:{PriceList.Count}"); scpdb.TB_PRICE.AddOrUpdate(qa=> qa.UID,_PRICEs.ToArray());
Console.WriteLine($"更新采购价格数据:{PriceList.Count + _PRICEs.Count }");
} }
/// <summary> /// <summary>
/// 更新供应商零件 /// 更新供应商零件

14
UniApiGroup/Controller/PriceController.cs

@ -33,19 +33,23 @@ namespace CK.SCP.UniApi.Controller
public class PURPriceDealMidTab public class PURPriceDealMidTab
{ {
/// <summary> /// <summary>
/// 工厂 /// 操作类型
/// </summary>
public string DI_OPERTYPE { get; set; }
/// <summary>
/// 操作批次
/// </summary> /// </summary>
/// ///
public int DI_BATCHNO { get; set; } public int DI_BATCHNO { get; set; }
public string vendorNO { get; set; } public string vendorNO { get; set; }
/// <summary> /// <summary>
/// 存储地点 /// 物料
/// </summary> /// </summary>
public string MTLNO { get; set; } public string MTLNO { get; set; }
/// <summary> /// <summary>
/// 物料号 /// 工厂
/// </summary> /// </summary>
public string plant { get; set; } public string plant { get; set; }
@ -56,9 +60,7 @@ namespace CK.SCP.UniApi.Controller
public DateTime validityStartPeriod { get; set; } public DateTime validityStartPeriod { get; set; }
public DateTime validityEndPeriod { get; set; } public DateTime validityEndPeriod { get; set; }
/// <summary>
/// 批次
/// </summary>
} }
} }

Loading…
Cancel
Save