|
@ -18,6 +18,7 @@ using System.Transactions; |
|
|
using System.Data.Entity.Core; |
|
|
using System.Data.Entity.Core; |
|
|
using System.Security.Cryptography; |
|
|
using System.Security.Cryptography; |
|
|
using System.Data.Entity; |
|
|
using System.Data.Entity; |
|
|
|
|
|
using System.Collections.ObjectModel; |
|
|
//using WebSrvAPITest;
|
|
|
//using WebSrvAPITest;
|
|
|
|
|
|
|
|
|
namespace CK.SCP.Controller |
|
|
namespace CK.SCP.Controller |
|
@ -52,7 +53,7 @@ namespace CK.SCP.Controller |
|
|
ResultObject<List<TEA_SUBSCRIBE>> _ret = new ResultObject<List<TEA_SUBSCRIBE>>(); |
|
|
ResultObject<List<TEA_SUBSCRIBE>> _ret = new ResultObject<List<TEA_SUBSCRIBE>>(); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance()) |
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance()) |
|
|
{ |
|
|
{ |
|
|
IQueryable<TEA_SUBSCRIBE> q = db.TEA_SUBSCRIBE; |
|
|
IQueryable<TEA_SUBSCRIBE> q = db.TEA_SUBSCRIBE; |
|
|
if (!string.IsNullOrEmpty(p_entity.TableName)) |
|
|
if (!string.IsNullOrEmpty(p_entity.TableName)) |
|
@ -112,7 +113,7 @@ namespace CK.SCP.Controller |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance()) |
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance()) |
|
|
{ |
|
|
{ |
|
|
foreach (var itm in p_entitys) |
|
|
foreach (var itm in p_entitys) |
|
|
{ |
|
|
{ |
|
@ -148,7 +149,7 @@ namespace CK.SCP.Controller |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance()) |
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance()) |
|
|
{ |
|
|
{ |
|
|
foreach (var itm in p_entitys) |
|
|
foreach (var itm in p_entitys) |
|
|
{ |
|
|
{ |
|
@ -180,84 +181,32 @@ namespace CK.SCP.Controller |
|
|
/// 获取
|
|
|
/// 获取
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
public static List<TEA_TASK_SUB> Get_TEA_TASK_SUB_List(ExchangeCenterContext db,TEA_TASK_SUB p_entity) |
|
|
//public static List<TEA_TASK_SUB> Get_TEA_TASK_SUB_List(TEA_TASK_SUB p_entity)
|
|
|
{ |
|
|
//{
|
|
|
List<TEA_TASK_SUB> list = new List<TEA_TASK_SUB>(); |
|
|
// List<TEA_TASK_SUB> list = new List<TEA_TASK_SUB>();
|
|
|
|
|
|
|
|
|
string _sql = "select * from TEA_TASK_SUB where TaskState = '{0}' and Subscriber = '{1}'"; |
|
|
// using (var db = EntitiesFactory.CreateExchangeCenterInstance())
|
|
|
_sql = string.Format(_sql, (int)p_entity.TaskState,p_entity.Subscriber); |
|
|
// {
|
|
|
list = db.Database.SqlQuery<TEA_TASK_SUB>(_sql).ToList(); |
|
|
// string _sql = "select * from TEA_TASK_SUB where TaskState = '{0}' and Subscriber = '{1}'";
|
|
|
return list; |
|
|
// _sql = string.Format(_sql, (int)p_entity.TaskState, p_entity.Subscriber);
|
|
|
} |
|
|
// list = db.Database.SqlQuery<TEA_TASK_SUB>(_sql).ToList();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return list;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
public static ResultObject<List<TEA_TASK_SUB>> Get_TEA_TASK_SUB_List(TEA_TASK_SUB p_entity) |
|
|
public static ResultObject<List<TEA_TASK_SUB>> Get_TEA_TASK_SUB_List(TEA_TASK_SUB p_entity) |
|
|
{ |
|
|
{ |
|
|
ResultObject<List<TEA_TASK_SUB>> _ret = new ResultObject<List<TEA_TASK_SUB>>(); |
|
|
ResultObject<List<TEA_TASK_SUB>> _ret = new ResultObject<List<TEA_TASK_SUB>>(); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance()) |
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance()) |
|
|
{ |
|
|
{ |
|
|
IQueryable<TEA_TASK_SUB> q = db.TEA_TASK_SUB; |
|
|
string _sql = "select * from TEA_TASK_SUB with(nolock) where TaskState = '{0}' and Subscriber = '{1}'"; |
|
|
if (!string.IsNullOrEmpty(p_entity.TableName)) |
|
|
_sql = string.Format(_sql, (int)p_entity.TaskState, p_entity.Subscriber); |
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.TableName.Contains(p_entity.TableName)); |
|
|
|
|
|
} |
|
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Creator)) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.Creator.Contains(p_entity.Creator)); |
|
|
|
|
|
} |
|
|
|
|
|
if (p_entity.DataCount != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.DataCount == p_entity.DataCount); |
|
|
|
|
|
} |
|
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Subscriber)) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.Subscriber == p_entity.Subscriber); |
|
|
|
|
|
} |
|
|
|
|
|
if (p_entity.FailedCount != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.FailedCount == p_entity.FailedCount); |
|
|
|
|
|
} |
|
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.FailedInfo)) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.FailedInfo.Contains(p_entity.FailedInfo)); |
|
|
|
|
|
} |
|
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Domain)) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.Domain.Contains(p_entity.Domain)); |
|
|
|
|
|
} |
|
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Site)) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.Site.Contains(p_entity.Site)); |
|
|
|
|
|
} |
|
|
|
|
|
if (p_entity.UID != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.UID == p_entity.UID); |
|
|
|
|
|
} |
|
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.CreateUser)) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser)); |
|
|
|
|
|
} |
|
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Remark)) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.Remark.Contains(p_entity.Remark)); |
|
|
|
|
|
} |
|
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.UpdateUser)) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.UpdateUser.Contains(p_entity.UpdateUser)); |
|
|
|
|
|
} |
|
|
|
|
|
if (p_entity.IsChecked != false) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.IsChecked == p_entity.IsChecked); |
|
|
|
|
|
} |
|
|
|
|
|
//if (!string.IsNullOrEmpty(p_entity.TaskState))
|
|
|
|
|
|
//{
|
|
|
|
|
|
// q = q.Where(p => p.UpdateUser.Contains(p_entity.UpdateUser));
|
|
|
|
|
|
//}
|
|
|
|
|
|
q = q.Where(p => p.TaskState==p_entity.TaskState); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var q = db.Database.SqlQuery<TEA_TASK_SUB>(_sql).OrderBy(p=>p.CreateTime).ToList(); |
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
_ret.Result = q.OrderBy(p => p.CreateTime).ToList(); |
|
|
_ret.Result = q; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
catch (Exception e) |
|
|
catch (Exception e) |
|
@ -293,7 +242,7 @@ namespace CK.SCP.Controller |
|
|
return _ret; |
|
|
return _ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static ResultObject<bool> CREATE_TEA_TASK_SUB(ExchangeCenterContext db, bool p_ismasterslave ,TEA_TASK_SUB p_task) |
|
|
public static ResultObject<bool> CREATE_TEA_TASK_SUB(ExchangeCenterContext db, bool p_ismasterslave, TEA_TASK_SUB p_task) |
|
|
{ |
|
|
{ |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
@ -385,7 +334,7 @@ namespace CK.SCP.Controller |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance()) |
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance()) |
|
|
{ |
|
|
{ |
|
|
foreach (var itm in p_entitys) |
|
|
foreach (var itm in p_entitys) |
|
|
{ |
|
|
{ |
|
@ -407,23 +356,24 @@ namespace CK.SCP.Controller |
|
|
public static void ReadService(Action<ResultObject<bool>> p_action) |
|
|
public static void ReadService(Action<ResultObject<bool>> p_action) |
|
|
{ |
|
|
{ |
|
|
ResultObject<bool> result = new ResultObject<bool>(); |
|
|
ResultObject<bool> result = new ResultObject<bool>(); |
|
|
ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance(); |
|
|
//ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance();
|
|
|
// ResultObject<List<LogModel>> result = new ResultObject<List<LogModel>>();
|
|
|
// ResultObject<List<LogModel>> result = new ResultObject<List<LogModel>>();
|
|
|
//var _result = Get_TEA_TASK_SUB_List(new TEA_TASK_SUB() { TaskState = EnumTaskState.Unread, Subscriber = "SCP"});
|
|
|
var _result = Get_TEA_TASK_SUB_List(new TEA_TASK_SUB() { TaskState = EnumTaskState.Unread, Subscriber = "SCP"}); |
|
|
List<TEA_TASK_SUB> tasklist = Get_TEA_TASK_SUB_List(db,new TEA_TASK_SUB() { TaskState = EnumTaskState.Unread, Subscriber = "SCP" }); |
|
|
//List<TEA_TASK_SUB> tasklist = Get_TEA_TASK_SUB_List(new TEA_TASK_SUB() { TaskState = EnumTaskState.Unread, Subscriber = "SCP" });
|
|
|
if (tasklist.Count()>0) |
|
|
//if (tasklist.Count() > 0)
|
|
|
//if (_result.State == ReturnStatus.Succeed)
|
|
|
if (_result.State == ReturnStatus.Succeed) |
|
|
{ |
|
|
{ |
|
|
foreach (var _task in tasklist) |
|
|
|
|
|
//foreach (var _task in _result.Result)
|
|
|
//foreach (var _task in tasklist)
|
|
|
|
|
|
foreach (var _task in _result.Result) |
|
|
{ |
|
|
{ |
|
|
ScpEntities scpdb = EntitiesFactory.CreateScpInstance(); |
|
|
ScpEntities scpdb = EntitiesFactory.CreateScpInstance(); |
|
|
DataCenterContext dc = EntitiesFactory.CreateDataCenterInstance(); |
|
|
DataCenterContext dc = EntitiesFactory.CreateDataCenterInstance(); |
|
|
AppBoxContext authdb = EntitiesFactory.CreateAppBoxInstance(); |
|
|
AppBoxContext authdb = EntitiesFactory.CreateAppBoxInstance(); |
|
|
//ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance();
|
|
|
ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance(); |
|
|
using (var scope = |
|
|
using (var scope = |
|
|
// 注释内容可去掉mdtc
|
|
|
// 注释内容可去掉dtc
|
|
|
//new TransactionScope(TransactionScopeOption.Suppress, new TransactionOptions()
|
|
|
//new TransactionScope(TransactionScopeOption.Suppress, new TransactionOptions()
|
|
|
new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() |
|
|
new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() |
|
|
{ |
|
|
{ |
|
|
IsolationLevel = System.Transactions.IsolationLevel.Serializable, |
|
|
IsolationLevel = System.Transactions.IsolationLevel.Serializable, |
|
@ -470,15 +420,19 @@ namespace CK.SCP.Controller |
|
|
break; |
|
|
break; |
|
|
case "TES_SUPPLIER": |
|
|
case "TES_SUPPLIER": |
|
|
var _supplierlist = db.TES_SUPPLIER.Where(p => p.TaskID == _task.TaskID).ToList(); |
|
|
var _supplierlist = db.TES_SUPPLIER.Where(p => p.TaskID == _task.TaskID).ToList(); |
|
|
result = UpdateSupplier(_supplierlist, scpdb,authdb, _task); |
|
|
result = UpdateSupplier(_supplierlist, scpdb, authdb, _task); |
|
|
result.Message = _task.TaskID.ToString(); |
|
|
result.Message = _task.TaskID.ToString(); |
|
|
Update_TEA_TASK_SUB(db, _task); |
|
|
Update_TEA_TASK_SUB(db, _task); |
|
|
EntitiesFactory.SaveDb(scpdb); |
|
|
scpdb.BulkSaveChanges(); |
|
|
EntitiesFactory.SaveDb(db); |
|
|
db.BulkSaveChanges(); |
|
|
EntitiesFactory.SaveDb(dc); |
|
|
authdb.BulkSaveChanges(); |
|
|
EntitiesFactory.SaveDb(authdb); |
|
|
dc.BulkSaveChanges(); |
|
|
scope.Complete(); |
|
|
//EntitiesFactory.SaveDb(scpdb);
|
|
|
|
|
|
//EntitiesFactory.SaveDb(db);
|
|
|
|
|
|
//EntitiesFactory.SaveDb(dc);
|
|
|
|
|
|
//EntitiesFactory.SaveDb(authdb);
|
|
|
UpdateSupplierExtend(_supplierlist); |
|
|
UpdateSupplierExtend(_supplierlist); |
|
|
|
|
|
scope.Complete(); |
|
|
break; |
|
|
break; |
|
|
case "TES_PART_MSTR": |
|
|
case "TES_PART_MSTR": |
|
|
result = UpdatePart(db, scpdb, _task); |
|
|
result = UpdatePart(db, scpdb, _task); |
|
@ -498,7 +452,7 @@ namespace CK.SCP.Controller |
|
|
EntitiesFactory.SaveDb(dc); |
|
|
EntitiesFactory.SaveDb(dc); |
|
|
scope.Complete(); |
|
|
scope.Complete(); |
|
|
break; |
|
|
break; |
|
|
// 作废asn单
|
|
|
// 作废asn单
|
|
|
case "TED_SCRAPASN": |
|
|
case "TED_SCRAPASN": |
|
|
result = UpApAsn(db, scpdb, _task); |
|
|
result = UpApAsn(db, scpdb, _task); |
|
|
result.Message = _task.TaskID.ToString(); |
|
|
result.Message = _task.TaskID.ToString(); |
|
@ -517,33 +471,38 @@ namespace CK.SCP.Controller |
|
|
result.State = ReturnStatus.Succeed; |
|
|
result.State = ReturnStatus.Succeed; |
|
|
result.Result = true; |
|
|
result.Result = true; |
|
|
} |
|
|
} |
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
//catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
{ |
|
|
//{
|
|
|
var sb = new StringBuilder(); |
|
|
// var sb = new StringBuilder();
|
|
|
foreach (var error in dbEx.EntityValidationErrors.ToList()) |
|
|
// 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); |
|
|
// sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
|
|
|
}); |
|
|
// });
|
|
|
} |
|
|
// }
|
|
|
scope.Dispose(); |
|
|
// scope.Dispose();
|
|
|
result.State = ReturnStatus.Failed; |
|
|
// result.State = ReturnStatus.Failed;
|
|
|
result.ErrorList.Add(dbEx); |
|
|
// result.ErrorList.Add(dbEx);
|
|
|
} |
|
|
//}
|
|
|
catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
//catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
{ |
|
|
//{
|
|
|
|
|
|
|
|
|
scope.Dispose(); |
|
|
// scope.Dispose();
|
|
|
result.State = ReturnStatus.Failed; |
|
|
// result.State = ReturnStatus.Failed;
|
|
|
result.ErrorList.Add(ex); |
|
|
// result.ErrorList.Add(ex);
|
|
|
} |
|
|
//}
|
|
|
catch (Exception ex) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
{ |
|
|
scope.Dispose(); |
|
|
scope.Dispose(); |
|
|
result.State = ReturnStatus.Failed; |
|
|
result.State = ReturnStatus.Failed; |
|
|
result.ErrorList.Add(ex); |
|
|
result.ErrorList.Add(ex); |
|
|
result.Message = _task.TaskID.ToString(); |
|
|
result.Message = ex.Message; //_task.TaskID.ToString();
|
|
|
|
|
|
if (ex.InnerException != null) |
|
|
|
|
|
{ |
|
|
|
|
|
result.Message = ex.InnerException.Message; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// result.MessageList.Add("任务编号:" + _task.TaskID + "错误信息:" + ex.Message);
|
|
|
// result.MessageList.Add("任务编号:" + _task.TaskID + "错误信息:" + ex.Message);
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -568,11 +527,12 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
ScpEntities scpdb = EntitiesFactory.CreateScpInstance(); |
|
|
ScpEntities scpdb = EntitiesFactory.CreateScpInstance(); |
|
|
ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance(); |
|
|
ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance(); |
|
|
var _list = scpdb.TS_UNI_API.Where(p => p.State == (int)DataState.Enabled&&p.Domain== "HFBMPT").OrderBy(p => p.UID).ToList(); |
|
|
var _list = scpdb.TS_UNI_API.Where(p => p.State == (int)DataState.Enabled && p.Domain == "CDBMPT").OrderBy(p => p.UID).ToList(); |
|
|
var _list1 = scpdb.TS_UNI_API.Where(p => p.State == (int)DataState.Enabled && p.Domain == "HFBMPT" && p.InterfaceType== "Price").OrderBy(p => p.UID).ToList(); |
|
|
var _list1 = scpdb.TS_UNI_API.Where(p => p.State == (int)DataState.Enabled && p.Domain == "CDBMPT" && p.InterfaceType == "Price").OrderBy(p => p.UID).ToList(); |
|
|
|
|
|
|
|
|
var apiii = _list1.Count(); |
|
|
var apiii = _list1.Count(); |
|
|
if (apiii > 0) { |
|
|
if (apiii > 0) |
|
|
|
|
|
{ |
|
|
var ret = UpdateTES_PURCHASE_PRICE(db, scpdb, _list1); |
|
|
var ret = UpdateTES_PURCHASE_PRICE(db, scpdb, _list1); |
|
|
} |
|
|
} |
|
|
var billNumList = _list.Select(p => p.BillNum).Distinct(); |
|
|
var billNumList = _list.Select(p => p.BillNum).Distinct(); |
|
@ -596,7 +556,7 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
var _taskId = Guid.NewGuid(); |
|
|
var _taskId = Guid.NewGuid(); |
|
|
_msglist.Add(new LogModel() { LogMessage = string.Format("发现发票信息{0}条", _invoiceList.Count), LogTime = DateTime.Now.ToString(), TaskId = _taskId.ToString(), TableName = "TED_INVOICE_MSTR" }); |
|
|
_msglist.Add(new LogModel() { LogMessage = string.Format("发现发票信息{0}条", _invoiceList.Count), LogTime = DateTime.Now.ToString(), TaskId = _taskId.ToString(), TableName = "TED_INVOICE_MSTR" }); |
|
|
var ret = UpdateInvoice(db, scpdb,_invoiceList, _taskId); |
|
|
var ret = UpdateInvoice(db, scpdb, _invoiceList, _taskId); |
|
|
if (ret.State == ReturnStatus.Succeed) |
|
|
if (ret.State == ReturnStatus.Succeed) |
|
|
{ |
|
|
{ |
|
|
_msglist.Add(ret.Result); |
|
|
_msglist.Add(ret.Result); |
|
@ -632,10 +592,10 @@ namespace CK.SCP.Controller |
|
|
result.State = ReturnStatus.Succeed; |
|
|
result.State = ReturnStatus.Succeed; |
|
|
result.Result = _msglist; |
|
|
result.Result = _msglist; |
|
|
} |
|
|
} |
|
|
catch(Exception e) |
|
|
catch (Exception e) |
|
|
{ |
|
|
{ |
|
|
_msglist.Add(new LogModel() { LogMessage = e.Message, LogTime = DateTime.Now.ToString(), TaskId =string.Empty, TableName = "ERROR" }); |
|
|
_msglist.Add(new LogModel() { LogMessage = e.Message, LogTime = DateTime.Now.ToString(), TaskId = string.Empty, TableName = "ERROR" }); |
|
|
result.State = ReturnStatus.Failed; |
|
|
result.State = ReturnStatus.Failed; |
|
|
result.Result = _msglist; |
|
|
result.Result = _msglist; |
|
|
scope.Dispose(); |
|
|
scope.Dispose(); |
|
|
|
|
|
|
|
@ -759,7 +719,7 @@ namespace CK.SCP.Controller |
|
|
|
|
|
|
|
|
using (var db = EntitiesFactory.CreateScpInstance()) |
|
|
using (var db = EntitiesFactory.CreateScpInstance()) |
|
|
{ |
|
|
{ |
|
|
_ls = db.TB_ASN.Where(p => p.AsnBillNum == p_asn&&p.State==3).ToList(); |
|
|
_ls = db.TB_ASN.Where(p => p.AsnBillNum == p_asn && p.State == 3).ToList(); |
|
|
} |
|
|
} |
|
|
return _ls; |
|
|
return _ls; |
|
|
} |
|
|
} |
|
@ -784,7 +744,7 @@ namespace CK.SCP.Controller |
|
|
_asn.KanbanBillNum = asn.AskBillNum; |
|
|
_asn.KanbanBillNum = asn.AskBillNum; |
|
|
_asn.PurchaseOrder = asn.PoBillNum.Trim(); |
|
|
_asn.PurchaseOrder = asn.PoBillNum.Trim(); |
|
|
|
|
|
|
|
|
if(_api.Domain=="CQBMPT") |
|
|
if (_api.Domain == "CQBMPT") |
|
|
{ |
|
|
{ |
|
|
_asn.Domain = "CQBMPT"; |
|
|
_asn.Domain = "CQBMPT"; |
|
|
_asn.Site = "CQ01"; |
|
|
_asn.Site = "CQ01"; |
|
@ -858,7 +818,7 @@ namespace CK.SCP.Controller |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
_ret.Result = new LogModel() { LogMessage=string.Format("成功发布发货单信息{0}条", _asnList.Count), LogTime=DateTime.Now.ToString(), TaskId= p_taskID.ToString(), TableName= "TED_ASN_MSTR" }; |
|
|
_ret.Result = new LogModel() { LogMessage = string.Format("成功发布发货单信息{0}条", _asnList.Count), LogTime = DateTime.Now.ToString(), TaskId = p_taskID.ToString(), TableName = "TED_ASN_MSTR" }; |
|
|
} |
|
|
} |
|
|
catch (Exception e) |
|
|
catch (Exception e) |
|
|
{ |
|
|
{ |
|
@ -1056,7 +1016,7 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
var _api = _poList.FirstOrDefault(); |
|
|
var _api = _poList.FirstOrDefault(); |
|
|
TED_PO_MSTR _po = new TED_PO_MSTR(); |
|
|
TED_PO_MSTR _po = new TED_PO_MSTR(); |
|
|
_po.GUID= Guid.NewGuid(); |
|
|
_po.GUID = Guid.NewGuid(); |
|
|
_po.PurchaseOrder = _api.BillNum; |
|
|
_po.PurchaseOrder = _api.BillNum; |
|
|
_po.ModeType = _api.SubBillType.ToString(); |
|
|
_po.ModeType = _api.SubBillType.ToString(); |
|
|
_po.Supplier = _api.VendId; |
|
|
_po.Supplier = _api.VendId; |
|
@ -1065,9 +1025,10 @@ namespace CK.SCP.Controller |
|
|
_po.OrderDate = _api.CreateTime; |
|
|
_po.OrderDate = _api.CreateTime; |
|
|
_po.DueDate = _api.PutTime; |
|
|
_po.DueDate = _api.PutTime; |
|
|
_po.Confirm = true; |
|
|
_po.Confirm = true; |
|
|
_po.Buyer= _api.Buyer; |
|
|
_po.Buyer = _api.Buyer; |
|
|
if (_api.SubBillType == 1) { |
|
|
if (_api.SubBillType == 1) |
|
|
_po.ScheduledOrder =true ; |
|
|
{ |
|
|
|
|
|
_po.ScheduledOrder = true; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
@ -1086,12 +1047,12 @@ namespace CK.SCP.Controller |
|
|
_po.CommandType = "A"; |
|
|
_po.CommandType = "A"; |
|
|
_po.TaskID = p_taskID; |
|
|
_po.TaskID = p_taskID; |
|
|
_po.DataID = Guid.NewGuid(); |
|
|
_po.DataID = Guid.NewGuid(); |
|
|
_po.Pricelist= _api.VendId.ToUpper().Trim() + _api.Site.Trim().Substring(1, 1) + _api.Site.Substring(3, 1).Trim(); |
|
|
_po.Pricelist = _api.VendId.ToUpper().Trim() + _api.Site.Trim().Substring(1, 1) + _api.Site.Substring(3, 1).Trim(); |
|
|
db.TED_PO_MSTR.Add(_po); |
|
|
db.TED_PO_MSTR.Add(_po); |
|
|
foreach (var detail in _poList) |
|
|
foreach (var detail in _poList) |
|
|
{ |
|
|
{ |
|
|
TED_PO_DET _entity = new TED_PO_DET(); |
|
|
TED_PO_DET _entity = new TED_PO_DET(); |
|
|
_entity.GUID= Guid.NewGuid(); |
|
|
_entity.GUID = Guid.NewGuid(); |
|
|
_entity.PurchaseOrder = detail.BillNum; |
|
|
_entity.PurchaseOrder = detail.BillNum; |
|
|
_entity.Line = detail.ErpLineNum; |
|
|
_entity.Line = detail.ErpLineNum; |
|
|
_entity.PartCode = detail.PartCode; |
|
|
_entity.PartCode = detail.PartCode; |
|
@ -1114,7 +1075,7 @@ namespace CK.SCP.Controller |
|
|
_entity.EndDate = detail.ValidDate; |
|
|
_entity.EndDate = detail.ValidDate; |
|
|
_entity.CreateUser = detail.VendBatch; |
|
|
_entity.CreateUser = detail.VendBatch; |
|
|
_entity.CreateTime = DateTime.Now; |
|
|
_entity.CreateTime = DateTime.Now; |
|
|
_entity.DataID= Guid.NewGuid(); |
|
|
_entity.DataID = Guid.NewGuid(); |
|
|
_entity.TaskID = _po.TaskID; |
|
|
_entity.TaskID = _po.TaskID; |
|
|
_entity.CommandType = "A"; |
|
|
_entity.CommandType = "A"; |
|
|
_entity.Domain = _po.Domain; |
|
|
_entity.Domain = _po.Domain; |
|
@ -1367,7 +1328,7 @@ namespace CK.SCP.Controller |
|
|
p.PoLine == detail.Line && |
|
|
p.PoLine == detail.Line && |
|
|
p.PartCode == detail.PartCode |
|
|
p.PartCode == detail.PartCode |
|
|
|
|
|
|
|
|
&& p.SubSite==detail.Site |
|
|
&& p.SubSite == detail.Site |
|
|
); |
|
|
); |
|
|
if (scpRcvDetail == null) |
|
|
if (scpRcvDetail == null) |
|
|
{ |
|
|
{ |
|
@ -1390,7 +1351,7 @@ namespace CK.SCP.Controller |
|
|
scpRcvDetail.VendBatch = detail.SupplierLot;//供应商批号
|
|
|
scpRcvDetail.VendBatch = detail.SupplierLot;//供应商批号
|
|
|
scpRcvDetail.PoUnit = detail.Um;//采购单位
|
|
|
scpRcvDetail.PoUnit = detail.Um;//采购单位
|
|
|
scpRcvDetail.LocUnit = detail.logisticsUm;//物流单位
|
|
|
scpRcvDetail.LocUnit = detail.logisticsUm;//物流单位
|
|
|
//收货总量 //DockCode = ?,//收货口
|
|
|
//收货总量 //DockCode = ?,//收货口
|
|
|
scpRcvDetail.State = 1;// (int)FormState.关闭,
|
|
|
scpRcvDetail.State = 1;// (int)FormState.关闭,
|
|
|
scpRcvDetail.Remark = detail.Remark; |
|
|
scpRcvDetail.Remark = detail.Remark; |
|
|
scpRcvDetail.CreateTime = detail.CreateTime == null ? DateTime.Now : (DateTime)detail.CreateTime;//创建日期
|
|
|
scpRcvDetail.CreateTime = detail.CreateTime == null ? DateTime.Now : (DateTime)detail.CreateTime;//创建日期
|
|
@ -1402,7 +1363,7 @@ namespace CK.SCP.Controller |
|
|
scpRcvDetail.Site = detail.Domain; |
|
|
scpRcvDetail.Site = detail.Domain; |
|
|
scpRcvDetail.Currency = detail.Currency; |
|
|
scpRcvDetail.Currency = detail.Currency; |
|
|
scpRcvDetail.Currencyamount = detail.Currencyamount; |
|
|
scpRcvDetail.Currencyamount = detail.Currencyamount; |
|
|
scpRcvDetail.ExchangeRate = detail.Exchangerate==null?"1":detail.Exchangerate.Value.ToString(); |
|
|
scpRcvDetail.ExchangeRate = detail.Exchangerate == null ? "1" : detail.Exchangerate.Value.ToString(); |
|
|
scpRcvDetail.ExchangeRate1 = detail.Exchangerate2 == null ? "1" : detail.Exchangerate2.Value.ToString(); |
|
|
scpRcvDetail.ExchangeRate1 = detail.Exchangerate2 == null ? "1" : detail.Exchangerate2.Value.ToString(); |
|
|
scpRcvDetail.ExchangeRateType = detail.Exchangeratetype; |
|
|
scpRcvDetail.ExchangeRateType = detail.Exchangeratetype; |
|
|
scpRcvDetail.WorkOrderID = detail.WorkOrderID; |
|
|
scpRcvDetail.WorkOrderID = detail.WorkOrderID; |
|
@ -1422,7 +1383,7 @@ namespace CK.SCP.Controller |
|
|
} |
|
|
} |
|
|
scpRcvDetail.Qty = detail.ReceiveQuantity; |
|
|
scpRcvDetail.Qty = detail.ReceiveQuantity; |
|
|
} |
|
|
} |
|
|
// var _str=JsonHelper.GetJson<List<TB_RECEIVE_DETAIL>>(scpRcveDetailList);
|
|
|
// var _str=JsonHelper.GetJson<List<TB_RECEIVE_DETAIL>>(scpRcveDetailList);
|
|
|
scpdb.TB_RECEIVE_DETAIL.AddOrUpdate(scpRcveDetailList.ToArray()); |
|
|
scpdb.TB_RECEIVE_DETAIL.AddOrUpdate(scpRcveDetailList.ToArray()); |
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
_ret.MessageList.Add(string.Format("QAD收货单更新{0}任务编号{1}", _reciveDetailList.Count().ToString(), p_entity.TaskID)); |
|
|
_ret.MessageList.Add(string.Format("QAD收货单更新{0}任务编号{1}", _reciveDetailList.Count().ToString(), p_entity.TaskID)); |
|
@ -1500,7 +1461,7 @@ namespace CK.SCP.Controller |
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(detail.ASN)) |
|
|
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) |
|
|
if (_entity != null) |
|
|
{ |
|
|
{ |
|
|
_entity.State = 4; |
|
|
_entity.State = 4; |
|
@ -1525,7 +1486,7 @@ namespace CK.SCP.Controller |
|
|
p.PoLine == detail.Line && |
|
|
p.PoLine == detail.Line && |
|
|
p.PartCode == detail.PartCode && |
|
|
p.PartCode == detail.PartCode && |
|
|
p.Batch == detail.Lot |
|
|
p.Batch == detail.Lot |
|
|
&&p.SubSite==detail.Site |
|
|
&& p.SubSite == detail.Site |
|
|
); |
|
|
); |
|
|
if (scpRcvDetail == null) |
|
|
if (scpRcvDetail == null) |
|
|
{ |
|
|
{ |
|
@ -1608,7 +1569,7 @@ namespace CK.SCP.Controller |
|
|
ResultObject<LogModel> _ret = new ResultObject<LogModel>(); |
|
|
ResultObject<LogModel> _ret = new ResultObject<LogModel>(); |
|
|
List<TED_INVOICE_MSTR> _mstList = new List<TED_INVOICE_MSTR>(); |
|
|
List<TED_INVOICE_MSTR> _mstList = new List<TED_INVOICE_MSTR>(); |
|
|
List<TED_INVOICE_DET> _detList = new List<TED_INVOICE_DET>(); |
|
|
List<TED_INVOICE_DET> _detList = new List<TED_INVOICE_DET>(); |
|
|
// List<TED_INVOICE_ADD> _addList = new List<TED_INVOICE_ADD>();
|
|
|
// List<TED_INVOICE_ADD> _addList = new List<TED_INVOICE_ADD>();
|
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
if (p_invoiceList.FirstOrDefault() != null) |
|
|
if (p_invoiceList.FirstOrDefault() != null) |
|
@ -1629,7 +1590,7 @@ namespace CK.SCP.Controller |
|
|
_invMast.InvoiceHoldAmountTC = _vinvoice.Amount.Value; |
|
|
_invMast.InvoiceHoldAmountTC = _vinvoice.Amount.Value; |
|
|
_invMast.InvoiceVoucher = 0; |
|
|
_invMast.InvoiceVoucher = 0; |
|
|
_invMast.InvoiceRegistrationNbr = 1000; |
|
|
_invMast.InvoiceRegistrationNbr = 1000; |
|
|
_invMast.PostingDate = _vinvoice.PostingDate==null?DateTime.Now:_vinvoice.PostingDate.Value; |
|
|
_invMast.PostingDate = _vinvoice.PostingDate == null ? DateTime.Now : _vinvoice.PostingDate.Value; |
|
|
_invMast.Currency = "CNY"; |
|
|
_invMast.Currency = "CNY"; |
|
|
_invMast.InvoiceDate = _vinvoice.UpdateTime == null ? DateTime.Now : _vinvoice.UpdateTime.Value; |
|
|
_invMast.InvoiceDate = _vinvoice.UpdateTime == null ? DateTime.Now : _vinvoice.UpdateTime.Value; |
|
|
_invMast.GUID = Guid.NewGuid(); |
|
|
_invMast.GUID = Guid.NewGuid(); |
|
@ -1638,7 +1599,7 @@ namespace CK.SCP.Controller |
|
|
_invMast.PaymentCondCode = "90"; |
|
|
_invMast.PaymentCondCode = "90"; |
|
|
_invMast.InvoiceDueDate = _invMast.InvoiceDate.AddDays(int.Parse(_invMast.PaymentCondCode)); |
|
|
_invMast.InvoiceDueDate = _invMast.InvoiceDate.AddDays(int.Parse(_invMast.PaymentCondCode)); |
|
|
_invMast.InvoiceIsStatusFinal = true; |
|
|
_invMast.InvoiceIsStatusFinal = true; |
|
|
_invMast.InvoicePostingYear = _vinvoice.PostingDate==null?DateTime.Now.Year: _vinvoice.PostingDate.Value.Year; |
|
|
_invMast.InvoicePostingYear = _vinvoice.PostingDate == null ? DateTime.Now.Year : _vinvoice.PostingDate.Value.Year; |
|
|
_invMast.APMatchingIsStatusFinal = true; |
|
|
_invMast.APMatchingIsStatusFinal = true; |
|
|
_invMast.InvoiceRemark = _vinvoice.InvcBillNum;//发票编号
|
|
|
_invMast.InvoiceRemark = _vinvoice.InvcBillNum;//发票编号
|
|
|
_invMast.CreateWithAmountIsTax = true; |
|
|
_invMast.CreateWithAmountIsTax = true; |
|
@ -1661,14 +1622,14 @@ namespace CK.SCP.Controller |
|
|
_mstList.Add(_invMast); |
|
|
_mstList.Add(_invMast); |
|
|
#endregion
|
|
|
#endregion
|
|
|
#region 发票差异
|
|
|
#region 发票差异
|
|
|
if ((_vinvoice.ContractPrice != null && _vinvoice.ContractPrice.Value != 0) ) |
|
|
if ((_vinvoice.ContractPrice != null && _vinvoice.ContractPrice.Value != 0)) |
|
|
{ |
|
|
{ |
|
|
_invMast.InvoiceHoldAmountTC = _vinvoice.Amount.Value + _vinvoice.ContractPrice.Value; |
|
|
_invMast.InvoiceHoldAmountTC = _vinvoice.Amount.Value + _vinvoice.ContractPrice.Value; |
|
|
|
|
|
|
|
|
//_add.VatDebitCC = _vinvoice.ContractPrice.Value;//折扣
|
|
|
//_add.VatDebitCC = _vinvoice.ContractPrice.Value;//折扣
|
|
|
//_add.VatDebitLC = _vinvoice.BlancePrice.Value;//税额调整
|
|
|
//_add.VatDebitLC = _vinvoice.BlancePrice.Value;//税额调整
|
|
|
//_add.VatDebitTC = _vinvoice.ContractPrice.Value;
|
|
|
//_add.VatDebitTC = _vinvoice.ContractPrice.Value;
|
|
|
// _addList.Add(_add);
|
|
|
// _addList.Add(_add);
|
|
|
} |
|
|
} |
|
|
if ((_vinvoice.BlancePrice != null && _vinvoice.BlancePrice.Value != 0)) |
|
|
if ((_vinvoice.BlancePrice != null && _vinvoice.BlancePrice.Value != 0)) |
|
|
{ |
|
|
{ |
|
@ -1682,12 +1643,12 @@ namespace CK.SCP.Controller |
|
|
var _invDetail = JsonConvert.DeserializeObject<V_TB_INVOICE_DETAIL>(detail.Extend2); |
|
|
var _invDetail = JsonConvert.DeserializeObject<V_TB_INVOICE_DETAIL>(detail.Extend2); |
|
|
_entity.CommandType = "A"; |
|
|
_entity.CommandType = "A"; |
|
|
_entity.GUID = _invDetail.GUID; |
|
|
_entity.GUID = _invDetail.GUID; |
|
|
_entity.Status =_invMast.Status; |
|
|
_entity.Status = _invMast.Status; |
|
|
_entity.PurchaseOrder = _invDetail.PoBillNum; |
|
|
_entity.PurchaseOrder = _invDetail.PoBillNum; |
|
|
_entity.Line = _invDetail.PoLineNum; |
|
|
_entity.Line = _invDetail.PoLineNum; |
|
|
_entity.ReceiveNbr = _invDetail.RecvBillNum; |
|
|
_entity.ReceiveNbr = _invDetail.RecvBillNum; |
|
|
_entity.MatchQuantity = _invDetail.Qty; |
|
|
_entity.MatchQuantity = _invDetail.Qty; |
|
|
_entity.MatchPrice = _invDetail.Price + ((_invDetail.BlancePrice==null)?0: _invDetail.BlancePrice.Value); |
|
|
_entity.MatchPrice = _invDetail.Price + ((_invDetail.BlancePrice == null) ? 0 : _invDetail.BlancePrice.Value); |
|
|
_entity.IsPvodFinished = true; |
|
|
_entity.IsPvodFinished = true; |
|
|
_entity.UsageDate = DateTime.Now; |
|
|
_entity.UsageDate = DateTime.Now; |
|
|
_entity.IsRecalculateTaxes = true; |
|
|
_entity.IsRecalculateTaxes = true; |
|
@ -1724,11 +1685,11 @@ namespace CK.SCP.Controller |
|
|
db.TED_INVOICE_DET.AddOrUpdate(_detList.ToArray()); |
|
|
db.TED_INVOICE_DET.AddOrUpdate(_detList.ToArray()); |
|
|
//db.TED_INVOICE_ADD.AddOrUpdate(_addList.ToArray());
|
|
|
//db.TED_INVOICE_ADD.AddOrUpdate(_addList.ToArray());
|
|
|
|
|
|
|
|
|
var str=JsonHelper.GetJson(_mstList.ToArray()); |
|
|
var str = JsonHelper.GetJson(_mstList.ToArray()); |
|
|
var str1=JsonHelper.GetJson(_detList.ToArray()); |
|
|
var str1 = JsonHelper.GetJson(_detList.ToArray()); |
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
_ret.Result = new LogModel() { LogMessage = string.Format("成功发布发票信息{0}条",_detList.Count), LogTime = DateTime.Now.ToString(), TaskId = p_taskId.ToString(), TableName = "TED_INVOICE_MSTR" }; |
|
|
_ret.Result = new LogModel() { LogMessage = string.Format("成功发布发票信息{0}条", _detList.Count), LogTime = DateTime.Now.ToString(), TaskId = p_taskId.ToString(), TableName = "TED_INVOICE_MSTR" }; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
catch (Exception e) |
|
|
catch (Exception e) |
|
@ -1809,7 +1770,7 @@ namespace CK.SCP.Controller |
|
|
|
|
|
|
|
|
public static ResultObject<bool> UpdateReturn(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity) |
|
|
public static ResultObject<bool> UpdateReturn(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity) |
|
|
{ |
|
|
{ |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
var _reciveList = db.TED_RETURN_MSTR.Where(p => p.TaskID == p_entity.TaskID && !string.IsNullOrEmpty(p.ReturnNbr)).ToList(); |
|
|
var _reciveList = db.TED_RETURN_MSTR.Where(p => p.TaskID == p_entity.TaskID && !string.IsNullOrEmpty(p.ReturnNbr)).ToList(); |
|
@ -1865,7 +1826,7 @@ namespace CK.SCP.Controller |
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(detail.ASN)) |
|
|
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) |
|
|
if (_entity != null) |
|
|
{ |
|
|
{ |
|
|
_entity.State = 4; |
|
|
_entity.State = 4; |
|
@ -1879,7 +1840,7 @@ namespace CK.SCP.Controller |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var scpRcveDetailList = new List<TB_ARRIVE_DETAIL>(); |
|
|
var scpRcveDetailList = new List<TB_ARRIVE_DETAIL>(); |
|
|
var _reciveDetailList = db.TED_RETURN_DET.Where(p => p.TaskID == p_entity.TaskID ).ToList(); |
|
|
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(); |
|
|
var _recive = db.TED_RETURN_MSTR.Where(p => p.TaskID == p_entity.TaskID && !string.IsNullOrEmpty(p.ReturnNbr)).FirstOrDefault(); |
|
|
if (_recive != null) |
|
|
if (_recive != null) |
|
|
{ |
|
|
{ |
|
@ -1981,7 +1942,7 @@ namespace CK.SCP.Controller |
|
|
PoDetail.PlanQty = detail.Qty;//订货数量-采购量
|
|
|
PoDetail.PlanQty = detail.Qty;//订货数量-采购量
|
|
|
PoDetail.PoUnit = detail.PoUm;//采购单位
|
|
|
PoDetail.PoUnit = detail.PoUm;//采购单位
|
|
|
PoDetail.LocUnit = detail.LocUm;//存储单位
|
|
|
PoDetail.LocUnit = detail.LocUm;//存储单位
|
|
|
PoDetail.Price = ScpCache.Config.项目名称 == ProjectName.重庆北汽模塑.ToString()? 0 : detail.Price; |
|
|
PoDetail.Price = ScpCache.Config.项目名称 == ProjectName.重庆北汽模塑.ToString() ? 0 : detail.Price; |
|
|
PoDetail.Currency = detail.Currency;//币种
|
|
|
PoDetail.Currency = detail.Currency;//币种
|
|
|
PoDetail.PackQty = detail.PackQty;//标包数量
|
|
|
PoDetail.PackQty = detail.PackQty;//标包数量
|
|
|
PoDetail.UnConv = detail.Conv;//转换率
|
|
|
PoDetail.UnConv = detail.Conv;//转换率
|
|
@ -2032,7 +1993,7 @@ namespace CK.SCP.Controller |
|
|
CreateTime = po.CreateTime == null ? DateTime.Now : (DateTime)po.CreateTime,//创建日期
|
|
|
CreateTime = po.CreateTime == null ? DateTime.Now : (DateTime)po.CreateTime,//创建日期
|
|
|
CreateUser = po.CreateUser,//创建用户
|
|
|
CreateUser = po.CreateUser,//创建用户
|
|
|
IsDeleted = false, |
|
|
IsDeleted = false, |
|
|
GUID =po.TaskID, |
|
|
GUID = po.TaskID, |
|
|
BeginTime = po.OrderDate == null ? DateTime.Now : po.OrderDate,//创建日期
|
|
|
BeginTime = po.OrderDate == null ? DateTime.Now : po.OrderDate,//创建日期
|
|
|
EndTime = po.DueDate//收货结束时间
|
|
|
EndTime = po.DueDate//收货结束时间
|
|
|
}; |
|
|
}; |
|
@ -2079,6 +2040,7 @@ namespace CK.SCP.Controller |
|
|
_dic.Add("CQBMPT", "CQ01"); |
|
|
_dic.Add("CQBMPT", "CQ01"); |
|
|
_dic.Add("ZZBMPT", "ZZ01"); |
|
|
_dic.Add("ZZBMPT", "ZZ01"); |
|
|
_dic.Add("HFBMPT", "HF01"); |
|
|
_dic.Add("HFBMPT", "HF01"); |
|
|
|
|
|
_dic.Add("CDBMPT", "CD01"); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
@ -2139,7 +2101,7 @@ namespace CK.SCP.Controller |
|
|
_venderlist.Add(_supplier); |
|
|
_venderlist.Add(_supplier); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
scpdb.TA_VENDER.AddOrUpdate(_venderlist.ToArray()); |
|
|
scpdb.TA_VENDER.AddOrUpdate(q => q.UID, _venderlist.ToArray()); |
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
_ret.MessageList.Add(string.Format("更新表{0}任务ID{1}成功!", "TES_SUPPLIER", p_entity.TaskID)); |
|
|
_ret.MessageList.Add(string.Format("更新表{0}任务ID{1}成功!", "TES_SUPPLIER", p_entity.TaskID)); |
|
|
} |
|
|
} |
|
@ -2157,7 +2119,7 @@ namespace CK.SCP.Controller |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void UpdateSupplierExtend(List<TES_SUPPLIER> p_vendList ) |
|
|
private static void UpdateSupplierExtend(List<TES_SUPPLIER> p_vendList) |
|
|
{ |
|
|
{ |
|
|
var _ls = new List<VenderUsers>(); |
|
|
var _ls = new List<VenderUsers>(); |
|
|
using (var db = EntitiesFactory.CreateAppBoxInstance()) |
|
|
using (var db = EntitiesFactory.CreateAppBoxInstance()) |
|
@ -2166,26 +2128,43 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
var vendname = string.Format("{0}@{1}", qadData.SupplierCode.ToUpper(), qadData.Domain.ToUpper()); |
|
|
//var vendname = string.Format("{0}@{1}", qadData.SupplierCode.ToUpper(), qadData.Domain.ToUpper());
|
|
|
var _first = db.Users.Where(p => p.Name == vendname).FirstOrDefault(); |
|
|
string vendtoup = qadData.SupplierCode.ToUpper(); |
|
|
|
|
|
var _first = db.Users.Where(p => p.Name.Contains(vendtoup)).ToList(); |
|
|
if (_first != null) |
|
|
if (_first != null) |
|
|
{ |
|
|
{ |
|
|
var _ef = db.VenderUsers.FirstOrDefault(p => p.VenderId == qadData.SupplierCode && p.UserId == _first.ID) ?? new VenderUsers() |
|
|
foreach (var item in _first) |
|
|
{ |
|
|
{ |
|
|
UserId = _first.ID, |
|
|
var count = db.VenderUsers.Count(p => p.VenderId == qadData.SupplierCode && p.UserId == item.ID); |
|
|
VenderId = qadData.SupplierCode.ToUpper() |
|
|
if (count == 0) |
|
|
}; |
|
|
{ |
|
|
_ls.Add(_ef); |
|
|
var _ef = new VenderUsers() |
|
|
|
|
|
{ |
|
|
|
|
|
UserId = item.ID, |
|
|
|
|
|
VenderId = qadData.SupplierCode.ToUpper() |
|
|
|
|
|
}; |
|
|
|
|
|
_ls.Add(_ef); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
var _ef = db.VenderUsers.FirstOrDefault(p => p.VenderId == qadData.SupplierCode && p.UserId == item.ID); |
|
|
|
|
|
_ef.UserId = item.ID; |
|
|
|
|
|
_ef.VenderId = qadData.SupplierCode.ToUpper(); |
|
|
|
|
|
_ls.Add(_ef); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
catch |
|
|
catch(Exception EX) |
|
|
{ |
|
|
{ |
|
|
|
|
|
throw EX; |
|
|
} |
|
|
} |
|
|
db.VenderUsers.AddOrUpdate(_ls.ToArray()); |
|
|
db.VenderUsers.AddOrUpdate(q=>q.Id,_ls.ToArray()); |
|
|
|
|
|
db.BulkSaveChanges(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 更新供应商零件
|
|
|
/// 更新供应商零件
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
@ -2204,7 +2183,7 @@ namespace CK.SCP.Controller |
|
|
decimal _packqty = 1; |
|
|
decimal _packqty = 1; |
|
|
foreach (var supplierpart in _supplierpartlist) |
|
|
foreach (var supplierpart in _supplierpartlist) |
|
|
{ |
|
|
{ |
|
|
var _supplierpart = scpdb.TA_VEND_PART.SingleOrDefault(p => p.VendId == supplierpart.Supplier && p.PartCode == supplierpart.PartCode && p.VendPartCode == supplierpart.SupplierPart && p.Site == supplierpart.Domain ); |
|
|
var _supplierpart = scpdb.TA_VEND_PART.SingleOrDefault(p => p.VendId == supplierpart.Supplier && p.PartCode == supplierpart.PartCode && p.VendPartCode == supplierpart.SupplierPart && p.Site == supplierpart.Domain); |
|
|
if (_supplierpart == null) |
|
|
if (_supplierpart == null) |
|
|
{ |
|
|
{ |
|
|
var _pack = dc.TS_PACK.SingleOrDefault(p => p.PartCode == supplierpart.PartCode && p.Site == supplierpart.Domain && p.Site == supplierpart.Site); |
|
|
var _pack = dc.TS_PACK.SingleOrDefault(p => p.PartCode == supplierpart.PartCode && p.Site == supplierpart.Domain && p.Site == supplierpart.Site); |
|
@ -2262,13 +2241,13 @@ namespace CK.SCP.Controller |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
var _partmstrlist = db.TES_PART_MSTR.Where(p => p.TaskID == p_entity.TaskID&&p.CommandType!="D").ToList(); |
|
|
var _partmstrlist = db.TES_PART_MSTR.Where(p => p.TaskID == p_entity.TaskID && p.CommandType != "D").ToList(); |
|
|
var _partmstrlistD = db.TES_PART_MSTR.Where(p => p.TaskID == p_entity.TaskID&&p.CommandType=="D").ToList(); |
|
|
var _partmstrlistD = db.TES_PART_MSTR.Where(p => p.TaskID == p_entity.TaskID && p.CommandType == "D").ToList(); |
|
|
var _partlist = new List<TA_PART>(); |
|
|
var _partlist = new List<TA_PART>(); |
|
|
var _partlistD = new List<TA_PART>(); |
|
|
var _partlistD = new List<TA_PART>(); |
|
|
foreach (var part in _partmstrlist) |
|
|
foreach (var part in _partmstrlist) |
|
|
{ |
|
|
{ |
|
|
var _part = scpdb.TA_PART.SingleOrDefault(p => p.PartCode == part.PartCode && p.Site == part.Domain ); |
|
|
var _part = scpdb.TA_PART.SingleOrDefault(p => p.PartCode == part.PartCode && p.Site == part.Domain); |
|
|
|
|
|
|
|
|
if (_part == null) |
|
|
if (_part == null) |
|
|
{ |
|
|
{ |
|
@ -2279,14 +2258,14 @@ namespace CK.SCP.Controller |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
_part.PartDesc1 = part.Desc1; |
|
|
_part.PartDesc1 = part.Desc1; |
|
|
_part.PartDesc2 = string.IsNullOrEmpty(part.Desc2)?string.Empty: part.Desc2; |
|
|
_part.PartDesc2 = string.IsNullOrEmpty(part.Desc2) ? string.Empty : part.Desc2; |
|
|
if (!string.IsNullOrEmpty(part.Group)) |
|
|
if (!string.IsNullOrEmpty(part.Group)) |
|
|
{ |
|
|
{ |
|
|
_part.ProjectId = part.Group; |
|
|
_part.ProjectId = part.Group; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
_part.ProjectId ="public"; |
|
|
_part.ProjectId = "public"; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
_part.Unit = !string.IsNullOrEmpty(part.Um) ? part.Um.ToUpper() : "EA"; |
|
|
_part.Unit = !string.IsNullOrEmpty(part.Um) ? part.Um.ToUpper() : "EA"; |
|
@ -2308,10 +2287,10 @@ namespace CK.SCP.Controller |
|
|
_part.PartGroup = "其他"; |
|
|
_part.PartGroup = "其他"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
_part.Qlevel = string.IsNullOrEmpty(part.Qgrade)?string.Empty: part.Qgrade; |
|
|
_part.Qlevel = string.IsNullOrEmpty(part.Qgrade) ? string.Empty : part.Qgrade; |
|
|
_part.State = part.Status; |
|
|
_part.State = part.Status; |
|
|
_part.Site = part.Domain; |
|
|
_part.Site = part.Domain; |
|
|
// _part.SubSite = part.Site;
|
|
|
// _part.SubSite = part.Site;
|
|
|
_part.Remark = part.TaskID.ToString(); |
|
|
_part.Remark = part.TaskID.ToString(); |
|
|
_partlist.Add(_part); |
|
|
_partlist.Add(_part); |
|
|
} |
|
|
} |
|
@ -2327,7 +2306,7 @@ namespace CK.SCP.Controller |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var str= JsonHelper.GetJson<List<TA_PART>>(_partlist); |
|
|
var str = JsonHelper.GetJson<List<TA_PART>>(_partlist); |
|
|
|
|
|
|
|
|
scpdb.TA_PART.AddOrUpdate(_partlist.ToArray()); |
|
|
scpdb.TA_PART.AddOrUpdate(_partlist.ToArray()); |
|
|
if (_partlistD.Count() > 0) |
|
|
if (_partlistD.Count() > 0) |
|
@ -2357,7 +2336,7 @@ namespace CK.SCP.Controller |
|
|
var _factorylist = db.TES_SITE.Where(p => p.TaskID == p_entity.TaskID).ToList(); |
|
|
var _factorylist = db.TES_SITE.Where(p => p.TaskID == p_entity.TaskID).ToList(); |
|
|
var _appboxfactorylist = new List<TA_FACTORY>(); |
|
|
var _appboxfactorylist = new List<TA_FACTORY>(); |
|
|
var _scpfactorylist = new List<TB_FACTORY>(); |
|
|
var _scpfactorylist = new List<TB_FACTORY>(); |
|
|
foreach(var factory in _factorylist) |
|
|
foreach (var factory in _factorylist) |
|
|
{ |
|
|
{ |
|
|
var item1 = appscpdb.TA_FACTORY.SingleOrDefault(p => p.ErpDomain == factory.Domain && p.ErpSite == factory.Site); |
|
|
var item1 = appscpdb.TA_FACTORY.SingleOrDefault(p => p.ErpDomain == factory.Domain && p.ErpSite == factory.Site); |
|
|
if (item1 == null) |
|
|
if (item1 == null) |
|
@ -2369,7 +2348,7 @@ namespace CK.SCP.Controller |
|
|
GUID = Guid.NewGuid(), |
|
|
GUID = Guid.NewGuid(), |
|
|
State = 1, |
|
|
State = 1, |
|
|
CreateTime = DateTime.Now, |
|
|
CreateTime = DateTime.Now, |
|
|
CreateUser= factory.CreateUser |
|
|
CreateUser = factory.CreateUser |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
item1.FactoryId = factory.Domain; |
|
|
item1.FactoryId = factory.Domain; |
|
@ -2427,11 +2406,11 @@ namespace CK.SCP.Controller |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
{ |
|
|
{ |
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
_ret.Result = true; |
|
|
_ret.Result = true; |
|
@ -2464,18 +2443,18 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
_item.Batch = "No"; |
|
|
_item.Batch = "No"; |
|
|
} |
|
|
} |
|
|
_item.Qty = _price.Amt+_price.SharingPrice; |
|
|
_item.Qty = _price.Amt + _price.SharingPrice; |
|
|
_item.Price = _price.Amt; |
|
|
_item.Price = _price.Amt; |
|
|
_item.State = 1; |
|
|
_item.State = 1; |
|
|
_item.ValidDate = DateTime.Now; |
|
|
_item.ValidDate = DateTime.Now; |
|
|
_item.ErpLineNum = 1; |
|
|
_item.ErpLineNum = 1; |
|
|
_item.PartCode =_partCode;//零件编号
|
|
|
_item.PartCode = _partCode;//零件编号
|
|
|
_item.Domain = _domain;//域
|
|
|
_item.Domain = _domain;//域
|
|
|
_item.Site = _site;//地点
|
|
|
_item.Site = _site;//地点
|
|
|
_item.Extend1 = _price.Remarks; |
|
|
_item.Extend1 = _price.Remarks; |
|
|
_item.CreateTime = Convert.ToDateTime(_price.StartTime);//开始时间
|
|
|
_item.CreateTime = Convert.ToDateTime(_price.StartTime);//开始时间
|
|
|
_item.PutTime = Convert.ToDateTime(_price.EndTime);//结束时间
|
|
|
_item.PutTime = Convert.ToDateTime(_price.EndTime);//结束时间
|
|
|
_item.CreateOper = _price.Creator; |
|
|
_item.CreateOper = _price.Creator; |
|
|
_item.Currency = _price.Curr;//货币
|
|
|
_item.Currency = _price.Curr;//货币
|
|
|
var _first = scpdb.TA_PART.Where(itm => itm.PartCode == _partCode).FirstOrDefault(); |
|
|
var _first = scpdb.TA_PART.Where(itm => itm.PartCode == _partCode).FirstOrDefault(); |
|
|
if (_first != null) |
|
|
if (_first != null) |
|
@ -2487,14 +2466,14 @@ namespace CK.SCP.Controller |
|
|
|
|
|
|
|
|
_item.PoUnit = _price.Unit;//单位
|
|
|
_item.PoUnit = _price.Unit;//单位
|
|
|
} |
|
|
} |
|
|
if(_domain == "BJBMPT") |
|
|
if (_domain == "BJBMPT") |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
var po = scpdb.V_TB_PO_DETAIL.Count(p => p.PartCode == _partCode&&p.Site== "BJBMPT"&&p.VendId== _vend.Trim()); |
|
|
var po = scpdb.V_TB_PO_DETAIL.Count(p => p.PartCode == _partCode && p.Site == "BJBMPT" && p.VendId == _vend.Trim()); |
|
|
if (po > 0) |
|
|
if (po > 0) |
|
|
{ |
|
|
{ |
|
|
var _list = scpdb.V_TB_PO_DETAIL.Where(p => p.PartCode == _partCode && p.Site == "BJBMPT" && p.VendId == _vend.Trim()).ToList(); |
|
|
var _list = scpdb.V_TB_PO_DETAIL.Where(p => p.PartCode == _partCode && p.Site == "BJBMPT" && p.VendId == _vend.Trim()).ToList(); |
|
|
foreach(var b in _list) |
|
|
foreach (var b in _list) |
|
|
{ |
|
|
{ |
|
|
var PP = scpdb.TB_PO_DETAIL.FirstOrDefault(p => p.PartCode == b.PartCode && p.Site == "BJBMPT" && p.PoBillNum == b.PoBillNum); |
|
|
var PP = scpdb.TB_PO_DETAIL.FirstOrDefault(p => p.PartCode == b.PartCode && p.Site == "BJBMPT" && p.PoBillNum == b.PoBillNum); |
|
|
PP.Price = _item.Price; |
|
|
PP.Price = _item.Price; |
|
@ -2527,7 +2506,7 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
_ret.Result = false; |
|
|
_ret.Result = false; |
|
|
_ret.Message =e.InnerException.Message; |
|
|
_ret.Message = e.InnerException.Message; |
|
|
} |
|
|
} |
|
|
return _ret; |
|
|
return _ret; |
|
|
} |
|
|
} |
|
@ -2557,7 +2536,7 @@ namespace CK.SCP.Controller |
|
|
_item.BillNum = (_vend + _site.Substring(1, 1) + _site.Substring(3, 1)).Trim(); |
|
|
_item.BillNum = (_vend + _site.Substring(1, 1) + _site.Substring(3, 1)).Trim(); |
|
|
_item.InterfaceType = "Price"; |
|
|
_item.InterfaceType = "Price"; |
|
|
|
|
|
|
|
|
_item.Batch = "No"; |
|
|
_item.Batch = "No"; |
|
|
|
|
|
|
|
|
_item.Qty = _price.Amt + _price.SharingPrice; |
|
|
_item.Qty = _price.Amt + _price.SharingPrice; |
|
|
_item.Price = _price.Amt; |
|
|
_item.Price = _price.Amt; |
|
@ -2624,7 +2603,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) => |
|
|
{ |
|
|
{ |
|
@ -2640,7 +2619,7 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
_po = new TB_PO { GUID = Guid.NewGuid(), PoBillNum = _entity.订单编号.ToUpper(), State = (int)PoState.Open, Site = site, SubSite = subsite, VendId = _entity.供应商编号.Trim().ToUpper() }; |
|
|
_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.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.联系人;
|
|
@ -2655,7 +2634,7 @@ namespace CK.SCP.Controller |
|
|
_po.EndTime = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.要求到货日期); |
|
|
_po.EndTime = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.要求到货日期); |
|
|
_po.Pricelist = _entity.供应商编号.Trim().ToUpper() + subsite.Substring(1, 1) + subsite.Substring(3, 1); |
|
|
_po.Pricelist = _entity.供应商编号.Trim().ToUpper() + subsite.Substring(1, 1) + subsite.Substring(3, 1); |
|
|
_po.Taxclass = _entity.税率; |
|
|
_po.Taxclass = _entity.税率; |
|
|
_po.SubSite= subsite.Trim().ToUpper(); |
|
|
_po.SubSite = subsite.Trim().ToUpper(); |
|
|
scpdb.TB_PO.AddOrUpdate(_po); |
|
|
scpdb.TB_PO.AddOrUpdate(_po); |
|
|
|
|
|
|
|
|
list.ForEach((itm) => |
|
|
list.ForEach((itm) => |
|
@ -2665,7 +2644,7 @@ namespace CK.SCP.Controller |
|
|
_PO_Detail.PoBillNum = _po.PoBillNum; |
|
|
_PO_Detail.PoBillNum = _po.PoBillNum; |
|
|
_PO_Detail.PartCode = itm.零件号.Trim(); |
|
|
_PO_Detail.PartCode = itm.零件号.Trim(); |
|
|
var part = scpdb.TA_PART.FirstOrDefault(t => t.PartCode == itm.零件号.Trim() && t.Site == _po.Site); |
|
|
var part = scpdb.TA_PART.FirstOrDefault(t => t.PartCode == itm.零件号.Trim() && t.Site == _po.Site); |
|
|
_PO_Detail.PoLine =int.Parse(itm.行号); |
|
|
_PO_Detail.PoLine = int.Parse(itm.行号); |
|
|
_PO_Detail.PoUnit = part.Unit; |
|
|
_PO_Detail.PoUnit = part.Unit; |
|
|
_PO_Detail.CreateTime = DateTime.Now; |
|
|
_PO_Detail.CreateTime = DateTime.Now; |
|
|
_PO_Detail.CreateUser = p_creator; |
|
|
_PO_Detail.CreateUser = p_creator; |
|
@ -2675,7 +2654,7 @@ namespace CK.SCP.Controller |
|
|
_PO_Detail.IsDeleted = false; |
|
|
_PO_Detail.IsDeleted = false; |
|
|
_PO_Detail.LocUnit = part.Unit; |
|
|
_PO_Detail.LocUnit = part.Unit; |
|
|
_PO_Detail.UnConv = 1; |
|
|
_PO_Detail.UnConv = 1; |
|
|
_PO_Detail.State= (int)PoState.Open; |
|
|
_PO_Detail.State = (int)PoState.Open; |
|
|
_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.加工单号); |
|
@ -2690,7 +2669,7 @@ namespace CK.SCP.Controller |
|
|
_PO_Detail.Dliverypatterncode = itm.发货样式; |
|
|
_PO_Detail.Dliverypatterncode = itm.发货样式; |
|
|
_PO_Detail.Deliverytimecode = itm.发货时间样式; |
|
|
_PO_Detail.Deliverytimecode = itm.发货时间样式; |
|
|
_PO_Detail.Transportdays = string.IsNullOrEmpty(itm.运输周期) ? 0 : int.Parse(itm.运输周期); |
|
|
_PO_Detail.Transportdays = string.IsNullOrEmpty(itm.运输周期) ? 0 : int.Parse(itm.运输周期); |
|
|
_PO_Detail.Site= site.Trim().ToUpper(); |
|
|
_PO_Detail.Site = site.Trim().ToUpper(); |
|
|
_PO_Detail.SubSite = subsite.Trim().ToUpper(); |
|
|
_PO_Detail.SubSite = subsite.Trim().ToUpper(); |
|
|
TS_UNI_API Ts = new TS_UNI_API(); |
|
|
TS_UNI_API Ts = new TS_UNI_API(); |
|
|
Ts.InterfaceType = "PO"; |
|
|
Ts.InterfaceType = "PO"; |
|
@ -2717,8 +2696,8 @@ namespace CK.SCP.Controller |
|
|
Ts.Domain = site.Trim().ToUpper(); |
|
|
Ts.Domain = site.Trim().ToUpper(); |
|
|
Ts.Extend1 = _entity.税率; |
|
|
Ts.Extend1 = _entity.税率; |
|
|
Ts.Extend2 = _entity.备注; |
|
|
Ts.Extend2 = _entity.备注; |
|
|
Ts.CreateOper= _entity.采购员; |
|
|
Ts.CreateOper = _entity.采购员; |
|
|
Ts.VendBatch= p_creator; |
|
|
Ts.VendBatch = p_creator; |
|
|
Ts.ErpLineNum = _PO_Detail.PoLine; |
|
|
Ts.ErpLineNum = _PO_Detail.PoLine; |
|
|
if (_entity.订单类型.ToUpper() == "S") |
|
|
if (_entity.订单类型.ToUpper() == "S") |
|
|
{ |
|
|
{ |
|
@ -2866,7 +2845,7 @@ namespace CK.SCP.Controller |
|
|
Ts.Extend2 = _entity.备注; |
|
|
Ts.Extend2 = _entity.备注; |
|
|
Ts.CreateOper = _entity.采购员; |
|
|
Ts.CreateOper = _entity.采购员; |
|
|
Ts.VendBatch = p_creator; |
|
|
Ts.VendBatch = p_creator; |
|
|
Ts.ErpBillNum= _po.PoBillNum; |
|
|
Ts.ErpBillNum = _po.PoBillNum; |
|
|
Ts.ErpLineNum = _PO_Detail.PoLine; |
|
|
Ts.ErpLineNum = _PO_Detail.PoLine; |
|
|
if (!string.IsNullOrEmpty(_entity.订单类型)) |
|
|
if (!string.IsNullOrEmpty(_entity.订单类型)) |
|
|
{ |
|
|
{ |
|
@ -2905,7 +2884,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) |
|
@ -2913,7 +2892,7 @@ namespace CK.SCP.Controller |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "InsterPo", e.Message); |
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "InsterPo", e.Message); |
|
|
_ret.Result = false; |
|
|
_ret.Result = false; |
|
|
_ret.Message = e.InnerException != null? e.Message+ e.InnerException.Message:e.Message; |
|
|
_ret.Message = e.InnerException != null ? e.Message + e.InnerException.Message : e.Message; |
|
|
scope.Dispose(); |
|
|
scope.Dispose(); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
@ -2956,7 +2935,7 @@ namespace CK.SCP.Controller |
|
|
_po.Contacter = p_chineseName;// _entity.联系人;
|
|
|
_po.Contacter = p_chineseName;// _entity.联系人;
|
|
|
_po.Buyer = p_chineseName;// _entity.联系人;
|
|
|
_po.Buyer = p_chineseName;// _entity.联系人;
|
|
|
_po.Site = site.Trim().ToUpper(); |
|
|
_po.Site = site.Trim().ToUpper(); |
|
|
_po.State= (int)PoState.Open; |
|
|
_po.State = (int)PoState.Open; |
|
|
_po.BuyerPhone = p_buyerPhone; |
|
|
_po.BuyerPhone = p_buyerPhone; |
|
|
_po.Remark = _entity.备注; |
|
|
_po.Remark = _entity.备注; |
|
|
_po.IsDeleted = false; |
|
|
_po.IsDeleted = false; |
|
@ -2975,7 +2954,7 @@ namespace CK.SCP.Controller |
|
|
_PO_Detail.Currency = "CNY"; |
|
|
_PO_Detail.Currency = "CNY"; |
|
|
_PO_Detail.PoBillNum = _po.PoBillNum; |
|
|
_PO_Detail.PoBillNum = _po.PoBillNum; |
|
|
_PO_Detail.PartCode = itm.零件号.Trim(); |
|
|
_PO_Detail.PartCode = itm.零件号.Trim(); |
|
|
var part = scpdb.TA_PART.FirstOrDefault(t=>t.PartCode== itm.零件号.Trim()&&t.Site==_po.Site); |
|
|
var part = scpdb.TA_PART.FirstOrDefault(t => t.PartCode == itm.零件号.Trim() && t.Site == _po.Site); |
|
|
_PO_Detail.PoLine = int.Parse(itm.行号); |
|
|
_PO_Detail.PoLine = int.Parse(itm.行号); |
|
|
_PO_Detail.PoUnit = part.Unit; |
|
|
_PO_Detail.PoUnit = part.Unit; |
|
|
_PO_Detail.CreateTime = DateTime.Now; |
|
|
_PO_Detail.CreateTime = DateTime.Now; |
|
@ -3544,7 +3523,7 @@ namespace CK.SCP.Controller |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
var ret = CREATE_TEA_TASK_SUB(db, true ,new TEA_TASK_SUB() |
|
|
var ret = CREATE_TEA_TASK_SUB(db, true, new TEA_TASK_SUB() |
|
|
{ |
|
|
{ |
|
|
DataCount = 1, |
|
|
DataCount = 1, |
|
|
TaskID = taskid, |
|
|
TaskID = taskid, |
|
@ -3580,25 +3559,25 @@ namespace CK.SCP.Controller |
|
|
return _ret; |
|
|
return _ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static ResultObject<bool> UpdatePo(List<string> p_po_list, string site, string p_creator, DateTime p_time, string subsite) |
|
|
public static ResultObject<bool> UpdatePo(List<string> p_po_list, string site, string p_creator, DateTime p_time, string subsite) |
|
|
{ |
|
|
{ |
|
|
ScpEntities scpdb = EntitiesFactory.CreateScpInstance(); |
|
|
ScpEntities scpdb = EntitiesFactory.CreateScpInstance(); |
|
|
ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance(); |
|
|
ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
foreach(var _num in p_po_list) |
|
|
foreach (var _num in p_po_list) |
|
|
{ |
|
|
{ |
|
|
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) |
|
|
{ |
|
|
{ |
|
|
// var uid = oldpolist.Select(p => p.UID).Max();
|
|
|
// var uid = oldpolist.Select(p => p.UID).Max();
|
|
|
// var _mstr = db.TED_PO_MSTR.FirstOrDefault(t => t.UID == uid);
|
|
|
// var _mstr = db.TED_PO_MSTR.FirstOrDefault(t => t.UID == uid);
|
|
|
|
|
|
|
|
|
var oldpodetaillist = scpdb.TB_PO_DETAIL.Where(q => q.PoBillNum == _num && q.State == (int)PoState.Open).ToList() ; |
|
|
var oldpodetaillist = scpdb.TB_PO_DETAIL.Where(q => q.PoBillNum == _num && q.State == (int)PoState.Open).ToList(); |
|
|
item.CommandType = "U"; |
|
|
item.CommandType = "U"; |
|
|
item.GUID = Guid.NewGuid(); |
|
|
item.GUID = Guid.NewGuid(); |
|
|
item.DataID = _mstr.GUID; |
|
|
item.DataID = _mstr.GUID; |
|
@ -3612,15 +3591,15 @@ namespace CK.SCP.Controller |
|
|
item.OrderDate = _mstr.CreateTime;//订单日期
|
|
|
item.OrderDate = _mstr.CreateTime;//订单日期
|
|
|
item.DueDate = Convert.ToDateTime(_mstr.EndTime); |
|
|
item.DueDate = Convert.ToDateTime(_mstr.EndTime); |
|
|
item.StartDate = _mstr.CreateTime;//订单日期
|
|
|
item.StartDate = _mstr.CreateTime;//订单日期
|
|
|
item.EndDate =Convert.ToDateTime( _mstr.EndTime); |
|
|
item.EndDate = Convert.ToDateTime(_mstr.EndTime); |
|
|
item.MadeIn = ""; |
|
|
item.MadeIn = ""; |
|
|
item.Confirm = true; |
|
|
item.Confirm = true; |
|
|
item.Buyer = _mstr.Buyer; |
|
|
item.Buyer = _mstr.Buyer; |
|
|
item.BuyerPhone = _mstr.BuyerPhone; |
|
|
item.BuyerPhone = _mstr.BuyerPhone; |
|
|
item.ScheduledOrder = _mstr.ModType==1?true:false; |
|
|
item.ScheduledOrder = _mstr.ModType == 1 ? true : false; |
|
|
item.CreateUser = _mstr.CreateUser; |
|
|
item.CreateUser = _mstr.CreateUser; |
|
|
item.CreateTime = _mstr.CreateTime; |
|
|
item.CreateTime = _mstr.CreateTime; |
|
|
item.Remark = "订单关闭" ; |
|
|
item.Remark = "订单关闭"; |
|
|
item.Domain = _mstr.Site; |
|
|
item.Domain = _mstr.Site; |
|
|
item.ModeType = _mstr.ModType.ToString(); |
|
|
item.ModeType = _mstr.ModType.ToString(); |
|
|
item.Site = _mstr.SubSite; |
|
|
item.Site = _mstr.SubSite; |
|
@ -3730,10 +3709,11 @@ namespace CK.SCP.Controller |
|
|
b_ASN.Reason = asn.Reason; |
|
|
b_ASN.Reason = asn.Reason; |
|
|
b_ASN.State = (int)AskState.Reject; |
|
|
b_ASN.State = (int)AskState.Reject; |
|
|
b_ASN.IsDeleted = true; |
|
|
b_ASN.IsDeleted = true; |
|
|
List<TB_ASN_DETAIL> asn_details = scpdb.TB_ASN_DETAIL.Where(q => q.AsnBillNum == asn.BillNum).ToList(); |
|
|
List<TB_ASN_DETAIL> asn_details = scpdb.TB_ASN_DETAIL.Where(q => q.AsnBillNum == asn.BillNum).ToList(); |
|
|
if (asn_details != null) |
|
|
if (asn_details != null) |
|
|
{ |
|
|
{ |
|
|
asn_details.ForEach(itm => { |
|
|
asn_details.ForEach(itm => |
|
|
|
|
|
{ |
|
|
itm.IsDeleted = true; |
|
|
itm.IsDeleted = true; |
|
|
itm.State = (int)AskState.Reject; |
|
|
itm.State = (int)AskState.Reject; |
|
|
}); |
|
|
}); |
|
|