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

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