纽威
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.

407 lines
25 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years 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 sql = @"DECLARE @Status VARCHAR(10)
  36. SELECT @Status=a.Status FROM ICSSDN a
  37. WHERE a.SDNCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='1'
  38. IF (@Status IS NULL)
  39. BEGIN
  40. RAISERROR('" + language.GetNameByCode("WMSAPIInfo139") + @"',16,1);
  41. RETURN
  42. END
  43. ELSE IF (@Status!='2')
  44. BEGIN
  45. RAISERROR('" + language.GetNameByCode("WMSAPIInfo140") + @"',16,1);
  46. RETURN
  47. END
  48. UPDATE a SET SDNQuantity=ISNULL(SDNQuantity,0)+'{2}'
  49. FROM ICSSDN a
  50. WHERE a.SDNCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='1'
  51. IF EXISTS(SELECT a.ID FROM ICSSDN a
  52. WHERE a.SDNCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Type='1' AND a.Quantity<a.SDNQuantity)
  53. BEGIN
  54. RAISERROR('" + language.GetNameByCode("WMSAPIInfo091") + @"',16,1);
  55. RETURN
  56. END";
  57. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  58. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  59. {
  60. throw new Exception(language.GetNameByCode("WMSAPIInfo141"));//"销售领料单更新失败!");
  61. }
  62. }
  63. catch (Exception)
  64. {
  65. throw;
  66. }
  67. }
  68. /// <summary>
  69. /// 销售出库接口
  70. /// </summary>
  71. /// <param name="TransType"></param>
  72. /// <param name="Identification"></param>
  73. /// <param name="cmd"></param>
  74. public static void SalesShipmentDocERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language)
  75. {
  76. try
  77. {
  78. #region ERP
  79. 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,
  80. a.InvCode,SUM(a.Quantity) AS Quantity,0 AS Amount,b.SDNDetailID,Enable AS UpdateTodoQuantity
  81. ,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand,
  82. 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
  83. INTO #TempERP
  84. FROM ICSWareHouseLotInfoLog a
  85. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  86. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  87. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.FromWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  88. INNER JOIN ICSSDN b ON a.TransCode=b.SDNCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  89. INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint
  90. WHERE a.Identification='{0}' AND ERPUpload='0' AND b.Type='1'
  91. GROUP BY b.CusCode,a.FromWarehouseCode,b.SDNCode,a.MUSER,a.InvCode,b.SDNDetailID,Enable
  92. ,a.WorkPoint,ISNULL(ext.ProjectCode, ''),CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''),
  93. 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, '')
  94. SELECT DISTINCT Costre,WorkPoint,CusCode,WarehouseCode AS WHCode,SDNCode AS SDNCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity FROM #TempERP
  95. SELECT Costre,Sequence,InvCode,Quantity,Amount,SDNDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP
  96. DROP TABLE #TempERP";
  97. sql = string.Format(sql, Identification);
  98. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  99. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  100. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.SalesDeliveryNoticeURL, Inputstr);
  101. Result result = new Result();
  102. result = JsonConvert.DeserializeObject<Result>(resultStr);
  103. if (result.Success)
  104. {
  105. try
  106. {
  107. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  108. foreach (var item in res)
  109. {
  110. JObject jo = (JObject)item;
  111. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  112. foreach (var detail in resdetail)
  113. {
  114. JObject det = (JObject)detail;
  115. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["SDNDetailID"].ToString(), Identification, jo["ID"].ToString(),
  116. det["DetailID"].ToString(), jo["SSDCode"].ToString(), det["Sequence"].ToString(), cmd, language);
  117. }
  118. }
  119. }
  120. catch (Exception ex)
  121. {
  122. log.Debug(ex.ToString());
  123. log.Debug(resultStr);
  124. }
  125. }
  126. else
  127. {
  128. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  129. }
  130. #endregion
  131. }
  132. catch (Exception)
  133. {
  134. throw;
  135. }
  136. }
  137. #endregion
  138. #region 销售退货
  139. /// <summary>
  140. /// 销售退货
  141. /// </summary>
  142. /// <param name="TransCode"></param>
  143. /// <param name="TransSequence"></param>
  144. /// <param name="Quantity"></param>
  145. /// <param name="WorkPoint"></param>
  146. /// <param name="cmd"></param>
  147. public static void SalesShipmentDocNegative(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  148. {
  149. try
  150. {
  151. string sql = @"DECLARE @Status VARCHAR(10)
  152. SELECT @Status=c.Status FROM ICSInventoryLot a
  153. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  154. INNER JOIN ICSSDN c ON b.TransCode=c.SDNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  155. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.Type='2'
  156. IF (@Status IS NULL)
  157. BEGIN
  158. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  159. RETURN
  160. END
  161. ELSE IF (@Status!='2')
  162. BEGIN
  163. RAISERROR('" + language.GetNameByCode("WMSAPIInfo142") + @"',16,1);
  164. RETURN
  165. END
  166. UPDATE c SET SDNQuantity=ISNULL(SDNQuantity,0)+'{2}'
  167. FROM ICSInventoryLot a
  168. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  169. INNER JOIN ICSSDN c ON b.TransCode=c.SDNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  170. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.Type='2'
  171. IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
  172. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  173. INNER JOIN ICSSDN c ON b.TransCode=c.SDNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  174. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.Type='2' AND c.Quantity<c.SDNQuantity)
  175. BEGIN
  176. RAISERROR('" + language.GetNameByCode("WMSAPIInfo114") + @"',16,1);
  177. END";
  178. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  179. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  180. {
  181. throw new Exception("销售退货单更新失败!");
  182. }
  183. }
  184. catch (Exception)
  185. {
  186. throw;
  187. }
  188. }
  189. /// <summary>
  190. /// 销售退货接口
  191. /// </summary>
  192. /// <param name="TransType"></param>
  193. /// <param name="Identification"></param>
  194. /// <param name="cmd"></param>
  195. public static void SalesShipmentDocNegativeERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language)
  196. {
  197. try
  198. {
  199. #region ERP
  200. 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,
  201. a.InvCode,SUM(a.Quantity) AS Quantity,0 AS Amount,c.SDNDetailID,Enable AS UpdateTodoQuantity
  202. ,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand,
  203. 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
  204. INTO #TempERP
  205. FROM ICSWareHouseLotInfoLog a
  206. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  207. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  208. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  209. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  210. INNER JOIN ICSSDN c ON b.TransCode=c.SDNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  211. INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
  212. WHERE a.Identification='{0}' AND ERPUpload='0' AND c.Type='2'
  213. GROUP BY c.CusCode,a.ToWarehouseCode,c.SDNCode,a.MUSER,a.InvCode,c.SDNDetailID,Enable
  214. ,a.WorkPoint,ISNULL(ext.ProjectCode, ''),CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''),
  215. 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, '')
  216. SELECT DISTINCT Costre,WorkPoint,CusCode,WarehouseCode AS WHCode,SDNCode AS SDNRTCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity FROM #TempERP
  217. 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
  218. DROP TABLE #TempERP";
  219. sql = string.Format(sql, Identification);
  220. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  221. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  222. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.SalesReturnBackURL, Inputstr);
  223. Result result = new Result();
  224. result = JsonConvert.DeserializeObject<Result>(resultStr);
  225. if (result.Success)
  226. {
  227. try
  228. {
  229. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  230. foreach (var item in res)
  231. {
  232. JObject jo = (JObject)item;
  233. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  234. foreach (var detail in resdetail)
  235. {
  236. JObject det = (JObject)detail;
  237. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["SDNRTDetailID"].ToString(), Identification, jo["ID"].ToString(),
  238. det["DetailID"].ToString(), jo["SDNNEGCode"].ToString(), det["Sequence"].ToString(), cmd, language);
  239. }
  240. }
  241. }
  242. catch (Exception ex)
  243. {
  244. log.Debug(ex.ToString());
  245. log.Debug(resultStr);
  246. }
  247. }
  248. else
  249. {
  250. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  251. }
  252. #endregion
  253. }
  254. catch (Exception)
  255. {
  256. throw;
  257. }
  258. }
  259. #endregion
  260. #region 销售退货-原条码
  261. /// <summary>
  262. /// 销售退货-原条码
  263. /// </summary>
  264. /// <param name="TransCode"></param>
  265. /// <param name="TransSequence"></param>
  266. /// <param name="Quantity"></param>
  267. /// <param name="WorkPoint"></param>
  268. /// <param name="cmd"></param>
  269. public static void SalesReturnBackIn(string TransCode, string TransSequence, string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  270. {
  271. try
  272. {
  273. string sql = @"DECLARE @Status VARCHAR(10)
  274. SELECT @Status=sdn.Status FROM ICSSDN sdn
  275. INNER JOIN ICSWareHouseLotInfoLog log ON sdn.WorkPoint=log.WorkPoint
  276. INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
  277. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND sdn.SDNCode='{2}' AND sdn.Sequence='{3}' AND sdn.Type='2'
  278. IF (@Status IS NULL)
  279. BEGIN
  280. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  281. RETURN
  282. END
  283. ELSE IF (@Status!='2')
  284. BEGIN
  285. RAISERROR('" + language.GetNameByCode("WMSAPIInfo142") + @"',16,1);
  286. RETURN
  287. END
  288. UPDATE sdn SET SDNQuantity=ISNULL(SDNQuantity,0)+'{2}'
  289. FROM ICSSDN sdn
  290. INNER JOIN ICSWareHouseLotInfoLog log ON sdn.WorkPoint=log.WorkPoint
  291. INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
  292. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND sdn.SDNCode='{2}' AND sdn.Sequence='{3}' AND sdn.Type='2'
  293. IF EXISTS(SELECT a.LotNo FROM ICSSDN sdn
  294. INNER JOIN ICSWareHouseLotInfoLog log ON sdn.WorkPoint=log.WorkPoint
  295. INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
  296. 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)
  297. BEGIN
  298. RAISERROR('" + language.GetNameByCode("WMSAPIInfo114") + @"',16,1);
  299. END";
  300. sql = string.Format(sql, LotNo, WorkPoint, Quantity, TransCode, TransSequence);
  301. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  302. {
  303. throw new Exception(language.GetNameByCode("WMSAPIInfo143"));//"销售退货单更新失败!");
  304. }
  305. }
  306. catch (Exception)
  307. {
  308. throw;
  309. }
  310. }
  311. /// <summary>
  312. /// 销售退货-原条码接口
  313. /// </summary>
  314. /// <param name="TransType"></param>
  315. /// <param name="Identification"></param>
  316. /// <param name="cmd"></param>
  317. public static void SalesReturnBackInERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language)
  318. {
  319. try
  320. {
  321. #region ERP
  322. 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,
  323. a.InvCode,SUM(a.Quantity) AS Quantity,0 AS Amount,c.SDNDetailID,Enable AS UpdateTodoQuantity
  324. ,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand,
  325. 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
  326. INTO #TempERP
  327. FROM ICSWareHouseLotInfoLog a
  328. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  329. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  330. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  331. INNER JOIN ICSSDN c ON a.TransCode=c.SDNCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  332. INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
  333. WHERE a.Identification='{0}' AND ERPUpload='0' AND c.Type='2'
  334. GROUP BY c.CusCode,a.ToWarehouseCode,c.SDNCode,a.MUSER,a.InvCode,c.SDNDetailID,Enable
  335. ,a.WorkPoint,ISNULL(ext.ProjectCode, ''),CASE WHEN ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''),
  336. 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, '')
  337. SELECT DISTINCT Costre,WorkPoint,CusCode,WarehouseCode AS WHCode,SDNCode AS SDNRTCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity FROM #TempERP
  338. 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
  339. DROP TABLE #TempERP";
  340. sql = string.Format(sql, Identification);
  341. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  342. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  343. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.SalesReturnBackURL, Inputstr);
  344. Result result = new Result();
  345. result = JsonConvert.DeserializeObject<Result>(resultStr);
  346. if (result.Success)
  347. {
  348. try
  349. {
  350. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  351. foreach (var item in res)
  352. {
  353. JObject jo = (JObject)item;
  354. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  355. foreach (var detail in resdetail)
  356. {
  357. JObject det = (JObject)detail;
  358. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["SDNRTDetailID"].ToString(), Identification, jo["ID"].ToString(),
  359. det["DetailID"].ToString(), jo["SDNNEGCode"].ToString(), det["Sequence"].ToString(), cmd, language);
  360. }
  361. }
  362. }
  363. catch (Exception ex)
  364. {
  365. log.Debug(ex.ToString());
  366. log.Debug(resultStr);
  367. }
  368. }
  369. else
  370. {
  371. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  372. }
  373. #endregion
  374. }
  375. catch (Exception)
  376. {
  377. throw;
  378. }
  379. }
  380. #endregion
  381. }
  382. }