Browse Source

Merge branch 'master' of https://gitee.com/zxyabc/COMONE

master
TML 4 years ago
parent
commit
4763408e8d
  1. 429
      Controller/SCP_DC_UNI_CONTROLLER.cs

429
Controller/SCP_DC_UNI_CONTROLLER.cs

@ -398,33 +398,69 @@ namespace CK.SCP.Controller
case "TED_PO_MSTR":
result = UpdatePo(db, scpdb, _task);
result.Message = _task.TaskID.ToString();
Update_TEA_TASK_SUB(db, _task);
EntitiesFactory.SaveDb(scpdb);
EntitiesFactory.SaveDb(db);
EntitiesFactory.SaveDb(dc);
scope.Complete();
break;
case "TED_RECEIPT_MSTR":
if (_task.Creator == "QAD")
{
result = UpdateRecive(db, scpdb, _task);
result = UpdateReciveQAD(db, scpdb, _task);
result.Message = _task.TaskID.ToString();
Update_TEA_TASK_SUB(db, _task);
EntitiesFactory.SaveDb(scpdb);
EntitiesFactory.SaveDb(db);
EntitiesFactory.SaveDb(dc);
scope.Complete();
}
else
{
result = UpdateARRIVE(db, scpdb, _task);
result = UpdateRecive(db, scpdb, _task);
result.Message = _task.TaskID.ToString();
Update_TEA_TASK_SUB(db, _task);
EntitiesFactory.SaveDb(scpdb);
EntitiesFactory.SaveDb(db);
EntitiesFactory.SaveDb(dc);
scope.Complete();
}
break;
case "TED_RETURN_MSTR":
result = UpdateReturn(db, scpdb, _task);
result.Message = _task.TaskID.ToString();
case "TED_RETURN_MSTR":
result = UpdateARRIVE(db, scpdb, _task);
result.Message = _task.TaskID.ToString();
Update_TEA_TASK_SUB(db, _task);
EntitiesFactory.SaveDb(scpdb);
EntitiesFactory.SaveDb(db);
EntitiesFactory.SaveDb(dc);
scope.Complete();
break;
case "TES_SUPPLIER":
result = UpdateSupplier(db, scpdb,authdb, _task);
result.Message = _task.TaskID.ToString();
Update_TEA_TASK_SUB(db, _task);
EntitiesFactory.SaveDb(scpdb);
EntitiesFactory.SaveDb(db);
EntitiesFactory.SaveDb(dc);
scope.Complete();
break;
case "TES_SUPPLIER_PART":
result = UpdateSupplierPart(dc, db, scpdb, _task);
result.Message = _task.TaskID.ToString();
Update_TEA_TASK_SUB(db, _task);
EntitiesFactory.SaveDb(scpdb);
EntitiesFactory.SaveDb(db);
EntitiesFactory.SaveDb(dc);
scope.Complete();
break;
case "TES_PART_MSTR":
result = UpdatePart(db, scpdb, _task);
result.Message = _task.TaskID.ToString();
Update_TEA_TASK_SUB(db, _task);
EntitiesFactory.SaveDb(scpdb);
EntitiesFactory.SaveDb(db);
EntitiesFactory.SaveDb(dc);
scope.Complete();
break;
//case "TES_SITE":
// result = UpdateFactory(db, scpdb, appscpdb, _task);
@ -432,13 +468,14 @@ namespace CK.SCP.Controller
case "TES_PURCHASE_PRICE":
result = UpdatePrice(db, scpdb, authdb, _task);
result.Message = _task.TaskID.ToString();
Update_TEA_TASK_SUB(db, _task);
EntitiesFactory.SaveDb(scpdb);
EntitiesFactory.SaveDb(db);
EntitiesFactory.SaveDb(dc);
scope.Complete();
break;
}
Update_TEA_TASK_SUB(db, _task);
EntitiesFactory.SaveDb(scpdb);
EntitiesFactory.SaveDb(db);
EntitiesFactory.SaveDb(dc);
scope.Complete();
// p_action(result);
result.State = ReturnStatus.Succeed;
result.Result = true;
@ -779,7 +816,7 @@ namespace CK.SCP.Controller
}
public static ResultObject<bool> UpdateRecive(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity)
public static ResultObject<bool> UpdateReciveQAD(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
@ -821,23 +858,25 @@ namespace CK.SCP.Controller
}
scpRcv = new TB_RECEIVE_QAD
{
RecvBillNum = detail.ReceiveNbr,//收货单号
RecvBillNum = detail.ReceiveNbr,//收货单号
ErpRecvBillNum = detail.ReceiveNbr,
State = istate,
Remark = "",
CreateTime = detail.ReceiptDate == null ? DateTime.Now : (DateTime)detail.ReceiptDate,//创建日期
CreateUser = detail.CreateUser,//创建用户
IsDeleted = false,
GUID = detail.TaskID,
BillType = 0
};
BillType = 0,
Site = detail.Domain,//地点
SubSite = detail.Site,//域
};
scpRcvList.Add(scpRcv);
}
scpRcv.PoBillNum = detail.PurchaseOrder;//采购单
scpRcv.AsnBillNum = detail.ASN;//发货单号
scpRcv.Site = detail.Domain;//地点
scpRcv.VendId = detail.Supplier;//供货商名称
scpRcv.ShipTime = detail.ReceiptDate;//收货日期
scpRcv.SubSite = detail.Site;
scpdb.TB_RECEIVE_QAD.AddOrUpdate(scpRcvList.ToArray());
}
@ -869,6 +908,7 @@ namespace CK.SCP.Controller
//}
scpRcvDetail = new TB_RECEIVE_DETAIL_QAD();
scpRcvDetail.RecvBillNum = detail.ReceiveNbr;//收货单号
scpRcvDetail.ErpRecvBillNum = detail.ReceiveNbr;//收货单号
scpRcvDetail.PoBillNum = detail.PurchaseOrder;//采购单
scpRcvDetail.PoLine = detail.Line;//订单行
scpRcvDetail.PartCode = detail.PartCode;//零件号
@ -876,37 +916,32 @@ namespace CK.SCP.Controller
scpRcvDetail.VendBatch = detail.SupplierLot;//供应商批号
scpRcvDetail.PoUnit = detail.Um;//采购单位
scpRcvDetail.LocUnit = detail.logisticsUm;//物流单位
//收货总量 //DockCode = ?,//收货口
scpRcvDetail.Qty = detail.ReceiveQuantity;
//收货总量 //DockCode = ?,//收货口
scpRcvDetail.State = 1;// (int)FormState.关闭,
scpRcvDetail.Remark = detail.Remark;
scpRcvDetail.CreateTime = detail.CreateTime == null ? DateTime.Now : (DateTime)detail.CreateTime;//创建日期
scpRcvDetail.CreateUser = detail.CreateUser;//创建用户
scpRcvDetail.IsDeleted = false;
scpRcvDetail.GUID = detail.TaskID;
scpRcvDetail.BillType = 0;
scpRcvDetail.Remark = detail.Remark;
scpRcvDetail.SubSite = detail.Shipto;
scpRcvDetail.Site = detail.Domain;
//scpRcvDetail.Currency = detail.Currency;
//scpRcvDetail.Currencyamount = detail.Currencyamount;
//scpRcvDetail.ExchangeRate = detail.Exchangerate==null?"1":detail.Exchangerate.Value.ToString();
//scpRcvDetail.ExchangeRate1 = detail.Exchangerate2 == null ? "1" : detail.Exchangerate2.Value.ToString();
//scpRcvDetail.ExchangeRateType = detail.Exchangeratetype;
//scpRcvDetail.WorkOrderID = detail.WorkOrderID;
//scpRcvDetail.POSite = detail.Posite;
//scpRcvDetail.POCost = detail.Purchasecost;
//scpRcvDetail.POStandardCost = detail.Purchasestandardcost;
//scpRcvDetail.ReceiptType = detail.receipttype;
//scpRcvDetail.ReturnReasonCode = detail.Returnreason;
//scpRcvDetail.Requestedby = detail.Requestby;
//scpRcvDetail.TaxEnvironment = detail.Taxenvironment;
//scpRcvDetail.TaxIn = detail.taxin;
//scpRcvDetail.TaxUsage = detail.Taxusage;
//scpRcvDetail.TaxClass = detail.Taxclass;
//scpRcvDetail.PurchaseType = detail.Purchasetype;
//scpRcvDetail.UMConversion = detail.Umconversion;
scpRcveDetailList.Add(scpRcvDetail);
scpRcvDetail.PurCost = detail.Purchasecost;
scpRcvDetail.StdCost = detail.Purchasestandardcost;
scpRcvDetail.Rate = detail.Exchangerate;
scpRcvDetail.Tax = detail.Taxclass;
scpRcvDetail.CurAmt = detail.Currencyamount;
scpRcvDetail.DockCode =detail.Location;
}
scpRcvDetail.Qty = detail.ReceiveQuantity;
scpRcvDetail.RecvBillNum = detail.ReceiveNbr;//收货单号;
scpRcvDetail.CurAmt = detail.Currencyamount;
scpRcvDetail.PurCost = detail.Purchasecost;
scpRcvDetail.StdCost = detail.Purchasestandardcost;
scpRcvDetail.Rate = detail.Exchangerate;
scpRcvDetail.Tax = detail.Taxclass;
scpRcveDetailList.Add(scpRcvDetail);
}
// var _str=JsonHelper.GetJson<List<TB_RECEIVE_DETAIL>>(scpRcveDetailList);
scpdb.TB_RECEIVE_DETAIL_QAD.AddOrUpdate(scpRcveDetailList.ToArray());
@ -926,18 +961,17 @@ namespace CK.SCP.Controller
}
return _ret;
}
public static ResultObject<bool> UpdateARRIVE(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity)
public static ResultObject<bool> UpdateRecive(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
var _reciveList = db.TED_RECEIPT_MSTR.Where(p => p.TaskID == p_entity.TaskID && !string.IsNullOrEmpty(p.ReceiveNbr)).ToList();
var _reciveList = db.TED_RECEIPT_MSTR.Where(p => p.TaskID == p_entity.TaskID).ToList();
var _scpPoDetailList = new List<TB_RECEIVE>();
foreach (var detail in _reciveList)
{
var scpRcv = scpdb.TB_RECEIVE.SingleOrDefault(p => p.RecvBillNum != null && p.RecvBillNum == detail.ReceiveNbr && p.Site == detail.Domain && p.SubSite == detail.Site);
var scpRcvList = new List<TB_RECEIVE>();
bool isRerviceOk = false;
@ -969,9 +1003,128 @@ namespace CK.SCP.Controller
{
istate = (int)FormState.;
}
scpRcv = new TB_RECEIVE
scpRcv = new TB_RECEIVE
{
RecvBillNum = detail.ReceiveNbr,//收货单号
RecvBillNum = detail.ReceiveNbr,//收货单号
State = istate,
Remark = "",
CreateTime = detail.ReceiptDate == null ? DateTime.Now : (DateTime)detail.ReceiptDate,//创建日期
CreateUser = detail.CreateUser,//创建用户
IsDeleted = false,
GUID = detail.TaskID,
BillType = 0
};
scpRcvList.Add(scpRcv);
}
scpRcv.PoBillNum = detail.PurchaseOrder;//采购单
scpRcv.AsnBillNum = detail.ASN;//发货单号
scpRcv.Site = detail.Domain;//地点
scpRcv.VendId = detail.Supplier;//供货商名称
scpRcv.ShipTime = detail.ReceiptDate;//收货日期
scpRcv.SubSite = detail.Site;
scpdb.TB_RECEIVE.AddOrUpdate(scpRcvList.ToArray());
}
var scpRcveDetailList = new List<TB_RECEIVE_DETAIL>();
var _reciveDetailList = db.TED_RECEIPT_DET.Where(p => p.TaskID == p_entity.TaskID).ToList();
foreach (var detail in _reciveDetailList)
{
var poLineNum = Convert.ToInt32(detail.Line);
var scpRcvDetail =
scpdb.TB_RECEIVE_DETAIL.FirstOrDefault(
p => p.RecvBillNum == detail.ReceiveNbr &&
p.PoBillNum == detail.PurchaseOrder &&
p.PoLine == detail.Line &&
p.PartCode == detail.PartCode
&& p.SubSite == detail.Site
);
if (scpRcvDetail == null)
{
scpRcvDetail = new TB_RECEIVE_DETAIL();
scpRcvDetail.RecvBillNum = detail.ReceiveNbr;//收货单号
scpRcvDetail.PoBillNum = detail.PurchaseOrder;//采购单
scpRcvDetail.PoLine = detail.Line;//订单行
scpRcvDetail.PartCode = detail.PartCode;//零件号
scpRcvDetail.Batch = detail.Lot;//批次
scpRcvDetail.VendBatch = detail.SupplierLot;//供应商批号
scpRcvDetail.PoUnit = detail.Um;//采购单位
scpRcvDetail.LocUnit = detail.logisticsUm;//物流单位
//收货总量 //DockCode = ?,//收货口
scpRcvDetail.State = 1;// (int)FormState.关闭,
scpRcvDetail.Remark = detail.Remark;
scpRcvDetail.CreateTime = detail.CreateTime == null ? DateTime.Now : (DateTime)detail.CreateTime;//创建日期
scpRcvDetail.CreateUser = detail.CreateUser;//创建用户
scpRcvDetail.IsDeleted = false;
scpRcvDetail.GUID = detail.TaskID;
scpRcvDetail.BillType = 0;
scpRcvDetail.SubSite = detail.Shipto;
scpRcvDetail.Site = detail.Domain;
scpRcveDetailList.Add(scpRcvDetail);
}
scpRcvDetail.Qty = detail.ReceiveQuantity;
}
// var _str=JsonHelper.GetJson<List<TB_RECEIVE_DETAIL>>(scpRcveDetailList);
scpdb.TB_RECEIVE_DETAIL.AddOrUpdate(scpRcveDetailList.ToArray());
_ret.State = ReturnStatus.Succeed;
_ret.MessageList.Add(string.Format("QAD收货单更新{0}任务编号{1}", _reciveDetailList.Count().ToString(), p_entity.TaskID));
_ret.Result = true;
// var retDetail=UpdateReciveDetail(db, scpdb, p_entity);
}
catch (Exception e)
{
_ret.State = ReturnStatus.Failed;
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "UpdateRecive", e.Message);
_ret.Result = false;
_ret.ErrorList.Add(e);
_ret.MessageList.Add(string.Format("QAD收货单更新失败任务编号{0}", p_entity.TaskID));
throw e;
}
return _ret;
}
public static ResultObject<bool> UpdateARRIVE(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
var _reciveList = db.TED_RECEIPT_MSTR.Where(p => p.TaskID == p_entity.TaskID && !string.IsNullOrEmpty(p.ReceiveNbr)).ToList();
var _scpPoDetailList = new List<TB_ARRIVE>();
foreach (var detail in _reciveList)
{
var scpRcv = scpdb.TB_ARRIVE.SingleOrDefault(p => p.ArrvBillNum != null && p.ArrvBillNum == detail.ReceiveNbr && p.Site == detail.Domain /*&& p.SubSite == detail.Site*/);
var scpRcvList = new List<TB_ARRIVE>();
bool isRerviceOk = false;
if (!string.IsNullOrEmpty(detail.Site) && !string.IsNullOrEmpty(detail.Domain))
{
string _domain = detail.Domain;
string _site = detail.Site;
List<TA_FACTORY_CONFIG> configs = scpdb.TA_FACTORY_CONFIG.Where(p => p.FactoryId == _domain).ToList();
foreach (TA_FACTORY_CONFIG cfg in configs)
{
TA_CONFIG tacfg = scpdb.TA_CONFIG.Where(p => p.UID == cfg.ConfigId).SingleOrDefault();
if (tacfg != null && !string.IsNullOrEmpty(tacfg.ParamName) && tacfg.ParamName == "收货自动审核")
{
if ("允许" == tacfg.ParamValue)
{
isRerviceOk = true;
}
}
}
}
if (scpRcv == null)
{
int istate = 0;
if (isRerviceOk == false)
{
istate = (int)FormState.;
}
else
{
istate = (int)FormState.;
}
scpRcv = new TB_ARRIVE
{
ArrvBillNum = detail.ReceiveNbr,//收货单号
State = istate,
Remark = "",
CreateTime = detail.CreateTime == null ? DateTime.Now : (DateTime)detail.CreateTime,//创建日期
@ -987,32 +1140,32 @@ namespace CK.SCP.Controller
if (!string.IsNullOrEmpty(detail.ASN))
{
var _entity=scpdb.TB_ASN.Where(p => p.AsnBillNum == detail.ASN).FirstOrDefault();
var _entity = scpdb.TB_ASN.Where(p => p.AsnBillNum == detail.ASN).FirstOrDefault();
if (_entity != null)
{
_entity.State = 4;
}
}
scpRcv.Site = detail.Domain;//地点
scpRcv.VendId = detail.Supplier;//供货商名称
scpRcv.VendId = detail.Supplier.Trim();//供货商名称
scpRcv.ShipTime = detail.ReceiptDate;//收货日期
scpRcv.SubSite = detail.Site;
scpdb.TB_RECEIVE.AddOrUpdate(scpRcvList.ToArray());
// scpRcv.SubSite = detail.Site;
scpdb.TB_ARRIVE.AddOrUpdate(scpRcvList.ToArray());
}
var scpRcveDetailList = new List<TB_RECEIVE_DETAIL>();
var scpRcveDetailList = new List<TB_ARRIVE_DETAIL>();
var _reciveDetailList = db.TED_RECEIPT_DET.Where(p => p.TaskID == p_entity.TaskID && !string.IsNullOrEmpty(p.ReceiveNbr)).ToList();
foreach (var detail in _reciveDetailList)
{
var poLineNum = Convert.ToInt32(detail.Line);
var scpRcvDetail =
scpdb.TB_RECEIVE_DETAIL.SingleOrDefault(
p => p.RecvBillNum == detail.ReceiveNbr &&
scpdb.TB_ARRIVE_DETAIL.SingleOrDefault(
p => p.ArrvBillNum == detail.ReceiveNbr &&
p.PoBillNum == detail.PurchaseOrder &&
p.PoLine == detail.Line &&
p.PartCode == detail.PartCode &&
p.Batch == detail.Lot
&&p.SubSite==detail.Site
//&& p.SubSite == detail.Site
);
if (scpRcvDetail == null)
{
@ -1026,9 +1179,9 @@ namespace CK.SCP.Controller
//{
// istate = (int)FormState.开放;
//}
scpRcvDetail = new TB_RECEIVE_DETAIL();
scpRcvDetail.RecvBillNum = detail.ReceiveNbr;//收货单号
scpRcvDetail.PoBillNum = detail.PurchaseOrder;//采购单
scpRcvDetail = new TB_ARRIVE_DETAIL();
scpRcvDetail.ArrvBillNum = detail.ReceiveNbr;//收货单号
scpRcvDetail.PoBillNum = detail.PurchaseOrder.Trim();//采购单
scpRcvDetail.PoLine = detail.Line;//订单行
scpRcvDetail.PartCode = detail.PartCode;//零件号
scpRcvDetail.Batch = detail.Lot;//批次
@ -1043,13 +1196,13 @@ namespace CK.SCP.Controller
scpRcvDetail.IsDeleted = false;
scpRcvDetail.GUID = detail.TaskID;
scpRcvDetail.BillType = 0;
scpRcvDetail.SubSite = detail.Site;
scpRcvDetail.Site = detail.Domain;
// scpRcvDetail.SubSite = detail.Site;
// scpRcvDetail.Site = detail.Domain;
scpRcveDetailList.Add(scpRcvDetail);
}
}
var _str = JsonHelper.GetJson<List<TB_RECEIVE_DETAIL>>(scpRcveDetailList);
scpdb.TB_RECEIVE_DETAIL.AddOrUpdate(scpRcveDetailList.ToArray());
var _str = JsonHelper.GetJson<List<TB_ARRIVE_DETAIL>>(scpRcveDetailList);
scpdb.TB_ARRIVE_DETAIL.AddOrUpdate(scpRcveDetailList.ToArray());
_ret.State = ReturnStatus.Succeed;
_ret.MessageList.Add(string.Format("到货单更新{0}任务编号{1}", _reciveDetailList.Count().ToString(), p_entity.TaskID));
_ret.Result = true;
@ -1187,8 +1340,8 @@ namespace CK.SCP.Controller
_entity.TaskID = p_taskId;
_entity.CommandType = "A";
_entity.DataID = Guid.NewGuid();
_entity.Domain = _invDetail.Site.Trim();
_entity.Site = _invDetail.SubSite.Trim();
_entity.Domain = _invDetail.Site;
_entity.Site = _invDetail.SubSite;
_entity.PartCode = _invDetail.PartCode;
_entity.Tax = _invDetail.Tax.ToString();
_detList.Add(_entity);
@ -1202,7 +1355,7 @@ namespace CK.SCP.Controller
DataCount = p_invoiceList.Count,
TaskID = p_taskId,
TableName = "TED_INVOICE_MSTR",
Site = _vinvoice.SubSite.Trim(),
Site = _vinvoice.SubSite,
Domain = _vinvoice.Site,
CreateTime = _api.CreateTime,
CreateUser = _api.CreateOper,
@ -1232,154 +1385,7 @@ namespace CK.SCP.Controller
return _ret;
}
public static ResultObject<bool> UpdateReturn(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
var _reciveList = db.TED_RETURN_MSTR.Where(p => p.TaskID == p_entity.TaskID && !string.IsNullOrEmpty(p.ReturnNbr)).ToList();
var _scpPoDetailList = new List<TB_RECEIVE>();
foreach (var detail in _reciveList)
{
var scpRcv = scpdb.TB_RECEIVE.SingleOrDefault(p => p.RecvBillNum != null && p.RecvBillNum == detail.ReturnNbr && p.Site == detail.Domain && p.SubSite == detail.Site);
var scpRcvList = new List<TB_RECEIVE>();
bool isRerviceOk = false;
if (!string.IsNullOrEmpty(detail.Site) && !string.IsNullOrEmpty(detail.Domain))
{
string _domain = detail.Domain;
string _site = detail.Site;
List<TA_FACTORY_CONFIG> configs = scpdb.TA_FACTORY_CONFIG.Where(p => p.FactoryId == _domain).ToList();
foreach (TA_FACTORY_CONFIG cfg in configs)
{
TA_CONFIG tacfg = scpdb.TA_CONFIG.Where(p => p.UID == cfg.ConfigId).SingleOrDefault();
if (tacfg != null && !string.IsNullOrEmpty(tacfg.ParamName) && tacfg.ParamName == "收货自动审核")
{
if ("允许" == tacfg.ParamValue)
{
isRerviceOk = true;
}
}
}
}
if (scpRcv == null)
{
int istate = 0;
if (isRerviceOk == false)
{
istate = (int)FormState.;
}
else
{
istate = (int)FormState.;
}
scpRcv = new TB_RECEIVE
{
RecvBillNum = detail.ReturnNbr,//收货单号
State = istate,
Remark = "",
CreateTime = detail.CreateTime == null ? DateTime.Now : (DateTime)detail.CreateTime,//创建日期
CreateUser = detail.CreateUser,//创建用户
IsDeleted = false,
GUID = detail.TaskID,
BillType = 1
};
scpRcvList.Add(scpRcv);
}
scpRcv.PoBillNum = detail.PurchaseOrder;//采购单
scpRcv.AsnBillNum = detail.ASN;//发货单号
if (!string.IsNullOrEmpty(detail.ASN))
{
var _entity=scpdb.TB_ASN.Where(p => p.AsnBillNum == detail.ASN).FirstOrDefault();
if (_entity != null)
{
_entity.State = 4;
}
}
scpRcv.Site = detail.Domain;//地点
scpRcv.VendId = detail.Supplier;//供货商名称
scpRcv.ShipTime = detail.ReturnDate;//收货日期
scpRcv.SubSite = detail.Site;
scpdb.TB_RECEIVE.AddOrUpdate(scpRcvList.ToArray());
}
var scpRcveDetailList = new List<TB_RECEIVE_DETAIL>();
var _reciveDetailList = db.TED_RETURN_DET.Where(p => p.TaskID == p_entity.TaskID ).ToList();
var _recive = db.TED_RETURN_MSTR.Where(p => p.TaskID == p_entity.TaskID && !string.IsNullOrEmpty(p.ReturnNbr)).FirstOrDefault();
if (_recive != null)
{
foreach (var detail in _reciveDetailList)
{
detail.ReturnNbr = _recive.ReturnNbr;
var poLineNum = Convert.ToInt32(detail.Line);
var scpRcvDetail =
scpdb.TB_RECEIVE_DETAIL.SingleOrDefault(
p => p.RecvBillNum == detail.ReturnNbr &&
p.PoBillNum == detail.PurchaseOrder &&
p.PoLine == detail.Line &&
p.PartCode == detail.PartCode &&
p.Batch == detail.Lot
&& p.SubSite == detail.Site
);
if (scpRcvDetail == null)
{
//int istate = 0;
//if (isRerviceOk == false)
//{
// istate = (int)FormState.关闭;
//}
//else
//{
// istate = (int)FormState.开放;
//}
scpRcvDetail = new TB_RECEIVE_DETAIL();
scpRcvDetail.RecvBillNum = detail.ReturnNbr;//收货单号
scpRcvDetail.PoBillNum = detail.PurchaseOrder;//采购单
scpRcvDetail.PoLine = detail.Line;//订单行
scpRcvDetail.PartCode = detail.PartCode;//零件号
scpRcvDetail.Batch = detail.Lot;//批次
scpRcvDetail.VendBatch = detail.SupplierLot;//供应商批号
scpRcvDetail.PoUnit = detail.Um;//采购单位
scpRcvDetail.LocUnit = detail.logisticsUm;//物流单位
scpRcvDetail.Qty = detail.ReturnQuantity;//收货总量 //DockCode = ?,//收货口
scpRcvDetail.State = 1;// (int)FormState.关闭,
scpRcvDetail.Remark = detail.Remark;
scpRcvDetail.CreateTime = detail.CreateTime == null ? DateTime.Now : (DateTime)detail.CreateTime;//创建日期
scpRcvDetail.CreateUser = detail.CreateUser;//创建用户
scpRcvDetail.IsDeleted = false;
scpRcvDetail.GUID = detail.TaskID;
scpRcvDetail.BillType = 1;
scpRcvDetail.SubSite = detail.Site;
scpRcvDetail.Site = detail.Domain;
scpRcveDetailList.Add(scpRcvDetail);
}
}
var _str = JsonHelper.GetJson<List<TB_RECEIVE_DETAIL>>(scpRcveDetailList);
scpdb.TB_RECEIVE_DETAIL.AddOrUpdate(scpRcveDetailList.ToArray());
}
_ret.State = ReturnStatus.Succeed;
_ret.MessageList.Add(string.Format("退货单更新{0}任务编号{1}", _reciveDetailList.Count().ToString(), p_entity.TaskID));
_ret.Result = true;
// var retDetail=UpdateReciveDetail(db, scpdb, p_entity);
}
catch (Exception e)
{
_ret.State = ReturnStatus.Failed;
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "UpdateRecive", e.Message);
_ret.Result = false;
_ret.ErrorList.Add(e);
_ret.MessageList.Add(string.Format("退货单更新失败任务编号{0}", p_entity.TaskID));
throw e;
}
return _ret;
}
public static ResultObject<bool> UpdatePoDetail(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity)
{
ResultObject<bool> _ret = new ResultObject<bool>();
@ -1450,13 +1456,14 @@ namespace CK.SCP.Controller
scpPo = new TB_PO
{
PoBillNum = po.PurchaseOrder,//订单号
//ErpBillNum = po.xxqad_pod_prj,//ERP订单号
ErpBillNum = po.PurchaseOrder,//ERP订单号
VendId = po.Supplier.ToUpper(),//供应商编号
ModType = Int32.TryParse(po.ModeType, out temp) ? temp : (int?)null, //单据类型(1:日程单,2:离散订单)
Contacter = po.Contact,//联系人
Site = po.Domain,//地点
SubSite = po.Site,
State = po.Status,
Remark = po.Remark,//说明
CreateTime = po.CreateTime == null ? DateTime.Now : (DateTime)po.CreateTime,//创建日期
CreateUser = po.CreateUser,//创建用户
IsDeleted = false,

Loading…
Cancel
Save