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

737 lines
46 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
  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,con.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,conv.Enable AS VerificationEnable
  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. INNER JOIN ICSConfiguration conv ON con.Code='CompleteVerification' AND a.WorkPoint=conv.WorkPoint
  423. WHERE a.Identification='{0}' AND ERPUpload='0'
  424. 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,con.Enable,conv.Enable
  425. ,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, ''),
  426. 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, '')
  427. SELECT DISTINCT Costre,VenCode,WarehouseCode AS WHCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,VerificationEnable,WorkPoint FROM #TempERP
  428. SELECT Costre,Sequence,InvCode,Quantity,Amount,DNDetailID,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
  429. FROM #TempERP
  430. DROP TABLE #TempERP";
  431. sql = string.Format(sql, Identification);
  432. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  433. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "Vouchs", "Costre");
  434. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.CreatePuArrivalVouchURL, Inputstr);
  435. Result result = new Result();
  436. result = JsonConvert.DeserializeObject<Result>(resultStr);
  437. if (result.Success)
  438. {
  439. try
  440. {
  441. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  442. foreach (var item in res)
  443. {
  444. JObject jo = (JObject)item;
  445. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  446. foreach (var detail in resdetail)
  447. {
  448. JObject det = (JObject)detail;
  449. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), cmd, language);
  450. }
  451. }
  452. }
  453. catch (Exception ex)
  454. {
  455. log.Debug(ex.ToString());
  456. log.Debug(resultStr);
  457. }
  458. }
  459. else
  460. {
  461. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  462. }
  463. #endregion
  464. }
  465. catch (Exception)
  466. {
  467. throw;
  468. }
  469. }
  470. #endregion
  471. #region 采购退货
  472. /// <summary>
  473. /// 采购退货
  474. /// </summary>
  475. /// <param name="TransCode"></param>
  476. /// <param name="TransSequence"></param>
  477. /// <param name="Quantity"></param>
  478. /// <param name="WorkPoint"></param>
  479. /// <param name="cmd"></param>
  480. public static void PurchaseReceiveDoctNegative(string TransCode, string TransSequence, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  481. {
  482. try
  483. {
  484. string sql = @"DECLARE @Status VARCHAR(10)
  485. SELECT @Status=Status FROM ICSDeliveryNotice WHERE DNCode='{0}' AND DNType='2' AND WorkPoint='{1}'
  486. IF (@Status IS NULL)
  487. BEGIN
  488. RAISERROR('" + language.GetNameByCode("WMSAPIInfo085") + @"',16,1);
  489. RETURN
  490. END
  491. ELSE IF (@Status!='2')
  492. BEGIN
  493. RAISERROR('" + language.GetNameByCode("WMSAPIInfo086") + @"',16,1);
  494. RETURN
  495. END
  496. UPDATE a SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
  497. FROM ICSDeliveryNotice a
  498. WHERE a.DNCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND DNType='2'
  499. IF EXISTS(SELECT a.ID FROM ICSDeliveryNotice a
  500. WHERE a.DNCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Quantity<a.RCVQuantity AND DNType='2')
  501. BEGIN
  502. RAISERROR('" + language.GetNameByCode("WMSAPIInfo087") + @"',16,1);
  503. RETURN
  504. END";
  505. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  506. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  507. {
  508. throw new Exception(language.GetNameByCode("WMSAPIInfo088"));//"采购退货单更新失败!");
  509. }
  510. }
  511. catch (Exception)
  512. {
  513. throw;
  514. }
  515. }
  516. /// <summary>
  517. /// 采购退货接口
  518. /// </summary>
  519. /// <param name="TransType"></param>
  520. /// <param name="Identification"></param>
  521. /// <param name="cmd"></param>
  522. public static void PurchaseReceiveDoctNegativeERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language)
  523. {
  524. try
  525. {
  526. #region ERP
  527. 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,
  528. 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
  529. ,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,
  530. 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
  531. INTO #TempERP
  532. FROM ICSWareHouseLotInfoLog a
  533. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  534. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  535. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  536. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.FromWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  537. INNER JOIN ICSDeliveryNotice y ON a.TransCode=y.DNCode AND a.TransSequence=y.Sequence AND a.WorkPoint=y.WorkPoint
  538. INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint
  539. WHERE a.Identification='{0}' AND ERPUpload='0' AND a.BusinessCode = '3'
  540. GROUP BY y.VenCode,a.FromWarehouseCode,y.DNCode,a.MUSER,a.InvCode,lot.Amount,lot.Quantity,y.DNDetailID,y.Currency,ISNULL(y.UnitPrice, 0),Enable
  541. ,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, ''),
  542. 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, '')
  543. SELECT DISTINCT Costre,WorkPoint,VenCode,WarehouseCode AS WHCode,DNCode AS DNRTCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity FROM #TempERP
  544. 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
  545. FROM #TempERP
  546. DROP TABLE #TempERP";
  547. sql = string.Format(sql, Identification);
  548. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  549. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  550. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.PurchaseReturnBackURL, Inputstr);
  551. Result result = new Result();
  552. result = JsonConvert.DeserializeObject<Result>(resultStr);
  553. if (result.Success)
  554. {
  555. try
  556. {
  557. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  558. foreach (var item in res)
  559. {
  560. JObject jo = (JObject)item;
  561. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  562. foreach (var detail in resdetail)
  563. {
  564. JObject det = (JObject)detail;
  565. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNRTDetailID"].ToString(), Identification, jo["ID"].ToString(),
  566. det["DetailID"].ToString(), jo["RCVNEGCode"].ToString(), det["Sequence"].ToString(), cmd, language);
  567. }
  568. }
  569. }
  570. catch (Exception ex)
  571. {
  572. log.Debug(ex.ToString());
  573. log.Debug(resultStr);
  574. }
  575. }
  576. else
  577. {
  578. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  579. }
  580. #endregion
  581. }
  582. catch (Exception)
  583. {
  584. throw;
  585. }
  586. }
  587. #endregion
  588. #region 开立红字入库
  589. /// <summary>
  590. /// 开立红字入库
  591. /// </summary>
  592. /// <param name="TransCode"></param>
  593. /// <param name="TransSequence"></param>
  594. /// <param name="Quantity"></param>
  595. /// <param name="WorkPoint"></param>
  596. /// <param name="cmd"></param>
  597. public static void PurchaseReceive(string TransCode, string TransSequence, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  598. {
  599. try
  600. {
  601. string sql = @"DECLARE @Status VARCHAR(10)
  602. SELECT @Status=a.Status FROM ICSPurchaseReceive a
  603. WHERE a.RCVCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='2'
  604. IF (@Status IS NULL)
  605. BEGIN
  606. RAISERROR('" + language.GetNameByCode("WMSAPIInfo089") + @"',16,1);
  607. RETURN
  608. END
  609. ELSE IF (@Status!='1')
  610. BEGIN
  611. RAISERROR('" + language.GetNameByCode("WMSAPIInfo090") + @"',16,1);
  612. RETURN
  613. END
  614. UPDATE a SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
  615. FROM ICSPurchaseReceive a
  616. WHERE a.RCVCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='2'
  617. IF EXISTS(SELECT a.ID FROM ICSPurchaseReceive a
  618. WHERE a.RCVCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Type='2' AND a.Quantity<a.RCVQuantity)
  619. BEGIN
  620. RAISERROR('" + language.GetNameByCode("WMSAPIInfo091") + @"',16,1);
  621. RETURN
  622. END";
  623. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  624. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  625. {
  626. throw new Exception(language.GetNameByCode("WMSAPIInfo092"));//"红字入库单更新失败!");
  627. }
  628. }
  629. catch (Exception)
  630. {
  631. throw;
  632. }
  633. }
  634. /// <summary>
  635. /// 开立红字入库接口
  636. /// </summary>
  637. /// <param name="TransType"></param>
  638. /// <param name="Identification"></param>
  639. /// <param name="cmd"></param>
  640. public static void PurchaseReceiveERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language)
  641. {
  642. try
  643. {
  644. #region ERP开立状态单据审核
  645. string sql = @"IF EXISTS(SELECT b.ID FROM ICSWareHouseLotInfoLog a
  646. INNER JOIN ICSPurchaseReceive b ON a.TransCode=b.RCVCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  647. WHERE a.Identification='{0}' AND b.Quantity!=b.RCVQuantity)
  648. BEGIN
  649. RAISERROR('" + language.GetNameByCode("WMSAPIInfo093") + @"',16,1);
  650. RETURN
  651. END
  652. SELECT b.RCVID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint
  653. FROM ICSWareHouseLotInfoLog a
  654. INNER JOIN ICSPurchaseReceive b ON a.TransCode=b.RCVCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  655. INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint
  656. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock001' AND a.WorkPoint=conStock.WorkPoint
  657. WHERE a.Identification='{0}' AND ERPUpload='0' AND a.BusinessCode = '4'
  658. GROUP BY b.RCVID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint";
  659. sql = string.Format(sql, Identification);
  660. DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  661. string Inputstr = JsonConvert.SerializeObject(dt);
  662. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.PurchaseReceiveDoctNegativeURL, Inputstr);
  663. Result result = new Result();
  664. result = JsonConvert.DeserializeObject<Result>(resultStr);
  665. if (result.Success)
  666. {
  667. try
  668. {
  669. foreach (DataRow dr in dt.Rows)
  670. {
  671. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "", cmd, language);
  672. }
  673. }
  674. catch (Exception ex)
  675. {
  676. log.Debug(ex.ToString());
  677. log.Debug(resultStr);
  678. }
  679. }
  680. else
  681. {
  682. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  683. }
  684. #endregion
  685. }
  686. catch (Exception)
  687. {
  688. throw;
  689. }
  690. }
  691. #endregion
  692. }
  693. }