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

735 lines
45 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
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
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 ICSPurchaseService
  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="TransType"></param>
  27. /// <param name="Identification"></param>
  28. /// <param name="cmd"></param>
  29. public static void DeliveryNoticeERP(string DNCode, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  30. {
  31. try
  32. {
  33. #region ERP
  34. string sql = @"SELECT a.VenCode+a.DepCode+y.POCode+a.MUSER AS Costre,a.VenCode,a.DepCode,y.POCode,a.MUSER,a.MTIME,
  35. a.Sequence,a.InvCode,a.Quantity,a.Amount,ISNULL(a.UnitPrice,0) AS UnitPrice,a.Currency,a.PODetailID
  36. ,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,
  37. 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
  38. INTO #TempERP
  39. FROM ICSDeliveryNotice a
  40. INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint
  41. LEFT JOIN ICSInventory invBat ON a.InvCode=invBat.InvCode AND a.WorkPoint=invBat.WorkPoint
  42. INNER JOIN ICSPurchaseOrder y ON a.PODetailID=y.PODetailID AND a.WorkPoint=y.WorkPoint
  43. WHERE a.DNCode='{0}' AND a.WorkPoint='{1}'
  44. SELECT DISTINCT Costre,WorkPoint,VenCode,DepCode,POCode,MUSER AS [User],SYSDATETIME() AS MTime FROM #TempERP
  45. SELECT Costre,Sequence,InvCode,Quantity,Amount,UnitPrice,Currency,PODetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
  46. FROM #TempERP
  47. DROP TABLE #TempERP";
  48. sql = string.Format(sql, DNCode, WorkPoint);
  49. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  50. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  51. string resultStr = HTTPHelper.HttpPost("采购到货", ERPUrl.CreatePOArrivURL, Inputstr);
  52. Result result = new Result();
  53. result = JsonConvert.DeserializeObject<Result>(resultStr);
  54. if (result.Success)
  55. {
  56. try
  57. {
  58. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  59. foreach (var item in res)
  60. {
  61. JObject jo = (JObject)item;
  62. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  63. foreach (var detail in resdetail)
  64. {
  65. JObject det = (JObject)detail;
  66. string ERPupdate = @"update ICSDeliveryNotice set DNCode='{0}',Sequence='{1}',DNID='{2}',DNDetailID='{3}'
  67. where PODetailID='{4}' AND DNType='1' AND DNCode='{5}' ";
  68. ERPupdate = string.Format(ERPupdate, jo["DNCode"], det["Sequence"], jo["ID"], det["DetailID"], det["PODetailID"],DNCode);
  69. if (!DBHelper.ExecuteNonQuery(ERPupdate, cmd))
  70. {
  71. throw new Exception(language.GetNameByCode("WMSAPIInfo079"));//"到货单更新失败!");
  72. }
  73. }
  74. }
  75. }
  76. catch (Exception ex)
  77. {
  78. log.Debug(ex.ToString());
  79. log.Debug(resultStr);
  80. }
  81. }
  82. else
  83. {
  84. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  85. }
  86. #endregion
  87. }
  88. catch (Exception)
  89. {
  90. throw;
  91. }
  92. }
  93. #endregion
  94. #region 采购入库
  95. /// <summary>
  96. /// 采购入库
  97. /// </summary>
  98. /// <param name="TransCode"></param>
  99. /// <param name="TransSequence"></param>
  100. /// <param name="Quantity"></param>
  101. /// <param name="WorkPoint"></param>
  102. /// <param name="cmd"></param>
  103. public static void PurchaseReceiveDoc(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  104. {
  105. try
  106. {
  107. string sql = @"DECLARE @Status VARCHAR(10)
  108. SELECT @Status=c.Status FROM ICSInventoryLot a
  109. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  110. INNER JOIN ICSPurchaseOrder c ON b.TransCode=c.POCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  111. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  112. IF (@Status IS NULL)
  113. BEGIN
  114. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  115. RETURN
  116. END
  117. ELSE IF (@Status='3')
  118. BEGIN
  119. RAISERROR('" + language.GetNameByCode("WMSAPIInfo082") + @"',16,1);
  120. RETURN
  121. END
  122. UPDATE c SET InQuantity=ISNULL(InQuantity,0)+'{2}'
  123. FROM ICSInventoryLot a
  124. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  125. INNER JOIN ICSPurchaseOrder c ON b.TransCode=c.POCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  126. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  127. IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
  128. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  129. INNER JOIN ICSPurchaseOrder c ON b.TransCode=c.POCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  130. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.Quantity<c.InQuantity)
  131. BEGIN
  132. RAISERROR('" + language.GetNameByCode("WMSAPIInfo083") + @"',16,1);
  133. END";
  134. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  135. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  136. {
  137. throw new Exception(language.GetNameByCode("WMSAPIInfo104"));//"采购入库单更新失败!");
  138. }
  139. }
  140. catch (Exception)
  141. {
  142. throw;
  143. }
  144. }
  145. /// <summary>
  146. /// 采购入库接口
  147. /// </summary>
  148. /// <param name="TransType"></param>
  149. /// <param name="Identification"></param>
  150. /// <param name="cmd"></param>
  151. public static void PurchaseReceiveDocERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language)
  152. {
  153. try
  154. {
  155. #region ERP
  156. string sql = @"SELECT c.VenCode+a.ToWarehouseCode+c.POCode+a.MUSER+f,DNCode AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.POCode,f,DNCode,a.MUSER,f.Sequence AS DNSequence,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.POCode,c.PODetailID,a.InvCode) AS Sequence,
  157. a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity)*(lot.Amount/lot.Quantity) AS Amount,isnull((c.UnitPrice),0) as UnitPrice,c.Currency,c.PODetailID,Enable AS UpdateTodoQuantity
  158. ,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,
  159. 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
  160. INTO #TempERP
  161. FROM ICSWareHouseLotInfoLog a
  162. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  163. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  164. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  165. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  166. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  167. INNER JOIN ICSASNDetail g ON a.LotNo=g.LotNo AND a.WorkPoint=g.WorkPoint
  168. INNER JOIN ICSDeliveryNotice f ON g.ASNCode=f.ASNCode AND g.WorkPoint=f.WorkPoint
  169. INNER JOIN ICSPurchaseOrder c ON b.TransCode=c.POCode AND b.TransSequence=c.Sequence AND f.PODetailID=c.PODetailID AND b.WorkPoint=c.WorkPoint
  170. INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
  171. WHERE a.Identification='{0}' AND ERPUpload='0'
  172. GROUP BY c.VenCode,a.ToWarehouseCode,c.POCode,a.MUSER,a.InvCode,lot.Amount,lot.Quantity,c.PODetailID,isnull((c.UnitPrice),0),c.Currency,Enable
  173. ,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, ''),
  174. 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, '')
  175. SELECT DISTINCT Costre,WorkPoint,VenCode,WarehouseCode AS WHCode,POCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity FROM #TempERP
  176. SELECT Costre,Sequence,DNSequence,InvCode,Quantity,Amount,PODetailID,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
  177. FROM #TempERP
  178. DROP TABLE #TempERP";
  179. sql = string.Format(sql, Identification);
  180. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  181. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  182. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.PurchaseOrderURL, Inputstr);
  183. Result result = new Result();
  184. result = JsonConvert.DeserializeObject<Result>(resultStr);
  185. if (result.Success)
  186. {
  187. try
  188. {
  189. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  190. foreach (var item in res)
  191. {
  192. JObject jo = (JObject)item;
  193. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  194. foreach (var detail in resdetail)
  195. {
  196. JObject det = (JObject)detail;
  197. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["PODetailID"].ToString(), Identification, jo["ID"].ToString(),
  198. det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), cmd, language);
  199. }
  200. }
  201. }
  202. catch (Exception ex)
  203. {
  204. log.Debug(ex.ToString());
  205. log.Debug(resultStr);
  206. }
  207. }
  208. else
  209. {
  210. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  211. }
  212. #endregion
  213. }
  214. catch (Exception)
  215. {
  216. throw;
  217. }
  218. }
  219. #endregion
  220. #region 审核的到货单
  221. /// <summary>
  222. /// 审核的到货单
  223. /// </summary>
  224. /// <param name="TransCode"></param>
  225. /// <param name="TransSequence"></param>
  226. /// <param name="Quantity"></param>
  227. /// <param name="WorkPoint"></param>
  228. /// <param name="cmd"></param>
  229. public static void DeliveryNoticeIn(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  230. {
  231. try
  232. {
  233. string sql = @"DECLARE @Status VARCHAR(10)
  234. SELECT @Status=c.Status FROM ICSInventoryLot a
  235. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  236. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  237. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='1'
  238. IF (@Status IS NULL)
  239. BEGIN
  240. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  241. RETURN
  242. END
  243. ELSE IF (@Status='3')
  244. BEGIN
  245. RAISERROR('" + language.GetNameByCode("WMSAPIInfo082") + @"',16,1);
  246. RETURN
  247. END
  248. UPDATE c SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
  249. FROM ICSInventoryLot a
  250. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  251. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  252. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='1'
  253. IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
  254. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  255. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  256. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='1' AND c.Quantity<c.RCVQuantity)
  257. BEGIN
  258. RAISERROR('" + language.GetNameByCode("WMSAPIInfo083") + @"',16,1);
  259. END";
  260. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  261. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  262. {
  263. throw new Exception(language.GetNameByCode("WMSAPIInfo079"));//"到货单更新失败!");
  264. }
  265. }
  266. catch (Exception)
  267. {
  268. throw;
  269. }
  270. }
  271. /// <summary>
  272. /// 审核的到货单接口
  273. /// </summary>
  274. /// <param name="TransType"></param>
  275. /// <param name="Identification"></param>
  276. /// <param name="cmd"></param>
  277. public static void DeliveryNoticeInERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language)
  278. {
  279. try
  280. {
  281. #region ERP
  282. string sql = @"SELECT c.VenCode+a.ToWarehouseCode+c.DNCode+a.MUSER AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.DNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.DNCode,c.DNDetailID,a.InvCode) AS Sequence,
  283. a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity)*(lot.Amount/lot.Quantity) AS Amount,isnull((c.UnitPrice),0) as UnitPrice,c.Currency,c.DNDetailID,con.Enable AS UpdateTodoQuantity.conn.Enable
  284. ,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,
  285. 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
  286. INTO #TempERP
  287. FROM ICSWareHouseLotInfoLog a
  288. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  289. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  290. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  291. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  292. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  293. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  294. INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
  295. INNER JOIN ICSConfiguration conn ON con.WorkPoint=conn.WorkPoint AND conn.Code='Escrow001'
  296. WHERE a.Identification='{0}' AND ERPUpload='0'
  297. GROUP BY c.VenCode,a.ToWarehouseCode,c.DNCode,a.MUSER,lot.Amount,lot.Quantity,a.InvCode,c.DNDetailID,isnull((c.UnitPrice),0),c.Currency,Enable
  298. ,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, ''),
  299. 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, '')
  300. SELECT DISTINCT Costre,WorkPoint,VenCode,WarehouseCode AS WHCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity FROM #TempERP
  301. SELECT Costre,Sequence,InvCode,Quantity,Amount,DNDetailID,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
  302. FROM #TempERP
  303. DROP TABLE #TempERP";
  304. sql = string.Format(sql, Identification);
  305. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  306. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  307. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.DeliveryNoticeURL, Inputstr);
  308. Result result = new Result();
  309. result = JsonConvert.DeserializeObject<Result>(resultStr);
  310. if (result.Success)
  311. {
  312. try
  313. {
  314. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  315. foreach (var item in res)
  316. {
  317. JObject jo = (JObject)item;
  318. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  319. foreach (var detail in resdetail)
  320. {
  321. JObject det = (JObject)detail;
  322. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(),
  323. det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), cmd, language);
  324. }
  325. }
  326. }
  327. catch (Exception ex)
  328. {
  329. log.Debug(ex.ToString());
  330. log.Debug(resultStr);
  331. }
  332. }
  333. else
  334. {
  335. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  336. }
  337. #endregion
  338. }
  339. catch (Exception)
  340. {
  341. throw;
  342. }
  343. }
  344. #endregion
  345. #region 采购拒收
  346. /// <summary>
  347. /// 采购拒收
  348. /// </summary>
  349. /// <param name="TransCode"></param>
  350. /// <param name="TransSequence"></param>
  351. /// <param name="Quantity"></param>
  352. /// <param name="WorkPoint"></param>
  353. /// <param name="cmd"></param>
  354. public static void PurchaseRejectDocIn(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  355. {
  356. try
  357. {
  358. string sql = @"DECLARE @Status VARCHAR(10)
  359. SELECT @Status=c.Status FROM ICSInventoryLot a
  360. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  361. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  362. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='3'
  363. IF (@Status IS NULL)
  364. BEGIN
  365. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  366. RETURN
  367. END
  368. ELSE IF (@Status='3')
  369. BEGIN
  370. RAISERROR('" + language.GetNameByCode("WMSAPIInfo082") + @"',16,1);
  371. RETURN
  372. END
  373. UPDATE c SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
  374. FROM ICSInventoryLot a
  375. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  376. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  377. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='3'
  378. IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
  379. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  380. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  381. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='3' AND c.Quantity<c.RCVQuantity)
  382. BEGIN
  383. RAISERROR('" + language.GetNameByCode("WMSAPIInfo083") + @"',16,1);
  384. END";
  385. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  386. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  387. {
  388. throw new Exception(language.GetNameByCode("WMSAPIInfo084"));//"拒收单更新失败!");
  389. }
  390. }
  391. catch (Exception)
  392. {
  393. throw;
  394. }
  395. }
  396. /// <summary>
  397. /// 采购拒收接口
  398. /// </summary>
  399. /// <param name="TransType"></param>
  400. /// <param name="Identification"></param>
  401. /// <param name="cmd"></param>
  402. public static void PurchaseRejectDocInERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language)
  403. {
  404. try
  405. {
  406. #region ERP
  407. string sql = @"SELECT c.VenCode+a.ToWarehouseCode+c.DNCode+a.MUSER AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,d.DNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.DNCode,c.DNDetailID,a.InvCode) AS Sequence,
  408. a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity)*(lot.Amount/lot.Quantity) AS Amount,isnull((c.UnitPrice),0) as UnitPrice,c.Currency,d.DNDetailID,Enable AS UpdateTodoQuantity
  409. ,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,
  410. 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
  411. INTO #TempERP
  412. FROM ICSWareHouseLotInfoLog a
  413. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  414. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  415. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  416. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  417. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  418. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  419. INNER JOIN ICSDeliveryNotice d ON c.PODetailID=d.DNDetailID AND d.WorkPoint=c.WorkPoint
  420. INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
  421. WHERE a.Identification='{0}' AND ERPUpload='0'
  422. GROUP BY c.VenCode,a.ToWarehouseCode,c.DNCode,d.DNCode,a.MUSER,lot.Amount,lot.Quantity,a.InvCode,d.DNDetailID,c.DNDetailID,isnull((c.UnitPrice),0),c.Currency,Enable
  423. ,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, ''),
  424. 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, '')
  425. SELECT DISTINCT Costre,VenCode,WarehouseCode AS WHCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,WorkPoint FROM #TempERP
  426. SELECT Costre,Sequence,InvCode,Quantity,Amount,DNDetailID,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
  427. FROM #TempERP
  428. DROP TABLE #TempERP";
  429. sql = string.Format(sql, Identification);
  430. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  431. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "Vouchs", "Costre");
  432. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.CreatePuArrivalVouchURL, Inputstr);
  433. Result result = new Result();
  434. result = JsonConvert.DeserializeObject<Result>(resultStr);
  435. if (result.Success)
  436. {
  437. try
  438. {
  439. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  440. foreach (var item in res)
  441. {
  442. JObject jo = (JObject)item;
  443. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  444. foreach (var detail in resdetail)
  445. {
  446. JObject det = (JObject)detail;
  447. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), cmd, language);
  448. }
  449. }
  450. }
  451. catch (Exception ex)
  452. {
  453. log.Debug(ex.ToString());
  454. log.Debug(resultStr);
  455. }
  456. }
  457. else
  458. {
  459. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  460. }
  461. #endregion
  462. }
  463. catch (Exception)
  464. {
  465. throw;
  466. }
  467. }
  468. #endregion
  469. #region 采购退货
  470. /// <summary>
  471. /// 采购退货
  472. /// </summary>
  473. /// <param name="TransCode"></param>
  474. /// <param name="TransSequence"></param>
  475. /// <param name="Quantity"></param>
  476. /// <param name="WorkPoint"></param>
  477. /// <param name="cmd"></param>
  478. public static void PurchaseReceiveDoctNegative(string TransCode, string TransSequence, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  479. {
  480. try
  481. {
  482. string sql = @"DECLARE @Status VARCHAR(10)
  483. SELECT @Status=Status FROM ICSDeliveryNotice WHERE DNCode='{0}' AND DNType='2' AND WorkPoint='{1}'
  484. IF (@Status IS NULL)
  485. BEGIN
  486. RAISERROR('" + language.GetNameByCode("WMSAPIInfo085") + @"',16,1);
  487. RETURN
  488. END
  489. ELSE IF (@Status!='2')
  490. BEGIN
  491. RAISERROR('" + language.GetNameByCode("WMSAPIInfo086") + @"',16,1);
  492. RETURN
  493. END
  494. UPDATE a SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
  495. FROM ICSDeliveryNotice a
  496. WHERE a.DNCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND DNType='2'
  497. IF EXISTS(SELECT a.ID FROM ICSDeliveryNotice a
  498. WHERE a.DNCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Quantity<a.RCVQuantity AND DNType='2')
  499. BEGIN
  500. RAISERROR('" + language.GetNameByCode("WMSAPIInfo087") + @"',16,1);
  501. RETURN
  502. END";
  503. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  504. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  505. {
  506. throw new Exception(language.GetNameByCode("WMSAPIInfo088"));//"采购退货单更新失败!");
  507. }
  508. }
  509. catch (Exception)
  510. {
  511. throw;
  512. }
  513. }
  514. /// <summary>
  515. /// 采购退货接口
  516. /// </summary>
  517. /// <param name="TransType"></param>
  518. /// <param name="Identification"></param>
  519. /// <param name="cmd"></param>
  520. public static void PurchaseReceiveDoctNegativeERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language)
  521. {
  522. try
  523. {
  524. #region ERP
  525. string sql = @"SELECT y.VenCode+a.FromWarehouseCode+y.DNCode+a.MUSER AS Costre,y.VenCode,a.FromWarehouseCode AS WarehouseCode,y.DNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY y.VenCode,a.FromWarehouseCode,y.DNCode,y.DNDetailID,a.InvCode) AS Sequence,
  526. a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity)*(lot.Amount/lot.Quantity) AS Amount,y.DNDetailID,y.Currency,ISNULL(y.UnitPrice, 0) AS UnitPrice,Enable AS UpdateTodoQuantity
  527. ,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,
  528. 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
  529. INTO #TempERP
  530. FROM ICSWareHouseLotInfoLog a
  531. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  532. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  533. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  534. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.FromWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  535. INNER JOIN ICSDeliveryNotice y ON a.TransCode=y.DNCode AND a.TransSequence=y.Sequence AND a.WorkPoint=y.WorkPoint
  536. INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint
  537. WHERE a.Identification='{0}' AND ERPUpload='0' AND ( a.BusinessCode = '105' OR a.BusinessCode = '3')
  538. GROUP BY y.VenCode,a.FromWarehouseCode,y.DNCode,a.MUSER,a.InvCode,y.DNDetailID,y.Currency,ISNULL(y.UnitPrice, 0),Enable
  539. ,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, ''),
  540. 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, '')
  541. SELECT DISTINCT Costre,WorkPoint,VenCode,WarehouseCode AS WHCode,DNCode AS DNRTCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity FROM #TempERP
  542. SELECT Costre,Sequence,InvCode,Quantity,Amount,DNDetailID AS DNRTDetailID,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
  543. FROM #TempERP
  544. DROP TABLE #TempERP";
  545. sql = string.Format(sql, Identification);
  546. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  547. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  548. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.PurchaseReturnBackURL, Inputstr);
  549. Result result = new Result();
  550. result = JsonConvert.DeserializeObject<Result>(resultStr);
  551. if (result.Success)
  552. {
  553. try
  554. {
  555. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  556. foreach (var item in res)
  557. {
  558. JObject jo = (JObject)item;
  559. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  560. foreach (var detail in resdetail)
  561. {
  562. JObject det = (JObject)detail;
  563. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNRTDetailID"].ToString(), Identification, jo["ID"].ToString(),
  564. det["DetailID"].ToString(), jo["RCVNEGCode"].ToString(), det["Sequence"].ToString(), cmd, language);
  565. }
  566. }
  567. }
  568. catch (Exception ex)
  569. {
  570. log.Debug(ex.ToString());
  571. log.Debug(resultStr);
  572. }
  573. }
  574. else
  575. {
  576. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  577. }
  578. #endregion
  579. }
  580. catch (Exception)
  581. {
  582. throw;
  583. }
  584. }
  585. #endregion
  586. #region 开立红字入库
  587. /// <summary>
  588. /// 开立红字入库
  589. /// </summary>
  590. /// <param name="TransCode"></param>
  591. /// <param name="TransSequence"></param>
  592. /// <param name="Quantity"></param>
  593. /// <param name="WorkPoint"></param>
  594. /// <param name="cmd"></param>
  595. public static void PurchaseReceive(string TransCode, string TransSequence, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  596. {
  597. try
  598. {
  599. string sql = @"DECLARE @Status VARCHAR(10)
  600. SELECT @Status=a.Status FROM ICSPurchaseReceive a
  601. WHERE a.RCVCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='2'
  602. IF (@Status IS NULL)
  603. BEGIN
  604. RAISERROR('" + language.GetNameByCode("WMSAPIInfo089") + @"',16,1);
  605. RETURN
  606. END
  607. ELSE IF (@Status!='1')
  608. BEGIN
  609. RAISERROR('" + language.GetNameByCode("WMSAPIInfo090") + @"',16,1);
  610. RETURN
  611. END
  612. UPDATE a SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
  613. FROM ICSPurchaseReceive a
  614. WHERE a.RCVCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='2'
  615. IF EXISTS(SELECT a.ID FROM ICSPurchaseReceive a
  616. WHERE a.RCVCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Type='2' AND a.Quantity<a.RCVQuantity)
  617. BEGIN
  618. RAISERROR('" + language.GetNameByCode("WMSAPIInfo091") + @"',16,1);
  619. RETURN
  620. END";
  621. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  622. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  623. {
  624. throw new Exception(language.GetNameByCode("WMSAPIInfo092"));//"红字入库单更新失败!");
  625. }
  626. }
  627. catch (Exception)
  628. {
  629. throw;
  630. }
  631. }
  632. /// <summary>
  633. /// 开立红字入库接口
  634. /// </summary>
  635. /// <param name="TransType"></param>
  636. /// <param name="Identification"></param>
  637. /// <param name="cmd"></param>
  638. public static void PurchaseReceiveERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language)
  639. {
  640. try
  641. {
  642. #region ERP开立状态单据审核
  643. string sql = @"IF EXISTS(SELECT b.ID FROM ICSWareHouseLotInfoLog a
  644. INNER JOIN ICSPurchaseReceive b ON a.TransCode=b.RCVCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  645. WHERE a.Identification='{0}' AND b.Quantity!=b.RCVQuantity)
  646. BEGIN
  647. RAISERROR('" + language.GetNameByCode("WMSAPIInfo093") + @"',16,1);
  648. RETURN
  649. END
  650. SELECT b.RCVID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint
  651. FROM ICSWareHouseLotInfoLog a
  652. INNER JOIN ICSPurchaseReceive b ON a.TransCode=b.RCVCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  653. INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint
  654. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock001' AND a.WorkPoint=conStock.WorkPoint
  655. WHERE a.Identification='{0}' AND ERPUpload='0' AND (a.BusinessCode = '4' OR a.BusinessCode = '105')
  656. GROUP BY b.RCVID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint";
  657. sql = string.Format(sql, Identification);
  658. DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  659. string Inputstr = JsonConvert.SerializeObject(dt);
  660. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.PurchaseReceiveDoctNegativeURL, Inputstr);
  661. Result result = new Result();
  662. result = JsonConvert.DeserializeObject<Result>(resultStr);
  663. if (result.Success)
  664. {
  665. try
  666. {
  667. foreach (DataRow dr in dt.Rows)
  668. {
  669. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "", cmd, language);
  670. }
  671. }
  672. catch (Exception ex)
  673. {
  674. log.Debug(ex.ToString());
  675. log.Debug(resultStr);
  676. }
  677. }
  678. else
  679. {
  680. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  681. }
  682. #endregion
  683. }
  684. catch (Exception)
  685. {
  686. throw;
  687. }
  688. }
  689. #endregion
  690. }
  691. }