|
@ -1620,7 +1620,7 @@ namespace CK.SCP.Controller |
|
|
_supplier.Site = supplier.Domain;//域
|
|
|
_supplier.Site = supplier.Domain;//域
|
|
|
_supplier.Tax = Convert.ToDecimal(supplier.TaxClass/100);//税率
|
|
|
_supplier.Tax = Convert.ToDecimal(supplier.TaxClass/100);//税率
|
|
|
|
|
|
|
|
|
_supplier.Remark = supplier.TaskID.ToString();//任务ID
|
|
|
_supplier.Remark = supplier.TaskID.ToString();//任务ID
|
|
|
|
|
|
|
|
|
var vendname = string.Format("{0}@{1}",_supplier.VendId.ToUpper(), _supplier.Site.ToUpper()); |
|
|
var vendname = string.Format("{0}@{1}",_supplier.VendId.ToUpper(), _supplier.Site.ToUpper()); |
|
|
var _first = authdb.Users.Where(p => p.Name == vendname).FirstOrDefault(); |
|
|
var _first = authdb.Users.Where(p => p.Name == vendname).FirstOrDefault(); |
|
@ -1897,12 +1897,368 @@ namespace CK.SCP.Controller |
|
|
return _ret; |
|
|
return _ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static ResultObject<bool> WritePo(List<SCP_PO_EXPORT_IMPORT_MODEL> p_order_list, string site, string p_creator, DateTime p_time, BillModType p_modtype, string subsite, string p_chineseName, string p_buyerPhone) |
|
|
|
|
|
{ |
|
|
|
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
|
|
|
using (var scope = |
|
|
|
|
|
new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() |
|
|
|
|
|
{ |
|
|
|
|
|
IsolationLevel = System.Transactions.IsolationLevel.Serializable, |
|
|
|
|
|
Timeout = new TimeSpan(0, 20, 0) |
|
|
|
|
|
})) |
|
|
|
|
|
{ |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
ScpEntities scpdb = EntitiesFactory.CreateScpInstance(); |
|
|
|
|
|
ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance(); |
|
|
|
|
|
var OrderList = p_order_list.GroupBy(p => p.订单编号).ToList(); |
|
|
|
|
|
string _polist = ""; |
|
|
|
|
|
int _num = 1; |
|
|
|
|
|
OrderList.ForEach((p) => |
|
|
|
|
|
{ |
|
|
|
|
|
Guid taskid = Guid.NewGuid(); |
|
|
|
|
|
var list = p.ToList(); |
|
|
|
|
|
if (list.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
#region 日程单
|
|
|
|
|
|
if (p_modtype == BillModType.Contract) |
|
|
|
|
|
{ |
|
|
|
|
|
var _entity = list.FirstOrDefault(); |
|
|
|
|
|
var _po = scpdb.TB_PO.SingleOrDefault(t => t.PoBillNum == _entity.订单编号/* && t.State == state*/ && t.Site == site && t.SubSite == subsite && t.VendId == _entity.供应商编号.ToUpper()); |
|
|
|
|
|
if (_po == null) |
|
|
|
|
|
{ |
|
|
|
|
|
_po = new TB_PO { GUID = Guid.NewGuid(), PoBillNum = _entity.订单编号.ToUpper(), State = (int)PoState.Open, Site = site, SubSite = subsite, VendId = _entity.供应商编号.Trim().ToUpper() }; |
|
|
|
|
|
} |
|
|
|
|
|
_po.ErpBillNum = _entity.订单编号.Trim().ToUpper(); ; |
|
|
|
|
|
_po.ModType = (int)p_modtype; |
|
|
|
|
|
_po.Contacter = p_chineseName;// _entity.联系人;
|
|
|
|
|
|
_po.Buyer = p_chineseName;// _entity.联系人;
|
|
|
|
|
|
_po.Site = site.Trim().ToUpper(); |
|
|
|
|
|
_po.BuyerPhone = p_buyerPhone; |
|
|
|
|
|
_po.Remark = _entity.备注; |
|
|
|
|
|
_po.IsDeleted = false; |
|
|
|
|
|
_po.CreateTime = DateTime.Now; |
|
|
|
|
|
_po.CreateUser = p_creator; |
|
|
|
|
|
_po.BeginTime = string.IsNullOrEmpty(_entity.订单创建时间) ? DateTime.Now : DateTime.Parse(_entity.订单创建时间); |
|
|
|
|
|
_po.EndTime = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.要求到货日期); |
|
|
|
|
|
scpdb.TB_PO.AddOrUpdate(_po); |
|
|
|
|
|
TED_PO_MSTR _po_mstr = new TED_PO_MSTR(); |
|
|
|
|
|
_po_mstr.GUID = Guid.NewGuid(); |
|
|
|
|
|
_po_mstr.PurchaseOrder = _entity.订单编号.Trim().ToUpper(); |
|
|
|
|
|
_po_mstr.Supplier = _entity.供应商编号.Trim().ToUpper(); |
|
|
|
|
|
_po_mstr.Contact = p_chineseName;// _entity.联系人;
|
|
|
|
|
|
_po_mstr.ShipTo = subsite.Trim().ToUpper();//发往
|
|
|
|
|
|
_po_mstr.OrderDate = string.IsNullOrEmpty(_entity.订单创建时间) ? DateTime.Now : DateTime.Parse(_entity.订单创建时间); |
|
|
|
|
|
_po_mstr.DueDate = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now : DateTime.Parse(_entity.要求到货日期); |
|
|
|
|
|
_po_mstr.StartDate = string.IsNullOrEmpty(_entity.订单开始时间) ? DateTime.Now : DateTime.Parse(_entity.订单开始时间);//订单日期
|
|
|
|
|
|
_po_mstr.EndDate = string.IsNullOrEmpty(_entity.订单截至日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.订单截至日期); |
|
|
|
|
|
_po_mstr.MadeIn = ""; |
|
|
|
|
|
_po_mstr.Confirm = true; |
|
|
|
|
|
_po_mstr.Buyer = p_chineseName;//_entity.采购员;
|
|
|
|
|
|
_po_mstr.BuyerPhone = p_buyerPhone;// _entity.采购员电话;
|
|
|
|
|
|
_po_mstr.Status = (int)PoState.Open; |
|
|
|
|
|
_po_mstr.ScheduledOrder = true; |
|
|
|
|
|
_po_mstr.CreateUser = p_creator; |
|
|
|
|
|
_po_mstr.CreateTime = p_time; |
|
|
|
|
|
_po_mstr.Remark = _entity.备注; ; |
|
|
|
|
|
_po_mstr.TaskID = taskid; |
|
|
|
|
|
_po_mstr.Domain = site.Trim().ToUpper(); |
|
|
|
|
|
_po_mstr.ModeType = ((int)p_modtype).ToString(); |
|
|
|
|
|
_po_mstr.Site = subsite.Trim().ToUpper(); |
|
|
|
|
|
_po_mstr.DataID = Guid.NewGuid(); |
|
|
|
|
|
_po_mstr.Pricelist = _entity.供应商编号.ToUpper().Trim() + subsite.Trim().Substring(1, 1) + subsite.Substring(3, 1).Trim(); |
|
|
|
|
|
_po_mstr.Taxclass = _entity.税率; |
|
|
|
|
|
_po_mstr.CommandType = "A"; |
|
|
|
|
|
db.TED_PO_MSTR.Add(_po_mstr); |
|
|
|
|
|
list.ForEach((itm) => |
|
|
|
|
|
{ |
|
|
|
|
|
int _poline = Int32.Parse(itm.行号); |
|
|
|
|
|
var _PO_Detail = scpdb.TB_PO_DETAIL.FirstOrDefault(t => t.PartCode == itm.零件号 && t.PoLine == _poline && t.PoBillNum == itm.订单编号 /*&& t.State == state*/ && t.Site == site && t.SubSite == subsite); |
|
|
|
|
|
TED_PO_DET _PO_Detail_Det = new TED_PO_DET(); |
|
|
|
|
|
_PO_Detail_Det.GUID = Guid.NewGuid(); |
|
|
|
|
|
_PO_Detail_Det.PurchaseOrder = itm.订单编号.Trim().ToUpper(); |
|
|
|
|
|
_PO_Detail_Det.Line = Int32.Parse(itm.行号); |
|
|
|
|
|
_PO_Detail_Det.Currency = "CNY"; |
|
|
|
|
|
_PO_Detail_Det.PoType = itm.订单类型; |
|
|
|
|
|
_PO_Detail_Det.PartCode = itm.零件号.Trim().ToUpper(); |
|
|
|
|
|
_PO_Detail_Det.Qty = decimal.Parse(itm.数量); |
|
|
|
|
|
_PO_Detail_Det.QtyOpen = 0; |
|
|
|
|
|
_PO_Detail_Det.PackQty = 1; |
|
|
|
|
|
_PO_Detail_Det.Currency = itm.币种; |
|
|
|
|
|
_PO_Detail_Det.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); |
|
|
|
|
|
var _part = scpdb.TA_PART.FirstOrDefault(part => part.PartCode == itm.零件号.Trim().ToUpper()); |
|
|
|
|
|
if (_part == null) |
|
|
|
|
|
{ |
|
|
|
|
|
_PO_Detail_Det.PoUm = itm.单位; |
|
|
|
|
|
_PO_Detail_Det.LocUm = itm.单位; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
_PO_Detail_Det.PoUm = _part.Unit; |
|
|
|
|
|
_PO_Detail_Det.LocUm = _part.Unit; |
|
|
|
|
|
} |
|
|
|
|
|
_PO_Detail_Det.Conv = 1; |
|
|
|
|
|
_PO_Detail_Det.DueDate = string.IsNullOrEmpty(itm.要求到货日期) ? DateTime.Now : DateTime.Parse(itm.要求到货日期); |
|
|
|
|
|
_PO_Detail_Det.Status = (int)PoState.Open; |
|
|
|
|
|
_PO_Detail_Det.CreateTime = DateTime.Parse(itm.订单创建时间); |
|
|
|
|
|
_PO_Detail_Det.StartDate = string.IsNullOrEmpty(itm.零件开始时间) ? p_time : DateTime.Parse(itm.零件开始时间); |
|
|
|
|
|
_PO_Detail_Det.EndDate = string.IsNullOrEmpty(itm.零件截至日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(itm.零件截至日期); |
|
|
|
|
|
_PO_Detail_Det.CreateUser = p_creator; |
|
|
|
|
|
_PO_Detail_Det.TaskID = taskid; |
|
|
|
|
|
if (_PO_Detail != null) |
|
|
|
|
|
{ |
|
|
|
|
|
_PO_Detail_Det.CommandType = "U"; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
_PO_Detail = new TB_PO_DETAIL { GUID = Guid.NewGuid(), PartCode = itm.零件号.Trim().ToUpper(), PoLine = _poline, PoBillNum = itm.订单编号.Trim().ToUpper(), State = (int)PoState.Open, Site = site, SubSite = subsite }; |
|
|
|
|
|
_PO_Detail_Det.CommandType = "A"; |
|
|
|
|
|
} |
|
|
|
|
|
_PO_Detail_Det.DataID = Guid.NewGuid(); |
|
|
|
|
|
_PO_Detail_Det.Domain = site.Trim().ToUpper(); |
|
|
|
|
|
_PO_Detail_Det.Site = subsite.Trim().ToUpper(); |
|
|
|
|
|
_PO_Detail_Det.Workorderlot = itm.加工单号; |
|
|
|
|
|
_PO_Detail_Det.PoType = itm.订单类型; |
|
|
|
|
|
_PO_Detail_Det.Operation = string.IsNullOrEmpty(itm.工序) ? 0 : int.Parse(itm.工序); |
|
|
|
|
|
_PO_Detail_Det.Location = itm.库位; |
|
|
|
|
|
_PO_Detail_Det.Firmdays = string.IsNullOrEmpty(itm.固定天数) ? 7 : int.Parse(itm.固定天数); |
|
|
|
|
|
_PO_Detail_Det.Scheduledays = string.IsNullOrEmpty(itm.日程天数) ? 7 : int.Parse(itm.日程天数); |
|
|
|
|
|
_PO_Detail_Det.Scheduleweeks = string.IsNullOrEmpty(itm.日程周数) ? 2 : int.Parse(itm.日程周数); |
|
|
|
|
|
_PO_Detail_Det.Schedulemonth = string.IsNullOrEmpty(itm.日程月数) ? 1 : int.Parse(itm.日程月数); |
|
|
|
|
|
_PO_Detail_Det.Supplieritem = itm.供应商零件; |
|
|
|
|
|
_PO_Detail_Det.Dliverypatterncode = itm.发货样式; |
|
|
|
|
|
_PO_Detail_Det.Deliverytimecode = itm.发货时间样式; |
|
|
|
|
|
_PO_Detail_Det.Transportdays = string.IsNullOrEmpty(itm.运输周期) ? 0 : int.Parse(itm.运输周期); |
|
|
|
|
|
_PO_Detail_Det.Pricelist = _entity.供应商编号.Trim().ToUpper() + subsite.Substring(1, 1) + subsite.Substring(3, 1); |
|
|
|
|
|
db.TED_POD_DET.Add(_PO_Detail_Det); |
|
|
|
|
|
_PO_Detail.Currency = "CNY"; |
|
|
|
|
|
_PO_Detail.PoUnit = itm.单位; |
|
|
|
|
|
_PO_Detail.CreateTime = DateTime.Now; |
|
|
|
|
|
_PO_Detail.CreateUser = p_creator; |
|
|
|
|
|
_PO_Detail.BeginTime = string.IsNullOrEmpty(itm.订单创建时间) ? DateTime.Now : DateTime.Parse(itm.订单创建时间); |
|
|
|
|
|
_PO_Detail.EndTime = string.IsNullOrEmpty(itm.要求到货日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(itm.要求到货日期); |
|
|
|
|
|
_PO_Detail.PlanQty = decimal.Parse(itm.数量); |
|
|
|
|
|
_PO_Detail.IsDeleted = false; |
|
|
|
|
|
_PO_Detail.LocUnit = itm.单位; |
|
|
|
|
|
_PO_Detail.PoUnit = itm.单位; |
|
|
|
|
|
_PO_Detail.UnConv = 1; |
|
|
|
|
|
_PO_Detail.Remark = itm.备注; |
|
|
|
|
|
_PO_Detail.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); |
|
|
|
|
|
scpdb.TB_PO_DETAIL.AddOrUpdate(_PO_Detail); |
|
|
|
|
|
}); |
|
|
|
|
|
_polist = _polist + _po.PoBillNum + ","; |
|
|
|
|
|
} |
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 离散单 (离散单只增加不修改)
|
|
|
|
|
|
if (p_modtype == BillModType.Non_Contract) |
|
|
|
|
|
{ |
|
|
|
|
|
var _entity = list.FirstOrDefault(); |
|
|
|
|
|
TB_PO _po = new TB_PO(); |
|
|
|
|
|
_po.GUID = Guid.NewGuid(); |
|
|
|
|
|
_po.PoBillNum = SCP_BILLCODE_CONTROLLER.MakePoNum(_num); |
|
|
|
|
|
_po.State = (int)PoState.Open; |
|
|
|
|
|
_po.Site = site.Trim().ToUpper(); |
|
|
|
|
|
_po.SubSite = subsite.Trim().ToUpper(); |
|
|
|
|
|
_po.VendId = _entity.供应商编号.Trim().ToUpper(); |
|
|
|
|
|
_po.ErpBillNum = _po.PoBillNum; |
|
|
|
|
|
_po.ModType = (int)p_modtype; |
|
|
|
|
|
_po.Contacter = p_chineseName;// _entity.联系人;
|
|
|
|
|
|
_po.Buyer = p_chineseName;// _entity.联系人;
|
|
|
|
|
|
_po.BuyerPhone = p_buyerPhone; |
|
|
|
|
|
_po.Site = site.Trim().ToUpper(); |
|
|
|
|
|
_po.Remark = _entity.备注; |
|
|
|
|
|
_po.IsDeleted = false; |
|
|
|
|
|
_po.CreateTime = DateTime.Now; |
|
|
|
|
|
_po.CreateUser = p_creator; |
|
|
|
|
|
_po.BeginTime = string.IsNullOrEmpty(_entity.订单创建时间) ? DateTime.Now : DateTime.Parse(_entity.订单创建时间); |
|
|
|
|
|
_po.EndTime = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.要求到货日期); |
|
|
|
|
|
scpdb.TB_PO.AddOrUpdate(_po); |
|
|
|
|
|
TB_ASK _ask = new TB_ASK(); |
|
|
|
|
|
_ask.AskBillNum = SCP_BILLCODE_CONTROLLER.MakeASKCodeByNum(_num); |
|
|
|
|
|
_ask.GUID = Guid.NewGuid(); |
|
|
|
|
|
_ask.PoBillNum = _po.PoBillNum; |
|
|
|
|
|
_ask.VendId = _entity.供应商编号.Trim().ToUpper(); |
|
|
|
|
|
_ask.IsDeleted = false; |
|
|
|
|
|
_ask.CreateTime = DateTime.Now; |
|
|
|
|
|
_ask.CreateUser = p_creator; |
|
|
|
|
|
_ask.Site = site.Trim().ToUpper(); |
|
|
|
|
|
_ask.ReceivedPort = "";//交货口
|
|
|
|
|
|
_ask.State = (int)AskState.New; |
|
|
|
|
|
_ask.Remark = _entity.备注; |
|
|
|
|
|
_ask.ModType = (int)p_modtype; |
|
|
|
|
|
_ask.ErpBillNum = _po.PoBillNum; |
|
|
|
|
|
_ask.BeginTime = p_time; |
|
|
|
|
|
_ask.EndTime = DateTime.Parse(_entity.要求到货日期); |
|
|
|
|
|
_ask.Buyer = p_chineseName; |
|
|
|
|
|
_ask.BuyerPhone = p_buyerPhone; |
|
|
|
|
|
_ask.SubSite = subsite; |
|
|
|
|
|
scpdb.TB_ASK.Add(_ask); |
|
|
|
|
|
|
|
|
|
|
|
TED_PO_MSTR _po_mstr = new TED_PO_MSTR(); |
|
|
|
|
|
_po_mstr.GUID = Guid.NewGuid(); |
|
|
|
|
|
_po_mstr.PurchaseOrder = _po.PoBillNum; |
|
|
|
|
|
_po_mstr.Supplier = _entity.供应商编号.Trim().ToUpper(); |
|
|
|
|
|
_po_mstr.Contact = p_chineseName;// _entity.联系人;
|
|
|
|
|
|
_po_mstr.ShipTo = subsite.Trim().ToUpper();//发往
|
|
|
|
|
|
_po_mstr.OrderDate = string.IsNullOrEmpty(_entity.订单创建时间) ? DateTime.Now : DateTime.Parse(_entity.订单创建时间); |
|
|
|
|
|
_po_mstr.DueDate = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now : DateTime.Parse(_entity.要求到货日期); |
|
|
|
|
|
_po_mstr.StartDate = string.IsNullOrEmpty(_entity.订单开始时间) ? DateTime.Now : DateTime.Parse(_entity.订单开始时间);//订单日期
|
|
|
|
|
|
_po_mstr.EndDate = string.IsNullOrEmpty(_entity.订单截至日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.订单截至日期); |
|
|
|
|
|
_po_mstr.MadeIn = ""; |
|
|
|
|
|
_po_mstr.Confirm = true; |
|
|
|
|
|
_po_mstr.Buyer = p_chineseName;// _entity.采购员;
|
|
|
|
|
|
_po_mstr.BuyerPhone = p_buyerPhone;// _entity.采购员电话;
|
|
|
|
|
|
_po_mstr.Status = (int)PoState.Open; |
|
|
|
|
|
_po_mstr.ScheduledOrder = false; |
|
|
|
|
|
_po_mstr.CreateUser = p_creator; |
|
|
|
|
|
_po_mstr.CreateTime = p_time; |
|
|
|
|
|
_po_mstr.Remark = _entity.备注; ; |
|
|
|
|
|
_po_mstr.TaskID = taskid; |
|
|
|
|
|
_po_mstr.CommandType = "A"; |
|
|
|
|
|
_po_mstr.Domain = site.Trim().ToUpper(); |
|
|
|
|
|
_po_mstr.ModeType = ((int)p_modtype).ToString(); |
|
|
|
|
|
_po_mstr.Site = subsite.Trim().ToUpper(); |
|
|
|
|
|
_po_mstr.DataID = Guid.NewGuid(); |
|
|
|
|
|
_po_mstr.Pricelist = _entity.供应商编号.ToUpper().Trim() + subsite.Substring(1, 1) + subsite.Substring(3, 1); |
|
|
|
|
|
_po_mstr.Taxclass = _entity.税率; |
|
|
|
|
|
db.TED_PO_MSTR.Add(_po_mstr); |
|
|
|
|
|
|
|
|
|
|
|
int _number = 1; |
|
|
|
|
|
list.ForEach((itm) => |
|
|
|
|
|
{ |
|
|
|
|
|
TB_PO_DETAIL _PO_Detail = new TB_PO_DETAIL(); |
|
|
|
|
|
_PO_Detail.GUID = Guid.NewGuid(); |
|
|
|
|
|
_PO_Detail.PartCode = itm.零件号.Trim().ToUpper(); |
|
|
|
|
|
_PO_Detail.PoLine = _number; |
|
|
|
|
|
_PO_Detail.PoBillNum = _po.PoBillNum; |
|
|
|
|
|
_PO_Detail.State = (int)PoState.Open; |
|
|
|
|
|
_PO_Detail.Site = site.Trim().ToUpper(); |
|
|
|
|
|
_PO_Detail.SubSite = subsite.Trim().ToUpper(); |
|
|
|
|
|
_PO_Detail.Currency = "CNY"; |
|
|
|
|
|
_PO_Detail.PoUnit = itm.单位; |
|
|
|
|
|
_PO_Detail.Remark = itm.备注; |
|
|
|
|
|
_PO_Detail.CreateTime = DateTime.Now; |
|
|
|
|
|
_PO_Detail.CreateUser = p_creator; |
|
|
|
|
|
_PO_Detail.BeginTime = string.IsNullOrEmpty(itm.订单创建时间) ? DateTime.Now : DateTime.Parse(itm.订单创建时间); |
|
|
|
|
|
_PO_Detail.EndTime = string.IsNullOrEmpty(itm.要求到货日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(itm.要求到货日期); |
|
|
|
|
|
_PO_Detail.PlanQty = decimal.Parse(itm.数量); |
|
|
|
|
|
_PO_Detail.IsDeleted = false; |
|
|
|
|
|
_PO_Detail.LocUnit = itm.单位; |
|
|
|
|
|
_PO_Detail.PoUnit = itm.单位; |
|
|
|
|
|
_PO_Detail.UnConv = 1; |
|
|
|
|
|
_PO_Detail.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); |
|
|
|
|
|
_PO_Detail.TempQty = decimal.Parse(itm.数量); |
|
|
|
|
|
TB_ASK_DETAIL _tDetail = new TB_ASK_DETAIL(); |
|
|
|
|
|
_tDetail.Remark = itm.备注; |
|
|
|
|
|
_tDetail.PoBillNum = _po.PoBillNum; |
|
|
|
|
|
_tDetail.AskBillNum = _ask.AskBillNum; |
|
|
|
|
|
_tDetail.PoLine = _number; |
|
|
|
|
|
_tDetail.PoUnit = itm.单位; |
|
|
|
|
|
_tDetail.CreateTime = DateTime.Now; |
|
|
|
|
|
_tDetail.CreateUser = p_creator; |
|
|
|
|
|
_tDetail.PartCode = itm.零件号.ToUpper().Trim(); |
|
|
|
|
|
_tDetail.ReceivedPort = ""; |
|
|
|
|
|
_tDetail.BeginTime = p_time; |
|
|
|
|
|
_tDetail.EndTime = Convert.ToDateTime(itm.要求到货日期); |
|
|
|
|
|
_tDetail.TempQty = 0; |
|
|
|
|
|
_tDetail.AskQty = Decimal.Parse(itm.数量); |
|
|
|
|
|
_tDetail.IsDeleted = false; |
|
|
|
|
|
_tDetail.LocUnit = itm.单位; |
|
|
|
|
|
_tDetail.UnConv = 1; |
|
|
|
|
|
_tDetail.State = (int)PoState.Open; |
|
|
|
|
|
_tDetail.SubSite = subsite.Trim().ToUpper(); |
|
|
|
|
|
_tDetail.Site = site.Trim().ToUpper(); |
|
|
|
|
|
_tDetail.Price = Decimal.Parse(itm.单价); |
|
|
|
|
|
_tDetail.GUID = Guid.NewGuid(); |
|
|
|
|
|
_tDetail.Currency = itm.币种; |
|
|
|
|
|
scpdb.TB_ASK_DETAIL.Add(_tDetail); |
|
|
|
|
|
scpdb.TB_PO_DETAIL.AddOrUpdate(_PO_Detail); |
|
|
|
|
|
TED_PO_DET _PO_Detail_Det = new TED_PO_DET(); |
|
|
|
|
|
_PO_Detail_Det.GUID = Guid.NewGuid(); |
|
|
|
|
|
_PO_Detail_Det.PurchaseOrder = _po.PoBillNum; |
|
|
|
|
|
_PO_Detail_Det.Line = _number; |
|
|
|
|
|
_PO_Detail_Det.Currency = "CNY"; |
|
|
|
|
|
_PO_Detail_Det.PoType = itm.订单类型; |
|
|
|
|
|
_PO_Detail_Det.PartCode = itm.零件号.Trim().ToUpper(); |
|
|
|
|
|
_PO_Detail_Det.Qty = decimal.Parse(itm.数量); |
|
|
|
|
|
_PO_Detail_Det.QtyOpen = 0; |
|
|
|
|
|
_PO_Detail_Det.PackQty = 1; |
|
|
|
|
|
_PO_Detail_Det.Currency = itm.币种; |
|
|
|
|
|
_PO_Detail_Det.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); |
|
|
|
|
|
_PO_Detail_Det.PoUm = itm.单位; |
|
|
|
|
|
_PO_Detail_Det.LocUm = itm.单位; |
|
|
|
|
|
_PO_Detail_Det.Conv = 1; |
|
|
|
|
|
_PO_Detail_Det.DueDate = string.IsNullOrEmpty(itm.要求到货日期) ? DateTime.Now : DateTime.Parse(itm.要求到货日期); |
|
|
|
|
|
_PO_Detail_Det.Status = (int)PoState.Open; |
|
|
|
|
|
_PO_Detail_Det.CreateTime = DateTime.Parse(itm.订单创建时间); |
|
|
|
|
|
_PO_Detail_Det.StartDate = string.IsNullOrEmpty(itm.零件开始时间) ? p_time : DateTime.Parse(itm.零件开始时间); |
|
|
|
|
|
_PO_Detail_Det.EndDate = string.IsNullOrEmpty(itm.零件截至日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(itm.零件截至日期); |
|
|
|
|
|
_PO_Detail_Det.CreateUser = p_creator; |
|
|
|
|
|
_PO_Detail_Det.TaskID = taskid; |
|
|
|
|
|
_PO_Detail_Det.CommandType = "A"; |
|
|
|
|
|
_PO_Detail_Det.DataID = Guid.NewGuid(); |
|
|
|
|
|
_PO_Detail_Det.Domain = site.Trim().ToUpper(); |
|
|
|
|
|
_PO_Detail_Det.Site = subsite.Trim().ToUpper(); |
|
|
|
|
|
_PO_Detail_Det.Workorderlot = itm.加工单号; |
|
|
|
|
|
_PO_Detail_Det.PoType = itm.订单类型; |
|
|
|
|
|
_PO_Detail_Det.Operation = string.IsNullOrEmpty(itm.工序) ? 0 : int.Parse(itm.工序); |
|
|
|
|
|
_PO_Detail_Det.Location = itm.库位; |
|
|
|
|
|
_PO_Detail_Det.Firmdays = string.IsNullOrEmpty(itm.固定天数) ? 7 : int.Parse(itm.固定天数); |
|
|
|
|
|
_PO_Detail_Det.Scheduledays = string.IsNullOrEmpty(itm.日程天数) ? 7 : int.Parse(itm.日程天数); |
|
|
|
|
|
_PO_Detail_Det.Scheduleweeks = string.IsNullOrEmpty(itm.日程周数) ? 2 : int.Parse(itm.日程周数); |
|
|
|
|
|
_PO_Detail_Det.Schedulemonth = string.IsNullOrEmpty(itm.日程月数) ? 1 : int.Parse(itm.日程月数); |
|
|
|
|
|
_PO_Detail_Det.Supplieritem = itm.供应商零件; |
|
|
|
|
|
_PO_Detail_Det.Dliverypatterncode = itm.发货样式; |
|
|
|
|
|
_PO_Detail_Det.Deliverytimecode = itm.发货时间样式; |
|
|
|
|
|
_PO_Detail_Det.Transportdays = string.IsNullOrEmpty(itm.运输周期) ? 0 : int.Parse(itm.运输周期); |
|
|
|
|
|
_PO_Detail_Det.Pricelist = _entity.供应商编号.ToUpper() + subsite.Substring(1, 1) + subsite.Substring(3, 1); |
|
|
|
|
|
db.TED_POD_DET.Add(_PO_Detail_Det); |
|
|
|
|
|
_number++; |
|
|
|
|
|
}); |
|
|
|
|
|
_polist = _polist + _po.PoBillNum + ","; |
|
|
|
|
|
} |
|
|
|
|
|
#endregion
|
|
|
|
|
|
} |
|
|
|
|
|
var ret = CREATE_TEA_TASK_SUB(db, true, new TEA_TASK_SUB() |
|
|
|
|
|
{ |
|
|
|
|
|
DataCount = 1, |
|
|
|
|
|
TaskID = taskid, |
|
|
|
|
|
TableName = "TED_PO_MSTR", |
|
|
|
|
|
Site = subsite.Trim().ToUpper(), |
|
|
|
|
|
Domain = site.Trim().ToUpper(), |
|
|
|
|
|
CreateTime = p_time, |
|
|
|
|
|
CreateUser = p_creator, |
|
|
|
|
|
Creator = "SCP", |
|
|
|
|
|
}); |
|
|
|
|
|
_num++; |
|
|
|
|
|
Thread.Sleep(10); |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
EntitiesFactory.SaveDb(scpdb); |
|
|
|
|
|
EntitiesFactory.SaveDb(db); |
|
|
|
|
|
scope.Complete(); |
|
|
|
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
|
|
|
_ret.Result = true; |
|
|
|
|
|
_ret.Message = _polist; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception e) |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "InsterPo", e.Message); |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.Message = e.InnerException.Message; |
|
|
|
|
|
scope.Dispose(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return _ret; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//public static ResultObject<bool> UpdateTES_PURCHASE_PRICE(List<long> p_list, string domain, string site, string name, bool flag,int ConfirmState)
|
|
|
//public static ResultObject<bool> UpdateTES_PURCHASE_PRICE(List<long> p_list, string domain, string site, string name, bool flag,int ConfirmState)
|
|
|
//{
|
|
|
//{
|
|
|
|
|
|
|
|
|
// ResultObject<bool> _ret = new ResultObject<bool>();
|
|
|
// ResultObject<bool> _ret = new ResultObject<bool>();
|
|
|
// if (ConfirmState!=(int)PriceState.FConfirm)
|
|
|
// if (ConfirmState!=(int)PriceState.FConfirm)
|
|
|
// {
|
|
|
// {
|
|
@ -1916,7 +2272,7 @@ namespace CK.SCP.Controller |
|
|
// ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance();
|
|
|
// ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance();
|
|
|
// List<TES_PURCHASE_PRICE> _teslist = new List<TES_PURCHASE_PRICE>();
|
|
|
// List<TES_PURCHASE_PRICE> _teslist = new List<TES_PURCHASE_PRICE>();
|
|
|
// var _ls = scpdb.V_TB_PRICE.Where(p => p_list.Contains(p.UID)).ToList();
|
|
|
// var _ls = scpdb.V_TB_PRICE.Where(p => p_list.Contains(p.UID)).ToList();
|
|
|
|
|
|
|
|
|
// foreach (var _price in _ls)
|
|
|
// foreach (var _price in _ls)
|
|
|
// {
|
|
|
// {
|
|
|
// Guid _taskguid = Guid.NewGuid();
|
|
|
// Guid _taskguid = Guid.NewGuid();
|
|
@ -2018,7 +2374,7 @@ namespace CK.SCP.Controller |
|
|
// ScpEntities scpdb = EntitiesFactory.CreateScpInstance();
|
|
|
// ScpEntities scpdb = EntitiesFactory.CreateScpInstance();
|
|
|
// ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance();
|
|
|
// ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance();
|
|
|
// var OrderList = p_order_list.GroupBy(p => p.订单编号).ToList();
|
|
|
// var OrderList = p_order_list.GroupBy(p => p.订单编号).ToList();
|
|
|
// string _polist = "";
|
|
|
// string _polist = "";
|
|
|
// int _num = 1;
|
|
|
// int _num = 1;
|
|
|
// OrderList.ForEach((p) =>
|
|
|
// OrderList.ForEach((p) =>
|
|
|
// {
|
|
|
// {
|
|
@ -2030,7 +2386,7 @@ namespace CK.SCP.Controller |
|
|
// if (p_modtype == BillModType.Contract)
|
|
|
// if (p_modtype == BillModType.Contract)
|
|
|
// {
|
|
|
// {
|
|
|
// var _entity = list.FirstOrDefault();
|
|
|
// var _entity = list.FirstOrDefault();
|
|
|
// var _po = scpdb.TB_PO.SingleOrDefault(t => t.PoBillNum == _entity.订单编号/* && t.State == state*/ && t.Site == site && t.SubSite == subsite && t.VendId == _entity.供应商编号.ToUpper());
|
|
|
// var _po = scpdb.TB_PO.SingleOrDefault(t => t.PoBillNum == _entity.订单编号/* && t.State == state*/ && t.Site == site && t.SubSite == subsite && t.VendId == _entity.供应商编号.ToUpper());
|
|
|
// TED_PO_MSTR _po_mstr = new TED_PO_MSTR();
|
|
|
// TED_PO_MSTR _po_mstr = new TED_PO_MSTR();
|
|
|
// _po_mstr.GUID = Guid.NewGuid();
|
|
|
// _po_mstr.GUID = Guid.NewGuid();
|
|
|
// _po_mstr.PurchaseOrder = _entity.订单编号.Trim().ToUpper();
|
|
|
// _po_mstr.PurchaseOrder = _entity.订单编号.Trim().ToUpper();
|
|
@ -2068,7 +2424,7 @@ namespace CK.SCP.Controller |
|
|
// }
|
|
|
// }
|
|
|
// db.TED_PO_MSTR.Add(_po_mstr);
|
|
|
// db.TED_PO_MSTR.Add(_po_mstr);
|
|
|
|
|
|
|
|
|
// _po.ErpBillNum = _entity.订单编号.Trim().ToUpper();;
|
|
|
// _po.ErpBillNum = _entity.订单编号.Trim().ToUpper(); ;
|
|
|
// _po.ModType = (int)p_modtype;
|
|
|
// _po.ModType = (int)p_modtype;
|
|
|
// _po.Contacter = p_chineseName;// _entity.联系人;
|
|
|
// _po.Contacter = p_chineseName;// _entity.联系人;
|
|
|
// _po.Buyer = p_chineseName;// _entity.联系人;
|
|
|
// _po.Buyer = p_chineseName;// _entity.联系人;
|
|
@ -2111,7 +2467,7 @@ namespace CK.SCP.Controller |
|
|
// else
|
|
|
// else
|
|
|
// {
|
|
|
// {
|
|
|
// _PO_Detail_Det.PoUm = _part.Unit;
|
|
|
// _PO_Detail_Det.PoUm = _part.Unit;
|
|
|
// _PO_Detail_Det.LocUm =_part.Unit;
|
|
|
// _PO_Detail_Det.LocUm = _part.Unit;
|
|
|
// }
|
|
|
// }
|
|
|
// _PO_Detail_Det.Conv = 1;
|
|
|
// _PO_Detail_Det.Conv = 1;
|
|
|
// _PO_Detail_Det.DueDate = string.IsNullOrEmpty(itm.要求到货日期) ? DateTime.Now : DateTime.Parse(itm.要求到货日期);
|
|
|
// _PO_Detail_Det.DueDate = string.IsNullOrEmpty(itm.要求到货日期) ? DateTime.Now : DateTime.Parse(itm.要求到货日期);
|
|
@ -2134,7 +2490,7 @@ namespace CK.SCP.Controller |
|
|
// _PO_Detail_Det.Domain = site.Trim().ToUpper();
|
|
|
// _PO_Detail_Det.Domain = site.Trim().ToUpper();
|
|
|
// _PO_Detail_Det.Site = subsite.Trim().ToUpper();
|
|
|
// _PO_Detail_Det.Site = subsite.Trim().ToUpper();
|
|
|
// _PO_Detail_Det.Workorderlot = itm.加工单号;
|
|
|
// _PO_Detail_Det.Workorderlot = itm.加工单号;
|
|
|
// _PO_Detail_Det.PoType = itm.订单类型;
|
|
|
// _PO_Detail_Det.PoType = itm.订单类型;
|
|
|
// _PO_Detail_Det.Operation = string.IsNullOrEmpty(itm.工序) ? 0 : int.Parse(itm.工序);
|
|
|
// _PO_Detail_Det.Operation = string.IsNullOrEmpty(itm.工序) ? 0 : int.Parse(itm.工序);
|
|
|
// _PO_Detail_Det.Location = itm.库位;
|
|
|
// _PO_Detail_Det.Location = itm.库位;
|
|
|
// _PO_Detail_Det.Firmdays = string.IsNullOrEmpty(itm.固定天数) ? 7 : int.Parse(itm.固定天数);
|
|
|
// _PO_Detail_Det.Firmdays = string.IsNullOrEmpty(itm.固定天数) ? 7 : int.Parse(itm.固定天数);
|
|
@ -2161,7 +2517,7 @@ namespace CK.SCP.Controller |
|
|
// _PO_Detail.Remark = itm.备注;
|
|
|
// _PO_Detail.Remark = itm.备注;
|
|
|
// _PO_Detail.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价);
|
|
|
// _PO_Detail.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价);
|
|
|
// _PO_Detail.Workorderlot = string.IsNullOrEmpty(itm.加工单号) ? 0 : int.Parse(itm.加工单号);
|
|
|
// _PO_Detail.Workorderlot = string.IsNullOrEmpty(itm.加工单号) ? 0 : int.Parse(itm.加工单号);
|
|
|
// _PO_Detail.PoType =itm.订单类型;
|
|
|
// _PO_Detail.PoType = itm.订单类型;
|
|
|
// _PO_Detail.Operation = string.IsNullOrEmpty(itm.工序) ? 0 : int.Parse(itm.工序);
|
|
|
// _PO_Detail.Operation = string.IsNullOrEmpty(itm.工序) ? 0 : int.Parse(itm.工序);
|
|
|
// _PO_Detail.Location = itm.库位;
|
|
|
// _PO_Detail.Location = itm.库位;
|
|
|
// _PO_Detail.Firmdays = string.IsNullOrEmpty(itm.固定天数) ? 7 : int.Parse(itm.固定天数);
|
|
|
// _PO_Detail.Firmdays = string.IsNullOrEmpty(itm.固定天数) ? 7 : int.Parse(itm.固定天数);
|
|
@ -2225,7 +2581,7 @@ namespace CK.SCP.Controller |
|
|
// scpdb.TB_ASK.Add(_ask);
|
|
|
// scpdb.TB_ASK.Add(_ask);
|
|
|
// TED_PO_MSTR _po_mstr = new TED_PO_MSTR();
|
|
|
// TED_PO_MSTR _po_mstr = new TED_PO_MSTR();
|
|
|
// _po_mstr.GUID = Guid.NewGuid();
|
|
|
// _po_mstr.GUID = Guid.NewGuid();
|
|
|
|
|
|
|
|
|
// _po_mstr.PurchaseOrder = _po.PoBillNum;
|
|
|
// _po_mstr.PurchaseOrder = _po.PoBillNum;
|
|
|
// _po_mstr.Supplier = _entity.供应商编号.Trim().ToUpper();
|
|
|
// _po_mstr.Supplier = _entity.供应商编号.Trim().ToUpper();
|
|
|
// _po_mstr.Contact = p_chineseName;// _entity.联系人;
|
|
|
// _po_mstr.Contact = p_chineseName;// _entity.联系人;
|
|
@ -2380,7 +2736,7 @@ namespace CK.SCP.Controller |
|
|
// scope.Complete();
|
|
|
// scope.Complete();
|
|
|
// _ret.State = ReturnStatus.Succeed;
|
|
|
// _ret.State = ReturnStatus.Succeed;
|
|
|
// _ret.Result = true;
|
|
|
// _ret.Result = true;
|
|
|
// _ret.Message= _polist;
|
|
|
// _ret.Message = _polist;
|
|
|
|
|
|
|
|
|
// }
|
|
|
// }
|
|
|
// catch (Exception e)
|
|
|
// catch (Exception e)
|
|
@ -2557,7 +2913,7 @@ namespace CK.SCP.Controller |
|
|
// {
|
|
|
// {
|
|
|
// Guid taskid = Guid.NewGuid();
|
|
|
// Guid taskid = Guid.NewGuid();
|
|
|
// TED_PO_MSTR item = new TED_PO_MSTR();
|
|
|
// TED_PO_MSTR item = new TED_PO_MSTR();
|
|
|
|
|
|
|
|
|
// var _mstr = scpdb.TB_PO.FirstOrDefault(t => t.PoBillNum == _num && t.State == (int)PoState.Open);
|
|
|
// var _mstr = scpdb.TB_PO.FirstOrDefault(t => t.PoBillNum == _num && t.State == (int)PoState.Open);
|
|
|
// if (_mstr!= null)
|
|
|
// if (_mstr!= null)
|
|
|
// {
|
|
|
// {
|
|
|