|
|
@ -3,6 +3,8 @@ using System.Collections.Generic; |
|
|
|
using System.Data; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
using Quartz; |
|
|
|
|
|
|
|
|
|
|
@ -11,7 +13,7 @@ namespace ICSSoft.FromERP |
|
|
|
/// <summary>
|
|
|
|
/// 采购到货(退货单)
|
|
|
|
/// </summary>
|
|
|
|
public class ICSDeliveryNoticeT : IJob |
|
|
|
public class ICSDeliveryNoticeT |
|
|
|
{ |
|
|
|
private static object key = new object(); |
|
|
|
private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
|
@ -38,7 +40,6 @@ namespace ICSSoft.FromERP |
|
|
|
{ |
|
|
|
string conStr = ICSHelper.GetConnectString(); |
|
|
|
string Namespace = this.GetType().Namespace; |
|
|
|
//string Class = this.GetType().Name;
|
|
|
|
DataTable dt = ICSHelper.GetERPDB(conStr); |
|
|
|
foreach (DataRow dr in dt.Rows) |
|
|
|
{ |
|
|
@ -46,49 +47,184 @@ namespace ICSSoft.FromERP |
|
|
|
string WorkPoint = dr["WorkPointCode"].ToString(); |
|
|
|
string Class = this.GetType().Name + WorkPoint; |
|
|
|
erpName = string.Format(erpName, WorkPoint); |
|
|
|
string dvURL = ""; |
|
|
|
string token = ""; |
|
|
|
List<string> lsid = new List<string>(); |
|
|
|
//获取token
|
|
|
|
token = YSHepler.GetToken(); |
|
|
|
dvURL = YSHepler.GetSELECTURL(); |
|
|
|
Dictionary<string, string> dic = new Dictionary<string, string>(); |
|
|
|
DYS dys = new DYS(); |
|
|
|
List<DYSs> ls = new List<DYSs>(); |
|
|
|
List<DYSq> lq = new List<DYSq>(); |
|
|
|
|
|
|
|
DataTable LastTime = ICSHelper.GetlastTime(conStr, Namespace, Class, WorkPoint, "", "#TempPO"); |
|
|
|
string Time = LastTime.Rows[0]["DateTime"].ToString(); |
|
|
|
dys.pageSize = 500; |
|
|
|
dys.pageIndex = 1; |
|
|
|
dys.isSum = true; |
|
|
|
|
|
|
|
#region 添加条件
|
|
|
|
DYSs s = new DYSs(); |
|
|
|
s.field = "modifyTime"; |
|
|
|
s.op = "gt"; |
|
|
|
s.value1 = Convert.ToDateTime(Time).ToString("yyyy-MM-dd HH:mm:ss"); |
|
|
|
ls.Add(s); |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 添加排序
|
|
|
|
DYSq q = new DYSq(); |
|
|
|
q.field = "modifyTime"; |
|
|
|
q.order = "desc"; |
|
|
|
lq.Add(q); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
dys.simpleVOs = ls; |
|
|
|
dys.queryOrders = lq; |
|
|
|
|
|
|
|
string JsonData = JsonConvert.SerializeObject(dys); |
|
|
|
#region 获取列表内ID
|
|
|
|
string results = YSHepler.HttpPost(dvURL + "/yonbip/scm/purchaseorder/list?access_token=" + token + "", JsonData, "", "POST"); |
|
|
|
JObject obj = JObject.Parse(results); |
|
|
|
if (obj["code"].ToString() == "200") |
|
|
|
{ |
|
|
|
foreach (JObject item in obj["data"]["recordList"]) |
|
|
|
{ |
|
|
|
if (item["bustype_name"].ToString() == "采购退货") |
|
|
|
lsid.Add(item["id"].ToString()); |
|
|
|
|
|
|
|
} |
|
|
|
int end = Convert.ToInt32(obj["data"]["endPageIndex"].ToString()); |
|
|
|
if (end > 1) |
|
|
|
{ |
|
|
|
for (int i = 2; i <= end; i++) |
|
|
|
{ |
|
|
|
dys.pageIndex = 1; |
|
|
|
JsonData = JsonConvert.SerializeObject(dys); |
|
|
|
results = YSHepler.HttpPost(dvURL + "/yonbip/scm/purchaseorder/list?access_token=" + token + "", JsonData, "", "POST"); |
|
|
|
obj = JObject.Parse(results); |
|
|
|
if (obj["code"].ToString() == "200") |
|
|
|
{ |
|
|
|
foreach (JObject item in obj["data"]["recordList"]) |
|
|
|
{ |
|
|
|
if (item["bustype_name"].ToString() == "采购退货") |
|
|
|
lsid.Add(item["id"].ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
string sql = ""; |
|
|
|
string sqlGG = ""; |
|
|
|
int number = 0; |
|
|
|
foreach (string item in lsid) |
|
|
|
{ |
|
|
|
|
|
|
|
results = YSHepler.PostByTokenGet(dvURL + "/yonbip/scm/purchaseorder/detail?access_token=" + token + "&id=" + item + "", dic, ""); |
|
|
|
obj = JObject.Parse(results); |
|
|
|
if (obj["code"].ToString() == "200") |
|
|
|
{ |
|
|
|
#region 通过ID获取对应信息
|
|
|
|
string VenCoderesult = YSHepler.PostByTokenGet(dvURL + "/yonbip/digitalModel/vendor/detail?access_token=" + token + "&id=" + obj["data"]["vendor"].ToString() + "&orgId=" + obj["data"]["org"].ToString() + "", dic, ""); |
|
|
|
JObject result = JObject.Parse(VenCoderesult); |
|
|
|
string VneCode = result["data"]["code"].ToString(); |
|
|
|
#endregion
|
|
|
|
foreach (JObject items in obj["data"]["purchaseOrders"]) |
|
|
|
{ |
|
|
|
|
|
|
|
number++; |
|
|
|
string POCode = obj["data"]?["code"] != null ? obj["data"]["code"].ToString() : ""; |
|
|
|
string lineNo = items["lineno"] != null ? items["lineno"].ToString() : ""; |
|
|
|
string venName = obj["data"]?["vendor_name"] != null ? obj["data"]["vendor_name"].ToString() : ""; |
|
|
|
string modifier = obj["data"]?["modifier"] != null ? obj["data"]["modifier"].ToString() : ""; |
|
|
|
string qty = items["qty"] != null ? items["qty"].ToString() : ""; |
|
|
|
string subQty = items["subQty"] != null ? items["subQty"].ToString() : ""; |
|
|
|
string productCCode = items["product_cCode"] != null ? items["product_cCode"].ToString() : ""; |
|
|
|
string currencyName = obj["data"]?["currency_name"] != null ? obj["data"]["currency_name"].ToString() : ""; |
|
|
|
string natUnitPrice = items["natUnitPrice"] != null ? items["natUnitPrice"].ToString() : ""; |
|
|
|
string creator = obj["data"]?["creator"] != null ? obj["data"]["creator"].ToString() : ""; |
|
|
|
string createTime = obj["data"]?["createTime"] != null ? obj["data"]["createTime"].ToString() : ""; |
|
|
|
string recieveDate = items["recieveDate"] != null ? items["recieveDate"].ToString() : ""; |
|
|
|
string id = obj["data"]["id"] != null ? obj["data"]["id"].ToString() : ""; |
|
|
|
string Zid = items["id"] != null ? items["id"].ToString() : ""; |
|
|
|
string POID = items["sourceid"] != null ? items["sourceid"].ToString() : ""; |
|
|
|
string PODetailID = items["sourceautoid"] != null ? items["sourceautoid"].ToString() : ""; |
|
|
|
|
|
|
|
sqlGG = @"select '" + POCode + "' DNCode,'" + lineNo + "' Sequence," + |
|
|
|
"'" + VneCode + "' VenCode,'' DepCode," + qty + " Quantity," + subQty + " Amount," + |
|
|
|
"'2' DNType,'" + productCCode + "'InvCode, " + |
|
|
|
"'" + currencyName + "' Currency,'" + natUnitPrice + "' UnitPrice,'1' Status," + |
|
|
|
"'" + creator + "' CreatePerson,'" + createTime + "' CreateDateTime," + |
|
|
|
"'" + createTime + "' MTIME,'" + id + "' DNID,'" + Zid + "' DNDetailID," + |
|
|
|
"'" + POID + "' POID,'" + PODetailID + "' PODetailID," + |
|
|
|
"'' ProjectCode,'' cBatch,'' version ,'' brand,'' as cFree1,'' as cFree2,'' as cFree3,'' as cFree4,'' as cFree5,'' as cFree6,'' as cFree7," + |
|
|
|
"'' as cFree8,'' as cFree9,'' as cFree10,CAST('' AS NVARCHAR(500)) as Colspan,'' WHCode"; |
|
|
|
|
|
|
|
if (number == 1) |
|
|
|
{ |
|
|
|
sql = sqlGG + @" INTO #ICSDelive "; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
sql += @" union all {0}"; |
|
|
|
sql = string.Format(sql, sqlGG); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#region 原SQL
|
|
|
|
// select a.cCode as DNCode,
|
|
|
|
// b.ivouchrowno as Sequence,
|
|
|
|
// a.cVenCode as VenCode ,
|
|
|
|
// cDepCode as DepCode ,
|
|
|
|
// CASE WHEN b.iQuantity >= 0 THEN '1' ELSE '2' END AS DNType,
|
|
|
|
// b.cInvCode as InvCode,
|
|
|
|
// b.iQuantity as Quantity ,
|
|
|
|
// isnull(b.iNum, 0) as Amount,
|
|
|
|
// a.cexch_name as Currency,
|
|
|
|
// b.iCost as UnitPrice,
|
|
|
|
// a.cMaker as CreatePerson,
|
|
|
|
// a.cMakeTime as CreateDateTime,
|
|
|
|
// a.iverifystateex as Status,
|
|
|
|
// a.cMakeTime as MTIME,
|
|
|
|
// a.ID as DNID,
|
|
|
|
// isnull(c.POID, '') as POID,
|
|
|
|
// isnull(b.iPOsID, '') as PODetailID,
|
|
|
|
// cast(b.AutoID as varchar(100)) as DNDetailID,
|
|
|
|
// isnull(b.cItemCode, '') ProjectCode,isnull(b.cbatch, '') cBatch,'' version ,'' brand,
|
|
|
|
// (case WHEN inv.bFree1 = 1 THEN isnull(b.cFree1,'') ELSE '' END) as cFree1,
|
|
|
|
// (case WHEN inv.bFree2 = 1 THEN isnull(b.cFree2,'') ELSE '' END) as cFree2,
|
|
|
|
// (case WHEN inv.bFree3 = 1 THEN isnull(b.cFree3,'') ELSE '' END) as cFree3,
|
|
|
|
// (case WHEN inv.bFree4 = 1 THEN isnull(b.cFree4,'') ELSE '' END) as cFree4,
|
|
|
|
// (case WHEN inv.bFree5 = 1 THEN isnull(b.cFree5,'') ELSE '' END) as cFree5,
|
|
|
|
// (case WHEN inv.bFree6 = 1 THEN isnull(b.cFree6,'') ELSE '' END) as cFree6,
|
|
|
|
// (case WHEN inv.bFree7 = 1 THEN isnull(b.cFree7,'') ELSE '' END) as cFree7,
|
|
|
|
// (case WHEN inv.bFree8 = 1 THEN isnull(b.cFree8,'') ELSE '' END) as cFree8,
|
|
|
|
// (case WHEN inv.bFree9 = 1 THEN isnull(b.cFree9,'') ELSE '' END) as cFree9,
|
|
|
|
// (case WHEN inv.bFree10 = 1 THEN isnull(b.cFree10,'') ELSE '' END) as cFree10,CAST('' AS NVARCHAR(500)) as Colspan,
|
|
|
|
// '{0}' as WorkPoint,
|
|
|
|
// b.cWhCode as WHCode
|
|
|
|
// INTO #ICSDelive
|
|
|
|
// from { 1}.DBO.PU_ArrivalVouch a
|
|
|
|
// inner join { 1}.DBO.PU_ArrivalVouchs b on a.ID = b.ID
|
|
|
|
// left join { 1}.DBO.PO_Podetails c on b.iPOsID = c.ID
|
|
|
|
// LEFT JOIN { 1}.dbo.Inventory inv ON b.cInvCode = inv.cInvCode
|
|
|
|
// where
|
|
|
|
//a.cBusType in('普通采购') and a.iBillType <> 2 and
|
|
|
|
// ISNULL(a.cverifier, '') <> ''and ISNULL(a.cAuditTime, ISNULL(a.cModifyTime, a.cmaketime))>= @LastTime
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region SQL
|
|
|
|
string sql = @"
|
|
|
|
select a.cCode as DNCode, |
|
|
|
b.ivouchrowno as Sequence, |
|
|
|
a.cVenCode as VenCode , |
|
|
|
cDepCode as DepCode , |
|
|
|
CASE WHEN b.iQuantity>=0 THEN '1' ELSE '2' END AS DNType, |
|
|
|
b.cInvCode as InvCode, |
|
|
|
b.iQuantity as Quantity , |
|
|
|
isnull(b.iNum,0) as Amount, |
|
|
|
a.cexch_name as Currency, |
|
|
|
b.iCost as UnitPrice, |
|
|
|
a.cMaker as CreatePerson, |
|
|
|
a.cMakeTime as CreateDateTime, |
|
|
|
a.iverifystateex as Status, |
|
|
|
a.cMakeTime as MTIME, |
|
|
|
a.ID as DNID, |
|
|
|
isnull(c.POID,'') as POID, |
|
|
|
isnull(b.iPOsID,'') as PODetailID, |
|
|
|
cast(b.AutoID as varchar(100)) as DNDetailID, |
|
|
|
isnull(b.cItemCode,'') ProjectCode,isnull(b.cbatch,'') cBatch,'' version ,'' brand, |
|
|
|
(case WHEN inv.bFree1=1 THEN isnull(b.cFree1,'') ELSE '' END) as cFree1, |
|
|
|
(case WHEN inv.bFree2=1 THEN isnull(b.cFree2,'') ELSE '' END) as cFree2, |
|
|
|
(case WHEN inv.bFree3=1 THEN isnull(b.cFree3,'') ELSE '' END) as cFree3, |
|
|
|
(case WHEN inv.bFree4=1 THEN isnull(b.cFree4,'') ELSE '' END) as cFree4, |
|
|
|
(case WHEN inv.bFree5=1 THEN isnull(b.cFree5,'') ELSE '' END) as cFree5, |
|
|
|
(case WHEN inv.bFree6=1 THEN isnull(b.cFree6,'') ELSE '' END) as cFree6, |
|
|
|
(case WHEN inv.bFree7=1 THEN isnull(b.cFree7,'') ELSE '' END) as cFree7, |
|
|
|
(case WHEN inv.bFree8=1 THEN isnull(b.cFree8,'') ELSE '' END) as cFree8, |
|
|
|
(case WHEN inv.bFree9=1 THEN isnull(b.cFree9,'') ELSE '' END) as cFree9, |
|
|
|
(case WHEN inv.bFree10=1 THEN isnull(b.cFree10,'') ELSE '' END) as cFree10,CAST('' AS NVARCHAR(500)) as Colspan, |
|
|
|
'{0}' as WorkPoint, |
|
|
|
b.cWhCode as WHCode |
|
|
|
INTO #ICSDelive |
|
|
|
from {1}.DBO.PU_ArrivalVouch a |
|
|
|
inner join {1}.DBO.PU_ArrivalVouchs b on a.ID =b.ID |
|
|
|
left join {1}.DBO.PO_Podetails c on b.iPOsID=c.ID |
|
|
|
LEFT JOIN {1}.dbo.Inventory inv ON b.cInvCode = inv.cInvCode |
|
|
|
where |
|
|
|
a.cBusType in('普通采购') and a.iBillType<>2 and |
|
|
|
ISNULL (a.cverifier ,'') <> ''and ISNULL(a.cAuditTime, ISNULL(a.cModifyTime, a.cmaketime))>=@LastTime |
|
|
|
update #ICSDelive set Colspan=isNULL(ProjectCode,'')+'~'+isNULL(cBatch,'')+'~'+isNULL(Version,'')+'~'+isNULL(Brand,'')+'~'+isNULL(cFree1,'')+'~'+isnull(cFree2,'')+'~'+isnull(cFree3,'')+'~'+isnull(cFree4,'')+'~'+isnull(cFree5,'')+'~'+isnull(cFree6,'')+'~'+isnull(cFree7,'')+'~'+isnull(cFree8,'')+'~'+isnull(cFree9,'')+'~'+isnull(cFree10,'') |
|
|
|
sql += @"
|
|
|
|
update #ICSDelive set Colspan=isNULL(ProjectCode,'')+'~'+isNULL(cBatch,'')+'~'+isNULL(Version,'')+'~'+isNULL(Brand,'')+'~'+isNULL(cFree1,'')+'~'+isnull(cFree2,'')+'~'+isnull(cFree3,'')+'~'+isnull(cFree4,'')+'~'+isnull(cFree5,'')+'~'+isnull(cFree6,'')+'~'+isnull(cFree7,'')+'~'+isnull(cFree8,'')+'~'+isnull(cFree9,'')+'~'+isnull(cFree10,'') |
|
|
|
select distinct |
|
|
|
Colspan,ProjectCode,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10,WorkPoint,cBatch,version ,brand |
|
|
|
INTO #TempExtension |
|
|
@ -195,5 +331,25 @@ LEFT JOIN {1}.dbo.[PU_ArrivalVouchs] b With(NoLock) ON a.DNDetailID=convert(varc |
|
|
|
log.Error(ex.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
public class DYS |
|
|
|
{ |
|
|
|
public int pageIndex; |
|
|
|
public int pageSize; |
|
|
|
public bool isSum; |
|
|
|
public List<DYSs> simpleVOs; |
|
|
|
public List<DYSq> queryOrders; |
|
|
|
} |
|
|
|
public class DYSs |
|
|
|
{ |
|
|
|
public string field; |
|
|
|
public string op; |
|
|
|
public string value1; |
|
|
|
} |
|
|
|
public class DYSq |
|
|
|
{ |
|
|
|
public string field; |
|
|
|
public string order; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |