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

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