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

1146 lines
68 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
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
1 year ago
1 year ago
1 year ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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 year ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 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, string BusinessCode)
  152. {
  153. try
  154. {
  155. #region ERP
  156. string sql = @"SELECT c.VenCode+a.ToWarehouseCode+c.POCode+a.MUSER+CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.DNCode END AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.POCode,CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.DNCode END AS DNCode,CASE WHEN(LEN(f.DNID)>=20) THEN '1' ELSE '0' END AS HasDN,a.MUSER,CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.Sequence END 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' AND BusinessCode='{1}'
  173. GROUP BY c.VenCode,a.ToWarehouseCode,c.POCode,CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.DNCode END,f.DNID,a.MUSER,a.InvCode,CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.Sequence END,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. SELECT HasDN FROM #TempERP
  180. DROP TABLE #TempERP";
  181. sql = string.Format(sql, Identification, BusinessCode);
  182. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  183. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  184. var IsDNCode = ds.Tables[2];
  185. if (IsDNCode == null || IsDNCode.Rows.Count != 1)
  186. {
  187. throw new Exception(language.GetNameByCode("WMSAPIInfo463"));//ERP到货单只能选择启用或不启用中的一种!
  188. }
  189. string dncode = Convert.ToString(IsDNCode.Rows[0]["HasDN"]);
  190. if (dncode.Equals(""))
  191. {
  192. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.DeliveryNoticeURL, Inputstr);
  193. Result result = new Result();
  194. result = JsonConvert.DeserializeObject<Result>(resultStr);
  195. if (result.Success)
  196. {
  197. try
  198. {
  199. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  200. foreach (var item in res)
  201. {
  202. JObject jo = (JObject)item;
  203. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  204. foreach (var detail in resdetail)
  205. {
  206. JObject det = (JObject)detail;
  207. string allcol = jo["cWhCode"].ToString() + det["ProjectCode"].ToString() + det["cBatch"].ToString() + det["version"].ToString() + det["brand"].ToString() + det["cFree1"].ToString() + det["cFree2"].ToString() + det["cFree3"].ToString() + det["cFree4"].ToString() + det["cFree5"].ToString()
  208. + det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString();
  209. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(),
  210. det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode);
  211. }
  212. }
  213. }
  214. catch (Exception ex)
  215. {
  216. log.Debug(ex.ToString());
  217. log.Debug(resultStr);
  218. }
  219. }
  220. else
  221. {
  222. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  223. }
  224. }
  225. else
  226. {
  227. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.PurchaseOrderURL, Inputstr);
  228. Result result = new Result();
  229. result = JsonConvert.DeserializeObject<Result>(resultStr);
  230. if (result.Success)
  231. {
  232. try
  233. {
  234. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  235. foreach (var item in res)
  236. {
  237. JObject jo = (JObject)item;
  238. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  239. foreach (var detail in resdetail)
  240. {
  241. JObject det = (JObject)detail;
  242. string allcol = jo["cWhCode"].ToString() + det["ProjectCode"].ToString() + det["cBatch"].ToString() + det["version"].ToString() + det["brand"].ToString() + det["cFree1"].ToString() + det["cFree2"].ToString() + det["cFree3"].ToString() + det["cFree4"].ToString() + det["cFree5"].ToString()
  243. + det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString();
  244. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["PODetailID"].ToString(), Identification, jo["ID"].ToString(),
  245. det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode);
  246. }
  247. }
  248. }
  249. catch (Exception ex)
  250. {
  251. log.Debug(ex.ToString());
  252. log.Debug(resultStr);
  253. }
  254. }
  255. else
  256. {
  257. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  258. }
  259. }
  260. #endregion
  261. }
  262. catch (Exception)
  263. {
  264. throw;
  265. }
  266. }
  267. #endregion
  268. /// <summary>
  269. /// 审核的到货单(货柜)
  270. /// </summary>
  271. /// <param name="TransCode"></param>
  272. /// <param name="TransSequence"></param>
  273. /// <param name="Quantity"></param>
  274. /// <param name="WorkPoint"></param>
  275. /// <param name="cmd"></param>
  276. public static void DeliveryNoticeInForHG(string DocNO, string TransLine, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language,string quantity)
  277. {
  278. try
  279. {
  280. decimal iquantity = Convert.ToDecimal(quantity);
  281. string sql = @" IF EXISTS (SELECT ID FROM ICSDeliveryNotice WHERE RCVQuantity=Quantity AND DNCode='{0}' AND Sequence='{1}' and WorkPoint='{2}' )
  282. BEGIN
  283. RAISERROR('" + language.GetNameByCode("WMSAPIInfo471") + @"',16,1);
  284. RETURN
  285. END;
  286. UPDATE ICSDeliveryNotice set RCVQuantity=RCVQuantity+{3}
  287. Where DNCode='{0}' AND Sequence='{1}' and WorkPoint='{2}'";
  288. sql = string.Format(sql, DocNO, TransLine, WorkPoint, iquantity);
  289. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  290. {
  291. throw new Exception(language.GetNameByCode("WMSAPIInfo079"));//"到货单更新失败!");
  292. }
  293. }
  294. catch (Exception)
  295. {
  296. throw;
  297. }
  298. }
  299. #region 审核的到货单
  300. /// <summary>
  301. /// 审核的到货单
  302. /// </summary>
  303. /// <param name="TransCode"></param>
  304. /// <param name="TransSequence"></param>
  305. /// <param name="Quantity"></param>
  306. /// <param name="WorkPoint"></param>
  307. /// <param name="cmd"></param>
  308. public static void DeliveryNoticeIn(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  309. {
  310. try
  311. {
  312. string sql = @"DECLARE @Status VARCHAR(10)
  313. SELECT @Status=c.Status FROM ICSInventoryLot a
  314. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  315. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  316. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='1'
  317. IF (@Status IS NULL)
  318. BEGIN
  319. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  320. RETURN
  321. END
  322. ELSE IF (@Status='3')
  323. BEGIN
  324. RAISERROR('" + language.GetNameByCode("WMSAPIInfo082") + @"',16,1);
  325. RETURN
  326. END
  327. UPDATE c SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
  328. FROM ICSInventoryLot a
  329. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  330. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  331. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='1'
  332. IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
  333. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  334. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  335. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='1' AND c.Quantity<c.RCVQuantity)
  336. BEGIN
  337. RAISERROR('" + language.GetNameByCode("WMSAPIInfo083") + @"',16,1);
  338. END";
  339. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  340. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  341. {
  342. throw new Exception(language.GetNameByCode("WMSAPIInfo079"));//"到货单更新失败!");
  343. }
  344. }
  345. catch (Exception)
  346. {
  347. throw;
  348. }
  349. }
  350. /// <summary>
  351. /// 审核的到货单接口(平库,传给SAP单据行总数)
  352. /// </summary>
  353. /// <param name="TransType"></param>
  354. /// <param name="Identification"></param>
  355. /// <param name="cmd"></param>
  356. public static void DeliveryNoticeInERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
  357. {
  358. try
  359. {
  360. #region SAP(检验合格单为两层结构 一行对应一个序列号)
  361. string IsSuccess = "";
  362. string ErrorMessage = "";
  363. string sql = @" select A.DNCode,A.WorkPoint,SUM(B.Quantity) AS Quantity from ICSDeliveryNotice A
  364. LEFT JOIN ICSWareHouseLotInfoLog B ON B.TransCode=A.DNCode AND B.WorkPoint=A.WorkPoint
  365. where B.Identification='{0}' AND BusinessCode='2'
  366. GROUP BY A.DNCode,A.WorkPoint";
  367. sql = string.Format(sql, Identification);
  368. DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  369. if (dt.Rows.Count > 1)
  370. {
  371. throw new Exception(language.GetNameByCode("WMSAPIInfo202"));//单次提交单据数量卡控(只允许一张单据)
  372. }
  373. for (int i = 0; i < dt.Rows.Count; i++)
  374. {
  375. string chksql = @"select SUM(Quantity) AS Quantity,SUM(RCVQuantity) AS RCVQuantity from ICSDeliveryNotice
  376. where DNCode='{0}' and WorkPoint='{1}'
  377. GROUP BY DNCode,WorkPoint";
  378. chksql = string.Format(chksql, dt.Rows[i]["DNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
  379. DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd);
  380. if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) != Convert.ToDecimal(chkdt.Rows[0]["RCVQuantity"]))
  381. {
  382. return;
  383. }
  384. sql = @"select A.DNCode,
  385. CASE WHEN SUM(Convert(decimal(18,6),A.SAPSequence)) IS NULL THEN SUM(A.RCVQuantity)
  386. ELSE SUM(Convert(decimal(18,6),A.SAPSequence)) END AS RCVQuantity,B.BatchCode from ICSDeliveryNotice A
  387. LEFT JOIN ICSExtension B ON B.ID=A.ExtensionID AND B.WorkPoint=A.WorkPoint
  388. WHERE DNCode='{0}' AND A.WorkPoint='{1}'
  389. GROUP BY A.DNCode,B.BatchCode";
  390. sql = string.Format(sql, dt.Rows[i]["DNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
  391. DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd);
  392. if (Sapdt.Rows.Count == 0)
  393. {
  394. throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo205"), dt.Rows[i]["DNCode"].ToString()));//单据查询失败
  395. }
  396. SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU Client = new SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU();
  397. SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU1 Info = new SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU1();
  398. Info.NEWID = Identification;
  399. Info.PRUEFLOS = Sapdt.Rows[0]["DNCode"].ToString();
  400. Info.L_LME = System.Decimal.Round(Convert.ToDecimal(Sapdt.Rows[0]["RCVQuantity"].ToString()), 3);
  401. Info.SERNP = Sapdt.Rows[0]["BatchCode"].ToString();
  402. Info.Z_GERNR = new SAPCallBackJYHGDCS.ZWEBS_GERNR[0];
  403. SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKUResponse result = new SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKUResponse();
  404. result = Client.CallZWMS_SK_WS_RUKU(Info);
  405. if (result.Z_NULL == "N")
  406. {
  407. IsSuccess = "N";
  408. ErrorMessage += result.L_MESSAGE;
  409. }
  410. }
  411. if (IsSuccess == "N")
  412. {
  413. throw new Exception(ErrorMessage);
  414. }
  415. #endregion
  416. }
  417. catch (Exception)
  418. {
  419. throw;
  420. }
  421. }
  422. /// <summary>
  423. /// 审核的到货单接口(货柜,传给SAP本次入库数量)
  424. /// </summary>
  425. /// <param name="TransType"></param>
  426. /// <param name="Identification"></param>
  427. /// <param name="cmd"></param>
  428. public static void DeliveryNoticeInERPHG(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
  429. {
  430. try
  431. {
  432. #region SAP(检验合格单为两层结构 一行对应一个序列号)
  433. string IsSuccess = "";
  434. string ErrorMessage = "";
  435. string sql = @" select A.DNCode,A.WorkPoint,SUM(B.Quantity) AS Quantity from ICSDeliveryNotice A
  436. LEFT JOIN ICSWareHouseLotInfoLog B ON B.TransCode=A.DNCode AND B.WorkPoint=A.WorkPoint
  437. where B.Identification='{0}' AND BusinessCode='2'
  438. GROUP BY A.DNCode,A.WorkPoint";
  439. sql = string.Format(sql, Identification);
  440. DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  441. if (dt.Rows.Count > 1)
  442. {
  443. throw new Exception(language.GetNameByCode("WMSAPIInfo202"));//单次提交单据数量卡控(只允许一张单据)
  444. }
  445. for (int i = 0; i < dt.Rows.Count; i++)
  446. {
  447. string chksql = @"select SUM(Quantity) AS Quantity,SUM(RCVQuantity) AS RCVQuantity from ICSDeliveryNotice
  448. where DNCode='{0}' and WorkPoint='{1}'
  449. GROUP BY DNCode,WorkPoint";
  450. chksql = string.Format(chksql, dt.Rows[i]["DNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
  451. DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd);
  452. if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) != Convert.ToDecimal(chkdt.Rows[0]["RCVQuantity"]))
  453. {
  454. return;
  455. }
  456. sql = @"select A.DNCode,SUM(A.RCVQuantity) AS RCVQuantity,B.BatchCode from ICSDeliveryNotice A
  457. LEFT JOIN ICSExtension B ON B.ID=A.ExtensionID AND B.WorkPoint=A.WorkPoint
  458. WHERE DNCode='{0}' AND A.WorkPoint='{1}'
  459. GROUP BY A.DNCode,B.BatchCode";
  460. sql = string.Format(sql, dt.Rows[i]["DNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
  461. DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd);
  462. if (Sapdt.Rows.Count == 0)
  463. {
  464. throw new Exception(string.Format(language.GetNameByCode("WMSAPIInfo205"), dt.Rows[i]["DNCode"].ToString()));//单据查询失败
  465. }
  466. SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU Client = new SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU();
  467. SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU1 Info = new SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKU1();
  468. Info.NEWID = Identification;
  469. Info.PRUEFLOS = Sapdt.Rows[0]["DNCode"].ToString();
  470. Info.L_LME = System.Decimal.Round(Convert.ToDecimal(dt.Rows[0]["Quantity"].ToString()), 3);
  471. Info.SERNP = Sapdt.Rows[0]["BatchCode"].ToString();
  472. Info.Z_GERNR = new SAPCallBackJYHGDCS.ZWEBS_GERNR[0];
  473. SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKUResponse result = new SAPCallBackJYHGDCS.ZWMS_SK_WS_RUKUResponse();
  474. result = Client.CallZWMS_SK_WS_RUKU(Info);
  475. if (result.Z_NULL == "N")
  476. {
  477. IsSuccess = "N";
  478. ErrorMessage += result.L_MESSAGE;
  479. }
  480. }
  481. if (IsSuccess == "N")
  482. {
  483. throw new Exception(ErrorMessage);
  484. }
  485. #endregion
  486. }
  487. catch (Exception)
  488. {
  489. throw;
  490. }
  491. }
  492. #endregion
  493. #region 叉车采购入库
  494. /// <summary>
  495. /// 叉车采购入库
  496. /// </summary>
  497. /// <param name="TransCode"></param>
  498. /// <param name="TransSequence"></param>
  499. /// <param name="Quantity"></param>
  500. /// <param name="WorkPoint"></param>
  501. /// <param name="cmd"></param>
  502. public static void DeliveryNoticeForkLift(string ContainerCode, SqlCommand cmd, Dictionary<string, string> language)
  503. {
  504. try
  505. {
  506. string lotsql = @" select A.LotNo,C.Quantity,B.WorkPoint from ICSContainerLot A
  507. LEFT JOIN ICSContainer B ON B.ID=A.ContainerID AND B.WorkPoint=A.WorkPoint
  508. LEFT JOIN ICSInventoryLot C ON C.LotNo=A.LotNo AND C.WorkPoint=A.WorkPoint
  509. where B.ContainerCode='{0}'";
  510. lotsql = string.Format(lotsql, ContainerCode);
  511. DataTable lotdt = DBHelper.SQlReturnData(lotsql, cmd);
  512. if (lotdt.Rows.Count == 0)
  513. {
  514. throw new Exception("托盘号不存在或者尚未绑定条码!");
  515. }
  516. foreach (DataRow dr in lotdt.Rows)
  517. {
  518. string sql = @" UPDATE c SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
  519. FROM ICSInventoryLot a
  520. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  521. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  522. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='1'
  523. IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
  524. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  525. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  526. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='1' AND c.Quantity<c.RCVQuantity)
  527. BEGIN
  528. RAISERROR('" + language.GetNameByCode("WMSAPIInfo083") + @"',16,1);
  529. END";
  530. sql = string.Format(sql, dr["LotNo"].ToString(), dr["WorkPoint"].ToString(), dr["Quantity"].ToString());
  531. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  532. {
  533. throw new Exception(language.GetNameByCode("WMSAPIInfo079"));//"到货单更新失败!");
  534. }
  535. }
  536. }
  537. catch (Exception)
  538. {
  539. throw;
  540. }
  541. }
  542. #endregion
  543. #region 采购拒收
  544. /// <summary>
  545. /// 采购拒收
  546. /// </summary>
  547. /// <param name="TransCode"></param>
  548. /// <param name="TransSequence"></param>
  549. /// <param name="Quantity"></param>
  550. /// <param name="WorkPoint"></param>
  551. /// <param name="cmd"></param>
  552. public static void PurchaseRejectDocIn(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  553. {
  554. try
  555. {
  556. string sql = @"DECLARE @Status VARCHAR(10)
  557. SELECT @Status=c.Status FROM ICSInventoryLot a
  558. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  559. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  560. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='3'
  561. IF (@Status IS NULL)
  562. BEGIN
  563. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  564. RETURN
  565. END
  566. ELSE IF (@Status='3')
  567. BEGIN
  568. RAISERROR('" + language.GetNameByCode("WMSAPIInfo082") + @"',16,1);
  569. RETURN
  570. END
  571. UPDATE c SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
  572. FROM ICSInventoryLot a
  573. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  574. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  575. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='3'
  576. IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
  577. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  578. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  579. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DNType='3' AND c.Quantity<c.RCVQuantity)
  580. BEGIN
  581. RAISERROR('" + language.GetNameByCode("WMSAPIInfo083") + @"',16,1);
  582. END";
  583. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  584. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  585. {
  586. throw new Exception(language.GetNameByCode("WMSAPIInfo084"));//"拒收单更新失败!");
  587. }
  588. }
  589. catch (Exception)
  590. {
  591. throw;
  592. }
  593. }
  594. /// <summary>
  595. /// 采购拒收接口
  596. /// </summary>
  597. /// <param name="TransType"></param>
  598. /// <param name="Identification"></param>
  599. /// <param name="cmd"></param>
  600. public static void PurchaseRejectDocInNewERP(string DNCode, string JDNCode, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  601. {
  602. //try
  603. //{
  604. // #region ERP
  605. // 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,
  606. // 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
  607. // ,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,
  608. // 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
  609. // INTO #TempERP
  610. // FROM ICSWareHouseLotInfoLog a
  611. // INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  612. // INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  613. // INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  614. // INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  615. // LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  616. // INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  617. // INNER JOIN ICSDeliveryNotice d ON c.PODetailID=d.DNDetailID AND d.WorkPoint=c.WorkPoint
  618. // INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
  619. // INNER JOIN ICSConfiguration conv ON con.Code='CompleteVerification' AND a.WorkPoint=conv.WorkPoint
  620. // WHERE a.Identification='{0}' AND ERPUpload='0'
  621. // 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
  622. // ,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, ''),
  623. // 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, '')
  624. // SELECT DISTINCT Costre,VenCode,WarehouseCode AS WHCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,VerificationEnable,WorkPoint FROM #TempERP
  625. // SELECT Costre,Sequence,InvCode,Quantity,Amount,DNDetailID,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
  626. // FROM #TempERP
  627. // DROP TABLE #TempERP";
  628. // sql = string.Format(sql, Identification);
  629. // DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  630. // string Inputstr = DataToJsonHelper.DataSetToJson(ds, "Vouchs", "Costre");
  631. // string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.CreatePuArrivalVouchURL, Inputstr);
  632. // Result result = new Result();
  633. // result = JsonConvert.DeserializeObject<Result>(resultStr);
  634. // if (result.Success)
  635. // {
  636. // try
  637. // {
  638. // JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  639. // foreach (var item in res)
  640. // {
  641. // JObject jo = (JObject)item;
  642. // JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  643. // foreach (var detail in resdetail)
  644. // {
  645. // JObject det = (JObject)detail;
  646. // ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), cmd, language);
  647. // }
  648. // }
  649. // }
  650. // catch (Exception ex)
  651. // {
  652. // log.Debug(ex.ToString());
  653. // log.Debug(resultStr);
  654. // }
  655. // }
  656. // else
  657. // {
  658. // throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  659. // }
  660. // #endregion
  661. //}
  662. //catch (Exception)
  663. //{
  664. // throw;
  665. //}
  666. try
  667. {
  668. #region ERP
  669. string sql = @"SELECT a.VenCode+a.DepCode+a.DNCode+a.MUSER AS Costre,a.VenCode,a.DepCode,a.DNCode,a.MUSER,a.MTIME,
  670. a.Sequence,a.InvCode,Sum(x.Quantity) AS Quantity,a.Amount,ISNULL(a.UnitPrice,0) AS UnitPrice,a.Currency,a.DNDetailID
  671. ,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,
  672. 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
  673. INTO #TempERP
  674. FROM ICSDeliveryNotice a
  675. INNER JOIN ICSExtension ext ON a.ExtensionID=ext.ID AND a.WorkPoint=ext.WorkPoint
  676. INNER JOIN ICSInventory invBat ON a.InvCode=invBat.InvCode AND a.WorkPoint=invBat.WorkPoint
  677. INNER JOIN ICSDeliveryNotice x ON a.DNDetailID=x.PODetailID AND a.WorkPoint=x.WorkPoint
  678. WHERE a.DNCode='{0}' AND a.WorkPoint='{1}'
  679. GROUP BY a.VenCode,a.DepCode,a.DNCode,a.MUSER,a.MTIME,a.Sequence,a.InvCode,a.Amount,a.Quantity,a.UnitPrice,a.Currency,a.DNDetailID,
  680. a.WorkPoint,ISNULL(ext.ProjectCode, ''),ISNULL(invBat.BatchEnable, ''),ISNULL(ext.BatchCode, ''),ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''),
  681. 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, '')
  682. SELECT DISTINCT Costre,WorkPoint,VenCode,DepCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime FROM #TempERP
  683. SELECT Costre,Sequence,InvCode,Quantity,Amount,UnitPrice,Currency,DNDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
  684. FROM #TempERP
  685. DROP TABLE #TempERP";
  686. sql = string.Format(sql, DNCode, WorkPoint);
  687. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  688. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "Vouchs", "Costre");
  689. string resultStr = HTTPHelper.HttpPost("采购拒收", ERPUrl.CreatePuArrivalVouchURL, Inputstr);
  690. Result result = new Result();
  691. result = JsonConvert.DeserializeObject<Result>(resultStr);
  692. if (result.Success)
  693. {
  694. try
  695. {
  696. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  697. foreach (var item in res)
  698. {
  699. JObject jo = (JObject)item;
  700. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  701. foreach (var detail in resdetail)
  702. {
  703. JObject det = (JObject)detail;
  704. //ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), det["DetailID"].ToString(), jo["RJTCode"].ToString(), det["Sequence"].ToString(), cmd, language);
  705. string ERPupdate = @"update ICSDeliveryNotice set DNCode='{0}',Sequence='{1}',DNID='{2}',DNDetailID='{3}'
  706. where PODetailID='{4}' AND DNType='3' AND DNCode='{5}' ";
  707. ERPupdate = string.Format(ERPupdate, jo["RJTCode"], det["Sequence"], jo["ID"], det["DetailID"], det["DNDetailID"], JDNCode);
  708. if (!DBHelper.ExecuteNonQuery(ERPupdate, cmd))
  709. {
  710. throw new Exception(language.GetNameByCode("WMSAPIInfo079"));//"到货单更新失败!");
  711. }
  712. }
  713. }
  714. }
  715. catch (Exception ex)
  716. {
  717. log.Debug(ex.ToString());
  718. log.Debug(resultStr);
  719. }
  720. }
  721. else
  722. {
  723. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  724. }
  725. #endregion
  726. }
  727. catch (Exception)
  728. {
  729. throw;
  730. }
  731. }
  732. /// <summary>
  733. /// 采购拒收接口
  734. /// </summary>
  735. /// <param name="TransType"></param>
  736. /// <param name="Identification"></param>
  737. /// <param name="cmd"></param>
  738. public static void PurchaseRejectDocInERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
  739. {
  740. //try
  741. //{
  742. // #region ERP
  743. // 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,
  744. // 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
  745. // ,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,
  746. // 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
  747. // INTO #TempERP
  748. // FROM ICSWareHouseLotInfoLog a
  749. // INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  750. // INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  751. // INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  752. // INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  753. // LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  754. // INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  755. // INNER JOIN ICSDeliveryNotice d ON c.PODetailID=d.DNDetailID AND d.WorkPoint=c.WorkPoint
  756. // INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
  757. // INNER JOIN ICSConfiguration conv ON con.Code='CompleteVerification' AND a.WorkPoint=conv.WorkPoint
  758. // WHERE a.Identification='{0}' AND ERPUpload='0'
  759. // GROUP BY c.VenCode,a.ToWarehouseCode,c.DNCode,d.DNCode,a.MUSER,a.InvCode,d.DNDetailID,c.DNDetailID,isnull((c.UnitPrice),0),c.Currency,con.Enable,conv.Enable
  760. // ,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, ''),
  761. // 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, '')
  762. // SELECT DISTINCT Costre,VenCode,WarehouseCode AS WHCode,DNCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,VerificationEnable,WorkPoint FROM #TempERP
  763. // SELECT Costre,Sequence,InvCode,Quantity,Amount,DNDetailID,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
  764. // FROM #TempERP
  765. // DROP TABLE #TempERP";
  766. // sql = string.Format(sql, Identification);
  767. // DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  768. // string Inputstr = DataToJsonHelper.DataSetToJson(ds, "Vouchs", "Costre");
  769. // string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.CreatePuArrivalVouchURL, Inputstr);
  770. // Result result = new Result();
  771. // result = JsonConvert.DeserializeObject<Result>(resultStr);
  772. // if (result.Success)
  773. // {
  774. // try
  775. // {
  776. // JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  777. // foreach (var item in res)
  778. // {
  779. // JObject jo = (JObject)item;
  780. // JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  781. // foreach (var detail in resdetail)
  782. // {
  783. // JObject det = (JObject)detail;
  784. // ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), cmd, language);
  785. // }
  786. // }
  787. // }
  788. // catch (Exception ex)
  789. // {
  790. // log.Debug(ex.ToString());
  791. // log.Debug(resultStr);
  792. // }
  793. // }
  794. // else
  795. // {
  796. // throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  797. // }
  798. // #endregion
  799. //}
  800. //catch (Exception)
  801. //{
  802. // throw;
  803. //}
  804. }
  805. #endregion
  806. #region 采购退货
  807. /// <summary>
  808. /// 采购退货
  809. /// </summary>
  810. /// <param name="TransCode"></param>
  811. /// <param name="TransSequence"></param>
  812. /// <param name="Quantity"></param>
  813. /// <param name="WorkPoint"></param>
  814. /// <param name="cmd"></param>
  815. public static void PurchaseReceiveDoctNegative(string TransCode, string TransSequence, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  816. {
  817. try
  818. {
  819. string sql = @"DECLARE @Status VARCHAR(10)
  820. SELECT @Status=Status FROM ICSDeliveryNotice WHERE DNCode='{0}' AND DNType='2' AND WorkPoint='{1}'
  821. IF (@Status IS NULL)
  822. BEGIN
  823. RAISERROR('" + language.GetNameByCode("WMSAPIInfo085") + @"',16,1);
  824. RETURN
  825. END
  826. ELSE IF (@Status!='2')
  827. BEGIN
  828. RAISERROR('" + language.GetNameByCode("WMSAPIInfo086") + @"',16,1);
  829. RETURN
  830. END
  831. UPDATE a SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
  832. FROM ICSDeliveryNotice a
  833. WHERE a.DNCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND DNType='2'
  834. IF EXISTS(SELECT a.ID FROM ICSDeliveryNotice a
  835. WHERE a.DNCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Quantity<a.RCVQuantity AND DNType='2')
  836. BEGIN
  837. RAISERROR('" + language.GetNameByCode("WMSAPIInfo087") + @"',16,1);
  838. RETURN
  839. END";
  840. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  841. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  842. {
  843. throw new Exception(language.GetNameByCode("WMSAPIInfo088"));//"采购退货单更新失败!");
  844. }
  845. }
  846. catch (Exception)
  847. {
  848. throw;
  849. }
  850. }
  851. /// <summary>
  852. /// 采购退货(货柜)
  853. /// </summary>
  854. /// <param name="TransCode"></param>
  855. /// <param name="TransSequence"></param>
  856. /// <param name="Quantity"></param>
  857. /// <param name="WorkPoint"></param>
  858. /// <param name="cmd"></param>
  859. public static void PurchaseReceiveDoctNegativeHG(string TransCode, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  860. {
  861. try
  862. {
  863. string sql = @" IF EXISTS (SELECT ID FROM ICSDeliveryNotice WHERE RCVQuantity=Quantity AND DNCode='{0}' AND WorkPoint='{1}' )
  864. BEGIN
  865. RAISERROR('" + language.GetNameByCode("WMSAPIInfo471") + @"',16,1);
  866. RETURN
  867. END;
  868. UPDATE ICSDeliveryNotice SET RCVQuantity=Quantity
  869. WHERE DNCode='{0}' AND WorkPoint='{1}'";
  870. sql = string.Format(sql, TransCode, WorkPoint);
  871. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  872. {
  873. throw new Exception(language.GetNameByCode("WMSAPIInfo088"));//"采购退货单更新失败!");
  874. }
  875. }
  876. catch (Exception)
  877. {
  878. throw;
  879. }
  880. }
  881. /// <summary>
  882. /// 采购退货接口
  883. /// </summary>
  884. /// <param name="TransType"></param>
  885. /// <param name="Identification"></param>
  886. /// <param name="cmd"></param>
  887. public static void PurchaseReceiveDoctNegativeERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
  888. {
  889. try
  890. {
  891. #region SAP(三层结构)
  892. string IsSuccess = "";
  893. string ErrorMessage = "";
  894. string sql = @" select A.DNCode,A.WorkPoint,SUM(B.Quantity) AS Quantity from ICSDeliveryNotice A
  895. LEFT JOIN ICSWareHouseLotInfoLog B ON B.TransCode=A.DNCode AND B.WorkPoint=A.WorkPoint
  896. where B.Identification='{0}' AND BusinessCode='3'
  897. GROUP BY A.DNCode,A.WorkPoint";
  898. sql = string.Format(sql, Identification);
  899. DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  900. if (dt.Rows.Count > 1)
  901. {
  902. throw new Exception(language.GetNameByCode("WMSAPIInfo202"));//单次提交单据数量卡控(只允许一张单据)
  903. }
  904. for (int i = 0; i < dt.Rows.Count; i++)
  905. {
  906. string chksql = @"select SUM(Quantity) AS Quantity,SUM(RCVQuantity) AS RCVQuantity from ICSDeliveryNotice
  907. where DNCode='{0}' and WorkPoint='{1}'
  908. GROUP BY DNCode,WorkPoint";
  909. chksql = string.Format(chksql, dt.Rows[i]["DNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
  910. DataTable chkdt = DBHelper.SQlReturnData(chksql, cmd);
  911. if (Convert.ToDecimal(chkdt.Rows[0]["Quantity"]) == Convert.ToDecimal(chkdt.Rows[0]["RCVQuantity"]))
  912. {
  913. SAPCallBackDocVPN.ZWMS_SK_WS_PZ Client = new SAPCallBackDocVPN.ZWMS_SK_WS_PZ();
  914. SAPCallBackDocVPN.ZWMS_SK_WS_PZ1 Info = new SAPCallBackDocVPN.ZWMS_SK_WS_PZ1();
  915. Info.NEWID = Identification;
  916. Info.DANJU = dt.Rows[i]["DNCode"].ToString();
  917. Info.STATE = "0";
  918. List<SAPCallBackDocVPN.ZWMS_PZ> ItemList = new List<SAPCallBackDocVPN.ZWMS_PZ>();
  919. List<SAPCallBackDocVPN.ZWEBS_GERNR> ItemLineList = new List<SAPCallBackDocVPN.ZWEBS_GERNR>();
  920. Info.Z_FLAG = new SAPCallBackDocVPN.ZWEB_RETURN[1];
  921. sql = @"select A.DNCode,A.SAPSequence,A.InvCode,A.Sequence,A.Quantity,A.RCVQuantity
  922. ,ISNULL(B.BatchCode,'') AS BatchCode from ICSDeliveryNotice A
  923. LEFT JOIN ICSExtension B ON B.ID=A.ExtensionID AND B.WorkPoint=A.WorkPoint
  924. WHERE DNCode='{0}' AND A.WorkPoint='{1}'";
  925. sql = string.Format(sql, dt.Rows[i]["DNCode"].ToString(), dt.Rows[i]["WorkPoint"].ToString());
  926. DataTable Sapdt = DBHelper.SQlReturnData(sql, cmd);
  927. foreach (DataRow dr in Sapdt.Rows)
  928. {
  929. if (Convert.ToDecimal(dr["Quantity"].ToString()) == Convert.ToDecimal(dr["RCVQuantity"].ToString()))
  930. {
  931. SAPCallBackDocVPN.ZWMS_PZ Item = new SAPCallBackDocVPN.ZWMS_PZ();
  932. SAPCallBackDocVPN.ZWEBS_GERNR ItemLine = new SAPCallBackDocVPN.ZWEBS_GERNR();
  933. Item.DANJU = dr["DNCode"].ToString();
  934. Item.POSNR = dr["SAPSequence"].ToString();
  935. Item.LINGYSL = System.Decimal.Round(Convert.ToDecimal(dt.Rows[0]["Quantity"].ToString()), 3);
  936. ItemList.Add(Item);
  937. if (dr["BatchCode"].ToString() != "")
  938. {
  939. ItemLine.DANJU = dr["DNCode"].ToString();
  940. ItemLine.POSNR = dr["SAPSequence"].ToString();
  941. ItemLine.MATNR = dr["InvCode"].ToString();
  942. ItemLine.GERNR = dr["BatchCode"].ToString();
  943. ItemLineList.Add(ItemLine);
  944. }
  945. }
  946. }
  947. if (ItemList.Count > 0)
  948. {
  949. Info.Z_ITEM = ItemList.ToArray();
  950. if (ItemLineList.Count > 0)
  951. {
  952. Info.Z_GERNR = ItemLineList.ToArray();
  953. }
  954. else
  955. {
  956. Info.Z_GERNR = new SAPCallBackDocVPN.ZWEBS_GERNR[1];
  957. }
  958. SAPCallBackDocVPN.ZWMS_SK_WS_PZResponse result = new SAPCallBackDocVPN.ZWMS_SK_WS_PZResponse();
  959. result = Client.CallZWMS_SK_WS_PZ(Info);
  960. if (result.Z_NULL == "N")
  961. {
  962. foreach (SAPCallBackDocVPN.ZWEB_RETURN resultItem in result.Z_FLAG)
  963. {
  964. IsSuccess = "N";
  965. ErrorMessage += resultItem.L_MESSAGE + "/r/n";
  966. }
  967. }
  968. }
  969. }
  970. }
  971. if (IsSuccess == "N")
  972. {
  973. throw new Exception(ErrorMessage);
  974. }
  975. #endregion
  976. }
  977. catch (Exception)
  978. {
  979. throw;
  980. }
  981. }
  982. #endregion
  983. #region 开立红字入库
  984. /// <summary>
  985. /// 开立红字入库
  986. /// </summary>
  987. /// <param name="TransCode"></param>
  988. /// <param name="TransSequence"></param>
  989. /// <param name="Quantity"></param>
  990. /// <param name="WorkPoint"></param>
  991. /// <param name="cmd"></param>
  992. public static void PurchaseReceive(string TransCode, string TransSequence, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  993. {
  994. try
  995. {
  996. string sql = @"DECLARE @Status VARCHAR(10)
  997. SELECT @Status=a.Status FROM ICSPurchaseReceive a
  998. WHERE a.RCVCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='2'
  999. IF (@Status IS NULL)
  1000. BEGIN
  1001. RAISERROR('" + language.GetNameByCode("WMSAPIInfo089") + @"',16,1);
  1002. RETURN
  1003. END
  1004. ELSE IF (@Status!='1')
  1005. BEGIN
  1006. RAISERROR('" + language.GetNameByCode("WMSAPIInfo090") + @"',16,1);
  1007. RETURN
  1008. END
  1009. UPDATE a SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}'
  1010. FROM ICSPurchaseReceive a
  1011. WHERE a.RCVCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}' AND a.Type='2'
  1012. IF EXISTS(SELECT a.ID FROM ICSPurchaseReceive a
  1013. WHERE a.RCVCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Type='2' AND a.Quantity<a.RCVQuantity)
  1014. BEGIN
  1015. RAISERROR('" + language.GetNameByCode("WMSAPIInfo091") + @"',16,1);
  1016. RETURN
  1017. END";
  1018. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  1019. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  1020. {
  1021. throw new Exception(language.GetNameByCode("WMSAPIInfo092"));//"红字入库单更新失败!");
  1022. }
  1023. }
  1024. catch (Exception)
  1025. {
  1026. throw;
  1027. }
  1028. }
  1029. /// <summary>
  1030. /// 开立红字入库接口
  1031. /// </summary>
  1032. /// <param name="TransType"></param>
  1033. /// <param name="Identification"></param>
  1034. /// <param name="cmd"></param>
  1035. public static void PurchaseReceiveERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
  1036. {
  1037. try
  1038. {
  1039. #region ERP开立状态单据审核
  1040. string sql = @"IF EXISTS(SELECT b.ID FROM ICSWareHouseLotInfoLog a
  1041. INNER JOIN ICSPurchaseReceive b ON a.TransCode=b.RCVCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  1042. WHERE a.Identification='{0}' AND b.Quantity!=b.RCVQuantity)
  1043. BEGIN
  1044. RAISERROR('" + language.GetNameByCode("WMSAPIInfo093") + @"',16,1);
  1045. RETURN
  1046. END
  1047. SELECT b.RCVID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint
  1048. FROM ICSWareHouseLotInfoLog a
  1049. INNER JOIN ICSPurchaseReceive b ON a.TransCode=b.RCVCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  1050. INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint
  1051. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock001' AND a.WorkPoint=conStock.WorkPoint
  1052. WHERE a.Identification='{0}' AND ERPUpload='0' AND a.BusinessCode = '4'
  1053. GROUP BY b.RCVID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint";
  1054. sql = string.Format(sql, Identification);
  1055. DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  1056. string Inputstr = JsonConvert.SerializeObject(dt);
  1057. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.PurchaseReceiveDoctNegativeURL, Inputstr);
  1058. Result result = new Result();
  1059. result = JsonConvert.DeserializeObject<Result>(resultStr);
  1060. if (result.Success)
  1061. {
  1062. try
  1063. {
  1064. foreach (DataRow dr in dt.Rows)
  1065. {
  1066. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "", "", cmd, language, BusinessCode);
  1067. }
  1068. }
  1069. catch (Exception ex)
  1070. {
  1071. log.Debug(ex.ToString());
  1072. log.Debug(resultStr);
  1073. }
  1074. }
  1075. else
  1076. {
  1077. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  1078. }
  1079. #endregion
  1080. }
  1081. catch (Exception)
  1082. {
  1083. throw;
  1084. }
  1085. }
  1086. #endregion
  1087. }
  1088. }