|
|
@ -30,6 +30,7 @@ using static CK.SCP.UniApi.Controller.PoBillNumcontroller; |
|
|
|
using static CK.SCP.UniApi.Controller.NetPriceController; |
|
|
|
using System.Xml.Linq; |
|
|
|
using System.Security.Principal; |
|
|
|
using System.Diagnostics; |
|
|
|
|
|
|
|
namespace CK.SCP.GrupUniApi.Controller |
|
|
|
{ |
|
|
@ -1643,7 +1644,8 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
try |
|
|
|
{ |
|
|
|
DateTime time = DateTime.Now.AddMonths(-12); |
|
|
|
var hisList = idb.xxDiMaxes_Order.Where(q => q.CREATEDDATE > time).ToList(); |
|
|
|
var hisList = new List<xxDiMaxes_Order>(); |
|
|
|
hisList = idb.xxDiMaxes_Order.Where(q => q.CREATEDDATE > time).ToList(); |
|
|
|
// 读取一年内 所有审批完的一般材料订单
|
|
|
|
DataTable b = GetGeneralMaterialOrder(); |
|
|
|
List<GeneralMaterialOrder> orderlist = ChangKeTec.Utils.ListHelper.DataTableToList<GeneralMaterialOrder>(b); |
|
|
@ -1669,8 +1671,16 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
var emails = new List<TS_Email>(); |
|
|
|
var Dlist = list.Where(p => p.DI_OPERTYPE == "D").GroupBy(p => p.PURDOCNO).Distinct();// 按照订单号分组去重
|
|
|
|
var Ilist = list.Where(p => p.DI_OPERTYPE == "I").GroupBy(p => p.PURDOCNO).Distinct();// 按照订单号分组去重
|
|
|
|
string wwadres= sdb.TA_CONFIG.FirstOrDefault(q => q.ParamName == "接口邮件网址").ParamValue; |
|
|
|
string wwadres = ""; |
|
|
|
var config = sdb.TA_CONFIG.FirstOrDefault(q => q.ParamName == "接口邮件网址"); |
|
|
|
if (config != null) |
|
|
|
{ |
|
|
|
wwadres = config.ParamValue; |
|
|
|
} |
|
|
|
if (Dlist.Count()>0) |
|
|
|
{ |
|
|
|
// 作废
|
|
|
|
#region
|
|
|
|
foreach (var DeleteItem in Dlist) |
|
|
|
{ |
|
|
|
var _list = DeleteItem.ToList(); |
|
|
@ -1698,7 +1708,7 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
string mailbody = ""; |
|
|
|
mailbody += "尊敬的 供应商<br>"; |
|
|
|
mailbody += "你好!<br><br>"; |
|
|
|
mailbody += "一般材料订单 <b>" + Ditem.PURDOCNO +"</b>"+"<b> 行号"+p.PURDOCITEMNO+ "</b> 进行了物料行作废的操作,请登录供应商协同网站进行订单查看。<br>"; |
|
|
|
mailbody += "一般材料订单 <b>" + Ditem.PURDOCNO + "</b>" + "<b> 行号" + p.PURDOCITEMNO + "</b> 进行了物料行作废的操作,请登录供应商协同网站进行订单查看。<br>"; |
|
|
|
mailbody += "登录账号:<b>" + Ditem.VENDORNO + "@W21" + "</b><br>"; |
|
|
|
mailbody += "登录地址:" + wwadres + "<br><br>"; |
|
|
|
mailbody += "<br><br><br><br>日期:" + DateTime.Now; |
|
|
@ -1722,7 +1732,7 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
var valueType = MATERIALORDERDETAILList.Select(q => q.Ctype).Distinct().ToList(); |
|
|
|
var type = valueType.FirstOrDefault(); |
|
|
|
// 子表全是d并且唯一 更新主表
|
|
|
|
if (valueType.Count() == 1 && type =="D") |
|
|
|
if (valueType.Count() == 1 && type == "D") |
|
|
|
{ |
|
|
|
var MATERIALORDERList = sdb.TB_MATERIALORDERS.Where(q => q.PurdocNO == Ditem.PURDOCNO).ToList(); |
|
|
|
MATERIALORDERList.ForEach(p => |
|
|
@ -1789,7 +1799,12 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
if (Ilist.Count()>0) |
|
|
|
{ |
|
|
|
// 新增
|
|
|
|
#region
|
|
|
|
foreach (var InsertItem in Ilist) |
|
|
|
{ |
|
|
|
var inlist = InsertItem.ToList(); |
|
|
@ -1798,23 +1813,25 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
TB_MATERIALORDERS order = new TB_MATERIALORDERS(); |
|
|
|
order.PurdocNO = inentity.PURDOCNO; |
|
|
|
order.BuyListStrdes = inentity.BUYLISTSTRDES; |
|
|
|
order.DocDate = inentity.DOCDATE != null? (DateTime)inentity.DOCDATE: DateTime.Now; |
|
|
|
order.DocDate = inentity.DOCDATE != null ? (DateTime)inentity.DOCDATE : DateTime.Now; |
|
|
|
order.VendorNO = inentity.VENDORNO; |
|
|
|
order.VendorDesc = inentity.VENDORDESC; |
|
|
|
order.PurgrpDesc = inentity.PURGRPDESC; |
|
|
|
order.ApprovalStatus = inentity.APPROVALSTATUS; |
|
|
|
order.ItemdeliveryDate = inentity.ITEMDELIVERYDATE != null?(DateTime)inentity.ITEMDELIVERYDATE:DateTime.Now; |
|
|
|
order.ItemdeliveryDate = inentity.ITEMDELIVERYDATE != null ? (DateTime)inentity.ITEMDELIVERYDATE : DateTime.Now; |
|
|
|
order.CreatedByDesc = inentity.CREATEDBYDESC; |
|
|
|
order.CreatedBy = inentity.CREATEDBY; |
|
|
|
order.Ctype = "new"; |
|
|
|
order.FIRSTTELNO = inentity.FIRSTTELNO; |
|
|
|
order.PHONE = inentity.PHONE; |
|
|
|
order.FAXNUM = inentity.FAXNUM; |
|
|
|
order.AcceptStatus = (int)GeneralMaterialOrderState.New; |
|
|
|
InPoList.Add(order); |
|
|
|
foreach (var initem in inlist) |
|
|
|
{ |
|
|
|
TB_MATERIALORDERS_DETAIL orderdetail = new TB_MATERIALORDERS_DETAIL(); |
|
|
|
orderdetail.PurdocNO = initem.PURDOCNO; |
|
|
|
orderdetail.AcceptStatus = (int)GeneralMaterialOrderState.New; |
|
|
|
orderdetail.PurchaseReqNO = initem.PURCHASEREQNO; |
|
|
|
orderdetail.ProposerDesc = initem.PROPOSERDESC; |
|
|
|
orderdetail.MtlNO = initem.MTLNO; |
|
|
@ -1823,8 +1840,8 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
orderdetail.SizeCol = initem.SIZECOL; |
|
|
|
orderdetail.Matbrand = initem.MATBRAND; |
|
|
|
orderdetail.Unitdes = initem.UNITDES; |
|
|
|
orderdetail.Quantity = initem.QUANTITY!=null?(decimal)initem.QUANTITY:0.000000m; |
|
|
|
orderdetail.PRICE = initem.PRICE != null ?(decimal) initem.PRICE : 0.00000m; |
|
|
|
orderdetail.Quantity = initem.QUANTITY != null ? (decimal)initem.QUANTITY : 0.000000m; |
|
|
|
orderdetail.PRICE = initem.PRICE != null ? (decimal)initem.PRICE : 0.00000m; |
|
|
|
orderdetail.NetValue = initem.NETVALUE != null ? (decimal)initem.NETVALUE : 0.00000m; |
|
|
|
orderdetail.PurinfoReCord = initem.PURINFORECORD; |
|
|
|
orderdetail.ItemDeliveryDate = initem.ITEMDELIVERYDATE != null ? (DateTime)initem.ITEMDELIVERYDATE : DateTime.Now; |
|
|
@ -1853,7 +1870,7 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
mailbody += "你好!<br><br>"; |
|
|
|
mailbody += "一般材料订单 <b>" + inentity.PURDOCNO + "</b> 已经发布,请到供应商协同网站打开查看!<br>"; |
|
|
|
mailbody += "登录账号:<b>" + inentity.VENDORNO + "@W21" + "</b><br>"; |
|
|
|
mailbody += "登录地址:" + wwadres+ "<br><br>"; |
|
|
|
mailbody += "登录地址:" + wwadres + "<br><br>"; |
|
|
|
mailbody += "<br><br><br><br>日期:" + DateTime.Now; |
|
|
|
email.EmailString = mailbody; |
|
|
|
var user = authdb.Users.FirstOrDefault(q => q.Name.Contains(inentity.VENDORNO)); |
|
|
@ -1871,6 +1888,8 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
#endregion
|
|
|
|
|
|
|
|
} |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
sdb.BulkInsert(emails);// 添加一般材料订单的邮件
|
|
|
|
sdb.BulkInsert(InPoList);// 添加插入的数据
|
|
|
|
sdb.BulkInsert(InPoDetailList);// 添加明细
|
|
|
@ -1887,7 +1906,8 @@ namespace CK.SCP.GrupUniApi.Controller |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
Console.WriteLine(ex.Message); |
|
|
|
|
|
|
|
Console.WriteLine(ex.ToString()); |
|
|
|
if (ex.InnerException != null) |
|
|
|
{ |
|
|
|
Console.WriteLine(ex.InnerException.Message); |
|
|
|