You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

684 lines
46 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 months ago
1 year ago
2 months ago
1 year ago
2 months ago
1 year ago
2 months ago
1 year ago
2 months ago
1 year ago
  1. using ICSSoft.Common;
  2. using ICSSoft.Entity;
  3. using Newtonsoft.Json;
  4. using Newtonsoft.Json.Linq;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Data.SqlClient;
  9. using System.Linq;
  10. using System.Net.Http;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace ICSSoft.DataProject
  14. {
  15. /// <summary>
  16. /// 使用中
  17. /// 销售模块
  18. /// </summary>
  19. public class ICSSalesService
  20. {
  21. private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  22. #region 销售出库
  23. /// <summary>
  24. /// 销售出库
  25. /// </summary>
  26. /// <param name="TransCode"></param>
  27. /// <param name="TransSequence"></param>
  28. /// <param name="Quantity"></param>
  29. /// <param name="WorkPoint"></param>
  30. /// <param name="cmd"></param>
  31. public static void SalesShipmentDoc(string TransCode, string TransSequence, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  32. {
  33. try
  34. {
  35. //string chekksql = @"select c.EATTRIBUTE1 FROM ICSSDN a
  36. // INNER JOIN ICSInventory c on a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  37. // WHERE a.Sequence='{2}' AND a.SDNCode='{0}' AND a.WorkPoint='{1}' and c.AmountEnable='1'";
  38. //chekksql = string.Format(chekksql, TransCode, WorkPoint, TransSequence);
  39. //DataTable dta = DBHelper.SQlReturnData(chekksql, cmd);
  40. //if (dta.Rows.Count > 0)
  41. //{
  42. // Quantity = (decimal.Parse(Quantity) * decimal.Parse(dta.Rows[0]["EATTRIBUTE1"].ToString())).ToString();
  43. //}
  44. string sql = @"DECLARE @Status VARCHAR(10)
  45. SELECT @Status=a.Status FROM ICSSDN a
  46. WHERE a.SDNCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='1'
  47. IF (@Status IS NULL)
  48. BEGIN
  49. RAISERROR('" + language.GetNameByCode("WMSAPIInfo139") + @"',16,1);
  50. RETURN
  51. END
  52. ELSE IF (@Status!='2')
  53. BEGIN
  54. RAISERROR('" + language.GetNameByCode("WMSAPIInfo140") + @"',16,1);
  55. RETURN
  56. END
  57. UPDATE a SET SDNQuantity=ISNULL(SDNQuantity,0)+'{2}'
  58. FROM ICSSDN a
  59. WHERE a.SDNCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='1'
  60. IF EXISTS(SELECT a.ID FROM ICSSDN a
  61. WHERE a.SDNCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Type='1' AND a.Quantity<a.SDNQuantity)
  62. BEGIN
  63. RAISERROR('" + language.GetNameByCode("WMSAPIInfo091") + @"',16,1);
  64. RETURN
  65. END";
  66. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  67. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  68. {
  69. throw new Exception(language.GetNameByCode("WMSAPIInfo141"));//"销售领料单更新失败!");
  70. }
  71. }
  72. catch (Exception)
  73. {
  74. throw;
  75. }
  76. }
  77. /// <summary>
  78. /// 销售出库
  79. /// </summary>
  80. /// <param name="TransCode"></param>
  81. /// <param name="TransSequence"></param>
  82. /// <param name="Quantity"></param>
  83. /// <param name="WorkPoint"></param>
  84. /// <param name="cmd"></param>
  85. public static void AMSalesShipmentDoc(string TransCode, string TransSequence, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  86. {
  87. try
  88. {
  89. //string chekksql = @"select c.EATTRIBUTE1 FROM ICSSDN a
  90. // INNER JOIN ICSInventory c on a.InvCode=c.InvCode and a.WorkPoint=c.WorkPoint
  91. // WHERE a.Sequence='{2}' AND a.SDNCode='{0}' AND a.WorkPoint='{1}' and c.AmountEnable='1'";
  92. //chekksql = string.Format(chekksql, TransCode, WorkPoint, TransSequence);
  93. //DataTable dta = DBHelper.SQlReturnData(chekksql, cmd);
  94. //if (dta.Rows.Count > 0)
  95. //{
  96. // Quantity = (decimal.Parse(Quantity) * decimal.Parse(dta.Rows[0]["EATTRIBUTE1"].ToString())).ToString();
  97. //}
  98. string sql = @"DECLARE @Status VARCHAR(10)
  99. SELECT @Status=a.Status FROM ICSSDN a
  100. WHERE a.SDNCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='1'
  101. IF (@Status IS NULL)
  102. BEGIN
  103. RAISERROR('" + language.GetNameByCode("WMSAPIInfo139") + @"',16,1);
  104. RETURN
  105. END
  106. ELSE IF (@Status!='2')
  107. BEGIN
  108. RAISERROR('" + language.GetNameByCode("WMSAPIInfo140") + @"',16,1);
  109. RETURN
  110. END
  111. UPDATE a SET SDNQuantity=ISNULL(SDNQuantity,0)+'{2}'
  112. FROM ICSSDN a
  113. WHERE a.SDNCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='1'
  114. IF EXISTS(SELECT a.ID FROM ICSSDN a
  115. WHERE a.SDNCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Type='1' AND a.Quantity<a.SDNQuantity)
  116. BEGIN
  117. RAISERROR('" + language.GetNameByCode("WMSAPIInfo091") + @"',16,1);
  118. RETURN
  119. END";
  120. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  121. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  122. {
  123. throw new Exception(language.GetNameByCode("WMSAPIInfo141"));//"销售领料单更新失败!");
  124. }
  125. }
  126. catch (Exception)
  127. {
  128. throw;
  129. }
  130. }
  131. /// <summary>
  132. /// 销售出库接口
  133. /// </summary>
  134. /// <param name="TransType"></param>
  135. /// <param name="Identification"></param>
  136. /// <param name="cmd"></param>
  137. public static void SalesShipmentDocERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language,string BusinessCode)
  138. {
  139. try
  140. {
  141. #region ERP
  142. string sql = @"DECLARE @quantity DECIMAL(38,4);
  143. DECLARE @sdnquantity DECIMAL(38,4);
  144. SELECT @quantity=SUM(Quantity),@sdnquantity=SUM(SDNQuantity) FROM ICSSDN b
  145. WHERE b.SDNCode+b.WorkPoint IN (SELECT a.TransCode+a.WorkPoint FROM ICSWareHouseLotInfoLog a WHERE a.Identification='{0}')
  146. IF (@quantity<>@sdnquantity)
  147. BEGIN
  148. RAISERROR('',16,1);
  149. RETURN
  150. END
  151. SELECT b.CusCode+a.FromWarehouseCode+b.SDNCode+a.MUSER AS Costre,b.CusCode,a.FromWarehouseCode AS WarehouseCode,b.SDNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY b.CusCode,a.FromWarehouseCode,b.SDNCode,b.SDNDetailID,a.InvCode) AS Sequence,
  152. a.InvCode,SUM(a.Quantity) AS Quantity,CASE inv.AmountEnable WHEN '1' THEN SUM(a.Quantity*(b.Amount/b.Quantity)) ELSE '0' END AS Amount, b.SDNDetailID,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock
  153. ,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand,
  154. ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10
  155. INTO #TempERP
  156. FROM ICSWareHouseLotInfoLog a
  157. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  158. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  159. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  160. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.FromWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  161. INNER JOIN ICSSDN b ON a.TransCode=b.SDNCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  162. INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint
  163. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock005' AND a.WorkPoint=conStock.WorkPoint
  164. WHERE a.Identification='{0}' AND ERPUpload='0' AND b.Type='1' AND a.BusinessCode = '19'
  165. GROUP BY inv.AmountEnable,b.CusCode,a.FromWarehouseCode,b.SDNCode,a.MUSER,a.InvCode,b.SDNDetailID,con.Enable,conStock.Enable
  166. ,a.WorkPoint,ISNULL(ext.ProjectCode, ''),CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''),
  167. ISNULL(ext.cFree1, ''),ISNULL(ext.cFree2, ''),ISNULL(ext.cFree3, ''),ISNULL(ext.cFree4, ''),ISNULL(ext.cFree5, ''),ISNULL(ext.cFree6, ''),ISNULL(ext.cFree7, ''),ISNULL(ext.cFree8, ''),ISNULL(ext.cFree9, ''),ISNULL(ext.cFree10, '')
  168. SELECT DISTINCT Costre,WorkPoint,CusCode,WarehouseCode AS WHCode,SDNCode AS SDNCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,UpdateStock FROM #TempERP
  169. SELECT Costre,Sequence,InvCode,Quantity,Amount,SDNDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP
  170. DROP TABLE #TempERP";
  171. sql = string.Format(sql, Identification);
  172. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  173. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  174. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.SalesDeliveryNoticeURL, Inputstr);
  175. Result result = new Result();
  176. result = JsonConvert.DeserializeObject<Result>(resultStr);
  177. if (result.Success)
  178. {
  179. try
  180. {
  181. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  182. foreach (var item in res)
  183. {
  184. JObject jo = (JObject)item;
  185. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  186. foreach (var detail in resdetail)
  187. {
  188. JObject det = (JObject)detail;
  189. string allcol = jo["WHCode"].ToString() + det["ProjectCode"].ToString() + det["cBatch"].ToString() + det["version"].ToString() + det["brand"].ToString() + det["cFree1"].ToString() + det["cFree2"].ToString() + det["cFree3"].ToString() + det["cFree4"].ToString() + det["cFree5"].ToString()
  190. + det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString();
  191. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["SDNDetailID"].ToString(), Identification, jo["ID"].ToString(),
  192. det["DetailID"].ToString(), jo["SSDCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language,BusinessCode);
  193. }
  194. }
  195. }
  196. catch (Exception ex)
  197. {
  198. log.Debug(ex.ToString());
  199. log.Debug(resultStr);
  200. }
  201. }
  202. else
  203. {
  204. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  205. }
  206. #endregion
  207. }
  208. catch (Exception)
  209. {
  210. throw;
  211. }
  212. }
  213. public static void U9SalesShipmentDocERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
  214. {
  215. try
  216. {
  217. #region ERP
  218. string sql = @"SELECT b.CusCode+a.FromWarehouseCode+b.SDNCode+a.MUSER AS Costre,b.CusCode,a.FromWarehouseCode AS WarehouseCode,b.SDNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY b.CusCode,a.FromWarehouseCode,b.SDNCode,b.SDNDetailID,a.InvCode) AS Sequence,
  219. a.InvCode,SUM(a.Quantity) AS Quantity,CASE inv.AmountEnable WHEN '1' THEN SUM(a.Quantity*(b.Amount/b.Quantity)) ELSE '0' END AS Amount, b.SDNDetailID,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock
  220. ,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand,
  221. ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10 ,b.SOCode,b.SOSequence as SrcDocSubLineNo
  222. INTO #TempERP
  223. FROM ICSWareHouseLotInfoLog a
  224. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  225. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  226. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  227. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.FromWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  228. INNER JOIN ICSSDN b ON a.TransCode=b.SDNCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  229. INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint
  230. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock005' AND a.WorkPoint=conStock.WorkPoint
  231. WHERE a.Identification='{0}' AND ERPUpload='0' AND b.Type='1' AND a.BusinessCode = '19'
  232. GROUP BY inv.AmountEnable,b.CusCode,a.FromWarehouseCode,b.SDNCode,a.MUSER,a.InvCode,b.SDNDetailID,con.Enable,conStock.Enable
  233. ,a.WorkPoint,ISNULL(ext.ProjectCode, ''),CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''),
  234. ISNULL(ext.cFree1, ''),ISNULL(ext.cFree2, ''),ISNULL(ext.cFree3, ''),ISNULL(ext.cFree4, ''),ISNULL(ext.cFree5, ''),ISNULL(ext.cFree6, ''),ISNULL(ext.cFree7, ''),ISNULL(ext.cFree8, ''),ISNULL(ext.cFree9, ''),ISNULL(ext.cFree10, ''),b.SOCode,b.SOSequence
  235. SELECT DISTINCT Costre,WorkPoint,CusCode,WarehouseCode AS WHCode,SOCode AS SDNCode,SrcDocSubLineNo,MUSER AS [User],SYSDATETIME() AS ShipDate,'ST1' as ShipDocTypeCode ,cast(0 as bit) as SOIsConsign,UpdateTodoQuantity,UpdateStock,InvCode,Quantity,Amount,SDNDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP
  236. DROP TABLE #TempERP";
  237. sql = string.Format(sql, Identification);
  238. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  239. string Inputstr = DataToJsonHelper.ToJson(ds.Tables[0]);
  240. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.U9SalesShipDocURL, Inputstr);
  241. Result result = new Result();
  242. result = JsonConvert.DeserializeObject<Result>(resultStr);
  243. if (result.Success)
  244. {
  245. try
  246. {
  247. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  248. foreach (var item in res)
  249. {
  250. JObject jo = (JObject)item;
  251. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  252. foreach (var detail in resdetail)
  253. {
  254. JObject det = (JObject)detail;
  255. string allcol = jo["WHCode"].ToString() + det["ProjectCode"].ToString() + det["cBatch"].ToString() + det["version"].ToString() + det["brand"].ToString() + det["cFree1"].ToString() + det["cFree2"].ToString() + det["cFree3"].ToString() + det["cFree4"].ToString() + det["cFree5"].ToString()
  256. + det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString();
  257. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["SDNDetailID"].ToString(), Identification, jo["ID"].ToString(),
  258. det["DetailID"].ToString(), jo["SSDCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode);
  259. }
  260. }
  261. }
  262. catch (Exception ex)
  263. {
  264. log.Debug(ex.ToString());
  265. log.Debug(resultStr);
  266. }
  267. }
  268. else
  269. {
  270. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  271. }
  272. #endregion
  273. }
  274. catch (Exception)
  275. {
  276. throw;
  277. }
  278. }
  279. #endregion
  280. #region 销售退货
  281. /// <summary>
  282. /// 销售退货
  283. /// </summary>
  284. /// <param name="TransCode"></param>
  285. /// <param name="TransSequence"></param>
  286. /// <param name="Quantity"></param>
  287. /// <param name="WorkPoint"></param>
  288. /// <param name="cmd"></param>
  289. public static void SalesShipmentDocNegative(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  290. {
  291. try
  292. {
  293. string sql = @"DECLARE @Status VARCHAR(10)
  294. SELECT @Status=c.Status FROM ICSInventoryLot a
  295. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  296. INNER JOIN ICSSDN c ON b.TransCode=c.SDNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  297. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.Type='2'
  298. IF (@Status IS NULL)
  299. BEGIN
  300. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  301. RETURN
  302. END
  303. ELSE IF (@Status!='2')
  304. BEGIN
  305. RAISERROR('" + language.GetNameByCode("WMSAPIInfo142") + @"',16,1);
  306. RETURN
  307. END
  308. UPDATE c SET SDNQuantity=ISNULL(SDNQuantity,0)+'{2}'
  309. FROM ICSInventoryLot a
  310. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  311. INNER JOIN ICSSDN c ON b.TransCode=c.SDNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  312. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.Type='2'
  313. IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
  314. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  315. INNER JOIN ICSSDN c ON b.TransCode=c.SDNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  316. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.Type='2' AND c.Quantity<c.SDNQuantity)
  317. BEGIN
  318. RAISERROR('" + language.GetNameByCode("WMSAPIInfo114") + @"',16,1);
  319. END";
  320. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  321. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  322. {
  323. throw new Exception("销售退货单更新失败!");
  324. }
  325. }
  326. catch (Exception)
  327. {
  328. throw;
  329. }
  330. }
  331. public static void SalesShipmentOutRedDocNegative(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  332. {
  333. try
  334. {
  335. string sql = @"DECLARE @Status VARCHAR(10)
  336. SELECT @Status=c.Status FROM ICSInventoryLot a
  337. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  338. INNER JOIN ICSSSD c ON b.TransCode=c.SSDCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  339. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  340. IF (@Status IS NULL)
  341. BEGIN
  342. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  343. RETURN
  344. END
  345. UPDATE c SET SSDQuantity=ISNULL(SSDQuantity,0)+'{2}'
  346. FROM ICSInventoryLot a
  347. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  348. INNER JOIN ICSSSD c ON b.TransCode=c.SSDCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  349. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' ";
  350. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  351. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  352. {
  353. throw new Exception("销售出库单更新失败!");
  354. }
  355. }
  356. catch (Exception)
  357. {
  358. throw;
  359. }
  360. }
  361. /// <summary>
  362. /// 销售退货接口
  363. /// </summary>
  364. /// <param name="TransType"></param>
  365. /// <param name="Identification"></param>
  366. /// <param name="cmd"></param>
  367. public static void SalesShipmentDocNegativeERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language,string BusinessCode)
  368. {
  369. try
  370. {
  371. #region ERP
  372. string sql = @"SELECT c.CusCode+a.ToWarehouseCode+c.SDNCode+a.MUSER AS Costre,c.CusCode,a.ToWarehouseCode AS WarehouseCode,c.SDNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.CusCode,a.ToWarehouseCode,c.SDNCode,c.SDNDetailID,a.InvCode) AS Sequence,
  373. a.InvCode,SUM(a.Quantity) AS Quantity,CASE inv.AmountEnable WHEN '1' THEN SUM(a.Quantity*(lot.Amount/lot.Quantity)) ELSE '0' END AS Amount,c.SDNDetailID,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock
  374. ,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand,
  375. ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10
  376. INTO #TempERP
  377. FROM ICSWareHouseLotInfoLog a
  378. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  379. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  380. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  381. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  382. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  383. INNER JOIN ICSSDN c ON b.TransCode=c.SDNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  384. INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
  385. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock005' AND a.WorkPoint=conStock.WorkPoint
  386. WHERE a.Identification='{0}' AND ERPUpload='0' AND c.Type='2' AND BusinessCode='{1}'
  387. GROUP BY inv.AmountEnable,c.CusCode,a.ToWarehouseCode,c.SDNCode,a.MUSER,a.InvCode,c.SDNDetailID,con.Enable,conStock.Enable
  388. ,a.WorkPoint,ISNULL(ext.ProjectCode, ''),CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''),
  389. ISNULL(ext.cFree1, ''),ISNULL(ext.cFree2, ''),ISNULL(ext.cFree3, ''),ISNULL(ext.cFree4, ''),ISNULL(ext.cFree5, ''),ISNULL(ext.cFree6, ''),ISNULL(ext.cFree7, ''),ISNULL(ext.cFree8, ''),ISNULL(ext.cFree9, ''),ISNULL(ext.cFree10, '')
  390. SELECT DISTINCT Costre,WorkPoint,CusCode,WarehouseCode AS WHCode,SDNCode AS SDNRTCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,UpdateStock FROM #TempERP
  391. SELECT Costre,Sequence,InvCode,Quantity,Amount,SDNDetailID AS SDNRTDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP
  392. DROP TABLE #TempERP";
  393. sql = string.Format(sql, Identification,BusinessCode);
  394. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  395. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  396. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.SalesReturnBackURL, Inputstr);
  397. Result result = new Result();
  398. result = JsonConvert.DeserializeObject<Result>(resultStr);
  399. if (result.Success)
  400. {
  401. try
  402. {
  403. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  404. foreach (var item in res)
  405. {
  406. JObject jo = (JObject)item;
  407. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  408. foreach (var detail in resdetail)
  409. {
  410. JObject det = (JObject)detail;
  411. string allcol = jo["WHCode"].ToString() + det["ProjectCode"].ToString() + det["cBatch"].ToString() + det["version"].ToString() + det["brand"].ToString() + det["cFree1"].ToString() + det["cFree2"].ToString() + det["cFree3"].ToString() + det["cFree4"].ToString() + det["cFree5"].ToString()
  412. + det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString();
  413. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["SDNRTDetailID"].ToString(), Identification, jo["ID"].ToString(),
  414. det["DetailID"].ToString(), jo["SDNNEGCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode);
  415. }
  416. }
  417. }
  418. catch (Exception ex)
  419. {
  420. log.Debug(ex.ToString());
  421. log.Debug(resultStr);
  422. }
  423. }
  424. else
  425. {
  426. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  427. }
  428. #endregion
  429. }
  430. catch (Exception)
  431. {
  432. throw;
  433. }
  434. }
  435. #endregion
  436. #region 销售退货-原条码
  437. /// <summary>
  438. /// 销售退货-原条码
  439. /// </summary>
  440. /// <param name="TransCode"></param>
  441. /// <param name="TransSequence"></param>
  442. /// <param name="Quantity"></param>
  443. /// <param name="WorkPoint"></param>
  444. /// <param name="cmd"></param>
  445. public static void SalesReturnBackIn(string TransCode, string TransSequence, string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  446. {
  447. try
  448. {
  449. string sql = @"DECLARE @Status VARCHAR(10)
  450. SELECT @Status=sdn.Status FROM ICSSDN sdn
  451. INNER JOIN ICSWareHouseLotInfoLog log ON sdn.WorkPoint=log.WorkPoint
  452. INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
  453. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND sdn.SDNCode='{2}' AND sdn.Sequence='{3}' AND sdn.Type='2'
  454. IF (@Status IS NULL)
  455. BEGIN
  456. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  457. RETURN
  458. END
  459. ELSE IF (@Status!='2')
  460. BEGIN
  461. RAISERROR('" + language.GetNameByCode("WMSAPIInfo142") + @"',16,1);
  462. RETURN
  463. END
  464. UPDATE sdn SET SDNQuantity=ISNULL(SDNQuantity,0)+'{4}'
  465. FROM ICSSDN sdn
  466. INNER JOIN ICSWareHouseLotInfoLog log ON sdn.WorkPoint=log.WorkPoint
  467. INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
  468. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND sdn.SDNCode='{2}' AND sdn.Sequence='{3}' AND sdn.Type='2'
  469. IF EXISTS(SELECT a.LotNo FROM ICSSDN sdn
  470. INNER JOIN ICSWareHouseLotInfoLog log ON sdn.WorkPoint=log.WorkPoint
  471. INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
  472. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND sdn.SDNCode='{2}' AND sdn.Sequence='{3}' AND sdn.Type='2' AND sdn.Quantity<sdn.SDNQuantity)
  473. BEGIN
  474. RAISERROR('" + language.GetNameByCode("WMSAPIInfo114") + @"',16,1);
  475. END";
  476. sql = string.Format(sql, LotNo, WorkPoint, TransCode, TransSequence, Quantity);
  477. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  478. {
  479. throw new Exception(language.GetNameByCode("WMSAPIInfo143"));//"销售退货单更新失败!");
  480. }
  481. }
  482. catch (Exception)
  483. {
  484. throw;
  485. }
  486. }
  487. /// <summary>
  488. /// 销售退货-原条码接口
  489. /// </summary>
  490. /// <param name="TransType"></param>
  491. /// <param name="Identification"></param>
  492. /// <param name="cmd"></param>
  493. public static void SalesReturnBackInERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language,string BusinessCode)
  494. {
  495. try
  496. {
  497. #region ERP
  498. string sql = @"SELECT c.CusCode+a.ToWarehouseCode+c.SDNCode+a.MUSER AS Costre,c.CusCode,a.ToWarehouseCode AS WarehouseCode,c.SDNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.CusCode,a.ToWarehouseCode,c.SDNCode,c.SDNDetailID,a.InvCode) AS Sequence,
  499. a.InvCode,SUM(a.Quantity) AS Quantity,CASE inv.AmountEnable WHEN '1' THEN SUM(a.Quantity*(lot.Amount/lot.Quantity)) ELSE '0' END AS Amount,c.SDNDetailID,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock
  500. ,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand,
  501. ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10
  502. INTO #TempERP
  503. FROM ICSWareHouseLotInfoLog a
  504. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  505. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  506. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  507. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  508. INNER JOIN ICSSDN c ON a.TransCode=c.SDNCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  509. INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
  510. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock005' AND a.WorkPoint=conStock.WorkPoint
  511. WHERE a.Identification='{0}' AND ERPUpload='0' AND c.Type='2' AND BusinessCode='{1}'
  512. GROUP BY inv.AmountEnable,c.CusCode,a.ToWarehouseCode,c.SDNCode,a.MUSER,a.InvCode,c.SDNDetailID,con.Enable,conStock.Enable
  513. ,a.WorkPoint,ISNULL(ext.ProjectCode, ''),CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''),
  514. ISNULL(ext.cFree1, ''),ISNULL(ext.cFree2, ''),ISNULL(ext.cFree3, ''),ISNULL(ext.cFree4, ''),ISNULL(ext.cFree5, ''),ISNULL(ext.cFree6, ''),ISNULL(ext.cFree7, ''),ISNULL(ext.cFree8, ''),ISNULL(ext.cFree9, ''),ISNULL(ext.cFree10, '')
  515. SELECT DISTINCT Costre,WorkPoint,CusCode,WarehouseCode AS WHCode,SDNCode AS SDNRTCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,UpdateStock FROM #TempERP
  516. SELECT Costre,Sequence,InvCode,Quantity,Amount,SDNDetailID AS SDNRTDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP
  517. DROP TABLE #TempERP";
  518. sql = string.Format(sql, Identification,BusinessCode);
  519. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  520. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  521. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.SalesReturnBackURL, Inputstr);
  522. Result result = new Result();
  523. result = JsonConvert.DeserializeObject<Result>(resultStr);
  524. if (result.Success)
  525. {
  526. try
  527. {
  528. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  529. foreach (var item in res)
  530. {
  531. JObject jo = (JObject)item;
  532. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  533. foreach (var detail in resdetail)
  534. {
  535. JObject det = (JObject)detail;
  536. string allcol = jo["WHCode"].ToString() + det["ProjectCode"].ToString() + det["cBatch"].ToString() + det["version"].ToString() + det["brand"].ToString() + det["cFree1"].ToString() + det["cFree2"].ToString() + det["cFree3"].ToString() + det["cFree4"].ToString() + det["cFree5"].ToString()
  537. + det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString();
  538. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["SDNRTDetailID"].ToString(), Identification, jo["ID"].ToString(),
  539. det["DetailID"].ToString(), jo["SDNNEGCode"].ToString(), det["Sequence"].ToString(), allcol,cmd, language, BusinessCode);
  540. }
  541. }
  542. }
  543. catch (Exception ex)
  544. {
  545. log.Debug(ex.ToString());
  546. log.Debug(resultStr);
  547. }
  548. }
  549. else
  550. {
  551. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  552. }
  553. #endregion
  554. }
  555. catch (Exception)
  556. {
  557. throw;
  558. }
  559. }
  560. /// <summary>
  561. /// 销售出库-红字出库单接口
  562. /// </summary>
  563. /// <param name="TransType"></param>
  564. /// <param name="Identification"></param>
  565. /// <param name="cmd"></param>
  566. public static void SalesShipmentDocOutRedERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
  567. {
  568. try
  569. {
  570. #region ERP
  571. string sql = @"SELECT c.CusCode+a.ToWarehouseCode+c.SSDCode+a.MUSER AS Costre,c.CusCode,a.ToWarehouseCode AS WarehouseCode,c.SSDCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.CusCode,a.ToWarehouseCode,c.SSDCode,c.SSDDetailID,a.InvCode) AS Sequence,
  572. a.InvCode,SUM(a.Quantity) AS Quantity,CASE inv.AmountEnable WHEN '1' THEN SUM(a.Quantity*(lot.Amount/lot.Quantity)) ELSE '0' END AS Amount,c.SSDDetailID,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock
  573. ,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand,
  574. ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10
  575. INTO #TempERP
  576. FROM ICSWareHouseLotInfoLog a
  577. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  578. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  579. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  580. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  581. INNER JOIN ICSSSD c ON a.TransCode=c.SSDCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  582. INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
  583. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock005' AND a.WorkPoint=conStock.WorkPoint
  584. WHERE a.Identification='{0}' AND ERPUpload='0' AND c.Type='2' AND BusinessCode='{1}'
  585. GROUP BY inv.AmountEnable,c.CusCode,a.ToWarehouseCode,c.SSDCode,a.MUSER,a.InvCode,c.SSDDetailID,con.Enable,conStock.Enable
  586. ,a.WorkPoint,ISNULL(ext.ProjectCode, ''),CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''),
  587. ISNULL(ext.cFree1, ''),ISNULL(ext.cFree2, ''),ISNULL(ext.cFree3, ''),ISNULL(ext.cFree4, ''),ISNULL(ext.cFree5, ''),ISNULL(ext.cFree6, ''),ISNULL(ext.cFree7, ''),ISNULL(ext.cFree8, ''),ISNULL(ext.cFree9, ''),ISNULL(ext.cFree10, '')
  588. SELECT DISTINCT Costre,WorkPoint,CusCode,WarehouseCode AS WHCode,SSDCode AS SDNCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,UpdateStock FROM #TempERP
  589. SELECT Costre,Sequence,InvCode,Quantity,Amount,SSDDetailID AS SDNDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP
  590. DROP TABLE #TempERP";
  591. sql = string.Format(sql, Identification, BusinessCode);
  592. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  593. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  594. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.SalesReturnBackURL, Inputstr);
  595. Result result = new Result();
  596. result = JsonConvert.DeserializeObject<Result>(resultStr);
  597. if (result.Success)
  598. {
  599. try
  600. {
  601. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  602. foreach (var item in res)
  603. {
  604. JObject jo = (JObject)item;
  605. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  606. foreach (var detail in resdetail)
  607. {
  608. JObject det = (JObject)detail;
  609. string allcol = jo["WHCode"].ToString() + det["ProjectCode"].ToString() + det["cBatch"].ToString() + det["version"].ToString() + det["brand"].ToString() + det["cFree1"].ToString() + det["cFree2"].ToString() + det["cFree3"].ToString() + det["cFree4"].ToString() + det["cFree5"].ToString()
  610. + det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString();
  611. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["SDNRTDetailID"].ToString(), Identification, jo["ID"].ToString(),
  612. det["DetailID"].ToString(), jo["SDNNEGCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode);
  613. }
  614. }
  615. }
  616. catch (Exception ex)
  617. {
  618. log.Debug(ex.ToString());
  619. log.Debug(resultStr);
  620. }
  621. }
  622. else
  623. {
  624. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  625. }
  626. #endregion
  627. }
  628. catch (Exception)
  629. {
  630. throw;
  631. }
  632. }
  633. #endregion
  634. }
  635. }