|
|
@ -5,6 +5,9 @@ using System.Text; |
|
|
|
using Quartz; |
|
|
|
|
|
|
|
using System.Data; |
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using System.Threading; |
|
|
|
|
|
|
|
namespace ICSSoft.FromERP |
|
|
|
{ |
|
|
@ -36,11 +39,8 @@ namespace ICSSoft.FromERP |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
//string conERPStr = ICSHelper.GetERPConnectString();
|
|
|
|
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) |
|
|
|
{ |
|
|
@ -48,60 +48,200 @@ namespace ICSSoft.FromERP |
|
|
|
string WorkPoint = dr["WorkPointCode"].ToString(); |
|
|
|
string Class = this.GetType().Name + WorkPoint; |
|
|
|
erpName = string.Format(erpName, WorkPoint); |
|
|
|
string dvURL = ""; |
|
|
|
string token = ""; |
|
|
|
List<InvList> lss = new List<InvList>(); |
|
|
|
//获取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>();
|
|
|
|
|
|
|
|
dys.pageSize = 500; |
|
|
|
dys.pageIndex = 1; |
|
|
|
dys.beganTime= "2025-04-01"; |
|
|
|
//dys.isSum = true;
|
|
|
|
|
|
|
|
#region 添加条件
|
|
|
|
//DYSs s = new DYSs();
|
|
|
|
//s.pubts = "2025-03-21";
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 添加排序
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
//dys.simple = s;
|
|
|
|
//dys.queryOrders = lq;
|
|
|
|
|
|
|
|
string JsonData = JsonConvert.SerializeObject(dys); |
|
|
|
#region 获取列表内ID
|
|
|
|
string results = YSHepler.HttpPost(dvURL + "/yonbip/digitalModel/product/integration/querylist?access_token=" + token + "", JsonData, "", "POST"); |
|
|
|
JObject obj = JObject.Parse(results); |
|
|
|
if (obj["code"].ToString() == "200") |
|
|
|
{ |
|
|
|
InvList ss = new InvList(); |
|
|
|
foreach (JObject item in obj["data"]["recordList"]) |
|
|
|
{ |
|
|
|
ss.ID = item["id"].ToString(); |
|
|
|
ss.WorkPointID = item["createOrgId"].ToString(); |
|
|
|
lss.Add(ss); |
|
|
|
} |
|
|
|
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/digitalModel/product/integration/querylist?access_token=" + token + "", JsonData, "", "POST"); |
|
|
|
obj = JObject.Parse(results); |
|
|
|
if (obj["code"].ToString() == "200") |
|
|
|
{ |
|
|
|
foreach (JObject item in obj["data"]["recordList"]) |
|
|
|
{ |
|
|
|
//lsid.Add(item["id"].ToString());
|
|
|
|
ss.ID = item["id"].ToString(); |
|
|
|
ss.WorkPointID = item["createOrgId"].ToString(); |
|
|
|
lss.Add(ss); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
string sql = ""; |
|
|
|
string sqlGG = ""; |
|
|
|
int number = 0; |
|
|
|
foreach (InvList item in lss) |
|
|
|
{ |
|
|
|
Thread.Sleep(500); |
|
|
|
number++; |
|
|
|
DetilBody detilBody = new DetilBody(); |
|
|
|
detilBody.id = item.ID; |
|
|
|
detilBody.orgId = item.WorkPointID; |
|
|
|
string JsonDataDetil = JsonConvert.SerializeObject(detilBody); |
|
|
|
JsonDataDetil = "[" + JsonDataDetil + "]"; |
|
|
|
// results = YSHepler.PostByTokenGet(dvURL + "/yonbip/digitalModel/product/batchdetailnew?access_token=" + token + "&id=" + item.ID + "", dic, "");
|
|
|
|
results = YSHepler.HttpPost(dvURL + "/yonbip/digitalModel/product/batchdetailnew?access_token=" + token + "", JsonDataDetil, "", "POST"); |
|
|
|
obj = JObject.Parse(results); |
|
|
|
if (obj["code"].ToString() == "200") |
|
|
|
{ |
|
|
|
#region 处理数据
|
|
|
|
|
|
|
|
string code = obj["data"]?[0]?["code"]?.ToString(); |
|
|
|
string name_simplifiedName = obj["data"]?[0]?["name"]?["simplifiedName"]?.ToString(); |
|
|
|
string model1 = obj["data"]?[0]?["model1"]?.ToString(); |
|
|
|
string unitName = obj["data"]?[0]?["unitName"]?.ToString(); |
|
|
|
string manageClassCode = obj["data"]?[0]?["manageClassCode"]?.ToString(); |
|
|
|
var aa = obj["data"]?[0]?["productAssistUnitExchanges"]?.ToList() ; |
|
|
|
string productAssistUnitExchanges_assistUnit = ""; |
|
|
|
string productAssistUnitExchanges_mainUnitCount = "0"; |
|
|
|
string productAssistUnitExchanges_assistUnitCount = "1"; |
|
|
|
if ( aa.Count>0) |
|
|
|
{ |
|
|
|
productAssistUnitExchanges_assistUnit = obj["data"]?[0]?["productAssistUnitExchanges"]?[0]?["assistUnit"]?.ToString(); |
|
|
|
productAssistUnitExchanges_mainUnitCount = obj["data"]?[0]?["productAssistUnitExchanges"]?[0]?["mainUnitCount"]?.ToString(); |
|
|
|
productAssistUnitExchanges_assistUnitCount = obj["data"]?[0]?["productAssistUnitExchanges"]?[0]?["assistUnitCount"]?.ToString(); |
|
|
|
} |
|
|
|
|
|
|
|
//string productAssistUnitExchanges_assistUnit = obj["data"][0]["productAssistUnitExchanges"]?[0]?["assistUnit"]?.ToString();
|
|
|
|
string enableAssistUnit = obj["data"]?[0]?["enableAssistUnit"]?.ToString(); |
|
|
|
string productClassName = obj["data"]?[0]?["productClassName"]?.ToString(); |
|
|
|
//string productAssistUnitExchanges_mainUnitCount = obj["data"][0]["productAssistUnitExchanges"]?[0]?["mainUnitCount"]?.ToString();
|
|
|
|
//string productAssistUnitExchanges_assistUnitCount = obj["data"][0]["productAssistUnitExchanges"]?[0]?["assistUnitCount"]?.ToString();
|
|
|
|
string batchManage = obj["data"]?[0]?["detail"]?["batchManage"]?.ToString(); |
|
|
|
string modifyTime = obj["data"]?[0]?["modifyTime"]?.ToString(); |
|
|
|
#endregion
|
|
|
|
sqlGG = @" select NEWID() AS ID,
|
|
|
|
'" + code + @"' AS INVCODE, |
|
|
|
'"+name_simplifiedName+@"' AS INVNAME, |
|
|
|
|
|
|
|
'"+model1+@"' INVSTD, |
|
|
|
'"+unitName+@"' AS InvUnit, |
|
|
|
'"+manageClassCode+@"' as ClassCode, |
|
|
|
'"+productAssistUnitExchanges_assistUnit+ @"' as AmountUnit, |
|
|
|
(case when isnull('" + enableAssistUnit + @"','') = '' then '0' else '1' end) AmountEnable, |
|
|
|
'" + productClassName+@"' as ClassName, |
|
|
|
'"+productAssistUnitExchanges_mainUnitCount+@"' / '"+productAssistUnitExchanges_assistUnitCount+@"' as InvRate, |
|
|
|
'365' as EffectiveDays, |
|
|
|
'"+batchManage+@"' as fInExcess, |
|
|
|
'"+modifyTime+@"' as MTIME, |
|
|
|
'0' OverType, |
|
|
|
'0' OverValue, |
|
|
|
'0' OverInType, |
|
|
|
'0' OverInValue, |
|
|
|
'' AS INVDESC, |
|
|
|
'' AS INVEXPORTIMPORT, |
|
|
|
'"+WorkPoint+@"' as WorkPoint |
|
|
|
";
|
|
|
|
if (number == 1) |
|
|
|
{ |
|
|
|
sql = sqlGG + @" INTO #TempINV "; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
sql += @" union all {0}"; |
|
|
|
sql = string.Format(sql, sqlGG); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#region 原SQL
|
|
|
|
//string sql = @"select NEWID() AS ID,
|
|
|
|
// cInvCode AS INVCODE,
|
|
|
|
// dbo.GetReplaceStr(cInvName) AS INVNAME,
|
|
|
|
// --dbo.GetReplaceStr(isnull(cInvAddCode,'')+'|'+isnull(cInvStd,'')) AS INVSTD,
|
|
|
|
|
|
|
|
//(case when isnull(cInvAddCode,'')='' then isnull(cInvStd,'') else isnull(cInvAddCode,'')+'|'+isnull(cInvStd,'') end ) INVSTD,
|
|
|
|
// c.cComUnitName AS InvUnit,
|
|
|
|
// a.cInvCCode as ClassCode,
|
|
|
|
// a.cAssComUnitCode as AmountUnit,
|
|
|
|
//(case when a.iGroupType=0 then '0' else '1' end) AmountEnable,
|
|
|
|
// a.cInvCCode AS INVCLASS,
|
|
|
|
// b.cInvCName as ClassName,
|
|
|
|
// ISNULL(c.iChangRate,0) as InvRate,
|
|
|
|
// a.cDefWareHouse as INVMACHINETYPE,
|
|
|
|
// ISNULL(a.iMassDate,'') as EffectiveDays,
|
|
|
|
// a.bInvBatch as fInExcess,
|
|
|
|
// fSupplyMulti as INVCARTONQTY,
|
|
|
|
// ISNULL(a.dModifyDate,e.dInvCreateDatetime) as MTIME,
|
|
|
|
//(case when isnull(a.fOutExcess,0)=0 then 0 else (case when isnull(a.fOutExcess,0)>5 then 3 else 2 end) end) OverType,
|
|
|
|
//isnull(a.fOutExcess,0) OverValue,
|
|
|
|
//(case when isnull(a.fInExcess,0)=0 then 0 else (case when isnull(a.fInExcess,0)>5 then 3 else 2 end) end) OverInType,
|
|
|
|
//isnull(a.fInExcess,0) OverInValue,
|
|
|
|
// '' AS INVDESC,
|
|
|
|
// '' AS INVEXPORTIMPORT,
|
|
|
|
// a.cInvAddCode as INVPARSETYPE,
|
|
|
|
// a.cinvdefine5 as PODetailID
|
|
|
|
// ,'{0}' as WorkPoint,
|
|
|
|
//--fSupplyMulti EATTRIBUTE1,
|
|
|
|
//a.cInvDefine12 EATTRIBUTE1,
|
|
|
|
//a.cInvDefine11 EATTRIBUTE2,a.cInvDefine10 EATTRIBUTE3
|
|
|
|
// INTO #TempINV
|
|
|
|
// FROM {1}.dbo.Inventory a
|
|
|
|
//left join {1}.dbo.Inventory_sub e on a.cinvcode=e.cInvSubCode
|
|
|
|
// LEFT JOIN {1}.dbo.InventoryClass b ON a.cInvCCode = b.cInvCCode
|
|
|
|
// LEFT JOIN {1}.dbo.ComputationUnit c ON a.cComUnitCode = c.cComunitCode
|
|
|
|
// WHERE a.dEDate IS NULL AND a.dModifyDate>=@LastTime
|
|
|
|
// ORDER BY cInvCode
|
|
|
|
#endregion
|
|
|
|
#region SQL
|
|
|
|
string sql = @"select NEWID() AS ID,
|
|
|
|
cInvCode AS INVCODE, |
|
|
|
dbo.GetReplaceStr(cInvName) AS INVNAME, |
|
|
|
--dbo.GetReplaceStr(isnull(cInvAddCode,'')+'|'+isnull(cInvStd,'')) AS INVSTD, |
|
|
|
|
|
|
|
(case when isnull(cInvAddCode,'')='' then isnull(cInvStd,'') else isnull(cInvAddCode,'')+'|'+isnull(cInvStd,'') end ) INVSTD, |
|
|
|
c.cComUnitName AS InvUnit, |
|
|
|
a.cInvCCode as ClassCode, |
|
|
|
a.cAssComUnitCode as AmountUnit, |
|
|
|
(case when a.iGroupType=0 then '0' else '1' end) AmountEnable, |
|
|
|
a.cInvCCode AS INVCLASS, |
|
|
|
b.cInvCName as ClassName, |
|
|
|
ISNULL(c.iChangRate,0) as InvRate, |
|
|
|
a.cDefWareHouse as INVMACHINETYPE, |
|
|
|
ISNULL(a.iMassDate,'') as EffectiveDays, |
|
|
|
a.bInvBatch as fInExcess, |
|
|
|
fSupplyMulti as INVCARTONQTY, |
|
|
|
ISNULL(a.dModifyDate,e.dInvCreateDatetime) as MTIME, |
|
|
|
(case when isnull(a.fOutExcess,0)=0 then 0 else (case when isnull(a.fOutExcess,0)>5 then 3 else 2 end) end) OverType, |
|
|
|
isnull(a.fOutExcess,0) OverValue, |
|
|
|
(case when isnull(a.fInExcess,0)=0 then 0 else (case when isnull(a.fInExcess,0)>5 then 3 else 2 end) end) OverInType, |
|
|
|
isnull(a.fInExcess,0) OverInValue, |
|
|
|
'' AS INVDESC, |
|
|
|
'' AS INVEXPORTIMPORT, |
|
|
|
a.cInvAddCode as INVPARSETYPE, |
|
|
|
a.cinvdefine5 as PODetailID |
|
|
|
,'{0}' as WorkPoint, |
|
|
|
--fSupplyMulti EATTRIBUTE1, |
|
|
|
a.cInvDefine12 EATTRIBUTE1, |
|
|
|
a.cInvDefine11 EATTRIBUTE2,a.cInvDefine10 EATTRIBUTE3 |
|
|
|
INTO #TempINV |
|
|
|
FROM {1}.dbo.Inventory a |
|
|
|
left join {1}.dbo.Inventory_sub e on a.cinvcode=e.cInvSubCode |
|
|
|
LEFT JOIN {1}.dbo.InventoryClass b ON a.cInvCCode = b.cInvCCode |
|
|
|
LEFT JOIN {1}.dbo.ComputationUnit c ON a.cComUnitCode = c.cComunitCode |
|
|
|
WHERE a.dEDate IS NULL AND a.dModifyDate>=@LastTime |
|
|
|
ORDER BY cInvCode |
|
|
|
|
|
|
|
IF NOT EXISTS(SELECT * FROM #TempINV) |
|
|
|
sql += @" IF NOT EXISTS(SELECT * FROM #TempINV)
|
|
|
|
RETURN";
|
|
|
|
sql = ICSHelper.Time(Namespace, Class, WorkPoint, sql, "#TempINV"); |
|
|
|
|
|
|
|
sql += @"--删除数据
|
|
|
|
-- DELETE ICSINVENTORY WHERE InvCode NOT IN (SELECT cInvCode FROM {1}.dbo.[Inventory]) |
|
|
|
SELECT a.INVCODE INTO #tableICSINVENTORY |
|
|
|
FROM ICSINVENTORY a With(NoLock) |
|
|
|
LEFT JOIN {1}.dbo.[Inventory] b With(NoLock) ON a.INVCODE=b.cInvCode |
|
|
|
WHERE a.WorkPoint='{0}' and b.cInvCode IS NULL |
|
|
|
// sql += @"--删除数据
|
|
|
|
// -- DELETE ICSINVENTORY WHERE InvCode NOT IN (SELECT cInvCode FROM {1}.dbo.[Inventory])
|
|
|
|
//SELECT a.INVCODE INTO #tableICSINVENTORY
|
|
|
|
//FROM ICSINVENTORY a With(NoLock)
|
|
|
|
//LEFT JOIN {1}.dbo.[Inventory] b With(NoLock) ON a.INVCODE=b.cInvCode
|
|
|
|
// WHERE a.WorkPoint='{0}' and b.cInvCode IS NULL
|
|
|
|
|
|
|
|
DELETE ICSINVENTORY |
|
|
|
WHERE WorkPoint='{0}' and INVCODE IN ( SELECT INVCODE from #tableICSINVENTORY) |
|
|
|
";
|
|
|
|
// DELETE ICSINVENTORY
|
|
|
|
// WHERE WorkPoint='{0}' and INVCODE IN ( SELECT INVCODE from #tableICSINVENTORY)
|
|
|
|
// ";
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, string> values = new Dictionary<string, string>(); |
|
|
@ -121,9 +261,9 @@ LEFT JOIN {1}.dbo.[Inventory] b With(NoLock) ON a.INVCODE=b.cInvCode |
|
|
|
values.Add("OverInValue", "a.OverInValue");//超入参数
|
|
|
|
values.Add("EffectiveDays", "a.EffectiveDays");//有效期天数
|
|
|
|
values.Add("BatchEnable", "a.fInExcess");//是否启用批次
|
|
|
|
values.Add("EATTRIBUTE1", "a.EATTRIBUTE1");//最小包装量
|
|
|
|
values.Add("EATTRIBUTE2", "a.EATTRIBUTE2");//最小包装-托
|
|
|
|
values.Add("EATTRIBUTE3", "a.EATTRIBUTE3");//客户存货名称
|
|
|
|
//values.Add("EATTRIBUTE1", "a.EATTRIBUTE1");//最小包装量
|
|
|
|
//values.Add("EATTRIBUTE2", "a.EATTRIBUTE2");//最小包装-托
|
|
|
|
//values.Add("EATTRIBUTE3", "a.EATTRIBUTE3");//客户存货名称
|
|
|
|
values.Add("MTIME", "a.MTIME");//操作时间
|
|
|
|
|
|
|
|
//更新存在数据
|
|
|
@ -149,7 +289,7 @@ LEFT JOIN {1}.dbo.[Inventory] b With(NoLock) ON a.INVCODE=b.cInvCode |
|
|
|
LEFT JOIN ICSINVENTORY b ON a.INVCODE=b.INVCODE and a.WorkPoint=b.WorkPoint |
|
|
|
WHERE b.INVCODE IS NULL and a.WorkPoint='" + WorkPoint + "' ";
|
|
|
|
sql += " DROP TABLE #TempINV " + |
|
|
|
" DROP TABLE #tableICSINVENTORY "; |
|
|
|
" "; |
|
|
|
sql = string.Format(sql, WorkPoint, erpName); |
|
|
|
|
|
|
|
|
|
|
@ -162,5 +302,45 @@ LEFT JOIN {1}.dbo.[Inventory] b With(NoLock) ON a.INVCODE=b.cInvCode |
|
|
|
log.Error(ex.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class DYS |
|
|
|
{ |
|
|
|
public int pageIndex; |
|
|
|
public int pageSize; |
|
|
|
public string beganTime; |
|
|
|
public DYSs simple; |
|
|
|
|
|
|
|
} |
|
|
|
public class DYSs |
|
|
|
{ |
|
|
|
public string pubts; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class DetilBody |
|
|
|
{ |
|
|
|
public string id; |
|
|
|
public string orgId; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class InvList |
|
|
|
{ |
|
|
|
public string ID; |
|
|
|
public string WorkPointID; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |