|
|
@ -395,9 +395,10 @@ namespace CK.SCP.Controller |
|
|
|
{ |
|
|
|
switch (_task.TableName) |
|
|
|
{ |
|
|
|
//case "TED_POD":
|
|
|
|
// result = UpdatePo(db, scpdb, _task);
|
|
|
|
// break;
|
|
|
|
case "TED_PO_MSTR": |
|
|
|
result = UpdatePo(db, scpdb, _task); |
|
|
|
result.Message = _task.TaskID.ToString(); |
|
|
|
break; |
|
|
|
case "TED_RECEIPT_MSTR": |
|
|
|
if (_task.Creator == "QAD") |
|
|
|
{ |
|
|
@ -418,9 +419,9 @@ namespace CK.SCP.Controller |
|
|
|
result = UpdateSupplier(db, scpdb,authdb, _task); |
|
|
|
result.Message = _task.TaskID.ToString(); |
|
|
|
break; |
|
|
|
//case "TES_SUPPLIER_PART":
|
|
|
|
// result = UpdateSupplierPart(dc, db, scpdb, _task);
|
|
|
|
// break;
|
|
|
|
case "TES_SUPPLIER_PART": |
|
|
|
result = UpdateSupplierPart(dc, db, scpdb, _task); |
|
|
|
break; |
|
|
|
case "TES_PART_MSTR": |
|
|
|
result = UpdatePart(db, scpdb, _task); |
|
|
|
result.Message = _task.TaskID.ToString(); |
|
|
@ -428,6 +429,10 @@ namespace CK.SCP.Controller |
|
|
|
//case "TES_SITE":
|
|
|
|
// result = UpdateFactory(db, scpdb, appscpdb, _task);
|
|
|
|
// break;
|
|
|
|
case "TES_PURCHASE_PRICE": |
|
|
|
result = UpdatePrice(db, scpdb, authdb, _task); |
|
|
|
result.Message = _task.TaskID.ToString(); |
|
|
|
break; |
|
|
|
} |
|
|
|
Update_TEA_TASK_SUB(db, _task); |
|
|
|
EntitiesFactory.SaveDb(scpdb); |
|
|
@ -1434,55 +1439,140 @@ namespace CK.SCP.Controller |
|
|
|
try |
|
|
|
{ |
|
|
|
var _poList = db.TED_PO_MSTR.Where(p => p.TaskID == p_entity.TaskID).ToList(); |
|
|
|
var _scpPolist = new List<TB_PO>(); |
|
|
|
foreach (var po in _poList) |
|
|
|
{ |
|
|
|
var _po = scpdb.TB_PO.SingleOrDefault(p => p.ErpBillNum == po.PurchaseOrder && p.Site == po.Domain); |
|
|
|
if (_po == null) |
|
|
|
var scpPo = scpdb.TB_PO.SingleOrDefault(p => p.PoBillNum != null && p.PoBillNum == po.PurchaseOrder && p.Site == po.Domain && p.SubSite == po.Site); |
|
|
|
var scpPoList = new List<TB_PO>(); |
|
|
|
|
|
|
|
if (scpPo == null) |
|
|
|
{ |
|
|
|
int temp; |
|
|
|
_po = new TB_PO |
|
|
|
scpPo = new TB_PO |
|
|
|
{ |
|
|
|
PoBillNum = po.PurchaseOrder,//订单号
|
|
|
|
ErpBillNum = po.PurchaseOrder,//ERP订单号
|
|
|
|
VendId = po.Supplier,//供应商编号
|
|
|
|
//ErpBillNum = po.xxqad_pod_prj,//ERP订单号
|
|
|
|
VendId = po.Supplier.ToUpper(),//供应商编号
|
|
|
|
ModType = Int32.TryParse(po.ModeType, out temp) ? temp : (int?)null, //单据类型(1:日程单,2:离散订单)
|
|
|
|
Contacter = po.Contact,//联系人
|
|
|
|
Site = po.Domain,//地点
|
|
|
|
State = (int)FormState.开放,//状态
|
|
|
|
Remark = po.Remark,//说明
|
|
|
|
SubSite = po.Site, |
|
|
|
State = po.Status, |
|
|
|
CreateTime = po.CreateTime == null ? DateTime.Now : (DateTime)po.CreateTime,//创建日期
|
|
|
|
CreateUser = po.CreateUser,//创建用户
|
|
|
|
IsDeleted = false, |
|
|
|
GUID =po.TaskID, |
|
|
|
BeginTime = po.OrderDate == null ? DateTime.Now : po.OrderDate,//创建日期
|
|
|
|
GUID = System.Guid.NewGuid(), |
|
|
|
BeginTime = po.OrderDate == null ? DateTime.Now : (DateTime)po.OrderDate,//创建日期
|
|
|
|
EndTime = po.DueDate//收货结束时间
|
|
|
|
}; |
|
|
|
int _count = _scpPolist.Count(p => p.ErpBillNum == po.PurchaseOrder && p.Site == po.Domain ); |
|
|
|
if (_count == 0) |
|
|
|
scpPoList.Add(scpPo); |
|
|
|
} |
|
|
|
scpPo.Contacter = po.Contact;//联系人
|
|
|
|
scpPo.Buyer = po.Buyer; |
|
|
|
scpPo.BuyerPhone = po.BuyerPhone; |
|
|
|
scpPo.UpdateTime = DateTime.Now;//更新日期
|
|
|
|
scpPo.UpdateUser = "QAD";//更新用户
|
|
|
|
scpPo.State = po.Status; |
|
|
|
scpdb.TB_PO.AddOrUpdate(scpPoList.ToArray()); |
|
|
|
} |
|
|
|
var scpPoDetailList = new List<TB_PO_DETAIL>(); |
|
|
|
var _poDetailList = db.TED_POD_DET.Where(p => p.TaskID == p_entity.TaskID).ToList(); |
|
|
|
foreach (var podetail in _poDetailList) |
|
|
|
{ |
|
|
|
var poLineNum = Convert.ToInt32(podetail.Line); |
|
|
|
var scpPoDetail =scpdb.TB_PO_DETAIL.SingleOrDefault( |
|
|
|
p => p.PoBillNum == podetail.PurchaseOrder && p.PoLine == poLineNum && p.Site == podetail.Domain&&p.SubSite==podetail.Site); |
|
|
|
if (scpPoDetail == null) |
|
|
|
{ |
|
|
|
scpPoDetail = new TB_PO_DETAIL |
|
|
|
{ |
|
|
|
_scpPolist.Add(_po); |
|
|
|
} |
|
|
|
PoBillNum = podetail.PurchaseOrder,//订单号
|
|
|
|
PoLine = poLineNum,//订单行
|
|
|
|
IsDeleted = false, |
|
|
|
GUID = System.Guid.NewGuid() |
|
|
|
}; |
|
|
|
scpPoDetailList.Add(scpPoDetail); |
|
|
|
} |
|
|
|
_po.Contacter = po.Contact; |
|
|
|
_po.Buyer = _po.Buyer; |
|
|
|
_po.BuyerPhone = _po.BuyerPhone; |
|
|
|
_po.UpdateTime = _po.UpdateTime;//更新日期
|
|
|
|
_po.UpdateUser = _po.UpdateUser;//更新用户
|
|
|
|
scpPoDetail.PartCode = podetail.PartCode.ToUpper();//零件号-物料号
|
|
|
|
scpPoDetail.PlanQty = podetail.Qty;//订货数量-采购量
|
|
|
|
scpPoDetail.BeginTime = podetail.StartDate;//收货开始时间
|
|
|
|
scpPoDetail.EndTime = podetail.EndDate;//收货结束时间
|
|
|
|
scpPoDetail.PoUnit = podetail.PoUm;//采购单位
|
|
|
|
scpPoDetail.LocUnit = podetail.LocUm.ToUpper();//存储单位
|
|
|
|
scpPoDetail.DockCode = podetail.Location; |
|
|
|
scpPoDetail.Price = podetail.Price; |
|
|
|
scpPoDetail.Currency = podetail.Currency;//币种
|
|
|
|
scpPoDetail.PackQty = podetail.PackQty;//标包数量
|
|
|
|
scpPoDetail.UnConv = podetail.Conv;//转换率
|
|
|
|
scpPoDetail.State = Convert.ToInt32(podetail.Status);//状态
|
|
|
|
scpPoDetail.Site = podetail.Domain; |
|
|
|
scpPoDetail.SubSite = podetail.Site; |
|
|
|
scpPoDetail.CreateTime = podetail.CreateTime == null ? DateTime.Now : (DateTime)podetail.CreateTime;//创建日期
|
|
|
|
scpPoDetail.CreateUser = podetail.CreateUser;//创建用户
|
|
|
|
scpPoDetail.UpdateTime = DateTime.Now;//更新日期
|
|
|
|
scpPoDetail.UpdateUser = "QAD";//更新用户
|
|
|
|
if (scpPoDetail.PlanQty != 0 && scpPoDetail.PlanQty <= scpPoDetail.ReceivedQty)scpPoDetail.State = (int)FormState.关闭; |
|
|
|
} |
|
|
|
scpdb.TB_PO.AddOrUpdate(_scpPolist.ToArray()); |
|
|
|
scpdb.TB_PO_DETAIL.AddOrUpdate(scpPoDetailList.ToArray()); |
|
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
|
_ret.MessageList.Add(string.Format("QAD订单更新{0}任务编号{1}", _poDetailList.Count().ToString(), p_entity.TaskID)); |
|
|
|
_ret.Result = true; |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "Save_TEA_TASK_SUB", e.Message); |
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "UpdatePo", e.Message); |
|
|
|
_ret.Result = false; |
|
|
|
_ret.ErrorList.Add(e); |
|
|
|
_ret.MessageList.Add(string.Format("QAD订单更新失败任务编号{0}", p_entity.TaskID)); |
|
|
|
throw e; |
|
|
|
} |
|
|
|
return _ret; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 价格
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="db"></param>
|
|
|
|
/// <param name="scpdb"></param>
|
|
|
|
/// <param name="p_entity"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static ResultObject<bool> UpdatePrice(ExchangeCenterContext db, ScpEntities scpdb, AppBoxContext authdb, TEA_TASK_SUB p_entity) |
|
|
|
{ |
|
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
|
try |
|
|
|
{ |
|
|
|
var _pricelistqad = db.TES_PURCHASE_PRICE.Where(p => p.TaskID == p_entity.TaskID).ToList(); |
|
|
|
var _pricelistscp = new List<TB_PRICE>(); |
|
|
|
foreach (var price in _pricelistqad) |
|
|
|
{ |
|
|
|
|
|
|
|
var _price = new TB_PRICE |
|
|
|
{ |
|
|
|
VendId = price.SupplierCode, |
|
|
|
Unit = price.Um, |
|
|
|
PartCode = price.PartCode, |
|
|
|
Site = price.Site, |
|
|
|
Remarks = price.Remark, |
|
|
|
StartTime = price.Start, |
|
|
|
EndTime = price.ExpireDate, |
|
|
|
Curr = price.Currency |
|
|
|
}; |
|
|
|
_price.Amt = price.Amount; |
|
|
|
_pricelistscp.Add(_price); |
|
|
|
} |
|
|
|
scpdb.TB_PRICE.AddOrUpdate(_pricelistscp.ToArray()); |
|
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
|
_ret.MessageList.Add(string.Format("更新表{0}任务ID{1}成功!", "TES_PURCHASE_PRICE", p_entity.TaskID)); |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "UpdatePrice", e.Message); |
|
|
|
_ret.Result = false; |
|
|
|
_ret.ErrorList.Add(e); |
|
|
|
throw e; |
|
|
|
} |
|
|
|
return _ret; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 更新供应商
|
|
|
|
/// </summary>
|
|
|
|